• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdemultimedia API Reference
  • KDE Home
  • Contact Us
 

libkcddb

  • sources
  • kde-4.14
  • kdemultimedia
  • libkcddb
  • libkcddb
submit.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002 Rik Hemsley (rikkus) <rik@kde.org>
3  Copyright (C) 2002 Benjamin Meyer <ben-devel@meyerhome.net>
4  Copyright (C) 2003-2005 Richard Lärkäng <nouseforaname@home.se>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #include "submit.h"
23 
24 #include <kdebug.h>
25 
26 namespace KCDDB
27 {
28  Submit::Submit()
29  : CDDB()
30  {
31  // Empty.
32  }
33 
34  Submit::~Submit()
35  {
36  // Empty.
37  }
38 
39  Result Submit::submit( CDInfo cdInfo, const TrackOffsetList& offsetList)
40  {
41  // If it was an inexact math from the server the discid might
42  // be different, so recalculate it
43  cdInfo.set(QLatin1String( "discid" ), trackOffsetListToId(offsetList));
44 
45  makeDiskData( cdInfo, offsetList );
46 
47  if (!validCategory(cdInfo.get(Category).toString()))
48  return InvalidCategory;
49 
50  KIO::Job* job = createJob(cdInfo);
51 
52  if (!job)
53  return UnknownError;
54 
55  return runJob(job);
56  }
57 
58  Result
59  Submit::parseWrite( const QString & line )
60  {
61  uint serverStatus = statusCode( line );
62 
63  if ( 320 != serverStatus )
64  return ServerError;
65 
66  return Success;
67  }
68 
69  void Submit::makeDiskData( const CDInfo& cdInfo, const TrackOffsetList& offsetList )
70  {
71  unsigned numTracks = cdInfo.numberOfTracks();
72 
73  diskData_ += QLatin1String( "# xmcd\n" );
74  diskData_ += QLatin1String( "#\n" );
75  diskData_ += QLatin1String( "# Track frame offsets:\n" );
76 
77  for (uint i=0; i < numTracks; i++)
78  diskData_ += QString::fromLatin1("#\t%1\n").arg(offsetList[i]);
79 
80  int l = offsetList[numTracks]/75;
81  diskData_ += QString::fromLatin1("# Disc length: %1 seconds\n").arg(l);
82 
83  diskData_ += cdInfo.toString(true);
84 
85  kDebug(60010) << "diskData_ == " << diskData_;
86  }
87 
88  bool Submit::validCategory( const QString& c )
89  {
90  QStringList validCategories;
91  validCategories << QLatin1String( "blues" ) << QLatin1String( "classical" ) << QLatin1String( "country" )
92  << QLatin1String( "data" ) << QLatin1String( "folk" ) << QLatin1String( "jazz" ) << QLatin1String( "misc" ) << QLatin1String( "newage" ) << QLatin1String( "reggae" )
93  << QLatin1String( "rock" ) << QLatin1String( "soundtrack" );
94 
95  if (validCategories.contains(c))
96  return true;
97  else
98  return false;
99  }
100 }
101 
102 // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1
KCDDB::Category
The freedb category of the entry.
Definition: cdinfo.h:46
KCDDB::Submit::parseWrite
Result parseWrite(const QString &)
Definition: submit.cpp:59
KCDDB::CDDB::statusCode
static uint statusCode(const QString &)
Definition: cddb.cpp:104
QStringList::contains
bool contains(const QString &str, Qt::CaseSensitivity cs) const
KCDDB::CDInfo::get
QVariant get(const QString &type) const
Get data for type that has been assigned to this disc.
Definition: cdinfo.cpp:518
KCDDB::CDDB::trackOffsetListToId
QString trackOffsetListToId()
Definition: cddb.cpp:48
KCDDB::CDInfo
Information about a CD.
Definition: cdinfo.h:117
KCDDB::UnknownError
Definition: kcddb.h:47
KCDDB::Success
Definition: kcddb.h:39
KCDDB::Submit::~Submit
virtual ~Submit()
Definition: submit.cpp:34
submit.h
KCDDB::CDInfo::set
void set(const QString &type, const QVariant &data)
Set any data from this disc.
Definition: cdinfo.cpp:522
KCDDB::ServerError
Definition: kcddb.h:40
QString
QList< uint >
KCDDB::Submit::validCategory
bool validCategory(const QString &)
Definition: submit.cpp:88
KCDDB::InvalidCategory
Definition: kcddb.h:46
QStringList
KCDDB::Submit::createJob
virtual KIO::Job * createJob(const CDInfo &cdInfo)=0
KCDDB::Submit::Submit
Submit()
Definition: submit.cpp:28
KCDDB::Submit::diskData_
QString diskData_
Definition: submit.h:60
QLatin1String
KCDDB::Result
Result
Definition: kcddb.h:37
KCDDB::CDDB
Definition: cddb.h:33
KCDDB::CDInfo::numberOfTracks
int numberOfTracks() const
Returns number of tracks on CD.
Definition: cdinfo.cpp:581
KCDDB::Submit::makeDiskData
virtual void makeDiskData(const CDInfo &, const TrackOffsetList &)
Definition: submit.cpp:69
KCDDB::CDInfo::toString
QString toString(bool submit=false) const
Definition: cdinfo.cpp:421
QString::fromLatin1
QString fromLatin1(const char *str, int size)
KCDDB::Submit::submit
Result submit(CDInfo cdInfo, const TrackOffsetList &offsetList)
Definition: submit.cpp:39
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QVariant::toString
QString toString() const
KCDDB::Submit::runJob
virtual Result runJob(KIO::Job *job)=0
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:28:13 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkcddb

Skip menu "libkcddb"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdemultimedia API Reference

Skip menu "kdemultimedia API Reference"
  • libkcddb
  • libkcompactdisc

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal