summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/Makefile.am1
-rw-r--r--drivers/atmodem/atmodem.c313
-rw-r--r--drivers/atmodem/session.c276
-rw-r--r--drivers/atmodem/session.h28
4 files changed, 0 insertions, 618 deletions
diff --git a/drivers/Makefile.am b/drivers/Makefile.am
index 2a4fbde1..1e7db353 100644
--- a/drivers/Makefile.am
+++ b/drivers/Makefile.am
@@ -5,7 +5,6 @@ builtin_cflags =
builtin_modules += atmodem
builtin_sources += atmodem/atmodem.c atmodem/at.h \
- atmodem/session.h atmodem/session.c \
atmodem/call-settings.c atmodem/sms.c \
atmodem/call-forwarding.c atmodem/call-meter.c \
atmodem/network-registration.c atmodem/sim.c \
diff --git a/drivers/atmodem/atmodem.c b/drivers/atmodem/atmodem.c
index a8eb1dc7..c2324e5d 100644
--- a/drivers/atmodem/atmodem.c
+++ b/drivers/atmodem/atmodem.c
@@ -31,49 +31,8 @@
#include <ofono/plugin.h>
#include <ofono/log.h>
-#include <ofono/dbus.h>
#include <ofono/modem.h>
-#include <ofono/call-barring.h>
-#include <ofono/call-forwarding.h>
-#include <ofono/call-meter.h>
-#include <ofono/call-settings.h>
-#include <ofono/devinfo.h>
-#include <ofono/message-waiting.h>
-#include <ofono/netreg.h>
-#include <ofono/phonebook.h>
-#include <ofono/sim.h>
-#include <ofono/sms.h>
-#include <ofono/ssn.h>
-#include <ofono/ussd.h>
-#include <ofono/voicecall.h>
-
#include "at.h"
-#include "session.h"
-
-#define AT_MANAGER_INTERFACE "org.ofono.at.Manager"
-
-static GSList *g_sessions = NULL;
-static GSList *g_pending = NULL;
-
-DBusMessage *__ofono_error_invalid_args(DBusMessage *msg);
-DBusMessage *__ofono_error_invalid_format(DBusMessage *msg);
-DBusMessage *__ofono_error_failed(DBusMessage *msg);
-DBusMessage *__ofono_error_not_found(DBusMessage *msg);
-
-static void modem_list(const char ***modems)
-{
- GSList *l;
- int i;
- struct at_data *at;
-
- *modems = g_new0(const char *, g_slist_length(g_sessions) + 1);
-
- for (l = g_sessions, i = 0; l; l = l->next, i++) {
- at = l->data;
-
- (*modems)[i] = ofono_modem_get_path(at->modem);
- }
-}
void dump_response(const char *func, gboolean ok, GAtResult *result)
{
@@ -97,274 +56,8 @@ void decode_at_error(struct ofono_error *error, const char *final)
}
}
-static void at_destroy(struct at_data *at)
-{
- if (at->parser)
- g_at_chat_unref(at->parser);
-
- if (at->driver)
- g_free(at->driver);
-
- g_free(at);
-}
-
-static void manager_free(gpointer user)
-{
- GSList *l;
-
- for (l = g_pending; l; l = l->next)
- g_io_channel_unref(l->data);
-
- g_slist_free(g_pending);
-
- for (l = g_sessions; l; l = l->next) {
- struct at_data *at = l->data;
-
- ofono_modem_unregister(at->modem);
-
- at_destroy(at);
- }
-
- g_slist_free(g_sessions);
-}
-
-static void send_init_commands(const char *vendor, GAtChat *parser)
-{
- if (!strcmp(vendor, "ti_calypso")) {
- g_at_chat_set_wakeup_command(parser, "\r", 1000, 5000);
-
- g_at_chat_send(parser, "AT%CUNS=0", NULL, NULL, NULL, NULL);
- g_at_chat_send(parser, "AT+CFUN=1", NULL, NULL, NULL, NULL);
- }
-}
-
-static void msg_destroy(gpointer user)
-{
- DBusMessage *msg = user;
-
- dbus_message_unref(msg);
-}
-
-static void at_debug(const char *str, gpointer user)
-{
- ofono_debug("%s", str);
-}
-
-static void create_cb(GIOChannel *io, gboolean success, gpointer user)
-{
- DBusConnection *conn = ofono_dbus_get_connection();
- DBusMessage *msg = user;
- DBusMessage *reply;
- struct at_data *at = NULL;
- const char *path;
- const char *target, *driver;
- const char **modems;
- GAtSyntax *syntax;
- struct ofono_message_waiting *mw;
-
- g_pending = g_slist_remove(g_pending, io);
-
- if (success == FALSE)
- goto out;
-
- syntax = g_at_syntax_new_gsmv1();
-
- at = g_new0(struct at_data, 1);
-
- at->parser = g_at_chat_new(io, syntax);
- g_at_syntax_unref(syntax);
-
- if (at->parser == NULL)
- goto out;
-
- if (getenv("OFONO_AT_DEBUG") != NULL)
- g_at_chat_set_debug(at->parser, at_debug, NULL);
-
- ofono_debug("Seting up AT channel");
-
- dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &target,
- DBUS_TYPE_STRING, &driver, DBUS_TYPE_INVALID);
-
- send_init_commands(driver, at->parser);
-
- at->modem = ofono_modem_register();
-
- if (!at->modem)
- goto out;
-
- ofono_modem_set_data(at->modem, at);
-
- ofono_devinfo_create(at->modem, "generic_at", at->parser);
- ofono_ussd_create(at->modem, "generic_at", at->parser);
- ofono_sim_create(at->modem, "generic_at", at->parser);
- ofono_call_forwarding_create(at->modem, "generic_at", at->parser);
- ofono_call_settings_create(at->modem, "generic_at", at->parser);
- ofono_netreg_create(at->modem, "generic_at", at->parser);
- ofono_voicecall_create(at->modem, "generic_at", at->parser);
- ofono_call_meter_create(at->modem, "generic_at", at->parser);
- ofono_call_barring_create(at->modem, "generic_at", at->parser);
- ofono_ssn_create(at->modem, "generic_at", at->parser);
- ofono_sms_create(at->modem, "generic_at", at->parser);
- ofono_phonebook_create(at->modem, "generic_at", at->parser);
-
- mw = ofono_message_waiting_create(at->modem);
- if (mw)
- ofono_message_waiting_register(mw);
-
- at->io = io;
- at->driver = g_strdup(driver);
-
- g_pending = g_slist_remove(g_pending, io);
- g_sessions = g_slist_prepend(g_sessions, at);
-
- path = ofono_modem_get_path(at->modem);
-
- reply = dbus_message_new_method_return(msg);
-
- dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-
- g_dbus_send_message(conn, reply);
-
- modem_list(&modems);
- ofono_dbus_signal_array_property_changed(conn, "/", AT_MANAGER_INTERFACE,
- "Modems", DBUS_TYPE_OBJECT_PATH,
- &modems);
- g_free(modems);
-
- return;
-
-out:
- if (at)
- at_destroy(at);
-
- reply = __ofono_error_failed(msg);
- g_dbus_send_message(conn, reply);
-}
-
-static DBusMessage *manager_create(DBusConnection *conn, DBusMessage *msg,
- void *data)
-{
- const char *target;
- const char *driver;
- GIOChannel *io;
-
- if (!dbus_message_get_args(msg, NULL,
- DBUS_TYPE_STRING, &target,
- DBUS_TYPE_STRING, &driver,
- DBUS_TYPE_INVALID))
- return __ofono_error_invalid_args(msg);
-
- io = modem_session_create(target, create_cb, msg, msg_destroy);
-
- if (!io)
- return __ofono_error_invalid_format(msg);
-
- dbus_message_ref(msg);
-
- g_pending = g_slist_prepend(g_pending, io);
-
- return NULL;
-}
-
-static DBusMessage *manager_destroy(DBusConnection *conn, DBusMessage *msg,
- void *data)
-{
- const char *path;
- GSList *l;
-
- if (!dbus_message_get_args(msg, NULL,
- DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID))
- return __ofono_error_invalid_args(msg);
-
- for (l = g_sessions; l; l = l->next) {
- struct at_data *at = l->data;
- const char **modems;
-
- if (strcmp(ofono_modem_get_path(at->modem), path))
- continue;
-
- ofono_modem_unregister(at->modem);
-
- g_sessions = g_slist_remove(g_sessions, at);
- at_destroy(at);
-
- modem_list(&modems);
- ofono_dbus_signal_array_property_changed(conn, "/",
- AT_MANAGER_INTERFACE,
- "Modems", DBUS_TYPE_OBJECT_PATH,
- &modems);
- g_free(modems);
-
- return dbus_message_new_method_return(msg);
- }
-
- return __ofono_error_not_found(msg);
-}
-
-static DBusMessage *manager_get_properties(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- DBusMessageIter iter;
- DBusMessageIter dict;
- DBusMessage *reply;
- const char **modems;
-
- reply = dbus_message_new_method_return(msg);
-
- if (!reply)
- return NULL;
-
- modem_list(&modems);
-
- dbus_message_iter_init_append(reply, &iter);
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- OFONO_PROPERTIES_ARRAY_SIGNATURE,
- &dict);
-
- ofono_dbus_dict_append_array(&dict, "Modems", DBUS_TYPE_OBJECT_PATH,
- &modems);
-
- g_free(modems);
-
- dbus_message_iter_close_container(&iter, &dict);
-
- return reply;
-}
-
-static GDBusMethodTable manager_methods[] = {
- { "Create", "ss", "o", manager_create,
- G_DBUS_METHOD_FLAG_ASYNC },
- { "Destroy", "o", "", manager_destroy },
- { "GetProperties", "", "a{sv}", manager_get_properties },
- { }
-};
-
-static GDBusSignalTable manager_signals[] = {
- { "PropertyChanged", "sv" },
- { }
-};
-
-static int manager_init(DBusConnection *conn)
-{
- if (g_dbus_register_interface(conn, "/", AT_MANAGER_INTERFACE,
- manager_methods, manager_signals,
- NULL, NULL, manager_free) == FALSE)
- return -1;
-
- return 0;
-}
-
-static void manager_exit(DBusConnection *conn)
-{
- g_dbus_unregister_interface(conn, "/", AT_MANAGER_INTERFACE);
-}
-
static int atmodem_init(void)
{
- DBusConnection *conn = ofono_dbus_get_connection();
-
at_voicecall_init();
at_devinfo_init();
at_call_barring_init();
@@ -378,17 +71,11 @@ static int atmodem_init(void)
at_sim_init();
at_netreg_init();
- manager_init(conn);
-
return 0;
}
static void atmodem_exit(void)
{
- DBusConnection *conn = ofono_dbus_get_connection();
-
- manager_exit(conn);
-
at_sim_exit();
at_sms_exit();
at_ussd_exit();
diff --git a/drivers/atmodem/session.c b/drivers/atmodem/session.c
deleted file mode 100644
index 3a9e49b0..00000000
--- a/drivers/atmodem/session.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- *
- * oFono - Open Source Telephony
- *
- * Copyright (C) 2008-2009 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <termios.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#include <glib.h>
-
-#include <ofono/log.h>
-
-#include "session.h"
-
-struct modem_session_callback {
- modem_session_callback_t callback;
- gpointer user_data;
- GDestroyNotify notify;
- guint timeout_watcher;
- GIOChannel *io;
-};
-
-static void connect_destroy(gpointer user)
-{
- struct modem_session_callback *callback = user;
-
- if (callback->notify)
- callback->notify(callback->user_data);
-
- if (callback->timeout_watcher != 0)
- g_source_remove(callback->timeout_watcher);
-
- g_free(callback);
-}
-
-static gboolean connect_cb(GIOChannel *io, GIOCondition cond, gpointer user)
-{
- struct modem_session_callback *callback = user;
- int err = 0;
- gboolean success;
-
- if (cond & G_IO_NVAL)
- return FALSE;
-
- if (cond & G_IO_OUT) {
- int sock = g_io_channel_unix_get_fd(io);
- socklen_t len = sizeof(err);
-
- if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &err, &len) < 0)
- err = errno == ENOTSOCK ? 0 : errno;
- } else if (cond & (G_IO_HUP | G_IO_ERR))
- err = ECONNRESET;
-
- success = !err;
-
- callback->callback(io, success, callback->user_data);
-
- return FALSE;
-}
-
-static gboolean connect_timeout(gpointer user)
-{
- struct modem_session_callback *callback = user;
-
- callback->callback(callback->io, FALSE, callback->user_data);
-
- callback->timeout_watcher = 0;
-
- g_io_channel_unref(callback->io);
-
- return FALSE;
-}
-
-static GIOChannel *tty_connect(const char *tty)
-{
- GIOChannel *io;
- int sk;
- struct termios newtio;
-
- sk = open(tty, O_RDWR | O_NOCTTY);
-
- if (sk < 0) {
- ofono_error("Can't open TTY %s: %s(%d)",
- tty, strerror(errno), errno);
- return NULL;
- }
-
- newtio.c_cflag = B115200 | CRTSCTS | CLOCAL | CREAD;
- newtio.c_iflag = IGNPAR;
- newtio.c_oflag = 0;
- newtio.c_lflag = 0;
-
- newtio.c_cc[VTIME] = 1;
- newtio.c_cc[VMIN] = 5;
-
- tcflush(sk, TCIFLUSH);
- if (tcsetattr(sk, TCSANOW, &newtio) < 0) {
- ofono_error("Can't change serial settings: %s(%d)",
- strerror(errno), errno);
- close(sk);
- return NULL;
- }
-
- io = g_io_channel_unix_new(sk);
- g_io_channel_set_close_on_unref(io, TRUE);
-
- if (g_io_channel_set_flags(io, G_IO_FLAG_NONBLOCK,
- NULL) != G_IO_STATUS_NORMAL) {
- g_io_channel_unref(io);
- return NULL;
- }
-
- return io;
-}
-
-static GIOChannel *socket_common(int sk, struct sockaddr *addr,
- socklen_t addrlen)
-{
- GIOChannel *io = g_io_channel_unix_new(sk);
-
- if (io == NULL) {
- close(sk);
- return NULL;
- }
-
- g_io_channel_set_close_on_unref(io, TRUE);
-
- if (g_io_channel_set_flags(io, G_IO_FLAG_NONBLOCK,
- NULL) != G_IO_STATUS_NORMAL) {
- g_io_channel_unref(io);
- return NULL;
- }
-
- if (connect(sk, addr, addrlen) < 0) {
- if (errno != EAGAIN && errno != EINPROGRESS) {
- g_io_channel_unref(io);
- return NULL;
- }
- }
-
- return io;
-}
-
-static GIOChannel *unix_connect(const char *address)
-{
- struct sockaddr_un addr;
- int sk;
-
- memset(&addr, 0, sizeof(addr));
- addr.sun_family = PF_UNIX;
-
- if (strncmp("x00", address, 3) == 0)
- strcpy(addr.sun_path + 1, address + 3);
- else
- strcpy(addr.sun_path, address);
-
- sk = socket(AF_UNIX, SOCK_STREAM, 0);
-
- if (sk < 0)
- return NULL;
-
- return socket_common(sk, (struct sockaddr *)&addr, sizeof(addr));
-}
-
-static GIOChannel *tcp_connect(const char *address)
-{
- struct sockaddr_in addr;
- int sk;
- unsigned short port;
- in_addr_t inetaddr;
- char *portstr;
- char addrstr[16];
-
- memset(&addr, 0, sizeof(addr));
-
- portstr = strchr(address, ':');
-
- if (!portstr || (unsigned int)(portstr-address) > (sizeof(addrstr) - 1))
- return NULL;
-
- strncpy(addrstr, address, portstr-address);
- addrstr[portstr-address] = '\0';
-
- portstr += 1;
-
- port = atoi(portstr);
-
- if (port == 0)
- return NULL;
-
- inetaddr = inet_addr(addrstr);
-
- if (inetaddr == INADDR_NONE)
- return NULL;
-
- sk = socket(PF_INET, SOCK_STREAM, 0);
-
- if (sk < 0)
- return NULL;
-
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = inetaddr;
- addr.sin_port = htons(port);
-
- return socket_common(sk, (struct sockaddr *) &addr, sizeof(addr));
-}
-
-GIOChannel *modem_session_create(const char *target,
- modem_session_callback_t func,
- gpointer user_data,
- GDestroyNotify notify)
-{
- struct modem_session_callback *callback;
- GIOChannel *io = NULL;
- GIOCondition cond;
-
- if (target == NULL || func == NULL)
- return NULL;
-
- if (!strncasecmp(target, "tcp:", 4))
- io = tcp_connect(target+4);
- else if (!strncasecmp(target, "unix:", 5))
- io = unix_connect(target+5);
- else if (!strncasecmp(target, "dev:", 4))
- io = tty_connect(target+4);
-
- if (io == NULL)
- return NULL;
-
- callback = g_new0(struct modem_session_callback, 1);
-
- callback->callback = func;
- callback->user_data = user_data;
- callback->notify = notify;
- callback->io = io;
- callback->timeout_watcher = g_timeout_add_seconds(20, connect_timeout,
- callback);
-
- cond = G_IO_OUT | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
- g_io_add_watch_full(io, G_PRIORITY_DEFAULT, cond, connect_cb,
- callback, connect_destroy);
-
- g_io_channel_unref(io);
-
- return io;
-}
diff --git a/drivers/atmodem/session.h b/drivers/atmodem/session.h
deleted file mode 100644
index 2e3e305e..00000000
--- a/drivers/atmodem/session.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * oFono - Open Source Telephony
- *
- * Copyright (C) 2008-2009 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-typedef void (*modem_session_callback_t)(GIOChannel *io, gboolean success,
- gpointer user_data);
-
-GIOChannel *modem_session_create(const char *target,
- modem_session_callback_t func,
- gpointer user_data,
- GDestroyNotify notify);