TpSimpleObserver

TpSimpleObserver — a subclass of TpBaseClient implementing a simple Observer

Synopsis

#include <telepathy-glib/simple-observer.h>

                    TpSimpleObserver;
void                (*TpSimpleObserverObserveChannelsImpl)
                                                        (TpSimpleObserver *self,
                                                         TpAccount *account,
                                                         TpConnection *connection,
                                                         GList *channels,
                                                         TpChannelDispatchOperation *dispatch_operation,
                                                         GList *requests,
                                                         TpObserveChannelsContext *context,
                                                         gpointer user_data);
TpBaseClient *      tp_simple_observer_new              (TpDBusDaemon *dbus,
                                                         gboolean recover,
                                                         const gchar *name,
                                                         gboolean unique,
                                                         TpSimpleObserverObserveChannelsImpl callback,
                                                         gpointer user_data,
                                                         GDestroyNotify destroy);

Object Hierarchy

  GObject
   +----TpBaseClient
         +----TpSimpleObserver

Implemented Interfaces

TpSimpleObserver implements TpSvcDBusProperties, TpSvcClient, TpSvcClientObserver, TpSvcClientApprover, TpSvcClientHandler and TpSvcClientInterfaceRequests.

Properties

  "callback"                 gpointer              : Write / Construct Only
  "destroy"                  gpointer              : Write / Construct Only
  "recover"                  gboolean              : Write / Construct Only
  "user-data"                gpointer              : Write / Construct Only

Description

This class makes it easier to write TpSvcClient implementing the TpSvcClientObserver interface.

A typical simple observer would look liks this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
static void
my_observe_channels (TpSimpleObserver *self,
   TpAccount *account,
   TpConnection *connection,
   GList *channels,
   TpChannelDispatchOperation *dispatch_operation,
   GList *requests,
   TpObserveChannelsContext *context,
   gpointer user_data)
{
 /* do something useful with the channels here */

 tp_observe_channels_context_accept (context);
}

client = tp_simple_observer_new (dbus, TRUE, "MyObserver", FALSE,
   my_observe_channels, user_data);

tp_base_client_take_observer_filter (client, tp_asv_new (
     TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT,
     TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
     NULL));

tp_base_client_register (client, NULL);

See examples/client/media-observer.c for a complete example.

Details

TpSimpleObserver

typedef struct _TpSimpleObserver TpSimpleObserver;

Data structure representing a simple Observer implementation.

Since 0.11.5


TpSimpleObserverObserveChannelsImpl ()

void                (*TpSimpleObserverObserveChannelsImpl)
                                                        (TpSimpleObserver *self,
                                                         TpAccount *account,
                                                         TpConnection *connection,
                                                         GList *channels,
                                                         TpChannelDispatchOperation *dispatch_operation,
                                                         GList *requests,
                                                         TpObserveChannelsContext *context,
                                                         gpointer user_data);

Signature of the implementation of the ObserveChannels method.

This function must call either tp_observe_channels_context_accept(), tp_observe_channels_context_delay() or tp_observe_channels_context_fail() on context before it returns.

self :

a TpSimpleObserver instance

account :

a TpAccount having TP_ACCOUNT_FEATURE_CORE prepared if possible

connection :

a TpConnection having TP_CONNECTION_FEATURE_CORE prepared if possible

channels :

a GList of TpChannel, all having TP_CHANNEL_FEATURE_CORE prepared if possible. [element-type TelepathyGLib.Channel]

dispatch_operation :

a TpChannelDispatchOperation or NULL; the dispatch_operation is not guaranteed to be prepared. [allow-none]

requests :

a GList of TpChannelRequest, all having their object-path defined but are not guaranteed to be prepared. [element-type TelepathyGLib.ChannelRequest]

context :

a TpObserveChannelsContext representing the context of this D-Bus call

user_data :

arbitrary user-supplied data passed to tp_simple_observer_new()

Since 0.11.5


tp_simple_observer_new ()

TpBaseClient *      tp_simple_observer_new              (TpDBusDaemon *dbus,
                                                         gboolean recover,
                                                         const gchar *name,
                                                         gboolean unique,
                                                         TpSimpleObserverObserveChannelsImpl callback,
                                                         gpointer user_data,
                                                         GDestroyNotify destroy);

Convenient function to create a new TpSimpleObserver instance.

dbus :

a TpDBusDaemon object, may not be NULL

recover :

the value of the Observer.Recover D-Bus property

name :

the name of the Observer (see the name of the Observer (see the name of the Observer (see the name of the Observer (see the name of the Observer (see the name of the Observer (see the name of the Observer (see the name of the Observer (see the name of the Observer (see the name of the Observer (see the name of the Observer (see the name of the Observer (see the name of the Observer (see the name of the Observer (see <