* Added private methods get_app_server_port() (that stores the server port,
and doesn't have to find it every time), and create_desktop_connection() that is now used from BApplication::_ConnectToServer() as well as the DesktopLink. * Move PortLink::SetTo() into base class ServerLink. * Eliminated duplicated member fReplyPort in DesktopLink. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34397 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -16,6 +16,9 @@ struct entry_ref;
|
|||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
class ServerLink;
|
||||||
|
|
||||||
|
|
||||||
status_t get_app_path(team_id team, char *buffer);
|
status_t get_app_path(team_id team, char *buffer);
|
||||||
status_t get_app_path(char *buffer);
|
status_t get_app_path(char *buffer);
|
||||||
status_t get_app_ref(team_id team, entry_ref *ref, bool traverse = true);
|
status_t get_app_ref(team_id team, entry_ref *ref, bool traverse = true);
|
||||||
@@ -26,6 +29,10 @@ thread_id main_thread_for(team_id team);
|
|||||||
|
|
||||||
bool is_app_showing_modal_window(team_id team);
|
bool is_app_showing_modal_window(team_id team);
|
||||||
|
|
||||||
|
port_id get_app_server_port();
|
||||||
|
status_t create_desktop_connection(ServerLink* link, const char* name,
|
||||||
|
int32 capacity);
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
// _get_object_token_
|
// _get_object_token_
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku.
|
* Copyright 2006-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -15,14 +15,11 @@
|
|||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
class DesktopLink : public PortLink {
|
class DesktopLink : public PortLink {
|
||||||
public:
|
public:
|
||||||
DesktopLink();
|
DesktopLink();
|
||||||
virtual ~DesktopLink();
|
virtual ~DesktopLink();
|
||||||
|
|
||||||
status_t InitCheck() const;
|
status_t InitCheck() const;
|
||||||
|
|
||||||
private:
|
|
||||||
port_id fReplyPort;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005, Haiku.
|
* Copyright 2005-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -14,14 +14,15 @@
|
|||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
class PortLink : public ServerLink {
|
|
||||||
public:
|
|
||||||
PortLink(port_id sender = -1, port_id receiver = -1);
|
|
||||||
virtual ~PortLink();
|
|
||||||
|
|
||||||
void SetTo(port_id sender, port_id receiver);
|
class PortLink : public ServerLink {
|
||||||
|
public:
|
||||||
|
PortLink(port_id sender = -1,
|
||||||
|
port_id receiver = -1);
|
||||||
|
virtual ~PortLink();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
#endif /* _PORT_LINK_H */
|
#endif /* _PORT_LINK_H */
|
||||||
|
|||||||
@@ -32,56 +32,68 @@ class BGradient;
|
|||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
class ServerLink {
|
class ServerLink {
|
||||||
public:
|
public:
|
||||||
ServerLink();
|
ServerLink();
|
||||||
virtual ~ServerLink();
|
virtual ~ServerLink();
|
||||||
|
|
||||||
// send methods
|
void SetTo(port_id sender, port_id receiver);
|
||||||
|
|
||||||
void SetSenderPort(port_id port);
|
// send methods
|
||||||
port_id SenderPort();
|
|
||||||
|
|
||||||
status_t StartMessage(int32 code, size_t minSize = 0);
|
void SetSenderPort(port_id port);
|
||||||
void CancelMessage();
|
port_id SenderPort();
|
||||||
status_t EndMessage();
|
|
||||||
|
|
||||||
status_t Flush(bigtime_t timeout = B_INFINITE_TIMEOUT, bool needsReply = false);
|
status_t StartMessage(int32 code, size_t minSize = 0);
|
||||||
status_t Attach(const void *data, ssize_t size);
|
void CancelMessage();
|
||||||
status_t AttachString(const char *string, int32 length = -1);
|
status_t EndMessage();
|
||||||
status_t AttachRegion(const BRegion ®ion);
|
|
||||||
status_t AttachShape(BShape &shape);
|
|
||||||
status_t AttachGradient(const BGradient &gradient);
|
|
||||||
template <class Type> status_t Attach(const Type& data);
|
|
||||||
|
|
||||||
// receive methods
|
status_t Flush(bigtime_t timeout = B_INFINITE_TIMEOUT,
|
||||||
|
bool needsReply = false);
|
||||||
|
status_t Attach(const void* data, ssize_t size);
|
||||||
|
status_t AttachString(const char* string,
|
||||||
|
int32 length = -1);
|
||||||
|
status_t AttachRegion(const BRegion& region);
|
||||||
|
status_t AttachShape(BShape& shape);
|
||||||
|
status_t AttachGradient(const BGradient& gradient);
|
||||||
|
|
||||||
void SetReceiverPort(port_id port);
|
template <class Type>
|
||||||
port_id ReceiverPort();
|
status_t Attach(const Type& data);
|
||||||
|
|
||||||
status_t GetNextMessage(int32 &code, bigtime_t timeout = B_INFINITE_TIMEOUT);
|
// receive methods
|
||||||
bool NeedsReply() const;
|
|
||||||
status_t Read(void *data, ssize_t size);
|
|
||||||
status_t ReadString(char *buffer, size_t bufferSize);
|
|
||||||
status_t ReadString(BString& string, size_t* _length = NULL);
|
|
||||||
status_t ReadString(char** _string, size_t* _length = NULL);
|
|
||||||
status_t ReadRegion(BRegion *region);
|
|
||||||
status_t ReadShape(BShape *shape);
|
|
||||||
status_t ReadGradient(BGradient **gradient);
|
|
||||||
template <class Type> status_t Read(Type *data);
|
|
||||||
|
|
||||||
// convenience methods
|
void SetReceiverPort(port_id port);
|
||||||
|
port_id ReceiverPort();
|
||||||
|
|
||||||
status_t FlushWithReply(int32 &code);
|
status_t GetNextMessage(int32& code,
|
||||||
LinkSender &Sender() { return *fSender; }
|
bigtime_t timeout = B_INFINITE_TIMEOUT);
|
||||||
LinkReceiver &Receiver() { return *fReceiver; }
|
bool NeedsReply() const;
|
||||||
|
status_t Read(void* data, ssize_t size);
|
||||||
|
status_t ReadString(char* buffer, size_t bufferSize);
|
||||||
|
status_t ReadString(BString& string,
|
||||||
|
size_t* _length = NULL);
|
||||||
|
status_t ReadString(char** _string,
|
||||||
|
size_t* _length = NULL);
|
||||||
|
status_t ReadRegion(BRegion* region);
|
||||||
|
status_t ReadShape(BShape* shape);
|
||||||
|
status_t ReadGradient(BGradient** _gradient);
|
||||||
|
|
||||||
|
template <class Type>
|
||||||
|
status_t Read(Type* data);
|
||||||
|
|
||||||
protected:
|
// convenience methods
|
||||||
LinkSender *fSender;
|
|
||||||
LinkReceiver *fReceiver;
|
status_t FlushWithReply(int32& code);
|
||||||
|
LinkSender& Sender() { return *fSender; }
|
||||||
|
LinkReceiver& Receiver() { return *fReceiver; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LinkSender* fSender;
|
||||||
|
LinkReceiver* fReceiver;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// sender inline functions
|
// #pragma mark - sender inline functions
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
ServerLink::SetSenderPort(port_id port)
|
ServerLink::SetSenderPort(port_id port)
|
||||||
@@ -89,110 +101,129 @@ ServerLink::SetSenderPort(port_id port)
|
|||||||
fSender->SetPort(port);
|
fSender->SetPort(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline port_id
|
inline port_id
|
||||||
ServerLink::SenderPort()
|
ServerLink::SenderPort()
|
||||||
{
|
{
|
||||||
return fSender->Port();
|
return fSender->Port();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
ServerLink::StartMessage(int32 code, size_t minSize)
|
ServerLink::StartMessage(int32 code, size_t minSize)
|
||||||
{
|
{
|
||||||
return fSender->StartMessage(code, minSize);
|
return fSender->StartMessage(code, minSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
ServerLink::EndMessage()
|
ServerLink::EndMessage()
|
||||||
{
|
{
|
||||||
return fSender->EndMessage();
|
return fSender->EndMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
ServerLink::CancelMessage()
|
ServerLink::CancelMessage()
|
||||||
{
|
{
|
||||||
fSender->CancelMessage();
|
fSender->CancelMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
ServerLink::Flush(bigtime_t timeout, bool needsReply)
|
ServerLink::Flush(bigtime_t timeout, bool needsReply)
|
||||||
{
|
{
|
||||||
return fSender->Flush(timeout, needsReply);
|
return fSender->Flush(timeout, needsReply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
ServerLink::Attach(const void *data, ssize_t size)
|
ServerLink::Attach(const void* data, ssize_t size)
|
||||||
{
|
{
|
||||||
return fSender->Attach(data, size);
|
return fSender->Attach(data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
ServerLink::AttachString(const char *string, int32 length)
|
ServerLink::AttachString(const char* string, int32 length)
|
||||||
{
|
{
|
||||||
return fSender->AttachString(string, length);
|
return fSender->AttachString(string, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type> status_t
|
template<class Type> status_t
|
||||||
ServerLink::Attach(const Type &data)
|
ServerLink::Attach(const Type& data)
|
||||||
{
|
{
|
||||||
return Attach(&data, sizeof(Type));
|
return Attach(&data, sizeof(Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - receiver inline functions
|
// #pragma mark - receiver inline functions
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
ServerLink::SetReceiverPort(port_id port)
|
ServerLink::SetReceiverPort(port_id port)
|
||||||
{
|
{
|
||||||
fReceiver->SetPort(port);
|
fReceiver->SetPort(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline port_id
|
inline port_id
|
||||||
ServerLink::ReceiverPort()
|
ServerLink::ReceiverPort()
|
||||||
{
|
{
|
||||||
return fReceiver->Port();
|
return fReceiver->Port();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
ServerLink::GetNextMessage(int32 &code, bigtime_t timeout)
|
ServerLink::GetNextMessage(int32& code, bigtime_t timeout)
|
||||||
{
|
{
|
||||||
return fReceiver->GetNextMessage(code, timeout);
|
return fReceiver->GetNextMessage(code, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
ServerLink::NeedsReply() const
|
ServerLink::NeedsReply() const
|
||||||
{
|
{
|
||||||
return fReceiver->NeedsReply();
|
return fReceiver->NeedsReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
ServerLink::Read(void *data, ssize_t size)
|
ServerLink::Read(void* data, ssize_t size)
|
||||||
{
|
{
|
||||||
return fReceiver->Read(data, size);
|
return fReceiver->Read(data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
ServerLink::ReadString(char *buffer, size_t bufferSize)
|
ServerLink::ReadString(char* buffer, size_t bufferSize)
|
||||||
{
|
{
|
||||||
return fReceiver->ReadString(buffer, bufferSize);
|
return fReceiver->ReadString(buffer, bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
ServerLink::ReadString(BString& string, size_t* _length)
|
ServerLink::ReadString(BString& string, size_t* _length)
|
||||||
{
|
{
|
||||||
return fReceiver->ReadString(string, _length);
|
return fReceiver->ReadString(string, _length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
ServerLink::ReadString(char** _string, size_t* _length)
|
ServerLink::ReadString(char** _string, size_t* _length)
|
||||||
{
|
{
|
||||||
return fReceiver->ReadString(_string, _length);
|
return fReceiver->ReadString(_string, _length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Type> status_t
|
template <class Type> status_t
|
||||||
ServerLink::Read(Type *data)
|
ServerLink::Read(Type* data)
|
||||||
{
|
{
|
||||||
return Read(data, sizeof(Type));
|
return Read(data, sizeof(Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
#endif /* _SERVER_LINK_H */
|
#endif /* _SERVER_LINK_H */
|
||||||
|
|||||||
@@ -8,12 +8,17 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <AppMisc.h>
|
#include <AppMisc.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <ServerLink.h>
|
||||||
#include <sys/utsname.h>
|
#include <ServerProtocol.h>
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
@@ -158,4 +163,55 @@ is_app_showing_modal_window(team_id team)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
port_id
|
||||||
|
get_app_server_port()
|
||||||
|
{
|
||||||
|
static port_id sServerPort = -1;
|
||||||
|
|
||||||
|
if (sServerPort < 0) {
|
||||||
|
// No need for synchronization - in the worst case, we'll call
|
||||||
|
// find_port() twice.
|
||||||
|
sServerPort = find_port(SERVER_PORT_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sServerPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Creates a connection with the desktop.
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
create_desktop_connection(ServerLink* link, const char* name, int32 capacity)
|
||||||
|
{
|
||||||
|
port_id serverPort = get_app_server_port();
|
||||||
|
if (serverPort < 0)
|
||||||
|
return serverPort;
|
||||||
|
|
||||||
|
// Create the port so that the app_server knows where to send messages
|
||||||
|
port_id clientPort = create_port(capacity, name);
|
||||||
|
if (clientPort < 0)
|
||||||
|
return clientPort;
|
||||||
|
|
||||||
|
link->SetTo(serverPort, clientPort);
|
||||||
|
|
||||||
|
link->StartMessage(AS_GET_DESKTOP);
|
||||||
|
link->Attach<port_id>(clientPort);
|
||||||
|
link->Attach<int32>(getuid());
|
||||||
|
link->AttachString(getenv("TARGET_SCREEN"));
|
||||||
|
link->Attach<int32>(AS_PROTOCOL_VERSION);
|
||||||
|
|
||||||
|
int32 code;
|
||||||
|
if (link->FlushWithReply(code) != B_OK || code != B_OK) {
|
||||||
|
link->SetSenderPort(-1);
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
link->Read<port_id>(&serverPort);
|
||||||
|
link->SetSenderPort(serverPort);
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|||||||
@@ -1228,33 +1228,10 @@ BApplication::_InitGUIContext()
|
|||||||
status_t
|
status_t
|
||||||
BApplication::_ConnectToServer()
|
BApplication::_ConnectToServer()
|
||||||
{
|
{
|
||||||
port_id serverPort = find_port(SERVER_PORT_NAME);
|
status_t status
|
||||||
if (serverPort < B_OK)
|
= create_desktop_connection(fServerLink, "a<app_server", 100);
|
||||||
return serverPort;
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
// Create the port so that the app_server knows where to send messages
|
|
||||||
port_id clientPort = create_port(100, "a<app_server");
|
|
||||||
if (clientPort < B_OK)
|
|
||||||
return clientPort;
|
|
||||||
|
|
||||||
// We can't use AppServerLink because be_app == NULL
|
|
||||||
fServerLink->SetTo(serverPort, clientPort);
|
|
||||||
|
|
||||||
fServerLink->StartMessage(AS_GET_DESKTOP);
|
|
||||||
fServerLink->Attach<port_id>(clientPort);
|
|
||||||
fServerLink->Attach<int32>(getuid());
|
|
||||||
fServerLink->AttachString(getenv("TARGET_SCREEN"));
|
|
||||||
fServerLink->Attach<int32>(AS_PROTOCOL_VERSION);
|
|
||||||
|
|
||||||
int32 code;
|
|
||||||
if (fServerLink->FlushWithReply(code) != B_OK || code != B_OK) {
|
|
||||||
fServerLink->SetSenderPort(-1);
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we talk to the desktop to create our application
|
|
||||||
fServerLink->Read<port_id>(&serverPort);
|
|
||||||
fServerLink->SetSenderPort(serverPort);
|
|
||||||
|
|
||||||
// AS_CREATE_APP:
|
// AS_CREATE_APP:
|
||||||
//
|
//
|
||||||
@@ -1266,14 +1243,16 @@ BApplication::_ConnectToServer()
|
|||||||
// 5) char * - signature of the regular app
|
// 5) char * - signature of the regular app
|
||||||
|
|
||||||
fServerLink->StartMessage(AS_CREATE_APP);
|
fServerLink->StartMessage(AS_CREATE_APP);
|
||||||
fServerLink->Attach<port_id>(clientPort);
|
fServerLink->Attach<port_id>(fServerLink->ReceiverPort());
|
||||||
fServerLink->Attach<port_id>(_get_looper_port_(this));
|
fServerLink->Attach<port_id>(_get_looper_port_(this));
|
||||||
fServerLink->Attach<team_id>(Team());
|
fServerLink->Attach<team_id>(Team());
|
||||||
fServerLink->Attach<int32>(_get_object_token_(this));
|
fServerLink->Attach<int32>(_get_object_token_(this));
|
||||||
fServerLink->AttachString(fAppName);
|
fServerLink->AttachString(fAppName);
|
||||||
|
|
||||||
area_id sharedReadOnlyArea;
|
area_id sharedReadOnlyArea;
|
||||||
|
port_id serverPort;
|
||||||
|
|
||||||
|
int32 code;
|
||||||
if (fServerLink->FlushWithReply(code) == B_OK
|
if (fServerLink->FlushWithReply(code) == B_OK
|
||||||
&& code == B_OK) {
|
&& code == B_OK) {
|
||||||
// We don't need to contact the main app_server anymore
|
// We don't need to contact the main app_server anymore
|
||||||
@@ -1288,7 +1267,7 @@ BApplication::_ConnectToServer()
|
|||||||
|
|
||||||
fServerLink->SetSenderPort(serverPort);
|
fServerLink->SetSenderPort(serverPort);
|
||||||
|
|
||||||
status_t status = _SetupServerAllocator();
|
status = _SetupServerAllocator();
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,7 @@
|
|||||||
|
|
||||||
#include <DesktopLink.h>
|
#include <DesktopLink.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <AppMisc.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -19,48 +17,21 @@ namespace BPrivate {
|
|||||||
|
|
||||||
|
|
||||||
DesktopLink::DesktopLink()
|
DesktopLink::DesktopLink()
|
||||||
:
|
|
||||||
fReplyPort(B_ERROR)
|
|
||||||
{
|
{
|
||||||
// get the app server port
|
create_desktop_connection(this, "desktop reply", 1);
|
||||||
port_id port = find_port(SERVER_PORT_NAME);
|
|
||||||
if (port < B_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// create a reply port
|
|
||||||
fReplyPort = create_port(1, "desktop reply");
|
|
||||||
if (fReplyPort < B_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SetTo(port, fReplyPort);
|
|
||||||
|
|
||||||
// We can't use AppServerLink because be_app may be NULL
|
|
||||||
StartMessage(AS_GET_DESKTOP);
|
|
||||||
Attach<port_id>(fReplyPort);
|
|
||||||
Attach<int32>(getuid());
|
|
||||||
AttachString(getenv("TARGET_SCREEN"));
|
|
||||||
Attach<int32>(AS_PROTOCOL_VERSION);
|
|
||||||
|
|
||||||
int32 code;
|
|
||||||
if (FlushWithReply(code) != B_OK || code != B_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// we now talk to the desktop
|
|
||||||
Read<port_id>(&port);
|
|
||||||
SetSenderPort(port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DesktopLink::~DesktopLink()
|
DesktopLink::~DesktopLink()
|
||||||
{
|
{
|
||||||
delete_port(fReplyPort);
|
delete_port(fReceiver->Port());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DesktopLink::InitCheck() const
|
DesktopLink::InitCheck() const
|
||||||
{
|
{
|
||||||
return fReplyPort < B_OK ? fReplyPort : B_OK;
|
return fReceiver->Port() < B_OK ? fReceiver->Port() : B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005, Haiku Inc.
|
* Copyright 2005-2009, Haiku Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
PortLink::PortLink(port_id send, port_id receive)
|
PortLink::PortLink(port_id send, port_id receive)
|
||||||
{
|
{
|
||||||
fSender = new LinkSender(send);
|
fSender = new LinkSender(send);
|
||||||
@@ -26,11 +27,4 @@ PortLink::~PortLink()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PortLink::SetTo(port_id sender, port_id receiver)
|
|
||||||
{
|
|
||||||
fSender->SetPort(sender);
|
|
||||||
fReceiver->SetPort(receiver);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|||||||
+32
-17
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,11 +7,16 @@
|
|||||||
* Axel Dörfler, [email protected]
|
* Axel Dörfler, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Class for low-overhead port-based messaging */
|
|
||||||
|
/*! Class for low-overhead port-based messaging */
|
||||||
|
|
||||||
|
|
||||||
|
#include <ServerLink.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <Gradient.h>
|
#include <Gradient.h>
|
||||||
#include <GradientLinear.h>
|
#include <GradientLinear.h>
|
||||||
#include <GradientRadial.h>
|
#include <GradientRadial.h>
|
||||||
@@ -21,9 +26,9 @@
|
|||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
#include <Shape.h>
|
#include <Shape.h>
|
||||||
|
|
||||||
#include <ServerLink.h>
|
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
|
|
||||||
|
|
||||||
//#define TRACE_SERVER_LINK_GRADIENTS
|
//#define TRACE_SERVER_LINK_GRADIENTS
|
||||||
#ifdef TRACE_SERVER_LINK_GRADIENTS
|
#ifdef TRACE_SERVER_LINK_GRADIENTS
|
||||||
# include <OS.h>
|
# include <OS.h>
|
||||||
@@ -35,6 +40,7 @@
|
|||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
ServerLink::ServerLink()
|
ServerLink::ServerLink()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -45,8 +51,16 @@ ServerLink::~ServerLink()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerLink::SetTo(port_id sender, port_id receiver)
|
||||||
|
{
|
||||||
|
fSender->SetPort(sender);
|
||||||
|
fReceiver->SetPort(receiver);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ServerLink::ReadRegion(BRegion *region)
|
ServerLink::ReadRegion(BRegion* region)
|
||||||
{
|
{
|
||||||
fReceiver->Read(®ion->fCount, sizeof(long));
|
fReceiver->Read(®ion->fCount, sizeof(long));
|
||||||
if (region->fCount > 0) {
|
if (region->fCount > 0) {
|
||||||
@@ -55,28 +69,28 @@ ServerLink::ReadRegion(BRegion *region)
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
return fReceiver->Read(region->fData,
|
return fReceiver->Read(region->fData,
|
||||||
region->fCount * sizeof(clipping_rect));
|
region->fCount * sizeof(clipping_rect));
|
||||||
} else {
|
|
||||||
return fReceiver->Read(®ion->fBounds, sizeof(clipping_rect));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fReceiver->Read(®ion->fBounds, sizeof(clipping_rect));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ServerLink::AttachRegion(const BRegion ®ion)
|
ServerLink::AttachRegion(const BRegion& region)
|
||||||
{
|
{
|
||||||
fSender->Attach(®ion.fCount, sizeof(long));
|
fSender->Attach(®ion.fCount, sizeof(long));
|
||||||
if (region.fCount > 0) {
|
if (region.fCount > 0) {
|
||||||
fSender->Attach(®ion.fBounds, sizeof(clipping_rect));
|
fSender->Attach(®ion.fBounds, sizeof(clipping_rect));
|
||||||
return fSender->Attach(region.fData,
|
return fSender->Attach(region.fData,
|
||||||
region.fCount * sizeof(clipping_rect));
|
region.fCount * sizeof(clipping_rect));
|
||||||
} else {
|
|
||||||
return fSender->Attach(®ion.fBounds, sizeof(clipping_rect));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fSender->Attach(®ion.fBounds, sizeof(clipping_rect));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ServerLink::ReadShape(BShape *shape)
|
ServerLink::ReadShape(BShape* shape)
|
||||||
{
|
{
|
||||||
int32 opCount, ptCount;
|
int32 opCount, ptCount;
|
||||||
fReceiver->Read(&opCount, sizeof(int32));
|
fReceiver->Read(&opCount, sizeof(int32));
|
||||||
@@ -96,11 +110,11 @@ ServerLink::ReadShape(BShape *shape)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ServerLink::AttachShape(BShape &shape)
|
ServerLink::AttachShape(BShape& shape)
|
||||||
{
|
{
|
||||||
int32 opCount, ptCount;
|
int32 opCount, ptCount;
|
||||||
uint32 *opList;
|
uint32* opList;
|
||||||
BPoint *ptList;
|
BPoint* ptList;
|
||||||
|
|
||||||
shape.GetData(&opCount, &ptCount, &opList, &ptList);
|
shape.GetData(&opCount, &ptCount, &opList, &ptList);
|
||||||
|
|
||||||
@@ -115,15 +129,15 @@ ServerLink::AttachShape(BShape &shape)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ServerLink::ReadGradient(BGradient **gradient)
|
ServerLink::ReadGradient(BGradient** _gradient)
|
||||||
{
|
{
|
||||||
GTRACE(("ServerLink::ReadGradient\n"));
|
GTRACE(("ServerLink::ReadGradient\n"));
|
||||||
return fReceiver->ReadGradient(gradient);
|
return fReceiver->ReadGradient(_gradient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ServerLink::AttachGradient(const BGradient &gradient)
|
ServerLink::AttachGradient(const BGradient& gradient)
|
||||||
{
|
{
|
||||||
GTRACE(("ServerLink::AttachGradient\n"));
|
GTRACE(("ServerLink::AttachGradient\n"));
|
||||||
BGradient::Type gradientType = gradient.GetType();
|
BGradient::Type gradientType = gradient.GetType();
|
||||||
@@ -196,7 +210,7 @@ ServerLink::AttachGradient(const BGradient &gradient)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ServerLink::FlushWithReply(int32 &code)
|
ServerLink::FlushWithReply(int32& code)
|
||||||
{
|
{
|
||||||
status_t status = Flush(B_INFINITE_TIMEOUT, true);
|
status_t status = Flush(B_INFINITE_TIMEOUT, true);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
@@ -205,4 +219,5 @@ ServerLink::FlushWithReply(int32 &code)
|
|||||||
return GetNextMessage(code);
|
return GetNextMessage(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|||||||
Reference in New Issue
Block a user