5 * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #define CONNMAN_API_SUBJECT_TO_CHANGE
31 #include <connman/plugin.h>
32 #include <connman/dbus.h>
33 #include <connman/log.h>
35 #define OFONO_SERVICE "org.ofono"
37 static DBusConnection *connection;
39 static GHashTable *ofono_modems = NULL;
41 static void unregister_modem(gpointer data)
46 static void ofono_connect(DBusConnection *connection, void *user_data)
48 DBG("connection %p", connection);
50 ofono_modems = g_hash_table_new_full(g_str_hash, g_str_equal,
51 g_free, unregister_modem);
54 static void ofono_disconnect(DBusConnection *connection, void *user_data)
56 DBG("connection %p", connection);
58 if (ofono_modems == NULL)
61 g_hash_table_destroy(ofono_modems);
67 static int ofono_init(void)
71 connection = connman_dbus_get_connection();
72 if (connection == NULL)
75 watch = g_dbus_add_service_watch(connection, OFONO_SERVICE,
76 ofono_connect, ofono_disconnect, NULL, NULL);
85 dbus_connection_unref(connection);
90 static void ofono_exit(void)
92 g_dbus_remove_watch(connection, watch);
94 ofono_disconnect(connection, NULL);
96 dbus_connection_unref(connection);
99 CONNMAN_PLUGIN_DEFINE(ofono, "oFono telephony plugin", VERSION,
100 CONNMAN_PLUGIN_PRIORITY_DEFAULT, ofono_init, ofono_exit)