static void
install_package_names_cb (GObject      *source_object,
                          GAsyncResult *res,
                          gpointer      user_data)
{
  GVariant *output;
  IMEData  *data = (IMEData *) user_data;
  GError   *error = NULL;

  output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
                                          res,
                                          &error);
  g_object_unref (source_object);

  if (output)
    {
      g_variant_unref (output);
    }
  else
    {
      if (error->domain != G_IO_ERROR ||
          error->code != G_IO_ERROR_CANCELLED)
        g_warning ("%s", error->message);
      g_error_free (error);
    }

  install_missing_executables_cb (data);
}
예제 #2
0
static void current_service_autoconnect_set_cb(GObject *source, GAsyncResult *res, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	struct ofono_wan_data *od = cbd->user;
	wan_result_cb cb = cbd->cb;
	struct wan_error werror;
	GError *error = 0;
	GDBusConnection *conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);

	GVariant *result = g_dbus_connection_call_finish(conn, res, &error);
	if (error) {
		g_warning("Failed to set auto connect field for cellular service %s: %s",
				  od->current_service_path, error->message);
		g_error_free(error);

		werror.code = WAN_ERROR_FAILED;
		cb(&werror, cbd->data);

		goto cleanup;
	}

	g_variant_unref(result);

	cb(NULL, cbd->data);

cleanup:
	g_free(cbd);
}
예제 #3
0
static void current_service_enabled_cb(GObject *source, GAsyncResult *res, gpointer user_data)
{
	struct cb_data *cbd = user_data;
	struct ofono_wan_data *od = cbd->user;
	wan_result_cb cb = cbd->cb;
	struct wan_error werror;
	GError *error = 0;
	GDBusConnection *conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);

	GVariant *result = g_dbus_connection_call_finish(conn, res, &error);
	if (error) {
		g_warning("Failed to %s current cellular service %s: %s",
				  !od->pending_configuration->disablewan ? "enable" : "disable",
				  od->current_service_path, error->message);
		g_error_free(error);

		werror.code = WAN_ERROR_FAILED;
		cb(&werror, cbd->data);

		g_free(cbd);

		return;
	}

	g_variant_unref(result);

	g_dbus_connection_call(conn, "net.connman", od->current_service_path,
						   "net.connman.Service", "SetProperty",
						   g_variant_new("(sv)", "AutoConnect", g_variant_new_boolean(!od->pending_configuration->disablewan)), NULL,
						   G_DBUS_CALL_FLAGS_NONE, -1, NULL,
						   current_service_autoconnect_set_cb, od);
}
예제 #4
0
static void
openoffice_missing_unoconv_ready_cb (GObject *source,
                                     GAsyncResult *res,
                                     gpointer user_data)
{
  PdfLoadJob *job = user_data;
  GError *error = NULL;

  g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), res, &error);
  if (error != NULL) {
    GError *local_error;

    /* can't install unoconv with packagekit - nothing else we can do */
    g_warning ("unoconv not found, and PackageKit failed to install it with error %s",
               error->message);
    local_error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
                                       _("LibreOffice is required to view this document"));

    pdf_load_job_complete_error (job, local_error);
    g_error_free (error);
    return;
  }

  /* now that we have unoconv installed, try again refreshing the cache */
  pdf_load_job_openoffice_refresh_cache (job);
}
static void
printer_set_enabled_cb (GObject      *source_object,
                        GAsyncResult *res,
                        gpointer      user_data)
{
  GVariant *output;
  PCData   *data = (PCData *) user_data;
  GError   *error = NULL;

  output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
                                          res,
                                          &error);
  g_object_unref (source_object);

  if (output)
    {
      g_variant_unref (output);
    }
  else
    {
      if (error->domain != G_IO_ERROR ||
          error->code != G_IO_ERROR_CANCELLED)
        g_warning ("%s", error->message);
      g_error_free (error);
    }

  data->set_enabled_finished = TRUE;
  printer_configure_async_finish (data);
}
예제 #6
0
static void
g_dbus_action_group_describe_all_done (GObject      *source,
                                       GAsyncResult *result,
                                       gpointer      user_data)
{
  GDBusActionGroup *group= user_data;
  GVariant *reply;

  g_assert (group->actions == NULL);
  group->actions = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, action_info_free);

  g_assert (group->connection == (gpointer) source);
  reply = g_dbus_connection_call_finish (group->connection, result, NULL);

  if (reply != NULL)
    {
      GVariantIter *iter;
      ActionInfo *action;

      g_variant_get (reply, "(a{s(bgav)})", &iter);
      while ((action = action_info_new_from_iter (iter)))
        {
          g_hash_table_insert (group->actions, action->name, action);

          if (group->strict)
            g_action_group_action_added (G_ACTION_GROUP (group), action->name);
        }
      g_variant_iter_free (iter);
      g_variant_unref (reply);
    }

  g_object_unref (group);
}
static void
on_set_static_hostname (GObject *source,
                        GAsyncResult *result,
                        gpointer user_data)
{
  GisAccountPageEnterprise *page = user_data;
  GisAccountPageEnterprisePrivate *priv = gis_account_page_enterprise_get_instance_private (page);
  GError *error = NULL;
  GVariant *retval;

  retval = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), result, &error);
  if (error != NULL) {
    join_show_prompt (page, error);
    g_error_free (error);
    return;
  }

  g_variant_unref (retval);

  /* Prompted for some admin credentials, try to use them to log in */
  um_realm_login (priv->realm,
                  gtk_entry_get_text (GTK_ENTRY (priv->join_name)),
                  gtk_entry_get_text (GTK_ENTRY (priv->join_password)),
                  priv->cancellable, on_join_login, page);
}
예제 #8
0
static void
bluez_connect_cb (GDBusConnection *dbus_connection,
                  GAsyncResult *res,
                  gpointer user_data)
{
	GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
	GObject *result_object = g_async_result_get_source_object (G_ASYNC_RESULT (result));
	NMBluezDevice *self = NM_BLUEZ_DEVICE (result_object);
	NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
	GError *error = NULL;
	char *device;
	GVariant *variant;

	variant = g_dbus_connection_call_finish (dbus_connection, res, &error);

	if (!variant) {
		g_simple_async_result_take_error (result, error);
	} else {
		g_variant_get (variant, "(s)", &device);

		g_simple_async_result_set_op_res_gpointer (result,
		                                           g_strdup (device),
		                                           g_free);
		priv->bt_iface = device;
		g_variant_unref (variant);
	}

	g_simple_async_result_complete (result);
	g_object_unref (result);
	g_object_unref (result_object);
}
static void
got_name_owner (GObject      *object,
                GAsyncResult *result,
                gpointer      user_data)
{
  GetNameOwnerData *data = user_data;
  GError *error = NULL;
  GVariant *reply;
  const gchar *owner;

  reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (object), result, &error);

  if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
    {
      g_error_free (error);
      goto out;
    }

  if (reply == NULL)
    {
      if (!g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER))
        g_warning ("bus_watch_namespace: error calling org.freedesktop.DBus.GetNameOwner: %s", error->message);
      g_error_free (error);
      goto out;
    }

  g_variant_get (reply, "(&s)", &owner);
  namespace_watcher_name_appeared (data->watcher, data->name, owner);

  g_variant_unref (reply);

out:
  g_free (data->name);
  g_slice_free (GetNameOwnerData, data);
}
예제 #10
0
static void
on_retrieved_unix_uid_pid (GObject              *src,
			   GAsyncResult         *res,
			   gpointer              user_data)
{
  AsyncGetBusNameCredsData *data = user_data;
  GVariant *v;

  v = g_dbus_connection_call_finish ((GDBusConnection*)src, res,
				     data->caught_error ? NULL : data->error);
  if (!v)
    {
      data->caught_error = TRUE;
    }
  else
    {
      guint32 value;
      g_variant_get (v, "(u)", &value);
      g_variant_unref (v);
      if (!data->retrieved_uid)
	{
	  data->retrieved_uid = TRUE;
	  data->uid = value;
	}
      else
	{
	  g_assert (!data->retrieved_pid);
	  data->retrieved_pid = TRUE;
	  data->pid = value;
	}
    }
}
예제 #11
0
static void
writeback_file_finished  (GObject      *source_object,
                          GAsyncResult *res,
                          gpointer      user_data)
{
	WritebackFileData *data = user_data;
	GError *error = NULL;

	g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
	                               res, &error);

	if (error && error->code == G_DBUS_ERROR_NO_REPLY && data->retries < 5) {
		/* This happens in case of exit() of the tracker-writeback binary, which
		 * happens on unmount of the FS event, for example */

		g_debug ("Retrying write-back after unmount (timeout in 5 seconds)");
		tracker_miner_fs_writeback_notify (data->fs, data->file, NULL);

		data->retry_timeout = g_timeout_add_seconds (5, retry_idle, data);
		data->retries++;

	} else {
		tracker_miner_fs_writeback_notify (data->fs, data->file, error);
		writeback_file_data_free (data);
	}
}
static void
printer_add_async_scb3 (GObject      *source_object,
                        GAsyncResult *res,
                        gpointer      user_data)
{
  PpNewPrinter        *printer = (PpNewPrinter *) user_data;
  PpNewPrinterPrivate *priv = printer->priv;
  GVariant            *output;
  PPDName             *ppd_item = NULL;
  GError              *error = NULL;

  output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
                                          res,
                                          &error);
  g_object_unref (source_object);

  if (output)
    {
      ppd_item = get_ppd_item_from_output (output);
      g_variant_unref (output);
    }
  else
    {
      if (error->domain != G_IO_ERROR ||
          error->code != G_IO_ERROR_CANCELLED)
        g_warning ("%s", error->message);
    }

  if ((!error ||
      error->domain != G_IO_ERROR ||
      error->code != G_IO_ERROR_CANCELLED) &&
      ppd_item && ppd_item->ppd_name)
    {
      priv->ppd_name = g_strdup (ppd_item->ppd_name);
      printer_add_real_async (printer);
    }
  else
    {
      _pp_new_printer_add_async_cb (FALSE, printer);
    }

  if (error)
    {
      g_error_free (error);
    }

  if (ppd_item)
    {
      g_free (ppd_item->ppd_name);
      g_free (ppd_item);
    }
}
예제 #13
0
static void
start_service_by_name_cb (GObject      *source_object,
                          GAsyncResult *res,
                          gpointer      user_data)
{
  Client *client = user_data;
  GVariant *result;

  result = NULL;

  result = g_dbus_connection_call_finish (client->connection,
                                          res,
                                          NULL);
  if (result != NULL)
    {
      guint32 start_service_result;
      g_variant_get (result, "(u)", &start_service_result);

      if (start_service_result == 1) /* DBUS_START_REPLY_SUCCESS */
        {
          invoke_get_name_owner (client);
        }
      else if (start_service_result == 2) /* DBUS_START_REPLY_ALREADY_RUNNING */
        {
          invoke_get_name_owner (client);
        }
      else
        {
          g_warning ("Unexpected reply %d from StartServiceByName() method", start_service_result);
          call_vanished_handler (client, FALSE);
          client->initialized = TRUE;
        }
    }
  else
    {
      /* Errors are not unexpected; the bus will reply e.g.
       *
       *   org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Epiphany2
       *   was not provided by any .service files
       *
       * This doesn't mean that the name doesn't have an owner, just
       * that it's not provided by a .service file. So proceed to
       * invoke GetNameOwner().
       */
      invoke_get_name_owner (client);
    }

  if (result != NULL)
    g_variant_unref (result);
  client_unref (client);
}
static void on_response_sap_transfer_apdu(GObject *source_object, GAsyncResult *res, gpointer user_data)
{
	GError *error = NULL;
	GDBusConnection *conn = NULL;
	GVariant *dbus_result;

	GVariantIter *iter = NULL;
	GVariant *param_gv = NULL;
	GVariant *inner_gv = NULL;
	guchar rt_i;
	int i = 0;

	struct tapi_resp_data *evt_cb_data = user_data;
	TelSimSapResultCode_t result = TAPI_SIM_SAP_RESULT_CODE_OK;
	TelSapApduData_t r_apdu;

	dbg("Func Entrance");
	memset(&r_apdu, 0, sizeof(TelSapApduData_t));

	conn = G_DBUS_CONNECTION (source_object);
	dbus_result = g_dbus_connection_call_finish(conn, res, &error);

	if (dbus_result) {
		/*	dbg("dbus_result type_format(%s)", g_variant_get_type_string(dbus_result));*/
		g_variant_get(dbus_result, "(i@v)", &result, &param_gv);
		inner_gv = g_variant_get_variant(param_gv);

		g_variant_get(inner_gv, "ay", &iter);
		while (g_variant_iter_loop(iter, "y", &rt_i)) {
			r_apdu.apdu_data[i] = rt_i;
			i++;
		}
		r_apdu.apdu_len = (int) i;
		g_variant_iter_free(iter);
		g_variant_unref(inner_gv);
		g_variant_unref(param_gv);
		/*		for(i=0; i < (int)r_apdu.apdu_len; i++)
		 dbg("apdu[%d][0x%02x]",i, r_apdu.apdu_data[i]);*/
	}
	else {
		result = TAPI_SIM_SAP_RESULT_CODE_DATA_NOT_AVAILABLE;
		dbg( "g_dbus_conn failed. error (%s)", error->message);
		g_error_free(error);
	}
	if (evt_cb_data->cb_fn) {
		evt_cb_data->cb_fn(evt_cb_data->handle, result, (void*)&r_apdu, evt_cb_data->user_data);
	}

	free(evt_cb_data);
}
static void
printer_add_real_async_dbus_cb (GObject      *source_object,
                                GAsyncResult *res,
                                gpointer      user_data)
{
  PpNewPrinter        *printer;
  PpNewPrinterPrivate *priv;
  GVariant            *output;
  GError              *error = NULL;

  output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
                                          res,
                                          &error);
  g_object_unref (source_object);

  if (output)
    {
      const gchar *ret_error;

      g_variant_get (output, "(&s)", &ret_error);
      if (ret_error[0] != '\0')
        {
          g_warning ("%s", ret_error);
        }

      g_variant_unref (output);
    }
  else
    {
      if (error->domain != G_IO_ERROR ||
          error->code != G_IO_ERROR_CANCELLED)
        g_warning ("%s", error->message);
    }

  if (!error ||
      error->domain != G_IO_ERROR ||
      error->code != G_IO_ERROR_CANCELLED)
    {
      printer = (PpNewPrinter *) user_data;
      priv = printer->priv;

      get_named_dest_async (priv->name,
                            printer_add_real_async_cb,
                            printer);
    }

  if (error)
      g_error_free (error);
}
static void
get_missing_executables_cb (GObject      *source_object,
                            GAsyncResult *res,
                            gpointer      user_data)
{
  GVariant *output;
  IMEData  *data = (IMEData *) user_data;
  GError   *error = NULL;
  GList    *executables = NULL;
  GList    *item;

  output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
                                          res,
                                          &error);

  if (output)
    {
      GVariant *array;

      g_variant_get (output, "(@as)", &array);

      if (array)
        {
          GVariantIter *iter;
          GVariant     *item;
          gchar        *executable;

          g_variant_get (array, "as", &iter);
          while ((item = g_variant_iter_next_value (iter)))
            {
              g_variant_get (item, "s", &executable);
              executables = g_list_append (executables, executable);
              g_variant_unref (item);
            }

          g_variant_unref (array);
        }

      g_variant_unref (output);
    }
  else if (error->domain == G_DBUS_ERROR &&
           (error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
            error->code == G_DBUS_ERROR_UNKNOWN_METHOD))
    {
      g_warning ("Install system-config-printer which provides \
DBus method \"MissingExecutables\" to find missing executables and filters.");
      g_error_free (error);
    }
예제 #17
0
static void
previewer_close_ready_cb (GObject *source,
                          GAsyncResult *res,
                          gpointer user_data)
{
  GError *error = NULL;

  g_dbus_connection_call_finish (G_DBUS_CONNECTION (source),
                                 res, &error);

  if (error != NULL) {
    DEBUG ("Unable to call Close on NautilusPreviewer: %s",
           error->message);
    g_error_free (error);
  }
}
static void
names_listed (GObject      *object,
              GAsyncResult *result,
              gpointer      user_data)
{
  NamespaceWatcher *watcher;
  GError *error = NULL;
  GVariant *reply;
  GVariantIter *iter;
  const gchar *name;

  reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (object), result, &error);

  if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
    {
      g_error_free (error);
      return;
    }

  watcher = user_data;

  if (reply == NULL)
    {
      g_warning ("bus_watch_namespace: error calling org.freedesktop.DBus.ListNames: %s", error->message);
      g_error_free (error);
      return;
    }

  g_variant_get (reply, "(as)", &iter);
  while (g_variant_iter_next (iter, "&s", &name))
    {
      if (dbus_name_has_namespace (name, watcher->name_space))
        {
          GetNameOwnerData *data = g_slice_new (GetNameOwnerData);
          data->watcher = watcher;
          data->name = g_strdup (name);
          g_dbus_connection_call (watcher->connection, "org.freedesktop.DBus", "/",
                                  "org.freedesktop.DBus", "GetNameOwner",
                                  g_variant_new ("(s)", name), G_VARIANT_TYPE ("(s)"),
                                  G_DBUS_CALL_FLAGS_NONE, -1, watcher->cancellable,
                                  got_name_owner, data);
        }
    }

  g_variant_iter_free (iter);
  g_variant_unref (reply);
}
static void
get_zones_reply (GObject      *source,
                 GAsyncResult *res,
                 gpointer      user_data)
{
        GDBusConnection *bus = G_DBUS_CONNECTION (source);
        GetZonesReplyData *d = user_data;
        GVariant *ret;
        GError *error = NULL;
        const gchar **zones;
        gint idx;
        gint i;

        ret = g_dbus_connection_call_finish (bus, res, &error);

        gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (d->combo),
                                        C_("Firewall zone", "Default"));
        gtk_widget_set_tooltip_text (d->combo, _("The zone defines the trust level of the connection"));

        idx = 0;
        if (error) {
                gtk_widget_set_sensitive (d->combo, FALSE);
                g_error_free (error);
        }
        else {
                gtk_widget_set_sensitive (d->combo, TRUE);
                g_variant_get (ret, "(^a&s)", &zones);

                for (i = 0; zones[i]; i++) {
                        gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (d->combo),
                                                        zones[i]);
                        if (g_strcmp0 (d->zone, zones[i]) == 0)
                                idx = i + 1;
                }
                if (d->zone && idx == 0) {
                        gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (d->combo),
                                                        d->zone);
                        idx = i + 1;
                }
                g_variant_unref (ret);
        }
        gtk_combo_box_set_active (GTK_COMBO_BOX (d->combo), idx);

        g_free (d);
}
예제 #20
0
파일: server.c 프로젝트: epico/ibus
static void
_server_connect_start_portal_cb (GObject      *source_object,
                                 GAsyncResult *res,
                                 gpointer      user_data)
{
    GVariant *result;
    GError *error = NULL;

    result = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
                                            res,
                                            &error);
    if (result != NULL) {
        g_variant_unref (result);
    } else {
        g_print ("portal is not running: %s\n", error->message);
        g_error_free (error);
    }
}
예제 #21
0
static void
reboot_done (GObject *source, GAsyncResult *res, gpointer data)
{
	GCallback reboot_failed = data;
	_cleanup_variant_unref_ GVariant *ret = NULL;
	_cleanup_error_free_ GError *error = NULL;

	ret = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), res, &error);
	if (ret)
		return;

	if (error != NULL) {
		g_warning ("Calling org.gnome.SessionManager.Reboot failed: %s",
			   error->message);
	}

	reboot_failed ();
}
예제 #22
0
static void
bluez_disconnect_cb (GDBusConnection *dbus_connection,
                     GAsyncResult *res,
                     gpointer user_data)
{
	NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (user_data);
	GError *error = NULL;
	GVariant *variant;

	variant = g_dbus_connection_call_finish (dbus_connection, res, &error);
	if (!variant) {
		if (!strstr (error->message, "org.bluez.Error.NotConnected"))
			nm_log_warn (LOGD_BT, "bluez[%s]: failed to disconnect: %s", priv->path, error->message);
		g_error_free (error);
	} else
		g_variant_unref (variant);

	g_object_unref (NM_BLUEZ_DEVICE (user_data));
}
예제 #23
0
static void
previewer_close_ready_cb (GObject *source,
                          GAsyncResult *res,
                          gpointer user_data)
{
  NemoPreviewer *self = user_data;
  GError *error = NULL;

  g_dbus_connection_call_finish (self->priv->connection,
                                 res, &error);

  if (error != NULL) {
    DEBUG ("Unable to call Close on NemoPreviewer: %s",
           error->message);
    g_error_free (error);
  }

  g_object_unref (self);
}
예제 #24
0
static void
select_items_ready_cb (GObject *source,
		       GAsyncResult *res,
		       gpointer user_data)
{
	GDBusConnection *connection = G_DBUS_CONNECTION (source);
	NautilusApplication *self = user_data;
	GError *error = NULL;

	g_dbus_connection_call_finish (connection, res, &error);

	if (error != NULL) {
		g_warning ("Unable to select specified URIs %s\n", error->message);
		g_error_free (error);

		/* open default location instead */
		g_application_open (G_APPLICATION (self), NULL, 0, "");
	}
}
예제 #25
0
static void
can_set_call_finished (GObject      *source,
                       GAsyncResult *result,
                       gpointer      user_data)
{
  Cache *cache = user_data;
  GVariant *reply;

  reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source),
                                         result, NULL);

  if (reply != NULL)
    {
      g_variant_get (reply, "(i)", &cache->value);
      g_variant_unref (reply);
    }

  cache->stamp = g_get_monotonic_time ();
  cache->in_progress = FALSE;
}
static void
libreoffice_missing_ready_cb (GObject *source,
                              GAsyncResult *res,
                              gpointer user_data)
{
  NemoPreviewPdfLoader *self = user_data;
  GError *error = NULL;

  g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), res, &error);
  if (error != NULL) {
    /* can't install libreoffice with packagekit - nothing else we can do */
    /* FIXME: error reporting! */
    g_warning ("libreoffice not found, and PackageKit failed to install it with error %s",
               error->message);
    return;
  }

  /* now that we have libreoffice installed, try again loading the document */
  load_libreoffice (self);
}
예제 #27
0
static void
on_get_connection_unix_user (GObject *source,
                             GAsyncResult *res,
                             gpointer user_data)
{
  gchar *bus_name = user_data;
  InvocationClient *client;
  GError *error = NULL;
  GVariant *value;

  value = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source),
                                         res, &error);

  g_mutex_lock (&inv.mutex);

  client = g_hash_table_lookup (inv.clients, bus_name);

  if (error == NULL)
    {
      if (client)
        {
          g_variant_get (value, "(u)", &client->uid_peer);
          client->uid_state = UID_VALID;
        }
      g_variant_unref (value);
      g_debug ("GetConnectionUnixUser('%s') == %u", bus_name, client->uid_peer);
    }
  else
    {
      if (client)
        client->uid_state = UID_FAILED;
      g_critical ("GetConnectionUnixUser('%s') failed: %s", bus_name, error->message);
      g_error_free (error);
    }

  g_cond_broadcast (&inv.wait_cond);
  g_mutex_unlock (&inv.mutex);

  g_free (bus_name);
}
예제 #28
0
static void
g_dbus_menu_group_start_ready (GObject      *source_object,
                               GAsyncResult *result,
                               gpointer      user_data)
{
  GDBusConnection *connection = G_DBUS_CONNECTION (source_object);
  GDBusMenuGroup *group = user_data;
  GVariant *reply;

  g_assert (group->state == GROUP_PENDING);

  reply = g_dbus_connection_call_finish (connection, result, NULL);

  if (group->active)
    {
      group->state = GROUP_ONLINE;

      /* If we receive no reply, just act like we got an empty reply. */
      if (reply)
        {
          GVariantIter *iter;
          GVariant *items;
          guint group_id;
          guint menu_id;

          g_variant_get (reply, "(a(uuaa{sv}))", &iter);
          while (g_variant_iter_loop (iter, "(uu@aa{sv})", &group_id, &menu_id, &items))
            if (group_id == group->id)
              g_dbus_menu_group_changed (group, menu_id, 0, 0, items);
          g_variant_iter_free (iter);
        }
    }
  else
    g_dbus_menu_group_go_offline (group);

  if (reply)
    g_variant_unref (reply);

  g_dbus_menu_group_unref (group);
}
static void
cc_sharing_panel_get_host_name_fqdn_done (GDBusConnection *connection,
                                          GAsyncResult    *res,
                                          GetHostNameData *data)
{
  GError *error = NULL;
  GVariant *variant;
  const gchar *fqdn;

  variant = g_dbus_connection_call_finish (connection, res, &error);

  if (variant == NULL)
    {
      /* Avahi service may not be available */
      g_debug ("Error calling GetHostNameFqdn: %s", error->message);

      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
        {
          gchar *hostname;

          hostname = cc_hostname_entry_get_hostname (CC_HOSTNAME_ENTRY (data->panel->priv->hostname_entry));

          cc_sharing_panel_setup_label (GTK_LABEL (data->label), hostname);

          g_free (hostname);
        }

      g_free (data);
      g_error_free (error);
      return;
    }

  g_variant_get (variant, "(&s)", &fqdn);

  cc_sharing_panel_setup_label (GTK_LABEL (data->label), fqdn);

  g_variant_unref (variant);
  g_object_unref (connection);
  g_free (data);
}
예제 #30
0
static void
on_reload_cb (GObject      *source_object,
	      GAsyncResult *res,
	      gpointer      user_data)
{
	GDBusConnection *connection = G_DBUS_CONNECTION (source_object);
	GVariant        *value;
	GError          *error = NULL;

	value = g_dbus_connection_call_finish (connection, res, &error);
	if (!value) {
		g_warning ("Failed to Reload: %s", error->message);
		g_error_free (error);
	}
	g_variant_unref (value);

	/* We did not open a window, so manually clear the startup
	 * notification. */
	gdk_notify_startup_complete ();

	ev_application_shutdown (EV_APP);
}