File indexing completed on 2024-04-14 04:49:13
0001 /* 0002 SPDX-FileCopyrightText: 2002 Rik Hemsley (rikkus) <rik@kde.org> 0003 SPDX-FileCopyrightText: 2002 Benjamin Meyer <ben-devel@meyerhome.net> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KCDDB_ASYNC_CDDBP_LOOKUP_H 0009 #define KCDDB_ASYNC_CDDBP_LOOKUP_H 0010 0011 #include "cddbplookup.h" 0012 0013 namespace KCDDB 0014 { 0015 class AsyncCDDBPLookup : public CDDBPLookup 0016 { 0017 Q_OBJECT 0018 0019 public: 0020 0021 enum State 0022 { 0023 Idle, 0024 WaitingForConnection, 0025 WaitingForGreeting, 0026 WaitingForHandshake, 0027 WaitingForProtoResponse, 0028 WaitingForQueryResponse, 0029 WaitingForMoreMatches, 0030 WaitingForCDInfoResponse, 0031 WaitingForCDInfoData, 0032 WaitingForQuitResponse 0033 }; 0034 0035 AsyncCDDBPLookup(); 0036 0037 virtual ~AsyncCDDBPLookup(); 0038 0039 Result lookup( const QString &, uint, const TrackOffsetList & ) override; 0040 0041 Q_SIGNALS: 0042 0043 void finished( KCDDB::Result ); 0044 void quit( Result ); 0045 0046 protected Q_SLOTS: 0047 0048 void slotGotError(QAbstractSocket::SocketError error); 0049 void slotConnectionSuccess(); 0050 void slotReadyRead(); 0051 0052 protected: 0053 0054 void doHandshake(); 0055 void doProto(); 0056 void doQuery(); 0057 void doQuit(); 0058 0059 bool parseQueryResponse( const QString & ); 0060 void requestCDInfoForMatch(); 0061 bool parseCDInfoResponse( const QString & ); 0062 void parseCDInfoData(); 0063 0064 void read(); 0065 0066 QString readLine(); 0067 0068 QString stateToString() const; 0069 0070 private: 0071 0072 State state_; 0073 Result result_; 0074 QStringList cdInfoBuffer_; 0075 }; 0076 } 0077 0078 #endif // KCDDB_ASYNC_CDDBP_LOOKUP_H 0079 // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1