mmc: add the internal api to return primary mmc information 88/80088/2 accepted/tizen/common/20160715.175725 accepted/tizen/ivi/20160717.035138 accepted/tizen/mobile/20160717.035123 accepted/tizen/tv/20160717.035000 accepted/tizen/wearable/20160717.035006 submit/tizen/20160715.121938
authortaeyoung <ty317.kim@samsung.com>
Thu, 14 Jul 2016 11:59:55 +0000 (20:59 +0900)
committertaeyoung <ty317.kim@samsung.com>
Thu, 14 Jul 2016 12:15:24 +0000 (21:15 +0900)
- Primary mmc information is used to install apps on the mmc.
  Thus primary mmc information api is necessary to avoid
  iterations with previous apis

Change-Id: Id27f575d0442225d0cb909220716e5d527ad506d
Signed-off-by: taeyoung <ty317.kim@samsung.com>
CMakeLists.txt
include/storage-internal.h [new file with mode: 0644]
src/storage-external-dbus.c
src/storage-external-dbus.h
src/storage-external-inhouse.c [new file with mode: 0755]

index 56482b0..55924cd 100644 (file)
@@ -30,7 +30,8 @@ ENDFOREACH(flag)
 
 SET(HEADERS
        include/storage.h
-       include/storage-expand.h)
+       include/storage-expand.h
+       include/storage-internal.h)
 
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g")
@@ -45,7 +46,8 @@ SET(SRCS
        src/storage.c
        src/storage-internal.c
        src/storage-external.c
-       src/storage-external-dbus.c)
+       src/storage-external-dbus.c
+       src/storage-external-inhouse.c)
 
 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS} ${TARGET_SRCS})
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${rpkgs_LDFLAGS})
diff --git a/include/storage-internal.h b/include/storage-internal.h
new file mode 100644 (file)
index 0000000..2040fc9
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * storage
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * 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.
+ */
+
+
+#ifndef __STORAGE_INTERNAL_H__
+#define __STORAGE_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @addtogroup CAPI_SYSTEM_STORAGE_MODULE
+ * @{
+ */
+
+#include <tizen.h>
+#include "storage.h"
+
+#define STORAGE_ERROR_NO_DEVICE TIZEN_ERROR_NO_SUCH_DEVICE
+
+/**
+ * @brief Get the mount path for the primary partition of sdcard.
+ *
+ * @since_tizen 3.0
+ *
+ * @remarks You must release the path using free() after use
+ *
+ * @param[out] storage_id The storage id
+ * @param[out] path The mount path of sdcard primary partition.
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #STORAGE_ERROR_NONE               Successful
+ * @retval #STORAGE_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #STORAGE_ERROR_NO_DEVICE          No such device
+ */
+int storage_get_primary_sdcard(int *storage_id, char **path);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __STORAGE_INTERNAL_H__ */
index 2793e40..012044c 100755 (executable)
@@ -112,14 +112,14 @@ static GDBusConnection *get_dbus_connection(void)
        return conn;
 }
 
-static GVariant *dbus_method_call_sync(const gchar *dest, const gchar *path,
+GVariant *dbus_method_call_sync(const gchar *dest, const gchar *path,
                                const gchar *iface, const gchar *method, GVariant *param)
 {
        GDBusConnection *conn;
        GError *err = NULL;
        GVariant *ret;
 
-       if (!dest || !path || !iface || !method || !param)
+       if (!dest || !path || !iface || !method)
                return NULL;
 
        conn = get_dbus_connection();
index d279c65..06153ee 100644 (file)
@@ -84,4 +84,8 @@ void storage_ext_unregister_device_change(storage_ext_changed_cb func);
 
 int storage_ext_get_device_info(int storage_id, storage_ext_device *info);
 
+/* storage-internal.c */
+GVariant *dbus_method_call_sync(const gchar *dest, const gchar *path,
+               const gchar *iface, const gchar *method, GVariant *param);
+
 #endif /* __STORAGE_EXTERNAL_DBUS_H__ */
diff --git a/src/storage-external-inhouse.c b/src/storage-external-inhouse.c
new file mode 100755 (executable)
index 0000000..6e7f5c4
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * 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.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "common.h"
+#include "list.h"
+#include "log.h"
+#include "storage-internal.h"
+#include "storage-external-dbus.h"
+
+API int storage_get_primary_sdcard(int *storage_id, char **path)
+{
+       GVariant *result;
+       storage_ext_device info;
+
+       if (!storage_id || !path)
+               return STORAGE_ERROR_INVALID_PARAMETER;
+
+       result = dbus_method_call_sync(STORAGE_EXT_BUS_NAME,
+                       STORAGE_EXT_PATH_MANAGER,
+                       STORAGE_EXT_IFACE_MANAGER,
+                       "GetMmcPrimary",
+                       NULL);
+       if (!result) {
+               _E("Failed to get primary sdcard partition"); //LCOV_EXCL_LINE
+               return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
+       g_variant_get(result, "(issssssisibii)",
+                       &info.type, &info.devnode, &info.syspath,
+                       &info.fs_usage, &info.fs_type,
+                       &info.fs_version, &info.fs_uuid,
+                       &info.readonly, &info.mount_point,
+                       &info.state, &info.primary,
+                       &info.flags, &info.storage_id);
+
+       g_variant_unref(result);
+
+       if (info.storage_id < 0)
+               return STORAGE_ERROR_NO_DEVICE;
+
+       *path = strdup(info.mount_point);
+       if (*path == NULL)
+               return STORAGE_ERROR_OUT_OF_MEMORY;
+
+       *storage_id = info.storage_id;
+
+       return STORAGE_ERROR_NONE;
+}