KVIrc 5.2.4
Developer APIs
KviIrcServer.h
Go to the documentation of this file.
1#ifndef _KVI_IRCSERVER_H_
2#define _KVI_IRCSERVER_H_
3//=============================================================================
4//
5// File : KviIrcServer.h
6// Creation date : Mon Jul 10 2000 03:24:11 by Szymon Stefanek
7//
8// This file is part of the KVIrc IRC client distribution
9// Copyright (C) 2000-2010 Szymon Stefanek (pragma 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
33#include "kvi_settings.h"
34#include "kvi_inttypes.h"
35#include "KviHeapObject.h"
36#include "KviPointerList.h"
37
38#include <QString>
39#include <QStringList>
40
43class KviProxy;
46
52{
53public:
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
74
80 KviIrcServer(const KviIrcServer & serv);
81
86
87private:
89 QString m_szHostname;
90 QString m_szIp;
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;
106 QString m_szEncoding;
110 QString m_szId;
112 QString m_szSaslNick;
113 QString m_szSaslPass;
116public:
118 {
119 return m_pReconnectInfo;
120 }
121
122 void clearReconnectInfo();
123
124 void setReconnectInfo(KviIrcServerReconnectInfo * pInfo);
125
130 int proxy() const { return m_iProxy; }
131
137 KviProxy * proxyServer(KviProxyDataBase * pDb);
138
143 kvi_u32_t port() const { return m_uPort; }
144
149 const QString & password() const { return m_szPass; }
150
155 const QString & saslNick() const { return m_szSaslNick; }
156
161 const QString & saslPass() const { return m_szSaslPass; }
162
167 const QString & saslMethod() const { return m_szSaslMethod; }
168
173 const QString & nickName() const { return m_szNick; }
174
179 const QString & alternativeNickName() const { return m_szAlternativeNick; }
180
185 const QString & initUMode() const { return m_szInitUMode; }
186
191 const QString & hostName() const { return m_szHostname; }
192
197 const QString & ip() const { return m_szIp; }
198
203 const QString & onLoginCommand() const { return m_szOnLoginCommand; }
204
209 const QString & onConnectCommand() const { return m_szOnConnectCommand; }
210
215 const QString & userName() const { return m_szUser; }
216
221 const QString & realName() const { return m_szRealName; }
222
227 const QString & linkFilter() const { return m_szLinkFilter; }
228
233 const QString & description() const { return m_szDescription; }
234
241 const QString & encoding() const { return m_szEncoding; }
242
248 const QString & textEncoding() const { return m_szTextEncoding; }
249
254 const QString & id() const { return m_szId; }
255
260 const QString & userIdentityId() const { return m_szUserIdentityId; }
261
266 bool autoConnect() const { return m_bAutoConnect; }
267
272 QStringList * autoJoinChannelList() { return m_pAutoJoinChannelList; }
273
278 const QString autoJoinChannelListAsString() { return m_pAutoJoinChannelList ? m_pAutoJoinChannelList->join(",") : ""; }
279
284 bool isIPv6() const { return (m_uFlags & KviIrcServer::IPv6); }
285
290 bool useSSL() const { return (m_uFlags & KviIrcServer::SSL); }
291
296 bool enabledCAP() const { return (m_uFlags & KviIrcServer::CAP); }
297
302 bool enabledSTARTTLS() const { return (m_uFlags & KviIrcServer::STARTTLS); }
303
308 bool enabledSASL() const { return (m_uFlags & KviIrcServer::SASL); }
309
314 bool cacheIp() const { return (m_uFlags & KviIrcServer::CacheIP); }
315
321 QString ircUri();
322
328 void setProxy(int iProxy) { m_iProxy = iProxy; }
329
335 void setIp(const QString & szIp) { m_szIp = szIp; }
336
342 void setPort(kvi_u32_t uPort) { m_uPort = uPort; }
343
349 void setHostName(const QString & szHost) { m_szHostname = szHost; }
350
356 void setDescription(const QString & szDesc) { m_szDescription = szDesc; }
357
363 void setUserName(const QString & szUser) { m_szUser = szUser; }
364
370 void setPassword(const QString & szPass) { m_szPass = szPass; }
371
377 void setNickName(const QString & szNick) { m_szNick = szNick; }
378
384 void setAlternativeNickName(const QString & szNick) { m_szAlternativeNick = szNick; }
385
391 void setSaslPass(const QString & szPass) { m_szSaslPass = szPass; }
392
398 void setSaslNick(const QString & szNick) { m_szSaslNick = szNick; }
399
405 void setSaslMethod(const QString & szMethod) { m_szSaslMethod = szMethod; }
406
412 void setRealName(const QString & szReal) { m_szRealName = szReal; }
413
422 void setEncoding(const QString & szEncoding) { m_szEncoding = szEncoding; }
423
430 void setTextEncoding(const QString & szEncoding) { m_szTextEncoding = szEncoding; }
431
437 void setInitUMode(const QString & szUMode) { m_szInitUMode = szUMode; }
438
444 void setOnConnectCommand(const QString & szCmd) { m_szOnConnectCommand = szCmd; }
445
451 void setOnLoginCommand(const QString & szCmd) { m_szOnLoginCommand = szCmd; }
452
462 void setLinkFilter(const QString & szFilter) { m_szLinkFilter = szFilter; }
463
470 void setAutoJoinChannelList(QStringList * pNewChannelList);
471
477 void setAutoJoinChannelList(const QString & szNewChannelList);
478
484 void setAutoConnect(bool bAutoConnect) { m_bAutoConnect = bAutoConnect; }
485
491 void setUserIdentityId(const QString & szUserIdentityId) { m_szUserIdentityId = szUserIdentityId; }
492
498 void setIPv6(bool bSet)
499 {
500 if(bSet)
501 m_uFlags |= KviIrcServer::IPv6;
502 else
503 m_uFlags &= static_cast<unsigned short>(~KviIrcServer::IPv6);
504 }
505
511 void setUseSSL(bool bSet)
512 {
513 if(bSet)
514 m_uFlags |= KviIrcServer::SSL;
515 else
516 m_uFlags &= static_cast<unsigned short>(~KviIrcServer::SSL);
517 }
518
524 void setEnabledSTARTTLS(bool bSet)
525 {
526 if(bSet)
527 m_uFlags |= KviIrcServer::STARTTLS;
528 else
529 m_uFlags &= static_cast<unsigned short>(~KviIrcServer::STARTTLS);
530 }
531
537 void setEnabledCAP(bool bSet)
538 {
539 if(bSet)
540 m_uFlags |= KviIrcServer::CAP;
541 else
542 m_uFlags &= static_cast<unsigned short>(~KviIrcServer::CAP);
543 }
544
550 void setEnabledSASL(bool bSet)
551 {
552 if(bSet)
553 m_uFlags |= KviIrcServer::SASL;
554 else
555 m_uFlags &= static_cast<unsigned short>(~KviIrcServer::SASL);
556 }
557
563 void setCacheIp(bool bSet)
564 {
565 if(bSet)
566 m_uFlags |= KviIrcServer::CacheIP;
567 else
568 m_uFlags &= static_cast<unsigned short>(~KviIrcServer::CacheIP);
569 }
570
575 void generateUniqueId();
576
582 void setId(const QString & szId)
583 {
584 m_szId = szId;
585 if(m_szId.isEmpty())
586 generateUniqueId();
587 }
588
595 bool load(KviConfigurationFile * pCfg, const QString & szPrefix);
596
603 void save(KviConfigurationFile * pCfg, const QString & szPrefix);
604
610 void operator=(const KviIrcServer & serv);
611
617 void setFavorite(bool bSet)
618 {
619 if(bSet)
620 m_uFlags |= KviIrcServer::FAVORITE;
621 else
622 m_uFlags &= static_cast<unsigned short>(~KviIrcServer::FAVORITE);
623 }
624
629 bool favorite() const { return (m_uFlags & KviIrcServer::FAVORITE); }
630};
631
632#endif //_KVI_IRCSERVER_H_
Heap Object.
C++ Template based double linked pointer list class.
Definition KviConfigurationFile.h:50
Definition KviHeapObject.h:119
A class for reconnecting purposes.
Definition KviIrcServerReconnectInfo.h:47
The class which manages the irc servers.
Definition KviIrcServer.h:52
Flags
Contains the features supported by the server.
Definition KviIrcServer.h:59
@ STARTTLS
Definition KviIrcServer.h:63
@ CacheIP
Definition KviIrcServer.h:61
@ CAP
Definition KviIrcServer.h:65
@ IPv6
Definition KviIrcServer.h:60
@ SASL
Definition KviIrcServer.h:64
@ SSL
Definition KviIrcServer.h:62
@ FAVORITE
Definition KviIrcServer.h:66
QString m_szSaslNick
Definition KviIrcServer.h:112
void setAutoConnect(bool bAutoConnect)
Sets the autoconnection mode for the server.
Definition KviIrcServer.h:484
QString m_szAlternativeNick
Definition KviIrcServer.h:100
bool favorite() const
Returns if the server is a favorite.
Definition KviIrcServer.h:629
QString m_szId
Definition KviIrcServer.h:110
kvi_u32_t port() const
Returns the port number.
Definition KviIrcServer.h:143
QString m_szUser
Definition KviIrcServer.h:97
const QString & id() const
Returns the id of the server.
Definition KviIrcServer.h:254
void setUserIdentityId(const QString &szUserIdentityId)
Sets the id of the user associated to the server.
Definition KviIrcServer.h:491
bool enabledCAP() const
Returns true if the CAP protocol is enabled for this server.
Definition KviIrcServer.h:296
const QString & userIdentityId() const
Returns the id of the user associated to the server.
Definition KviIrcServer.h:260
const QString & alternativeNickName() const
Returns the alternative nickname of the user associated to the server.
Definition KviIrcServer.h:179
void setSaslMethod(const QString &szMethod)
Sets the sasl method to be used for auth.
Definition KviIrcServer.h:405
bool enabledSTARTTLS() const
Returns true if the STARTTLS protocol is enabled for this server.
Definition KviIrcServer.h:302
QString m_szIp
Definition KviIrcServer.h:90
void setIp(const QString &szIp)
Sets the IP for the server.
Definition KviIrcServer.h:335
QString m_szOnLoginCommand
Definition KviIrcServer.h:104
const QString & password() const
Returns the password of the user associated to the server.
Definition KviIrcServer.h:149
QStringList * m_pAutoJoinChannelList
Definition KviIrcServer.h:108
int m_iProxy
Definition KviIrcServer.h:111
bool autoConnect() const
Returns true if the server is in autoconnect mode.
Definition KviIrcServer.h:266
const QString & saslPass() const
Returns the password used for sasl auth.
Definition KviIrcServer.h:161
void setUseSSL(bool bSet)
Sets if the server uses SSL.
Definition KviIrcServer.h:511
const QString & saslNick() const
Returns the nickname used for sasl auth.
Definition KviIrcServer.h:155
void setIPv6(bool bSet)
Sets if the server uses IPv6.
Definition KviIrcServer.h:498
void setSaslPass(const QString &szPass)
Sets the password used for sasl auth.
Definition KviIrcServer.h:391
const QString & realName() const
Returns the realname of the user associated to the server.
Definition KviIrcServer.h:221
QString m_szLinkFilter
Definition KviIrcServer.h:105
QString m_szInitUMode
Definition KviIrcServer.h:102
void setDescription(const QString &szDesc)
Sets the description for the server.
Definition KviIrcServer.h:356
QString m_szTextEncoding
Definition KviIrcServer.h:107
int proxy() const
Returns the proxy server's id.
Definition KviIrcServer.h:130
void setRealName(const QString &szReal)
Sets the realname of the user associated to the server.
Definition KviIrcServer.h:412
void setOnConnectCommand(const QString &szCmd)
Sets the commands to run on server connection.
Definition KviIrcServer.h:444
KviIrcServerReconnectInfo * m_pReconnectInfo
Definition KviIrcServer.h:88
void setId(const QString &szId)
Sets an unique id for the server.
Definition KviIrcServer.h:582
const QString & hostName() const
Returns the hostname of the user associated to the server.
Definition KviIrcServer.h:191
void setSaslNick(const QString &szNick)
Sets the nickname used for sasl auth.
Definition KviIrcServer.h:398
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:430
void setProxy(int iProxy)
Sets the proxy server for the server.
Definition KviIrcServer.h:328
unsigned short int m_uFlags
Definition KviIrcServer.h:93
void setPort(kvi_u32_t uPort)
Sets the port for the server.
Definition KviIrcServer.h:342
const QString autoJoinChannelListAsString()
Returns the list of the channels in the autojoin list as a string.
Definition KviIrcServer.h:278
bool useSSL() const
Returns true if the server uses SSL.
Definition KviIrcServer.h:290
const QString & onLoginCommand() const
Returns the commands to run on server login.
Definition KviIrcServer.h:203
const QString & initUMode() const
Returns the user modes of the user associated to the server.
Definition KviIrcServer.h:185
QString m_szHostname
Definition KviIrcServer.h:89
KviIrcServerReconnectInfo * reconnectInfo()
Definition KviIrcServer.h:117
bool isIPv6() const
Returns true if the server uses IPv6.
Definition KviIrcServer.h:284
QString m_szUserIdentityId
Definition KviIrcServer.h:96
const QString & textEncoding() const
Returns the text encoding associated to the server This is the default encoding when talking on chann...
Definition KviIrcServer.h:248
QString m_szDescription
Definition KviIrcServer.h:91
QString m_szSaslPass
Definition KviIrcServer.h:113
QString m_szSaslMethod
Definition KviIrcServer.h:114
QString m_szOnConnectCommand
Definition KviIrcServer.h:103
const QString & userName() const
Returns the username of the user associated to the server.
Definition KviIrcServer.h:215
kvi_u32_t m_uPort
Definition KviIrcServer.h:92
void setEnabledSASL(bool bSet)
Sets if SASL support is enabled/disabled for this server.
Definition KviIrcServer.h:550
QStringList * autoJoinChannelList()
Returns the list of the channels in the autojoin list.
Definition KviIrcServer.h:272
const QString & linkFilter() const
Returns the filter applied on the server.
Definition KviIrcServer.h:227
void setEnabledSTARTTLS(bool bSet)
Sets if STARTTLS support is enabled/disabled for this server.
Definition KviIrcServer.h:524
void setPassword(const QString &szPass)
Sets the password of the user associated to the server.
Definition KviIrcServer.h:370
void setOnLoginCommand(const QString &szCmd)
Sets the commands to run on server login.
Definition KviIrcServer.h:451
bool enabledSASL() const
Returns true if the SASL protocol is enabled for this server.
Definition KviIrcServer.h:308
void setInitUMode(const QString &szUMode)
Sets the user modes of the user associated to the server.
Definition KviIrcServer.h:437
void setCacheIp(bool bSet)
Sets if the server caches the IP.
Definition KviIrcServer.h:563
const QString & saslMethod() const
Returns the sasl authentication method to be used.
Definition KviIrcServer.h:167
void setNickName(const QString &szNick)
Sets the nickname of the user associated to the server.
Definition KviIrcServer.h:377
void setAlternativeNickName(const QString &szNick)
Sets the alternative nickname of the user associated to the server.
Definition KviIrcServer.h:384
const QString & nickName() const
Returns the nickname of the user associated to the server.
Definition KviIrcServer.h:173
bool cacheIp() const
Returns true if the server caches the IP.
Definition KviIrcServer.h:314
QString m_szPass
Definition KviIrcServer.h:98
QString m_szEncoding
Definition KviIrcServer.h:106
void setEnabledCAP(bool bSet)
Sets if CAP support is enabled/disabled for this server.
Definition KviIrcServer.h:537
void setFavorite(bool bSet)
Sets the server to a favorite.
Definition KviIrcServer.h:617
const QString & encoding() const
Returns the encoding associated to the server Some information as nickname and channel names are enco...
Definition KviIrcServer.h:241
bool m_bAutoConnect
Definition KviIrcServer.h:109
void setEncoding(const QString &szEncoding)
Sets the encoding associated to the server Some information as nickname and channel names are encoded...
Definition KviIrcServer.h:422
const QString & description() const
Returns the description of the server.
Definition KviIrcServer.h:233
QString m_szRealName
Definition KviIrcServer.h:101
void setHostName(const QString &szHost)
Sets the hostname for the server.
Definition KviIrcServer.h:349
void setUserName(const QString &szUser)
Sets the username of the user associated to the server.
Definition KviIrcServer.h:363
const QString & onConnectCommand() const
Returns the commands to run on server connection.
Definition KviIrcServer.h:209
QString m_szNick
Definition KviIrcServer.h:99
void setLinkFilter(const QString &szFilter)
Applies the filter to the server.
Definition KviIrcServer.h:462
const QString & ip() const
Returns the IP address of the server.
Definition KviIrcServer.h:197
Definition KviNickServRuleSet.h:38
Definition KviProxyDataBase.h:37
Definition KviProxy.h:37
This file contains compile time settings.
#define KVILIB_API
Definition kvi_settings.h:124
QString szHost
Definition libkvisetup.cpp:48
unsigned int uPort
Definition libkvisetup.cpp:47