示例#1
0
static void
set_location_sent_cb (GabbleConnection *conn,
    WockyStanza *sent_msg,
    WockyStanza *reply_msg,
    GObject *object,
    gpointer user_data)
{
  DBusGMethodInvocation *context = user_data;
  GError *error = NULL;

  if (!wocky_stanza_extract_errors (reply_msg, NULL, &error, NULL, NULL))
    {
      dbus_g_method_return (context);
    }
  else
    {
      GError *tp_error = NULL;

      DEBUG ("SetLocation failed: %s", error->message);

      gabble_set_tp_error_from_wocky (error, &tp_error);
      dbus_g_method_return_error (context, tp_error);
      g_error_free (tp_error);
      g_error_free (error);
    }
}
示例#2
0
gboolean
conn_util_send_iq_finish (GabbleConnection *self,
    GAsyncResult *result,
    WockyStanza **response,
    GError **error)
{
  GSimpleAsyncResult *res;
  WockyStanza *resp;
  GError *err = NULL;

  g_return_val_if_fail (g_simple_async_result_is_valid (result,
          G_OBJECT (self), conn_util_send_iq_async), FALSE);

  res = (GSimpleAsyncResult *) result;

  resp = g_simple_async_result_get_op_res_gpointer (res);

  if (g_simple_async_result_propagate_error (res, &err) ||
      wocky_stanza_extract_errors (resp, NULL, &err, NULL, NULL))
    {
      gabble_set_tp_error_from_wocky (err, error);
      g_error_free (err);

      return FALSE;
    }

  if (response != NULL)
    *response = g_object_ref (resp);

  return TRUE;
}
示例#3
0
static void
request_location_reply_cb (GObject *source,
    GAsyncResult *res,
    gpointer user_data)
{
  YetAnotherContextStruct *ctx = user_data;
  WockyStanza *reply;
  WockyNode *item_node;
  GError *wocky_error = NULL, *tp_error = NULL;

  reply = wocky_pep_service_get_finish (WOCKY_PEP_SERVICE (source), res,
      &item_node, &wocky_error);

  if (reply == NULL ||
      wocky_stanza_extract_errors (reply, NULL, &wocky_error, NULL, NULL))
    {
      DEBUG ("fetching location failed: %s", wocky_error->message);
      gabble_set_tp_error_from_wocky (wocky_error, &tp_error);
      dbus_g_method_return_error (ctx->context, tp_error);
      g_error_free (tp_error);
    }
  else
    {
      GHashTable *location;

      if (update_location_from_item (ctx->self, ctx->handle, item_node))
        {
          location = get_cached_location (ctx->self, ctx->handle);
          /* We just cached a location for this contact, so it should be
           * non-NULL.
           */
          g_return_if_fail (location != NULL);
        }
      else
        {
          /* If the location's unparseable, we'll hit this path. That seems
           * okay.
           */
          location = g_hash_table_new (NULL, NULL);
        }

      tp_svc_connection_interface_location_return_from_request_location (
          ctx->context, location);
      g_hash_table_unref (location);
    }

  tp_clear_object (&reply);
  g_object_unref (ctx->self);
  g_slice_free (YetAnotherContextStruct, ctx);
}