Enlightenment CVS committal

Author  : devilhorns
Project : e_modules
Module  : wlan

Dir     : e_modules/wlan


Modified Files:
        e_mod_config.c e_mod_main.c e_mod_main.h 


Log Message:
Wlan device is now configable.

===================================================================
RCS file: /cvs/e/e_modules/wlan/e_mod_config.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- e_mod_config.c      2 Sep 2006 09:55:34 -0000       1.15
+++ e_mod_config.c      2 Sep 2006 11:03:14 -0000       1.16
@@ -3,11 +3,13 @@
 
 struct _E_Config_Dialog_Data
 {
+   char *device;
+   Ecore_List *devs;
+   int dev_num;
+   
   double poll_time;
   int always_text;
   int show_percent;
-#ifdef __linux__
-#endif
 };
 
 /* Protos */
@@ -18,6 +20,7 @@
 static int _basic_apply_data (E_Config_Dialog * cfd,
                              E_Config_Dialog_Data * cfdata);
 static void _fill_data (Config_Item * ci, E_Config_Dialog_Data * cfdata);
+static void _wlan_config_get_devices(Ecore_List *devs);
 
 /* Config Calls */
 void
@@ -45,10 +48,34 @@
 static void
 _fill_data (Config_Item * ci, E_Config_Dialog_Data * cfdata)
 {
+   char *tmp;
+   int i = 0;
+   
   cfdata->poll_time = ci->poll_time;
-//   cfdata->show_text = c->conf->show_text;
   cfdata->always_text = ci->always_text;
   cfdata->show_percent = ci->show_percent;
+   
+   cfdata->device = NULL;
+   if (ci->device != NULL) 
+     cfdata->device = strdup(ci->device);
+   
+   if (!cfdata->device) return;
+   
+   cfdata->devs = ecore_list_new();
+   _wlan_config_get_devices(cfdata->devs);
+   if (!cfdata->devs) return;
+
+   ecore_list_goto_first(cfdata->devs);
+   while ((tmp = ecore_list_next(cfdata->devs)) != NULL) 
+     {
+       if (!strcmp(cfdata->device, tmp)) 
+         {
+            cfdata->dev_num = i;
+            break;
+         }
+       i++;
+     }
+   E_FREE(tmp);
 }
 
 static void *
@@ -70,6 +97,10 @@
   if (!wlan_config)
     return;
   wlan_config->config_dialog = NULL;
+   E_FREE(cfdata->device);
+   if (cfdata->devs)
+     ecore_list_destroy(cfdata->devs);
+   
   free (cfdata);
   cfdata = NULL;
 }
@@ -80,7 +111,9 @@
 {
   Evas_Object *o, *of, *ob;
   E_Radio_Group *rg;
-
+   char *tmp;
+   int i = 0;
+   
   o = e_widget_list_add (evas, 0, 0);
   of = e_widget_framelist_add (evas, D_ ("General Settings"), 0);
   rg = e_widget_radio_group_new (&(cfdata->always_text));
@@ -101,6 +134,21 @@
   e_widget_framelist_object_append (of, ob);
   e_widget_list_object_append (o, of, 1, 1, 0.5);
 
+   if (cfdata->devs) 
+     {
+       of = e_widget_framelist_add (evas, D_ ("Device Settings"), 0);
+       rg = e_widget_radio_group_new(&(cfdata->dev_num));
+       ecore_list_goto_first(cfdata->devs);
+       while ((tmp = ecore_list_next(cfdata->devs)) != NULL) 
+         {
+            ob = e_widget_radio_add(evas, tmp, i, rg);
+            e_widget_framelist_object_append (of, ob);
+            i++;
+         }
+       E_FREE(tmp);
+       e_widget_list_object_append (o, of, 1, 1, 0.5);
+     }
+   
   return o;
 }
 
@@ -108,14 +156,58 @@
 _basic_apply_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
 {
   Config_Item *ci;
-
+   char *tmp;
+   
   ci = cfd->data;
   ci->poll_time = cfdata->poll_time;
 
   ci->always_text = cfdata->always_text;
   ci->show_percent = cfdata->show_percent;
+   
+   if (cfdata->devs) 
+     {
+       tmp = ecore_list_goto_index(cfdata->devs, cfdata->dev_num);
+       if (tmp != NULL) 
+         {
+            evas_stringshare_del(ci->device);
+            ci->device = evas_stringshare_add(tmp);
+         }
+       E_FREE(tmp);
+     }
+   
   e_config_save_queue ();
   _wlan_config_updated (ci->id);
 
   return 1;
+}
+
+static void 
+_wlan_config_get_devices(Ecore_List *devs) 
+{
+  FILE *stat;
+  char dev[64];
+  char buf[256];
+  unsigned long dummy;
+
+  stat = fopen ("/proc/net/wireless", "r");
+  if (!stat)
+    return;
+
+  while (fgets (buf, 256, stat))
+    {
+      int i = 0;
+
+      for (; buf[i] != 0; i++)
+       {
+         if (buf[i] == ':')
+           buf[i] = ' ';
+       }       
+      if (sscanf (buf, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
+                 "%lu %lu %lu %lu\n", dev, &dummy, &dummy, &dummy,
+                 &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy,
+                 &dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 16)
+       continue;
+      ecore_list_append (devs, strdup (dev));
+    }
+  fclose (stat);   
 }
===================================================================
RCS file: /cvs/e/e_modules/wlan/e_mod_main.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -3 -r1.29 -r1.30
--- e_mod_main.c        2 Sep 2006 09:55:34 -0000       1.29
+++ e_mod_main.c        2 Sep 2006 11:03:14 -0000       1.30
@@ -39,6 +39,8 @@
 static Wlan *_wlan_new (Evas * evas);
 static void _wlan_free (Wlan * wlan);
 static int _wlan_cb_check (void *data);
+static void _wlan_update_qual (void *data, double value);
+static void _wlan_update_level (void *data, double value);
 
 static E_Config_DD *conf_edd = NULL;
 static E_Config_DD *conf_item_edd = NULL;
@@ -240,6 +242,7 @@
     }
   ci = E_NEW (Config_Item, 1);
   ci->id = evas_stringshare_add (id);
+  ci->device = evas_stringshare_add ("wlan0");  
   ci->poll_time = 1.0;
   ci->always_text = 0;
   ci->show_percent = 1;
@@ -265,6 +268,7 @@
 #define T Config_Item
 #define D conf_item_edd
   E_CONFIG_VAL (D, T, id, STR);
+  E_CONFIG_VAL (D, T, device, STR);  
   E_CONFIG_VAL (D, T, poll_time, DOUBLE);
   E_CONFIG_VAL (D, T, always_text, INT);
   E_CONFIG_VAL (D, T, show_percent, INT);
@@ -285,6 +289,7 @@
 
       ci = E_NEW (Config_Item, 1);
       ci->id = evas_stringshare_add ("0");
+      ci->device = evas_stringshare_add ("wlan0");      
       ci->poll_time = 1.0;
       ci->always_text = 0;
       ci->show_percent = 1;
@@ -318,6 +323,9 @@
        evas_list_remove_list (wlan_config->items, wlan_config->items);
       if (ci->id)
        evas_stringshare_del (ci->id);
+      if (ci->device)
+       evas_stringshare_del (ci->device);
+       
       free (ci);
       ci = NULL;
     }
@@ -441,11 +449,13 @@
         if (sscanf(buf, "%s %u %u %u %u %u %u %u %u %u %u",
                    iface, &wlan_status, &wlan_link, &wlan_level, &wlan_noise, 
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 11)
            continue;
-        if (!strcmp(iface, "wlan0"))
-          {
-             found_dev = 1;
-             break;
-          }
+      if (!ci->device)
+       continue;
+      if (!strcmp (iface, ci->device))
+       {
+         found_dev = 1;
+         break;
+       }
      }
    fclose(stat);
 
@@ -457,21 +467,12 @@
   inst = data;
   ci = _wlan_config_item_get (inst->gcc->id);
 
-
    double link_send = ((double)wlan_link / (double)100.0);
    double level_send = ((double)wlan_level / (double)100.0);
 
-   Edje_Message_Float *val;
-   val = malloc(sizeof(Edje_Message_Float));
-   val->val = link_send;   
-   edje_object_message_send(inst->wlan_obj, EDJE_MESSAGE_FLOAT,1, val);
-   free(val);
-
-   val = malloc(sizeof(Edje_Message_Float));
-   val->val = level_send;   
-   edje_object_message_send(inst->wlan_obj, EDJE_MESSAGE_FLOAT,2, val);
-   free(val);
-
+  _wlan_update_qual(inst, link_send);
+  _wlan_update_level (inst, level_send);
+  
    snprintf(omsg,sizeof(omsg),"Qual: %d%%", wlan_link);
    edje_object_signal_emit(inst->wlan_obj, "label_active", "");
    edje_object_part_text_set(inst->wlan_obj, "qual_label", omsg);
@@ -479,6 +480,32 @@
    snprintf(omsg,sizeof(omsg),"Lvl: %d%%", wlan_level);
    edje_object_part_text_set(inst->wlan_obj, "level_label", omsg);
 
-
   return 1;
 }
+
+static void 
+_wlan_update_qual(void *data, double value) 
+{
+   Instance *inst;
+   Edje_Message_Float *val;
+   
+   inst = data;
+   val = malloc(sizeof(Edje_Message_Float));
+   val->val = value;
+   edje_object_message_send(inst->wlan_obj, EDJE_MESSAGE_FLOAT,1, val);
+   free(val);
+}
+
+static void 
+_wlan_update_level(void *data, double value) 
+{
+   Instance *inst;
+   Edje_Message_Float *val;
+   
+   inst = data;
+   val = malloc(sizeof(Edje_Message_Float));
+   val->val = value;   
+   edje_object_message_send(inst->wlan_obj, EDJE_MESSAGE_FLOAT,2, val);
+   free(val);
+}
+
===================================================================
RCS file: /cvs/e/e_modules/wlan/e_mod_main.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- e_mod_main.h        2 Sep 2006 00:56:06 -0000       1.10
+++ e_mod_main.h        2 Sep 2006 11:03:14 -0000       1.11
@@ -18,6 +18,8 @@
 struct _Config_Item
 {
    const char *id;
+   
+   const char *device;   
    double poll_time;
    int show_percent;
    int always_text;



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to