2
Copyright (C) 2002 Rik Hemsley (rikkus) <rik@kde.org>
3
Copyright (C) 2002 Benjamin Meyer <ben-devel@meyerhome.net>
4
CopyRight (C) 2002 Nadeem Hasan <nhasan@kde.org>
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.
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.
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., 59 Temple Place - Suite 330,
19
Boston, MA 02111-1307, USA.
23
#include <qstringlist.h>
26
#include <kstringhandler.h>
34
: user_( "libkcddb-user" ),
35
localHostName_( "localHost" ),
47
CDDB::trackOffsetListToId()
49
return trackOffsetListToId( trackOffsetList_ );
52
CDDB::trackOffsetListToId( const TrackOffsetList & list )
54
// Taken from version by Michael Matz in kio_audiocd.
56
int numTracks = list.count() - 2;
58
// The last two in the list are disc begin and disc end.
59
for ( int i = numTracks-1; i >= 0; i-- )
69
unsigned int l = (list[numTracks + 1] + 1) / 75;
72
id = ( ( id % 255 ) << 24 ) | ( l << 8 ) | numTracks;
74
return QString::number( id, 16 ).rightJustify( 8, '0' );
78
CDDB::trackOffsetListToString()
81
uint numTracks = trackOffsetList_.count()-2;
84
ret.append( QString::number( numTracks ) );
87
for ( uint i = 0; i < numTracks; i++ )
89
ret.append( QString::number( trackOffsetList_[ i ] ) );
93
unsigned int discLengthInSec = ( trackOffsetList_[ numTracks+1 ] ) / 75;
95
// Disc length in seconds.
96
ret.append( QString::number( discLengthInSec ) );
102
CDDB::parseGreeting( const QString & line )
104
uint serverStatus = statusCode( line );
106
if ( 200 == serverStatus )
108
kdDebug(60010) << "Server response: read-only" << endl;
111
else if ( 201 == serverStatus )
113
kdDebug(60010) << "Server response: read-write" << endl;
117
kdDebug(60010) << "Server response: bugger off" << endl;
125
CDDB::parseHandshake( const QString & line )
127
uint serverStatus = statusCode( line );
129
if ( ( 200 != serverStatus ) && ( 402 != serverStatus ) )
131
kdDebug(60010) << "Handshake was too tight. Letting go." << endl;
135
kdDebug(60010) << "Handshake was warm and firm" << endl;
141
CDDB::statusCode( const QString & line )
143
QStringList tokenList = QStringList::split( ' ', line );
145
uint serverStatus = tokenList[ 0 ].toUInt();
151
CDDB::stringToTransport(const QString & s)
155
else if ( "CDDBP" == s )
162
CDDB::resultToString(Result r)
167
return i18n("Success");
171
return i18n("Server error");
175
return i18n("Host not found");
179
return i18n("No response");
183
return i18n("No record found");
186
case MultipleRecordFound:
187
return i18n("Multiple records found");
191
return i18n("Cannot save");
194
case InvalidCategory:
195
return i18n("Invalid category");
199
return i18n("Unknown error");
205
CDDB::transportToString(uint t)
207
switch (Transport(t))
222
return "UnknownTransport";
228
// vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1