* Improved BNotification API.

- No more manual memory management.
   - Make it clear who keeps or releases ownership of arguments passed.
   - Copy icon, arguments and entry_refs.
   - Do not expose implementation details (What do the BLists contain?!).
   - BRoster takes const BNotification& and bigtime_t timeout.

 * BRoster::Notify():
   - Proper error handling.
   - Fixed documentation.

 * Adjusted notify:
   - Renamed fOk to fHasGoodArguments.
   - The "const char*" members were really "char*" members (self-managed).
   - free() is NULL-safe.
   - fRefs contains BEntries, so passing void* to delete does no good.
   - Adjustments to the changed API.
   - Coding style fixes.

 * notification_server:
   - Adjustment to the new type for timeout.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36952 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2010-05-27 17:50:12 +00:00
parent e5846dfa61
commit f33637d9a8
6 changed files with 239 additions and 195 deletions
+23 -19
View File
@@ -7,10 +7,8 @@
#include <Entry.h>
class BBitmap;
class BList;
#include <List.h>
#include <String.h>
// notification types
@@ -21,6 +19,8 @@ enum notification_type {
B_PROGRESS_NOTIFICATION
};
class BBitmap;
class BNotification {
public:
@@ -47,29 +47,33 @@ public:
const char* OnClickApp() const;
void SetOnClickApp(const char* app);
entry_ref* OnClickFile() const;
void SetOnClickFile(const entry_ref* file);
const entry_ref* OnClickFile() const;
status_t SetOnClickFile(const entry_ref* file);
BList* OnClickRefs() const;
void AddOnClickRef(const entry_ref* ref);
status_t AddOnClickRef(const entry_ref* ref);
status_t AddOnClickRef(const entry_ref& ref);
int32 CountOnClickRefs() const;
const entry_ref* OnClickRefAt(int32 index) const;
BList* OnClickArgv() const;
void AddOnClickArg(const char* arg);
status_t AddOnClickArg(const char* arg);
int32 CountOnClickArgs() const;
const char* OnClickArgAt(int32 index) const;
BBitmap* Icon() const;
void SetIcon(BBitmap* icon);
const BBitmap* Icon() const;
status_t SetIcon(const BBitmap* icon);
private:
notification_type fType;
char* fAppName;
char* fTitle;
char* fContent;
char* fID;
BString fAppName;
BString fTitle;
BString fContent;
BString fID;
float fProgress;
char* fApp;
BString fApp;
entry_ref* fFile;
BList* fRefs;
BList* fArgv;
BList fRefs;
BList fArgv;
BBitmap* fBitmap;
};