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
26 #define CONNMAN_API_SUBJECT_TO_CHANGE
27 #include <connman/plugin.h>
28 #include <connman/notifier.h>
29 #include <connman/dbus.h>
30 #include <connman/log.h>
32 #define IOSPM_SERVICE "com.intel.mid.ospm"
33 #define IOSPM_INTERFACE IOSPM_SERVICE ".Comms"
35 #define IOSPM_BLUETOOTH "/com/intel/mid/ospm/bluetooth"
36 #define IOSPM_FLIGHT_MODE "/com/intel/mid/ospm/flight_mode"
38 static DBusConnection *connection;
40 static void send_indication(const char *path, connman_bool_t enabled)
45 DBG("path %s enabled %d", path, enabled);
48 method = "IndicateStart";
50 method = "IndicateStop";
52 message = dbus_message_new_method_call(IOSPM_SERVICE, path,
53 IOSPM_INTERFACE, method);
57 dbus_message_set_no_reply(message, TRUE);
59 dbus_connection_send(connection, message, NULL);
61 dbus_message_unref(message);
64 static void iospm_device_enabled(enum connman_device_type type,
65 connman_bool_t enabled)
68 case CONNMAN_DEVICE_TYPE_UNKNOWN:
69 case CONNMAN_DEVICE_TYPE_VENDOR:
70 case CONNMAN_DEVICE_TYPE_ETHERNET:
71 case CONNMAN_DEVICE_TYPE_WIFI:
72 case CONNMAN_DEVICE_TYPE_WIMAX:
73 case CONNMAN_DEVICE_TYPE_GPS:
74 case CONNMAN_DEVICE_TYPE_MBM:
75 case CONNMAN_DEVICE_TYPE_HSO:
76 case CONNMAN_DEVICE_TYPE_NOZOMI:
77 case CONNMAN_DEVICE_TYPE_HUAWEI:
78 case CONNMAN_DEVICE_TYPE_NOVATEL:
80 case CONNMAN_DEVICE_TYPE_BLUETOOTH:
81 send_indication(IOSPM_BLUETOOTH, enabled);
86 static void iospm_offline_mode(connman_bool_t enabled)
88 send_indication(IOSPM_FLIGHT_MODE, enabled);
91 static struct connman_notifier iospm_notifier = {
93 .priority = CONNMAN_NOTIFIER_PRIORITY_DEFAULT,
94 .device_enabled = iospm_device_enabled,
95 .offline_mode = iospm_offline_mode,
98 static int iospm_init(void)
100 connection = connman_dbus_get_connection();
102 return connman_notifier_register(&iospm_notifier);
105 static void iospm_exit(void)
107 connman_notifier_unregister(&iospm_notifier);
109 dbus_connection_unref(connection);
112 CONNMAN_PLUGIN_DEFINE(ospm, "Intel OSPM notification plugin", VERSION,
113 CONNMAN_PLUGIN_PRIORITY_DEFAULT, iospm_init, iospm_exit)