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; }
gboolean empathy_streamed_media_factory_register (EmpathyStreamedMediaFactory *self, GError **error) { EmpathyStreamedMediaFactoryPriv *priv = GET_PRIV (self); return tp_base_client_register (priv->handler, error); }
gboolean empathy_ft_factory_register (EmpathyFTFactory *self, GError **error) { EmpathyFTFactoryPriv *priv = GET_PRIV (self); return tp_base_client_register (priv->handler, error); }
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); } }
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); }
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; }
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); } }
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 GObject * empathy_chatroom_manager_constructor (GType type, guint n_props, GObjectConstructParam *props) { GObject *obj; EmpathyChatroomManager *self; EmpathyChatroomManagerPriv *priv; GError *error = NULL; if (chatroom_manager_singleton != NULL) return g_object_ref (chatroom_manager_singleton); /* Parent constructor chain */ obj = G_OBJECT_CLASS (empathy_chatroom_manager_parent_class)-> constructor (type, n_props, props); self = EMPATHY_CHATROOM_MANAGER (obj); priv = GET_PRIV (self); priv->ready = FALSE; chatroom_manager_singleton = self; g_object_add_weak_pointer (obj, (gpointer) &chatroom_manager_singleton); priv->account_manager = tp_account_manager_dup (); tp_proxy_prepare_async (priv->account_manager, NULL, account_manager_ready_cb, g_object_ref (self)); if (priv->file == NULL) { /* Set the default file path */ gchar *dir; dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL); if (!g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR); priv->file = g_build_filename (dir, CHATROOMS_XML_FILENAME, NULL); g_free (dir); } /* Setup a room observer */ priv->observer = tp_simple_observer_new_with_am (priv->account_manager, TRUE, "Empathy.ChatroomManager", TRUE, observe_channels_cb, self, NULL); tp_base_client_take_observer_filter (priv->observer, 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)); if (!tp_base_client_register (priv->observer, &error)) { g_critical ("Failed to register Observer: %s", error->message); g_error_free (error); } return obj; }
/** * tp_yts_client_register: * @self: The client object. * @error: If not %NULL, raise an error here when %FALSE is returned. * * Register this client with telepathy. This must be done before new channels * are created or received. * * Returns: %TRUE if registering was successful. */ gboolean tp_yts_client_register (TpYtsClient *self, GError **error) { return tp_base_client_register (TP_BASE_CLIENT (self), error); }