示例#1
0
文件: sms.c 项目: AndriusA/ofono
static void sms_tx_queue_remove_entry(struct ofono_sms *sms, GList *entry_list,
					enum message_state tx_state)
{
	struct tx_queue_entry *entry = entry_list->data;
	struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom);

	g_queue_delete_link(sms->txq, entry_list);

	DBG("%p", entry);

	if (entry->cb)
		entry->cb(tx_state == MESSAGE_STATE_SENT, entry->data);

	if (entry->flags & OFONO_SMS_SUBMIT_FLAG_RECORD_HISTORY) {
		enum ofono_history_sms_status hs;

		switch(tx_state) {
		case MESSAGE_STATE_SENT:
			hs = OFONO_HISTORY_SMS_STATUS_SUBMITTED;
			break;
		case MESSAGE_STATE_FAILED:
			hs = OFONO_HISTORY_SMS_STATUS_SUBMIT_FAILED;
			break;
		case MESSAGE_STATE_CANCELLED:
			hs = OFONO_HISTORY_SMS_STATUS_SUBMIT_CANCELLED;
			break;
		default:
			ofono_error("Unexpected sms state %d", tx_state);
			goto done;
		}

		__ofono_history_sms_send_status(modem, &entry->uuid,
								time(NULL), hs);
	}

	if (entry->flags & OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS) {
		struct message *m;

		sms_tx_backup_free(sms->imsi, entry->id, entry->flags,
					ofono_uuid_to_str(&entry->uuid));

		m = g_hash_table_lookup(sms->messages, &entry->uuid);

		if (m != NULL) {
			message_set_state(m, tx_state);
			g_hash_table_remove(sms->messages, &entry->uuid);
			message_emit_removed(m,
					OFONO_MESSAGE_MANAGER_INTERFACE);
			message_dbus_unregister(m);
		}
	}

done:
	tx_queue_entry_destroy(entry);
}
示例#2
0
文件: sms.c 项目: AndriusA/ofono
static void handle_sms_status_report(struct ofono_sms *sms,
						const struct sms *incoming)
{
	struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom);
	gboolean delivered;
	struct ofono_uuid uuid;

	DBG("");

	if (status_report_assembly_report(sms->sr_assembly, incoming, uuid.uuid,
						&delivered) == FALSE)
		return;

	__ofono_history_sms_send_status(modem, &uuid, time(NULL),
			delivered ? OFONO_HISTORY_SMS_STATUS_DELIVERED :
			OFONO_HISTORY_SMS_STATUS_DELIVER_FAILED);
}
示例#3
0
文件: sms.c 项目: yongsu/oFono
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);
	}
}