+ Added {Get,Add,Clear}Recent{Apps,Documents,Folders} framework
+ Fleshed out {Get,Add}RecentApps calls + Updated argument names for GetRecent{Documents,Folders} to versions used in R5 release notes in the Be Book. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1715 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4c2f542522
commit
44db8a0885
|
@ -134,13 +134,13 @@ public:
|
||||||
|
|
||||||
/* Recent document and app support */
|
/* Recent document and app support */
|
||||||
void GetRecentDocuments(BMessage *refList, int32 maxCount,
|
void GetRecentDocuments(BMessage *refList, int32 maxCount,
|
||||||
const char *ofType = NULL,
|
const char *fileType = NULL,
|
||||||
const char *openedByAppSig = NULL) const;
|
const char *appSig = NULL) const;
|
||||||
void GetRecentDocuments(BMessage *refList, int32 maxCount,
|
void GetRecentDocuments(BMessage *refList, int32 maxCount,
|
||||||
const char *ofTypeList[], int32 ofTypeListCount,
|
const char *fileTypes[], int32 fileTypesCount,
|
||||||
const char *openedByAppSig = NULL) const;
|
const char *appSig = NULL) const;
|
||||||
void GetRecentFolders(BMessage *refList, int32 maxCount,
|
void GetRecentFolders(BMessage *refList, int32 maxCount,
|
||||||
const char *openedByAppSig = NULL) const;
|
const char *appSig = NULL) const;
|
||||||
void GetRecentApps(BMessage *refList, int32 maxCount) const;
|
void GetRecentApps(BMessage *refList, int32 maxCount) const;
|
||||||
|
|
||||||
void AddToRecentDocuments(const entry_ref *doc,
|
void AddToRecentDocuments(const entry_ref *doc,
|
||||||
|
@ -207,6 +207,11 @@ private:
|
||||||
const BList *messageList, const entry_ref *ref,
|
const BList *messageList, const entry_ref *ref,
|
||||||
bool readyToRun) const;
|
bool readyToRun) const;
|
||||||
void InitMessengers();
|
void InitMessengers();
|
||||||
|
|
||||||
|
void AddToRecentApps(const char *appSig) const;
|
||||||
|
void ClearRecentDocuments() const;
|
||||||
|
void ClearRecentFolders() const;
|
||||||
|
void ClearRecentApps() const;
|
||||||
|
|
||||||
BMessenger fMess;
|
BMessenger fMess;
|
||||||
BMessenger fMimeMess;
|
BMessenger fMimeMess;
|
||||||
|
|
|
@ -1040,42 +1040,224 @@ BRoster::Launch(const entry_ref *ref, int argc, const char * const *args,
|
||||||
// GetRecentDocuments
|
// GetRecentDocuments
|
||||||
void
|
void
|
||||||
BRoster::GetRecentDocuments(BMessage *refList, int32 maxCount,
|
BRoster::GetRecentDocuments(BMessage *refList, int32 maxCount,
|
||||||
const char *ofType,
|
const char *fileType,
|
||||||
const char *openedByAppSig) const
|
const char *appSig) const
|
||||||
{
|
{
|
||||||
|
if (!refList)
|
||||||
|
return;
|
||||||
|
|
||||||
|
status_t err = maxCount > 0 ? B_OK : B_BAD_VALUE;
|
||||||
|
|
||||||
|
// Use the message we've been given for both request and reply
|
||||||
|
BMessage &msg = *refList;
|
||||||
|
BMessage &reply = *refList;
|
||||||
|
status_t result;
|
||||||
|
|
||||||
|
// Build and send the message, read the reply
|
||||||
|
if (!err) {
|
||||||
|
msg.what = B_REG_GET_RECENT_DOCUMENTS;
|
||||||
|
err = msg.AddInt32("max count", maxCount);
|
||||||
|
}
|
||||||
|
if (!err && fileType)
|
||||||
|
err = msg.AddString("file type", fileType);
|
||||||
|
if (!err && appSig)
|
||||||
|
err = msg.AddString("app sig", appSig);
|
||||||
|
fMess.SendMessage(&msg, &reply);
|
||||||
|
if (!err)
|
||||||
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY;
|
||||||
|
if (!err)
|
||||||
|
err = reply.FindInt32("result", &result);
|
||||||
|
if (!err)
|
||||||
|
err = result;
|
||||||
|
// Clear the result if an error occured
|
||||||
|
if (err && refList)
|
||||||
|
refList->MakeEmpty();
|
||||||
|
// No return value, how sad :-(
|
||||||
|
// return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRecentDocuments
|
// GetRecentDocuments
|
||||||
void
|
void
|
||||||
BRoster::GetRecentDocuments(BMessage *refList, int32 maxCount,
|
BRoster::GetRecentDocuments(BMessage *refList, int32 maxCount,
|
||||||
const char *ofTypeList[], int32 ofTypeListCount,
|
const char *fileTypes[], int32 fileTypesCount,
|
||||||
const char *openedByAppSig) const
|
const char *appSig) const
|
||||||
{
|
{
|
||||||
|
if (!refList)
|
||||||
|
return;
|
||||||
|
|
||||||
|
status_t err = maxCount > 0 ? B_OK : B_BAD_VALUE;
|
||||||
|
|
||||||
|
// Use the message we've been given for both request and reply
|
||||||
|
BMessage &msg = *refList;
|
||||||
|
BMessage &reply = *refList;
|
||||||
|
status_t result;
|
||||||
|
|
||||||
|
// Build and send the message, read the reply
|
||||||
|
if (!err) {
|
||||||
|
msg.what = B_REG_GET_RECENT_DOCUMENTS;
|
||||||
|
err = msg.AddInt32("max count", maxCount);
|
||||||
|
}
|
||||||
|
if (!err && fileTypes) {
|
||||||
|
for (int i = 0; i < fileTypesCount && !err; i++)
|
||||||
|
err = msg.AddString("file type", fileTypes[i]);
|
||||||
|
}
|
||||||
|
if (!err && appSig)
|
||||||
|
err = msg.AddString("app sig", appSig);
|
||||||
|
fMess.SendMessage(&msg, &reply);
|
||||||
|
if (!err)
|
||||||
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY;
|
||||||
|
if (!err)
|
||||||
|
err = reply.FindInt32("result", &result);
|
||||||
|
if (!err)
|
||||||
|
err = result;
|
||||||
|
// Clear the result if an error occured
|
||||||
|
if (err && refList)
|
||||||
|
refList->MakeEmpty();
|
||||||
|
// No return value, how sad :-(
|
||||||
|
// return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRecentFolders
|
// GetRecentFolders
|
||||||
void
|
void
|
||||||
BRoster::GetRecentFolders(BMessage *refList, int32 maxCount,
|
BRoster::GetRecentFolders(BMessage *refList, int32 maxCount,
|
||||||
const char *openedByAppSig) const
|
const char *appSig) const
|
||||||
{
|
{
|
||||||
|
if (!refList)
|
||||||
|
return;
|
||||||
|
|
||||||
|
status_t err = maxCount > 0 ? B_OK : B_BAD_VALUE;
|
||||||
|
|
||||||
|
// Use the message we've been given for both request and reply
|
||||||
|
BMessage &msg = *refList;
|
||||||
|
BMessage &reply = *refList;
|
||||||
|
status_t result;
|
||||||
|
|
||||||
|
// Build and send the message, read the reply
|
||||||
|
if (!err) {
|
||||||
|
msg.what = B_REG_GET_RECENT_FOLDERS;
|
||||||
|
err = msg.AddInt32("max count", maxCount);
|
||||||
|
}
|
||||||
|
if (!err && appSig)
|
||||||
|
err = msg.AddString("app sig", appSig);
|
||||||
|
fMess.SendMessage(&msg, &reply);
|
||||||
|
if (!err)
|
||||||
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY;
|
||||||
|
if (!err)
|
||||||
|
err = reply.FindInt32("result", &result);
|
||||||
|
if (!err)
|
||||||
|
err = result;
|
||||||
|
// Clear the result if an error occured
|
||||||
|
if (err && refList)
|
||||||
|
refList->MakeEmpty();
|
||||||
|
// No return value, how sad :-(
|
||||||
|
// return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRecentApps
|
// GetRecentApps
|
||||||
void
|
void
|
||||||
BRoster::GetRecentApps(BMessage *refList, int32 maxCount) const
|
BRoster::GetRecentApps(BMessage *refList, int32 maxCount) const
|
||||||
{
|
{
|
||||||
|
if (!refList)
|
||||||
|
return;
|
||||||
|
|
||||||
|
status_t err = maxCount > 0 ? B_OK : B_BAD_VALUE;
|
||||||
|
|
||||||
|
// Use the message we've been given for both request and reply
|
||||||
|
BMessage &msg = *refList;
|
||||||
|
BMessage &reply = *refList;
|
||||||
|
status_t result;
|
||||||
|
|
||||||
|
// Build and send the message, read the reply
|
||||||
|
if (!err) {
|
||||||
|
msg.what = B_REG_GET_RECENT_APPS;
|
||||||
|
err = msg.AddInt32("max count", maxCount);
|
||||||
|
}
|
||||||
|
fMess.SendMessage(&msg, &reply);
|
||||||
|
if (!err)
|
||||||
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY;
|
||||||
|
if (!err)
|
||||||
|
err = reply.FindInt32("result", &result);
|
||||||
|
if (!err)
|
||||||
|
err = result;
|
||||||
|
// Clear the result if an error occured
|
||||||
|
if (err && refList)
|
||||||
|
refList->MakeEmpty();
|
||||||
|
// No return value, how sad :-(
|
||||||
|
// return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddToRecentDocuments
|
// AddToRecentDocuments
|
||||||
void
|
void
|
||||||
BRoster::AddToRecentDocuments(const entry_ref *doc, const char *appSig) const
|
BRoster::AddToRecentDocuments(const entry_ref *doc, const char *appSig) const
|
||||||
{
|
{
|
||||||
|
status_t err = doc ? B_OK : B_BAD_VALUE;
|
||||||
|
|
||||||
|
// Use the message we've been given for both request and reply
|
||||||
|
BMessage msg(B_REG_ADD_TO_RECENT_DOCUMENTS);
|
||||||
|
BMessage reply;
|
||||||
|
status_t result;
|
||||||
|
char *callingAppSig = NULL;
|
||||||
|
|
||||||
|
// If no signature is supplied, look up the signature of
|
||||||
|
// the calling app
|
||||||
|
if (!err && !appSig) {
|
||||||
|
app_info info;
|
||||||
|
err = GetRunningAppInfo(be_app->Team(), &info);
|
||||||
|
if (!err)
|
||||||
|
callingAppSig = info.signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build and send the message, read the reply
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddRef("ref", doc);
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddString("app sig", (appSig ? appSig : callingAppSig));
|
||||||
|
fMess.SendMessage(&msg, &reply);
|
||||||
|
if (!err)
|
||||||
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY;
|
||||||
|
if (!err)
|
||||||
|
err = reply.FindInt32("result", &result);
|
||||||
|
if (!err)
|
||||||
|
err = result;
|
||||||
|
if (err)
|
||||||
|
DBG(OUT("WARNING: BRoster::AddToRecentDocuments() failed with error 0x%lx\n", err));
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddToRecentFolders
|
// AddToRecentFolders
|
||||||
void
|
void
|
||||||
BRoster::AddToRecentFolders(const entry_ref *folder, const char *appSig) const
|
BRoster::AddToRecentFolders(const entry_ref *folder, const char *appSig) const
|
||||||
{
|
{
|
||||||
|
status_t err = folder ? B_OK : B_BAD_VALUE;
|
||||||
|
|
||||||
|
// Use the message we've been given for both request and reply
|
||||||
|
BMessage msg(B_REG_ADD_TO_RECENT_FOLDERS);
|
||||||
|
BMessage reply;
|
||||||
|
status_t result;
|
||||||
|
char *callingAppSig = NULL;
|
||||||
|
|
||||||
|
// If no signature is supplied, look up the signature of
|
||||||
|
// the calling app
|
||||||
|
if (!err && !appSig) {
|
||||||
|
app_info info;
|
||||||
|
err = GetRunningAppInfo(be_app->Team(), &info);
|
||||||
|
if (!err)
|
||||||
|
callingAppSig = info.signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build and send the message, read the reply
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddRef("ref", folder);
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddString("app sig", (appSig ? appSig : callingAppSig));
|
||||||
|
fMess.SendMessage(&msg, &reply);
|
||||||
|
if (!err)
|
||||||
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY;
|
||||||
|
if (!err)
|
||||||
|
err = reply.FindInt32("result", &result);
|
||||||
|
if (!err)
|
||||||
|
err = result;
|
||||||
|
if (err)
|
||||||
|
DBG(OUT("WARNING: BRoster::AddToRecentDocuments() failed with error 0x%lx\n", err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1993,6 +2175,57 @@ strerror(error)));
|
||||||
DBG(OUT("BRoster::InitMessengers() done\n"));
|
DBG(OUT("BRoster::InitMessengers() done\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddToRecentApps
|
||||||
|
/*! \brief Sends a request to the roster to add the application with the
|
||||||
|
given signature to the front of the recent apps list.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
BRoster::AddToRecentApps(const char *appSig) const
|
||||||
|
{
|
||||||
|
status_t error = B_OK;
|
||||||
|
// compose the request message
|
||||||
|
BMessage request(B_REG_ADD_TO_RECENT_APPS);
|
||||||
|
if (error == B_OK)
|
||||||
|
error = request.AddString("app sig", appSig);
|
||||||
|
// send the request
|
||||||
|
BMessage reply;
|
||||||
|
if (error == B_OK)
|
||||||
|
error = fMess.SendMessage(&request, &reply);
|
||||||
|
// evaluate the reply
|
||||||
|
status_t result;
|
||||||
|
if (error == B_OK)
|
||||||
|
error = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY;
|
||||||
|
if (error == B_OK)
|
||||||
|
error = reply.FindInt32("result", &result);
|
||||||
|
if (error == B_OK)
|
||||||
|
error = result;
|
||||||
|
// Nothing to return... how sad :-(
|
||||||
|
// return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! \brief Sends a request to the roster to clear the recent
|
||||||
|
documents list.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
BRoster::ClearRecentDocuments() const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! \brief Sends a request to the roster to clear the recent
|
||||||
|
documents list.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
BRoster::ClearRecentFolders() const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! \brief Sends a request to the roster to clear the recent
|
||||||
|
documents list.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
BRoster::ClearRecentApps() const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------*/
|
/*-----------------------------------------------------*/
|
||||||
/*----- Global be_roster ------------------------------*/
|
/*----- Global be_roster ------------------------------*/
|
||||||
|
|
Loading…
Reference in New Issue