From: Kristen Carlson Accardi <kristen@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 1/3 v2] sms: store pending tx pdus on disk
Date: Fri, 10 Dec 2010 16:16:11 -0800 [thread overview]
Message-ID: <1292026571-16774-1-git-send-email-kristen@linux.intel.com> (raw)
In-Reply-To: <4CFD9E42.3050109@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3475 bytes --]
---
src/sms.c | 15 +++++++++++++++
src/smsutil.c | 26 ++++++++++++++++++++++++++
src/smsutil.h | 3 +++
3 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/src/sms.c b/src/sms.c
index 163eab0..e5e06db 100644
--- a/src/sms.c
+++ b/src/sms.c
@@ -77,6 +77,7 @@ struct ofono_sms {
struct sms_assembly *assembly;
guint ref;
GQueue *txq;
+ unsigned long tx_counter;
guint tx_source;
struct ofono_message_waiting *mw;
unsigned int mw_watch;
@@ -111,6 +112,7 @@ struct tx_queue_entry {
ofono_sms_txq_submit_cb_t cb;
void *data;
ofono_destroy_func destroy;
+ unsigned long id;
};
static gboolean uuid_equal(gconstpointer v1, gconstpointer v2)
@@ -1896,6 +1898,8 @@ int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
{
struct message *m = NULL;
struct tx_queue_entry *entry;
+ int i;
+ GSList *l;
entry = tx_queue_entry_new(list, flags);
if (entry == NULL)
@@ -1920,6 +1924,8 @@ int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
sms->ref = sms->ref + 1;
}
+ entry->id = sms->tx_counter++;
+
g_queue_push_tail(sms->txq, entry);
if (g_queue_get_length(sms->txq) == 1)
@@ -1928,6 +1934,15 @@ int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
if (uuid)
memcpy(uuid, &entry->uuid, sizeof(*uuid));
+ if (flags & OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS) {
+ for (i = 0, l = list; l; i++, l = l->next) {
+ struct sms *s = l->data;
+ sms_tx_store(sms->imsi, entry->id, entry->flags,
+ ofono_uuid_to_str(&entry->uuid),
+ s, i);
+ }
+ }
+
if (cb)
cb(sms, &entry->uuid, data);
diff --git a/src/smsutil.c b/src/smsutil.c
index 5e1d233..9c6596f 100644
--- a/src/smsutil.c
+++ b/src/smsutil.c
@@ -48,6 +48,10 @@
#define SMS_SR_BACKUP_PATH STORAGEDIR "/%s/sms_sr"
#define SMS_SR_BACKUP_PATH_FILE SMS_SR_BACKUP_PATH "/%s-%s"
+#define SMS_TX_BACKUP_PATH STORAGEDIR "/%s/tx_queue"
+#define SMS_TX_BACKUP_PATH_DIR SMS_TX_BACKUP_PATH "/%lu-%lu-%s"
+#define SMS_TX_BACKUP_PATH_FILE SMS_TX_BACKUP_PATH_DIR "/%03i"
+
#define SMS_ADDR_FMT "%24[0-9A-F]"
#define SMS_MSGID_FMT "%40[0-9A-F]"
@@ -3143,6 +3147,28 @@ void status_report_assembly_expire(struct status_report_assembly *assembly,
}
}
+gboolean sms_tx_store(const char *imsi, unsigned long id, unsigned long flags,
+ const char *uuid, struct sms *s, guint8 seq)
+{
+ int len;
+ unsigned char buf[177];
+
+ if (!imsi)
+ return FALSE;
+
+ len = sms_serialize(buf, s);
+
+ /*
+ * file name is: imsi/order in tx_queue-flags-uuid/order of pdus
+ */
+ if (write_file(buf, len, SMS_BACKUP_MODE,
+ SMS_TX_BACKUP_PATH_FILE, imsi, id, flags, uuid,
+ seq) != len)
+ return FALSE;
+
+ return TRUE;
+}
+
static inline GSList *sms_list_append(GSList *l, const struct sms *in)
{
struct sms *sms;
diff --git a/src/smsutil.h b/src/smsutil.h
index 4b6159f..46084ab 100644
--- a/src/smsutil.h
+++ b/src/smsutil.h
@@ -517,6 +517,9 @@ void status_report_assembly_add_fragment(struct status_report_assembly
void status_report_assembly_expire(struct status_report_assembly *assembly,
time_t before);
+gboolean sms_tx_store(const char *imsi, unsigned long id, unsigned long flags,
+ const char *uuid, struct sms *s, guint8 seq);
+
GSList *sms_text_prepare(const char *to, const char *utf8, guint16 ref,
gboolean use_16bit,
gboolean use_delivery_reports);
--
1.7.2.3
next prev parent reply other threads:[~2010-12-11 0:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-24 22:53 [PATCH 0/3] Persist TX SMS messages Kristen Carlson Accardi
2010-11-24 22:53 ` [PATCH 1/3] sms: store pending tx pdus on disk Kristen Carlson Accardi
2010-12-07 2:38 ` Denis Kenzior
2010-12-07 22:57 ` Kristen Carlson Accardi
2010-12-08 11:01 ` Denis Kenzior
2010-12-11 0:16 ` Kristen Carlson Accardi [this message]
2010-12-07 13:26 ` Aki Niemi
2010-11-24 22:53 ` [PATCH 2/3] sms: delete sent sms messages from backup Kristen Carlson Accardi
2010-12-07 2:31 ` Denis Kenzior
2010-12-11 0:16 ` [PATCH 2/3 v2] " Kristen Carlson Accardi
2010-11-24 22:53 ` [PATCH 3/3] sms: restore pending tx " Kristen Carlson Accardi
2010-12-07 2:43 ` Denis Kenzior
2010-12-11 0:17 ` [PATCH 3/3 v2] " Kristen Carlson Accardi
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=1292026571-16774-1-git-send-email-kristen@linux.intel.com \
--to=kristen@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