static void iterate_contacts (TpChannel *channel, GArray *handles, char **argv) { GError *error = NULL; int i; for (i = 0; i < handles->len; i++) { int handle = g_array_index (handles, int, i); /* FIXME: we should check that our client has the * FT capability */ /* begin ex.filetransfer.sending.gfileinfo */ GFile *file = g_file_new_for_commandline_arg (argv[3]); GFileInfo *info = g_file_query_info (file, "standard::*", G_FILE_QUERY_INFO_NONE, NULL, &error); handle_error (error); GHashTable *props = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT, handle, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_FILENAME, G_TYPE_STRING, g_file_info_get_display_name (info), TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_TYPE, G_TYPE_STRING, g_file_info_get_content_type (info), TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_SIZE, G_TYPE_UINT64, g_file_info_get_size (info), NULL); tp_cli_connection_interface_requests_call_create_channel ( conn, -1, props, create_ft_channel_cb, NULL, NULL, NULL); g_hash_table_destroy (props); g_object_unref (info); g_object_unref (file); /* end ex.filetransfer.sending.gfileinfo */ } }
gboolean empathy_tls_verifier_verify_finish (EmpathyTLSVerifier *self, GAsyncResult *res, EmpTLSCertificateRejectReason *reason, GHashTable **details, GError **error) { EmpathyTLSVerifierPriv *priv = GET_PRIV (self); if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) { if (reason != NULL) *reason = (*error)->code; if (details != NULL) { *details = tp_asv_new (NULL, NULL); tp_g_hash_table_update (*details, priv->details, (GBoxedCopyFunc) g_strdup, (GBoxedCopyFunc) tp_g_value_slice_dup); } return FALSE; } if (reason != NULL) *reason = EMP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN; return TRUE; }
static void empathy_ft_factory_init (EmpathyFTFactory *self) { EmpathyFTFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_FT_FACTORY, EmpathyFTFactoryPriv); TpDBusDaemon *dbus; GError *error = NULL; self->priv = priv; dbus = tp_dbus_daemon_dup (&error); if (dbus == NULL) { g_warning ("Failed to get TpDBusDaemon: %s", error->message); g_error_free (error); return; } priv->handler = tp_simple_handler_new (dbus, FALSE, FALSE, EMPATHY_FT_BUS_NAME_SUFFIX, FALSE, handle_channels_cb, self, NULL); tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, /* Only handle *incoming* channels as outgoing FT channels has to be * handled by the requester. */ TP_PROP_CHANNEL_REQUESTED, G_TYPE_BOOLEAN, FALSE, NULL)); g_object_unref (dbus); }
gboolean hev_impathy_tls_verifier_verify_finish(HevImpathyTLSVerifier *self, GAsyncResult *res, TpTLSCertificateRejectReason *reason, GHashTable **details, GError **error) { HevImpathyTLSVerifierPrivate *priv = NULL; g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); g_return_val_if_fail(HEV_IS_IMPATHY_TLS_VERIFIER(self), FALSE); priv = HEV_IMPATHY_TLS_VERIFIER_GET_PRIVATE(self); if(g_simple_async_result_propagate_error(G_SIMPLE_ASYNC_RESULT(res), error)) { if(NULL != reason) *reason = (*error)->code; if(NULL != details) { *details = tp_asv_new(NULL, NULL); tp_g_hash_table_update(*details, priv->details, (GBoxedCopyFunc)g_strdup, (GBoxedCopyFunc)tp_g_value_slice_dup); } return FALSE; } if(NULL != reason) *reason = TP_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN; return TRUE; }
static void import_widget_add_account (EmpathyImportWidget *self, EmpathyImportAccountData *data) { TpAccountManager *account_manager; gchar *display_name; GHashTable *properties; GValue *username; account_manager = tp_account_manager_dup (); DEBUG ("connection_manager: %s\n", data->connection_manager); /* Set the display name of the account */ username = g_hash_table_lookup (data->settings, "account"); display_name = g_strdup_printf ("%s (%s)", data->protocol, g_value_get_string (username)); DEBUG ("display name: %s\n", display_name); properties = tp_asv_new (NULL, NULL); tp_asv_set_boolean (properties, TP_IFACE_ACCOUNT ".Enabled", data->enabled); tp_account_manager_create_account_async (account_manager, (const gchar*) data->connection_manager, data->protocol, display_name, data->settings, properties, import_widget_create_account_cb, g_object_ref (self)); g_hash_table_unref (properties); g_free (display_name); g_object_unref (account_manager); }
static void create_text_channel (TpAccount *account, TpHandleType target_handle_type, const gchar *target_id, gboolean sms_channel, gint64 timestamp, GAsyncReadyCallback callback, gpointer user_data) { GHashTable *request; TpAccountChannelRequest *req; request = 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, target_handle_type, TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, target_id, NULL); if (sms_channel) tp_asv_set_boolean (request, TP_PROP_CHANNEL_INTERFACE_SMS_SMS_CHANNEL, TRUE); req = tp_account_channel_request_new (account, request, timestamp); tp_account_channel_request_set_delegate_to_preferred_handler (req, TRUE); tp_account_channel_request_ensure_channel_async (req, EMPATHY_CHAT_BUS_NAME, NULL, callback ? callback : ensure_text_channel_cb, user_data); g_hash_table_unref (request); g_object_unref (req); }
static void ft_handler_populate_outgoing_request (EmpathyFTHandler *handler) { guint contact_handle; EmpathyFTHandlerPriv *priv = GET_PRIV (handler); gchar *uri; contact_handle = empathy_contact_get_handle (priv->contact); uri = g_file_get_uri (priv->gfile); priv->request = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT, contact_handle, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_TYPE, G_TYPE_STRING, priv->content_type, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_FILENAME, G_TYPE_STRING, priv->filename, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_SIZE, G_TYPE_UINT64, priv->total_bytes, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_DATE, G_TYPE_UINT64, priv->mtime, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_URI, G_TYPE_STRING, uri, NULL); g_free (uri); }
static void add_room (GPtrArray *rooms) { GHashTable *hash; hash = tp_asv_new ( "handle-name", G_TYPE_STRING, "the handle name", "name", G_TYPE_STRING, "the name", "description", G_TYPE_STRING, "the description", "subject", G_TYPE_STRING, "the subject", "members", G_TYPE_UINT, 10, "password", G_TYPE_BOOLEAN, TRUE, "invite-only", G_TYPE_BOOLEAN, TRUE, "room-id", G_TYPE_STRING, "the room id", "server", G_TYPE_STRING, "the server", NULL); g_ptr_array_add (rooms, tp_value_array_build (3, G_TYPE_UINT, 0, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, TP_HASH_TYPE_STRING_VARIANT_MAP, hash, G_TYPE_INVALID)); g_hash_table_unref (hash); }
void remmina_tp_channel_handler_new(const gchar *account_path, const gchar *connection_path, const gchar *channel_path, GHashTable *channel_properties, DBusGMethodInvocation *context) { TpDBusDaemon *bus; TpAccount *account; GError *error = NULL; RemminaTpChannelHandler *chandler; bus = tp_dbus_daemon_dup(&error); if (bus == NULL) { g_print("tp_dbus_daemon_dup: %s", error->message); return; } account = tp_account_new(bus, account_path, &error); if (account == NULL) { g_object_unref(bus); g_print("tp_account_new: %s", error->message); return; } chandler = g_new0(RemminaTpChannelHandler, 1); chandler->bus = bus; chandler->account = account; chandler->connection_path = g_strdup(connection_path); chandler->channel_path = g_strdup(channel_path); chandler->channel_properties = tp_asv_new(NULL, NULL); tp_g_hash_table_update(chandler->channel_properties, channel_properties, (GBoxedCopyFunc) g_strdup, (GBoxedCopyFunc) tp_g_value_slice_dup); chandler->context = context; tp_account_prepare_async(account, NULL, remmina_tp_channel_handler_account_ready, chandler); }
static void cm_ready (TpConnectionManager *cm, const GError *in_error, gpointer user_data, GObject *weak_obj) { char **argv = (char **) user_data; g_print (" > cm_ready\n"); if (in_error) g_error ("%s", in_error->message); const TpConnectionManagerProtocol *prot = tp_connection_manager_get_protocol (cm, "local-xmpp"); if (!prot) g_error ("Protocol is not supported"); /* request a new connection */ GHashTable *parameters = tp_asv_new ( "first-name", G_TYPE_STRING, argv[1], "last-name", G_TYPE_STRING, argv[2], NULL); tp_cli_connection_manager_call_request_connection (cm, -1, "local-xmpp", parameters, request_connection_cb, argv, NULL, NULL); g_hash_table_destroy (parameters); }
int main (int argc, char **argv) { TpAccountManager *manager; TpSimpleClientFactory *factory; TpBaseClient *approver; GError *error = NULL; gtk_init (&argc, &argv); tp_debug_set_flags (g_getenv ("LIBO_APPROVER_DEBUG")); manager = tp_account_manager_dup (); factory = tp_proxy_get_factory (manager); /* We want the target contact on channels to be available... */ tp_simple_client_factory_add_channel_features_varargs (factory, TP_CHANNEL_FEATURE_CONTACTS, 0); /* ...and for it to have its alias and avatar available */ tp_simple_client_factory_add_contact_features_varargs (factory, TP_CONTACT_FEATURE_ALIAS, TP_CONTACT_FEATURE_AVATAR_DATA, TP_CONTACT_FEATURE_INVALID); approver = tp_simple_approver_new_with_am (manager, "LibreOfficeApprover", FALSE, add_dispatch_operation_cb, NULL, NULL); tp_base_client_take_approver_filter (approver, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_DBUS_TUBE, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, TP_PROP_CHANNEL_TYPE_DBUS_TUBE_SERVICE_NAME, G_TYPE_STRING, LIBO_DTUBE_SERVICE, NULL)); if (!tp_base_client_register (approver, &error)) { g_warning ("Failed to register Approver: %s\n", error->message); g_error_free (error); goto out; } g_print ("Start approving\n"); mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); /* TODO: time out after 5 seconds of inactivity? */ if (mainloop != NULL) g_main_loop_unref (mainloop); out: g_object_unref (manager); g_object_unref (approver); return 0; }
static void hev_impathy_tls_verifier_init(HevImpathyTLSVerifier * self) { HevImpathyTLSVerifierPrivate * priv = HEV_IMPATHY_TLS_VERIFIER_GET_PRIVATE(self); g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); priv->details = tp_asv_new(NULL, NULL); }
static void empathy_tls_verifier_init (EmpathyTLSVerifier *self) { EmpathyTLSVerifierPriv *priv; priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_TLS_VERIFIER, EmpathyTLSVerifierPriv); priv->details = tp_asv_new (NULL, NULL); }
static void empathy_call_observer_init (EmpathyCallObserver *self) { EmpathyCallObserverPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_CALL_OBSERVER, EmpathyCallObserverPriv); TpAccountManager *am; GError *error = NULL; self->priv = priv; self->priv->notify_mgr = empathy_notify_manager_dup_singleton (); am = tp_account_manager_dup (); self->priv->observer = tp_simple_observer_new_with_am (am, TRUE, "Empathy.CallObserver", FALSE, observe_channels, self, NULL); /* Observe Call and StreamedMedia channels */ tp_base_client_take_observer_filter (self->priv->observer, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, NULL)); tp_base_client_take_observer_filter (self->priv->observer, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_CALL, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, NULL)); tp_base_client_set_observer_delay_approvers (self->priv->observer, TRUE); if (!tp_base_client_register (self->priv->observer, &error)) { DEBUG ("Failed to register observer: %s", error->message); g_error_free (error); } g_object_unref (am); }
/** * tp_yts_client_request_channel_async: * @self: The client object * @target_contact: The contact to open the channel to * @target_service: The Ytstenut service to open the channel to * @request_type: The type of request to send * @request_attributes: A table of Ytstenut attributes, or %NULL * @request_body: A UTF-8 encoded XML Ytstenut message, or %NULL * @cancellable: Used to cancel this operation * @callback: Called when the operation completes * @user_data: Data to pass to the callback * * Start an operation to request a new Ytstenut channel. * * The new channel will have a Ytstenut request message ready to send. The * message is assembled from the arguments specified here. */ void tp_yts_client_request_channel_async (TpYtsClient *self, TpContact *target_contact, const gchar *target_service, TpYtsRequestType request_type, GHashTable *request_attributes, const gchar *request_body, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { TpAccountChannelRequest *channel_request; GSimpleAsyncResult *res; GHashTable *request_properties; TpHandle target_handle; g_return_if_fail (TP_IS_YTS_CLIENT (self)); g_return_if_fail (TP_IS_CONTACT (target_contact)); g_return_if_fail (tp_dbus_check_valid_interface_name (target_service, NULL)); if (!request_body) request_body = ""; g_return_if_fail (g_utf8_validate (request_body, -1, NULL)); target_handle = tp_contact_get_handle (target_contact); g_return_if_fail (target_handle); res = g_simple_async_result_new (G_OBJECT (self), callback, user_data, tp_yts_client_request_channel_async); request_properties = tp_asv_new ( TP_IFACE_CHANNEL ".ChannelType", G_TYPE_STRING, TP_YTS_IFACE_CHANNEL, TP_IFACE_CHANNEL ".TargetHandleType", G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, TP_IFACE_CHANNEL ".TargetHandle", G_TYPE_UINT, target_handle, TP_YTS_IFACE_CHANNEL ".TargetService", G_TYPE_STRING, target_service, TP_YTS_IFACE_CHANNEL ".InitiatorService", G_TYPE_STRING, self->priv->service_name, TP_YTS_IFACE_CHANNEL ".RequestType", G_TYPE_UINT, request_type, TP_YTS_IFACE_CHANNEL ".RequestBody", G_TYPE_STRING, request_body, NULL); if (request_attributes) tp_asv_set_boxed (request_properties, TP_YTS_IFACE_CHANNEL ".RequestAttributes", TP_HASH_TYPE_STRING_STRING_MAP, request_attributes); channel_request = tp_account_channel_request_new (self->priv->account, request_properties, 0); tp_account_channel_request_create_and_handle_channel_async (channel_request, cancellable, on_channel_request_create_and_handle_channel_returned, res); g_hash_table_unref (request_properties); }
static void empathy_streamed_media_factory_init (EmpathyStreamedMediaFactory *obj) { EmpathyStreamedMediaFactoryPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj, EMPATHY_TYPE_STREAMED_MEDIA_FACTORY, EmpathyStreamedMediaFactoryPriv); TpAccountManager *am; obj->priv = priv; am = tp_account_manager_dup (); priv->handler = tp_simple_handler_new_with_am (am, FALSE, FALSE, EMPATHY_AV_BUS_NAME_SUFFIX, FALSE, handle_channels_cb, obj, NULL); tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, NULL)); tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, G_TYPE_BOOLEAN, TRUE, NULL)); tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, G_TYPE_BOOLEAN, TRUE, NULL)); tp_base_client_add_handler_capabilities_varargs (priv->handler, "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/ice-udp", "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/gtalk-p2p", "org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/video/h264", NULL); g_object_unref (am); }
static void empathy_chat_manager_init (EmpathyChatManager *self) { EmpathyChatManagerPriv *priv = GET_PRIV (self); TpAccountManager *am; GError *error = NULL; priv->closed_queue = g_queue_new (); priv->messages = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_unref); am = tp_account_manager_dup (); priv->chatroom_mgr = empathy_chatroom_manager_dup_singleton (NULL); /* Text channels handler */ priv->handler = tp_simple_handler_new_with_am (am, FALSE, FALSE, EMPATHY_CHAT_BUS_NAME_SUFFIX, FALSE, handle_channels, self, NULL); g_object_unref (am); tp_base_client_take_handler_filter (priv->handler, 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_take_handler_filter (priv->handler, 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_ROOM, NULL)); tp_base_client_take_handler_filter (priv->handler, 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_NONE, NULL)); if (!tp_base_client_register (priv->handler, &error)) { g_critical ("Failed to register text handler: %s", error->message); g_error_free (error); } }
static void shell_tp_client_init (ShellTpClient *self) { GHashTable *filter; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, SHELL_TYPE_TP_CLIENT, ShellTpClientPrivate); /* We only care about single-user text-based chats */ filter = 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); /* Observer */ tp_base_client_set_observer_recover (TP_BASE_CLIENT (self), TRUE); tp_base_client_add_observer_filter (TP_BASE_CLIENT (self), filter); /* Approver */ tp_base_client_add_approver_filter (TP_BASE_CLIENT (self), filter); /* Approve room invitations. We don't handle or observe room channels so * just register this filter for the approver. */ tp_base_client_take_approver_filter (TP_BASE_CLIENT (self), 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_ROOM, NULL)); /* Handler */ tp_base_client_add_handler_filter (TP_BASE_CLIENT (self), filter); g_hash_table_unref (filter); }
static void conn_ready_cb (TpConnection *connection, const GError *error, gpointer data) { EmpathyTpContactList *list = data; EmpathyTpContactListPriv *priv = GET_PRIV (list); GHashTable *request; if (error != NULL) { DEBUG ("failed: %s", error->message); goto out; } /* Look for existing group channels */ tp_cli_dbus_properties_call_get (connection, -1, TP_IFACE_CONNECTION_INTERFACE_REQUESTS, "Channels", got_channels_cb, NULL, NULL, G_OBJECT (list)); request = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_LIST, NULL); /* Watch the NewChannels signal so if ensuring list channels fails (for * example because the server is slow and the D-Bus call timeouts before CM * fetches the roster), we have a chance to get them later. */ tp_cli_connection_interface_requests_connect_to_new_channels ( priv->connection, new_channels_cb, NULL, NULL, G_OBJECT (list), NULL); /* Request the 'stored' list. */ tp_asv_set_static_string (request, TP_PROP_CHANNEL_TARGET_ID, "stored"); tp_cli_connection_interface_requests_call_ensure_channel (priv->connection, G_MAXINT, request, list_ensure_channel_cb, list, NULL, G_OBJECT (list)); /* Request the 'publish' list. */ tp_asv_set_static_string (request, TP_PROP_CHANNEL_TARGET_ID, "publish"); tp_cli_connection_interface_requests_call_ensure_channel (priv->connection, G_MAXINT, request, list_ensure_channel_cb, list, NULL, G_OBJECT (list)); /* Request the 'subscribe' list. */ tp_asv_set_static_string (request, TP_PROP_CHANNEL_TARGET_ID, "subscribe"); tp_cli_connection_interface_requests_call_ensure_channel (priv->connection, G_MAXINT, request, list_ensure_channel_cb, list, NULL, G_OBJECT (list)); g_hash_table_unref (request); out: g_object_unref (list); }
static void gabble_server_sasl_channel_init (GabbleServerSaslChannel *self) { GabbleServerSaslChannelPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GABBLE_TYPE_SERVER_SASL_CHANNEL, GabbleServerSaslChannelPrivate); self->priv = priv; priv->sasl_status = TP_SASL_STATUS_NOT_STARTED; priv->sasl_error = NULL; priv->sasl_error_details = tp_asv_new (NULL, NULL); /* a safe assumption if we don't set anything else */ priv->disconnect_reason = TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED; }
static void example_echo_2_im_manager_type_foreach_channel_class (GType type, TpChannelManagerTypeChannelClassFunc func, gpointer user_data) { GHashTable *table = 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); func (type, table, allowed_properties, user_data); g_hash_table_unref (table); }
static void example_csh_room_manager_foreach_channel_class (TpChannelManager *manager, TpChannelManagerChannelClassFunc func, gpointer user_data) { GHashTable *table = 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_ROOM, NULL); func (manager, table, allowed_properties, user_data); g_hash_table_destroy (table); }
static void _offer_with_address (TpStreamTubeChannel *self, GHashTable *params) { GValue *addressv = NULL; GError *error = NULL; addressv = tp_address_variant_from_g_socket_address (self->priv->address, &self->priv->socket_type, &error); if (error != NULL) { operation_failed (self, error); g_clear_error (&error); goto finally; } /* Connect the NewRemoteConnection signal */ tp_cli_channel_type_stream_tube_connect_to_new_remote_connection ( TP_CHANNEL (self), _new_remote_connection, NULL, NULL, G_OBJECT (self), &error); if (error != NULL) { operation_failed (self, error); g_clear_error (&error); goto finally; } g_assert (self->priv->parameters == NULL); if (params != NULL) self->priv->parameters = g_hash_table_ref (params); else self->priv->parameters = tp_asv_new (NULL, NULL); g_object_notify (G_OBJECT (self), "parameters"); g_object_notify (G_OBJECT (self), "parameters-vardict"); /* Call Offer */ tp_cli_channel_type_stream_tube_call_offer (TP_CHANNEL (self), -1, self->priv->socket_type, addressv, self->priv->access_control, self->priv->parameters, _channel_offered, NULL, NULL, G_OBJECT (self)); finally: if (addressv != NULL) tp_g_value_slice_free (addressv); }
static void vino_tube_servers_manager_init (VinoTubeServersManager *self) { TpDBusDaemon *dbus; GError *error = NULL; TpSimpleClientFactory *factory; self->priv = VINO_TUBE_SERVERS_MANAGER_GET_PRIVATE (self); self->priv->vino_tube_servers = NULL; self->priv->alternative_port = 26570; dbus = tp_dbus_daemon_dup (NULL); factory = TP_SIMPLE_CLIENT_FACTORY (tp_automatic_client_factory_new (dbus)); g_object_unref (dbus); tp_simple_client_factory_add_contact_features_varargs (factory, TP_CONTACT_FEATURE_ALIAS, TP_CONTACT_FEATURE_AVATAR_DATA, TP_CONTACT_FEATURE_INVALID); tp_simple_client_factory_add_channel_features_varargs (factory, TP_CHANNEL_FEATURE_CONTACTS, 0); self->priv->handler = tp_simple_handler_new_with_factory (factory, FALSE, FALSE, "Vino", FALSE, handle_channels_cb, self, NULL); g_object_unref (factory); tp_base_client_take_handler_filter (self->priv->handler, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, TP_PROP_CHANNEL_REQUESTED, G_TYPE_BOOLEAN, TRUE, TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, G_TYPE_STRING, "rfb", NULL)); if (!tp_base_client_register (self->priv->handler, &error)) { dprintf (TUBE, "Failed to register Handler: %s\n", error->message); g_error_free (error); } }
ConnectResult TelepathyAccountHandler::connect() { UT_DEBUGMSG(("TelepathyAccountHandler::connect()\n")); AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager(); UT_return_val_if_fail(pManager, CONNECT_FAILED); UT_return_val_if_fail(m_pTpClient == NULL, CONNECT_INTERNAL_ERROR); // inform telepathy that we can handle incoming AbiCollab tubes GError *error = NULL; TpDBusDaemon* dbus = tp_dbus_daemon_dup (&error); UT_return_val_if_fail(dbus, CONNECT_FAILED); m_pTpClient = tp_simple_handler_new(dbus, TRUE, FALSE, "AbiCollab", FALSE, handle_dbus_channel, this, NULL); tp_base_client_take_handler_filter(m_pTpClient, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_DBUS_TUBE, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_ROOM, TP_PROP_CHANNEL_TYPE_DBUS_TUBE_SERVICE_NAME, G_TYPE_STRING, INTERFACE, NULL ) ); if (!tp_base_client_register(m_pTpClient, &error)) { UT_DEBUGMSG(("Error registering tube handler: %s", error->message)); UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); } UT_DEBUGMSG(("Tube handler setup, listening for incoming tubes...\n")); // we are connected now, time to start sending out messages (such as events) pManager->registerEventListener(this); // signal all listeners we are logged in AccountOnlineEvent event; pManager->signal(event); return CONNECT_SUCCESS; }
int main (int argc, char **argv) { TpBaseClient *client; TpAccountManager *am; GMainLoop *loop; g_type_init (); loop = g_main_loop_new (NULL, FALSE); am = tp_account_manager_dup (); client = tp_simple_handler_new_with_am (am, FALSE, FALSE, "Phoenix.Authenticator", FALSE, handle_channels_cb, NULL, NULL); tp_base_client_take_handler_filter (client, tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_SERVER_AUTHENTICATION, TP_PROP_CHANNEL_TYPE_SERVER_AUTHENTICATION_AUTHENTICATION_METHOD, G_TYPE_STRING, TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION, NULL)); tp_base_client_register (client, NULL); g_main_loop_run (loop); g_object_unref (am); g_object_unref (client); g_main_loop_unref (loop); return 0; }
static void tp_yts_client_constructed (GObject *obj) { TpYtsClient *self = TP_YTS_CLIENT (obj); TpBaseClient *client = TP_BASE_CLIENT (self); /* chain up to TpBaseClient first */ G_OBJECT_CLASS (tp_yts_client_parent_class)->constructed (obj); _tp_yts_register_dbus_glib_marshallers (); tp_base_client_set_handler_bypass_approval (client, FALSE); tp_base_client_take_handler_filter (client, tp_asv_new ( /* ChannelType */ TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_YTS_IFACE_CHANNEL, /* TargetService */ TP_YTS_IFACE_CHANNEL ".TargetService", G_TYPE_STRING, self->priv->service_name, NULL)); }
static void conn_ready (TpConnection *conn, const GError *in_error, gpointer user_data) { char **argv = (char **) user_data; GError *error = NULL; g_print (" > conn_ready\n"); handle_error (in_error); /* check if the Requests interface is available */ if (tp_proxy_has_interface_by_id (conn, TP_IFACE_QUARK_CONNECTION_INTERFACE_REQUESTS)) { /* we need to ensure a contact list */ GHashTable *props = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_LIST, TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, "subscribe", NULL); tp_cli_connection_interface_requests_call_ensure_channel ( conn, -1, props, create_contact_list_channel_cb, argv, NULL, NULL); g_hash_table_destroy (props); } }
void empathy_share_my_desktop_share_with_contact (EmpathyContact *contact) { TpAccountChannelRequest *req; GHashTable *request; TpContact *tp_contact; tp_contact = empathy_contact_get_tp_contact (contact); DEBUG ("Creation of ShareMyDesktop"); if (!TP_IS_CONTACT (tp_contact)) { DEBUG ("It's not a tp contact"); return; } request = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT, tp_contact_get_handle (tp_contact), TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, G_TYPE_STRING, "rfb", NULL); req = tp_account_channel_request_new (empathy_contact_get_account (contact), request, TP_USER_ACTION_TIME_CURRENT_TIME); tp_account_channel_request_create_channel_async (req, NULL, NULL, create_tube_channel_cb, NULL); g_object_unref (req); g_hash_table_unref (request); }
void _client_create_tube_async (TpAccount *account, const gchar *contact_id, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *simple; CreateTubeData *data; GHashTable *request; TpAccountChannelRequest *acr; simple = g_simple_async_result_new (NULL, callback, user_data, _client_create_tube_finish); data = g_slice_new0 (CreateTubeData); g_simple_async_result_set_op_res_gpointer (simple, data, (GDestroyNotify) create_tube_data_free); request = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, contact_id, TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, G_TYPE_STRING, TUBE_SERVICE, NULL); acr = tp_account_channel_request_new (account, request, G_MAXINT64); tp_account_channel_request_create_and_handle_channel_async (acr, NULL, create_channel_cb, simple); g_hash_table_unref (request); g_object_unref (acr); }