static void dispatch_app_datagram(struct ofono_sms *sms, const struct ofono_uuid *uuid, int dst, int src, unsigned char *buf, unsigned len, const struct sms_address *addr, const struct sms_scts *scts) { const char *sender = sms_address_to_string(addr); time_t ts; struct tm remote; struct tm local; ofono_sms_datagram_notify_cb_t notify; struct sms_handler *h; GSList *l; ts = sms_scts_to_time(scts, &remote); localtime_r(&ts, &local); for (l = sms->datagram_handlers->items; l; l = l->next) { h = l->data; notify = h->item.notify; if (!port_equal(dst, h->dst) || !port_equal(src, h->src)) continue; notify(sender, &remote, &local, dst, src, buf, len, h->item.notify_data); } }
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); }
static void dispatch_text_message(struct ofono_sms *sms, const struct ofono_uuid *uuid, const char *message, enum sms_class cls, const struct sms_address *addr, const struct sms_scts *scts) { struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom); DBusConnection *conn = ofono_dbus_get_connection(); const char *path = __ofono_atom_get_path(sms->atom); DBusMessage *signal; DBusMessageIter iter; DBusMessageIter dict; char buf[128]; const char *signal_name; time_t ts; struct tm remote; struct tm local; const char *str = buf; ofono_sms_text_notify_cb_t notify; struct sms_handler *h; GSList *l; if (message == NULL) return; if (cls == SMS_CLASS_0) signal_name = "ImmediateMessage"; else signal_name = "IncomingMessage"; signal = dbus_message_new_signal(path, OFONO_MESSAGE_MANAGER_INTERFACE, signal_name); if (signal == NULL) return; dbus_message_iter_init_append(signal, &iter); dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &message); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, OFONO_PROPERTIES_ARRAY_SIGNATURE, &dict); ts = sms_scts_to_time(scts, &remote); localtime_r(&ts, &local); strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", &local); buf[127] = '\0'; ofono_dbus_dict_append(&dict, "LocalSentTime", DBUS_TYPE_STRING, &str); strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", &remote); buf[127] = '\0'; ofono_dbus_dict_append(&dict, "SentTime", DBUS_TYPE_STRING, &str); str = sms_address_to_string(addr); ofono_dbus_dict_append(&dict, "Sender", DBUS_TYPE_STRING, &str); dbus_message_iter_close_container(&iter, &dict); g_dbus_send_message(conn, signal); if (cls == SMS_CLASS_0) return; for (l = sms->text_handlers->items; l; l = l->next) { h = l->data; notify = h->item.notify; notify(str, &remote, &local, message, h->item.notify_data); } __ofono_history_sms_received(modem, uuid, str, &remote, &local, message); }