registrar ClipboardHandler: Style fixes.
This commit is contained in:
parent
90520f9b43
commit
b367d3a77c
@ -17,10 +17,12 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::string;
|
using std::string;
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class ClipboardHandler
|
\class ClipboardHandler
|
||||||
\brief Handles all clipboard related requests.
|
\brief Handles all clipboard related requests.
|
||||||
@ -28,6 +30,7 @@ using namespace BPrivate;
|
|||||||
|
|
||||||
struct ClipboardHandler::ClipboardMap : map<string, Clipboard*> {};
|
struct ClipboardHandler::ClipboardMap : map<string, Clipboard*> {};
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
/*! \brief Creates and initializes a ClipboardHandler.
|
/*! \brief Creates and initializes a ClipboardHandler.
|
||||||
*/
|
*/
|
||||||
@ -37,18 +40,19 @@ ClipboardHandler::ClipboardHandler()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// destructor
|
// destructor
|
||||||
/*! \brief Frees all resources associate with this object.
|
/*! \brief Frees all resources associate with this object.
|
||||||
*/
|
*/
|
||||||
ClipboardHandler::~ClipboardHandler()
|
ClipboardHandler::~ClipboardHandler()
|
||||||
{
|
{
|
||||||
for (ClipboardMap::iterator it = fClipboards->begin();
|
for (ClipboardMap::iterator it = fClipboards->begin();
|
||||||
it != fClipboards->end();
|
it != fClipboards->end();
|
||||||
++it) {
|
++it)
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MessageReceived
|
// MessageReceived
|
||||||
/*! \brief Overrides the super class version to handle the clipboard specific
|
/*! \brief Overrides the super class version to handle the clipboard specific
|
||||||
messages.
|
messages.
|
||||||
@ -64,32 +68,32 @@ ClipboardHandler::MessageReceived(BMessage *message)
|
|||||||
{
|
{
|
||||||
status_t result = B_BAD_VALUE;
|
status_t result = B_BAD_VALUE;
|
||||||
|
|
||||||
if (message->FindString("name", &name) == B_OK) {
|
if (message->FindString("name", &name) == B_OK) {
|
||||||
if (_GetClipboard(name))
|
if (_GetClipboard(name))
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
reply.AddInt32("result", result);
|
reply.AddInt32("result", result);
|
||||||
message->SendReply(&reply);
|
message->SendReply(&reply);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_GET_CLIPBOARD_COUNT:
|
case B_REG_GET_CLIPBOARD_COUNT:
|
||||||
{
|
{
|
||||||
status_t result = B_BAD_VALUE;
|
status_t result = B_BAD_VALUE;
|
||||||
|
|
||||||
if (message->FindString("name", &name) == B_OK) {
|
if (message->FindString("name", &name) == B_OK) {
|
||||||
if (Clipboard *clipboard = _GetClipboard(name)) {
|
if (Clipboard *clipboard = _GetClipboard(name)) {
|
||||||
reply.AddInt32("count", clipboard->Count());
|
reply.AddInt32("count", clipboard->Count());
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.AddInt32("result", result);
|
reply.AddInt32("result", result);
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
message->SendReply(&reply);
|
message->SendReply(&reply);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_CLIPBOARD_START_WATCHING:
|
case B_REG_CLIPBOARD_START_WATCHING:
|
||||||
@ -97,17 +101,17 @@ ClipboardHandler::MessageReceived(BMessage *message)
|
|||||||
status_t result = B_BAD_VALUE;
|
status_t result = B_BAD_VALUE;
|
||||||
|
|
||||||
BMessenger target;
|
BMessenger target;
|
||||||
if (message->FindString("name", &name) == B_OK
|
if (message->FindString("name", &name) == B_OK
|
||||||
&& message->FindMessenger("target", &target) == B_OK) {
|
&& message->FindMessenger("target", &target) == B_OK) {
|
||||||
Clipboard *clipboard = _GetClipboard(name);
|
Clipboard *clipboard = _GetClipboard(name);
|
||||||
if (clipboard && clipboard->AddWatcher(target))
|
if (clipboard && clipboard->AddWatcher(target))
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
reply.AddInt32("result", result);
|
reply.AddInt32("result", result);
|
||||||
message->SendReply(&reply);
|
message->SendReply(&reply);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_CLIPBOARD_STOP_WATCHING:
|
case B_REG_CLIPBOARD_STOP_WATCHING:
|
||||||
@ -115,37 +119,37 @@ ClipboardHandler::MessageReceived(BMessage *message)
|
|||||||
status_t result = B_BAD_VALUE;
|
status_t result = B_BAD_VALUE;
|
||||||
|
|
||||||
BMessenger target;
|
BMessenger target;
|
||||||
if (message->FindString("name", &name) == B_OK
|
if (message->FindString("name", &name) == B_OK
|
||||||
&& message->FindMessenger("target", &target) == B_OK) {
|
&& message->FindMessenger("target", &target) == B_OK) {
|
||||||
Clipboard *clipboard = _GetClipboard(name);
|
Clipboard *clipboard = _GetClipboard(name);
|
||||||
if (clipboard && clipboard->RemoveWatcher(target))
|
if (clipboard && clipboard->RemoveWatcher(target))
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
reply.AddInt32("result", result);
|
reply.AddInt32("result", result);
|
||||||
message->SendReply(&reply);
|
message->SendReply(&reply);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_DOWNLOAD_CLIPBOARD:
|
case B_REG_DOWNLOAD_CLIPBOARD:
|
||||||
{
|
{
|
||||||
status_t result = B_BAD_VALUE;
|
status_t result = B_BAD_VALUE;
|
||||||
|
|
||||||
if (message->FindString("name", &name) == B_OK) {
|
if (message->FindString("name", &name) == B_OK) {
|
||||||
Clipboard *clipboard = _GetClipboard(name);
|
Clipboard *clipboard = _GetClipboard(name);
|
||||||
if (clipboard) {
|
if (clipboard) {
|
||||||
reply.AddMessage("data", clipboard->Data());
|
reply.AddMessage("data", clipboard->Data());
|
||||||
reply.AddMessenger("data source", clipboard->DataSource());
|
reply.AddMessenger("data source", clipboard->DataSource());
|
||||||
reply.AddInt32("count", clipboard->Count());
|
reply.AddInt32("count", clipboard->Count());
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
reply.AddInt32("result", result);
|
reply.AddInt32("result", result);
|
||||||
message->SendReply(&reply);
|
message->SendReply(&reply);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_REG_UPLOAD_CLIPBOARD:
|
case B_REG_UPLOAD_CLIPBOARD:
|
||||||
@ -154,31 +158,32 @@ ClipboardHandler::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
BMessage data;
|
BMessage data;
|
||||||
BMessenger source;
|
BMessenger source;
|
||||||
if (message->FindString("name", &name) == B_OK
|
if (message->FindString("name", &name) == B_OK
|
||||||
&& message->FindMessenger("data source", &source) == B_OK
|
&& message->FindMessenger("data source", &source) == B_OK
|
||||||
&& message->FindMessage("data", &data) == B_OK) {
|
&& message->FindMessage("data", &data) == B_OK) {
|
||||||
Clipboard *clipboard = _GetClipboard(name);
|
Clipboard *clipboard = _GetClipboard(name);
|
||||||
if (clipboard) {
|
if (clipboard) {
|
||||||
int32 localCount;
|
int32 localCount;
|
||||||
bool failIfChanged;
|
bool failIfChanged;
|
||||||
if (message->FindInt32("count", &localCount) == B_OK
|
if (message->FindInt32("count", &localCount) == B_OK
|
||||||
&& message->FindBool("fail if changed", &failIfChanged) == B_OK
|
&& message->FindBool("fail if changed", &failIfChanged)
|
||||||
&& failIfChanged
|
== B_OK
|
||||||
&& localCount != clipboard->Count()) {
|
&& failIfChanged
|
||||||
// atomic support
|
&& localCount != clipboard->Count()) {
|
||||||
result = B_ERROR;
|
// atomic support
|
||||||
} else {
|
result = B_ERROR;
|
||||||
clipboard->SetData(&data, source);
|
} else {
|
||||||
|
clipboard->SetData(&data, source);
|
||||||
result = reply.AddInt32("count", clipboard->Count());
|
result = reply.AddInt32("count", clipboard->Count());
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.what = B_REG_RESULT;
|
reply.what = B_REG_RESULT;
|
||||||
reply.AddInt32("result", result);
|
reply.AddInt32("result", result);
|
||||||
message->SendReply(&reply);
|
message->SendReply(&reply);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -187,6 +192,7 @@ ClipboardHandler::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Gets the clipboard with the specified name, or adds it, if not yet
|
/*! \brief Gets the clipboard with the specified name, or adds it, if not yet
|
||||||
existent.
|
existent.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user