summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrzej Zaborowski <andrew.zaborowski@intel.com>2010-05-16 16:05:04 +0200
committerDenis Kenzior <denkenz@gmail.com>2010-05-25 16:52:52 -0500
commiteacb4395fc274f8c1bceb04abdf27904514ff5a4 (patch)
treeffc9ae8b5d5a005990616557bb893355a60fa4bb /src
parent60cab4354c9f730c09ee5ad4ef39e40c987248d8 (diff)
downloadofono-eacb4395fc274f8c1bceb04abdf27904514ff5a4.tar.bz2
stkutil: Add Get Inkey response builder
Diffstat (limited to 'src')
-rw-r--r--src/stkutil.c87
-rw-r--r--src/stkutil.h16
2 files changed, 102 insertions, 1 deletions
diff --git a/src/stkutil.c b/src/stkutil.c
index 78ebda3d..0535b623 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -36,7 +36,8 @@
enum stk_data_object_flag {
DATAOBJ_FLAG_MANDATORY = 1,
- DATAOBJ_FLAG_MINIMUM = 2
+ DATAOBJ_FLAG_MINIMUM = 2,
+ DATAOBJ_FLAG_CR = 4
};
struct stk_file_iter {
@@ -3035,6 +3036,23 @@ static inline gboolean stk_tlv_append_bytes(struct stk_tlv_builder *iter,
return TRUE;
}
+/* Described in TS 102.223 Section 8.8 */
+static gboolean build_dataobj_duration(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_duration *duration = data;
+
+ if (duration->interval == 0x00)
+ return TRUE;
+
+ return stk_tlv_open_container(tlv, cr,
+ STK_DATA_OBJECT_TYPE_DURATION, FALSE) &&
+ stk_tlv_append_byte(tlv, duration->unit) &&
+ stk_tlv_append_byte(tlv, duration->interval) &&
+ stk_tlv_close_container(tlv);
+}
+
+/* Described in TS 102.223 Section 8.12 */
static gboolean build_dataobj_result(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
{
@@ -3056,6 +3074,65 @@ static gboolean build_dataobj_result(struct stk_tlv_builder *tlv,
return FALSE;
}
+/* Defined in TS 102.223 Section 8.15 */
+static gboolean build_dataobj_text(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_answer_text *text = data;
+
+ if (!text->text && !text->yesno)
+ return TRUE;
+
+ if (stk_tlv_open_container(tlv, cr, STK_DATA_OBJECT_TYPE_TEXT,
+ TRUE) != TRUE)
+ return FALSE;
+
+ if (text->yesno == TRUE) {
+ /* Section 6.8.5:
+ * When the terminal issues [...] command qualifier set
+ * to "Yes/No", it shall supply the value "01" when the
+ * answer is "positive" and the value '00' when the
+ * answer is "negative" in the text string data object.
+ */
+ if (stk_tlv_append_byte(tlv, 0x04) != TRUE)
+ return FALSE;
+ if (stk_tlv_append_byte(tlv, text->text ? 0x01 : 0x00) != TRUE)
+ return FALSE;
+ } else if (text->packed) {
+ if (stk_tlv_append_text(tlv, 0x00, text->text) != TRUE)
+ return FALSE;
+ } else {
+ if (stk_tlv_append_text(tlv, -1, text->text) != TRUE)
+ return FALSE;
+ }
+
+ return stk_tlv_close_container(tlv);
+}
+
+static gboolean build_dataobj(struct stk_tlv_builder *tlv, gboolean
+ (*builder_func)(struct stk_tlv_builder *,
+ const void *, gboolean), ...)
+{
+ va_list args;
+
+ va_start(args, builder_func);
+
+ while (builder_func) {
+ unsigned int flags = va_arg(args, enum stk_data_object_flag);
+ const void *data = va_arg(args, const void *);
+ gboolean cr = (flags & DATAOBJ_FLAG_CR) ? TRUE : FALSE;
+
+ if (builder_func(tlv, data, cr) != TRUE)
+ return FALSE;
+
+ builder_func = va_arg(args, gboolean (*)(
+ struct stk_tlv_builder *,
+ const void *, gboolean));
+ }
+
+ return TRUE;
+}
+
unsigned int stk_pdu_from_response(const struct stk_response *response,
unsigned char *pdu, unsigned int size)
{
@@ -3115,6 +3192,14 @@ unsigned int stk_pdu_from_response(const struct stk_response *response,
switch (response->type) {
case STK_COMMAND_TYPE_DISPLAY_TEXT:
break;
+ case STK_COMMAND_TYPE_GET_INKEY:
+ ok = build_dataobj(&builder,
+ build_dataobj_text, DATAOBJ_FLAG_CR,
+ &response->get_inkey.text,
+ build_dataobj_duration, 0,
+ &response->get_inkey.duration,
+ NULL);
+ break;
default:
return 0;
};
diff --git a/src/stkutil.h b/src/stkutil.h
index 382ef0cc..9603dd75 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -995,6 +995,21 @@ struct stk_command {
struct stk_response_generic {
};
+struct stk_answer_text {
+ char *text;
+ ofono_bool_t packed;
+ ofono_bool_t yesno;
+ /* If a "Yes/No" answer was requested in a GET INKEY command,
+ * .yesno must be TRUE and text should be non-NULL to indicate
+ * a Yes response or NULL to indicate a No response.
+ */
+};
+
+struct stk_response_get_inkey {
+ struct stk_answer_text text;
+ struct stk_duration duration;
+};
+
struct stk_response {
unsigned char number;
unsigned char type;
@@ -1005,6 +1020,7 @@ struct stk_response {
union {
struct stk_response_generic display_text;
+ struct stk_response_get_inkey get_inkey;
};
void (*destructor)(struct stk_response *response);