KVIrc  4.9.2
DeveloperAPIs
DccDescriptor.h
Go to the documentation of this file.
1 #ifndef _DESCRIPTOR_H_
2 #define _DESCRIPTOR_H_
3 //=============================================================================
4 //
5 // File : DccDescriptor.h
6 // Creation date : Tue Jul 23 01:11:52 2002 GMT by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2002-2010 Szymon Stefanek (oragma at kvirc dot net)
10 //
11 // This program is FREE software. You can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the HOPE that it will be USEFUL,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 // See the GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 #include "KviCString.h"
28 #include "KviConsoleWindow.h"
29 #include "KviPointerHashTable.h"
30 
31 class DccWindow;
32 class DccFileTransfer;
34 {
35 public:
36  DccDescriptor(KviConsoleWindow * pConsole);
37  DccDescriptor(const DccDescriptor & src);
38 
40 
41 protected:
43 
44  // mIrc zero port reverse send/chat extension
46 
47  unsigned int m_uId; // this dcc session ID
48  QString m_szId;
49 
50  DccWindow * m_pDccWindow; // 0 if it has no window
51  DccFileTransfer * m_pDccTransfer; // 0 if it is not a transfer
52 
54 
55 public:
56  // A console that this DCC is bound to (might be replaced while we wait for user acknowledge in dialogs)
57  KviConsoleWindow * console() const { return m_pConsole; };
59 
60  DccWindow * window() const { return m_pDccWindow; };
62 
63  DccFileTransfer * transfer() const { return m_pDccTransfer; };
65 
66  // mIrc zero port reverse send/chat extension
67  bool isZeroPortRequest() const { return m_szZeroPortRequestTag.hasData(); };
68  const char * zeroPortRequestTag() const { return m_szZeroPortRequestTag.ptr(); };
69  void setZeroPortRequestTag(const KviCString & szTag) { m_szZeroPortRequestTag = szTag; };
70 
71  unsigned int id() const { return m_uId; };
72  const QString & idString() const { return m_szId; };
73  static DccDescriptor * find(unsigned int uId);
75 
76  void triggerCreationEvent(); // this MUST be called by the creator of the descriptor!
77 private:
78  void copyFrom(const DccDescriptor & src);
79 
80 public:
81  // Generic parameters
82  QString szType; // DCC protocol : CHAT, SCHAT, SEND, TSSEND....
83 
84  bool bActive; // active or passive connection ?
85 
86  QString szNick; // remote user nickname
87  QString szUser; // remote user name (unknown for passive dcc)
88  QString szHost; // remote user host (unknown for passive dcc)
89 
90  QString szLocalNick; // local user nickname (always from irc)
91  QString szLocalUser; // local user username (always from irc)
92  QString szLocalHost; // local user hostname (always from irc)
93 
94  QString szIp; // remote user ip (active dcc only)
95  QString szPort; // remote user port (active dcc only)
96 
97  QString szListenIp; // passive only : ip to listen on
98  QString szListenPort; // passive only : port to listen on
99 
100  bool bSendRequest; // passive only : true if we have to send the CTCP request
101 
102  QString szFakeIp; // passive only : fake ip to send in the CTCP
103  QString szFakePort; // passive only : fake port to send in the CTCP
104 
105  bool bDoTimeout; // the marshall has to setup a timeout ?
106 
107  bool bIsTdcc; // is this a TDCC ?
108 
109  bool bOverrideMinimize; // Override the default minimize option ?
110  bool bShowMinimized; // Show minimized ? (valid if bOverrideMinimize is true)
111 
112  bool bAutoAccept; // Auto accepted dcc send/chat ?
113 #ifdef COMPILE_SSL_SUPPORT
114  bool bIsSSL; // do we have to use SSL ?
115 #endif
116  // Specific parameters
117 
118  // DCC SEND/RECV
119 
120  QString szFileName; // RECVFILE: incoming file name, SENDFILE: filename sent to the remote end
121  QString szFileSize; // RECVFILE: incoming file size, SENDFILE: remote resume size
122 
123  QString szLocalFileName; // RECVFILE: save file name selected, SENDFILE: file to send
124  QString szLocalFileSize; // RECVFILE: local file size (to resume), SENDFILE: file to send size
125 
126  bool bRecvFile; // do we have to RECEIVE the file or SEND it ?
127  bool bResume; // do we want to resume ?
128  bool bNoAcks; // blind dcc send ? (do not receive nor send acknowledges)
129 
130  bool bIsIncomingAvatar; // It is an Incoming Avatar DCC SEND ?
131 
132  // DCC VOICE
133  KviCString szCodec; // codec name
134  int iSampleRate; // Sample rate
135 public:
136  QString protocol() const { return szType; };
137  bool isActive() const { return bActive; };
138  QString remoteNick() const { return szNick; };
139  QString remoteUser() const { return szUser; };
140  QString remoteHost() const { return szHost; };
141  QString remoteIp() const { return szIp; };
142  QString remotePort() const { return szPort; };
143  QString remoteFileName() const { return szFileName; };
144  QString remoteFileSize() const { return szFileSize; };
145  QString localNick() const { return szLocalNick; };
146  QString localUser() const { return szLocalUser; };
147  QString localHost() const { return szLocalHost; };
148  QString localIp() const { return szIp; };
149  QString localPort() const { return szPort; };
150  QString localFileName() const { return szLocalFileName; };
151  QString localFileSize() const { return szLocalFileSize; };
152  bool isFileUpload();
153  bool isFileDownload();
154  bool isDccChat();
155  bool isFileTransfer() { return (isFileUpload() || isFileDownload()); };
156 #ifdef COMPILE_SSL_SUPPORT
157  bool isSSL() const
158  {
159  return bIsSSL;
160  };
161 #endif
162 };
163 
164 #endif //_DESCRIPTOR_H_
void setConsole(KviConsoleWindow *c)
Definition: DccDescriptor.h:58
QString localIp() const
Definition: DccDescriptor.h:148
bool bAutoAccept
Definition: DccDescriptor.h:112
QString szFileName
Definition: DccDescriptor.h:120
unsigned int m_uId
Definition: DccDescriptor.h:47
Definition: KviCString.h:105
Definition: KviConsoleWindow.h:75
QString remoteFileSize() const
Definition: DccDescriptor.h:144
KviCString m_szZeroPortRequestTag
Definition: DccDescriptor.h:45
char s char s char s s s s s char char c s *s c s s s d c s *s d c d d d d c
Definition: KviIrcNumericCodes.h:391
bool bDoTimeout
Definition: DccDescriptor.h:105
QString remoteUser() const
Definition: DccDescriptor.h:139
QString localPort() const
Definition: DccDescriptor.h:149
QString szLocalHost
Definition: DccDescriptor.h:92
QString szUser
Definition: DccDescriptor.h:87
Definition: DccWindow.h:34
QString localHost() const
Definition: DccDescriptor.h:147
QString szLocalNick
Definition: DccDescriptor.h:90
DccDescriptor(KviConsoleWindow *pConsole)
Definition: DccDescriptor.cpp:47
DccFileTransfer * m_pDccTransfer
Definition: DccDescriptor.h:51
KviCString szCodec
Definition: DccDescriptor.h:133
static DccDescriptor * find(unsigned int uId)
Definition: DccDescriptor.cpp:139
void setZeroPortRequestTag(const KviCString &szTag)
Definition: DccDescriptor.h:69
KviConsoleWindow * console() const
Definition: DccDescriptor.h:57
QString remoteFileName() const
Definition: DccDescriptor.h:143
QString szFileSize
Definition: DccDescriptor.h:121
bool bSendRequest
Definition: DccDescriptor.h:100
bool isDccChat()
Definition: DccDescriptor.cpp:226
DccFileTransfer * transfer() const
Definition: DccDescriptor.h:63
QString szNick
Definition: DccDescriptor.h:86
QString m_szId
Definition: DccDescriptor.h:48
QString szLocalUser
Definition: DccDescriptor.h:91
bool hasData() const
Definition: KviCString.h:181
QString szLocalFileSize
Definition: DccDescriptor.h:124
void setTransfer(DccFileTransfer *t)
Definition: DccDescriptor.h:64
QString szType
Definition: DccDescriptor.h:82
void triggerCreationEvent()
Definition: DccDescriptor.cpp:120
QString szHost
Definition: DccDescriptor.h:88
Pointer Hash Table.
Definition: DccDescriptor.h:33
bool bNoAcks
Definition: DccDescriptor.h:128
bool bIsTdcc
Definition: DccDescriptor.h:107
QString localNick() const
Definition: DccDescriptor.h:145
const QString & idString() const
Definition: DccDescriptor.h:72
Definition: DccFileTransfer.h:174
void setWindow(DccWindow *w)
Definition: DccDescriptor.h:61
QString szListenIp
Definition: DccDescriptor.h:97
static KviPointerHashTable< int, DccDescriptor > * descriptorDict()
Definition: DccDescriptor.cpp:37
QString remoteHost() const
Definition: DccDescriptor.h:140
QString szFakeIp
Definition: DccDescriptor.h:102
bool isActive() const
Definition: DccDescriptor.h:137
bool isFileUpload()
Definition: DccDescriptor.cpp:200
bool isZeroPortRequest() const
Definition: DccDescriptor.h:67
QString localUser() const
Definition: DccDescriptor.h:146
QHashIterator< int, QFile * > t(getDict)
bool isFileTransfer()
Definition: DccDescriptor.h:155
bool m_bCreationEventTriggered
Definition: DccDescriptor.h:53
int iSampleRate
Definition: DccDescriptor.h:134
QString szPort
Definition: DccDescriptor.h:95
bool bResume
Definition: DccDescriptor.h:127
QString remoteIp() const
Definition: DccDescriptor.h:141
QString remoteNick() const
Definition: DccDescriptor.h:138
#define w
Definition: detector.cpp:87
bool bRecvFile
Definition: DccDescriptor.h:126
bool bActive
Definition: DccDescriptor.h:84
QString localFileSize() const
Definition: DccDescriptor.h:151
QString szIp
Definition: DccDescriptor.h:94
QString szFakePort
Definition: DccDescriptor.h:103
QString remotePort() const
Definition: DccDescriptor.h:142
QString szLocalFileName
Definition: DccDescriptor.h:123
QString localFileName() const
Definition: DccDescriptor.h:150
KviConsoleWindow * m_pConsole
Definition: DccDescriptor.h:42
void copyFrom(const DccDescriptor &src)
Definition: DccDescriptor.cpp:146
A fast pointer hash table implementation.
Definition: KviPointerHashTable.h:391
DccWindow * m_pDccWindow
Definition: DccDescriptor.h:50
bool isFileDownload()
Definition: DccDescriptor.cpp:213
const char * zeroPortRequestTag() const
Definition: DccDescriptor.h:68
char * ptr() const
Definition: KviCString.h:172
DccWindow * window() const
Definition: DccDescriptor.h:60
~DccDescriptor()
Definition: DccDescriptor.cpp:95
unsigned int id() const
Definition: DccDescriptor.h:71
bool bIsIncomingAvatar
Definition: DccDescriptor.h:130
bool bOverrideMinimize
Definition: DccDescriptor.h:109
bool bShowMinimized
Definition: DccDescriptor.h:110
QString szListenPort
Definition: DccDescriptor.h:98
QString protocol() const
Definition: DccDescriptor.h:136