technology: Track rfkill blocked state
authorSamuel Ortiz <sameo@linux.intel.com>
Wed, 6 Oct 2010 09:57:24 +0000 (11:57 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 7 Oct 2010 18:07:43 +0000 (20:07 +0200)
src/technology.c

index 46fb23f..b255236 100644 (file)
@@ -36,6 +36,8 @@ static GSList *technology_list = NULL;
 struct connman_rfkill {
        unsigned int index;
        enum connman_service_type type;
+       connman_bool_t softblock;
+       connman_bool_t hardblock;
 };
 
 enum connman_technology_state {
@@ -611,18 +613,18 @@ int __connman_technology_add_rfkill(unsigned int index,
        DBG("index %u type %d soft %u hard %u", index, type,
                                                        softblock, hardblock);
 
+       technology = technology_get(type);
+       if (technology == NULL)
+               return -ENXIO;
+
        rfkill = g_try_new0(struct connman_rfkill, 1);
        if (rfkill == NULL)
                return -ENOMEM;
 
        rfkill->index = index;
        rfkill->type = type;
-
-       technology = technology_get(type);
-       if (technology == NULL) {
-               g_free(rfkill);
-               return -ENXIO;
-       }
+       rfkill->softblock = softblock;
+       rfkill->hardblock = hardblock;
 
        g_hash_table_replace(rfkill_table, &index, technology);
 
@@ -636,6 +638,7 @@ int __connman_technology_update_rfkill(unsigned int index,
                                                connman_bool_t hardblock)
 {
        struct connman_technology *technology;
+       struct connman_rfkill *rfkill;
 
        DBG("index %u soft %u hard %u", index, softblock, hardblock);
 
@@ -643,6 +646,13 @@ int __connman_technology_update_rfkill(unsigned int index,
        if (technology == NULL)
                return -ENXIO;
 
+       rfkill = g_hash_table_lookup(technology->rfkill_list, &index);
+       if (rfkill == NULL)
+               return -ENXIO;
+
+       rfkill->softblock = softblock;
+       rfkill->hardblock = hardblock;
+
        return 0;
 }