~ubuntu-branches/ubuntu/natty/kdemultimedia/natty-proposed

« back to all changes in this revision

Viewing changes to libkcddb/cache.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Debian Qt/KDE Maintainers
  • Date: 2011-05-26 02:41:36 UTC
  • mfrom: (0.2.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 108.
  • Revision ID: james.westby@ubuntu.com-20110526024136-jjwsigfy402jhupm
Tags: upstream-4.6.3
ImportĀ upstreamĀ versionĀ 4.6.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include "cddb.h"
27
27
 
28
28
#include "config-musicbrainz.h"
29
 
#ifdef HAVE_MUSICBRAINZ
 
29
#ifdef HAVE_MUSICBRAINZ3
30
30
#include "musicbrainz/musicbrainzlookup.h"
31
31
#endif
32
32
 
49
49
    CDInfoList infoList;
50
50
 
51
51
    infoList << CDDB::cacheFiles(offsetList, c);
52
 
#ifdef HAVE_MUSICBRAINZ
 
52
#ifdef HAVE_MUSICBRAINZ3
53
53
    infoList << MusicBrainzLookup::cacheFiles(offsetList, c);
54
54
#endif
55
55
 
68
68
    void
69
69
  Cache::store(const TrackOffsetList& offsetList, const CDInfo& info, const Config& c)
70
70
  {
71
 
    QString discid = info.get("discid").toString();
 
71
    QString discid = info.get(QLatin1String( "discid" )).toString();
72
72
 
73
73
    // Some entries from freedb could contain several discids separated
74
74
    // by a ','. Store for each discid, but replace the discid line
75
75
    // so it doesn't happen again.
76
 
    QStringList discids = discid.split(',');
 
76
    QStringList discids = discid.split(QLatin1Char( ',' ));
77
77
    if (discids.count() > 2)
78
78
    {
79
79
      foreach(const QString &newid, discids)
80
80
      {
81
81
        CDInfo newInfo = info;
82
 
        newInfo.set("discid", newid);
 
82
        newInfo.set(QLatin1String( "discid" ), newid);
83
83
        store(offsetList, newInfo, c);
84
84
      }
85
85
    }
86
86
 
87
 
    QString source = info.get("source").toString();
 
87
    QString source = info.get(QLatin1String( "source" )).toString();
88
88
 
89
89
    QString cacheDir;
90
90
    QString cacheFile;
91
91
 
92
92
    CDInfo newInfo = info;
93
93
 
94
 
    if (source == "freedb")
 
94
    if (source == QLatin1String( "freedb" ))
95
95
    {
96
 
      cacheDir = '/' + info.get("category").toString() + '/';
 
96
      cacheDir = QLatin1Char( '/' ) + info.get(QLatin1String( "category" )).toString() + QLatin1Char( '/' );
97
97
      cacheFile = discid;
98
98
    }
99
 
    else if (source == "musicbrainz")
 
99
    else if (source == QLatin1String( "musicbrainz" ))
100
100
    {
101
 
      cacheDir = "/musicbrainz/";
 
101
      cacheDir = QLatin1String( "/musicbrainz/" );
102
102
      cacheFile = discid;
103
103
    }
104
104
    else
105
105
    {
106
 
      if (source != "user")
 
106
      if (source != QLatin1String( "user" ))
107
107
        kWarning(60010) << "Unknown source " << source << " for CDInfo";
108
108
 
109
 
      cacheDir = "/user/";
 
109
      cacheDir = QLatin1String( "/user/" );
110
110
      QString id = CDDB::trackOffsetListToId(offsetList);
111
111
      cacheFile = id;
112
 
      newInfo.set("discid", id);
 
112
      newInfo.set(QLatin1String( "discid" ), id);
113
113
    }
114
114
 
115
115
    cacheDir = c.cacheLocations().first() + cacheDir;
127
127
 
128
128
    kDebug(60010) << "Storing " << cacheFile << " in CDDB cache";
129
129
 
130
 
    QFile f(cacheDir + '/' + cacheFile);
 
130
    QFile f(cacheDir + QLatin1Char( '/' ) + cacheFile);
131
131
    if ( f.open(QIODevice::WriteOnly) )
132
132
    {
133
133
      QTextStream ts(&f);