static void tx_finished(const struct ofono_error *error, int mr, void *data) { struct ofono_sms *sms = data; struct tx_queue_entry *entry = g_queue_peek_head(sms->txq); gboolean ok = error->type == OFONO_ERROR_TYPE_NO_ERROR; enum message_state tx_state; DBG("tx_finished %p", entry); sms->flags &= ~MESSAGE_MANAGER_FLAG_TXQ_ACTIVE; if (ok == FALSE) { /* Retry again when back in online mode */ /* Note this does not increment retry count */ if (sms->registered == FALSE) return; tx_state = MESSAGE_STATE_FAILED; /* Retry done only for Network Timeout failure */ if (error->type == OFONO_ERROR_TYPE_CMS && error->error != NETWORK_TIMEOUT) goto next_q; if (!(entry->flags & OFONO_SMS_SUBMIT_FLAG_RETRY)) goto next_q; entry->retry += 1; if (entry->retry < TXQ_MAX_RETRIES) { DBG("Sending failed, retry in %d secs", entry->retry * 5); sms->tx_source = g_timeout_add_seconds(entry->retry * 5, tx_next, sms); return; } DBG("Max retries reached, giving up"); 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; if (entry->flags & OFONO_SMS_SUBMIT_FLAG_REQUEST_SR) status_report_assembly_add_fragment(sms->sr_assembly, entry->uuid.uuid, &entry->receiver, mr, time(NULL), entry->num_pdus); if (entry->cur_pdu < entry->num_pdus) { sms->tx_source = g_timeout_add(0, tx_next, sms); return; } tx_state = MESSAGE_STATE_SENT; next_q: sms_tx_queue_remove_entry(sms, g_queue_peek_head_link(sms->txq), tx_state); if (sms->registered == FALSE) return; if (g_queue_peek_head(sms->txq)) { DBG("Scheduling next"); sms->tx_source = g_timeout_add(0, tx_next, sms); } }
static void tx_finished(const struct ofono_error *error, int mr, void *data) { struct ofono_sms *sms = data; struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom); struct tx_queue_entry *entry = g_queue_peek_head(sms->txq); gboolean ok = error->type == OFONO_ERROR_TYPE_NO_ERROR; DBG("tx_finished"); if (ok == FALSE) { if (!(entry->flags & OFONO_SMS_SUBMIT_FLAG_RETRY)) goto next_q; entry->retry += 1; if (entry->retry < TXQ_MAX_RETRIES) { DBG("Sending failed, retry in %d secs", entry->retry * 5); sms->tx_source = g_timeout_add_seconds(entry->retry * 5, tx_next, sms); return; } DBG("Max retries reached, giving up"); goto next_q; } entry->cur_pdu += 1; entry->retry = 0; if (entry->flags & OFONO_SMS_SUBMIT_FLAG_REQUEST_SR) status_report_assembly_add_fragment(sms->sr_assembly, entry->msg_id, &entry->receiver, mr, time(NULL), entry->num_pdus); if (entry->cur_pdu < entry->num_pdus) { sms->tx_source = g_timeout_add(0, tx_next, sms); return; } next_q: entry = g_queue_pop_head(sms->txq); if (entry->cb) entry->cb(ok, entry->data); if (entry->flags & OFONO_SMS_SUBMIT_FLAG_RECORD_HISTORY) { enum ofono_history_sms_status hs; if (ok) hs = OFONO_HISTORY_SMS_STATUS_SUBMITTED; else hs = OFONO_HISTORY_SMS_STATUS_SUBMIT_FAILED; __ofono_history_sms_send_status(modem, entry->msg_id, time(NULL), hs); } if (entry->destroy) entry->destroy(entry->data); g_free(entry->pdus); g_free(entry); if (g_queue_peek_head(sms->txq)) { DBG("Scheduling next"); sms->tx_source = g_timeout_add(0, tx_next, sms); } }