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
|
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* 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 3 of the License, or
* (at your option) 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, see <http://www.gnu.org/licenses/>.
*/
/* irc-config.c: IRC configuration options */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
#include <pwd.h>
#include "../weechat-plugin.h"
#include "irc.h"
#include "irc-config.h"
#include "irc-dcc.h"
#include "irc-server.h"
struct t_config_file *irc_config_file = NULL;
struct t_config_section *irc_config_section_server = NULL;
/* config, irc section */
struct t_config_option *irc_config_irc_one_server_buffer;
struct t_config_option *irc_config_irc_open_near_server;
struct t_config_option *irc_config_irc_nick_prefix;
struct t_config_option *irc_config_irc_nick_suffix;
struct t_config_option *irc_config_irc_nick_completion_smart;
struct t_config_option *irc_config_irc_display_away;
struct t_config_option *irc_config_irc_show_away_once;
struct t_config_option *irc_config_irc_default_msg_part;
struct t_config_option *irc_config_irc_notice_as_pv;
struct t_config_option *irc_config_irc_away_check;
struct t_config_option *irc_config_irc_away_check_max_nicks;
struct t_config_option *irc_config_irc_lag_check;
struct t_config_option *irc_config_irc_lag_min_show;
struct t_config_option *irc_config_irc_lag_disconnect;
struct t_config_option *irc_config_irc_anti_flood;
struct t_config_option *irc_config_irc_highlight;
struct t_config_option *irc_config_irc_colors_receive;
struct t_config_option *irc_config_irc_colors_send;
struct t_config_option *irc_config_irc_send_unknown_commands;
/* config, dcc section */
struct t_config_option *irc_config_dcc_auto_accept_files;
struct t_config_option *irc_config_dcc_auto_accept_chats;
struct t_config_option *irc_config_dcc_timeout;
struct t_config_option *irc_config_dcc_blocksize;
struct t_config_option *irc_config_dcc_fast_send;
struct t_config_option *irc_config_dcc_port_range;
struct t_config_option *irc_config_dcc_own_ip;
struct t_config_option *irc_config_dcc_download_path;
struct t_config_option *irc_config_dcc_upload_path;
struct t_config_option *irc_config_dcc_convert_spaces;
struct t_config_option *irc_config_dcc_auto_rename;
struct t_config_option *irc_config_dcc_auto_resume;
/* config, log section */
struct t_config_option *irc_config_log_auto_server;
struct t_config_option *irc_config_log_auto_channel;
struct t_config_option *irc_config_log_auto_private;
struct t_config_option *irc_config_log_hide_nickserv_pwd;
/* config, server section */
struct t_config_option *irc_config_server_name;
struct t_config_option *irc_config_server_autoconnect;
struct t_config_option *irc_config_server_autoreconnect;
struct t_config_option *irc_config_server_autoreconnect_delay;
struct t_config_option *irc_config_server_addresses;
struct t_config_option *irc_config_server_ipv6;
struct t_config_option *irc_config_server_ssl;
struct t_config_option *irc_config_server_password;
struct t_config_option *irc_config_server_nicks;
struct t_config_option *irc_config_server_username;
struct t_config_option *irc_config_server_realname;
struct t_config_option *irc_config_server_hostname;
struct t_config_option *irc_config_server_command;
struct t_config_option *irc_config_server_command_delay;
struct t_config_option *irc_config_server_autojoin;
struct t_config_option *irc_config_server_autorejoin;
struct t_config_option *irc_config_server_notify_levels;
struct t_irc_server *irc_config_server = NULL;
int irc_config_reload_flag;
/*
* irc_config_change_one_server_buffer: called when the "one server buffer"
* setting is changed
*/
void
irc_config_change_one_server_buffer ()
{
/*if (irc_config_irc_one_server_buffer)
irc_buffer_merge_servers (gui_current_window);
else
irc_buffer_split_server (gui_current_window);
*/
}
/*
* irc_config_change_away_check: called when away check is changed
*/
void
irc_config_change_away_check ()
{
if (irc_hook_timer_check_away)
{
weechat_unhook (irc_hook_timer_check_away);
irc_hook_timer_check_away = NULL;
}
if (weechat_config_integer (irc_config_irc_away_check) == 0)
{
/* reset away flag for all nicks/chans/servers */
//irc_server_remove_away ();
}
/*irc_hook_timer_check_away = weechat_hook_timer (weechat_config_integer (irc_config_irc_away_check) * 60 * 1000,
0,
irc_server_timer_check_away,
NULL);
*/
}
/*
* irc_config_change_log: called when log settings are changed
* (for server/channel/private logging)
*/
void
irc_config_change_log ()
{
/*t_gui_buffer *ptr_buffer;
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->protocol == irc_protocol)
{
ptr_server = irc_server_search (ptr_buffer->category);
ptr_channel = irc_channel_search (ptr_server, ptr_buffer->name);
if (ptr_server && !ptr_channel)
{
if (irc_config_log_auto_server && !ptr_buffer->log_file)
gui_log_start (ptr_buffer);
else if (!irc_config_log_auto_server && ptr_buffer->log_file)
gui_log_end (ptr_buffer);
}
if (ptr_server && ptr_channel)
{
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
if (irc_config_log_auto_channel && !ptr_buffer->log_file)
gui_log_start (ptr_buffer);
else if (!irc_config_log_auto_channel && ptr_buffer->log_file)
gui_log_end (ptr_buffer);
}
else
{
if (irc_config_log_auto_private && !ptr_buffer->log_file)
gui_log_start (ptr_buffer);
else if (!irc_config_log_auto_private && ptr_buffer->log_file)
gui_log_end (ptr_buffer);
}
}
}
}
*/
}
/*
* irc_config_change_notify_levels: called when notify level is changed
*/
void
irc_config_change_notify_levels ()
{
}
/*
* irc_config_reload: reload IRC configuration file
*/
int
irc_config_reload (void *data, struct t_config_file *config_file)
{
struct t_irc_server *ptr_server, *next_server;
int rc;
/* make C compiler happy */
(void) data;
(void) config_file;
irc_config_server = NULL;
irc_config_reload_flag = 1;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
ptr_server->reloaded_from_config = 0;
}
rc = weechat_config_reload (irc_config_file);
if (rc == 0)
{
if (irc_config_server)
irc_server_init_with_config_options (irc_config_server,
irc_config_section_server,
irc_config_reload_flag);
ptr_server = irc_servers;
while (ptr_server)
{
next_server = ptr_server->next_server;
if (!ptr_server->reloaded_from_config)
{
if (ptr_server->is_connected)
{
weechat_printf (NULL,
_("%s%s: warning: server \"%s\" not found "
"in configuration file, not deleted in "
"memory because it's currently used"),
weechat_prefix ("error"), "irc",
ptr_server->name);
}
else
irc_server_free (ptr_server);
}
ptr_server = next_server;
}
}
return rc;
}
/*
* irc_config_read_server_line: read a server line in configuration file
*/
void
irc_config_read_server_line (void *data, struct t_config_file *config_file,
char *option_name, char *value)
{
struct t_config_option *ptr_option;
int rc;
/* make C compiler happy */
(void) data;
(void) config_file;
if (option_name && value)
{
if (irc_config_server)
{
ptr_option = weechat_config_search_option (irc_config_file,
irc_config_section_server,
option_name);
if (ptr_option)
{
rc = weechat_config_option_set (ptr_option, value, 0);
switch (rc)
{
case 2:
break;
case 1:
break;
case 0:
weechat_printf (NULL,
_("%s%s: value \"%s\" is invalid "
"for option \"%s\""),
weechat_prefix ("error"), "irc",
value, option_name);
break;
}
}
else
{
weechat_printf (NULL,
_("%s%s: option \"%s\" not found"),
weechat_prefix ("error"), "irc",
option_name);
}
}
}
else
{
/* beginning of [server] section: save current server and create new
with default values for filling with next lines in file */
if (irc_config_server)
{
irc_server_init_with_config_options (irc_config_server,
irc_config_section_server,
irc_config_reload_flag);
}
irc_config_server = irc_server_alloc ();
if (!irc_config_server)
{
weechat_printf (NULL,
_("%s%s: error creating server for reading "
"configuration file"), "irc",
weechat_prefix ("error"));
}
}
}
/*
* irc_config_write_servers: write servers in configuration file
*/
void
irc_config_write_servers (void *data, struct t_config_file *config_file,
char *section_name)
{
struct t_irc_server *ptr_server;
/* make C compiler happy */
(void) data;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if (!ptr_server->temp_server)
{
weechat_config_write_line (config_file, section_name, NULL);
weechat_config_write_line (config_file, "server_name", "\"%s\"",
ptr_server->name);
weechat_config_write_line (config_file, "server_autoconnect", "%s",
(ptr_server->autoconnect) ? "on" : "off");
weechat_config_write_line (config_file, "server_autoreconnect", "%s",
(ptr_server->autoreconnect) ? "on" : "off");
weechat_config_write_line (config_file, "server_autoreconnect_delay", "%d",
ptr_server->autoreconnect_delay);
weechat_config_write_line (config_file, "server_addresses", "\"%s\"", ptr_server->addresses);
weechat_config_write_line (config_file, "server_ipv6", "%s",
(ptr_server->ipv6) ? "on" : "off");
weechat_config_write_line (config_file, "server_ssl", "%s",
(ptr_server->ssl) ? "on" : "off");
weechat_config_write_line (config_file, "server_password", "\"%s\"",
(ptr_server->password) ? ptr_server->password : "");
weechat_config_write_line (config_file, "server_nicks", "\"%s\"",
ptr_server->nicks);
weechat_config_write_line (config_file, "server_username", "\"%s\"",
ptr_server->username);
weechat_config_write_line (config_file, "server_realname", "\"%s\"",
ptr_server->realname);
weechat_config_write_line (config_file, "server_hostname", "\"%s\"",
(ptr_server->hostname) ? ptr_server->hostname : "");
weechat_config_write_line (config_file, "server_command", "\"%s\"",
(ptr_server->command) ? ptr_server->command : "");
weechat_config_write_line (config_file, "server_command_delay", "%d",
ptr_server->command_delay);
weechat_config_write_line (config_file, "server_autojoin", "\"%s\"",
(ptr_server->autojoin) ? ptr_server->autojoin : "");
weechat_config_write_line (config_file, "server_autorejoin", "%s",
(ptr_server->autorejoin) ? "on" : "off");
weechat_config_write_line (config_file, "server_notify_levels", "\"%s\"",
(ptr_server->notify_levels) ? ptr_server->notify_levels : "");
}
}
}
/*
* irc_config_write_server_default: write default server in configuration file
*/
void
irc_config_write_server_default (void *data, struct t_config_file *config_file,
char *section_name)
{
struct passwd *my_passwd;
char *realname, *pos;
/* make C compiler happy */
(void) data;
weechat_config_write_line (config_file, section_name, NULL);
weechat_config_write_line (config_file, "server_name", "%s", "\"freenode\"");
weechat_config_write_line (config_file, "server_autoconnect", "%s", "off");
weechat_config_write_line (config_file, "server_autoreconnect", "%s", "on");
weechat_config_write_line (config_file, "server_autoreconnect_delay", "%s", "30");
weechat_config_write_line (config_file, "server_addresses", "%s", "\"irc.freenode.net/6667\"");
weechat_config_write_line (config_file, "server_ipv6", "%s", "off");
weechat_config_write_line (config_file, "server_ssl", "%s", "off");
weechat_config_write_line (config_file, "server_password", "%s", "\"\"");
/* Get the user's name from /etc/passwd */
if ((my_passwd = getpwuid (geteuid ())) != NULL)
{
weechat_config_write_line (config_file,
"server_nicks", "\"%s,%s1,%s2,%s3,%s4\"",
my_passwd->pw_name,
my_passwd->pw_name,
my_passwd->pw_name,
my_passwd->pw_name,
my_passwd->pw_name);
weechat_config_write_line (config_file, "server_username", "\"%s\"", my_passwd->pw_name);
if ((!my_passwd->pw_gecos)
|| (my_passwd->pw_gecos[0] == '\0')
|| (my_passwd->pw_gecos[0] == ',')
|| (my_passwd->pw_gecos[0] == ' '))
weechat_config_write_line (config_file, "server_realname", "\"%s\"", my_passwd->pw_name);
else
{
realname = strdup (my_passwd->pw_gecos);
pos = strchr (realname, ',');
if (pos)
pos[0] = '\0';
weechat_config_write_line (config_file, "server_realname", "\"%s\"",
realname);
if (pos)
pos[0] = ',';
free (realname);
}
}
else
{
/* default values if /etc/passwd can't be read */
weechat_config_write_line (config_file, "server_nicks", "%s",
"\"" IRC_SERVER_DEFAULT_NICKS "\"");
weechat_config_write_line (config_file, "server_username", "%s", "\"weechat\"");
weechat_config_write_line (config_file, "server_realname", "%s", "\"weechat\"");
}
weechat_config_write_line (config_file, "server_hostname", "%s", "\"\"");
weechat_config_write_line (config_file, "server_command", "%s", "\"\"");
weechat_config_write_line (config_file, "server_command_delay", "%s", "0");
weechat_config_write_line (config_file, "server_autojoin", "%s", "\"\"");
weechat_config_write_line (config_file, "server_autorejoin", "%s", "on");
weechat_config_write_line (config_file, "server_notify_levels", "%s", "\"\"");
}
/*
* irc_config_init: init IRC configuration file
* return: 1 if ok, 0 if error
*/
int
irc_config_init ()
{
struct t_config_section *ptr_section;
irc_config_file = weechat_config_new (IRC_CONFIG_FILENAME,
&irc_config_reload, NULL);
if (!irc_config_file)
return 0;
ptr_section = weechat_config_new_section (irc_config_file, "irc",
NULL, NULL,
NULL, NULL,
NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
return 0;
}
irc_config_irc_one_server_buffer = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_one_server_buffer", "boolean",
N_("use same buffer for all servers"),
NULL, 0, 0, "off", &irc_config_change_one_server_buffer, NULL);
irc_config_irc_open_near_server = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_open_near_server", "boolean",
N_("open new channels/privates near server"),
NULL, 0, 0, "off", NULL, NULL);
irc_config_irc_nick_prefix = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_nick_prefix", "string",
N_("text to display before nick in chat window"),
NULL, 0, 0, "", NULL, NULL);
irc_config_irc_nick_suffix = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_nick_suffix", "string",
N_("text to display after nick in chat window"),
NULL, 0, 0, "", NULL, NULL);
irc_config_irc_nick_completion_smart = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_nick_completion_smart", "boolean",
N_("smart completion for nicks (completes with last speakers first)"),
NULL, 0, 0, "on", NULL, NULL);
irc_config_irc_display_away = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_display_away", "integer",
N_("display message when (un)marking as away"),
"off|local|channel", 0, 0, "local", NULL, NULL);
irc_config_irc_show_away_once = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_show_away_once", "boolean",
N_("show remote away message only once in private"),
NULL, 0, 0, "on", NULL, NULL);
irc_config_irc_default_msg_part = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_default_msg_part", "string",
N_("default part message (leaving channel) ('%v' will be replaced by "
"WeeChat version in string)"),
NULL, 0, 0, "WeeChat %v", NULL, NULL);
irc_config_irc_notice_as_pv = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_notice_as_pv", "boolean",
N_("display notices as private messages"),
NULL, 0, 0, "off", NULL, NULL);
irc_config_irc_away_check = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_away_check", "integer",
N_("interval between two checks for away (in minutes, 0 = never "
"check)"),
NULL, 0, INT_MAX, "0", &irc_config_change_away_check, NULL);
irc_config_irc_away_check_max_nicks = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_away_check_max_nicks", "integer",
N_("do not check away nicks on channels with high number of nicks "
"(0 = unlimited)"),
NULL, 0, INT_MAX, "0", &irc_config_change_away_check, NULL);
irc_config_irc_lag_check = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_lag_check", "integer",
N_("interval between two checks for lag (in seconds, 0 = never "
"check)"),
NULL, 0, INT_MAX, "60", NULL, NULL);
irc_config_irc_lag_min_show = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_lag_min_show", "integer",
N_("minimum lag to show (in seconds)"),
NULL, 0, INT_MAX, "1", NULL, NULL);
irc_config_irc_lag_disconnect = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_lag_disconnect", "integer",
N_("disconnect after important lag (in minutes, 0 = never "
"disconnect)"),
NULL, 0, INT_MAX, "5", NULL, NULL);
irc_config_irc_anti_flood = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_anti_flood", "integer",
N_("anti-flood: # seconds between two user messages (0 = no "
"anti-flood)"),
NULL, 0, 5, "2", NULL, NULL);
irc_config_irc_highlight = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_highlight", "string",
N_("comma separated list of words to highlight (case insensitive "
"comparison, words may begin or end with \"*\" for partial match)"),
NULL, 0, 0, "", NULL, NULL);
irc_config_irc_colors_receive = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_colors_receive", "boolean",
N_("when off, colors codes are ignored in incoming messages"),
NULL, 0, 0, "on", NULL, NULL);
irc_config_irc_colors_send = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_colors_send", "boolean",
N_("allow user to send colors with special codes (^Cb=bold, "
"^Ccxx=color, ^Ccxx,yy=color+background, ^Cu=underline, "
"^Cr=reverse)"),
NULL, 0, 0, "on", NULL, NULL);
irc_config_irc_send_unknown_commands = weechat_config_new_option (
irc_config_file, ptr_section,
"irc_send_unknown_commands", "boolean",
N_("send unknown commands to IRC server"),
NULL, 0, 0, "off", NULL, NULL);
ptr_section = weechat_config_new_section (irc_config_file, "dcc",
NULL, NULL,
NULL, NULL,
NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
return 0;
}
irc_config_dcc_auto_accept_files = weechat_config_new_option (
irc_config_file, ptr_section,
"dcc_auto_accept_files", "boolean",
N_("automatically accept incoming dcc files (use carefully!)"),
NULL, 0, 0, "off", NULL, NULL);
irc_config_dcc_auto_accept_chats = weechat_config_new_option (
irc_config_file, ptr_section,
"dcc_auto_accept_chats", "boolean",
N_("automatically accept dcc chats (use carefully!)"),
NULL, 0, 0, "off", NULL, NULL);
irc_config_dcc_timeout = weechat_config_new_option (
irc_config_file, ptr_section,
"dcc_timeout", "integer",
N_("timeout for dcc request (in seconds)"),
NULL, 5, INT_MAX, "300", NULL, NULL);
irc_config_dcc_blocksize = weechat_config_new_option (
irc_config_file, ptr_section,
"dcc_blocksize", "integer",
N_("block size for dcc packets in bytes"),
NULL, IRC_DCC_MIN_BLOCKSIZE, IRC_DCC_MAX_BLOCKSIZE, "65536",
NULL, NULL);
irc_config_dcc_fast_send = weechat_config_new_option (
irc_config_file, ptr_section,
"dcc_fast_send", "boolean",
N_("does not wait for ACK when sending file"),
NULL, 0, 0, "on", NULL, NULL);
irc_config_dcc_port_range = weechat_config_new_option (
irc_config_file, ptr_section,
"dcc_port_range", "string",
N_("restricts outgoing dcc to use only ports in the given range "
"(useful for NAT) (syntax: a single port, ie. 5000 or a port "
"range, ie. 5000-5015, empty value means any port)"),
NULL, 0, 0, "", NULL, NULL);
irc_config_dcc_own_ip = weechat_config_new_option (
irc_config_file, ptr_section,
"dcc_own_ip", "string",
N_("IP or DNS address used for outgoing dcc "
"(if empty, local interface IP is used)"),
NULL, 0, 0, "", NULL, NULL);
irc_config_dcc_download_path = weechat_config_new_option (
irc_config_file, ptr_section,
"dcc_download_path", "string",
N_("path for writing incoming files with dcc"),
NULL, 0, 0, "%h/dcc", NULL, NULL);
irc_config_dcc_upload_path = weechat_config_new_option (
irc_config_file, ptr_section,
"dcc_upload_path", "string",
N_("path for reading files when sending thru dcc (when no path is "
"specified)"),
NULL, 0, 0, "~", NULL, NULL);
irc_config_dcc_convert_spaces = weechat_config_new_option (
irc_config_file, ptr_section,
"dcc_convert_spaces", "boolean",
N_("convert spaces to underscores when sending files"),
NULL, 0, 0, "on", NULL, NULL);
irc_config_dcc_auto_rename = weechat_config_new_option (
irc_config_file, ptr_section,
"dcc_auto_rename", "boolean",
N_("rename incoming files if already exists (add '.1', '.2', ...)"),
NULL, 0, 0, "on", NULL, NULL);
irc_config_dcc_auto_resume = weechat_config_new_option (
irc_config_file, ptr_section,
"dcc_auto_resume", "boolean",
N_("automatically resume dcc transfer if connection with remote host "
"is loosed"),
NULL, 0, 0, "on", NULL, NULL);
ptr_section = weechat_config_new_section (irc_config_file, "log",
NULL, NULL,
NULL, NULL,
NULL, NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
return 0;
}
irc_config_log_auto_server = weechat_config_new_option (
irc_config_file, ptr_section,
"log_auto_server", "boolean",
N_("automatically log server messages"),
NULL, 0, 0, "off", &irc_config_change_log, NULL);
irc_config_log_auto_channel = weechat_config_new_option (
irc_config_file, ptr_section,
"log_auto_channel", "boolean",
N_("automatically log channel chats"),
NULL, 0, 0, "off", &irc_config_change_log, NULL);
irc_config_log_auto_private = weechat_config_new_option (
irc_config_file, ptr_section,
"log_auto_private", "boolean",
N_("automatically log private chats"),
NULL, 0, 0, "off", &irc_config_change_log, NULL);
irc_config_log_hide_nickserv_pwd = weechat_config_new_option (
irc_config_file, ptr_section,
"log_hide_nickserv_pwd", "boolean",
N_("hide password displayed by nickserv"),
NULL, 0, 0, "on", &irc_config_change_log, NULL);
ptr_section = weechat_config_new_section (irc_config_file, "server",
&irc_config_read_server_line,
NULL,
&irc_config_write_servers,
NULL,
&irc_config_write_server_default,
NULL);
if (!ptr_section)
{
weechat_config_free (irc_config_file);
return 0;
}
irc_config_section_server = ptr_section;
irc_config_server_name = weechat_config_new_option (
irc_config_file, ptr_section,
"server_name", "string",
N_("name associated to IRC server (for display only)"),
NULL, 0, 0, "", NULL, NULL);
irc_config_server_autoconnect = weechat_config_new_option (
irc_config_file, ptr_section,
"server_autoconnect", "boolean",
N_("automatically connect to server when WeeChat is starting"),
NULL, 0, 0, "off", NULL, NULL);
irc_config_server_autoreconnect = weechat_config_new_option (
irc_config_file, ptr_section,
"server_autoreconnect", "boolean",
N_("automatically reconnect to server when disconnected"),
NULL, 0, 0, "on", NULL, NULL);
irc_config_server_autoreconnect_delay = weechat_config_new_option (
irc_config_file, ptr_section,
"server_autoreconnect_delay", "integer",
N_("delay (in seconds) before trying again to reconnect to server"),
NULL, 0, 65535, "30", NULL, NULL);
irc_config_server_addresses = weechat_config_new_option (
irc_config_file, ptr_section,
"server_addresses", "string",
N_("list of IP/port or hostname/port for server (separated by comma)"),
NULL, 0, 0, "", NULL, NULL);
irc_config_server_ipv6 = weechat_config_new_option (
irc_config_file, ptr_section,
"server_ipv6", "boolean",
N_("use IPv6 protocol for server communication"),
NULL, 0, 0, "on", NULL, NULL);
irc_config_server_ssl = weechat_config_new_option (
irc_config_file, ptr_section,
"server_ssl", "boolean",
N_("use SSL for server communication"),
NULL, 0, 0, "on", NULL, NULL);
irc_config_server_password = weechat_config_new_option (
irc_config_file, ptr_section,
"server_password", "string",
N_("password for IRC server"),
NULL, 0, 0, "", NULL, NULL);
irc_config_server_nicks = weechat_config_new_option (
irc_config_file, ptr_section,
"server_nicks", "string",
N_("nicknames to use on IRC server (separated by comma)"),
NULL, 0, 0, "", NULL, NULL);
irc_config_server_username = weechat_config_new_option (
irc_config_file, ptr_section, "server_username", "string",
N_("user name to use on IRC server"),
NULL, 0, 0, "", NULL, NULL);
irc_config_server_realname = weechat_config_new_option (
irc_config_file, ptr_section,
"server_realname", "string",
N_("real name to use on IRC server"),
NULL, 0, 0, "", NULL, NULL);
irc_config_server_hostname = weechat_config_new_option (
irc_config_file, ptr_section,
"server_hostname", "string",
N_("custom hostname/IP for server (optional, if empty local hostname "
"is used)"),
NULL, 0, 0, "", NULL, NULL);
irc_config_server_command = weechat_config_new_option (
irc_config_file, ptr_section,
"server_command", "string",
N_("command(s) to run when connected to server (many commands should "
"be separated by ';', use '\\;' for a semicolon, special variables "
"$nick, $channel and $server are replaced by their value)"),
NULL, 0, 0, "", NULL, NULL);
irc_config_server_command_delay = weechat_config_new_option (
irc_config_file, ptr_section,
"server_command_delay", "integer",
N_("delay (in seconds) after command was executed (example: give some "
"time for authentication)"),
NULL, 0, 3600, "0", NULL, NULL);
irc_config_server_autojoin = weechat_config_new_option (
irc_config_file, ptr_section,
"server_autojoin", "string",
N_("comma separated list of channels to join when connected to server "
"(example: \"#chan1,#chan2,#chan3 key1,key2\")"),
NULL, 0, 0, "", NULL, NULL);
irc_config_server_autorejoin = weechat_config_new_option (
irc_config_file, ptr_section,
"server_autorejoin", "string",
N_("automatically rejoin channels when kicked"),
NULL, 0, 0, "on", NULL, NULL);
irc_config_server_notify_levels = weechat_config_new_option (
irc_config_file, ptr_section,
"server_notify_levels", "string",
N_("comma separated list of notify levels for channels of this server "
"(format: #channel:1,..), a channel name '*' is reserved for "
"server default notify level"),
NULL, 0, 0, "", NULL, NULL);
return 1;
}
/*
* irc_config_read: read IRC configuration file
* return: 0 = successful
* -1 = configuration file file not found
* -2 = error in configuration file
*/
int
irc_config_read ()
{
int rc;
irc_config_server = NULL;
irc_config_reload_flag = 0;
rc = weechat_config_read (irc_config_file);
if (irc_config_server)
irc_server_init_with_config_options (irc_config_server,
irc_config_section_server,
irc_config_reload_flag);
return rc;
}
/*
* irc_config_write: write IRC configuration file
* return: 0 if ok
* < 0 if error
*/
int
irc_config_write ()
{
return weechat_config_write (irc_config_file);
}
|