sms: delete sent sms messages from backup

Based on patch from Kristen Carlson Accardi <kristen@linux.intel.com>
This commit is contained in:
Lucas De Marchi 2011-01-28 00:39:56 -02:00 committed by Denis Kenzior
parent 8305ddf321
commit f55447a39e
3 changed files with 61 additions and 0 deletions

View File

@ -571,6 +571,11 @@ static void tx_finished(const struct ofono_error *error, int mr, void *data)
goto next_q;
}
if (entry->flags & OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS)
sms_tx_backup_remove(sms->imsi, entry->id, entry->flags,
ofono_uuid_to_str(&entry->uuid),
entry->cur_pdu);
entry->cur_pdu += 1;
entry->retry = 0;
@ -607,6 +612,9 @@ next_q:
if (entry->flags & OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS) {
enum message_state ms;
sms_tx_backup_free(sms->imsi, entry->id, entry->flags,
ofono_uuid_to_str(&entry->uuid));
if (ok)
ms = MESSAGE_STATE_SENT;
else

View File

@ -3172,6 +3172,53 @@ gboolean sms_tx_backup_store(const char *imsi, unsigned long id,
return TRUE;
}
void sms_tx_backup_free(const char *imsi, unsigned long id,
unsigned long flags, const char *uuid)
{
char *path;
struct dirent **entries;
int len;
path = g_strdup_printf(SMS_TX_BACKUP_PATH_DIR,
imsi, id, flags, uuid);
len = scandir(path, &entries, NULL, versionsort);
if (len < 0)
return;
/* skip '..' and '.' entries */
while (len-- > 2) {
struct dirent *dir = entries[len];
char *file = g_strdup_printf("%s/%s", path, dir->d_name);
unlink(file);
g_free(file);
g_free(entries[len]);
}
g_free(entries[1]);
g_free(entries[0]);
g_free(entries);
rmdir(path);
g_free(path);
}
void sms_tx_backup_remove(const char *imsi, unsigned long id,
unsigned long flags, const char *uuid,
guint8 seq)
{
char *path;
path = g_strdup_printf(SMS_TX_BACKUP_PATH_FILE,
imsi, id, flags, uuid, seq);
unlink(path);
g_free(path);
}
static inline GSList *sms_list_append(GSList *l, const struct sms *in)
{
struct sms *sms;

View File

@ -521,6 +521,12 @@ gboolean sms_tx_backup_store(const char *imsi, unsigned long id,
unsigned long flags, const char *uuid,
guint8 seq, const unsigned char *pdu,
int pdu_len, int tpdu_len);
void sms_tx_backup_remove(const char *imsi, unsigned long id,
unsigned long flags, const char *uuid,
guint8 seq);
void sms_tx_backup_free(const char *imsi, unsigned long id,
unsigned long flags, const char *uuid);
GSList *sms_text_prepare(const char *to, const char *utf8, guint16 ref,
gboolean use_16bit,
gboolean use_delivery_reports);