void MsgEdit::fillPhones() { phoneEdit->clear(); ICQUser *u = pClient->getUser(Uin); if (u == NULL) return; for (PhoneBook::iterator it = u->Phones.begin(); it != u->Phones.end(); it++){ PhoneInfo *phone = static_cast<PhoneInfo*>(*it); if (phone->Type != SMS) continue; phoneEdit->insertItem(phone->getNumber().c_str()); QString t = phoneEdit->lineEdit()->text(); if (phoneEdit->lineEdit()->text().length() == 0) phoneEdit->lineEdit()->setText(QString::fromLocal8Bit(phone->getNumber().c_str())); } }
void MainInfo::load(ICQUser *u) { if (u->Type == USER_TYPE_ICQ){ edtUin->setText(QString::number(u->Uin)); edtFirst->setReadOnly(bReadOnly); edtLast->setReadOnly(bReadOnly); edtNick->setReadOnly(bReadOnly); edtUin->show(); lblUin->show(); lineDiv->show(); } cmbEncoding->setCurrentItem(pClient->userEncoding(u->Uin)); edtFirst->setText(QString::fromLocal8Bit(u->FirstName.c_str())); edtLast->setText(QString::fromLocal8Bit(u->LastName.c_str())); edtNotes->setText(QString::fromLocal8Bit(u->Notes.c_str())); edtNick->setText(QString::fromLocal8Bit(u->Nick.c_str())); QStringList strDisplay; cmbDisplay->lineEdit()->setText(QString::fromLocal8Bit(u->Alias.c_str())); addString(strDisplay, QString::fromLocal8Bit(u->Nick.c_str())); addString(strDisplay, QString::fromLocal8Bit(u->FirstName.c_str()) + " " + QString::fromLocal8Bit(u->LastName.c_str())); addString(strDisplay, QString::fromLocal8Bit(u->LastName.c_str()) + " " + QString::fromLocal8Bit(u->FirstName.c_str())); addString(strDisplay, QString::fromLocal8Bit(u->FirstName.c_str())); addString(strDisplay, QString::fromLocal8Bit(u->LastName.c_str())); if (u->Type == USER_TYPE_EXT){ for (PhoneBook::iterator itPhone = u->Phones.begin(); itPhone != u->Phones.end(); ++itPhone){ PhoneInfo *info = static_cast<PhoneInfo*>(*itPhone); addString(strDisplay, QString::fromLocal8Bit(info->getNumber().c_str())); } for (EMailList::iterator itMail = u->EMails.begin(); itMail != u->EMails.end(); ++itMail){ EMailInfo *info = static_cast<EMailInfo*>(*itMail); addString(strDisplay, QString::fromLocal8Bit(info->Email.c_str())); } } cmbDisplay->clear(); cmbDisplay->insertStringList(strDisplay); CUser user(u); cmbDisplay->lineEdit()->setText(user.name()); mails = u->EMails; for (EMailList::iterator it = mails.begin(); it != mails.end(); it++){ EMailInfo *email = static_cast<EMailInfo*>(*it); lstEmail->insertItem(Pict("mail_generic"), QString::fromLocal8Bit(email->Email.c_str())); } reloadList(); setButtons(-1); }
void MsgEdit::send() { if (msg->Type() == ICQ_MSGxSMS){ ICQUser *u = pClient->getUser(Uin); if (u){ string msgPhone; msgPhone = phoneEdit->lineEdit()->text().local8Bit(); PhoneBook::iterator it; for (it = u->Phones.begin(); it != u->Phones.end(); it++){ PhoneInfo *phone = static_cast<PhoneInfo*>(*it); if (phone->Type != SMS) continue; if (phone->getNumber() == msgPhone) break; } if (it == u->Phones.end()){ PhoneInfo *phone = new PhoneInfo; phone->setNumber(msgPhone.c_str(), SMS); phone->MyInfo = true; u->Phones.push_back(phone); ICQEvent e(EVENT_INFO_CHANGED, Uin); pClient->process_event(&e); } } } if (pMain->SpellOnSend){ switch (msg->Type()){ case ICQ_MSGxSMS: case ICQ_MSGxMSG: case ICQ_MSGxURL: case ICQ_MSGxFILE: case ICQ_MSGxCHAT: connect(edit, SIGNAL(spellDone(bool)), this, SLOT(spellDone(bool))); edit->spell(); return; default: break; } } makeMessage(); }
void ICQClient::snac_message(unsigned short type, unsigned short) { switch (type){ case ICQ_SNACxMSG_RIGHTSxGRANTED: log(L_DEBUG, "Message rights granted"); break; case ICQ_SNACxMSG_ACK: log(L_DEBUG, "Ack message"); break; case ICQ_SNACxMSG_AUTOREPLY:{ unsigned long timestamp1, timestamp2; readBuffer >> timestamp1 >> timestamp2; readBuffer.incReadPos(2); unsigned long uin = readBuffer.unpackUin(); readBuffer.incReadPos(6); unsigned long t1, t2; readBuffer >> t1 >> t2; unsigned short seq; readBuffer.incReadPos(0x0F); readBuffer >> seq; if ((t1 == 0) && (t2 == 0)){ readBuffer.incReadPos(0x16); string answer; readBuffer >> answer; fromServer(answer); if (timestamp1 || timestamp2){ log(L_DEBUG, "Message declined %s", answer.c_str()); list<ICQEvent*>::iterator it; for (it = processQueue.begin(); it != processQueue.end(); ++it){ ICQEvent *e = *it; if (e->type() != EVENT_MESSAGE_SEND) continue; ICQMessage *msg = e->message(); if (msg == NULL) continue; if ((msg->Uin == uin) && (msg->timestamp1 == timestamp1) && (msg->timestamp2 == timestamp2)){ msg->DeclineReason = answer; cancelMessage(msg, false); break; } } if (it == processQueue.end()) log(L_WARN, "Decline file answer: message not found"); }else{ log(L_DEBUG, "[%X] Autoreply from %u %s", seq, uin, answer.c_str()); ICQUser *u = getUser(uin); if (u) u->AutoReply = answer; ICQEvent e(EVENT_STATUS_CHANGED, uin); process_event(&e); processResponseRequestQueue(seq); } } if ((t1 == 0xA0E93F37L) && (t2 == 0x4FE9D311L)){ ICQUser *u = getUser(uin); if (u == NULL){ log(L_WARN, "Request info no my user %lu", uin); return; } if (u->inIgnore()){ log(L_WARN, "Request info ignore user %lu", uin); return; } readBuffer.incReadPos(0x1D); unsigned long cookie; readBuffer >> cookie; readBuffer.incReadPos(4); readBuffer.unpack(t1); if (t1 == 3){ u->PhoneBookTime = (unsigned long)htonl(cookie); u->bPhoneChanged = false; log(L_DEBUG, "[%X] Phone book info %u", seq, uin); PhoneBook::iterator it; PhonePtrList myNumbers; for (it = u->Phones.begin(); it != u->Phones.end(); ++it){ PhoneInfo *phone = static_cast<PhoneInfo*>(*it); if (!phone->MyInfo()) continue; PhoneInfo *myPhone = new PhoneInfo; *myPhone = *phone; myNumbers.push_back(myPhone); } u->Phones.clear(); unsigned long nPhones; readBuffer.unpack(nPhones); for (unsigned i = 0; i < nPhones; i++){ PhoneInfo *phone = new PhoneInfo; u->Phones.push_back(phone); readBuffer.unpackStr32(phone->Name); readBuffer.unpackStr32(phone->AreaCode); readBuffer.unpackStr32(phone->Number); readBuffer.unpackStr32(phone->Extension); readBuffer.unpackStr32(phone->Country); unsigned long type; readBuffer.unpack(type); if (type) phone->Active = true; if (readBuffer.readPos() >= readBuffer.size()) break; } for (it = u->Phones.begin(); it != u->Phones.end(); it++){ PhoneInfo *phone = static_cast<PhoneInfo*>(*it); string prop; readBuffer.unpackStr32(prop); Buffer b; b.pack(prop.c_str(), prop.length()); b.unpack(phone->Type); b.unpackStr32(phone->Provider); if (readBuffer.readPos() >= readBuffer.size()) break; } for (;;){ for (it = u->Phones.begin(); it != u->Phones.end(); it++){ PhoneInfo *phone = static_cast<PhoneInfo*>(*it); bool bOK = (phone->getNumber().length() > 0); if (bOK && !*phone->Number.c_str()) bOK = false; if (bOK) for (const char *p = phone->Number.c_str(); *p; p++){ if ((*p >= '0') && (*p <= '9')) continue; if ((*p == ' ') || (*p == '-')) continue; bOK = false; break; } if (bOK) continue; u->Phones.remove(phone); break; } if (it == u->Phones.end()) break; } u->adjustPhones(); u->Phones.add(myNumbers); ICQEvent e(EVENT_INFO_CHANGED, uin); process_event(&e); processPhoneRequestQueue(seq); } } break; }
QString CUser::toolTip() { if (u == NULL) return ""; QString r; QString s; r = "<nobr>"; r += name(true); r += "</nobr>"; if (u->Uin < UIN_SPECIAL) r += s.sprintf("<br><nobr><font size=-1>UIN:</font> %lu</nobr>", u->Uin); QString sFirstName = firstName(true); QString sLastName = lastName(true); if (sFirstName.length() || sLastName.length()){ r += "<br>"; r += sFirstName; r += " "; r += sLastName; } QString sEmail = email(true); if (sEmail.length()){ r += "<br>"; r += sEmail; } if (u->uStatus == ICQ_STATUS_OFFLINE){ if (u->StatusTime){ r += "<br>_____________"; r += "<br><font size=-1>"; r += i18n("Last online"); r += ": </font>"; r += statusTime(); } }else{ if (u->OnlineTime){ r += "<br>_____________"; r += "<br><font size=-1>"; r += i18n("Online"); r += ": </font>"; r += onlineTime(); } if (u->uStatus & (ICQ_STATUS_AWAY | ICQ_STATUS_NA)){ r += "<br><font size=-1>"; r += SIMClient::getStatusText(u->uStatus); r += ": </font>"; r += statusTime(); } } if (u->IP || u->RealIP){ r += "<br>"; r += addr(); } bool isDiv = false; PhoneBook::iterator it; for (it = u->Phones.begin(); it != u->Phones.end(); it++){ PhoneInfo *phone = static_cast<PhoneInfo*>(*it); if (phone->Type != SMS) continue; if (!isDiv){ r += "<br>_____________"; isDiv = true; } r += "<br><img src=\"icon:cell\">"; r += pClient->from8Bit(u->Uin, phone->getNumber().c_str()); } for (it = u->Phones.begin(); it != u->Phones.end(); it++){ PhoneInfo *phone = static_cast<PhoneInfo*>(*it); if (!phone->Active) continue; if (!isDiv){ r += "<br>_____________"; isDiv = true; } r += "<br><img src=\"icon:phone\">"; r += pClient->from8Bit(u->Uin, phone->getNumber().c_str()); } QString sAutoReply = autoReply(true); if (sAutoReply.length()){ r += "<br>_____________<br>"; r += sAutoReply; } QString sClient = client(); if (!sClient.isEmpty()){ r += "<br>_____________<br>"; r += sClient; } return r; }
void MsgEdit::action(int type, bool bSaveEdit) { if (type == mnuMail){ pMain->sendMail(Uin); return; } if (sendEvent) return; if (Uin == 0) log(L_WARN, "Bad UIN for message create"); if ((type == mnuAction) || (type == mnuActionInt)){ if ((type == mnuAction) && canSend()) return; ICQUser *u = pClient->getUser(Uin); if (u && u->unreadMsgs.size()){ ICQMessage *msg = history()->getMessage(u->unreadMsgs.front()); if (msg){ setMessage(msg, true, true); setState(); return; } } if (u && (u->Type == USER_TYPE_EXT)){ PhoneBook::iterator it; for (it = u->Phones.begin(); it != u->Phones.end(); ++it){ PhoneInfo *info = static_cast<PhoneInfo*>(*it); if (info->Type() == SMS){ type = mnuSMS; break; } } if (type == mnuActionInt){ pMain->sendMail(u->Uin); return; } }else{ type = mnuMessage; } } ICQMessage *editMsg = NULL; switch (type){ case mnuMessage: editMsg = new ICQMsg; editMsg->Uin.push_back(Uin); break; case mnuURL: editMsg = new ICQUrl; editMsg->Uin.push_back(Uin); break; case mnuSMS: editMsg = new ICQSMS; editMsg->Uin.push_back(Uin); break; case mnuAuth: editMsg = new ICQAuthRequest; editMsg->Uin.push_back(Uin); break; case mnuContacts: editMsg = new ICQContacts; editMsg->Uin.push_back(Uin); break; case mnuFile: editMsg = new ICQFile; editMsg->Uin.push_back(Uin); break; case mnuChat: editMsg = new ICQChat; editMsg->Uin.push_back(Uin); break; default: log(L_WARN, "Unknown message type: %u", type); } setMessage(editMsg, false, false, bSaveEdit); setState(); }