2
Copyright (C) 2002 Rik Hemsley (rikkus) <rik@kde.org>
3
Copyright (C) 2002 Benjamin Meyer <ben-devel@meyerhome.net>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
Boston, MA 02111-1307, USA.
21
#include <qstringlist.h>
22
#include <qapplication.h>
26
#include <kio/netaccess.h>
28
#include "synchttplookup.h"
32
SyncHTTPLookup::SyncHTTPLookup()
37
SyncHTTPLookup::~SyncHTTPLookup()
43
SyncHTTPLookup::lookup
45
const QString & hostName,
47
const TrackOffsetList & trackOffsetList
50
if ( trackOffsetList.count() < 3 )
53
trackOffsetList_ = trackOffsetList;
55
initURL( hostName, port );
60
if ( Success != result_ )
63
kdDebug(60010) << matchList_.count() << " matches found." << endl;
65
if (matchList_.isEmpty())
68
// For each match, read the cd info from the server and save it to
70
CDDBMatchList::ConstIterator matchIt = matchList_.begin();
72
while ( matchIt != matchList_.end() )
74
CDDBMatch match( *matchIt );
75
result_ = matchToCDInfo( match );
83
SyncHTTPLookup::runQuery()
86
state_ = WaitingForQueryResponse;
88
result_ = sendQuery();
90
if ( Success != result_ )
93
kdDebug(60010) << "runQuery() Result: " << resultToString(result_) << endl;
99
SyncHTTPLookup::matchToCDInfo( const CDDBMatch & match )
101
data_ = QByteArray();
102
state_ = WaitingForReadResponse;
104
result_ = sendRead( match );
106
if ( Success != result_ )
113
SyncHTTPLookup::fetchURL()
115
kdDebug(60010) << "About to fetch: " << cgiURL_.url() << endl;
117
KIO::TransferJob* job = KIO::get( cgiURL_, false, false );
122
if (!KIO::NetAccess::synchronousRun(job, 0, &data_))
131
// vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1