xref: /haiku/headers/private/notification/AppUsage.h (revision a5bf12376daeded4049521eb17a6cc41192250d9)
1 /*
2  * Copyright 2010, Haiku, Inc. All Rights Reserved.
3  * Copyright 2008-2009, Pier Luigi Fiorini. All Rights Reserved.
4  * Copyright 2004-2008, Michael Davidson. All Rights Reserved.
5  * Copyright 2004-2007, Mikael Eiman. All Rights Reserved.
6  * Distributed under the terms of the MIT License.
7  */
8 #ifndef _APP_USAGE_H
9 #define _APP_USAGE_H
10 
11 #include <map>
12 
13 #include <Entry.h>
14 #include <Flattenable.h>
15 #include <Notification.h>
16 #include <Roster.h>
17 #include <String.h>
18 
19 class BMessage;
20 class NotificationReceived;
21 
22 typedef std::map<BString, NotificationReceived*> notify_t;
23 
24 class AppUsage : public BFlattenable {
25 public:
26 										AppUsage();
27 										AppUsage(entry_ref ref, const char* name,
28 											bool allow = true);
29 										~AppUsage();
30 
31 	virtual	bool						AllowsTypeCode(type_code code) const;
32 	virtual	status_t					Flatten(void* buffer, ssize_t numBytes) const;
33 	virtual	ssize_t						FlattenedSize() const;
34 	virtual	bool						IsFixedSize() const;
35 	virtual	type_code					TypeCode() const;
36 	virtual	status_t					Unflatten(type_code code, const void* buffer,
37 											ssize_t numBytes);
38 
39 			entry_ref					Ref();
40 			const char*					Name();
41 			bool						Allowed(const char* title, notification_type type);
42 			bool						Allowed();
43 			NotificationReceived*		NotificationAt(int32 index);
44 			int32						Notifications();
45 			void						AddNotification(NotificationReceived* notification);
46 
47 private:
48 			entry_ref					fRef;
49 			BString						fName;
50 			bool						fAllow;
51 			notify_t					fNotifications;
52 };
53 
54 #endif	// _APP_USAGE_H
55