+ Added code for:
- {Get,Set}PreferredApp()
- {Get,Set}AppHint()
- {Get,Set}Icon() (though it's a hacked up temporary version)
+ Replaced B_SIMPLE_DATA with B_REG_RESULT
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@820 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+137
-16
@@ -7,6 +7,7 @@
|
|||||||
BMimeType implementation.
|
BMimeType implementation.
|
||||||
*/
|
*/
|
||||||
#include <MimeType.h>
|
#include <MimeType.h>
|
||||||
|
#include <Bitmap.h>
|
||||||
#include <ctype.h> // For tolower()
|
#include <ctype.h> // For tolower()
|
||||||
#include <new.h> // For new(nothrow)
|
#include <new.h> // For new(nothrow)
|
||||||
#include <stdio.h> // For printf()
|
#include <stdio.h> // For printf()
|
||||||
@@ -324,7 +325,7 @@ BMimeType::Install()
|
|||||||
if (!err)
|
if (!err)
|
||||||
err = _send_to_roster_(&msg, &reply, true);
|
err = _send_to_roster_(&msg, &reply, true);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.what == B_SIMPLE_DATA ? B_OK : B_BAD_VALUE;
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE;
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.FindInt32("result", &result);
|
err = reply.FindInt32("result", &result);
|
||||||
if (!err)
|
if (!err)
|
||||||
@@ -360,7 +361,7 @@ BMimeType::Delete()
|
|||||||
if (!err)
|
if (!err)
|
||||||
err = _send_to_roster_(&msg, &reply, true);
|
err = _send_to_roster_(&msg, &reply, true);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.what == B_SIMPLE_DATA ? B_OK : B_BAD_VALUE;
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE;
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.FindInt32("result", &result);
|
err = reply.FindInt32("result", &result);
|
||||||
if (!err)
|
if (!err)
|
||||||
@@ -385,9 +386,9 @@ BMimeType::Delete()
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BMimeType::GetIcon(BBitmap *icon, icon_size) const
|
BMimeType::GetIcon(BBitmap *icon, icon_size size) const
|
||||||
{
|
{
|
||||||
return NOT_IMPLEMENTED;
|
return fMimeDatabase->GetIcon(Type(), icon, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPreferredApp
|
// GetPreferredApp
|
||||||
@@ -413,7 +414,7 @@ BMimeType::GetIcon(BBitmap *icon, icon_size) const
|
|||||||
status_t
|
status_t
|
||||||
BMimeType::GetPreferredApp(char *signature, app_verb verb) const
|
BMimeType::GetPreferredApp(char *signature, app_verb verb) const
|
||||||
{
|
{
|
||||||
return NOT_IMPLEMENTED;
|
return fMimeDatabase->GetPreferredApp(Type(), signature, verb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAttrInfo
|
// GetAttrInfo
|
||||||
@@ -622,9 +623,79 @@ BMimeType::GetSupportingApps(BMessage *signatures) const
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BMimeType::SetIcon(const BBitmap *icon, icon_size)
|
BMimeType::SetIcon(const BBitmap *icon, icon_size size)
|
||||||
{
|
{
|
||||||
return NOT_IMPLEMENTED;
|
status_t err = icon ? B_OK : B_BAD_VALUE;
|
||||||
|
if (!err)
|
||||||
|
err = InitCheck();
|
||||||
|
|
||||||
|
BMessage msg(B_REG_MIME_SET_PARAM);
|
||||||
|
BMessage reply;
|
||||||
|
status_t result;
|
||||||
|
|
||||||
|
void *data = NULL;
|
||||||
|
int32 dataSize;
|
||||||
|
|
||||||
|
if (!err)
|
||||||
|
err = BPrivate::MimeDatabase::GetIconData(icon, size, &data, &dataSize);
|
||||||
|
|
||||||
|
// Build and send the message, read the reply
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddString("type", Type());
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddInt32("which", B_REG_MIME_ICON);
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddData("icon data", B_RAW_TYPE, data, dataSize);
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddInt32("icon size", size);
|
||||||
|
if (!err)
|
||||||
|
err = _send_to_roster_(&msg, &reply, true);
|
||||||
|
if (!err)
|
||||||
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE;
|
||||||
|
if (!err)
|
||||||
|
err = reply.FindInt32("result", &result);
|
||||||
|
if (!err)
|
||||||
|
err = result;
|
||||||
|
|
||||||
|
delete [] data;
|
||||||
|
return err;
|
||||||
|
|
||||||
|
|
||||||
|
/* This is the code I was using before BBitmap::Instantiate
|
||||||
|
blew up on me
|
||||||
|
|
||||||
|
status_t err = icon ? B_OK : B_BAD_VALUE;
|
||||||
|
if (!err)
|
||||||
|
err = InitCheck();
|
||||||
|
|
||||||
|
BMessage msg(B_REG_MIME_SET_PARAM);
|
||||||
|
BMessage reply;
|
||||||
|
status_t result;
|
||||||
|
|
||||||
|
BMessage archive;
|
||||||
|
|
||||||
|
// Build and send the message, read the reply
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddString("type", Type());
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddInt32("which", B_REG_MIME_ICON);
|
||||||
|
if (!err)
|
||||||
|
err = icon->Archive(&archive);
|
||||||
|
archive.PrintToStream();
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddMessage("icon archive", &archive);
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddInt32("size", size);
|
||||||
|
if (!err)
|
||||||
|
err = _send_to_roster_(&msg, &reply, true);
|
||||||
|
if (!err)
|
||||||
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE;
|
||||||
|
if (!err)
|
||||||
|
err = reply.FindInt32("result", &result);
|
||||||
|
if (!err)
|
||||||
|
err = result;
|
||||||
|
return err;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPreferredApp
|
// SetPreferredApp
|
||||||
@@ -650,7 +721,32 @@ BMimeType::SetIcon(const BBitmap *icon, icon_size)
|
|||||||
status_t
|
status_t
|
||||||
BMimeType::SetPreferredApp(const char *signature, app_verb verb)
|
BMimeType::SetPreferredApp(const char *signature, app_verb verb)
|
||||||
{
|
{
|
||||||
return NOT_IMPLEMENTED;
|
status_t err = signature ? B_OK : B_BAD_VALUE;
|
||||||
|
if (!err)
|
||||||
|
err = InitCheck();
|
||||||
|
|
||||||
|
BMessage msg(B_REG_MIME_SET_PARAM);
|
||||||
|
BMessage reply;
|
||||||
|
status_t result;
|
||||||
|
|
||||||
|
// Build and send the message, read the reply
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddString("type", Type());
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddInt32("which", B_REG_MIME_PREFERRED_APP);
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddString("signature", signature);
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddInt32("app verb", verb);
|
||||||
|
if (!err)
|
||||||
|
err = _send_to_roster_(&msg, &reply, true);
|
||||||
|
if (!err)
|
||||||
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE;
|
||||||
|
if (!err)
|
||||||
|
err = reply.FindInt32("result", &result);
|
||||||
|
if (!err)
|
||||||
|
err = result;
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAttrInfo
|
// SetAttrInfo
|
||||||
@@ -769,6 +865,8 @@ BMimeType::SetShortDescription(const char *description)
|
|||||||
status_t result;
|
status_t result;
|
||||||
|
|
||||||
// Build and send the message, read the reply
|
// Build and send the message, read the reply
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddString("type", Type());
|
||||||
if (!err)
|
if (!err)
|
||||||
err = msg.AddInt32("which", B_REG_MIME_DESCRIPTION);
|
err = msg.AddInt32("which", B_REG_MIME_DESCRIPTION);
|
||||||
if (!err)
|
if (!err)
|
||||||
@@ -780,7 +878,7 @@ BMimeType::SetShortDescription(const char *description)
|
|||||||
if (!err)
|
if (!err)
|
||||||
err = _send_to_roster_(&msg, &reply, true);
|
err = _send_to_roster_(&msg, &reply, true);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.what == B_SIMPLE_DATA ? B_OK : B_BAD_VALUE;
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE;
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.FindInt32("result", &result);
|
err = reply.FindInt32("result", &result);
|
||||||
if (!err)
|
if (!err)
|
||||||
@@ -813,18 +911,18 @@ BMimeType::SetLongDescription(const char *description)
|
|||||||
status_t result;
|
status_t result;
|
||||||
|
|
||||||
// Build and send the message, read the reply
|
// Build and send the message, read the reply
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddString("type", Type());
|
||||||
if (!err)
|
if (!err)
|
||||||
err = msg.AddInt32("which", B_REG_MIME_DESCRIPTION);
|
err = msg.AddInt32("which", B_REG_MIME_DESCRIPTION);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = msg.AddString("description", description);
|
err = msg.AddString("description", description);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = msg.AddBool("long", true);
|
err = msg.AddBool("long", true);
|
||||||
if (!err)
|
|
||||||
err = msg.AddString("type", Type());
|
|
||||||
if (!err)
|
if (!err)
|
||||||
err = _send_to_roster_(&msg, &reply, true);
|
err = _send_to_roster_(&msg, &reply, true);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.what == B_SIMPLE_DATA ? B_OK : B_BAD_VALUE;
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE;
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.FindInt32("result", &result);
|
err = reply.FindInt32("result", &result);
|
||||||
if (!err)
|
if (!err)
|
||||||
@@ -984,7 +1082,7 @@ bool isValidMimeChar(const char ch)
|
|||||||
status_t
|
status_t
|
||||||
BMimeType::GetAppHint(entry_ref *ref) const
|
BMimeType::GetAppHint(entry_ref *ref) const
|
||||||
{
|
{
|
||||||
return NOT_IMPLEMENTED;
|
return fMimeDatabase->GetAppHint(Type(), ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAppHint
|
// SetAppHint
|
||||||
@@ -1008,7 +1106,30 @@ BMimeType::GetAppHint(entry_ref *ref) const
|
|||||||
status_t
|
status_t
|
||||||
BMimeType::SetAppHint(const entry_ref *ref)
|
BMimeType::SetAppHint(const entry_ref *ref)
|
||||||
{
|
{
|
||||||
return NOT_IMPLEMENTED;
|
status_t err = ref ? B_OK : B_BAD_VALUE;
|
||||||
|
if (!err)
|
||||||
|
err = InitCheck();
|
||||||
|
|
||||||
|
BMessage msg(B_REG_MIME_SET_PARAM);
|
||||||
|
BMessage reply;
|
||||||
|
status_t result;
|
||||||
|
|
||||||
|
// Build and send the message, read the reply
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddString("type", Type());
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddInt32("which", B_REG_MIME_APP_HINT);
|
||||||
|
if (!err)
|
||||||
|
err = msg.AddRef("app hint", ref);
|
||||||
|
if (!err)
|
||||||
|
err = _send_to_roster_(&msg, &reply, true);
|
||||||
|
if (!err)
|
||||||
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE;
|
||||||
|
if (!err)
|
||||||
|
err = reply.FindInt32("result", &result);
|
||||||
|
if (!err)
|
||||||
|
err = result;
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIconForType
|
// GetIconForType
|
||||||
@@ -1289,7 +1410,7 @@ BMimeType::StartWatching(BMessenger target)
|
|||||||
if (!err)
|
if (!err)
|
||||||
err = _send_to_roster_(&msg, &reply, true);
|
err = _send_to_roster_(&msg, &reply, true);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.what == B_SIMPLE_DATA ? B_OK : B_BAD_VALUE;
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE;
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.FindInt32("result", &result);
|
err = reply.FindInt32("result", &result);
|
||||||
if (!err)
|
if (!err)
|
||||||
@@ -1318,7 +1439,7 @@ BMimeType::StopWatching(BMessenger target)
|
|||||||
if (!err)
|
if (!err)
|
||||||
err = _send_to_roster_(&msg, &reply, true);
|
err = _send_to_roster_(&msg, &reply, true);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.what == B_SIMPLE_DATA ? B_OK : B_BAD_VALUE;
|
err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE;
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reply.FindInt32("result", &result);
|
err = reply.FindInt32("result", &result);
|
||||||
if (!err)
|
if (!err)
|
||||||
|
|||||||
Reference in New Issue
Block a user