include/dbus.h include/rfkill.h include/option.h \
include/profile.h include/provider.h include/dhcp.h \
include/utsname.h include/timeserver.h \
- include/location.h
+ include/location.h include/technology.h
local_headers = $(foreach file,$(include_HEADERS) $(nodist_include_HEADERS) \
$(noinst_HEADERS), include/connman/$(notdir $(file)))
--- /dev/null
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2007-2010 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
+ *
+ */
+
+#ifndef __CONNMAN_TECHNOLOGY_H
+#define __CONNMAN_TECHNOLOGY_H
+
+#include <connman/service.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * SECTION:technology
+ * @title: technology premitives
+ * @short_description: Functions for handling technology details
+ */
+
+struct connman_technology;
+
+struct connman_technology_driver {
+ const char *name;
+ enum connman_service_type type;
+ int priority;
+ int (*probe) (struct connman_technology *technology);
+ void (*remove) (struct connman_technology *technology);
+};
+
+int connman_technology_driver_register(struct connman_technology_driver *driver);
+void connman_technology_driver_unregister(struct connman_technology_driver *driver);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONNMAN_TECHNOLOGY_H */
void __connman_udev_rfkill(const char *sysname, connman_bool_t blocked);
connman_bool_t __connman_udev_get_blocked(int phyindex);
-#include <connman/device.h>
+#include <connman/technology.h>
void __connman_technology_list(DBusMessageIter *iter, void *user_data);
connman_bool_t hardblock);
int __connman_technology_remove_rfkill(unsigned int index);
+#include <connman/device.h>
+
int __connman_device_init(void);
void __connman_device_cleanup(void);
GHashTable *rfkill_list;
GSList *device_list;
gint enabled;
+
+ struct connman_technology_driver *driver;
+ void *driver_data;
};
+static GSList *driver_list = NULL;
+
+static gint compare_priority(gconstpointer a, gconstpointer b)
+{
+ const struct connman_technology_driver *driver1 = a;
+ const struct connman_technology_driver *driver2 = b;
+
+ return driver2->priority - driver1->priority;
+}
+
+/**
+ * connman_technology_driver_register:
+ * @driver: Technology driver definition
+ *
+ * Register a new technology driver
+ *
+ * Returns: %0 on success
+ */
+int connman_technology_driver_register(struct connman_technology_driver *driver)
+{
+ DBG("driver %p name %s", driver, driver->name);
+
+ driver_list = g_slist_insert_sorted(driver_list, driver,
+ compare_priority);
+
+ return 0;
+}
+
+/**
+ * connman_technology_driver_unregister:
+ * @driver: Technology driver definition
+ *
+ * Remove a previously registered technology driver
+ */
+void connman_technology_driver_unregister(struct connman_technology_driver *driver)
+{
+ DBG("driver %p name %s", driver, driver->name);
+
+ driver_list = g_slist_remove(driver_list, driver);
+}
+
static void free_rfkill(gpointer data)
{
struct connman_rfkill *rfkill = data;
{
struct connman_technology *technology;
const char *str;
+ GSList *list;
DBG("type %d", type);
technologies_changed();
+ if (technology->driver != NULL)
+ goto done;
+
+ for (list = driver_list; list; list = list->next) {
+ struct connman_technology_driver *driver = list->data;
+
+ DBG("driver %p name %s", driver, driver->name);
+
+ if (driver->type != technology->type)
+ continue;
+
+ if (driver->probe(technology) == 0) {
+ technology->driver = driver;
+ break;
+ }
+ }
+
done:
DBG("technology %p", technology);
if (g_atomic_int_dec_and_test(&technology->refcount) == FALSE)
return;
+ if (technology->driver) {
+ technology->driver->remove(technology);
+ technology->driver = NULL;
+ }
+
technology_list = g_slist_remove(technology_list, technology);
technologies_changed();