btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / webpositive / BrowsingHistory.h
blob18b7ff1836af58718aabc6c10be4e88cbc797ee9
1 /*
2 * Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de>
4 * All rights reserved. Distributed under the terms of the MIT License.
5 */
6 #ifndef BROWSING_HISTORY_H
7 #define BROWSING_HISTORY_H
9 #include "DateTime.h"
10 #include <List.h>
11 #include <Locker.h>
13 class BFile;
14 class BString;
17 class BrowsingHistoryItem {
18 public:
19 BrowsingHistoryItem(const BString& url);
20 BrowsingHistoryItem(
21 const BrowsingHistoryItem& other);
22 BrowsingHistoryItem(const BMessage* archive);
23 ~BrowsingHistoryItem();
25 status_t Archive(BMessage* archive) const;
27 BrowsingHistoryItem& operator=(const BrowsingHistoryItem& other);
29 bool operator==(
30 const BrowsingHistoryItem& other) const;
31 bool operator!=(
32 const BrowsingHistoryItem& other) const;
33 bool operator<(
34 const BrowsingHistoryItem& other) const;
35 bool operator<=(
36 const BrowsingHistoryItem& other) const;
37 bool operator>(
38 const BrowsingHistoryItem& other) const;
39 bool operator>=(
40 const BrowsingHistoryItem& other) const;
42 const BString& URL() const { return fURL; }
43 const BDateTime& DateTime() const { return fDateTime; }
44 uint32 InvokationCount() const {
45 return fInvokationCount; }
46 void Invoked();
48 private:
49 BString fURL;
50 BDateTime fDateTime;
51 uint32 fInvokationCount;
55 class BrowsingHistory : public BLocker {
56 public:
57 static BrowsingHistory* DefaultInstance();
59 bool AddItem(const BrowsingHistoryItem& item);
61 // Should Lock() the object when using these in some loop or so:
62 int32 CountItems() const;
63 BrowsingHistoryItem HistoryItemAt(int32 index) const;
64 void Clear();
66 void SetMaxHistoryItemAge(int32 days);
67 int32 MaxHistoryItemAge() const;
69 private:
70 BrowsingHistory();
71 virtual ~BrowsingHistory();
73 void _Clear();
74 bool _AddItem(const BrowsingHistoryItem& item,
75 bool invoke);
77 void _LoadSettings();
78 void _SaveSettings();
79 bool _OpenSettingsFile(BFile& file, uint32 mode);
81 private:
82 BList fHistoryItems;
83 int32 fMaxHistoryItemAge;
85 static BrowsingHistory sDefaultInstance;
86 bool fSettingsLoaded;
90 #endif // BROWSING_HISTORY_H