Exemplo n.º 1
0
static void
workrave_dbus_server_cleanup()
{
  DBusGProxy *driver_proxy;
  GError *err = NULL;
  guint release_name_result;

  driver_proxy = dbus_g_proxy_new_for_name(g_connection,
                                           DBUS_SERVICE_DBUS,
                                           DBUS_PATH_DBUS,
                                           DBUS_INTERFACE_DBUS);

  if (!org_freedesktop_DBus_release_name(driver_proxy,
                                         DBUS_SERVICE_APPLET,
                                         &release_name_result,
                                         &err))
    {
      g_warning("DBUS Service name release failed.");
      g_clear_error(&err);
    }

  if (g_connection != NULL)
    {
      dbus_g_connection_unref(g_connection);
      g_connection = NULL;
    }
}
Exemplo n.º 2
0
/**
 * Class destructor function.
 */
static void  psm_client_finalize ( 
        PSMClient *server /**< [in] the instance to finalize. */
)
{
    guint request_ret;
    GError *error = NULL;
    DBusGProxy *proxy = NULL;

    /* Get a proxy to DBus. */
    proxy = dbus_g_proxy_new_for_name (gDbusConnection,
                                       DBUS_SERVICE_DBUS,
                                       DBUS_PATH_DBUS,
                                       DBUS_INTERFACE_DBUS);

    dbus_connection_unregister_object_path (
            dbus_g_connection_get_connection(gDbusConnection),
            PSM_CLIENT_PATH);

    /** Release the connection name so that we can own request it again 
     * later if we need.
     */
    if (!org_freedesktop_DBus_release_name(proxy, PSM_CLIENT_SERVICE, 
                                           &request_ret, &error) )
    {
        g_critical ("Unable to release PSMClient service: %s\n",
                error->message);
        g_error_free(error);
    }
    else if (request_ret != DBUS_RELEASE_NAME_REPLY_RELEASED)
    {
        g_critical ("Unable to release PSMClient service.  Is another"
                    " instance already running?");
    }

    g_type_free_instance((GTypeInstance*)server);

    g_object_unref(proxy);
}