summaryrefslogtreecommitdiffstats
path: root/src/modules/dcc/descriptor.h
blob: 49a705ce12356429d2948e7ca734350b92985c6c (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
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
#ifndef _DESCRIPTOR_H_
#define _DESCRIPTOR_H_
//=============================================================================
//
//   File : src/modules/dcc/descriptor.h
//   Creation date : Tue Jul 23 01:11:52 2002 GMT by Szymon Stefanek
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 2002-2004 Szymon Stefanek (oragma at kvirc dot net)
//
//   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 opinion) 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, write to the Free Software Foundation,
//   Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=============================================================================

#include "kvi_string.h"
#include "kvi_console.h"

#include "kvi_pointerhashtable.h"


class KviDccWindow;
class KviDccFileTransfer;

class KviDccDescriptor
{
public:
	KviDccDescriptor(KviConsole * pConsole);
	//KviDccDescriptor(const KviDccDescriptor & src);
	~KviDccDescriptor();
protected:
	KviConsole         * m_pConsole;

	// mIrc zero port reverse send/chat extension
	KviStr               m_szZeroPortRequestTag;

	unsigned int         m_uId; // this dcc session ID
	TQString              m_szId;
	
	KviDccWindow       * m_pDccWindow;   // 0 if it has no window
	KviDccFileTransfer * m_pDccTransfer; // 0 if it is not a transfer
	
	bool                 m_bCreationEventTriggered;
public:
	// A console that this DCC is bound to (might be replaced while we wait for user acknowledge in dialogs)
	KviConsole * console() const { return m_pConsole; };
	void setConsole(KviConsole * c){ m_pConsole = c; };

	KviDccWindow * window() const { return m_pDccWindow; };
	void setWindow(KviDccWindow * w){ m_pDccWindow = w; };
	
	KviDccFileTransfer * transfer() const { return m_pDccTransfer; };
	void setTransfer(KviDccFileTransfer * t){ m_pDccTransfer = t; };

	// mIrc zero port reverse send/chat extension
	bool isZeroPortRequest() const { return m_szZeroPortRequestTag.hasData(); };
	const char * zeroPortRequestTag() const { return m_szZeroPortRequestTag.ptr(); };
	void setZeroPortRequestTag(const KviStr &szTag){ m_szZeroPortRequestTag = szTag; };

	unsigned int id() const { return m_uId; };
	const TQString & idString() const { return m_szId; };
	static KviDccDescriptor * tqfind(unsigned int uId);
	static KviPointerHashTable<int,KviDccDescriptor> * descriptorDict();

	void triggerCreationEvent(); // this MUST be called by the creator of the descriptor!
//private:
//	void copyFrom(const KviDccDescriptor &src);
public:
	// Generic parameters
	TQString         szType;            // DCC protocol : CHAT , SCHAT , SEND , TSSEND....

	bool           bActive;           // active or passive connection ?

	TQString         szNick;            // remote user nickname
	TQString         szUser;            // remote user name (unknown for passive dcc)
	TQString         szHost;            // remote user host (unknown for passive dcc)

	TQString         szLocalNick;       // local user nickname (always from irc)
	TQString         szLocalUser;       // local user username (always from irc)
	TQString         szLocalHost;       // local user hostname (always from irc)

	TQString         szIp;              // remote user ip (active dcc only)
	TQString         szPort;            // remote user port (active dcc only)

	TQString         szListenIp;        // passive only : ip to listen on
	TQString         szListenPort;      // passive only : port to listen on

	bool           bSendRequest;      // passive only : true if we have to send the CTCP request

	TQString         szFakeIp;          // passive only : fake ip to send in the CTCP
	TQString         szFakePort;        // passive only : fake port to send in the CTCP

	bool           bDoTimeout;        // the marshall has to setup a timeout ?

	bool           bIsTdcc;           // is this a TDCC ?

	bool           bOverrideMinimize; // Override the default minimize option ?
	bool           bShowMinimized;    // Show minimized ? (valid if bOverrideMinimize is true)

	bool           bAutoAccept;       // Auto accepted dcc send/chat ?
#ifdef COMPILE_SSL_SUPPORT
	bool           bIsSSL;            // do we have to use SSL ?
#endif
	// Specific parameters

	// DCC SEND/RECV

	TQString         szFileName;        // RECVFILE: incoming file name, SENDFILE: filename sent to the remote end
	TQString         szFileSize;        // RECVFILE: incoming file size, SENDFILE: remote resume size

	TQString         szLocalFileName;   // RECVFILE: save file name selected, SENDFILE: file to send
	TQString         szLocalFileSize;   // RECVFILE: local file size (to resume), SENDFILE: file to send size

	bool           bRecvFile;         // do we have to RECEIVE the file or SEND it ?

	bool           bResume;           // do we want to resume ?
	bool           bNoAcks;           // blind dcc send ? (do not receive nor send acknowledges)

	bool           bIsIncomingAvatar; // It is an Incoming Avatar DCC SEND ?

	// DCC VOICE

	KviStr         szCodec;           // codec name
	int            iSampleRate;       // Sample rate
public:
	// new interface... but should be converted to TQString...
	TQString protocol(){ return szType; };
	bool isActive(){ return bActive; };
	TQString remoteNick(){ return szNick; };
	TQString remoteUser(){ return szUser; };
	TQString remoteHost(){ return szHost; };
	TQString remoteIp(){ return szIp; };
	TQString remotePort(){ return szPort; };
	TQString remoteFileName(){ return szFileName; };
	TQString remoteFileSize(){ return szFileSize; };
	TQString localNick(){ return szLocalNick; };
	TQString localUser(){ return szLocalUser; };
	TQString localHost(){ return szLocalHost; };
	TQString localIp(){ return szIp; };
	TQString localPort(){ return szPort; };
	TQString localFileName(){ return szLocalFileName; };
	TQString localFileSize(){ return szLocalFileSize; };
	bool isFileUpload();
	bool isFileDownload();
	bool isDccChat();
	bool isFileTransfer(){ return (isFileUpload() || isFileDownload()); };
};




#endif //_DESCRIPTOR_H_