1 //=============================================================================
2 //
3 // File : libkviserverdb.cpp
4 // Creation date : Tue Jul 1 01:48:49 2008 GMT by Elvio Basello
5 //
6 // This file is part of the KVIrc IRC client distribution
7 // Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org)
8 //
9 // This program is FREE software. You can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
13 //
14 // This program is distributed in the HOPE that it will be USEFUL,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 // See the GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program. If not, write to the Free Software Foundation,
21 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 //=============================================================================
24
25 #include "KviModule.h"
26 #include "KviApplication.h"
27 #include "KviLocale.h"
28 #include "KviIrcServer.h"
29 #include "KviIrcServerDataBase.h"
30 #include "KviIrcNetwork.h"
31
32 #include <QString>
33
34 extern KVIRC_API KviIrcServerDataBase * g_pServerDataBase;
35
36 /*
37 @doc: serverdb
38 @type:
39 module
40 @short:
41 Interface to the servers database
42 @title:
43 The serverDB module
44 @body:
45 The serverDB module is the scripting interface to the servers and networks database.[br]
46 It provides the following set of commands:[br]
47 [cmd]serverdb.addNetwork[/cmd]: adds a network entry to the database[br]
48 [cmd]serverdb.addServer[/cmd]: adds a server entry to the database[br]
49 [cmd]serverdb.setNetworkConnectCommand[/cmd]: sets a "on connect" script for the network[br]
50 [cmd]serverdb.setNetworkEncoding[/cmd]: sets the network encoding[br]
51 [cmd]serverdb.setNetworkTextEncoding[/cmd]: sets the network text encoding[br]
52 [cmd]serverdb.setNetworkDescription[/cmd]: sets the network description[br]
53 [cmd]serverdb.setNetworkLoginCommand[/cmd]: sets a "on login" script for the network[br]
54 [cmd]serverdb.setNetworkNickName[/cmd]: sets the network specific nickname[br]
55 [cmd]serverdb.setNetworkRealName[/cmd]: sets the network specific realname[br]
56 [cmd]serverdb.setNetworkUserName[/cmd]: sets the network specific username[br]
57 [cmd]serverdb.setNetworkJoinChannels[/cmd]: sets the network autojoin channels list[br]
58 [cmd]serverdb.setServerConnectCommand[/cmd]: sets a "on connect" script for the server[br]
59 [cmd]serverdb.setServerEncoding[/cmd]: sets the server encoding[br]
60 [cmd]serverdb.setServerTextEncoding[/cmd]: sets the server text encoding[br]
61 [cmd]serverdb.setServerDescription[/cmd]: sets the server description[br]
62 [cmd]serverdb.setServerLoginCommand[/cmd]: sets a "on login" script for the server[br]
63 [cmd]serverdb.setServerNickName[/cmd]: sets the server specific nickname[br]
64 [cmd]serverdb.setServerRealName[/cmd]: sets the server specific realname[br]
65 [cmd]serverdb.setServerUserName[/cmd]: sets the server specific username[br]
66 [cmd]serverdb.setServerJoinChannels[/cmd]: sets the server autojoin channels list[br]
67 [br]
68 It provides the following set of functions:[br]
69 [fnc]$serverdb.favorite[/fnc]: returns if the server is favorited or not[br]
70 [fnc]$serverdb.cacheIp[/fnc]: returns the cache-ip status for a server[br]
71 [fnc]$serverdb.networkConnectCommand[/fnc]: returns the "on connect" script for a network[br]
72 [fnc]$serverdb.networkDescription[/fnc]: returns the description for a network[br]
73 [fnc]$serverdb.networkEncoding[/fnc]: returns the encoding for a network[br]
74 [fnc]$serverdb.networkTextEncoding[/fnc]: returns the text encoding for a network[br]
75 [fnc]$serverdb.networkLoginCommand[/fnc]: returns the "on login" script for a network[br]
76 [fnc]$serverdb.networkName[/fnc]: returns the name of a network[br]
77 [fnc]$serverdb.networkNickName[/fnc]: returns the specific nickname for a network[br]
78 [fnc]$serverdb.networkRealName[/fnc]: returns the specific realname for a network[br]
79 [fnc]$serverdb.networkUserName[/fnc]: returns the specific username for a network[br]
80 [fnc]$serverdb.networkJoinChannels[/fnc]: returns the list of autojoin channels for a network[br]
81 [fnc]$serverdb.serverConnectCommand[/fnc]: returns the "on connect" script for a server[br]
82 [fnc]$serverdb.serverDescription[/fnc]: returns the description for a server[br]
83 [fnc]$serverdb.serverEncoding[/fnc]: returns the encoding for a server[br]
84 [fnc]$serverdb.serverTextEncoding[/fnc]: returns the text encoding for a server[br]
85 [fnc]$serverdb.serverId[/fnc]: returns the unique ID for a server[br]
86 [fnc]$serverdb.serverIp[/fnc]: returns the IP for a server[br]
87 [fnc]$serverdb.serverLoginCommand[/fnc]: returns the "on login" script for a server[br]
88 [fnc]$serverdb.serverNickName[/fnc]: returns the specific nickname for a server[br]
89 [fnc]$serverdb.serverPassword[/fnc]: returns the password for a server[br]
90 [fnc]$serverdb.serverPort[/fnc]: returns the port for a server[br]
91 [fnc]$serverdb.serverRealName[/fnc]: returns the specific realname for a server[br]
92 [fnc]$serverdb.serverUserName[/fnc]: returns the specific username for a server[br]
93 [fnc]$serverdb.serverJoinChannels[/fnc]: returns the list of autojoin channels for a server[br]
94 [fnc]$serverdb.isAutoConnect[/fnc]: returns the autoconnect status for a server[br]
95 [fnc]$serverdb.isIPv6[/fnc]: returns the ipv6 status for a server[br]
96 [fnc]$serverdb.isSSL[/fnc]: returns the SSL status for a server[br]
97 [fnc]$serverdb.networkExists[/fnc]: checks if a network exists[br]
98 [fnc]$serverdb.serverExists[/fnc]: checks if a server exists[br]
99 */
100
101 /*
102 @doc: serverdb.networkExists
103 @type:
104 function
105 @title:
106 $serverdb.networkExists
107 @short:
108 Checks if the network already exists in the DB
109 @syntax:
110 <bool> $serverdb.networkExists(<network_name:string>)
111 @description:
112 Checks if the network already exists in the DB.[br]
113 It returns [b]1[/b] if the network exists, and [b]0[/b] otherwise.
114 @seealso:
115 [module:serverdb]ServerDB module documentation[/module]
116 */
serverdb_kvs_fnc_networkExists(KviKvsModuleFunctionCall * c)117 static bool serverdb_kvs_fnc_networkExists(KviKvsModuleFunctionCall * c)
118 {
119 QString szNetwork;
120
121 KVSM_PARAMETERS_BEGIN(c)
122 KVSM_PARAMETER("network_name", KVS_PT_STRING, 0, szNetwork)
123 KVSM_PARAMETERS_END(c)
124
125 if(szNetwork.isEmpty())
126 {
127 c->error(__tr2qs_ctx("You must provide the network name as parameter", "serverdb"));
128 return false;
129 }
130
131 KviIrcNetwork * pNetwork = g_pServerDataBase->findNetwork(szNetwork);
132 if(!pNetwork)
133 {
134 c->returnValue()->setBoolean(false);
135 return true;
136 }
137
138 c->returnValue()->setBoolean(true);
139 return true;
140 }
141
142 /*
143 @doc: serverdb.serverExists
144 @type:
145 function
146 @title:
147 $serverdb.serverExists
148 @short:
149 Checks if the network already exists in the DB
150 @syntax:
151 <bool> $serverdb.serverExists(<servername:string>[,<networkname:string>])
152 @description:
153 Checks if the server already exists for a network in the DB.[br]
154 If no network name is provided, the check is made globally.[br]
155 It returns 1 if the server exists, and [b]0[/b] otherwise
156 @seealso:
157 [module:serverdb]ServerDB module documentation[/module]
158 */
159
serverdb_kvs_fnc_serverExists(KviKvsModuleFunctionCall * c)160 static bool serverdb_kvs_fnc_serverExists(KviKvsModuleFunctionCall * c)
161 {
162 QString szServer, szNetwork;
163
164 KVSM_PARAMETERS_BEGIN(c)
165 KVSM_PARAMETER("server_name", KVS_PT_STRING, 0, szServer)
166 KVSM_PARAMETER("network_name", KVS_PT_STRING, KVS_PF_OPTIONAL, szNetwork)
167 KVSM_PARAMETERS_END(c)
168
169 if(szServer.isEmpty())
170 {
171 c->error(__tr2qs_ctx("You must provide the server name as parameter", "serverdb"));
172 return false;
173 }
174
175 if(!szNetwork.isEmpty())
176 {
177 // Check in the given network
178 KviIrcNetwork * pRecord = g_pServerDataBase->findNetwork(szNetwork);
179 if(!pRecord)
180 {
181 c->returnValue()->setBoolean(false);
182 return true;
183 }
184
185 KviIrcServer * pCheckServer = pRecord->findServer(szServer);
186 if(!pCheckServer)
187 {
188 c->returnValue()->setBoolean(false);
189 return true;
190 }
191
192 c->returnValue()->setBoolean(true);
193 }
194 else
195 {
196 // Check through all networks
197 KviPointerHashTableIterator<QString, KviIrcNetwork> it(*(g_pServerDataBase->recordDict()));
198
199 while(KviIrcNetwork * r = it.current())
200 {
201 KviPointerList<KviIrcServer> * sl = r->serverList();
202
203 for(KviIrcServer * s = sl->first(); s; s = sl->next())
204 {
205 if(QString::compare(s->hostName().toUtf8().data(), szServer, Qt::CaseInsensitive) == 0)
206 {
207 c->returnValue()->setBoolean(true);
208 return true;
209 }
210 }
211 ++it;
212 }
213
214 c->returnValue()->setBoolean(false);
215 }
216
217 return true;
218 }
219
220 #define BEGIN_SERVERDB_GET_NETWORK_PROPERTY(__functionName) \
221 static bool __functionName(KviKvsModuleFunctionCall * c) \
222 { \
223 QString szName; \
224 \
225 KVSM_PARAMETERS_BEGIN(c) \
226 KVSM_PARAMETER("name", KVS_PT_STRING, 0, szName) \
227 KVSM_PARAMETERS_END(c) \
228 \
229 if(szName.isEmpty()) \
230 { \
231 c->error(__tr2qs_ctx("You must provide the network name as parameter", "serverdb")); \
232 return false; \
233 } \
234 \
235 KviIrcNetwork * pNetwork = g_pServerDataBase->findNetwork(szName); \
236 if(!pNetwork) \
237 { \
238 c->error(__tr2qs_ctx("The specified network doesn't exist", "serverdb")); \
239 return false; \
240 }
241
242 #define END_SERVERDB_GET_NETWORK_PROPERTY \
243 return true; \
244 }
245
246 #define SERVERDB_GET_NETWORK_PROPERTY(__functionName, __callName) \
247 BEGIN_SERVERDB_GET_NETWORK_PROPERTY(__functionName) \
248 \
249 c->returnValue()->setString(pNetwork->__callName()); \
250 \
251 END_SERVERDB_GET_NETWORK_PROPERTY
252
253 #define BEGIN_SERVERDB_GET_SERVER_PROPERTY(__functionName) \
254 static bool __functionName(KviKvsModuleFunctionCall * c) \
255 { \
256 QString szNetName, szServName; \
257 \
258 KVSM_PARAMETERS_BEGIN(c) \
259 KVSM_PARAMETER("network_name", KVS_PT_STRING, 0, szNetName) \
260 KVSM_PARAMETER("server_name", KVS_PT_STRING, 0, szServName) \
261 KVSM_PARAMETERS_END(c) \
262 \
263 if(szNetName.isEmpty()) \
264 { \
265 c->error(__tr2qs_ctx("You must provide the network name as parameter", "serverdb")); \
266 return false; \
267 } \
268 \
269 if(szServName.isEmpty()) \
270 { \
271 c->error(__tr2qs_ctx("You must provide the server name as parameter", "serverdb")); \
272 return false; \
273 } \
274 \
275 KviIrcNetwork * pRecord = g_pServerDataBase->findNetwork(szNetName); \
276 if(!pRecord) \
277 { \
278 c->error(__tr2qs_ctx("The specified network doesn't exist", "serverdb")); \
279 return false; \
280 } \
281 \
282 KviIrcServer * pServer = pRecord->findServer(szServName); \
283 if(!pServer) \
284 { \
285 c->error(__tr2qs_ctx("The specified server doesn't exist", "serverdb")); \
286 return false; \
287 }
288
289 #define END_SERVERDB_GET_SERVER_PROPERTY \
290 return true; \
291 }
292
293 #define SERVERDB_GET_SERVER_PROPERTY(__functionName, __callName, __variantSetCallName) \
294 BEGIN_SERVERDB_GET_SERVER_PROPERTY(__functionName) \
295 c->returnValue()->__variantSetCallName(pServer->__callName()); \
296 END_SERVERDB_GET_SERVER_PROPERTY
297
298 /*
299 @doc: serverdb.networkNickName
300 @type:
301 function
302 @title:
303 $serverdb.networkNickName
304 @short:
305 Returns the nickname
306 @syntax:
307 <string> $serverdb.networkNickName(<network:string>)
308 @description:
309 Returns the nickname set for the network <network> if set
310 @seealso:
311 [module:serverdb]ServerDB module documentation[/module]
312 */
313
314 SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_networkNickName, nickName)
315
316 /*
317 @doc: serverdb.networkUserName
318 @type:
319 function
320 @title:
321 $serverdb.networkUserName
322 @short:
323 Returns the username
324 @syntax:
325 <string> $serverdb.networkUserName(<network:string>)
326 @description:
327 Returns the username set for the network <network> if set.
328 @seealso:
329 [module:serverdb]ServerDB module documentation[/module]
330 */
331
332 SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_networkUserName, userName)
333
334 /*
335 @doc: serverdb.networkRealName
336 @type:
337 function
338 @title:
339 $serverdb.networkRealName
340 @short:
341 Returns the real name
342 @syntax:
343 <string> $serverdb.networkRealName(<network:string>)
344 @description:
345 Returns the real name set for the network <network> if set
346 @seealso:
347 [module:serverdb]ServerDB module documentation[/module]
348 */
349
350 SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_networkRealName, realName)
351
352 /*
353 @doc: serverdb.networkEncoding
354 @type:
355 function
356 @title:
357 $serverdb.networkEncoding
358 @short:
359 Returns the encoding
360 @syntax:
361 <string> $serverdb.networkEncoding(<network:string>)
362 @description:
363 Returns the encoding used for the network <network> for server specific messages, like channel and nick names, if set
364 @seealso:
365 [module:serverdb]ServerDB module documentation[/module]
366 */
367
368 SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_networkEncoding, encoding)
369
370 /*
371 @doc: serverdb.networkTextEncoding
372 @type:
373 function
374 @title:
375 $serverdb.networkTextEncoding
376 @short:
377 Returns the encoding
378 @syntax:
379 <string> $serverdb.networkTextEncoding(<network:string>)
380 @description:
381 Returns the encoding used for the network <network> for text messages, if set
382 @seealso:
383 [module:serverdb]ServerDB module documentation[/module]
384 */
385
386 SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_networkTextEncoding, textEncoding)
387
388 /*
389 @doc: serverdb.networkDescription
390 @type:
391 function
392 @title:
393 $serverdb.networkDescription
394 @short:
395 Returns the description
396 @syntax:
397 <string> $serverdb.networkDescription(<network:string>)
398 @description:
399 Returns the description set for the network <network> if set
400 @seealso:
401 [module:serverdb]ServerDB module documentation[/module]
402 */
403 SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_networkDescription, description)
404
405 /*
406 @doc: serverdb.networkConnectCommand
407 @type:
408 function
409 @title:
410 $serverdb.networkConnectCommand
411 @short:
412 Returns the connect command
413 @syntax:
414 <string> $serverdb.networkConnectCommand(<network:string>)
415 @description:
416 Returns the connect command set for the network <network> if set
417 @seealso:
418 [module:serverdb]ServerDB module documentation[/module]
419 */
420
421 SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_networkConnectCommand, onConnectCommand)
422
423 /*
424 @doc: serverdb.networkLoginCommand
425 @type:
426 function
427 @title:
428 $serverdb.networkLoginCommand
429 @short:
430 Returns the login command
431 @syntax:
432 <string> $serverdb.networkLoginCommand(<network:string>)
433 @description:
434 Returns the login command set for the network <network> if set
435 @seealso:
436 [module:serverdb]ServerDB module documentation[/module]
437 */
438
439 SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_networkLoginCommand, onLoginCommand)
440
441 /*
442 @doc: serverdb.networkName
443 @type:
444 function
445 @title:
446 $serverdb.networkName
447 @short:
448 Returns the name
449 @syntax:
450 <string> $serverdb.networkName(<network:string>)
451 @description:
452 Returns the name of the network <network>
453 @seealso:
454 [module:serverdb]ServerDB module documentation[/module]
455 */
456
457 SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_networkName, name)
458
459 /*
460 @doc: serverdb.networkJoinChannels
461 @type:
462 function
463 @title:
464 $serverdb.networkJoinChannels
465 @short:
466 Returns the list of autojoin channels
467 @syntax:
468 <string> $serverdb.networkJoinChannels(<network:string>)
469 @description:
470 Returns an array of autojoin channels and their relative passwords set for the network <network>[br]
471 Each item in the array is in the format <channel:string>:<password:string>
472 @seealso:
473 [module:serverdb]ServerDB module documentation[/module]
474 */
475
476 BEGIN_SERVERDB_GET_NETWORK_PROPERTY(serverdb_kvs_fnc_networkJoinChannels)
477
478 KviKvsArray * pArray = new KviKvsArray();
479
480 QStringList * pAutoJoinChannels = pNetwork->autoJoinChannelList();
481 if(pAutoJoinChannels)
482 {
483 kvs_uint_t idx = 0;
484 foreach(QString szEntry, *pAutoJoinChannels)
485 {
486 pArray->set(idx, new KviKvsVariant(szEntry));
487 idx++;
488 }
489 }
490
491 c->returnValue()->setArray(pArray);
492
493 END_SERVERDB_GET_NETWORK_PROPERTY
494
495 /*
496 @doc: serverdb.serverNickName
497 @type:
498 function
499 @title:
500 $serverdb.serverNickName
501 @short:
502 Returns the nickname
503 @syntax:
504 <string> $serverdb.serverNickName(<network:string>,<server:string>)
505 @description:
506 Returns the nickname set for the server <server> of the network <network> if set
507 @seealso:
508 [module:serverdb]ServerDB module documentation[/module]
509 */
510
511 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverNickName, nickName, setString)
512
513 /*
514 @doc: serverdb.serverUserName
515 @type:
516 function
517 @title:
518 $serverdb.serverUserName
519 @short:
520 Returns the username
521 @syntax:
522 <string> $serverdb.serverUserName(<network:string>,<server:string>)
523 @description:
524 Returns the username set for the server <server> of the network <network> if set
525 @seealso:
526 [module:serverdb]ServerDB module documentation[/module]
527 */
528
529 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverUserName, userName, setString)
530
531 /*
532 @doc: serverdb.serverRealName
533 @type:
534 function
535 @title:
536 $serverdb.serverRealName
537 @short:
538 Returns the real name
539 @syntax:
540 <string> $serverdb.serverRealName(<network:string>,<server:string>)
541 @description:
542 Returns the real name set for the server <server> of the network <network> if set
543 @seealso:
544 [module:serverdb]ServerDB module documentation[/module]
545 */
546
547 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverRealName, realName, setString)
548
549 /*
550 @doc: serverdb.serverEncoding
551 @type:
552 function
553 @title:
554 $serverdb.serverEncoding
555 @short:
556 Returns the encoding
557 @syntax:
558 <string> $serverdb.serverEncoding(<network:string>,<server:string>)
559 @description:
560 Returns the encoding used for the server <server> of the network <network> for server specific messages, like channel and nick names, if set
561 @seealso:
562 [module:serverdb]ServerDB module documentation[/module]
563 */
564
565 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverEncoding, encoding, setString)
566
567 /*
568 @doc: serverdb.serverTextEncoding
569 @type:
570 function
571 @title:
572 $serverdb.serverTextEncoding
573 @short:
574 Returns the encoding
575 @syntax:
576 <string> $serverdb.serverTextEncoding(<network:string>,<server:string>)
577 @description:
578 Returns the encoding used for the server <server> of the network <network> for server specific messages, like channel and nick names, if set
579 @seealso:
580 [module:serverdb]ServerDB module documentation[/module]
581 */
582
583 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverTextEncoding, textEncoding, setString)
584
585 /*
586 @doc: serverdb.serverDescription
587 @type:
588 function
589 @title:
590 $serverdb.serverDescription
591 @short:
592 Returns the description
593 @syntax:
594 <string> $serverdb.serverDescription(<network:string>,<server:string>)
595 @description:
596 Returns the description set for the server <server> of the network <network> if set
597 @seealso:
598 [module:serverdb]ServerDB module documentation[/module]
599 */
600
601 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverDescription, description, setString)
602
603 /*
604 @doc: serverdb.serverConnectCommand
605 @type:
606 function
607 @title:
608 $serverdb.serverConnectCommand
609 @short:
610 Returns the connect command
611 @syntax:
612 <string> $serverdb.serverConnectCommand(<network:string>,<server:string>)
613 @description:
614 Returns the connect command set for the server <server> of the network <network> if set
615 @seealso:
616 [module:serverdb]ServerDB module documentation[/module]
617 */
618
619 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverConnectCommand, onConnectCommand, setString)
620
621 /*
622 @doc: serverdb.serverLoginCommand
623 @type:
624 function
625 @title:
626 $serverdb.serverLoginCommand
627 @short:
628 Returns the login command
629 @syntax:
630 <string> $serverdb.serverLoginCommand(<network:string>,<server:string>)
631 @description:
632 Returns the login command set for the server <server> of the network <network> if set
633 @seealso:
634 [module:serverdb]ServerDB module documentation[/module]
635 */
636
637 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverLoginCommand, onLoginCommand, setString)
638
639 /*
640 @doc: serverdb.serverIp
641 @type:
642 function
643 @title:
644 $serverdb.serverIp
645 @short:
646 Returns the IP address
647 @syntax:
648 <string> $serverdb.serverIp(<network:string>,<server:string>)
649 @description:
650 Returns the IP address of the server <server> of the network <network>
651 @seealso:
652 [module:serverdb]ServerDB module documentation[/module]
653 */
654
655 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverIp, ip, setString)
656
657 /*
658 @doc: serverdb.serverId
659 @type:
660 function
661 @title:
662 $serverdb.serverId
663 @short:
664 Returns the ID
665 @syntax:
666 <string> $serverdb.serverId(<network:string>,<server:string>)
667 @description:
668 Returns the ID of the server <server> of the network <network>
669 @seealso:
670 [module:serverdb]ServerDB module documentation[/module]
671 */
672
673 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverId, id, setString)
674
675 /*
676 @doc: serverdb.serverPassword
677 @type:
678 function
679 @title:
680 $serverdb.serverPassword
681 @short:
682 Returns the password
683 @syntax:
684 <string> $serverdb.serverPassword(<network:string>,<server:string>)
685 @description:
686 Returns the password of the server <server> of the network <network> if set
687 @seealso:
688 [module:serverdb]ServerDB module documentation[/module]
689 */
690
691 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverPassword, password, setString)
692
693 /*
694 @doc: serverdb.serverPort
695 @type:
696 function
697 @title:
698 $serverdb.serverPort
699 @short:
700 Returns the port
701 @syntax:
702 <int> $serverdb.serverPort(<network:string>,<server:string>)
703 @description:
704 Returns the port of the server <server> of the network <network> if set
705 @seealso:
706 [module:serverdb]ServerDB module documentation[/module]
707 */
708
709 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverPort, port, setInteger)
710
711 /*
712 @doc: serverdb.isAutoConnect
713 @type:
714 function
715 @title:
716 $serverdb.isAutoConnect
717 @short:
718 Returns the autoconnect status
719 @syntax:
720 <bool> $serverdb.isAutoConnect(<network:string>,<server:string>)
721 @description:
722 Returns true if the server <server> of the network <network> if set to autoconnect, false otherwise
723 @seealso:
724 [module:serverdb]ServerDB module documentation[/module]
725 */
726
727 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverAutoConnect, autoConnect, setBoolean)
728
729 /*
730 @doc: serverdb.isIPv6
731 @type:
732 function
733 @title:
734 $serverdb.isIPv6
735 @short:
736 Returns the IPv6 status
737 @syntax:
738 <bool> $serverdb.isIPv6(<network:string>,<server:string>)
739 @description:
740 Returns true if the server <server> of the network <network> if set to connect using IPv6 sockets, false otherwise
741 @seealso:
742 [module:serverdb]ServerDB module documentation[/module]
743 */
744
745 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverIPv6, isIPv6, setBoolean)
746
747 /*
748 @doc: serverdb.isSSL
749 @type:
750 function
751 @title:
752 $serverdb.isSSL
753 @short:
754 Returns the SSL status
755 @syntax:
756 <bool> $serverdb.isSSL(<network:string>,<server:string>)
757 @description:
758 Returns true if the server <server> of the network <network> if set to connect using SSL (Secure Socket Layer) sockets, false otherwise
759 @seealso:
760 [module:serverdb]ServerDB module documentation[/module]
761 */
762
763 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverSSL, useSSL, setBoolean)
764
765 /*
766 @doc: serverdb.cacheIp
767 @type:
768 function
769 @title:
770 $serverdb.cacheIp
771 @short:
772 Returns the cache-ip status
773 @syntax:
774 <bool> $serverdb.cacheIp(<network:string>,<server:string>)
775 @description:
776 Returns true if KVIrc is set to cache the IP of the server <server> of the network <network>, false otherwise
777 @seealso:
778 [module:serverdb]ServerDB module documentation[/module]
779 */
780
781 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverCacheIp, cacheIp, setBoolean)
782
783 /*
784 @doc: serverdb.favorite
785 @type:
786 function
787 @title:
788 $serverdb.favorite
789 @short:
790 Returns if the server is favorited
791 @syntax:
792 <bool> $serverdb.favorite(<network:string>,<server:string>)
793 @description:
794 Returns true if KVIrc has the server set to a favorite, false otherwise
795 */
796
797 SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverFavorite, favorite, setBoolean)
798
799 /*
800 @doc: serverdb.serverJoinChannels
801 @type:
802 function
803 @title:
804 $serverdb.serverJoinChannels
805 @short:
806 Returns the list of autojoin channels
807 @syntax:
808 <array> $serverdb.serverJoinChannels(<network:string>,<server:string>)
809 @description:
810 Returns an array containing the autojoin channels and their relative passwords set for the server <server> of the network <network>[br]
811 Each item in the array is in the format channel_name:password
812 @seealso:
813 [module:serverdb]ServerDB module documentation[/module]
814 */
815 BEGIN_SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverJoinChannels)
816
817 KviKvsArray * pArray = new KviKvsArray();
818
819 QStringList * pAutoJoinChannels = pServer->autoJoinChannelList();
820 if(pAutoJoinChannels)
821 {
822 kvs_uint_t idx = 0;
823 foreach(QString szEntry, *pAutoJoinChannels)
824 {
825 pArray->set(idx, new KviKvsVariant(szEntry));
826 idx++;
827 }
828 }
829
830 c->returnValue()->setArray(pArray);
831
832 END_SERVERDB_GET_SERVER_PROPERTY
833
834 /*
835 @doc: serverdb.addNetwork
836 @type:
837 command
838 @title:
839 serverdb.addNetwork
840 @short:
841 Adds a network
842 @syntax:
843 serverdb.addNetwork <string:network name>
844 @description:
845 Adds the specified network <network name> to the DB.[br]
846 If the network already exists, an error is printed unless the -q switch is used.
847 @switches:
848 !sw: -a | --autoconnect
849 Autoconnect this network at KVIrc start.
850 @examples:
851 [example]
852 if(![fnc]$serverdb.networkExists[/fnc](freenode)) serverdb.addNetwork -q freenode
853 [/example]
854 @seealso:
855 [module:serverdb]ServerDB module documentation[/module]
856 */
857
serverdb_kvs_cmd_addNetwork(KviKvsModuleCommandCall * c)858 static bool serverdb_kvs_cmd_addNetwork(KviKvsModuleCommandCall * c)
859 {
860 QString szNetName, szNetwork;
861
862 KVSM_PARAMETERS_BEGIN(c)
863 KVSM_PARAMETER("network_name", KVS_PT_STRING, 0, szNetName)
864 KVSM_PARAMETERS_END(c)
865
866 if(szNetName.isEmpty())
867 {
868 c->error(__tr2qs_ctx("You must provide the network name as parameter", "serverdb"));
869 return false;
870 }
871
872 KviIrcNetwork * pNetwork = g_pServerDataBase->findNetwork(szNetName);
873 if(pNetwork)
874 {
875 if(c->switches()->find('q', "quiet"))
876 return true;
877 c->error(__tr2qs_ctx("The network specified already exists", "serverdb"));
878 return false;
879 }
880
881 pNetwork = new KviIrcNetwork(szNetName);
882 if(c->switches()->find('a', "autoconnect"))
883 pNetwork->setAutoConnect(true);
884
885 g_pServerDataBase->addNetwork(pNetwork);
886 return true;
887 }
888
889 /*
890 @doc: serverdb.addServer
891 @type:
892 command
893 @title:
894 serverdb.addServer
895 @short:
896 Adds a server
897 @syntax:
898 serverdb.addServer [switches] <network:string> <server:string>
899 @description:
900 Adds the server <server> to the network <network>.
901 @switches:
902 !sw: -a | --autoconnect
903 Autoconnect this server at KVIrc start.[br]
904
905 !sw: -c | --cache-ip
906 Caches the server IP at first connect to save bandwidth for future connects.[br]
907
908 !sw: -f | --favorite
909 Sets the server as a favorite.[br]
910
911 !sw: -i | --ipv6
912 Use IPv6 socket to connect to the server.[br]
913
914 !sw: -p=<port> | --port=<port>
915 Use the port <port> to connect to the server.[br]
916
917 !sw: -q | --quiet
918 Do not print errors if the server already exist.[br]
919
920 !sw: -s | --ssl
921 Use SSL (Secure Socket Layer) socket to connect to the server.[br]
922
923 !sw: -w=<password> | --password=<password>
924 Use password <password> to connect to the server.
925 @examples:
926 [example]
927 [comment]Sets the nickname HelLViS69 for the server irc.freenode.net[/comment][br]
928 serverdb.setNickName -s irc.freenode.net HelLViS69
929 [/example]
930 @seealso:
931 [module:serverdb]ServerDB module documentation[/module]
932 */
933
serverdb_kvs_cmd_addServer(KviKvsModuleCommandCall * c)934 static bool serverdb_kvs_cmd_addServer(KviKvsModuleCommandCall * c)
935 {
936 QString szNetwork, szServer;
937
938 KVSM_PARAMETERS_BEGIN(c)
939 KVSM_PARAMETER("network_name", KVS_PT_STRING, 0, szNetwork)
940 KVSM_PARAMETER("server_name", KVS_PT_STRING, 0, szServer)
941 KVSM_PARAMETERS_END(c)
942
943 if(szNetwork.isEmpty())
944 {
945 c->error(__tr2qs_ctx("You must provide the network name as parameter", "serverdb"));
946 return false;
947 }
948
949 if(szServer.isEmpty())
950 {
951 c->error(__tr2qs_ctx("You must provide the server name as parameter", "serverdb"));
952 return false;
953 }
954
955 KviIrcNetwork * pRecord = g_pServerDataBase->findNetwork(szNetwork);
956 if(!pRecord)
957 {
958 // FIXME: default to orphan servers
959 c->error(__tr2qs_ctx("The specified network doesn't exist", "serverdb"));
960 return false;
961 }
962
963 KviIrcServer * pServer = new KviIrcServer();
964 pServer->setHostName(szServer);
965
966 KviIrcServer * pServerRecord = pRecord->findServer(pServer);
967 if(pServerRecord)
968 {
969 delete pServer;
970 if(c->switches()->find('q', "quiet"))
971 return true;
972 c->error(__tr2qs_ctx("The specified server already exists", "serverdb"));
973 return false;
974 }
975
976 if(c->switches()->find('a', "autoconnect"))
977 pServer->setAutoConnect(true);
978 if(c->switches()->find('c', "cache-ip"))
979 pServer->setCacheIp(true);
980 if(c->switches()->find('f', "favorite"))
981 pServer->setFavorite(true);
982 if(c->switches()->find('i', "ipv6"))
983 pServer->setIPv6(true);
984 if(c->switches()->find('s', "ssl"))
985 pServer->setUseSSL(true);
986
987 QString tmp;
988
989 if(c->switches()->getAsStringIfExisting('p', "port", tmp))
990 {
991 bool bOk;
992 unsigned int uPort = tmp.toInt(&bOk);
993 if(!bOk)
994 uPort = 6667;
995 pServer->setPort(uPort);
996 }
997
998 if(c->switches()->getAsStringIfExisting('w', "password", tmp))
999 pServer->setPassword(tmp);
1000
1001 pRecord->insertServer(pServer);
1002
1003 return true;
1004 }
1005
1006 #define SERVERDB_SET_NETWORK_PROPERTY(__functionName, __callName) \
1007 static bool __functionName(KviKvsModuleCommandCall * c) \
1008 { \
1009 QString szName, szPropertyValue; \
1010 \
1011 KVSM_PARAMETERS_BEGIN(c) \
1012 KVSM_PARAMETER("name", KVS_PT_STRING, 0, szName) \
1013 KVSM_PARAMETER("property", KVS_PT_STRING, KVS_PF_APPENDREMAINING, szPropertyValue) \
1014 KVSM_PARAMETERS_END(c) \
1015 \
1016 if(szName.isEmpty()) \
1017 { \
1018 c->error(__tr2qs_ctx("You must provide the network name as parameter", "serverdb")); \
1019 return false; \
1020 } \
1021 \
1022 KviIrcNetwork * pNetwork = g_pServerDataBase->findNetwork(szName); \
1023 if(!pNetwork) \
1024 { \
1025 if(c->switches()->find('q', "quiet")) \
1026 return true; \
1027 c->error(__tr2qs_ctx("The specified network doesn't exist", "serverdb")); \
1028 return false; \
1029 } \
1030 \
1031 pNetwork->__callName(szPropertyValue); \
1032 \
1033 return true; \
1034 }
1035
1036 #define SERVERDB_SET_SERVER_PROPERTY(__functionName, __callName) \
1037 static bool __functionName(KviKvsModuleCommandCall * c) \
1038 { \
1039 QString szNetName, szServName, szPropertyValue; \
1040 \
1041 KVSM_PARAMETERS_BEGIN(c) \
1042 KVSM_PARAMETER("network_name", KVS_PT_STRING, 0, szNetName) \
1043 KVSM_PARAMETER("server_name", KVS_PT_STRING, 0, szServName) \
1044 KVSM_PARAMETER("property", KVS_PT_STRING, KVS_PF_APPENDREMAINING, szPropertyValue) \
1045 KVSM_PARAMETERS_END(c) \
1046 \
1047 if(szNetName.isEmpty()) \
1048 { \
1049 c->error(__tr2qs_ctx("You must provide the network name as parameter", "serverdb")); \
1050 return false; \
1051 } \
1052 \
1053 if(szServName.isEmpty()) \
1054 { \
1055 c->error(__tr2qs_ctx("You must provide the server name as parameter", "serverdb")); \
1056 return false; \
1057 } \
1058 \
1059 KviIrcNetwork * pRecord = g_pServerDataBase->findNetwork(szNetName); \
1060 if(!pRecord) \
1061 { \
1062 if(c->switches()->find('q', "quiet")) \
1063 return true; \
1064 c->error(__tr2qs_ctx("The specified network doesn't exist", "serverdb")); \
1065 return false; \
1066 } \
1067 \
1068 KviIrcServer * pServer = pRecord->findServer(szServName); \
1069 if(!pServer) \
1070 { \
1071 if(c->switches()->find('q', "quiet")) \
1072 return true; \
1073 c->error(__tr2qs_ctx("The specified server doesn't exist", "serverdb")); \
1074 return false; \
1075 } \
1076 \
1077 pServer->__callName(szPropertyValue); \
1078 \
1079 return true; \
1080 }
1081
1082 /*
1083 @doc: serverdb.setNetworkNickName
1084 @type:
1085 command
1086 @title:
1087 serverdb.setNetworkNickName
1088 @short:
1089 Sets the nickname
1090 @syntax:
1091 serverdb.setNetworkNickName [switches] <name:string> <nick:string>
1092 @description:
1093 Sets the nickname <nick> for the specified network <name>.
1094 @switches:
1095 !sw: -q | --quiet
1096 Do not print errors if the network already exists.
1097 @examples:
1098 [example]
1099 [comment]Quietly sets the nickname HelLViS69 for the freenode network[/comment][br]
1100 serverdb.setNetworkNickName -q freenode HelLViS69
1101 [/example]
1102 @seealso:
1103 [module:serverdb]ServerDB module documentation[/module]
1104 */
1105
SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkNickName,setNickName)1106 SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkNickName, setNickName)
1107
1108 /*
1109 @doc: serverdb.setNetworkUserName
1110 @type:
1111 command
1112 @title:
1113 serverdb.setNetworkUserName
1114 @short:
1115 Sets the username
1116 @syntax:
1117 serverdb.setNetworkUserName [switches] <name:string> <username:string>
1118 @description:
1119 Sets the username <username> for the specified network <name>.
1120 @switches:
1121 !sw: -q | --quiet
1122 Do not print errors if the network already exists.
1123 @examples:
1124 [example]
1125 [comment]Quietly sets the username kvirc for the freenode network[/comment][br]
1126 serverdb.setNetworkUserName -q freenode kvirc
1127 [/example]
1128 @seealso:
1129 [module:serverdb]ServerDB module documentation[/module]
1130 */
1131
1132 SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkUserName, setUserName)
1133
1134 /*
1135 @doc: serverdb.setNetworkRealName
1136 @type:
1137 command
1138 @title:
1139 serverdb.setNetworkRealName
1140 @short:
1141 Sets the realn ame
1142 @syntax:
1143 serverdb.setNetworkRealName [switches] <name:string> <realname:string>
1144 @description:
1145 Sets the real name <realname> for the specified network <name>.
1146 @switches:
1147 !sw: -q | --quiet
1148 Do not print errors if the network already exists.
1149 @examples:
1150 [example]
1151 [comment]Quietly sets the real name KVIrc 4.0 for the freenode network[/comment][br]
1152 serverdb.setNetworkRealName -q freenode KVIrc 4.0
1153 [/example]
1154 @seealso:
1155 [module:serverdb]ServerDB module documentation[/module]
1156 */
1157
1158 SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkRealName, setRealName)
1159
1160 /*
1161 @doc: serverdb.setNetworkEncoding
1162 @type:
1163 command
1164 @title:
1165 serverdb.setNetworkEncoding
1166 @short:
1167 Sets the encoding
1168 @syntax:
1169 serverdb.setNetworkEncoding [switches] <name:string> <encoding:string>
1170 @description:
1171 Sets the encoding <encoding> for the specified network <name>. This encoding will be used for server-specific
1172 text, like channel names and nicknames.
1173 @switches:
1174 !sw: -q | --quiet
1175 Do not print errors if the network already exists.
1176 @examples:
1177 [example]
1178 [comment]Quietly sets the encoding UTF-8 for the freenode network[/comment][br]
1179 serverdb.setNetworkEncoding -q freenode UTF-8
1180 [/example]
1181 @seealso:
1182 [module:serverdb]ServerDB module documentation[/module]
1183 */
1184
1185 SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkEncoding, setEncoding)
1186
1187 /*
1188 @doc: serverdb.setNetworkTextEncoding
1189 @type:
1190 command
1191 @title:
1192 serverdb.setNetworkTextEncoding
1193 @short:
1194 Sets the encoding
1195 @syntax:
1196 serverdb.setNetworkTextEncoding [switches] <name:string> <encoding:string>
1197 @description:
1198 Sets the encoding <encoding> for the specified network <name>. This encoding will be used for text messages.
1199 @switches:
1200 !sw: -q | --quiet
1201 Do not print errors if the network already exists.
1202 @examples:
1203 [example]
1204 [comment]Quietly sets the text encoding UTF-8 for the freenode network[/comment][br]
1205 serverdb.setNetworkTextEncoding -q freenode UTF-8
1206 [/example]
1207 @seealso:
1208 [module:serverdb]ServerDB module documentation[/module]
1209 */
1210
1211 SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkTextEncoding, setTextEncoding)
1212
1213 /*
1214 @doc: serverdb.setNetworkDescription
1215 @type:
1216 command
1217 @title:
1218 serverdb.setNetworkDescription
1219 @short:
1220 Sets the description
1221 @syntax:
1222 serverdb.setNetworkDescription [switches] <name:string> <description:string>
1223 @description:
1224 Sets the description <description> for the specified network <name>.
1225 @switches:
1226 !sw: -q | --quiet
1227 Do not print errors if the network already exists.
1228 @examples:
1229 [example]
1230 [comment]Quietly sets the description for the freenode network[/comment][br]
1231 serverdb.setNetworkDescription -q freenode The FOSS Network
1232 [/example]
1233 @seealso:
1234 [module:serverdb]ServerDB module documentation[/module]
1235 */
1236
1237 SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkDescription, setDescription)
1238
1239 /*
1240 @doc: serverdb.setNetworkConnectCommand
1241 @type:
1242 command
1243 @title:
1244 serverdb.setNetworkConnectCommand
1245 @short:
1246 Sets the connect command
1247 @syntax:
1248 serverdb.setNetworkConnectCommand [switches] <name:string> <command:string>
1249 @description:
1250 Sets the command <command> to run on connect for the specified network <name>.
1251 @switches:
1252 !sw: -q | --quiet
1253 Do not print errors if the network already exists.
1254 @examples:
1255 [example]
1256 [comment]Quietly sets the connect command for the freenode network[/comment][br]
1257 serverdb.setNetworkConnectCommand -q freenode ns identify HelLViS69 foobar
1258 [/example]
1259 @seealso:
1260 [module:serverdb]ServerDB module documentation[/module]
1261 */
1262
1263 SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkConnectCommand, setOnConnectCommand)
1264
1265 /*
1266 @doc: serverdb.setNetworkLoginCommand
1267 @type:
1268 command
1269 @title:
1270 serverdb.setNetworkLoginCommand
1271 @short:
1272 Sets the login command
1273 @syntax:
1274 serverdb.setNetworkLoginCommand [switches] <name:string> <command:string>
1275 @description:
1276 Sets the command <command> to run on login for the specified network <name>.
1277 @switches:
1278 !sw: -q | --quiet
1279 Do not print errors if the network already exists.
1280 @examples:
1281 [example]
1282 [comment]Quietly sets the login command for the freenode network[/comment][br]
1283 serverdb.setNetworkLoginCommand -q freenode join #KVIrc
1284 [/example]
1285 @seealso:
1286 [module:serverdb]ServerDB module documentation[/module]
1287 */
1288
1289 SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkLoginCommand, setOnLoginCommand)
1290
1291 /*
1292 @doc: serverdb.setNetworkJoinChannels
1293 @type:
1294 command
1295 @title:
1296 serverdb.setNetworkJoinChannels
1297 @short:
1298 Sets the autojoin channels list
1299 @syntax:
1300 serverdb.setNetworkJoinChannels <name:string> <channel_list:string>
1301 @description:
1302 Sets the autojoin channels list for the specified network <name>.[br]
1303 Items in the list have to be separated by a comma, and each item has to be in the form <channel:string>:<password:string>
1304 @examples:
1305 [example]
1306 [comment]Set two autojoin channels for freenode[/comment][br]
1307 serverdb.setNetworkJoinChannels freenode #kvirc:,#secretchan:password
1308 [/example]
1309 @seealso:
1310 [module:serverdb]ServerDB module documentation[/module]
1311 */
1312
1313 SERVERDB_SET_NETWORK_PROPERTY(serverdb_kvs_cmd_setNetworkJoinChannels, setAutoJoinChannelList)
1314
1315 /*
1316 @doc: serverdb.setServerNickName
1317 @type:
1318 command
1319 @title:
1320 serverdb.setServerNickName
1321 @short:
1322 Sets the nickname
1323 @syntax:
1324 serverdb.setServerNickName [switches] <network:string> <server:string> <nick:string>
1325 @description:
1326 Sets the nickname <nick> for the specified server <server> in the network <network>.
1327 @switches:
1328 !sw: -q | --quiet
1329 Do not print errors if the server already exists.
1330 @examples:
1331 [example]
1332 [comment]Quietly sets the nickname HelLViS69 for the freenode network[/comment][br]
1333 serverdb.setServerNickName -q irc.freenode.net HelLViS69
1334 [/example]
1335 @seealso:
1336 [module:serverdb]ServerDB module documentation[/module]
1337 */
1338
1339 SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerNickName, setNickName)
1340
1341 /*
1342 @doc: serverdb.setServerUserName
1343 @type:
1344 command
1345 @title:
1346 serverdb.setServerUserName
1347 @short:
1348 Sets the username
1349 @syntax:
1350 serverdb.setServerUserName [switches] <network:string> <server:string> <username:string>
1351 @description:
1352 Sets the username <username> for the specified server <server> in the network <network>.
1353 @switches:
1354 !sw: -q | --quiet
1355 Do not print errors if the server already exists.
1356 @examples:
1357 [example]
1358 [comment]Quietly sets the username kvirc for the freenode server[/comment][br]
1359 serverdb.setServerUserName -q irc.freenode.net kvirc
1360 [/example]
1361 @seealso:
1362 [module:serverdb]ServerDB module documentation[/module]
1363 */
1364
1365 SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerUserName, setUserName)
1366
1367 /*
1368 @doc: serverdb.setServerRealName
1369 @type:
1370 command
1371 @title:
1372 serverdb.setServerRealName
1373 @short:
1374 Sets the real name
1375 @syntax:
1376 serverdb.setServerRealName [switches] <network:string> <server:string> <realname:string>
1377 @description:
1378 Sets the real name <realname> for the specified server <server> in the network <network>.
1379 @switches:
1380 !sw: -q | --quiet
1381 Do not print errors if the server already exists.
1382 @examples:
1383 [example]
1384 [comment]Quietly sets the real name KVIrc 4.0 for the freenode server[/comment][br]
1385 serverdb.setServerRealName -q irc.freenode.net KVIrc 4.0
1386 [/example]
1387 @seealso:
1388 [module:serverdb]ServerDB module documentation[/module]
1389 */
1390
1391 SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerRealName, setRealName)
1392
1393 /*
1394 @doc: serverdb.setServerEncoding
1395 @type:
1396 command
1397 @title:
1398 serverdb.setServerEncoding
1399 @short:
1400 Sets the encoding
1401 @syntax:
1402 serverdb.setServerEncoding [switches] <network:string> <server:string> <encoding:string>
1403 @description:
1404 Sets the encoding <encoding> for the specified server <server> in the network <network>. This encoding will be used for server-specific
1405 text, like channel names and nicknames.
1406 @switches:
1407 !sw: -q | --quiet
1408 Do not print errors if the server already exists.
1409 @examples:
1410 [example]
1411 [comment]Quietly sets the encoding UTF-8 for the irc.freenode.net server[/comment][br]
1412 serverdb.setServerEncoding -q irc.freenode.net UTF-8
1413 [/example]
1414 @seealso:
1415 [module:serverdb]ServerDB module documentation[/module]
1416 */
1417
1418 SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerEncoding, setEncoding)
1419
1420 /*
1421 @doc: serverdb.setServerTextEncoding
1422 @type:
1423 command
1424 @title:
1425 serverdb.setServerTextEncoding
1426 @short:
1427 Sets the text encoding
1428 @syntax:
1429 serverdb.setServerTextEncoding [switches] <network:string> <server:string> <encoding:string>
1430 @description:
1431 Sets the encoding <encoding> for the specified server <server> in the network <network>. This encoding will be used for text messages.
1432 @switches:
1433 !sw: -q | --quiet
1434 Do not print errors if the server already exists.
1435 @examples:
1436 [example]
1437 [comment]Quietly sets the text encoding UTF-8 for the irc.freenode.net server[/comment][br]
1438 serverdb.setServerTextEncoding -q irc.freenode.net UTF-8
1439 [/example]
1440 @seealso:
1441 [module:serverdb]ServerDB module documentation[/module]
1442 */
1443
1444 SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerTextEncoding, setTextEncoding)
1445
1446 /*
1447 @doc: serverdb.setServerDescription
1448 @type:
1449 command
1450 @title:
1451 serverdb.setServerDescription
1452 @short:
1453 Sets the description
1454 @syntax:
1455 serverdb.setServerDescription [switches] <network:string> <server:string> <description:string>
1456 @description:
1457 Sets the description <description> for the specified server <server> in the network <network>.
1458 @switches:
1459 !sw: -q | --quiet
1460 Do not print errors if the server already exists.
1461 @examples:
1462 [example]
1463 [comment]Quietly sets the description for the freenode server[/comment][br]
1464 serverdb.setServerDescription -q irc.freenode.net The FOSS Network
1465 [/example]
1466 @seealso:
1467 [module:serverdb]ServerDB module documentation[/module]
1468 */
1469
1470 SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerDescription, setDescription)
1471
1472 /*
1473 @doc: serverdb.setServerConnectCommand
1474 @type:
1475 command
1476 @title:
1477 serverdb.setServerConnectCommand
1478 @short:
1479 Sets the connect command
1480 @syntax:
1481 serverdb.setServerConnectCommand [switches] <network:string> <server:string> <command:string>
1482 @description:
1483 Sets the command <command> to run on connect for the specified server <server> in the network <network>.
1484 @switches:
1485 !sw: -q | --quiet
1486 Do not print errors if the server already exists.
1487 @examples:
1488 [example]
1489 [comment]Quietly sets the connect command for the freenode server[/comment][br]
1490 serverdb.setServerConnectCommand -q irc.freenode.net ns identify HelLViS69 foobar
1491 [/example]
1492 @seealso:
1493 [module:serverdb]ServerDB module documentation[/module]
1494 */
1495
1496 SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerConnectCommand, setOnConnectCommand)
1497
1498 /*
1499 @doc: serverdb.setServerLoginCommand
1500 @type:
1501 command
1502 @title:
1503 serverdb.setServerLoginCommand
1504 @short:
1505 Sets the login command
1506 @syntax:
1507 serverdb.setServerLoginCommand [switches] <network:string> <server:string> <command:string>
1508 @description:
1509 Sets the command <command> to run on login for the specified server <server> in the network <network>.
1510 @switches:
1511 !sw: -q | --quiet
1512 Do not print errors if the server already exists.
1513 @examples:
1514 [example]
1515 [comment]Quietly sets the login command for the freenode server[/comment][br]
1516 serverdb.setServerLoginCommand -q irc.freenode.net join #KVIrc
1517 [/example]
1518 @seealso:
1519 [module:serverdb]ServerDB module documentation[/module]
1520 */
1521
1522 SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerLoginCommand, setOnLoginCommand)
1523
1524 /*
1525 @doc: serverdb.setServerJoinChannels
1526 @type:
1527 command
1528 @title:
1529 serverdb.setServerJoinChannels
1530 @short:
1531 Sets the autojoin channels list
1532 @syntax:
1533 serverdb.setServerJoinChannels <network:string> <server:string> <channel_list:string>
1534 @description:
1535 Sets the autojoin channels list for the specified server <server> in the network <network>.[br]
1536 Items in the list have to be separated by a comma, and each item has to be in the form <channel:string>:<password:string>
1537 @examples:
1538 [example]
1539 [comment]Set two autojoin channels for irc.freenode.net[/comment][br]
1540 serverdb.setServerJoinChannels irc.freenode.net #kvirc:,#secretchan:password
1541 [/example]
1542 @seealso:
1543 [module:serverdb]ServerDB module documentation[/module]
1544 */
1545
1546 SERVERDB_SET_SERVER_PROPERTY(serverdb_kvs_cmd_setServerJoinChannels, setAutoJoinChannelList)
1547
1548 static bool serverdb_module_init(KviModule * m)
1549 {
1550 /*
1551 KVSM_REGISTER_SIMPLE_COMMAND(m,"updateList",serverdb_kvs_cmd_updateList);
1552 */
1553
1554 KVSM_REGISTER_FUNCTION(m, "favorite", serverdb_kvs_fnc_serverFavorite);
1555 KVSM_REGISTER_FUNCTION(m, "cacheIp", serverdb_kvs_fnc_serverCacheIp);
1556 KVSM_REGISTER_FUNCTION(m, "networkConnectCommand", serverdb_kvs_fnc_networkConnectCommand);
1557 KVSM_REGISTER_FUNCTION(m, "networkDescription", serverdb_kvs_fnc_networkDescription);
1558 KVSM_REGISTER_FUNCTION(m, "networkEncoding", serverdb_kvs_fnc_networkEncoding);
1559 KVSM_REGISTER_FUNCTION(m, "networkTextEncoding", serverdb_kvs_fnc_networkTextEncoding);
1560 KVSM_REGISTER_FUNCTION(m, "networkLoginCommand", serverdb_kvs_fnc_networkLoginCommand);
1561 KVSM_REGISTER_FUNCTION(m, "networkName", serverdb_kvs_fnc_networkName);
1562 KVSM_REGISTER_FUNCTION(m, "networkNickName", serverdb_kvs_fnc_networkNickName);
1563 KVSM_REGISTER_FUNCTION(m, "networkRealName", serverdb_kvs_fnc_networkRealName);
1564 KVSM_REGISTER_FUNCTION(m, "networkUserName", serverdb_kvs_fnc_networkUserName);
1565 KVSM_REGISTER_FUNCTION(m, "networkJoinChannels", serverdb_kvs_fnc_networkJoinChannels);
1566 KVSM_REGISTER_FUNCTION(m, "serverConnectCommand", serverdb_kvs_fnc_serverConnectCommand);
1567 KVSM_REGISTER_FUNCTION(m, "serverDescription", serverdb_kvs_fnc_serverDescription);
1568 KVSM_REGISTER_FUNCTION(m, "serverEncoding", serverdb_kvs_fnc_serverEncoding);
1569 KVSM_REGISTER_FUNCTION(m, "serverTextEncoding", serverdb_kvs_fnc_serverTextEncoding);
1570 KVSM_REGISTER_FUNCTION(m, "serverId", serverdb_kvs_fnc_serverId)
1571 KVSM_REGISTER_FUNCTION(m, "serverIp", serverdb_kvs_fnc_serverIp)
1572 KVSM_REGISTER_FUNCTION(m, "serverLoginCommand", serverdb_kvs_fnc_serverLoginCommand);
1573 KVSM_REGISTER_FUNCTION(m, "serverNickName", serverdb_kvs_fnc_serverNickName);
1574 KVSM_REGISTER_FUNCTION(m, "serverPassword", serverdb_kvs_fnc_serverPassword);
1575 KVSM_REGISTER_FUNCTION(m, "serverPort", serverdb_kvs_fnc_serverPort);
1576 KVSM_REGISTER_FUNCTION(m, "serverRealName", serverdb_kvs_fnc_serverRealName);
1577 KVSM_REGISTER_FUNCTION(m, "serverUserName", serverdb_kvs_fnc_serverUserName);
1578 KVSM_REGISTER_FUNCTION(m, "serverJoinChannels", serverdb_kvs_fnc_serverJoinChannels);
1579 KVSM_REGISTER_FUNCTION(m, "isAutoConnect", serverdb_kvs_fnc_serverAutoConnect);
1580 KVSM_REGISTER_FUNCTION(m, "isIPv6", serverdb_kvs_fnc_serverIPv6);
1581 KVSM_REGISTER_FUNCTION(m, "isSSL", serverdb_kvs_fnc_serverSSL);
1582 KVSM_REGISTER_FUNCTION(m, "networkExists", serverdb_kvs_fnc_networkExists);
1583 KVSM_REGISTER_FUNCTION(m, "serverExists", serverdb_kvs_fnc_serverExists);
1584
1585 KVSM_REGISTER_SIMPLE_COMMAND(m, "addNetwork", serverdb_kvs_cmd_addNetwork);
1586 KVSM_REGISTER_SIMPLE_COMMAND(m, "addServer", serverdb_kvs_cmd_addServer);
1587 KVSM_REGISTER_SIMPLE_COMMAND(m, "setNetworkConnectCommand", serverdb_kvs_cmd_setNetworkConnectCommand);
1588 KVSM_REGISTER_SIMPLE_COMMAND(m, "setNetworkEncoding", serverdb_kvs_cmd_setNetworkEncoding);
1589 KVSM_REGISTER_SIMPLE_COMMAND(m, "setNetworkTextEncoding", serverdb_kvs_cmd_setNetworkTextEncoding);
1590 KVSM_REGISTER_SIMPLE_COMMAND(m, "setNetworkDescription", serverdb_kvs_cmd_setNetworkDescription);
1591 KVSM_REGISTER_SIMPLE_COMMAND(m, "setNetworkLoginCommand", serverdb_kvs_cmd_setNetworkLoginCommand);
1592 KVSM_REGISTER_SIMPLE_COMMAND(m, "setNetworkNickName", serverdb_kvs_cmd_setNetworkNickName);
1593 KVSM_REGISTER_SIMPLE_COMMAND(m, "setNetworkRealName", serverdb_kvs_cmd_setNetworkRealName);
1594 KVSM_REGISTER_SIMPLE_COMMAND(m, "setNetworkUserName", serverdb_kvs_cmd_setNetworkUserName);
1595 KVSM_REGISTER_SIMPLE_COMMAND(m, "setNetworkJoinChannels", serverdb_kvs_cmd_setNetworkJoinChannels);
1596 KVSM_REGISTER_SIMPLE_COMMAND(m, "setServerConnectCommand", serverdb_kvs_cmd_setServerConnectCommand);
1597 KVSM_REGISTER_SIMPLE_COMMAND(m, "setServerEncoding", serverdb_kvs_cmd_setServerEncoding);
1598 KVSM_REGISTER_SIMPLE_COMMAND(m, "setServerTextEncoding", serverdb_kvs_cmd_setServerTextEncoding);
1599 KVSM_REGISTER_SIMPLE_COMMAND(m, "setServerDescription", serverdb_kvs_cmd_setServerDescription);
1600 KVSM_REGISTER_SIMPLE_COMMAND(m, "setServerLoginCommand", serverdb_kvs_cmd_setServerLoginCommand);
1601 KVSM_REGISTER_SIMPLE_COMMAND(m, "setServerNickName", serverdb_kvs_cmd_setServerNickName);
1602 KVSM_REGISTER_SIMPLE_COMMAND(m, "setServerRealName", serverdb_kvs_cmd_setServerRealName);
1603 KVSM_REGISTER_SIMPLE_COMMAND(m, "setServerUserName", serverdb_kvs_cmd_setServerUserName);
1604 KVSM_REGISTER_SIMPLE_COMMAND(m, "setServerJoinChannels", serverdb_kvs_cmd_setServerJoinChannels);
1605
1606 return true;
1607 }
1608
serverdb_module_cleanup(KviModule *)1609 static bool serverdb_module_cleanup(KviModule *)
1610 {
1611 return true;
1612 }
1613
serverdb_module_can_unload(KviModule *)1614 static bool serverdb_module_can_unload(KviModule *)
1615 {
1616 return true;
1617 }
1618
1619 KVIRC_MODULE(
1620 "ServerDB", // module name
1621 "4.0.0", // module version
1622 "Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org)", // author & (C)
1623 "IRC serverDB related functions",
1624 serverdb_module_init,
1625 serverdb_module_can_unload,
1626 0,
1627 serverdb_module_cleanup,
1628 "serverdb")
1629