コード例 #1
0
GabbleConnection *
gabble_call_member_get_connection (GabbleCallMember *self)
{
  TpBaseChannel *base_chan = TP_BASE_CHANNEL (self->priv->call);

  return GABBLE_CONNECTION (tp_base_channel_get_connection (base_chan));
}
コード例 #2
0
ファイル: conn-location.c プロジェクト: jku/telepathy-gabble
static void
location_request_location (
    TpSvcConnectionInterfaceLocation *iface,
    TpHandle handle,
    DBusGMethodInvocation *context)
{
  GabbleConnection *self = GABBLE_CONNECTION (iface);
  TpBaseConnection *base = (TpBaseConnection *) self;
  TpHandleRepoIface *contact_handles = tp_base_connection_get_handles (base,
      TP_HANDLE_TYPE_CONTACT);
  const gchar *jid;
  WockyBareContact *contact;
  YetAnotherContextStruct *ctx;
  GError *error = NULL;

  if (!tp_handle_is_valid (contact_handles, handle, &error))
    {
      dbus_g_method_return_error (context, error);
      g_error_free (error);
      return;
    }

  /* Oh! for GDBus. */
  ctx = g_slice_new (YetAnotherContextStruct);
  ctx->self = g_object_ref (self);
  ctx->handle = handle;
  ctx->context = context;

  jid = tp_handle_inspect (contact_handles, handle);
  contact = ensure_bare_contact_from_jid (self, jid);
  DEBUG ("fetching location for '%s'", jid);
  wocky_pep_service_get_async (self->pep_location, contact, NULL,
      request_location_reply_cb, ctx);
  g_object_unref (contact);
}
コード例 #3
0
static gboolean
poll_unread_mails_cb (gpointer user_data)
{
  GabbleConnection *conn = GABBLE_CONNECTION (user_data);
  GabbleConnectionMailNotificationPrivate *priv = conn->mail_priv;

  if (priv->poll_count * POLL_DELAY >= POLL_DURATION)
    {
      DEBUG ("%i seconds since <new-mail>, stopping polling",
          priv->poll_count * POLL_DELAY);
      priv->poll_timeout_id = 0;
      priv->poll_count = 0;
      return FALSE;
    }

  priv->poll_count++;

  /* When no subscriber, keep counting time, but don't actually update the
   * data since nobody would care about it */
  if (priv->interested)
    {
      update_unread_mails (conn);
      DEBUG ("%i seconds since <new-mail>, still polling",
          priv->poll_count * POLL_DELAY);
    }

  return TRUE;
}
コード例 #4
0
static void
query_unread_mails_cb (GObject *source_object,
    GAsyncResult *res,
    gpointer user_data)
{
  GError *error = NULL;
  WockyPorter *porter = WOCKY_PORTER (source_object);
  WockyStanza *reply = wocky_porter_send_iq_finish (porter, res, &error);
  GabbleConnection *conn = GABBLE_CONNECTION (user_data);

  if (reply == NULL ||
      wocky_stanza_extract_errors (reply, NULL, &error, NULL, NULL))
    {
      DEBUG ("Failed retreive unread emails information: %s", error->message);
      g_error_free (error);
    }
  else if (conn->mail_priv->interested)
    {
      WockyNode *node = wocky_node_get_child (
          wocky_stanza_get_top_node (reply), "mailbox");

      DEBUG ("Got unread mail details");

      if (node != NULL)
        store_unread_mails (conn, node);
    }
  /* else we no longer care about unread mail, so ignore it */

  tp_clear_object (&reply);

  return_from_request_inbox_url (conn);
}
コード例 #5
0
ファイル: conn-location.c プロジェクト: jku/telepathy-gabble
void
conn_location_properties_getter (GObject *object,
                                 GQuark interface,
                                 GQuark name,
                                 GValue *value,
                                 gpointer getter_data)
{
  GabbleConnection *conn = GABBLE_CONNECTION (object);

  if (!tp_strdiff (g_quark_to_string (name), "LocationAccessControlTypes"))
    {
      guint access_control_type =
        TP_RICH_PRESENCE_ACCESS_CONTROL_TYPE_PUBLISH_LIST;
      GArray *access_control = g_array_sized_new (FALSE, FALSE,
          sizeof (guint), 1);

      g_array_append_val (access_control, access_control_type);
      g_value_take_boxed (value, access_control);
    }
  else if (!tp_strdiff (g_quark_to_string (name), "LocationAccessControl"))
    {
      GValueArray *access_control = g_value_array_new (2);
      GValue type = {0,};
      GValue variant = {0,};
      GValue *allocated_value;

      /* G_TYPE_UINT is the D-Bus type of TpRichPresenceAccessControlType */
      g_value_init (&type, G_TYPE_UINT);
      g_value_set_uint (&type,
          TP_RICH_PRESENCE_ACCESS_CONTROL_TYPE_PUBLISH_LIST);
      g_value_array_append (access_control, &type);
      g_value_unset (&type);

      g_value_init (&variant, G_TYPE_VALUE);
      /* For Publish_List, the variant isn't used, so we set a dummy value,
       * (guint) 0 */
      allocated_value = tp_g_value_slice_new (G_TYPE_UINT);
      g_value_set_uint (allocated_value, 0);
      g_value_set_boxed (&variant, allocated_value);
      g_value_array_append (access_control, &variant);
      g_value_unset (&variant);
      tp_g_value_slice_free (allocated_value);

      g_value_take_boxed (value, access_control);
    }
  else if (name == g_quark_from_static_string ("SupportedLocationFeatures"))
    {
      TpLocationFeatures flags = 0;

      if (conn->features & GABBLE_CONNECTION_FEATURES_PEP)
        flags |= TP_LOCATION_FEATURE_CAN_SET;

      g_value_set_uint (value, flags);
    }
  else
    {
      g_assert_not_reached ();
    }
}
コード例 #6
0
ファイル: conn-location.c プロジェクト: jku/telepathy-gabble
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);
}
コード例 #7
0
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);
    }
}
コード例 #8
0
void
conn_location_properties_getter (GObject *object,
                                 GQuark interface,
                                 GQuark name,
                                 GValue *value,
                                 gpointer getter_data)
{
  GabbleConnection *conn = GABBLE_CONNECTION (object);

  if (!tp_strdiff (g_quark_to_string (name), "LocationAccessControlTypes"))
    {
      guint access_control_type =
        TP_RICH_PRESENCE_ACCESS_CONTROL_TYPE_PUBLISH_LIST;
      GArray *access_control = g_array_sized_new (FALSE, FALSE,
          sizeof (guint), 1);

      g_array_append_val (access_control, access_control_type);
      g_value_take_boxed (value, access_control);
    }
  else if (!tp_strdiff (g_quark_to_string (name), "LocationAccessControl"))
    {
      GValueArray *access_control;
      GValue dummy = G_VALUE_INIT;

      /* For Publish_List, the variant isn't used, so we set a dummy value,
       * (guint) 0 */
      g_value_init (&dummy, G_TYPE_UINT);
      g_value_set_uint (&dummy, 0);

      access_control = tp_value_array_build (2,
          G_TYPE_UINT,
              (guint) TP_RICH_PRESENCE_ACCESS_CONTROL_TYPE_PUBLISH_LIST,
          G_TYPE_VALUE, &dummy,
          G_TYPE_INVALID);

      g_value_unset (&dummy);
      g_value_take_boxed (value, access_control);
    }
  else if (name == g_quark_from_static_string ("SupportedLocationFeatures"))
    {
      TpLocationFeatures flags = 0;

      if (conn->features & GABBLE_CONNECTION_FEATURES_PEP)
        flags |= TP_LOCATION_FEATURE_CAN_SET;

      g_value_set_uint (value, flags);
    }
  else
    {
      g_assert_not_reached ();
    }
}
コード例 #9
0
static void
gabble_mail_notification_request_mail_url (
    TpSvcConnectionInterfaceMailNotification *iface,
    const gchar *in_id,
    const GValue *in_url_data,
    DBusGMethodInvocation *context)
{
  GabbleConnection *conn = GABBLE_CONNECTION (iface);
  GabbleConnectionMailNotificationPrivate *priv = conn->mail_priv;

  if (check_supported_or_dbus_return (conn, context))
    return;

  /* TODO Make sure we don't have to authenticate again */

  if (priv->inbox_url != NULL && priv->inbox_url[0] != 0)
    {
      GValueArray *result;
      gchar *url = NULL;
      GPtrArray *empty_array;

      /* IDs are decimal on the XMPP side and hexadecimal on the wemail side. */
      guint64 tid = g_ascii_strtoull (in_id, NULL, 0);
      url = g_strdup_printf ("%s/#inbox/%" G_GINT64_MODIFIER "x",
          priv->inbox_url, tid);

      empty_array = g_ptr_array_new ();

      result = tp_value_array_build (3,
          G_TYPE_STRING, url ? url : "",
          G_TYPE_UINT, TP_HTTP_METHOD_GET,
          TP_ARRAY_TYPE_HTTP_POST_DATA_LIST, empty_array,
          G_TYPE_INVALID);

      tp_svc_connection_interface_mail_notification_return_from_request_mail_url (
          context, result);

      g_value_array_free (result);
      g_ptr_array_free (empty_array, TRUE);
      g_free (url);
    }
  else
    {
      GError error = { TP_ERRORS, TP_ERROR_NETWORK_ERROR,
          "Failed to retrieve URL from server."};
      dbus_g_method_return_error (context, &error);
    }
}
コード例 #10
0
static void
gabble_mail_notification_request_inbox_url (
    TpSvcConnectionInterfaceMailNotification *iface,
    DBusGMethodInvocation *context)
{
  GabbleConnection *conn = GABBLE_CONNECTION (iface);
  GabbleConnectionMailNotificationPrivate *priv = conn->mail_priv;

  if (check_supported_or_dbus_return (conn, context))
    return;

  /* TODO Make sure we don't have to authenticate again */

  priv->inbox_url_requests = g_list_append (priv->inbox_url_requests, context);

  if (priv->inbox_url != NULL)
    return_from_request_inbox_url (conn);
}
コード例 #11
0
ファイル: conn-location.c プロジェクト: jku/telepathy-gabble
static void
location_get_locations (TpSvcConnectionInterfaceLocation *iface,
                        const GArray *contacts,
                        DBusGMethodInvocation *context)
{
  GabbleConnection *conn = GABBLE_CONNECTION (iface);
  TpBaseConnection *base = (TpBaseConnection *) conn;
  TpHandleRepoIface *contact_handles;
  guint i;
  GError *error = NULL;
  GHashTable *return_locations = g_hash_table_new_full (g_direct_hash,
      g_direct_equal, NULL, (GDestroyNotify) g_hash_table_unref);

  DEBUG ("GetLocation for contacts:");

  gabble_connection_ensure_capabilities (conn,
      gabble_capabilities_get_geoloc_notify ());

  /* Validate contacts */
  contact_handles = tp_base_connection_get_handles (base,
      TP_HANDLE_TYPE_CONTACT);

  if (!tp_handles_are_valid (contact_handles, contacts, TRUE, &error))
    {
      dbus_g_method_return_error (context, error);
      g_error_free (error);
      g_hash_table_unref (return_locations);
      return;
    }

  for (i = 0; i < contacts->len; i++)
    {
      TpHandle contact = g_array_index (contacts, TpHandle, i);
      GHashTable *location = get_cached_location (conn, contact);

      if (location != NULL)
        g_hash_table_insert (return_locations, GUINT_TO_POINTER (contact),
            location);
    }

  tp_svc_connection_interface_location_return_from_get_locations
      (context, return_locations);
  g_hash_table_unref (return_locations);
}
コード例 #12
0
static void
toggle_google_queueing_cb (GObject *source_object,
    GAsyncResult *res,
    gpointer user_data)
{
  GabbleConnection *self = GABBLE_CONNECTION (source_object);
  ToggleQueueingContext *queueing_context = (ToggleQueueingContext *) user_data;
  GError *error = NULL;
  gboolean enabling;

  enabling = queueing_context->enabling;

  if (!conn_util_send_iq_finish (self, res, NULL, &error))
    {
      DEBUG ("Failed to %sable queueing: %s",
          enabling ? "en" : "dis", error->message);

      enabling = FALSE;

      dbus_g_method_return_error (queueing_context->dbus_context, error);

      g_error_free (error);
    }
  else
    {
      DEBUG ("%sabled queueing", enabling ? "en" : "dis");

      tp_svc_connection_interface_power_saving_return_from_set_power_saving (
          queueing_context->dbus_context);

      if (!enabling)
        google_queueing_send_command (self, "flush", NULL, NULL);
    }

  maybe_emit_power_saving_changed (self, enabling);

  g_slice_free (ToggleQueueingContext, queueing_context);
}
コード例 #13
0
ファイル: conn-location.c プロジェクト: jku/telepathy-gabble
static void
conn_location_fill_contact_attributes (GObject *obj,
    const GArray *contacts,
    GHashTable *attributes_hash)
{
  GabbleConnection *self = GABBLE_CONNECTION (obj);
  guint i;

  for (i = 0; i < contacts->len; i++)
    {
      TpHandle handle = g_array_index (contacts, TpHandle, i);
      GHashTable *location = get_cached_location (self, handle);

      if (location != NULL)
        {
          GValue *val = tp_g_value_slice_new_take_boxed (
              TP_HASH_TYPE_STRING_VARIANT_MAP, location);

          tp_contacts_mixin_set_contact_attribute (attributes_hash,
              handle, TP_IFACE_CONNECTION_INTERFACE_LOCATION"/location", val);
        }
    }
}
コード例 #14
0
static gboolean
new_mail_handler (WockyPorter *porter,
    WockyStanza *stanza,
    gpointer user_data)
{
  GabbleConnection *conn = GABBLE_CONNECTION (user_data);

  if (conn->mail_priv->interested)
    {
      DEBUG ("Got Google <new-mail> notification");
      update_unread_mails (conn);

      conn->mail_priv->poll_count = 0;
      if (conn->mail_priv->poll_timeout_id == 0)
        {
          DEBUG ("Starting to poll mail for next %i seconds", POLL_DURATION);
          conn->mail_priv->poll_timeout_id = g_timeout_add_seconds (
              POLL_DELAY,
              (GSourceFunc) poll_unread_mails_cb, conn);
        }
    }

  return TRUE;
}