DBus-1-TQt 1.0
|
#include <tqdbusmessage.h>
Public Types | |
enum | { DefaultTimeout = -1 , NoTimeout = INT_MAX } |
enum | MessageType { InvalidMessage , MethodCallMessage , ReplyMessage , ErrorMessage , SignalMessage } |
Public Member Functions | |
TQT_DBusMessage () | |
TQT_DBusMessage (const TQT_DBusMessage &other) | |
~TQT_DBusMessage () | |
TQT_DBusMessage & | operator= (const TQT_DBusMessage &other) |
TQString | path () const |
TQString | interface () const |
TQString | member () const |
TQString | sender () const |
TQT_DBusError | error () const |
MessageType | type () const |
int | timeout () const |
void | setTimeout (int ms) |
int | serialNumber () const |
int | replySerialNumber () const |
DBusMessage * | toDBusMessage () const |
Static Public Member Functions | |
static TQT_DBusMessage | signal (const TQString &path, const TQString &interface, const TQString &member) |
static TQT_DBusMessage | methodCall (const TQString &service, const TQString &path, const TQString &interface, const TQString &method) |
static TQT_DBusMessage | methodReply (const TQT_DBusMessage &other) |
static TQT_DBusMessage | methodError (const TQT_DBusMessage &other, const TQT_DBusError &error) |
static TQT_DBusMessage | fromDBusMessage (DBusMessage *dmsg) |
Private Attributes | |
TQT_DBusMessagePrivate * | d |
Friends | |
class | TQT_DBusConnection |
A message converts and transports data over D-Bus.
A TQT_DBusMessage is implicitly shared, similar to a TQString, i.e. copying a message creates just a shallow copy.
The TQT_DBusMessage is the TQt3 bindings means of encapsulating data for a method call, a method reply or an error.
Data specifying the sender and receipient is directly accessible through getter methods, while data, e.g. method parameters or return values, are managed as a list of TQT_DBusData.
To create a message suitable for sending use one of the static factory methods:
Message sending is achieved through TQT_DBusConnection
Example:
A service returning such a reply would do something like this
Definition at line 115 of file tqdbusmessage.h.
anonymous enum |
Anonymous enum for timeout constants.
Enumerator | |
---|---|
DefaultTimeout | Use whatever D-Bus has as default timeout |
NoTimeout | Use no timeout at all, i.e. wait as long as necessary |
Definition at line 125 of file tqdbusmessage.h.
D-Bus message types.
A message of a specific type can be created using the respective factory method. A message created by the default constructor becomes an InvalidMessage
Enumerator | |
---|---|
InvalidMessage | An invalid message cannot be sent over D-Bus. This type serves for initializing message variables without requiring a "real" message |
MethodCallMessage | A message for doing method calls on remote service objects
|
ReplyMessage | A message for replying to a method call in case of success
|
ErrorMessage | A message for replying to a method call in case of failure
|
SignalMessage | A message for emitting D-Bus signals
|
Definition at line 151 of file tqdbusmessage.h.
TQT_DBusMessage::TQT_DBusMessage | ( | ) |
Creates an empty and invalid message.
To create a message suitable for sending through D-Bus see the factory methods signal(), methodCall(), methodReply() and methodError()
Definition at line 104 of file tqdbusmessage.cpp.
References d.
TQT_DBusMessage::TQT_DBusMessage | ( | const TQT_DBusMessage & | other | ) |
Creates a shallow copy of the given message.
This instance will become a handle to the same message data the other message is using, including MessageType
other | the message to copy |
Definition at line 109 of file tqdbusmessage.cpp.
References d, Atomic::ref(), and TQT_DBusMessagePrivate::ref.
TQT_DBusMessage::~TQT_DBusMessage | ( | ) |
Destroys a message.
If this message handle is the last one using this respective message content, the message content will be deleted as well
Definition at line 116 of file tqdbusmessage.cpp.
References d, Atomic::deref(), and TQT_DBusMessagePrivate::ref.
TQT_DBusError TQT_DBusMessage::error | ( | ) | const |
Returns the error of an error message.
If this message is of type ErrorMessage, this method can be used to retrieve the respective error object
Definition at line 207 of file tqdbusmessage.cpp.
References d, and TQT_DBusMessagePrivate::error.
|
static |
Creates a TQt3-bindings message from the given raw D-Bus message.
De-marshalls data contained in the message to a list of TQT_DBusData.
dmsg | a C API D-Bus message |
0
or if de-marshalling failed Definition at line 162 of file tqdbusmessage.cpp.
References d, TQT_DBusMessagePrivate::error, TQT_DBusMessagePrivate::interface, TQT_DBusMessagePrivate::member, TQT_DBusMarshall::messageToList(), TQT_DBusMessagePrivate::msg, TQT_DBusMessagePrivate::path, TQT_DBusMessagePrivate::sender, and TQT_DBusMessagePrivate::type.
TQString TQT_DBusMessage::interface | ( | ) | const |
Returns the message's interface name.
See section Interface names for details.
The context of the interface name depends on the message type:
TQString()
Definition at line 192 of file tqdbusmessage.cpp.
References d, and TQT_DBusMessagePrivate::interface.
TQString TQT_DBusMessage::member | ( | ) | const |
Returns the message's member name.
See section Method and signal names for details.
The context of the member name depends on the message type:
TQString()
Definition at line 197 of file tqdbusmessage.cpp.
References d, and TQT_DBusMessagePrivate::member.
|
static |
Creates a message for sending a D-Bus method call.
Invoking a method over D-Bus requires a message of type MethodCallMessage as well as the information where it should be sent to, e.g which interface of which object in which service. See Naming and syntax conventions in D-Bus for recommendations on those parameters.
service | the D-Bus name of the application hosting the service object |
path | the object path of the service object |
interface | the object's interface to which the method belongs |
method | the method's name |
Definition at line 62 of file tqdbusmessage.cpp.
References d, interface(), TQT_DBusMessagePrivate::interface, TQT_DBusMessagePrivate::member, path(), TQT_DBusMessagePrivate::path, TQT_DBusMessagePrivate::service, and TQT_DBusMessagePrivate::type.
|
static |
Creates a message for replying to a D-Bus method call.
Replying to a D-Bus method call in the case of failure requires a message of type ErrorMessage as well as the information to which method call it is replying to and which error occured.
other | the method call message it is replying to |
error | the error which occured during during the method call |
Definition at line 86 of file tqdbusmessage.cpp.
References d, error(), TQT_DBusMessagePrivate::error, TQT_DBusError::isValid(), TQT_DBusMessagePrivate::msg, TQT_DBusMessagePrivate::reply, and TQT_DBusMessagePrivate::type.
|
static |
Creates a message for replying to a D-Bus method call.
Replying to a D-Bus method call in the case of success requires a message of type ReplyMessage as well as the information to which method call it is replying to.
other | the method call message it is replying to |
Definition at line 75 of file tqdbusmessage.cpp.
References d, TQT_DBusMessagePrivate::msg, TQT_DBusMessagePrivate::reply, and TQT_DBusMessagePrivate::type.
TQT_DBusMessage & TQT_DBusMessage::operator= | ( | const TQT_DBusMessage & | other | ) |
Creates a shallow copy of the given message.
This instance will become a handle to the same message data the other message is usingm including MessageType
Any content used in this instance will be deleted if this instance was the last handle using that content
other | the message to copy |
Definition at line 122 of file tqdbusmessage.cpp.
References d, Atomic::deref(), Atomic::ref(), and TQT_DBusMessagePrivate::ref.
TQString TQT_DBusMessage::path | ( | ) | const |
Returns the message's object path.
See section Object paths for details.
The context of the object path depends on the message type:
TQString()
Definition at line 187 of file tqdbusmessage.cpp.
References d, and TQT_DBusMessagePrivate::path.
int TQT_DBusMessage::replySerialNumber | ( | ) | const |
Returns the message's reply serial number.
The reply serial number is the serial number of the method call message this message is a reply to.
If this is neither a message of type ReplyMessage or ErrorMessage, the returned value will be 0
It can be used to associate a reply or error message with a method call message.
0
if this message is not a reply messageReturns the unique serial number assigned to the message that triggered this reply message.
If this message is not a reply to another message, 0 is returned.
Definition at line 241 of file tqdbusmessage.cpp.
References d, and TQT_DBusMessagePrivate::msg.
TQString TQT_DBusMessage::sender | ( | ) | const |
Returns the name of the message sender.
The message sender name or address used on the D-Bus message bus to refer to the application which sent this message.
See section Service names for details.
This can either be a unique name as handed out by the bus, see TQT_DBusConnection::uniqueName() or a name registered with TQT_DBusConnection::requestName()
TQString()
Definition at line 202 of file tqdbusmessage.cpp.
References d, and TQT_DBusMessagePrivate::sender.
int TQT_DBusMessage::serialNumber | ( | ) | const |
Returns the message's serial number.
The serial number is some kind of short term identifier for messages travelling the same connection.
It can be used to associate a reply or error message with a method call message.
0
if the message hasn't been send yetsReturns the unique serial number assigned to this message or 0 if the message was not sent yet.
Definition at line 226 of file tqdbusmessage.cpp.
References d, and TQT_DBusMessagePrivate::msg.
void TQT_DBusMessage::setTimeout | ( | int | ms | ) |
Sets the message's timeout.
The timeout is the number of milliseconds the D-Bus connection will wait for the reply of an asynchronous call.
If no reply is received in time, an error message will be delivered to the asynchronous reply receiver.
If no timeout is set explicitly, DefaultTimeout is assumed, which is usually the best option
ms | timeout in milliseconds |
Definition at line 217 of file tqdbusmessage.cpp.
References d, and TQT_DBusMessagePrivate::timeout.
|
static |
Creates a message for sending a D-Bus signal.
Sending/emitting a signal over D-Bus requires a message of type SignalMessage as well as the information where it is coming from, i.e. which interface of which object is sending it. See Naming and syntax conventions in D-Bus for recommendations on those parameters.
path | the object path of the service object |
interface | the object's interface to which the signal belongs |
member | the signal's name |
Definition at line 50 of file tqdbusmessage.cpp.
References d, interface(), TQT_DBusMessagePrivate::interface, member(), TQT_DBusMessagePrivate::member, path(), TQT_DBusMessagePrivate::path, and TQT_DBusMessagePrivate::type.
int TQT_DBusMessage::timeout | ( | ) | const |
Returns the message's timeout.
Definition at line 212 of file tqdbusmessage.cpp.
References d, and TQT_DBusMessagePrivate::timeout.
DBusMessage * TQT_DBusMessage::toDBusMessage | ( | ) | const |
Creates a raw D-Bus message from this TQt3-bindings message.
Marshalls data contained in the message's value list into D-Bus data format and creates a low level API D-Bus message for it.
0
if this is an InvalidMessage or marshalling failed Definition at line 134 of file tqdbusmessage.cpp.
References d, TQT_DBusMessagePrivate::error, TQT_DBusMessagePrivate::interface, TQT_DBusMarshall::listToMessage(), TQT_DBusMessagePrivate::member, TQT_DBusError::message(), TQT_DBusError::name(), TQT_DBusMessagePrivate::path, TQT_DBusMessagePrivate::reply, TQT_DBusMessagePrivate::service, and TQT_DBusMessagePrivate::type.
TQT_DBusMessage::MessageType TQT_DBusMessage::type | ( | ) | const |
Returns which kind of message this is.
Definition at line 248 of file tqdbusmessage.cpp.
References d, ErrorMessage, InvalidMessage, MethodCallMessage, ReplyMessage, SignalMessage, and TQT_DBusMessagePrivate::type.
|
friend |
Definition at line 117 of file tqdbusmessage.h.
|
private |
Definition at line 510 of file tqdbusmessage.h.