/* * 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); }
static void test_serialize_assembly(void) { unsigned char pdu[176]; long pdu_len; struct sms sms; struct sms_assembly *assembly = sms_assembly_new("1234"); guint16 ref; guint8 max; guint8 seq; GSList *l; decode_hex_own_buf(assembly_pdu1, -1, &pdu_len, 0, pdu); sms_decode(pdu, pdu_len, FALSE, assembly_pdu_len1, &sms); sms_extract_concatenation(&sms, &ref, &max, &seq); l = sms_assembly_add_fragment(assembly, &sms, time(NULL), &sms.deliver.oaddr, ref, max, seq); if (g_test_verbose()) { g_print("Ref: %u\n", ref); g_print("Max: %u\n", max); g_print("From: %s\n", sms_address_to_string(&sms.deliver.oaddr)); } g_assert(g_slist_length(assembly->assembly_list) == 1); g_assert(l == NULL); decode_hex_own_buf(assembly_pdu2, -1, &pdu_len, 0, pdu); sms_decode(pdu, pdu_len, FALSE, assembly_pdu_len2, &sms); sms_extract_concatenation(&sms, &ref, &max, &seq); l = sms_assembly_add_fragment(assembly, &sms, time(NULL), &sms.deliver.oaddr, ref, max, seq); g_assert(l == NULL); sms_assembly_free(assembly); assembly = sms_assembly_new("1234"); decode_hex_own_buf(assembly_pdu3, -1, &pdu_len, 0, pdu); sms_decode(pdu, pdu_len, FALSE, assembly_pdu_len3, &sms); sms_extract_concatenation(&sms, &ref, &max, &seq); l = sms_assembly_add_fragment(assembly, &sms, time(NULL), &sms.deliver.oaddr, ref, max, seq); g_assert(l != NULL); sms_assembly_free(assembly); }