当前位置: 首页>>代码示例>>C++>>正文


C++ g_dbus_proxy_call_sync函数代码示例

本文整理汇总了C++中g_dbus_proxy_call_sync函数的典型用法代码示例。如果您正苦于以下问题:C++ g_dbus_proxy_call_sync函数的具体用法?C++ g_dbus_proxy_call_sync怎么用?C++ g_dbus_proxy_call_sync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了g_dbus_proxy_call_sync函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pk_dbus_get_session

/**
 * pk_dbus_get_session:
 * @dbus: the #PkDbus instance
 * @sender: the sender, usually got from dbus_g_method_get_dbus()
 *
 * Gets the logind or ConsoleKit session for the ID.
 *
 * Return value: the session identifier, or %NULL if it could not be obtained
 **/
gchar *
pk_dbus_get_session (PkDbus *dbus, const gchar *sender)
{
	gchar *session = NULL;
#ifndef PK_BUILD_SYSTEMD
	_cleanup_error_free_ GError *error = NULL;
#endif
	guint pid;
	_cleanup_variant_unref_ GVariant *value = NULL;

	g_return_val_if_fail (PK_IS_DBUS (dbus), NULL);
	g_return_val_if_fail (sender != NULL, NULL);

	/* set in the test suite */
	if (g_strcmp0 (sender, ":org.freedesktop.PackageKit") == 0) {
		g_debug ("using self-check shortcut");
		session = g_strdup ("xxx");
		goto out;
	}

	/* no ConsoleKit? */
	if (dbus->priv->proxy_session == NULL) {
		g_warning ("no ConsoleKit, so cannot get session");
		goto out;
	}

	/* get pid */
	pid = pk_dbus_get_pid (dbus, sender);
	if (pid == G_MAXUINT) {
		g_warning ("failed to get PID");
		goto out;
	}

	/* get session from systemd or ConsoleKit */
#ifdef PK_BUILD_SYSTEMD
	session = pk_dbus_get_session_systemd (pid);
#else
	/* get session from ConsoleKit */
	value = g_dbus_proxy_call_sync (dbus->priv->proxy_session,
					"GetSessionForUnixProcess",
					g_variant_new ("(u)",
						       pid),
					G_DBUS_CALL_FLAGS_NONE,
					2000,
					NULL,
					&error);
	if (value == NULL) {
		g_warning ("Failed to get session for %s: %s",
			   sender, error->message);
		goto out;
	}
	g_variant_get (value, "(o)", &session);
#endif
out:
	return session;
}
开发者ID:cjwatson,项目名称:PackageKit,代码行数:65,代码来源:pk-dbus.c

示例2: eog_util_show_file_in_filemanager

void
eog_util_show_file_in_filemanager (GFile *file, GdkScreen *screen)
{
	GDBusProxy *proxy;
	gboolean done = FALSE;

	g_return_if_fail (file != NULL);

	proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
				G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
				G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
				NULL, "org.freedesktop.FileManager1",
				"/org/freedesktop/FileManager1",
				"org.freedesktop.FileManager1",
				NULL, NULL);

	if (proxy) {
		gchar *uri = g_file_get_uri (file);
		gchar *startup_id;
		GVariant *params, *result;
		GVariantBuilder builder;

		g_variant_builder_init (&builder,
					G_VARIANT_TYPE ("as"));
		g_variant_builder_add (&builder, "s", uri);

		/* This seems to be the expected format, as other values
		   cause the filemanager window not to get focus. */
		startup_id = g_strdup_printf("_TIME%u",
					     gtk_get_current_event_time());

		/* params is floating! */
		params = g_variant_new ("(ass)", &builder, startup_id);

		g_free (startup_id);
		g_variant_builder_clear (&builder);

		/* Floating params-GVariant is consumed here */
		result = g_dbus_proxy_call_sync (proxy, "ShowItems",
						 params, G_DBUS_CALL_FLAGS_NONE,
						 -1, NULL, NULL);

		/* Receiving a non-NULL result counts as a successful call. */
		if (G_LIKELY (result != NULL)) {
			done = TRUE;
			g_variant_unref (result);
		}

		g_free (uri);
		g_object_unref (proxy);
	}

	/* Fallback to gtk_show_uri() if launch over DBus is not possible */
	if (!done)
		_eog_util_show_file_in_filemanager_fallback (file, screen);
}
开发者ID:UIKit0,项目名称:eog,代码行数:56,代码来源:eog-util.c

示例3: systemd_daemon_reload

static void
systemd_daemon_reload(GDBusProxy * proxy, GError ** error)
{
    GVariant *_ret = g_dbus_proxy_call_sync(proxy, "Reload", g_variant_new("()"),
                                            G_DBUS_CALL_FLAGS_NONE, -1, NULL, error);

    if (_ret) {
        g_variant_unref(_ret);
    }
}
开发者ID:chjohnst,项目名称:pacemaker,代码行数:10,代码来源:systemd.c

示例4: _onDbusOwnerChange

static void _onDbusOwnerChange(GObject *gobject, GParamSpec *pspec, gpointer user_data) {
  GDBusProxy *proxy = G_DBUS_PROXY(gobject);

  gchar *owner = g_dbus_proxy_get_name_owner(proxy);

  if (owner == NULL || owner[0] == '\0') {
    /* We only care about folks coming on the bus.  Exit quickly otherwise. */
    _info("new dbus owner is empty, nothing to do");
    g_free(owner);
    return;
  }

  if (g_strcmp0(owner, DBUS_NAME)) {
    /* We only care about this address, reject all others. */
    _info("new dbus owner is AppMenu.Registrar, nothing to do");
    g_free(owner);
    return;
  }

  if (user_data == NULL) {
    _error("_onDbusOwnerChange invoked with null user_data");
    g_free(owner);
    return;
  }

  // _logmsg(LOG_LEVEL_INFO, "new owner '%s'", owner);

  WndInfo *wi = (WndInfo *) user_data;

  if (wi->menuPath == NULL) {
    _error("_onDbusOwnerChange invoked with empty WndInfo");
    g_free(owner);
    return;
  }

  char buf[1024];
  _printWndInfo(wi, buf, 1024);
  _logmsg(LOG_LEVEL_INFO, "window: '%s'", buf);

  GError *error = NULL;
  g_dbus_proxy_call_sync(wi->registrar, "RegisterWindow",
                         g_variant_new("(uo)",
                         wi->xid,
                         wi->menuPath),
                         G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
  if (error != NULL) {
    _logmsg(LOG_LEVEL_ERROR, "Unable to re-register window, error: %s", error->message);
    g_error_free(error);
    g_free(owner);
    return;
  }

  // _info("Window has been successfully re-registered");
  g_free(owner);
}
开发者ID:SeanFarrow,项目名称:intellij-community,代码行数:55,代码来源:DbusMenuWrapper.c

示例5: uninstall_application

static bool uninstall_application(GDBusObjectManager* installed,
                                  const char* appid)
{
  GList* objects = g_dbus_object_manager_get_objects(installed);
  GList* l;
  bool ret = false;

  for (l = objects; l; l = l->next) {
    GDBusObject* object = l->data;
    GDBusInterface* iface = g_dbus_object_get_interface(
        object,
        xwalk_installed_app_iface);
    if (!iface)
      continue;

    GDBusProxy* proxy = G_DBUS_PROXY(iface);

    GVariant* value = g_dbus_proxy_get_cached_property(proxy, "AppID");
    if (!value) {
      g_object_unref(iface);
      continue;
    }

    const char* id;
    g_variant_get(value, "s", &id);

    if (g_strcmp0(appid, id)) {
      g_object_unref(iface);
      continue;
    }

    GError* error = NULL;
    GVariant* result = g_dbus_proxy_call_sync(proxy, "Uninstall", NULL,
                                              G_DBUS_CALL_FLAGS_NONE,
                                              -1, NULL, &error);
    if (!result) {
      g_print("Uninstalling application failed: %s\n", error->message);
      g_error_free(error);
      g_object_unref(iface);
      ret = false;
      goto done;
    }

    g_object_unref(iface);
    ret = true;
    goto done;
  }

  g_print("Application ID '%s' could not be found\n", appid);

done:
  g_list_free_full(objects, g_object_unref);

  return ret;
}
开发者ID:cDoru,项目名称:crosswalk,代码行数:55,代码来源:xwalkctl_main.c

示例6: systemd_unit_listall

GList *
systemd_unit_listall(void)
{
    int lpc = 0;
    GList *units = NULL;
    GError *error = NULL;
    GVariant *out_units = NULL;
    GVariantIter iter;
    struct unit_info u;
    GVariant *_ret = NULL;

    if (systemd_init() == FALSE) {
        return NULL;
    }

/*
        "  <method name=\"ListUnits\">\n"                               \
        "   <arg name=\"units\" type=\"a(ssssssouso)\" direction=\"out\"/>\n" \
        "  </method>\n"                                                 \
*/

    _ret = g_dbus_proxy_call_sync(systemd_proxy, "ListUnits", g_variant_new("()"),
                                  G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);

    if (error || _ret == NULL) {
        crm_info("Call to ListUnits failed: %s", error ? error->message : "unknown");
        g_error_free(error);
        return NULL;
    }

    g_variant_get(_ret, "(@a(ssssssouso))", &out_units);

    g_variant_iter_init(&iter, out_units);
    while (g_variant_iter_loop(&iter, "(ssssssouso)",
                               &u.id,
                               &u.description,
                               &u.load_state,
                               &u.active_state,
                               &u.sub_state,
                               &u.following, &u.unit_path, &u.job_id, &u.job_type, &u.job_path)) {
        char *match = strstr(u.id, ".service");

        if (match) {
            lpc++;
            match[0] = 0;
            crm_trace("Got %s[%s] = %s", u.id, u.active_state, u.description);
            units = g_list_append(units, strdup(u.id));
        }
    }

    crm_info("Call to ListUnits passed: type '%s' count %d", g_variant_get_type_string(out_units),
             lpc);
    g_variant_unref(_ret);
    return units;
}
开发者ID:chjohnst,项目名称:pacemaker,代码行数:55,代码来源:systemd.c

示例7: tracker_miner_manager_pause_for_process

/**
 * tracker_miner_manager_pause_for_process:
 * @manager: a #TrackerMinerManager.
 * @miner: miner reference
 * @reason: reason to pause
 * @cookie: (out) (allow-none): return location for the pause cookie ID
 *
 * This function operates exactly the same way as
 * tracker_miner_manager_pause() with the exception that if the calling
 * process dies, the pause is resumed. This API is useful for cases
 * where the calling process has a risk of crashing without resuming
 * the pause.
 *
 * NOTE: If you call g_object_unref() on the @manager before you
 * intend to resume the pause and it finalizes, it will automatically
 * resume.
 *
 * Returns: %TRUE if the miner was paused successfully, otherwise
 * %FALSE.
 *
 * Since: 0.10.15
 **/
gboolean
tracker_miner_manager_pause_for_process (TrackerMinerManager *manager,
                                         const gchar         *miner,
                                         const gchar         *reason,
                                         guint32             *cookie)
{
	GDBusProxy *proxy;
	const gchar *app_name;
	GError *error = NULL;
	GVariant *v;

	g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), FALSE);
	g_return_val_if_fail (miner != NULL, FALSE);
	g_return_val_if_fail (reason != NULL, FALSE);

	proxy = find_miner_proxy (manager, miner, TRUE);

	if (!proxy) {
		g_critical ("No D-Bus proxy found for miner '%s'", miner);
		return FALSE;
	}

	/* Find a reasonable app name */
	app_name = g_get_application_name ();

	if (!app_name) {
		app_name = g_get_prgname ();
	}

	if (!app_name) {
		app_name = "TrackerMinerManager client";
	}

	v = g_dbus_proxy_call_sync (proxy,
	                            "PauseForProcess",
	                            g_variant_new ("(ss)", app_name, reason),
	                            G_DBUS_CALL_FLAGS_NONE,
	                            -1,
	                            NULL,
	                            &error);

	if (error) {
		g_critical ("Could not pause miner '%s': %s", miner, error->message);
		g_error_free (error);
		return FALSE;
	}

	if (cookie) {
		g_variant_get (v, "(i)", cookie);
	}

	g_variant_unref (v);

	return TRUE;
}
开发者ID:anantkaushik89,项目名称:tracker,代码行数:77,代码来源:tracker-miner-manager.c

示例8: g_assert

GVariant *obex_object_push_send_file(ObexObjectPush *self, const gchar *sourcefile, GError **error)
{
	g_assert(OBEX_OBJECT_PUSH_IS(self));
	GVariant *ret = NULL;
	GVariant *proxy_ret = g_dbus_proxy_call_sync(self->priv->proxy, "SendFile", g_variant_new ("(s)", sourcefile), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error);
	if (proxy_ret != NULL)
		return NULL;
	ret = g_variant_ref_sink(proxy_ret);
	g_variant_unref(proxy_ret);
	return ret;
}
开发者ID:khvzak,项目名称:bluez-tools,代码行数:11,代码来源:obex_object_push.c

示例9: g_dbus_proxy_call_sync

static GVariant *_set_proxy_property(GDBusProxy *proxy,
				const char *prop,
				GVariant *val,
				GError **err)
{
	GVariant *retv = NULL;
	retv = g_dbus_proxy_call_sync(proxy, "SetProperty",
		 g_variant_new("(sv)", prop, val),
		 G_DBUS_CALL_FLAGS_NONE, 120000000, NULL, err);
	return retv;
}
开发者ID:slapin,项目名称:dbus-tools,代码行数:11,代码来源:ofono-props.c

示例10: enroll_start

static gboolean
enroll_start (EnrollData *data, GError **error)
{
        GVariant *result;

        result = g_dbus_proxy_call_sync (data->device, "EnrollStart", g_variant_new ("(s)", data->finger), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error);
        if (result == NULL)
                return FALSE;
        g_variant_unref (result);
        return TRUE;
}
开发者ID:kororaproject,项目名称:korora-control-center,代码行数:11,代码来源:um-fingerprint-dialog.c

示例11: release

static gboolean
release (EnrollData *data, GError **error)
{
        GVariant *result;

        result = g_dbus_proxy_call_sync (data->device, "Release", g_variant_new ("()"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error);
        if (result == NULL)
                return FALSE;
        g_variant_unref (result);
        return TRUE;
}
开发者ID:kororaproject,项目名称:korora-control-center,代码行数:11,代码来源:um-fingerprint-dialog.c

示例12: get_session_id

static char *
get_session_id (UrfSessionChecker *logind,
                const char *bus_name)
{
	UrfLogindPrivate *priv = logind->priv;
	pid_t calling_pid;
	char *session_id = NULL;
	GVariant *retval;
	GError *error;

        error = NULL;
	retval = g_dbus_proxy_call_sync (priv->bus_proxy, "GetConnectionUnixProcessID",
	                                 g_variant_new ("(s)", bus_name),
	                                 G_DBUS_CALL_FLAGS_NONE,
	                                 -1, NULL, &error);
	if (error) {
		g_warning("GetConnectionUnixProcessID() failed: %s", error->message);
		g_error_free (error);
		goto out;
	}
	g_variant_get (retval, "(u)", &calling_pid);
	g_variant_unref (retval);

        error = NULL;
	retval = g_dbus_proxy_call_sync (priv->proxy, "GetSessionByPID",
	                                 g_variant_new ("(u)", (guint)calling_pid),
	                                 G_DBUS_CALL_FLAGS_NONE,
	                                 -1, NULL, &error);
	if (error) {
		g_warning ("Couldn't send GetSessionByPID: %s", error->message);
		g_error_free (error);
		session_id = NULL;
		goto out;
	}

	g_variant_get (retval, "(o)", &session_id);
	session_id = g_strdup (session_id);
	g_variant_unref (retval);
out:
	return session_id;
}
开发者ID:kaijanmaki,项目名称:urfkill,代码行数:41,代码来源:urf-session-checker-logind.c

示例13: health_device_echo

/* boolean Echo() */
gboolean health_device_echo(HealthDevice *self, GError **error)
{
	g_assert(HEALTH_DEVICE_IS(self));
	gboolean ret = FALSE;
	GVariant *proxy_ret = g_dbus_proxy_call_sync(self->priv->proxy, "Echo", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, error);
	if (proxy_ret != NULL)
		return FALSE;
	proxy_ret = g_variant_get_child_value(proxy_ret, 0);
	ret = g_variant_get_boolean(proxy_ret);
	g_variant_unref(proxy_ret);
	return ret;
}
开发者ID:khvzak,项目名称:bluez-tools,代码行数:13,代码来源:health_device.c

示例14: g_assert

/* object CreateSession(string destination, dict args) */
const gchar *obex_client_create_session(ObexClient *self, const gchar *destination, const GVariant *args, GError **error)
{
	g_assert(OBEX_CLIENT_IS(self));
	const gchar *ret = NULL;
	GVariant *proxy_ret = g_dbus_proxy_call_sync(self->priv->proxy, "CreateSession", g_variant_new ("([email protected]{sv})", destination, args), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error);
	if (proxy_ret == NULL)
		return NULL;
	proxy_ret = g_variant_get_child_value(proxy_ret, 0);
	ret = g_variant_get_string(proxy_ret, NULL);
	g_variant_unref(proxy_ret);
	return ret;
}
开发者ID:khvzak,项目名称:bluez-tools,代码行数:13,代码来源:obex_client.c

示例15: g_assert

/* string Connect(string uuid) */
const gchar *network_connect(Network *self, const gchar *uuid, GError **error)
{
	g_assert(NETWORK_IS(self));
	const gchar *ret = NULL;
	GVariant *proxy_ret = g_dbus_proxy_call_sync(self->priv->proxy, "Connect", g_variant_new ("(s)", uuid), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error);
	if (proxy_ret != NULL)
		return NULL;
	proxy_ret = g_variant_get_child_value(proxy_ret, 0);
	ret = g_variant_get_string(proxy_ret, NULL);
	g_variant_unref(proxy_ret);
	return ret;
}
开发者ID:khvzak,项目名称:bluez-tools,代码行数:13,代码来源:network.c


注:本文中的g_dbus_proxy_call_sync函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。