Commits

shuerhaaken committed f9969b5

clean up code

  • Participants
  • Parent commits ef9baff

Comments (0)

Files changed (10)

libtaginfo/asfinfo.cc

     }
     else {
         printf("Error: Could not read tags from file '%s'\n", file_name.toCString(true));
-        return false; //JM
+        return false; 
     }
     return true;
 }

libtaginfo/flacinfo.cc

 FlacInfo::FlacInfo(const string &filename) : Info(filename) {
     if(!file_name.isEmpty() && !create_file_ref())
         printf("Error creating file ref! %s\n", filename.c_str());
-    if(taglib_file) {// && !taglib_file->isNull()) 
+    if(taglib_file) {
         xiphcomment = ((TagLib::FLAC::File *) taglib_file)->xiphComment();
         if(!xiphcomment || xiphcomment->isEmpty()) { // Use fallback for id3v1 or extended header
             taglib_tag = ((TagLib::FLAC::File *) taglib_file)->tag();

libtaginfo/id3_common.cc

 
 
 bool get_id3v2_image(ID3v2::Tag * tagv2, char*& data, int &data_length, ImageType &image_type) {
-    TagLib::ID3v2::FrameList FrameList = tagv2->frameListMap()["APIC"];
+    TagLib::ID3v2::FrameList frameList = tagv2->frameListMap()["APIC"];
     //cout << "get front cover" << endl;
     get_typed_id3v2_image(data, data_length,
-                          FrameList, 
+                          frameList, 
                           TagLib::ID3v2::AttachedPictureFrame::FrontCover,
                           image_type);
     
     if(!(data) || (data_length <= 0)) {
         //cout << "try get attached image" << endl;
         get_typed_id3v2_image(data, data_length, 
-                              FrameList, 
+                              frameList, 
                               TagLib::ID3v2::AttachedPictureFrame::Other,
                               image_type);
     }
 
 void set_id3v2_image(ID3v2::Tag * tagv2, const char* pdata, int pdata_length, ImageType image_type) {
     TagLib::ID3v2::AttachedPictureFrame * PicFrame = NULL;
-    TagLib::ID3v2::FrameList FrameList = tagv2->frameListMap()["APIC"];
-    for(list<TagLib::ID3v2::Frame*>::iterator iter = FrameList.begin(); iter != FrameList.end(); iter++) {
+    TagLib::ID3v2::FrameList frameList = tagv2->frameListMap()["APIC"];
+    for(list<TagLib::ID3v2::Frame*>::iterator iter = frameList.begin(); iter != frameList.end(); iter++) {
         PicFrame = static_cast<TagLib::ID3v2::AttachedPictureFrame *>(*iter);
         if((PicFrame->type() == TagLib::ID3v2::AttachedPictureFrame::FrontCover) ||
             (PicFrame->type() == TagLib::ID3v2::AttachedPictureFrame::Other))
 void set_id3v2_lyrics(ID3v2::Tag * tagv2, const String &lyrics) {
     TagLib::ID3v2::UnsynchronizedLyricsFrame * LyricsFrame;
     
-    TagLib::ID3v2::FrameList FrameList = tagv2->frameListMap()["USLT"];
-    for(list<TagLib::ID3v2::Frame*>::iterator iter = FrameList.begin(); iter != FrameList.end(); iter++) {
+    TagLib::ID3v2::FrameList frameList = tagv2->frameListMap()["USLT"];
+    for(list<TagLib::ID3v2::Frame*>::iterator iter = frameList.begin(); iter != frameList.end(); iter++) {
             LyricsFrame = static_cast<TagLib::ID3v2::UnsynchronizedLyricsFrame*>(*iter);
         tagv2->removeFrame(LyricsFrame, true);
     }

libtaginfo/mp3info.cc

                 playcount = PopMFrame->counter();
             }
             if(track_labels.size() == 0) {
-                ID3v2::UserTextIdentificationFrame * Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "TRACK_LABELS");
-                if(!Frame)
-                    Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "guTRLABELS");
-                if(Frame) {
-                    StringList TrLabelsList = Frame->fieldList();
-                    if(TrLabelsList.size())
-                    {
+                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "TRACK_LABELS");
+                if(!frame)
+                    frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "TRACKLABELS");
+                if(frame) {
+                    StringList TrLabelsList = frame->fieldList();
+                    if(TrLabelsList.size()) {
                         track_labels_str = TrLabelsList[ 1 ];
                         track_labels = split(track_labels_str, "|");
                     }
                 }
             }
             if(artist_labels.size() == 0) {
-                ID3v2::UserTextIdentificationFrame * Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ARTIST_LABELS");
-                if(!Frame)
-                    Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "guARLABELS");
-                if(Frame) {
-                    StringList ArLabelsList = Frame->fieldList();
-                    if(ArLabelsList.size())
-                    {
+                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ARTIST_LABELS");
+                if(!frame)
+                    frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ARTISTLABELS");
+                if(frame) {
+                    StringList ArLabelsList = frame->fieldList();
+                    if(ArLabelsList.size()) {
                         artist_labels_str = ArLabelsList[ 1 ];//.toCString(true);
                         artist_labels = split(artist_labels_str, "|");
                     }
                 }
             }
             if(album_labels.size() == 0) {
-                ID3v2::UserTextIdentificationFrame * Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ALBUM_LABELS");
-                if(!Frame)
-                    Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "guALLABELS");
-                if(Frame) {
-                    StringList AlLabelsList = Frame->fieldList();
-                    if(AlLabelsList.size())
-                    {
+                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ALBUM_LABELS");
+                if(!frame)
+                    frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ALBUMLABELS");
+                if(frame) {
+                    StringList AlLabelsList = frame->fieldList();
+                    if(AlLabelsList.size()) {
                         album_labels_str = AlLabelsList[1];//.toCString(true);
                         album_labels = split(album_labels_str, "|");
                     }
     }
     else {
           cout  << "Error: Could not read tags from file '" << file_name.toCString(true) << "'" <<  endl;
-        return false; //JM
+        return false; 
     }
     return true;
 }
                 taglib_tagId3v2->addFrame(frame);
             }
             if(changedflag & CHANGED_IS_COMPILATION_TAG) {
-                taglib_tagId3v2->removeFrames("TCMP"); //JM **********
+                taglib_tagId3v2->removeFrames("TCMP");
                 frame = new TagLib::ID3v2::TextIdentificationFrame("TCMP");
                 if(is_compilation)
                     frame->setText("1");

libtaginfo/mpcinfo.cc

                     free (str);
                 }
             }
-            // The Labels
+            // Labels
             if(changedflag & CHANGED_TRACK_LABELS)
                 check_ape_label_frame(taglib_apetag, "TRACK_LABELS",  track_labels_str);
             if(changedflag & CHANGED_ARTIST_LABELS)

libtaginfo/taginfo.h

         CHANGED_DATA_IMAGES        = (1 << 9),
         CHANGED_DATA_LYRICS        = (1 << 10),
         CHANGED_DATA_RATING        = (1 << 11),
-        CHANGED_COMPOSER_TAG       = (1 << 12), // TODO: Reoreder them.
+        CHANGED_COMPOSER_TAG       = (1 << 12),
         CHANGED_TRACK_LABELS       = (1 << 13),
         CHANGED_ARTIST_LABELS      = (1 << 14),
         CHANGED_ALBUM_LABELS       = (1 << 15),
     };
     
     
-    class WaveInfo : public Info {
+    class ASFInfo : public Info {
         protected :
-            ID3v2::Tag * taglib_tagId3v2;
+            ASF::Tag * asf_tag;
             virtual bool create_file_ref();
-            
+        
         public :
-            WaveInfo(const string &filename = "");
-            ~WaveInfo();
+            ASFInfo(const string &filename = "");
+            ~ASFInfo();
             
             virtual bool read(void);
-            virtual bool write();
+            virtual bool write(void);
             
             virtual bool can_handle_images(void) const;
             virtual bool get_image(char*& data, int &data_length, ImageType &image_type) const;
     };
     
     
-    class ASFInfo : public Info {
+    class WaveInfo : public Info {
         protected :
-            ASF::Tag * asf_tag;
+            ID3v2::Tag * taglib_tagId3v2;
             virtual bool create_file_ref();
-        
+            
         public :
-            ASFInfo(const string &filename = "");
-            ~ASFInfo();
+            WaveInfo(const string &filename = "");
+            ~WaveInfo();
             
             virtual bool read(void);
-            virtual bool write(void);
+            virtual bool write();
             
             virtual bool can_handle_images(void) const;
             virtual bool get_image(char*& data, int &data_length, ImageType &image_type) const;

libtaginfo/taginfo_internal.h

 }
 
 
-//inline void split(const string& str, const string& delimiters , vector<string>& tokens) {
-//    // Skip delimiters at beginning.
-//    string::size_type lastPos = str.find_first_not_of(delimiters, 0);
-//    // Find first "non-delimiter".
-//    string::size_type pos     = str.find_first_of(delimiters, lastPos);
-//    
-//    while (string::npos != pos || string::npos != lastPos) {
-//        // Found a token, add it to the vector.
-//        tokens.push_back(str.substr(lastPos, pos - lastPos));
-//        // Skip delimiters.  Note the "not_of"
-//        lastPos = str.find_first_not_of(delimiters, pos);
-//        // Find next "non-delimiter"
-//        pos = str.find_first_of(delimiters, lastPos);
-//    }
-//}
-
-
 inline string format(const char* fmt, ...) {
     char buffer[BUFFERSIZE] = {'\0'};
     va_list vl;
 
 inline int rating_to_popularity(const int rating) {
     int Ratings[] = { 0, 0, 1, 64, 128, 192, 255 };
-    //printf("Rating: %i => %i\n", rating, Ratings[ rating + 1 ]);
     return Ratings[rating + 1];
 }
 
 
 
 
+////////// APE
+
+void check_ape_label_frame(TagLib::APE::Tag * apetag, const char * description, const String &value);
+
+bool get_ape_item_image(const TagLib::APE::Item &item, char*& data, int &data_length, ImageType &image_type);
+bool get_ape_image(TagLib::APE::Tag * apetag, char*& data, int &data_length, ImageType &image_type);
+bool set_ape_image(TagLib::APE::Tag * apetag, const char* data, int data_length, ImageType image_type);
+
+String get_ape_lyrics(APE::Tag * apetag);
+bool set_ape_lyrics(APE::Tag * apetag, const String &lyrics);
+
+////////// end APE
+
+
+
 //////////ID3
 
 void id3v2_check_label_frame(ID3v2::Tag * tagv2, const String& description, const String &value);
 
 
 
-////////// APE
-
-void check_ape_label_frame(TagLib::APE::Tag * apetag, const char * description, const String &value);
-
-bool get_ape_item_image(const TagLib::APE::Item &item, char*& data, int &data_length, ImageType &image_type);
-bool get_ape_image(TagLib::APE::Tag * apetag, char*& data, int &data_length, ImageType &image_type);
-bool set_ape_image(TagLib::APE::Tag * apetag, const char* data, int data_length, ImageType image_type);
-
-String get_ape_lyrics(APE::Tag * apetag);
-bool set_ape_lyrics(APE::Tag * apetag, const String &lyrics);
-
-////////// end APE
-
-
-

libtaginfo/trueaudioinfo.cc

 
 bool TrueAudioInfo::read(void) {
     if(Info::read()) {
-        // If its a ID3v2 Tag try to load the labels
         if(taglib_tagId3v2 && !taglib_tagId3v2->isEmpty()) {
             if(!taglib_tag)
                 read_virtual_tags((TagLib::Tag *)taglib_tagId3v2);
                 playcount = PopMFrame->counter();
             }
             if(track_labels.size() == 0) {
-                ID3v2::UserTextIdentificationFrame * Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "TRACK_LABELS");
-                if(!Frame)
-                    Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "guTRLABELS");
-                if(Frame) {
-                    track_labels_str = Frame->fieldList()[ 1 ];
+                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "TRACK_LABELS");
+                if(!frame)
+                    frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "TRACKLABELS");
+                if(frame) {
+                    track_labels_str = frame->fieldList()[ 1 ];
                     track_labels = split(track_labels_str, "|");
                 }
             }
             if(artist_labels.size() == 0) {
-                ID3v2::UserTextIdentificationFrame * Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ARTIST_LABELS");
-                if(!Frame)
-                    Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "guARLABELS");
-                if(Frame) {
-                    artist_labels_str = Frame->fieldList()[ 1 ];
+                ID3v2::UserTextIdentificationFrame * frame = 
+                    ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ARTIST_LABELS");
+                if(!frame)
+                    frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ARTISTLABELS");
+                if(frame) {
+                    artist_labels_str = frame->fieldList()[ 1 ];
                     artist_labels = split(artist_labels_str, "|");
                 }
             }
             if(album_labels.size() == 0) {
-                ID3v2::UserTextIdentificationFrame * Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ALBUM_LABELS");
-                if(!Frame)
-                    Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "guALLABELS");
-                if(Frame) {
-                    album_labels_str = Frame->fieldList()[ 1 ];
+                ID3v2::UserTextIdentificationFrame * frame = 
+                    ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ALBUM_LABELS");
+                    frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ALBUMLABELS");
+                if(frame) {
+                    album_labels_str = frame->fieldList()[ 1 ];
                     album_labels = split(album_labels_str, "|");
                 }
             }
     }
     else {
         printf("Error: Could not read tags from file '%s'\n", file_name.toCString(true));
-        return false; //JM
+        return false; 
     }
     return true;
 }

libtaginfo/waveinfo.cc

 
 bool WaveInfo::read(void) {
     if(Info::read()) {
-            // If its a ID3v2 Tag try to load the labels
         if(taglib_tagId3v2 && !taglib_tagId3v2->isEmpty()) {
             if(!taglib_tag)
                 read_virtual_tags((TagLib::Tag *)taglib_tagId3v2);
                 playcount = PopMFrame->counter();
             }
             if(track_labels.size() == 0) {
-                ID3v2::UserTextIdentificationFrame * Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "TRACK_LABELS");
-                if(!Frame)
-                    Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "guTRLABELS");
-                if(Frame) {
-                    StringList TrLabelsList = Frame->fieldList();
-                    if(TrLabelsList.size())
-                    {
+                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "TRACK_LABELS");
+                if(!frame)
+                    frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "TRACKLABELS");
+                if(frame) {
+                    StringList TrLabelsList = frame->fieldList();
+                    if(TrLabelsList.size()) {
                         track_labels_str = TrLabelsList[ 1 ];
                         track_labels = split(track_labels_str, "|");
                     }
                 }
             }
             if(artist_labels.size() == 0) {
-                ID3v2::UserTextIdentificationFrame * Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ARTIST_LABELS");
-                if(!Frame)
-                    Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "guARLABELS");
-                if(Frame) {
-                    StringList ArLabelsList = Frame->fieldList();
-                    if(ArLabelsList.size())
-                    {
+                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ARTIST_LABELS");
+                if(!frame)
+                    frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ARTISTLABELS");
+                if(frame) {
+                    StringList ArLabelsList = frame->fieldList();
+                    if(ArLabelsList.size()) {
                         artist_labels_str = ArLabelsList[ 1 ];//.toCString(true);
                         artist_labels = split(artist_labels_str, "|");
                     }
                 }
             }
             if(album_labels.size() == 0) {
-                ID3v2::UserTextIdentificationFrame * Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ALBUM_LABELS");
-                if(!Frame)
-                    Frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "guALLABELS");
-                if(Frame) {
-                    StringList AlLabelsList = Frame->fieldList();
-                    if(AlLabelsList.size())
-                    {
+                ID3v2::UserTextIdentificationFrame * frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ALBUM_LABELS");
+                if(!frame)
+                    frame = ID3v2::UserTextIdentificationFrame::find(taglib_tagId3v2, "ALBUMLABELS");
+                if(frame) {
+                    StringList AlLabelsList = frame->fieldList();
+                    if(AlLabelsList.size()) {
                         album_labels_str = AlLabelsList[1];//.toCString(true);
                         album_labels = split(album_labels_str, "|");
                     }
     }
     else {
           cout  << "Error: Could not read tags from file '" << file_name.toCString(true) << "'" <<  endl;
-        return false; //JM
+        return false; 
     }
     return true;
 }
                 taglib_tagId3v2->addFrame(frame);
             }
             if(changedflag & CHANGED_IS_COMPILATION_TAG) {
-                taglib_tagId3v2->removeFrames("TCMP"); //JM **********
+                taglib_tagId3v2->removeFrames("TCMP");
                 frame = new TagLib::ID3v2::TextIdentificationFrame("TCMP");
                 if(is_compilation)
                     frame->setText("1");

libtaginfo/wavpackinfo.cc

             if(taglib_apetag->itemListMap().contains("RATING")) {
                 long Rating = 0;
                 Rating = atol(taglib_apetag->itemListMap()["RATING"].toStringList().front().toCString(true));
-                if(Rating)
-                {
-                    if(Rating > 5)
-                    {
+                if(Rating) {
+                    if(Rating > 5) {
                         rating = popularity_to_rating(Rating);
                     }
-                    else
-                    {
+                    else {
                         rating = Rating;
                     }
                 }
             }
             // Labels
             if(track_labels.size() == 0) {
-                if(taglib_apetag->itemListMap().contains("TRACK_LABELS"))
-                {
+                if(taglib_apetag->itemListMap().contains("TRACK_LABELS")) {
                     track_labels_str = taglib_apetag->itemListMap()["TRACK_LABELS"].toStringList().front();
                     track_labels = split(track_labels_str, "|");
                 }
             }
             if(artist_labels.size() == 0) {
-                if(taglib_apetag->itemListMap().contains("ARTIST_LABELS"))
-                {
+                if(taglib_apetag->itemListMap().contains("ARTIST_LABELS")) {
                     artist_labels_str = taglib_apetag->itemListMap()["ARTIST_LABELS"].toStringList().front();
                     artist_labels = split(artist_labels_str, "|");
                 }
             }
             if(album_labels.size() == 0) {
-                if(taglib_apetag->itemListMap().contains("ALBUM_LABELS"))
-                {
+                if(taglib_apetag->itemListMap().contains("ALBUM_LABELS")) {
                     album_labels_str = taglib_apetag->itemListMap()["ALBUM_LABELS"].toStringList().front();
                     album_labels = split(album_labels_str, "|");
                 }
             }
-            return true; //JM
+            return true; 
         }
-//        return true; // JM
     }
     return false;
 }