vfs: check userland buffers before reading them.
[haiku.git] / src / kits / tracker / RecentItems.h
blob9b6a606722b223bd676149ec066374d7f8dd898a
1 /*
2 Open Tracker License
4 Terms and Conditions
6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
32 All rights reserved.
34 #ifndef _RECENT_ITEMS_LIST_H
35 #define _RECENT_ITEMS_LIST_H
38 // BRecentItemsList classes allow creating an entire menu with
39 // recent files, folders, apps. If the user wishes to add items to
40 // their own menu, they can instead use the GetNextMenuItem call to
41 // get one menu at a time to add it to their app.
44 #include <Entry.h>
45 #include <Message.h>
46 #include <String.h>
49 class BMenuItem;
50 class BMenu;
53 class BRecentItemsList {
54 public:
55 BRecentItemsList(int32 maxItems, bool navMenuFolders);
56 // if <navMenuFolders> passed, folder items get NavMenu-style
57 // subdirectories attached to them
59 virtual ~BRecentItemsList() {}
61 virtual void Rewind();
62 // resets the iteration
64 virtual BMenuItem* GetNextMenuItem(const BMessage* fileOpenMessage = NULL,
65 const BMessage* containerOpenMessage = NULL,
66 BHandler* target = NULL, entry_ref* currentItemRef = NULL);
67 // if <fileOpenMessage> specified, the item for a file gets a copy
68 // with the item ref attached as "refs", otherwise a default
69 // B_REFS_RECEIVED message message gets attached
70 // if <containerOpenMessage> specified, the item for a folder, volume
71 // or query gets a copy with the item ref attached as "refs",
72 // otherwise a default B_REFS_RECEIVED message message gets attached
73 // if <currentItemRef> gets passed, the caller gets to look at the
74 // entry_ref corresponding to the item
76 virtual status_t GetNextRef(entry_ref*);
78 protected:
79 BMessage fItems;
80 int32 fIndex;
81 int32 fMaxItems;
82 bool fNavMenuFolders;
84 private:
85 virtual void _r1();
86 virtual void _r2();
87 virtual void _r3();
88 virtual void _r4();
89 virtual void _r5();
90 virtual void _r6();
91 virtual void _r7();
92 virtual void _r8();
93 virtual void _r9();
94 virtual void _r10();
96 uint32 _reserved[20];
100 class BRecentFilesList : public BRecentItemsList {
101 public:
102 // use one of the two constructors to set up next item iteration
103 BRecentFilesList(int32 maxItems = 10, bool navMenuFolders = false,
104 const char* ofType = NULL, const char* openedByAppSig = NULL);
105 BRecentFilesList(int32 maxItems, bool navMenuFolders,
106 const char* ofTypeList[], int32 ofTypeListCount,
107 const char* openedByAppSig = NULL);
108 virtual ~BRecentFilesList();
110 // use one of the two NewFileListMenu calls to get an entire menu
111 static BMenu* NewFileListMenu(const char* title,
112 BMessage* openFileMessage = NULL, BMessage* openFolderMessage = NULL,
113 BHandler* target = NULL,
114 int32 maxItems = 10, bool navMenuFolders = false,
115 const char* ofType = NULL, const char* openedByAppSig = NULL);
117 static BMenu* NewFileListMenu(const char* title,
118 BMessage* openFileMessage, BMessage* openFolderMessage,
119 BHandler* target,
120 int32 maxItems, bool navMenuFolders,
121 const char* ofTypeList[], int32 ofTypeListCount,
122 const char* openedByAppSig);
124 virtual status_t GetNextRef(entry_ref*);
126 protected:
127 BString fType;
128 char** fTypes;
129 int32 fTypeCount;
130 BString fAppSig;
132 private:
133 virtual void _r11();
134 virtual void _r12();
135 virtual void _r13();
136 virtual void _r14();
137 virtual void _r15();
138 virtual void _r16();
139 virtual void _r17();
140 virtual void _r18();
141 virtual void _r19();
142 virtual void _r110();
144 uint32 _reserved[20];
148 class BRecentFoldersList : public BRecentItemsList {
149 public:
150 // use the constructor to set up next item iteration
151 BRecentFoldersList(int32 maxItems, bool navMenuFolders = false,
152 const char* openedByAppSig = NULL);
154 // use NewFolderListMenu to get an entire menu
155 static BMenu* NewFolderListMenu(const char* title,
156 BMessage* openMessage = NULL, BHandler* target = NULL,
157 int32 maxItems = 10, bool navMenuFolders = false,
158 const char* openedByAppSig = NULL);
160 virtual status_t GetNextRef(entry_ref*);
162 protected:
163 BString fAppSig;
165 private:
166 virtual void _r21();
167 virtual void _r22();
168 virtual void _r23();
169 virtual void _r24();
170 virtual void _r25();
171 virtual void _r26();
172 virtual void _r27();
173 virtual void _r28();
174 virtual void _r29();
175 virtual void _r210();
177 uint32 _reserved[20];
181 class BRecentAppsList : public BRecentItemsList {
182 public:
183 // use the constructor to set up next item iteration
184 BRecentAppsList(int32 maxItems);
186 // use NewFolderListMenu to get an entire menu
187 static BMenu* NewAppListMenu(const char* title,
188 BMessage* openMessage = NULL, BHandler* target = NULL,
189 int32 maxItems = 10);
191 virtual status_t GetNextRef(entry_ref*);
193 private:
194 virtual void _r31();
195 virtual void _r32();
196 virtual void _r33();
197 virtual void _r34();
198 virtual void _r35();
199 virtual void _r36();
200 virtual void _r37();
201 virtual void _r38();
202 virtual void _r39();
203 virtual void _r310();
205 uint32 _reserved[20];
209 #endif // _RECENT_ITEMS_LIST_H