diff options
author | Martin Xu <martin.xu@intel.com> | 2010-01-22 13:30:47 +0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-01-23 10:45:48 +0100 |
commit | 88d5a1eeb0389c65c06c41fb4dc11bcd70dfc6a2 (patch) | |
tree | b3048c458a61cfbbddcce197451e1cc9ee8d5cf9 /plugins | |
parent | 02dc82ffa4bf38a0bf33b33f4832bd50d13d6124 (diff) | |
download | connman-88d5a1eeb0389c65c06c41fb4dc11bcd70dfc6a2.tar.gz connman-88d5a1eeb0389c65c06c41fb4dc11bcd70dfc6a2.tar.bz2 connman-88d5a1eeb0389c65c06c41fb4dc11bcd70dfc6a2.zip |
Set APN before connecting via oFono plugin
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ofono.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/plugins/ofono.c b/plugins/ofono.c index a35ae3fd..4e92aa98 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -417,11 +417,77 @@ static int set_network_active(struct connman_network *network, return 0; } +static void set_apn_reply(DBusPendingCall *call, void *user_data) +{ + DBusMessage *reply; + DBusError error; + + reply = dbus_pending_call_steal_reply(call); + + dbus_error_init(&error); + if (dbus_set_error_from_message(&error, reply)) { + connman_error("%s", error.message); + + dbus_error_free(&error); + } + + dbus_message_unref(reply); + + dbus_pending_call_unref(call); +} + +static void set_apn(struct connman_network *network) +{ + DBusMessage *message; + DBusPendingCall *call; + DBusMessageIter iter; + const char *apn, *path; + + apn = connman_network_get_string(network, "Cellular.APN"); + if (apn == NULL) + return; + + path = connman_network_get_string(network, "Path"); + if (path == NULL) + return; + + DBG("path %s, apn %s", path, apn); + + message = dbus_message_new_method_call(OFONO_SERVICE, path, + OFONO_PRI_CONTEXT_INTERFACE, SET_PROPERTY); + if (message == NULL) + return; + + dbus_message_set_auto_start(message, FALSE); + + dbus_message_iter_init_append(message, &iter); + connman_dbus_property_append_basic(&iter, "AccessPointName", + DBUS_TYPE_STRING, &apn); + + if (dbus_connection_send_with_reply(connection, message, + &call, TIMEOUT) == FALSE) { + dbus_message_unref(message); + return; + } + + if (call == NULL) { + connman_error("D-Bus connection not available"); + dbus_message_unref(message); + return; + } + + dbus_pending_call_set_notify(call, set_apn_reply, NULL, NULL); + + dbus_message_unref(message); +} + static int network_connect(struct connman_network *network) { if (connman_network_get_index(network) >= 0) return -EISCONN; + set_apn(network); + return set_network_active(network, TRUE); } |