-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathCddb.h
216 lines (167 loc) · 5.95 KB
/
Cddb.h
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
** CDex - Open Source Digital Audio CD Extractor
**
** Copyright (C) 2006 - 2007 Georgy Berdyshev
** Copyright (C) 1999 - 2002 Albert L. Faber
**
** http://cdexos.sourceforge.net/
** http://sourceforge.net/projects/cdexos
**
** 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 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CDDB_H_INCLUDED
#define CDDB_H_INCLUDED
#include <AfxSock.h>
#include "CDdbDlg.h"
#include "TextFile.h"
#include "config.h"
#include "TagData.h"
/**
* CDInfo Foreward Class declaration
*/
class CDInfo;
/**
* Define the CDDB batch file name
*/
#define CDDB_BATCH_FNAME g_config.GetCDDBPath() + _W( "CDDB_Batch.txt" )
#define CDDB_BATCH_FNAME_TMP ( CDDB_BATCH_FNAME + _W( ".tmp" ) )
typedef enum CDDB_ERROR
{
CDDB_ERROR_OK,
CDDB_ERROR_SOCKET,
CDDB_ERROR_CONNECT,
CDDB_ERROR_FAILED,
CDDB_ERROR_QUERY_FAILED,
CDDB_ERROR_SEND_FAILED,
CDDB_ERROR_INEXACT_MATCH,
CDDB_ERROR_MULTIPLE_MATCH,
CDDB_ERROR_NO_MATCH,
CDDB_ERROR_INVALID_EMAIL_ADDRESS,
CDDB_ERROR_RESPONSE,
};
/**
* CDdb is a class to obtain (load/get) or store (save/put) CD related information
*/
class CDdb
{
public:
INT m_lastResponseCode;
INT GetLastResponseCode() const { return m_lastResponseCode; }
// class constructor
CDdb(
CDInfo* pCDInfo, //! pointer to a CDInfo object
CWnd* pWnd = NULL //! pointer to Wnd object
);
// class destructor
virtual ~CDdb();
// Obtain CDDB data from local CDDB database
// return TRUE if query is successful, otherwise FALSE
BOOL QueryLocal();
// Writes the current CDDB data to the local CDDB database
BOOL WriteCurrentEntry();
// Obtain CDDB data from remote CDDB database
BOOL QueryRemote( );
// Obtain a server list from the remote site
BOOL QuerySites();
// Writes the current CDDB data to the remote CDDB database
BOOL SubmitRemote( );
// Add or remove the current entry from the CDDB batch list
BOOL AddRemoveQueryBatch( //! returns FALSE if successful
BOOL bAdd //! Add or remove entry
); //! returns TRUE if successful
static CUString GetCDDBAction();
static CUString GetInfoMsg();
BOOL RemoveFromCDDBBatch( const CUString& strLine );
BOOL ParseData( const CUString& strToParse );
public:
vector<CHAR> m_vReadResult;
CDDB_ERROR SendProto();
BOOL GetMultipleMatches( CUString& strMatches );
CDDB_ERROR OpenConnection(CUString strAddress = _T( "" ),int nPort = 80 );
CDDB_ERROR CloseConnection();
CDDB_ERROR SendHello();
CDDB_ERROR SendQuery( CUString& strReadCat );
CDDB_ERROR ReadRemote( const CUString& strReadCatagory, CUString& strDiscID, vector<CHAR>& vReadChars );
CUString GetDiscIDString() const { return m_strDiscID; }
void SetCategory( const CUString& strCategory );
private:
void GetRealServerName();
int GetString( CUString& strRet);
BOOL SendStat();
CDDB_ERROR SendRemoteMessage( CUString& strSend, BOOL bQuery );
int SendString(CUString strSend, BOOL bAppendLineFeed=TRUE);
int SendString_UTF( CHAR* strSend, BOOL bAppendLineFeed=TRUE );
CUString CreateHttpSendString( CUString strSend );
void EncodeEmailAddress( CUString& strEmailAddress );
int SendAuthentication();
CDDB_ERROR CheckServerResponse( CUString strCheck, BOOL bQuery );
BOOL CheckForTestQuery( DWORD& dwDiscID, CUString& strQuery );
// void ReceiveMessage();
BOOL GetRemoteSites();
CUString GetWindowCDDBFileName( const CUString& strCategoryDir );
CUString GetCategoryDir( DWORD dwCategory );
BOOL StoreToCDDBBatch( const CUString& strLine );
BOOL CheckFrameOffsets( CTextFile& cReadFile );
LONG SearchEntryInFiles( CUString& strFileName );
LONG SearchEntry( CUString& strFileName, CUString& strCategory );
BOOL ReadEntry( const CUString& strFileName, long lFilePos );
BOOL ReadRarEntry( const CUString& strFileName );
void WriteLine( CTextFile& cWriteFile, const CUString& strName, const CUString& strValue );
BOOL WriteEntry( const CUString& strFileName, bool bIsWindowsTypeDB, bool bIsDosFileType );
BOOL RemoveEntry( CUString& strFileName );
BOOL InitWinSock();
CUString GenerateFileName( const CUString& strCategory );
BOOL GetHostName( CUString &szFullyQualifiedHostName );
BOOL SendSmtpString( const CUString& strSend, int nNotOkValue );
BOOL SmtpOpenConnection( const CUString& strAddr, int nPort );
CUString EncodeBASE64( CUString szMessage );
int SendStringQuotedPrintable( const CUString& strSend );
BOOL SendSmtp(
const CUString& strServer,
const int nPort,
const CUString& strMailTo,
const CUString& strMailFrom,
const CUString& strMailSubject,
const CUString& strMailBody
);
CUString GetClientVersion();
void SetInfoMsg( const CUString& strMsg );
private:
CUString m_strReadID;
CUString m_strDiscID;
CUString m_strLocalPath;
CDInfo* m_pCDInfo;
CUString m_strLastResponseString;
// A buffer to hold the receive data
char m_lpszBuffer[4*8192];
// For server
sockaddr_in sAddrServer;
CUString m_strServer;
CSocket m_Socket;
BOOL m_bConnected;
CUString m_strRemoteServer;
CUString m_strReadCat;
CUString m_strReceive;
BOOL m_bInexact;
BOOL m_bIsUnixCDDBType;
BOOL m_bUTF;
CUString m_lastResponseString;
static CWnd* m_pWnd;
static CMutex m_mInfoMsg;
static CUString m_strInfoMsg;
static CMutex m_mCDDBAction;
static CUString m_strCDDBAction;
const CUString m_strSubmitFileName;
};
#endif