Top |
GDBusConnection * | dbus-connection | Read / Write / Construct Only |
TpClientFactory * | factory | Read / Write / Construct Only |
gchar * | name | Read / Write / Construct Only |
gboolean | uniquify-name | Read / Write / Construct Only |
GObject ╰── TpBaseClient ├── TpSimpleApprover ├── TpSimpleHandler ╰── TpSimpleObserver
TpBaseClient implements TpSvcClient, TpSvcClientObserver, TpSvcClientApprover, TpSvcClientHandler and TpSvcClientInterfaceRequests.
This base class makes it easier to write TpSvcClient implementations. Subclasses should usually pass the filters they want and override the D-Bus methods they implement.
For many applications, the provided TpSimpleObserver, TpSimpleApprover and TpSimpleHandler subclasses can be used instead of deriving from this class.
void tp_base_client_add_observer_filter_variant (TpBaseClient *self
,GVariant *filter
);
Register a new channel class as Observer.ObserverChannelFilter.
The TpBaseClientClass.observe_channel virtual method will be called
whenever a new channel's properties match the ones in filter
.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.observe_channel.
If the variant is floating (see g_variant_ref_sink()
), ownership
will be taken, allowing for uses like this:
1 2 3 4 5 |
tp_base_client_add_observer_filter_variant (client, g_variant_new_parsed ("{ %s: <%s>, %s: <%u>, ... }", TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_TEXT, TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, (guint32) TP_ENTITY_TYPE_CONTACT, ...)); |
Since 0.19.10
void tp_base_client_add_observer_filter (TpBaseClient *self
,TpChannelFilter *filter
);
Register a new filter to match channels as an Observer.
The TpBaseClientClass.observe_channel virtual method will be called
whenever a new channel's properties match the ones in filter
.
This method can be called more than once. If it is, the client will be an Observer for any channel that matches any of the filters. For instance, this Client:
1 2 3 4 5 6 7 8 9 |
filter = tp_channel_filter_new_for_text_chats (); tp_base_client_add_observer_filter (client, filter); g_object_unref (filter); filter = tp_channel_filter_new_for_file_transfer (NULL); tp_channel_filter_require_target_is_contact (filter); tp_channel_filter_require_requested (filter, FALSE); tp_base_client_add_observer_filter (client, filter); g_object_unref (filter); |
will be notified about all Text channels, and also about 1-1 incoming Call channels.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.observe_channel.
Since 0.99.8
void tp_base_client_take_observer_filter (TpBaseClient *self
,TpChannelFilter *filter
);
The same as tp_base_client_add_observer_filter()
, but also
takes ownership of the filter. This makes it more convenient to call
in simple situations:
1 2 |
tp_base_client_take_observer_filter (client, tp_channel_filter_new_for_text_chats ()); |
Since 0.99.8
void tp_base_client_set_observer_recover (TpBaseClient *self
,gboolean recover
);
Set whether the channel dispatcher should attempt to recover this Observer if it crashes. (This is implemented by setting the value of its Recover D-Bus property.)
Normally, Observers are only notified when new channels
appear. If an Observer is set to recover, when it registers with
tp_base_client_register()
, it will also be told about any channels
that already existed before it started.
For Observers that are activatable as a D-Bus service, if the Observer exits or crashes while there are any channels that match its filter, it will automatically be restarted by service-activation.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.observe_channel.
Since 0.11.5
void tp_base_client_set_observer_delay_approvers (TpBaseClient *self
,gboolean delay
);
Set whether the channel dispatcher should wait for
tp_observe_channel_context_accept()
or tp_observe_channel_context_fail()
to be called before calling
TpBaseClientClass.add_dispatch_operation on appropriate Approvers.
This is implemented by setting the value of the DelayApprovers D-Bus property.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.observe_channel.
Since 0.13.16
void (*TpBaseClientClassObserveChannelImpl) (TpBaseClient *client
,TpAccount *account
,TpConnection *connection
,TpChannel *channel
,TpChannelDispatchOperation *dispatch_operation
,GList *requests
,TpObserveChannelContext *context
);
Signature of the implementation of the ObserveChannel method.
This function must call either tp_observe_channel_context_accept()
,
tp_observe_channel_context_delay()
or tp_observe_channel_context_fail()
on context
before it returns.
client |
a TpBaseClient instance |
|
account |
a TpAccount with |
|
connection |
a TpConnection with |
|
channel |
a TpChannel, with |
|
dispatch_operation |
a TpChannelDispatchOperation or |
[allow-none] |
requests |
a GList of TpChannelRequest having their object-path defined but are not guaranteed to be prepared. |
[element-type TelepathyGLib.ChannelRequest] |
context |
a TpObserveChannelContext representing the context of this D-Bus call |
void tp_base_client_implement_observe_channel (TpBaseClientClass *klass
,TpBaseClientClassObserveChannelImpl impl
);
Called by subclasses to define the actual implementation of the
ObserveChannel()
D-Bus method.
This is exactly equivalent to setting the TpBaseClientClass.observe_channel function pointer.
klass |
the TpBaseClientClass of the object |
|
impl |
the TpBaseClientClassObserveChannelImpl function implementing
|
Since 0.11.5
void tp_base_client_add_approver_filter_variant (TpBaseClient *self
,GVariant *filter
);
Register a new channel class as Approver.ApproverChannelFilter.
The TpBaseClientClass.add_dispatch_operation virtual method will be called
whenever a new channel's properties match the ones in filter
.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.add_dispatch_operation.
If the variant is floating (see g_variant_ref_sink()
), ownership
will be taken. See tp_base_client_add_observer_filter_variant()
for
more details.
Since 0.19.10
void tp_base_client_add_approver_filter (TpBaseClient *self
,TpChannelFilter *filter
);
Register a new filter to match channels as an Approver.
The TpBaseClientClass.add_dispatch_operation virtual method will be called
whenever a new channel's properties match the ones in filter
.
This method can be called more than once. If it is, the client will
be an Approver for any channel that matches any of the filters.
See tp_base_client_add_observer_filter()
.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.add_dispatch_operation.
Since 0.99.8
void tp_base_client_take_approver_filter (TpBaseClient *self
,TpChannelFilter *filter
);
The same as tp_base_client_add_approver_filter()
, but also
takes ownership of the filter. This makes it more convenient to call
in simple situations:
1 2 |
tp_base_client_take_approver_filter (client, tp_channel_filter_new_for_text_chats ()); |
Since 0.99.8
void (*TpBaseClientClassAddDispatchOperationImpl) (TpBaseClient *client
,TpAccount *account
,TpConnection *connection
,TpChannel *channel
,TpChannelDispatchOperation *dispatch_operation
,TpAddDispatchOperationContext *context
);
Signature of the implementation of the AddDispatchOperation method.
This function must call either tp_add_dispatch_operation_context_accept()
,
tp_add_dispatch_operation_context_delay()
or
tp_add_dispatch_operation_context_fail()
on context
before it returns.
The implementation can then use
tp_channel_dispatch_operation_handle_with_async()
to approve handling of the
channels, or tp_channel_dispatch_operation_claim_async()
to take
responsibility for handling or closing them".
client |
a TpBaseClient instance |
|
account |
a TpAccount with |
|
connection |
a TpConnection with |
|
channel |
a TpChannel with |
|
dispatch_operation |
a TpChannelDispatchOperation having
|
|
context |
a TpObserveChannelContext representing the context of this D-Bus call |
Since 0.11.5
void tp_base_client_implement_add_dispatch_operation (TpBaseClientClass *klass
,TpBaseClientClassAddDispatchOperationImpl impl
);
Called by subclasses to define the actual implementation of the
AddDispatchOperation()
D-Bus method.
Since 0.11.13 this is exactly equivalent to setting the TpBaseClientClass.add_dispatch_operation function pointer.
klass |
the TpBaseClientClass of the object |
|
impl |
the TpBaseClientClassAddDispatchOperationImpl function implementing
|
Since 0.11.5
void tp_base_client_add_handler_capabilities (TpBaseClient *self
,const gchar * const *tokens
);
Add several capability tokens to this client. These are used to signal that Telepathy connection managers should advertise certain capabilities to other contacts, such as the ability to receive audio/video calls using particular streaming protocols and codecs.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.handle_channel.
self |
a client, which must not have been registered with
|
|
tokens |
capability tokens as defined by the Telepathy D-Bus API Specification. |
[array zero-terminated=1][element-type utf8] |
Since 0.11.6
void tp_base_client_add_handler_capabilities_varargs (TpBaseClient *self
,const gchar *first_token
,...
);
Convenience C API equivalent to calling
tp_base_client_add_handler_capability()
for each capability token.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.handle_channel.
self |
a client, which must not have been registered with
|
|
first_token |
a capability token from the Telepathy D-Bus API Specification |
|
... |
more tokens, ending with |
Since 0.11.6
void tp_base_client_add_handler_capability (TpBaseClient *self
,const gchar *token
);
Add one capability token to this client, as if via
tp_base_client_add_handler_capabilities()
.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.handle_channel.
self |
a client, which must not have been registered with
|
|
token |
a capability token as defined by the Telepathy D-Bus API Specification |
Since 0.11.6
void tp_base_client_add_handler_filter_variant (TpBaseClient *self
,GVariant *filter
);
Register a new channel class as Handler.HandlerChannelFilter.
The TpBaseClientClass.handle_channel virtual method will be called
whenever a new channel's properties match the ones in filter
.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.handle_channel.
If the variant is floating (see g_variant_ref_sink()
), ownership
will be taken. See tp_base_client_add_observer_filter_variant()
for
more details.
Since 0.19.10
void tp_base_client_add_handler_filter (TpBaseClient *self
,TpChannelFilter *filter
);
Register a new filter to match channels as a Handler.
The TpBaseClientClass.handle_channel virtual method will be called
whenever a new channel's properties match the ones in filter
.
This method can be called more than once. If it is, the client will
be a Handler for any channel that matches any of the filters.
See tp_base_client_add_observer_filter()
.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.handle_channel.
Since 0.99.8
void tp_base_client_take_handler_filter (TpBaseClient *self
,TpChannelFilter *filter
);
The same as tp_base_client_add_handler_filter()
, but also
takes ownership of the filter. This makes it more convenient to call
in simple situations:
1 2 |
tp_base_client_take_handler_filter (client, tp_channel_filter_new_for_text_chats ()); |
Since 0.99.8
void
tp_base_client_be_a_handler (TpBaseClient *self
);
Register self
as a Client.Handler with an empty list of filters.
This is useful if you want to create a client that only handle channels
for which it's the PreferredHandler.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.handle_channel.
Since 0.11.6
void (*TpBaseClientClassHandleChannelImpl) (TpBaseClient *client
,TpAccount *account
,TpConnection *connection
,TpChannel *channel
,GList *requests_satisfied
,gint64 user_action_time
,TpHandleChannelContext *context
);
Signature of the implementation of the HandleChannel method.
This function must call either tp_handle_channel_context_accept()
,
tp_handle_channel_context_delay()
or tp_handle_channel_context_fail()
on context
before it returns.
client |
a TpBaseClient instance |
|
account |
a TpAccount with |
|
connection |
a TpConnection with |
|
channel |
a TpChannel, with |
|
requests_satisfied |
a GList of TpChannelRequest having their object-path defined but are not guaranteed to be prepared. |
[element-type TelepathyGLib.ChannelRequest] |
user_action_time |
the time at which user action occurred, or one of the
special values |
|
context |
a TpHandleChannelContext representing the context of this D-Bus call |
Since 0.11.6
void tp_base_client_implement_handle_channel (TpBaseClientClass *klass
,TpBaseClientClassHandleChannelImpl impl
);
Called by subclasses to define the actual implementation of the
HandleChannel()
D-Bus method.
Since 0.11.13 this is exactly equivalent to setting the TpBaseClientClass.handle_channel function pointer.
klass |
the TpBaseClientClass of the object |
|
impl |
the TpBaseClientClassHandleChannelImpl function implementing
|
GList *
tp_base_client_dup_handled_channels (TpBaseClient *self
);
Returns the set of channels currently handled by this base client or by any other TpBaseClient with which it shares a unique name.
Since 0.19.9
gboolean tp_base_client_is_handling_channel (TpBaseClient *self
,TpChannel *channel
);
Check if self
is currently handling channel
.
Since 0.14.5
void tp_base_client_delegate_channels_async (TpBaseClient *self
,GList *channels
,gint64 user_action_time
,const gchar *preferred_handler
,GAsyncReadyCallback callback
,gpointer user_data
);
Asynchronously calls DelegateChannels on the ChannelDispatcher to try
stopping handling channels
and pass them to another Handler.
You can then call tp_base_client_delegate_channels_finish()
to
get the result of the operation.
self |
||
channels |
[element-type TelepathyGLib.Channel] | |
user_action_time |
the time at which user action occurred, or TP_USER_ACTION_TIME_NOT_USER_ACTION if this delegation request is for some reason not involving user action. |
|
preferred_handler |
Either the well-known bus name (starting with
|
|
callback |
a callback to call when the request is satisfied |
|
user_data |
data to pass to |
Since 0.15.0
gboolean tp_base_client_delegate_channels_finish (TpBaseClient *self
,GAsyncResult *result
,GPtrArray **delegated
,GHashTable **not_delegated
,GError **error
);
Finishes an async channels delegation request started using
tp_base_client_delegate_channels_async()
.
self |
||
result |
||
delegated |
if not |
[out][element-type TelepathyGLib.Channel][transfer container] |
not_delegated |
if not not |
[out][element-type TelepathyGLib.Channel GLib.Error][transfer container] |
error |
a GError to fill |
TRUE
if the operation succeed, delegated
and not_delegated
can be used to know the channels that self
is not handling any more,
otherwise FALSE
.
Since 0.15.0
void (*TpBaseClientDelegatedChannelsCb) (TpBaseClient *client
,GPtrArray *channels
,gpointer user_data
);
Called when a client asked us to delegate channels
to another Handler.
When this function is called client
is not longer handling channels
.
client |
a TpBaseClient instance |
|
channels |
[element-type TelepathyGLib.Channel] | |
user_data |
arbitrary user-supplied data passed to
|
Since 0.15.3
void tp_base_client_set_delegated_channels_callback (TpBaseClient *self
,TpBaseClientDelegatedChannelsCb callback
,gpointer user_data
,GDestroyNotify destroy
);
Turn on support for the im.telepathy.v1.ChannelRequest.DelegateToPreferredHandler hint.
When receiving a request containing this hint, self
will automatically
delegate the channels to the preferred handler of the request and then call
callback
to inform the client that it is no longer handling those
channels.
self |
a TpBaseClient implementing Handler |
|
callback |
function called when channels currently handled by |
|
user_data |
arbitrary user-supplied data passed to |
|
destroy |
called with the |
Since 0.15.3
void tp_channel_dispatcher_present_channel_async (TpChannelDispatcher *self
,TpChannel *channel
,gint64 user_action_time
,GAsyncReadyCallback callback
,gpointer user_data
);
Asynchronously calls PresentChannel on the ChannelDispatcher to ask
to the handler of channel
to re-present it to the user.
You can then call tp_channel_dispatcher_present_channel_finish()
to
get the result of the operation.
self |
||
channel |
||
user_action_time |
the time at which user action occurred, or TP_USER_ACTION_TIME_NOT_USER_ACTION if this presentation request is for some reason not involving user action. |
|
callback |
a callback to call when the request is satisfied |
|
user_data |
data to pass to |
Since 0.15.0
gboolean tp_channel_dispatcher_present_channel_finish (TpChannelDispatcher *self
,GAsyncResult *result
,GError **error
);
Finishes an async channel presentation request started using
tp_channel_dispatcher_present_channel_async()
.
Since 0.15.0
GList *
tp_base_client_dup_pending_requests (TpBaseClient *self
);
Only works if tp_base_client_set_handler_request_notification()
has been
called.
Returns the list of requests self
is likely be asked to handle.
Since 0.19.9
void tp_base_client_set_handler_bypass_approval (TpBaseClient *self
,gboolean bypass_approval
);
Set whether the channels destined for this handler are automatically handled, without invoking approvers. (This is implemented by setting the value of its BypassApproval D-Bus property.)
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.handle_channel.
Since 0.11.6
void
tp_base_client_set_handler_request_notification
(TpBaseClient *self
);
Indicate that self
is a Handler willing to be notified about requests for
channels that it is likely to be asked to handle. This means that the
“request-added” and “request-removed” signals will
be fired and tp_base_client_get_pending_requests()
will return the list of
pending requests.
This method may only be called before tp_base_client_register()
is
called, and may only be called on objects whose class implements
TpBaseClientClass.handle_channel.
Since 0.11.6
gboolean tp_base_client_register (TpBaseClient *self
,GError **error
);
Publish self
as an available client. After this method is called, as long
as it continues to exist, it will receive and process whatever events were
requested via the various filters.
Methods that set the filters and other immutable state, such as
tp_base_client_add_observer_filter_variant()
, cannot be called after this one.
self |
a TpBaseClient, which must not have been registered with
|
|
error |
used to indicate the error if |
Since 0.11.5
void
tp_base_client_unregister (TpBaseClient *self
);
Remove this client object from D-Bus, if tp_base_client_register()
has already been called.
If the object is not registered, this method may be called, but has no effect.
Releasing the last reference to the object also has the same effect as calling this method, but this method should be preferred, as it has more deterministic behaviour.
If the object still exists, tp_base_client_register()
may be used to
attempt to register it again.
self |
a client, which may already have been registered with
|
Since 0.11.6
const gchar *
tp_base_client_get_bus_name (TpBaseClient *self
);
Return the bus name of self
. Note that doesn't mean the client is
actually owning this name; for example if tp_base_client_register()
has not been called yet or failed.
Since 0.11.5
const gchar *
tp_base_client_get_object_path (TpBaseClient *self
);
Return the object path of self
. Note that doesn't mean the client is
actually registered on this path; for example if tp_base_client_register()
has not been called yet or failed.
Since 0.11.5
GDBusConnection *
tp_base_client_get_dbus_connection (TpBaseClient *self
);
Return the “dbus-connection” construct-only property, which represents the D-Bus connection used to export this client object.
The returned object's reference count is not incremented, so it is not
necessarily valid after self
is destroyed.
Since 0.99.10
const gchar *
tp_base_client_get_name (TpBaseClient *self
);
Return the “name” construct-only property, which is used as part of the bus name and object path.
Since 0.11.11
gboolean
tp_base_client_get_uniquify_name (TpBaseClient *self
);
Return the “uniquify-name” construct-only property; if this is true, the bus name and object path will be made unique by appending a suffix that includes the D-Bus unique name and a per-process counter.
Since 0.11.11
struct TpBaseClient;
Data structure representing a generic TpSvcClient implementation.
Since 0.11.5
struct TpBaseClientClass { GObjectClass parent_class; TpBaseClientClassObserveChannelImpl observe_channel; TpBaseClientClassAddDispatchOperationImpl add_dispatch_operation; TpBaseClientClassHandleChannelImpl handle_channel; };
The class of a TpBaseClient.
The virtual methods observe_channel
, add_dispatch_operation
and
handle_channel
can be also implemented by calling
tp_base_client_implement_observe_channel()
,
tp_base_client_implement_add_dispatch_operation()
and
tp_base_client_implement_handle_channel()
. This is compatible with
telepathy-glib versions older than 0.11.13.
GObjectClass |
the parent class |
|
TpBaseClientClassObserveChannelImpl |
the function called to observe newly-created channels matching this client's observer filter |
|
TpBaseClientClassAddDispatchOperationImpl |
the function called to request user approval of unrequested (incoming) channels matching this client's approver filter (since 0.11.13) |
|
TpBaseClientClassHandleChannelImpl |
the function called to handle channels matching this client's handler filter |
Since 0.11.5
“dbus-connection”
property“dbus-connection” GDBusConnection *
This object's connection to D-Bus. Read-only except during construction.
This property can't be NULL
after construction.
Flags: Read / Write / Construct Only
Since 0.99.10
“factory”
property“factory” TpClientFactory *
Factory for this base client, used to look up or create TpAccount objects.
Flags: Read / Write / Construct Only
Since 0.15.5
“name”
property“name” gchar *
The name of the client. This is used to register the D-Bus service name and object path of the service.
This property can't be NULL
.
Flags: Read / Write / Construct Only
Default value: NULL
Since 0.11.5
“uniquify-name”
property“uniquify-name” gboolean
If TRUE
, tp_base_client_register()
will append an unique token to the
service bus name and object path to ensure they are unique.
Flags: Read / Write / Construct Only
Default value: FALSE
Since 0.11.5
“request-added”
signalvoid user_function (TpBaseClient *self, TpAccount *account, TpChannelRequest *request, gpointer user_data)
Emitted when a channels have been requested, and that if the request is successful, they will probably be handled by this Handler.
This signal is only fired if
tp_base_client_set_handler_request_notification()
has been called
on self
previously.
self |
||
account |
the TpAccount on which the request was made,
with |
|
request |
a TpChannelRequest having its object-path defined but is not guaranteed to be prepared. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Has Details
Since 0.11.6
“request-removed”
signalvoid user_function (TpBaseClient *self, TpChannelRequest *request, gchar *error, gchar *message, gpointer user_data)
Emitted when a request has failed and should be disregarded.
This signal is only fired if
tp_base_client_set_handler_request_notification()
has been called
on self
previously.
self |
||
request |
the TpChannelRequest being removed |
|
error |
the name of the D-Bus error with which the request failed. |
|
message |
any message supplied with the D-Bus error. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Has Details
Since 0.11.6