add Exception handling code / organize Dubeg log 52/54052/1 accepted/tizen/mobile/20151212.070938 accepted/tizen/tv/20151212.072449 accepted/tizen/wearable/20151212.073017 submit/tizen/20151211.060218
authorHyihong Chae <hh.chae@samsung.com>
Fri, 11 Dec 2015 05:57:27 +0000 (14:57 +0900)
committerHyihong Chae <hh.chae@samsung.com>
Fri, 11 Dec 2015 05:57:27 +0000 (14:57 +0900)
Change-Id: Idd26601fa21e5f5bccb7d09c915796d928599139
Signed-off-by: HyiHong Chae <hh.chae@samsung.com>
packaging/mtp-initiator.spec
src/daemon/mtp_daemon_db.c
src/daemon/mtp_daemon_event.c
src/daemon/mtp_daemon_gdbus.c
src/daemon/mtp_daemon_gdbus_deviceinfo.c
src/daemon/mtp_daemon_gdbus_manager.c
src/daemon/mtp_daemon_gdbus_objectinfo.c
src/daemon/mtp_daemon_gdbus_storageinfo.c
src/daemon/mtp_daemon_util.c

index 979d8040c5d90d4598afabf65394ecf27ca9a46b..7604cbe4f988e0f3719dc82a31b85e54d5172e8d 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       mtp-initiator
 Summary:    mtp(media transfer protocol) initiator
-Version:    1.2.8
+Version:    1.3.0
 Release:    1
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
index 89400d306b81f50203cbffa5f21ee4b263fdfd38..4438586135f32c426fa730ab092857495d9974fa 100755 (executable)
@@ -54,7 +54,7 @@ mtp_error_e mtp_daemon_db_delete(int device_handle, int storage_id,
        if (sql != NULL) {
                sql_ret = sqlite3_exec(mtp_ctx->db, sql, NULL, NULL, &error);
                if (sql_ret != SQLITE_OK) {
-                       MTP_LOGE("sqlite3_exec failed, [%d] : %s", ret, error);
+                       MTP_LOGE("sqlite3_exec failed, sql_ret[%d] : %s", sql_ret, error);
                        ret = MTP_ERROR_DB;
                        sqlite3_free(error);
                }
@@ -84,7 +84,7 @@ mtp_error_e mtp_daemon_db_update(int device_handle, int object_handle,
                MTP_DB_TABLE,
                object_info->ObjectFormat,
                object_info->ProtectionStatus,
-               object_info->ObjectCompressedSize,
+               (int)object_info->ObjectCompressedSize,
                object_info->ThumbFormat,
                object_info->ThumbCompressedSize,
                object_info->ThumbPixWidth,
@@ -102,7 +102,7 @@ mtp_error_e mtp_daemon_db_update(int device_handle, int object_handle,
        if (sql != NULL) {
                sql_ret = sqlite3_exec(mtp_ctx->db, sql, NULL, NULL, &error);
                if (sql_ret != SQLITE_OK) {
-                       MTP_LOGE("sqlite3_exec failed, [%d] : %s", ret, error);
+                       MTP_LOGE("sqlite3_exec failed, sql_ret[%d] : %s", sql_ret, error);
                        ret = MTP_ERROR_DB;
                        sqlite3_free(error);
                }
@@ -136,14 +136,14 @@ MTPObjectInfo* mtp_daemon_db_get_object_info(int device_handle,
        if (sql != NULL && object_info != NULL) {
                sql_ret = sqlite3_prepare_v2(mtp_ctx->db, sql, strlen(sql), &stmt, NULL);
                if (stmt == NULL) {
-                       MTP_LOGE("sqlite3_prepare_v2 failed, [%d], %s", sql_ret, sqlite3_errmsg(mtp_ctx->db));
+                       MTP_LOGE("sqlite3_prepare_v2 failed, sql_ret[%d], %s", sql_ret, sqlite3_errmsg(mtp_ctx->db));
                        g_free(object_info);
                        return NULL;
                }
 
                sql_ret = sqlite3_step(stmt);
                if (sql_ret != SQLITE_ROW) {
-                       MTP_LOGE("sqlite3_step failed, [%d]", sql_ret);
+                       MTP_LOGE("sqlite3_step failed, sql_ret[%d]", sql_ret);
                        g_free(object_info);
                        return NULL;
                }
@@ -168,7 +168,7 @@ MTPObjectInfo* mtp_daemon_db_get_object_info(int device_handle,
                object_info->ModificationDate = sqlite3_column_int(stmt, 20);
                object_info->Keywords = g_strdup((const char *)sqlite3_column_text(stmt, 21));
 
-               /*MTP_LOGI("object_info->Filename : %s, %ld, object_info->ModificationDate : %ld",
+               /*MTP_LOGI("Filename: %s, CaptureDate: %ld, ModificationDate: %ld",
                        object_info->Filename, (long)object_info->CaptureDate, (long)object_info->ModificationDate);*/
 
                sqlite3_finalize(stmt);
@@ -200,20 +200,19 @@ bool mtp_daemon_db_is_exist(int device_handle, int object_handle, mtp_context *m
        if (sql != NULL) {
                sql_ret = sqlite3_prepare_v2(mtp_ctx->db, sql, strlen(sql), &stmt, NULL);
                if (stmt == NULL) {
-                       MTP_LOGE("sqlite3_prepare_v2 failed, [%d], %s", sql_ret, sqlite3_errmsg(mtp_ctx->db));
+                       MTP_LOGE("sqlite3_prepare_v2 failed, sql_ret[%d], %s", sql_ret, sqlite3_errmsg(mtp_ctx->db));
                        return false;
                }
 
                sql_ret = sqlite3_step(stmt);
                if (sql_ret != SQLITE_ROW) {
-                       MTP_LOGE("sqlite3_step failed, [%d]", sql_ret);
+                       MTP_LOGE("sqlite3_step failed, sql_ret[%d]", sql_ret);
                        return false;
                }
 
                count = sqlite3_column_int(stmt, 0);
 
-               /*MTP_LOGI("device : %d, object_id : %d, count is [%d]", device_handle,
-                       object_handle, count);*/
+               /*MTP_LOGI("device: %d, object_id: %d, count: %d", device_handle, object_handle, count);*/
 
                sqlite3_finalize(stmt);
                sqlite3_free(sql);
@@ -228,6 +227,8 @@ mtp_error_e mtp_daemon_db_begin(mtp_context *mtp_ctx)
 {
        int sql_ret;
 
+       MTP_LOGI("mtp_ctx %p", mtp_ctx);
+
        if (mtp_ctx->db == NULL) {
                MTP_LOGE("mtp_ctx->db is NULL");
                return MTP_ERROR_DB;
@@ -235,7 +236,7 @@ mtp_error_e mtp_daemon_db_begin(mtp_context *mtp_ctx)
 
        sql_ret = sqlite3_exec(mtp_ctx->db, "BEGIN;", NULL, NULL, NULL);
        if (sql_ret != SQLITE_OK) {
-               MTP_LOGE("sqlite3_exec BEGIN failed");
+               MTP_LOGE("sqlite3_exec BEGIN failed - sql_ret[%d]", sql_ret);
                return MTP_ERROR_DB;
        }
 
@@ -246,6 +247,8 @@ mtp_error_e mtp_daemon_db_commit(mtp_context *mtp_ctx)
 {
        int sql_ret;
 
+       MTP_LOGI("mtp_ctx %p", mtp_ctx);
+
        if (mtp_ctx->db == NULL) {
                MTP_LOGE("mtp_ctx->db is NULL");
                return MTP_ERROR_DB;
@@ -253,7 +256,7 @@ mtp_error_e mtp_daemon_db_commit(mtp_context *mtp_ctx)
 
        sql_ret = sqlite3_exec(mtp_ctx->db, "COMMIT;", NULL, NULL, NULL);
        if (sql_ret != SQLITE_OK) {
-               MTP_LOGE("sqlite3_exec COMMIT failed");
+               MTP_LOGE("sqlite3_exec COMMIT failed - sql_ret[%d]", sql_ret);
                return MTP_ERROR_DB;
        }
 
@@ -301,7 +304,7 @@ mtp_error_e mtp_daemon_db_insert(int device_handle, int storage_id,
        if (sql != NULL) {
                sql_ret = sqlite3_exec(mtp_ctx->db, sql, NULL, NULL, &error);
                if (sql_ret != SQLITE_OK) {
-                       MTP_LOGE("sqlite3_exec failed, [%d] : %s", ret, error);
+                       MTP_LOGE("sqlite3_exec failed, sql_ret[%d] : %s", sql_ret, error);
                        ret = MTP_ERROR_DB;
                        sqlite3_free(error);
                }
@@ -332,7 +335,7 @@ static mtp_error_e __create_table(mtp_context *mtp_ctx)
        if (sql != NULL) {
                sql_ret = sqlite3_exec(mtp_ctx->db, sql, NULL, NULL, &error);
                if (sql_ret != SQLITE_OK) {
-                       MTP_LOGE("sqlite3_exec failed, [%d] : %s", ret, error);
+                       MTP_LOGE("sqlite3_exec failed, sql_ret[%d] : %s", sql_ret, error);
                        ret = MTP_ERROR_DB;
                        sqlite3_free(error);
                }
@@ -352,9 +355,9 @@ mtp_error_e mtp_daemon_db_init(mtp_context *mtp_ctx)
 
        if (mtp_ctx->db == NULL) {
                sql_ret = sqlite3_open_v2(MTP_DB_FILE, &mtp_ctx->db,
-                       SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
+                       SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
                if (sql_ret != SQLITE_OK) {
-                       MTP_LOGE("sqlite3_open_v2 failed, [%d]", sql_ret);
+                       MTP_LOGE("sqlite3_open_v2 failed, sql_ret[%d]", sql_ret);
                        return MTP_ERROR_DB;
                }
 
@@ -372,7 +375,7 @@ mtp_error_e mtp_daemon_db_deinit(mtp_context *mtp_ctx)
        if (mtp_ctx->db != NULL) {
                sql_ret = sqlite3_close(mtp_ctx->db);
                if (sql_ret != SQLITE_OK) {
-                       MTP_LOGE("sqlite3_close failed, [%d]", sql_ret);
+                       MTP_LOGE("sqlite3_close failed, sql_ret[%d]", sql_ret);
                        return MTP_ERROR_DB;
                }
                mtp_ctx->db = NULL;
index f9787bfd023f3be57106fa0005e6ce3a937b2c62..68e74307c4d512a29b68d3ff633575984d33ffde 100755 (executable)
@@ -75,7 +75,7 @@ static int __search_empty_slot(mtp_context *mtp_ctx)
 
        for (slot = 1; slot < MTP_MAX_SLOT; slot++) {
                if (mtp_ctx->device_list->device_info_list[slot] == NULL) {
-                       MTP_LOGI("empty slot : %d", slot);
+                       MTP_LOGI("empty slot: %d", slot);
                        return slot;
                }
        }
@@ -95,7 +95,7 @@ static int __parsing_usb_busno(const char *devpath)
        else
                MTP_LOGE("pos is NULL");
 
-       MTP_LOGI("busno : %d, pos : %s, devpath : %s", busno, pos, devpath);
+       MTP_LOGI("busno: %d, pos: %s, devpath: %s", busno, pos, devpath);
 
        return busno;
 }
@@ -129,43 +129,43 @@ static void __dbus_usb_host_event_cb(GDBusConnection* connection,
 
        tmp = g_variant_get_child_value(parameters, 0);
        state = g_variant_get_int32(tmp);
-       MTP_LOGI("state : %d", state);
+       MTP_LOGI("state: %d", state);
 
        tmp = g_variant_get_child_value(parameters, 1);
        devpath = g_variant_get_string(tmp, &size);
-       MTP_LOGI("devpath : %s", devpath);
+       MTP_LOGI("devpath: %s", devpath);
 
        tmp = g_variant_get_child_value(parameters, 2);
        baseclass = g_variant_get_int32(tmp);
-       MTP_LOGI("baseclass : %d", baseclass);
+       MTP_LOGI("baseclass: %d", baseclass);
 
        tmp = g_variant_get_child_value(parameters, 3);
        subclass = g_variant_get_int32(tmp);
-       MTP_LOGI("subclass : %d", subclass);
+       MTP_LOGI("subclass: %d", subclass);
 
        tmp = g_variant_get_child_value(parameters, 4);
        protocol = g_variant_get_int32(tmp);
-       MTP_LOGI("protocol : %d", protocol);
+       MTP_LOGI("protocol: %d", protocol);
 
        tmp = g_variant_get_child_value(parameters, 5);
        vendorid = g_variant_get_int32(tmp);
-       MTP_LOGI("vendorid : %d", vendorid);
+       MTP_LOGI("vendorid: %d", vendorid);
 
        tmp = g_variant_get_child_value(parameters, 6);
        productid = g_variant_get_int32(tmp);
-       MTP_LOGI("productid : %d", productid);
+       MTP_LOGI("productid: %d", productid);
 
        tmp = g_variant_get_child_value(parameters, 7);
        manufacturer = g_variant_get_string(tmp, &size);
-       MTP_LOGI("manufacturer : %s", manufacturer);
+       MTP_LOGI("manufacturer: %s", manufacturer);
 
        tmp = g_variant_get_child_value(parameters, 8);
        product = g_variant_get_string(tmp, &size);
-       MTP_LOGI("product : %s", product);
+       MTP_LOGI("product: %s", product);
 
        tmp = g_variant_get_child_value(parameters, 9);
        serial = g_variant_get_string(tmp, &size);
-       MTP_LOGI("serial : %s", serial);
+       MTP_LOGI("serial: %s", serial);
 
        busno = __parsing_usb_busno(devpath);
 
@@ -180,7 +180,7 @@ static int __dbus_subscribe_usb_host_event(device_changed_cb usr_callback, void
        int ret = MTP_ERROR_NONE;
        GError *error = NULL;
 
-       MTP_LOGE("BEGIN");
+       MTP_LOGI("BEGIN");
 
        g_usb_cb_data = malloc(sizeof(device_cb_data));
        if (g_usb_cb_data == NULL) {
@@ -214,7 +214,7 @@ static int __dbus_subscribe_usb_host_event(device_changed_cb usr_callback, void
                                        g_usb_cb_data,
                                        NULL);
 
-       MTP_LOGE("END");
+       MTP_LOGI("END");
 
        return MTP_ERROR_NONE;
 
@@ -241,13 +241,13 @@ void __usb_host_status_changed_cb(const char *dev_path, int bus_no, usbhost_stat
        LIBMTP_mtpdevice_t *device;
        mtp_device_info *device_info;
 
-       MTP_LOGE("host_status : %d, bus_no : %d, dev_path : %s", host_status, bus_no, dev_path);
+       MTP_LOGI("host_status: %d, bus_no: %d, dev_path: %s", host_status, bus_no, dev_path);
 
        if (host_status == USB_HOST_ADDED) {
                LIBMTP_Detect_Raw_Devices(&raw_devices, &num_of_devices);
                for (slot = 0; slot < num_of_devices; slot++) {
                        if (bus_no == raw_devices[slot].bus_location) {
-                               MTP_LOGE("connected bus_no : %d", bus_no);
+                               MTP_LOGI("connected bus_no: %d", bus_no);
                                int empty_slot = 0;
 
                                device = LIBMTP_Open_Raw_Device_Uncached(&raw_devices[slot]);
@@ -275,7 +275,7 @@ void __usb_host_status_changed_cb(const char *dev_path, int bus_no, usbhost_stat
                g_free(raw_devices);
                __print_device_list(mtp_ctx);
        } else if (host_status == USB_HOST_REMOVED) {
-               MTP_LOGE("disconnected bus_no : %d", bus_no);
+               MTP_LOGI("disconnected bus_no: %d", bus_no);
        }
 }
 
@@ -325,7 +325,7 @@ static void* __event_thread(gpointer dev, gpointer data)
                mtp_daemon_gdbus_emit_event(device_event, (int)param1, mtp_ctx);
        }
 
-       MTP_LOGI("device is closing down!! device : %p", device);
+       MTP_LOGI("device is closing down!! device: %p", device);
 
        mtp_daemon_gdbus_emit_event(MTP_INITIATOR_EVENT_DEVICE_REMOVED,
                mtp_daemon_util_get_device_id(device, mtp_ctx), mtp_ctx);
@@ -373,7 +373,7 @@ mtp_error_e __device_list_init(mtp_context *mtp_ctx)
 
        LIBMTP_Init();
        LIBMTP_Detect_Raw_Devices(&rawdevices, &numrawdevices);
-       MTP_LOGE("detected device num %d", numrawdevices);
+       MTP_LOGI("detected device num %d", numrawdevices);
 
        if (numrawdevices == 0) {
                MTP_LOGE("MTP Host have not any mtp device");
@@ -405,14 +405,13 @@ mtp_error_e __device_list_init(mtp_context *mtp_ctx)
                MTP_LOGI("Device: %s, Bus: %d", device_info->model_name, device_info->bus_location);
 
                empty_slot = __search_empty_slot(mtp_ctx);
-               MTP_LOGI("empty slot : %d", empty_slot);
 
                mtp_ctx->device_list->device_info_list[empty_slot] = device_info;
                mtp_ctx->device_list->device_num++;
 
-               MTP_LOGI("mtp_ctx Device: %s, mtp_ctx Bus: %d",
+               /*MTP_LOGI("mtp_ctx Device: %s, mtp_ctx Bus: %d",
                        mtp_ctx->device_list->device_info_list[empty_slot]->model_name,
-                       mtp_ctx->device_list->device_info_list[empty_slot]->bus_location);
+                       mtp_ctx->device_list->device_info_list[empty_slot]->bus_location);*/
        }
        g_free(rawdevices);
 
@@ -423,8 +422,6 @@ int usb_host_set_event_cb(device_changed_cb usr_callback, void *usr_data)
 {
        int ret = MTP_ERROR_NONE;
 
-       MTP_LOGE();
-
        ret = __dbus_subscribe_usb_host_event(usr_callback, usr_data);
 
        return ret;
@@ -478,7 +475,7 @@ mtp_error_e mtp_daemon_event_init(mtp_context *mtp_ctx)
                }
        }
 
-       MTP_LOGE("now, number of devices and thread is %d", mtp_ctx->device_list->device_num);
+       MTP_LOGI("number of Devices and Thread is %d", mtp_ctx->device_list->device_num);
 
        if (mtp_ctx->device_list->device_num == 0)
                return MTP_ERROR_NO_DEVICE;
index a80122d7e6c74294ba893eef7093e9c7953aec3b..7d5146122541454075f52e8d3d063e4d706887ae 100755 (executable)
@@ -260,7 +260,7 @@ static void on_bus_acquired(GDBusConnection *connection,
 {
        mtp_context* mtp_ctx = (mtp_context*)user_data;
 
-       MTP_LOGE("path : %s", path);
+       MTP_LOGI("path: %s", path);
 
        mtp_ctx->connection = connection;
 
@@ -288,7 +288,7 @@ static void on_name_acquired(GDBusConnection *connection,
 {
        mtp_context* mtp_ctx = (mtp_context*)user_data;
 
-       MTP_LOGE("name : %s", name);
+       MTP_LOGI("name: %s", name);
 
        if (mtp_daemon_event_init(mtp_ctx) != MTP_ERROR_NONE)
                g_main_loop_quit(mtp_ctx->main_loop);
@@ -298,7 +298,7 @@ static void on_name_lost(GDBusConnection *connnection,
                        const gchar *name,
                        gpointer user_data)
 {
-       MTP_LOGE("name : %s", name);
+       MTP_LOGI("name : %s", name);
 }
 
 mtp_error_e mtp_daemon_gdbus_init(mtp_context *mtp_ctx)
@@ -312,14 +312,14 @@ mtp_error_e mtp_daemon_gdbus_init(mtp_context *mtp_ctx)
                mtp_ctx,
                NULL);
 
-       MTP_LOGE("mtp_ctx->bus_id : %d", mtp_ctx->bus_id);
+       MTP_LOGI("mtp_ctx->bus_id: %d", mtp_ctx->bus_id);
 
        return MTP_ERROR_NONE;
 }
 
 mtp_error_e mtp_daemon_gdbus_emit_event(mtp_event event, int arg1, mtp_context *mtp_ctx)
 {
-       MTP_LOGE("signal emit event : %d, arg1 : %d", event, arg1);
+       MTP_LOGI("signal emit event: %d, arg1: %d", event, arg1);
 
        mtp_gdbuslib_manager_emit_mtp_event(mtp_ctx->manager, event, arg1);
 
index ba99d65ddba2397468a1143e86a8a87fb2ca95d1..a76318794b4123b620f80f0c6d924272ca658194 100755 (executable)
@@ -26,21 +26,32 @@ static void __deviceinfo_get_manufacturername_thread_func(gpointer user_data)
        mtp_error_e result = MTP_ERROR_NONE;
        LIBMTP_mtpdevice_t *device;
        char *name = NULL;
+       mtp_device_info *device_info;
+       int device_id;
 
        /* check precondition */
        g_assert(param != NULL);
        g_assert(param->object != NULL);
        g_assert(param->invocation != NULL);
 
-       MTP_LOGE(">>> Call deviceinfo_get_manufacturername_thread_func");
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-
-       /* do process */
-       name = LIBMTP_Get_Manufacturername(device);
+       device_id = param->param1;
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
+
+       if (device_info != NULL) {
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
+
+               /* do process */
+               name = LIBMTP_Get_Manufacturername(device);
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               name = strdup("No Device");
+               result = MTP_ERROR_NO_DEVICE;
+       }
 
-       MTP_LOGE("name : %s, device handle : %p", name, device);
+       MTP_LOGI("name: %s, device handle: %p", name, device);
 
        mtp_gdbuslib_deviceinfo_complete_get_manufacturername(param->object,
                param->invocation, name, result);
@@ -59,21 +70,32 @@ static void __deviceinfo_get_modelname_thread_func(gpointer user_data)
        mtp_error_e result = MTP_ERROR_NONE;
        LIBMTP_mtpdevice_t *device;
        char *name = NULL;
+       mtp_device_info *device_info;
+       int device_id;
 
        /* check precondition */
        g_assert(param != NULL);
        g_assert(param->object != NULL);
        g_assert(param->invocation != NULL);
 
-       MTP_LOGE(">>> Call deviceinfo_get_modelname_thread_func");
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-
-       /* do process */
-       name = LIBMTP_Get_Modelname(device);
+       device_id = param->param1;
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
+
+       if (device_info != NULL) {
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
+
+               /* do process */
+               name = LIBMTP_Get_Modelname(device);
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               name = strdup("No Device");
+               result = MTP_ERROR_NO_DEVICE;
+       }
 
-       MTP_LOGE("name : %s, device handle : %p", name, device);
+       MTP_LOGI("name: %s, device handle: %p", name, device);
 
        mtp_gdbuslib_deviceinfo_complete_get_modelname(param->object,
                param->invocation, name, result);
@@ -90,26 +112,38 @@ static void __deviceinfo_get_serialnumber_thread_func(gpointer user_data)
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
        LIBMTP_mtpdevice_t *device;
-       char *name = NULL;
+       char *number = NULL;
+       mtp_device_info *device_info;
+       int device_id;
 
        g_assert(param != NULL);
        g_assert(param->object != NULL);
        g_assert(param->invocation != NULL);
 
-       MTP_LOGE(">>> Call deviceinfo_get_serialnumber_thread_func");
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-
-       name = LIBMTP_Get_Serialnumber(device);
+       device_id = param->param1;
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
+
+       if (device_info != NULL) {
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
+
+               /* do process */
+               number = LIBMTP_Get_Serialnumber(device);
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               number = strdup("No Device");
+               result = MTP_ERROR_NO_DEVICE;
+       }
 
-       MTP_LOGE("name : %s, device handle : %p", name, device);
+       MTP_LOGI("name: %s, device handle: %p", number, device);
 
        mtp_gdbuslib_deviceinfo_complete_get_serialnumber(param->object,
-               param->invocation, name, result);
+               param->invocation, number, result);
 
        /* deinitializing */
-       g_free(name);
+       g_free(number);
        g_object_unref(param->invocation);
        g_object_unref(param->object);
        g_free(param);
@@ -120,26 +154,38 @@ static void __deviceinfo_get_deviceversion_thread_func(gpointer user_data)
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
        LIBMTP_mtpdevice_t *device;
-       char *name = NULL;
+       char *version = NULL;
+       mtp_device_info *device_info;
+       int device_id;
 
        g_assert(param != NULL);
        g_assert(param->object != NULL);
        g_assert(param->invocation != NULL);
 
-       MTP_LOGE(">>> Call deviceinfo_get_deviceversion_thread_func");
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-
-       name = LIBMTP_Get_Deviceversion(device);
+       device_id = param->param1;
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
+
+       if (device_info != NULL) {
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
+
+               /* do process */
+               version = LIBMTP_Get_Deviceversion(device);
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               version = strdup("No Device");
+               result = MTP_ERROR_NO_DEVICE;
+       }
 
-       MTP_LOGE("name : %s, device handle: %p", name, device);
+       MTP_LOGI("version: %s, device handle: %p", version, device);
 
        mtp_gdbuslib_deviceinfo_complete_get_deviceversion(param->object,
-               param->invocation, name, result);
+               param->invocation, version, result);
 
        /* deinitializing */
-       g_free(name);
+       g_free(version);
        g_object_unref(param->invocation);
        g_object_unref(param->object);
        g_free(param);
@@ -154,7 +200,7 @@ gboolean deviceinfo_get_manufacturername(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
@@ -203,7 +249,7 @@ gboolean deviceinfo_get_modelname(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
@@ -251,7 +297,7 @@ gboolean deviceinfo_get_serialnumber(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
@@ -299,7 +345,7 @@ gboolean deviceinfo_get_deviceversion(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
index 5196c2cc74269467d30ab8b2de1115422bade6ee..cf54507e5ab6be5f511edb65a27d90af2cf1897f 100755 (executable)
@@ -41,7 +41,7 @@ static void __manager_get_device_list_thread_func(gpointer user_data)
        g_assert(param->invocation != NULL);
        g_assert(param->mtp_ctx != NULL);
 
-       MTP_LOGI("%s", __func__);
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
        object = (mtpgdbuslibManager *)(param->object);
@@ -50,7 +50,7 @@ static void __manager_get_device_list_thread_func(gpointer user_data)
        g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
 
        count = param->mtp_ctx->device_list->device_num;
-       MTP_LOGE("devices_num : %d", count);
+       MTP_LOGI("devices_num: %d", count);
 
        for (slot = 1; slot < MTP_MAX_SLOT; slot++) {
                mtp_device_info *device_info;
@@ -94,7 +94,7 @@ static void __manager_get_device_handle_thread_func(gpointer user_data)
        g_assert(param->object != NULL);
        g_assert(param->invocation != NULL);
 
-       MTP_LOGI("%s", __func__);
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
        busno = (int)(param->param1);
@@ -105,17 +105,19 @@ static void __manager_get_device_handle_thread_func(gpointer user_data)
                mtp_device_info *device_info = NULL;
                device_info = param->mtp_ctx->device_list->device_info_list[slot];
 
-               if (busno == device_info->bus_location) {
+               if (device_info != NULL && busno == device_info->bus_location) {
                        handle = slot;
-                       MTP_LOGI("handle : %d, device : %p", handle, device_info->device);
+                       MTP_LOGI("handle: %d, device: %p", handle, device_info->device);
                        break;
                }
        }
 
        if (handle != -1)
-               MTP_LOGE("found MTP device - handle : %p, bus: %d", handle, busno);
-       else
+               MTP_LOGI("found MTP device - handle: %p, bus: %d", handle, busno);
+       else {
                MTP_LOGE("!!! not found MTP device handle - bus: %d", busno);
+               result = MTP_ERROR_NO_DEVICE;
+       }
 
        mtp_gdbuslib_manager_complete_get_device_handle(object, param->invocation, handle, result);
 
@@ -130,8 +132,10 @@ static void __manager_get_storage_ids_thread_func(gpointer user_data)
        /* variable definition */
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
-       LIBMTP_mtpdevice_t *device;
+       LIBMTP_mtpdevice_t *device = NULL;
        LIBMTP_devicestorage_t *storage;
+       mtp_device_info *device_info;
+       int device_id;
        int count = 0;
 
        GVariant *gv = NULL;
@@ -143,31 +147,41 @@ static void __manager_get_storage_ids_thread_func(gpointer user_data)
        g_assert(param->invocation != NULL);
        g_assert(param->mtp_ctx != NULL);
 
-       MTP_LOGI("%s", __func__);
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-       MTP_LOGI("param->param1 %d, device %p", param->param1, device);
+       device_id = param->param1;
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
+
+       if (device_info != NULL)
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
+
+       MTP_LOGI("device_id: %d, device: %p", device_id, device);
 
        /* loop over storages */
        g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
 
-       for (storage = device->storage; storage != NULL; storage = storage->next) {
-               MTP_LOGE("storage : %p", storage);
+       if (device_info != NULL) {
+               for (storage = device->storage; storage != NULL; storage = storage->next) {
+                       MTP_LOGI("storage: %p", storage);
 
-               g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
+                       g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
 
-               g_variant_builder_add(&b, "{sv}", "storage_id",
-                       g_variant_new_int32(storage->id));
+                       g_variant_builder_add(&b, "{sv}", "storage_id",
+                               g_variant_new_int32(storage->id));
 
-               g_variant_builder_close(&b);
+                       g_variant_builder_close(&b);
 
-               count++;
+                       count++;
+               }
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               result = MTP_ERROR_NO_DEVICE;
        }
 
        gv = g_variant_builder_end(&b);
 
-       MTP_LOGE("storage_num : %d", count);
+       MTP_LOGI("storage_num: %d", count);
 
        mtp_gdbuslib_manager_complete_get_storage_ids(param->object,
                param->invocation, count, gv, result);
@@ -183,10 +197,12 @@ static void __manager_get_object_handles_thread_func(gpointer user_data)
        /* variable definition */
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
+       mtp_device_info *device_info;
+       LIBMTP_mtpdevice_t *device = NULL;
 
-       LIBMTP_mtpdevice_t *device;
        int ret;
        int slot;
+       int device_id;
        int storage_id;
        int format;
        int parent_object_handle;
@@ -206,76 +222,88 @@ static void __manager_get_object_handles_thread_func(gpointer user_data)
        /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-       MTP_LOGI("param->param1 %d, device %p", param->param1, device);
-
+       device_id = param->param1;
        storage_id = param->param2;
        format = param->param3;
        parent_object_handle = param->param4;
 
-       MTP_LOGI("storage id : %d", param->param2);
-       MTP_LOGI("format : %d", param->param3);
-       MTP_LOGI("parent : %d", param->param4);
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
 
-       ret = LIBMTP_Get_Object_Handles(device, (uint32_t)storage_id, (uint32_t)format, (uint32_t)parent_object_handle,
-               (uint32_t **)&object_list, (uint32_t *)&total_object_num);
+       if (device_info != NULL)
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
 
-       if (ret < 0)
-               MTP_LOGE("LIBMTP_Get_Object_Handles is failed : %d", ret);
+       MTP_LOGI("device_id: %d, storage id: %d, format: %d, parent: %d, device: %p",
+               param->param1, param->param2, param->param3, param->param4, device);
 
-       /*MTP_LOGI("Total Object number : %d", temp);*/
+       if (device_info != NULL) {
+               ret = LIBMTP_Get_Object_Handles(device, (uint32_t)storage_id,
+                       (uint32_t)format, (uint32_t)parent_object_handle,
+                       (uint32_t **)&object_list, (uint32_t *)&total_object_num);
 
-       /* loop over storages */
-       g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
+               if (ret < 0)
+                       MTP_LOGE("LIBMTP_Get_Object_Handles is failed : %d", ret);
+       }
 
-       mtp_daemon_db_begin(param->mtp_ctx);
+       /*MTP_LOGI("Total Object number: %d", temp);*/
 
-       for (slot = 0; slot < total_object_num; slot++) {
-               MTPObjectInfo *object_info = NULL;
-               object_info = LIBMTP_Get_Object_Info(device, (uint32_t)object_list[slot]);
+       /* loop over storages */
+       g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
 
-               if (object_info != NULL)
-                       mtp_daemon_db_insert(param->param1, storage_id, object_list[slot], object_info, param->mtp_ctx);
+       if (device_info != NULL) {
+               mtp_daemon_db_begin(param->mtp_ctx);
 
-               /*if (mtp_daemon_db_is_exist((int)device, object_list[i], param->mtp_ctx) == false) {
-                       MTP_LOGI("Objectinfo is not stored. %d, %d", device, object_list[i]);
-                       object_info = LIBMTP_Get_Object_Info(device, object_list[i]);
+               for (slot = 0; slot < total_object_num; slot++) {
+                       MTPObjectInfo *object_info = NULL;
+                       /*object_info = LIBMTP_Get_Object_Info(device, (uint32_t)object_list[slot]);
 
                        if (object_info != NULL)
-                               mtp_daemon_db_insert(device, storage_id, object_list[i], object_info, param->mtp_ctx);
-               } else {
-                       MTP_LOGI("Objectinfo is stored. ");
-                       object_info = mtp_daemon_db_get_object_info(device, object_list[i], param->mtp_ctx);
-               }*/
+                               mtp_daemon_db_insert(device_id, storage_id, object_list[slot], object_info, param->mtp_ctx);*/
+
+                       if (mtp_daemon_db_is_exist(device_id, object_list[slot], param->mtp_ctx) == false) {
+                               MTP_LOGI("Objectinfo is Not stored. device_id: %d, object_list[%d]: %d",
+                                       device_id, slot, object_list[slot]);
+                               object_info = LIBMTP_Get_Object_Info(device, (uint32_t)object_list[slot]);
+
+                               if (object_info != NULL)
+                                       mtp_daemon_db_insert(device_id, storage_id, object_list[slot], object_info, param->mtp_ctx);
+                       } else {
+                               MTP_LOGI("Objectinfo is stored. device_id: %d, object_list[%d]: %d",
+                                       device_id, slot, object_list[slot]);
+                               object_info = mtp_daemon_db_get_object_info(device_id, object_list[slot], param->mtp_ctx);
+                       }
 
-               if (object_info != NULL) {
-                       /*MTP_LOGI("object id : %d, format : %d, filename : %s", object_list[i],
-                                                       object_info->ObjectFormat, object_info->Filename);*/
+                       if (object_info != NULL) {
+                               /*MTP_LOGI("object id: %d, format : %d, filename : %s", object_list[slot],
+                                       object_info->ObjectFormat, object_info->Filename);*/
 
-                       if ((format == LIBMTP_FILETYPE_ALL &&
-                                       (object_info->ObjectFormat == LIBMTP_FILETYPE_FOLDER ||
-                                       LIBMTP_FILETYPE_IS_IMAGE(object_info->ObjectFormat))) ||
-                               (format == LIBMTP_FILETYPE_ALL_IMAGE &&
-                                       LIBMTP_FILETYPE_IS_IMAGE(object_info->ObjectFormat)) ||
-                               (format == object_info->ObjectFormat)) {
-                               g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
+                               if ((format == LIBMTP_FILETYPE_ALL &&
+                                               (object_info->ObjectFormat == LIBMTP_FILETYPE_FOLDER ||
+                                               LIBMTP_FILETYPE_IS_IMAGE(object_info->ObjectFormat))) ||
+                                       (format == LIBMTP_FILETYPE_ALL_IMAGE &&
+                                               LIBMTP_FILETYPE_IS_IMAGE(object_info->ObjectFormat)) ||
+                                       (format == object_info->ObjectFormat)) {
+                                       g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
 
-                               g_variant_builder_add(&b, "{sv}", "object_handle",
-                               g_variant_new_int32(object_list[slot]));
+                                       g_variant_builder_add(&b, "{sv}", "object_handle",
+                                       g_variant_new_int32(object_list[slot]));
 
-                               g_variant_builder_close(&b);
+                                       g_variant_builder_close(&b);
 
-                               target_object_num++;
+                                       target_object_num++;
+                               }
                        }
+                       g_free(object_info);
                }
-               g_free(object_info);
-       }
 
-       mtp_daemon_db_commit(param->mtp_ctx);
+               mtp_daemon_db_commit(param->mtp_ctx);
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               result = MTP_ERROR_NO_DEVICE;
+       }
 
        gv = g_variant_builder_end(&b);
 
-       /*MTP_LOGE("Real object_num : %d", target_object_num);*/
+       /*MTP_LOGI("Real object_num: %d", target_object_num);*/
 
        mtp_gdbuslib_manager_complete_get_object_handles(param->object,
                param->invocation, target_object_num, gv, result);
@@ -291,12 +319,14 @@ static void __manager_get_object_handles_thread_func(gpointer user_data)
 static void __manager_get_object_thread_func(gpointer user_data)
 {
        /* variable definition */
-       int ret;
-       int fd;
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
+       int ret;
+       int fd;
 
        LIBMTP_mtpdevice_t *device;
+       mtp_device_info *device_info;
+       int device_id;
        int object_handle;
        char *dest_path;
 
@@ -309,34 +339,42 @@ static void __manager_get_object_thread_func(gpointer user_data)
        /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-       MTP_LOGI("param->param1 %d, device %p", param->param1, device);
-
+       device_id = param->param1;
        object_handle = param->param2;
        dest_path = param->char_param1;
 
-       /* file open */
-       if (access(dest_path, F_OK) >= 0) {
-               MTP_LOGE("file exist - dest_path : %s", dest_path);
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
 
-               if (unlink(dest_path) < 0)
-                       MTP_LOGE("remove fail - dest_path : %s", dest_path);
-       }
+       if (device_info != NULL) {
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
+               MTP_LOGI("device_id: %d, device: %p, dest_path: %s", device_id, device, dest_path);
 
-       fd = open(dest_path, O_WRONLY | O_CREAT | O_EXCL, 0644);
+               /* file open */
+               if (access(dest_path, F_OK) >= 0) {
+                       MTP_LOGE("file exist - dest_path: %s", dest_path);
 
-       if (fd < 0) {
-               MTP_LOGE("%s file open fail - fd : %d, dest_path : %s", __func__, fd, dest_path);
-               result = MTP_ERROR_GENERAL;
-       } else {
-               ret = LIBMTP_Get_File_To_File_Descriptor(device, object_handle, fd, NULL, NULL);
-
-               if (ret != 0) {
-                       MTP_LOGE("get descriptor fail - ret : %d", ret);
-                       result = MTP_ERROR_PLUGIN;
+                       if (unlink(dest_path) < 0)
+                               MTP_LOGE("remove fail - dest_path: %s", dest_path);
                }
 
-               close(fd);
+               fd = open(dest_path, O_WRONLY | O_CREAT | O_EXCL, 0644);
+
+               if (fd < 0) {
+                       MTP_LOGE("file open fail - fd: %d, dest_path: %s", fd, dest_path);
+                       result = MTP_ERROR_GENERAL;
+               } else {
+                       ret = LIBMTP_Get_File_To_File_Descriptor(device, object_handle, fd, NULL, NULL);
+
+                       if (ret != 0) {
+                               MTP_LOGE("get descriptor fail - ret: %d", ret);
+                               result = MTP_ERROR_PLUGIN;
+                       }
+
+                       close(fd);
+               }
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               result = MTP_ERROR_NO_DEVICE;
        }
 
        mtp_gdbuslib_manager_complete_get_object(param->object,
@@ -353,14 +391,16 @@ static void __manager_get_object_thread_func(gpointer user_data)
 static void __manager_get_thumbnail_thread_func(gpointer user_data)
 {
        /* variable definition */
-       int ret;
-       int fd;
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
        unsigned char *thumb_data;
        unsigned int thumb_size;
+       int ret;
+       int fd;
 
        LIBMTP_mtpdevice_t *device;
+       mtp_device_info *device_info;
+       int device_id;
        int object_handle;
        char *dest_path;
 
@@ -373,40 +413,46 @@ static void __manager_get_thumbnail_thread_func(gpointer user_data)
        /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-       MTP_LOGI("param->param1 %d, device %p", param->param1, device);
-
+       device_id = param->param1;
        object_handle = param->param2;
        dest_path = param->char_param1;
 
-       /*MTP_LOGI("dest_path : %s", dest_path);*/
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
 
-       /* file open */
-       if (access(dest_path, F_OK) >= 0) {
-               MTP_LOGE("file exist - dest_path : %s", dest_path);
+       if (device_info != NULL) {
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
+               MTP_LOGI("device_id: %d, device: %p, dest_path: %s", device_id, device, dest_path);
 
-               if (unlink(dest_path) < 0)
-                       MTP_LOGE("remove fail - dest_path : %s", dest_path);
-       }
+               /* file open */
+               if (access(dest_path, F_OK) >= 0) {
+                       MTP_LOGE("file exist - dest_path: %s", dest_path);
 
-       fd = open(dest_path, O_WRONLY | O_CREAT | O_EXCL, 0644);
+                       if (unlink(dest_path) < 0)
+                               MTP_LOGE("remove fail - dest_path: %s", dest_path);
+               }
 
-       if (fd < 0) {
-               MTP_LOGE("%s file open fail - fd : %d, dest_path : %s", __func__, fd, dest_path);
-               result = MTP_ERROR_GENERAL;
-       } else {
-               ret = LIBMTP_Get_Thumbnail(device, object_handle, &thumb_data, &thumb_size);
+               fd = open(dest_path, O_WRONLY | O_CREAT | O_EXCL, 0644);
 
-               if (ret == 0) {
-                       ret = write(fd, thumb_data, thumb_size);
-                       if (ret == 0)
-                               result = MTP_ERROR_ALLOC_FAIL;
+               if (fd < 0) {
+                       MTP_LOGE("file open fail - fd: %d, dest_path: %s", fd, dest_path);
+                       result = MTP_ERROR_GENERAL;
                } else {
-                       MTP_LOGE("get thumbnail fail - ret : %d", ret);
-                       result = MTP_ERROR_PLUGIN;
-               }
+                       ret = LIBMTP_Get_Thumbnail(device, object_handle, &thumb_data, &thumb_size);
+
+                       if (ret == 0) {
+                               ret = write(fd, thumb_data, thumb_size);
+                               if (ret == 0)
+                                       result = MTP_ERROR_ALLOC_FAIL;
+                       } else {
+                               MTP_LOGE("get thumbnail fail - ret: %d", ret);
+                               result = MTP_ERROR_PLUGIN;
+                       }
 
-               close(fd);
+                       close(fd);
+               }
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               result = MTP_ERROR_NO_DEVICE;
        }
 
        mtp_gdbuslib_manager_complete_get_thumbnail(param->object,
@@ -428,6 +474,8 @@ static void __manager_delete_object_thread_func(gpointer user_data)
        mtp_error_e result = MTP_ERROR_NONE;
 
        LIBMTP_mtpdevice_t *device;
+       mtp_device_info *device_info;
+       int device_id;
        int object_handle;
 
        /* check precondition */
@@ -439,14 +487,23 @@ static void __manager_delete_object_thread_func(gpointer user_data)
        MTP_LOGI("%s", __func__);
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-       MTP_LOGI("param->param1 %d, device %p", param->param1, device);
+       device_id = param->param1;
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
 
-       object_handle = param->param2;
+       if (device_info != NULL) {
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
+
+               MTP_LOGI("device_id: %d, device: %p", device_id, device);
+
+               object_handle = param->param2;
 
-       ret = LIBMTP_Delete_Object(device, object_handle);
-       if (ret != 0)
-               result = MTP_ERROR_PLUGIN;
+               ret = LIBMTP_Delete_Object(device, object_handle);
+               if (ret != 0)
+                       result = MTP_ERROR_PLUGIN;
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               result = MTP_ERROR_NO_DEVICE;
+       }
 
        mtp_gdbuslib_manager_complete_delete_object(param->object,
                param->invocation, result);
@@ -466,7 +523,7 @@ gboolean manager_get_device_list(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
@@ -513,7 +570,7 @@ gboolean manager_get_device_handle(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
@@ -561,7 +618,7 @@ gboolean manager_get_storage_ids(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
@@ -773,7 +830,7 @@ gboolean manager_delete_object(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
index 8327f80b86168de73235fb3490644f886e180541..dfb2d6d32f79fb9bc6f28820e29451e11fa5f028 100755 (executable)
@@ -24,6 +24,8 @@ static void __objectinfo_get_property_thread_func(gpointer user_data)
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
        LIBMTP_mtpdevice_t *device_handle;
+       mtp_device_info *device_info;
+       int device_id;
        int object_handle;
        mtp_property_e property;
        int property_value = 0;
@@ -33,80 +35,90 @@ static void __objectinfo_get_property_thread_func(gpointer user_data)
        g_assert(param->object != NULL);
        g_assert(param->invocation != NULL);
 
-       MTP_LOGE(">>> Call objectinfo_get_property_thread_func");
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device_handle = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
+       device_id = param->param1;
        object_handle = param->param2;
        property = param->param3;
-       MTP_LOGI("param->param1 %d, device %p", param->param1, device_handle);
 
-       MTP_LOGE("Get property start - property %d", property);
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
 
-       if (mtp_daemon_db_is_exist(param->param1, object_handle, param->mtp_ctx) == false) {
-               object_info = LIBMTP_Get_Object_Info(device_handle, object_handle);
+       if (device_info != NULL) {
+               device_handle = (LIBMTP_mtpdevice_t *)device_info->device;
+               /*MTP_LOGI("device_id: %d, device: %p", device_id, device_handle);*/
 
-               if (object_info != NULL)
-                       mtp_daemon_db_insert(param->param1, object_info->StorageID, object_handle, object_info, param->mtp_ctx);
-       } else {
-               object_info = mtp_daemon_db_get_object_info(param->param1, object_handle, param->mtp_ctx);
-       }
+               MTP_LOGI("Get property start - property %d", property);
+
+               if (mtp_daemon_db_is_exist(device_id, object_handle, param->mtp_ctx) == false) {
+                       object_info = LIBMTP_Get_Object_Info(device_handle, object_handle);
+
+                       if (object_info != NULL)
+                               mtp_daemon_db_insert(device_id, object_info->StorageID, object_handle, object_info, param->mtp_ctx);
+               } else {
+                       object_info = mtp_daemon_db_get_object_info(device_id, object_handle, param->mtp_ctx);
+               }
 
-       if (object_info != NULL) {
-               switch (property) {
-               case MTP_PROPERTY_ASSOCIATION_DESC:
-                       property_value = object_info->AssociationDesc;
-                       break;
-               case MTP_PROPERTY_ASSOCIATION_TYPE:
-                       property_value = object_info->AssociationType;
-                       break;
-               case MTP_PROPERTY_SIZE:
-                       property_value = object_info->ObjectCompressedSize;
-                       break;
-               case MTP_PROPERTY_FORMAT:
-                       property_value = object_info->ObjectFormat;
-                       break;
-               case MTP_PROPERTY_IMAGE_FIX_DEPTH:
-                       property_value = object_info->ImageBitDepth;
-                       break;
-               case MTP_PROPERTY_IMAGE_FIX_WIDTH:
-                       property_value = object_info->ImagePixWidth;
-                       break;
-               case MTP_PROPERTY_IMAGE_FIX_HEIGHT:
-                       property_value = object_info->ImagePixHeight;
-                       break;
-               case MTP_PROPERTY_PARENT_OBJECT_HANDLE:
-                       property_value = object_info->ParentObject;
-                       break;
-               case MTP_PROPERTY_STORAGE_ID:
-                       property_value = object_info->StorageID;
-                       break;
-               case MTP_PROPERTY_THUMBNAIL_SIZE:
-                       property_value = object_info->ThumbCompressedSize;
-                       break;
-               case MTP_PROPERTY_THUMBNAIL_FORMAT:
-                       property_value = object_info->ThumbFormat;
-                       break;
-               case MTP_PROPERTY_THUMBNAIL_WIDTH:
-                       property_value = object_info->ThumbPixWidth;
-                       break;
-               case MTP_PROPERTY_THUMBNAIL_HEIGHT:
-                       property_value = object_info->ThumbPixHeight;
-                       break;
-               case MTP_PROPERTY_DATA_CREATED:
-                       property_value = object_info->CaptureDate;
-                       break;
-               case MTP_PROPERTY_DATA_MODIFIED:
-                       property_value = object_info->ModificationDate;
-                       break;
-               default:
-                       property_value = 0;
-                       break;
+               if (object_info != NULL) {
+                       switch (property) {
+                       case MTP_PROPERTY_ASSOCIATION_DESC:
+                               property_value = object_info->AssociationDesc;
+                               break;
+                       case MTP_PROPERTY_ASSOCIATION_TYPE:
+                               property_value = object_info->AssociationType;
+                               break;
+                       case MTP_PROPERTY_SIZE:
+                               property_value = object_info->ObjectCompressedSize;
+                               break;
+                       case MTP_PROPERTY_FORMAT:
+                               property_value = object_info->ObjectFormat;
+                               break;
+                       case MTP_PROPERTY_IMAGE_FIX_DEPTH:
+                               property_value = object_info->ImageBitDepth;
+                               break;
+                       case MTP_PROPERTY_IMAGE_FIX_WIDTH:
+                               property_value = object_info->ImagePixWidth;
+                               break;
+                       case MTP_PROPERTY_IMAGE_FIX_HEIGHT:
+                               property_value = object_info->ImagePixHeight;
+                               break;
+                       case MTP_PROPERTY_PARENT_OBJECT_HANDLE:
+                               property_value = object_info->ParentObject;
+                               break;
+                       case MTP_PROPERTY_STORAGE_ID:
+                               property_value = object_info->StorageID;
+                               break;
+                       case MTP_PROPERTY_THUMBNAIL_SIZE:
+                               property_value = object_info->ThumbCompressedSize;
+                               break;
+                       case MTP_PROPERTY_THUMBNAIL_FORMAT:
+                               property_value = object_info->ThumbFormat;
+                               break;
+                       case MTP_PROPERTY_THUMBNAIL_WIDTH:
+                               property_value = object_info->ThumbPixWidth;
+                               break;
+                       case MTP_PROPERTY_THUMBNAIL_HEIGHT:
+                               property_value = object_info->ThumbPixHeight;
+                               break;
+                       case MTP_PROPERTY_DATA_CREATED:
+                               property_value = object_info->CaptureDate;
+                               break;
+                       case MTP_PROPERTY_DATA_MODIFIED:
+                               property_value = object_info->ModificationDate;
+                               break;
+                       default:
+                               property_value = 0;
+                               break;
+                       }
+                       MTP_LOGI("Get property end, value is %d", property_value);
+               } else {
+                       property_value = -999;
+                       MTP_LOGE("object_info is NULL!!");
                }
-               MTP_LOGE("Get property end, value is %d", property_value);
        } else {
+               MTP_LOGE("!!! no MTP device");
                property_value = -999;
-               MTP_LOGE("object_info is NULL!!");
+               result = MTP_ERROR_NO_DEVICE;
        }
 
        mtp_gdbuslib_objectinfo_complete_get_property(param->object,
@@ -124,6 +136,8 @@ static void __objectinfo_get_property_string_thread_func(gpointer user_data)
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
        LIBMTP_mtpdevice_t *device_handle;
+       mtp_device_info *device_info;
+       int device_id;
        int object_handle;
        mtp_property_e property;
        char *property_value = NULL;
@@ -133,41 +147,51 @@ static void __objectinfo_get_property_string_thread_func(gpointer user_data)
        g_assert(param->object != NULL);
        g_assert(param->invocation != NULL);
 
-       MTP_LOGE(">>> Call objectinfo_get_property_thread_func");
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device_handle = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
+       device_id = param->param1;
        object_handle = param->param2;
        property = param->param3;
-       MTP_LOGI("param->param1 %d, device %p", param->param1, device_handle);
 
-       MTP_LOGE("Get property start - property %d", property);
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
 
-       if (mtp_daemon_db_is_exist(param->param1, object_handle, param->mtp_ctx) == false) {
-               object_info = LIBMTP_Get_Object_Info(device_handle, object_handle);
+       if (device_info != NULL) {
+               device_handle = (LIBMTP_mtpdevice_t *)device_info->device;
+               /*MTP_LOGI("device_id: %d, device: %p", device_id, device_handle);*/
 
-               if (object_info != NULL)
-                       mtp_daemon_db_insert(param->param1, object_info->StorageID, object_handle, object_info, param->mtp_ctx);
-       } else {
-               object_info = mtp_daemon_db_get_object_info(param->param1, object_handle, param->mtp_ctx);
-       }
+               MTP_LOGI("Get property start - property %d", property);
+
+               if (mtp_daemon_db_is_exist(device_id, object_handle, param->mtp_ctx) == false) {
+                       object_info = LIBMTP_Get_Object_Info(device_handle, object_handle);
+
+                       if (object_info != NULL)
+                               mtp_daemon_db_insert(device_id, object_info->StorageID, object_handle, object_info, param->mtp_ctx);
+               } else {
+                       object_info = mtp_daemon_db_get_object_info(device_id, object_handle, param->mtp_ctx);
+               }
 
-       if (object_info != NULL) {
-               switch (property) {
-               case MTP_PROPERTY_FILENAME:
-                       property_value = object_info->Filename;
-                       break;
-               case MTP_PROPERTY_KEYWORD:
-                       property_value = object_info->Keywords;
-                       break;
-               default:
+               if (object_info != NULL) {
+                       switch (property) {
+                       case MTP_PROPERTY_FILENAME:
+                               property_value = object_info->Filename;
+                               break;
+                       case MTP_PROPERTY_KEYWORD:
+                               property_value = object_info->Keywords;
+                               break;
+                       default:
+                               property_value = NULL;
+                               break;
+                       }
+                       MTP_LOGI("Get property end, value is %d", property_value);
+               } else {
                        property_value = NULL;
-                       break;
+                       MTP_LOGE("object_info is NULL!!");
                }
-               MTP_LOGE("Get property end, value is %d", property_value);
        } else {
+               MTP_LOGE("!!! no MTP device");
                property_value = NULL;
-               MTP_LOGE("object_info is NULL!!");
+               result = MTP_ERROR_NO_DEVICE;
        }
 
        mtp_gdbuslib_objectinfo_complete_get_property_string(param->object,
@@ -191,7 +215,7 @@ gboolean objectinfo_get_property(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
@@ -245,7 +269,7 @@ gboolean objectinfo_get_property_string(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
index e46c6baee312e87a5fb5aedafde32cf8161599a4..5c9755a3cc381fe3b812bf775b1d8d63c7e51548 100755 (executable)
@@ -22,29 +22,41 @@ static void __storageinfo_get_description_thread_func(gpointer user_data)
 {
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
+       int device_id;
        int storage_id;
        LIBMTP_mtpdevice_t *device;
        LIBMTP_devicestorage_t *storage;
+       mtp_device_info *device_info;
        char *name = NULL;
 
        g_assert(param != NULL);
        g_assert(param->object != NULL);
        g_assert(param->invocation != NULL);
 
-       MTP_LOGE(">>> Call storageinfo_get_description_thread_func");
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-       storage_id = param->param2;
-       MTP_LOGI("param->param1 %d, device %p", param->param1, device);
+       device_id = param->param1;
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
 
-       storage = mtp_daemon_util_get_storage_handle(device,
-               storage_id, param->mtp_ctx);
+       if (device_info != NULL) {
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
 
-       if (storage)
-               name = storage->StorageDescription;
+               storage_id = param->param2;
+               MTP_LOGI("device_id: %d, device: %p, storage_id: %d", device_id, device, storage_id);
 
-       MTP_LOGI("StorageDescription : %s, storage handle: %p", name, storage);
+               storage = mtp_daemon_util_get_storage_handle(device,
+                       storage_id, param->mtp_ctx);
+
+               if (storage)
+                       name = storage->StorageDescription;
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               name = strdup("No Device");
+               result = MTP_ERROR_NO_DEVICE;
+       }
+
+       MTP_LOGI("StorageDescription: %s, storage handle: %p", name, storage);
 
        mtp_gdbuslib_storageinfo_complete_get_description(param->object,
                param->invocation, name, result);
@@ -58,29 +70,40 @@ static void __storageinfo_get_freespace_thread_func(gpointer user_data)
 {
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
+       int device_id;
        int storage_id;
        LIBMTP_mtpdevice_t *device;
        LIBMTP_devicestorage_t *storage;
+       mtp_device_info *device_info;
        guint64 value = 0;
 
        g_assert(param != NULL);
        g_assert(param->object != NULL);
        g_assert(param->invocation != NULL);
 
-       MTP_LOGE(">>> Call storageinfo_get_freespace_thread_func");
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-       storage_id = param->param2;
-       MTP_LOGI("param->param1 %d, device %p", param->param1, device);
+       device_id = param->param1;
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
+
+       if (device_info != NULL) {
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
 
-       storage = mtp_daemon_util_get_storage_handle(device,
-               storage_id, param->mtp_ctx);
+               storage_id = param->param2;
+               MTP_LOGI("device_id: %d, device: %p, storage_id: %d", device_id, device, storage_id);
 
-       if (storage)
-               value = storage->FreeSpaceInBytes;
+               storage = mtp_daemon_util_get_storage_handle(device,
+                       storage_id, param->mtp_ctx);
 
-       MTP_LOGI("FreeSpaceInBytes : %llu, storage handle: %p", value, storage);
+               if (storage)
+                       value = storage->FreeSpaceInBytes;
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               result = MTP_ERROR_NO_DEVICE;
+       }
+
+       MTP_LOGI("FreeSpaceInBytes: %llu, storage handle: %p", value, storage);
 
        mtp_gdbuslib_storageinfo_complete_get_free_space(param->object,
                param->invocation, value, result);
@@ -94,29 +117,40 @@ static void __storageinfo_get_maxcapacity_thread_func(gpointer user_data)
 {
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
+       int device_id;
        int storage_id;
        LIBMTP_mtpdevice_t *device;
        LIBMTP_devicestorage_t *storage;
+       mtp_device_info *device_info;
        guint64 value = 0;
 
        g_assert(param != NULL);
        g_assert(param->object != NULL);
        g_assert(param->invocation != NULL);
 
-       MTP_LOGE(">>> Call storageinfo_get_maxcapacity_thread_func");
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-       storage_id = param->param2;
-       MTP_LOGI("param->param1 %d, device %p", param->param1, device);
+       device_id = param->param1;
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
 
-       storage = mtp_daemon_util_get_storage_handle(device,
-               storage_id, param->mtp_ctx);
+       if (device_info != NULL) {
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
 
-       if (storage)
-               value = storage->MaxCapacity;
+               storage_id = param->param2;
+               MTP_LOGI("device_id: %d, device: %p, storage_id: %d", device_id, device, storage_id);
 
-       MTP_LOGI("MaxCapacity : %llu, storage handle: %p", value, storage);
+               storage = mtp_daemon_util_get_storage_handle(device,
+                       storage_id, param->mtp_ctx);
+
+               if (storage)
+                       value = storage->MaxCapacity;
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               result = MTP_ERROR_NO_DEVICE;
+       }
+
+       MTP_LOGI("MaxCapacity: %llu, storage handle: %p", value, storage);
 
        mtp_gdbuslib_storageinfo_complete_get_max_capacity(param->object,
                param->invocation, value, result);
@@ -130,29 +164,40 @@ static void __storageinfo_get_storagetype_thread_func(gpointer user_data)
 {
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
+       int device_id;
        int storage_id;
        LIBMTP_mtpdevice_t *device;
        LIBMTP_devicestorage_t *storage;
+       mtp_device_info *device_info;
        int value = 0;
 
        g_assert(param != NULL);
        g_assert(param->object != NULL);
        g_assert(param->invocation != NULL);
 
-       MTP_LOGE(">>> Call storageinfo_get_storagetype_thread_func");
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-       storage_id = param->param2;
-       MTP_LOGI("param->param1 %d, device %p", param->param1, device);
+       device_id = param->param1;
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
+
+       if (device_info != NULL) {
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
 
-       storage = mtp_daemon_util_get_storage_handle(device,
-               storage_id, param->mtp_ctx);
+               storage_id = param->param2;
+               MTP_LOGI("device_id: %d, device: %p, storage_id: %d", device_id, device, storage_id);
 
-       if (storage)
-               value = storage->StorageType;
+               storage = mtp_daemon_util_get_storage_handle(device,
+                       storage_id, param->mtp_ctx);
+
+               if (storage)
+                       value = storage->StorageType;
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               result = MTP_ERROR_NO_DEVICE;
+       }
 
-       MTP_LOGI("StorageType : %d, storage handle: %p", value, storage);
+       MTP_LOGI("StorageType: %d, storage handle: %p", value, storage);
 
        mtp_gdbuslib_storageinfo_complete_get_storage_type(param->object,
                param->invocation, value, result);
@@ -166,29 +211,41 @@ static void __storageinfo_get_volumeidentifier_thread_func(gpointer user_data)
 {
        mtp_param *param = (mtp_param *)user_data;
        mtp_error_e result = MTP_ERROR_NONE;
+       int device_id;
        int storage_id;
        LIBMTP_mtpdevice_t *device;
        LIBMTP_devicestorage_t *storage;
+       mtp_device_info *device_info;
        char *name = NULL;
 
        g_assert(param != NULL);
        g_assert(param->object != NULL);
        g_assert(param->invocation != NULL);
 
-       MTP_LOGE(">>> Call storageinfo_get_volumeidentifier_thread_func");
+       /*MTP_LOGI("%s", __func__);*/
 
        /* parameter unpacking */
-       device = (LIBMTP_mtpdevice_t *)param->mtp_ctx->device_list->device_info_list[param->param1]->device;
-       storage_id = param->param2;
-       MTP_LOGI("param->param1 %d, device %p", param->param1, device);
+       device_id = param->param1;
+       device_info = (mtp_device_info *)param->mtp_ctx->device_list->device_info_list[device_id];
 
-       storage = mtp_daemon_util_get_storage_handle(device,
-               storage_id, param->mtp_ctx);
+       if (device_info != NULL) {
+               device = (LIBMTP_mtpdevice_t *)device_info->device;
 
-       if (storage)
-               name = storage->VolumeIdentifier;
+               storage_id = param->param2;
+               MTP_LOGI("device_id: %d, device: %p, storage_id: %d", device_id, device, storage_id);
+
+               storage = mtp_daemon_util_get_storage_handle(device,
+                       storage_id, param->mtp_ctx);
+
+               if (storage)
+                       name = storage->VolumeIdentifier;
+       } else {
+               MTP_LOGE("!!! no MTP device");
+               name = strdup("No Device");
+               result = MTP_ERROR_NO_DEVICE;
+       }
 
-       MTP_LOGI("VolumeIdentifier : %s, storage handle: %p", name, storage);
+       MTP_LOGI("VolumeIdentifier: %s, storage handle: %p", name, storage);
 
        mtp_gdbuslib_storageinfo_complete_get_volume_identifier(param->object,
                param->invocation, name, result);
@@ -208,7 +265,7 @@ gboolean storageinfo_get_description(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
@@ -258,7 +315,7 @@ gboolean storageinfo_get_freespace(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
@@ -308,7 +365,7 @@ gboolean storageinfo_get_maxcapacity(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
@@ -358,7 +415,7 @@ gboolean storageinfo_get_storagetype(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
@@ -408,7 +465,7 @@ gboolean storageinfo_get_volumeidentifier(
        mtp_param *param = NULL;
        gint result = MTP_ERROR_NONE;
 
-       MTP_LOGE(">>> REQUEST from [%s]",
+       MTP_LOGI(">>> REQUEST from [%s]",
                g_dbus_method_invocation_get_sender(invocation));
 
        param = g_try_new0(mtp_param, 1);
index 05dc1174f2aa48e3332ca6a46f356c6feeb2d4de..6e2c1c49d70d5533492e304afccd36139f913480 100755 (executable)
@@ -23,7 +23,7 @@ LIBMTP_devicestorage_t *mtp_daemon_util_get_storage_handle(
        int slot;
        int device_num = mtp_ctx->device_list->device_num;
 
-       MTP_LOGI("storage handle device_num : %d", device_num);
+       MTP_LOGI("device_num: %d", device_num);
 
        /* search device */
        for (slot = 1; slot < MTP_MAX_SLOT; slot++) {
@@ -45,17 +45,18 @@ int mtp_daemon_util_get_device_id(LIBMTP_mtpdevice_t *device, mtp_context *mtp_c
 {
        int slot;
 
-       MTP_LOGI("device : %p, mtp_ctx->device_list : %p", device, mtp_ctx->device_list);
+       MTP_LOGI("device: %p, device_num: %d", device, mtp_ctx->device_list->device_num);
 
        for (slot = 1; slot < MTP_MAX_SLOT; slot++) {
                mtp_device_info *device_info;
                device_info = mtp_ctx->device_list->device_info_list[slot];
 
                if (device_info != NULL && device_info->device == device) {
-                       MTP_LOGI("get device id - slot : %d", slot);
+                       MTP_LOGI("device id: %d", slot);
                        return slot;
                }
        }
+
        return -1;
 }