unsigned int __ofono_modem_add_atom_watch(struct ofono_modem *modem, enum ofono_atom_type type, ofono_atom_watch_func notify, void *data, ofono_destroy_func destroy) { struct atom_watch *watch; unsigned int id; GSList *l; struct ofono_atom *atom; if (notify == NULL) return 0; watch = g_new0(struct atom_watch, 1); watch->type = type; watch->item.notify = notify; watch->item.destroy = destroy; watch->item.notify_data = data; id = __ofono_watchlist_add_item(modem->atom_watches, (struct ofono_watchlist_item *)watch); for (l = modem->atoms; l; l = l->next) { atom = l->data; if (atom->type != type || atom->unregister == NULL) continue; notify(atom, OFONO_ATOM_WATCH_CONDITION_REGISTERED, data); } return id; }
unsigned int __ofono_modemwatch_add(ofono_modemwatch_cb_t cb, void *user, ofono_destroy_func destroy) { struct ofono_watchlist_item *watch; if (cb == NULL) return 0; watch = g_new0(struct ofono_watchlist_item, 1); watch->notify = cb; watch->destroy = destroy; watch->notify_data = user; return __ofono_watchlist_add_item(g_modemwatches, watch); }
unsigned int __ofono_modem_add_powered_watch(struct ofono_modem *modem, ofono_modem_powered_notify_func notify, void *data, ofono_destroy_func destroy) { struct ofono_watchlist_item *item; if (modem == NULL || notify == NULL) return 0; item = g_new0(struct ofono_watchlist_item, 1); item->notify = notify; item->destroy = destroy; item->notify_data = data; return __ofono_watchlist_add_item(modem->powered_watches, item); }
static unsigned int add_sms_handler(struct ofono_watchlist *watchlist, int dst, int src, void *notify, void *data, ofono_destroy_func destroy) { struct sms_handler *handler; if (notify == NULL) return 0; handler = g_try_new0(struct sms_handler, 1); if (handler == NULL) return 0; handler->dst = dst; handler->src = src; handler->item.notify = notify; handler->item.notify_data = data; handler->item.destroy = destroy; return __ofono_watchlist_add_item(watchlist, (struct ofono_watchlist_item *) handler); }