Exemple #1
0
static gboolean handle_command_send_sms(const struct stk_command *cmd,
					struct stk_response *rsp,
					struct ofono_stk *stk)
{
	struct ofono_modem *modem = __ofono_atom_get_modem(stk->atom);
	struct ofono_atom *sms_atom;
	struct ofono_sms *sms;
	GSList msg_list;

	sms_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SMS);

	if (!sms_atom || !__ofono_atom_get_registered(sms_atom)) {
		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
		return TRUE;
	}

	sms = __ofono_atom_get_data(sms_atom);

	stk->sms_submit_req = g_new0(struct sms_submit_req, 1);
	stk->sms_submit_req->stk = stk;

	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);

	stk->cancel_cmd = send_sms_cancel;

	if (cmd->send_sms.alpha_id && cmd->send_sms.alpha_id[0])
		stk_alpha_id_set(stk, cmd->send_sms.alpha_id);

	return FALSE;
}
Exemple #2
0
/*
 * Pre-process a SMS text message and deliver it [D-Bus SendMessage()]
 *
 * @conn: D-Bus connection
 * @msg: message data (telephone number and text)
 * @data: SMS object to use for transmision
 *
 * An alphabet is chosen for the text and it (might be) segmented in
 * fragments by sms_text_prepare() into @msg_list. A queue list @entry
 * is created by tx_queue_entry_new() and g_queue_push_tail()
 * appends that entry to the SMS transmit queue. Then the tx_next()
 * function is scheduled to run to process the queue.
 */
static DBusMessage *sms_send_message(DBusConnection *conn, DBusMessage *msg,
					void *data)
{
	struct ofono_sms *sms = data;
	const char *to;
	const char *text;
	GSList *msg_list;
	struct ofono_modem *modem;
	unsigned int flags;
	gboolean use_16bit_ref = FALSE;
	int err;
	struct ofono_uuid uuid;

	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &to,
					DBUS_TYPE_STRING, &text,
					DBUS_TYPE_INVALID))
		return __ofono_error_invalid_args(msg);

	if (valid_phone_number_format(to) == FALSE)
		return __ofono_error_invalid_format(msg);

	msg_list = sms_text_prepare_with_alphabet(to, text, sms->ref,
						use_16bit_ref,
						sms->use_delivery_reports,
						sms->alphabet);

	if (msg_list == NULL)
		return __ofono_error_invalid_format(msg);

	flags = OFONO_SMS_SUBMIT_FLAG_RECORD_HISTORY;
	flags |= OFONO_SMS_SUBMIT_FLAG_RETRY;
	flags |= OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS;
	if (sms->use_delivery_reports)
		flags |= OFONO_SMS_SUBMIT_FLAG_REQUEST_SR;

	err = __ofono_sms_txq_submit(sms, msg_list, flags, &uuid,
					message_queued, msg);

	g_slist_foreach(msg_list, (GFunc) g_free, NULL);
	g_slist_free(msg_list);

	if (err < 0)
		return __ofono_error_failed(msg);

	modem = __ofono_atom_get_modem(sms->atom);
	__ofono_history_sms_send_pending(modem, &uuid, to, time(NULL), text);

	return NULL;
}