TpSimpleHandler

TpSimpleHandler — a subclass of TpBaseClient implementing a simple Handler

Functions

Properties

gboolean bypass-approval Write / Construct Only
gpointer callback Write / Construct Only
gpointer destroy Write / Construct Only
gboolean requests Write / Construct Only
gpointer user-data Write / Construct Only

Types and Values

Object Hierarchy

    GObject
    ╰── TpBaseClient
        ╰── TpSimpleHandler

Implemented Interfaces

TpSimpleHandler implements TpSvcClient, TpSvcClientObserver, TpSvcClientApprover, TpSvcClientHandler and TpSvcClientInterfaceRequests.

Includes

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

Description

This class makes it easier to construct a TpSvcClient implementing the TpSvcClientHandler interface.

A typical simple handler 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
static void
my_handle_channel (TpSimpleHandler *handler,
   TpAccount *account,
   TpConnection *connection,
   TpChannel *channel,
   GList *requests_satisfied,
   gint64 user_action_time,
   GList *requests,
   TpHandleChannelContext *context,
   gpointer user_data)
{
 /<!-- -->* start handling the channel here *<!-- -->/

 tp_handle_channel_context_accept (context);
}

client = tp_simple_handler_new (NULL, FALSE, FALSE,
    "MyHandler", FALSE, my_handle_channel, user_data);

tp_base_client_take_handler_filter (client,
     tp_channel_filter_new_for_text_chats ());

tp_base_client_register (client, NULL);

See examples/client/text-handler.c for a complete example.

Functions

TpSimpleHandlerHandleChannelImpl ()

void
(*TpSimpleHandlerHandleChannelImpl) (TpSimpleHandler *handler,
                                     TpAccount *account,
                                     TpConnection *connection,
                                     TpChannel *channel,
                                     GList *requests_satisfied,
                                     gint64 user_action_time,
                                     TpHandleChannelContext *context,
                                     gpointer user_data);

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.

Parameters

handler

a TpSimpleHandler instance

 

account

a TpAccount having TP_ACCOUNT_FEATURE_CORE prepared if possible

 

connection

a TpConnection having TP_CONNECTION_FEATURE_CORE prepared if possible

 

channel

a TpChannel, having TP_CHANNEL_FEATURE_CORE prepared if possible

 

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 TP_USER_ACTION_TIME_NOT_USER_ACTION or TP_USER_ACTION_TIME_CURRENT_TIME (see “user-action-time” for details)

 

context

a TpHandleChannelContext representing the context of this D-Bus call

 

user_data

arbitrary user-supplied data passed to tp_simple_handler_new()

 

Since 0.11.6


tp_simple_handler_new ()

TpBaseClient *
tp_simple_handler_new (TpClientFactory *factory,
                       gboolean bypass_approval,
                       gboolean requests,
                       const gchar *name,
                       gboolean uniquify,
                       TpSimpleHandlerHandleChannelImpl callback,
                       gpointer user_data,
                       GDestroyNotify destroy);

Convenient function to create a new TpSimpleHandler instance.

If factory is NULL a new TpAutomaticClientFactory will be used.

Parameters

factory

a TpClientFactory, or NULL

 

bypass_approval

the value of the Handler.BypassApproval D-Bus property (see tp_base_client_set_handler_bypass_approval() for details)

 

requests

whether this handler should implement Requests (see tp_base_client_set_handler_request_notification() for details)

 

name

the name of the Handler (see “name” for details)

 

uniquify

the value of the “uniquify-name” property

 

callback

the function called when HandleChannel is called

 

user_data

arbitrary user-supplied data passed to callback

 

destroy

called with user_data as its argument when the TpSimpleHandler is destroyed

 

Returns

a new TpSimpleHandler.

[type TelepathyGLib.SimpleHandler]

Since 0.99.1


tp_simple_handler_new_with_am ()

TpBaseClient *
tp_simple_handler_new_with_am (TpAccountManager *account_manager,
                               gboolean bypass_approval,
                               gboolean requests,
                               const gchar *name,
                               gboolean uniquify,
                               TpSimpleHandlerHandleChannelImpl callback,
                               gpointer user_data,
                               GDestroyNotify destroy);

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

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

Parameters

account_manager

an account manager, which may not be NULL

 

bypass_approval

the value of the Handler.BypassApproval D-Bus property (see tp_base_client_set_handler_bypass_approval() for details)

 

requests

whether this handler should implement Requests (see tp_base_client_set_handler_request_notification() for details)

 

name

the name of the Handler (see “name” for details)

 

uniquify

the value of the “uniquify-name” property

 

callback

the function called when HandleChannel is called

 

user_data

arbitrary user-supplied data passed to callback

 

destroy

called with user_data as its argument when the TpSimpleHandler is destroyed

 

Returns

a new TpSimpleHandler.

[type TelepathyGLib.SimpleHandler]

Since 0.11.14

Types and Values

struct TpSimpleHandler

struct TpSimpleHandler;

Data structure representing a simple Handler implementation.

Since 0.11.6

Property Details

The “bypass-approval” property

  “bypass-approval”          gboolean

The value of the Handler.BypassApproval D-Bus property.

Flags: Write / Construct Only

Default value: FALSE

Since 0.11.6


The “callback” property

  “callback”                 gpointer

The TpSimpleHandlerHandleChannelImpl callback implementing the HandleChannel D-Bus method.

This property can't be NULL.

Flags: Write / Construct Only

Since 0.11.6


The “destroy” property

  “destroy”                  gpointer

The GDestroyNotify function called to free “user-data” when the TpSimpleHandler is destroyed.

Flags: Write / Construct Only

Since 0.11.6


The “requests” property

  “requests”                 gboolean

If TRUE, the Handler will implement the Requests interface

Flags: Write / Construct Only

Default value: FALSE

Since 0.11.6


The “user-data” property

  “user-data”                gpointer

The user-data pointer passed to “callback”.

Flags: Write / Construct Only

Since 0.11.6