MTP_LOGI("controller thread join end");
}
+ if (mtp_ctx->usb_ctx != NULL) {
+ MTP_LOGI("usb interrupt event handler");
+ libusb_interrupt_event_handler(mtp_ctx->usb_ctx);
+ }
+
if (mtp_ctx->usb_event_thread != NULL) {
MTP_LOGI("usb event thread join start");
g_thread_join(mtp_ctx->usb_event_thread);
switch (signo) {
case SIGTERM:
+ _mtp_ctx->is_running = false;
g_main_loop_quit(_mtp_ctx->main_loop);
MTP_LOGD("SIGTERM");
break;
return;
}
-static bool __exists_mtp_devices(void)
-{
- LIBMTP_raw_device_t *devices;
- int num_of_devices = 0;
-
- LIBMTP_Init();
- LIBMTP_Detect_Raw_Devices(&devices, &num_of_devices);
- free(devices);
-
- return num_of_devices > 0 ? true : false;
-}
-
int main(int argc, char *argv[])
{
mtp_context *mtp_ctx = NULL;
MTP_LOGE("mtp initiator start");
- if (__exists_mtp_devices() == false) {
- MTP_LOGE("There are not mtp devices");
- return 0;
- }
-
remove(MTP_DB_FILE);
/* 1. signal registration */
MTP_LOGI("mtp initiator exit process start"); //LCOV_EXCL_LINE
if (mtp_ctx != NULL && mtp_ctx->device_list != NULL
&& mtp_ctx->device_list->threads != NULL) {
- g_thread_pool_free(mtp_ctx->device_list->threads, true, true);
+ g_thread_pool_free(mtp_ctx->device_list->threads, true, false);
+ MTP_LOGI("g_thread_pool free successful");
}
/* LCOV_EXCL_START */
if (object_info == NULL) {
MTP_LOGE("object info is NULL");
+ LIBMTP_Dump_Errorstack(device);
+ LIBMTP_Clear_Errorstack(device);
result = MTP_ERROR_PLUGIN_FAIL;
goto END;
}
(uint32_t)format, (uint32_t)parent_object_handle,
(uint32_t **)&object_list, (uint32_t *)&total_object_num);
- if (ret < 0)
+ if (ret < 0) {
MTP_LOGE("LIBMTP_Get_Object_Handles is failed : %d", ret);
+ LIBMTP_Dump_Errorstack(device);
+ LIBMTP_Clear_Errorstack(device);
+ goto END;
+ }
mtp_daemon_db_begin(param->mtp_ctx);
if (mtp_daemon_db_is_exist(device_id, mtp_storage, object_list[slot], param->mtp_ctx) == false) {
object_info = LIBMTP_Get_Object_Info(device, (uint32_t)object_list[slot]);
- if (object_info != NULL)
+ if (object_info != NULL) {
mtp_daemon_db_insert(device_id, mtp_storage, object_list[slot], object_info, param->mtp_ctx);
+ } else {
+ LIBMTP_Dump_Errorstack(device);
+ LIBMTP_Clear_Errorstack(device);
+ }
} else {
object_info = mtp_daemon_db_get_object_info(device_id, object_list[slot], param->mtp_ctx);
}
if (ret != 0) {
/* LCOV_EXCL_START */
MTP_LOGE("get descriptor fail - ret: %d", ret);
+ LIBMTP_Dump_Errorstack(device);
+ LIBMTP_Clear_Errorstack(device);
result = MTP_ERROR_PLUGIN_FAIL;
/* LCOV_EXCL_STOP */
}
/* LCOV_EXCL_STOP */
} else {
MTP_LOGE("get partial object fail - ret: %d", ret);
+ LIBMTP_Dump_Errorstack(device);
+ LIBMTP_Clear_Errorstack(device);
result = MTP_ERROR_PLUGIN_FAIL;
}
result = MTP_ERROR_IO_ERROR;
/* LCOV_EXCL_STOP */
} else {
- ret = LIBMTP_Get_Thumbnail_From_Exif_Data(device, object_handle, &thumb_data, &thumb_size);
- if (ret != 0)
- ret = LIBMTP_Get_Thumbnail(device, object_handle, &thumb_data, &thumb_size);
+ MTP_LOGI("get thumbnail start. object_handle : %d, dest_path : %s", object_handle, dest_path);
+ ret = LIBMTP_Get_Thumbnail(device, object_handle, &thumb_data, &thumb_size);
if (ret == 0) {
+ MTP_LOGI("get thumbnail end. thumb_size : %d", thumb_size);
ret = write(fd, thumb_data, thumb_size);
if (ret == 0)
result = MTP_ERROR_OUT_OF_MEMORY;
} else {
/* LCOV_EXCL_START */
MTP_LOGE("get thumbnail fail - ret: %d", ret);
+ LIBMTP_Dump_Errorstack(device);
+ LIBMTP_Clear_Errorstack(device);
result = MTP_ERROR_PLUGIN_FAIL;
/* LCOV_EXCL_STOP */
}
object_handle = param->param2;
ret = LIBMTP_Delete_Object(device, object_handle);
- if (ret != 0)
+ if (ret != 0) {
+ LIBMTP_Dump_Errorstack(device);
+ LIBMTP_Clear_Errorstack(device);
result = MTP_ERROR_PLUGIN_FAIL;
+ }
} else {
/* LCOV_EXCL_START */
MTP_LOGE("No MTP device");