Open Source Telephony
 help / color / mirror / Atom feed
From: Inaky Perez-Gonzalez <inaky@linux.intel.com>
To: ofono@ofono.org
Subject: Re: [SMS D-Bus 14/23] SMS: export outgoing messages over D-Bus (skeleton)
Date: Mon, 28 Jun 2010 16:28:32 -0700	[thread overview]
Message-ID: <1277767712.3006.28.camel@localhost.localdomain> (raw)
In-Reply-To: <35d2fe59c28a8e703a5204cbfcc1e981cf5479d0.1277507431.git.inaky.perez-gonzalez@intel.com>

[-- Attachment #1: Type: text/plain, Size: 2620 bytes --]

On Fri, 2010-06-25 at 16:15 -0700, Inaky Perez-Gonzalez wrote: 
> From: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
> 
> 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);


  reply	other threads:[~2010-06-28 23:28 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-25 23:15 [SMS D-Bus 00/23] Exports SMS over D-Bus and mis cleanups Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 01/23] documentation: add note about referencing standards Inaky Perez-Gonzalez
2010-07-02 20:35   ` Denis Kenzior
2010-06-25 23:15 ` [SMS D-Bus 02/23] util.h: Add BUILD_BUG_ON() and friends for compile-time assert checking Inaky Perez-Gonzalez
2010-06-25 23:46   ` Marcel Holtmann
2010-06-28 16:49     ` Inaky Perez-Gonzalez
2010-06-28 17:01   ` Denis Kenzior
2010-06-28 16:58     ` Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 03/23] smutil.h: add missing header file dependencies Inaky Perez-Gonzalez
2010-06-25 23:48   ` Marcel Holtmann
2010-06-28 16:52     ` Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 04/23] write_file: make transaction-safe Inaky Perez-Gonzalez
2010-07-02 20:39   ` Denis Kenzior
2010-07-02 21:25     ` Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 05/23] doc: explain debugging options to -d, add a pointer in -h to manpage Inaky Perez-Gonzalez
2010-07-02 20:43   ` Denis Kenzior
2010-07-02 21:18     ` Inaky Perez-Gonzalez
2010-07-02 21:19     ` Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 06/23] SMS: introduce message ID API Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 07/23] introduce DECLARE_SMS_ADDR_STR() Inaky Perez-Gonzalez
2010-07-07 22:54   ` Denis Kenzior
2010-07-07 23:28     ` Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 08/23] export sms_assembly_encode_address Inaky Perez-Gonzalez
2010-07-07 22:57   ` Denis Kenzior
2010-07-07 23:28     ` Inaky Perez-Gonzalez
2010-07-07 23:36       ` Denis Kenzior
2010-06-25 23:15 ` [SMS D-Bus 09/23] SMS: implement SHA256-based message IDs [incomplete] Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 10/23] sms: add doc about the extensions D-Bus API (not yet implemented) Inaky Perez-Gonzalez
2010-07-07 23:01   ` Denis Kenzior
2010-07-07 23:31     ` Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 11/23] struct tx_queue_entry: add fields and destructor Inaky Perez-Gonzalez
2010-07-07 23:04   ` Denis Kenzior
2010-07-07 23:24     ` Inaky Perez-Gonzalez
2010-07-07 23:32       ` Denis Kenzior
2010-07-07 23:31         ` Inaky Perez-Gonzalez
2010-07-07 23:39           ` Denis Kenzior
2010-07-08 23:28             ` Inaky Perez-Gonzalez
2010-07-08 23:38               ` Denis Kenzior
2010-07-08 23:37                 ` Inaky Perez-Gonzalez
2010-07-09  0:03                 ` Inaky Perez-Gonzalez
2010-07-09  0:22                   ` Denis Kenzior
2010-07-09 17:11                     ` Inaky Perez-Gonzalez
2010-07-09 17:19                       ` Denis Kenzior
2010-07-09 21:53                         ` Inaky Perez-Gonzalez
2010-07-09 22:28                           ` Marcel Holtmann
2010-07-12 20:17         ` Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 12/23] SMS: produce a unique, persistent name for in-transit messages Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 13/23] SMS: introduce bare state machine and transitions Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 14/23] SMS: export outgoing messages over D-Bus (skeleton) Inaky Perez-Gonzalez
2010-06-28 23:28   ` Inaky Perez-Gonzalez [this message]
2010-06-25 23:15 ` [SMS D-Bus 15/23] SMS: split sms_send_message() into a D-Bus front end and an internal API Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 16/23] SMS: introduce wait-for-ack state and infrastructure Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 17/23] SMS: introduce sms_msg_cancel and its D-Bus wrapper Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 18/23] SMS: rename tx_queue_entry->msg to ->dbus_msg for clarity Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 19/23] SMS: Implement D-Bus SMS-MSG::GetProperties Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 20/23] SMS: send D-Bus SMS-MSG::ProperyChanged signals when message changes status Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 21/23] SMS: make D-Bus SendMessage and Cancel fully synchronous Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 22/23] SMS: set the SRR bit in outgoing PDUs if WFA is requested Inaky Perez-Gonzalez
2010-06-28 23:30   ` Inaky Perez-Gonzalez
2010-06-25 23:15 ` [SMS D-Bus 23/23] sms_text_prepare: document @use_delivery_reports Inaky Perez-Gonzalez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1277767712.3006.28.camel@localhost.localdomain \
    --to=inaky@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox