summaryrefslogtreecommitdiffstats
path: root/src/kvirc/kvs/kvi_kvs_coresimplecommands_af.cpp
blob: 6eb820e99ce2c32c270605037ac5ea582b8b444a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
//=============================================================================
//
//   File : kvi_kvs_coresimplecommands_af.cpp
//   Created on Fri 31 Oct 2003 00:04:25 by Szymon Stefanek
//
//   This file is part of the KVIrc IRC client distribution
//   Copyright (C) 2003 Szymon Stefanek <pragma at kvirc dot net>
//
//   This program is FREE software. You can redistribute it and/or
//   modify it under the terms of the GNU General Public License
//   as published by the Free Software Foundation; either version 2
//   of the License, or (at your opinion) any later version.
//
//   This program is distributed in the HOPE that it will be USEFUL,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//   See the GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program. If not, write to the Free Software Foundation,
//   Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=============================================================================

#define __KVIRC__

#include "kvi_kvs_coresimplecommands.h"


#include "kvi_window.h"
#include "kvi_out.h"
#include "kvi_locale.h"
#include "kvi_app.h"
#include "kvi_options.h"
#include "kvi_ircview.h" // this is only for KviIrcView::NoTimestamp
#include "kvi_debugwindow.h"
#include "kvi_console.h"
#include "kvi_scriptbutton.h"
#include "kvi_iconmanager.h"

#include "kvi_kvs_popupmanager.h"
#include "kvi_kvs_eventmanager.h"
#include "kvi_kvs_kernel.h"
#include "kvi_kvs_object_controller.h"

#ifndef COMPILE_NO_X_BELL
	#include "kvi_xlib.h" // XBell : THIS SHOULD BE INCLUDED AS LAST!
	#include <unistd.h>   // for usleep();

	#ifdef COMPILE_USE_QT4
		#include <tqx11info_x11.h>
		#define get_xdisplay QX11Info::display
	#else
		#define get_xdisplay tqt_xdisplay
	#endif

#endif

#include "kvi_tal_tooltip.h"

// kvi_app.cpp
extern KviPointerHashTable<const char *,KviWindow> * g_pGlobalWindowDict;

namespace KviKvsCoreSimpleCommands
{
	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: admin
		@type:
			command
		@title:
			admin
		@syntax:
			admin [target server]
		@short:
			Requests the admin info from a server
		@description:
			Requests admin information from the specified server or the current server if no [target server] is specified.[br]
			This command is a [doc:rfc2821wrappers]RFC2821 command wrapper[/doc]; see that document for more information.[br]
	*/
	// RFC2821 wrapper

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: away
		@type:
			command
		@title:
			away
		@syntax:
			away [-a | --all-networks] [<reason:string>]
		@short:
			Puts you into 'away' state
		@switches:
			!sw: -a | --all-networks
			Set away on all networks
		@description:
			Puts you into 'away' state in the connection associated to the
			current [b]IRC context[/b].[br] This command is "server based";
			this means that the effects will be visible only after the
			server has acknowledged the change.[br]
			When you use this command, other people will know that you are 
			away from the keyboard, and they will know why you're not here.[br]
			To return from being away you must use [cmd]back[/cmd].[br]
			This command is [doc:connection_dependant_commands]connection dependant[/doc].[br]
		@examples:
			[example]
			away I'm asleep. Don't wake me up.
			[/example]
	*/

	KVSCSC(away)
	{
		TQString szReason;
		KVSCSC_PARAMETERS_BEGIN
			KVSCSC_PARAMETER("reason",KVS_PT_STRING,KVS_PF_OPTIONAL | KVS_PF_APPENDREMAINING,szReason)
		KVSCSC_PARAMETERS_END

		KVSCSC_REQUIRE_CONNECTION

		if(szReason.isEmpty())szReason = KVI_OPTION_STRING(KviOption_stringAwayMessage);
	
		if(KVSCSC_pSwitches->find('a',"all-networks"))
		{
			KviPointerHashTableIterator<const char *,KviWindow> it(*g_pGlobalWindowDict);
			while(KviWindow * wnd = it.current())
			{
				if(wnd->type()==KVI_WINDOW_TYPE_CONSOLE)
				{
					KviConsole* pConsole=(KviConsole*)wnd;
					if(pConsole->isConnected())
						pConsole->connection()->sendFmtData("AWAY :%s",
								pConsole->connection()->encodeText(szReason).data()
								);
				}
				++it;
			}
		} else  {
			KviTQCString szR = KVSCSC_pConnection->encodeText(szReason);
			if(!(KVSCSC_pConnection->sendFmtData("AWAY :%s",szR.data())))
				return KVSCSC_pContext->warningNoIrcConnection();
		}
	
		return true;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: back
		@type:
			command
		@title:
			back
		@syntax:
			back [-a | --all-networks]
		@switches:
			!sw: -a | --all-networks
			Set back on all networks
		@short:
			Allows you to return from being away
		@description:
			Using this command makes you return from being [cmd]away[/cmd] in the connection associated to the
			current [b]IRC context[/b].[br] This command is "server based";
			this means that the effects will be visible only after the
			server has acknowledged the change.[br]
			This command is [doc:connection_dependant_commands]connection dependant[/doc].[br]
		@examples:
			[example]
			back
			[/example]
	*/

	KVSCSC(back)
	{
		
		if(KVSCSC_pSwitches->find('a',"all-networks"))
		{
			KviPointerHashTableIterator<const char *,KviWindow> it(*g_pGlobalWindowDict);
			while(KviWindow * wnd = it.current())
			{
				if(wnd->type()==KVI_WINDOW_TYPE_CONSOLE)
				{
					KviConsole* pConsole=(KviConsole*)wnd;
					if(pConsole->isConnected())
						pConsole->connection()->sendFmtData("AWAY");
				}
				++it;
			}
		} else {
			KVSCSC_REQUIRE_CONNECTION
	
			if(!(KVSCSC_pConnection->sendFmtData("AWAY")))
				return KVSCSC_pContext->warningNoIrcConnection();
		}
	
		return true;
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: ban
		@type:
			command
		@title:
			ban
		@syntax:
			ban <mask_list>
		@short:
			Sets ban masks for the channel
		@description:
			Sets the ban masks specified in the <mask_list>,
			which is a comma separated list of nicknames. 
			This command works only if executed in a channel window.
			The command is translated to a set of MODE messages containing
			a variable number of +b flags.
			This command is [doc:connection_dependant_commands]connection dependant[/doc].
		@examples:
			[example]
			ban Maxim,Gizmo!*@*,*!root@*
			[/example]
		@seealso:
			[cmd]op[/cmd],
			[cmd]deop[/cmd],
			[cmd]voice[/cmd],
			[cmd]devoice[/cmd],
			[cmd]unban[/cmd]
	*/

	KVSCSC(ban)
	{
		return multipleModeCommand(__pContext,__pParams,__pSwitches,'+','b');
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
	 	@doc: beep
		@type:
			command
		@title:
			beep
		@syntax:
			beep [-p=<pitch:uint>] [-d=<duration:uint>] [-s] [volume:uint]
		@short:
			Beep beep!
		@switches:
			!sw: -p=<pitch:uint> | --pitch=<pitch:uint>
			Sets the bell to the specified pitch, if possible
			!sw: -d=<duration:uint> | --duration=<duration:uint>
			Sets the duration of the beep to <duration> milliseconds
			!sw: -s | --synchronous
			Causes KVIrc to wait for completion of the beeping before
			returning from this command
		@description:
			Beeps (when possible :D)[br]
			...[br]
			No , really..[br]
			This command rings the bell on the keyboard (the PC speaker).
			The volume must be in range 0-100; the default is 100.[br]
			The pitch is specified in Hz and must be positive.[br]
			The duration is specified in milliseconds.[br]
			An invalid (or unspecified) pitch, volume or duration
			makes KVIrc to use the default values set by the system.[br]
			The duration of the bell is only indicative and
			can be shortened by a subsequent call to /beep (that
			will override the currently playing one).[br]
			On Windows, the bell is always synchronous and it is not
			event granted that the bell will be a bell at all... you might
			get the system default sound instead.. so be careful if you
			want to write portable scripts :)[br]
			If the -s switch is specified the bell becomes synchronous:
			KVIrc waits the bell to complete before continuing.[br]
			Obviously -s is senseless on Windows.[br]
			(WARNING : the main KVIrc thread is stopped in that case
			so if you play long notes (duration > 100)
			the entire application will appear to freeze for a while).[br]
			The precision of the bell pitch, duration and
			volume is strongly dependant on the system and the underlying hardware.[br]
	*/

	KVSCSC(beep)
	{
		kvs_uint_t uVolume;
		KVSCSC_PARAMETERS_BEGIN
			KVSCSC_PARAMETER("volume",KVS_PT_UINT,KVS_PF_OPTIONAL,uVolume)
		KVSCSC_PARAMETERS_END

		kvs_int_t pitch    = -1;
		kvs_int_t duration = -1;
		bool bSync   = (KVSCSC_pSwitches->find('s',"sync") != 0);
		bool bOk = false;

		KviKvsVariant * pPitch = KVSCSC_pSwitches->find('p',"pitch");
		if(pPitch)
		{
			if(!pPitch->asInteger(pitch))
			{
				KVSCSC_pContext->warning(__tr2qs("Invalid pitch value: using default"));
				pitch = -1;
			}
		}

		KviKvsVariant * pDuration = KVSCSC_pSwitches->find('d',"duration");
		if(pDuration)
		{
			if(!pDuration->asInteger(duration))
			{
				KVSCSC_pContext->warning(__tr2qs("Invalid duration value: using default"));
				duration = -1;
			}
		}
	
		if((uVolume > 100) || (uVolume < 1))uVolume = 100;

#ifdef COMPILE_ON_WINDOWS
		Beep(pitch,duration);
#else
	#ifndef COMPILE_NO_X_BELL



		XKeyboardState st;
		XKeyboardControl ctl;

		XGetKeyboardControl(get_xdisplay(),&st);

		unsigned long mask = KBBellPercent;
		ctl.bell_percent = uVolume;
		if(pitch >= 0)
		{
			ctl.bell_pitch    = pitch;
			mask             |= KBBellPitch;
		}
		if(duration >= 0)
		{
			ctl.bell_duration = duration;
			mask             |= KBBellDuration;
		}
		XChangeKeyboardControl(get_xdisplay(),mask,&ctl);

		XBell(get_xdisplay(),100);

		if(bSync)
		{
			if(duration >= 0)usleep(duration * 1000);
			else usleep(st.bell_duration * 1000);
		}

		ctl.bell_pitch = st.bell_pitch;
		ctl.bell_duration = st.bell_duration;
		ctl.bell_percent = st.bell_percent;

		XChangeKeyboardControl(get_xdisplay(),mask,&ctl);

	#endif //COMPILE_NO_X_BELL
#endif
		return true;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: buttonctl
		@title:
			buttonctl
		@type:
			command
		@short:
			changes user definable buttons
		@syntax:
			buttonctl [-q] <type:string> <name:string> <operation:string> [parameter:string]
		@switches:
			!sw: -q | --quiet
			Run quietly
		@description:
			Changes an existing user defined button.[br]
			<type_unused> is ignored and present only for backward compatibility.[br]
			<name> is the name of the button.[br]
			<operation> may be one of the constant strings "enable", "disable", "image",
			"text".[br]
			Operations "enable" and "disable" do not require the fourth [parameter] and have
			the obvious meaning.[br] Operation "image" requires the [parameter] to be
			a valid [doc:image_id]image_id[/doc] and sets the button image.[br]
			Operation "text" requires the [parameter] (and in fact all the following ones)
			to be a string containing the button text label.[br]
			The <operation> constants may be abbreviated, even to the single letters 'e','d','i' and 't'.[br]
			The -q switch causes the command to be quiet about errors and warnings.[br]
		@seealso:
			[cmd]button[/cmd]
	*/

//#warning	"ALSO /HELP must NOT interpret the identifiers!"
//#warning	"ALSO /DEBUG that relays to the DEBUG WINDOW"
	
	KVSCSC(buttonctl)
	{
		TQString tbTypeUnused,tbName,tbOp,tbPar;
		KVSCSC_PARAMETERS_BEGIN
			KVSCSC_PARAMETER("type",KVS_PT_STRING,0,tbTypeUnused)
			KVSCSC_PARAMETER("name",KVS_PT_STRING,0,tbName)
			KVSCSC_PARAMETER("operation",KVS_PT_STRING,0,tbOp)
			KVSCSC_PARAMETER("parameter",KVS_PT_STRING,KVS_PF_OPTIONAL,tbPar)
		KVSCSC_PARAMETERS_END

		KviScriptUserButton * pButton = 0;

		if(!KVSCSC_pWindow->buttonContainer())
		{
			if(!KVSCSC_pSwitches->find('q',"quiet"))KVSCSC_pContext->warning(__tr2qs("The specified window has no button containers"));
			return true;
		}
	
		pButton = (KviScriptUserButton *)(KVSCSC_pWindow->buttonContainer())->child(tbName,"KviWindowScriptButton");

		if(!pButton)
		{
			if(!KVSCSC_pSwitches->find('q',"quiet"))KVSCSC_pContext->warning(__tr2qs("No button with type %Q named %Q"),&tbTypeUnused,&tbName);
			return true;
		}
		TQChar o;
		if (tbOp.length() > 0) o=tbOp[0];
			else o=TQChar('x');

	//	TQChar o = tbOp.length() > 0 ? tbOp[0] : TQChar('x');

		switch(o.unicode())
		{
			case 't':
				KviTalToolTip::remove(pButton);
				KviTalToolTip::add(pButton,tbPar);
				pButton->setButtonText(tbPar);
			break;
			case 'i':
				if(!tbPar.isEmpty())
				{
					TQPixmap * pix = g_pIconManager->getImage(tbPar);
					if(pix)
					{
						pButton->setButtonPixmap(*pix);
					} else {
						if(!KVSCSC_pSwitches->find('q',"quiet"))KVSCSC_pContext->warning(__tr2qs("Can't find the icon '%Q'"),&tbPar);
					}
				}
			break;
			case 'e':
				pButton->setEnabled(true);
			break;
			case 'd':
				pButton->setEnabled(false);
			break;
		}
		return true;
	
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: codepage
		@type:
			command
		@title:
			codepage
		@syntax:
			codepage <encoding name>
		@short:
			Tries to set the codepage on server
		@description:
			This is a not-widely implemented extension
			that allows the user to set the codepage mapping
			on server.
			This command is a [doc:rfc2821wrappers]RFC2821 command wrapper[/doc]; see that document for more information.[br]
	*/
	// RFC2821 wrapper

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: ctcp
		@type:
			command
		@title:
			ctcp
		@syntax:
			ctcp [-n] <target:string> <ctcp_data:string>
		@short:
			Sends a CTCP message
		@description:
			Sends a CTCP message to the specified <target>.[br]
			The target may be a nickname , a channel, or a comma separated list of nicknames.[br]
			The <ctcp_data> is a string containing the ctcp type followed by the ctcp parameters.[br]
			For more info take a look at the [doc:ctcp_handling]ctcp protocol implementation notes[/doc].[br]
			The CTCP message will be a request (sent through a PRIVMSG) unless the -n switch
			specified: in that case it will be a reply (sent through a NOTICE).[br]
			If <ctcp_data> is the single string "ping" then a trailing time string argument
			is added in order to determine the round trip time when the ping reply comes back.
			To override this behaviour simply specify your own time string parameter.[br]
			This command is [doc:connection_dependant_commands]connection dependant[/doc].[br]
		@examples:
			[example]
			ctcp Pragma VERSION
			[/example]
	*/

	KVSCSC(ctcp)
	{
		TQString szTarget,szCtcpData;
		KVSCSC_PARAMETERS_BEGIN
			KVSCSC_PARAMETER("target",KVS_PT_NONEMPTYSTRING,0,szTarget)
			KVSCSC_PARAMETER("ctcp_data",KVS_PT_STRING,KVS_PF_OPTIONAL | KVS_PF_APPENDREMAINING,szCtcpData)
		KVSCSC_PARAMETERS_END

		KVSCSC_REQUIRE_CONNECTION
		
		if(KviTQString::equalCI(szCtcpData,"PING"))
		{
			struct timeval tv;
			kvi_gettimeofday(&tv,0);
			KviTQString::appendFormatted(szCtcpData," %d.%d",tv.tv_sec,tv.tv_usec);
		}

		KviTQCString szT = KVSCSC_pConnection->encodeText(szTarget);
		KviTQCString szD = KVSCSC_pConnection->encodeText(szCtcpData);
	
		if(!(KVSCSC_pConnection->sendFmtData("%s %s :%c%s%c",
				KVSCSC_pSwitches->find('n',"notice") ? "NOTICE" : "PRIVMSG",szT.data(),0x01,szD.data(),0x01)))
			return KVSCSC_pContext->warningNoIrcConnection();

		return true;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: debug
		@type:
			command
		@title:
			debug
		@syntax:
			debug <text>
		@short:
			Outputs text to the debug window
		@switches:
		@description:
			Outputs the &lt;text&gt; to the debug window.[br]
		@seealso:
	*/

	KVSCSC(debug)
	{
		TQString szAll;
		KVSCSC_pParams->allAsString(szAll);
		KviWindow * pWnd = KviDebugWindow::getInstance();
		pWnd->outputNoFmt(KVI_OUT_NONE,szAll);
		return true;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: delete
		@type:
			command
		@title:
			delete
		@syntax:
			delete [-q] [-i] <objectHandle>
		@short:
			Destroys an object
		@switches:
			!sw: -q | --quiet
			Causes the command to run quietly
			!sw: -i | --immediate
			Causes the object to be destroyed immediately
			instead of simply scheduling its later deletion.
		@description:
			Schedules for destruction the object designed by <objectHandle>.
			This command is internally aliased to [cmd]destroy[/cmd].
			Please note that the object is NOT immediately destroyed:
			it will be destroyed when KVIrc returns to the main event loop,
			so after the current script code part has been executed.
			This behaviour makes the object destruction safe in any
			part of the script, but may lead to problems when
			using signals and slots.[br]
			For example, when you delete an object that emits some signals,
			the signals may be still emitted after the delete call.
			You have to disconnect the signals explicitly if you don't want it
			to happen.[br]
			Alternatively you can use the -i switch: it causes the object
			to be destructed immediately but is intrinsicly unsafe:
			in complex script scenarios it may lead to a SIGSEGV;
			usually when called from one of the deleted object function
			handlers, or from a slot connected to one of the deleted object
			signals. Well, it actually does not SIGSEGV, but I can't guarantee it;
			so, if use the -i switch, test your script 10 times before releasing it.
			The -q switch causes the command to run a bit more silently: it still
			complains if the parameter passed is not an object reference, but
			it fails silently if the reference just points to an inexisting object (or is null).
		@examples:
			[example]
			[/example]
	*/

	/*
		@doc: destroy
		@type:
			command
		@title:
			destroy
		@syntax:
			destroy [-q] [-i] <objectHandle>
		@short:
			Destroys an object
		@description:
			This is a builtin alias for the command [cmd]delete[/cmd]
	*/

	KVSCSC(deleteCKEYWORDWORKAROUND)
	{
		kvs_hobject_t hObject;
		KVSCSC_PARAMETERS_BEGIN
			KVSCSC_PARAMETER("objectHandle",KVS_PT_HOBJECT,0,hObject)
		KVSCSC_PARAMETERS_END
		if(hObject == (kvs_hobject_t)0)
		{
			if(!KVSCSC_pSwitches->find('q',"quiet"))
				KVSCSC_pContext->warning(__tr2qs("Can't delete a null object reference"));
		} else {
			KviKvsObject * o = KviKvsKernel::instance()->objectController()->lookupObject(hObject);
			if(!o)
			{
				if(!KVSCSC_pSwitches->find('q',"quiet"))
					KVSCSC_pContext->warning(__tr2qs("Can't delete an inexisting object"));
			} else {
				if(KVSCSC_pSwitches->find('i',"immediate"))
					o->dieNow();
				else
					o->die();
			}
		}
		return true;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: delpopupitem
		@type:
			command
		@title:
			delpopupitem
		@syntax:
			delpopupitem [-d] [-q] <popupname:string> <item_id:string>
		@short:
			Deletes an item from a popup
		@switches:
			!sw: -q | --quiet
			Run quietly
			!sw: -d | --deep
			Search the whole popup tree instead of only the first level
		@description:
			Deletes the item specified by <id> from the poup <popupname>.
			If the -d flag is specified then the item with the specified
			<id> is seached in the whole popup tree (containing submenus)
			otherwise it is searched only in the first level.[br]
			If the -q flag is specified the command does not complain
			about inexisting items or inexisting popup menus.[br]
			See [cmd]defpopup[/cmd] for more informations.[br]
		@seealso:
			[cmd]defpopup[/cmd], [cmd]popup[/cmd]
	*/
	// FIXME: #warning "Separator should have the expression too ?"


	KVSCSC(delpopupitem)
	{
		TQString szPopupName,szItemId;
		KVSCSC_PARAMETERS_BEGIN
			KVSCSC_PARAMETER("popupname",KVS_PT_NONEMPTYSTRING,0,szPopupName)
			KVSCSC_PARAMETER("item_id",KVS_PT_NONEMPTYSTRING,0,szItemId)
		KVSCSC_PARAMETERS_END

		KviKvsPopupMenu * p = KviKvsPopupManager::instance()->lookup(szPopupName);
		if(!p)
		{
			if(!KVSCSC_pSwitches->find('q',"quiet"))
				KVSCSC_pContext->warning(__tr2qs("Inexisting popup \"%Q\""),&szPopupName);
			return true;
		}
	
		if(p->isLocked())
		{
			KVSCSC_pContext->error(__tr2qs("Popup menu self-modification is not allowed (the popup is probably open)"));
			return false;
		}
	
		if(!p->removeItemByName(szItemId,KVSCSC_pSwitches->find('d',"deep")))
		{
			if(!KVSCSC_pSwitches->find('q',"quiet"))
				KVSCSC_pContext->warning(__tr2qs("The menu item with id \"%Q\" does not exist in popup \"%Q\""),&szItemId,&szPopupName);
		}
	
		return true;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: deop
		@type:
			command
		@title:
			deop
		@syntax:
			deop <nickname_list>
		@short:
			Removes chanop status from the specified users
		@description:
			Removes channel operator status to the users specified in <nickname_list>,
			which is a comma separated list of nicknames. 
			This command works only if executed in a channel window.
			The command is translated to a set of MODE messages containing
			a variable number of -o flags.
			This command is [doc:connection_dependant_commands]connection dependant[/doc].
		@examples:
			[example]
			deop Pragma,Crocodile
			[/example]
		@seealso:
			[cmd]op[/cmd], [cmd]voice[/cmd], [cmd]devoice[/cmd]
	*/

	KVSCSC(deop)
	{
		return multipleModeCommand(__pContext,__pParams,__pSwitches,'-','o');
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: devoice
		@type:
			command
		@title:
			devoice
		@syntax:
			devoice <nickname_list>
		@short:
			Removes voice flag for the specified users
		@description:
			Removes the voice flag for the users specified in <nickname_list>,
			which is a comma separated list of nicknames. 
			This command works only if executed in a channel window.
			The command is translated to a set of MODE messages containing
			a variable number of -v flags.
			This command is [doc:connection_dependant_commands]connection dependant[/doc].
		@examples:
			[example]
			devoice Pragma,Crocodile
			[/example]
		@seealso:
			[cmd]op[/cmd], [cmd]deop[/cmd], [cmd]voice[/cmd]
	*/

	KVSCSC(devoice)
	{
		return multipleModeCommand(__pContext,__pParams,__pSwitches,'-','v');
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: die
		@type:
			command
		@title:
			die
		@syntax:
			die <message:text>
		@short:
			Prints an error message and stops the script
		@description:
			Prints an error message and stops the current script
			This command is equivalent to [cmd]error[/cmd]
	*/
	// Internally aliased to error

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: echo
		@type:
			command
		@title:
			echo
		@syntax:
			echo [-d] [-w=<window_id>] [-i=<icon_number>] [-n] <text>
		@short:
			Outputs text to a KVirc window
		@switches:
			!sw: -w=<window_id> | --window=<window_id>
			Causes the output to be redirected to the window specified by &lt;window_id&gt
			!sw: -i=<icon_number> | --icon=<icon_number>
			Causes the output to use the icon & color scheme specified by &lt;icon_number&gt
			!sw: -n | --no-timestamp
			Disables the message timestamping
			!sw: -d | --debug
			Send the output to the debug window (takes precedence over -w)
		@description:
			Outputs the &lt;text&gt; to the current window.[br]
			If the 'w' switch is present , outputs the &lt;text&gt;
			to the specified window instead of the current one.
			The <window_id&> parameter is the [doc:window_naming_conventions]global ID[/doc] of the window
			that has to be used.[br]
			If the 'i' switch is given , it uses the specified
			icon scheme (icon and colors) , otherwise it uses
			the default one (0).[br]
			If the -d switch is used then the output is sent to a special
			window called "Debug" (the window is created if not existing yet).
			This is useful for script debugging purposes (you get the output 
			in Debug regardless of the window that the executed command is attacched to).
			The KVIrc view widgets support clickable links that can be realized by using special [doc:escape_sequences]escape sequences[/doc].[br]
			The 'n' switch disables timestamping so you can output your own timestamp
			or not timestamp at all.[br]
		@examples:
			[example]
			echo Hey! this is my first echo test!
			echo -i=10 This text has a specified icon and colors
			echo --icon=[fnc]$icon[/fnc](parser error) this has the colors of the parser error messages
			[/example]
		@seealso:
			[fnc]$window[/fnc],
			[doc:window_naming_conventions]window naming conventions documentation[/doc]
	*/

	KVSCSC(echo)
	{
		TQString szAll;
		KVSCSC_pParams->allAsString(szAll);

		kvs_int_t iMsgType = KVI_OUT_NONE;
		KviWindow * pWnd = KVSCSC_pContext->window();

		if(!KVSCSC_pSwitches->isEmpty())
		{
			KviKvsVariant * v;
			if((v = KVSCSC_pSwitches->find('w',"window")))
			{
				TQString szWnd;
				v->asString(szWnd);
	//#warning "FIXME: the window database is not unicode! (we even could keep integer window id's at this point!)"
				pWnd = g_pApp->findWindow(szWnd.utf8().data());
				if(!pWnd)
				{
					KVSCSC_pContext->warning(__tr2qs("The argument of the -w switch did not evaluate to a valid window id: using default"));
					pWnd = KVSCSC_pContext->window();
				}
			}
				
			if((v = KVSCSC_pSwitches->find('i',"icon")))
			{
				if(!v->asInteger(iMsgType))
				{
					KVSCSC_pContext->warning(__tr2qs("The argument of the i switch did not evaluate to a number: using default"));
					iMsgType = KVI_OUT_NONE;
				} else {
					iMsgType = iMsgType % KVI_NUM_MSGTYPE_OPTIONS;
				}
			}
			
			if(KVSCSC_pSwitches->find('d',"debug"))
			{
				pWnd = KviDebugWindow::getInstance();
			}
		}

		int iFlags = KVSCSC_pSwitches->find('n',"no-timestamp") ? KviIrcView::NoTimestamp : 0;
		pWnd->outputNoFmt(iMsgType,szAll,iFlags);
		return true;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: echoprivmsg
		@type:
			command
		@title:
			echoprivmsg
		@syntax:
			echoprivmsg [switches] <nick:string> <user:string> <host:string> <text:string>
		@short:
			Outputs text to a KVIrc window
		@switches:
			!sw: -p[=<nick_prefix>] | --prefix[=<prefix>]
			The message is printed with the specified custom nickname prefix.
			If <nick_prefix> is omitted then an empty string is assumed.
			!sw: -s[=<nick_suffix>] | --suffix[=<nicksuffix>]
			The message is printed with the specified custom nickname suffix.
			If <nick_suffix> is omitted then an empty string is assumed.
			!sw: -w=<window_id> | --window=<window_id>
			The message is printed to the window specified by [doc:window_naming_conventions]window_id[/doc]
			!sw: -i=<color_set> | --color-set=<color_set>
			Causes the message to use the specified icon scheme (icon and colors).
			!sw: -n | --no-highlighting
			Do not apply the highlighting rules
			!sw: -x | --no-notifier
			Never cause the notifier window to pop up
			!sw: -f | --no-flashing
			Never cause the window taskbar entry to flash (this works only on some platforms)
		@description:
			Outputs a <text> to the current window in the privmsg format.[br]
			The <nick> <user> and <host> parameters are formatted
			as specified by the user preferences (for example
			the nick may use smart colorisation).
			If you don't know the username and host then just use '*' for
			that parameters.
			The message will also get the highlighting rules applied.
			If the 'w' switch is present, outputs <text>
			to the specified window instead of the current one.
			The <window_id> parameter is the [doc:window_naming_conventions]global ID[/doc] of the window
			that has to be used.[br]
			Please note that this is not the same as the standard
			[doc:command_rebinding]-r rebinding switch[/doc]:
			-w causes the specified window to be used only for output,
			but the command parameters are evaluated in the current window.[br]
			If the 'i' switch is given , it uses the specified
			icon scheme (icon and colors) , otherwise it uses
			the default one (0).[br]
			If the -n switch is present then the highlighting rules
			are not applied.[br]
			If the -x switch is present then the message will never cause
			the notifier window to be popped up.[br]
			If the -f switch is present then the message will never cause
			the system taskbar to flash.[br]
			Actually -x and -f have a sense only if highlighting is used and thus -n is not present.[br]
			For more informations about the icon/color schemes see [fnc]$msgtype[/fnc].
			The KVIrc view widgets support clickable sockets that can be realized by using special [doc:escape_sequences]escape sequences[/doc].[br]
		@examples:
			[example]
			echoprivmsg Test * * This is a test message
			echoprivmsg -i=$msgtype(ChanPrivmsgCrypted) Pragma pragma staff.kvirc.net Hi people! :)
			[/example]
		@seealso:
			[fnc]$window[/fnc],
			[fnc]$window.caption[/fnc],
			[fnc]$msgtype[/fnc],
			[cmd]echo[/cmd],
			[doc:window_naming_conventions]Window Naming Conventions[/doc]
	*/

	KVSCSC(echoprivmsg)
	{
		TQString szNick,szUser,szHost,szText;
		KVSCSC_PARAMETERS_BEGIN
			KVSCSC_PARAMETER("nick",KVS_PT_NONEMPTYSTRING,0,szNick)
			KVSCSC_PARAMETER("user",KVS_PT_STRING,0,szUser)
			KVSCSC_PARAMETER("host",KVS_PT_STRING,0,szHost)
			KVSCSC_PARAMETER("text",KVS_PT_STRING,KVS_PF_OPTIONAL | KVS_PF_APPENDREMAINING,szText)
		KVSCSC_PARAMETERS_END

		int type = KVI_OUT_NONE;
		KviWindow * pWnd = KVSCSC_pWindow;
		KviConsole * pConsole = pWnd->console();
		if(!pConsole)pConsole = g_pApp->activeConsole();

		KviKvsVariant * v;

		if(v = KVSCSC_pSwitches->find('i',"color-set"))
		{
			kvs_int_t msgType;
			if(v->asInteger(msgType))
			{
				if(msgType < 0)msgType = -msgType;
				type = (int)(msgType % KVI_NUM_MSGTYPE_OPTIONS);
			} else KVSCSC_pContext->warning(__tr2qs("Invalid color-set specification, using default"));
		}

		if(v = KVSCSC_pSwitches->find('w',"window"))
		{
			TQString szWin;
			v->asString(szWin);
			KviStr window = szWin;
			pWnd = g_pApp->findWindow(window.ptr());
			if(!pWnd)
			{
				KVSCSC_pContext->warning(__tr2qs("Window '%s' not found, using current one"),window.ptr());
				pWnd = KVSCSC_pWindow;
			}
		}

		TQString szPrefix,szSuffix;
		bool bPrefix = false;
		bool bSuffix = false;

		if(v = KVSCSC_pSwitches->find('p',"prefix"))
		{
			v->asString(szPrefix);
			bPrefix = true;
		}
		if(v = KVSCSC_pSwitches->find('s',"suffix"))
		{
			v->asString(szSuffix);
			bSuffix = true;
		}

		int iFlags = 0;
		if(KVSCSC_pSwitches->find('n',"no-highlighting"))iFlags |= KviConsole::NoHighlighting;
		if(KVSCSC_pSwitches->find('f',"no-flashing"))iFlags |= KviConsole::NoWindowFlashing;
		if(KVSCSC_pSwitches->find('x',"no-notifier"))iFlags |= KviConsole::NoNotifier;
		
		pConsole->outputPrivmsg(pWnd,type,
				szNick,szUser,szHost,szText,
				iFlags,
				bPrefix ? szPrefix : TQString(),bSuffix ? szSuffix : TQString());

		return true;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: error
		@type:
			command
		@title:
			error
		@syntax:
			error <message:text>
		@short:
			Prints an error message and stops the script
		@description:
			Prints an error message and stops the current script
			This command is equivalent to [cmd]die[/cmd]
		@seealso:
			[cmd]warning[/cmd]
	*/

	KVSCSC(error)
	{
#ifdef COMPILE_NEW_KVS
		TQString szAll;
		KVSCSC_pParams->allAsString(szAll);
		KVSCSC_pContext->error("%Q",&szAll);
#endif
		return false;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: eval
		@type:
			command
		@title:
			eval
		@syntax:
			eval [-q] [-r=<window>] <command>
		@switches:
			!sw: -q | --quiet
			Disable any error output
			!sw: -f | --force
			Continue execution even if <command> fails with an error
		@short:
			Change the behaviour of a set of commands
		@description:
			This command is useful to execute variable command sequences.[br]
			<command> is first evaluated as a normal parameter (thus identifiers
			and variables are substituted) then the evaluated string is executed
			as a command sequence.[br]
			-q causes eval to run quietly and don't display any errors in the inner command.[br]
			-f causes eval to ignore the errors inside <command> and continue execution.[br]
			This command may be used to rebind the <command> to a specified window.
			<command> shares the local variables with this command scope so you
			can easily exchange data with it.
			Remember that <command> is still a normal parameter and it must be
			enclosed in quotes if youwant it to be a complex command sequence.
			eval propagates the <command> return value.[br]
		@examples:
			[example]
				[comment]# evaluate a variable command[/comment]
				[cmd]if[/cmd](%somecondition)%tmp = "echo yeah"
				else %tmp = "echo -i=10 yeah"
				eval %tmp
				[comment]# Rebind the command to the #linux channel to get the user list[/comment]
				eval -r=[fnc]$channel[/fnc](#linux) "%Nicks[]=$chan.array;"
				[comment]# A nice alias that allows iterating commands through all the consoles[/comment]
				[comment]# This is by LatinSuD :)[/comment]
				[cmd]alias[/cmd](iterate)
				{
					%ctxt[]=[fnc]$window.list[/fnc](console,all)
					[cmd]for[/cmd](%i=0;%i<%ctxt[]#;%i++)
					{
						[cmd]eval[/cmd] -r=%ctxt[%i] $0-
					}
				}
				iterate [cmd]echo[/cmd] Hi ppl! :)
				[comment]# A little bit shorter (but less "colorful") version might be...[/comment]
				[cmd]alias[/cmd](iterate)
				{
					[cmd]foreach[/cmd](%x,[fnc]$window.list[/fnc](console,all))
							[cmd]eval[/cmd] -r=%x $0-;
				}
				iterate [cmd]echo[/cmd] Hi again!
				[comment]# Evaluate a command block[/comment]
				eval "{ echo First command!; echo Second command!; }"
			[/example]
	*/

	KVSCSC(eval)
	{
		TQString szCommands;
		KVSCSC_PARAMETERS_BEGIN
			KVSCSC_PARAMETER("commands",KVS_PT_STRING,KVS_PF_APPENDREMAINING,szCommands)
		KVSCSC_PARAMETERS_END

		KviKvsScript s("eval::inner",szCommands);
		int iRunFlags = 0;
		if(KVSCSC_pContext->reportingDisabled() || KVSCSC_pSwitches->find('q',"quiet"))
			iRunFlags |= KviKvsScript::Quiet;
		bool bRet = s.run(KVSCSC_pContext,iRunFlags) ? true : false;
		if(!bRet)
		{
			if(!KVSCSC_pSwitches->find('f',"force"))
				return false;
			KVSCSC_pContext->clearError();
		}
		return true;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: eventctl
		@title:
			eventctl
		@type:
			command
		@short:
			Controls the execution of event handlers
		@syntax:
			eventctl [-u] [-e] [-d] [-q] <event_name:string> <handler_name:string> [parameters]
		@switches:
			!sw: -u | --unregister
			Unregisters the specified handler
			!sw: -e | --enable
			Enables the specified handler
			!sw: -d | --disable
			Disables the specified handler
			!sw: -q | --quiet
			Do not print any warnings
		@description:
			Performs control actions on the handler <handler_name> for
			the event <event_name>.
			Without any switch it triggers the handler for testing purposes,
			eventually passing [parameters].[br]
			With the -u switch the handler <handler_name> is unregistered.[br]
			With the -d swtich is is disabled (so it is never executed)
			and with -e is enabled again.[br]
			The <event_name> may be one of the kvirc-builtin event names
			or a numeric code (from 0 to 999) of a raw server message.[br]
		@seealso:
			[cmd]event[/cmd]
	*/
	KVSCSC(eventctl)
	{
		TQString szEventName,szHandlerName;
		KviKvsVariantList vList;
		KVSCSC_PARAMETERS_BEGIN
			KVSCSC_PARAMETER("event_name",KVS_PT_NONEMPTYSTRING,0,szEventName)
			KVSCSC_PARAMETER("handler_name",KVS_PT_NONEMPTYSTRING,0,szHandlerName)
			KVSCSC_PARAMETER("parameters",KVS_PT_VARIANTLIST,KVS_PF_OPTIONAL,vList)
		KVSCSC_PARAMETERS_END
		
		bool bOk;
		int iNumber = szEventName.toInt(&bOk);
		bool bIsRaw = (bOk && (iNumber >= 0) && (iNumber < 1000));

		if(bIsRaw)
		{
			if(!KviKvsEventManager::instance()->isValidRawEvent(iNumber))
			{
				if(!KVSCSC_pSwitches->find('q',"quiet"))
					KVSCSC_pContext->warning(__tr2qs("No such event (%Q)"),&szEventName);
				return true;
			}
		} else {
			iNumber = KviKvsEventManager::instance()->findAppEventIndexByName(szEventName);
			if(!KviKvsEventManager::instance()->isValidAppEvent(iNumber))
			{
				if(!KVSCSC_pSwitches->find('q',"quiet"))
					KVSCSC_pContext->warning(__tr2qs("No such event (%Q)"),&szEventName);
				return true;
			}
		}

		if(KVSCSC_pSwitches->find('u',"unregister"))
		{
			// unregister it
			if(bIsRaw)
			{
				if(!KviKvsEventManager::instance()->removeScriptRawHandler(iNumber,szHandlerName))
					if(!KVSCSC_pSwitches->find('q',"quiet"))
						KVSCSC_pContext->warning(__tr2qs("No handler '%Q' for raw numeric event '%d'"),&szHandlerName,iNumber);
			} else {
				if(!KviKvsEventManager::instance()->removeScriptAppHandler(iNumber,szHandlerName))
					if(!KVSCSC_pSwitches->find('q',"quiet"))
						KVSCSC_pContext->warning(__tr2qs("No handler '%Q' for event '%Q'"),&szHandlerName,&szEventName);
			}
		} else if(KVSCSC_pSwitches->find('e',"enable") || KVSCSC_pSwitches->find('d',"disable"))
		{
			// enable it
			if(bIsRaw)
			{
				if(!KviKvsEventManager::instance()->enableScriptRawHandler(iNumber,szHandlerName,KVSCSC_pSwitches->find('e',"enable")))
					if(!KVSCSC_pSwitches->find('q',"quiet"))
						KVSCSC_pContext->warning(__tr2qs("No handler '%Q' for raw numeric event '%d'"),&szHandlerName,iNumber);
			} else {
				if(!KviKvsEventManager::instance()->enableScriptAppHandler(iNumber,szHandlerName,KVSCSC_pSwitches->find('e',"enable")))
					if(!KVSCSC_pSwitches->find('q',"quiet"))
						KVSCSC_pContext->warning(__tr2qs("No handler '%Q' for event '%Q'"),&szHandlerName,&szEventName);
			}
		} else {
			// trigger it
			KviKvsScriptEventHandler * h;
			TQString code;
			
			if(bIsRaw)
			{
				h = KviKvsEventManager::instance()->findScriptRawHandler(iNumber,szHandlerName);
			} else {
				h = KviKvsEventManager::instance()->findScriptAppHandler(iNumber,szHandlerName);
			}
	
			if(h)
			{
				KviKvsScript * s = h->script();
				KviKvsScript copy(*s);
				KviKvsVariant retVal;
				copy.run(KVSCSC_pWindow,&vList,0,KviKvsScript::PreserveParams);
			} else {
				if(!KVSCSC_pSwitches->find('q',"quiet"))
					KVSCSC_pContext->warning(__tr2qs("No handler '%Q' for event '%Q'"),&szHandlerName,&szEventName);
			}
		}

		return true;
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////////

	/*
		@doc: exit
		@type:
			command
		@title:
			exit
		@syntax:
			exit
		@switches:
		@short:
			Closes KVIrc
		@description:
			It closes KVirc application
	*/

	KVSCSC(exit)
	{
		g_pApp->quit();
		return true;
	}

};