_prop_destroy_obj_propval(prop_val);\
ERR("_util_add_node() Fail");\
return (FALSE);\
- }\
+ } \
} while (0);
#define propvalue_alloc_and_check(prop_val)\
/*MtpObject.c, for unknown metadata */
#define MTP_USE_FILL_EMPTYMETADATA_WITH_UNKNOWN
-/*define MTP_USE_VARIABLE_PTP_STRING_MALLOC*/ /*allocPtpString in ptpstring.c*/
+/*define MTP_USE_VARIABLE_PTP_STRING_MALLOC*/ /*allocPtpString in ptpstring.c*/
#define MTP_USE_RUNTIME_GETOBJECTPROPVALUE /*use runtime get object property list*/
/*keywords has many space. not support*/
#define MTP_MAX_PACKET_SIZE_SEND_HS 512 /* High speed */
#define MTP_MAX_PACKET_SIZE_SEND_FS 64 /* Full speed */
-#define MTP_FILESIZE_4GB 4294967296L
+#define MTP_FILESIZE_4GB 4294967296L
/* approximately 3 times of media files. consider album*/
#define MTP_MAX_REFDB_ROWCNT 4500
int lock_ret = 0;\
DBG("Thread [%d] trying to lock the Mutex \n", syscall(__NR_gettid));\
lock_ret = pthread_mutex_lock(mut);\
- if(lock_ret != 0) {\
- if(lock_ret == EDEADLK) {\
+ if (lock_ret != 0) {\
+ if (lock_ret == EDEADLK) {\
DBG("Mutex is already locked by the same thread");\
} else {\
ERR("Error locking mutex. Error = %d \n", lock_ret);\
- }\
+ } \
} else {\
DBG("Mutex locked by thread [%d] \n", syscall(__NR_gettid));\
- }\
+ } \
} while (0);\
ERR("Error unlocking mutex. Error = %d \n", unlock_ret);\
} else {\
DBG("Mutex unlocked by thread [%d] \n", syscall(__NR_gettid));\
- }\
+ } \
} while (0);\
mtp_bool _util_thread_create(pthread_t *tid, const mtp_char *tname,
Name: mtp-responder
Summary: Media Transfer Protocol daemon (responder)
-Version: 0.0.18
+Version: 0.0.19
Release: 1
Group: Network & Connectivity/Other
License: Apache-2.0
break;
mounted = _device_is_store_mounted(MTP_STORAGE_EXTERNAL);
if (mounted == FALSE) {
- if (__add_store_to_device(MTP_STORAGE_EXTERNAL)== FALSE) {
+ if (__add_store_to_device(MTP_STORAGE_EXTERNAL) == FALSE) {
ERR("__add_store_to_device() Fail");
return FALSE;
}
mtp_uint32 *ptr32 = child_arr.array_entry;
child_obj = _entity_get_object_from_store(src_store, ptr32[idx]);
- if (NULL == child_obj) {
+ if (NULL == child_obj)
continue;
- }
if (_util_is_file_opened(child_obj->file_path) == TRUE) {
ERR_SECURE("File [%s] is already opened\n",
}
ptr = strstr(child_obj->file_path, src_path);
- if (NULL == ptr) {
+ if (NULL == ptr)
continue;
- }
_util_utf8_to_utf16(dest_chld_wpath,
sizeof(dest_chld_wpath) / WCHAR_SIZ, src_path);
static mtp_bool __create_prop_timestring(mtp_obj_t *obj,
mtp_uint32 propcode, ptp_time_string_t *value)
{
- obj_prop_desc_t *prop = NULL;
- obj_prop_val_t *prop_val= NULL;
+ obj_prop_desc_t *prop = NULL;
+ obj_prop_val_t *prop_val = NULL;
mtp_uint32 fmt_code = obj->obj_info->obj_fmt;
retv_if(obj == NULL, FALSE);
{
mtp_bool success = TRUE;
mtp_int32 converted_rating = 0;
- comp_audio_meta_t audio_data = {{0}, {0}};
+ comp_audio_meta_t audio_data = {{0}, {0} };
retv_if(obj == NULL, FALSE);
retv_if(obj->obj_info == NULL, FALSE);
{
ptp_array_t *parray;
parray = (ptp_array_t *)g_malloc(sizeof(ptp_array_t));
- if (parray != NULL) {
+ if (parray != NULL)
_prop_init_ptparray(parray, type);
- }
return (parray);
}
case UINT8_TYPE:
ptr8 = parray->array_entry;
for (ii = 0; ii < parray->num_ele; ii++) {
- if (ptr8[ii] == (mtp_uchar) element) {
+ if (ptr8[ii] == (mtp_uchar) element)
return ii;
- }
}
break;
case UINT16_TYPE:
ptr16 = parray->array_entry;
for (ii = 0; ii < parray->num_ele; ii++) {
- if (ptr16[ii] == (mtp_uint16) element) {
+ if (ptr16[ii] == (mtp_uint16) element)
return ii;
- }
}
break;
case UINT32_TYPE:
ptr32 = parray->array_entry;
for (ii = 0; ii < parray->num_ele; ii++) {
- if (ptr32[ii] == (mtp_uint32)element) {
+ if (ptr32[ii] == (mtp_uint32)element)
return ii;
- }
}
break;
{
parray->num_ele = 0;
parray->arr_size = 0;
- if (parray->array_entry) {
+ if (parray->array_entry)
g_free(parray->array_entry);
- }
+
parray->array_entry = NULL;
return;
}
if (parray == NULL)
return;
- if (parray->array_entry != NULL) {
+ if (parray->array_entry != NULL)
g_free(parray->array_entry);
- }
+
parray->arr_size = 0;
parray->num_ele = 0;
g_free(parray);
ptp_string_t *pstring = NULL;
pstring = (ptp_string_t *)g_malloc(sizeof(ptp_string_t));
- if (pstring != NULL) {
+ if (pstring != NULL)
_prop_init_ptpstring(pstring);
- }
return (pstring);
}
alloc_size = ((size_tmp >> 5) + 1) << 5; /* multiple of 32 */
pstring = (ptp_string_t *)g_malloc(alloc_size); /* for margin */
- if (pstring != NULL) {
+ if (pstring != NULL)
_prop_init_ptpstring(pstring);
- }
return (pstring);
}
pstring->num_chars = 0;
return;
}
- for (i = 0; i < MAX_PTP_STRING_CHARS && pchar[i]; i++) {
+ for (i = 0; i < MAX_PTP_STRING_CHARS && pchar[i]; i++)
pstring->str[i] = (mtp_wchar)pchar[i];
- }
} else if (cmode == WCHAR_TYPE) {
if (pwchar[0] == 0) {
pstring->num_chars = 0;
return;
}
- for (i = 0; i < MAX_PTP_STRING_CHARS && pwchar[i]; i++) {
+ for (i = 0; i < MAX_PTP_STRING_CHARS && pwchar[i]; i++)
pstring->str[i] = pwchar[i];
- }
} else {
ERR("Unknown character mode : %d\n", cmode);
pstring->num_chars = 0;
mtp_uint16 ii;
dst->num_chars = src->num_chars;
- for (ii = 0; ii < src->num_chars; ii++) {
+ for (ii = 0; ii < src->num_chars; ii++)
dst->str[ii] = src->str[ii];
- }
+
return;
}
mtp_uint16 ii;
dst->num_chars = src->num_chars;
- for (ii = 0; ii < src->num_chars; ii++) {
+ for (ii = 0; ii < src->num_chars; ii++)
dst->str[ii] = src->str[ii];
- }
+
return;
}
buf[0] = pstring->num_chars;
bytes_written = _prop_size_ptpstring(pstring);
- for (ii = 0; ii < (bytes_written - 1); ii++) {
+ for (ii = 0; ii < (bytes_written - 1); ii++)
buf[ii + 1] = pchar[ii];
- }
}
return bytes_written;
}
{
mtp_uint16 ii;
- if (buf == NULL) {
+ if (buf == NULL)
return 0;
- }
if (buf[0] == 0) {
pstring->num_chars = 0;
} else {
pstring->num_chars = buf[0];
ii = (mtp_uint16) ((size - 1) / sizeof(mtp_wchar));
- if (pstring->num_chars > ii) {
+ if (pstring->num_chars > ii)
pstring->num_chars = (mtp_uchar)ii;
- }
for (ii = 1; ii <= pstring->num_chars; ii++) {
#ifdef __BIG_ENDIAN__
void _prop_destroy_ptpstring(ptp_string_t *pstring)
{
- if (pstring != NULL) {
+ if (pstring != NULL)
g_free(pstring);
- }
+
return;
}
mtp_uint32 ii;
for (ii = 0; ii < prop_info->supp_value_list.nnodes;
ii++, node = node->link) {
- if (value == (mtp_uint32) node->value) {
+ if (value == (mtp_uint32) node->value)
return TRUE;
- }
}
/* if it hits here, must be an invalid value */
mtp_bool _prop_is_valid_string(prop_info_t *prop_info, ptp_string_t *pstring)
{
- if ((prop_info->data_type != PTP_DATATYPE_STRING) || (pstring == NULL)) {
+ if ((prop_info->data_type != PTP_DATATYPE_STRING) || (pstring == NULL))
return FALSE;
- }
- if (prop_info->form_flag == ENUM_FORM)
- {
+ if (prop_info->form_flag == ENUM_FORM) {
slist_node_t *node = NULL;
mtp_uint32 ii;
ptp_string_t *ele_str = NULL;
_prop_copy_char_to_ptpstring(prop_info->default_val.str,
val, WCHAR_TYPE);
return TRUE;
- }
- else {
+ } else {
return FALSE;
}
}
return FALSE;
/* Copies the data into the PTP array */
- if ((prop_info->default_val.array != NULL) && (num_ele != 0))
- {
+ if ((prop_info->default_val.array != NULL) && (num_ele != 0)) {
mtp_uchar *ptr8 = NULL;
mtp_uint16 *ptr16 = NULL;
mtp_uint32 *ptr32 = NULL;
_prop_grow_ptparray(prop_info->default_val.array, num_ele);
if ((prop_info->data_type == PTP_DATATYPE_AUINT8) ||
- (prop_info->data_type == PTP_DATATYPE_AINT8))
- {
+ (prop_info->data_type == PTP_DATATYPE_AINT8)) {
ptr8 = (mtp_uchar *) parray;
for (ii = 0; ii < num_ele; ii++)
_prop_append_ele_ptparray(prop_info->default_val.array,
ptr = (mtp_uchar *) &val;
- for (ii = 0; ii < sizeof(mtp_uint32); ii++) {
+ for (ii = 0; ii < sizeof(mtp_uint32); ii++)
prop->current_val.integer[ii] = ptr[ii];
- }
return TRUE;
} else {
mtp_bool _prop_set_current_string(device_prop_desc_t *prop, ptp_string_t *str)
{
- if (_prop_is_valid_string(&(prop->propinfo), str))
- {
+ if (_prop_is_valid_string(&(prop->propinfo), str)) {
_prop_destroy_ptpstring(prop->current_val.str);
#ifndef MTP_USE_VARIABLE_PTP_STRING_MALLOC
prop->current_val.str = __alloc_ptpstring();
if (prop->current_val.str != NULL) {
_prop_copy_ptpstring(prop->current_val.str, str);
return TRUE;
- }
- else {
+ } else {
_prop_destroy_ptpstring(prop->current_val.str);
return FALSE;
}
PTP_DATATYPE_ARRAY) {
mtp_uint32 *ptr = (mtp_uint32 *) val;
- if (size < sizeof(mtp_uint32)) {
+ if (size < sizeof(mtp_uint32))
return FALSE;
- }
- if (size < sizeof(mtp_uint32) + ptr[0] * prop->propinfo.dts_size) {
+
+ if (size < sizeof(mtp_uint32) + ptr[0] * prop->propinfo.dts_size)
return FALSE;
- }
+
return _prop_set_current_array(prop, val);
- }
- else if ((prop->propinfo.data_type & PTP_DATATYPE_VALUEMASK) ==
+ } else if ((prop->propinfo.data_type & PTP_DATATYPE_VALUEMASK) ==
PTP_DATATYPE_VALUE) {
- if (prop->propinfo.dts_size > size) {
+ if (prop->propinfo.dts_size > size)
return FALSE;
- }
if ((prop->propinfo.data_type == PTP_DATATYPE_INT64) ||
(prop->propinfo.data_type == PTP_DATATYPE_UINT64) ||
pval->current_val.str = __alloc_ptpstring(str->num_chars);
#endif /* MTP_USE_VARIABLE_PTP_STRING_MALLOC */
if (pval->current_val.str != NULL) {
- _prop_copy_ptpstring (pval->current_val.str, str);
+ _prop_copy_ptpstring(pval->current_val.str, str);
return TRUE;
} else
return FALSE;
slist_node_t *node = NULL;
mtp_uint32 ii;
- if (!buf || size < _prop_size_device_prop_desc(prop)) {
+ if (!buf || size < _prop_size_device_prop_desc(prop))
return 0;
- }
/* Pack propcode, data_type, & get_set */
bytes_to_write = sizeof(mtp_uint16);
bytes_to_write = __size_curval_device_prop(prop);
- if ((!bytes_to_write) || (buf == NULL) || (size < bytes_to_write)) {
+ if ((!bytes_to_write) || (buf == NULL) || (size < bytes_to_write))
return 0;
- }
if (prop->propinfo.data_type == PTP_DATATYPE_STRING) {
if (bytes_to_write != _prop_pack_ptpstring(prop->current_val.str,
if (NULL == prop->current_val.str)
return;
- _prop_copy_ptpstring (prop->current_val.str,
+ _prop_copy_ptpstring(prop->current_val.str,
prop->propinfo.default_val.str);
} else if ((prop->propinfo.data_type & PTP_DATATYPE_ARRAYMASK) ==
obj_prop_val_t *pval = NULL;
pval = (obj_prop_val_t *)g_malloc(sizeof(obj_prop_val_t));
- if (pval != NULL) {
+ if (pval != NULL)
__init_obj_propval(pval, prop);
- }
return pval;
}
pval->prop = prop;
- for (ii = 0; ii < 16; ii++) {
+ for (ii = 0; ii < 16; ii++)
pval->current_val.integer[ii] = 0;
- }
if (prop->propinfo.data_type == PTP_DATATYPE_STRING) {
#endif /* MTP_USE_VARIABLE_PTP_STRING_MALLOC */
if (NULL == pval->current_val.str)
return;
- _prop_copy_ptpstring (pval->current_val.str,
+ _prop_copy_ptpstring(pval->current_val.str,
prop->propinfo.default_val.str);
} else if ((prop->propinfo.data_type & PTP_DATATYPE_VALUEMASK) ==
PTP_DATATYPE_VALUE) {
prop_val = (obj_prop_val_t *)node->value;
if (prop_val) {
- if (prop_val->prop->propinfo.prop_code == propcode) {
+ if (prop_val->prop->propinfo.prop_code == propcode)
return prop_val;
- }
}
}
{
mtp_uint32 bytes_to_write = _prop_size_obj_propval(pval);
- if ((!bytes_to_write) || (buf == NULL) || (size < bytes_to_write)) {
+ if ((!bytes_to_write) || (buf == NULL) || (size < bytes_to_write))
return 0;
- }
if (pval->prop->propinfo.data_type == PTP_DATATYPE_STRING) {
return size;
if (pval->prop->propinfo.data_type == PTP_DATATYPE_STRING) {
- if (pval->current_val.str == NULL) {
+ if (pval->current_val.str == NULL)
size = 0;
- } else {
+ else
size = _prop_size_ptpstring(pval->current_val.str);
- }
} else if ((pval->prop->propinfo.data_type & PTP_DATATYPE_ARRAYMASK) ==
PTP_DATATYPE_ARRAY) {
void _prop_destroy_obj_propval(obj_prop_val_t *pval)
{
- if (pval == NULL) {
+ if (pval == NULL)
return;
- }
if (pval->prop == NULL) {
g_free(pval);
prop->propinfo.form_flag = form_flag;
- if (prop->propinfo.form_flag == BYTE_ARRAY_FORM) {
+ if (prop->propinfo.form_flag == BYTE_ARRAY_FORM)
prop->propinfo.data_type = PTP_DATATYPE_AUINT8;
- } else if (prop->propinfo.form_flag == LONG_STRING_FORM) {
+ else if (prop->propinfo.form_flag == LONG_STRING_FORM)
prop->propinfo.data_type = PTP_DATATYPE_AUINT16;
- }
prop->group_code = group_code;
break;
case RANGE_FORM:
- if (prop->propinfo.data_type != PTP_DATATYPE_STRING) {
+ if (prop->propinfo.data_type != PTP_DATATYPE_STRING)
size += 3 * prop->propinfo.dts_size;/* Min,Max,Step */
- }
+
break;
case ENUM_FORM:
slist_node_t *node = NULL;
mtp_uint16 ii;
- if (!buf || size < _prop_size_obj_prop_desc(prop)) {
+ if (!buf || size < _prop_size_obj_prop_desc(prop))
return 0;
- }
/* Pack propcode, data_type, & get_set */
bytes_to_write = sizeof(mtp_uint16);
bytes_to_write = __get_size_default_val_obj_prop_desc(prop);
- if ((!bytes_to_write) || (buf == NULL) || (size < bytes_to_write)) {
+ if ((!bytes_to_write) || (buf == NULL) || (size < bytes_to_write))
return 0;
- }
if (prop->propinfo.data_type == PTP_DATATYPE_STRING) {
if (bytes_to_write !=
int num_default_obj_props = 0;
/*Default*/
- if (_get_oma_drm_status() == TRUE) {
+ if (_get_oma_drm_status() == TRUE)
num_default_obj_props = NUM_OBJECT_PROP_DESC_DEFAULT;
- } else {
+ else
num_default_obj_props = NUM_OBJECT_PROP_DESC_DEFAULT - 1;
- }
for (i = 0; i < num_default_obj_props; i++) {
- if (props_list_default[i].propinfo.prop_code == propcode) {
+ if (props_list_default[i].propinfo.prop_code == propcode)
return &(props_list_default[i]);
- }
}
switch (format_code) {
case PTP_FMT_MP3:
case PTP_FMT_WAVE:
for (i = 0; i < NUM_OBJECT_PROP_DESC_MP3; i++) {
- if (props_list_mp3[i].propinfo.prop_code == propcode) {
+ if (props_list_mp3[i].propinfo.prop_code == propcode)
return &(props_list_mp3[i]);
- }
}
break;
case MTP_FMT_WMA:
for (i = 0; i < NUM_OBJECT_PROP_DESC_WMA; i++) {
- if (props_list_wma[i].propinfo.prop_code == propcode) {
+ if (props_list_wma[i].propinfo.prop_code == propcode)
return &(props_list_wma[i]);
- }
}
break;
case MTP_FMT_WMV:
case PTP_FMT_MPEG:
case MTP_FMT_3GP:
for (i = 0; i < NUM_OBJECT_PROP_DESC_WMV; i++) {
- if (props_list_wmv[i].propinfo.prop_code == propcode) {
+ if (props_list_wmv[i].propinfo.prop_code == propcode)
return &(props_list_wmv[i]);
- }
}
break;
case MTP_FMT_ABSTRACT_AUDIO_ALBUM:
case PTP_FMT_IMG_BMP:
case PTP_FMT_IMG_PNG:
for (i = 0; i < NUM_OBJECT_PROP_DESC_ALBUM; i++) {
- if (props_list_album[i].propinfo.prop_code == propcode) {
+ if (props_list_album[i].propinfo.prop_code == propcode)
return &(props_list_album[i]);
- }
}
break;
node = prop_list->prop_quad_list.start;
for (ii = 0; ii < prop_list->prop_quad_list.nnodes; ii++) {
quad = (prop_quad_t *) node->value;
- if (quad) {
+ if (quad)
size += quad->val_size;
- }
+
node = node->link;
}
return size;
ii++, node = node->link) {
propval = (obj_prop_val_t *)node->value;
- if (NULL == propval) {
+ if (NULL == propval)
continue;
- }
if (FALSE == __check_object_propcode(propval->prop,
propcode, group_code)) {
mtp_uint32 ii;
slist_node_t *node = NULL;
- if (!buf || size < _prop_size_obj_proplist(prop_list)) {
+ if (!buf || size < _prop_size_obj_proplist(prop_list))
return 0;
- }
*(mtp_uint32 *) buf = prop_list->prop_quad_list.nnodes;
#ifdef __BIG_ENDIAN__
str = (ptp_string_t *) quad->pval;
if (str) {
temp += _prop_pack_ptpstring(str, temp,
- _prop_size_ptpstring (str));
+ _prop_size_ptpstring(str));
} else {
/* Put in an empty string: NumOfChars = 0; */
*temp++ = 0;
mtp_uint32 num_default_obj_props = 0;
/*Default*/
- if (_get_oma_drm_status() == TRUE) {
+ if (_get_oma_drm_status() == TRUE)
num_default_obj_props = NUM_OBJECT_PROP_DESC_DEFAULT;
- } else {
+ else
num_default_obj_props = NUM_OBJECT_PROP_DESC_DEFAULT - 1;
- }
for (i = 0; i < num_default_obj_props; i++) {
_prop_append_ele_ptparray(supp_props,
mtp_uint32 i = 0;
int num_default_obj_prps = 0;
- for (i = 0; i < NUM_OBJECT_PROP_DESC_MP3; i++) {
+ for (i = 0; i < NUM_OBJECT_PROP_DESC_MP3; i++)
__destroy_obj_prop_desc(&(props_list_mp3[i]));
- }
- for (i = 0; i < NUM_OBJECT_PROP_DESC_WMA; i++) {
+ for (i = 0; i < NUM_OBJECT_PROP_DESC_WMA; i++)
__destroy_obj_prop_desc(&(props_list_wma[i]));
- }
- for (i = 0; i < NUM_OBJECT_PROP_DESC_WMV; i++) {
+ for (i = 0; i < NUM_OBJECT_PROP_DESC_WMV; i++)
__destroy_obj_prop_desc(&(props_list_wmv[i]));
- }
- for (i = 0; i < NUM_OBJECT_PROP_DESC_ALBUM; i++) {
+ for (i = 0; i < NUM_OBJECT_PROP_DESC_ALBUM; i++)
__destroy_obj_prop_desc(&(props_list_album[i]));
- }
- if (_get_oma_drm_status() == TRUE) {
+ if (_get_oma_drm_status() == TRUE)
num_default_obj_prps = NUM_OBJECT_PROP_DESC_DEFAULT;
- } else {
+ else
num_default_obj_prps = NUM_OBJECT_PROP_DESC_DEFAULT - 1;
- }
- for (i = 0; i < num_default_obj_prps; i++) {
+ for (i = 0; i < num_default_obj_prps; i++)
__destroy_obj_prop_desc(&(props_list_default[i]));
- }
+
return;
}
node = prop_config->propdesc_list.start;
for (ii = 0; ii < prop_config->propdesc_list.nnodes; ii++) {
prop = node->value;
- if (prop) {
+ if (prop)
size += _prop_size_obj_prop_desc(prop);
- }
}
return size;
}
mtp_uint32 ele_size = 0;
mtp_int32 ii;
- if (!buf || size < _prop_get_size_interdep_prop(prop_config)) {
+ if (!buf || size < _prop_get_size_interdep_prop(prop_config))
return 0;
- }
*(mtp_uint32 *) buf = prop_config->propdesc_list.nnodes;
#ifdef __BIG_ENDIAN__
{
char sto_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
- switch(store_id) {
- case MTP_INTERNAL_STORE_ID :
+ switch (store_id) {
+ case MTP_INTERNAL_STORE_ID:
_util_get_internal_path(sto_path);
g_strlcpy(path, sto_path,
MTP_MAX_PATHNAME_SIZE + 1);
break;
- case MTP_EXTERNAL_STORE_ID :
+ case MTP_EXTERNAL_STORE_ID:
_util_get_external_path(sto_path);
g_strlcpy(path, sto_path,
MTP_MAX_PATHNAME_SIZE + 1);
break;
- default :
+ default:
ERR("No valid match for the store id [0x%x]\n", store_id);
return FALSE;
/* references */
if (PTP_OBJECTHANDLE_ROOT != obj->obj_info->h_parent) {
par_obj = _entity_get_object_from_store(store, obj->obj_info->h_parent);
- if (NULL != par_obj) {
+ if (NULL != par_obj)
_entity_add_reference_child_array(par_obj, obj->obj_handle);
- }
}
return TRUE;
return NULL;
}
- while(UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
+ while (UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
obj = (mtp_obj_t *)_util_get_list_next(iter);
if (obj && obj->obj_handle == handle) {
return NULL;
}
- while(UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
+ while (UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
temp_obj = (mtp_obj_t *)_util_get_list_next(iter);
- if (temp_obj && temp_obj->obj_handle == handle) {
+ if (temp_obj && temp_obj->obj_handle == handle)
obj = temp_obj;
- }
}
_util_deinit_list_iterator(iter);
return NULL;
}
- while(UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
+ while (UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
obj = (mtp_obj_t *)_util_get_list_next(iter);
if (obj == NULL) {
ERR("Object is NULL");
return 0;
}
- while(UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
+ while (UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
obj = (mtp_obj_t *)_util_get_list_next(iter);
if (obj == NULL) {
return obj_arr->num_ele;
}
- if (PTP_OBJECTHANDLE_ROOT != obj_handle) {
+ if (PTP_OBJECTHANDLE_ROOT != obj_handle)
_prop_append_ele_ptparray(obj_arr, obj_handle);
- }
+
if (depth > 0) {
ptp_array_t *child_arr = NULL;
mtp_uint32 *ptr = NULL;
return 0;
}
- while(UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
+ while (UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
obj = (mtp_obj_t *)_util_get_list_next(iter);
if (obj == NULL || obj->obj_info == NULL)
retv_if(store == NULL, 0);
- if (PTP_FORMATCODE_NOTUSED == format) {
+ if (PTP_FORMATCODE_NOTUSED == format)
return store->obj_list.nnodes;
- }
iter = (slist_iterator *)_util_init_list_iterator(&(store->obj_list));
if (iter == NULL) {
return 0;
}
- while(UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
+ while (UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
obj = (mtp_obj_t *)_util_get_list_next(iter);
if (obj == NULL || obj->obj_info == NULL)
return 0;
}
- while(UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
+ while (UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
obj = (mtp_obj_t *)_util_get_list_next(iter);
if (obj == NULL || obj->obj_info == NULL)
return 0;
}
- while(UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
+ while (UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
obj = (mtp_obj_t *)_util_get_list_next(iter);
if (obj == NULL || obj->obj_info == NULL)
continue;
- if (obj->obj_info->h_parent == h_parent) {
+ if (obj->obj_info->h_parent == h_parent)
_prop_append_ele_ptparray(child_arr, obj->obj_handle);
- }
}
_util_deinit_list_iterator(iter);
return 0;
}
- while(UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
+ while (UTIL_CHECK_LIST_NEXT(iter) == TRUE) {
obj = (mtp_obj_t *)_util_get_list_next(iter);
if (obj == NULL || obj->obj_info == NULL)
child_obj = _entity_get_object_from_store(store,
ptr32[i]);
- if (NULL == child_obj) {
+ if (NULL == child_obj)
continue;
- }
+
if (_entity_remove_object_mtp_store(store, child_obj,
format, response, atleast_one,
read_only)) {
DBG_SECURE("Folder[%s] contains only read-only files\n",
obj->file_path);
all_del = FALSE;
- } else if (num_of_deleted_file < num_of_file){
+ } else if (num_of_deleted_file < num_of_file) {
DBG("num of files[%d] is present in folder[%s]\
and number of deleted files[%d]\n",
num_of_file, obj->file_path,
obj->obj_handle);
}
}
- } else if(*atleast_one) {
+ } else if (*atleast_one) {
*response = PTP_RESPONSE_PARTIAL_DELETION;
return FALSE;
} else {
}
}
- if (all_del) {
+ if (all_del)
response = PTP_RESPONSE_OK;
- } else if (atleas_one)
+ else if (atleas_one)
response = PTP_RESPONSE_PARTIAL_DELETION;
return response;
do {
if (TRUE == _transport_get_usb_discon_state()) {
DBG("USB is disconnected");
- if (closedir(h_dir) < 0) {
+ if (closedir(h_dir) < 0)
ERR("Close directory Fail");
- }
+
return;
}
&entry);
} while (status);
- if (closedir(h_dir) < 0) {
+ if (closedir(h_dir) < 0)
ERR("close directory fail");
- }
+
#ifdef MTP_SUPPORT_OBJECTADDDELETE_EVENT
_inoti_add_watch_for_fs_events(folder_name);
#endif /*MTP_SUPPORT_OBJECTADDDELETE_EVENT*/
*/
void _cmd_hdlr_reset_cmd(mtp_handler_t *hdlr)
{
- if (hdlr->data4_send_obj.obj != NULL) {
+ if (hdlr->data4_send_obj.obj != NULL)
_entity_dealloc_mtp_obj(hdlr->data4_send_obj.obj);
- }
memset(hdlr, 0x00, sizeof(mtp_handler_t));
_prop_init_ptparray(&ids, UINT32_TYPE);
- if (_hutil_get_storage_ids(&ids) == MTP_ERROR_NONE)
- {
+ if (_hutil_get_storage_ids(&ids) == MTP_ERROR_NONE) {
_hdlr_init_data_container(&blk, hdlr->usb_cmd.code,
hdlr->usb_cmd.tid);
num_bytes = _prop_get_size_ptparray(&ids);
resp = PTP_RESPONSE_GEN_ERROR;
}
- if (resp == PTP_RESPONSE_OK) {
+ if (resp == PTP_RESPONSE_OK)
_cmd_hdlr_send_response(hdlr, resp, 1, (mtp_uint32 *)&num_obj);
- } else {
+ else
_cmd_hdlr_send_response_code(hdlr, resp);
- }
}
static void __get_object_handles(mtp_handler_t *hdlr)
sent += read_len;
}
- if (total_len % ((mtp_uint64)_transport_get_usb_packet_len()) == 0) {
+ if (total_len % ((mtp_uint64)_transport_get_usb_packet_len()) == 0)
_transport_send_zlp();
- }
Done:
_util_file_close(h_file);
obj_data_t obdata = { 0 };
store_id = _hdlr_get_param_cmd_container(&(hdlr->usb_cmd), 0);
- if (store_id == 0) {
+ if (store_id == 0)
store_id = _device_get_default_store_id();
- }
+
h_parent = _hdlr_get_param_cmd_container(&(hdlr->usb_cmd), 1);
if (_hdlr_get_param_cmd_container(&(hdlr->usb_cmd), 2)) {
resp = PTP_RESPONSE_PARAM_NOTSUPPORTED;
- if (_device_get_phase() != DEVICE_PHASE_NOTREADY) {
+ if (_device_get_phase() != DEVICE_PHASE_NOTREADY)
_cmd_hdlr_send_response_code(hdlr, resp);
- }
+
return;
}
prop_id = _hdlr_get_param_cmd_container(&(hdlr->usb_cmd), 0);
_hdlr_init_data_container(&blk, hdlr->usb_cmd.code, hdlr->usb_cmd.tid);
- switch(prop_id) {
+ switch (prop_id) {
#ifdef MTP_SUPPORT_DEVICEPROP_BATTERYLEVEL
case PTP_PROPERTYCODE_BATTERYLEVEL: {
mtp_int32 batt = 0;
_prop_init_ptparray(&val_arr, UINT8_TYPE);
_prop_grow_ptparray(&val_arr, read_bytes);
- for (ii = 0; ii < read_bytes; ii++) {
+ for (ii = 0; ii < read_bytes; ii++)
_prop_append_ele_ptparray(&val_arr, data[ii]);
- }
no_bytes = _prop_get_size_ptparray(&val_arr);
ptr = _hdlr_alloc_buf_data_container(&blk, no_bytes, no_bytes);
case MTP_ERROR_NONE:
resp = PTP_RESPONSE_OK;
break;
- default :
+ default:
resp = PTP_RESPONSE_GEN_ERROR;
}
}
ptr = _hdlr_get_payload_data(&blk);
- if (ptr == NULL) {
+ if (ptr == NULL)
return;
- }
memcpy(&num_ref, ptr, sizeof(mtp_uint32));
#ifdef __BIG_ENDIAN__
mtp_store_t *store = NULL;
store = _device_get_store_containing_obj(obj_handles[ii]);
- if (store == NULL) {
+ if (store == NULL)
continue;
- }
obj = _entity_get_object_from_store(store, obj_handles[ii]);
- if (NULL == obj || obj->propval_list.nnodes == 0) {
+ if (NULL == obj || obj->propval_list.nnodes == 0)
continue;
- }
+
/*Remove all the old property value, and ready to set up new */
for (jj = 0, next_node = obj->propval_list.start;
jj < obj->propval_list.nnodes; jj++) {
if (tid == 0) {
if (access(MTP_FILES_MODIFIED_FILES, F_OK) == 0)
- if (remove(MTP_FILES_MODIFIED_FILES) < 0) {
+ if (remove(MTP_FILES_MODIFIED_FILES) < 0)
ERR("remove(%s) Fail", MTP_FILES_MODIFIED_FILES);
- }
+
resp = PTP_RESPONSE_OK;
_prop_grow_ptparray(&guid_arr, 1);
_prop_append_ele_ptparray(&guid_arr, 0);
max_size : num_lines - start_idx;
rem_modified = (num_lines - start_idx > max_size) ?
- (num_lines - start_idx- max_size) : 0;
+ (num_lines - start_idx - max_size) : 0;
g_has_round_trip = FALSE;
_prop_init_ptparray(&guid_arr, UINT32_TYPE);
_util_file_close(h_file);
if (rem_modified == 0) {
- if (remove(MTP_FILES_MODIFIED_FILES) < 0) {
+ if (remove(MTP_FILES_MODIFIED_FILES) < 0)
ERR("remove(%s) Fail", MTP_FILES_MODIFIED_FILES);
- }
+
g_mgr->meta_info.mod = 0;
}
_device_set_phase(DEVICE_PHASE_DATAIN);
}
- if (_hdlr_send_data_container(&blk)) {
+ if (_hdlr_send_data_container(&blk))
resp = PTP_RESPONSE_OK;
- } else {
+ else
resp = PTP_RESPONSE_GEN_ERROR;
- }
_prop_deinit_ptparray(&guid_arr);
g_free(blk.data);
mtp_uint16 resp = PTP_RESPONSE_INVALIDPARAM;
skip = (mtp_int32) _hdlr_get_param_cmd_container(&(hdlr->usb_cmd), 0);
- if (MTP_ERROR_NONE == _hutil_get_playback_skip(skip)) {
+ if (MTP_ERROR_NONE == _hutil_get_playback_skip(skip))
resp = PTP_RESPONSE_OK;
- }
+
_cmd_hdlr_send_response_code(hdlr, resp);
return;
}
}
_transport_set_mtp_operation_state(MTP_STATE_ONSERVICE);
- if (resp == PTP_RESPONSE_OK) {
+ if (resp == PTP_RESPONSE_OK)
_cmd_hdlr_send_response(hdlr, resp, 1, &new_handle);
- } else {
+ else
_cmd_hdlr_send_response_code(hdlr, resp);
- }
return;
}
prop->current_val.str->str);
_device_set_sync_partner(temp);
- if (!g_strcmp0(temp, MTP_DEV_PROPERTY_NULL_SYNCPARTNER)) {
+ if (!g_strcmp0(temp, MTP_DEV_PROPERTY_NULL_SYNCPARTNER))
vconf_set_str(VCONFKEY_MTP_SYNC_PARTNER_STR, "");
- } else {
+ else
vconf_set_str(VCONFKEY_MTP_SYNC_PARTNER_STR, temp);
- }
}
_cmd_hdlr_send_response_code(hdlr, PTP_RESPONSE_OK);
idx = 0;
if (store_id) {
- if (!h_parent) {
+ if (!h_parent)
h_parent = _device_get_default_parent_handle();
- } else if (h_parent == 0xFFFFFFFF) {
+ else if (h_parent == 0xFFFFFFFF)
h_parent = PTP_OBJECTHANDLE_ROOT;
- }
} else {
store_id = _device_get_default_store_id();
if (!store_id)
}
if (PTP_RESPONSE_OK != resp) {
- if (hdlr->data4_send_obj.obj) {
+ if (hdlr->data4_send_obj.obj)
_entity_dealloc_mtp_obj(hdlr->data4_send_obj.obj);
- }
hdlr->data4_send_obj.obj = NULL;
hdlr->data4_send_obj.is_valid = FALSE;
#ifdef MTP_SUPPORT_PRINT_COMMAND
static void __print_command(mtp_uint16 code)
{
- switch(code) {
- case PTP_OPCODE_GETDEVICEINFO :
+ switch (code) {
+ case PTP_OPCODE_GETDEVICEINFO:
DBG("COMMAND ======== GET DEVICE INFO===========");
break;
- case PTP_OPCODE_OPENSESSION :
+ case PTP_OPCODE_OPENSESSION:
DBG("COMMAND ======== OPEN SESSION ===========");
break;
- case PTP_OPCODE_CLOSESESSION :
+ case PTP_OPCODE_CLOSESESSION:
DBG("COMMAND ======== CLOSE SESSION ===========");
break;
- case PTP_OPCODE_GETSTORAGEIDS :
+ case PTP_OPCODE_GETSTORAGEIDS:
DBG("COMMAND ======== GET STORAGE IDS ===========");
break;
- case PTP_OPCODE_GETSTORAGEINFO :
+ case PTP_OPCODE_GETSTORAGEINFO:
DBG("COMMAND ======== GET STORAGE INFO ===========");
break;
- case PTP_OPCODE_GETNUMOBJECTS :
+ case PTP_OPCODE_GETNUMOBJECTS:
DBG("COMMAND ======== GET NUM OBJECTS ===========");
break;
- case PTP_OPCODE_GETOBJECTHANDLES :
+ case PTP_OPCODE_GETOBJECTHANDLES:
DBG("COMMAND ======== GET OBJECT HANDLES ===========");
break;
- case PTP_OPCODE_GETOBJECTINFO :
+ case PTP_OPCODE_GETOBJECTINFO:
DBG("COMMAND ======== GET OBJECT INFO ===========");
break;
- case PTP_OPCODE_GETOBJECT :
+ case PTP_OPCODE_GETOBJECT:
DBG("COMMAND ======== GET OBJECT ===========");
break;
- case PTP_OPCODE_DELETEOBJECT :
+ case PTP_OPCODE_DELETEOBJECT:
DBG("COMMAND ======== DELETE OBJECT ===========");
break;
- case PTP_OPCODE_SENDOBJECTINFO :
+ case PTP_OPCODE_SENDOBJECTINFO:
DBG("COMMAND ======== SEND OBJECT INFO ===========");
break;
- case PTP_OPCODE_SENDOBJECT :
+ case PTP_OPCODE_SENDOBJECT:
DBG("COMMAND ======== SEND OBJECT ===========");
break;
- case PTP_OPCODE_INITIATECAPTURE :
+ case PTP_OPCODE_INITIATECAPTURE:
DBG("COMMAND ======== INITIATE CAPTURE ===========");
break;
- case PTP_OPCODE_FORMATSTORE :
+ case PTP_OPCODE_FORMATSTORE:
DBG("COMMAND ======== FORMAT STORE ===========");
break;
- case PTP_OPCODE_RESETDEVICE :
+ case PTP_OPCODE_RESETDEVICE:
DBG("COMMAND ======== RESET DEVICE ===========");
break;
- case PTP_OPCODE_SELFTEST :
+ case PTP_OPCODE_SELFTEST:
DBG("COMMAND ======== SELF TEST ===========");
break;
- case PTP_OPCODE_SETOBJECTPROTECTION :
+ case PTP_OPCODE_SETOBJECTPROTECTION:
DBG("COMMAND ======== SET OBJECT PROTECTION ===========");
break;
- case PTP_OPCODE_POWERDOWN :
+ case PTP_OPCODE_POWERDOWN:
DBG("COMMAND ======== POWER DOWN ===========");
break;
- case PTP_OPCODE_GETDEVICEPROPDESC :
+ case PTP_OPCODE_GETDEVICEPROPDESC:
DBG("COMMAND ======== GET DEVICE PROP DESC ===========");
break;
- case PTP_OPCODE_GETDEVICEPROPVALUE :
+ case PTP_OPCODE_GETDEVICEPROPVALUE:
DBG("COMMAND ======== GET DEVICE PROP VALUE ===========");
break;
- case PTP_OPCODE_SETDEVICEPROPVALUE :
+ case PTP_OPCODE_SETDEVICEPROPVALUE:
DBG("COMMAND ======== SET DEVICE PROP VALUE ===========");
break;
- case PTP_OPCODE_RESETDEVICEPROPVALUE :
+ case PTP_OPCODE_RESETDEVICEPROPVALUE:
DBG("COMMAND ======== RESET DEVICE PROP VALUE ===========");
break;
- case PTP_OPCODE_TERMINATECAPTURE :
+ case PTP_OPCODE_TERMINATECAPTURE:
DBG("COMMAND ======== TERMINATE CAPTURE ===========");
break;
- case PTP_OPCODE_MOVEOBJECT :
+ case PTP_OPCODE_MOVEOBJECT:
DBG("COMMAND ======== MOVE OBJECT ===========");
break;
- case PTP_OPCODE_COPYOBJECT :
+ case PTP_OPCODE_COPYOBJECT:
DBG("COMMAND ======== COPY OBJECT ===========");
break;
- case PTP_OPCODE_GETPARTIALOBJECT :
+ case PTP_OPCODE_GETPARTIALOBJECT:
DBG("COMMAND ======== GET PARTIAL OBJECT ===========");
break;
- case PTP_OPCODE_INITIATEOPENCAPTURE :
+ case PTP_OPCODE_INITIATEOPENCAPTURE:
DBG("COMMAND ======== INITIATE OPEN CAPTURE ===========");
break;
- case MTP_OPCODE_WMP_UNDEFINED :
+ case MTP_OPCODE_WMP_UNDEFINED:
DBG("COMMAND ======== WMP UNDEFINED ==========");
break;
- case MTP_OPCODE_WMP_REPORTACQUIREDCONTENT :
+ case MTP_OPCODE_WMP_REPORTACQUIREDCONTENT:
DBG("COMMAND ======= REPORT ACQUIRED CONTENT =========");
break;
- case MTP_OPCODE_GETOBJECTPROPSUPPORTED :
+ case MTP_OPCODE_GETOBJECTPROPSUPPORTED:
DBG("COMMAND ======= GET OBJECT PROP SUPPORTED ========");
break;
- case MTP_OPCODE_GETOBJECTPROPDESC :
+ case MTP_OPCODE_GETOBJECTPROPDESC:
DBG("COMMAND ======== GET OBJECT PROP DESC ==========");
break;
- case MTP_OPCODE_GETOBJECTPROPVALUE :
+ case MTP_OPCODE_GETOBJECTPROPVALUE:
DBG("COMMAND ======== GET OBJECT PROP VALUE ==========");
break;
- case MTP_OPCODE_SETOBJECTPROPVALUE :
+ case MTP_OPCODE_SETOBJECTPROPVALUE:
DBG("COMMAND ======== SET OBJECT PROP VALUE ==========");
break;
- case MTP_OPCODE_GETOBJECTPROPLIST :
+ case MTP_OPCODE_GETOBJECTPROPLIST:
DBG("COMMAND ======== GET OBJECT PROP LIST ==========");
break;
- case MTP_OPCODE_SETOBJECTPROPLIST :
+ case MTP_OPCODE_SETOBJECTPROPLIST:
DBG("COMMAND ======== SET OBJECT PROP LIST ==========");
break;
- case MTP_OPCODE_GETINTERDEPPROPDESC :
+ case MTP_OPCODE_GETINTERDEPPROPDESC:
DBG("COMMAND ======== GET INTERDEP PROP DESC ==========");
break;
- case MTP_OPCODE_SENDOBJECTPROPLIST :
+ case MTP_OPCODE_SENDOBJECTPROPLIST:
DBG("COMMAND ======== SEND OBJECT PROP LIST ==========");
break;
- case MTP_OPCODE_GETOBJECTREFERENCES :
+ case MTP_OPCODE_GETOBJECTREFERENCES:
DBG("COMMAND ======== GET OBJECT REFERENCES ==========");
break;
- case MTP_OPCODE_SETOBJECTREFERENCES :
+ case MTP_OPCODE_SETOBJECTREFERENCES:
DBG("COMMAND ======== SET OBJECT REFERENCES ==========");
break;
- case MTP_OPCODE_PLAYBACK_SKIP :
+ case MTP_OPCODE_PLAYBACK_SKIP:
DBG("COMMAND ======== PLAYBACK SKIP ==========");
break;
- default :
+ default:
DBG("======== UNKNOWN COMMAND ==========");
break;
}
_util_file_close(g_mgr->ftemp_st.fhandle);
g_mgr->ftemp_st.fhandle = NULL;
DBG("In Cancel Transaction, remove ");
- if (remove(g_mgr->ftemp_st.filepath) < 0) {
+ if (remove(g_mgr->ftemp_st.filepath) < 0)
ERR_SECURE("remove(%s) Fail", g_mgr->ftemp_st.filepath);
- }
} else {
DBG("g_mgr->ftemp_st.fhandle is not valid, return");
}
if (data_len < rx_size ||
g_mgr->ftemp_st.size_remaining == g_mgr->ftemp_st.file_size) {
- if (_util_file_write(g_mgr->ftemp_st.fhandle, buffer, *data_sz) != *data_sz) {
+ if (_util_file_write(g_mgr->ftemp_st.fhandle, buffer, *data_sz) != *data_sz)
ERR("fwrite error write size=[%u]\n", *data_sz);
- }
+
*data_sz = 0;
_util_file_close(g_mgr->ftemp_st.fhandle);
g_mgr->ftemp_st.fhandle = NULL;
num_elem = _device_get_store_ids(store_ids);
num_stores = _device_get_num_stores();
- if (num_elem == num_stores) {
+ if (num_elem == num_stores)
return MTP_ERROR_NONE;
- }
ERR("get storage id Fail. num_elem[%d], num_stores[%d]\n",
num_elem, num_stores);
ERR("property reference is NULL");
return MTP_ERROR_GENERAL;
}
- for (ii = 0; ii < NUM_DEVICE_PROPERTIES; ii++) {
+ for (ii = 0; ii < NUM_DEVICE_PROPERTIES; ii++)
_prop_reset_device_prop_desc(&prop[ii]);
- }
} else {
prop = _device_get_device_property(prop_id);
if (prop == NULL)
resp = MTP_ERROR_ACCESS_DENIED;
break;
case PTP_RESPONSE_INVALID_OBJ_HANDLE:
- resp =MTP_ERROR_INVALID_OBJECTHANDLE;
+ resp = MTP_ERROR_INVALID_OBJECTHANDLE;
break;
default:
break;
mtp_obj_t *obj = NULL;
obj = _device_get_object_with_handle(obj_handle);
- if (NULL == obj || NULL == obj->obj_info) {
+ if (NULL == obj || NULL == obj->obj_info)
return MTP_ERROR_GENERAL;
- }
*obj_ptr = obj;
return MTP_ERROR_NONE;
mtp_uint32 *ptr32 = child_arr.array_entry;
child_obj = _entity_get_object_from_store(src, ptr32[ii]);
- if (child_obj == NULL) {
+ if (child_obj == NULL)
continue;
- }
ret = _hutil_copy_object_entries(dst_store_id, src_store_id,
new_obj->obj_handle, child_obj->obj_handle,
return MTP_ERROR_STORE_FULL;
}
- if((ret = _hutil_copy_object_entries(dst_store_id, src->store_id,
+ if ((ret = _hutil_copy_object_entries(dst_store_id, src->store_id,
h_parent, obj_handle, new_handle, FALSE)) != MTP_ERROR_NONE) {
return ret;
}
return MTP_ERROR_GENERAL;
}
- if (new_obj->obj_info->obj_fmt == PTP_FMT_ASSOCIATION) {
+ if (new_obj->obj_info->obj_fmt == PTP_FMT_ASSOCIATION)
_util_scan_folder_contents_in_db(new_obj->file_path);
- } else {
+ else
_util_add_file_to_db(new_obj->file_path);
- }
return MTP_ERROR_NONE;
}
return MTP_ERROR_GENERAL;
}
- if (MTP_FILE_ATTR_MODE_NONE == attrs.attribute) {
+ if (MTP_FILE_ATTR_MODE_NONE == attrs.attribute)
return MTP_ERROR_GENERAL;
- }
- if (prot_status == PTP_PROTECTIONSTATUS_READONLY) {
+ if (prot_status == PTP_PROTECTIONSTATUS_READONLY)
attrs.attribute |= MTP_FILE_ATTR_MODE_READ_ONLY;
- } else {
+ else
attrs.attribute &= ~MTP_FILE_ATTR_MODE_READ_ONLY;
- }
if (FALSE == _util_set_file_attrs(fname, attrs.attribute)) {
ERR("Failed to set file[%s] attrs\n", fname);
mtp_char file_name[MTP_MAX_FILENAME_SIZE + 1] = { 0 };
if (store_id) {
- if (!h_parent) {
+ if (!h_parent)
h_parent = _device_get_default_parent_handle();
- } else if (h_parent == 0xFFFFFFFF) {
+ else if (h_parent == 0xFFFFFFFF)
h_parent = PTP_OBJECTHANDLE_ROOT;
- }
} else {
store_id = _device_get_default_store_id();
}
/* Delete and invalidate the old obj_info for send object */
- if (objdata->obj != NULL) {
+ if (objdata->obj != NULL)
_entity_dealloc_mtp_obj(objdata->obj);
- }
}
store = _device_get_store(store_id);
}
obj_info->obj_fmt = format;
- if (obj_info->obj_fmt == PTP_FMT_ASSOCIATION) {
+ if (obj_info->obj_fmt == PTP_FMT_ASSOCIATION)
obj_info->association_type = PTP_ASSOCIATIONTYPE_FOLDER;
- }
obj_info->file_size = obj_sz;
/* Acquire object information related data. */
prop_val = _prop_alloc_obj_propval(prop_desc);
- if (prop_val == NULL) {
+ if (prop_val == NULL)
continue;
- }
+
_prop_set_current_array_val(prop_val, temp, bytes_left);
switch (prop_code) {
case MTP_OBJ_PROPERTYCODE_WIDTH:
tobj = _device_get_object_with_handle(obj_handle);
if (NULL == tobj) {
- ERR("requested handle does not exist[0x%x]\n",obj_handle);
+ ERR("requested handle does not exist[0x%x]\n", obj_handle);
return MTP_ERROR_INVALID_OBJECTHANDLE;
}
ERR("Propert [0x%x] is GETONLY\n", prop_code);
}
- if (prop_sz != NULL) {
+ if (prop_sz != NULL)
*prop_sz = p_size;
- }
return MTP_ERROR_NONE;
}
return MTP_ERROR_NONE;
}
- if (_entity_remove_reference_child_array(obj, ref_handle) == FALSE) {
+ if (_entity_remove_reference_child_array(obj, ref_handle) == FALSE)
ERR("_entity_remove_reference_child_array Fail");
- }
return MTP_ERROR_NONE;
}
for (idx = 0; idx < ref_arr.num_ele; idx++) {
ref_obj = _device_get_object_with_handle(ref_ptr[idx]);
- if (ref_obj == NULL) {
+ if (ref_obj == NULL)
_entity_remove_reference_child_array(obj, ref_ptr[idx]);
- }
}
*num_ele = obj->child_array.num_ele;
return MTP_ERROR_GENERAL;
}
- if (obj_handle == 0x0) {
+ if (obj_handle == 0x0)
return MTP_ERROR_NONE;
- }
obj = _device_get_object_with_handle(obj_handle);
if (obj == NULL || obj->obj_info == NULL) {
ref_arr = _entity_get_reference_child_array(par_obj);
idx = _prop_find_ele_ptparray(ref_arr, obj_handle);
if (idx != ELEMENT_NOT_FOUND) {
- if (((long long)idx + (long long)skip_param) > UINT_MAX) {
+ if (((long long)idx + (long long)skip_param) > UINT_MAX)
new_idx = ref_arr->num_ele - 1;
- } else if ((idx + skip_param) >= ref_arr->num_ele) {
+ else if ((idx + skip_param) >= ref_arr->num_ele)
new_idx = 0;
- } else {
+ else
new_idx = idx + skip_param;
- }
if (_prop_get_ele_ptparray(ref_arr, new_idx,
(void *)(&new_hobj)) == TRUE) {
}
memcpy(&idx, dev_prop->current_val.integer, sizeof(mtp_uint32));
ref_arr = _entity_get_reference_child_array(obj);
- if (((long long)idx + (long long)skip_param) > UINT_MAX) {
+ if (((long long)idx + (long long)skip_param) > UINT_MAX)
new_idx = ref_arr->num_ele - 1;
- } else if ((idx + skip_param) >= ref_arr->num_ele) {
+ else if ((idx + skip_param) >= ref_arr->num_ele)
new_idx = 0;
- } else {
+ else
new_idx = idx + skip_param;
- }
+
_prop_set_current_integer(dev_prop, new_idx);
return MTP_ERROR_NONE;
}
}
error = _entity_format_store(store, fs_format);
- if (error == PTP_RESPONSE_OK) {
+ if (error == PTP_RESPONSE_OK)
return MTP_ERROR_NONE;
- }
ERR("Format store Fail");
return error;
while (flag) {
mtp_int32 status = 0;
status = read(g_pipefd[0], &evt, sizeof(mtp_event_t));
- if(( status== -1) && errno == EINTR) {
+ if ((status == -1) && errno == EINTR) {
ERR("read() Fail");
continue;
}
previous_val = _util_get_local_lock_status();
_util_get_lock_status(¤t_val);
- if (previous_val == current_val) {
+ if (previous_val == current_val)
return;
- }
_util_set_local_lock_status(current_val);
DBG("action[%d], param1[%ld], param2[%ld]\n", action, param1, param2);
status = write(g_pipefd[1], &event, sizeof(mtp_event_t));
- if(status== -1 || errno == EINTR) {
+ if (status == -1 || errno == EINTR) {
ERR("Event write over pipe Fail, status = [%d], pipefd = [%d], errno [%d]\n",
status, g_pipefd[1], errno);
}
DBG("Action : START MTP OPERATION");
status = write(g_pipefd[1], &event, sizeof(mtp_event_t));
- if(status== -1 || errno == EINTR) {
+ if (status == -1 || errno == EINTR) {
ERR("Event write over pipe Fail, status= [%d],pipefd = [%d], errno [%d]\n",
status, g_pipefd[1], errno);
return FALSE;
DBG("## Terminate all threads");
if (g_eh_thrd) {
_eh_send_event_req_to_eh_thread(EVENT_USB_REMOVED, 0, 0, NULL);
- if (_util_thread_join(g_eh_thrd, NULL) == FALSE) {
+ if (_util_thread_join(g_eh_thrd, NULL) == FALSE)
ERR("_util_thread_join() Fail");
- }
+
g_eh_thrd = 0;
}
return;
}
-static gboolean __check_internal_storage (gpointer user_data)
+static gboolean __check_internal_storage(gpointer user_data)
{
_handle_lock_status_notification(NULL, NULL);
*token = '\0';
token = strtok_r(buf, "=", &saveptr);
- if (token == NULL) {
+ if (token == NULL)
continue;
- }
if (strcasecmp(token, "mmap_threshold") == 0) {
token = strtok_r(NULL, "=", &saveptr);
DBG("***********************************************************");
DBG("### Extension ###");
- if (_get_oma_drm_status() == TRUE) {
+ if (_get_oma_drm_status() == TRUE)
DBG("### 2. OMADRM : [ON]");
- } else {
+ else
DBG("### 2. OMADRM : [OFF]");
- }
DBG("***********************************************************");
DBG("### Feature ###");
event = (struct inotify_event *)(&buffer[i]);
__process_inoti_event(event);
temp_idx = i + event->len + INOTI_EVENT_SIZE;
- if (temp_idx > length) {
+ if (temp_idx > length)
break;
- } else {
+ else
i = temp_idx;
- }
}
}
/* find empty cell */
for (i = 0; i < INOTI_FOLDER_COUNT_MAX; i++) {
/* If not empty */
- if (g_inoti_watches[i].wd != 0) {
+ if (g_inoti_watches[i].wd != 0)
continue;
- } else {
+ else
break;
- }
}
if (i == INOTI_FOLDER_COUNT_MAX) {
return;
}
- if (_util_thread_join(g_inoti_thrd, 0) == FALSE) {
+ if (_util_thread_join(g_inoti_thrd, 0) == FALSE)
ERR("_util_thread_join() Fail");
- }
return;
}
mtp_int32 i = 0;
for (i = 0; i < g_cnt_watch_folder; i++) {
- if (g_inoti_watches[i].forlder_name == NULL) {
+ if (g_inoti_watches[i].forlder_name == NULL)
continue;
- }
- if (g_strcmp0(g_inoti_watches[i].forlder_name, path) != 0) {
+ if (g_strcmp0(g_inoti_watches[i].forlder_name, path) != 0)
continue;
- }
g_free(g_inoti_watches[i].forlder_name);
g_inoti_watches[i].forlder_name = NULL;
static void __remove_file_from_inoti_open_files_list(open_files_info_t *node)
{
- if (NULL != node->previous) {
+ if (NULL != node->previous)
node->previous->next = node->next;
- }
- if (NULL != node->next) {
+ if (NULL != node->next)
node->next->previous = node->previous;
- }
- if (node == g_open_files_list) {
+ if (node == g_open_files_list)
g_open_files_list = node->previous;
- }
+
g_free(node->name);
g_free(node);
_util_get_internal_path(inter_path);
if (!g_strcmp0(parent_path, inter_path) ||
- !g_strcmp0(parent_path, ext_path))
- {
+ !g_strcmp0(parent_path, ext_path)) {
DBG("parent is the root folder");
h_parent = 0;
} else {
}
}
- if (TRUE == isdir) {
+ if (TRUE == isdir)
__delete_children_from_store_inoti(store, obj);
- }
node = _util_delete_node(&(store->obj_list), obj);
g_free(node);
ret_if(g_open_files_list == NULL);
- while(g_open_files_list) {
+ while (g_open_files_list) {
current = g_open_files_list;
g_open_files_list = g_open_files_list->previous;
- if (g_open_files_list) {
+ if (g_open_files_list)
g_open_files_list->next = NULL;
- }
g_free(current->name);
current->wd = 0;
mtp_uint32 _hdlr_get_param_cmd_container(cmd_container_t *cntr,
mtp_uint32 index)
{
- if (index < cntr->no_param) {
+ if (index < cntr->no_param)
return cntr->params[index];
- }
+
return 0;
}
dst->no_param =
(src->len - sizeof(header_container_t)) / sizeof(mtp_uint32);
- for (ii = 0; ii < dst->no_param; ii++) {
+ for (ii = 0; ii < dst->no_param; ii++)
dst->params[ii] = src->params[ii];
- }
+
return;
}
dst->len = src->len;
dst->no_param = src->no_param;
- for (ii = 0; ii < dst->no_param; ii++) {
+ for (ii = 0; ii < dst->no_param; ii++)
dst->params[ii] = src->params[ii];
- }
return;
}
}
res = _util_thread_join(g_data_rcv, &th_result);
- if (res == FALSE) {
+ if (res == FALSE)
ERR("_util_thread_join(data_rcv) Fail");
- }
}
- if (_transport_mq_deinit(&g_usb_to_mtp_mqid, &mtp_to_usb_mqid) == FALSE) {
+ if (_transport_mq_deinit(&g_usb_to_mtp_mqid, &mtp_to_usb_mqid) == FALSE)
ERR("_transport_mq_deinit() Fail");
- }
_transport_deinit_usb_device();
mtp_uint32 pkt_len = 0;
mtp_int32 flag = 1;
mtp_int32 len = 0;
- _cmd_handler_cb _cmd_handler_func = (_cmd_handler_cb )func;
+ _cmd_handler_cb _cmd_handler_func = (_cmd_handler_cb)func;
while (flag) {
if (_util_msgq_receive(g_usb_to_mtp_mqid, (void *)&pkt,
DBG("USB_PTPREQUEST_RESET");
_reset_mtp_device();
- if (kernel_reset == FALSE) {
+ if (kernel_reset == FALSE)
kernel_reset = TRUE;
- }
status = ioctl(g_usb_fd, MTP_SEND_RESET_ACK, NULL);
if (status < 0) {
statusreq_data.code = PTP_RESPONSE_GEN_ERROR;
}
- if (statusreq_data.code == PTP_RESPONSE_DEVICEBUSY) {
+ if (statusreq_data.code == PTP_RESPONSE_DEVICEBUSY)
sent_busy = TRUE;
- } else {
+ else
sent_busy = FALSE;
- }
status = ioctl(g_usb_fd, MTP_SET_SETUP_DATA, &statusreq_data);
if (status < 0) {
if (*rx_mqid) {
res = _util_msgq_deinit(rx_mqid);
- if (res == FALSE) {
+ if (res == FALSE)
ERR("rx_mqid deinit Fail [%d]\n", errno);
- } else {
+ else
*rx_mqid = 0;
- }
}
if (*tx_mqid) {
res = _util_msgq_deinit(tx_mqid);
- if (res == FALSE) {
+ if (res == FALSE)
ERR("tx_mqid deinit fail [%d]\n", errno);
- } else {
+ else
*tx_mqid = 0;
- }
}
return res;
}
}
- if (usb_speed % MTP_MAX_PACKET_SIZE_SEND_HS) {
+ if (usb_speed % MTP_MAX_PACKET_SIZE_SEND_HS)
return MTP_MAX_PACKET_SIZE_SEND_FS;
- }
return MTP_MAX_PACKET_SIZE_SEND_HS;
}
}
if (MTP_ERROR_OBJECT_WRITE_PROTECTED == ret) {
DBG("Folder[%s] contains read-only files,hence\
- folder is not deleted\n",pathname);
+ folder is not deleted\n", pathname);
/* Read the next entry */
goto DONE;
}
(S_IWGRP & entryinfo.st_mode) ||
(S_IWOTH & entryinfo.st_mode))) {
ret = MTP_ERROR_OBJECT_WRITE_PROTECTED;
- DBG("File [%s] is readOnly:Deletion Fail\n",pathname);
+ DBG("File [%s] is readOnly:Deletion Fail\n", pathname);
goto DONE;
}
}
switch (stat_buf.st_mode & S_IFMT) {
case S_IFREG:
dir_info->type = MTP_FILE_TYPE;
- if (!(stat_buf.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH))) {
+ if (!(stat_buf.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
dir_info->attrs.attribute |= MTP_FILE_ATTR_MODE_READ_ONLY;
- }
break;
case S_IFDIR:
}
#ifdef __USE_STDIO__
- while((read_bytes = getline(&buffer,
+ while ((read_bytes = getline(&buffer,
(size_t *)&line_max_length, fhandle)) != -1) {
if (read_bytes > MTP_MAX_PATHNAME_SIZE + 1)
continue;
mtp_uint32 prev_pos = -1;
mtp_uint32 new_pos;
mtp_uint32 filename_len = 0;
- while((read_bytes = read(fhandle, buffer, LINUX_MAX_PATHNAME_LENGTH)) > 0) {
+ while ((read_bytes = read(fhandle, buffer, LINUX_MAX_PATHNAME_LENGTH)) > 0) {
for (ii = 0; ii < read_bytes; ii++) {
if (buffer[ii] != '\n')
continue;
continue;
line_count++;
}
- if (buffer[read_bytes - 1] != '\n') {
+ if (buffer[read_bytes - 1] != '\n')
_util_file_seek(fhandle, prev_pos + 1 - read_bytes, SEEK_CUR);
- }
+
prev_pos = -1;
}
#endif /* __USE_STDIO__ */
pguidarray->num_elements += sizeof(mtp_uint32);
}
- if (buffer[read_bytes - 1] != '\n') {
+ if (buffer[read_bytes - 1] != '\n')
_util_file_seek(fhandle, prev_pos + 1 - read_bytes, SEEK_CUR);
- }
+
prev_pos = -1;
}
#endif /* __USE_STDIO__ */
fp = fopen(MTP_LOG_FILE, "a+");
}
- if (fp == NULL) {
+ if (fp == NULL)
return;
- }
written_bytes += fprintf(fp, "%s ", __FILE__);
va_start(ap, fmt);
slist_node_t *nptr = l_ptr->start;
slist_node_t *temp = NULL;
- if (nptr->value == data) {
+ if (nptr->value == data)
return __util_del_first_node(l_ptr);
- }
while (nptr->link) {
if (nptr->link->value == data)
temp = l_ptr->start;
l_ptr->nnodes -= 1;
l_ptr->start = temp->link;
- if (temp == l_ptr->end) {
+ if (temp == l_ptr->end)
l_ptr->end = NULL;
- }
return temp;
}
static void __scan_folder_cb(media_content_error_e err, void *user_data)
{
- if (err != MEDIA_CONTENT_ERROR_NONE) {
+ if (err != MEDIA_CONTENT_ERROR_NONE)
ERR("Scan folder callback returns error = [%d]\n", err);
- }
return;
}
goto ERROR_EXIT;
}
- ret =audio_meta_get_composer(audio, &(audio_data->commonmeta.author));
+ ret = audio_meta_get_composer(audio, &(audio_data->commonmeta.author));
if (ret != MEDIA_CONTENT_ERROR_NONE) {
ERR("METADATA_AUTHOR Fail");
goto ERROR_EXIT;
ERR("media_info_foreach_media_from_db() Fail");
break;
}
- }while (0);
+ } while (0);
media_filter_destroy(filter);
ret_if(filepath == NULL);
ret = media_content_scan_folder(filepath, true, __scan_folder_cb, NULL);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
ERR("media_content_scan_folder Fail : %d\n", ret);
- }
return;
}
{
int ret = 0;
- if (flags == 1) {
+ if (flags == 1)
ret = msgrcv(mq_id, buf, size, 0, IPC_NOWAIT);
- } else {
+ else
ret = msgrcv(mq_id, buf, size, 0, 0);
- }
if (ret == -1) {
ERR("msgrcv() Fail");
ret_if(str == NULL);
retm_if(elem_sz <= 1, "elem_sz(%d) is invalid", elem_sz);
- for (idx = 0; idx < f_size; idx += elem_sz) {
+ for (idx = 0; idx < f_size; idx += elem_sz)
_util_conv_byte_order(&(l_str[idx]), elem_sz);
- }
return;
}
ret_if(src == NULL);
ret_if(dest == NULL);
- if (!((int)dest & 0x1) && !((int)src & 0x1)){
+ if (!((int)dest & 0x1) && !((int)src & 0x1)) {
/* 2-byte aligned */
mtp_wchar *temp = dest;
- while ((*temp++ = *src++) != '\0') {
+ while ((*temp++ = *src++) != '\0')
; /* DO NOTHING */
- }
} else {
/* not-aligned, byte to byte approach - slow */
mtp_char *pc1 = (mtp_char *)dest;
if (!((int)dest & 0x1) && !((int)src & 0x1)) { /* 2-byte aligned */
temp = dest;
- while (n && (*temp++ = *src++)) {
+ while (n && (*temp++ = *src++))
n--;
- }
if (n) {
- while (--n) {
+ while (--n)
*temp++ = 0;
- }
}
} else { /* not-aligned, byte to byte approach - slow */
if (!((int)s & 0x1)) { /* 2-byte aligned */
mtp_wchar *temp = (mtp_wchar *)s;
- while (*temp++) {
+ while (*temp++)
/* DO NOTHING */ ;
- }
DBG("Length : %d\n", temp - s - 1);
return ((size_t)(temp - s - 1));
unsigned char *temp = (unsigned char *)s;
- while (*temp || *(temp + 1)) {
+ while (*temp || *(temp + 1))
temp += 2;
- }
DBG("Length : %d\n", (temp - (unsigned char *)s) / 2);
return ((size_t) (temp - (unsigned char *)s) / 2);
*nstr++ = '0';
*nstr++ = 'x';
- for (val = int_val; val; val <<= 4) {
+ for (val = int_val; val; val <<= 4)
*nstr++ = hex[(val >> (sizeof(int) * 8 - 4)) & 0xF];
- }
+
*nstr = '\0';
return str;
}
i = strlen(fullpath);
- for (j=0; i >= 0; i--) {
+ for (j = 0; i >= 0; i--) {
if (fullpath[i] == '/') {
g_strlcpy(f_name, &fullpath[i + 1], j);
return TRUE;
root_path_len = internal_store_len;
} else if (!strncmp(path, ext_path, external_store_len)) {
root_path_len = external_store_len;
- }
- else {
+ } else {
ERR("Unknown store's path : %s\n", path);
return FALSE;
}
ret_if(wstr == NULL);
ret_if(guid == NULL);
- while (wstr[count] != 0) {
+ while (wstr[count] != 0)
count++;
- }
memset(guid, 0, sizeof(temp));
skip_idx = sizeof(temp) / sizeof(mtp_wchar);
memset(temp, 0, sizeof(temp));
cpy_sz = (count - cur_idx) * sizeof(mtp_wchar);
- if (cpy_sz > sizeof(temp)) {
+ if (cpy_sz > sizeof(temp))
cpy_sz = sizeof(temp);
- }
+
memcpy(temp, &(wstr[cur_idx]), cpy_sz);
guid[0] += temp[0];
guid[1] += temp[1];
while (val < max_value) {
/* Including NUL and '_' */
g_snprintf(&buf[len], num_bytes + 2, "_%u", val++);
- if (access(buf, F_OK) < 0) {
+ if (access(buf, F_OK) < 0)
goto SUCCESS;
- }
}
g_free(buf);
error = pthread_create(tid, &attr, thread_func, arg);
if (error != 0) {
- ERR( "[%s] Thread creation Fail errno [%d]\n", tname, errno);
+ ERR("[%s] Thread creation Fail errno [%d]\n", tname, errno);
pthread_attr_destroy(&attr);
return FALSE;
}
error = pthread_attr_destroy(&attr);
- if (error != 0) {
+ if (error != 0)
ERR("pthread_attr_destroy Fail [%d] errno [%d]\n", error, errno);
- }
return TRUE;
}
result = vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY,
&battery_level);
- if (result != 0) {
+ if (result != 0)
ERR("VCONFKEY_SYSMAN_BATTERY_CAPACITY Fail!");
- }
+
return battery_level;
}
gcry_md_hash_buffer(GCRY_MD_MD5, hash_value, imei_no, strlen(imei_no));
- for (i = 0; i < MD5_HASH_LEN; i++) {
+ for (i = 0; i < MD5_HASH_LEN; i++)
g_snprintf(&serial[i*2], 3, "%02X", hash_value[i]);
- }
if (vconf_set_str(VCONFKEY_MTP_SERIAL_NUMBER_STR, serial) == -1) {
ERR("vconf_set Fail for %s\n",
g_snprintf(serial, len, "%s-%010ld-%011ld", model_name,
st.tv_sec, st.tv_usec);
- if (vconf_set_str(VCONFKEY_MTP_SERIAL_NUMBER_STR, serial) == -1) {
+ if (vconf_set_str(VCONFKEY_MTP_SERIAL_NUMBER_STR, serial) == -1)
ERR("vconf_set Fail %s\n", VCONFKEY_MTP_SERIAL_NUMBER_STR);
- }
return;
}
{
char *storage_path = (char *)user_data;
- DBG("storage id: %d, path: %s", storage_id, path);
+ //DBG("storage id: %d, path: %s", storage_id, path);
if (type == STORAGE_TYPE_EXTERNAL && path != NULL) {
strncpy(storage_path, path, strlen(path));
- DBG("external storage path : %s", storage_path);
+ //DBG("external storage path : %s", storage_path);
}
return TRUE;
{
char *storage_path = (char *)user_data;
- DBG("storage id: %d, path: %s", storage_id, path);
+ //DBG("storage id: %d, path: %s", storage_id, path);
if (type == STORAGE_TYPE_INTERNAL && path != NULL) {
strncpy(storage_path, path, strlen(path));
- DBG("internal storage path : %s", storage_path);
+ //DBG("internal storage path : %s", storage_path);
if (storage_get_root_directory(storage_id, &storage_path) != STORAGE_ERROR_NONE) {
ERR("get internal storage path Fail");
return FALSE;
} else {
- DBG("get internal storage path : %s", storage_path);
+ //DBG("get internal storage path : %s", storage_path);
}
}