KVIrc  4.9.2
DeveloperAPIs
KviIrcServer.h
Go to the documentation of this file.
1 #ifndef _KVI_IRCSERVER_H_
2 #define _KVI_IRCSERVER_H_
3 
4 //=============================================================================
5 //
6 // File : KviIrcServer.h
7 // Creation date : Mon Jul 10 2000 03:24:11 by Szymon Stefanek
8 //
9 // This file is part of the KVIrc IRC client distribution
10 // Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
11 //
12 // This program is FREE software. You can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the HOPE that it will be USEFUL,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 // See the GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, write to the Free Software Foundation,
24 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 //
26 //=============================================================================
27 
34 #include "kvi_settings.h"
35 #include "KviHeapObject.h"
36 #include "KviQString.h"
37 #include "KviPointerList.h"
38 
39 #include <QStringList>
40 
42 class KviNickServRuleSet;
43 class KviProxy;
44 class KviProxyDataBase;
46 
52 {
53 public:
58  enum Flags
59  {
60  IPv6 = 1,
61  CacheIP = 2,
62  SSL = 4,
63  STARTTLS = 8,
64  SASL = 16,
65  CAP = 32,
66  FAVORITE = 64
67  };
68 
73  KviIrcServer();
74 
80  KviIrcServer(const KviIrcServer & serv);
81 
85  ~KviIrcServer();
86 
87 private:
89  QString m_szHostname;
90  QString m_szIp;
91  QString m_szDescription;
92  kvi_u32_t m_uPort;
93  unsigned short int m_uFlags;
95  // Extended data
97  QString m_szUser;
98  QString m_szPass;
99  QString m_szNick;
101  QString m_szRealName;
102  QString m_szInitUMode;
105  QString m_szLinkFilter;
106  QString m_szEncoding;
108  QStringList * m_pAutoJoinChannelList;
110  QString m_szId;
111  int m_iProxy;
112  QString m_szSaslNick;
113  QString m_szSaslPass;
115 public:
117  {
118  return m_pReconnectInfo;
119  }
120 
121  void clearReconnectInfo();
122 
123  void setReconnectInfo(KviIrcServerReconnectInfo * pInfo);
124 
129  inline int proxy() { return m_iProxy; };
130 
136  KviProxy * proxyServer(KviProxyDataBase * pDb);
137 
142  inline kvi_u32_t port() const { return m_uPort; };
143 
148  inline const QString & password() const { return m_szPass; };
149 
154  inline const QString & saslNick() const { return m_szSaslNick; };
155 
160  inline const QString & saslPass() const { return m_szSaslPass; };
161 
166  inline const QString & nickName() const { return m_szNick; };
167 
172  inline const QString & alternativeNickName() const { return m_szAlternativeNick; };
173 
178  inline const QString & initUMode() const { return m_szInitUMode; };
179 
184  inline const QString & hostName() const { return m_szHostname; };
185 
190  inline const QString & ip() const { return m_szIp; };
191 
196  inline const QString & onLoginCommand() const { return m_szOnLoginCommand; };
197 
202  inline const QString & onConnectCommand() const { return m_szOnConnectCommand; };
203 
208  inline const QString & userName() const { return m_szUser; };
209 
214  inline const QString & realName() const { return m_szRealName; };
215 
220  inline const QString & linkFilter() const { return m_szLinkFilter; };
221 
226  inline const QString & description() const { return m_szDescription; };
227 
234  inline const QString & encoding() const { return m_szEncoding; };
235 
241  inline const QString & textEncoding() const { return m_szTextEncoding; };
242 
247  inline const QString & id() const { return m_szId; };
248 
253  inline const QString & userIdentityId() const { return m_szUserIdentityId; };
254 
259  inline bool autoConnect() const { return m_bAutoConnect; };
260 
265  inline QStringList * autoJoinChannelList() { return m_pAutoJoinChannelList; };
266 
271  inline const QString autoJoinChannelListAsString() { return m_pAutoJoinChannelList ? m_pAutoJoinChannelList->join(",") : ""; };
272 
277  inline bool isIPv6() const { return (m_uFlags & KviIrcServer::IPv6); };
278 
283  inline bool useSSL() const { return (m_uFlags & KviIrcServer::SSL); };
284 
289  inline bool enabledCAP() const { return (m_uFlags & KviIrcServer::CAP); };
290 
295  inline bool enabledSTARTTLS() const { return (m_uFlags & KviIrcServer::STARTTLS); };
296 
301  inline bool enabledSASL() const { return (m_uFlags & KviIrcServer::SASL); };
302 
307  inline bool cacheIp() const { return (m_uFlags & KviIrcServer::CacheIP); };
308 
314  QString ircUri();
315 
321  inline void setProxy(int iProxy) { m_iProxy = iProxy; };
322 
328  inline void setIp(const QString & szIp) { m_szIp = szIp; };
329 
335  inline void setPort(kvi_u32_t uPort) { m_uPort = uPort; };
336 
342  inline void setHostName(const QString & szHost) { m_szHostname = szHost; };
343 
349  inline void setDescription(const QString & szDesc) { m_szDescription = szDesc; };
350 
356  inline void setUserName(const QString & szUser) { m_szUser = szUser; };
357 
363  inline void setPassword(const QString & szPass) { m_szPass = szPass; };
364 
370  inline void setNickName(const QString & szNick) { m_szNick = szNick; };
371 
377  inline void setAlternativeNickName(const QString & szNick) { m_szAlternativeNick = szNick; };
378 
384  inline void setSaslPass(const QString & szPass) { m_szSaslPass = szPass; };
385 
391  inline void setSaslNick(const QString & szNick) { m_szSaslNick = szNick; };
392 
398  inline void setRealName(const QString & szReal) { m_szRealName = szReal; };
399 
408  inline void setEncoding(const QString & szEncoding) { m_szEncoding = szEncoding; };
409 
416  inline void setTextEncoding(const QString & szEncoding) { m_szTextEncoding = szEncoding; };
417 
423  inline void setInitUMode(const QString & szUMode) { m_szInitUMode = szUMode; };
424 
430  inline void setOnConnectCommand(const QString & szCmd) { m_szOnConnectCommand = szCmd; };
431 
437  inline void setOnLoginCommand(const QString & szCmd) { m_szOnLoginCommand = szCmd; };
438 
448  inline void setLinkFilter(const QString & szFilter) { m_szLinkFilter = szFilter; };
449 
456  void setAutoJoinChannelList(QStringList * pNewChannelList);
457 
463  void setAutoJoinChannelList(const QString & szNewChannelList);
464 
470  inline void setAutoConnect(bool bAutoConnect) { m_bAutoConnect = bAutoConnect; };
471 
477  inline void setUserIdentityId(const QString & szUserIdentityId) { m_szUserIdentityId = szUserIdentityId; };
478 
484  inline void setIPv6(bool bSet)
485  {
486  if(bSet)
487  m_uFlags |= KviIrcServer::IPv6;
488  else
489  m_uFlags &= static_cast<unsigned short>(~KviIrcServer::IPv6);
490  };
491 
497  inline void setUseSSL(bool bSet)
498  {
499  if(bSet)
500  m_uFlags |= KviIrcServer::SSL;
501  else
502  m_uFlags &= static_cast<unsigned short>(~KviIrcServer::SSL);
503  };
504 
510  inline void setEnabledSTARTTLS(bool bSet)
511  {
512  if(bSet)
513  m_uFlags |= KviIrcServer::STARTTLS;
514  else
515  m_uFlags &= static_cast<unsigned short>(~KviIrcServer::STARTTLS);
516  };
517 
523  inline void setEnabledCAP(bool bSet)
524  {
525  if(bSet)
526  m_uFlags |= KviIrcServer::CAP;
527  else
528  m_uFlags &= static_cast<unsigned short>(~KviIrcServer::CAP);
529  };
530 
536  inline void setEnabledSASL(bool bSet)
537  {
538  if(bSet)
539  m_uFlags |= KviIrcServer::SASL;
540  else
541  m_uFlags &= static_cast<unsigned short>(~KviIrcServer::SASL);
542  };
543 
549  inline void setCacheIp(bool bSet)
550  {
551  if(bSet)
552  m_uFlags |= KviIrcServer::CacheIP;
553  else
554  m_uFlags &= static_cast<unsigned short>(~KviIrcServer::CacheIP);
555  };
556 
561  void generateUniqueId();
562 
568  inline void setId(const QString & szId)
569  {
570  m_szId = szId;
571  if(m_szId.isEmpty())
572  generateUniqueId();
573  };
574 
581  bool load(KviConfigurationFile * pCfg, const QString & szPrefix);
582 
589  void save(KviConfigurationFile * pCfg, const QString & szPrefix);
590 
596  void operator=(const KviIrcServer & serv);
597 
603  inline void setFavorite(bool bSet)
604  {
605  if(bSet)
606  m_uFlags |= KviIrcServer::FAVORITE;
607  else
608  m_uFlags &= static_cast<unsigned short>(~KviIrcServer::FAVORITE);
609  };
610 
615  inline bool favorite() const { return (m_uFlags & KviIrcServer::FAVORITE); };
616 };
617 
618 #endif //_KVI_IRCSERVER_H_
Definition: KviIrcServer.h:62
const QString & saslNick() const
Returns the nickname used for sasl auth.
Definition: KviIrcServer.h:154
Definition: KviHeapObject.h:124
QString m_szAlternativeNick
Definition: KviIrcServer.h:100
QString m_szUser
Definition: KviIrcServer.h:97
bool isIPv6() const
Returns true if the server uses IPv6.
Definition: KviIrcServer.h:277
KviIrcServerReconnectInfo * reconnectInfo()
Definition: KviIrcServer.h:116
The class which manages the irc servers.
Definition: KviIrcServer.h:51
QString m_szDescription
Definition: KviIrcServer.h:91
const QString & hostName() const
Returns the hostname of the user associated to the server.
Definition: KviIrcServer.h:184
Definition: KviIrcServer.h:60
const QString & nickName() const
Returns the nickname of the user associated to the server.
Definition: KviIrcServer.h:166
Definition: KviNickServRuleSet.h:36
void setPort(kvi_u32_t uPort)
Sets the port for the server.
Definition: KviIrcServer.h:335
const QString autoJoinChannelListAsString()
Returns the list of the channels in the autojoin list as a string.
Definition: KviIrcServer.h:271
QString m_szSaslPass
Definition: KviIrcServer.h:113
bool cacheIp() const
Returns true if the server caches the IP.
Definition: KviIrcServer.h:307
Definition: KviIrcServer.h:66
QString m_szPass
Definition: KviIrcServer.h:98
const QString & ip() const
Returns the IP address of the server.
Definition: KviIrcServer.h:190
const QString & alternativeNickName() const
Returns the alternative nickname of the user associated to the server.
Definition: KviIrcServer.h:172
void setFavorite(bool bSet)
Sets the server to a favorite.
Definition: KviIrcServer.h:603
const QString & userIdentityId() const
Returns the id of the user associated to the server.
Definition: KviIrcServer.h:253
Definition: KviConfigurationFile.h:48
Definition: KviIrcServer.h:63
void setIp(const QString &szIp)
Sets the IP for the server.
Definition: KviIrcServer.h:328
bool enabledCAP() const
Returns true if the CAP protocol is enabled for this server.
Definition: KviIrcServer.h:289
bool enabledSTARTTLS() const
Returns true if the STARTTLS protocol is enabled for this server.
Definition: KviIrcServer.h:295
void setOnLoginCommand(const QString &szCmd)
Sets the commands to run on server login.
Definition: KviIrcServer.h:437
void setSaslNick(const QString &szNick)
Sets the nickname used for sasl auth.
Definition: KviIrcServer.h:391
QString m_szOnConnectCommand
Definition: KviIrcServer.h:103
bool enabledSASL() const
Returns true if the SASL protocol is enabled for this server.
Definition: KviIrcServer.h:301
bool useSSL() const
Returns true if the server uses SSL.
Definition: KviIrcServer.h:283
void setUseSSL(bool bSet)
Sets if the server uses SSL.
Definition: KviIrcServer.h:497
const QString & id() const
Returns the id of the server.
Definition: KviIrcServer.h:247
Definition: KviProxy.h:37
int m_iProxy
Definition: KviIrcServer.h:111
const QString & onConnectCommand() const
Returns the commands to run on server connection.
Definition: KviIrcServer.h:202
const QString & description() const
Returns the description of the server.
Definition: KviIrcServer.h:226
bool favorite() const
Returns if the server is a favorite.
Definition: KviIrcServer.h:615
void setEnabledCAP(bool bSet)
Sets if CAP support is enabled/disabled for this server.
Definition: KviIrcServer.h:523
void setId(const QString &szId)
Sets an unique id for the server.
Definition: KviIrcServer.h:568
QString m_szOnLoginCommand
Definition: KviIrcServer.h:104
unsigned short int m_uFlags
Definition: KviIrcServer.h:93
QString szHost
Definition: libkvisetup.cpp:45
KviIrcServerReconnectInfo * m_pReconnectInfo
Definition: KviIrcServer.h:88
QString m_szUserIdentityId
Definition: KviIrcServer.h:96
QString m_szEncoding
Definition: KviIrcServer.h:106
const QString & onLoginCommand() const
Returns the commands to run on server login.
Definition: KviIrcServer.h:196
void setUserIdentityId(const QString &szUserIdentityId)
Sets the id of the user associated to the server.
Definition: KviIrcServer.h:477
A class for reconnecting purposes.
Definition: KviIrcServerReconnectInfo.h:47
int proxy()
Returns the proxy server's id.
Definition: KviIrcServer.h:129
void setIPv6(bool bSet)
Sets if the server uses IPv6.
Definition: KviIrcServer.h:484
void setHostName(const QString &szHost)
Sets the hostname for the server.
Definition: KviIrcServer.h:342
const QString & initUMode() const
Returns the user modes of the user associated to the server.
Definition: KviIrcServer.h:178
const QString & encoding() const
Returns the encoding associated to the server Some information as nickname and channel names are enco...
Definition: KviIrcServer.h:234
void setTextEncoding(const QString &szEncoding)
Sets the encoding associated to the server This is the default encoding when talking on channels or q...
Definition: KviIrcServer.h:416
bool save(KviThemeInfo &options, bool bSaveIcons)
Definition: KviOptions.cpp:986
QString m_szNick
Definition: KviIrcServer.h:99
void setLinkFilter(const QString &szFilter)
Applies the filter to the server.
Definition: KviIrcServer.h:448
void setRealName(const QString &szReal)
Sets the realname of the user associated to the server.
Definition: KviIrcServer.h:398
void setEnabledSASL(bool bSet)
Sets if SASL support is enabled/disabled for this server.
Definition: KviIrcServer.h:536
const QString & userName() const
Returns the username of the user associated to the server.
Definition: KviIrcServer.h:208
Flags
Contains the features supported by the server.
Definition: KviIrcServer.h:58
void setInitUMode(const QString &szUMode)
Sets the user modes of the user associated to the server.
Definition: KviIrcServer.h:423
QString m_szIp
Definition: KviIrcServer.h:90
QString m_szHostname
Definition: KviIrcServer.h:89
Definition: KviIrcServer.h:61
bool autoConnect() const
Returns true if the server is in autoconnect mode.
Definition: KviIrcServer.h:259
void setAlternativeNickName(const QString &szNick)
Sets the alternative nickname of the user associated to the server.
Definition: KviIrcServer.h:377
void setEnabledSTARTTLS(bool bSet)
Sets if STARTTLS support is enabled/disabled for this server.
Definition: KviIrcServer.h:510
C++ Template based double linked pointer list class.
QString m_szSaslNick
Definition: KviIrcServer.h:112
void setDescription(const QString &szDesc)
Sets the description for the server.
Definition: KviIrcServer.h:349
const QString & password() const
Returns the password of the user associated to the server.
Definition: KviIrcServer.h:148
Definition: KviProxyDataBase.h:33
void setPassword(const QString &szPass)
Sets the password of the user associated to the server.
Definition: KviIrcServer.h:363
Heap Object.
bool m_bAutoConnect
Definition: KviIrcServer.h:109
void setProxy(int iProxy)
Sets the proxy server for the server.
Definition: KviIrcServer.h:321
void setEncoding(const QString &szEncoding)
Sets the encoding associated to the server Some information as nickname and channel names are encoded...
Definition: KviIrcServer.h:408
QString m_szInitUMode
Definition: KviIrcServer.h:102
Definition: KviIrcServer.h:64
unsigned int uPort
Definition: libkvisetup.cpp:44
void setNickName(const QString &szNick)
Sets the nickname of the user associated to the server.
Definition: KviIrcServer.h:370
QString m_szRealName
Definition: KviIrcServer.h:101
QString m_szId
Definition: KviIrcServer.h:110
void setCacheIp(bool bSet)
Sets if the server caches the IP.
Definition: KviIrcServer.h:549
const QString & realName() const
Returns the realname of the user associated to the server.
Definition: KviIrcServer.h:214
QStringList * autoJoinChannelList()
Returns the list of the channels in the autojoin list.
Definition: KviIrcServer.h:265
void setAutoConnect(bool bAutoConnect)
Sets the autoconnection mode for the server.
Definition: KviIrcServer.h:470
void setUserName(const QString &szUser)
Sets the username of the user associated to the server.
Definition: KviIrcServer.h:356
QString m_szTextEncoding
Definition: KviIrcServer.h:107
const QString & textEncoding() const
Returns the text encoding associated to the server This is the default encoding when talking on chann...
Definition: KviIrcServer.h:241
This file contains compile time settings.
QString m_szLinkFilter
Definition: KviIrcServer.h:105
QStringList * m_pAutoJoinChannelList
Definition: KviIrcServer.h:108
kvi_u32_t port() const
Returns the port number.
Definition: KviIrcServer.h:142
void setOnConnectCommand(const QString &szCmd)
Sets the commands to run on server connection.
Definition: KviIrcServer.h:430
const QString & saslPass() const
Returns the password used for sasl auth.
Definition: KviIrcServer.h:160
#define KVILIB_API
Definition: kvi_settings.h:125
const QString & linkFilter() const
Returns the filter applied on the server.
Definition: KviIrcServer.h:220
Helper functions for the QString class.
kvi_u32_t m_uPort
Definition: KviIrcServer.h:92
void setSaslPass(const QString &szPass)
Sets the password used for sasl auth.
Definition: KviIrcServer.h:384
Definition: KviIrcServer.h:65