--- /dev/null
+/*\r
+ *\r
+ * oFono - Open Source Telephony\r
+ *\r
+ * Copyright (C) 2008-2009 Intel Corporation. All rights reserved.\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License version 2 as\r
+ * published by the Free Software Foundation.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\r
+ *\r
+ */\r
+\r
+#ifdef HAVE_CONFIG_H\r
+#include <config.h>\r
+#endif\r
+\r
+#include <errno.h>\r
+#include <unistd.h>\r
+#include <string.h>\r
+#include <sys/socket.h>\r
+#include <netinet/in.h>\r
+#include <arpa/inet.h>\r
+\r
+#include <glib.h>\r
+#include <gatchat.h>\r
+\r
+#define OFONO_API_SUBJECT_TO_CHANGE\r
+#include <ofono/plugin.h>\r
+#include <ofono/log.h>\r
+#include <ofono/modem.h>\r
+#include <ofono/call-barring.h>\r
+#include <ofono/call-forwarding.h>\r
+#include <ofono/call-meter.h>\r
+#include <ofono/call-settings.h>\r
+#include <ofono/devinfo.h>\r
+#include <ofono/message-waiting.h>\r
+#include <ofono/netreg.h>\r
+#include <ofono/phonebook.h>\r
+#include <ofono/sim.h>\r
+#include <ofono/sms.h>\r
+#include <ofono/ssn.h>\r
+#include <ofono/ussd.h>\r
+#include <ofono/voicecall.h>\r
+\r
+static int phonesim_probe(struct ofono_modem *modem)\r
+{\r
+ return 0;\r
+}\r
+\r
+static void phonesim_remove(struct ofono_modem *modem)\r
+{\r
+}\r
+\r
+static int phonesim_enable(struct ofono_modem *modem)\r
+{\r
+ GIOChannel *io;\r
+ GAtChat *chat;\r
+ GAtSyntax *syntax;\r
+ struct sockaddr_in addr;\r
+ int sk, err;\r
+\r
+ DBG("%p", modem);\r
+\r
+ sk = socket(PF_INET, SOCK_STREAM, 0);\r
+ if (sk < 0)\r
+ return -EINVAL;\r
+\r
+ memset(&addr, 0, sizeof(addr));\r
+ addr.sin_family = AF_INET;\r
+ addr.sin_addr.s_addr = inet_addr("127.0.0.1");\r
+ addr.sin_port = htons(12345);\r
+\r
+ err = connect(sk, (struct sockaddr *) &addr, sizeof(addr));\r
+ if (err < 0) {\r
+ close(sk);\r
+ return err;\r
+ }\r
+\r
+ io = g_io_channel_unix_new(sk);\r
+ if (!io) {\r
+ close(sk);\r
+ return -ENOMEM;\r
+ }\r
+\r
+ syntax = g_at_syntax_new_gsmv1();\r
+ chat = g_at_chat_new(io, syntax);\r
+ g_at_syntax_unref(syntax);\r
+\r
+ if (!chat) {\r
+ g_io_channel_unref(io);\r
+ return -ENOMEM;\r
+ }\r
+\r
+ g_io_channel_unref(io);\r
+\r
+ ofono_modem_set_data(modem, chat);\r
+\r
+ return 0;\r
+}\r
+\r
+static int phonesim_disable(struct ofono_modem *modem)\r
+{\r
+ GAtChat *chat = ofono_modem_get_data(modem);\r
+\r
+ DBG("%p", modem);\r
+\r
+ ofono_modem_set_data(modem, NULL);\r
+\r
+ g_at_chat_unref(chat);\r
+\r
+ return 0;\r
+}\r
+\r
+static void phonesim_populate(struct ofono_modem *modem)\r
+{\r
+ GAtChat *chat = ofono_modem_get_data(modem);\r
+ struct ofono_message_waiting *mw;\r
+\r
+ DBG("%p", modem);\r
+\r
+ ofono_devinfo_create(modem, 0, "atmodem", chat);\r
+ ofono_ussd_create(modem, 0, "atmodem", chat);\r
+ ofono_sim_create(modem, 0, "atmodem", chat);\r
+ ofono_call_forwarding_create(modem, 0, "atmodem", chat);\r
+ ofono_call_settings_create(modem, 0, "atmodem", chat);\r
+ ofono_netreg_create(modem, 0, "atmodem", chat);\r
+ ofono_voicecall_create(modem, 0, "atmodem", chat);\r
+ ofono_call_meter_create(modem, 0, "atmodem", chat);\r
+ ofono_call_barring_create(modem, 0, "atmodem", chat);\r
+ ofono_ssn_create(modem, 0, "atmodem", chat);\r
+ ofono_sms_create(modem, 0, "atmodem", chat);\r
+ ofono_phonebook_create(modem, 0, "atmodem", chat);\r
+\r
+ mw = ofono_message_waiting_create(modem);\r
+ if (mw)\r
+ ofono_message_waiting_register(mw);\r
+}\r
+\r
+static struct ofono_modem_driver phonesim_driver = {\r
+ .name = "phonesim",\r
+ .probe = phonesim_probe,\r
+ .remove = phonesim_remove,\r
+ .enable = phonesim_enable,\r
+ .disable = phonesim_disable,\r
+ .populate = phonesim_populate,\r
+};\r
+\r
+static int phonesim_init(void)\r
+{\r
+ return ofono_modem_driver_register(&phonesim_driver);\r
+}\r
+\r
+static void phonesim_exit(void)\r
+{\r
+ ofono_modem_driver_unregister(&phonesim_driver);\r
+}\r
+\r
+OFONO_PLUGIN_DEFINE(phonesim, "PhoneSIM driver", VERSION,\r
+ OFONO_PLUGIN_PRIORITY_DEFAULT, phonesim_init, phonesim_exit)\r