~morphis/phablet-extras/ofono-sms-status-report

« back to all changes in this revision

Viewing changes to src/stkagent.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-08-22 19:59:08 UTC
  • mfrom: (1.3.3) (6.1.5 experimental)
  • Revision ID: package-import@ubuntu.com-20120822195908-0bmmk1hlh989bgk6
Tags: 1.9-1ubuntu1
* Merge with Debian experimental; remaining changes:
  - debian/control: explicitly Conflicts with modemmanager: having both
    installed / running at the same time causes issues causes issues with
    both claiming modem devices.
  - debian/patches/02-dont-handle-stacktraces.patch: stop catching stacktraces
    and printing the information internally, so apport can catch and report
    the possible bugs.
  - debian/ofono.postinst: on configure, notify the user that a reboot is
    required (so ofono can get started by upstart). (LP: #600501)
  - debian/rules: pass --no-restart-on-upgrade so ofono isn't automatically
    restarted when upgrades.
  - Adding upstart config / Removing standard init script
  - Adding Apport support
  - Patch for recognizing special Huawei devices with weird serial
  - Override lintian to avoid script-in-etc-init.d... warnings.
  - Update debian/compat to 7
* debian/series: add our patches to debian/patches/series now that the package
  uses quilt.
* debian/patches/02-dont-handle-stacktraces.patch: refreshed.
* debian/ofono-dev.install, debian/ofono.install:
  - Install usr/sbin/dundee and ofono.pc to the proper packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *
3
3
 *  oFono - Open Source Telephony
4
4
 *
5
 
 *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
 
5
 *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
6
6
 *
7
7
 *  This program is free software; you can redistribute it and/or modify
8
8
 *  it under the terms of the GNU General Public License version 2 as
38
38
#include "stkutil.h"
39
39
#include "stkagent.h"
40
40
 
 
41
#ifndef DBUS_TIMEOUT_INFINITE
 
42
#define DBUS_TIMEOUT_INFINITE ((int) 0x7fffffff)
 
43
#endif
 
44
 
41
45
enum allowed_error {
42
46
        ALLOWED_ERROR_GO_BACK   = 0x1,
43
47
        ALLOWED_ERROR_TERMINATE = 0x2,
1005
1009
                                        DBUS_TYPE_INVALID);
1006
1010
 
1007
1011
        if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call,
1008
 
                                                0) == FALSE ||
 
1012
                                        DBUS_TIMEOUT_INFINITE) == FALSE ||
1009
1013
                        agent->call == NULL)
1010
1014
                return -EIO;
1011
1015
 
1061
1065
        if (agent->msg == NULL)
1062
1066
                return -ENOMEM;
1063
1067
 
 
1068
        if (url == NULL)
 
1069
                url = "";
 
1070
 
1064
1071
        dbus_message_append_args(agent->msg,
1065
1072
                                        DBUS_TYPE_STRING, &text,
1066
1073
                                        DBUS_TYPE_BYTE, &icon_id,
1081
1088
 
1082
1089
        return 0;
1083
1090
}
 
1091
 
 
1092
static void display_action_cb(DBusPendingCall *call, void *data)
 
1093
{
 
1094
        struct stk_agent *agent = data;
 
1095
        stk_agent_display_action_cb cb = agent->user_cb;
 
1096
        DBusMessage *reply = dbus_pending_call_steal_reply(call);
 
1097
        enum stk_agent_result result;
 
1098
        gboolean remove_agent;
 
1099
 
 
1100
        if (check_error(agent, reply,
 
1101
                        ALLOWED_ERROR_TERMINATE, &result) == -EINVAL) {
 
1102
                remove_agent = TRUE;
 
1103
                goto error;
 
1104
        }
 
1105
 
 
1106
        if (dbus_message_get_args(reply, NULL, DBUS_TYPE_INVALID) == FALSE) {
 
1107
                ofono_error("Can't parse the reply to DisplayAction()");
 
1108
                remove_agent = TRUE;
 
1109
                goto error;
 
1110
        }
 
1111
 
 
1112
        cb(result, agent->user_data);
 
1113
        goto done;
 
1114
 
 
1115
        CALLBACK_END();
 
1116
}
 
1117
 
 
1118
int stk_agent_display_action(struct stk_agent *agent,
 
1119
                                        const char *text,
 
1120
                                        const struct stk_icon_id *icon,
 
1121
                                        stk_agent_display_action_cb cb,
 
1122
                                        void *user_data,
 
1123
                                        ofono_destroy_func destroy)
 
1124
{
 
1125
        DBusConnection *conn = ofono_dbus_get_connection();
 
1126
 
 
1127
        agent->msg = dbus_message_new_method_call(agent->bus, agent->path,
 
1128
                                                OFONO_SIM_APP_INTERFACE,
 
1129
                                                "DisplayAction");
 
1130
        if (agent->msg == NULL)
 
1131
                return -ENOMEM;
 
1132
 
 
1133
        dbus_message_append_args(agent->msg,
 
1134
                                        DBUS_TYPE_STRING, &text,
 
1135
                                        DBUS_TYPE_BYTE, &icon->id,
 
1136
                                        DBUS_TYPE_INVALID);
 
1137
 
 
1138
        if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call,
 
1139
                                        DBUS_TIMEOUT_INFINITE) == FALSE ||
 
1140
                        agent->call == NULL)
 
1141
                return -EIO;
 
1142
 
 
1143
        agent->user_cb = cb;
 
1144
        agent->user_data = user_data;
 
1145
        agent->user_destroy = destroy;
 
1146
 
 
1147
        dbus_pending_call_set_notify(agent->call, display_action_cb,
 
1148
                                        agent, NULL);
 
1149
 
 
1150
        return 0;
 
1151
}
 
1152
 
 
1153
static void confirm_open_channel_cb(DBusPendingCall *call, void *data)
 
1154
{
 
1155
        struct stk_agent *agent = data;
 
1156
        stk_agent_confirmation_cb cb = agent->user_cb;
 
1157
        DBusMessage *reply = dbus_pending_call_steal_reply(call);
 
1158
        enum stk_agent_result result;
 
1159
        gboolean remove_agent;
 
1160
        dbus_bool_t confirm;
 
1161
 
 
1162
        if (check_error(agent, reply,
 
1163
                        ALLOWED_ERROR_TERMINATE, &result) == -EINVAL) {
 
1164
                remove_agent = TRUE;
 
1165
                goto error;
 
1166
        }
 
1167
 
 
1168
        if (result != STK_AGENT_RESULT_OK) {
 
1169
                cb(result, FALSE, agent->user_data);
 
1170
                goto done;
 
1171
        }
 
1172
 
 
1173
        if (dbus_message_get_args(reply, NULL,
 
1174
                                        DBUS_TYPE_BOOLEAN, &confirm,
 
1175
                                        DBUS_TYPE_INVALID) == FALSE) {
 
1176
                ofono_error("Can't parse the reply to ConfirmOpenChannel()");
 
1177
                remove_agent = TRUE;
 
1178
                goto error;
 
1179
        }
 
1180
 
 
1181
        cb(result, confirm, agent->user_data);
 
1182
 
 
1183
        CALLBACK_END();
 
1184
}
 
1185
 
 
1186
int stk_agent_confirm_open_channel(struct stk_agent *agent, const char *text,
 
1187
                                        const struct stk_icon_id *icon,
 
1188
                                        stk_agent_confirmation_cb cb,
 
1189
                                        void *user_data,
 
1190
                                        ofono_destroy_func destroy, int timeout)
 
1191
{
 
1192
        DBusConnection *conn = ofono_dbus_get_connection();
 
1193
 
 
1194
        agent->msg = dbus_message_new_method_call(agent->bus, agent->path,
 
1195
                                                        OFONO_SIM_APP_INTERFACE,
 
1196
                                                        "ConfirmOpenChannel");
 
1197
        if (agent->msg == NULL)
 
1198
                return -ENOMEM;
 
1199
 
 
1200
        dbus_message_append_args(agent->msg,
 
1201
                                        DBUS_TYPE_STRING, &text,
 
1202
                                        DBUS_TYPE_BYTE, &icon->id,
 
1203
                                        DBUS_TYPE_INVALID);
 
1204
 
 
1205
        if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call,
 
1206
                                                timeout) == FALSE ||
 
1207
                                                agent->call == NULL)
 
1208
                return -EIO;
 
1209
 
 
1210
        agent->user_cb = cb;
 
1211
        agent->user_data = user_data;
 
1212
        agent->user_destroy = destroy;
 
1213
 
 
1214
        dbus_pending_call_set_notify(agent->call, confirm_open_channel_cb,
 
1215
                                        agent, NULL);
 
1216
 
 
1217
        return 0;
 
1218
}