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
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);
}
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,
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);
}
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;
}
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);
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);
{
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;
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;
}
{
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;
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;
}
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);
}
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);
}
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;
}
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;
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;
}
}
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;
}
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);
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) {
g_usb_cb_data,
NULL);
- MTP_LOGE("END");
+ MTP_LOGI("END");
return MTP_ERROR_NONE;
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]);
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);
}
}
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);
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");
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);
{
int ret = MTP_ERROR_NONE;
- MTP_LOGE();
-
ret = __dbus_subscribe_usb_host_event(usr_callback, usr_data);
return ret;
}
}
- 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;
{
mtp_context* mtp_ctx = (mtp_context*)user_data;
- MTP_LOGE("path : %s", path);
+ MTP_LOGI("path: %s", path);
mtp_ctx->connection = 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);
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)
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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;
g_assert(param->object != NULL);
g_assert(param->invocation != NULL);
- MTP_LOGI("%s", __func__);
+ /*MTP_LOGI("%s", __func__);*/
/* parameter unpacking */
busno = (int)(param->param1);
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);
/* 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;
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);
/* 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;
/*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);
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;
/*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,
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;
/*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,
mtp_error_e result = MTP_ERROR_NONE;
LIBMTP_mtpdevice_t *device;
+ mtp_device_info *device_info;
+ int device_id;
int object_handle;
/* check precondition */
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);
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);
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);
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);
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);
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;
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,
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;
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,
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);
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);
{
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);
{
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);
{
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);
{
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);
{
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);
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);
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);
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);
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);
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);
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++) {
{
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;
}