2002-07-22 02:40:07 +04:00
|
|
|
// Registrar.cpp
|
|
|
|
|
|
|
|
#include "Debug.h"
|
|
|
|
|
|
|
|
#include <Application.h>
|
|
|
|
#include <Message.h>
|
|
|
|
#include <OS.h>
|
|
|
|
#include <RegistrarDefs.h>
|
|
|
|
|
|
|
|
#include "ClipboardHandler.h"
|
|
|
|
#include "MIMEManager.h"
|
|
|
|
#include "Registrar.h"
|
2002-07-24 03:40:12 +04:00
|
|
|
#include "TRoster.h"
|
2002-07-22 02:40:07 +04:00
|
|
|
|
|
|
|
// constructor
|
|
|
|
Registrar::Registrar()
|
|
|
|
: BApplication(kRegistrarSignature),
|
2002-07-24 03:40:12 +04:00
|
|
|
fRoster(NULL),
|
2002-07-22 02:40:07 +04:00
|
|
|
fClipboardHandler(NULL),
|
|
|
|
fMIMEManager(NULL)
|
|
|
|
{
|
2002-07-27 00:02:10 +04:00
|
|
|
FUNCTION_START();
|
2002-07-22 02:40:07 +04:00
|
|
|
// move the following code to ReadyToRun() once it works.
|
2002-07-24 03:40:12 +04:00
|
|
|
fRoster = new TRoster;
|
2002-07-22 02:40:07 +04:00
|
|
|
fClipboardHandler = new ClipboardHandler;
|
|
|
|
AddHandler(fClipboardHandler);
|
|
|
|
fMIMEManager = new MIMEManager;
|
|
|
|
fMIMEManager->Run();
|
2002-07-27 00:02:10 +04:00
|
|
|
FUNCTION_END();
|
2002-07-22 02:40:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// destructor
|
|
|
|
Registrar::~Registrar()
|
|
|
|
{
|
2002-07-27 00:02:10 +04:00
|
|
|
FUNCTION_START();
|
2002-07-22 02:40:07 +04:00
|
|
|
fMIMEManager->Lock();
|
|
|
|
fMIMEManager->Quit();
|
|
|
|
RemoveHandler(fClipboardHandler);
|
|
|
|
delete fClipboardHandler;
|
2002-07-24 03:40:12 +04:00
|
|
|
delete fRoster;
|
2002-07-27 00:02:10 +04:00
|
|
|
FUNCTION_END();
|
2002-07-22 02:40:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// MessageReceived
|
|
|
|
void
|
|
|
|
Registrar::MessageReceived(BMessage *message)
|
|
|
|
{
|
2002-07-27 00:02:10 +04:00
|
|
|
FUNCTION_START();
|
2002-07-22 02:40:07 +04:00
|
|
|
switch (message->what) {
|
|
|
|
case B_REG_GET_MIME_MESSENGER:
|
|
|
|
{
|
|
|
|
PRINT(("B_REG_GET_MIME_MESSENGER\n"));
|
|
|
|
BMessenger messenger(NULL, fMIMEManager);
|
|
|
|
BMessage reply(B_REG_SUCCESS);
|
|
|
|
reply.AddMessenger("messenger", messenger);
|
|
|
|
message->SendReply(&reply);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case B_REG_GET_CLIPBOARD_MESSENGER:
|
|
|
|
{
|
|
|
|
PRINT(("B_REG_GET_CLIPBOARD_MESSENGER\n"));
|
|
|
|
BMessenger messenger(fClipboardHandler);
|
|
|
|
BMessage reply(B_REG_SUCCESS);
|
|
|
|
reply.AddMessenger("messenger", messenger);
|
|
|
|
message->SendReply(&reply);
|
|
|
|
break;
|
|
|
|
}
|
2002-07-24 03:40:12 +04:00
|
|
|
case B_REG_ADD_APP:
|
|
|
|
fRoster->HandleAddApplication(message);
|
|
|
|
break;
|
|
|
|
case B_REG_COMPLETE_REGISTRATION:
|
|
|
|
fRoster->HandleCompleteRegistration(message);
|
|
|
|
break;
|
|
|
|
case B_REG_IS_PRE_REGISTERED:
|
|
|
|
fRoster->HandleIsAppPreRegistered(message);
|
|
|
|
break;
|
|
|
|
case B_REG_REMOVE_PRE_REGISTERED_APP:
|
|
|
|
fRoster->HandleRemovePreRegApp(message);
|
|
|
|
break;
|
|
|
|
case B_REG_REMOVE_APP:
|
|
|
|
fRoster->HandleRemoveApp(message);
|
|
|
|
break;
|
2002-07-27 00:02:10 +04:00
|
|
|
case B_REG_SET_THREAD_AND_TEAM:
|
|
|
|
fRoster->HandleSetThreadAndTeam(message);
|
|
|
|
break;
|
|
|
|
case B_REG_GET_RUNNING_APP_INFO:
|
|
|
|
fRoster->HandleGetRunningAppInfo(message);
|
|
|
|
break;
|
2002-07-22 02:40:07 +04:00
|
|
|
default:
|
|
|
|
BApplication::MessageReceived(message);
|
|
|
|
break;
|
|
|
|
}
|
2002-07-27 00:02:10 +04:00
|
|
|
FUNCTION_END();
|
2002-07-22 02:40:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ReadyToRun
|
|
|
|
void
|
|
|
|
Registrar::ReadyToRun()
|
|
|
|
{
|
2002-07-27 00:02:10 +04:00
|
|
|
FUNCTION_START();
|
2002-07-22 02:40:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// QuitRequested
|
|
|
|
bool
|
|
|
|
Registrar::QuitRequested()
|
|
|
|
{
|
2002-07-27 00:02:10 +04:00
|
|
|
FUNCTION_START();
|
2002-07-22 02:40:07 +04:00
|
|
|
// The final registrar must not quit. At least not that easily. ;-)
|
|
|
|
return BApplication::QuitRequested();
|
2002-07-27 00:02:10 +04:00
|
|
|
FUNCTION_END();
|
2002-07-22 02:40:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// main
|
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
2002-07-27 00:02:10 +04:00
|
|
|
FUNCTION_START();
|
2002-07-22 02:40:07 +04:00
|
|
|
// rename the main thread
|
|
|
|
rename_thread(find_thread(NULL), kRosterThreadName);
|
|
|
|
// create and run the registrar application
|
|
|
|
Registrar *app = new Registrar();
|
|
|
|
PRINT(("app->Run()...\n"));
|
|
|
|
app->Run();
|
|
|
|
PRINT(("delete app...\n"));
|
|
|
|
delete app;
|
2002-07-27 00:02:10 +04:00
|
|
|
FUNCTION_END();
|
2002-07-22 02:40:07 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|