On Fri, 2010-06-25 at 16:15 -0700, Inaky Perez-Gonzalez wrote:
> From: Inaky Perez-Gonzalez <[email protected]>
>
> This creates two frunctions, sms_msg_[un]register() which will
> add/remove a D-Bus object for each SMS message when in transit.
>
> Future changes make sms_msg_register() need information that is not
> available at the time create_tx_queue_entry() is called, thus why
> registration happens later.
Found a few rough corners here when integrating the final parts of
status reports into the SMS state-machine. A re-submit will have this
incremental patch merged:
diff --git a/src/sms.c b/src/sms.c
index 1b35fa9..27a3d64 100644
--- a/src/sms.c
+++ b/src/sms.c
@@ -532,8 +532,15 @@ GDBusSignalTable sms_msg_signals[] = {
};
+/**
+ *
+ * @returns 0 if ok, 0 on error
+ *
+ * On success, sms_msg->dbus_path is non-NULL; this is needed as the
+ * cleanup path on error are not easy to break up.
+ */
static
-void sms_msg_register(struct tx_queue_entry *sms_msg)
+int sms_msg_register(struct tx_queue_entry *sms_msg)
{
g_assert(sms_msg->name != NULL);
sms_msg->dbus_path = g_strdup(sms_msg->name);
@@ -544,20 +551,26 @@ void sms_msg_register(struct tx_queue_entry *sms_msg)
ofono_error("%s: Could not create %s interface",
sms_msg->dbus_path, SMS_MSG_INTERFACE);
g_free(sms_msg->dbus_path);
+ sms_msg->dbus_path = NULL;
+ return 1;
+ } else {
+ ofono_debug("%s: %d: sms %p @ %s: MSG registered",
+ __FILE__, __LINE__, sms_msg, sms_msg->dbus_path);
+ return 0;
}
- ofono_debug("%s: %d: sms %p: MSG registered @ %s",
- __FILE__, __LINE__, sms_msg, sms_msg->dbus_path);
}
static
void sms_msg_unregister(struct tx_queue_entry *sms_msg)
{
+ if (sms_msg->dbus_path == NULL)
+ return;
+ ofono_debug("%s: %d: sms %p @ %s: MSG unregistered",
+ __FILE__, __LINE__, sms_msg, sms_msg->dbus_path);
g_dbus_unregister_interface(ofono_dbus_get_connection(),
sms_msg->dbus_path, SMS_MSG_INTERFACE);
g_free(sms_msg->dbus_path);
- ofono_debug("%s: %d: sms %p: MSG unregistered",
- __FILE__, __LINE__, sms_msg);
}
@@ -801,7 +814,10 @@ struct tx_queue_entry *sms_msg_send(
entry->name = g_strdup_printf(SMS_MSG_NAME_FMT, sms_path,
msg_id_str, entry->num_pdus);
ofono_debug("sms/entry %p name %s\n", entry, entry->name);
- sms_msg_register(entry);
+ if (sms_msg_register(entry)) {
+ tx_queue_entry_destroy_free(entry, NULL);
+ return NULL;
+ }
g_queue_push_tail(sms->txq, entry);
ofono_sms_tx_state_set(entry, OFONO_SMS_TX_ST_QUEUED);
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono