[PATCHv3 0/2] Make message state feature independent of the stack

2011-01-20 Thread Faiyaz Baxamusa
This set of patches enable the org.ofono.Message interface code to be
independent of the protocol stack. This will enable both GSM and CDMA SMS stack
to reuse the interface code.

The changes have been tested with phonesim using send-sms script.

Faiyaz Baxamusa (2):
  doc: Add messagemanager-api and change message-api
  sms: Introduce message code independent of protocol stack

 Makefile.am|7 +-
 ...message-api.txt = cdma-messagemanager-api.txt} |0
 doc/message-api.txt|   89 ---
 doc/messagemanager-api.txt |   88 +++
 src/message.c  |  228 ++
 src/message.h  |   54 +
 src/sms.c  |  247 +++-
 7 files changed, 402 insertions(+), 311 deletions(-)
 rename doc/{cdma-message-api.txt = cdma-messagemanager-api.txt} (100%)
 create mode 100644 doc/messagemanager-api.txt
 create mode 100644 src/message.c
 create mode 100644 src/message.h

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCHv3 1/2] doc: Add messagemanager-api and change message-api

2011-01-20 Thread Faiyaz Baxamusa
---
 Makefile.am|4 +-
 ...message-api.txt = cdma-messagemanager-api.txt} |0
 doc/message-api.txt|   89 
 doc/messagemanager-api.txt |   88 +++
 4 files changed, 90 insertions(+), 91 deletions(-)
 rename doc/{cdma-message-api.txt = cdma-messagemanager-api.txt} (100%)
 create mode 100644 doc/messagemanager-api.txt

diff --git a/Makefile.am b/Makefile.am
index 9c8083b..2618fa3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -392,11 +392,11 @@ doc_files = doc/overview.txt doc/ofono-paper.txt 
doc/release-faq.txt \
doc/pushnotification-api.txt \
doc/smartmessaging-api.txt \
doc/call-volume-api.txt doc/cell-broadcast-api.txt \
-   doc/message-api.txt doc/message-waiting-api.txt \
+   doc/messagemanager-api.txt doc/message-waiting-api.txt \
doc/phonebook-api.txt doc/radio-settings-api.txt \
doc/sim-api.txt doc/stk-api.txt \
doc/audio-settings-api.txt doc/text-telephony-api.txt \
-   doc/calypso-modem.txt
+   doc/calypso-modem.txt doc/message-api.txt
 
 
 test_scripts = test/backtrace \
diff --git a/doc/cdma-message-api.txt b/doc/cdma-messagemanager-api.txt
similarity index 100%
rename from doc/cdma-message-api.txt
rename to doc/cdma-messagemanager-api.txt
diff --git a/doc/message-api.txt b/doc/message-api.txt
index f7ab22a..1c68aee 100644
--- a/doc/message-api.txt
+++ b/doc/message-api.txt
@@ -1,92 +1,3 @@
-Message Manager hierarchy
-===
-
-Serviceorg.ofono
-Interface  org.ofono.MessageManager
-Object path[variable prefix]/{modem0,modem1,...}
-
-Methodsdict GetProperties()
-
-   Returns properties for the manager object. See
-   the properties section for available properties.
-
-   Possible Errors: [service].Error.InvalidArguments
-
-   array{object,dict} GetMessages()
-
-   Get an array of message object paths and properties
-   that represents the currently pending messages.
-
-   This method call should only be used once when an
-   application starts up.  Further message additions
-   and removal shall be monitored via MessageAdded and
-   MessageRemoved signals.
-
-   void SetProperty(string name, variant value)
-
-   Changes the value of the specified property. Only
-   properties that are listed as readwrite are
-   changeable. On success a PropertyChanged signal
-   will be emitted.
-
-   Possible Errors: [service].Error.InvalidArguments
-[service].Error.DoesNotExist
-
-   object SendMessage(string to, string text)
-
-   Send the message in text to the number in to.  If the
-   message could be queued successfully, this method
-   returns an object path to the created Message object.
-
-SignalsPropertyChanged(string name, variant value)
-
-   This signal indicates a changed value of the given
-   property.
-
-   ImmediateMessage(string message, dict info)
-
-   New immediate (class 0) SMS received. Info has Sender,
-   LocalSentTime, and SentTime information.  Sender
-   address is given in string format.  LocalSentTime and
-   SentTime are given in string form using ISO8601 format.
-
-   IncomingMessage(string message, dict info)
-
-   New incoming text SMS received. Info has Sender,
-   LocalSentTime, and SentTime information.
-
-   MessageAdded(object path, dict properties)
-
-   This signal is emitted whenever a new Message object
-   has been created.
-
-   MessageRemoved(object path)
-
-   This signal is emitted whenever a Message object
-   has been removed, e.g. when it reaches a final state.
-
-Properties string ServiceCenterAddress
-
-   Contains the number of the SMS service center.
-
-   boolean UseDeliveryReports
-
-   This property controls whether SMS Status Reports,
-   sometimes better known as Delivery Reports are to be
-   used.  If enabled, all outgoing SMS messages will be
-   flagged to request a status report from the SMSC.
-
-   string Bearer

[PATCHv3 2/2] sms: Introduce message code independent of protocol stack

2011-01-20 Thread Faiyaz Baxamusa
---
 Makefile.am   |3 +-
 src/message.c |  228 
 src/message.h |   54 +
 src/sms.c |  247 +++--
 4 files changed, 312 insertions(+), 220 deletions(-)
 create mode 100644 src/message.c
 create mode 100644 src/message.h

diff --git a/Makefile.am b/Makefile.am
index 2618fa3..9933e32 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -354,7 +354,8 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/nettime.c src/stkagent.c src/stkagent.h \
src/simfs.c src/simfs.h src/audio-settings.c \
src/smsagent.c src/smsagent.h src/ctm.c \
-   src/cdma-voicecall.c src/sim-auth.c
+   src/cdma-voicecall.c src/sim-auth.c \
+   src/message.h src/message.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
diff --git a/src/message.c b/src/message.c
new file mode 100644
index 000..050a522
--- /dev/null
+++ b/src/message.c
@@ -0,0 +1,228 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include string.h
+#include gdbus.h
+#include stdio.h
+
+#include ofono.h
+#include message.h
+
+struct message {
+   struct ofono_uuid uuid;
+   enum message_state state;
+   struct ofono_atom *atom;
+   void *data;
+};
+
+static const char *message_state_to_string(enum message_state s)
+{
+   switch (s) {
+   case MESSAGE_STATE_PENDING:
+   return pending;
+   case MESSAGE_STATE_SENT:
+   return sent;
+   case MESSAGE_STATE_FAILED:
+   return failed;
+   }
+
+   return NULL;
+}
+
+static DBusMessage *message_get_properties(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   struct message *m = data;
+   DBusMessage *reply;
+   DBusMessageIter iter;
+   DBusMessageIter dict;
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_iter_init_append(reply, iter);
+
+   dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+   OFONO_PROPERTIES_ARRAY_SIGNATURE,
+   dict);
+   message_append_properties(m, dict);
+   dbus_message_iter_close_container(iter, dict);
+
+   return reply;
+}
+
+static GDBusMethodTable message_methods[] = {
+   { GetProperties,  ,a{sv},   message_get_properties },
+   { }
+};
+
+static GDBusSignalTable message_signals[] = {
+   { PropertyChanged,sv },
+   { }
+};
+
+struct message *message_create(const struct ofono_uuid *uuid,
+   struct ofono_atom *atom)
+{
+   struct message *v;
+
+   v = g_try_new0(struct message, 1);
+   if (v == NULL)
+   return NULL;
+
+   memcpy(v-uuid, uuid, sizeof(*uuid));
+
+   v-atom = atom;
+
+   return v;
+}
+
+static void message_destroy(gpointer userdata)
+{
+   struct message *m = userdata;
+
+   g_free(m);
+}
+
+gboolean message_dbus_register(struct message *m)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = message_path_from_uuid(m-atom, m-uuid);
+
+   if (!g_dbus_register_interface(conn, path, OFONO_MESSAGE_INTERFACE,
+   message_methods, message_signals,
+   NULL, m, message_destroy)) {
+   ofono_error(Could not register Message %s, path);
+   message_destroy(m);
+
+   return FALSE;
+   }
+
+   return TRUE;
+}
+
+void message_dbus_unregister(struct message *m)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = message_path_from_uuid(m-atom, m-uuid);
+
+   g_dbus_unregister_interface(conn, path, OFONO_MESSAGE_INTERFACE);
+
+   return;
+}
+
+const struct ofono_uuid *message_get_uuid(const struct message *m)
+{
+   return m-uuid;
+}
+
+void 

[PATCHv2 0/2] Make message state feature independent of the stack

2011-01-14 Thread Faiyaz Baxamusa
This set of patches enable the org.ofono.Message interface code to be
independent of the protocol stack. This will enable both GSM and CDMA SMS stack
to reuse the interface code.

The changes have been tested with phonesim using send-sms script.

Faiyaz Baxamusa (2):
  doc: Add messagemanager-api and change message-api
  sms: Introduce message code independent of protocol stack

 Makefile.am|6 +-
 ...message-api.txt = cdma-messagemanager-api.txt} |0
 doc/message-api.txt|   89 ---
 doc/messagemanager-api.txt |   88 +++
 src/message.c  |  230 ++
 src/message.h  |   67 ++
 src/sms.c  |  247 +++-
 7 files changed, 416 insertions(+), 311 deletions(-)
 rename doc/{cdma-message-api.txt = cdma-messagemanager-api.txt} (100%)
 create mode 100644 doc/messagemanager-api.txt
 create mode 100644 src/message.c
 create mode 100644 src/message.h

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCHv2 2/2] sms: Introduce message code independent of protocol stack

2011-01-14 Thread Faiyaz Baxamusa
---
 Makefile.am   |2 +-
 src/message.c |  230 +
 src/message.h |   67 
 src/sms.c |  247 +++--
 4 files changed, 326 insertions(+), 220 deletions(-)
 create mode 100644 src/message.c
 create mode 100644 src/message.h

diff --git a/Makefile.am b/Makefile.am
index c2e5706..9fe2d30 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -349,7 +349,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/nettime.c src/stkagent.c src/stkagent.h \
src/simfs.c src/simfs.h src/audio-settings.c \
src/smsagent.c src/smsagent.h src/ctm.c \
-   src/cdma-voicecall.c
+   src/cdma-voicecall.c src/message.h src/message.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ \
@BLUEZ_LIBS@ -ldl
diff --git a/src/message.c b/src/message.c
new file mode 100644
index 000..e39265e
--- /dev/null
+++ b/src/message.c
@@ -0,0 +1,230 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include string.h
+#include gdbus.h
+#include stdio.h
+
+#include ofono.h
+#include message.h
+
+struct message {
+   struct ofono_uuid uuid;
+   enum message_state state;
+   struct ofono_atom *atom;
+   void *data;
+};
+
+static const char *message_state_to_string(enum message_state s)
+{
+   switch (s) {
+   case MESSAGE_STATE_PENDING:
+   return pending;
+   case MESSAGE_STATE_SENT:
+   return sent;
+   case MESSAGE_STATE_FAILED:
+   return failed;
+   }
+
+   return NULL;
+}
+
+static DBusMessage *message_get_properties(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   struct message *m = data;
+   DBusMessage *reply;
+   DBusMessageIter iter;
+   DBusMessageIter dict;
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_iter_init_append(reply, iter);
+
+   dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+   OFONO_PROPERTIES_ARRAY_SIGNATURE,
+   dict);
+   message_append_properties(m, dict);
+   dbus_message_iter_close_container(iter, dict);
+
+   return reply;
+}
+
+static GDBusMethodTable message_methods[] = {
+   { GetProperties,  ,a{sv},   message_get_properties },
+   { }
+};
+
+static GDBusSignalTable message_signals[] = {
+   { PropertyChanged,sv },
+   { }
+};
+
+struct message *message_create(const struct ofono_uuid *uuid,
+   struct ofono_atom *atom)
+{
+   struct message *v;
+
+   v = g_try_new0(struct message, 1);
+   if (v == NULL)
+   return NULL;
+
+   memcpy(v-uuid, uuid, sizeof(*uuid));
+
+   v-atom = atom;
+
+   return v;
+}
+
+static void message_destroy(gpointer userdata)
+{
+   struct message *m = userdata;
+
+   m-data = NULL;
+   m-atom = NULL;
+   g_free(m);
+}
+
+gboolean message_dbus_register(struct message *m)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = message_path_from_uuid(m-atom, m-uuid);
+
+   if (!g_dbus_register_interface(conn, path, OFONO_MESSAGE_INTERFACE,
+   message_methods, message_signals,
+   NULL, m, message_destroy)) {
+   ofono_error(Could not register Message %s, path);
+   message_destroy(m);
+
+   return FALSE;
+   }
+
+   return TRUE;
+}
+
+void message_dbus_unregister(struct message *m)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = message_path_from_uuid(m-atom, m-uuid);
+
+   g_dbus_unregister_interface(conn, path, OFONO_MESSAGE_INTERFACE);
+
+   return;
+}
+
+const struct ofono_uuid *message_get_uuid(const struct message *m)
+{
+   return 

[PATCHv2 1/2] doc: Add messagemanager-api and change message-api

2011-01-14 Thread Faiyaz Baxamusa
---
 Makefile.am|4 +-
 ...message-api.txt = cdma-messagemanager-api.txt} |0
 doc/message-api.txt|   89 
 doc/messagemanager-api.txt |   88 +++
 4 files changed, 90 insertions(+), 91 deletions(-)
 rename doc/{cdma-message-api.txt = cdma-messagemanager-api.txt} (100%)
 create mode 100644 doc/messagemanager-api.txt

diff --git a/Makefile.am b/Makefile.am
index ce4799e..c2e5706 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -388,11 +388,11 @@ doc_files = doc/overview.txt doc/ofono-paper.txt 
doc/release-faq.txt \
doc/pushnotification-api.txt \
doc/smartmessaging-api.txt \
doc/call-volume-api.txt doc/cell-broadcast-api.txt \
-   doc/message-api.txt doc/message-waiting-api.txt \
+   doc/messagemanager-api.txt doc/message-waiting-api.txt \
doc/phonebook-api.txt doc/radio-settings-api.txt \
doc/sim-api.txt doc/stk-api.txt \
doc/audio-settings-api.txt doc/text-telephony-api.txt \
-   doc/calypso-modem.txt
+   doc/calypso-modem.txt doc/message-api.txt
 
 
 test_scripts = test/backtrace \
diff --git a/doc/cdma-message-api.txt b/doc/cdma-messagemanager-api.txt
similarity index 100%
rename from doc/cdma-message-api.txt
rename to doc/cdma-messagemanager-api.txt
diff --git a/doc/message-api.txt b/doc/message-api.txt
index f7ab22a..1c68aee 100644
--- a/doc/message-api.txt
+++ b/doc/message-api.txt
@@ -1,92 +1,3 @@
-Message Manager hierarchy
-===
-
-Serviceorg.ofono
-Interface  org.ofono.MessageManager
-Object path[variable prefix]/{modem0,modem1,...}
-
-Methodsdict GetProperties()
-
-   Returns properties for the manager object. See
-   the properties section for available properties.
-
-   Possible Errors: [service].Error.InvalidArguments
-
-   array{object,dict} GetMessages()
-
-   Get an array of message object paths and properties
-   that represents the currently pending messages.
-
-   This method call should only be used once when an
-   application starts up.  Further message additions
-   and removal shall be monitored via MessageAdded and
-   MessageRemoved signals.
-
-   void SetProperty(string name, variant value)
-
-   Changes the value of the specified property. Only
-   properties that are listed as readwrite are
-   changeable. On success a PropertyChanged signal
-   will be emitted.
-
-   Possible Errors: [service].Error.InvalidArguments
-[service].Error.DoesNotExist
-
-   object SendMessage(string to, string text)
-
-   Send the message in text to the number in to.  If the
-   message could be queued successfully, this method
-   returns an object path to the created Message object.
-
-SignalsPropertyChanged(string name, variant value)
-
-   This signal indicates a changed value of the given
-   property.
-
-   ImmediateMessage(string message, dict info)
-
-   New immediate (class 0) SMS received. Info has Sender,
-   LocalSentTime, and SentTime information.  Sender
-   address is given in string format.  LocalSentTime and
-   SentTime are given in string form using ISO8601 format.
-
-   IncomingMessage(string message, dict info)
-
-   New incoming text SMS received. Info has Sender,
-   LocalSentTime, and SentTime information.
-
-   MessageAdded(object path, dict properties)
-
-   This signal is emitted whenever a new Message object
-   has been created.
-
-   MessageRemoved(object path)
-
-   This signal is emitted whenever a Message object
-   has been removed, e.g. when it reaches a final state.
-
-Properties string ServiceCenterAddress
-
-   Contains the number of the SMS service center.
-
-   boolean UseDeliveryReports
-
-   This property controls whether SMS Status Reports,
-   sometimes better known as Delivery Reports are to be
-   used.  If enabled, all outgoing SMS messages will be
-   flagged to request a status report from the SMSC.
-
-   string Bearer

Re: [PATCH 1/3] doc: Add message state API

2011-01-13 Thread Faiyaz Baxamusa

Hi Denis,

On 01/13/2011 10:04 AM, ext Denis Kenzior wrote:

Hi Faiyaz,

On 01/06/2011 01:50 PM, Faiyaz Baxamusa wrote:

---
  Makefile.am   |2 +-
  doc/cdma-message-api.txt  |5 +
  doc/message-api.txt   |   24 +---


Please rename this file into doc/messagemanager-api.txt


I will rename current doc/message-api.txt to
doc/messagemanager-api.txt file and also rename doc/cdma-message-api.txt 
to doc/cdma-messagemanager-api.txt





  doc/message-state-api.txt |   27 +++


And this one can be message-api.txt


I will rename the new file to doc/message-api.txt




  4 files changed, 34 insertions(+), 24 deletions(-)
  create mode 100644 doc/message-state-api.txt

diff --git a/Makefile.am b/Makefile.am
index 09dc9ad..14f53ef 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -369,7 +369,7 @@ doc_files = doc/overview.txt doc/ofono-paper.txt 
doc/release-faq.txt \
doc/phonebook-api.txt doc/radio-settings-api.txt \
doc/sim-api.txt doc/stk-api.txt \
doc/audio-settings-api.txt doc/text-telephony-api.txt \
-   doc/calypso-modem.txt
+   doc/calypso-modem.txt doc/message-state-api.txt


  test_scripts = test/backtrace \
diff --git a/doc/cdma-message-api.txt b/doc/cdma-message-api.txt
index 8e6b9ea..c3d03f8 100644
--- a/doc/cdma-message-api.txt
+++ b/doc/cdma-message-api.txt
@@ -110,3 +110,8 @@ Properties  boolean UseDeliveryAcknowledgement
The call back number for the user.  If the number is
empty, then the optional field is not included
in the encoded PDU.
+
+Message hierarchy
+===
+
+Please refer to message-state-api.txt


Please get rid of this chunk.



Sure.


diff --git a/doc/message-api.txt b/doc/message-api.txt
index f7ab22a..e6c8522 100644
--- a/doc/message-api.txt
+++ b/doc/message-api.txt
@@ -90,26 +90,4 @@ Properties   string ServiceCenterAddress
  Message hierarchy
  ===

-Serviceorg.ofono
-Interface  org.ofono.Message
-Object path[variable prefix]/{modem0,modem1,...}/{message_01,...}
-
-Methodsdict GetProperties()
-
-   Returns properties for the message object. See
-   the properties section for available properties.
-
-   Possible Errors: [service].Error.InvalidArguments
-
-SignalsPropertyChanged(string name, variant value)
-
-   This signal indicates a changed value of the given
-   property.
-
-Properties string State
-
-   Contains the state of the message object.  Possible
-   values are:
-   pending,
-   sent,
-   failed
+Please refer to message-state-api.txt
diff --git a/doc/message-state-api.txt b/doc/message-state-api.txt
new file mode 100644
index 000..edd0cbf
--- /dev/null
+++ b/doc/message-state-api.txt
@@ -0,0 +1,27 @@
+Message hierarchy
+===
+
+Serviceorg.ofono
+Interface  org.ofono.Message
+Object path[variable prefix]/{modem0,modem1,...}/{message_01,...}
+
+Methodsdict GetProperties()
+
+   Returns properties for the message object. See
+   the properties section for available properties.
+
+   Possible Errors: [service].Error.InvalidArguments
+
+SignalsPropertyChanged(string name, variant value)
+
+   This signal indicates a changed value of the given
+   property.
+
+Properties string State
+
+   Contains the state of the message object.  Possible
+   values are:
+   pending,
+   sent,
+   failed
+   invalid


Please get rid of this invalid state.



Sure, will remove invalid


Regards,
-Denis



___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 2/3] include: Introduce message

2011-01-13 Thread Faiyaz Baxamusa

Hi Denis:

On 01/13/2011 10:08 AM, ext Denis Kenzior wrote:

Hi Faiyaz,

On 01/06/2011 01:50 PM, Faiyaz Baxamusa wrote:

---
  Makefile.am   |2 +-
  include/message.h |   67 +
  2 files changed, 68 insertions(+), 1 deletions(-)
  create mode 100644 include/message.h


This is not an atom, it is an implementation detail inside the core.  So
please don't put this into include/ (this is where the public API, for
e.g. plugins and drivers goes)

Moving this inside src/message.h is the way to go.


Will move the file to src/message.h





diff --git a/Makefile.am b/Makefile.am
index 14f53ef..8b19eef 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,7 @@ include_HEADERS = include/log.h include/plugin.h 
include/history.h \
include/radio-settings.h include/stk.h \
include/audio-settings.h include/nettime.h \
include/ctm.h include/cdma-voicecall.h \
-   include/cdma-sms.h
+   include/cdma-sms.h include/message.h

  nodist_include_HEADERS = include/version.h

diff --git a/include/message.h b/include/message.h
new file mode 100644
index 000..7c60390
--- /dev/null
+++ b/include/message.h
@@ -0,0 +1,67 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef __OFONO_MESSAGE_H
+#define __OFONO_MESSAGE_H
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+#includeofono/types.h
+
+enum message_state {
+   MESSAGE_STATE_PENDING,
+   MESSAGE_STATE_SENT,
+   MESSAGE_STATE_FAILED
+};
+
+struct message;
+
+struct message *ofono_message_create(const struct ofono_uuid *uuid,
+   void *data);


Please use message_set_data to be symmetrical with the rest of the codebase.


Sure will initialize data param using message_set_data.



+
+gboolean ofono_message_dbus_register(const char *atompath, struct message *m);
+void ofono_message_dbus_unregister(const char *atompath, struct message *m);
+
+const struct ofono_uuid *ofono_message_get_uuid(const struct message *m);
+
+void ofono_message_set_state(const char *atompath, struct message *m,
+   enum message_state new_state);
+
+void ofono_message_append_properties(struct message *m, DBusMessageIter *dict);
+
+void ofono_emit_message_added(const char *atompath, const char *interface,
+   struct message *m);
+
+void ofono_emit_message_removed(const char *atompath, const char *interface,
+   struct message *m);
+
+void *ofono_message_get_data(struct message *m);
+
+const char *ofono_message_path_from_uuid(const char *atompath,
+   const struct ofono_uuid *uuid);
+


Since this is not public API please don't use the ofono_ prefix for
this.  Using e.g. message_emit_removed, message_append_properties, etc
is good enough.


Will rename all the functions to message_XXX.

Thank you
Faiyaz




Regards,
-Denis


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 3/3] message: Code independent of protocol stack

2011-01-13 Thread Faiyaz Baxamusa

Hi Denis:

On 01/13/2011 10:20 AM, ext Denis Kenzior wrote:

Hi Faiyaz,


+static const char *message_state_to_string(enum message_state s)
+{
+   switch (s) {
+   case MESSAGE_STATE_PENDING:
+   return pending;
+   case MESSAGE_STATE_SENT:
+   return sent;
+   case MESSAGE_STATE_FAILED:
+   return failed;
+   }
+
+   return invalid;


As mentioned previously, don't return invalid here.


Will remove invalid



snip


+gboolean ofono_message_dbus_register(const char *atompath, struct message *m)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path;
+
+   if ((atompath == NULL) || (m == NULL))
+   return FALSE;


Please get rid of these parentheses, they're not needed.  Also, in
general we prefer not to use null checking in the core.  The earlier we
crash the easier it is to find the bugs.


will fix all the occurrences.




+
+   path = ofono_message_path_from_uuid(atompath,m-uuid);
+
+   if (!g_dbus_register_interface(conn, path, OFONO_MESSAGE_INTERFACE,
+   message_methods, message_signals,
+   NULL, m, message_destroy)) {
+   ofono_error(Could not register Message %s, path);
+   message_destroy(m);
+
+   return FALSE;
+   }
+
+   return TRUE;
+}
+
+void ofono_message_dbus_unregister(const char *atompath, struct message *m)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path;
+
+   if ((atompath == NULL) || (m == NULL))
+   return;


Same comment as above about the parentheses.


+
+   path = ofono_message_path_from_uuid(atompath,m-uuid);
+
+   g_dbus_unregister_interface(conn, path, OFONO_MESSAGE_INTERFACE);
+
+   return;
+}
+
+const struct ofono_uuid *ofono_message_get_uuid(const struct message *m)
+{
+   if (m == NULL)
+   return NULL;
+
+   returnm-uuid;
+}
+
+void ofono_message_set_state(const char *atompath,
+   struct message *m, enum message_state new_state)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *state;
+   const char *path;
+
+   if ((atompath == NULL) || (m == NULL))
+   return;
+


And again the comment about parentheses.


+   if (m-state == new_state)
+   return;
+
+   path = ofono_message_path_from_uuid(atompath,m-uuid);
+
+   m-state = new_state;
+   state = message_state_to_string(m-state);
+
+   ofono_dbus_signal_property_changed(conn, path, OFONO_MESSAGE_INTERFACE,
+   State, DBUS_TYPE_STRING,
+   state);
+}
+
+void ofono_message_append_properties(struct message *m, DBusMessageIter *dict)
+{
+   const char *state;
+
+   if (m == NULL)
+   return;
+
+   state = message_state_to_string(m-state);
+   ofono_dbus_dict_append(dict, State, DBUS_TYPE_STRING,state);
+}
+
+void ofono_emit_message_added(const char *atompath, const char *interface,
+   struct message *m)
+{
+   DBusMessage *signal;
+   DBusMessageIter iter;
+   DBusMessageIter dict;
+   const char *path;
+
+   if ((atompath == NULL) || (m == NULL))
+   return;
+


And here


+   signal = dbus_message_new_signal(atompath, interface, MessageAdded);
+   if (signal == NULL)
+   return;
+
+   path = ofono_message_path_from_uuid(atompath,m-uuid);
+
+   dbus_message_iter_init_append(signal,iter);
+
+   dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH,path);
+
+   dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+   OFONO_PROPERTIES_ARRAY_SIGNATURE,
+   dict);
+   ofono_message_append_properties(m,dict);
+   dbus_message_iter_close_container(iter,dict);
+
+   g_dbus_send_message(ofono_dbus_get_connection(), signal);
+}
+
+void ofono_emit_message_removed(const char *atompath, const char *interface,
+   struct message *m)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path;
+
+   if ((atompath == NULL) || (m == NULL))
+   return;
+


And here ;)


+   path = ofono_message_path_from_uuid(atompath,m-uuid);
+
+   g_dbus_emit_signal(conn, atompath, interface,
+   MessageRemoved, DBUS_TYPE_OBJECT_PATH,path,
+   DBUS_TYPE_INVALID);
+}
+
+const char *ofono_message_path_from_uuid(const char *atompath,
+   const struct ofono_uuid *uuid)


Please keep this as an internal API (e.g.
__ofono_message_path_from_uuid) and update ofono.h appropriately.


Based on a 

[PATCH 0/3] Make Message state feature independent of the stack

2011-01-06 Thread Faiyaz Baxamusa
This set of patches enable the org.ofono.Message interface code to be
independent of the protocol stack. This will enable both GSM and CDMA SMS stack
to reuse the interface code.

The changes have been tested with phonesim using send-sms script.

Faiyaz Baxamusa (3):
  doc: Add message state API
  include: Introduce message
  message: Code independent of protocol stack

 Makefile.am   |6 +-
 doc/cdma-message-api.txt  |5 +
 doc/message-api.txt   |   24 +
 doc/message-state-api.txt |   27 +
 include/message.h |   67 
 src/message.c |  257 
 src/ofono.h   |2 +
 src/sms.c |  258 +++--
 8 files changed, 399 insertions(+), 247 deletions(-)
 create mode 100644 doc/message-state-api.txt
 create mode 100644 include/message.h
 create mode 100644 src/message.c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/3] doc: Add message state API

2011-01-06 Thread Faiyaz Baxamusa
---
 Makefile.am   |2 +-
 doc/cdma-message-api.txt  |5 +
 doc/message-api.txt   |   24 +---
 doc/message-state-api.txt |   27 +++
 4 files changed, 34 insertions(+), 24 deletions(-)
 create mode 100644 doc/message-state-api.txt

diff --git a/Makefile.am b/Makefile.am
index 09dc9ad..14f53ef 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -369,7 +369,7 @@ doc_files = doc/overview.txt doc/ofono-paper.txt 
doc/release-faq.txt \
doc/phonebook-api.txt doc/radio-settings-api.txt \
doc/sim-api.txt doc/stk-api.txt \
doc/audio-settings-api.txt doc/text-telephony-api.txt \
-   doc/calypso-modem.txt
+   doc/calypso-modem.txt doc/message-state-api.txt
 
 
 test_scripts = test/backtrace \
diff --git a/doc/cdma-message-api.txt b/doc/cdma-message-api.txt
index 8e6b9ea..c3d03f8 100644
--- a/doc/cdma-message-api.txt
+++ b/doc/cdma-message-api.txt
@@ -110,3 +110,8 @@ Properties  boolean UseDeliveryAcknowledgement
The call back number for the user.  If the number is
empty, then the optional field is not included
in the encoded PDU.
+
+Message hierarchy
+===
+
+Please refer to message-state-api.txt
diff --git a/doc/message-api.txt b/doc/message-api.txt
index f7ab22a..e6c8522 100644
--- a/doc/message-api.txt
+++ b/doc/message-api.txt
@@ -90,26 +90,4 @@ Properties   string ServiceCenterAddress
 Message hierarchy
 ===
 
-Serviceorg.ofono
-Interface  org.ofono.Message
-Object path[variable prefix]/{modem0,modem1,...}/{message_01,...}
-
-Methodsdict GetProperties()
-
-   Returns properties for the message object. See
-   the properties section for available properties.
-
-   Possible Errors: [service].Error.InvalidArguments
-
-SignalsPropertyChanged(string name, variant value)
-
-   This signal indicates a changed value of the given
-   property.
-
-Properties string State
-
-   Contains the state of the message object.  Possible
-   values are:
-   pending,
-   sent,
-   failed
+Please refer to message-state-api.txt
diff --git a/doc/message-state-api.txt b/doc/message-state-api.txt
new file mode 100644
index 000..edd0cbf
--- /dev/null
+++ b/doc/message-state-api.txt
@@ -0,0 +1,27 @@
+Message hierarchy
+===
+
+Serviceorg.ofono
+Interface  org.ofono.Message
+Object path[variable prefix]/{modem0,modem1,...}/{message_01,...}
+
+Methodsdict GetProperties()
+
+   Returns properties for the message object. See
+   the properties section for available properties.
+
+   Possible Errors: [service].Error.InvalidArguments
+
+SignalsPropertyChanged(string name, variant value)
+
+   This signal indicates a changed value of the given
+   property.
+
+Properties string State
+
+   Contains the state of the message object.  Possible
+   values are:
+   pending,
+   sent,
+   failed
+   invalid
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/3] include: Introduce message

2011-01-06 Thread Faiyaz Baxamusa
---
 Makefile.am   |2 +-
 include/message.h |   67 +
 2 files changed, 68 insertions(+), 1 deletions(-)
 create mode 100644 include/message.h

diff --git a/Makefile.am b/Makefile.am
index 14f53ef..8b19eef 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,7 @@ include_HEADERS = include/log.h include/plugin.h 
include/history.h \
include/radio-settings.h include/stk.h \
include/audio-settings.h include/nettime.h \
include/ctm.h include/cdma-voicecall.h \
-   include/cdma-sms.h
+   include/cdma-sms.h include/message.h
 
 nodist_include_HEADERS = include/version.h
 
diff --git a/include/message.h b/include/message.h
new file mode 100644
index 000..7c60390
--- /dev/null
+++ b/include/message.h
@@ -0,0 +1,67 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef __OFONO_MESSAGE_H
+#define __OFONO_MESSAGE_H
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+#include ofono/types.h
+
+enum message_state {
+   MESSAGE_STATE_PENDING,
+   MESSAGE_STATE_SENT,
+   MESSAGE_STATE_FAILED
+};
+
+struct message;
+
+struct message *ofono_message_create(const struct ofono_uuid *uuid,
+   void *data);
+
+gboolean ofono_message_dbus_register(const char *atompath, struct message *m);
+void ofono_message_dbus_unregister(const char *atompath, struct message *m);
+
+const struct ofono_uuid *ofono_message_get_uuid(const struct message *m);
+
+void ofono_message_set_state(const char *atompath, struct message *m,
+   enum message_state new_state);
+
+void ofono_message_append_properties(struct message *m, DBusMessageIter *dict);
+
+void ofono_emit_message_added(const char *atompath, const char *interface,
+   struct message *m);
+
+void ofono_emit_message_removed(const char *atompath, const char *interface,
+   struct message *m);
+
+void *ofono_message_get_data(struct message *m);
+
+const char *ofono_message_path_from_uuid(const char *atompath,
+   const struct ofono_uuid *uuid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_MESSAGE_H */
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/3] message: Code independent of protocol stack

2011-01-06 Thread Faiyaz Baxamusa
---
 Makefile.am   |2 +-
 src/message.c |  257 
 src/ofono.h   |2 +
 src/sms.c |  258 
 4 files changed, 297 insertions(+), 222 deletions(-)
 create mode 100644 src/message.c

diff --git a/Makefile.am b/Makefile.am
index 8b19eef..756e6b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -329,7 +329,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/nettime.c src/stkagent.c src/stkagent.h \
src/simfs.c src/simfs.h src/audio-settings.c \
src/smsagent.c src/smsagent.h src/ctm.c \
-   src/cdma-voicecall.c
+   src/cdma-voicecall.c src/message.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
diff --git a/src/message.c b/src/message.c
new file mode 100644
index 000..9e880f6
--- /dev/null
+++ b/src/message.c
@@ -0,0 +1,257 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include string.h
+#include gdbus.h
+#include stdio.h
+
+#include ofono/types.h
+
+#include ofono.h
+#include common.h
+
+struct message {
+   struct ofono_uuid uuid;
+   enum message_state state;
+   void *data;
+};
+
+static const char *message_state_to_string(enum message_state s)
+{
+   switch (s) {
+   case MESSAGE_STATE_PENDING:
+   return pending;
+   case MESSAGE_STATE_SENT:
+   return sent;
+   case MESSAGE_STATE_FAILED:
+   return failed;
+   }
+
+   return invalid;
+}
+
+static DBusMessage *message_get_properties(DBusConnection *conn,
+   DBusMessage *msg, void *data)
+{
+   struct message *m = data;
+   DBusMessage *reply;
+   DBusMessageIter iter;
+   DBusMessageIter dict;
+
+   reply = dbus_message_new_method_return(msg);
+   if (reply == NULL)
+   return NULL;
+
+   dbus_message_iter_init_append(reply, iter);
+
+   dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+   OFONO_PROPERTIES_ARRAY_SIGNATURE,
+   dict);
+   ofono_message_append_properties(m, dict);
+   dbus_message_iter_close_container(iter, dict);
+
+   return reply;
+}
+
+static GDBusMethodTable message_methods[] = {
+   { GetProperties,  ,a{sv},   message_get_properties },
+   { }
+};
+
+static GDBusSignalTable message_signals[] = {
+   { PropertyChanged,sv },
+   { }
+};
+
+struct message *ofono_message_create(const struct ofono_uuid *uuid,
+   void *data)
+{
+   struct message *v;
+
+   if (uuid == NULL)
+   return NULL;
+
+   v = g_try_new0(struct message, 1);
+   if (v == NULL)
+   return NULL;
+
+   memcpy(v-uuid, uuid, sizeof(*uuid));
+
+   v-data = data;
+
+   return v;
+}
+
+static void message_destroy(gpointer userdata)
+{
+   struct message *m = userdata;
+
+   if (m == NULL)
+   return;
+
+   m-data = NULL;
+   g_free(m);
+}
+
+gboolean ofono_message_dbus_register(const char *atompath, struct message *m)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path;
+
+   if ((atompath == NULL) || (m == NULL))
+   return FALSE;
+
+   path = ofono_message_path_from_uuid(atompath, m-uuid);
+
+   if (!g_dbus_register_interface(conn, path, OFONO_MESSAGE_INTERFACE,
+   message_methods, message_signals,
+   NULL, m, message_destroy)) {
+   ofono_error(Could not register Message %s, path);
+   message_destroy(m);
+
+   return FALSE;
+   }
+
+   return TRUE;
+}
+
+void ofono_message_dbus_unregister(const char *atompath, struct message *m)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path;
+
+   if ((atompath == NULL) || (m == NULL))
+   return;
+
+