stkagent: Add ConfirmOpenChannel method
authorPhilippe Nunes <philippe.nunes@linux.intel.com>
Fri, 8 Apr 2011 16:33:26 +0000 (18:33 +0200)
committerDenis Kenzior <denkenz@gmail.com>
Tue, 12 Apr 2011 04:16:56 +0000 (23:16 -0500)
src/stkagent.c
src/stkagent.h

index 220812e..1a4bdd8 100644 (file)
@@ -1145,3 +1145,70 @@ int stk_agent_display_action(struct stk_agent *agent,
 
        return 0;
 }
+
+static void confirm_open_channel_cb(DBusPendingCall *call, void *data)
+{
+       struct stk_agent *agent = data;
+       stk_agent_confirmation_cb cb = agent->user_cb;
+       DBusMessage *reply = dbus_pending_call_steal_reply(call);
+       enum stk_agent_result result;
+       gboolean remove_agent;
+       dbus_bool_t confirm;
+
+       if (check_error(agent, reply,
+                       ALLOWED_ERROR_TERMINATE, &result) == -EINVAL) {
+               remove_agent = TRUE;
+               goto error;
+       }
+
+       if (result != STK_AGENT_RESULT_OK) {
+               cb(result, FALSE, agent->user_data);
+               goto done;
+       }
+
+       if (dbus_message_get_args(reply, NULL,
+                                       DBUS_TYPE_BOOLEAN, &confirm,
+                                       DBUS_TYPE_INVALID) == FALSE) {
+               ofono_error("Can't parse the reply to ConfirmOpenChannel()");
+               remove_agent = TRUE;
+               goto error;
+       }
+
+       cb(result, confirm, agent->user_data);
+
+       CALLBACK_END();
+}
+
+int stk_agent_confirm_open_channel(struct stk_agent *agent, const char *text,
+                                       const struct stk_icon_id *icon,
+                                       stk_agent_confirmation_cb cb,
+                                       void *user_data,
+                                       ofono_destroy_func destroy, int timeout)
+{
+       DBusConnection *conn = ofono_dbus_get_connection();
+
+       agent->msg = dbus_message_new_method_call(agent->bus, agent->path,
+                                                       OFONO_SIM_APP_INTERFACE,
+                                                       "ConfirmOpenChannel");
+       if (agent->msg == NULL)
+               return -ENOMEM;
+
+       dbus_message_append_args(agent->msg,
+                                       DBUS_TYPE_STRING, &text,
+                                       DBUS_TYPE_BYTE, &icon->id,
+                                       DBUS_TYPE_INVALID);
+
+       if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call,
+                                               timeout) == FALSE ||
+                                               agent->call == NULL)
+               return -EIO;
+
+       agent->user_cb = cb;
+       agent->user_data = user_data;
+       agent->user_destroy = destroy;
+
+       dbus_pending_call_set_notify(agent->call, confirm_open_channel_cb,
+                                       agent, NULL);
+
+       return 0;
+}
index 4b5d0a6..5e81485 100644 (file)
@@ -156,3 +156,10 @@ int stk_agent_display_action(struct stk_agent *agent, const char *text,
                                        stk_agent_display_action_cb cb,
                                        void *user_data,
                                        ofono_destroy_func destroy);
+
+int stk_agent_confirm_open_channel(struct stk_agent *agent, const char *text,
+                                       const struct stk_icon_id *icon,
+                                       stk_agent_confirmation_cb cb,
+                                       void *user_data,
+                                       ofono_destroy_func destroy,
+                                       int timeout);