diff --git a/src/servers/registrar/ClipboardHandler.cpp b/src/servers/registrar/ClipboardHandler.cpp new file mode 100644 index 0000000000..b798b05b13 --- /dev/null +++ b/src/servers/registrar/ClipboardHandler.cpp @@ -0,0 +1,28 @@ +// ClipboardHandler.cpp + +#include + +#include "ClipboardHandler.h" + +// constructor +ClipboardHandler::ClipboardHandler() + : BHandler() +{ +} + +// destructor +ClipboardHandler::~ClipboardHandler() +{ +} + +// MessageReceived +void +ClipboardHandler::MessageReceived(BMessage *message) +{ + switch (message->what) { + default: + BHandler::MessageReceived(message); + break; + } +} + diff --git a/src/servers/registrar/ClipboardHandler.h b/src/servers/registrar/ClipboardHandler.h new file mode 100644 index 0000000000..a8a5d66e5c --- /dev/null +++ b/src/servers/registrar/ClipboardHandler.h @@ -0,0 +1,16 @@ +// ClipboardHandler.h + +#ifndef CLIPBOARD_HANDLER_H +#define CLIPBOARD_HANDLER_H + +#include + +class ClipboardHandler : public BHandler { +public: + ClipboardHandler(); + virtual ~ClipboardHandler(); + + virtual void MessageReceived(BMessage *message); +}; + +#endif // CLIPBOARD_HANDLER_H diff --git a/src/servers/registrar/Debug.h b/src/servers/registrar/Debug.h new file mode 100644 index 0000000000..1cc894772a --- /dev/null +++ b/src/servers/registrar/Debug.h @@ -0,0 +1,50 @@ +#ifndef DEBUG_H +#define DEBUG_H +/* Debug - debug stuff +** +** Initial version by Axel Dörfler, axeld@pinc-software.de +** This file may be used under the terms of the OpenBeOS License. +*/ + +#include +#define __out printf + +// Short overview over the debug output macros: +// PRINT() +// is for general messages that very unlikely should appear in a release build +// FATAL() +// this is for fatal messages, when something has really gone wrong +// INFORM() +// general information, as disk size, etc. +// REPORT_ERROR(status_t) +// prints out error information +// RETURN_ERROR(status_t) +// calls REPORT_ERROR() and return the value +// D() +// the statements in D() are only included if DEBUG is defined + +#define DEBUG_APP "REG" +#ifdef DEBUG + #define PRINT(x) { __out(DEBUG_APP ": "); __out x; } + #define REPORT_ERROR(status) __out(DEBUG_APP ": %s:%ld: %s\n",__FUNCTION__,__LINE__,strerror(status)); + #define RETURN_ERROR(err) { status_t _status = err; if (_status < B_OK) REPORT_ERROR(_status); return _status;} + #define FATAL(x) { __out(DEBUG_APP ": "); __out x; } + #define INFORM(x) { __out(DEBUG_APP ": "); __out x; } + #define FUNCTION(x) { __out(DEBUG_APP ": %s() ",__FUNCTION__); __out x; } + #define FUNCTION_START() { __out(DEBUG_APP ": %s()\n",__FUNCTION__); } + #define FUNCTION_END() { __out(DEBUG_APP ": %s() done\n",__FUNCTION__); } + #define D(x) {x;}; +#else + #define PRINT(x) ; + #define REPORT_ERROR(status) ; + #define RETURN_ERROR(status) return status; + #define FATAL(x) { __out(DEBUG_APP ": "); __out x; } + #define INFORM(x) { __out(DEBUG_APP ": "); __out x; } + #define FUNCTION(x) ; + #define FUNCTION_START() ; + #define FUNCTION_END() ; + #define D(x) ; +#endif + + +#endif /* DEBUG_H */ diff --git a/src/servers/registrar/Jamfile b/src/servers/registrar/Jamfile new file mode 100644 index 0000000000..333309ae48 --- /dev/null +++ b/src/servers/registrar/Jamfile @@ -0,0 +1,14 @@ +SubDir OBOS_TOP src servers registrar ; + +UsePublicHeaders app ; +UsePrivateHeaders app ; + +Server obos_registrar : + ClipboardHandler.cpp + MIMEManager.cpp + Registrar.cpp +; +LinkSharedOSLibs obos_registrar : + libopenbeos.so + be root +; diff --git a/src/servers/registrar/MIMEManager.cpp b/src/servers/registrar/MIMEManager.cpp new file mode 100644 index 0000000000..47f2d01a41 --- /dev/null +++ b/src/servers/registrar/MIMEManager.cpp @@ -0,0 +1,28 @@ +// MIMEManager.cpp + +#include + +#include "MIMEManager.h" + +// constructor +MIMEManager::MIMEManager() + : BLooper("main_mime") +{ +} + +// destructor +MIMEManager::~MIMEManager() +{ +} + +// MessageReceived +void +MIMEManager::MessageReceived(BMessage *message) +{ + switch (message->what) { + default: + BLooper::MessageReceived(message); + break; + } +} + diff --git a/src/servers/registrar/MIMEManager.h b/src/servers/registrar/MIMEManager.h new file mode 100644 index 0000000000..793f8bc194 --- /dev/null +++ b/src/servers/registrar/MIMEManager.h @@ -0,0 +1,16 @@ +// MIMEManager.h + +#ifndef MIME_MANAGER_H +#define MIME_MANAGER_H + +#include + +class MIMEManager : public BLooper { +public: + MIMEManager(); + virtual ~MIMEManager(); + + virtual void MessageReceived(BMessage *message); +}; + +#endif // MIME_MANAGER_H diff --git a/src/servers/registrar/Registrar.cpp b/src/servers/registrar/Registrar.cpp new file mode 100644 index 0000000000..5cc453229c --- /dev/null +++ b/src/servers/registrar/Registrar.cpp @@ -0,0 +1,105 @@ +// Registrar.cpp + +#ifndef DEBUG +# define DEBUG 1 +#endif +#include "Debug.h" + +#include +#include +#include +#include + +#include "ClipboardHandler.h" +#include "MIMEManager.h" +#include "Registrar.h" + +// constructor +Registrar::Registrar() + : BApplication(kRegistrarSignature), + fClipboardHandler(NULL), + fMIMEManager(NULL) +{ +FUNCTION_START(); + // move the following code to ReadyToRun() once it works. + fClipboardHandler = new ClipboardHandler; + AddHandler(fClipboardHandler); + fMIMEManager = new MIMEManager; + fMIMEManager->Run(); +} + +// destructor +Registrar::~Registrar() +{ +FUNCTION_START(); + fMIMEManager->Lock(); + fMIMEManager->Quit(); + RemoveHandler(fClipboardHandler); + delete fClipboardHandler; +} + +// MessageReceived +void +Registrar::MessageReceived(BMessage *message) +{ +FUNCTION_START(); + 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; + } + default: + BApplication::MessageReceived(message); + break; + } +FUNCTION_END(); +} + +// ReadyToRun +void +Registrar::ReadyToRun() +{ +FUNCTION_START(); +} + +// QuitRequested +bool +Registrar::QuitRequested() +{ +FUNCTION_START(); + // The final registrar must not quit. At least not that easily. ;-) + return BApplication::QuitRequested(); +} + + +// main +int +main() +{ +FUNCTION_START(); + // 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; +FUNCTION_END(); + return 0; +} + diff --git a/src/servers/registrar/Registrar.h b/src/servers/registrar/Registrar.h new file mode 100644 index 0000000000..d34323a76f --- /dev/null +++ b/src/servers/registrar/Registrar.h @@ -0,0 +1,48 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: Registrar.h +// Author: Ingo Weinhold (bonefish@users.sf.net) +// Description: Registrar application. +//------------------------------------------------------------------------------ +#ifndef REGISTRAR_H +#define REGISTRAR_H + +#include + +class ClipboardHandler; +class MIMEManager; + +class Registrar : public BApplication { +public: + Registrar(); + virtual ~Registrar(); + + virtual void MessageReceived(BMessage *message); + virtual void ReadyToRun(); + virtual bool QuitRequested(); + +private: + ClipboardHandler *fClipboardHandler; + MIMEManager *fMIMEManager; +}; + +#endif // REGISTRAR_H