本文整理汇总了C++中dbus_bus_add_match函数的典型用法代码示例。如果您正苦于以下问题:C++ dbus_bus_add_match函数的具体用法?C++ dbus_bus_add_match怎么用?C++ dbus_bus_add_match使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbus_bus_add_match函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: eldbus_signal_handler_match_extra_vset
EAPI Eina_Bool
eldbus_signal_handler_match_extra_vset(Eldbus_Signal_Handler *sh, va_list ap)
{
const char *key = NULL, *read;
DBusError err;
ELDBUS_SIGNAL_HANDLER_CHECK_RETVAL(sh, EINA_FALSE);
dbus_error_init(&err);
dbus_bus_remove_match(sh->conn->dbus_conn,
eina_strbuf_string_get(sh->match), &err);
EINA_SAFETY_ON_TRUE_RETURN_VAL(dbus_error_is_set(&err), EINA_FALSE);
for (read = va_arg(ap, char *); read; read = va_arg(ap, char *))
{
Signal_Argument *arg;
if (!key)
{
key = read;
continue;
}
arg = calloc(1, sizeof(Signal_Argument));
EINA_SAFETY_ON_NULL_GOTO(arg, error);
if (!strncmp(key, ARGX, strlen(ARGX)))
{
int id = atoi(key + strlen(ARGX));
arg->index = (unsigned short) id;
arg->value = eina_stringshare_add(read);
sh->args = eina_inlist_sorted_state_insert(sh->args,
EINA_INLIST_GET(arg),
_sort_arg,
sh->state_args);
_match_append(sh->match, key, read);
}
else
{
ERR("%s not supported", key);
free(arg);
}
key = NULL;
}
dbus_error_init(&err);
dbus_bus_add_match(sh->conn->dbus_conn,
eina_strbuf_string_get(sh->match), &err);
if (!dbus_error_is_set(&err))
return EINA_TRUE;
ERR("Error setting new match.");
return EINA_FALSE;
error:
dbus_error_init(&err);
dbus_bus_add_match(sh->conn->dbus_conn,
eina_strbuf_string_get(sh->match), &err);
if (dbus_error_is_set(&err))
ERR("Error setting partial extra arguments.");
return EINA_FALSE;
}
开发者ID:RomainNaour,项目名称:efl,代码行数:60,代码来源:eldbus_signal_handler.c
示例2: g_debug
void
HippoDBusIpcProviderImpl::setBusUniqueName(const char *uniqueName)
{
g_debug("unique name of client: %s", uniqueName ? uniqueName : "NULL");
if (uniqueName == NULL && busUniqueName_ == NULL)
return;
if (uniqueName && busUniqueName_ && strcmp(uniqueName, busUniqueName_) == 0)
return;
if (busUniqueName_ != NULL && connection_) {
char *connectedRule = connected_rule(busUniqueName_);
char *disconnectedRule = disconnected_rule(busUniqueName_);
// both of these will fail if the matched busUniqueName_ is disconnected,
// since the bus garbage collects the match rules for nonexistent unique
// names. we just want to ignore the failure.
g_debug("removing rule %s", connectedRule);
dbus_bus_remove_match(connection_, connectedRule, NULL);
g_debug("removing rule %s", disconnectedRule);
dbus_bus_remove_match(connection_, disconnectedRule, NULL);
g_free(connectedRule);
g_free(disconnectedRule);
}
/* note the new unique name can be NULL */
busUniqueName_ = g_strdup(uniqueName);
if (busUniqueName_ != NULL && connection_) {
char *connectedRule = connected_rule(busUniqueName_);
char *disconnectedRule = disconnected_rule(busUniqueName_);
g_debug("adding rule %s", connectedRule);
dbus_bus_add_match(connection_, connectedRule, NULL);
g_debug("adding rule %s", disconnectedRule);
dbus_bus_add_match(connection_, disconnectedRule, NULL);
g_free(connectedRule);
g_free(disconnectedRule);
}
if (busUniqueName_ != NULL)
notifyRegisterEndpointOpportunity();
else
notifyEndpointsInvalidated();
}
开发者ID:nihed,项目名称:magnetism,代码行数:48,代码来源:hippo-dbus-ipc-provider.cpp
示例3: connect_to_service
static DBusConnection*
connect_to_service (void)
{
DBusError derr = DBUS_ERROR_INIT;
DBusConnection *conn;
const gchar *rule;
/*
* TODO: We currently really have no way to close this connection or do
* cleanup, and it's unclear how and whether we need to.
*/
if (!dbus_connection) {
if (!g_getenv ("DBUS_SESSION_BUS_ADDRESS"))
return NULL;
conn = dbus_bus_get_private (DBUS_BUS_SESSION, &derr);
if (conn == NULL) {
g_message ("couldn't connect to dbus session bus: %s", derr.message);
dbus_error_free (&derr);
return NULL;
}
dbus_connection_set_exit_on_disconnect (conn, FALSE);
/* Listen for the completed signal */
rule = "type='signal',interface='org.mate.secrets.Prompt',member='Completed'";
dbus_bus_add_match (conn, rule, NULL);
/* Listen for name owner changed signals */
rule = "type='signal',member='NameOwnerChanged',interface='org.freedesktop.DBus'";
dbus_bus_add_match (conn, rule, NULL);
dbus_connection_add_filter (conn, on_name_changed_filter, NULL, NULL);
G_LOCK (dbus_connection);
{
if (dbus_connection) {
dbus_connection_unref (conn);
} else {
egg_dbus_connect_with_mainloop (conn, NULL);
dbus_connection = conn;
}
}
G_UNLOCK (dbus_connection);
}
return dbus_connection_ref (dbus_connection);
}
开发者ID:TheCoffeMaker,项目名称:Mate-Desktop-Environment,代码行数:48,代码来源:gkr-operation.c
示例4: message
CLogindUPowerSyscall::CLogindUPowerSyscall()
{
m_delayLockFd = -1;
m_lowBattery = false;
CLog::Log(LOGINFO, "Selected Logind/UPower as PowerSyscall");
// Check if we have UPower. If not, we avoid any battery related operations.
CDBusMessage message("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower", "EnumerateDevices");
m_hasUPower = message.SendSystem() != NULL;
if (!m_hasUPower)
CLog::Log(LOGINFO, "LogindUPowerSyscall - UPower not found, battery information will not be available");
m_canPowerdown = LogindCheckCapability("CanPowerOff");
m_canReboot = LogindCheckCapability("CanReboot");
m_canHibernate = LogindCheckCapability("CanHibernate");
m_canSuspend = LogindCheckCapability("CanSuspend");
InhibitDelayLock();
m_batteryLevel = 0;
if (m_hasUPower)
UpdateBatteryLevel();
DBusError error;
dbus_error_init(&error);
m_connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
if (dbus_error_is_set(&error))
{
CLog::Log(LOGERROR, "LogindUPowerSyscall: Failed to get dbus connection: %s", error.message);
dbus_connection_close(m_connection);
dbus_connection_unref(m_connection);
m_connection = NULL;
dbus_error_free(&error);
return;
}
dbus_connection_set_exit_on_disconnect(m_connection, false);
dbus_bus_add_match(m_connection, "type='signal',interface='org.freedesktop.login1.Manager',member='PrepareForSleep'", NULL);
if (m_hasUPower)
dbus_bus_add_match(m_connection, "type='signal',interface='org.freedesktop.UPower',member='DeviceChanged'", NULL);
dbus_connection_flush(m_connection);
dbus_error_free(&error);
}
开发者ID:Dreamer-4pda,项目名称:kodi-cmake,代码行数:48,代码来源:LogindUPowerSyscall.cpp
示例5: 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
示例6: initdbus
void
initdbus(void) {
int ret;
dbus_error_init(&dbus_err);
dbus_conn = dbus_bus_get(DBUS_BUS_SESSION, &dbus_err);
if(dbus_error_is_set(&dbus_err)) {
fprintf(stderr, "Connection Error (%s)\n", dbus_err.message);
dbus_error_free(&dbus_err);
}
if(dbus_conn == NULL) {
fprintf(stderr, "dbus_con == NULL\n");
exit(EXIT_FAILURE);
}
ret = dbus_bus_request_name(dbus_conn, "org.freedesktop.Notifications",
DBUS_NAME_FLAG_REPLACE_EXISTING, &dbus_err);
if(dbus_error_is_set(&dbus_err)) {
fprintf(stderr, "Name Error (%s)\n", dbus_err.message);
}
if(DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
fprintf(stderr, "There's already another notification-daemon running\n");
exit(EXIT_FAILURE);
}
dbus_bus_add_match(dbus_conn,
"type='signal',interface='org.freedesktop.Notifications'",
&dbus_err);
if(dbus_error_is_set(&dbus_err)) {
fprintf(stderr, "Match error (%s)\n", dbus_err.message);
exit(EXIT_FAILURE);
}
}
开发者ID:wm4,项目名称:dunst,代码行数:32,代码来源:dunst_dbus.c
示例7: dbus_error_init
void
nsNetworkManagerListener::RegisterWithConnection(DBusConnection* connection) {
DBusError error;
dbus_error_init(&error);
dbus_bus_add_match(connection,
"type='signal',"
"interface='" NM_DBUS_INTERFACE "',"
"sender='" NM_DBUS_SERVICE "',"
"path='" NM_DBUS_PATH "'", &error);
mOK = !dbus_error_is_set(&error);
dbus_error_free(&error);
if (!mOK)
return;
DBusMessage* msg =
dbus_message_new_method_call(NM_DBUS_SERVICE, NM_DBUS_PATH,
NM_DBUS_INTERFACE, "state");
if (!msg) {
mOK = PR_FALSE;
return;
}
DBusPendingCall* reply = mDBUS->SendWithReply(this, msg);
if (!reply) {
mOK = PR_FALSE;
return;
}
dbus_pending_call_set_notify(reply, NetworkStatusNotify, this, NULL);
dbus_pending_call_unref(reply);
}
开发者ID:isleon,项目名称:Jaxer,代码行数:32,代码来源:nsNetworkManagerListener.cpp
示例8: elektraDbusReceiveMessage
int elektraDbusReceiveMessage (DBusBusType type, DBusHandleMessageFunction filter_func)
{
DBusConnection *connection;
DBusError error;
dbus_error_init (&error);
connection = dbus_bus_get (type, &error);
if (connection == NULL)
{
fprintf (stderr, "Failed to open connection to %s message bus: %s\n",
(type == DBUS_BUS_SYSTEM) ? "system" : "session",
error.message);
goto error;
}
dbus_bus_add_match (connection, "type='signal',interface='org.libelektra',path='/org/libelektra/configuration'", &error);
if (dbus_error_is_set (&error)) goto error;
if (!dbus_connection_add_filter (connection, filter_func, NULL, NULL))
{
goto error;
}
while (dbus_connection_read_write_dispatch(connection, -1));
return 0;
error:
printf ("Error occurred\n");
dbus_error_free (&error);
return -1;
}
开发者ID:tryge,项目名称:libelektra,代码行数:30,代码来源:receivemessage.c
示例9: setup_network_monitor
static void
setup_network_monitor (MateWeatherApplet *gw_applet)
{
GError *error;
static DBusGConnection *bus = NULL;
DBusConnection *dbus;
if (bus == NULL) {
error = NULL;
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (bus == NULL) {
g_warning ("Couldn't connect to system bus: %s",
error->message);
g_error_free (error);
return;
}
dbus = dbus_g_connection_get_connection (bus);
dbus_connection_add_filter (dbus, filter_func, gw_applet, NULL);
dbus_bus_add_match (dbus,
"type='signal',"
"interface='" NM_DBUS_INTERFACE "'",
NULL);
}
}
开发者ID:anastasis2014,项目名称:mate-applets,代码行数:26,代码来源:mateweather-applet.c
示例10: 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
示例11: pa_dbus_add_matches
int pa_dbus_add_matches(DBusConnection *c, DBusError *error, ...) {
const char *t;
va_list ap;
unsigned k = 0;
pa_assert(c);
pa_assert(error);
va_start(ap, error);
while ((t = va_arg(ap, const char*))) {
dbus_bus_add_match(c, t, error);
if (dbus_error_is_set(error))
goto fail;
k++;
}
va_end(ap);
return 0;
fail:
va_end(ap);
va_start(ap, error);
for (; k > 0; k--) {
pa_assert_se(t = va_arg(ap, const char*));
dbus_bus_remove_match(c, t, NULL);
}
va_end(ap);
return -1;
}
开发者ID:BYSTROSTREL,项目名称:pulseaudio,代码行数:32,代码来源:dbus-util.c
示例12: client_bind
static bool client_bind(Client* client,
DsmeDbusHandler* handler,
const char* interface,
const char* name)
{
bool bound = false;
const char* match_format = "type='signal', interface='%s', member='%s'";
char* match;
DBusError error;
dispatcher_list_add(client->handlers,
handler_dispatcher_new(handler, interface, name));
match = malloc(strlen(match_format) +
strlen(interface) +
strlen(name) - 3);
sprintf(match, match_format, interface, name);
dbus_error_init(&error);
dbus_bus_add_match(client->filter->connection, match, &error);
free(match);
if (dbus_error_is_set(&error)) {
dsme_log(LOG_DEBUG, "dbus_bus_add_match(): %s", error.message);
dbus_error_free(&error);
} else {
dsme_log(LOG_DEBUG, "bound handler for: %s, %s", interface, name);
bound = true;
}
return bound;
}
开发者ID:plundstr,项目名称:dsme,代码行数:32,代码来源:dsme_dbus.c
示例13: dbus_threads_init_default
bool
DBusThread::SetUpEventLoop()
{
// If we already have a connection, exit
if (mConnection) {
return false;
}
dbus_threads_init_default();
DBusError err;
dbus_error_init(&err);
// If we can't establish a connection to dbus, nothing else will work
nsresult rv = EstablishDBusConnection();
if (NS_FAILED(rv)) {
NS_WARNING("Cannot create DBus Connection for DBus Thread!");
return false;
}
// Set which messages will be processed by this dbus connection.
// Since we are maintaining a single thread for all the DBus bluez
// signals we want, register all of them in this thread at startup.
// The event handler will sort the destinations out as needed.
for (uint32_t i = 0; i < ArrayLength(DBUS_SIGNALS); ++i) {
dbus_bus_add_match(mConnection,
DBUS_SIGNALS[i],
&err);
if (dbus_error_is_set(&err)) {
LOG_AND_FREE_DBUS_ERROR(&err);
return false;
}
}
return true;
}
开发者ID:TheTypoMaster,项目名称:fennec-777045,代码行数:34,代码来源:DBusThread.cpp
示例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: 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
示例16: 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
示例17: 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
示例18: dbus_connection_set_exit_on_disconnect
CUPowerSyscall::CUPowerSyscall()
{
CLog::Log(LOGINFO, "Selected UPower as PowerSyscall");
m_lowBattery = false;
//! @todo do not use dbus_connection_pop_message() that requires the use of a
//! private connection
if (m_connection.Connect(DBUS_BUS_SYSTEM, true))
{
dbus_connection_set_exit_on_disconnect(m_connection, false);
CDBusError error;
dbus_bus_add_match(m_connection, "type='signal',interface='org.freedesktop.UPower'", error);
dbus_connection_flush(m_connection);
if (error)
{
error.Log("UPower: Failed to attach to signal");
m_connection.Destroy();
}
}
m_CanPowerdown = false;
m_CanReboot = false;
UpdateCapabilities();
EnumeratePowerSources();
}
开发者ID:FernetMenta,项目名称:xbmc,代码行数:30,代码来源:UPowerSyscall.cpp
示例19: mce_sink_initialize
static int
mce_sink_initialize (NSinkInterface *iface)
{
(void) iface;
DBusError error;
dbus_error_init (&error);
bus = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
if (bus == NULL) {
N_WARNING ("%s >> failed to get system bus: %s", __FUNCTION__, error.message);
dbus_error_free (&error);
return FALSE;
}
char *rule = "type='signal',interface='" MCE_SIGNAL_IF "'";
dbus_bus_add_match(bus, rule, &error);
if (dbus_error_is_set(&error)) {
N_WARNING ("%s >> failed to add D-BUS match rule, cause: %s", __FUNCTION__, error.message);
dbus_error_free (&error);
return FALSE;
}
dbus_connection_add_filter(bus, mce_signal_filter, NULL, NULL);
return TRUE;
}
开发者ID:kjokinie,项目名称:ngfd,代码行数:26,代码来源:plugin.c
示例20: 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
注:本文中的dbus_bus_add_match函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论