TpSimpleApprover

TpSimpleApprover — a subclass of TpBaseClient implementing a simple Approver

Synopsis

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

                    TpSimpleApprover;
void                (*TpSimpleApproverAddDispatchOperationImpl)
                                                        (TpSimpleApprover *self,
                                                         TpAccount *account,
                                                         TpConnection *connection,
                                                         GList *channels,
                                                         TpChannelDispatchOperation *dispatch_operation,
                                                         TpAddDispatchOperationContext *context,
                                                         gpointer user_data);
TpBaseClient *      tp_simple_approver_new              (TpDBusDaemon *dbus,
                                                         const gchar *name,
                                                         gboolean unique,
                                                         TpSimpleApproverAddDispatchOperationImpl callback,
                                                         gpointer user_data,
                                                         GDestroyNotify destroy);
TpBaseClient *      tp_simple_approver_new_with_am      (TpAccountManager *account_manager,
                                                         const gchar *name,
                                                         gboolean unique,
                                                         TpSimpleApproverAddDispatchOperationImpl callback,
                                                         gpointer user_data,
                                                         GDestroyNotify destroy);

Object Hierarchy

  GObject
   +----TpBaseClient
         +----TpSimpleApprover

Implemented Interfaces

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

Properties

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

Description

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

A typical simple approver 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_add_dispatch_operation (TpSimpleApprover *self,
   TpAccount *account,
   TpConnection *connection,
   GList *channels,
   TpChannelDispatchOperation *dispatch_operation,
   TpAddDispatchOperationContext *context,
   gpointer user_data)
{
 /* call tp_channel_dispatch_operation_handle_with_async()
 if wanting to approve the channels */

 tp_add_dispatch_operation_context_accept (context);
}

client = tp_simple_approver_new (dbus, "MyApprover", FALSE,
   my_add_dispatch_operation, user_data);

tp_base_client_take_approver_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/text-approver.c for a complete example.

Details

TpSimpleApprover

typedef struct _TpSimpleApprover TpSimpleApprover;

Data structure representing a simple Approver implementation.

Since 0.11.5


TpSimpleApproverAddDispatchOperationImpl ()

void                (*TpSimpleApproverAddDispatchOperationImpl)
                                                        (TpSimpleApprover *self,
                                                         TpAccount *account,
                                                         TpConnection *connection,
                                                         GList *channels,
                                                         TpChannelDispatchOperation *dispatch_operation,
                                                         TpAddDispatchOperationContext *context,
                                                         gpointer user_data);

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.

self :

a TpSimpleApprover 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. [element-type TelepathyGLib.Channel]

dispatch_operation :

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

context :

a TpAddDispatchOperationContext representing the context of this D-Bus call

user_data :

arbitrary user-supplied data passed to tp_simple_approver_new()

Since 0.11.5


tp_simple_approver_new ()

TpBaseClient *      tp_simple_approver_new              (TpDBusDaemon *dbus,
                                                         const gchar *name,
                                                         gboolean unique,
                                                         TpSimpleApproverAddDispatchOperationImpl callback,
                                                         gpointer user_data,
                                                         GDestroyNotify destroy);

Convenient function to create a new TpSimpleApprover instance.

If dbus is not the result of tp_dbus_daemon_dup(), you should call tp_simple_approver_new_with_am() instead, so that TpAccount, TpConnection and TpContact instances can be shared between modules.

dbus :

a TpDBusDaemon object, may not be NULL

name :

the name of the Approver (see "name": for details)

unique :

the value of the TpBaseClient:uniquify-name: property

callback :

the function called when ApproverChannels is called

user_data :

arbitrary user-supplied data passed to callback

destroy :

called with the user_data as argument, when the TpSimpleApprover is destroyed

Returns :

a new TpSimpleApprover. [type TelepathyGLib.SimpleApprover]

Since 0.11.5


tp_simple_approver_new_with_am ()

TpBaseClient *      tp_simple_approver_new_with_am      (TpAccountManager *account_manager,
                                                         const gchar *name,
                                                         gboolean unique,
                                                         TpSimpleApproverAddDispatchOperationImpl callback,
                                                         gpointer user_data,
                                                         GDestroyNotify destroy);

Convenient function to create a new TpSimpleApprover instance with a specified TpAccountManager.

It is not necessary to prepare any features on account_manager before calling this function.

account_manager :

an account manager, which may not be NULL

name :

the name of the Approver (see "name": for details)

unique :

the value of the TpBaseClient:uniquify-name: property

callback :

the function called when ApproverChannels is called

user_data :

arbitrary user-supplied data passed to callback

destroy :

called with the user_data as argument, when the TpSimpleApprover is destroyed

Returns :

a new TpSimpleApprover. [type TelepathyGLib.SimpleApprover]

Since 0.11.14

Property Details

The "callback" property

  "callback"                 gpointer              : Write / Construct Only

The TpSimpleApproverAddDispatchOperationImpl callback implementing the ApproverChannels D-Bus method.

This property can't be NULL.

Since 0.11.5


The "destroy" property

  "destroy"                  gpointer              : Write / Construct Only

The GDestroyNotify function called to free the user-data pointer when the TpSimpleApprover is destroyed.

Since 0.11.5


The "user-data" property

  "user-data"                gpointer              : Write / Construct Only

The user-data pointer passed to the callback implementing the ApproverChannels D-Bus method.

Since 0.11.5