static void location_set_location (TpSvcConnectionInterfaceLocation *iface, GHashTable *location, DBusGMethodInvocation *context) { GabbleConnection *conn = GABBLE_CONNECTION (iface); LmMessage *msg; LmMessageNode *geoloc; WockyNode *item; GHashTableIter iter; gpointer key, value; GError *err = NULL; TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED ((TpBaseConnection *) conn, context); if (!(conn->features & GABBLE_CONNECTION_FEATURES_PEP)) { GError error = { TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED, "Server does not support PEP, cannot publish geolocation" }; dbus_g_method_return_error (context, &error); return; } gabble_connection_ensure_capabilities (conn, gabble_capabilities_get_geoloc_notify ()); msg = wocky_pep_service_make_publish_stanza (conn->pep_location, &item); geoloc = wocky_node_add_child_ns (item, "geoloc", NS_GEOLOC); DEBUG ("SetLocation to"); build_mapping_tables (); g_hash_table_iter_init (&iter, location); while (g_hash_table_iter_next (&iter, &key, &value)) { if (!add_to_geoloc_node ((const gchar *) key, (GValue *) value, geoloc, &err)) { DEBUG ("%s", err->message); dbus_g_method_return_error (context, err); g_error_free (err); goto out; } } if (!_gabble_connection_send_with_reply (conn, msg, set_location_sent_cb, G_OBJECT (conn), context, NULL)) { GError error = { TP_ERRORS, TP_ERROR_NETWORK_ERROR, "Failed to send msg" }; dbus_g_method_return_error (context, &error); } out: lm_message_unref (msg); }
static void get_alias_flags (TpSvcConnectionInterfaceAliasing *aliasing, DBusGMethodInvocation *context) { TpBaseConnection *base = TP_BASE_CONNECTION (aliasing); TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); tp_svc_connection_interface_aliasing_return_from_get_alias_flags (context, TP_CONNECTION_ALIAS_FLAG_USER_SET); }
static void conn_power_saving_set_power_saving ( TpSvcConnectionInterfacePowerSaving *conn, gboolean enable, DBusGMethodInvocation *context) { GabbleConnection *self = GABBLE_CONNECTION (conn); TpBaseConnection *base = TP_BASE_CONNECTION (self); gboolean enabled; TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); g_object_get (G_OBJECT (self), "power-saving", &enabled, NULL); if (enable == enabled) { /* no-op */ tp_svc_connection_interface_power_saving_return_from_set_power_saving ( context); return; } DEBUG ("%sabling presence queueing", enable ? "en" : "dis"); /* google:queue is loosely described here: * <http://mail.jabber.org/pipermail/summit/2010-February/000528.html>. Since * April 2011, it is advertised as a stream feature by the Google Talk * server; the development version of M-Link, and possibly other servers, * also implement the protocol and advertise this stream feature. */ if (self->features & GABBLE_CONNECTION_FEATURES_GOOGLE_QUEUE) { ToggleQueueingContext *queueing_context; queueing_context = g_slice_new0 (ToggleQueueingContext); queueing_context->enabling = enable; queueing_context->dbus_context = context; google_queueing_send_command (self, enable ? "enable" : "disable", toggle_google_queueing_cb, queueing_context); } else { /* If the server doesn't support any method of queueing, we can still * do it locally by enabling power save mode on Wocky. */ WockyPorter *porter = gabble_connection_dup_porter (self); wocky_c2s_porter_enable_power_saving_mode (WOCKY_C2S_PORTER (porter), enable); DEBUG ("%sabled local stanza queueing", enable ? "En" : "Dis"); g_object_unref (porter); maybe_emit_power_saving_changed (self, enable); tp_svc_connection_interface_power_saving_return_from_set_power_saving ( context); } }
static void request_aliases (TpSvcConnectionInterfaceAliasing *aliasing, const GArray *contacts, DBusGMethodInvocation *context) { ExampleContactListConnection *self = EXAMPLE_CONTACT_LIST_CONNECTION (aliasing); TpBaseConnection *base = TP_BASE_CONNECTION (aliasing); TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base, TP_HANDLE_TYPE_CONTACT); GPtrArray *result; gchar **strings; GError *error = NULL; guint i; TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); if (!tp_handles_are_valid (contact_repo, contacts, FALSE, &error)) { dbus_g_method_return_error (context, error); g_error_free (error); return; } result = g_ptr_array_sized_new (contacts->len + 1); for (i = 0; i < contacts->len; i++) { TpHandle contact = g_array_index (contacts, TpHandle, i); const gchar *alias = example_contact_list_manager_get_alias ( self->priv->list_manager, contact); g_ptr_array_add (result, (gchar *) alias); } g_ptr_array_add (result, NULL); strings = (gchar **) g_ptr_array_free (result, FALSE); tp_svc_connection_interface_aliasing_return_from_request_aliases (context, (const gchar **) strings); g_free (strings); }
static void tp_contacts_mixin_get_contact_attributes_impl ( TpSvcConnectionInterfaceContacts *iface, const GArray *handles, const char **interfaces, gboolean hold, DBusGMethodInvocation *context) { TpBaseConnection *conn = TP_BASE_CONNECTION (iface); GHashTable *result; TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (conn, context); result = tp_contacts_mixin_get_contact_attributes (G_OBJECT (conn), handles, interfaces, always_included_interfaces, NULL); tp_svc_connection_interface_contacts_return_from_get_contact_attributes ( context, result); g_hash_table_unref (result); }
static void get_aliases (TpSvcConnectionInterfaceAliasing *aliasing, const GArray *contacts, DBusGMethodInvocation *context) { ExampleContactListConnection *self = EXAMPLE_CONTACT_LIST_CONNECTION (aliasing); TpBaseConnection *base = TP_BASE_CONNECTION (aliasing); TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base, TP_HANDLE_TYPE_CONTACT); GHashTable *result; GError *error = NULL; guint i; TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); if (!tp_handles_are_valid (contact_repo, contacts, FALSE, &error)) { dbus_g_method_return_error (context, error); g_error_free (error); return; } result = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL); for (i = 0; i < contacts->len; i++) { TpHandle contact = g_array_index (contacts, TpHandle, i); const gchar *alias = example_contact_list_manager_get_alias ( self->priv->list_manager, contact); g_hash_table_insert (result, GUINT_TO_POINTER (contact), (gchar *) alias); } tp_svc_connection_interface_aliasing_return_from_get_aliases (context, result); g_hash_table_destroy (result); }
static void tp_contacts_mixin_get_contact_by_id_impl ( TpSvcConnectionInterfaceContacts *iface, const gchar *id, const gchar **interfaces, DBusGMethodInvocation *context) { TpBaseConnection *conn = TP_BASE_CONNECTION (iface); TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn, TP_HANDLE_TYPE_CONTACT); GetContactByIdData *data; TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (conn, context); data = g_slice_new0 (GetContactByIdData); data->conn = g_object_ref (conn); data->interfaces = g_strdupv ((gchar **) interfaces); data->context = context; tp_handle_ensure_async (contact_repo, conn, id, NULL, ensure_handle_cb, data); }