* 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 {
|
||||
|
||||
class ServerLink;
|
||||
|
||||
|
||||
status_t get_app_path(team_id team, char *buffer);
|
||||
status_t get_app_path(char *buffer);
|
||||
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);
|
||||
|
||||
port_id get_app_server_port();
|
||||
status_t create_desktop_connection(ServerLink* link, const char* name,
|
||||
int32 capacity);
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
// _get_object_token_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku.
|
||||
* Copyright 2006-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -15,14 +15,11 @@
|
||||
namespace BPrivate {
|
||||
|
||||
class DesktopLink : public PortLink {
|
||||
public:
|
||||
DesktopLink();
|
||||
virtual ~DesktopLink();
|
||||
public:
|
||||
DesktopLink();
|
||||
virtual ~DesktopLink();
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
private:
|
||||
port_id fReplyPort;
|
||||
status_t InitCheck() const;
|
||||
};
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005, Haiku.
|
||||
* Copyright 2005-2009, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -14,14 +14,15 @@
|
||||
|
||||
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
|
||||
|
||||
#endif /* _PORT_LINK_H */
|
||||
|
||||
@@ -32,56 +32,68 @@ class BGradient;
|
||||
namespace BPrivate {
|
||||
|
||||
class ServerLink {
|
||||
public:
|
||||
ServerLink();
|
||||
virtual ~ServerLink();
|
||||
public:
|
||||
ServerLink();
|
||||
virtual ~ServerLink();
|
||||
|
||||
// send methods
|
||||
void SetTo(port_id sender, port_id receiver);
|
||||
|
||||
void SetSenderPort(port_id port);
|
||||
port_id SenderPort();
|
||||
// send methods
|
||||
|
||||
status_t StartMessage(int32 code, size_t minSize = 0);
|
||||
void CancelMessage();
|
||||
status_t EndMessage();
|
||||
void SetSenderPort(port_id port);
|
||||
port_id SenderPort();
|
||||
|
||||
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 ®ion);
|
||||
status_t AttachShape(BShape &shape);
|
||||
status_t AttachGradient(const BGradient &gradient);
|
||||
template <class Type> status_t Attach(const Type& data);
|
||||
status_t StartMessage(int32 code, size_t minSize = 0);
|
||||
void CancelMessage();
|
||||
status_t EndMessage();
|
||||
|
||||
// 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);
|
||||
port_id ReceiverPort();
|
||||
template <class Type>
|
||||
status_t Attach(const Type& data);
|
||||
|
||||
status_t GetNextMessage(int32 &code, bigtime_t timeout = B_INFINITE_TIMEOUT);
|
||||
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);
|
||||
// receive methods
|
||||
|
||||
// convenience methods
|
||||
void SetReceiverPort(port_id port);
|
||||
port_id ReceiverPort();
|
||||
|
||||
status_t FlushWithReply(int32 &code);
|
||||
LinkSender &Sender() { return *fSender; }
|
||||
LinkReceiver &Receiver() { return *fReceiver; }
|
||||
status_t GetNextMessage(int32& code,
|
||||
bigtime_t timeout = B_INFINITE_TIMEOUT);
|
||||
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:
|
||||
LinkSender *fSender;
|
||||
LinkReceiver *fReceiver;
|
||||
// convenience methods
|
||||
|
||||
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
|
||||
ServerLink::SetSenderPort(port_id port)
|
||||
@@ -89,110 +101,129 @@ ServerLink::SetSenderPort(port_id port)
|
||||
fSender->SetPort(port);
|
||||
}
|
||||
|
||||
|
||||
inline port_id
|
||||
ServerLink::SenderPort()
|
||||
{
|
||||
return fSender->Port();
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
ServerLink::StartMessage(int32 code, size_t minSize)
|
||||
{
|
||||
return fSender->StartMessage(code, minSize);
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
ServerLink::EndMessage()
|
||||
{
|
||||
return fSender->EndMessage();
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
ServerLink::CancelMessage()
|
||||
{
|
||||
fSender->CancelMessage();
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
ServerLink::Flush(bigtime_t timeout, bool needsReply)
|
||||
{
|
||||
return fSender->Flush(timeout, needsReply);
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
ServerLink::Attach(const void *data, ssize_t size)
|
||||
ServerLink::Attach(const void* data, ssize_t size)
|
||||
{
|
||||
return fSender->Attach(data, size);
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
ServerLink::AttachString(const char *string, int32 length)
|
||||
ServerLink::AttachString(const char* string, int32 length)
|
||||
{
|
||||
return fSender->AttachString(string, length);
|
||||
}
|
||||
|
||||
|
||||
template<class Type> status_t
|
||||
ServerLink::Attach(const Type &data)
|
||||
ServerLink::Attach(const Type& data)
|
||||
{
|
||||
return Attach(&data, sizeof(Type));
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - receiver inline functions
|
||||
|
||||
|
||||
inline void
|
||||
ServerLink::SetReceiverPort(port_id port)
|
||||
{
|
||||
fReceiver->SetPort(port);
|
||||
}
|
||||
|
||||
|
||||
inline port_id
|
||||
ServerLink::ReceiverPort()
|
||||
{
|
||||
return fReceiver->Port();
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
ServerLink::GetNextMessage(int32 &code, bigtime_t timeout)
|
||||
ServerLink::GetNextMessage(int32& code, bigtime_t timeout)
|
||||
{
|
||||
return fReceiver->GetNextMessage(code, timeout);
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
ServerLink::NeedsReply() const
|
||||
{
|
||||
return fReceiver->NeedsReply();
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
ServerLink::Read(void *data, ssize_t size)
|
||||
ServerLink::Read(void* data, ssize_t size)
|
||||
{
|
||||
return fReceiver->Read(data, size);
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
ServerLink::ReadString(char *buffer, size_t bufferSize)
|
||||
ServerLink::ReadString(char* buffer, size_t bufferSize)
|
||||
{
|
||||
return fReceiver->ReadString(buffer, bufferSize);
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
ServerLink::ReadString(BString& string, size_t* _length)
|
||||
{
|
||||
return fReceiver->ReadString(string, _length);
|
||||
}
|
||||
|
||||
|
||||
inline status_t
|
||||
ServerLink::ReadString(char** _string, size_t* _length)
|
||||
{
|
||||
return fReceiver->ReadString(_string, _length);
|
||||
}
|
||||
|
||||
|
||||
template <class Type> status_t
|
||||
ServerLink::Read(Type *data)
|
||||
ServerLink::Read(Type* data)
|
||||
{
|
||||
return Read(data, sizeof(Type));
|
||||
}
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
#endif /* _SERVER_LINK_H */
|
||||
|
||||
Reference in New Issue
Block a user