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


C++ dbus_connection_set_watch_functions函数代码示例

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


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

示例1: weston_dbus_bind

static int weston_dbus_bind(struct wl_event_loop *loop, DBusConnection *c,
			    struct wl_event_source **ctx_out)
{
	bool b;
	int r, fd;

	/* Idle events cannot reschedule themselves, therefore we use a dummy
	 * event-fd and mark it for post-dispatch. Hence, the dbus
	 * dispatcher is called after every dispatch-round.
	 * This is required as dbus doesn't allow dispatching events from
	 * within its own event sources. */
	fd = eventfd(0, EFD_CLOEXEC);
	if (fd < 0)
		return -errno;

	*ctx_out = wl_event_loop_add_fd(loop, fd, 0, weston_dbus_dispatch, c);
	close(fd);

	if (!*ctx_out)
		return -ENOMEM;

	wl_event_source_check(*ctx_out);

	b = dbus_connection_set_watch_functions(c,
						weston_dbus_add_watch,
						weston_dbus_remove_watch,
						weston_dbus_toggle_watch,
						loop,
						NULL);
	if (!b) {
		r = -ENOMEM;
		goto error;
	}

	b = dbus_connection_set_timeout_functions(c,
						  weston_dbus_add_timeout,
						  weston_dbus_remove_timeout,
						  weston_dbus_toggle_timeout,
						  loop,
						  NULL);
	if (!b) {
		r = -ENOMEM;
		goto error;
	}

	dbus_connection_ref(c);
	return 0;

error:
	dbus_connection_set_timeout_functions(c, NULL, NULL, NULL,
					      NULL, NULL);
	dbus_connection_set_watch_functions(c, NULL, NULL, NULL,
					    NULL, NULL);
	wl_event_source_remove(*ctx_out);
	*ctx_out = NULL;
	return r;
}
开发者ID:ChristophHaag,项目名称:weston,代码行数:57,代码来源:dbus.c

示例2: dbus_connection_set_watch_functions

void
DBusThread::EventLoop()
{
  dbus_connection_set_watch_functions(mConnection, AddWatch,
                                      RemoveWatch, ToggleWatch, this, NULL);
  dbus_connection_set_wakeup_main_function(mConnection, DBusWakeup, this, NULL);
#ifdef DEBUG
  LOG("DBus Event Loop Starting\n");
#endif
  while (1) {
    poll(mPollData.Elements(), mPollData.Length(), -1);

    for (uint32_t i = 0; i < mPollData.Length(); i++) {
      if (!mPollData[i].revents) {
        continue;
      }

      if (mPollData[i].fd == mControlFdR.get()) {
        char data;
        while (recv(mControlFdR.get(), &data, sizeof(char), MSG_DONTWAIT)
               != -1) {
          switch (data) {
          case DBUS_EVENT_LOOP_EXIT:
#ifdef DEBUG
            LOG("DBus Event Loop Exiting\n");
#endif
            dbus_connection_set_watch_functions(mConnection,
                                                NULL, NULL, NULL, NULL, NULL);
            return;
          case DBUS_EVENT_LOOP_ADD:
            HandleWatchAdd(this);
            break;
          case DBUS_EVENT_LOOP_REMOVE:
            HandleWatchRemove(this);
            break;
          case DBUS_EVENT_LOOP_WAKEUP:
            // noop
            break;
          }
        }
      } else {
        short events = mPollData[i].revents;
        unsigned int flags = UnixEventsToDBusFlags(events);
        dbus_watch_handle(mWatchData[i], flags);
        mPollData[i].revents = 0;
        // Break at this point since we don't know if the operation
        // was destructive
        break;
      }
    }
    while (dbus_connection_dispatch(mConnection) ==
           DBUS_DISPATCH_DATA_REMAINS)
    {}
  }
}
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:55,代码来源:DBusThread.cpp

示例3: test_connection_setup

dbus_bool_t
test_connection_setup (DBusLoop       *loop,
                       DBusConnection *connection)
{
  CData *cd;

  cd = NULL;
  
  dbus_connection_set_dispatch_status_function (connection, dispatch_status_function,
                                                loop, NULL);
  
  cd = cdata_new (loop, connection);
  if (cd == NULL)
    goto nomem;

  if (!dbus_connection_set_watch_functions (connection,
                                            add_watch,
                                            remove_watch,
                                            toggle_watch,
                                            cd, cdata_free))
    goto nomem;


  cd = cdata_new (loop, connection);
  if (cd == NULL)
    goto nomem;
  
  if (!dbus_connection_set_timeout_functions (connection,
                                              add_timeout,
                                              remove_timeout,
                                              NULL,
                                              cd, cdata_free))
    goto nomem;

  if (dbus_connection_get_dispatch_status (connection) != DBUS_DISPATCH_COMPLETE)
    {
      if (!_dbus_loop_queue_dispatch (loop, connection))
        goto nomem;
    }
  
  return TRUE;
  
 nomem:
  if (cd)
    cdata_free (cd);
  
  dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL);
  dbus_connection_set_watch_functions (connection, NULL, NULL, NULL, NULL, NULL);
  dbus_connection_set_timeout_functions (connection, NULL, NULL, NULL, NULL, NULL);
  
  return FALSE;
}
开发者ID:520lly,项目名称:platform_external_dbus,代码行数:52,代码来源:test-utils.c

示例4: egg_dbus_connect_with_mainloop

void
egg_dbus_connect_with_mainloop (DBusConnection *connection, GMainContext *context)
{
	ConnectionSetup *cs;

	if (context == NULL)
		context = g_main_context_default ();
	cs = connection_setup_new (context, connection);
	the_setup = cs;

	if (!dbus_connection_set_watch_functions (connection, add_watch,
	                                          remove_watch, watch_toggled,
	                                          cs, NULL))
		goto nomem;

	if (!dbus_connection_set_timeout_functions (connection, add_timeout,
	                                            remove_timeout, timeout_toggled,
	                                            cs, NULL))
		goto nomem;

	dbus_connection_set_wakeup_main_function (connection, wakeup_main, cs, NULL);

	return;

nomem:
	g_error ("Not enough memory to set up DBusConnection for use with GLib");
}
开发者ID:TheCoffeMaker,项目名称:Mate-Desktop-Environment,代码行数:27,代码来源:egg-dbus.c

示例5: dbus_connection_set_change_sigpipe

static DBusConnection *virDBusBusInit(DBusBusType type, DBusError *dbuserr)
{
    DBusConnection *bus;

    /* Allocate and initialize a new HAL context */
    dbus_connection_set_change_sigpipe(FALSE);
    dbus_threads_init_default();

    dbus_error_init(dbuserr);
    bus = sharedBus ?
        dbus_bus_get(type, dbuserr) :
        dbus_bus_get_private(type, dbuserr);
    if (!bus)
        return NULL;

    dbus_connection_set_exit_on_disconnect(bus, FALSE);

    /* Register dbus watch callbacks */
    if (!dbus_connection_set_watch_functions(bus,
                                             virDBusAddWatch,
                                             virDBusRemoveWatch,
                                             virDBusToggleWatch,
                                             bus, NULL)) {
        return NULL;
    }
    return bus;
}
开发者ID:cbosdo,项目名称:libvirt,代码行数:27,代码来源:virdbus.c

示例6: fcntl

bool DBusThread::Init()
{
	if (pipe(m_wakeup_pipe) == -1)
	{
		// Just to be sure
		m_wakeup_pipe[0] = -1;
		m_wakeup_pipe[1] = -1;
		return false;
	}

	if (Create() != wxTHREAD_NO_ERROR)
		return false;

	int res;
	do {
		res = fcntl(m_wakeup_pipe[0], F_SETFL, O_NONBLOCK);
	} while( res == -1 && errno == EINTR );

	m_parent_id = pthread_self();

	dbus_connection_set_watch_functions(m_connection, add_watch, remove_watch, toggle_watch, (void *)this, NULL);

	Run();

	return true;
}
开发者ID:bugiii,项目名称:filezilla3ex,代码行数:26,代码来源:wxdbusconnection.cpp

示例7: integrate_with_eloop

/**
 * integrate_with_eloop - Register our mainloop integration with dbus
 * @connection: connection to the system message bus
 * @iface: a dbus control interface data structure
 * Returns: 0 on success, -1 on failure
 *
 * We register our mainloop integration functions with dbus here.
 */
static int integrate_with_eloop(DBusConnection *connection,
	struct ctrl_iface_dbus_priv *iface)
{
	if (!dbus_connection_set_watch_functions(connection, add_watch,
						 remove_watch, watch_toggled,
						 iface, NULL)) {
		perror("dbus_connection_set_watch_functions[dbus]");
		wpa_printf(MSG_ERROR, "Not enough memory to set up dbus.");
		return -1;
	}

	if (!dbus_connection_set_timeout_functions(connection, add_timeout,
						   remove_timeout,
						   timeout_toggled, iface,
						   NULL)) {
		perror("dbus_connection_set_timeout_functions[dbus]");
		wpa_printf(MSG_ERROR, "Not enough memory to set up dbus.");
		return -1;
	}

	if (connection_setup_wakeup_main(iface) < 0) {
		perror("connection_setup_wakeup_main[dbus]");
		wpa_printf(MSG_ERROR, "Could not setup main wakeup function.");
		return -1;
	}

	return 0;
}
开发者ID:ebichu,项目名称:dd-wrt,代码行数:36,代码来源:ctrl_iface_dbus.c

示例8: MOZ_ASSERT

void
DBusThread::CleanUp()
{
  MOZ_ASSERT(!NS_IsMainThread());

  dbus_connection_set_wakeup_main_function(mConnection, nullptr, nullptr, nullptr);

  dbus_bool_t success = dbus_connection_set_watch_functions(mConnection, nullptr,
                                                            nullptr, nullptr,
                                                            nullptr, nullptr);
  if (success != TRUE) {
    NS_WARNING("dbus_connection_set_watch_functions failed");
  }

#ifdef DEBUG
  LOG("Removing DBus Sockets\n");
#endif
  if (mControlFdW.get()) {
    mControlFdW.dispose();
  }
  if (mControlFdR.get()) {
    mControlFdR.dispose();
  }
  mPollData.Clear();

  // DBusWatch pointers are maintained by DBus, so we won't leak by
  // clearing.
  mWatchData.Clear();
}
开发者ID:Jaxo,项目名称:releases-mozilla-central,代码行数:29,代码来源:DBusThread.cpp

示例9: dbus_error_init

/* returns NULL or error message, may fail silently if dbus daemon not yet up. */
char *dbus_init(void)
{
  DBusConnection *connection = NULL;
  DBusObjectPathVTable dnsmasq_vtable = {NULL, &message_handler, NULL, NULL, NULL, NULL };
  DBusError dbus_error;
  DBusMessage *message;

  dbus_error_init (&dbus_error);
  if (!(connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error)))
    return NULL;
    
  dbus_connection_set_exit_on_disconnect(connection, FALSE);
  dbus_connection_set_watch_functions(connection, add_watch, remove_watch, 
				      NULL, NULL, NULL);
  dbus_error_init (&dbus_error);
  dbus_bus_request_name (connection, daemon->dbus_name, 0, &dbus_error);
  if (dbus_error_is_set (&dbus_error))
    return (char *)dbus_error.message;
  
  if (!dbus_connection_register_object_path(connection,  DNSMASQ_PATH, 
					    &dnsmasq_vtable, NULL))
    return _("could not register a DBus message handler");
  
  daemon->dbus = connection; 
  
  if ((message = dbus_message_new_signal(DNSMASQ_PATH, daemon->dbus_name, "Up")))
    {
      dbus_connection_send(connection, message, NULL);
      dbus_message_unref(message);
    }

  return NULL;
}
开发者ID:afdnlw,项目名称:dnsmasq-chinadns,代码行数:34,代码来源:dbus.c

示例10: ldbus_connection_set_watch_functions

static int ldbus_connection_set_watch_functions(lua_State *L) {
	ldbus_watch_udata *data;

	DBusConnection *connection = check_DBusConnection(L, 1);
	int has_toggle = lua_isnil(L, 4);
	lua_settop(L, 4);
	/* Place a table below the 3 callback argument */
	lua_createtable(L, 0, 3);
	lua_insert(L, 2);
	/* Insert in reverse order */
	lua_rawseti(L, 2, DBUS_LUA_FUNC_TOGGLE);
	lua_rawseti(L, 2, DBUS_LUA_FUNC_REMOVE);
	lua_rawseti(L, 2, DBUS_LUA_FUNC_ADD);

	/* make sure ldbus.watch has been loaded */
	luaL_requiref(L, "ldbus.watch", luaopen_ldbus_watch, FALSE);
	lua_pop(L, 1);

	if ((data = malloc(sizeof(ldbus_watch_udata))) == NULL) return luaL_error(L, LDBUS_NO_MEMORY);
	data->L = L;
	data->ref = luaL_ref(L, LUA_REGISTRYINDEX);

	if (!dbus_connection_set_watch_functions(connection,
			ldbus_watch_add_function, ldbus_watch_remove_function,
			has_toggle ? NULL : ldbus_watch_toggled_function,
			(void *)data, ldbus_watch_free_data_function)) {
		free(data);
		return luaL_error(L, LDBUS_NO_MEMORY);
	};
	lua_pushboolean(L, TRUE);
	return 1;
}
开发者ID:dodo,项目名称:ldbus,代码行数:32,代码来源:connection.c

示例11: pcb_dbus_connection_finish_with_mainloop

void
pcb_dbus_connection_finish_with_mainloop (DBusConnection * connection) {
    //ConnectionSetup *cs;

    //cs = dbus_connection_get_data (connection, connection_slot );

    // Replace the stored data with NULL, thus freeing the old data
    // DBus will call the function connection_setup_free() which we registered earlier
    //dbus_connection_set_data (connection, connection_slot, NULL, NULL );

    //dbus_connection_free_data_slot( &connection_slot );
    if (!dbus_connection_set_watch_functions (connection,
            NULL, NULL, NULL, NULL, NULL)) {
        goto nomem;
    }

    if (!dbus_connection_set_timeout_functions (connection,
            NULL, NULL, NULL, NULL, NULL)) {
        goto nomem;
    }

    dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL);
    return;
nomem:
    fprintf (stderr,
             "Not enough memory when cleaning up DBusConnection mainloop integration\n");
}
开发者ID:majenkotech,项目名称:pcb,代码行数:27,代码来源:dbus-pcbmain.c

示例12: pa_dbus_wrap_connection_new

pa_dbus_wrap_connection* pa_dbus_wrap_connection_new(pa_mainloop_api *m, pa_bool_t use_rtclock, DBusBusType type, DBusError *error) {
    DBusConnection *conn;
    pa_dbus_wrap_connection *pconn;
    char *id;

    pa_assert(type == DBUS_BUS_SYSTEM || type == DBUS_BUS_SESSION || type == DBUS_BUS_STARTER);

    if (!(conn = dbus_bus_get_private(type, error)))
        return NULL;

    pconn = pa_xnew(pa_dbus_wrap_connection, 1);
    pconn->mainloop = m;
    pconn->connection = conn;
    pconn->use_rtclock = use_rtclock;

    dbus_connection_set_exit_on_disconnect(conn, FALSE);
    dbus_connection_set_dispatch_status_function(conn, dispatch_status, pconn, NULL);
    dbus_connection_set_watch_functions(conn, add_watch, remove_watch, toggle_watch, pconn, NULL);
    dbus_connection_set_timeout_functions(conn, add_timeout, remove_timeout, toggle_timeout, pconn, NULL);
    dbus_connection_set_wakeup_main_function(conn, wakeup_main, pconn, NULL);

    pconn->dispatch_event = pconn->mainloop->defer_new(pconn->mainloop, dispatch_cb, conn);

    pa_log_debug("Successfully connected to D-Bus %s bus %s as %s",
                 type == DBUS_BUS_SYSTEM ? "system" : (type == DBUS_BUS_SESSION ? "session" : "starter"),
                 pa_strnull((id = dbus_connection_get_server_id(conn))),
                 pa_strnull(dbus_bus_get_unique_name(conn)));

    dbus_free(id);

    return pconn;
}
开发者ID:Klayv,项目名称:pulseaudio,代码行数:32,代码来源:dbus-util.c

示例13: pcmk_dbus_connection_setup_with_select

void pcmk_dbus_connection_setup_with_select(DBusConnection *c){
        dbus_connection_set_exit_on_disconnect (c, FALSE);
	dbus_connection_set_timeout_functions(
            c, pcmk_dbus_timeout_add, pcmk_dbus_timeout_remove, pcmk_dbus_timeout_toggle, NULL, NULL);
	dbus_connection_set_watch_functions(c, pcmk_dbus_watch_add, pcmk_dbus_watch_remove, pcmk_dbus_watch_toggle, NULL, NULL);
	dbus_connection_set_dispatch_status_function(c, pcmk_dbus_connection_dispatch, NULL, NULL);

	pcmk_dbus_connection_dispatch(c, dbus_connection_get_dispatch_status(c), NULL);
}
开发者ID:tradej,项目名称:pacemaker,代码行数:9,代码来源:dbus.c

示例14: weston_dbus_unbind

static void weston_dbus_unbind(DBusConnection *c, struct wl_event_source *ctx)
{
	dbus_connection_set_timeout_functions(c, NULL, NULL, NULL,
					      NULL, NULL);
	dbus_connection_set_watch_functions(c, NULL, NULL, NULL,
					    NULL, NULL);
	dbus_connection_unref(c);
	wl_event_source_remove(ctx);
}
开发者ID:ChristophHaag,项目名称:weston,代码行数:9,代码来源:dbus.c

示例15: attach_dbus_conn_to_glib_main_loop

/*
 * Initialization. Works as follows:
 *
 * we have a DBusConnection* (say, obtained with dbus_bus_get)
 * we call dbus_connection_set_watch_functions
 *  libdbus calls back add_watch(watch:0x2341090, data), this watch is for writing
 *   we call toggled_watch, but it finds that watch is not to be enabled yet
 *  libdbus calls back add_watch(watch:0x23410e0, data), this watch is for reading
 *   we call toggled_watch, it adds watch's fd to glib main loop with POLLIN
 *  (note: these watches are different objects, but they have the same fd)
 * we call dbus_connection_set_timeout_functions
 * we call dbus_connection_register_object_path
 *
 * Note: if user will later call dbus_bus_request_name(conn, ...):
 *  libdbus calls back add_timeout()
 *  libdbus calls back remove_timeout()
 *  note - no callback to timeout_toggled()!
 * (therefore there is no code yet in timeout_toggled (see above), it's not used)
 */
void attach_dbus_conn_to_glib_main_loop(DBusConnection* conn,
        const char* object_path,
        DBusHandlerResult (*message_received_func)(DBusConnection *conn, DBusMessage *msg, void* data)
) {
    if (g_dbus_conn)
        error_msg_and_die("Internal bug: can't connect to more than one dbus");
    g_dbus_conn = conn;

//do we need this? why?
//log("dbus_connection_set_dispatch_status_function");
//    dbus_connection_set_dispatch_status_function(conn,
//                dispatch, /* void dispatch(DBusConnection *conn, DBusDispatchStatus new_status, void* data) */
//                NULL, /* data */
//                NULL /* free_data_function */
//    )
    log_debug("dbus_connection_set_watch_functions");
    if (!dbus_connection_set_watch_functions(conn,
                add_watch,
                remove_watch,
                toggled_watch,
                NULL, /* data */
                NULL /* free_data_function */
                )
    ) {
        die_out_of_memory();
    }
    log_debug("dbus_connection_set_timeout_functions");
    if (!dbus_connection_set_timeout_functions(conn,
                add_timeout,
                remove_timeout,
                timeout_toggled,
                NULL, /* data */
                NULL /* free_data_function */
                )
    ) {
        die_out_of_memory();
    }

    if (object_path && message_received_func)
    {
        /* Table */
        const DBusObjectPathVTable vtable = {
            /* .unregister_function = */ unregister_vtable,
            /* .message_function    = */ message_received_func,
        };
        log_debug("dbus_connection_register_object_path");
        if (!dbus_connection_register_object_path(conn,
                    object_path,
                    &vtable,
                    NULL /* data */
                    )
        ) {
            die_out_of_memory();
        }
    }
}
开发者ID:credmon,项目名称:libreport,代码行数:75,代码来源:abrt_dbus.c


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