• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dbus_connection_setup_with_g_main函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: start_devicelock_listener

int start_devicelock_listener(void)
{
  DBusError       err = DBUS_ERROR_INIT;
  DBusConnection *dbus_conn_devicelock = NULL;

  if( (dbus_conn_devicelock = dbus_bus_get(DBUS_BUS_SYSTEM, &err)) == 0 )
  {
	 log_err("Could not connect to dbus for devicelock\n"); 
	 goto cleanup;
  }

  dbus_bus_add_match(dbus_conn_devicelock, MATCH_DEVICELOCK_SIGNALS, &err);
  if( dbus_error_is_set(&err) )
  {
    goto cleanup;
  }
  if( !dbus_connection_add_filter(dbus_conn_devicelock, devicelock_unlocked_cb , 0, 0) )
  {
        log_err("adding system dbus filter for devicelock failed");
    goto cleanup;
  }
  dbus_connection_setup_with_g_main(dbus_conn_devicelock, NULL);

cleanup:
  dbus_error_free(&err);
  return(1);
}
开发者ID:d0b3rm4n,项目名称:usb-moded,代码行数:27,代码来源:usb_moded-devicelock.c


示例2: vehicle_gpsd_dbus_open

static int
vehicle_gpsd_dbus_open(struct vehicle_priv *priv)
{
	DBusError error;

	dbus_error_init(&error);
	if (priv->address) {
		priv->connection = dbus_connection_open(priv->address, &error);
	} else {
		priv->connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
	}
	if (!priv->connection) {
		dbg(0,"Failed to open connection to %s message bus: %s\n", priv->address?priv->address:"session",error.message);
		dbus_error_free(&error);
		return 0;
	}
	dbus_connection_setup_with_g_main(priv->connection, NULL);
	dbus_bus_add_match(priv->connection,"type='signal',interface='org.gpsd'",&error);
	dbus_connection_flush(priv->connection);
	if (dbus_error_is_set(&error)) {
		dbg(0,"Failed to add match to connection: %s\n", error.message);
		vehicle_gpsd_dbus_close(priv);
		return 0;
	}
	if (!dbus_connection_add_filter(priv->connection, vehicle_gpsd_dbus_filter, priv, NULL)) {
		dbg(0,"Failed to add filter to connection\n");
		vehicle_gpsd_dbus_close(priv);
		return 0;
	}
	return 1;
}
开发者ID:swkim01,项目名称:navit,代码行数:31,代码来源:vehicle_gpsd_dbus.c


示例3: getenv

void VolumeBarLogic::openConnection (bool init)
{
    /*
     * Check the connection first, maybe this function
     * only called because of lost connection
     */
    if ((dbus_conn != NULL) && (dbus_connection_get_is_connected (dbus_conn)))
        return;

    DBusError dbus_err;
    char *pa_bus_address = getenv ("PULSE_DBUS_SERVER");

    if (pa_bus_address == NULL)
        pa_bus_address = (char *) DEFAULT_ADDRESS;

    dbus_error_init (&dbus_err);

    dbus_conn = dbus_connection_open (pa_bus_address, &dbus_err);

    DBUS_ERR_CHECK (dbus_err);

    if (dbus_conn != NULL) {
        dbus_connection_setup_with_g_main (dbus_conn, NULL);

        dbus_connection_add_filter (
            dbus_conn,
            (DBusHandleMessageFunction) VolumeBarLogic::stepsUpdatedSignal,
            (void *) this, NULL);

        if (init == true)
            initValues ();
    }
}
开发者ID:CODeRUS,项目名称:unrestricted-system-ui,代码行数:33,代码来源:volumebarlogic.cpp


示例4: _new_connection

static void
_new_connection (DBusServer *server,
		 DBusConnection *connection,
		 void *data)
{
	ServiceData *svc = (ServiceData *)data;
	DBusObjectPathVTable vt = {
		_unregister_handler,
		_handle_message,
		NULL, NULL, NULL, NULL
	};

	rb_debug ("new connection to metadata service");

	/* don't allow more than one connection at a time */
	if (svc->connection) {
		rb_debug ("metadata service already has a client.  go away.");
		return;
	}

	dbus_connection_register_object_path (connection,
					      RB_METADATA_DBUS_OBJECT_PATH,
					      &vt,
					      svc);
	dbus_connection_ref (connection);
	dbus_connection_setup_with_g_main (connection,
					   g_main_loop_get_context (svc->loop));
	if (!svc->external)
		dbus_connection_set_exit_on_disconnect (connection, TRUE);
}
开发者ID:AdamZ,项目名称:rhythmbox-magnatune,代码行数:30,代码来源:rb-metadata-dbus-service.c


示例5: main

int
main (int argc, char **argv)
{
  GMainLoop *loop;
  DBusConnection *bus;
  DBusError error;

  loop = g_main_loop_new (NULL, FALSE);

  dbus_error_init (&error);
  bus = dbus_bus_get (DBUS_BUS_SESSION, &error);
  if (!bus) {
    g_warning ("Failed to connect to the D-BUS daemon: %s", error.message);
    dbus_error_free (&error);
    return 1;
  }
  dbus_connection_setup_with_g_main (bus, NULL);

  /* listening to messages from all objects as no path is specified */
  dbus_bus_add_match (bus, "type='signal',interface='com.burtonini.dbus.Signal'", &error);
  dbus_connection_add_filter (bus, signal_filter, loop, NULL);

  g_main_loop_run (loop);
  return 0;
}
开发者ID:korobool,项目名称:dbus-examples,代码行数:25,代码来源:dbus-ping-listen.c


示例6: new_connection_cb

static void
new_connection_cb (DBusServer    * server,
                   DBusConnection* connection,
                   gpointer        user_data)
{
  dbus_int32_t  slot = -1;
  GObject     * object;
  if (!dbus_connection_allocate_data_slot (&slot))
    {
      g_warning ("error allocating data slot for DBusConnection");
      dbus_connection_close (connection);
      return;
    }

  dbus_connection_ref (connection);

  dbus_connection_set_allow_anonymous (connection, TRUE);
  dbus_connection_setup_with_g_main (connection, NULL);

  object = g_object_new (p2p_object_get_type (), NULL);
  dbus_g_connection_register_g_object (dbus_connection_get_g_connection (connection),
                                       "/", object);
  dbus_connection_set_data (connection, slot,
                            object, g_object_unref);
}
开发者ID:herzi,项目名称:p2p-dbus,代码行数:25,代码来源:server.c


示例7: pm_upower_init

void pm_upower_init()
{
    DBusError error;

    dbus_error_init(&error);
    DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);

    if (dbus_error_is_set(&error)) {
        g_error("Cannot get System BUS connection: %s", error.message);
        dbus_error_free(&error);
        return;
    }

    dbus_connection_setup_with_g_main(conn, NULL);

    dbus_bus_add_match(conn, RULE, &error);

    if (dbus_error_is_set(&error)) {
        g_error("Cannot add D-BUS match rule, cause: %s", error.message);
        dbus_error_free(&error);
        return;
    }

    dbus_connection_add_filter(conn, signal_filter, NULL, NULL);

}
开发者ID:dreamlayers,项目名称:gadgets,代码行数:26,代码来源:pm_systemd.c


示例8: main

int
main ()
{
        NotifyNotification *n;
        DBusConnection     *conn;

        if (!notify_init ("Default Action Test"))
                exit (1);

        conn = dbus_bus_get (DBUS_BUS_SESSION, NULL);
        loop = g_main_loop_new (NULL, FALSE);

        dbus_connection_setup_with_g_main (conn, NULL);

        n = notify_notification_new ("Matt is online", "", NULL, NULL);
        notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);
        notify_notification_add_action (n,
                                        "default",
                                        "Do Default Action",
                                        (NotifyActionCallback) callback,
                                        NULL,
                                        NULL);
        notify_notification_set_category (n, "presence.online");

        if (!notify_notification_show (n, NULL)) {
                fprintf (stderr, "failed to send notification\n");
                return 1;
        }

        g_main_loop_run (loop);

        return 0;
}
开发者ID:TheCoffeMaker,项目名称:Mate-Desktop-Environment,代码行数:33,代码来源:test-default-action.c


示例9: dbus_related

static void dbus_related(GMainLoop *loop)
{
	DBusConnection *bus;
	DBusError error;
	dbus_error_init (&error);

	
	bus = dbus_bus_get (DBUS_BUS_SESSION, &error);
	if (!bus)
	{
		g_warning ("Failed to connect to the D-BUS daemon: %s", error.message);
		dbus_error_free (&error);
		return;
	}
	//dbus_bus_register(bus, NULL);
	//dbus_bus_set_unique_name(bus, "org.freedesktop.program2");

	/*注意这句话一定要有,这样才有公共名称!*/
	dbus_bus_request_name(bus, "org.freedesktop.program2", DBUS_NAME_FLAG_ALLOW_REPLACEMENT, NULL);
	dbus_connection_setup_with_g_main (bus, NULL);

	/*添加消息信息*/
	//dbus_bus_add_match (bus, "type='method_call',interface='org.freedesktop.program2',member='print', path='/org/freedesktop/program2',destination='org.freedesktop.program2'", NULL);

	/*添加消息侦听函数*/
	dbus_connection_add_filter (bus, signal_filter, loop, NULL);
	g_main_loop_run (loop);
}
开发者ID:cherry-wb,项目名称:quietheart,代码行数:28,代码来源:receiveExample.c


示例10: dbus_mainloop

static int dbus_mainloop(void)
{
    GMainLoop *mainloop;
    DBusError error;

    mainloop = g_main_loop_new(NULL, FALSE);

    dbus_error_init(&error);
    connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
    if (dbus_error_is_set(&error)) {
	syslog(LOG_CRIT, "%s: %s", error.name, error.message);
	return 3;
    }

    dbus_bus_add_match(connection, "type='signal'", &error);
    if (dbus_error_is_set(&error)) {
	syslog(LOG_CRIT, "unable to add match for signals %s: %s", error.name,
	       error.message);
	return 4;
    }

    if (!dbus_connection_add_filter
	(connection, (DBusHandleMessageFunction) signal_handler, NULL,
	 NULL)) {
	syslog(LOG_CRIT, "unable to register filter with the connection");
	return 5;
    }

    dbus_connection_setup_with_g_main(connection, NULL);

    print_gpx_header();
    g_main_loop_run(mainloop);
    return 0;
}
开发者ID:idaohang,项目名称:gpsd-3,代码行数:34,代码来源:gpxlogger.c


示例11: wrapper_init

/**
 * wrapper_init:
 *
 * Acquires connection to the session bus and initializes source and renderer
 * wrappers.
 */
void wrapper_init(void)
{
	DBusError err;

	dbus_error_init(&err);
	Session_bus = dbus_bus_get(DBUS_BUS_SESSION, &err);
	if (dbus_error_is_set(&err)) {
		g_critical("wrapper_init(): %s",
                           dbus_error_is_set(&err) ? err.message : "error");
		dbus_error_free(&err);
                exit(2);
	}
	dbus_connection_setup_with_g_main(Session_bus, NULL);

	g_signal_connect(mafw_registry_get_instance(), "source-added",
			 G_CALLBACK(registry_action),
			 GUINT_TO_POINTER(EXTENSION_ADDED));
	g_signal_connect(mafw_registry_get_instance(), "source-removed",
			 G_CALLBACK(registry_action),
			 GUINT_TO_POINTER(EXTENSION_REMOVED));
	g_signal_connect(mafw_registry_get_instance(), "renderer-added",
			 G_CALLBACK(registry_action),
			 GUINT_TO_POINTER(EXTENSION_ADDED));
	g_signal_connect(mafw_registry_get_instance(), "renderer-removed",
			 G_CALLBACK(registry_action),
			 GUINT_TO_POINTER(EXTENSION_REMOVED));
	
	extension_init(Session_bus);
}
开发者ID:community-ssu,项目名称:mafw,代码行数:35,代码来源:wrapper.c


示例12: xdbus_init

static DBusConnection *
xdbus_init(void)
{
    DBusError err = DBUS_ERROR_INIT;
    DBusBusType bus_type = DBUS_BUS_SYSTEM;

    if( xdbus_con )
        goto EXIT;

    if( !(xdbus_con = dbus_bus_get(bus_type, &err)) ) {
        log_error("Failed to open connection to message bus"
                  "; %s: %s", err.name, err.message);
        goto EXIT;
    }

    dbus_connection_setup_with_g_main(xdbus_con, 0);

    dbus_connection_add_filter(xdbus_con, xdbus_filter_cb, 0, 0);

    dbus_bus_add_match(xdbus_con, mce_display_ind_rule, 0);

    log_debug("connected to system bus");

EXIT:
    dbus_error_free(&err);
    return xdbus_con;
}
开发者ID:mer-hybris,项目名称:unblank-restart-sensors,代码行数:27,代码来源:unblank-restart-sensors.c


示例13: gconfd_dbus_init

gboolean
gconfd_dbus_init (void)
{
  DBusError error;
  gint      ret;

  dbus_error_init (&error);

  bus_conn = dbus_bus_get (DBUS_BUS_SESSION, &error);

  if (!bus_conn) 
   {
     gconf_log (GCL_ERR, _("Daemon failed to connect to the D-BUS daemon:\n%s"),
		error.message);
     dbus_error_free (&error);
     return FALSE;
   }

  /* We handle exiting ourselves on disconnect. */
  dbus_connection_set_exit_on_disconnect (bus_conn, FALSE);

  /* Add message filter to handle Disconnected. */
  dbus_connection_add_filter (bus_conn,
			      (DBusHandleMessageFunction) server_filter_func,
			      NULL, NULL);
  
  ret = dbus_bus_request_name (bus_conn,
			       GCONF_DBUS_SERVICE,
			       0,
			       &error);

  if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
    {
      gconf_log (GCL_ERR, "Daemon could not become primary owner");
      return FALSE;
    }
  
  if (dbus_error_is_set (&error)) 
    {
      gconf_log (GCL_ERR, _("Daemon failed to acquire gconf service:\n%s"),
		 error.message);
      dbus_error_free (&error);
      return FALSE;
    }

  if (!dbus_connection_register_object_path (bus_conn,
					     server_path,
					     &server_vtable,
					     NULL))
    {
      gconf_log (GCL_ERR, _("Failed to register server object with the D-BUS bus daemon"));
      return FALSE;
    }
  
  
  nr_of_connections = 1;
  dbus_connection_setup_with_g_main (bus_conn, NULL);
  
  return TRUE;
}
开发者ID:BARGAN,项目名称:gconf,代码行数:60,代码来源:gconfd-dbus.c


示例14: plugin_init

void plugin_init(void)
{
	DBusError error;

    object_hash=g_hash_table_new(g_str_hash, g_str_equal);
	object_count=g_hash_table_new(g_str_hash, g_str_equal);
	dbg(0,"enter 1\n");
	dbus_error_init(&error);
	connection = dbus_bus_get(DBUS_BUS_SESSION, &error);
	if (!connection) {
		dbg(0,"Failed to open connection to session message bus: %s\n", error.message);
		dbus_error_free(&error);
		return;
	}
	dbus_connection_setup_with_g_main(connection, NULL);
#if 0
	dbus_connection_add_filter(connection, filter, NULL, NULL);
	dbus_bus_add_match(connection, "type='signal',""interface='" DBUS_INTERFACE_DBUS  "'", &error);
#endif
	dbus_connection_register_fallback(connection, object_path, &dbus_navit_vtable, NULL);
	dbus_bus_request_name(connection, service_name, 0, &error);
	if (dbus_error_is_set(&error)) {
		dbg(0,"Failed to request name: %s", error.message);
		dbus_error_free (&error);
	}
}
开发者ID:justinzane,项目名称:navit,代码行数:26,代码来源:binding_dbus.c


示例15: init_dbus

static gboolean
init_dbus ()
{
	DBusError error;

	dbus_error_init (&error);
	bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);

	dbus_connection_setup_with_g_main (bus, NULL);

	if (dbus_error_is_set (&error)) {
		g_error ("Net Monitor: Couldn't connect to system bus : %s: %s\n", error.name, error.message);
		return FALSE;
	}

	dbus_connection_add_filter (bus, filter_func, NULL, NULL);
	dbus_bus_add_match (bus, "type='signal',interface='" NM_INTERFACE "'", &error);

	if (dbus_error_is_set (&error)) {
		g_error ("Net Monitor: Could not register signal handler: %s: %s\n", error.name, error.message);
		return FALSE;
	}

	return TRUE;
}
开发者ID:GNOME,项目名称:xchat-gnome,代码行数:25,代码来源:net-monitor.c


示例16: new_connection_callback

static void
new_connection_callback (DBusServer     *server,
                         DBusConnection *new_connection,
                         void           *user_data)
{
    ThreadTestData * data;

    g_print ("new_connection_callback\n");

    dbus_connection_ref (new_connection);
    dbus_connection_setup_with_g_main (new_connection, NULL);

    data = thread_test_data_new ();

    if (!dbus_connection_add_filter (new_connection,
                                     filter_test_message, data,
                                     (DBusFreeFunction) thread_test_data_free))
        goto nomem;

    if (!dbus_connection_add_filter (new_connection,
                                     filter_disconnect, NULL, NULL))
        goto nomem;

    return;

nomem:
    g_error ("no memory to setup new connection");
}
开发者ID:kuailexs,项目名称:symbiandump-os2,代码行数:28,代码来源:test-thread-server.c


示例17: connect_peer_to_peer

static gboolean
connect_peer_to_peer()
{
    DBusError   error;

    dbus_error_init (&error);
    volume_bus = dbus_connection_open (volume_pulse_address, &error);

    if (dbus_error_is_set (&error)) {
        N_WARNING (LOG_CAT "failed to open connection to pulseaudio: %s",
            error.message);
        dbus_error_free (&error);
        return FALSE;
    }

    dbus_connection_setup_with_g_main (volume_bus, NULL);

    if (!dbus_connection_add_filter (volume_bus, filter_cb, NULL, NULL)) {
        N_WARNING (LOG_CAT "failed to add filter");
        return FALSE;
    }

    process_queued_ops();

    return TRUE;
}
开发者ID:kjokinie,项目名称:ngfd,代码行数:26,代码来源:volume-controller.c


示例18: init_network_manager

static void
init_network_manager (GUPnPNetworkManager *manager)
{
        GUPnPNetworkManagerPrivate *priv;
        DBusError derror;
        GMainContext *main_context;

        priv = manager->priv;

        g_object_get (manager, "main-context", &main_context, NULL);

        /* Do fake open to initialize types */
        dbus_g_connection_open ("", NULL);
        dbus_error_init (&derror);
        priv->dbus_connection = dbus_bus_get_private (DBUS_BUS_SYSTEM, &derror);
        if (priv->dbus_connection == NULL) {
                g_message ("Failed to connect to System Bus: %s",
                           derror.message);
                return;
        }

        dbus_connection_setup_with_g_main (priv->dbus_connection, main_context);

        priv->connection =
            dbus_connection_get_g_connection (priv->dbus_connection);

        priv->manager_proxy = dbus_g_proxy_new_for_name (priv->connection,
                                                         DBUS_SERVICE_NM,
                                                         MANAGER_PATH,
                                                         MANAGER_INTERFACE);

        dbus_g_proxy_add_signal (priv->manager_proxy,
                                 "DeviceAdded",
                                 DBUS_TYPE_G_OBJECT_PATH,
                                 G_TYPE_INVALID);
        dbus_g_proxy_connect_signal (priv->manager_proxy,
                                     "DeviceAdded",
                                     G_CALLBACK (on_device_added),
                                     manager,
                                     NULL);

        dbus_g_proxy_add_signal (priv->manager_proxy,
                                 "DeviceRemoved",
                                 DBUS_TYPE_G_OBJECT_PATH,
                                 G_TYPE_INVALID);
        dbus_g_proxy_connect_signal (priv->manager_proxy,
                                     "DeviceRemoved",
                                     G_CALLBACK (on_device_removed),
                                     manager,
                                     NULL);

        dbus_g_proxy_begin_call (priv->manager_proxy,
                                 "GetDevices",
                                 get_devices_cb,
                                 manager,
                                 NULL,
                                 G_TYPE_INVALID);
}
开发者ID:ZachGoldberg,项目名称:gupnp-gi,代码行数:58,代码来源:gupnp-network-manager.c


示例19: main

int
main (int argc, char *argv[])
{
	DBusConnection *dbus_connection;
	DBusError error;
	const char *commandline;

	hal_set_proc_title_init (argc, argv);

	setup_logger ();

	dbus_error_init (&error);
	if ((ctx = libhal_ctx_init_direct (&error)) == NULL) {
		HAL_WARNING (("Unable to init libhal context"));
		goto out;
	}

	if ((dbus_connection = libhal_ctx_get_dbus_connection(ctx)) == NULL) {
		HAL_WARNING (("Cannot get DBus connection"));
		goto out;
	}

	if ((commandline = getenv ("SINGLETON_COMMAND_LINE")) == NULL) {
		HAL_WARNING (("SINGLETON_COMMAND_LINE not set"));
		goto out;
	}

	libhal_ctx_set_singleton_device_added (ctx, add_device);
	libhal_ctx_set_singleton_device_removed (ctx, remove_device);

	dbus_connection_setup_with_g_main (dbus_connection, NULL);
	dbus_connection_set_exit_on_disconnect (dbus_connection, 0);


	if (!libhal_device_singleton_addon_is_ready (ctx, commandline, &error)) {
		goto out;
	}

	leds = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);

	gmain = g_main_loop_new (NULL, FALSE);
	g_main_loop_run (gmain);

	return 0;

out:
	HAL_DEBUG (("An error occured, exiting cleanly"));
	
	LIBHAL_FREE_DBUS_ERROR (&error);

	if (ctx != NULL) {
		libhal_ctx_shutdown (ctx, &error);
		LIBHAL_FREE_DBUS_ERROR (&error);
		libhal_ctx_free (ctx);
	}

	return 0;
}
开发者ID:iegor,项目名称:hal,代码行数:58,代码来源:addon-leds.c


示例20: dbus_py_glib_set_up_conn

static dbus_bool_t
dbus_py_glib_set_up_conn(DBusConnection *conn, void *data)
{
    GMainContext *ctx = (GMainContext *)data;
    Py_BEGIN_ALLOW_THREADS
    dbus_connection_setup_with_g_main(conn, ctx);
    Py_END_ALLOW_THREADS
    return 1;
}
开发者ID:mahomahomaho,项目名称:dbus-python-egg,代码行数:9,代码来源:module.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dbus_connection_unref函数代码示例发布时间:2022-05-30
下一篇:
C++ dbus_connection_set_watch_functions函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap