blob: c2680cbf1db73a44f811aeb6654d1bdbb547fb16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*
*
* $Id: k3bcddbquery.h 619556 2007-01-03 17:38:12Z trueg $
* Copyright (C) 2003 Sebastian Trueg <[email protected]>
*
* This file is part of the K3b project.
* Copyright (C) 1998-2007 Sebastian Trueg <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* See the file "COPYING" for the exact licensing terms.
*/
#ifndef K3BCDDB_QUERY_H
#define K3BCDDB_QUERY_H
#include <tqobject.h>
#include <tqstring.h>
#include <tqtextstream.h>
#include "k3bcddbresult.h"
#include <k3btoc.h>
#include "k3b_export.h"
class LIBK3B_EXPORT K3bCddbQuery : public TQObject
{
Q_OBJECT
public:
K3bCddbQuery( TQObject* parent = 0, const char* name = 0 );
virtual ~K3bCddbQuery();
void query( const K3bDevice::Toc& );
/**
* Use this if the query returned multiple matches
*/
void queryMatch( const K3bCddbResultHeader& );
const K3bCddbResultEntry& result() const { return m_result; }
/**
* After emitting the signal inexactMatches one has to choose one
* of these entries and query it with queryInexactMatch
*/
const TQValueList<K3bCddbResultHeader>& getInexactMatches() const { return m_inexactMatches; }
static const TQStringList& categories();
enum Error { SUCCESS = 0,
CANCELED,
NO_ENTRY_FOUND,
CONNECTION_ERROR,
QUERY_ERROR,
READ_ERROR,
FAILURE,
WORKING };
int error() const { return m_error; }
signals:
/**
* This gets emitted if a single entry has been found or
* no entry has been found.
*/
void queryFinished( K3bCddbQuery* );
/**
* This gets emitted if multiple entries have been found.
* Call queryInexactMatch() after receiving it.
*/
void inexactMatches( K3bCddbQuery* );
void infoMessage( const TQString& );
protected slots:
virtual void doQuery() = 0;
virtual void doMatchQuery() = 0;
protected:
const K3bDevice::Toc& toc() const { return m_toc; }
K3bCddbResultHeader& header() { return m_header; }
K3bCddbResultEntry& result() { return m_result; }
void setError( int e ) { m_error = e; }
bool parseEntry( TQTextStream&, K3bCddbResultEntry& );
int getCode( const TQString& );
TQString handshakeString() const;
TQString queryString() const;
bool parseMatchHeader( const TQString& line, K3bCddbResultHeader& header );
/**
* since I'm not quite sure when the socket will emit connectionClosed
* this method makes sure the queryFinished signal
* gets emited only once.
*/
void emitQueryFinished();
TQValueList<K3bCddbResultHeader> m_inexactMatches;
private:
K3bDevice::Toc m_toc;
K3bCddbResultEntry m_result;
K3bCddbResultHeader m_header;
int m_error;
bool m_bQueryFinishedEmited;
};
#endif
|