Checkin for Gabe Yoder

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1826 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2002-11-02 23:33:33 +00:00
parent ad68e9c90b
commit e4840f5bd2
4 changed files with 64 additions and 22 deletions
+4 -1
View File
@@ -47,7 +47,10 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
BClipboard::BClipboard(const char *name, bool transient = false) BClipboard::BClipboard(const char *name, bool transient = false)
{ {
fName = strdup(name); if ( name )
fName = strdup(name);
else
fName = strdup("system");
fData = new BMessage(); fData = new BMessage();
fCount = 0; fCount = 0;
fSystemCount = 0; fSystemCount = 0;
+40 -3
View File
@@ -21,6 +21,7 @@
// //
// File Name: Cursor.cpp // File Name: Cursor.cpp
// Author: Frans van Nispen ([email protected]) // Author: Frans van Nispen ([email protected])
// Gabe Yoder ([email protected])
// Description: BCursor describes a view-wide or application-wide cursor. // Description: BCursor describes a view-wide or application-wide cursor.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** /**
@@ -29,12 +30,19 @@
*/ */
// Standard Includes ----------------------------------------------------------- // Standard Includes -----------------------------------------------------------
#include <stdio.h>
// System Includes ------------------------------------------------------------- // System Includes -------------------------------------------------------------
#include <Cursor.h> #include <Cursor.h>
#include <PortLink.h>
#include <AppServerLink.h>
// Project Includes ------------------------------------------------------------ // Project Includes ------------------------------------------------------------
// Needed from app server
#if 0
#include <ServerProtocol.h>
#else
#define SET_CURSOR_BCURSOR 'sscb'
#endif
// Local Includes -------------------------------------------------------------- // Local Includes --------------------------------------------------------------
@@ -46,13 +54,39 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
BCursor::BCursor(const void *cursorData) BCursor::BCursor(const void *cursorData)
{ {
// uint8 data[68]; int8 *data = (int8 *)cursorData;
// memcpy(&data, cursorData, 68); m_serverToken = 0;
if ( sizeof(cursorData) < 68 )
return;
if ( data[0] != 16 )
return;
if ( data[1] != 1 )
return;
if ( (data[2] >= 16) || (data[3] >= 16) )
return;
ssize_t buffersize;
status_t status;
int32 returncode;
int8 *buffer;
// Send data directly to server
BPrivate::BAppServerLink *serverlink = new BPrivate::BAppServerLink;
serverlink->Init();
serverlink->portlink->SetOpCode(SET_CURSOR_BCURSOR);
serverlink->portlink->Attach((void *)cursorData,68);
//Rumor has it that this API will be cleaned up later
buffer=serverlink->portlink->FlushWithReply(&returncode,&status,&buffersize);
m_serverToken=*((int32*)buffer);
delete serverlink;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// undefined on BeOS // undefined on BeOS
BCursor::BCursor(BMessage *data) BCursor::BCursor(BMessage *data)
{ {
m_serverToken = 0;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
BCursor::~BCursor() BCursor::~BCursor()
@@ -73,7 +107,9 @@ BArchivable *BCursor::Instantiate(BMessage *data)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
status_t BCursor::Perform(perform_code d, void *arg) status_t BCursor::Perform(perform_code d, void *arg)
{ {
/*
printf("perform %d\n", (int)d); printf("perform %d\n", (int)d);
*/
return B_OK; return B_OK;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -101,3 +137,4 @@ void BCursor::_ReservedCursor4()
* *
*/ */
+18 -17
View File
@@ -40,12 +40,12 @@ ClipboardHandler::MessageReceived(BMessage *message)
{ {
if ( message->FindString("name",&name) != B_OK ) if ( message->FindString("name",&name) != B_OK )
{ {
reply.AddInt32("result",0); reply.AddInt32("result",B_BAD_VALUE);
} }
else else
{ {
fClipboardTree.AddNode(name); fClipboardTree.AddNode(name);
reply.AddInt32("result",1); reply.AddInt32("result",B_OK);
} }
reply.what = B_REG_RESULT; reply.what = B_REG_RESULT;
message->SendReply(&reply); message->SendReply(&reply);
@@ -55,7 +55,7 @@ ClipboardHandler::MessageReceived(BMessage *message)
{ {
if ( message->FindString("name",&name) != B_OK ) if ( message->FindString("name",&name) != B_OK )
{ {
reply.AddInt32("result",0); reply.AddInt32("result",B_BAD_VALUE);
} }
else else
{ {
@@ -63,10 +63,10 @@ ClipboardHandler::MessageReceived(BMessage *message)
if ( node ) if ( node )
{ {
reply.AddInt32("count",(uint32)(node->GetCount())); reply.AddInt32("count",(uint32)(node->GetCount()));
reply.AddInt32("result",1); reply.AddInt32("result",B_OK);
} }
else else
reply.AddInt32("result",0); reply.AddInt32("result",B_BAD_VALUE);
} }
reply.what = B_REG_RESULT; reply.what = B_REG_RESULT;
message->SendReply(&reply); message->SendReply(&reply);
@@ -78,15 +78,15 @@ ClipboardHandler::MessageReceived(BMessage *message)
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) )
{ {
reply.AddInt32("result",0); reply.AddInt32("result",B_BAD_VALUE);
} }
else else
{ {
ClipboardTree *node = fClipboardTree.GetNode(name); ClipboardTree *node = fClipboardTree.GetNode(name);
if ( node && node->AddWatcher(&target) ) if ( node && node->AddWatcher(&target) )
reply.AddInt32("result",1); reply.AddInt32("result",B_OK);
else else
reply.AddInt32("result",0); reply.AddInt32("result",B_BAD_VALUE);
} }
reply.what = B_REG_RESULT; reply.what = B_REG_RESULT;
message->SendReply(&reply); message->SendReply(&reply);
@@ -98,15 +98,15 @@ ClipboardHandler::MessageReceived(BMessage *message)
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) )
{ {
reply.AddInt32("result",0); reply.AddInt32("result",B_BAD_VALUE);
} }
else else
{ {
ClipboardTree *node = fClipboardTree.GetNode(name); ClipboardTree *node = fClipboardTree.GetNode(name);
if ( node && node->RemoveWatcher(&target) ) if ( node && node->RemoveWatcher(&target) )
reply.AddInt32("result",1); reply.AddInt32("result",B_OK);
else else
reply.AddInt32("result",0); reply.AddInt32("result",B_BAD_VALUE);
} }
reply.what = B_REG_RESULT; reply.what = B_REG_RESULT;
message->SendReply(&reply); message->SendReply(&reply);
@@ -116,7 +116,7 @@ ClipboardHandler::MessageReceived(BMessage *message)
{ {
if ( message->FindString("name",&name) != B_OK ) if ( message->FindString("name",&name) != B_OK )
{ {
reply.AddInt32("result",0); reply.AddInt32("result",B_BAD_VALUE);
} }
else else
{ {
@@ -126,10 +126,10 @@ ClipboardHandler::MessageReceived(BMessage *message)
reply.AddMessage("data",node->GetData()); reply.AddMessage("data",node->GetData());
reply.AddMessenger("data source",*node->GetDataSource()); reply.AddMessenger("data source",*node->GetDataSource());
reply.AddInt32("count",(uint32)(node->GetCount())); reply.AddInt32("count",(uint32)(node->GetCount()));
reply.AddInt32("result",1); reply.AddInt32("result",B_OK);
} }
else else
reply.AddInt32("result",0); reply.AddInt32("result",B_BAD_VALUE);
} }
reply.what = B_REG_RESULT; reply.what = B_REG_RESULT;
message->SendReply(&reply); message->SendReply(&reply);
@@ -144,7 +144,7 @@ ClipboardHandler::MessageReceived(BMessage *message)
(message->FindMessage("data",&data) != B_OK) || (message->FindMessage("data",&data) != B_OK) ||
(message->FindMessenger("data source",&dataSource) != B_OK) ) (message->FindMessenger("data source",&dataSource) != B_OK) )
{ {
reply.AddInt32("result",0); reply.AddInt32("result",B_BAD_VALUE);
} }
else else
{ {
@@ -154,10 +154,10 @@ ClipboardHandler::MessageReceived(BMessage *message)
node->SetData(&data); node->SetData(&data);
node->SetDataSource(&dataSource); node->SetDataSource(&dataSource);
reply.AddInt32("count",(uint32)(node->IncrementCount())); reply.AddInt32("count",(uint32)(node->IncrementCount()));
reply.AddInt32("result",1); reply.AddInt32("result",B_OK);
} }
else else
reply.AddInt32("result",0); reply.AddInt32("result",B_BAD_VALUE);
} }
reply.what = B_REG_RESULT; reply.what = B_REG_RESULT;
message->SendReply(&reply); message->SendReply(&reply);
@@ -172,3 +172,4 @@ ClipboardHandler::MessageReceived(BMessage *message)
} }
+2 -1
View File
@@ -108,7 +108,7 @@ bool ClipboardTree::AddWatcher(BMessenger *watcher)
bool ClipboardTree::RemoveWatcher(BMessenger *watcher) bool ClipboardTree::RemoveWatcher(BMessenger *watcher)
{ {
return fWatchingService.RemoveWatcher(*watcher,true); return fWatchingService.RemoveWatcher(*watcher,false);
} }
void ClipboardTree::NotifyWatchers() void ClipboardTree::NotifyWatchers()
@@ -117,3 +117,4 @@ void ClipboardTree::NotifyWatchers()
fWatchingService.NotifyWatchers(&message,NULL); fWatchingService.NotifyWatchers(&message,NULL);
} }