+ Added fMimeDatabase member

+ Updated MessageReceived to handle:
  - B_REG_MIME_SET_PARAM.B_REG_MIME_DESCRIPTION
  - B_REG_MIME_{START,STOP}_WATCHING
  - B_REG_MIME_{INSTALL,DELETE}


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@789 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Tyler Dauwalder 2002-08-16 22:08:49 +00:00
parent f231d0901c
commit f978bce0b0
2 changed files with 81 additions and 0 deletions

View File

@ -1,6 +1,9 @@
// MIMEManager.cpp
#include <Message.h>
#include <RegistrarDefs.h>
#include <stdio.h>
#include <string>
#include "MIMEManager.h"
@ -16,6 +19,7 @@
*/
MIMEManager::MIMEManager()
: BLooper("main_mime")
, fMimeDatabase()
{
}
@ -34,8 +38,82 @@ MIMEManager::~MIMEManager()
void
MIMEManager::MessageReceived(BMessage *message)
{
BMessage reply;
status_t err;
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);
}
break;
}
case B_REG_MIME_START_WATCHING:
case B_REG_MIME_STOP_WATCHING:
{
BMessenger messenger;
err = message->FindMessenger("target", &messenger);
if (!err) {
err = message->what == B_REG_MIME_START_WATCHING
? fMimeDatabase.StartWatching(messenger)
: fMimeDatabase.StopWatching(messenger);
}
reply.what = B_SIMPLE_DATA;
reply.AddInt32("result", err);
message->SendReply(&reply, this);
break;
}
case B_REG_MIME_INSTALL:
case B_REG_MIME_DELETE:
{
const char *type;
err = message->FindString("type", &type);
if (!err)
err = message->what == B_REG_MIME_INSTALL
? fMimeDatabase.Install(type)
: fMimeDatabase.Delete(type);
reply.what = B_SIMPLE_DATA;
reply.AddInt32("result", err);
message->SendReply(&reply, this);
break;
}
default:
printf("MIMEMan: msg->what == %.4s\n", &(message->what));
BLooper::MessageReceived(message);
break;
}

View File

@ -4,6 +4,7 @@
#define MIME_MANAGER_H
#include <Looper.h>
#include <MimeDatabase.h>
class MIMEManager : public BLooper {
public:
@ -11,6 +12,8 @@ public:
virtual ~MIMEManager();
virtual void MessageReceived(BMessage *message);
private:
BPrivate::MimeDatabase fMimeDatabase;
};
#endif // MIME_MANAGER_H