本文整理汇总了C++中dbus_connection_add_filter函数的典型用法代码示例。如果您正苦于以下问题:C++ dbus_connection_add_filter函数的具体用法?C++ dbus_connection_add_filter怎么用?C++ dbus_connection_add_filter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbus_connection_add_filter函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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_GMAIN_FUNCTION_NAME (set_up_connection) (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:d-bus,项目名称:dbus-python,代码行数:28,代码来源:test-thread-server.c
示例2: usb_moded_app_sync_init_connection
/**
* Attach to session bus
*/
gboolean usb_moded_app_sync_init_connection(void)
{
gboolean result = FALSE;
DBusError error = DBUS_ERROR_INIT;
if( dbus_connection_ses != 0 )
{
result = TRUE;
goto EXIT;
}
if( dbus_connection_disc )
{
// we've already observed death of session
goto EXIT;
}
/* Connect to session bus */
if ((dbus_connection_ses = dbus_bus_get(DBUS_BUS_SESSION, &error)) == NULL)
{
log_err("Failed to open connection to session message bus; %s\n", error.message);
goto EXIT;
}
/* Add disconnect handler */
dbus_connection_add_filter(dbus_connection_ses, handle_disconnect, 0, 0);
/* Add method call handler */
dbus_connection_add_filter(dbus_connection_ses, msg_handler, 0, 0);
/* Make sure we do not get forced to exit if dbus session dies or stops */
dbus_connection_set_exit_on_disconnect(dbus_connection_ses, FALSE);
/* Connect D-Bus to the mainloop */
dbus_connection_setup_with_g_main(dbus_connection_ses, NULL);
/* Request service name */
if( !usb_moded_app_sync_obtain_name() )
{
goto EXIT;
}
/* everything went fine */
result = TRUE;
EXIT:
dbus_error_free(&error);
return result;
}
开发者ID:d0b3rm4n,项目名称:usb-moded,代码行数:52,代码来源:usb_moded-appsync-dbus.c
示例3: rtdbus_add_signal_rule_and_filter
gboolean rtdbus_add_signal_rule_and_filter(
const char *path, const char *interface,
DBusHandleMessageFunction filter_fn)
{
DBusError derror;
char *match_rule;
dbus_error_init(&derror);
match_rule = g_strdup_printf(
"type='signal',path='%s',interface='%s'",
path, interface);
dbus_bus_add_match(rtdbus_connection, match_rule, &derror);
if (dbus_error_is_set(&derror))
{
rtdbus_whinge(&derror, _("Unable to add D-BUS signal match rule"));
return FALSE;
}
if (!dbus_connection_add_filter(rtdbus_connection,
filter_fn, NULL, NULL))
{
rtdbus_whinge(&derror, _("Unable to install D-BUS message filter"));
return FALSE;
}
return TRUE;
}
开发者ID:forivall-mirrors,项目名称:roxterm,代码行数:25,代码来源:rtdbus.c
示例4: 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
示例5: _init_dbus_signal
gboolean _init_dbus_signal(void)
{
DBG("+\n");
DBusGConnection *conn;
GError *err = NULL;
DBusError dbus_error;
conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
if(!conn) {
ERR(" DBUS get failed\n");
g_error_free(err);
return FALSE;
}
dbus_connection = dbus_g_connection_get_connection(conn);
/* Add the filter for network client functions */
dbus_error_init(&dbus_error);
dbus_connection_add_filter(dbus_connection, __dbus_event_filter, NULL, NULL);
dbus_bus_add_match(dbus_connection,
"type=signal,interface=" NETWORK_SERIAL_INTERFACE
",member=ready_for_serial", &dbus_error);
if (dbus_error_is_set(&dbus_error)) {
ERR("Fail to add dbus filter signal\n");
dbus_error_free(&dbus_error);
}
DBG("-\n");
return TRUE;
}
开发者ID:tizenorg,项目名称:framework.connectivity.data-router,代码行数:29,代码来源:dr-ipc.c
示例6: gconf_database_dbus_setup
void
gconf_database_dbus_setup (GConfDatabase *db)
{
DBusConnection *conn;
g_assert (db->object_path == NULL);
db->object_path = g_strdup_printf ("%s/%d",
DATABASE_OBJECT_PATH,
object_nr++);
conn = gconfd_dbus_get_connection ();
dbus_connection_register_object_path (conn,
db->object_path,
&database_vtable,
db);
db->notifications = g_hash_table_new (g_str_hash, g_str_equal);
db->listening_clients = g_hash_table_new (g_str_hash, g_str_equal);
dbus_connection_add_filter (conn,
(DBusHandleMessageFunction)database_filter_func,
db,
NULL);
}
开发者ID:SpOlErOk38,项目名称:gconf-dbus,代码行数:26,代码来源:gconf-database-dbus.c
示例7: 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
示例8: 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
示例9: 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
示例10: halInitPrivate
/* This constructor sets up a private connection to the DBus daemon, connects
* to the hal service and installs a filter which sets the mTriggered flag in
* the Context structure when a device (not necessarily USB) is added or
* removed. */
VBoxMainHotplugWaiter::VBoxMainHotplugWaiter ()
{
#if defined RT_OS_LINUX && defined VBOX_WITH_DBUS
int rc = VINF_SUCCESS;
mContext = new Context;
if (RT_SUCCESS(RTDBusLoadLib()))
{
for (unsigned i = 0; RT_SUCCESS(rc) && i < 5 && !mContext->mConnection; ++i)
{
rc = halInitPrivate (&mContext->mConnection);
}
if (!mContext->mConnection)
rc = VERR_NOT_SUPPORTED;
DBusMessage *pMessage;
while ( RT_SUCCESS(rc)
&& (pMessage = dbus_connection_pop_message (mContext->mConnection.get())) != NULL)
dbus_message_unref (pMessage); /* empty the message queue. */
if ( RT_SUCCESS(rc)
&& !dbus_connection_add_filter (mContext->mConnection.get(),
dbusFilterFunction,
(void *) &mContext->mTriggered, NULL))
rc = VERR_NO_MEMORY;
if (RT_FAILURE(rc))
mContext->mConnection.reset();
}
#endif /* defined RT_OS_LINUX && defined VBOX_WITH_DBUS */
}
开发者ID:mcenirm,项目名称:vbox,代码行数:32,代码来源:HostHardwareFreeBSD.cpp
示例11: main
int
main (int argv, char ** argc)
{
g_type_init();
g_debug("Waiting to init.");
GError * error = NULL;
DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
if (error != NULL) {
g_error("Unable to get session bus: %s", error->message);
return 1;
}
DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
gboolean has_owner = FALSE;
gint owner_count = 0;
while (!has_owner && owner_count < 10000) {
org_freedesktop_DBus_name_has_owner(bus_proxy, "org.test", &has_owner, NULL);
owner_count++;
}
if (owner_count == 10000) {
g_error("Unable to get name owner after 10000 tries");
return 1;
}
g_usleep(500000);
g_debug("Initing");
guint nameret = 0;
if (!org_freedesktop_DBus_request_name(bus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, 0, &nameret, &error)) {
g_error("Unable to call to request name");
return 1;
}
if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
g_error("Unable to get name");
return 1;
}
dbus_connection_add_filter(dbus_g_connection_get_connection(session_bus), dbus_filter, NULL, NULL);
/* This is the final kill function. It really shouldn't happen
unless we get an error. */
g_timeout_add(2000, kill_func, NULL);
g_debug("Entering Mainloop");
mainloop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(mainloop);
g_debug("Exiting");
return 0;
}
开发者ID:stonexer,项目名称:chinese-datetime,代码行数:60,代码来源:test-libappindicator-fallback-watcher.c
示例12: get_session_bus
static DBusGConnection *
get_session_bus (void)
{
GError *error;
DBusGConnection *bus;
DBusConnection *connection;
error = NULL;
bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (bus == NULL) {
g_warning ("Couldn't connect to session bus: %s",
error->message);
g_error_free (error);
goto out;
}
connection = dbus_g_connection_get_connection (bus);
dbus_connection_add_filter (connection,
(DBusHandleMessageFunction)
bus_message_handler,
NULL, NULL);
dbus_connection_set_exit_on_disconnect (connection, FALSE);
out:
return bus;
}
开发者ID:TheCoffeMaker,项目名称:Mate-Desktop-Environment,代码行数:27,代码来源:main.c
示例13: 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
示例14: 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
示例15: main
int
main (int argc, char *argv[])
{
DBusServer *server;
DBusError error;
DBusLoop *loop;
DBusConnection *session;
TestServiceData *testdata;
dbus_error_init (&error);
loop = _dbus_loop_new ();
testdata = dbus_new (TestServiceData, 1);
testdata->loop = loop;
session = dbus_bus_get (DBUS_BUS_SESSION, &error);
if (!session)
die ("couldn't access session bus");
test_connection_setup (loop, session);
dbus_bus_request_name (session, "org.freedesktop.DBus.TestSuite.PrivServer", 0, &error);
if (dbus_error_is_set (&error))
die ("couldn't request name: %s", error.message);
if (!dbus_connection_add_filter (session, filter_session_message, testdata, NULL))
die ("couldn't add filter");
#ifdef DBUS_CMAKE
server = dbus_server_listen (TEST_LISTEN, &error);
#else
server = dbus_server_listen ("unix:tmpdir=/tmp", &error);
#endif
if (!server)
die ("%s", error.message);
testdata->private_addr = dbus_server_get_address (server);
fprintf (stderr, "test server listening on %s\n", testdata->private_addr);
dbus_server_set_new_connection_function (server, new_connection_callback,
testdata, NULL);
test_server_setup (loop, server);
fprintf (stderr, "server running mainloop\n");
_dbus_loop_run (loop);
fprintf (stderr, "server mainloop quit\n");
test_server_shutdown (loop, server);
test_connection_shutdown (loop, session);
dbus_connection_unref (session);
_dbus_loop_unref (loop);
dbus_free (testdata);
return 0;
}
开发者ID:halfline,项目名称:dbus,代码行数:60,代码来源:test-privserver.c
示例16: 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
示例17: 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
示例18: dbus_threads_init_default
wxDBusConnection::wxDBusConnection(int ID, wxEvtHandler * EvtHandler, bool System)
{
// Make sure libdbus locks its data structures, otherwise
// there'll be crashes if it gets used from multiple threads
// at the same time
dbus_threads_init_default();
m_error = new wxDBusError;
m_connection = System ? dbus_bus_get(DBUS_BUS_SYSTEM, &(m_error->GetError())) : dbus_bus_get(DBUS_BUS_SESSION, &(m_error->GetError()));
if (!m_connection) {
fprintf(stderr, "Failed to connect to D-BUS: %s\n", m_error->GetError().message);
}
else
{
m_filter_installed = dbus_connection_add_filter(m_connection, handle_message, (void *) this, NULL);
m_ID = ID;
m_EvtHandler = EvtHandler;
m_thread = new DBusThread(wxTHREAD_JOINABLE, this, ID, m_connection);
if (!m_thread->Init())
{
fprintf(stderr, "Failed to create worker thread\n");
delete m_thread;
m_thread = NULL;
if (m_filter_installed)
{
dbus_connection_remove_filter(m_connection, handle_message, (void *) this);
m_filter_installed = false;
}
dbus_connection_unref(m_connection);
m_connection = 0;
}
}
}
开发者ID:bugiii,项目名称:filezilla3ex,代码行数:35,代码来源:wxdbusconnection.cpp
示例19: 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
示例20: cpu_keepalive_attach_to_dbus
/** Install signal and method call message handlers
*
* @return TRUE on success, or FALSE on failure
*/
static gboolean cpu_keepalive_attach_to_dbus(void)
{
gboolean success = TRUE;
/* Register signal handling filter */
dbus_connection_add_filter(systembus, cpu_keepalive_dbus_filter_cb, 0, 0);
/* Register dbus method call handlers */
for( size_t i = 0; methods[i].member; ++i )
{
mce_log(LL_INFO, "registering handler for: %s", methods[i].member);
methods[i].cookie = mce_dbus_handler_add(MCE_REQUEST_IF,
methods[i].member,
NULL,
DBUS_MESSAGE_TYPE_METHOD_CALL,
methods[i].handler);
if( !methods[i].cookie )
{
mce_log(LL_WARN, "failed to add dbus handler for: %s",
methods[i].member);
success = FALSE;
}
}
return success;
}
开发者ID:Vesuri,项目名称:mce,代码行数:31,代码来源:cpu-keepalive.c
注:本文中的dbus_connection_add_filter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论