author | Mikael Berthe <mikael@lilotux.net> |
Sat, 08 Jul 2006 22:07:30 +0200 | |
changeset 937 | 548def60b810 |
permissions | -rwxr-xr-x |
937
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
1 |
#!/usr/bin/perl |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
2 |
# |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
3 |
# Copyright (C) 2006 Adam Wolk "Mulander" <netprobe@gmail.com> |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
4 |
# Copyright (C) 2006 Mateusz Karkula "Karql" |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
5 |
# A few tweaks by Mikael Berthe |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
6 |
# |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
7 |
# This script is provided under the terms of the GNU General Public License, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
8 |
# see the file COPYING in the root mcabber source directory. |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
9 |
# |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
10 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
11 |
use warnings; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
12 |
use strict; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
13 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
14 |
use Getopt::Long; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
15 |
use Term::ReadKey; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
16 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
17 |
my %options; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
18 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
19 |
Getopt::Long::Configure qw(bundling); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
20 |
my $result = GetOptions( |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
21 |
"help|h" => \$options{help}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
22 |
"version|V" => \$options{version}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
23 |
"ignore|i" => \$options{ignore}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
24 |
"ignore-auto|I" => \$options{ignore_auto}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
25 |
"output|o" => \$options{output}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
26 |
"passwd|p" => \$options{passwd}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
27 |
"color|c" => \$options{color}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
28 |
"ssl|s" => \$options{ssl}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
29 |
"status|S" => \$options{status}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
30 |
"proxy|P" => \$options{proxy}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
31 |
"keep|k" => \$options{keep}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
32 |
"log|l" => \$options{log}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
33 |
"tracelog|t" => \$options{tracelog}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
34 |
); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
35 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
36 |
## |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
37 |
# Allowed colors |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
38 |
my @bg_color = qw( black red green yellow blue magenta cyan white ); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
39 |
my @fg_color = (@bg_color, map("bright$_", @bg_color), map("bold$_", @bg_color)); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
40 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
41 |
## |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
42 |
# info for specific settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
43 |
my %info = ( |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
44 |
# not grouped |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
45 |
beep_on_message => { msg => 'Should mcabber beep when you receive a message?', allow => undef, type => 'yesno', anwsers => undef, default => 0}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
46 |
password => { msg => 'Enter your password (at your own risk, this will be saved in plain text)', allow=>'.+', type=>'pass',anwsers => undef, default => undef }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
47 |
pinginterval => { msg => 'Enter pinginterval in seconds for keepalive settings, set this to 0 to disable, ', allow =>'\d+', type=>'edit', anwsers => undef, default => 40 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
48 |
hide_offline_buddies => {msg => 'Display only connected buddies in the roster?', allow => undef, type => 'yesno', anwsers => undef, default => 0 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
49 |
iq_version_hide_os => { msg => 'Hide Your OS information?', allow => undef, type => 'yesno', anwsers => undef, default => 0 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
50 |
# server settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
51 |
username => { msg => 'Your username', allow => '[^\s\@:<>&\'"]+', type => 'edit', anwsers => undef, default => undef }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
52 |
server => { msg => 'Your jabber server', allow => '\S+', type => 'edit', anwsers => undef, default => undef }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
53 |
resource => { msg => 'Resource (If your don\'t know what a resource is, use the default setting)', allow => '.{1,1024}', type => 'edit', anwsers => undef, default => 'mcabber' }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
54 |
nickname => { msg => 'Conference nickname (if you skip this setting your username will be used as a nickname in MUC chatrooms)', allow => '.+', type => 'edit', anwsers => undef, default => undef }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
55 |
# ssl settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
56 |
ssl => { msg => 'Enable ssl?', allow => undef, type => 'yesno', anwsers => undef, default => 0 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
57 |
port => { msg => 'Enter ssl port', allow => '\d+', type => 'edit', anwsers => undef, default => 5222 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
58 |
# proxy settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
59 |
proxy_host => { msg => 'Proxy host', allow => '\S+?\.\S+?', type => 'edit', anwsers => undef, default => undef }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
60 |
proxy_port => { msg => 'Proxy port', allow => '\d+', type => 'edit', anwsers => undef, default => 3128 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
61 |
proxy_user => { msg => 'Proxy user (optional, you can skip this if not required)', allow => '.+', type => 'edit', anwsers => undef, default => undef }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
62 |
proxy_pass => { msg => 'Proxy pass (optional, you can skip this if not required)', allow => '.+', type => 'pass', anwsers => undef, default => undef }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
63 |
# trace logs |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
64 |
tracelog_level => { msg => 'Specify level of advanced traces', allow => undef, type => 'multi', anwsers => ['lvl0: I don\'t want advanced tracing','lvl1: most events of the log window are written to the file','lvl2: debug logging (XML etc.)'], default => 0 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
65 |
tracelog_file => { msg => 'Specify a file to which the logs will be written', allow => undef, type => 'edit', anwsers => undef, default => undef }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
66 |
# logging settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
67 |
log_win_height => { msg => 'Set log window height (minimum 1)', allow => '[1-9]\d*', type => 'edit', anwsers => undef, default => 5 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
68 |
log_display_sender => { msg => 'Display the message sender\'s jid in the log window?', allow => undef, type => 'yesno', anwsers => undef, default => 0 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
69 |
logging => { msg => 'Enable logging?', allow => undef, type => 'yesno', anwsers => undef, default => 1 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
70 |
load_logs => { msg => 'Enable loading logs?', allow => undef, type => 'yesno', anwsers => undef, default => 1 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
71 |
logging_dir => { msg => 'Enter logging directory', allow => '.+' , type => 'edit', anwsers => undef, default => undef }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
72 |
log_muc_conf => { msg => 'Log MUC chats?', allow => undef, type => 'yesno', anwsers => undef, default => 1 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
73 |
load_muc_logs => { msg => 'Load MUC chat logs?', allow => undef, type => 'yesno', default => 0 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
74 |
# status settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
75 |
roster_width => { msg => 'Set buddylist window width (minimum 2)', allow => '[2-9]\d*', type => 'edit', anwsers => undef, default => 24 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
76 |
buddy_format => { msg => 'What buddy name format (in status window) do you prefer?', allow => undef, type => 'multi', anwsers => ['<jid/resource>','name <jid/resource> (name is omitted if same as the jid)','name/resource (if the name is same as the jid, use <jid/res>','name (if the name is the same as the jid, use <jid/res>'], default => 0 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
77 |
show_status_in_buffer => { msg => 'What status changes should be displayed in the buffer?', allow => undef, type => 'multi', anwsers => ['none','connect/disconnect','all'], default => 2 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
78 |
autoaway => { msg => 'After how many seconds of inactivity should You become auto away? (0 for never)', allow => '\d+', type => 'edit', anwsers => undef, default => 0 }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
79 |
message => { msg => 'Skip this setting unless you want to override all other status messages', allow => undef, type => 'edit', default => 'Unique message status'}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
80 |
message_avail => { msg => 'Set avaible status', allow => undef, type =>'edit',anwsers => undef, default =>'I\'m avaible'}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
81 |
message_free => { msg => 'Set free for chat status', allow => undef, type =>'edit', anwsers => undef, default => 'I\'m free for chat'}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
82 |
message_dnd => { msg => 'Set do not disturb status', allow => undef, type => 'edit', anwsers => undef, default => 'Please do not disturb'}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
83 |
message_notavail=> { msg => 'Set not avaible status', allow => undef, type => 'edit', anwsers => undef, default => 'I\'m not avaible'}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
84 |
message_away => { msg => 'Set away status', allow => undef, type => 'edit', anwsers => undef, default => 'I\'m away' }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
85 |
message_autoaway=> { msg => 'Set auto-away status', allow => undef, type => 'edit', anwsers => undef, default => 'Auto-away'}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
86 |
# color settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
87 |
color_background=> { msg => 'Select background color of the chat window and the log window', allow => undef, type => 'multi', anwsers => \@bg_color, default => 'black' }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
88 |
color_general => { msg => 'Select text color in the chat window and the log window', allow => undef, type =>'multi', anwsers => \@fg_color , default => 'white' }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
89 |
color_msgout => { msg => 'Select text color in the chat window for outgoing messages', allow => undef, type => 'multi', anwsers => \@fg_color, default => 'cyan'}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
90 |
color_bgstatus => { msg => 'Select background color of the status lines', allow => undef, type => 'multi', anwsers => \@bg_color, default =>'blue'}, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
91 |
color_status => { msg => 'Select text color of the status lines', allow => undef, type => 'multi', anwsers => \@fg_color, default => 'white' }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
92 |
color_roster => { msg => 'Select text color of the roster (buddylist) normal items', allow => undef, type => 'multi', anwsers => \@fg_color, default => 'green' }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
93 |
color_bgrostersel=>{ msg => 'Select background color of the selected roster item', allow => undef, type => 'multi', anwsers => \@bg_color, default => 'cyan' }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
94 |
color_rostersel => { msg => 'Select text color of the selected roster item', allow => undef, type => 'multi', anwsers => \@fg_color, default => 'blue' }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
95 |
color_rosterselmsg=>{ msg => 'Select text color of the selected roster item, if there is a new message', allow => undef, type => 'multi', anwsers => \@fg_color, default => 'red' }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
96 |
color_rosternewmsg=>{ msg => 'Select text color of items with unread messages', allow => undef, type => 'multi', anwsers => \@fg_color , default => 'red' }, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
97 |
); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
98 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
99 |
## |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
100 |
# question groups |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
101 |
my %groups = ( required => [qw(username server resource nickname ssl port)], |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
102 |
proxy_settings => [qw(proxy_host proxy_port proxy_user proxy_pass)], |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
103 |
logging_settings=> [qw(logging log_win_height log_display_sender load_logs logging_dir log_muc_conf load_muc_logs)], |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
104 |
status_settings => [qw(buddy_format roster_width show_status_in_buffer autoaway message message_avail message_free message_dnd message_notavail message_away message_autoaway )], |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
105 |
color_settings => [qw(color_background color_general color_msgout color_bgstatus color_status color_roster color_bgrostersel color_rostersel color_rosterselmsg color_rosternewmsg)], |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
106 |
tracelog_settings => [qw(tracelog_level tracelog_file)], |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
107 |
); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
108 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
109 |
my (%conf,@old); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
110 |
## |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
111 |
# regexp for valid keys |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
112 |
my $key_reg = join '|', keys %info; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
113 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
114 |
help() if $options{help}; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
115 |
version() if $options{version}; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
116 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
117 |
prepare(); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
118 |
ask('password') if $options{passwd}; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
119 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
120 |
ask($_) for @{ $groups{required} }; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
121 |
if($options{proxy}) { ask($_) for @{ $groups{proxy_settings} } }; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
122 |
ask('pinginterval') if $options{keep}; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
123 |
ask('beep_on_message'); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
124 |
ask('hide_offline_buddies'); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
125 |
ask('iq_version_hide_os'); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
126 |
ask('autoaway'); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
127 |
if($options{log} ) { ask($_) for @{ $groups{logging_settings} } }; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
128 |
if($options{status} ) { ask($_) for @{ $groups{status_settings} } }; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
129 |
if($options{color} ) { ask($_) for @{ $groups{color_settings} } }; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
130 |
if($options{tracelog} ) { ask($_) for @{ $groups{tracelog_settings}} }; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
131 |
build_config(); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
132 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
133 |
## |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
134 |
# Prepare for work |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
135 |
sub prepare |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
136 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
137 |
mkdir "$ENV{HOME}/.mcabber", 0700 unless ( -d "$ENV{HOME}/.mcabber" ); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
138 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
139 |
parse_config() if ( -e "$ENV{HOME}/.mcabber/mcabberrc" && !$options{ignore} ); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
140 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
141 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
142 |
## |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
143 |
# Parse current user configuration and save it |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
144 |
sub parse_config |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
145 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
146 |
my $conf_file = "$ENV{HOME}/.mcabber/mcabberrc"; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
147 |
my $flag = 1; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
148 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
149 |
open CONF, "<$conf_file" or return; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
150 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
151 |
my ($key,$value); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
152 |
while(<CONF>) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
153 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
154 |
push @old, $_; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
155 |
$flag = 0 if $options{ignore_auto} && m/^#BEGIN AUTO GENERATED SECTION/; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
156 |
$flag = 1 if $options{ignore_auto} && m/^#END AUTO GENERATED SECTION/; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
157 |
if ( $flag && m/^set\s+($key_reg)\s*=\s*(.+)$/ ) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
158 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
159 |
($key,$value) = ($1,$2); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
160 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
161 |
$conf{$key} = $value if ( exists $info{$key} ); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
162 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
163 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
164 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
165 |
close CONF; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
166 |
return 1; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
167 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
168 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
169 |
## |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
170 |
# Ask the user for a setting |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
171 |
sub ask |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
172 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
173 |
my ($key) = @_; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
174 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
175 |
my %dispatch = ( |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
176 |
edit => \&_ask_edit, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
177 |
yesno => \&_ask_yesno, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
178 |
multi => \&_ask_multi, |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
179 |
pass => \&_ask_pass |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
180 |
); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
181 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
182 |
my $lp = 1; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
183 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
184 |
print "\n'$key'\n", |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
185 |
$info{$key}->{msg},"\n", |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
186 |
( defined $info{$key}->{default} ) ? |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
187 |
( $lp++, '. ', ( exists $conf{$key} ) ? 'Reset' : 'Set', " to Default [",show($key,'default'),"]\n" ) : '', |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
188 |
( exists $conf{$key} ) ? ( $lp++, ". Leave Current setting [",show($key,'current'),"]\n", $lp++ ) : $lp++ , ". ", |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
189 |
( $info{$key}->{type} eq 'pass') ? 'Enter Passowrd' : ( ( $info{$key}->{type} eq 'edit' ) ? 'Edit' : 'Set' ), |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
190 |
"\n$lp. Skip\n[choice]: "; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
191 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
192 |
chomp(my $action = <STDIN>); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
193 |
unless ( $action =~ /^\d$/ && $action >= 1 && $action <= $lp ) { |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
194 |
ask($key); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
195 |
return; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
196 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
197 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
198 |
## |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
199 |
# Edit |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
200 |
if ( $lp -1 == $action ) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
201 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
202 |
&{ $dispatch{ $info{$key}->{type} } }($key); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
203 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
204 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
205 |
## |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
206 |
# Default |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
207 |
elsif ( $action == 1 ) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
208 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
209 |
$conf{$key} = $info{$key}->{default} if defined $info{$key}->{default}; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
210 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
211 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
212 |
## |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
213 |
# Skip |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
214 |
elsif ( $lp == $action ) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
215 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
216 |
delete $conf{$key}; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
217 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
218 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
219 |
## |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
220 |
# Nothing for Leave Current setting |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
221 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
222 |
return 1; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
223 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
224 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
225 |
sub _ask_yesno |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
226 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
227 |
my ($key) = @_; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
228 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
229 |
print "1. yes\n2. no\n[choice]: "; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
230 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
231 |
chomp(my $set = <STDIN>); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
232 |
unless ( $set =~ /^[12]$/ ) { |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
233 |
ask($key); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
234 |
return; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
235 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
236 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
237 |
$conf{$key} = $set; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
238 |
$conf{$key} = 0 if $set eq 2; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
239 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
240 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
241 |
sub _ask_multi |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
242 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
243 |
my ($key) = @_; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
244 |
my $count = scalar @{$info{$key}->{anwsers}}; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
245 |
my $row = sprintf("%0.f",($count/3+0.5)); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
246 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
247 |
for (my $i = 0; $i < $row; ++$i) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
248 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
249 |
printf("%-25s", ($i+1) . ". " . $info{$key}->{anwsers}->[$i]); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
250 |
printf("%-25s", ($i+$row+1) . ". " . $info{$key}->{anwsers}->[$i+$row]) if ($i+$row < $count); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
251 |
printf("%-25s", ($i+2*$row+1) . ". " . $info{$key}->{anwsers}->[$i+2*$row]) if ($i+2*$row < $count); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
252 |
print "\n"; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
253 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
254 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
255 |
print '[choice]: '; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
256 |
chomp(my $set = <STDIN>); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
257 |
unless ( $set =~ /^\d+$/ && $set >= 1 && $set <= $count ) { |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
258 |
ask($key); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
259 |
return; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
260 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
261 |
$conf{$key} = $info{$key}->{anwsers}->[$set-1]; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
262 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
263 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
264 |
sub _ask_edit |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
265 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
266 |
my ($key) = @_; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
267 |
print '[edit]: '; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
268 |
chomp(my $set = <STDIN>); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
269 |
unless ( $set =~ /^$info{$key}->{allow}$/ ) { |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
270 |
ask($key); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
271 |
return; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
272 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
273 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
274 |
$conf{$key} = $set; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
275 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
276 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
277 |
sub _ask_pass |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
278 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
279 |
my ($key) = @_; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
280 |
print "Characters you type in will not be shown\n[password]: "; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
281 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
282 |
ReadMode(2); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
283 |
my $anws = ReadLine(0); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
284 |
ReadMode(0); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
285 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
286 |
ask($key) unless $anws =~ /^$info{$key}->{allow}$/; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
287 |
chomp($anws); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
288 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
289 |
$anws =~ s/^((?:\s.+)|(?:.+\s))$/"$1"/; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
290 |
$conf{$key} = $anws; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
291 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
292 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
293 |
## |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
294 |
# Build configuration file |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
295 |
sub build_config |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
296 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
297 |
my $config_file = "$ENV{HOME}/.mcabber/mcabberrc"; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
298 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
299 |
local *STDOUT unless $options{output} ; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
300 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
301 |
unless($options{output}) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
302 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
303 |
open STDOUT,">$config_file" or die "Can't create config file"; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
304 |
chmod 0600, $config_file |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
305 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
306 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
307 |
my ($flag,$dumped) = (1,0); |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
308 |
for (@old) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
309 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
310 |
$flag = 0 if m/^#BEGIN AUTO GENERATED SECTION/; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
311 |
$flag = 1 if m/^#END AUTO GENERATED SECTION/; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
312 |
if ( $flag ) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
313 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
314 |
print |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
315 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
316 |
elsif( !$flag && !$dumped ) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
317 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
318 |
print "#BEGIN AUTO GENERATED SECTION\n\n"; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
319 |
print "set $_ = $conf{$_}\n" for sort keys %conf; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
320 |
print "\n"; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
321 |
$dumped = 1; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
322 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
323 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
324 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
325 |
unless($dumped) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
326 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
327 |
print "\n#BEGIN AUTO GENERATED SECTION\n\n"; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
328 |
print "set $_ = $conf{$_}\n" for sort keys %conf; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
329 |
print "\n#END AUTO GENERATED SECTION\n"; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
330 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
331 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
332 |
close STDOUT unless $options{output}; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
333 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
334 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
335 |
sub show |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
336 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
337 |
my ($key,$name) = @_; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
338 |
my $value; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
339 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
340 |
$value = $info{$key}->{default} if $name eq 'default'; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
341 |
$value = $conf{$key} if $name eq 'current'; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
342 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
343 |
if ( $info{$key}->{type} eq 'yesno' ) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
344 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
345 |
return ( $value ) ? 'yes' : 'no'; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
346 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
347 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
348 |
elsif ( $info{$key}->{type} eq 'multi' ) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
349 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
350 |
return $info{$key}->{anwsers}->[$value]; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
351 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
352 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
353 |
else |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
354 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
355 |
return $value; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
356 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
357 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
358 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
359 |
sub help |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
360 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
361 |
print<<EOF; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
362 |
Usage: $0 options |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
363 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
364 |
This script generates configuration files for mcabber jabber client |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
365 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
366 |
-h, --help display this help screen |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
367 |
-v, --version display version information |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
368 |
-i, --ignore ignore previous user configuration |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
369 |
-I, --ignore-auto ignore auto generated section |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
370 |
-o, --output output to stdout instead of file |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
371 |
-p, --passwd save password in the config file (not recommended) |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
372 |
-s, --ssl ask for ssl settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
373 |
-c, --color ask for color settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
374 |
-S, --status ask for status settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
375 |
-P, --proxy ask for proxy settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
376 |
-k, --keep ping/keepalive connection settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
377 |
-l, --log ask for logging settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
378 |
-t, --tracelog ask for trace log settings |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
379 |
EOF |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
380 |
exit; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
381 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
382 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
383 |
sub version |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
384 |
{ |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
385 |
print<<EOF; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
386 |
mcwizz v0.02 coded by Karql & mulander <netprobe\@gmail.com> |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
387 |
EOF |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
388 |
exit; |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
389 |
} |
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
390 |
|
548def60b810
Add configuration script (mcwizz.pl) to contrib (Mulander, Karql)
Mikael Berthe <mikael@lilotux.net>
parents:
diff
changeset
|
391 |
# vim: set noexpandtab sts=8: |