本文整理汇总了C++中dbus_watch_get_enabled函数的典型用法代码示例。如果您正苦于以下问题:C++ dbus_watch_get_enabled函数的具体用法?C++ dbus_watch_get_enabled怎么用?C++ dbus_watch_get_enabled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbus_watch_get_enabled函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: watch_toggled
static void watch_toggled( DBusWatch *p_watch, void *p_data )
{
intf_thread_t *p_intf = (intf_thread_t*) p_data;
if( dbus_watch_get_enabled( p_watch ) )
wakeup_main_loop( p_intf );
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: edbus_add_watch
static dbus_bool_t edbus_add_watch(DBusWatch* watch, void* d) {
E_ASSERT(watch != NULL);
/*
* check if watch is enabled since dbus_watch_handle() can't be used
* on as connection will not be ready to handle this watch yet
*/
if(!dbus_watch_get_enabled(watch))
return 1;
EdbusConnImpl* dc = (EdbusConnImpl*)d;
E_ASSERT(dc != NULL);
E_ASSERT(dc->watch_list != NULL);
int fd = dbus_watch_get_fd(watch);
int flags = dbus_watch_get_flags(watch);
dc->watch_list->push_back(watch);
if(flags & DBUS_WATCH_READABLE)
Fl::add_fd(fd, FL_READ, read_watch_cb, d);
if(flags & DBUS_WATCH_WRITABLE)
Fl::add_fd(fd, FL_WRITE, write_watch_cb, d);
return 1;
}
示例6: 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;
}
示例7: 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;
}
示例8: pcmk_dbus_watch_dispatch
static int
pcmk_dbus_watch_dispatch(gpointer userdata)
{
bool oom = FALSE;
DBusWatch *watch = userdata;
int flags = dbus_watch_get_flags(watch);
bool enabled = dbus_watch_get_enabled (watch);
mainloop_io_t *client = dbus_watch_get_data(watch);
crm_trace("Dispatching client %p: %s", client, dbus_watch_flags_to_string(flags));
if (enabled && is_set(flags, DBUS_WATCH_READABLE)) {
oom = !dbus_watch_handle(watch, flags);
} else if (enabled && is_set(flags, DBUS_WATCH_READABLE)) {
oom = !dbus_watch_handle(watch, flags);
} else if(enabled) {
oom = !dbus_watch_handle(watch, DBUS_WATCH_ERROR);
}
if(flags != dbus_watch_get_flags(watch)) {
flags = dbus_watch_get_flags(watch);
crm_trace("Dispatched client %p: %s (%d)", client, dbus_watch_flags_to_string(flags), flags);
}
if(oom) {
crm_err("DBus encountered OOM while attempting to dispatch %p (%s)", client, dbus_watch_flags_to_string(flags));
}
return 0;
}
示例9:
//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;
}
示例10: 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);
}
}
示例11: read_watch_cb
static void read_watch_cb(int fd, void* d) {
/* E_DEBUG(E_STRLOC ": read_watch_cb()\n"); */
EdbusConnImpl* dc = (EdbusConnImpl*)d;
E_ASSERT(dc != NULL);
E_ASSERT(dc->watch_list != NULL);
WatchListIter it = dc->watch_list->begin(), it_end = dc->watch_list->end();
while(it != it_end) {
if(dbus_watch_get_fd(*it) == fd && dbus_watch_get_enabled(*it)) {
if(!dbus_watch_handle(*it, DBUS_WATCH_READABLE))
E_WARNING(E_STRLOC ": Out of memory\n");
break;
}
++it;
}
/*
* Check if there are more incomming data and process them. Note that
* dbus_connection_dispatch() call will also remove data from queue.
* This means that (here) timer will not be installed if only one unprocessed
* message is in queue; opposite, after installment it will process the rest
* of the messages without interrupting read_watch_cb() flow.
*
* If this is not set (e.g. all data are processed here), we can miss initial
* (or later) messages that are sent to us. Also, timer will be triggered faster
* as it can (seems that 0.5 as timer value misses some data...).
*/
if(dbus_connection_dispatch(dc->conn) == DBUS_DISPATCH_DATA_REMAINS)
Fl::add_timeout(0.2, dispatch_cb, dc);
}
示例12: toggled_watch
/* Callback: "dbus_watch_get_enabled() may return a different value than it did before" */
static void toggled_watch(DBusWatch *watch, void* data)
{
log_debug("%s(watch:%p, data)", __func__, watch);
watch_app_info_t* app_info = (watch_app_info_t*)dbus_watch_get_data(watch);
if (dbus_watch_get_enabled(watch))
{
if (!app_info->watch_enabled)
{
app_info->watch_enabled = true;
int dbus_flags = dbus_watch_get_flags(watch);
int glib_flags = 0;
if (dbus_flags & DBUS_WATCH_READABLE) glib_flags |= G_IO_IN;
if (dbus_flags & DBUS_WATCH_WRITABLE) glib_flags |= G_IO_OUT;
log_debug(" adding watch to glib main loop. dbus_flags:%x glib_flags:%x", dbus_flags, glib_flags);
app_info->event_source_id = g_io_add_watch(app_info->channel, (GIOCondition)glib_flags, handle_dbus_fd, watch);
}
/* else: it was already enabled */
}
else
{
if (app_info->watch_enabled)
{
app_info->watch_enabled = false;
/* does it free the hidden GSource too? */
log_debug(" removing watch from glib main loop");
g_source_remove(app_info->event_source_id);
}
/* else: it was already disabled */
}
}
示例13: 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;
}
示例14: 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);
}
示例15: add
static dbus_bool_t
add(DBusWatch *watch, void *data)
{
JoyDBus *self = JOY_DBUS(data);
if (G_UNLIKELY(!self)) {
goto exit;
}
struct Private *priv = GET_PRIVATE(self);
if (G_UNLIKELY(!priv->app)) {
goto exit;
}
if (!dbus_watch_get_enabled(watch)) {
goto exit;
}
JoySource *source = joy_source_dbus_new(self, watch);
if (G_UNLIKELY(!source)) {
goto exit;
}
g_object_ref_sink(source);
g_hash_table_insert(priv->sources, watch, source);
guint condition = dbus_watch_get_flags(watch);
if (condition & DBUS_WATCH_READABLE) {
joy_source_set_condition(source, G_IO_IN);
}
if (condition & DBUS_WATCH_WRITABLE) {
joy_source_set_condition(source, G_IO_OUT);
}
joy_application_add_source(priv->app, source);
exit:
return TRUE;
}