[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdesupport/taglib
From:       Lukáš Lalinský <lalinsky () gmail ! com>
Date:       2009-12-13 15:32:55
Message-ID: 1260718375.771081.27476.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1062026 by lalinsky:

Handle WM/TrackNumber with DWORD content

The default type for this attribute is String, but even MSDN suggests to
support also DWORD, because some applications write such files.

BUG:218526


 M  +7 -2      taglib/asf/asftag.cpp  
 M  +27 -0     tests/test_asf.cpp  


--- trunk/kdesupport/taglib/taglib/asf/asftag.cpp #1062025:1062026
@@ -105,8 +105,13 @@
 unsigned int
 ASF::Tag::track() const
 {
-  if(d->attributeListMap.contains("WM/TrackNumber"))
-    return d->attributeListMap["WM/TrackNumber"][0].toString().toInt();
+  if(d->attributeListMap.contains("WM/TrackNumber")) {
+    const ASF::Attribute attr = d->attributeListMap["WM/TrackNumber"][0];
+    if(attr.type() == ASF::Attribute::DWordType)
+      return attr.toUInt();
+    else
+      return attr.toString().toInt();
+  }
   if(d->attributeListMap.contains("WM/Track"))
     return d->attributeListMap["WM/Track"][0].toUInt();
   return 0;
--- trunk/kdesupport/taglib/tests/test_asf.cpp #1062025:1062026
@@ -18,6 +18,7 @@
   CPPUNIT_TEST(testSaveMultipleValues);
   CPPUNIT_TEST(testSaveStream);
   CPPUNIT_TEST(testSaveLanguage);
+  CPPUNIT_TEST(testDWordTrackNumber);
   CPPUNIT_TEST_SUITE_END();
 
 public:
@@ -55,6 +56,32 @@
     delete f;
   }
 
+  void testDWordTrackNumber()
+  {
+    ScopedFileCopy copy("silence-1", ".wma");
+    string newname = copy.fileName();
+
+    ASF::File *f = new ASF::File(newname.c_str());
+    CPPUNIT_ASSERT(!f->tag()->attributeListMap().contains("WM/TrackNumber"));
+    f->tag()->setAttribute("WM/TrackNumber", (unsigned int)(123));
+    f->save();
+    delete f;
+
+    f = new ASF::File(newname.c_str());
+    CPPUNIT_ASSERT(f->tag()->attributeListMap().contains("WM/TrackNumber"));
+    CPPUNIT_ASSERT_EQUAL(ASF::Attribute::DWordType, \
f->tag()->attributeListMap()["WM/TrackNumber"].front().type()); +    \
CPPUNIT_ASSERT_EQUAL(TagLib::uint(123), f->tag()->track()); +    \
f->tag()->setTrack(234); +    f->save();
+    delete f;
+
+    f = new ASF::File(newname.c_str());
+    CPPUNIT_ASSERT(f->tag()->attributeListMap().contains("WM/TrackNumber"));
+    CPPUNIT_ASSERT_EQUAL(ASF::Attribute::UnicodeType, \
f->tag()->attributeListMap()["WM/TrackNumber"].front().type()); +    \
CPPUNIT_ASSERT_EQUAL(TagLib::uint(234), f->tag()->track()); +    delete f;
+  }
+
   void testSaveStream()
   {
     ScopedFileCopy copy("silence-1", ".wma");


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic