From: Minje Ahn Date: Mon, 13 Dec 2021 05:42:01 +0000 (+0900) Subject: Fix build error caused by using deprecated APIs X-Git-Tag: submit/tizen/20211223.232850^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd34979e7943ddc98da1d6ef648e37adf342bb1d;p=platform%2Fcore%2Fapi%2Fmetadata-editor.git Fix build error caused by using deprecated APIs Fixed build errors due to taglib upgrade (1.11.1 to 1.12) Change-Id: Ic753ffa1a3f712b67c89e45e100d3de4a1ff0632 Signed-off-by: Minje Ahn --- diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index a89b302..62dfcd5 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -240,17 +240,17 @@ static int __ID3_getTwixFrameByName(ID3v1::Tag *tag1, ID3v2::Tag *tag2, const ch metadata_editor_info("Reading data from ID3v1 tag"); - //check isNull(). toCString() returns "", when String is NULL. + //check isEmpty(). toCString() returns "", when String is NULL. //for "genre", taglib returns "", if genre is out or range. - if (!strcmp(frameID, "TPE1") && !(tag1->artist().isNull())) /* artist */ + if (!strcmp(frameID, "TPE1") && !(tag1->artist().isEmpty())) /* artist */ *value = g_strdup(tag1->artist().toCString(true)); - else if (!strcmp(frameID, "TALB") && !(tag1->album().isNull())) /* album */ + else if (!strcmp(frameID, "TALB") && !(tag1->album().isEmpty())) /* album */ *value = g_strdup(tag1->album().toCString(true)); - else if (!strcmp(frameID, "COMM") && !(tag1->comment().isNull())) /* comment */ + else if (!strcmp(frameID, "COMM") && !(tag1->comment().isEmpty())) /* comment */ *value = g_strdup(tag1->comment().toCString(true)); - else if (!strcmp(frameID, "TCON") && !(tag1->genre().isNull()) && !(tag1->genre().isEmpty())) /* genre */ + else if (!strcmp(frameID, "TCON") && !(tag1->genre().isEmpty()) && !(tag1->genre().isEmpty())) /* genre */ *value = g_strdup(tag1->genre().toCString(true)); - else if (!strcmp(frameID, "TIT2") && !(tag1->title().isNull())) /* title */ + else if (!strcmp(frameID, "TIT2") && !(tag1->title().isEmpty())) /* title */ *value = g_strdup(tag1->title().toCString(true)); else if (!strcmp(frameID, "TRCK")) /* track */ *value = g_strdup_printf("%u", tag1->track()); @@ -360,7 +360,7 @@ static int __ID3_getLyricsFrame(ID3v2::Tag *tag2, char **value) auto it = lst.begin(); auto frame = static_cast(*it); - if (!(frame->text().isNull())) + if (!(frame->text().isEmpty())) *value = g_strdup(frame->text().toCString(true)); return METADATA_EDITOR_ERROR_NONE; @@ -435,11 +435,10 @@ static int __MP4_getStringItem(MP4::Tag *tag, const char *itemname, char **value metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_NONE, "[No-Error] No tag"); metadata_editor_retvm_if(!itemname, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid itemname"); - auto &itemMap = tag->itemListMap(); - auto it = itemMap.find(itemname); + auto item = tag->item(itemname); - if (it != itemMap.end()) - *value = g_strdup(it->second.toStringList()[0].toCString(true)); + if (item.isValid()) + *value = g_strdup(item.toStringList().toString().toCString(false)); else metadata_editor_info("No item <%s> in file", itemname); @@ -451,10 +450,10 @@ static int __MP4_getIntegerItem(MP4::Tag *tag, const char *itemname, char **valu metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_NONE, "[No-Error] No tag"); metadata_editor_retvm_if(!itemname, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid itemname"); - auto &itemMap = tag->itemListMap(); - auto it = itemMap.find(itemname); - if (it != itemMap.end()) - *value = g_strdup_printf("%u", it->second.toInt()); + auto item = tag->item(itemname); + + if (item.isValid()) + *value = g_strdup_printf("%u", item.toInt()); else metadata_editor_info("No item <%s> in file", itemname); @@ -466,18 +465,15 @@ static int __MP4_updateStringItem(MP4::Tag *tag, const char *itemname, const cha metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE, "Tag does not exist"); metadata_editor_retvm_if(!itemname, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid itemname"); - // Get map of items directly from tag and launch a search of specific item - auto &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>", itemname); - auto it = itemMap.find(itemname); - if (it != itemMap.end()) - itemMap.erase(it); + tag->removeItem(itemname); + return METADATA_EDITOR_ERROR_NONE; } metadata_editor_info("The item <%s> will be added", itemname); - itemMap[itemname] = MP4::Item(String(value, String::UTF8)); + tag->setItem(itemname, MP4::Item(String(value, String::UTF8))); return METADATA_EDITOR_ERROR_NONE; } @@ -487,21 +483,18 @@ static int __MP4_updateIntegerItem(MP4::Tag *tag, const char *itemname, const ch metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE, "Tag does not exist"); metadata_editor_retvm_if(!itemname, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid itemname"); - // Get map of items directly from tag and launch a search of specific item - auto &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>", itemname); - MP4::ItemListMap::Iterator it = itemMap.find(itemname); - if (it != itemMap.end()) - itemMap.erase(it); + tag->removeItem(itemname); + return METADATA_EDITOR_ERROR_NONE; } // 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", itemname); int number = atoi(value); - itemMap[itemname] = MP4::Item(number); + tag->setItem(itemname, 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"); @@ -545,7 +538,7 @@ static int __xiph_updateFieldValue(Ogg::XiphComment *xtag, const char *fieldname // Check if it is a request for deletion if ((value == NULL) || value[0] == '\0') { metadata_editor_info("Request for deleting of field %s", fieldname); - xtag->removeField(fieldname); + xtag->removeFields(fieldname); return METADATA_EDITOR_ERROR_NONE; } metadata_editor_info("The field %s will be added", fieldname);