static void print_scts(struct sms_scts *scts, const char *prefix) { time_t ts; struct tm remote; char buf[128]; g_print("%s: (YY-MM-DD) %02d-%02d-%02d\n", prefix, (int)scts->year, (int)scts->month, (int)scts->day); g_print("%s: (HH-MM-SS) %02d:%02d:%02d\n", prefix, (int)scts->hour, (int)scts->minute, (int)scts->second); g_print("%s: Timezone %d hours %d minutes\n", prefix, (int)scts->timezone / 4, (int)((abs(scts->timezone) % 4) * 15)); ts = sms_scts_to_time(scts, &remote); strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", localtime(&ts)); buf[127] = '\0'; g_print("local time: %s\n", buf); strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", &remote); buf[127] = '\0'; g_print("remote time: %s\n", buf); }
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 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); }