sms: Refactor __ofono_sms_txq_submit

This commit is contained in:
Denis Kenzior 2010-09-20 14:02:34 -05:00
parent 63c8b720fe
commit 016f168f47
3 changed files with 25 additions and 12 deletions

View File

@ -218,10 +218,10 @@ enum ofono_sms_submit_flag {
typedef void (*ofono_sms_txq_submit_cb_t)(gboolean ok, void *data);
unsigned int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
unsigned int flags,
ofono_sms_txq_submit_cb_t cb,
void *data, ofono_destroy_func destroy);
int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
unsigned int flags, struct ofono_uuid *uuid,
ofono_sms_txq_submit_cb_t cb,
void *data, ofono_destroy_func destroy);
#include <ofono/sim.h>
#include <ofono/stk.h>

View File

@ -1457,18 +1457,27 @@ void *ofono_sms_get_data(struct ofono_sms *sms)
return sms->driver_data;
}
unsigned int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
unsigned int flags,
ofono_sms_txq_submit_cb_t cb,
void *data, ofono_destroy_func destroy)
int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
unsigned int flags,
struct ofono_uuid *uuid,
ofono_sms_txq_submit_cb_t cb,
void *data, ofono_destroy_func destroy)
{
struct tx_queue_entry *entry = tx_queue_entry_new(list);
struct tx_queue_entry *entry;
entry = tx_queue_entry_new(list, flags, cb, data, destroy);
if (entry == NULL)
return -ENOMEM;
g_queue_push_tail(sms->txq, entry);
if (g_queue_get_length(sms->txq) == 1)
sms->tx_source = g_timeout_add(0, tx_next, sms);
return entry->msg_id;
if (uuid)
memcpy(uuid, &entry->uuid, sizeof(*uuid));
/* TODO: If this is exported via D-Bus, signal MessageAdded */
return 0;
}

View File

@ -720,8 +720,12 @@ static gboolean handle_command_send_sms(const struct stk_command *cmd,
msg_list.data = (void *) &cmd->send_sms.gsm_sms;
msg_list.next = NULL;
__ofono_sms_txq_submit(sms, &msg_list, 0, send_sms_submit_cb,
stk->sms_submit_req, g_free);
if (__ofono_sms_txq_submit(sms, &msg_list, 0, NULL, send_sms_submit_cb,
stk->sms_submit_req, g_free) < 0) {
g_free(stk->sms_submit_req);
rsp->result.type = STK_RESULT_TYPE_TERMINAL_BUSY;
return TRUE;
}
stk->cancel_cmd = send_sms_cancel;