+ Updated doxygen
+ Added code for: - B_REG_MIME_SET_PARAM::B_REG_MIME_PREFERRED_APP - B_REG_MIME_SET_PARAM::B_REG_MIME_APP_HINT - B_REG_MIME_SET_PARAM::B_REG_MIME_ICON git-svn-id: file:///srv/svn/repos/haiku/trunk/current@821 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
dff6cb3f88
commit
7cf4e78a5d
@ -1,7 +1,11 @@
|
||||
// MIMEManager.cpp
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <ClassInfo.h>
|
||||
#include <Message.h>
|
||||
#include <RegistrarDefs.h>
|
||||
#include <TypeConstants.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
@ -9,9 +13,9 @@
|
||||
|
||||
/*!
|
||||
\class MIMEManager
|
||||
\brief MIMEManager is the master of the MIME data base.
|
||||
\brief MIMEManager handles communication between BMimeType and the system-wide
|
||||
MimeDatabase object for BMimeType's write and non-atomic read functions.
|
||||
|
||||
All write and non-atomic read accesses are carried out by this class.
|
||||
*/
|
||||
|
||||
// constructor
|
||||
@ -43,42 +47,8 @@ MIMEManager::MessageReceived(BMessage *message)
|
||||
|
||||
switch (message->what) {
|
||||
case B_REG_MIME_SET_PARAM:
|
||||
{
|
||||
int32 which;
|
||||
const char *type;
|
||||
|
||||
err = message->FindString("type", &type);
|
||||
if (!err)
|
||||
err = message->FindInt32("which", &which);
|
||||
if (!err) {
|
||||
switch (which) {
|
||||
case B_REG_MIME_DESCRIPTION:
|
||||
{
|
||||
bool isLong;
|
||||
const char *description;
|
||||
err = message->FindBool("long", &isLong);
|
||||
if (!err)
|
||||
err = message->FindString("description", &description);
|
||||
if (!err) {
|
||||
err = (isLong
|
||||
? fMimeDatabase.SetLongDescription(type, description)
|
||||
: fMimeDatabase.SetShortDescription(type, description));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
err = B_BAD_VALUE;
|
||||
break;
|
||||
}
|
||||
|
||||
reply.what = B_SIMPLE_DATA;
|
||||
reply.AddInt32("result", err);
|
||||
message->SendReply(&reply, this);
|
||||
}
|
||||
|
||||
HandleSetParam(message);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_REG_MIME_START_WATCHING:
|
||||
case B_REG_MIME_STOP_WATCHING:
|
||||
@ -91,7 +61,7 @@ MIMEManager::MessageReceived(BMessage *message)
|
||||
: fMimeDatabase.StopWatching(messenger);
|
||||
}
|
||||
|
||||
reply.what = B_SIMPLE_DATA;
|
||||
reply.what = B_REG_RESULT;
|
||||
reply.AddInt32("result", err);
|
||||
message->SendReply(&reply, this);
|
||||
break;
|
||||
@ -106,7 +76,7 @@ MIMEManager::MessageReceived(BMessage *message)
|
||||
err = message->what == B_REG_MIME_INSTALL
|
||||
? fMimeDatabase.Install(type)
|
||||
: fMimeDatabase.Delete(type);
|
||||
reply.what = B_SIMPLE_DATA;
|
||||
reply.what = B_REG_RESULT;
|
||||
reply.AddInt32("result", err);
|
||||
message->SendReply(&reply, this);
|
||||
break;
|
||||
@ -119,3 +89,103 @@ MIMEManager::MessageReceived(BMessage *message)
|
||||
}
|
||||
}
|
||||
|
||||
// HandleSetParam
|
||||
//! Handles all B_REG_MIME_SET_PARAM messages
|
||||
void
|
||||
MIMEManager::HandleSetParam(BMessage *message)
|
||||
{
|
||||
status_t err;
|
||||
int32 which;
|
||||
const char *type;
|
||||
|
||||
err = message->FindString("type", &type);
|
||||
if (!err)
|
||||
err = message->FindInt32("which", &which);
|
||||
if (!err) {
|
||||
switch (which) {
|
||||
case B_REG_MIME_APP_HINT:
|
||||
{
|
||||
entry_ref ref;
|
||||
err = message->FindRef("app hint", &ref);
|
||||
if (!err)
|
||||
err = fMimeDatabase.SetAppHint(type, &ref);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_REG_MIME_DESCRIPTION:
|
||||
{
|
||||
bool isLong;
|
||||
const char *description;
|
||||
err = message->FindBool("long", &isLong);
|
||||
if (!err)
|
||||
err = message->FindString("description", &description);
|
||||
if (!err)
|
||||
err = (isLong
|
||||
? fMimeDatabase.SetLongDescription(type, description)
|
||||
: fMimeDatabase.SetShortDescription(type, description));
|
||||
break;
|
||||
}
|
||||
|
||||
case B_REG_MIME_PREFERRED_APP:
|
||||
{
|
||||
const char *signature;
|
||||
int32 verb;
|
||||
err = message->FindString("signature", &signature);
|
||||
if (!err)
|
||||
err = message->FindInt32("app verb", &verb);
|
||||
if (!err)
|
||||
err = fMimeDatabase.SetPreferredApp(type, signature, (app_verb)verb);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_REG_MIME_ICON:
|
||||
{
|
||||
// Begin temporary fix code
|
||||
const void *data;
|
||||
ssize_t dataSize;
|
||||
int32 size;
|
||||
err = message->FindData("icon data", B_RAW_TYPE, &data, &dataSize);
|
||||
if (!err)
|
||||
err = message->FindInt32("icon size", &size);
|
||||
if (!err)
|
||||
err = fMimeDatabase.SetIcon(type, (icon_size)size, data, dataSize);
|
||||
break;
|
||||
// End temporary fix code
|
||||
|
||||
/* This is the code I was using until BBitmap::Instantiate blew up on me.
|
||||
|
||||
BMessage iconArchive;
|
||||
int32 size;
|
||||
err = message->FindMessage("icon archive", &iconArchive);
|
||||
if (!err)
|
||||
err = message->FindInt32("size", &size);
|
||||
iconArchive.PrintToStream();
|
||||
if (!err) {
|
||||
BArchivable *unarchived = instantiate_object(&iconArchive);
|
||||
if (unarchived) {
|
||||
BBitmap *icon = cast_as(unarchived, BBitmap);
|
||||
if (icon) {
|
||||
err = icon->InitCheck();
|
||||
if (!err)
|
||||
err = fMimeDatabase.SetIcon(type, icon, (icon_size)size);
|
||||
delete icon;
|
||||
} else
|
||||
err = B_BAD_VALUE;
|
||||
|
||||
} else
|
||||
err = B_NO_MEMORY;
|
||||
}
|
||||
break;
|
||||
*/
|
||||
}
|
||||
|
||||
default:
|
||||
err = B_BAD_VALUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BMessage reply(B_REG_RESULT);
|
||||
reply.AddInt32("result", err);
|
||||
message->SendReply(&reply, this);
|
||||
}
|
@ -13,6 +13,7 @@ public:
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
private:
|
||||
void HandleSetParam(BMessage *message);
|
||||
BPrivate::MimeDatabase fMimeDatabase;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user