75
76
fcapabs.insert(hookcapab::visibility);
76
77
fcapabs.insert(hookcapab::cltemporary);
77
78
fcapabs.insert(hookcapab::changeabout);
81
fcapabs.insert(hookcapab::pgp);
79
84
cli.connected.connect(this, &icqhook::connected_cb);
80
85
cli.disconnected.connect(this, &icqhook::disconnected_cb);
116
121
void icqhook::init() {
117
manualstatus = conf.getstatus(proto);
122
manualstatus = conf->getstatus(proto);
120
125
cli.logger.connect(this, &icqhook::logger_cb);
123
128
void icqhook::connect() {
124
icqconf::imaccount acc = conf.getourid(proto);
129
icqconf::imaccount acc = conf->getourid(proto);
125
130
int i, ptpmin, ptpmax;
128
133
if(acc.additional["webaware"].empty()) acc.additional["webaware"] = "1";
131
136
if(!acc.server.empty()) cli.setLoginServerHost(acc.server);
132
137
if(acc.port) cli.setLoginServerPort(acc.port);
134
if(!conf.getsmtphost().empty()) cli.setSMTPServerHost(conf.getsmtphost());
135
if(conf.getsmtpport()) cli.setSMTPServerPort(conf.getsmtpport());
139
if(!conf->getsmtphost().empty()) cli.setSMTPServerHost(conf->getsmtphost());
140
if(conf->getsmtpport()) cli.setSMTPServerPort(conf->getsmtpport());
137
if(!conf.getbindhost().empty()) cli.setClientBindHost(conf.getbindhost());
142
if(!conf->getbindhost().empty()) cli.setClientBindHost(conf->getbindhost());
139
conf.getpeertopeer(ptpmin, ptpmax);
144
conf->getpeertopeer(ptpmin, ptpmax);
141
146
cli.setAcceptInDC(true);
142
147
cli.setPortRangeLowerBound(ptpmin);
396
401
const immessage *m = static_cast<const immessage *> (&ev);
397
402
string text = m->gettext(), sub;
405
if ( (c!=NULL) && (pgp.enabled(ev.getcontact())) ) {
406
text = pgp.encrypt(text, c->getpgpkey(), proto);
407
text = "-----BEGIN PGP MESSAGE-----\n\n" + text + "\n-----END PGP MESSAGE-----\n";
399
411
if(ic->getStatus() == STATUS_OFFLINE)
400
412
if(text.size() > 450) {
401
413
while(!text.empty()) {
460
472
case imauthorization::Request:
461
473
sev = new AuthReqEvent(ic, ruscrlfconv("kw", m->getmessage()));
462
if(c = clist.get(ev.getcontact())) {
463
475
icqcontact::basicinfo bi = c->getbasicinfo();
464
476
bi.authawait = true;
465
477
c->setbasicinfo(bi);
639
651
void icqhook::requestinfo(const imcontact &c) {
640
652
if(logged() && c.uin) {
641
if(c == imcontact(conf.getourid(icq).uin, icq)) {
653
if(c == imcontact(conf->getourid(icq).uin, icq)) {
642
654
// Our info is requested
643
655
cli.fetchSelfDetailContactInfo();
768
780
ic->setWorkInfo(work);
769
781
ic->setAuthReq(cbinfo.requiresauth);
771
icqconf::imaccount acc = conf.getourid(icq);
783
icqconf::imaccount acc = conf->getourid(icq);
772
784
acc.additional["webaware"] = cbinfo.webaware ? "1" : "0";
773
785
acc.additional["randomgroup"] = i2str(cbinfo.randomgroup);
776
788
cli.setWebAware(cbinfo.webaware);
777
789
cli.setRandomChatGroup(cbinfo.randomgroup);
1008
1020
logger.putourstatus(icq, offline, manualstatus);
1010
cli.setRandomChatGroup(strtoul(conf.getourid(icq).additional["randomgroup"].c_str(), 0, 0));
1022
cli.setRandomChatGroup(strtoul(conf->getourid(icq).additional["randomgroup"].c_str(), 0, 0));
1012
1024
log(logLogged);
1016
ifstream f(conf.getconfigfname("icq-infoset").c_str());
1028
ifstream f(conf->getconfigfname("icq-infoset").c_str());
1018
1030
if(f.is_open()) {
1019
1031
getstring(f, buf); cli.getSelfContact()->setAlias(buf);
1025
1037
cli.getSelfContact()->getMainHomeInfo().timezone = (Timezone) getSystemTimezone();
1026
1038
cli.uploadSelfDetails();
1028
unlink(conf.getconfigfname("icq-infoset").c_str());
1040
unlink(conf->getconfigfname("icq-infoset").c_str());
1031
1043
cli.fetchServerBasedContactList();
1123
1135
text = r->getMessage();
1124
1136
if(text.substr(0, 6) == "{\\rtf1")
1125
text = fixicqrtf(striprtf(text, converted?conf.getconvertto(proto):conf.getconvertfrom(proto)));
1127
em.store(immessage(ic, imevent::incoming, converted?text:rusconv("wk", text), r->getTime()));
1137
text = fixicqrtf(striprtf(text, converted?conf->getconvertto(proto):conf->getconvertfrom(proto)));
1139
text = converted ? text : rusconv("wk", text);
1142
const string pgpBlockBegin = "-----BEGIN PGP MESSAGE-----";
1143
const string pgpBlockEnd = "-----END PGP MESSAGE-----";
1145
int pgpDataBegin = text.find(pgpBlockBegin);
1146
int pgpDataEnd = text.find(pgpBlockEnd);
1148
// find where actual PGP data starts
1149
if (pgpDataBegin != string::npos) {
1150
int a = text.find("\n\n", pgpDataBegin+1);
1151
int b = text.find("\r\n\r\n", pgpDataBegin+1);
1153
if(a != string::npos) {
1154
if(b != string::npos) {
1155
// if we found both, take the smaller value
1162
// we didn't find second match, so just take first
1166
// we didn't find first, so take whatever is in second
1171
if((pgpDataBegin != string::npos) && (pgpDataEnd != string::npos)) {
1173
enc=text.substr(pgpDataBegin, pgpDataEnd-pgpDataBegin);
1175
icqcontact *c = clist.get(ic);
1179
c->setusepgpkey(true);
1180
if(pgp.enabled(proto)) {
1181
string dec = pgp.decrypt(enc, proto);
1184
if(dec.length() != 0) {
1185
logMsg="+ "+ic.totext()+" ("+c->getdispnick()+") PGP message decoded";
1188
// if we fail to decode message,
1189
// just display it as it is
1190
logMsg="+ "+ic.totext()+" ("+c->getdispnick()+") FAILED to decode PGP message";
1192
logger.putmessage(logMsg);
1195
c->setusepgpkey(false);
1198
c->setusepgpkey(false);
1204
em.store(immessage(ic, imevent::incoming, text, r->getTime()));
1129
1206
} else if(ev->getType() == MessageEvent::URL) {
1130
1207
URLMessageEvent *r = static_cast<URLMessageEvent *>(ev);
1250
1327
rusconv("wk", r->getAwayMessage())));
1253
face.log(_("+ [icq] cannot fetch away msg from %s, %s"),
1330
face.log(_("+ [icq] cannot fetch away msg from %s, %s (maybe no away msg set)"),
1254
1331
c->getdispnick().c_str(), ic.totext().c_str());
1394
1471
if(c) ident += " (" + c->getdispnick() + ")";
1396
1473
/* logger.putmessage(buf); */
1397
ev->setAwayMessage(rusconv("kw", conf.getawaymsg(icq)));
1474
ev->setAwayMessage(rusconv("kw", conf->getawaymsg(icq)));
1400
1477
void icqhook::search_result_cb(SearchResultEvent *ev) {
1460
icqconf::imaccount im = conf.getourid(icq);
1537
icqconf::imaccount im = conf->getourid(icq);
1461
1538
icqcontact::basicinfo cbinfo = c->getbasicinfo();
1462
1539
cbinfo.webaware = im.additional["webaware"] == "1";
1463
1540
cbinfo.randomgroup = strtoul(im.additional["randomgroup"].c_str(), 0, 0);