• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/dbus-1.6.8/dbus/

Lines Matching defs:watch

2 /* dbus-watch.c DBusWatch implementation
26 #include "dbus-watch.h"
44 unsigned int flags; /**< Conditions to watch. */
48 DBusFreeFunction free_handler_data_function; /**< Free the watch handler data. */
57 _dbus_watch_get_enabled (DBusWatch *watch)
59 return watch->enabled;
63 _dbus_watch_get_oom_last_time (DBusWatch *watch)
65 return watch->oom_last_time;
69 _dbus_watch_set_oom_last_time (DBusWatch *watch,
72 watch->oom_last_time = oom;
80 * @param flags the conditions to watch for on the descriptor.
95 DBusWatch *watch;
101 watch = dbus_new0 (DBusWatch, 1);
102 if (watch == NULL)
105 watch->refcount = 1;
106 watch->fd = fd;
107 watch->flags = flags;
108 watch->enabled = enabled;
110 watch->handler = handler;
111 watch->handler_data = data;
112 watch->free_handler_data_function = free_data_function;
114 return watch;
120 * @param watch the watch object.
121 * @returns the watch object.
124 _dbus_watch_ref (DBusWatch *watch)
126 watch->refcount += 1;
128 return watch;
135 * @param watch the watch object.
138 _dbus_watch_unref (DBusWatch *watch)
140 _dbus_assert (watch != NULL);
141 _dbus_assert (watch->refcount > 0);
143 watch->refcount -= 1;
144 if (watch->refcount == 0)
146 if (watch->fd != -1)
147 _dbus_warn ("this watch should have been invalidated");
149 dbus_watch_set_data (watch, NULL, NULL); /* call free_data_function */
151 if (watch->free_handler_data_function)
152 (* watch->free_handler_data_function) (watch->handler_data);
154 dbus_free (watch);
159 * Clears the file descriptor from a now-invalid watch object so that
160 * no one tries to use it. This is because a watch may stay alive due
166 * @param watch the watch object.
169 _dbus_watch_invalidate (DBusWatch *watch)
171 watch->fd = -1;
172 watch->flags = 0;
178 * watch is a DBUS_WATCH_READABLE watch then
181 * @param watch the watch object.
185 _dbus_watch_sanitize_condition (DBusWatch *watch,
188 if (!(watch->flags & DBUS_WATCH_READABLE))
190 if (!(watch->flags & DBUS_WATCH_WRITABLE))
202 * Holds a reference count to each watch.
218 DBusAddWatchFunction add_watch_function; /**< Callback for adding a watch. */
219 DBusRemoveWatchFunction remove_watch_function; /**< Callback for removing a watch. */
221 void *watch_data; /**< Data for watch callbacks */
222 DBusFreeFunction watch_free_data_function; /**< Free function for watch callback data */
226 * Creates a new watch list. Returns #NULL if insufficient
229 * @returns the new watch list, or #NULL on failure.
246 * @param watch_list the watch list.
263 * Sets the watch functions. This function is the "backend"
267 * @param watch_list the watch list.
268 * @param add_function the add watch function.
269 * @param remove_function the remove watch function.
284 /* Add watches with the new watch function, failing on OOM */
311 _dbus_verbose ("Adding a %s watch on fd %d using newly-set add watch function\n",
328 _dbus_verbose ("Removing watch on fd %d using newly-set remove function because initial add failed\n",
343 /* Remove all current watches from previous watch handlers */
367 * Adds a new watch to the watch list, invoking the
370 * @param watch_list the watch list.
371 * @param watch the watch to add.
376 DBusWatch *watch)
378 if (!_dbus_list_append (&watch_list->watches, watch))
381 _dbus_watch_ref (watch);
385 _dbus_verbose ("Adding watch on fd %d\n",
386 dbus_watch_get_socket (watch));
388 if (!(* watch_list->add_watch_function) (watch,
391 _dbus_list_remove_last (&watch_list->watches, watch);
392 _dbus_watch_unref (watch);
401 * Removes a watch from the watch list, invoking the
404 * @param watch_list the watch list.
405 * @param watch the watch to remove.
409 DBusWatch *watch)
411 if (!_dbus_list_remove (&watch_list->watches, watch))
412 _dbus_assert_not_reached ("Nonexistent watch was removed");
416 _dbus_verbose ("Removing watch on fd %d\n",
417 dbus_watch_get_socket (watch));
419 (* watch_list->remove_watch_function) (watch,
423 _dbus_watch_unref (watch);
427 * Sets a watch to the given enabled state, invoking the
430 * @param watch_list the watch list.
431 * @param watch the watch to toggle.
436 DBusWatch *watch,
441 if (enabled == watch->enabled)
444 watch->enabled = enabled;
448 _dbus_verbose ("Toggling watch %p on fd %d to %d\n",
449 watch, dbus_watch_get_socket (watch), watch->enabled);
451 (* watch_list->watch_toggled_function) (watch,
457 * Sets the handler for the watch.
463 * @param watch the watch
469 _dbus_watch_set_handler (DBusWatch *watch,
474 if (watch->free_handler_data_function)
475 (* watch->free_handler_data_function) (watch->handler_data);
477 watch->handler = handler;
478 watch->handler_data = data;
479 watch->free_handler_data_function = free_data_function;
489 * Types and functions related to DBusWatch. A watch represents
510 * @param watch the DBusWatch object.
511 * @returns the file descriptor to watch.
514 dbus_watch_get_fd (DBusWatch *watch)
516 _dbus_return_val_if_fail (watch != NULL, -1);
518 return dbus_watch_get_unix_fd(watch);
529 * dbus_watch_get_socket() to get a Winsock socket to watch.
531 * @param watch the DBusWatch object.
532 * @returns the file descriptor to watch.
535 dbus_watch_get_unix_fd (DBusWatch *watch)
537 _dbus_return_val_if_fail (watch != NULL, -1);
540 * (watch should have set_socket and set_unix_fd and track
542 * appropriate watch type)
545 return watch->fd;
547 return dbus_watch_get_socket( watch );
560 * @param watch the DBusWatch object.
561 * @returns the socket to watch.
564 dbus_watch_get_socket (DBusWatch *watch)
566 _dbus_return_val_if_fail (watch != NULL, -1);
568 return watch->fd;
578 * DBUS_WATCH_ERROR; all watches implicitly include a watch
581 * @param watch the DBusWatch object.
582 * @returns the conditions to watch.
585 dbus_watch_get_flags (DBusWatch *watch)
587 _dbus_return_val_if_fail (watch != NULL, 0);
588 _dbus_assert ((watch->flags & VALID_WATCH_FLAGS) == watch->flags);
590 return watch->flags;
597 * @param watch the DBusWatch object.
601 dbus_watch_get_data (DBusWatch *watch)
603 _dbus_return_val_if_fail (watch != NULL, NULL);
605 return watch->data;
612 * Qt you might store the QSocketNotifier for this watch and with GLib
615 * @param watch the DBusWatch object.
620 dbus_watch_set_data (DBusWatch *watch,
624 _dbus_return_if_fail (watch != NULL);
626 _dbus_verbose ("Setting watch fd %d data to data = %p function = %p from data = %p function = %p\n",
627 dbus_watch_get_socket (watch),
628 data, free_data_function, watch->data, watch->free_data_function);
630 if (watch->free_data_function != NULL)
631 (* watch->free_data_function) (watch->data);
633 watch->data = data;
634 watch->free_data_function = free_data_function;
638 * Returns whether a watch is enabled or not. If not
641 * @param watch the DBusWatch object
642 * @returns #TRUE if the watch is enabled
645 dbus_watch_get_enabled (DBusWatch *watch)
647 _dbus_return_val_if_fail (watch != NULL, FALSE);
649 return watch->enabled;
654 * Called to notify the D-Bus library when a previously-added watch is
666 * that watch yet.
671 * @param watch the DBusWatch object.
676 dbus_watch_handle (DBusWatch *watch,
679 _dbus_return_val_if_fail (watch != NULL, FALSE);
682 if (watch->fd < 0 || watch->flags == 0)
689 _dbus_return_val_if_fail (watch->fd >= 0 /* fails if watch was removed */, TRUE);
691 _dbus_watch_sanitize_condition (watch, &flags);
695 _dbus_verbose ("After sanitization, watch flags on fd %d were 0\n",
696 watch->fd);
700 return (* watch->handler) (watch, flags,
701 watch->handler_data);