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

C++ dbus_watch_get_unix_fd函数代码示例

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

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



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

示例1: add_watch

static dbus_bool_t add_watch(DBusWatch *watch, void *data)
{
	GIOCondition cond = G_IO_HUP | G_IO_ERR;
	DBusConnection *conn = data;
	struct watch_info *info;
	int fd, flags;

	if (!dbus_watch_get_enabled(watch))
		return TRUE;

	info = g_new(struct watch_info, 1);

	fd = dbus_watch_get_unix_fd(watch);
	info->io = g_io_channel_unix_new(fd);
	info->conn = dbus_connection_ref(conn);

	dbus_watch_set_data(watch, info, NULL);

	flags = dbus_watch_get_flags(watch);

	if (flags & DBUS_WATCH_READABLE) cond |= G_IO_IN;
	if (flags & DBUS_WATCH_WRITABLE) cond |= G_IO_OUT;

	info->watch_id = g_io_add_watch(info->io, cond, watch_func, watch);

	return TRUE;
}
开发者ID:wenhann,项目名称:chromiumos,代码行数:27,代码来源:mainloop.c


示例2: AddWatch

static dbus_bool_t
AddWatch(DBusWatch *aWatch, void *aData)
{
  DBusThread *dbt = (DBusThread *)aData;

  if (dbus_watch_get_enabled(aWatch)) {
    // note that we can't just send the watch and inspect it later
    // because we may get a removeWatch call before this data is reacted
    // to by our eventloop and remove this watch..  reading the add first
    // and then inspecting the recently deceased watch would be bad.
    char control = DBUS_EVENT_LOOP_ADD;
    if (write(dbt->mControlFdW.get(), &control, sizeof(char)) < 0) {
      LOG("Cannot write DBus add watch control data to socket!\n");
      return false;
    }

    int fd = dbus_watch_get_unix_fd(aWatch);
    if (write(dbt->mControlFdW.get(), &fd, sizeof(int)) < 0) {
      LOG("Cannot write DBus add watch descriptor data to socket!\n");
      return false;
    }

    unsigned int flags = dbus_watch_get_flags(aWatch);
    if (write(dbt->mControlFdW.get(), &flags, sizeof(unsigned int)) < 0) {
      LOG("Cannot write DBus add watch flag data to socket!\n");
      return false;
    }

    if (write(dbt->mControlFdW.get(), &aWatch, sizeof(DBusWatch*)) < 0) {
      LOG("Cannot write DBus add watch struct data to socket!\n");
      return false;
    }
  }
  return true;
}
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:35,代码来源:DBusThread.cpp


示例3: add_watch

static dbus_bool_t add_watch(DBusWatch *w, void *data)
{
    	if (!dbus_watch_get_enabled(w))
      		return TRUE;

	ASDBusFd *fd = safecalloc (1, sizeof(ASDBusFd));
	fd->fd =  dbus_watch_get_unix_fd(w);
	unsigned int flags = dbus_watch_get_flags(w);
	if (get_flags(flags, DBUS_WATCH_READABLE))
		fd->readable = True;
    /*short cond = EV_PERSIST;
    if (flags & DBUS_WATCH_READABLE)
        cond |= EV_READ;
    if (flags & DBUS_WATCH_WRITABLE)
        cond |= EV_WRITE; */

      // TODO add to the list of FDs
	dbus_watch_set_data(w, fd, NULL);
	if (ASDBus.watchFds == NULL)
		ASDBus.watchFds = create_asvector (sizeof(ASDBusFd*));

	append_vector(ASDBus.watchFds, &fd, 1);

	show_debug(__FILE__,__FUNCTION__,__LINE__,"added dbus watch fd=%d watch=%p readable =%d\n", fd->fd, w, fd->readable);
	return TRUE;
}
开发者ID:afterstep,项目名称:afterstep,代码行数:26,代码来源:dbus.c


示例4: addWatch

static dbus_bool_t addWatch(DBusWatch *watch, void *data)
{
   dbus_bool_t result = FALSE;
   (void)data;

   if (ARRAY_SIZE(gPollInfo.fds) > (unsigned int)(gPollInfo.nfds))
   {
      unsigned int flags = dbus_watch_get_flags(watch);

      tObjectEntry * const pEntry = &gPollInfo.objects[gPollInfo.nfds];
      pEntry->objtype = OT_WATCH;
      pEntry->watch = watch;

      gPollInfo.fds[gPollInfo.nfds].fd = dbus_watch_get_unix_fd(watch);

      if (TRUE==dbus_watch_get_enabled(watch))
      {
         if (flags&DBUS_WATCH_READABLE)
         {
            gPollInfo.fds[gPollInfo.nfds].events |= POLLIN;
         }
         if (flags&DBUS_WATCH_WRITABLE)
         {
            gPollInfo.fds[gPollInfo.nfds].events |= POLLOUT;
         }

         ++gPollInfo.nfds;
      }
      result = TRUE;
   }

   return result;
}
开发者ID:GENIVI,项目名称:persistence-client-library,代码行数:33,代码来源:persistence_client_library_dbus_service.c


示例5: GetPollFds

/**
 * GetPollFds() fills an array of pollfd data structures with :
 *  - the set of enabled dbus watches
 *  - the unix pipe which we use to manually wake up the main loop
 *
 * This function must be called with p_sys->lock locked
 *
 * @return The number of file descriptors
 *
 * @param intf_thread_t *p_intf this interface thread's state
 * @param struct pollfd *p_fds a pointer to a pollfd array large enough to
 * contain all the returned data (number of enabled dbus watches + 1)
 */
static int GetPollFds( intf_thread_t *p_intf, struct pollfd *p_fds )
{
    intf_sys_t *p_sys = p_intf->p_sys;
    int i_fds = 1, i_watches = vlc_array_count( p_sys->p_watches );

    p_fds[0].fd = p_sys->p_pipe_fds[PIPE_OUT];
    p_fds[0].events = POLLIN | POLLPRI;

    for( int i = 0; i < i_watches; i++ )
    {
        DBusWatch *p_watch = NULL;
        p_watch = vlc_array_item_at_index( p_sys->p_watches, i );
        if( !dbus_watch_get_enabled( p_watch ) )
            continue;

        p_fds[i_fds].fd = dbus_watch_get_unix_fd( p_watch );
        int i_flags = dbus_watch_get_flags( p_watch );

        if( i_flags & DBUS_WATCH_READABLE )
            p_fds[i_fds].events |= POLLIN | POLLPRI;

        if( i_flags & DBUS_WATCH_WRITABLE )
            p_fds[i_fds].events |= POLLOUT;

        i_fds++;
    }

    return i_fds;
}
开发者ID:iamnpc,项目名称:myfaplayer,代码行数:42,代码来源:dbus.c


示例6: TEMP_FAILURE_RETRY

void
DBusWatcher::RemoveWatch(DBusWatch* aWatch)
{
  static const char control = DBUS_EVENT_LOOP_REMOVE;

  ssize_t res =
    TEMP_FAILURE_RETRY(write(mControlFdW.get(), &control, sizeof(control)));
  if (res < 0) {
    LOG("Cannot write DBus remove watch control data to socket!\n");
    return;
  }

  int fd = dbus_watch_get_unix_fd(aWatch);
  res = TEMP_FAILURE_RETRY(write(mControlFdW.get(), &fd, sizeof(fd)));
  if (res < 0) {
    LOG("Cannot write DBus remove watch descriptor data to socket!\n");
    return;
  }

  unsigned int flags = dbus_watch_get_flags(aWatch);
  res = TEMP_FAILURE_RETRY(write(mControlFdW.get(), &flags, sizeof(flags)));
  if (res < 0) {
    LOG("Cannot write DBus remove watch flag data to socket!\n");
    return;
  }
}
开发者ID:gw280,项目名称:gecko-dev,代码行数:26,代码来源:DBusThread.cpp


示例7: check_dbus_listeners

void check_dbus_listeners(fd_set *rset, fd_set *wset, fd_set *eset)
{
  DBusConnection *connection = (DBusConnection *)daemon->dbus;
  struct watch *w;

  for (w = daemon->watches; w; w = w->next)
    if (dbus_watch_get_enabled(w->watch))
      {
	unsigned int flags = 0;
	int fd = dbus_watch_get_unix_fd(w->watch);
	
	if (FD_ISSET(fd, rset))
	  flags |= DBUS_WATCH_READABLE;
	
	if (FD_ISSET(fd, wset))
	  flags |= DBUS_WATCH_WRITABLE;
	
	if (FD_ISSET(fd, eset))
	  flags |= DBUS_WATCH_ERROR;

	if (flags != 0)
	  dbus_watch_handle(w->watch, flags);
      }

  if (connection)
    {
      dbus_connection_ref (connection);
      while (dbus_connection_dispatch (connection) == DBUS_DISPATCH_DATA_REMAINS);
      dbus_connection_unref (connection);
    }
}
开发者ID:afdnlw,项目名称:dnsmasq-chinadns,代码行数:31,代码来源:dbus.c


示例8: virDBusAddWatch

static dbus_bool_t virDBusAddWatch(DBusWatch *watch,
                                   void *data)
{
    int flags = 0;
    int fd;
    struct virDBusWatch *info;

    if (VIR_ALLOC(info) < 0)
        return 0;

    if (dbus_watch_get_enabled(watch))
        flags = virDBusTranslateWatchFlags(dbus_watch_get_flags(watch));

# if HAVE_DBUS_WATCH_GET_UNIX_FD
    fd = dbus_watch_get_unix_fd(watch);
# else
    fd = dbus_watch_get_fd(watch);
# endif
    info->bus = (DBusConnection *)data;
    info->watch = virEventAddHandle(fd, flags,
                                    virDBusWatchCallback,
                                    watch, NULL);
    if (info->watch < 0) {
        VIR_FREE(info);
        return 0;
    }
    dbus_watch_set_data(watch, info, virDBusWatchFree);

    return 1;
}
开发者ID:avdv,项目名称:libvirt,代码行数:30,代码来源:virdbus.c


示例9: handle_io_event

/* pa_io_event_cb_t IO event handler */
static void handle_io_event(pa_mainloop_api *ea, pa_io_event *e, int fd, pa_io_event_flags_t events, void *userdata) {
    unsigned int flags = 0;
    DBusWatch *watch = userdata;

#if HAVE_DBUS_WATCH_GET_UNIX_FD
    pa_assert(fd == dbus_watch_get_unix_fd(watch));
#else
    pa_assert(fd == dbus_watch_get_fd(watch));
#endif

    if (!dbus_watch_get_enabled(watch)) {
        pa_log_warn("Asked to handle disabled watch: %p %i", (void*) watch, fd);
        return;
    }

    if (events & PA_IO_EVENT_INPUT)
        flags |= DBUS_WATCH_READABLE;
    if (events & PA_IO_EVENT_OUTPUT)
        flags |= DBUS_WATCH_WRITABLE;
    if (events & PA_IO_EVENT_HANGUP)
        flags |= DBUS_WATCH_HANGUP;
    if (events & PA_IO_EVENT_ERROR)
        flags |= DBUS_WATCH_ERROR;

    dbus_watch_handle(watch, flags);
}
开发者ID:Klayv,项目名称:pulseaudio,代码行数:27,代码来源:dbus-util.c


示例10: dbus_watch_get_fd

/**
 * Deprecated former name of dbus_watch_get_unix_fd().
 * 
 * @param watch the DBusWatch object.
 * @returns the file descriptor to watch.
 */
int
dbus_watch_get_fd (DBusWatch *watch)
{
  _dbus_return_val_if_fail (watch != NULL, -1);

  return dbus_watch_get_unix_fd(watch);
}
开发者ID:d-bus,项目名称:dbus,代码行数:13,代码来源:dbus-watch.c


示例11: sbus_add_watch

/*
 * add_watch
 * Set up hooks into the libevents mainloop for
 * D-BUS to add file descriptor-based events
 */
dbus_bool_t sbus_add_watch(DBusWatch *dbus_watch, void *data)
{
    unsigned int flags;
    uint16_t event_flags;
    struct sbus_connection *conn;
    struct sbus_watch_ctx *watch;
    dbus_bool_t enabled;
    int fd;

    conn = talloc_get_type(data, struct sbus_connection);

#ifdef HAVE_DBUS_WATCH_GET_UNIX_FD
    fd = dbus_watch_get_unix_fd(dbus_watch);
#else
    fd = dbus_watch_get_fd(dbus_watch);
#endif

    watch = fd_to_watch(conn->watch_list, fd);
    if (!watch) {
        /* does not exist, allocate new one */
        watch = talloc_zero(conn, struct sbus_watch_ctx);
        if (!watch) {
            DEBUG(0, ("Out of Memory!\n"));
            return FALSE;
        }
        watch->conn = conn;
        watch->fd = fd;
    }
开发者ID:AbhishekKumarSingh,项目名称:sssd,代码行数:33,代码来源:sssd_dbus_common.c


示例12: dbus_watch_get_flags

//Callbacks implementation
unsigned int DBusHandler::Callbacks::addWatch(DBusWatch* watch, void* data)
{
	if(!data) return 0;
	auto& loop = static_cast<DBusHandler*>(data)->compositor().wlEventLoop();

    unsigned int mask = 0;
    if (dbus_watch_get_enabled(watch))
    {
        unsigned int flags = dbus_watch_get_flags(watch);

        if (flags & DBUS_WATCH_READABLE) mask |= WL_EVENT_READABLE;
        if (flags & DBUS_WATCH_WRITABLE) mask |= WL_EVENT_WRITABLE;
    }

    int fd = dbus_watch_get_unix_fd(watch);
    wl_event_source* source = wl_event_loop_add_fd(&loop, fd, mask, dispatchWatch, watch);

    if (!source)
	{
		ny::sendWarning("failed to add dbus watch wl_event_loop_fd");
		return 0;
	}

    dbus_watch_set_data(watch, source, nullptr);
    return 1;
}
开发者ID:nyorain,项目名称:iro,代码行数:27,代码来源:dbus.cpp


示例13: get_pollfds

static int get_pollfds(struct dbus* dbus, struct pollfd *pollfds)
{
    int count = 0;
    Word_t index = 0;
    DBusWatch** pwatch;

    JLF(pwatch, dbus->watches, index);
    while(pwatch != NULL) {
        DBusWatch* watch = *pwatch;

        if(dbus_watch_get_enabled(watch)) {
            pollfds[count].fd = dbus_watch_get_unix_fd(watch);
            pollfds[count].events = 0;

            int flags = dbus_watch_get_flags(watch);
            if(flags & DBUS_WATCH_READABLE) pollfds[count].events |= POLLIN | POLLPRI;
            if(flags & DBUS_WATCH_WRITABLE) pollfds[count].events |= POLLOUT;

            count += 1;
        }

        JLN(pwatch, dbus->watches, index);
    }

    return count;
}
开发者ID:chaind,项目名称:chaind,代码行数:26,代码来源:dbus.c


示例14: cdbus_callback_remove_watch

/**
 * Callback for removing D-Bus watch.
 */
static void
cdbus_callback_remove_watch(DBusWatch *watch, void *data) {
  session_t *ps = data;

  fds_drop(ps, dbus_watch_get_unix_fd(watch),
      cdbus_get_watch_cond(watch));
}
开发者ID:xorgy,项目名称:companion,代码行数:10,代码来源:dbus.c


示例15: connection_setup_add_watch

static void connection_setup_add_watch(struct ctrl_iface_dbus_priv *iface,
				       DBusWatch *watch)
{
	unsigned int flags;
	int fd;

	if (!dbus_watch_get_enabled(watch))
		return;

	flags = dbus_watch_get_flags(watch);
	fd = dbus_watch_get_unix_fd(watch);

	eloop_register_sock(fd, EVENT_TYPE_EXCEPTION, process_watch_exception,
			    iface, watch);

	if (flags & DBUS_WATCH_READABLE) {
		eloop_register_sock(fd, EVENT_TYPE_READ, process_watch_read,
				    iface, watch);
	}
	if (flags & DBUS_WATCH_WRITABLE) {
		eloop_register_sock(fd, EVENT_TYPE_WRITE, process_watch_write,
				    iface, watch);
	}

	dbus_watch_set_data(watch, iface, NULL);
}
开发者ID:ebichu,项目名称:dd-wrt,代码行数:26,代码来源:ctrl_iface_dbus.c


示例16: set_dbus_listeners

void set_dbus_listeners(int *maxfdp,
			fd_set *rset, fd_set *wset, fd_set *eset)
{
  struct watch *w;
  
  for (w = daemon->watches; w; w = w->next)
    if (dbus_watch_get_enabled(w->watch))
      {
	unsigned int flags = dbus_watch_get_flags(w->watch);
#if (DBUS_MINOR > 0)
	int fd = dbus_watch_get_unix_fd(w->watch);
#else
	int fd = dbus_watch_get_fd(w->watch);
#endif
	
	bump_maxfd(fd, maxfdp);
	
	if (flags & DBUS_WATCH_READABLE)
	  FD_SET(fd, rset);
	
	if (flags & DBUS_WATCH_WRITABLE)
	  FD_SET(fd, wset);
	
	FD_SET(fd, eset);
      }
}
开发者ID:ebichu,项目名称:dd-wrt,代码行数:26,代码来源:dbus.c


示例17: add_watch

static dbus_bool_t add_watch(DBusWatch *watch, void *data)
{
	struct wpas_dbus_priv *priv = data;
	unsigned int flags;
	int fd;

	if (!dbus_watch_get_enabled(watch))
		return TRUE;

	flags = dbus_watch_get_flags(watch);
	fd = dbus_watch_get_unix_fd(watch);

	eloop_register_sock(fd, EVENT_TYPE_EXCEPTION, process_watch_exception,
			    priv, watch);

	if (flags & DBUS_WATCH_READABLE) {
		eloop_register_sock(fd, EVENT_TYPE_READ, process_watch_read,
				    priv, watch);
	}
	if (flags & DBUS_WATCH_WRITABLE) {
		eloop_register_sock(fd, EVENT_TYPE_WRITE, process_watch_write,
				    priv, watch);
	}

	dbus_watch_set_data(watch, priv, NULL);

	return TRUE;
}
开发者ID:MultiNet-80211,项目名称:Hostapd,代码行数:28,代码来源:dbus_common.c


示例18: add_watch

static dbus_bool_t add_watch(DBusWatch *watch, void *data)
{
	DBusConnection *conn = data;
	GIOCondition cond = G_IO_HUP | G_IO_ERR;
	GIOChannel *chan;
	struct watch_info *info;
	unsigned int flags;
	int fd;

	if (!dbus_watch_get_enabled(watch))
		return TRUE;

	info = g_new0(struct watch_info, 1);

	fd = dbus_watch_get_unix_fd(watch);
	chan = g_io_channel_unix_new(fd);

	info->watch = watch;
	info->conn = dbus_connection_ref(conn);

	dbus_watch_set_data(watch, info, watch_info_free);

	flags = dbus_watch_get_flags(watch);

	if (flags & DBUS_WATCH_READABLE) cond |= G_IO_IN;
	if (flags & DBUS_WATCH_WRITABLE) cond |= G_IO_OUT;

	info->id = g_io_add_watch(chan, cond, watch_func, info);

	g_io_channel_unref(chan);

	return TRUE;
}
开发者ID:Andrewas,项目名称:android_hardware_semc,代码行数:33,代码来源:mainloop.c


示例19: watch_toggled

static void watch_toggled( DBusWatch *p_watch, void *p_data )
{
    intf_thread_t *p_intf = (intf_thread_t*) p_data;

    msg_Dbg( p_intf, "Toggling dbus watch on fd %d",
             dbus_watch_get_unix_fd( p_watch ) );

    if( dbus_watch_get_enabled( p_watch ) )
    {
        msg_Dbg( p_intf,
                  "Watch on fd %d has been enabled, "
                  "the main loops needs to wake up",
                  dbus_watch_get_unix_fd( p_watch ) );

        wakeup_main_loop( p_intf );
    }
}
开发者ID:iamnpc,项目名称:myfaplayer,代码行数:17,代码来源:dbus.c


示例20: pcmk_dbus_watch_add

static dbus_bool_t
pcmk_dbus_watch_add(DBusWatch *watch, void *data){
    int fd = dbus_watch_get_unix_fd(watch);

    mainloop_io_t *client = mainloop_add_fd(
        "dbus", G_PRIORITY_DEFAULT, fd, watch, &pcmk_dbus_cb);

    crm_trace("Added watch %p with fd=%d to client %p", watch, fd, client);
    dbus_watch_set_data(watch, client, NULL);
    return TRUE;
}
开发者ID:tradej,项目名称:pacemaker,代码行数:11,代码来源:dbus.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ dc函数代码示例发布时间:2022-05-30
下一篇:
C++ dbus_watch_get_flags函数代码示例发布时间: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