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);
}
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);
}
예제 #3
0
/**
 * @brief Perform sending remote signals to connected clients.
 * @memberof GstSwitchController
 */
static void
gst_switch_controller_emit_signal (GstSwitchController * controller,
    const gchar * signame, GVariant * parameters)
{
  GError *error;
  gboolean res;
  GList *client;
  gint num;

  GST_SWITCH_CONTROLLER_LOCK_CLIENTS (controller);
  g_assert (parameters);
  g_variant_ref_sink (parameters);

  for (client = controller->clients, num = 0; client;
      client = g_list_next (client)) {
    error = NULL;
    res = g_dbus_connection_emit_signal (G_DBUS_CONNECTION (client->data),
        /*destination_bus_name */ NULL,
        SWITCH_CONTROLLER_OBJECT_PATH,
        SWITCH_CONTROLLER_OBJECT_NAME, signame, parameters, &error);

    if (!res) {
      g_assert (error != NULL);
      ERROR ("emit: (%d) %s", num, error->message);
    } else {
      ++num;
    }
  }
  /*
     INFO ("emit: %s (%d/%d)", signame, num, g_list_length (controller->uis));
   */
  g_variant_unref (parameters);

  GST_SWITCH_CONTROLLER_UNLOCK_CLIENTS (controller);
}
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);
}
예제 #5
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);
}
예제 #6
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
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
close_and_unref_connection (void *data)
{
    GDBusConnection *connection = G_DBUS_CONNECTION (data);

    /* TODO: watch for the need to manually call g_dbus_connection_close_sync () */
    g_object_unref (connection);
}
예제 #9
0
static void uriChangedCallback(WebKitWebPage* webPage, GParamSpec* pspec, WebKitWebExtension* extension)
{
    gpointer data = g_object_get_data(G_OBJECT(extension), "dbus-connection");
    if (data)
        emitURIChanged(G_DBUS_CONNECTION(data), webkit_web_page_get_uri(webPage));
    else
        delayedSignalsQueue.append(adoptPtr(new DelayedSignal(URIChangedSignal, webkit_web_page_get_uri(webPage))));
}
예제 #10
0
static void documentLoadedCallback(WebKitWebPage*, WebKitWebExtension* extension)
{
    gpointer data = g_object_get_data(G_OBJECT(extension), "dbus-connection");
    if (data)
        emitDocumentLoaded(G_DBUS_CONNECTION(data));
    else
        delayedSignalsQueue.append(adoptPtr(new DelayedSignal(DocumentLoadedSignal)));
}
예제 #11
0
파일: fu-util.c 프로젝트: phomes/fwupd
/**
 * fu_util_update_cb:
 **/
static void
fu_util_update_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
	FuUtilPrivate *priv = (FuUtilPrivate *) user_data;
	GDBusConnection *con = G_DBUS_CONNECTION (source_object);
	priv->message = g_dbus_connection_send_message_with_reply_finish (con, res,
									  &priv->error);
	g_main_loop_quit (priv->loop);
}
예제 #12
0
static gboolean
evd_dbus_agent_foreach_remove_reg_obj (gpointer key,
                                       gpointer value,
                                       gpointer user_data)
{
  RegObjData *reg_obj_data = (RegObjData *) value;
  GDBusConnection *conn = G_DBUS_CONNECTION (user_data);

  return reg_obj_data->dbus_conn == conn;
}
예제 #13
0
static gboolean
evd_dbus_agent_foreach_remove_owned_names (gpointer key,
                                           gpointer value,
                                           gpointer user_data)
{
  NameOwnerData *name_owner_data = (NameOwnerData *) value;
  GDBusConnection *conn = G_DBUS_CONNECTION (user_data);

  return name_owner_data->dbus_conn == conn;
}
static void documentLoadedCallback(WebKitWebPage*, gpointer userData)
{
    bool ok = g_dbus_connection_emit_signal(G_DBUS_CONNECTION(userData),
        0,
        "/org/webkit/gtk/WebExtensionTest",
        "org.webkit.gtk.WebExtensionTest",
        "DocumentLoaded",
        0,
        0);
    g_assert(ok);
}
static void uriChangedCallback(WebKitWebPage* webPage, GParamSpec* pspec, gpointer userData)
{
    bool ok = g_dbus_connection_emit_signal(
        G_DBUS_CONNECTION(userData),
        0,
        "/org/webkit/gtk/WebExtensionTest",
        "org.webkit.gtk.WebExtensionTest",
        "URIChanged",
        g_variant_new("(s)", webkit_web_page_get_uri(webPage)),
        0);
    g_assert(ok);
}
예제 #16
0
static gboolean
evd_dbus_agent_foreach_remove_proxy (gpointer key,
                                     gpointer value,
                                     gpointer user_data)
{
  ProxyData *proxy_data = (ProxyData *) value;
  GDBusConnection *conn = G_DBUS_CONNECTION (user_data);
  GDBusConnection *proxy_conn;

  proxy_conn = g_dbus_proxy_get_connection (proxy_data->proxy);
  return proxy_conn == conn;
}
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);
    }
}
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);
}
예제 #19
0
파일: ext-main.c 프로젝트: cdlscpmv/vimb
/**
 * Emit the page created signal that is used in the UI process to finish the
 * dbus proxy connection.
 */
static void emit_page_created(GDBusConnection *connection, guint64 pageid)
{
    GError *error = NULL;

    /* propagate the signal over dbus */
    g_dbus_connection_emit_signal(G_DBUS_CONNECTION(connection), NULL,
            VB_WEBEXTENSION_OBJECT_PATH, VB_WEBEXTENSION_INTERFACE,
            "PageCreated", g_variant_new("(t)", pageid), &error);

    if (error) {
        g_warning("Failed to emit signal PageCreated: %s", error->message);
        g_error_free(error);
    }
}
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);
    }
예제 #22
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);
}
예제 #24
0
파일: main.c 프로젝트: pwithnall/bendy-bus
static void
connection_close_cb (GObject *source_object, GAsyncResult *result, MainData *data)
{
	GError *error = NULL;

	/* Finish closing the connection */
	g_dbus_connection_close_finish (G_DBUS_CONNECTION (source_object), result, &error);

	if (error != NULL) {
		g_printerr (_("Error closing D-Bus connection: %s"), error->message);
		g_printerr ("\n");

		g_error_free (error);
	}

	post_connection_closed (data);
}
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);
}
예제 #26
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 ();
}
예제 #27
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);
    }
}
예제 #28
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, "");
	}
}
예제 #29
0
static void documentLoadedCallback(WebKitWebPage* webPage, WebKitWebExtension* extension)
{
    // FIXME: Too much code just to send a message, we need convenient custom API for this.
    WebKitDOMDocument* document = webkit_web_page_get_dom_document(webPage);
    GRefPtr<WebKitDOMDOMWindow> window = adoptGRef(webkit_dom_document_get_default_view(document));
    if (WebKitDOMWebKitNamespace* webkit = webkit_dom_dom_window_get_webkit_namespace(window.get())) {
        WebKitDOMUserMessageHandlersNamespace* messageHandlers = webkit_dom_webkit_namespace_get_message_handlers(webkit);
        if (WebKitDOMUserMessageHandler* handler = webkit_dom_user_message_handlers_namespace_get_handler(messageHandlers, "dom"))
            webkit_dom_user_message_handler_post_message(handler, "DocumentLoaded", nullptr);
    }

    webkit_dom_dom_window_webkit_message_handlers_post_message(window.get(), "dom-convenience", "DocumentLoaded");

    gpointer data = g_object_get_data(G_OBJECT(extension), "dbus-connection");
    if (data)
        emitDocumentLoaded(G_DBUS_CONNECTION(data));
    else
        delayedSignalsQueue.append(DelayedSignal(DocumentLoadedSignal));
}
예제 #30
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;
}