Index: configure.ac
===================================================================
--- configure.ac	(revision 1153)
+++ configure.ac	(working copy)
@@ -18,8 +18,23 @@
 AC_SUBST(GETTEXT_PACKAGE)
 AM_GLIB_GNU_GETTEXT
 
-PKG_CHECK_MODULES(NEOD, gtk+-2.0 gthread-2.0 gconf-2.0 libh1settings libnotify)
+PKG_CHECK_MODULES(NEOD, gtk+-2.0 gthread-2.0 gconf-2.0 libh1settings libnotify dbus-glib-1)
 
+AC_MSG_CHECKING([for wireless-tools >= 28pre9])
+AC_TRY_COMPILE([#include <iwlib.h>],
+               [#ifndef IWEVGENIE
+                #error "not found"
+                #endif],
+               [ac_have_iwevgenie=yes],
+               [ac_have_iwevgenie=no])
+AC_MSG_RESULT($ac_have_iwevgenie)
+if test "$ac_have_iwevgenie" = no; then
+        AC_MSG_ERROR(wireless-tools >= 28pre9 not installed or not functional)
+fi
+IWLIB=-liw
+AC_SUBST(IWLIB)
+
+
 AC_ARG_WITH([platform],
             AC_HELP_STRING([--with-platform], [Which platform to use [[default=vanilla]]]),
             [neod_platform=$with_platform])
Index: src/wifi.c
===================================================================
--- src/wifi.c	(revision 1153)
+++ src/wifi.c	(working copy)
@@ -14,11 +14,57 @@
 
 
 #include "wifi.h"
+#include <dbus/dbus-glib.h>
 
-gboolean
-wifi_radio_is_on (const gchar *iface)
+static gchar * found_ifname = NULL;
+
+static int
+get_ifwireless(int                    skfd,
+         char *                 ifname,
+         struct wireless_info * info)
 {
-  struct iwreq wrq;
+
+  memset((char *) info, 0, sizeof(struct wireless_info));
+
+  /* Get basic information */
+  if(iw_get_basic_config(skfd, ifname, &(info->b)) < 0)
+    {
+      /* If no wireless name : no wireless extensions */
+      /* But let's check if the interface exists at all */
+      struct ifreq ifr;
+
+      strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+      if(ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0)
+        return(-ENODEV);
+      else
+        return(-ENOTSUP);
+    }
+
+    return 0;
+}
+
+static int
+fill_wireless(int          skfd,
+           char *       ifname,
+           char *       args[],
+           int          count)
+{
+  struct wireless_info  info;
+  int rc;
+
+  rc = get_ifwireless(skfd, ifname, &info);
+  if (!rc) {
+    if (found_ifname == NULL)
+      found_ifname = g_strdup(ifname);
+  }
+  return rc;
+}
+
+
+
+gchar *
+wifi_first_interface ()
+{
   int sock = 0; /* socket */
 
   /* Open socket to perform ioctl() on */
@@ -29,25 +75,21 @@
     return FALSE;
   }
 
-  /* Clear our request and set the interface name */
-  memset (&wrq, 0, sizeof (struct iwreq));
-  strncpy ((char *)&wrq.ifr_name, iface, IFNAMSIZ);
-
-  /* Feel the power, uhh, do the ioctl() */
-  if (ioctl (sock, SIOCGIWTXPOW, &wrq) != 0)
+  if(found_ifname == NULL)
+    iw_enum_devices(sock, &fill_wireless ,NULL, 0);
+  if(found_ifname == NULL)
   {
-    g_warning ("Error performing ioctl: %s", g_strerror (errno));
-    close (sock);
+    g_warning ("No wireless interface found.");
     return FALSE;
   }
 
   close (sock);
 
-  return !wrq.u.txpower.disabled;
+  return g_strdup(found_ifname);
 }
 
 gboolean
-wifi_radio_control (const gchar *iface, gboolean enable)
+wifi_radio_is_on (const gchar *iface)
 {
   struct iwreq wrq;
   int sock = 0; /* socket */
@@ -62,7 +104,6 @@
 
   /* Clear our request and set the interface name */
   memset (&wrq, 0, sizeof (struct iwreq));
-
   strncpy ((char *)&wrq.ifr_name, iface, IFNAMSIZ);
 
   /* Feel the power, uhh, do the ioctl() */
@@ -73,17 +114,48 @@
     return FALSE;
   }
 
-  wrq.u.txpower.disabled = !enable;
+  close (sock);
 
-  /* Feel the power, uhh, do the ioctl() */
-  if (ioctl (sock, SIOCSIWTXPOW, &wrq) != 0)
+  return !wrq.u.txpower.disabled;
+}
+
+gboolean
+wifi_radio_control (const gchar *iface, gboolean enable)
+{
+  DBusGProxy *proxy;
+  DBusGConnection *connection;
+  GError *error = NULL;
+  gboolean result;
+
+  connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+  if (connection == NULL)
   {
-    g_warning ("Error performing ioctl: %s", g_strerror (errno));
-    close (sock);
-    return FALSE;
+	g_warning("Unable to connect to dbus: %sn", error->message);
+	g_error_free (error);
+	/* Basically here, there is a problem, since there is no dbus :)  */
+	return FALSE;
   }
 
-  close (sock);
+  /* This won't trigger activation! */
+  proxy = dbus_g_proxy_new_for_name (connection,
+		"org.prahal.TempDaemon",
+		"/org/prahal/TempDaemon/Wifi",
+		"org.prahal.TempDaemon.Wifi");
 
-  return TRUE;
+  /* The method call will trigger activation, more on that later */
+  if (!dbus_g_proxy_call (proxy, "WifiRadioControl", &error, G_TYPE_STRING, iface, G_TYPE_BOOLEAN, enable, G_TYPE_INVALID,
+                          G_TYPE_BOOLEAN, &result, G_TYPE_INVALID))
+  {
+	/* Method failed, the GError is set, let's warn everyone */
+	g_warning ("Woops remote method failed: %s", error->message);
+	g_error_free (error);
+	return FALSE;
+  }
+
+  g_print ("We got the folowing result: %d", result);
+
+  /* Cleanup */
+  g_object_unref (proxy);
+
+  return result;
 }
Index: src/neod-device.c
===================================================================
--- src/neod-device.c	(revision 1153)
+++ src/neod-device.c	(working copy)
@@ -87,8 +87,6 @@
 #define HEADPHONE_INSERTION_SWITCHCODE 0x02
 #define CHARGER_INSERTION_BUTTON 0x164
 
-#define WIFI_IFACE "eth1"
-
 #define BIT_MASK( name, numbits )                                        \
     unsigned short  name[ ((numbits) - 1) / (sizeof( short ) * 8) + 1 ];    \
     memset( name, 0, sizeof( name ) )
@@ -240,13 +238,13 @@
 void
 device_wifi_enable(gboolean enable)
 {
-    wifi_radio_control(WIFI_IFACE, enable);
+    wifi_radio_control(wifi_first_interface(), enable);
 }
 
 gboolean 
 device_wifi_is_enabled()
 {
-    return wifi_radio_is_on ( WIFI_IFACE );
+    return wifi_radio_is_on ( wifi_first_interface() );
 }
 
 void 
Index: src/wifi.h
===================================================================
--- src/wifi.h	(revision 1153)
+++ src/wifi.h	(working copy)
@@ -25,9 +25,9 @@
 #include <netdb.h>
 #include <unistd.h>
 
-#include <linux/if.h>
-#include <linux/wireless.h>
+#include <iwlib.h>
 
+gchar *wifi_first_interface ();
 gboolean wifi_radio_is_on (const gchar *iface);
 gboolean wifi_radio_control (const gchar *iface, gboolean enable);
 #endif /* __WIFI_H_ */
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 1153)
+++ src/Makefile.am	(working copy)
@@ -25,7 +25,7 @@
   wifi.c \
   wifi.h
 
-neod_LDADD = @NEOD_LIBS@ -lapm
+neod_LDADD = @NEOD_LIBS@ @IWLIB@ -lapm
 
 MAINTAINERCLEANFILES  = config.h.in Makefile.in
 

