From d6b91b8bd212979b4996cb2d8747b96dedcc4aec Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Fri, 15 Jan 2016 15:12:48 +0900 Subject: [PATCH 01/16] Update document Change-Id: I9c5f3aa395a554c9199eaadbb688c69dff1336b7 Signed-off-by: Minje Ahn --- doc/metadata_editor_doc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/metadata_editor_doc.h b/doc/metadata_editor_doc.h index 9821d03..56f1310 100755 --- a/doc/metadata_editor_doc.h +++ b/doc/metadata_editor_doc.h @@ -31,7 +31,7 @@ /** * @addtogroup CAPI_MEDIA_METADATA_EDITOR_MODULE - * @brief The @ref CAPI_MEDIA_METADATA_EDITOR_MODULE API provides functions for editing the metadata of several popular audio format. + * @brief The @ref CAPI_MEDIA_METADATA_EDITOR_MODULE API provides functions for editing the metadata of mp3, mp4 contents. * @ingroup CAPI_MEDIA_FRAMEWORK * @section CAPI_MEDIA_METADATA_EDITOR_MODULE_HEADER Required Header * \#include -- 2.7.4 From 8e891f25aca30bae1460ea724cf0f95ec0424ca0 Mon Sep 17 00:00:00 2001 From: Haejeong Kim Date: Tue, 26 Jan 2016 15:24:31 +0900 Subject: [PATCH 02/16] Apply tizen coding rule Change-Id: Ib0db311b7d228881df5b6ba684df155065c33b64 --- test/metadata_editor_test.c | 98 ++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/test/metadata_editor_test.c b/test/metadata_editor_test.c index 132ab89..76ad7e6 100755 --- a/test/metadata_editor_test.c +++ b/test/metadata_editor_test.c @@ -308,19 +308,19 @@ static bool __add_picture(metadata_editor_h metadata) __flush(); switch (c2) { - case 1: - printf("\n==========================="); - printf("\n Your choice is TestImage.png\n"); - picture_filename = strdup("TestImage.png"); - break; - - case 2: - printf("\n==========================="); - printf("\n Your choice is TestImage.jpg\n"); - picture_filename = strdup("TestImage.jpg"); - break; - default: - break; + case 1: + printf("\n==========================="); + printf("\n Your choice is TestImage.png\n"); + picture_filename = strdup("TestImage.png"); + break; + + case 2: + printf("\n==========================="); + printf("\n Your choice is TestImage.jpg\n"); + picture_filename = strdup("TestImage.jpg"); + break; + default: + break; } metadata_editor_append_picture(metadata, picture_filename); @@ -367,7 +367,7 @@ int main(int argc, char *argv[]) if (cnt < 1) { printf("\n===================================================================================================="); - printf("\n Please type file path and media type as media-metadata-test /opt/usr/media/Sounds/ "); + printf("\n Please type file path and media type as media-metadata-test /opt/usr/media/Sounds/"); printf("\n===================================================================================================="); return 0; } @@ -377,7 +377,7 @@ int main(int argc, char *argv[]) /*__printRetValue("metadata_editor_create(...)",ret); */ if (ret != METADATA_EDITOR_ERROR_NONE) { - printf("Fail metadata_editor_create() at line [%d]\n", __LINE__); + printf("Fail metadata_editor_create() at line [%d]\n", __LINE__); return 0; } @@ -385,7 +385,7 @@ int main(int argc, char *argv[]) /*__printRetValue("metadata_editor_set_path(...)",ret); */ if (ret != METADATA_EDITOR_ERROR_NONE) { - printf("Fail metadata_editor_set_path() at line [%d]\n", __LINE__); + printf("Fail metadata_editor_set_path() at line [%d]\n", __LINE__); goto exception; } @@ -404,42 +404,42 @@ int main(int argc, char *argv[]) printf("9 - Quit. Press 9 "); printf("\n=========================\n"); printf("\n Your choice : "); - dummy = scanf("%u", &c2); + dummy = scanf("%u", &c2); __flush(); switch (c2) { - case 1: - printf("\n=============="); - printf("\n Reading tags \n"); - __get_tag_info(metadata); - break; - case 2: - printf("\n=============="); - printf("\n Writing tags "); - __write_tag_info(metadata); - break; - case 3: - printf("\n=============="); - printf("\n Deleting tags "); - __delete_tag_info(metadata); - break; - case 4: - printf("\n=============="); - printf("\n Adding picture "); - __add_picture(metadata); - break; - case 5: - printf("\n=============="); - printf("\n Deleting pictures \n"); - __delete_pictures(metadata); - break; - case 6: - printf("\n=============="); - printf("\n Saving updated tags \n"); - __save_tags(metadata); - break; - default: - break; + case 1: + printf("\n=============="); + printf("\n Reading tags \n"); + __get_tag_info(metadata); + break; + case 2: + printf("\n=============="); + printf("\n Writing tags "); + __write_tag_info(metadata); + break; + case 3: + printf("\n=============="); + printf("\n Deleting tags "); + __delete_tag_info(metadata); + break; + case 4: + printf("\n=============="); + printf("\n Adding picture "); + __add_picture(metadata); + break; + case 5: + printf("\n=============="); + printf("\n Deleting pictures \n"); + __delete_pictures(metadata); + break; + case 6: + printf("\n=============="); + printf("\n Saving updated tags \n"); + __save_tags(metadata); + break; + default: + break; } } -- 2.7.4 From 564eb422f457852a780f0276f98834c02f47b421 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Wed, 2 Mar 2016 17:43:12 +0900 Subject: [PATCH 03/16] Fix error type Change-Id: Ifd294812f6143d9b27d82f8ca2f29148c16f164b Signed-off-by: Minje Ahn --- include/metadata_editor_type.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/metadata_editor_type.h b/include/metadata_editor_type.h index 37345a0..2e738af 100755 --- a/include/metadata_editor_type.h +++ b/include/metadata_editor_type.h @@ -31,6 +31,9 @@ extern "C" { * @{ */ +/** @brief Definition for Metadata editor Error Class */ +#define METADATA_EDITOR_ERROR_CLASS TIZEN_ERROR_METADATA_EDITOR + /** * @ingroup CAPI_MEDIA_METADATA_EDITOR_MODULE * @brief The enumerations of media metadata error @@ -38,13 +41,13 @@ extern "C" { */ typedef enum { - METADATA_EDITOR_ERROR_NONE = TIZEN_ERROR_METADATA_EDITOR, /**< Successful */ + METADATA_EDITOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ METADATA_EDITOR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ METADATA_EDITOR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ METADATA_EDITOR_ERROR_FILE_EXISTS = TIZEN_ERROR_FILE_EXISTS, /**< File not exist */ METADATA_EDITOR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ METADATA_EDITOR_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Unsupported type */ - METADATA_EDITOR_ERROR_OPERATION_FAILED = TIZEN_ERROR_METADATA_EDITOR |0x01, /**< Invalid internal operation */ + METADATA_EDITOR_ERROR_OPERATION_FAILED = METADATA_EDITOR_ERROR_CLASS |0x01, /**< Invalid internal operation */ } metadata_editor_error_e; -- 2.7.4 From 09c03e69defe45bc39ab890f5cff0d08babf98d1 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Tue, 22 Mar 2016 14:14:51 +0900 Subject: [PATCH 04/16] Update API version description Change-Id: I867b863095d44467ed5f0412d33d4a49a299c11a Signed-off-by: Minje Ahn --- include/metadata_editor.h | 18 +++++++++--------- include/metadata_editor_type.h | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/metadata_editor.h b/include/metadata_editor.h index 1a038f6..1502e52 100755 --- a/include/metadata_editor.h +++ b/include/metadata_editor.h @@ -37,7 +37,7 @@ extern "C" { /** * @brief Create metadata - * @since_tizen 2.4 + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remarks You must release @a metadata using metadata_editor_destroy(). * @@ -53,7 +53,7 @@ int metadata_editor_create(metadata_editor_h *metadata); /** * @brief Set file path to read or write metadata - * @since_tizen 2.4 + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remarks In case of accessing specific path in internal storage or external storage, you may add the privilege for accessing the path. \n * For example, if you get the specific path by using storage_get_directory(). you should add previlege http://tizen.org/privilege/mediastorage or http://tizen.org/privilege/externalstorage. @@ -75,7 +75,7 @@ int metadata_editor_set_path(metadata_editor_h metadata, const char *path); /** * @brief Get the metadata corresponding to the attribute. - * @since_tizen 2.4 + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remarks You must release @a value using @c free(). \n * If the attribute value of the metadata is empty, return value is NULL. \n @@ -99,7 +99,7 @@ int metadata_editor_get_metadata(metadata_editor_h metadata, metadata_editor_att /** * @brief Set the attribute of the metadata. - * @since_tizen 2.4 + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @details This function set the attribute of the metadata for updating the metadata. \n * * @remarks You must release @a value using @c free(). \n @@ -121,7 +121,7 @@ int metadata_editor_set_metadata(metadata_editor_h metadata, metadata_editor_att /** * @brief Update the modified metadata - * @since_tizen 2.4 + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @details This function update the metadata in the media file that is modified by metadata_editor_set_metadata(). * * @remarks In case of accessing specific path in internal storage or external storage, you may add the privilege for accessing the path. \n @@ -141,7 +141,7 @@ int metadata_editor_update_metadata(metadata_editor_h metadata); /** * @brief Get the picture in the media file - * @since_tizen 2.4 + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remarks You must release @a picture using @c free(). \n * In case of accessing specific path in internal storage or external storage, you may add the privilege for accessing the path. \n @@ -165,7 +165,7 @@ int metadata_editor_get_picture(metadata_editor_h metadata, int index, void **pi /** * @brief Append the picture to the media file - * @since_tizen 2.4 + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remarks You must call metadata_editor_update_metadata() for applying to the metadata of the media file. if not, you will see the existing metadata when you call metadata_editor_get_metadata(). \n * Image type of the metadata supports jpeg and png. \n @@ -188,7 +188,7 @@ int metadata_editor_append_picture(metadata_editor_h metadata, const char *pictu /** * @brief Remove artwork image from media file - * @since_tizen 2.4 + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remarks You must call metadata_editor_update_metadata() for applying to the metadata of the media file. if not, you will see the existing metadata when you call metadata_editor_get_metadata(). \n * @@ -207,7 +207,7 @@ int metadata_editor_remove_picture(metadata_editor_h metadata, int index); /** * @brief Destroy metadata - * @since_tizen 2.4 + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @param [in] metadata The handle to metadata * @return 0 on success, otherwise a negative error value diff --git a/include/metadata_editor_type.h b/include/metadata_editor_type.h index 2e738af..0c0354f 100755 --- a/include/metadata_editor_type.h +++ b/include/metadata_editor_type.h @@ -37,7 +37,7 @@ extern "C" { /** * @ingroup CAPI_MEDIA_METADATA_EDITOR_MODULE * @brief The enumerations of media metadata error - * @since_tizen 2.4 + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { @@ -54,7 +54,7 @@ typedef enum /** * @ingroup CAPI_MEDIA_METADATA_EDITOR_MODULE * @brief The enumerations of attribute - * @since_tizen 2.4 + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { METADATA_EDITOR_ATTR_ARTIST, /**< Artist*/ @@ -75,7 +75,7 @@ typedef enum { /** * @ingroup CAPI_MEDIA_METADATA_EDITOR_MODULE * @brief The handle of media metadata - * @since_tizen 2.4 + * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef void * metadata_editor_h; -- 2.7.4 From 4392787a14aec29c34c7ba619b1e8b0818143f19 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Fri, 1 Apr 2016 09:59:50 +0900 Subject: [PATCH 05/16] Apply coding rule Change-Id: I9235d4dcff529f0f0deacdcb399cf45b4edb9f24 Signed-off-by: Minje Ahn --- include/metadata_editor_private.h | 10 +++++----- include/metadata_editor_type.h | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/metadata_editor_private.h b/include/metadata_editor_private.h index a71df10..f60994f 100755 --- a/include/metadata_editor_private.h +++ b/include/metadata_editor_private.h @@ -53,9 +53,9 @@ extern "C" { #undef LOG_TAG #endif #define LOG_TAG "CAPI_MEDIA_METADATA_EDITOR" -#define META_SAFE_FREE(src) { if(src) {free(src); src = NULL;} } -#define META_MALLOC(src, size) { if (size <= 0) {src = NULL;} \ - else { src = (char *)malloc(size); if(src) memset(src, 0x0, size);} } +#define META_SAFE_FREE(src) { if (src) {free(src); src = NULL; } } +#define META_MALLOC(src, size) { if (size <= 0) src = NULL; \ + else { src = (char *)malloc(size); if (src) memset(src, 0x0, size); } } #define META_MAX_BUF_LEN 20 @@ -81,8 +81,8 @@ extern "C" { } while (0) #define metadata_editor_retvm_if(expr, val, fmt, arg...) do { \ - if(expr) { \ - LOGE(""fmt"", ##arg); \ + if (expr) { \ + LOGE(""fmt"", ##arg); \ return (val); \ } \ } while (0) diff --git a/include/metadata_editor_type.h b/include/metadata_editor_type.h index 0c0354f..d7ab918 100755 --- a/include/metadata_editor_type.h +++ b/include/metadata_editor_type.h @@ -39,11 +39,10 @@ extern "C" { * @brief The enumerations of media metadata error * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ -typedef enum -{ - METADATA_EDITOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ +typedef enum { + METADATA_EDITOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ METADATA_EDITOR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - METADATA_EDITOR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + METADATA_EDITOR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ METADATA_EDITOR_ERROR_FILE_EXISTS = TIZEN_ERROR_FILE_EXISTS, /**< File not exist */ METADATA_EDITOR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ METADATA_EDITOR_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Unsupported type */ -- 2.7.4 From bd3d6f71199bca30fd24ba81b2e3b3d7bfe9f9ff Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Thu, 14 Apr 2016 08:38:29 +0900 Subject: [PATCH 06/16] Apply tizen coding rule Change-Id: Ia165a1d0fb745012cce961c712077af831a2d9bc Signed-off-by: Minje Ahn --- src/metadata_editor.cpp | 157 ++++++++++++++++++++++++------------------------ 1 file changed, 78 insertions(+), 79 deletions(-) diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index b152df9..f7fa133 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -101,7 +101,7 @@ static int __ID3_getTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: if (!str.isLatin1()) isUTF = true; metadata_editor_info("String is %sUTF\n", (isUTF ? "" : "not ")); length = strlen(str.toCString(isUTF)); - metadata_editor_retvm_if(length == 0,METADATA_EDITOR_ERROR_NONE,"Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); *value = strndup(str.toCString(isUTF), length); return METADATA_EDITOR_ERROR_NONE; } @@ -118,7 +118,7 @@ static int __ID3_getTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: if (found) { length = strlen(buf); - metadata_editor_retvm_if(length == 0,METADATA_EDITOR_ERROR_NONE,"Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); *value = strndup(buf, length); return METADATA_EDITOR_ERROR_NONE; } @@ -136,7 +136,7 @@ static int __ID3_getTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: if (!str.isLatin1()) isUTF = true; metadata_editor_info("String is %sUTF\n", (isUTF ? "" : "not ")); uint length = strlen(str.toCString(isUTF)); - metadata_editor_retvm_if(length == 0,METADATA_EDITOR_ERROR_NONE,"Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); *value = strndup(str.toCString(isUTF), length); @@ -153,7 +153,7 @@ static int __ID3_setTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: metadata_editor_retvm_if(frameID == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); // Check if the valid tag pointer exists @@ -186,14 +186,14 @@ static int __ID3_setTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: metadata_editor_info("The frame %s does not exist. Creating.\n", frameID); // This is a common frame type for textural frames except comment frame TagLib::ID3v2::TextIdentificationFrame* fr = new TagLib::ID3v2::TextIdentificationFrame(frameID); - metadata_editor_retvm_if(fr == NULL,METADATA_EDITOR_ERROR_OUT_OF_MEMORY,"OUT_OF_MEMORY"); + metadata_editor_retvm_if(fr == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); fr->setTextEncoding(TagLib::String::UTF8); - fr->setText(TagLib::String(value,TagLib::String::UTF8)); + fr->setText(TagLib::String(value, TagLib::String::UTF8)); tag2->addFrame(fr); } else { // if not - just modify the data in the existing frame metadata_editor_info("The frame %s exists. Changing.\n", frameID); - tag2->frameListMap()[frameID][0]->setText(TagLib::String(value,TagLib::String::UTF8)); + tag2->frameListMap()[frameID][0]->setText(TagLib::String(value, TagLib::String::UTF8)); } if (tag1 && !tag1->isEmpty()) { // Check if ID3v1 tag exists. Must copy data if yes. @@ -225,10 +225,10 @@ static int __ID3_getFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); // Check if the frame is empty (nothing to read) or ID3v2 tag does not exist - metadata_editor_retvm_if(!tag2 || tag2->frameListMap()[frameID].isEmpty(),METADATA_EDITOR_ERROR_NONE,"The frame %s does not exist\n", frameID); + metadata_editor_retvm_if(!tag2 || tag2->frameListMap()[frameID].isEmpty(), METADATA_EDITOR_ERROR_NONE, "The frame %s does not exist\n", frameID); metadata_editor_info("The frame %s exists\n", frameID); // This string is used to copy the value in the frame @@ -238,7 +238,7 @@ static int __ID3_getFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag metadata_editor_info("String is %sUTF\n", (isUTF ? "" : "not ")); uint length = strlen(str.toCString(isUTF)); - metadata_editor_retvm_if(length == 0,METADATA_EDITOR_ERROR_NONE,"Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); *value = strndup(str.toCString(isUTF), length); @@ -253,7 +253,7 @@ static int __ID3_setFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag metadata_editor_retvm_if(frameID == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); // Check if the valid tag pointer exist @@ -271,14 +271,14 @@ static int __ID3_setFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag metadata_editor_info("The frame %s does not exist. Creating.\n", frameID); // This is a common frame type for textural frames except comment frame TagLib::ID3v2::TextIdentificationFrame* fr = new TagLib::ID3v2::TextIdentificationFrame(frameID); - metadata_editor_retvm_if(fr == NULL,METADATA_EDITOR_ERROR_OUT_OF_MEMORY,"OUT_OF_MEMORY"); + metadata_editor_retvm_if(fr == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); fr->setTextEncoding(TagLib::String::UTF8); - fr->setText(TagLib::String(value,TagLib::String::UTF8)); + fr->setText(TagLib::String(value, TagLib::String::UTF8)); tag2->addFrame(fr); } else { // if not - just modify the data in the existing frame metadata_editor_info("The frame %s exists. Changing.\n", frameID); - tag2->frameListMap()[frameID][0]->setText(TagLib::String(value,TagLib::String::UTF8)); + tag2->frameListMap()[frameID][0]->setText(TagLib::String(value, TagLib::String::UTF8)); } return METADATA_EDITOR_ERROR_NONE; @@ -293,7 +293,7 @@ static int __ID3_getNumberOfPictures(metadata_editor_s* _metadata, TagLib::ID3v2 // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); // Check if the valid tag pointer exist metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag does not exist. Can not process further"); @@ -308,7 +308,6 @@ static int __ID3_getNumberOfPictures(metadata_editor_s* _metadata, TagLib::ID3v2 snprintf(buf, META_MAX_BUF_LEN, "%u", lst.size()); *value = strndup(buf, strlen(buf)); return METADATA_EDITOR_ERROR_NONE; - } // *** This function is used to receive unsynchronized lyrics from ID3v2 tag in file *** // @@ -321,14 +320,14 @@ static int __ID3_getLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); // Check if the valid tag pointer exist - metadata_editor_retvm_if(tag2 == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Error. ID3v2 tag does not exist. Can not process further"); + metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag does not exist. Can not process further"); TagLib::ID3v2::FrameList lst = tag2->frameListMap()["USLT"]; // link to unsynchronized lyric frames in tag // Check if frames exist in file - metadata_editor_retvm_if(lst.isEmpty(),METADATA_EDITOR_ERROR_NONE,"The frame USLT does not exist\n"); + metadata_editor_retvm_if(lst.isEmpty(), METADATA_EDITOR_ERROR_NONE, "The frame USLT does not exist\n"); metadata_editor_info("The frame USLT exists\n"); TagLib::ID3v2::FrameList::Iterator it = lst.begin(); @@ -351,11 +350,11 @@ static int __ID3_setTwixCommentFrame(metadata_editor_s* _metadata, TagLib::ID3v1 metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); // Check if the valid tag pointer exist - metadata_editor_retvm_if(tag2 == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Error. ID3v2 tag was not created. Can not proceed metadata updating"); + metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); // If the pointer is NULL or c-string is empty - handle as request for deletion if (!value || (*value == '\0')) { @@ -375,7 +374,7 @@ static int __ID3_setTwixCommentFrame(metadata_editor_s* _metadata, TagLib::ID3v1 tag2->addFrame(fr); } else { // If the frame already exists - just modify its value metadata_editor_info("The frame COMM exists. Changing.\n"); - tag2->frameListMap()["COMM"][0]->setText(TagLib::String(value,TagLib::String::UTF8)); + tag2->frameListMap()["COMM"][0]->setText(TagLib::String(value, TagLib::String::UTF8)); } if (tag1 && !tag1->isEmpty()) { // Copy the value to ID3v1 tag comment @@ -394,11 +393,11 @@ static int __ID3_setLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); // Check if the valid tag pointer exist - metadata_editor_retvm_if(tag2 == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Error. ID3v2 tag was not created. Can not proceed metadata updating"); + metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); TagLib::ID3v2::FrameList lst = tag2->frameListMap()["USLT"]; // link to unsynchronized lyric frames in tag // If the pointer is NULL or c-string is empty - handle as request for deletion @@ -412,17 +411,17 @@ static int __ID3_setLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag // No lyrics - create the frame and add it to the ID3v2 tag metadata_editor_info("The frame USLT does not exist. Creating.\n"); TagLib::ID3v2::UnsynchronizedLyricsFrame* frame = new TagLib::ID3v2::UnsynchronizedLyricsFrame; - metadata_editor_retvm_if(frame == NULL,METADATA_EDITOR_ERROR_OUT_OF_MEMORY,"OUT_OF_MEMORY"); + metadata_editor_retvm_if(frame == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); frame->setTextEncoding(TagLib::String::UTF8); - frame->setText(TagLib::String(value,TagLib::String::UTF8)); + frame->setText(TagLib::String(value, TagLib::String::UTF8)); tag2->addFrame(frame); } else { // the lyrics frames exist - change the existing one metadata_editor_info("USLT frames exist in file. Changing.\n"); TagLib::ID3v2::FrameList::Iterator it = lst.begin(); TagLib::ID3v2::UnsynchronizedLyricsFrame* frame = static_cast(*it); frame->setTextEncoding(TagLib::String::UTF8); - frame->setText(TagLib::String(value,TagLib::String::UTF8)); + frame->setText(TagLib::String(value, TagLib::String::UTF8)); } return METADATA_EDITOR_ERROR_NONE; @@ -439,11 +438,11 @@ static int __MP4_getStringItem(metadata_editor_s* _metadata, const char* itemnam // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); - metadata_editor_retvm_if(tag == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Tag does not exist"); + metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); // Get map of items directly from tag and launch a search of specific item TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); @@ -456,7 +455,7 @@ static int __MP4_getStringItem(metadata_editor_s* _metadata, const char* itemnam metadata_editor_info("String is %sUTF\n", (isUTF ? "" : "not ")); // Get the length of the string and check if it is empty or not uint length = strlen(str.toCString(isUTF)); - metadata_editor_retvm_if(length == 0,METADATA_EDITOR_ERROR_NONE,"Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); *value = strndup(str.toCString(isUTF), length); return METADATA_EDITOR_ERROR_NONE; } else { // Item was not found @@ -476,11 +475,11 @@ static int __MP4_getIntegerItem(metadata_editor_s* _metadata, const char* itemna // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); - metadata_editor_retvm_if(tag == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Tag does not exist"); + metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); // Get map of items directly from tag and launch a search of specific item TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); @@ -491,7 +490,7 @@ static int __MP4_getIntegerItem(metadata_editor_s* _metadata, const char* itemna snprintf(buf, META_MAX_BUF_LEN, "%u", num); // Convert int into char[] // Determine the length of created c-string and copy it into the output variable int length = strlen(buf); - metadata_editor_retvm_if(length == 0,METADATA_EDITOR_ERROR_NONE,"Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); *value = strndup(buf, length); return METADATA_EDITOR_ERROR_NONE; } else { // Item was not found @@ -509,12 +508,12 @@ static int __MP4_updateStringItem(metadata_editor_s* _metadata, const char* item metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail."); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); - metadata_editor_retvm_if(tag == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Tag was not created"); + metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag was not created"); // Get map of items directly from tag and launch a search of specific item TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); @@ -541,12 +540,12 @@ static int __MP4_updateIntegerItem(metadata_editor_s* _metadata, const char* ite metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail."); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); - metadata_editor_retvm_if(tag == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Tag was not created"); + metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag was not created"); // Get map of items directly from tag and launch a search of specific item TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); @@ -580,11 +579,11 @@ static int __MP4_getNumberOfPictures(metadata_editor_s* _metadata, char** value) // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); - metadata_editor_retvm_if(tag == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Tag does not exist\n"); + metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist\n"); // Get map of items directly from tag and launch a search of specific item TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); @@ -593,9 +592,9 @@ static int __MP4_getNumberOfPictures(metadata_editor_s* _metadata, char** value) uint number = it->second.toCoverArtList().size(); // Get the size of CoverList (i.e. number of pictures in file) metadata_editor_info("There are %u picture(s) in file\n", number); char buf[META_MAX_BUF_LEN] = {0, }; - snprintf(buf,META_MAX_BUF_LEN, "%u", number); // Convert integer value of size to its c-string representation + snprintf(buf, META_MAX_BUF_LEN, "%u", number); // Convert integer value of size to its c-string representation int length = strlen(buf); - metadata_editor_retvm_if(length == 0,METADATA_EDITOR_ERROR_NONE,"Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); *value = strndup(buf, length); return METADATA_EDITOR_ERROR_NONE; } else { // Item was not found @@ -614,8 +613,8 @@ static int __xiph_getFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::XiphC // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(!xtag,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Tag does not exist\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(!xtag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist\n"); const TagLib::Ogg::FieldListMap& fieldMap = xtag->fieldListMap(); TagLib::Ogg::FieldListMap::ConstIterator it = fieldMap.find(fieldname); @@ -629,7 +628,7 @@ static int __xiph_getFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::XiphC metadata_editor_info("String is %sUTF\n", (isUTF ? "" : "not ")); // Get the length of the string and check if it is empty or not uint length = strlen(str.toCString(isUTF)); - metadata_editor_retvm_if(length == 0,METADATA_EDITOR_ERROR_NONE,"Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); *value = strndup(str.toCString(isUTF), length); return METADATA_EDITOR_ERROR_NONE; } else { // Field was not found @@ -647,9 +646,9 @@ static int __xiph_updateFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::Xi // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); - metadata_editor_retvm_if(!xtag,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Tag does not exist\n"); + metadata_editor_retvm_if(!xtag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist\n"); // Check if it is a request for deletion if ((value == NULL) || value[0] == '\0') { @@ -659,7 +658,7 @@ static int __xiph_updateFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::Xi } metadata_editor_info("The field %s will be added\n", fieldname); // "true" is used to remove other strings of the same "fieldname" first - xtag->addField(fieldname, TagLib::String(value,TagLib::String::UTF8), true); + xtag->addField(fieldname, TagLib::String(value, TagLib::String::UTF8), true); return METADATA_EDITOR_ERROR_NONE; } @@ -673,7 +672,7 @@ static int __FLAC_getNumberOfPictures(metadata_editor_s* _metadata, char** value // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); TagLib::FLAC::File* _file = (TagLib::FLAC::File*) _metadata->file; if (_file->pictureList().isEmpty()) { @@ -683,9 +682,9 @@ static int __FLAC_getNumberOfPictures(metadata_editor_s* _metadata, char** value uint number = _file->pictureList().size(); metadata_editor_info("There are %u picture(s) in file\n", number); char buf[META_MAX_BUF_LEN] = {0, }; - snprintf(buf,META_MAX_BUF_LEN, "%u", number); // Convert integer value of size to its c-string representation + snprintf(buf, META_MAX_BUF_LEN, "%u", number); // Convert integer value of size to its c-string representation uint length = strlen(buf); - metadata_editor_retvm_if(length == 0,METADATA_EDITOR_ERROR_NONE,"Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); *value = strndup(buf, length); return METADATA_EDITOR_ERROR_NONE; } @@ -712,7 +711,7 @@ int __metadata_editor_get_file_ext(const char *file_path, char *file_ext, int ma int __metadata_editor_get_file_type(const char *path) { int ret = 0; - char mimetype[255] = {0,}; + char mimetype[255] = {0, }; /* get content type and mime type from file. */ ret = aul_get_mime_from_file(path, mimetype, sizeof(mimetype)); @@ -721,7 +720,7 @@ int __metadata_editor_get_file_type(const char *path) char ext[255] = { 0 }; int ret = __metadata_editor_get_file_ext(path, ext, sizeof(ext)); - metadata_editor_retvm_if(ret < 0,METADATA_EDITOR_FORMAT_NOTYPE,"__metadata_editor_get_file_type failed"); + metadata_editor_retvm_if(ret < 0, METADATA_EDITOR_FORMAT_NOTYPE, "__metadata_editor_get_file_type failed"); if (strcasecmp(ext, "MP3") == 0) return METADATA_EDITOR_FORMAT_MP3; @@ -745,7 +744,7 @@ int __metadata_editor_get_file_type(const char *path) int __metadata_editor_get_picture_type(const char *path, char **type) { int ret = 0; - char mimetype[255] = {0,}; + char mimetype[255] = {0, }; const char *type_jpeg = "image/jpeg"; const char *type_png = "image/png"; @@ -756,7 +755,7 @@ int __metadata_editor_get_picture_type(const char *path, char **type) char ext[255] = { 0 }; int ret = __metadata_editor_get_file_ext(path, ext, sizeof(ext)); - metadata_editor_retvm_if(ret < 0,METADATA_EDITOR_ERROR_OPERATION_FAILED,"__metadata_editor_get_file_type failed"); + metadata_editor_retvm_if(ret < 0, METADATA_EDITOR_ERROR_OPERATION_FAILED, "__metadata_editor_get_file_type failed"); if (strcasecmp(ext, "JPG") == 0 || strcasecmp(ext, "JPEG") == 0) { *type = strndup(type_jpeg, strlen(type_jpeg)); @@ -800,7 +799,7 @@ int __metadata_editor_get_picture_info(const char *path, void **picture, int *si file_size++; fclose(fin); - char picture_buffer[file_size] = {0,}; + char picture_buffer[file_size] = {0, }; memset(picture_buffer, 0, file_size * sizeof(char)); fin = fopen(path, "rb"); if (fin) { @@ -826,7 +825,7 @@ extern "C" int metadata_editor_create(metadata_editor_h *metadata) metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_s *_metadata = new metadata_editor_s; // Allocate a structure for handler - metadata_editor_retvm_if(_metadata == NULL,METADATA_EDITOR_ERROR_OUT_OF_MEMORY,"OUT_OF_MEMORY"); + metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); _metadata->file = NULL; _metadata->filetype = METADATA_EDITOR_FORMAT_NOTYPE; // Specify file type out of range @@ -1077,7 +1076,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); switch (_metadata->filetype) { // Process the file according to the specified file type case METADATA_EDITOR_FORMAT_MP3: @@ -1256,7 +1255,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail.\n"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); switch (_metadata->filetype) { // Process the file according to the specified file type @@ -1267,7 +1266,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata TagLib::ID3v1::Tag* tag1 = _file->ID3v1Tag(); TagLib::ID3v2::Tag* tag2 = _file->ID3v2Tag(true); - metadata_editor_retvm_if(tag2 == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Error. ID3v2 tag was not created. Can not proceed metadata updating"); + metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); switch (attribute) { // Check which one of frame type was given for processing case METADATA_EDITOR_ATTR_ARTIST: return __ID3_setTwixFrameByName(_metadata, tag1, tag2, "TPE1", value); @@ -1429,7 +1428,7 @@ extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail.\n"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); switch (_metadata->filetype) { // Process the file according to the specified file type @@ -1518,14 +1517,14 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index *size = 0; *mime_type = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); switch (_metadata->filetype) { // Process the file according to the specified file type case METADATA_EDITOR_FORMAT_MP3: { TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file; // Bring the pointer to actual file type TagLib::ID3v2::Tag* tag2 = _file->ID3v2Tag(); - metadata_editor_retvm_if(tag2 == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Error. No ID3v2 tag in file."); + metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. No ID3v2 tag in file."); TagLib::ID3v2::FrameList lst = tag2->frameListMap()["APIC"]; // Check if there are pictures in the tag @@ -1545,16 +1544,16 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index if (i != index) continue; TagLib::ID3v2::AttachedPictureFrame* pictureFrame = static_cast(*it); uint pictureSize = pictureFrame->picture().size(); - metadata_editor_retvm_if(pictureSize == 0,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Size of picture is 0"); + metadata_editor_retvm_if(pictureSize == 0, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Size of picture is 0"); META_MALLOC(*picture, pictureSize); metadata_editor_retvm_if(*picture == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); memcpy(*picture, pictureFrame->picture().data(), pictureSize); *size = pictureSize; TagLib::String mime = pictureFrame->mimeType(); - if (!strcmp(mime.toCString(),"image/jpeg")) + if (!strcmp(mime.toCString(), "image/jpeg")) *mime_type = strndup(TYPE_JPEG, strlen(TYPE_JPEG)); - else if (!strcmp(mime.toCString(),"image/png")) + else if (!strcmp(mime.toCString(), "image/png")) *mime_type = strndup(TYPE_PNG, strlen(TYPE_PNG)); else *mime_type = NULL; @@ -1568,7 +1567,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index { TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); - metadata_editor_retvm_if(tag == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Tag does not exist\n"); + metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist\n"); // Get map of items directly from tag and launch a search of specific item TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); @@ -1584,7 +1583,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index for (TagLib::MP4::CoverArtList::ConstIterator picIt = lst.begin(); picIt != lst.end(); ++picIt, ++i) { if (i != index) continue; int pictureSize = picIt->data().size(); - metadata_editor_retvm_if(pictureSize == 0,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Size of picture is 0"); + metadata_editor_retvm_if(pictureSize == 0, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Size of picture is 0"); META_MALLOC(*picture, pictureSize); metadata_editor_retvm_if(*picture == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); @@ -1623,16 +1622,16 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index // picture can be received as ByteVector (picIt->data()). // ByteVector has data() - picture itself and size() - the size of picture in data() method int pictureSize = (*picIt)->data().size(); - metadata_editor_retvm_if(pictureSize == 0,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Size of picture is 0"); + metadata_editor_retvm_if(pictureSize == 0, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Size of picture is 0"); META_MALLOC(*picture, pictureSize); metadata_editor_retvm_if(*picture == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); memcpy(*picture, (*picIt)->data().data(), pictureSize); *size = pictureSize; TagLib::String mime = (*picIt)->mimeType(); - if (!strcmp(mime.toCString(),"image/jpeg")) + if (!strcmp(mime.toCString(), "image/jpeg")) *mime_type = strndup(TYPE_JPEG, strlen(TYPE_JPEG)); - else if (!strcmp(mime.toCString(),"image/png")) + else if (!strcmp(mime.toCString(), "image/png")) *mime_type = strndup(TYPE_PNG, strlen(TYPE_PNG)); else *mime_type = NULL; @@ -1668,7 +1667,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index if (i != index) continue; TagLib::ID3v2::AttachedPictureFrame* pictureFrame = static_cast(*it); uint pictureSize = pictureFrame->picture().size(); - metadata_editor_retvm_if(pictureSize == 0,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Size of picture is 0"); + metadata_editor_retvm_if(pictureSize == 0, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Size of picture is 0"); META_MALLOC(*picture, pictureSize); metadata_editor_retvm_if(*picture == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); @@ -1676,9 +1675,9 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index memcpy(*picture, pictureFrame->picture().data(), pictureSize); *size = pictureSize; TagLib::String mime = pictureFrame->mimeType(); - if (!strcmp(mime.toCString(),"image/jpeg")) + if (!strcmp(mime.toCString(), "image/jpeg")) *mime_type = strndup(TYPE_JPEG, strlen(TYPE_JPEG)); - else if (!strcmp(mime.toCString(),"image/png")) + else if (!strcmp(mime.toCString(), "image/png")) *mime_type = strndup(TYPE_PNG, strlen(TYPE_PNG)); else *mime_type = NULL; @@ -1711,11 +1710,11 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail.\n"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); ret = __metadata_editor_get_picture_info(path, &picture, &size, &type); - metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); switch (_metadata->filetype) { // Process the file according to the specified file type case METADATA_EDITOR_FORMAT_MP3: @@ -1861,7 +1860,7 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail.\n"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false,METADATA_EDITOR_ERROR_PERMISSION_DENIED,"File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); switch (_metadata->filetype) { // Process the file according to the specified file type @@ -1871,7 +1870,7 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file; TagLib::ID3v2::Tag* tag2 = _file->ID3v2Tag(true); // Check if the valid tag pointer exists - metadata_editor_retvm_if(tag2 == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Error. ID3v2 tag was not created. Can not proceed metadata updating"); + metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); TagLib::ID3v2::FrameList lst = tag2->frameListMap()["APIC"]; // Check if there are pictures in the tag if (lst.isEmpty()) { @@ -1899,7 +1898,7 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in { TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); - metadata_editor_retvm_if(tag == NULL,METADATA_EDITOR_ERROR_OPERATION_FAILED,"Error. tag not exist."); + metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. tag not exist."); // Get map of items directly from tag and launch a search of specific item TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); @@ -1944,7 +1943,7 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in int i = 0; for (TagLib::List::Iterator picIt = lst.begin(); picIt != lst.end(); ++picIt, ++i) { if (i != index) continue; - _file->removePicture(*picIt,true); + _file->removePicture(*picIt, true); break; } return METADATA_EDITOR_ERROR_NONE; -- 2.7.4 From 965fbc8cd0ff955983eba95f50fcc3b20f36c750 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Mon, 18 Apr 2016 15:37:57 +0900 Subject: [PATCH 07/16] Apply tizen coding rule Change-Id: Ibdea7c535d077fe248c24505621f10ea88be2d70 Signed-off-by: Minje Ahn --- src/metadata_editor.cpp | 216 ++++++++++++++++-------------------------------- 1 file changed, 72 insertions(+), 144 deletions(-) diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index f7fa133..d24c549 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -53,8 +53,7 @@ typedef enum { // *** This is an auxiliary function that is used to get the frame value *** // // *** It operates with frames that exists both in ID3v1 and ID3v2 tags *** // -static int __ID3_getTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* frameID, char** value) -{ +static int __ID3_getTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* frameID, char** value) { // Check if we have valid arguments to work with metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(frameID == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -146,8 +145,7 @@ static int __ID3_getTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: // *** This is an auxiliary function that is used to write the new value to the frame *** // // *** It operates with frames that exists both in ID3v1 and ID3v2 tags *** // -static int __ID3_setTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* frameID, const char* value) -{ +static int __ID3_setTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* frameID, const char* value) { // Check if we have valid arguments to work with metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(frameID == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -216,8 +214,7 @@ static int __ID3_setTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: } // *** This function reads frames that exist only in ID3v2 tag *** // -static int __ID3_getFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, const char* frameID, char** value) -{ +static int __ID3_getFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, const char* frameID, char** value) { // Check if we have valid arguments to work with metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(frameID == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -246,8 +243,7 @@ static int __ID3_getFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag } // *** This function writes frames that exist only in ID3v2 tag *** // -static int __ID3_setFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, const char* frameID, const char* value) -{ +static int __ID3_setFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, const char* frameID, const char* value) { // Check if we have valid arguments to work with metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(frameID == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -285,8 +281,7 @@ static int __ID3_setFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag } // *** This function is used to receive the number of pictures stored in ID3v2 tag of file *** // -static int __ID3_getNumberOfPictures(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, char** value) -{ +static int __ID3_getNumberOfPictures(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, char** value) { // Check if parameters are valid metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(value == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -312,8 +307,7 @@ static int __ID3_getNumberOfPictures(metadata_editor_s* _metadata, TagLib::ID3v2 // *** This function is used to receive unsynchronized lyrics from ID3v2 tag in file *** // // *** This frame differs from other string-type frames and uses UnsynchronizedLyricsFrame instead of TextIdentificationFrame *** // -static int __ID3_getLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, char** value) -{ +static int __ID3_getLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, char** value) { // Check if parameters are valid metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(value == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -344,8 +338,7 @@ static int __ID3_getLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag // *** This function is used to set text in comment frame. It processes both ID3v1 and ID3v2 tags *** // // *** Comment frame is different from other string-type frames. It uses CommentsFrame instead of TextIdentificationFrame *** // -static int __ID3_setTwixCommentFrame(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* value) -{ +static int __ID3_setTwixCommentFrame(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* value) { // Check if we have a valid argument to work with metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -387,8 +380,7 @@ static int __ID3_setTwixCommentFrame(metadata_editor_s* _metadata, TagLib::ID3v1 // *** This function is used to set text in Lyrics frame *** // // *** Lyrics frame is different from other string-type frames and uses UnsynchronizedLyricsFrame instead of TextIdentificationFrame *** // -static int __ID3_setLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, const char* value) -{ +static int __ID3_setLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, const char* value) { // Check if we have a valid argument to work with metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -428,8 +420,7 @@ static int __ID3_setLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag } // *** This function extracts string values from tag in MP4 file *** // -static int __MP4_getStringItem(metadata_editor_s* _metadata, const char* itemname, char** value) -{ +static int __MP4_getStringItem(metadata_editor_s* _metadata, const char* itemname, char** value) { // Check if parameters are valid metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(itemname == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -465,8 +456,7 @@ static int __MP4_getStringItem(metadata_editor_s* _metadata, const char* itemnam } // *** This function extracts integer value from item in MP4 tag *** // -static int __MP4_getIntegerItem(metadata_editor_s* _metadata, const char* itemname, char** value) -{ +static int __MP4_getIntegerItem(metadata_editor_s* _metadata, const char* itemname, char** value) { // Check if parameters are valid metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(itemname == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -500,8 +490,7 @@ static int __MP4_getIntegerItem(metadata_editor_s* _metadata, const char* itemna } // *** This function adds (or changes) string item of itemname type *** // -static int __MP4_updateStringItem(metadata_editor_s* _metadata, const char* itemname, const char* value) -{ +static int __MP4_updateStringItem(metadata_editor_s* _metadata, const char* itemname, const char* value) { // Check if parameters are valid metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(itemname == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -532,8 +521,7 @@ static int __MP4_updateStringItem(metadata_editor_s* _metadata, const char* item } // *** This function adds (or changes) integer item of itemname type *** // -static int __MP4_updateIntegerItem(metadata_editor_s* _metadata, const char* itemname, const char* value) -{ +static int __MP4_updateIntegerItem(metadata_editor_s* _metadata, const char* itemname, const char* value) { // Check if parameters are valid metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(itemname == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -570,8 +558,7 @@ static int __MP4_updateIntegerItem(metadata_editor_s* _metadata, const char* ite } // *** This function is used to find the number of pictures stored in MP4 file *** // -static int __MP4_getNumberOfPictures(metadata_editor_s* _metadata, char** value) -{ +static int __MP4_getNumberOfPictures(metadata_editor_s* _metadata, char** value) { // Check if parameters are valid metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(value == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -604,8 +591,7 @@ static int __MP4_getNumberOfPictures(metadata_editor_s* _metadata, char** value) } #if 0 // *** This function is used to extract string from Xiph Comment field *** // -static int __xiph_getFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::XiphComment* xtag, const char* fieldname, char** value) -{ +static int __xiph_getFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::XiphComment* xtag, const char* fieldname, char** value) { // Check if we have a valid argument to work with metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(fieldname == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -638,8 +624,7 @@ static int __xiph_getFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::XiphC } // *** This function is used to write string into Xiph Comment fields *** // -static int __xiph_updateFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::XiphComment* xtag, const char* fieldname, const char* value) -{ +static int __xiph_updateFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::XiphComment* xtag, const char* fieldname, const char* value) { // Check if we have a valid argument to work with metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(fieldname == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -663,8 +648,7 @@ static int __xiph_updateFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::Xi } // *** This function is used to receive the number of pictures in FLAC file *** // -static int __FLAC_getNumberOfPictures(metadata_editor_s* _metadata, char** value) -{ +static int __FLAC_getNumberOfPictures(metadata_editor_s* _metadata, char** value) { // Check if parameters are valid metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Handle"); metadata_editor_retvm_if(value == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Value Pointer"); @@ -689,8 +673,7 @@ static int __FLAC_getNumberOfPictures(metadata_editor_s* _metadata, char** value return METADATA_EDITOR_ERROR_NONE; } #endif -int __metadata_editor_get_file_ext(const char *file_path, char *file_ext, int max_len) -{ +int __metadata_editor_get_file_ext(const char *file_path, char *file_ext, int max_len) { int i = 0; unsigned int path_len = strlen(file_path); @@ -708,8 +691,7 @@ int __metadata_editor_get_file_ext(const char *file_path, char *file_ext, int ma return -1; } -int __metadata_editor_get_file_type(const char *path) -{ +int __metadata_editor_get_file_type(const char *path) { int ret = 0; char mimetype[255] = {0, }; @@ -741,8 +723,7 @@ int __metadata_editor_get_file_type(const char *path) return METADATA_EDITOR_FORMAT_NOTYPE; } -int __metadata_editor_get_picture_type(const char *path, char **type) -{ +int __metadata_editor_get_picture_type(const char *path, char **type) { int ret = 0; char mimetype[255] = {0, }; const char *type_jpeg = "image/jpeg"; @@ -782,8 +763,7 @@ int __metadata_editor_get_picture_type(const char *path, char **type) return METADATA_EDITOR_ERROR_NOT_SUPPORTED; } -int __metadata_editor_get_picture_info(const char *path, void **picture, int *size, char **type) -{ +int __metadata_editor_get_picture_info(const char *path, void **picture, int *size, char **type) { int ret; ret = __metadata_editor_get_picture_type(path, type); @@ -819,8 +799,7 @@ int __metadata_editor_get_picture_info(const char *path, void **picture, int *si // *** This function is used to allocate the metadata_editor_s in memory *** // // *** The structure metadata_editor_s contains all information about the file *** // -extern "C" int metadata_editor_create(metadata_editor_h *metadata) -{ +extern "C" int metadata_editor_create(metadata_editor_h *metadata) { // Check if we have a valid argument to work with metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); @@ -839,8 +818,7 @@ extern "C" int metadata_editor_create(metadata_editor_h *metadata) } // *** This function is used to open the file. It creates the instance that is responsible for connection with file *** // -extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char *path) -{ +extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char *path) { // Check if we have valid arguments to work with metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Handle"); metadata_editor_retvm_if(path == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Handle"); @@ -866,8 +844,7 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * media_type = __metadata_editor_get_file_type(path); switch (media_type) { // Parse file according the specified type - case METADATA_EDITOR_FORMAT_MP3: - { + case METADATA_EDITOR_FORMAT_MP3: { if (_metadata->file) { TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file; metadata_editor_info("file free [%lX]", _metadata->file); @@ -906,8 +883,7 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * return METADATA_EDITOR_ERROR_NONE; } - case METADATA_EDITOR_FORMAT_MP4: - { + case METADATA_EDITOR_FORMAT_MP4: { if (_metadata->file) { TagLib::MP4::File* _file = (TagLib::MP4::File*)_metadata->file; metadata_editor_info("file free [%lX]", _metadata->file); @@ -945,8 +921,7 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * return METADATA_EDITOR_ERROR_NONE; } #if 0 - case METADATA_EDITOR_FORMAT_FLAC: - { + case METADATA_EDITOR_FORMAT_FLAC: { // Allocate the file object in memory to work with it later on TagLib::FLAC::File* _file = new TagLib::FLAC::File(path); @@ -973,8 +948,7 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * } return METADATA_EDITOR_ERROR_NONE; } - case METADATA_EDITOR_FORMAT_OGG_VORBIS: - { + case METADATA_EDITOR_FORMAT_OGG_VORBIS: { // Allocate the file object in memory to work with it later on TagLib::Ogg::Vorbis::File* _file = new TagLib::Ogg::Vorbis::File(path); @@ -1001,8 +975,7 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * } return METADATA_EDITOR_ERROR_NONE; } - case METADATA_EDITOR_FORMAT_OGG_FLAC: - { + case METADATA_EDITOR_FORMAT_OGG_FLAC: { // Allocate the file object in memory to work with it later on TagLib::Ogg::FLAC::File* _file = new TagLib::Ogg::FLAC::File(path); @@ -1029,8 +1002,7 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * } return METADATA_EDITOR_ERROR_NONE; } - case METADATA_EDITOR_FORMAT_WAV: - { + case METADATA_EDITOR_FORMAT_WAV: { // Allocate the file object in memory to work with it later on TagLib::RIFF::WAV::File* _file = new TagLib::RIFF::WAV::File(path); @@ -1065,8 +1037,7 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * } // *** This function is used to get the tag frame (field, item - each tag has its own name for data unit) from file *** // -extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata_editor_attr_e attribute, char **value) -{ +extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata_editor_attr_e attribute, char **value) { // Check if we have valid arguments to work with metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Handle"); metadata_editor_retvm_if(value == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Value Pointer"); @@ -1079,8 +1050,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); switch (_metadata->filetype) { // Process the file according to the specified file type - case METADATA_EDITOR_FORMAT_MP3: - { + case METADATA_EDITOR_FORMAT_MP3: { // Bring the pointer to actual file type and make tag pointers TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file; TagLib::ID3v1::Tag* tag1 = _file->ID3v1Tag(); @@ -1104,8 +1074,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } - case METADATA_EDITOR_FORMAT_MP4: - { + case METADATA_EDITOR_FORMAT_MP4: { switch (attribute) { // Check which one of frame types was given to the function for processing case METADATA_EDITOR_ATTR_ARTIST: return __MP4_getStringItem(_metadata, "\xA9""ART", value); case METADATA_EDITOR_ATTR_TITLE: return __MP4_getStringItem(_metadata, "\xA9""nam", value); @@ -1125,8 +1094,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata } } #if 0 - case METADATA_EDITOR_FORMAT_FLAC: - { + case METADATA_EDITOR_FORMAT_FLAC: { // Bring the pointer to actual file type and make tags pointers TagLib::FLAC::File* _file = (TagLib::FLAC::File*)_metadata->file; TagLib::Ogg::XiphComment* xtag = _file->xiphComment(false); @@ -1153,8 +1121,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } - case METADATA_EDITOR_FORMAT_OGG_VORBIS: - { + case METADATA_EDITOR_FORMAT_OGG_VORBIS: { // Bring the pointer to actual file type and make tags pointers TagLib::Ogg::Vorbis::File* _file = (TagLib::Ogg::Vorbis::File*)_metadata->file; TagLib::Ogg::XiphComment* xtag = _file->tag(); @@ -1180,8 +1147,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } - case METADATA_EDITOR_FORMAT_OGG_FLAC: - { + case METADATA_EDITOR_FORMAT_OGG_FLAC: { // Bring the pointer to actual file type and make tags pointers TagLib::Ogg::FLAC::File* _file = (TagLib::Ogg::FLAC::File*)_metadata->file; TagLib::Ogg::XiphComment* xtag = _file->tag(); @@ -1207,8 +1173,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } - case METADATA_EDITOR_FORMAT_WAV: - { + case METADATA_EDITOR_FORMAT_WAV: { // Bring the pointer to actual file type and make tag pointers TagLib::RIFF::WAV::File* _file = (TagLib::RIFF::WAV::File*)_metadata->file; TagLib::ID3v2::Tag* tag2 = _file->tag(); @@ -1245,8 +1210,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata } // *** This function is used to modify the metadata (frame in tag). But it does not apply changes to file *** // -extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata_editor_attr_e attribute, const char* value) -{ +extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata_editor_attr_e attribute, const char* value) { // Check if we have valid arguments to work with metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Handle"); @@ -1259,8 +1223,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); switch (_metadata->filetype) { // Process the file according to the specified file type - case METADATA_EDITOR_FORMAT_MP3: - { + case METADATA_EDITOR_FORMAT_MP3: { // Bring the pointer to actual file type and make tags pointers TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file; TagLib::ID3v1::Tag* tag1 = _file->ID3v1Tag(); @@ -1285,8 +1248,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } - case METADATA_EDITOR_FORMAT_MP4: - { + case METADATA_EDITOR_FORMAT_MP4: { switch (attribute) { // Check which one of frame type was given for processing case METADATA_EDITOR_ATTR_ARTIST: return __MP4_updateStringItem(_metadata, "\xA9""ART", value); case METADATA_EDITOR_ATTR_TITLE: return __MP4_updateStringItem(_metadata, "\xA9""nam", value); @@ -1305,8 +1267,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata } } #if 0 - case METADATA_EDITOR_FORMAT_FLAC: - { + case METADATA_EDITOR_FORMAT_FLAC: { // Bring the pointer to actual file type and make tags pointers TagLib::FLAC::File* _file = (TagLib::FLAC::File*)_metadata->file; TagLib::Ogg::XiphComment* xtag = _file->xiphComment(true); @@ -1331,8 +1292,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } - case METADATA_EDITOR_FORMAT_OGG_VORBIS: - { + case METADATA_EDITOR_FORMAT_OGG_VORBIS: { // Bring the pointer to actual file type and make tags pointers TagLib::Ogg::Vorbis::File* _file = (TagLib::Ogg::Vorbis::File*)_metadata->file; TagLib::Ogg::XiphComment* xtag = _file->tag(); @@ -1357,8 +1317,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } - case METADATA_EDITOR_FORMAT_OGG_FLAC: - { + case METADATA_EDITOR_FORMAT_OGG_FLAC: { // Bring the pointer to actual file type and make tags pointers TagLib::Ogg::FLAC::File* _file = (TagLib::Ogg::FLAC::File*)_metadata->file; TagLib::Ogg::XiphComment* xtag = _file->tag(); @@ -1383,8 +1342,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } - case METADATA_EDITOR_FORMAT_WAV: - { + case METADATA_EDITOR_FORMAT_WAV: { // Bring the pointer to actual file type and make tags pointers TagLib::RIFF::WAV::File* _file = (TagLib::RIFF::WAV::File*)_metadata->file; TagLib::ID3v2::Tag* tag2 = _file->tag(); @@ -1419,8 +1377,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata } // *** This function apply all changes done in the tag(s) and update them to file *** // -extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) -{ +extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) { // Check if we have a valid argument to work with metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Handle\n"); @@ -1432,8 +1389,7 @@ extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); switch (_metadata->filetype) { // Process the file according to the specified file type - case METADATA_EDITOR_FORMAT_MP3: - { + case METADATA_EDITOR_FORMAT_MP3: { // Bring the pointer to actual file type TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file; @@ -1451,8 +1407,7 @@ extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) return METADATA_EDITOR_ERROR_OPERATION_FAILED; } } - case METADATA_EDITOR_FORMAT_MP4: - { + case METADATA_EDITOR_FORMAT_MP4: { TagLib::MP4::File* _file = (TagLib::MP4::File*)_metadata->file; if (_file->save()) return METADATA_EDITOR_ERROR_NONE; @@ -1460,32 +1415,28 @@ extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) return METADATA_EDITOR_ERROR_OPERATION_FAILED; } #if 0 - case METADATA_EDITOR_FORMAT_FLAC: - { + case METADATA_EDITOR_FORMAT_FLAC: { TagLib::FLAC::File* _file = (TagLib::FLAC::File*)_metadata->file; if (_file->save()) return METADATA_EDITOR_ERROR_NONE; else return METADATA_EDITOR_ERROR_OPERATION_FAILED; } - case METADATA_EDITOR_FORMAT_OGG_VORBIS: - { + case METADATA_EDITOR_FORMAT_OGG_VORBIS: { TagLib::Ogg::Vorbis::File* _file = (TagLib::Ogg::Vorbis::File*)_metadata->file; if (_file->save()) return METADATA_EDITOR_ERROR_NONE; else return METADATA_EDITOR_ERROR_OPERATION_FAILED; } - case METADATA_EDITOR_FORMAT_OGG_FLAC: - { + case METADATA_EDITOR_FORMAT_OGG_FLAC: { TagLib::Ogg::FLAC::File* _file = (TagLib::Ogg::FLAC::File*)_metadata->file; if (_file->save()) return METADATA_EDITOR_ERROR_NONE; else return METADATA_EDITOR_ERROR_OPERATION_FAILED; } - case METADATA_EDITOR_FORMAT_WAV: - { + case METADATA_EDITOR_FORMAT_WAV: { TagLib::RIFF::WAV::File* _file = (TagLib::RIFF::WAV::File*)_metadata->file; if (_file->save()) return METADATA_EDITOR_ERROR_NONE; @@ -1500,8 +1451,7 @@ extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) } // *** This function returns buffer with picture under the specified index and buffer's (picture's) size *** // -extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index, void **picture, int *size, char **mime_type) -{ +extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index, void **picture, int *size, char **mime_type) { const char *TYPE_JPEG = "image/jpeg"; const char *TYPE_PNG = "image/png"; // Check if we have valid arguments to work with @@ -1520,8 +1470,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); switch (_metadata->filetype) { // Process the file according to the specified file type - case METADATA_EDITOR_FORMAT_MP3: - { + case METADATA_EDITOR_FORMAT_MP3: { TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file; // Bring the pointer to actual file type TagLib::ID3v2::Tag* tag2 = _file->ID3v2Tag(); metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. No ID3v2 tag in file."); @@ -1563,8 +1512,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index } } } - case METADATA_EDITOR_FORMAT_MP4: - { + case METADATA_EDITOR_FORMAT_MP4: { TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist\n"); @@ -1602,8 +1550,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index } } #if 0 - case METADATA_EDITOR_FORMAT_FLAC: - { + case METADATA_EDITOR_FORMAT_FLAC: { TagLib::FLAC::File* _file = (TagLib::FLAC::File*) _metadata->file; TagLib::List lst = _file->pictureList(); if (lst.isEmpty()) { @@ -1641,8 +1588,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index } } } - case METADATA_EDITOR_FORMAT_WAV: - { + case METADATA_EDITOR_FORMAT_WAV: { TagLib::RIFF::WAV::File* _file = (TagLib::RIFF::WAV::File*)_metadata->file; // Bring the pointer to actual file type TagLib::ID3v2::Tag* tag2 = _file->tag(); if (!tag2) { @@ -1695,8 +1641,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index } // *** This function appends a cover art picture to the file *** // -extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const char *path) -{ +extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const char *path) { int ret = METADATA_EDITOR_ERROR_NONE; void *picture = NULL; int size = 0; @@ -1717,8 +1662,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); switch (_metadata->filetype) { // Process the file according to the specified file type - case METADATA_EDITOR_FORMAT_MP3: - { + case METADATA_EDITOR_FORMAT_MP3: { // Bring the pointer to actual file type and make tags pointers TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file; TagLib::ID3v2::Tag* tag2 = _file->ID3v2Tag(true); @@ -1744,8 +1688,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const ret = METADATA_EDITOR_ERROR_NONE; break; } - case METADATA_EDITOR_FORMAT_MP4: - { + case METADATA_EDITOR_FORMAT_MP4: { TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); if (!tag) { @@ -1792,8 +1735,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const } } #if 0 - case METADATA_EDITOR_FORMAT_FLAC: - { + case METADATA_EDITOR_FORMAT_FLAC: { TagLib::FLAC::File* _file = (TagLib::FLAC::File*) _metadata->file; TagLib::FLAC::Picture* frontCover = new TagLib::FLAC::Picture; if (frontCover == NULL) { @@ -1810,8 +1752,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const ret = METADATA_EDITOR_ERROR_NONE; break; } - case METADATA_EDITOR_FORMAT_WAV: - { + case METADATA_EDITOR_FORMAT_WAV: { // Bring the pointer to actual file type and make tags pointers TagLib::RIFF::WAV::File* _file = (TagLib::RIFF::WAV::File*)_metadata->file; TagLib::ID3v2::Tag* tag2 = _file->tag(); @@ -1836,8 +1777,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const break; } #endif - default: - { + default: { metadata_editor_error("Wrong file type\n"); ret = METADATA_EDITOR_ERROR_NOT_SUPPORTED; break; @@ -1851,8 +1791,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const } // *** This function is used to delete picture with specified index *** // -extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int index) -{ +extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int index) { // Check if we have a valid argument to work with metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID handler."); @@ -1864,8 +1803,7 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); switch (_metadata->filetype) { // Process the file according to the specified file type - case METADATA_EDITOR_FORMAT_MP3: - { + case METADATA_EDITOR_FORMAT_MP3: { // Bring the pointer to actual file type and make tags pointers TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file; TagLib::ID3v2::Tag* tag2 = _file->ID3v2Tag(true); @@ -1894,8 +1832,7 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in } } } - case METADATA_EDITOR_FORMAT_MP4: - { + case METADATA_EDITOR_FORMAT_MP4: { TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. tag not exist."); @@ -1926,8 +1863,7 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in } } #if 0 - case METADATA_EDITOR_FORMAT_FLAC: - { + case METADATA_EDITOR_FORMAT_FLAC: { TagLib::FLAC::File* _file = (TagLib::FLAC::File*) _metadata->file; TagLib::List lst = _file->pictureList(); if (lst.isEmpty()) { @@ -1949,8 +1885,7 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in return METADATA_EDITOR_ERROR_NONE; } } - case METADATA_EDITOR_FORMAT_WAV: - { + case METADATA_EDITOR_FORMAT_WAV: { // Bring the pointer to actual file type and make tags pointers TagLib::RIFF::WAV::File* _file = (TagLib::RIFF::WAV::File*)_metadata->file; TagLib::ID3v2::Tag* tag2 = _file->tag(); @@ -1990,53 +1925,46 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in } // *** This function is used to free memory that was allocated with metadata_editor_create(...) and metadata_editor_set_path(...) functions *** // -extern "C" int metadata_editor_destroy(metadata_editor_h metadata) -{ +extern "C" int metadata_editor_destroy(metadata_editor_h metadata) { // Check if we have a valid argument to work with metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_s *_metadata = (metadata_editor_s*)metadata; switch (_metadata->filetype) { - case METADATA_EDITOR_FORMAT_MP3: - { + case METADATA_EDITOR_FORMAT_MP3: { // Bring the pointer to actual file type TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file; metadata_editor_info("file free [%lX]", _metadata->file); delete _file; break; } - case METADATA_EDITOR_FORMAT_MP4: - { + case METADATA_EDITOR_FORMAT_MP4: { TagLib::MP4::File* _file = (TagLib::MP4::File*)_metadata->file; metadata_editor_info("file free [%lX]", _metadata->file); delete _file; break; } #if 0 - case METADATA_EDITOR_FORMAT_FLAC: - { + case METADATA_EDITOR_FORMAT_FLAC: { TagLib::FLAC::File* _file = (TagLib::FLAC::File*)_metadata->file; metadata_editor_info("file free [%lX]", _metadata->file); delete _file; break; } - case METADATA_EDITOR_FORMAT_OGG_VORBIS: - { + case METADATA_EDITOR_FORMAT_OGG_VORBIS: { TagLib::Ogg::Vorbis::File* _file = (TagLib::Ogg::Vorbis::File*)_metadata->file; metadata_editor_info("file free [%lX]", _metadata->file); delete _file; break; } - case METADATA_EDITOR_FORMAT_OGG_FLAC: - { + case METADATA_EDITOR_FORMAT_OGG_FLAC: { TagLib::Ogg::FLAC::File* _file = (TagLib::Ogg::FLAC::File*)_metadata->file; metadata_editor_info("file free [%lX]", _metadata->file); delete _file; break; } - case METADATA_EDITOR_FORMAT_WAV: - { + case METADATA_EDITOR_FORMAT_WAV: { TagLib::RIFF::WAV::File* _file = (TagLib::RIFF::WAV::File*)_metadata->file; metadata_editor_info("file free [%lX]", _metadata->file); delete _file; -- 2.7.4 From 6955f6010fc3d35e66643e7aa1e64a8eb670294c Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Fri, 23 Sep 2016 10:28:17 +0900 Subject: [PATCH 08/16] Fix native api reference warning Change-Id: I712c7e25e48cb0142b15f15df79c7d45e8dcf79d Signed-off-by: Minje Ahn --- include/metadata_editor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/metadata_editor.h b/include/metadata_editor.h index 1502e52..07d6a50 100755 --- a/include/metadata_editor.h +++ b/include/metadata_editor.h @@ -107,7 +107,7 @@ int metadata_editor_get_metadata(metadata_editor_h metadata, metadata_editor_att * * @param [in] metadata The handle to metadata * @param [in] attribute key attribute name to get - * @param [int] value The value of the attribute + * @param [in] value The value of the attribute * @return 0 on success, otherwise a negative error value * @retval #METADATA_EDITOR_ERROR_NONE Successful * @retval #METADATA_EDITOR_ERROR_INVALID_PARAMETER Invalid parameter -- 2.7.4 From 10eca137f487ab21d6aaddc96a8754499d7af1b0 Mon Sep 17 00:00:00 2001 From: Jiyong Min Date: Mon, 9 Jan 2017 09:29:48 +0900 Subject: [PATCH 09/16] fix build error (build fails because of undefined C++11 user-defined literals) Change-Id: If4d3caa4fd73e7881304cd33f68b536addf92549 Signed-off-by: jiyong.min --- include/metadata_editor_private.h | 8 ++++---- packaging/capi-media-metadata-editor.spec | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/metadata_editor_private.h b/include/metadata_editor_private.h index f60994f..48d558b 100755 --- a/include/metadata_editor_private.h +++ b/include/metadata_editor_private.h @@ -61,15 +61,15 @@ extern "C" { #define metadata_editor_debug(fmt, arg...) do { \ - LOGD(""fmt"", ##arg); \ + LOGD("" fmt "", ##arg); \ } while (0) #define metadata_editor_info(fmt, arg...) do { \ - LOGI(""fmt"", ##arg); \ + LOGI("" fmt "", ##arg); \ } while (0) #define metadata_editor_error(fmt, arg...) do { \ - LOGE(""fmt"", ##arg); \ + LOGE("" fmt "", ##arg); \ } while (0) #define metadata_editor_debug_fenter() do { \ @@ -82,7 +82,7 @@ extern "C" { #define metadata_editor_retvm_if(expr, val, fmt, arg...) do { \ if (expr) { \ - LOGE(""fmt"", ##arg); \ + LOGE("" fmt "", ##arg); \ return (val); \ } \ } while (0) diff --git a/packaging/capi-media-metadata-editor.spec b/packaging/capi-media-metadata-editor.spec index 5dc6d23..31ff102 100755 --- a/packaging/capi-media-metadata-editor.spec +++ b/packaging/capi-media-metadata-editor.spec @@ -1,6 +1,6 @@ Name: capi-media-metadata-editor Summary: A metadata editor library in Tizen Native API -Version: 0.1.5 +Version: 0.1.6 Release: 0 Group: Multimedia/API License: Apache-2.0 @@ -31,6 +31,7 @@ A media metadata editor library in Tizen Native API. (Development files included export CFLAGS+=" -Wextra -Wno-array-bounds" export CFLAGS+=" -Wno-ignored-qualifiers -Wno-unused-parameter -Wshadow" export CFLAGS+=" -Wwrite-strings -Wswitch-default" +CXXFLAGS=${CXXFLAGS/-fgnu89-inline/} MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -- 2.7.4 From f5f048ed492f20455e23387183c0378f40e9b255 Mon Sep 17 00:00:00 2001 From: Haejeong Kim Date: Thu, 23 Mar 2017 14:44:02 +0900 Subject: [PATCH 10/16] Use license macro in spec file Change-Id: I4a6f0c03cb4bd4a1701dbacf369495f0b0f9f361 --- packaging/capi-media-metadata-editor.spec | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packaging/capi-media-metadata-editor.spec b/packaging/capi-media-metadata-editor.spec index 31ff102..3f76b49 100755 --- a/packaging/capi-media-metadata-editor.spec +++ b/packaging/capi-media-metadata-editor.spec @@ -40,8 +40,6 @@ make %{?jobs:-j%jobs} %install rm -rf %{buildroot} %make_install -mkdir -p %{buildroot}/%{_datadir}/license -cp -rf %{_builddir}/%{name}-%{version}/LICENSE.APLv2.0 %{buildroot}/%{_datadir}/license/%{name} %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -49,7 +47,7 @@ cp -rf %{_builddir}/%{name}-%{version}/LICENSE.APLv2.0 %{buildroot}/%{_datadir}/ %files %manifest capi-media-metadata-editor.manifest %{_libdir}/libcapi-media-metadata-editor.so -%{_datadir}/license/%{name} +%license LICENSE.APLv2.0 %files devel %{_includedir}/metadata-editor/*.h -- 2.7.4 From baa085b5d1e9acbb6c6f0a7e9dfed786b3f09ffe Mon Sep 17 00:00:00 2001 From: Haejeong Kim Date: Fri, 16 Jun 2017 11:40:23 +0900 Subject: [PATCH 11/16] [RQ170613-00147] fix invalid format argument types for dlog Change-Id: Ibd62b71f5308218acb3e97c6d69d942a46b8f09d --- packaging/capi-media-metadata-editor.spec | 2 +- src/metadata_editor.cpp | 42 +++++++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packaging/capi-media-metadata-editor.spec b/packaging/capi-media-metadata-editor.spec index 3f76b49..e69ec87 100755 --- a/packaging/capi-media-metadata-editor.spec +++ b/packaging/capi-media-metadata-editor.spec @@ -1,6 +1,6 @@ Name: capi-media-metadata-editor Summary: A metadata editor library in Tizen Native API -Version: 0.1.6 +Version: 0.1.7 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index d24c549..fe9cd79 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -847,7 +847,7 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * case METADATA_EDITOR_FORMAT_MP3: { if (_metadata->file) { TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file; - metadata_editor_info("file free [%lX]", _metadata->file); + metadata_editor_info("file free [%p]", _metadata->file); delete _file; _metadata->file = NULL; _metadata->filetype = METADATA_EDITOR_FORMAT_NOTYPE; @@ -865,10 +865,10 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * _metadata->filetype = METADATA_EDITOR_FORMAT_MP3; if (_file->isOpen()) { // Check if the file was opened successfully - metadata_editor_info("The file is successfully opened. Address is %lX\n", _metadata->file); + metadata_editor_info("The file is successfully opened. Address is %p\n", _metadata->file); _metadata->isOpen = true; } else { // The file does not exist or you have no permission to process it - metadata_editor_error("The file was not found. Pointer address is %lX\n", _metadata->file); + metadata_editor_error("The file was not found. Pointer address is %p\n", _metadata->file); _metadata->isOpen = false; return METADATA_EDITOR_ERROR_PERMISSION_DENIED; } @@ -886,7 +886,7 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * case METADATA_EDITOR_FORMAT_MP4: { if (_metadata->file) { TagLib::MP4::File* _file = (TagLib::MP4::File*)_metadata->file; - metadata_editor_info("file free [%lX]", _metadata->file); + metadata_editor_info("file free [%p]", _metadata->file); delete _file; _metadata->file = NULL; _metadata->filetype = METADATA_EDITOR_FORMAT_NOTYPE; @@ -904,10 +904,10 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * _metadata->filetype = METADATA_EDITOR_FORMAT_MP4; if (_file->isOpen()) { // Check if the file was opened successfully - metadata_editor_info("The file is successfully opened. Address is %lX\n", _metadata->file); + metadata_editor_info("The file is successfully opened. Address is %p\n", _metadata->file); _metadata->isOpen = true; } else { // The file does not exist or you have no permission to process it - metadata_editor_error("The file was not found. Pointer address is %lX\n", _metadata->file); + metadata_editor_error("The file was not found. Pointer address is %p\n", _metadata->file); _metadata->isOpen = false; return METADATA_EDITOR_ERROR_FILE_EXISTS; } @@ -932,10 +932,10 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * _metadata->filetype = METADATA_EDITOR_FORMAT_FLAC; if (_file->isOpen()) { // Check if the file was opened successfully - metadata_editor_info("The file is successfully opened. Address is %lX\n", _metadata->file); + metadata_editor_info("The file is successfully opened. Address is %p\n", _metadata->file); _metadata->isOpen = true; } else { // The file does not exist or you have no permission to process it - metadata_editor_error("The file was not found. Pointer address is %lX\n", _metadata->file); + metadata_editor_error("The file was not found. Pointer address is %p\n", _metadata->file); _metadata->isOpen = false; return METADATA_EDITOR_ERROR_FILE_EXISTS; } @@ -959,10 +959,10 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * _metadata->filetype = METADATA_EDITOR_FORMAT_OGG_VORBIS; if (_file->isOpen()) { // Check if the file was opened successfully - metadata_editor_info("The file is successfully opened. Address is %lX\n", _metadata->file); + metadata_editor_info("The file is successfully opened. Address is %p\n", _metadata->file); _metadata->isOpen = true; } else { // The file does not exist or you have no permission to process it - metadata_editor_error("The file was not found. Pointer address is %lX\n", _metadata->file); + metadata_editor_error("The file was not found. Pointer address is %p\n", _metadata->file); _metadata->isOpen = false; return METADATA_EDITOR_ERROR_FILE_EXISTS; } @@ -986,10 +986,10 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * _metadata->filetype = METADATA_EDITOR_FORMAT_OGG_FLAC; if (_file->isOpen()) { // Check if the file was opened successfully - metadata_editor_info("The file is successfully opened. Address is %lX\n", _metadata->file); + metadata_editor_info("The file is successfully opened. Address is %p\n", _metadata->file); _metadata->isOpen = true; } else { // The file does not exist or you have no permission to process it - metadata_editor_error("The file was not found. Pointer address is %lX\n", _metadata->file); + metadata_editor_error("The file was not found. Pointer address is %p\n", _metadata->file); _metadata->isOpen = false; return METADATA_EDITOR_ERROR_FILE_EXISTS; } @@ -1013,10 +1013,10 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * _metadata->filetype = METADATA_EDITOR_FORMAT_WAV; if (_file->isOpen()) { // Check if the file was opened successfully - metadata_editor_info("The file is successfully opened. Address is %lX\n", _metadata->file); + metadata_editor_info("The file is successfully opened. Address is %p\n", _metadata->file); _metadata->isOpen = true; } else { // The file does not exist or you have no permission to process it - metadata_editor_error("The file was not found. Pointer address is %lX\n", _metadata->file); + metadata_editor_error("The file was not found. Pointer address is %p\n", _metadata->file); _metadata->isOpen = false; return METADATA_EDITOR_ERROR_FILE_EXISTS; } @@ -1935,38 +1935,38 @@ extern "C" int metadata_editor_destroy(metadata_editor_h metadata) { case METADATA_EDITOR_FORMAT_MP3: { // Bring the pointer to actual file type TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file; - metadata_editor_info("file free [%lX]", _metadata->file); + metadata_editor_info("file free [%p]", _metadata->file); delete _file; break; } case METADATA_EDITOR_FORMAT_MP4: { TagLib::MP4::File* _file = (TagLib::MP4::File*)_metadata->file; - metadata_editor_info("file free [%lX]", _metadata->file); + metadata_editor_info("file free [%p]", _metadata->file); delete _file; break; } #if 0 case METADATA_EDITOR_FORMAT_FLAC: { TagLib::FLAC::File* _file = (TagLib::FLAC::File*)_metadata->file; - metadata_editor_info("file free [%lX]", _metadata->file); + metadata_editor_info("file free [%p]", _metadata->file); delete _file; break; } case METADATA_EDITOR_FORMAT_OGG_VORBIS: { TagLib::Ogg::Vorbis::File* _file = (TagLib::Ogg::Vorbis::File*)_metadata->file; - metadata_editor_info("file free [%lX]", _metadata->file); + metadata_editor_info("file free [%p]", _metadata->file); delete _file; break; } case METADATA_EDITOR_FORMAT_OGG_FLAC: { TagLib::Ogg::FLAC::File* _file = (TagLib::Ogg::FLAC::File*)_metadata->file; - metadata_editor_info("file free [%lX]", _metadata->file); + metadata_editor_info("file free [%p]", _metadata->file); delete _file; break; } case METADATA_EDITOR_FORMAT_WAV: { TagLib::RIFF::WAV::File* _file = (TagLib::RIFF::WAV::File*)_metadata->file; - metadata_editor_info("file free [%lX]", _metadata->file); + metadata_editor_info("file free [%p]", _metadata->file); delete _file; break; } @@ -1976,7 +1976,7 @@ extern "C" int metadata_editor_destroy(metadata_editor_h metadata) { return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } - metadata_editor_info(" with address %lX will be freed\n", metadata); + metadata_editor_info(" with address %p will be freed\n", metadata); delete _metadata; return METADATA_EDITOR_ERROR_NONE; -- 2.7.4 From 06865e71def5aab40367c38b4c758f51850604f5 Mon Sep 17 00:00:00 2001 From: Haejeong Kim Date: Wed, 19 Jul 2017 14:30:57 +0900 Subject: [PATCH 12/16] Just update debugging msg Change-Id: I8390c2bcdb7e1be1980c4bac727d5df83b6d8aba --- src/metadata_editor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index fe9cd79..846bf94 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -702,7 +702,7 @@ int __metadata_editor_get_file_type(const char *path) { char ext[255] = { 0 }; int ret = __metadata_editor_get_file_ext(path, ext, sizeof(ext)); - metadata_editor_retvm_if(ret < 0, METADATA_EDITOR_FORMAT_NOTYPE, "__metadata_editor_get_file_type failed"); + metadata_editor_retvm_if(ret < 0, METADATA_EDITOR_FORMAT_NOTYPE, "__metadata_editor_get_file_ext failed"); if (strcasecmp(ext, "MP3") == 0) return METADATA_EDITOR_FORMAT_MP3; @@ -736,7 +736,7 @@ int __metadata_editor_get_picture_type(const char *path, char **type) { char ext[255] = { 0 }; int ret = __metadata_editor_get_file_ext(path, ext, sizeof(ext)); - metadata_editor_retvm_if(ret < 0, METADATA_EDITOR_ERROR_OPERATION_FAILED, "__metadata_editor_get_file_type failed"); + metadata_editor_retvm_if(ret < 0, METADATA_EDITOR_ERROR_OPERATION_FAILED, "__metadata_editor_get_file_ext failed"); if (strcasecmp(ext, "JPG") == 0 || strcasecmp(ext, "JPEG") == 0) { *type = strndup(type_jpeg, strlen(type_jpeg)); -- 2.7.4 From 7e278a8c510dae9549741c2f25c2c50ff6bb05cd Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Tue, 25 Jul 2017 10:43:21 +0900 Subject: [PATCH 13/16] Fix svace defects Change-Id: I8777be6887041dfcb3d31fc4640a1af8fa6b5590 Signed-off-by: Minje Ahn --- test/metadata_editor_test.c | 50 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/test/metadata_editor_test.c b/test/metadata_editor_test.c index 76ad7e6..1f84eb3 100755 --- a/test/metadata_editor_test.c +++ b/test/metadata_editor_test.c @@ -18,10 +18,12 @@ #include #include #include +#include #include #define SAFE_FREE(src) { if (src) {free(src); src = NULL; } } +#define FILE_NAME_SIZE 30 int dummy; @@ -32,6 +34,32 @@ static bool __write_tag_info(metadata_editor_h metadata); static bool __add_picture(metadata_editor_h metadata); static bool __delete_pictures(metadata_editor_h metadata); + +static int __safe_atoi(char *buffer, int *si) +{ + char *end = NULL; + errno = 0; + if (buffer == NULL || si == NULL) + return METADATA_EDITOR_ERROR_INVALID_PARAMETER; + + const long sl = strtol(buffer, &end, 10); + + if (end == buffer) + return METADATA_EDITOR_ERROR_INVALID_PARAMETER; + if ('\0' != *end) + return METADATA_EDITOR_ERROR_INVALID_PARAMETER; + if ((LONG_MIN == sl || LONG_MAX == sl) && (ERANGE == errno)) + return METADATA_EDITOR_ERROR_INVALID_PARAMETER; + if (sl > INT_MAX) + return METADATA_EDITOR_ERROR_INVALID_PARAMETER; + if (sl < INT_MIN) + return METADATA_EDITOR_ERROR_INVALID_PARAMETER; + + *si = (int)sl; + + return METADATA_EDITOR_ERROR_NONE; +} + void __flush() { int c; @@ -131,19 +159,27 @@ static bool __get_tag_info(metadata_editor_h metadata) #endif if (ret != METADATA_EDITOR_ERROR_NONE) printf("Fail metadata_editor_get_metadata() at line [%d]\n", __LINE__); else if ((ret == METADATA_EDITOR_ERROR_NONE) && picture_index) { - uint num, i; - num = atoi(picture_index); + int num = 0, i; + ret = __safe_atoi(picture_index, &num); + if (ret != METADATA_EDITOR_ERROR_NONE || num < 0) + return true; + printf("Number of pictures: %u\n", num); + for (i = 0; i < num; ++i) { ret = metadata_editor_get_picture(metadata, i, &picture, &picture_size, &picture_type); /*__printRetValue("metadata_editor_get_picture(...)", ret); */ if (ret == METADATA_EDITOR_ERROR_NONE && picture) { printf("Saving picture number %u\n", i); - int size = 30; - char picture_file_name[size]; - snprintf(picture_file_name, size, "outputFile_%u" , i + 1); - if (strncmp(picture_type, "image/jpeg", strlen("image/jpeg")) == 0) strncat(picture_file_name, ".jpg", strlen(".jpg")); - else if (strncmp(picture_type, "image/png", strlen("image/jpeg")) == 0) strncat(picture_file_name, ".png", strlen(".png")); + char picture_file_name[FILE_NAME_SIZE] = {0, }; + + memset(picture_file_name, 0, sizeof(picture_file_name)); + + if (strncmp(picture_type, "image/jpeg", strlen("image/jpeg")) == 0) + snprintf(picture_file_name, FILE_NAME_SIZE, "outputFile_%u.jpg", i + 1); + else if (strncmp(picture_type, "image/png", strlen("image/png")) == 0) + snprintf(picture_file_name, FILE_NAME_SIZE, "outputFile_%u.png", i + 1); + FILE *fout = fopen(picture_file_name, "wb"); if (fout) { fwrite(picture, picture_size, 1, fout); -- 2.7.4 From cdb1cf06ff36b800b82ac989a706e55345e5b3cf Mon Sep 17 00:00:00 2001 From: Haejeong Kim Date: Wed, 6 Sep 2017 10:22:41 +0900 Subject: [PATCH 14/16] Remove \n in dlog msg Change-Id: Ibef41d8fe675c1e9feac348eb6dafbe9b34acc44 --- src/metadata_editor.cpp | 354 ++++++++++++++++++++++++------------------------ 1 file changed, 177 insertions(+), 177 deletions(-) diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index 846bf94..5953d9d 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -61,17 +61,17 @@ static int __ID3_getTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); // Check if the frame is empty (nothing to read) or ID3v2 tag does not exist if (!tag2 || tag2->frameListMap()[frameID].isEmpty()) { - metadata_editor_info("The frame %s in ID3v2 tag is empty\n", frameID); + metadata_editor_info("The frame %s in ID3v2 tag is empty", frameID); // Check if the tag ID3v1 is also empty or does not exist if (!tag1 || tag1->isEmpty()) { - metadata_editor_info("The frame %s in ID3v1 tag is empty as well\n", frameID); + metadata_editor_info("The frame %s in ID3v1 tag is empty as well", frameID); return METADATA_EDITOR_ERROR_NONE; } else { // if not - read the frame you need there - metadata_editor_info("Reading data from ID3v1 tag\n"); + metadata_editor_info("Reading data from ID3v1 tag"); TagLib::String str; uint length; @@ -98,9 +98,9 @@ static int __ID3_getTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: if (found) { bool isUTF = false; if (!str.isLatin1()) isUTF = true; - metadata_editor_info("String is %sUTF\n", (isUTF ? "" : "not ")); + metadata_editor_info("String is %sUTF", (isUTF ? "" : "not ")); length = strlen(str.toCString(isUTF)); - metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string"); *value = strndup(str.toCString(isUTF), length); return METADATA_EDITOR_ERROR_NONE; } @@ -117,7 +117,7 @@ static int __ID3_getTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: if (found) { length = strlen(buf); - metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string"); *value = strndup(buf, length); return METADATA_EDITOR_ERROR_NONE; } @@ -126,16 +126,16 @@ static int __ID3_getTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: return METADATA_EDITOR_ERROR_OPERATION_FAILED; } } else { // or frame has data to read - metadata_editor_info("The frame %s exists in ID3v2 tag\n", frameID); + metadata_editor_info("The frame %s exists in ID3v2 tag", frameID); // This string is used to copy the value in the frame TagLib::String str = tag2->frameListMap()[frameID][0]->toString(); bool isUTF = false; if (!str.isLatin1()) isUTF = true; - metadata_editor_info("String is %sUTF\n", (isUTF ? "" : "not ")); + metadata_editor_info("String is %sUTF", (isUTF ? "" : "not ")); uint length = strlen(str.toCString(isUTF)); - metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string"); *value = strndup(str.toCString(isUTF), length); @@ -151,15 +151,15 @@ static int __ID3_setTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: metadata_editor_retvm_if(frameID == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); + metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify"); // Check if the valid tag pointer exists metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); // If the pointer is NULL or c-string is empty - handle as request for deletion if (!value || (*value == '\0')) { - metadata_editor_info("Request for frame %s deletion\n", frameID); + metadata_editor_info("Request for frame %s deletion", frameID); tag2->removeFrames(frameID); if (tag1 && !tag1->isEmpty()) { if (!strcmp(frameID, "TPE1")) @@ -181,7 +181,7 @@ static int __ID3_setTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: // Check if the frame is empty (must create the frame before writing the data) if (tag2->frameListMap()[frameID].isEmpty()) { - metadata_editor_info("The frame %s does not exist. Creating.\n", frameID); + metadata_editor_info("The frame %s does not exist. Creating", frameID); // This is a common frame type for textural frames except comment frame TagLib::ID3v2::TextIdentificationFrame* fr = new TagLib::ID3v2::TextIdentificationFrame(frameID); metadata_editor_retvm_if(fr == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); @@ -190,12 +190,12 @@ static int __ID3_setTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: fr->setText(TagLib::String(value, TagLib::String::UTF8)); tag2->addFrame(fr); } else { // if not - just modify the data in the existing frame - metadata_editor_info("The frame %s exists. Changing.\n", frameID); + metadata_editor_info("The frame %s exists. Changing", frameID); tag2->frameListMap()[frameID][0]->setText(TagLib::String(value, TagLib::String::UTF8)); } if (tag1 && !tag1->isEmpty()) { // Check if ID3v1 tag exists. Must copy data if yes. - metadata_editor_info("ID3v1 tag also exists. Copying frame\n"); + metadata_editor_info("ID3v1 tag also exists. Copying frame"); if (!strcmp(frameID, "TPE1")) tag1->setArtist(value); else if (!strcmp(frameID, "TALB")) @@ -222,20 +222,20 @@ static int __ID3_getFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); // Check if the frame is empty (nothing to read) or ID3v2 tag does not exist - metadata_editor_retvm_if(!tag2 || tag2->frameListMap()[frameID].isEmpty(), METADATA_EDITOR_ERROR_NONE, "The frame %s does not exist\n", frameID); + metadata_editor_retvm_if(!tag2 || tag2->frameListMap()[frameID].isEmpty(), METADATA_EDITOR_ERROR_NONE, "The frame %s does not exist", frameID); - metadata_editor_info("The frame %s exists\n", frameID); + metadata_editor_info("The frame %s exists", frameID); // This string is used to copy the value in the frame TagLib::String str = tag2->frameListMap()[frameID][0]->toString(); bool isUTF = false; if (!str.isLatin1()) isUTF = true; - metadata_editor_info("String is %sUTF\n", (isUTF ? "" : "not ")); + metadata_editor_info("String is %sUTF", (isUTF ? "" : "not ")); uint length = strlen(str.toCString(isUTF)); - metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string"); *value = strndup(str.toCString(isUTF), length); @@ -249,22 +249,22 @@ static int __ID3_setFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag metadata_editor_retvm_if(frameID == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); + metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify"); // Check if the valid tag pointer exist metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); // If the pointer is NULL or c-string is empty - handle as request for deletion if (!value || (*value == '\0')) { - metadata_editor_info("Request for frame %s deletion\n", frameID); + metadata_editor_info("Request for frame %s deletion", frameID); tag2->removeFrames(frameID); return METADATA_EDITOR_ERROR_NONE; } // Check if the ID3v2 tag exists if (tag2->frameListMap()[frameID].isEmpty()) { - metadata_editor_info("The frame %s does not exist. Creating.\n", frameID); + metadata_editor_info("The frame %s does not exist. Creating", frameID); // This is a common frame type for textural frames except comment frame TagLib::ID3v2::TextIdentificationFrame* fr = new TagLib::ID3v2::TextIdentificationFrame(frameID); metadata_editor_retvm_if(fr == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); @@ -273,7 +273,7 @@ static int __ID3_setFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag fr->setText(TagLib::String(value, TagLib::String::UTF8)); tag2->addFrame(fr); } else { // if not - just modify the data in the existing frame - metadata_editor_info("The frame %s exists. Changing.\n", frameID); + metadata_editor_info("The frame %s exists. Changing", frameID); tag2->frameListMap()[frameID][0]->setText(TagLib::String(value, TagLib::String::UTF8)); } @@ -288,16 +288,16 @@ static int __ID3_getNumberOfPictures(metadata_editor_s* _metadata, TagLib::ID3v2 // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); // Check if the valid tag pointer exist metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag does not exist. Can not process further"); TagLib::ID3v2::FrameList lst = tag2->frameListMap()["APIC"]; // link to picture frames in tag // Check if the frames exist - metadata_editor_retvm_if(lst.isEmpty(), METADATA_EDITOR_ERROR_NONE, "No pictures in file\n"); + metadata_editor_retvm_if(lst.isEmpty(), METADATA_EDITOR_ERROR_NONE, "No pictures in file"); - metadata_editor_info("APIC frames exist in file\n"); + metadata_editor_info("APIC frames exist in file"); char buf[META_MAX_BUF_LEN] = {0, }; // Convert the number of frames (lst.size()) to c-string snprintf(buf, META_MAX_BUF_LEN, "%u", lst.size()); @@ -314,24 +314,24 @@ static int __ID3_getLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); // Check if the valid tag pointer exist metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag does not exist. Can not process further"); TagLib::ID3v2::FrameList lst = tag2->frameListMap()["USLT"]; // link to unsynchronized lyric frames in tag // Check if frames exist in file - metadata_editor_retvm_if(lst.isEmpty(), METADATA_EDITOR_ERROR_NONE, "The frame USLT does not exist\n"); + metadata_editor_retvm_if(lst.isEmpty(), METADATA_EDITOR_ERROR_NONE, "The frame USLT does not exist"); - metadata_editor_info("The frame USLT exists\n"); + metadata_editor_info("The frame USLT exists"); TagLib::ID3v2::FrameList::Iterator it = lst.begin(); TagLib::ID3v2::UnsynchronizedLyricsFrame* frame = static_cast(*it); TagLib::String str = frame->text(); bool isUTF = false; if (!str.isLatin1()) isUTF = true; - metadata_editor_info("String is %sUTF\n", (isUTF ? "" : "not ")); + metadata_editor_info("String is %sUTF", (isUTF ? "" : "not ")); uint length = strlen(str.toCString(isUTF)); - metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string"); *value = strndup(str.toCString(isUTF), length); return METADATA_EDITOR_ERROR_NONE; } @@ -343,15 +343,15 @@ static int __ID3_setTwixCommentFrame(metadata_editor_s* _metadata, TagLib::ID3v1 metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); + metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify"); // Check if the valid tag pointer exist metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); // If the pointer is NULL or c-string is empty - handle as request for deletion if (!value || (*value == '\0')) { - metadata_editor_info("Request for frame COMM deletion\n"); + metadata_editor_info("Request for frame COMM deletion"); tag2->removeFrames("COMM"); if (tag1 && !tag1->isEmpty()) tag1->setComment(""); @@ -359,19 +359,19 @@ static int __ID3_setTwixCommentFrame(metadata_editor_s* _metadata, TagLib::ID3v1 } // If the comment frame is empty - create the frame and add it to the list if (tag2->frameListMap()["COMM"].isEmpty()) { - metadata_editor_info("The frame COMM does not exist. Creating.\n"); + metadata_editor_info("The frame COMM does not exist. Creating"); TagLib::ID3v2::CommentsFrame* fr = new TagLib::ID3v2::CommentsFrame; - metadata_editor_retvm_if(fr == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY\n"); + metadata_editor_retvm_if(fr == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); fr->setText(TagLib::String(value, TagLib::String::UTF8)); fr->setTextEncoding(TagLib::String::UTF8); tag2->addFrame(fr); } else { // If the frame already exists - just modify its value - metadata_editor_info("The frame COMM exists. Changing.\n"); + metadata_editor_info("The frame COMM exists. Changing"); tag2->frameListMap()["COMM"][0]->setText(TagLib::String(value, TagLib::String::UTF8)); } if (tag1 && !tag1->isEmpty()) { // Copy the value to ID3v1 tag comment - metadata_editor_info("ID3v1 tag also exists. Copying frame\n"); + metadata_editor_info("ID3v1 tag also exists. Copying frame"); tag1->setComment(value); } @@ -385,8 +385,8 @@ static int __ID3_setLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag metadata_editor_retvm_if(_metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); + metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify"); // Check if the valid tag pointer exist metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); @@ -394,14 +394,14 @@ static int __ID3_setLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag TagLib::ID3v2::FrameList lst = tag2->frameListMap()["USLT"]; // link to unsynchronized lyric frames in tag // If the pointer is NULL or c-string is empty - handle as request for deletion if (!value || (*value == '\0')) { - metadata_editor_info("Request for frame USLT deletion\n"); + metadata_editor_info("Request for frame USLT deletion"); tag2->removeFrames("USLT"); return METADATA_EDITOR_ERROR_NONE; } // Check if lyrics frames exist if (lst.isEmpty()) { // No lyrics - create the frame and add it to the ID3v2 tag - metadata_editor_info("The frame USLT does not exist. Creating.\n"); + metadata_editor_info("The frame USLT does not exist. Creating"); TagLib::ID3v2::UnsynchronizedLyricsFrame* frame = new TagLib::ID3v2::UnsynchronizedLyricsFrame; metadata_editor_retvm_if(frame == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); @@ -409,7 +409,7 @@ static int __ID3_setLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag frame->setText(TagLib::String(value, TagLib::String::UTF8)); tag2->addFrame(frame); } else { // the lyrics frames exist - change the existing one - metadata_editor_info("USLT frames exist in file. Changing.\n"); + metadata_editor_info("USLT frames exist in file. Changing"); TagLib::ID3v2::FrameList::Iterator it = lst.begin(); TagLib::ID3v2::UnsynchronizedLyricsFrame* frame = static_cast(*it); frame->setTextEncoding(TagLib::String::UTF8); @@ -429,7 +429,7 @@ static int __MP4_getStringItem(metadata_editor_s* _metadata, const char* itemnam // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); @@ -443,14 +443,14 @@ static int __MP4_getStringItem(metadata_editor_s* _metadata, const char* itemnam // Check the encoding of the string (1252 or not) bool isUTF = false; if (!str.isLatin1()) isUTF = true; - metadata_editor_info("String is %sUTF\n", (isUTF ? "" : "not ")); + metadata_editor_info("String is %sUTF", (isUTF ? "" : "not ")); // Get the length of the string and check if it is empty or not uint length = strlen(str.toCString(isUTF)); - metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string"); *value = strndup(str.toCString(isUTF), length); return METADATA_EDITOR_ERROR_NONE; } else { // Item was not found - metadata_editor_info("No item <%s> in file\n", itemname); + metadata_editor_info("No item <%s> in file", itemname); return METADATA_EDITOR_ERROR_NONE; } } @@ -465,7 +465,7 @@ static int __MP4_getIntegerItem(metadata_editor_s* _metadata, const char* itemna // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); @@ -480,11 +480,11 @@ static int __MP4_getIntegerItem(metadata_editor_s* _metadata, const char* itemna snprintf(buf, META_MAX_BUF_LEN, "%u", num); // Convert int into char[] // Determine the length of created c-string and copy it into the output variable int length = strlen(buf); - metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string"); *value = strndup(buf, length); return METADATA_EDITOR_ERROR_NONE; } else { // Item was not found - metadata_editor_info("No item <%s> in file\n", itemname); + metadata_editor_info("No item <%s> in file", itemname); return METADATA_EDITOR_ERROR_NONE; } } @@ -497,8 +497,8 @@ static int __MP4_updateStringItem(metadata_editor_s* _metadata, const char* item metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail."); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); + metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify"); TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); @@ -508,13 +508,13 @@ static int __MP4_updateStringItem(metadata_editor_s* _metadata, const char* item TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); // Check if it is a request for deletion if ((value == NULL) || value[0] == '\0') { - metadata_editor_info("Request for deleting of item <%s>\n", itemname); + metadata_editor_info("Request for deleting of item <%s>", itemname); TagLib::MP4::ItemListMap::Iterator it = itemMap.find(itemname); if (it != itemMap.end()) itemMap.erase(it); return METADATA_EDITOR_ERROR_NONE; } - metadata_editor_info("The item <%s> will be added\n", itemname); + metadata_editor_info("The item <%s> will be added", itemname); itemMap[itemname] = TagLib::MP4::Item(TagLib::String(value, TagLib::String::UTF8)); return METADATA_EDITOR_ERROR_NONE; @@ -528,8 +528,8 @@ static int __MP4_updateIntegerItem(metadata_editor_s* _metadata, const char* ite metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail."); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); + metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify"); TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); @@ -539,7 +539,7 @@ static int __MP4_updateIntegerItem(metadata_editor_s* _metadata, const char* ite TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); // Check if it is a request for deletion if ((value == NULL) || value[0] == '\0') { - metadata_editor_info("Request for deleting of item <%s>\n", itemname); + metadata_editor_info("Request for deleting of item <%s>", itemname); TagLib::MP4::ItemListMap::Iterator it = itemMap.find(itemname); if (it != itemMap.end()) itemMap.erase(it); @@ -547,12 +547,12 @@ static int __MP4_updateIntegerItem(metadata_editor_s* _metadata, const char* ite } // Check if the value is integer string then it can be successfully converted into integer if (isdigit(value[0])) { - metadata_editor_info("The item <%s> will be added\n", itemname); + metadata_editor_info("The item <%s> will be added", itemname); int number = atoi(value); itemMap[itemname] = TagLib::MP4::Item(number); return METADATA_EDITOR_ERROR_NONE; } else { // Notify that string is not a number to process - metadata_editor_error("Error. String does not contain a number\n"); + metadata_editor_error("Error. String does not contain a number"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } @@ -566,26 +566,26 @@ static int __MP4_getNumberOfPictures(metadata_editor_s* _metadata, char** value) // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); - metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist\n"); + metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); // Get map of items directly from tag and launch a search of specific item TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); TagLib::MP4::ItemListMap::ConstIterator it = itemMap.find("covr"); if (it != itemMap.end()) { // Item was found uint number = it->second.toCoverArtList().size(); // Get the size of CoverList (i.e. number of pictures in file) - metadata_editor_info("There are %u picture(s) in file\n", number); + metadata_editor_info("There are %u picture(s) in file", number); char buf[META_MAX_BUF_LEN] = {0, }; snprintf(buf, META_MAX_BUF_LEN, "%u", number); // Convert integer value of size to its c-string representation int length = strlen(buf); - metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string"); *value = strndup(buf, length); return METADATA_EDITOR_ERROR_NONE; } else { // Item was not found - metadata_editor_info("No item in file\n"); + metadata_editor_info("No item in file"); return METADATA_EDITOR_ERROR_NONE; } } @@ -599,26 +599,26 @@ static int __xiph_getFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::XiphC // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(!xtag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); + metadata_editor_retvm_if(!xtag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); const TagLib::Ogg::FieldListMap& fieldMap = xtag->fieldListMap(); TagLib::Ogg::FieldListMap::ConstIterator it = fieldMap.find(fieldname); if ((xtag->contains(fieldname)) && (it != fieldMap.end())) { // Field was found - metadata_editor_info("Field %s was found. Extracting\n", fieldname); + metadata_editor_info("Field %s was found. Extracting", fieldname); TagLib::String str = it->second[0]; // Get the first string in xiph field // Check the encoding of the string (1252 or not) bool isUTF = false; if (!str.isLatin1()) isUTF = true; - metadata_editor_info("String is %sUTF\n", (isUTF ? "" : "not ")); + metadata_editor_info("String is %sUTF", (isUTF ? "" : "not ")); // Get the length of the string and check if it is empty or not uint length = strlen(str.toCString(isUTF)); - metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string"); *value = strndup(str.toCString(isUTF), length); return METADATA_EDITOR_ERROR_NONE; } else { // Field was not found - metadata_editor_info("No field %s in Xiph Comment\n", fieldname); + metadata_editor_info("No field %s in Xiph Comment", fieldname); return METADATA_EDITOR_ERROR_NONE; } } @@ -631,17 +631,17 @@ static int __xiph_updateFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::Xi // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); - metadata_editor_retvm_if(!xtag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); + metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify"); + metadata_editor_retvm_if(!xtag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); // Check if it is a request for deletion if ((value == NULL) || value[0] == '\0') { - metadata_editor_info("Request for deleting of field %s\n", fieldname); + metadata_editor_info("Request for deleting of field %s", fieldname); xtag->removeField(fieldname); return METADATA_EDITOR_ERROR_NONE; } - metadata_editor_info("The field %s will be added\n", fieldname); + metadata_editor_info("The field %s will be added", fieldname); // "true" is used to remove other strings of the same "fieldname" first xtag->addField(fieldname, TagLib::String(value, TagLib::String::UTF8), true); return METADATA_EDITOR_ERROR_NONE; @@ -656,19 +656,19 @@ static int __FLAC_getNumberOfPictures(metadata_editor_s* _metadata, char** value // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); TagLib::FLAC::File* _file = (TagLib::FLAC::File*) _metadata->file; if (_file->pictureList().isEmpty()) { - metadata_editor_info("No pictures in FLAC file\n"); + metadata_editor_info("No pictures in FLAC file"); return METADATA_EDITOR_ERROR_NONE; } uint number = _file->pictureList().size(); - metadata_editor_info("There are %u picture(s) in file\n", number); + metadata_editor_info("There are %u picture(s) in file", number); char buf[META_MAX_BUF_LEN] = {0, }; snprintf(buf, META_MAX_BUF_LEN, "%u", number); // Convert integer value of size to its c-string representation uint length = strlen(buf); - metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string...\n"); + metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string"); *value = strndup(buf, length); return METADATA_EDITOR_ERROR_NONE; } @@ -828,7 +828,7 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * /* check the file exits actually */ exist = open(path, O_RDONLY); if(exist < 0) { - metadata_editor_error("Not exist file\n"); + metadata_editor_error("Not exist file"); if (errno == EACCES || errno == EPERM) { return METADATA_EDITOR_ERROR_PERMISSION_DENIED; } else { @@ -865,19 +865,19 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * _metadata->filetype = METADATA_EDITOR_FORMAT_MP3; if (_file->isOpen()) { // Check if the file was opened successfully - metadata_editor_info("The file is successfully opened. Address is %p\n", _metadata->file); + metadata_editor_info("The file is successfully opened. Address is %p", _metadata->file); _metadata->isOpen = true; } else { // The file does not exist or you have no permission to process it - metadata_editor_error("The file was not found. Pointer address is %p\n", _metadata->file); + metadata_editor_error("The file was not found. Pointer address is %p", _metadata->file); _metadata->isOpen = false; return METADATA_EDITOR_ERROR_PERMISSION_DENIED; } if (_file->readOnly()) { // Check if the file is readonly - metadata_editor_info("File is readonly\n"); + metadata_editor_info("File is readonly"); _metadata->isReadOnly = true; } else { // or not - metadata_editor_info("The file is writable\n"); + metadata_editor_info("The file is writable"); _metadata->isReadOnly = false; } @@ -904,18 +904,18 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * _metadata->filetype = METADATA_EDITOR_FORMAT_MP4; if (_file->isOpen()) { // Check if the file was opened successfully - metadata_editor_info("The file is successfully opened. Address is %p\n", _metadata->file); + metadata_editor_info("The file is successfully opened. Address is %p", _metadata->file); _metadata->isOpen = true; } else { // The file does not exist or you have no permission to process it - metadata_editor_error("The file was not found. Pointer address is %p\n", _metadata->file); + metadata_editor_error("The file was not found. Pointer address is %p", _metadata->file); _metadata->isOpen = false; return METADATA_EDITOR_ERROR_FILE_EXISTS; } if (_file->readOnly()) { // Check if the file is readonly - metadata_editor_info("File is readonly\n"); + metadata_editor_info("File is readonly"); _metadata->isReadOnly = true; } else { // or not - metadata_editor_info("The file is writable\n"); + metadata_editor_info("The file is writable"); _metadata->isReadOnly = false; } return METADATA_EDITOR_ERROR_NONE; @@ -932,18 +932,18 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * _metadata->filetype = METADATA_EDITOR_FORMAT_FLAC; if (_file->isOpen()) { // Check if the file was opened successfully - metadata_editor_info("The file is successfully opened. Address is %p\n", _metadata->file); + metadata_editor_info("The file is successfully opened. Address is %p", _metadata->file); _metadata->isOpen = true; } else { // The file does not exist or you have no permission to process it - metadata_editor_error("The file was not found. Pointer address is %p\n", _metadata->file); + metadata_editor_error("The file was not found. Pointer address is %p", _metadata->file); _metadata->isOpen = false; return METADATA_EDITOR_ERROR_FILE_EXISTS; } if (_file->readOnly()) { // Check if the file is readonly - metadata_editor_info("File is readonly\n"); + metadata_editor_info("File is readonly"); _metadata->isReadOnly = true; } else { // or not - metadata_editor_info("The file is writable\n"); + metadata_editor_info("The file is writable"); _metadata->isReadOnly = false; } return METADATA_EDITOR_ERROR_NONE; @@ -959,18 +959,18 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * _metadata->filetype = METADATA_EDITOR_FORMAT_OGG_VORBIS; if (_file->isOpen()) { // Check if the file was opened successfully - metadata_editor_info("The file is successfully opened. Address is %p\n", _metadata->file); + metadata_editor_info("The file is successfully opened. Address is %p", _metadata->file); _metadata->isOpen = true; } else { // The file does not exist or you have no permission to process it - metadata_editor_error("The file was not found. Pointer address is %p\n", _metadata->file); + metadata_editor_error("The file was not found. Pointer address is %p", _metadata->file); _metadata->isOpen = false; return METADATA_EDITOR_ERROR_FILE_EXISTS; } if (_file->readOnly()) { // Check if the file is readonly - metadata_editor_info("File is readonly\n"); + metadata_editor_info("File is readonly"); _metadata->isReadOnly = true; } else { // or not - metadata_editor_info("The file is writable\n"); + metadata_editor_info("The file is writable"); _metadata->isReadOnly = false; } return METADATA_EDITOR_ERROR_NONE; @@ -986,18 +986,18 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * _metadata->filetype = METADATA_EDITOR_FORMAT_OGG_FLAC; if (_file->isOpen()) { // Check if the file was opened successfully - metadata_editor_info("The file is successfully opened. Address is %p\n", _metadata->file); + metadata_editor_info("The file is successfully opened. Address is %p", _metadata->file); _metadata->isOpen = true; } else { // The file does not exist or you have no permission to process it - metadata_editor_error("The file was not found. Pointer address is %p\n", _metadata->file); + metadata_editor_error("The file was not found. Pointer address is %p", _metadata->file); _metadata->isOpen = false; return METADATA_EDITOR_ERROR_FILE_EXISTS; } if (_file->readOnly()) { // Check if the file is readonly - metadata_editor_info("File is readonly\n"); + metadata_editor_info("File is readonly"); _metadata->isReadOnly = true; } else { // or not - metadata_editor_info("The file is writable\n"); + metadata_editor_info("The file is writable"); _metadata->isReadOnly = false; } return METADATA_EDITOR_ERROR_NONE; @@ -1013,25 +1013,25 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * _metadata->filetype = METADATA_EDITOR_FORMAT_WAV; if (_file->isOpen()) { // Check if the file was opened successfully - metadata_editor_info("The file is successfully opened. Address is %p\n", _metadata->file); + metadata_editor_info("The file is successfully opened. Address is %p", _metadata->file); _metadata->isOpen = true; } else { // The file does not exist or you have no permission to process it - metadata_editor_error("The file was not found. Pointer address is %p\n", _metadata->file); + metadata_editor_error("The file was not found. Pointer address is %p", _metadata->file); _metadata->isOpen = false; return METADATA_EDITOR_ERROR_FILE_EXISTS; } if (_file->readOnly()) { // Check if the file is readonly - metadata_editor_info("File is readonly\n"); + metadata_editor_info("File is readonly"); _metadata->isReadOnly = true; } else { // or not - metadata_editor_info("The file is writable\n"); + metadata_editor_info("The file is writable"); _metadata->isReadOnly = false; } return METADATA_EDITOR_ERROR_NONE; } #endif default: - metadata_editor_error("Wrong file type\n"); + metadata_editor_error("Wrong file type"); return METADATA_EDITOR_ERROR_NOT_SUPPORTED; } } @@ -1043,11 +1043,11 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata metadata_editor_retvm_if(value == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Value Pointer"); metadata_editor_s *_metadata = (metadata_editor_s*)metadata; - metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail.\n"); + metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail"); // Check if the file, given through metadata, exists and is opened correctly *value = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); switch (_metadata->filetype) { // Process the file according to the specified file type case METADATA_EDITOR_FORMAT_MP3: { @@ -1099,7 +1099,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata TagLib::FLAC::File* _file = (TagLib::FLAC::File*)_metadata->file; TagLib::Ogg::XiphComment* xtag = _file->xiphComment(false); if (!xtag) { // Check if we have a valid tag for processing - metadata_editor_error("Tag does not exist\n"); + metadata_editor_error("Tag does not exist"); *value = NULL; return METADATA_EDITOR_ERROR_OPERATION_FAILED; } @@ -1126,7 +1126,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata TagLib::Ogg::Vorbis::File* _file = (TagLib::Ogg::Vorbis::File*)_metadata->file; TagLib::Ogg::XiphComment* xtag = _file->tag(); if (!xtag) { // Check if we have a valid tag for processing - metadata_editor_error("Tag does not exist\n"); + metadata_editor_error("Tag does not exist"); *value = NULL; return METADATA_EDITOR_ERROR_OPERATION_FAILED; } @@ -1152,7 +1152,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata TagLib::Ogg::FLAC::File* _file = (TagLib::Ogg::FLAC::File*)_metadata->file; TagLib::Ogg::XiphComment* xtag = _file->tag(); if (!xtag) { // Check if we have a valid tag for processing - metadata_editor_error("Tag does not exist\n"); + metadata_editor_error("Tag does not exist"); *value = NULL; return METADATA_EDITOR_ERROR_OPERATION_FAILED; } @@ -1179,7 +1179,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata TagLib::ID3v2::Tag* tag2 = _file->tag(); if (tag2 == NULL) { // Check if we have a valid tag for processing - metadata_editor_error("Error. ID3v2 tag does not exist. Can not proceed metadata extraction\n"); + metadata_editor_error("Error. ID3v2 tag does not exist. Can not proceed metadata extraction"); *value = NULL; return METADATA_EDITOR_ERROR_OPERATION_FAILED; } @@ -1204,7 +1204,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata } #endif default: - metadata_editor_error("Wrong file type\n"); + metadata_editor_error("Wrong file type"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } @@ -1216,11 +1216,11 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata metadata_editor_s* _metadata = (metadata_editor_s*) metadata; - metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail.\n"); + metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); + metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify"); switch (_metadata->filetype) { // Process the file according to the specified file type case METADATA_EDITOR_FORMAT_MP3: { @@ -1272,7 +1272,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata TagLib::FLAC::File* _file = (TagLib::FLAC::File*)_metadata->file; TagLib::Ogg::XiphComment* xtag = _file->xiphComment(true); if (!xtag) { // Check if we have a valid tag for processing - metadata_editor_error("Error. Xiph Comment was not created. Can not proceed metadata updating\n"); + metadata_editor_error("Error. Xiph Comment was not created. Can not proceed metadata updating"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } switch (attribute) { // Check which one of frame type was given for processing @@ -1297,7 +1297,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata TagLib::Ogg::Vorbis::File* _file = (TagLib::Ogg::Vorbis::File*)_metadata->file; TagLib::Ogg::XiphComment* xtag = _file->tag(); if (!xtag) { // Check if we have a valid tag for processing - metadata_editor_error("Error. Xiph Comment was not created. Can not proceed metadata updating\n"); + metadata_editor_error("Error. Xiph Comment was not created. Can not proceed metadata updating"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } switch (attribute) { // Check which one of frame type was given for processing @@ -1322,7 +1322,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata TagLib::Ogg::FLAC::File* _file = (TagLib::Ogg::FLAC::File*)_metadata->file; TagLib::Ogg::XiphComment* xtag = _file->tag(); if (!xtag) { // Check if we have a valid tag for processing - metadata_editor_error("Error. Xiph Comment was not created. Can not proceed metadata updating\n"); + metadata_editor_error("Error. Xiph Comment was not created. Can not proceed metadata updating"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } switch (attribute) { // Check which one of frame type was given for processing @@ -1348,7 +1348,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata TagLib::ID3v2::Tag* tag2 = _file->tag(); // Check if the valid tag pointer exist if (tag2 == NULL) { - metadata_editor_error("Error. ID3v2 tag was not created. Can not proceed metadata updating\n"); + metadata_editor_error("Error. ID3v2 tag was not created. Can not proceed metadata updating"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } @@ -1371,7 +1371,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata } #endif default: - metadata_editor_error("Wrong file type\n"); + metadata_editor_error("Wrong file type"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } @@ -1379,14 +1379,14 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata // *** This function apply all changes done in the tag(s) and update them to file *** // extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) { // Check if we have a valid argument to work with - metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Handle\n"); + metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Handle"); metadata_editor_s *_metadata = (metadata_editor_s*)metadata; - metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail.\n"); + metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); + metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify"); switch (_metadata->filetype) { // Process the file according to the specified file type case METADATA_EDITOR_FORMAT_MP3: { @@ -1445,7 +1445,7 @@ extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) { } #endif default: - metadata_editor_error("Wrong file type\n"); + metadata_editor_error("Wrong file type"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } @@ -1455,19 +1455,19 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index const char *TYPE_JPEG = "image/jpeg"; const char *TYPE_PNG = "image/png"; // Check if we have valid arguments to work with - metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Handle\n"); + metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID Handle"); metadata_editor_retvm_if(picture == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_retvm_if(size == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_s* _metadata = (metadata_editor_s*) metadata; - metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail.\n"); + metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail"); // Check if the file, given through metadata, exists and is opened correctly *picture = NULL; *size = 0; *mime_type = NULL; - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); switch (_metadata->filetype) { // Process the file according to the specified file type case METADATA_EDITOR_FORMAT_MP3: { @@ -1478,12 +1478,12 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index TagLib::ID3v2::FrameList lst = tag2->frameListMap()["APIC"]; // Check if there are pictures in the tag if (lst.isEmpty()) { - metadata_editor_error("No pictures in file\n"); + metadata_editor_error("No pictures in file"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } else { // pictures exist in file // Check if index is correct or not if ((index < 0) || (lst.size() <= (uint)index)) { - metadata_editor_error("Index of picture is out of range\n"); + metadata_editor_error("Index of picture is out of range"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } else { // everything is correct - begin extraction metadata_editor_info("There are %u pictures in file. Start of picture number %d extraction", lst.size(), index); @@ -1515,7 +1515,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index case METADATA_EDITOR_FORMAT_MP4: { TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); - metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist\n"); + metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); // Get map of items directly from tag and launch a search of specific item TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); @@ -1524,7 +1524,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index TagLib::MP4::CoverArtList lst = it->second.toCoverArtList(); // Check if the index is in range of CoverArtList Item if ((index < 0) || ((uint)index >= lst.size())) { // it is not - metadata_editor_error("Index of picture is out of range\n"); + metadata_editor_error("Index of picture is out of range"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } else { // index is in range int i = 0; @@ -1545,7 +1545,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index return METADATA_EDITOR_ERROR_NONE; } } else { // Item was not found - no pictures in file - metadata_editor_error("No item in file. No pictures in file\n"); + metadata_editor_error("No item in file. No pictures in file"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } } @@ -1554,12 +1554,12 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index TagLib::FLAC::File* _file = (TagLib::FLAC::File*) _metadata->file; TagLib::List lst = _file->pictureList(); if (lst.isEmpty()) { - metadata_editor_error("No pictures in FLAC file\n"); + metadata_editor_error("No pictures in FLAC file"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } else { // Check if the index is in range of CoverArtList Item if ((index < 0) || ((uint)index >= lst.size())) { // it is not - metadata_editor_error("Index of picture is out of range\n"); + metadata_editor_error("Index of picture is out of range"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } else { // index is in range // Consecutive check of all pictures until the desired one is found @@ -1592,18 +1592,18 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index TagLib::RIFF::WAV::File* _file = (TagLib::RIFF::WAV::File*)_metadata->file; // Bring the pointer to actual file type TagLib::ID3v2::Tag* tag2 = _file->tag(); if (!tag2) { - metadata_editor_error("No ID3v2 tag in file\n"); + metadata_editor_error("No ID3v2 tag in file"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } TagLib::ID3v2::FrameList lst = tag2->frameListMap()["APIC"]; // Check if there are pictures in the tag if (lst.isEmpty()) { - metadata_editor_error("No pictures in file\n"); + metadata_editor_error("No pictures in file"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } else { // pictures exist in file // Check if index is correct or not if ((index < 0) || (lst.size() <= (uint)index)) { - metadata_editor_error("Index of picture is out of range\n"); + metadata_editor_error("Index of picture is out of range"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } else { // everything is correct - begin extraction metadata_editor_info("There are %u pictures in file. Start of picture number %d extraction", lst.size(), index); @@ -1635,7 +1635,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index } #endif default: - metadata_editor_error("Wrong file type\n"); + metadata_editor_error("Wrong file type"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } @@ -1652,14 +1652,14 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const metadata_editor_retvm_if(path == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID PARAMETER"); metadata_editor_s* _metadata = (metadata_editor_s*) metadata; - metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail.\n"); + metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); + metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify"); ret = __metadata_editor_get_picture_info(path, &picture, &size, &type); - metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); + metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); switch (_metadata->filetype) { // Process the file according to the specified file type case METADATA_EDITOR_FORMAT_MP3: { @@ -1668,17 +1668,17 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const TagLib::ID3v2::Tag* tag2 = _file->ID3v2Tag(true); // Check if the valid tag pointer exists if (tag2 == NULL) { - metadata_editor_error("Error. ID3v2 tag was not created. Can not proceed metadata updating\n"); + metadata_editor_error("Error. ID3v2 tag was not created. Can not proceed metadata updating"); ret = METADATA_EDITOR_ERROR_OPERATION_FAILED; break; } TagLib::ID3v2::AttachedPictureFrame* pictureFrame = new TagLib::ID3v2::AttachedPictureFrame(); if (pictureFrame == NULL) { - metadata_editor_error("OUT_OF_MEMORY\n"); + metadata_editor_error("OUT_OF_MEMORY"); ret = METADATA_EDITOR_ERROR_OUT_OF_MEMORY; break; } - metadata_editor_info("New APIC frame will be added to the ID3v2 tag\n"); + metadata_editor_info("New APIC frame will be added to the ID3v2 tag"); pictureFrame->setPicture(TagLib::ByteVector((char*)picture, size)); pictureFrame->setType(TagLib::ID3v2::AttachedPictureFrame::FrontCover); pictureFrame->setMimeType(type); @@ -1692,7 +1692,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; TagLib::MP4::Tag* tag = _file->tag(); if (!tag) { - metadata_editor_error("Tag was not created\n"); + metadata_editor_error("Tag was not created"); ret = METADATA_EDITOR_ERROR_OPERATION_FAILED; break; } @@ -1701,7 +1701,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); TagLib::MP4::ItemListMap::ConstIterator it = itemMap.find("covr"); if (it != itemMap.end()) { // Item was found - metadata_editor_info("The item exists. Adding picture\n"); + metadata_editor_info("The item exists. Adding picture"); TagLib::MP4::CoverArtList lst = it->second.toCoverArtList(); TagLib::MP4::CoverArt::Format format; if (strncmp(type, "image/jpeg", strlen("image/jpeg")) == 0) @@ -1717,7 +1717,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const ret = METADATA_EDITOR_ERROR_NONE; break; } else { // Item was not found - metadata_editor_info("The item does not exist. Adding picture\n"); + metadata_editor_info("The item does not exist. Adding picture"); TagLib::MP4::CoverArt::Format format; if (strncmp(type, "image/jpeg", strlen("image/jpeg")) == 0) format = TagLib::MP4::CoverArt::JPEG; @@ -1739,7 +1739,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const TagLib::FLAC::File* _file = (TagLib::FLAC::File*) _metadata->file; TagLib::FLAC::Picture* frontCover = new TagLib::FLAC::Picture; if (frontCover == NULL) { - metadata_editor_error("OUT_OF_MEMORY\n"); + metadata_editor_error("OUT_OF_MEMORY"); ret = METADATA_EDITOR_ERROR_OUT_OF_MEMORY; break; } @@ -1747,7 +1747,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const frontCover->setType(TagLib::FLAC::Picture::FrontCover); frontCover->setMimeType(type); - metadata_editor_info("Picture will be added to FLAC file\n"); + metadata_editor_info("Picture will be added to FLAC file"); _file->addPicture(frontCover); ret = METADATA_EDITOR_ERROR_NONE; break; @@ -1758,17 +1758,17 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const TagLib::ID3v2::Tag* tag2 = _file->tag(); // Check if the valid tag pointer exists if (tag2 == NULL) { - metadata_editor_error("Error. ID3v2 tag was not created. Can not proceed metadata updating\n"); + metadata_editor_error("Error. ID3v2 tag was not created. Can not proceed metadata updating"); ret = METADATA_EDITOR_ERROR_OPERATION_FAILED; break; } TagLib::ID3v2::AttachedPictureFrame* pictureFrame = new TagLib::ID3v2::AttachedPictureFrame(); if (pictureFrame == NULL) { - metadata_editor_error("OUT_OF_MEMORY\n"); + metadata_editor_error("OUT_OF_MEMORY"); ret = METADATA_EDITOR_ERROR_OUT_OF_MEMORY; break; } - metadata_editor_info("New APIC frame will be added to the ID3v2 tag\n"); + metadata_editor_info("New APIC frame will be added to the ID3v2 tag"); pictureFrame->setPicture(TagLib::ByteVector((char*)picture, size)); pictureFrame->setType(TagLib::ID3v2::AttachedPictureFrame::FrontCover); pictureFrame->setMimeType(type); @@ -1778,7 +1778,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const } #endif default: { - metadata_editor_error("Wrong file type\n"); + metadata_editor_error("Wrong file type"); ret = METADATA_EDITOR_ERROR_NOT_SUPPORTED; break; } @@ -1796,11 +1796,11 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "INVALID handler."); metadata_editor_s* _metadata = (metadata_editor_s*) metadata; - metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail.\n"); + metadata_editor_retvm_if(_metadata->file == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "File loading fail"); // Check if the file, given through metadata, exists and is opened correctly - metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it\n"); - metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify\n"); + metadata_editor_retvm_if(_metadata->file && _metadata->isOpen == false, METADATA_EDITOR_ERROR_PERMISSION_DENIED, "File does not exist or you have no rights to open it"); + metadata_editor_retvm_if(_metadata->isReadOnly, METADATA_EDITOR_ERROR_OPERATION_FAILED, "File is readonly. Unable to modify"); switch (_metadata->filetype) { // Process the file according to the specified file type case METADATA_EDITOR_FORMAT_MP3: { @@ -1812,15 +1812,15 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in TagLib::ID3v2::FrameList lst = tag2->frameListMap()["APIC"]; // Check if there are pictures in the tag if (lst.isEmpty()) { - metadata_editor_error("No pictures in file\n"); + metadata_editor_error("No pictures in file"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } else { // pictures exist in file // Check if index is correct or not if ((index < 0) || (lst.size() <= (uint)index)) { - metadata_editor_error("Index of picture is out of range\n"); + metadata_editor_error("Index of picture is out of range"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } else { // everything is correct - begin extraction - metadata_editor_info("Removing of picture number %d\n", index); + metadata_editor_info("Removing of picture number %d", index); int i = 0; // Among all frames we must choose that one with specified index. "i" will be counter for (TagLib::ID3v2::FrameList::Iterator it = lst.begin(); it != lst.end(); ++it, ++i) { @@ -1844,10 +1844,10 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in TagLib::MP4::CoverArtList lst = it->second.toCoverArtList(); // Check if the index is in range of CoverArtList Item if ((index < 0) || ((uint)index >= lst.size())) { // it is not - metadata_editor_error("Index of picture is out of range\n"); + metadata_editor_error("Index of picture is out of range"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } else { // index is in range - metadata_editor_info("The picture number %d will be deleted\n", index); + metadata_editor_info("The picture number %d will be deleted", index); int i = 0; for (TagLib::MP4::CoverArtList::Iterator picIt = lst.begin(); picIt != lst.end(); ++picIt, ++i) { if (i != index) continue; @@ -1858,7 +1858,7 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in return METADATA_EDITOR_ERROR_NONE; } } else { // Item was not found - metadata_editor_error("The item does not exist. Nothing to delete\n"); + metadata_editor_error("The item does not exist. Nothing to delete"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } } @@ -1867,15 +1867,15 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in TagLib::FLAC::File* _file = (TagLib::FLAC::File*) _metadata->file; TagLib::List lst = _file->pictureList(); if (lst.isEmpty()) { - metadata_editor_error("No pictures in file. Nothing to delete\n"); + metadata_editor_error("No pictures in file. Nothing to delete"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } // Check if the index is in range of CoverArtList Item if ((index < 0) || ((uint)index >= lst.size())) { // it is not - metadata_editor_error("Index of picture is out of range\n"); + metadata_editor_error("Index of picture is out of range"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } else { // index is in range - metadata_editor_info("The picture number %d will be deleted\n", index); + metadata_editor_info("The picture number %d will be deleted", index); int i = 0; for (TagLib::List::Iterator picIt = lst.begin(); picIt != lst.end(); ++picIt, ++i) { if (i != index) continue; @@ -1891,21 +1891,21 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in TagLib::ID3v2::Tag* tag2 = _file->tag(); // Check if the valid tag pointer exists if (tag2 == NULL) { - metadata_editor_error("Error. ID3v2 tag does not exist. Can not remove picture\n"); + metadata_editor_error("Error. ID3v2 tag does not exist. Can not remove picture"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } TagLib::ID3v2::FrameList lst = tag2->frameListMap()["APIC"]; // Check if there are pictures in the tag if (lst.isEmpty()) { - metadata_editor_error("No pictures in file\n"); + metadata_editor_error("No pictures in file"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } else { // pictures exist in file // Check if index is correct or not if ((index < 0) || (lst.size() <= (uint)index)) { - metadata_editor_error("Index of picture is out of range\n"); + metadata_editor_error("Index of picture is out of range"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } else { // everything is correct - begin extraction - metadata_editor_info("Removing of picture number %d\n", index); + metadata_editor_info("Removing of picture number %d", index); int i = 0; // Among all frames we must choose that one with specified index. "i" will be counter for (TagLib::ID3v2::FrameList::Iterator it = lst.begin(); it != lst.end(); ++it, ++i) { @@ -1919,7 +1919,7 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in } #endif default: - metadata_editor_error("Wrong file type\n"); + metadata_editor_error("Wrong file type"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } @@ -1972,11 +1972,11 @@ extern "C" int metadata_editor_destroy(metadata_editor_h metadata) { } #endif default: - metadata_editor_error("Wrong file type\n"); + metadata_editor_error("Wrong file type"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } - metadata_editor_info(" with address %p will be freed\n", metadata); + metadata_editor_info(" with address %p will be freed", metadata); delete _metadata; return METADATA_EDITOR_ERROR_NONE; -- 2.7.4 From 0b7673bf7f1f7ba04e9db43c812b17326eabf13c Mon Sep 17 00:00:00 2001 From: Jiyong Min Date: Tue, 12 Sep 2017 13:25:08 +0900 Subject: [PATCH 15/16] Apply tizen coding rule Change-Id: I808f35cc9231b7fe41b16f3c46d1cee1a6a48148 Signed-off-by: Jiyong Min --- include/metadata_editor_private.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/metadata_editor_private.h b/include/metadata_editor_private.h index 48d558b..4207292 100755 --- a/include/metadata_editor_private.h +++ b/include/metadata_editor_private.h @@ -54,8 +54,7 @@ extern "C" { #endif #define LOG_TAG "CAPI_MEDIA_METADATA_EDITOR" #define META_SAFE_FREE(src) { if (src) {free(src); src = NULL; } } -#define META_MALLOC(src, size) { if (size <= 0) src = NULL; \ - else { src = (char *)malloc(size); if (src) memset(src, 0x0, size); } } +#define META_MALLOC(src, size) { if (size <= 0) { src = NULL; } else { src = (char *)malloc(size); if (src) memset(src, 0x0, size); } } #define META_MAX_BUF_LEN 20 -- 2.7.4 From 7b795050a1ca3bace60959d52d2ce0ea217ff197 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Fri, 29 Sep 2017 12:06:35 +0900 Subject: [PATCH 16/16] Reinforce coverage Change-Id: I387ff9ec8c67a0cfc8ec787a81d42a80b33a4168 Signed-off-by: Minje Ahn --- src/metadata_editor.cpp | 46 +++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index 5953d9d..7d4004e 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -21,6 +21,7 @@ #include #include #include +#include static int __ID3_getTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* frameID, char** value); static int __ID3_setTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* frameID, const char* value); @@ -576,13 +577,10 @@ static int __MP4_getNumberOfPictures(metadata_editor_s* _metadata, char** value) TagLib::MP4::ItemListMap& itemMap = tag->itemListMap(); TagLib::MP4::ItemListMap::ConstIterator it = itemMap.find("covr"); if (it != itemMap.end()) { // Item was found - uint number = it->second.toCoverArtList().size(); // Get the size of CoverList (i.e. number of pictures in file) - metadata_editor_info("There are %u picture(s) in file", number); char buf[META_MAX_BUF_LEN] = {0, }; - snprintf(buf, META_MAX_BUF_LEN, "%u", number); // Convert integer value of size to its c-string representation - int length = strlen(buf); - metadata_editor_retvm_if(length == 0, METADATA_EDITOR_ERROR_NONE, "Empty string"); - *value = strndup(buf, length); + snprintf(buf, META_MAX_BUF_LEN, "%u", it->second.toCoverArtList().size()); // Convert integer value of size to its c-string representation + if (strlen(buf) > 0) + *value = g_strdup(buf); return METADATA_EDITOR_ERROR_NONE; } else { // Item was not found metadata_editor_info("No item in file"); @@ -1398,14 +1396,11 @@ extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) { if (!tag1 || tag1->isEmpty()) { // If no ID3v1 tag - prevent its creation if (_file->save(TagLib::MPEG::File::ID3v2 | TagLib::MPEG::File::APE)) return METADATA_EDITOR_ERROR_NONE; - else - return METADATA_EDITOR_ERROR_OPERATION_FAILED; } else { // otherwise - save all tags in file if (_file->save(TagLib::MPEG::File::AllTags)) return METADATA_EDITOR_ERROR_NONE; - else - return METADATA_EDITOR_ERROR_OPERATION_FAILED; } + return METADATA_EDITOR_ERROR_OPERATION_FAILED; } case METADATA_EDITOR_FORMAT_MP4: { TagLib::MP4::File* _file = (TagLib::MP4::File*)_metadata->file; @@ -1811,26 +1806,19 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); TagLib::ID3v2::FrameList lst = tag2->frameListMap()["APIC"]; // Check if there are pictures in the tag - if (lst.isEmpty()) { - metadata_editor_error("No pictures in file"); - return METADATA_EDITOR_ERROR_OPERATION_FAILED; - } else { // pictures exist in file - // Check if index is correct or not - if ((index < 0) || (lst.size() <= (uint)index)) { - metadata_editor_error("Index of picture is out of range"); - return METADATA_EDITOR_ERROR_INVALID_PARAMETER; - } else { // everything is correct - begin extraction - metadata_editor_info("Removing of picture number %d", index); - int i = 0; - // Among all frames we must choose that one with specified index. "i" will be counter - for (TagLib::ID3v2::FrameList::Iterator it = lst.begin(); it != lst.end(); ++it, ++i) { - if (i != index) continue; - tag2->removeFrame(*it); - break; - } - return METADATA_EDITOR_ERROR_NONE; - } + metadata_editor_retvm_if(lst.isEmpty(), METADATA_EDITOR_ERROR_OPERATION_FAILED, "No pictures in file"); + + // Check if index is correct or not + metadata_editor_retvm_if((index < 0) || (lst.size() <= (uint)index), METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Index of picture is out of range"); + metadata_editor_info("Removing of picture number %d", index); + int i = 0; + // Among all frames we must choose that one with specified index. "i" will be counter + for (TagLib::ID3v2::FrameList::Iterator it = lst.begin(); it != lst.end(); ++it, ++i) { + if (i != index) continue; + tag2->removeFrame(*it); + break; } + return METADATA_EDITOR_ERROR_NONE; } case METADATA_EDITOR_FORMAT_MP4: { TagLib::MP4::File* _file = (TagLib::MP4::File*) _metadata->file; -- 2.7.4