#include "ofono.h"
+#include "common.h"
#include "smsutil.h"
#include "stkutil.h"
void (*cancel_cmd)(struct ofono_stk *stk);
gboolean cancelled;
GQueue *envelope_q;
+
+ struct sms_submit_req *sms_submit_req;
};
struct envelope_op {
const unsigned char *data, int length);
};
+struct sms_submit_req {
+ struct ofono_stk *stk;
+ gboolean cancelled;
+};
+
#define ENVELOPE_RETRIES_DEFAULT 5
static void envelope_queue_run(struct ofono_stk *stk);
DBG("TERMINAL RESPONSE to a command reported no errors");
}
+static void stk_alpha_id_set(struct ofono_stk *stk, const char *text)
+{
+ /* TODO */
+}
+
+static void stk_alpha_id_unset(struct ofono_stk *stk)
+{
+ /* TODO */
+}
+
static gboolean handle_command_more_time(const struct stk_command *cmd,
struct stk_response *rsp,
struct ofono_stk *stk)
return TRUE;
}
+static void send_sms_cancel(struct ofono_stk *stk)
+{
+ stk->sms_submit_req->cancelled = TRUE;
+
+ if (!stk->pending_cmd->send_sms.alpha_id ||
+ !stk->pending_cmd->send_sms.alpha_id[0])
+ return;
+
+ stk_alpha_id_unset(stk);
+}
+
+static void send_sms_submit_cb(const struct ofono_error *error, int mr,
+ void *data)
+{
+ struct stk_response rsp;
+ struct sms_submit_req *req = data;
+ struct ofono_stk *stk = req->stk;
+ struct ofono_error failure = { .type = OFONO_ERROR_TYPE_FAILURE };
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
+ ofono_debug("SMS submission returned errors: %s",
+ telephony_error_to_str(error));
+ else
+ ofono_debug("SMS submission successful");
+
+ if (req->cancelled) {
+ ofono_debug("Received an SMS submitted callback after the "
+ "proactive command was cancelled");
+ goto out;
+ }
+
+ memset(&rsp, 0, sizeof(rsp));
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
+ rsp.result.type = STK_RESULT_TYPE_NETWORK_UNAVAILABLE;
+
+ if (stk_respond(stk, &rsp, stk_command_cb))
+ stk_command_cb(&failure, stk);
+
+ if (!stk->pending_cmd->send_sms.alpha_id ||
+ !stk->pending_cmd->send_sms.alpha_id[0])
+ goto out;
+
+ stk_alpha_id_unset(stk);
+
+out:
+ g_free(req);
+}
+
+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;
+
+ 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;
+
+ __ofono_sms_submit(sms, &cmd->send_sms.gsm_sms,
+ send_sms_submit_cb, stk->sms_submit_req);
+
+ stk->cancel_cmd = send_sms_cancel;
+
+ if (!cmd->send_sms.alpha_id || !cmd->send_sms.alpha_id[0])
+ return FALSE;
+
+ stk_alpha_id_set(stk, cmd->send_sms.alpha_id);
+
+ return FALSE;
+}
+
static void stk_proactive_command_cancel(struct ofono_stk *stk)
{
if (!stk->pending_cmd)
respond = handle_command_more_time(stk->pending_cmd,
&rsp, stk);
break;
+ case STK_COMMAND_TYPE_SEND_SMS:
+ respond = handle_command_send_sms(stk->pending_cmd,
+ &rsp, stk);
+ break;
}
if (respond)