/* * Indicate oFono that a SMS driver is ready for operation * * This is called after ofono_sms_create() was done and the modem * driver determined that a modem supports SMS correctly. Once this * call succeeds, the D-BUS interface for SMS goes live. */ void ofono_sms_register(struct ofono_sms *sms) { DBusConnection *conn = ofono_dbus_get_connection(); struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom); const char *path = __ofono_atom_get_path(sms->atom); struct ofono_sim *sim; if (!g_dbus_register_interface(conn, path, OFONO_MESSAGE_MANAGER_INTERFACE, sms_manager_methods, sms_manager_signals, NULL, sms, NULL)) { ofono_error("Could not create %s interface", OFONO_MESSAGE_MANAGER_INTERFACE); return; } ofono_modem_add_interface(modem, OFONO_MESSAGE_MANAGER_INTERFACE); sms->mw_watch = __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_MESSAGE_WAITING, mw_watch, sms, NULL); sms->netreg_watch = __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_NETREG, netreg_watch, sms, NULL); sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem); /* * If we have a sim atom, we can uniquely identify the SIM, * otherwise create an sms assembly which doesn't backup the fragment * store. */ if (sim) { const char *imsi; imsi = ofono_sim_get_imsi(sim); sms->assembly = sms_assembly_new(imsi); sms->sr_assembly = status_report_assembly_new(imsi); sms_load_settings(sms, imsi); } else { sms->assembly = sms_assembly_new(NULL); sms->sr_assembly = status_report_assembly_new(NULL); sms->bearer = 3; /* Default to CS then PS */ } if (sms->driver->bearer_set) sms->driver->bearer_set(sms, sms->bearer, bearer_init_callback, sms); sms_restore_tx_queue(sms); sms->text_handlers = __ofono_watchlist_new(g_free); sms->datagram_handlers = __ofono_watchlist_new(g_free); __ofono_atom_register(sms->atom, sms_unregister); }
int ofono_modem_register(struct ofono_modem *modem) { DBusConnection *conn = ofono_dbus_get_connection(); GSList *l; DBG("%p", modem); if (modem == NULL) return -EINVAL; if (powering_down == TRUE) return -EBUSY; if (modem->driver != NULL) return -EALREADY; for (l = g_driver_list; l; l = l->next) { const struct ofono_modem_driver *drv = l->data; if (g_strcmp0(drv->name, modem->driver_type)) continue; if (drv->probe(modem) < 0) continue; modem->driver = drv; break; } if (modem->driver == NULL) return -ENODEV; if (!g_dbus_register_interface(conn, modem->path, OFONO_MODEM_INTERFACE, modem_methods, modem_signals, NULL, modem, NULL)) { ofono_error("Modem register failed on path %s", modem->path); if (modem->driver->remove) modem->driver->remove(modem); modem->driver = NULL; return -EIO; } g_free(modem->driver_type); modem->driver_type = NULL; modem->atom_watches = __ofono_watchlist_new(g_free); modem->online_watches = __ofono_watchlist_new(g_free); modem->powered_watches = __ofono_watchlist_new(g_free); emit_modem_added(modem); call_modemwatches(modem, TRUE); modem->sim_watch = __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_SIM, sim_watch, modem, NULL); return 0; }
void __ofono_modemwatch_init(void) { g_modemwatches = __ofono_watchlist_new(g_free); }