storage_foreach_device_supported() gets run-time device state
authorHyunbin Lee <hyunbin.lee@samsung.com>
Wed, 17 Apr 2013 00:53:02 +0000 (09:53 +0900)
committerHyunbin Lee <hyunbin.lee@samsung.com>
Wed, 17 Apr 2013 00:53:02 +0000 (09:53 +0900)
Signed-off-by: Hyunbin Lee <hyunbin.lee@samsung.com>
packaging/capi-appfw-application.spec
src/storage.c
src/storage_internal.c
src/storage_sdcard.c
src/storage_usbhost.c

index 38d65ded067f1bb17a2b9939b0a1f5631e5dde98..5eb43e0922fdc4a699c6eaa507c1ac927fb8065a 100755 (executable)
@@ -1,7 +1,7 @@
 Name:       capi-appfw-application
 Summary:    An Application library in SLP C API
 Version:    0.1.0
-Release:    51
+Release:    52
 Group:      API
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index 1a42a1e6b6564c8a67dd50e912d7ae3a23e2fcd5..81894cb9002d1ff057310ef1db3f6372cf7cd71e 100755 (executable)
@@ -41,6 +41,9 @@ extern storage_device_h storage_internal_device();
 extern storage_device_h storage_sdcard_device();
 extern storage_device_h storage_usbhost_device();
 
+extern int storage_internal_get_state();
+extern int storage_sdcard_get_state();
+extern int storage_usbhost_get_state();
 
 #define STORAGE_MAX 3
 static struct storage_info_s storage_info_table[STORAGE_MAX];
@@ -79,8 +82,8 @@ static int storage_initialize()
        dev_internal = storage_internal_device();
        storage_register_device(dev_internal);
 
-       dev_sdcard =  storage_sdcard_device();
-       storage_register_device(        dev_sdcard);
+       dev_sdcard = storage_sdcard_device();
+       storage_register_device(dev_sdcard);
 
        dev_usbhost = storage_usbhost_device();
        storage_register_device(dev_usbhost);
@@ -88,9 +91,10 @@ static int storage_initialize()
        return 0;
 }
 
-
 static int storage_get_storage(int id, storage_info_h* storage_info)
 {
+       int device_state = -1;
+
        if (storage_num < 1)
        {
                if (storage_initialize() != 0)
@@ -99,17 +103,32 @@ static int storage_get_storage(int id, storage_info_h* storage_info)
                }
        }
 
-       if (id <0 || id >= storage_num)
+       if (id < 0 || id >= storage_num)
        {
                return STORAGE_ERROR_NOT_SUPPORTED;
        }
 
+       switch (id)
+       {
+       case 0:
+               device_state = storage_internal_get_state();
+               break;
+       case 1:
+               device_state = storage_sdcard_get_state();
+               break;
+       case 2:
+               device_state = storage_usbhost_get_state();
+               break;
+       default:
+               LOGE("Device statei is invalid");
+               break;
+       }
+       storage_info_table[id].state = device_state;
        *storage_info = &(storage_info_table[id]);
 
        return STORAGE_ERROR_NONE;
 }
 
-
 int storage_foreach_device_supported(storage_device_supported_cb callback, void *user_data)
 {
        int storage_id = 0;
index 973fd54df5a91bedd91cf1ad0bb946b12a46fdc2..9698630c98df8dd8746df10548c65775f183dab2 100755 (executable)
@@ -35,7 +35,7 @@
 
 #define INTERNAL_MEMORY_PATH "/opt/usr/media"
 
-static int storage_internal_get_state()
+int storage_internal_get_state()
 {
        return STORAGE_STATE_MOUNTED;
 }
index 9dd9cb09878e6b9872fb910bf7cd50965a944533..3fa1f4379f2e15db0b163360a3332d36969ba658 100755 (executable)
@@ -11,7 +11,7 @@
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
 
@@ -35,7 +35,7 @@
 
 #define SDCARD_PATH "/opt/storage/sdcard"
 
-static int storage_sdcard_get_state()
+int storage_sdcard_get_state()
 {
        int sdcard_state = 0;
 
index aba65c083bb506c51ce149bd2ba69d3c7425b36d..88394e4ee25814957648fb2d125ef6da7c3f170c 100755 (executable)
@@ -11,7 +11,7 @@
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
 
@@ -35,7 +35,7 @@
 
 #define USBHOST_PATH "/opt/storage/usb"
 
-static int storage_usbhost_get_state()
+int storage_usbhost_get_state()
 {
        int usbhost_state = 0;