1 /***************************************************************************
2 *  common.h
3 *
4 *  Wed Sep  6 22:19:52 2006
5 *  Copyright  2006  liubin,China
6 *  Email multiget@gmail.com
7 ****************************************************************************/
8 
9 /*
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23  */
24 #ifndef _COMMON_H
25 #define _COMMON_H
26 
27 #include <cstring>
28 #include <cstdlib>
29 #include <string>
30 #include <vector>
31 #include <list>
32 
33 #ifndef WIN32
34 #include <assert.h>
35 #endif
36 
37 #ifdef WIN32
38 #include <wx/setup.h>
39 #include <windows.h>
40 #endif
41 
42 #ifdef WIN32
43 typedef __int64 llong;
44 typedef unsigned __int64 ullong;
45 #else
46 typedef long long int llong ;
47 typedef unsigned long long int ullong ;
48 #endif
49 
50 #define RECVBUF 16384
51 
52 
53 #define DBGOUT(str) std::cout<<__FILE__<<":"<<__LINE__<<":"<<str<<std::endl;
54 
55 
56 struct bindex
57 {
58     llong start;
59     llong end;
60     int mark;
61 };
62 
63 class CMgFileManager;
64 
65 struct btask
66 {
67     int ntaskid;
68     int priority;
69     int status;
70     CMgFileManager *fm;
71 };
72 
73 enum _MGLANG {
74     EN_US_UTF_8 = 0,
75     ZH_CN_UTF_8 = 1,
76     ZH_TW_UTF_8 = 2,
77     DE_DE_UTF_8 = 3,
78     ZH_TW_BIG5,
79     ZH_CN_18030,
80     //add your language here
81 
82 };
83 
84 enum _SOCKVER
85 {
86 	AUTOVERSION,
87 	V4,
88 	V4A,
89 	V5
90 };
91 
92 enum _SPEED_MODE
93 {
94     _SPEED_UNLIMIT = 0,
95     _SPEED_5M = 1,
96     _SPEED_2M = 2,
97     _SPEED_1M = 3,
98     _SPEED_700K = 4,
99     _SPEED_500K = 5,
100     _SPEED_400K = 6,
101     _SPEED_300K = 7,
102     _SPEED_200K = 8,
103     _SPEED_100K = 9,
104     _SPEED_50K = 10,
105     _SPEED_20K = 11,
106     _SPEED_10K = 12,
107 };
108 
109 enum _SINGLE_TASK_STATUS
110 {
111     _TASK_NONE,
112     _TASK_WAITTING,
113     _TASK_RUNNING,
114     _TASK_ERROR,
115     _TASK_FINISH,
116 };
117 
118 enum _TASK_SHOWTYPE{
119     _SHOW_NONE,
120     _SHOW_RUNNING,
121     _SHOW_WAITING,
122     _SHOW_PAUSE,
123     _SHOW_WRONG,
124     _SHOW_FINISH,
125     _SHOW_DELETE,
126 };
127 
128 enum _PROTYPE{
129     UNKNOW_PROTOCOL = 0,
130     FTP_PROTOCOL = 1,
131     HTTP_PROTOCOL = 2,
132     SFTP_PROTOCOL = 3,
133     SHTTP_PROTOCOL = 4,
134     RTSP_PROTOCOL = 5,
135     MMS_PROTOCOL = 6,
136     RSYNC_PROTOCOL = 7,
137 };
138 
139 
140 enum _MSGTYPE {
141     MSG_ERROR,
142     MSG_WARNNING,
143     MSG_INFO,
144     MSG_SUCCESS,
145     MSG_OUT,
146     MSG_IN,
147 };
148 
149 enum _TASK_TYPE{
150     _STATUS_ROOT,
151     _STATUS_RUNNING,
152     _STATUS_WAITING,
153     _STATUS_PAUSE,
154     _STATUS_WRONG,
155     _STATUS_FINISH,
156     _STATUS_FINISH_SOFT,
157     _STATUS_FINISH_PACK,
158     _STATUS_FINISH_MUSIC,
159     _STATUS_FINISH_ISO,
160     _STATUS_FINISH_MOVIE,
161     _STATUS_FINISH_PUBLISH,
162     _STATUS_FINISH_PICTURE,
163     _STATUS_FINISH_UNKNOW,
164     _STATUS_DELETE,
165 };
166 
167 
168 struct _TaskAttr
169 {
170     int nID; //
171     _TASK_TYPE nStatus; //
172     int nThread; //
173     //   int nPriority; //
174     bool bAutoMd5; //10/20
175     std::string sName; ////
176     llong nLen; //
177     float fRatio; //
178     llong nFinish; //
179     int nSpeed; //average speed
180     int nTime; //time to finish
181     int nError; //error times
182     int nRetry; //09/29
183     int nRetryWait; //09/29
184     //	bool bAutoMd5;	//10/20
185     std::string sURL; //mainURL
186     std::string sRefer; //2006/10/20
187     std::vector<std::string> sMirrorURL; //mirrorURL 10/12
188     std::string sSavePath;
189     std::string sSockProxy;
190     std::string sFtpProxy;
191     std::string sHttpProxy;
192     std::string sMD5;
193 };
194 
195 struct _ProxyAttr
196 {
197     int nType; //socks(0),socksv4(1),socksv4a(2),socksv5(3),ftp(4),http(5) ...
198     std::string sName; //unique custom name,
199     std::string sServer; //proxy server name
200     int nPort;
201     std::string sUser;
202     std::string sPass;
203 };
204 
205 
206 
207 struct _syslog
208 {
209     int ntime;
210     std::string info;
211 };
212 
213 
214 
215 struct _tasklog
216 {
217     int ntaskid;
218     int ntime;
219     _MSGTYPE ntype;
220     std::string info;
221 };
222 
223 
224 
225 //int getserverip( const char *server, char *sip, int buflen );
226 bool GetUserHome( std::string& homedir );
227 #ifdef WIN32
228 bool CheckForRegisterValue(
229     HKEY syskey, std::string key, std::string keyname, std::string &value );
230 #endif
231 bool GetTempDir( std::string& tempdir );
232 void Trim( std::string& str );
233 
234 class CSpeedCtrl;
235 
236 #endif
237