diff --git a/src/servers/registrar/MIMEManager.cpp b/src/servers/registrar/MIMEManager.cpp index b229697e58..55e98822dd 100644 --- a/src/servers/registrar/MIMEManager.cpp +++ b/src/servers/registrar/MIMEManager.cpp @@ -1,6 +1,9 @@ // MIMEManager.cpp #include +#include +#include +#include #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; } diff --git a/src/servers/registrar/MIMEManager.h b/src/servers/registrar/MIMEManager.h index 793f8bc194..d843e480de 100644 --- a/src/servers/registrar/MIMEManager.h +++ b/src/servers/registrar/MIMEManager.h @@ -4,6 +4,7 @@ #define MIME_MANAGER_H #include +#include 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