3 * centerim configuration handling routines
4 * $Id: icqconf.cc,v 1.143 2005/09/02 15:20:59 konst Exp $
6 * Copyright (C) 2001-2004 by Konstantin Klyagin <konst@konst.org.ua>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 #include <sys/types.h>
31 #include <sys/statvfs.h>
36 #include "icqcontacts.h"
37 #include "abstracthook.h"
38 #include "imexternal.h"
39 #include "eventmanager.h"
44 DEFAULT_TIMESTAMP_FORMAT
= "DD.MM.YY hh:mm";
45 DEFAULT_LOGTIMESTAMP_FORMAT
= "%R ";
46 SECONDS_TIMESTAMP_FORMAT
= "DD.MM.YY hh:mm:ss";
47 SECONDS_LOGTIMESTAMP_FORMAT
= "%T ";
52 fgroupmode
= nogroups
;
54 autoaway
= autona
= 0;
56 hideoffline
= antispam
= makelog
= askaway
= logtimestamps
=
57 logonline
= emacs
= proxyssl
= proxyconnect
= notitles
=
58 debug
= timestampstothesecond
= false;
60 timestampformat
= DEFAULT_TIMESTAMP_FORMAT
;
61 logtimestampformat
= DEFAULT_LOGTIMESTAMP_FORMAT
;
65 savepwd
= mailcheck
= fenoughdiskspace
= true;
67 for(protocolname pname
= icq
; pname
!= protocolname_size
; pname
++) {
68 chatmode
[pname
] = true;
69 cpconvert
[pname
] = entersends
[pname
] = nonimonline
[pname
] = false;
72 // quick and dirty fix to support .centerim as well as .centericq
73 basedir
= (string
) getenv("HOME") + "/.centerim/";
74 if ( access(basedir
.c_str(), F_OK
) != 0 ) {
75 basedir
= (string
) getenv("HOME") + "/.centericq/";
76 if ( access(basedir
.c_str(), F_OK
) != 0 ) {
77 basedir
= (string
) getenv("HOME") + "/.centerim/";
80 screensocketpath
= "/var/run/screen";
86 icqconf::imaccount
icqconf::getourid(protocolname pname
) const {
88 vector
<imaccount
>::const_iterator i
;
90 i
= find(accounts
.begin(), accounts
.end(), pname
);
91 im
= i
== accounts
.end() ? imaccount(pname
) : *i
;
96 icqconf::imserver
icqconf::defservers
[protocolname_size
] = {
97 { "login.icq.com", 5190, 0 },
98 { "scs.msg.yahoo.com", 5050, 0 },
99 { "messenger.hotmail.com", 1863, 0 },
100 { "toc.oscar.aol.com", 9898, 0 },
101 { "irc.oftc.net", 6667, 0 },
102 { "jabber.org", 5222, 5223 },
104 { "livejournal.com", 80, 0 },
105 { "appmsg.gadu-gadu.pl", 80 }
108 void icqconf::setourid(const imaccount
&im
) {
109 vector
<imaccount
>::iterator i
;
111 i
= find(accounts
.begin(), accounts
.end(), im
.pname
);
113 if(i
!= accounts
.end()) {
120 } else if(!im
.empty()) {
121 accounts
.push_back(im
);
122 i
= accounts
.end()-1;
125 if(i
!= accounts
.end()) {
126 if(i
->server
.empty()) {
127 i
->server
= defservers
[i
->pname
].server
;
128 i
->port
= defservers
[i
->pname
].port
;
132 i
->port
= defservers
[i
->pname
].port
;
136 if(i
->additional
.find("prio") == i
->additional
.end())
137 i
->additional
["prio"] = "4";
141 if(i
->additional
.find("importfriends") == i
->additional
.end())
142 i
->additional
["importfriends"] = "1";
146 if(i
->password
.size() > 8)
147 i
->password
= i
->password
.substr(0, 8);
153 string
icqconf::getawaymsg(protocolname pname
) const {
154 string r
, buf
, fname
;
157 if(!gethook(pname
).getCapabs().count(hookcapab::setaway
))
160 fname
= conf
.getconfigfname("awaymsg-" + getprotocolname(pname
));
161 f
.open(fname
.c_str());
166 if(!r
.empty()) r
+= "\n";
176 sprintf(buf
, _("I do really enjoy the default %s away message of %s %s."),
177 getprotocolname(pname
).c_str(), PACKAGE
, VERSION
);
185 void icqconf::setawaymsg(protocolname pname
, const string
&amsg
) {
189 if(!gethook(pname
).getCapabs().count(hookcapab::setaway
))
192 fname
= conf
.getconfigfname("awaymsg-" + getprotocolname(pname
));
193 f
.open(fname
.c_str());
201 void icqconf::checkdir() {
202 string dname
= getdirname();
203 dname
.erase(dname
.size()-1);
205 if(access(dname
.c_str(), F_OK
))
206 mkdir(dname
.c_str(), S_IRUSR
| S_IWUSR
| S_IXUSR
);
209 void icqconf::load() {
217 vector
<icqconf::keybinding
> icqconf::keys
;
219 void icqconf::loadkeys() {
221 string fname
= getconfigfname("keybindings"), buf
, param
;
227 if(access(fname
.c_str(), F_OK
)) {
228 ofstream
of(fname
.c_str());
231 of
<< "# This file contains keybinding configuration for centerim" << endl
;
232 of
<< "# Every line should look like: bind <section> <key> <command>" << endl
<< endl
;
233 of
<< "bind contact\t?\tinfo" << endl
;
234 of
<< "bind contact\tq\tquit" << endl
;
235 of
<< "bind contact\t<F3>\tchange_status" << endl
;
236 of
<< "bind contact\ts\tchange_status" << endl
;
237 of
<< "bind contact\th\thistory" << endl
;
238 of
<< "bind contact\tf\tfetch_away_message" << endl
;
239 of
<< "bind contact\t<F2>\tuser_menu" << endl
;
240 of
<< "bind contact\tm\tuser_menu" << endl
;
241 of
<< "bind contact\t<F4>\tgeneral_menu" << endl
;
242 of
<< "bind contact\tg\tgeneral_menu" << endl
;
243 of
<< "bind contact\t<F5>\thide_offline" << endl
;
244 of
<< "bind contact\t<F6>\tcontact_external_action" << endl
;
245 of
<< "bind contact\ta\tadd" << endl
;
246 of
<< "bind contact\t<delete> remove" << endl
;
247 of
<< "bind contact\t<enter> compose" << endl
;
248 of
<< "bind contact\tc\tsend_contact" << endl
;
249 of
<< "bind contact\tc\trss_check" << endl
;
250 of
<< "bind contact\tu\tsend_url" << endl
;
251 of
<< "bind contact\tr\trename" << endl
;
252 of
<< "bind contact\tv\tversion" << endl
;
253 of
<< "bind contact\te\tedit" << endl
;
254 of
<< "bind contact\ti\tignore" << endl
;
255 of
<< "bind contact\t\\as\tquickfind" << endl
;
256 of
<< "bind contact\t/\tquickfind" << endl
<< endl
;
257 of
<< "bind contact\t\\cn\tnext_chat" << endl
;
258 of
<< "bind contact\t\\cb\tprev_chat" << endl
;
259 of
<< "bind contact\t[\tleft_panel_move_left" << endl
;
260 of
<< "bind contact\t]\tleft_panel_move_right" << endl
;
261 of
<< "bind contact\t{\tlog_panel_move_up" << endl
;
262 of
<< "bind contact\t}\tlog_panel_move_down" << endl
;
263 of
<< "bind history\t/\tsearch" << endl
;
264 of
<< "bind history\ts\tsearch" << endl
;
265 of
<< "bind history\tn\tsearch_again" << endl
;
266 of
<< "bind history\t<F2>\tshow_urls" << endl
;
267 of
<< "bind history\t<F9>\tfullscreen" << endl
<< endl
;
268 of
<< "bind editor\t\\cx\tsend_message" << endl
;
269 of
<< "bind editor\t<esc>\tquit" << endl
;
270 of
<< "bind editor\t\\cp\tmultiple_recipients" << endl
;
271 of
<< "bind editor\t\\co\thistory" << endl
;
272 of
<< "bind editor\t\\cn\tnext_chat" << endl
;
273 of
<< "bind editor\t\\cb\tprev_chat" << endl
;
274 of
<< "bind editor\t\\a?\tinfo" << endl
;
275 of
<< "bind editor\t<F2>\tshow_urls" << endl
;
276 of
<< "bind editor\t<F9>\tfullscreen" << endl
<< endl
;
277 of
<< "bind editor\t<F4>\tchat_panel_move_up" << endl
;
278 of
<< "bind editor\t<F5>\tchat_panel_move_down" << endl
;
279 of
<< "bind info\t<F2>\tshow_urls" << endl
;
280 of
<< "bind info\t<F6>\tuser_external_action" << endl
;
286 f
.open(fname
.c_str());
292 if(buf
.empty() || buf
[0] == '#') continue;
297 param
= getword(buf
); /* first word is always bind */
299 param
= getword(buf
); /* read section */
300 if(param
== "contact")
301 k
.section
= section_contact
; else
302 if(param
== "history")
303 k
.section
= section_history
; else
304 if (param
== "editor")
305 k
.section
= section_editor
; else
307 k
.section
= section_info
;
309 param
= getword(buf
); /* key */
310 if(param
== "\\c<space>" || param
== "\\C<space>" || param
== "^<space>") {
313 } else if(param
== "\\a<enter>" || param
== "\\A<enter>" || param
== "@<enter>") {
316 } else if(param
== "\\a<space>" || param
== "\\A<space>" || param
== "@<space>") {
319 } else if(param
[0] == '\\') {
320 if(param
[1] == 'c' || param
[1] == 'C') {
322 k
.key
= CTRL(param
[2]);
323 } else if(param
[1] == 'a' || param
[1] == 'A') {
325 k
.key
= ALT(param
[2]);
326 } else if(param
[1] == '\\') {
328 } else if(param
[1] == '@') {
330 } else if(param
[1] == '^') {
333 } else if(param
[0] == '^') {
335 k
.key
= CTRL(param
[1]);
336 } else if(param
[0] == '@') {
338 k
.key
= ALT(param
[1]);
339 } else if(param
== "<delete>")
341 else if(param
== "<enter>")
343 else if(param
== "<esc>")
345 else if(param
== "<space>")
347 else if(param
== "<backspace>")
349 else if(param
== "<pageup>")
351 else if(param
== "<pagedown>")
353 else if(param
== "<tab>")
355 else if(param
== "<insert>")
357 else if(param
[0] == '<' && param
[1] == 'F') {
360 k
.key
= KEY_F(param
[2]-'0');
364 param
= getword(buf
); /* action */
365 if(param
== "info") k
.action
= key_info
; else
366 if(param
== "remove") k
.action
= key_remove
; else
367 if(param
== "quit") k
.action
= key_quit
; else
368 if(param
== "change_status") k
.action
= key_change_status
; else
369 if(param
== "history") k
.action
= key_history
; else
370 if(param
== "next_chat") k
.action
= key_next_chat
; else
371 if(param
== "prev_chat") k
.action
= key_prev_chat
; else
372 if(param
== "fetch_away_message") k
.action
= key_fetch_away_message
; else
373 if(param
== "user_menu") k
.action
= key_user_menu
; else
374 if(param
== "general_menu") k
.action
= key_general_menu
; else
375 if(param
== "hide_offline") k
.action
= key_hide_offline
; else
376 if(param
== "contact_external_action") k
.action
= key_contact_external_action
; else
377 if(param
== "add") k
.action
= key_add
; else
378 if(param
== "remove") k
.action
= key_remove
; else
379 if(param
== "send_message") k
.action
= key_send_message
; else
380 if(param
== "send_contact") k
.action
= key_send_contact
; else
381 if(param
== "send_url") k
.action
= key_send_url
; else
382 if(param
== "rename") k
.action
= key_rename
; else
383 if(param
== "version") k
.action
= key_version
; else
384 if(param
== "fullscreen") k
.action
= key_fullscreen
; else
385 if(param
== "edit") k
.action
= key_edit
; else
386 if(param
== "ignore") k
.action
= key_ignore
; else
387 if(param
== "quickfind") k
.action
= key_quickfind
; else
388 if(param
== "search") k
.action
= key_search
; else
389 if(param
== "compose") k
.action
= key_compose
; else
390 if(param
== "search_again") k
.action
= key_search_again
; else
391 if(param
== "show_urls") k
.action
= key_show_urls
; else
392 if(param
== "rss_check") k
.action
= key_rss_check
; else
393 if(param
== "multiple_recipients") k
.action
= key_multiple_recipients
; else
394 if(param
== "user_external_action") k
.action
= key_user_external_action
; else
395 if(param
== "left_panel_move_left") k
.action
= key_left_panel_move_left
; else
396 if(param
== "left_panel_move_right") k
.action
= key_left_panel_move_right
; else
397 if(param
== "log_panel_move_up") k
.action
= key_log_panel_move_up
; else
398 if(param
== "log_panel_move_down") k
.action
= key_log_panel_move_down
; else
399 if(param
== "chat_panel_move_up") k
.action
= key_chat_panel_move_up
; else
400 if(param
== "chat_panel_move_down") k
.action
= key_chat_panel_move_down
; else
409 if(face.action2key(key_info, section_contact).empty()) keys.push_back(keybinding()); else
410 if(face.action2key(key_quit, section_contact).empty())
411 if(face.action2key(key_change_status, section_contact).empty())
412 if(face.action2key(key_history, section_contact).empty())
413 if(face.action2key(key_fetch_away_message, section_contact).empty())
414 if(face.action2key(key_user_menu, section_contact).empty())
415 if(face.action2key(key_general_menu, section_contact).empty())
416 if(face.action2key(key_hide_offline, section_contact).empty())
417 if(face.action2key(key_contact_external_action, section_contact).empty())
418 if(face.action2key(key_add, section_contact).empty())
419 if(face.action2key(key_remove, section_contact).empty())
420 if(face.action2key(key_compose, section_contact).empty())
421 if(face.action2key(key_send_contact, section_contact).empty())
422 if(face.action2key(key_rss_check, section_contact).empty())
423 if(face.action2key(key_send_url, section_contact).empty())
424 if(face.action2key(key_rename, section_contact).empty())
425 if(face.action2key(key_version, section_contact).empty())
426 if(face.action2key(key_edit, section_contact).empty())
427 if(face.action2key(key_ignore, section_contact).empty())
428 if(face.action2key(key_quickfind, section_contact).empty())
429 if(face.action2key(key_next_chat, section_contact).empty())
430 if(face.action2key(key_prev_chat, section_contact).empty())
431 if(face.action2key(key_search, section_history).empty())
432 if(face.action2key(key_search_again, section_history).empty())
433 if(face.action2key(key_show_urls, section_history).empty())
434 if(face.action2key(key_fullscreen, section_history).empty())
435 if(face.action2key(key_send_message, section_editor).empty())
436 if(face.action2key(key_quit, section_editor).empty())
437 if(face.action2key(key_multiple_recipients, section_editor).empty())
438 if(face.action2key(key_history, section_editor).empty())
439 if(face.action2key(key_next_chat, section_editor).empty())
440 if(face.action2key(key_prev_chat, section_editor).empty())
441 if(face.action2key(key_info, section_editor).empty())
442 if(face.action2key(key_show_urls, section_editor).empty())
443 if(face.action2key(key_fullscreen, section_editor).empty())
444 if(face.action2key(key_show_urls, section_info).empty())
445 if(face.action2key(key_user_external_action, section_info).empty()) {}
449 void icqconf::loadmainconfig() {
450 string fname
= getconfigfname("config"), buf
, param
, rbuf
;
451 ifstream
f(fname
.c_str());
456 mailcheck
= askaway
= false;
457 savepwd
= bidi
= true;
460 setpeertopeer(0, 65535);
465 param
= getword(buf
);
467 if(param
== "hideoffline") hideoffline
= true; else
468 if(param
== "emacs") emacs
= true; else
469 if(param
== "autoaway") autoaway
= atol(buf
.c_str()); else
470 if(param
== "autona") autona
= atol(buf
.c_str()); else
471 if(param
== "antispam") antispam
= true; else
472 if(param
== "screenna") screenna
= true; else
473 if(param
== "screensocketpath") screensocketpath
= buf
; else
474 if(param
== "mailcheck") mailcheck
= true; else
475 if(param
== "quotemsgs") quote
= true; else
476 if(param
== "sockshost") setsockshost(buf
); else
477 if(param
== "socksusername") socksuser
= buf
; else
478 if(param
== "sockspass") sockspass
= buf
; else
479 if((param
== "usegroups") || (param
== "group1")) fgroupmode
= group1
; else
480 if(param
== "group2") fgroupmode
= group2
; else
481 if(param
== "protocolormode") cm
= icqconf::cmproto
; else
482 if(param
== "statuscolormode") cm
= icqconf::cmstatus
; else
483 if(param
== "smtp") setsmtphost(buf
); else
484 if(param
== "browser") setbrowser(browser
); else
485 if(param
== "http_proxy") sethttpproxyhost(buf
); else
486 if(param
== "log") makelog
= true; else
487 if(param
== "proxy_connect") proxyconnect
= true; else
488 if(param
== "proxy_ssl") proxyssl
= true; else
489 if(param
== "chatmode") initmultiproto(chatmode
, buf
, true); else
490 if(param
== "entersends") initmultiproto(entersends
, buf
, true); else
491 if(param
== "nonimonline") initmultiproto(nonimonline
, buf
, false); else
492 if(param
== "russian" || param
== "convert") initmultiproto(cpconvert
, buf
, false); else
493 if(param
== "nobidi") setbidi(false); else
494 if(param
== "askaway") askaway
= true; else
495 if(param
== "logtimestamps") logtimestamps
= true; else
496 if(param
== "logonline") logonline
= true; else
497 if(param
== "fromcharset") fromcharset
= buf
; else
498 if(param
== "tocharset") tocharset
= buf
; else
499 if(param
== "left_panel_width") leftpanelwidth
= atol(buf
.c_str()); else
500 if(param
== "log_panel_height") logpanelheight
= atol(buf
.c_str()); else
501 if(param
== "chat_panel_height") chatpanelheight
= atol(buf
.c_str()); else
502 if(param
== "timestampstothesecond") settimestampstothesecond(true); else
504 ptpmin
= atoi(getword(buf
, "-").c_str());
505 ptpmax
= atoi(buf
.c_str());
507 for(pname
= icq
; pname
!= protocolname_size
; pname
++) {
508 buf
= getprotocolname(pname
);
509 if(param
.substr(0, buf
.size()) == buf
) {
510 im
= getourid(pname
);
518 if(fromcharset
.empty() && tocharset
.empty())
519 for(pname
= icq
; pname
!= protocolname_size
; pname
++) {
520 if(getcpconvert(pname
)) {
521 fromcharset
= "cp1251";
522 tocharset
= "koi8-r";
532 void icqconf::save() {
533 string fname
= getconfigfname("config"), param
;
536 if(enoughdiskspace()) {
537 ofstream
f(fname
.c_str());
540 if(!getsockshost().empty()) {
542 getsocksuser(user
, pass
);
543 f
<< "sockshost\t" << getsockshost() + ":" + i2str(getsocksport()) << endl
;
544 f
<< "socksusername\t" << user
<< endl
;
545 f
<< "sockspass\t" << pass
<< endl
;
550 if(away
) f
<< "autoaway\t" << i2str(away
) << endl
;
551 if(na
) f
<< "autona\t" << i2str(na
) << endl
;
552 if(hideoffline
) f
<< "hideoffline" << endl
;
553 if(emacs
) f
<< "emacs" << endl
;
554 if(getquote()) f
<< "quotemsgs" << endl
;
555 if(getantispam()) f
<< "antispam" << endl
;
556 if(getmailcheck()) f
<< "mailcheck" << endl
;
557 if(getaskaway()) f
<< "askaway" << endl
;
558 if(getscreenna()) f
<< "screenna" << endl
;
559 if(!screensocketpath
.empty()) f
<< "screensocketpath\t" << screensocketpath
<< endl
;
562 for(protocolname pname
= icq
; pname
!= protocolname_size
; pname
++)
563 if(getchatmode(pname
)) param
+= (string
) " " + conf
.getprotocolname(pname
);
565 f
<< "chatmode" << param
<< endl
;
568 for(protocolname pname
= icq
; pname
!= protocolname_size
; pname
++)
569 if(getentersends(pname
)) param
+= (string
) " " + conf
.getprotocolname(pname
);
571 f
<< "entersends" << param
<< endl
;
574 for(protocolname pname
= icq
; pname
!= protocolname_size
; pname
++)
575 if(getnonimonline(pname
)) param
+= (string
) " " + conf
.getprotocolname(pname
);
577 f
<< "nonimonline" << param
<< endl
;
580 for(protocolname pname
= icq
; pname
!= protocolname_size
; pname
++)
581 if(getcpconvert(pname
)) param
+= (string
) " " + conf
.getprotocolname(pname
);
583 f
<< "convert" << param
<< endl
;
585 f
<< "fromcharset\t" << fromcharset
<< endl
;
586 f
<< "tocharset\t" << tocharset
<< endl
;
588 if(!getbidi()) f
<< "nobidi" << endl
;
589 if(logtimestamps
) f
<< "logtimestamps" << endl
;
590 if(timestampstothesecond
) f
<< "timestampstothesecond" << endl
;
591 if(logonline
) f
<< "logonline" << endl
;
593 f
<< "smtp\t" << getsmtphost() << ":" << getsmtpport() << endl
;
594 f
<< "browser\t" << getbrowser() << endl
;
596 if(!gethttpproxyhost().empty())
597 if (!gethttpproxyuser().empty())
598 f
<< "http_proxy\t" << gethttpproxyuser() << ":" << gethttpproxypasswd() << "@" << gethttpproxyhost() << ":" << gethttpproxyport() << endl
;
600 f
<< "http_proxy\t" << gethttpproxyhost() << ":" << gethttpproxyport() << endl
;
602 f
<< "ptp\t" << ptpmin
<< "-" << ptpmax
<< endl
;
604 switch(getgroupmode()) {
605 case group1
: f
<< "group1" << endl
; break;
606 case group2
: f
<< "group2" << endl
; break;
609 switch(getcolormode()) {
611 f
<< "protocolormode" << endl
;
614 f
<< "statuscolormode" << endl
;
618 if(getmakelog()) f
<< "log" << endl
;
619 if(getproxyconnect()) f
<< "proxy_connect" << endl
;
620 if(getproxyssl()) f
<< "proxy_ssl" << endl
;
622 if(getleftpanelwidth()) f
<< "left_panel_width\t" << getleftpanelwidth() << endl
;
623 if(getlogpanelheight()) f
<< "log_panel_height\t" << getlogpanelheight() << endl
;
624 if(getchatpanelheight()) f
<< "chat_panel_height\t" << getchatpanelheight() << endl
;
626 vector
<imaccount
>::iterator ia
;
627 for(ia
= accounts
.begin(); ia
!= accounts
.end(); ++ia
)
635 void icqconf::loadcolors() {
636 string tname
= getconfigfname("colorscheme");
638 switch(conf
.getregcolor()) {
640 schemer
.push(cp_status
, "status black/white");
641 schemer
.push(cp_dialog_text
, "dialog_text black/white");
642 schemer
.push(cp_dialog_menu
, "dialog_menu black/white");
643 schemer
.push(cp_dialog_selected
, "dialog_selected white/transparent bold");
644 schemer
.push(cp_dialog_highlight
, "dialog_highlight red/white");
645 schemer
.push(cp_dialog_frame
, "dialog_frame blue/white");
646 schemer
.push(cp_main_text
, "main_text cyan/transparent");
647 schemer
.push(cp_main_menu
, "main_menu green/transparent");
648 schemer
.push(cp_main_selected
, "main_selected black/white");
649 schemer
.push(cp_main_highlight
, "main_highlight yellow/transparent bold");
650 schemer
.push(cp_main_frame
, "main_frame blue/transparent bold");
651 schemer
.push(cp_main_history_incoming
, "main_history_incoming yellow/transparent bold");
652 schemer
.push(cp_main_history_outgoing
, "main_history_outgoing cyan/transparent");
653 schemer
.push(cp_clist_icq
, "clist_icq green/transparent");
654 schemer
.push(cp_clist_yahoo
, "clist_yahoo magenta/transparent");
655 schemer
.push(cp_clist_infocard
, "clist_infocard white/transparent");
656 schemer
.push(cp_clist_msn
, "clist_msn cyan/transparent");
657 schemer
.push(cp_clist_aim
, "clist_aim yellow/transparent");
658 schemer
.push(cp_clist_irc
, "clist_irc blue/transparent");
659 schemer
.push(cp_clist_jabber
, "clist_jabber red/transparent");
660 schemer
.push(cp_clist_rss
, "clist_rss white/transparent bold");
661 schemer
.push(cp_clist_lj
, "clist_lj cyan/transparent bold");
662 schemer
.push(cp_clist_gadu
, "clist_gg blue/transparent bold");
663 schemer
.push(cp_clist_online
, "clist_online green/transparent bold");
664 schemer
.push(cp_clist_offline
, "clist_offline red/transparent bold");
665 schemer
.push(cp_clist_away
, "clist_away yellow/transparent bold");
666 schemer
.push(cp_clist_dnd
, "clist_dnd cyan/transparent bold");
667 schemer
.push(cp_clist_na
, "clist_na blue/transparent bold");
668 schemer
.push(cp_clist_free_for_chat
, "clist_free_for_chat green/transparent bold");
669 schemer
.push(cp_clist_invisible
, "clist_invisible grey/transparent bold");
670 schemer
.push(cp_clist_not_in_list
, "clist_not_in_list white/transparent bold");
674 schemer
.push(cp_status
, "status black/white");
675 schemer
.push(cp_dialog_text
, "dialog_text black/cyan");
676 schemer
.push(cp_dialog_menu
, "dialog_menu black/cyan");
677 schemer
.push(cp_dialog_selected
, "dialog_selected white/black bold");
678 schemer
.push(cp_dialog_highlight
, "dialog_highlight white/cyan bold");
679 schemer
.push(cp_dialog_frame
, "dialog_frame black/cyan");
680 schemer
.push(cp_main_text
, "main_text white/blue");
681 schemer
.push(cp_main_menu
, "main_menu white/blue");
682 schemer
.push(cp_main_selected
, "main_selected black/cyan");
683 schemer
.push(cp_main_highlight
, "main_highlight white/blue bold");
684 schemer
.push(cp_main_frame
, "main_frame blue/blue bold");
685 schemer
.push(cp_main_history_incoming
, "main_history_incoming white/blue");
686 schemer
.push(cp_main_history_outgoing
, "main_history_outgoing white/blue bold");
687 schemer
.push(cp_clist_icq
, "clist_icq green/blue");
688 schemer
.push(cp_clist_yahoo
, "clist_yahoo magenta/blue");
689 schemer
.push(cp_clist_msn
, "clist_msn cyan/blue");
690 schemer
.push(cp_clist_infocard
, "clist_infocard white/blue");
691 schemer
.push(cp_clist_aim
, "clist_aim yellow/blue");
692 schemer
.push(cp_clist_irc
, "clist_irc blue/blue bold");
693 schemer
.push(cp_clist_jabber
, "clist_jabber red/blue");
694 schemer
.push(cp_clist_rss
, "clist_rss white/blue bold");
695 schemer
.push(cp_clist_lj
, "clist_lj cyan/blue bold");
696 schemer
.push(cp_clist_gadu
, "clist_gg blue/blue bold");
697 schemer
.push(cp_clist_online
, "clist_online green/transparent bold");
698 schemer
.push(cp_clist_offline
, "clist_offline red/transparent bold");
699 schemer
.push(cp_clist_away
, "clist_away yellow/transparent bold");
700 schemer
.push(cp_clist_dnd
, "clist_dnd cyan/transparent bold");
701 schemer
.push(cp_clist_na
, "clist_na blue/transparent bold");
702 schemer
.push(cp_clist_free_for_chat
, "clist_free_for_chat green/transparent bold");
703 schemer
.push(cp_clist_invisible
, "clist_invisible grey/transparent bold");
704 schemer
.push(cp_clist_not_in_list
, "clist_not_in_list white/transparent bold");
708 if(access(tname
.c_str(), F_OK
)) {
715 void icqconf::loadsounds() {
716 string tname
= getconfigfname("sounds"), buf
, suin
, skey
;
719 imevent::imeventtype it
;
721 typedef pair
<imevent::imeventtype
, string
> eventsound
;
722 vector
<eventsound
> soundnames
;
723 vector
<eventsound
>::iterator isn
;
725 soundnames
.push_back(eventsound(imevent::message
, "msg"));
726 soundnames
.push_back(eventsound(imevent::sms
, "sms"));
727 soundnames
.push_back(eventsound(imevent::url
, "url"));
728 soundnames
.push_back(eventsound(imevent::online
, "online"));
729 soundnames
.push_back(eventsound(imevent::offline
, "offline"));
730 soundnames
.push_back(eventsound(imevent::email
, "email"));
732 for(i
= 0; i
< clist
.count
; i
++) {
733 c
= (icqcontact
*) clist
.at(i
);
735 for(it
= imevent::message
; it
!= imevent::imeventtype_size
; it
++) {
740 if(access(tname
.c_str(), F_OK
)) {
741 ofstream
fo(tname
.c_str());
744 fo
<< "# This file contains sound configuration for centerim" << endl
;
745 fo
<< "# Every line should look like: <id> <event> <command>" << endl
<< "#" << endl
;
747 fo
<< "# <id>\tid of a contact; can be one of the following" << endl
;
748 fo
<< "# *\tmeans default sound for all the contacts" << endl
;
749 fo
<< "# icq_<uin>\tfor icq contacts (e.g. icq_123)" << endl
;
750 fo
<< "# yahoo_<nickname>\tfor yahoo (e.g. yahoo_thekonst)" << endl
;
751 fo
<< "# .. etc. Similar for the other protocols" << endl
<< "#" << endl
;
753 fo
<< "# <event>\tcan be: ";
754 for(isn
= soundnames
.begin(); isn
!= soundnames
.end(); ++isn
) {
755 if(isn
!= soundnames
.begin()) fo
<< ", ";
759 fo
<< endl
<< "# <command>\tcommand line to be executed to play a sound" << endl
<< endl
;
763 fo
<< "*\tmsg\tplay " << SHARE_DIR
<< "/msg.wav" << endl
;
764 fo
<< "*\turl\tplay " << SHARE_DIR
<< "/url.wav" << endl
;
765 fo
<< "*\temail\tplay " << SHARE_DIR
<< "/email.wav" << endl
;
766 fo
<< "*\tonline\tplay " << SHARE_DIR
<< "/online.wav" << endl
;
767 fo
<< "*\toffline\tplay " << SHARE_DIR
<< "/offline.wav" << endl
;
768 fo
<< "*\tsms\tplay " << SHARE_DIR
<< "/sms.wav" << endl
;
772 fo
<< "*\tmsg\t!spk1" << endl
;
773 fo
<< "*\turl\t!spk2" << endl
;
774 fo
<< "*\tsms\t!spk3" << endl
;
775 fo
<< "*\temail\t!spk5" << endl
;
783 ifstream
fi(tname
.c_str());
787 if(buf
.empty() || (buf
.substr(0, 1) == "#")) continue;
792 it
= imevent::imeventtype_size
;
794 for(isn
= soundnames
.begin(); isn
!= soundnames
.end(); ++isn
) {
795 if(skey
== isn
->second
) {
801 if(it
== imevent::imeventtype_size
)
807 if((i
= suin
.find("_")) != -1) {
808 skey
= suin
.substr(0, i
);
814 for(pname
= icq
; pname
!= protocolname_size
&& skey
!= getprotocolname(pname
); pname
++);
816 if(pname
!= protocolname_size
) {
818 for(i
= 0; i
< clist
.count
; i
++) {
819 c
= (icqcontact
*) clist
.at(i
);
821 if(c
->getdesc().pname
== pname
) c
->setsound(it
, buf
);
824 if(pname
== icq
) ic
= imcontact(strtoul(suin
.c_str(), 0, 0), pname
);
825 else ic
= imcontact(suin
, pname
);
832 c
= clist
.get(contactroot
);
835 if(c
) c
->setsound(it
, buf
);
842 void icqconf::loadactions() {
843 string fname
= getconfigfname("actions"), buf
, name
;
847 if(access(fname
.c_str(), F_OK
)) {
848 buf
= getenv("PATH") ? getenv("PATH") : "";
850 ofstream
of(fname
.c_str());
853 of
<< "# This file contains external actions configuration for centerim" << endl
;
854 of
<< "# Every line should look like: <action> <command>" << endl
;
855 of
<< "# Possible actions are: openurl, detectmusic" << endl
<< endl
;
857 of
<< "openurl \\" << endl
;
858 of
<< " (if test ! -z \"`ps x | grep /" << browser
<< " | grep -v grep`\"; \\" << endl
;
859 of
<< "\tthen DISPLAY=0:0 " << browser
<< " -remote 'openURL($url$, new-window)'; \\" << endl
;
860 of
<< "\telse DISPLAY=0:0 " << browser
<< " \"$url$\"; \\" << endl
;
861 of
<< " fi) >/dev/null 2>&1 &" << endl
;
863 of
<< "detectmusic \\" << endl
;
864 of
<< " if test ! -z \"`ps x | grep orpheus | grep -v grep`\"; \\" << endl
;
865 of
<< "\tthen cat ~/.orpheus/currently_playing; \\" << endl
;
872 f
.open(fname
.c_str());
880 if(!cont
) name
= getword(buf
);
882 if(name
== "openurl" || name
== "detectmusic") {
884 if(cont
= buf
.substr(buf
.size()-1, 1) == "\\")
885 buf
.erase(buf
.size()-1, 1);
887 actions
[name
] += buf
;
895 icqconf::regcolor
icqconf::getregcolor() const {
899 void icqconf::setregcolor(icqconf::regcolor c
) {
903 icqconf::regsound
icqconf::getregsound() const {
907 void icqconf::setregsound(icqconf::regsound s
) {
911 icqconf::colormode
icqconf::getcolormode() const {
915 void icqconf::setcolormode(colormode c
) {
919 void icqconf::setauto(int away
, int na
) {
927 void icqconf::getauto(int &away
, int &na
) const {
935 bool icqconf::getscreenna() const {
939 void icqconf::setscreenna(bool sna
) {
943 string
icqconf::getscreensocketpath() const {
944 return screensocketpath
;
947 void icqconf::setscreensocketpath(string path
) {
948 screensocketpath
= path
;
951 void icqconf::setquote(bool use
) {
955 void icqconf::setsockshost(const string
&nsockshost
) {
958 if(!nsockshost
.empty()) {
959 if((pos
= nsockshost
.find(":")) != -1) {
960 sockshost
= nsockshost
.substr(0, pos
);
961 socksport
= atol(nsockshost
.substr(pos
+1).c_str());
963 sockshost
= nsockshost
;
971 string
icqconf::getsockshost() const {
975 unsigned int icqconf::getsocksport() const {
979 void icqconf::getsocksuser(string
&name
, string
&pass
) const {
984 void icqconf::setsocksuser(const string
&name
, const string
&pass
) {
989 void icqconf::setsavepwd(bool ssave
) {
993 void icqconf::sethideoffline(bool fho
) {
997 void icqconf::settimestampstothesecond(bool ttts
) {
998 timestampstothesecond
= ttts
;
999 if (timestampstothesecond
) {
1000 timestampformat
= SECONDS_TIMESTAMP_FORMAT
;
1001 logtimestampformat
= SECONDS_LOGTIMESTAMP_FORMAT
;
1003 timestampformat
= DEFAULT_TIMESTAMP_FORMAT
;
1004 logtimestampformat
= DEFAULT_LOGTIMESTAMP_FORMAT
;
1008 void icqconf::setemacs(bool fem
) {
1012 void icqconf::setantispam(bool fas
) {
1016 void icqconf::seticqdropauthreq(bool fas
) {
1017 icqdropauthreq
= fas
;
1020 void icqconf::setmailcheck(bool fmc
) {
1024 void icqconf::setaskaway(bool faskaway
) {
1028 bool icqconf::getchatmode(protocolname pname
) {
1035 return chatmode
[pname
];
1038 void icqconf::setchatmode(protocolname pname
, bool fchatmode
) {
1039 chatmode
[pname
] = fchatmode
;
1042 bool icqconf::getentersends(protocolname pname
) {
1043 return entersends
[pname
];
1046 void icqconf::setentersends(protocolname pname
, bool fentersends
) {
1047 entersends
[pname
] = fentersends
;
1050 bool icqconf::getnonimonline(protocolname pname
) {
1051 return nonimonline
[pname
];
1054 void icqconf::setnonimonline(protocolname pname
, bool fnonimonline
) {
1055 nonimonline
[pname
] = fnonimonline
;
1058 bool icqconf::getcpconvert(protocolname pname
) const {
1059 return cpconvert
[pname
];
1062 void icqconf::setcpconvert(protocolname pname
, bool fcpconvert
) {
1063 cpconvert
[pname
] = fcpconvert
;
1066 string
icqconf::execaction(const string
&name
, const string
¶m
) {
1067 int inpipe
[2], outpipe
[2], pid
, npos
;
1068 struct sigaction sact
, osact
;
1069 string torun
= actions
[name
], out
;
1073 if(name
== "openurl")
1074 while((npos
= torun
.find("$url$")) != -1)
1075 torun
.replace(npos
, 5, param
);
1077 if(!pipe(inpipe
) && !pipe(outpipe
)) {
1078 memset(&sact
, 0, sizeof(sact
));
1079 sigaction(SIGCHLD
, &sact
, &osact
);
1083 dup2(inpipe
[1], STDOUT_FILENO
);
1084 dup2(outpipe
[0], STDIN_FILENO
);
1091 execl("/bin/sh", "/bin/sh", "-c", torun
.c_str(), (char *)NULL
);
1099 FD_SET(inpipe
[0], &rfds
);
1101 if(select(inpipe
[0]+1, &rfds
, 0, 0, 0) < 0) break; else {
1102 if(FD_ISSET(inpipe
[0], &rfds
)) {
1103 if(read(inpipe
[0], &ch
, 1) != 1) break; else {
1115 sigaction(SIGCHLD
, &osact
, 0);
1118 face
.log(_("+ launched the %s action command"), name
.c_str());
1122 string
icqconf::getprotocolname(protocolname pname
) const {
1123 static const string ptextnames
[protocolname_size
] = {
1124 "icq", "yahoo", "msn", "aim", "irc", "jab", "rss", "lj", "gg", "infocard"
1127 return ptextnames
[pname
];
1130 protocolname
icqconf::getprotocolbyletter(char letter
) const {
1132 case 'y': return yahoo
;
1133 case 'a': return aim
;
1134 case 'i': return irc
;
1135 case 'm': return msn
;
1136 case 'n': return infocard
;
1137 case 'j': return jabber
;
1138 case 'r': return rss
;
1139 case 'l': return livejournal
;
1140 case 'g': return gadu
;
1150 case '9': return icq
;
1153 return protocolname_size
;
1156 string
icqconf::getprotocolprefix(protocolname pname
) const {
1157 static const string pprefixes
[protocolname_size
] = {
1158 "", "y", "m", "a", "i", "j", "r", "l", "g", "n"
1161 return pprefixes
[pname
];
1164 imstatus
icqconf::getstatus(protocolname pname
) {
1168 imstatus st
= available
;
1169 map
<string
, string
>::iterator ia
;
1170 imaccount a
= getourid(pname
);
1172 if((ia
= a
.additional
.find("status")) != a
.additional
.end()) {
1173 if(!ia
->second
.empty()) {
1174 for(st
= offline
; st
!= imstatus_size
&& imstatus2char
[st
] != ia
->second
[0]; st
++);
1175 if(st
== imstatus_size
) st
= available
;
1182 void icqconf::savestatus(protocolname pname
, imstatus st
) {
1183 imaccount im
= getourid(pname
);
1184 im
.additional
["status"] = string(1, imstatus2char
[st
]);
1188 int icqconf::getprotcolor(protocolname pname
) const {
1190 case icq
: return getcolor(cp_clist_icq
);
1191 case yahoo
: return getcolor(cp_clist_yahoo
);
1192 case infocard
: return getcolor(cp_clist_infocard
);
1193 case msn
: return getcolor(cp_clist_msn
);
1194 case aim
: return getcolor(cp_clist_aim
);
1195 case irc
: return getcolor(cp_clist_irc
);
1196 case jabber
: return getcolor(cp_clist_jabber
);
1197 case rss
: return getcolor(cp_clist_rss
);
1198 case livejournal
: return getcolor(cp_clist_lj
);
1199 case gadu
: return getcolor(cp_clist_gadu
);
1200 default : return getcolor(cp_main_text
);
1204 int icqconf::getstatuscolor(imstatus status
) const {
1206 case offline
: return getcolor(cp_clist_offline
);
1207 case available
: return getcolor(cp_clist_online
);
1208 case invisible
: return getcolor(cp_clist_invisible
);
1209 case freeforchat
: return getcolor(cp_clist_free_for_chat
);
1210 case dontdisturb
: return getcolor(cp_clist_dnd
);
1211 case occupied
: return getcolor(cp_clist_occupied
);
1212 case notavail
: return getcolor(cp_clist_na
);
1213 case away
: return getcolor(cp_clist_away
);
1214 default : return getcolor(cp_main_text
);
1218 void icqconf::setbidi(bool fbidi
) {
1225 void icqconf::commandline(int argc
, char **argv
) {
1227 string event
, proto
, dest
, number
;
1232 for(i
= 1; i
< argc
; i
++) {
1233 string args
= argv
[i
];
1235 if((args
== "-a") || (args
== "--ascii")) {
1238 } else if((args
== "-b") || (args
== "--basedir")) {
1241 if(basedir
.substr(basedir
.size()-1) != "/") basedir
+= "/";
1244 } else if((args
== "-B") || (args
== "--bind")) {
1247 cw_setbind(bindhost
.c_str());
1250 } else if((args
== "-T") || (args
== "--no-xtitles")) {
1253 } else if((args
== "-o") || (args
== "--offline")) {
1254 startoffline
= true;
1256 } else if((args
== "-s") || (args
== "--send")) {
1257 if(argv
[++i
]) event
= argv
[i
];
1259 } else if((args
== "-p") || (args
== "--proto")) {
1260 if(argv
[++i
]) proto
= argv
[i
];
1262 } else if((args
== "-t") || (args
== "--to")) {
1263 if(argv
[++i
]) dest
= argv
[i
];
1265 } else if((args
== "-n") || (args
== "--number")) {
1266 if(argv
[++i
]) number
= argv
[i
];
1268 } else if((args
== "-S") || (args
== "--status")) {
1273 } else if((args
== "-d") || (args
== "--debug")) {
1276 } else if((args
== "-v") || (args
== "--version")) {
1277 cout
<< PACKAGE
<< " " << VERSION
<< endl
1278 << "Written by Konstantin Klyagin." << endl
1279 << "Built-in protocols are:";
1281 for(protocolname pname
= icq
; pname
!= protocolname_size
; pname
++)
1282 if(gethook(pname
).enabled()) cout
<< " " << conf
.getprotocolname(pname
);
1284 cout
<< endl
<< endl
1285 << "This is free software; see the source for copying conditions. There is NO" << endl
1286 << "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." << endl
;
1296 if(!number
.empty()) {
1297 if(event
.empty()) event
= "sms";
1298 if(proto
.empty()) proto
= "icq";
1302 constructevent(event
, proto
, dest
, number
);
1303 externalstatuschange(st
, proto
);
1306 void icqconf::constructevent(const string
&event
, const string
&proto
,
1307 const string
&dest
, const string
&number
) const {
1314 if(event
.empty() && dest
.empty()) return; else
1315 if(event
.empty() || proto
.empty() || dest
.empty()) {
1316 cout
<< _("event sending error: not enough parameters") << endl
;
1320 while(getline(cin
, buf
)) {
1321 if(!text
.empty()) text
+= "\n";
1325 if(proto
== "icq") {
1326 if(dest
.find_first_not_of("0123456789") != -1) {
1327 cout
<< _("event sending error: only UINs are allowed with icq protocol") << endl
;
1330 cdest
= imcontact(strtoul(dest
.c_str(), 0, 0), icq
);
1334 for(pname
= icq
; pname
!= protocolname_size
; pname
++) {
1335 if(getprotocolname(pname
) == proto
) {
1336 cdest
= imcontact(dest
, pname
);
1341 if(pname
== protocolname_size
) {
1342 cout
<< _("event sending error: unknown IM type") << endl
;
1347 if(event
== "msg") {
1348 ev
= new immessage(cdest
, imevent::outgoing
, text
);
1349 } else if(event
== "url") {
1352 if((pos
= text
.find("\n")) != -1) {
1353 url
= text
.substr(0, pos
);
1354 text
.erase(0, pos
+1);
1360 ev
= new imurl(cdest
, imevent::outgoing
, url
, text
);
1361 } else if(event
== "sms") {
1362 ev
= new imsms(cdest
, imevent::outgoing
, text
, number
);
1364 cout
<< _("event sending error: unknown event type") << endl
;
1369 icqcontact
*c
= new icqcontact(cdest
);
1371 if(access(c
->getdirname().c_str(), X_OK
)) {
1372 mkdir(c
->getdirname().c_str(), S_IRUSR
| S_IWUSR
| S_IXUSR
);
1373 selfsignal(SIGUSR2
);
1376 if(!access(c
->getdirname().c_str(), X_OK
)) {
1381 sprintf(buf
, _("%s to %s has been put to the queue"),
1382 streventname(ev
->gettype()),
1383 number
.empty() ? c
->getdesc().totext().c_str() : number
.c_str());
1385 cout
<< buf
<< endl
;
1387 cout
<< _("event sending error: error creating directory for the contact") << endl
;
1398 void icqconf::selfsignal(int signum
) const {
1400 ifstream
f(conf
.getconfigfname("pid").c_str());
1412 void icqconf::externalstatuschange(char st
, const string
&proto
) const {
1417 for(pname
= icq
; pname
!= protocolname_size
; pname
++)
1418 if(getprotocolname(pname
) == proto
)
1421 for(imst
= offline
; imst
!= imstatus_size
; imst
++)
1422 if(imstatus2char
[imst
] == st
)
1426 if(pname
!= protocolname_size
) {
1427 if(imst
!= imstatus_size
) {
1428 string sfname
= conf
.getconfigfname((string
) "status-" + proto
);
1429 ofstream
sf(sfname
.c_str());
1430 if(sf
.is_open()) sf
<< imstatus2char
[imst
], sf
.close();
1432 selfsignal(SIGUSR1
);
1434 throw _("unknown status character was given");
1437 throw _("unknown IM type");
1440 cout
<< _("status change error: ") << p
<< endl
;
1448 void icqconf::usage() const {
1449 cout
<< _("Usage: ") << argv0
<< " [OPTION].." << endl
;
1451 cout
<< endl
<< _("General options:") << endl
;
1452 cout
<< _(" --ascii, -a use ASCII characters for windows and UI controls") << endl
;
1453 cout
<< _(" --basedir, -b <path> set a custom base directory") << endl
;
1454 cout
<< _(" --bind, -B <host/ip> bind a custom local IP") << endl
;
1455 cout
<< _(" --no-xtitles, -T disable xterm titles") << endl
;
1456 cout
<< _(" --offline, -o set all protocols status to offline upon start") << endl
;
1457 cout
<< _(" --debug, -d enables debug info logging") << endl
;
1458 cout
<< _(" --help display this stuff") << endl
;
1459 cout
<< _(" --version, -v show the program version info") << endl
;
1461 cout
<< endl
<< _("Events sending options:") << endl
;
1462 cout
<< _(" -s, --send <event type> event type; can be msg, sms or url") << endl
;
1463 cout
<< _(" -S, --status <status> change the current IM status") << endl
;
1464 cout
<< _(" -p, --proto <protocol> protocol type; can be icq, yahoo, msn, aim, irc, jab, rss, lj, gg or infocard") << endl
;
1466 cout
<< _(" -t, --to <destination> destination UIN or nick (depends on protocol)") << endl
;
1467 cout
<< _(" -n, --number <phone#> mobile number to send an event to (sms only)") << endl
;
1469 cout
<< endl
<< _("Report bugs to <centericq-bugs@konst.org.ua>.") << endl
;
1472 void icqconf::setproxy() {
1473 if(getproxyconnect()) {
1474 cw_setproxy(gethttpproxyhost().c_str(), gethttpproxyport(),
1475 gethttpproxyuser().c_str(),
1476 gethttpproxypasswd().c_str());
1479 cw_setproxy(0, 0, 0, 0);
1484 void icqconf::setmakelog(bool slog
) {
1488 void icqconf::setproxyconnect(bool sproxy
) {
1489 proxyconnect
= sproxy
;
1493 void icqconf::setproxyssl(bool sproxyssl
) {
1494 proxyssl
= sproxyssl
;
1497 void icqconf::setgroupmode(icqconf::groupmode amode
) {
1501 void icqconf::initmultiproto(bool p
[], string buf
, bool excludenochat
) {
1505 for(pname
= icq
; pname
!= protocolname_size
; pname
++)
1506 p
[pname
] = buf
.empty();
1508 while(!(w
= getword(buf
)).empty()) {
1509 for(pname
= icq
; pname
!= protocolname_size
; pname
++) {
1510 if(getprotocolname(pname
) == w
) {
1512 p
[pname
] = !gethook(pname
).getCapabs().count(hookcapab::nochat
);
1522 void icqconf::setbrowser(const string
&abrowser
) {
1523 if (!abrowser
.empty())
1526 browser
= "mozilla";
1529 void icqconf::setsmtphost(const string
&asmtphost
) {
1535 if(!asmtphost
.empty()) {
1536 if((pos
= asmtphost
.find(":")) != -1) {
1537 smtphost
= asmtphost
.substr(0, pos
);
1538 smtpport
= atol(asmtphost
.substr(pos
+1).c_str());
1540 smtphost
= asmtphost
;
1545 if(smtphost
.empty() || !smtpport
) {
1546 smtphost
= getsmtphost();
1547 smtpport
= getsmtpport();
1551 void icqconf::sethttpproxyhost(const string
&ahttpproxyhost
) {
1557 httpproxypasswd
= "";
1559 if(!ahttpproxyhost
.empty()) {
1560 if((pos
= ahttpproxyhost
.find(":")) != -1) {
1561 if ((posn
= ahttpproxyhost
.find("@")) != -1) {
1562 httpproxyuser
= ahttpproxyhost
.substr(0, pos
);
1563 httpproxypasswd
= ahttpproxyhost
.substr(pos
+1, posn
-pos
-1);
1564 if((pos
= ahttpproxyhost
.find(":", posn
)) != -1) {
1565 httpproxyhost
= ahttpproxyhost
.substr(posn
+1, pos
-posn
-1);
1566 httpproxyport
= atol(ahttpproxyhost
.substr(pos
+1).c_str());
1569 httpproxyhost
= ahttpproxyhost
.substr(0, pos
);
1570 httpproxyport
= atol(ahttpproxyhost
.substr(pos
+1).c_str());
1573 httpproxyhost
= ahttpproxyhost
;
1574 httpproxyport
= 8080;
1581 string
icqconf::getbrowser() const {
1582 return browser
.empty() ? "mozilla" : browser
;
1585 string
icqconf::getsmtphost() const {
1586 return smtphost
.empty() ? "localhost" : smtphost
;
1589 unsigned int icqconf::getsmtpport() const {
1590 return smtpport
? smtpport
: 25;
1593 string
icqconf::gethttpproxyhost() const {
1594 return httpproxyhost
;
1597 unsigned int icqconf::gethttpproxyport() const {
1598 return httpproxyport
? httpproxyport
: 8080;
1601 string
icqconf::gethttpproxyuser() const {
1602 return httpproxyuser
;
1605 string
icqconf::gethttpproxypasswd() const {
1606 return httpproxypasswd
;
1609 void icqconf::checkdiskspace() {
1610 fenoughdiskspace
= true;
1614 if(!statfs(conf
.getdirname().c_str(), &st
)) {
1617 if(!statvfs(conf
.getdirname().c_str(), &st
)) {
1619 fenoughdiskspace
= ((double) st
.f_bavail
) * st
.f_bsize
>= 10240;
1623 void icqconf::setcharsets(const string
&from
, const string
&to
) {
1628 const char *icqconf::getconvertfrom(protocolname pname
) const {
1629 if(pname
!= protocolname_size
&& !getcpconvert(pname
)) return "iso-8859-1";
1630 return fromcharset
.c_str();
1633 const char *icqconf::getconvertto(protocolname pname
) const {
1634 if(pname
!= protocolname_size
&& !getcpconvert(pname
)) return "iso-8859-1";
1635 return tocharset
.c_str();
1638 // ----------------------------------------------------------------------------
1640 icqconf::imaccount::imaccount() {
1645 icqconf::imaccount::imaccount(protocolname apname
) {
1650 bool icqconf::imaccount::empty() const {
1651 return !uin
&& nickname
.empty();
1654 void icqconf::imaccount::write(ofstream
&f
) {
1655 string prefix
= conf
.getprotocolname(pname
) + "_";
1656 map
<string
, string
>::iterator ia
;
1659 if(!nickname
.empty()) f
<< prefix
<< "nick\t" << nickname
<< endl
;
1660 if(uin
) f
<< prefix
<< "uin\t" << uin
<< endl
;
1661 if(conf
.getsavepwd()) f
<< prefix
<< "pass\t" << password
<< endl
;
1662 if(!server
.empty()) {
1663 f
<< prefix
<< "server\t" << server
;
1664 if(port
) f
<< ":" << port
;
1668 for(ia
= additional
.begin(); ia
!= additional
.end(); ++ia
)
1669 if(!ia
->first
.empty() && !ia
->second
.empty())
1670 f
<< prefix
<< ia
->first
<< "\t" << ia
->second
<< endl
;
1673 void icqconf::imaccount::read(const string
&spec
) {
1674 int pos
= spec
.find("_");
1679 spname
= getword(buf
.erase(0, pos
+1));
1681 if(spname
== "nick") nickname
= buf
; else
1682 if(spname
== "uin") uin
= strtoul(buf
.c_str(), 0, 0); else
1683 if(spname
== "pass") password
= buf
; else
1684 if(spname
== "server") {
1685 if((pos
= buf
.find(":")) != -1) {
1686 server
= buf
.substr(0, pos
);
1687 port
= strtoul(buf
.substr(pos
+1).c_str(), 0, 0);
1693 if(server
== "icq.mirabilis.com")
1697 if(server
== "scs.yahoo.com")
1701 additional
[spname
] = buf
;
1706 bool icqconf::imaccount::operator == (protocolname apname
) const {
1707 return pname
== apname
;
1710 bool icqconf::imaccount::operator != (protocolname apname
) const {
1711 return pname
!= apname
;