bool LiveJournalClient::add(const char *name) { Contact *contact; LiveJournalUserData *data = findContact(name, contact, false); if (data) return false; findContact(name, contact); return true; }
void ICQClient::getEncoding(QComboBox *cmbEncoding, ICQUserData *data, bool bDefault) { string encoding; int n = cmbEncoding->currentItem(); QString t = cmbEncoding->currentText(); if (n){ n--; QStringList l; const ENCODING *e; QStringList main; for (e = ICQPlugin::core->encodings; e->language; e++){ if (!e->bMain) continue; main.append(i18n(e->language) + " (" + e->codec + ")"); } main.sort(); QStringList::Iterator it; for (it = main.begin(); it != main.end(); ++it){ l.append(*it); } QStringList noMain; for (e = ICQPlugin::core->encodings; e->language; e++){ if (e->bMain) continue; noMain.append(i18n(e->language) + " (" + e->codec + ")"); } noMain.sort(); for (it = noMain.begin(); it != noMain.end(); ++it){ l.append(*it); } for (it = l.begin(); it != l.end(); ++it){ if (n-- == 0){ QString str = *it; int n = str.find('('); str = str.mid(n + 1); n = str.find(')'); str = str.left(n); encoding = str.latin1(); break; } } } if (bDefault) ICQPlugin::core->setDefaultEncoding(encoding.c_str()); if (!set_str(&data->Encoding.ptr, encoding.c_str())) return; Contact *contact; if (data->Uin.value ? findContact(number(data->Uin.value).c_str(), NULL, false, contact) : findContact(data->Screen.ptr, NULL, false, contact)){ Event e(EventContactChanged, contact); e.process(); Event eh(EventHistoryConfig, (void*)(contact->id())); eh.process(); } }
QVariant NewsFeedModel::data(const QModelIndex &index, int role) const { int row = index.row(); auto news = m_newsList.at(row); switch (role) { case TypeRole: return news.type(); case PostIdRole: return news.postId(); break; case SourceRole: { int source = news.sourceId(); return qVariantFromValue(findContact(source)); } case DateRole: return news.date(); case BodyRole: return news.body(); case AttachmentsRole: return vk::Attachment::toVariantMap(news.attachments()); case LikesRole: return news.likes(); case RepostsRole: return news.reposts(); case CommentsRole: return news.property("comments"); case OwnerNameRole: { int ownerId = news.property("copy_owner_id").toInt(); if (ownerId) { auto contact = findContact(ownerId); return contact->name(); } return QVariant(); } case SourcePhotoRole: { if (auto contact = findContact(news.sourceId())) return contact->photoSource(); break; } case SourceNameRole: { if (auto contact = findContact(news.sourceId())) return contact->name(); break; } case LikesCount: { return news.likes().value("count").toInt(); } case CommentsCount: return news.property("comments").toMap().value("count").toInt(); default: break; } return QVariant::Invalid; }
void JabberClient::auth_request(const char *jid, unsigned type, const char *text, bool bCreate) { Contact *contact; JabberUserData *data = findContact(jid, NULL, false, contact); if (isAgent(jid)){ switch (type){ case MessageAuthRequest:{ if (data == NULL) data = findContact(jid, NULL, true, contact); m_socket->writeBuffer.packetStart(); m_socket->writeBuffer << "<presence to=\"" << data->ID << "\" type=\"subscribed\"></presence>"; sendPacket(); m_socket->writeBuffer.packetStart(); m_socket->writeBuffer << "<presence to=\"" << data->ID << "\" type=\"subscribe\"><status>" << "</status></presence>"; sendPacket(); Event e(EventContactChanged, contact); e.process(); return; } case MessageAuthGranted:{ if (data == NULL) data = findContact(jid, NULL, true, contact); Event e(EventContactChanged, contact); e.process(); return; } } } if ((data == NULL) && bCreate){ data = findContact(jid, NULL, true, contact); contact->setTemporary(CONTACT_TEMP); } if (data == NULL) return; AuthMessage msg(type); msg.setContact(contact->id()); msg.setClient(dataName(data).c_str()); msg.setFlags(MESSAGE_RECEIVED); if (text) msg.setText(unquoteString(QString::fromUtf8(text))); Event e(EventMessageReceived, &msg); e.process(); }
void NotifyProvider::LogEventL(const CLogEvent &event) { // store new call QString number=QString::fromRawData(reinterpret_cast<const QChar*>(event.Number().Ptr()),event.Number().Length()); QString direction=QString::fromRawData(reinterpret_cast<const QChar*>(event.Direction().Ptr()),event.Direction().Length()); QString description=QString::fromRawData(reinterpret_cast<const QChar*>(event.Description().Ptr()),event.Description().Length()); if (description.contains("Voice call")&&direction.contains("Missed call")) { TTime times=event.Time(); RTz tzsession; tzsession.Connect(); tzsession.ConvertToLocalTime(times); tzsession.Close(); TDateTime dts=times.DateTime(); QDate d; QTime t; d.setYMD(dts.Year(),dts.Month()+1,dts.Day()+1); t.setHMS(dts.Hour(),dts.Minute(),dts.Second()); QDateTime dt; dt.setDate(d); dt.setTime(t); dt=dt.toLocalTime(); QString time=dt.toString("d.M.yy hh:mm"); TNotifyInfo info; info.time=time; info.timeStamp=dt; info.sender=number; info.text=findContact(number); info.id=-1; info.type=EMissedCall; iNotifiers.insert(0,info); qDebug()<<"store call from"<<info.sender; prepareNotifier(EMissedCall); } }
AddressBook::AddressBook(QWidget *parent) : QWidget(parent), ui(new Ui::AddressBook) { ui->setupUi(this); ui->nameLine->setReadOnly(true); ui->addressText->setReadOnly(true); ui->submitButton->hide(); ui->cancelButton->hide(); ui->nextButton->setEnabled(false); ui->previousButton->setEnabled(false); ui->editButton->setEnabled(false); ui->removeButton->setEnabled(false); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addContact())); connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(submitContact())); connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(next())); connect(ui->previousButton, SIGNAL(clicked()), this, SLOT(previous())); connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editContact())); connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(removeContact())); //! [signal slot] connect(ui->findButton, SIGNAL(clicked()), this, SLOT(findContact())); //! [signal slot] setWindowTitle(tr("Simple Address Book")); }
void YahooClient::processStatus(unsigned short service, const char *id, const char *_state, const char *_msg, const char *_away, const char *_idle) { Contact *contact; YahooUserData *data = findContact(id, NULL, contact); if (data == NULL) return; unsigned state = 0; unsigned away = 0; unsigned idle = 0; if (_state) state = atol(_state); if (_away) away = atol(_away); if (_idle) idle = atol(_idle); if (service == YAHOO_SERVICE_LOGOFF) state = YAHOO_STATUS_OFFLINE; if ((state != data->Status.value) || ((state == YAHOO_STATUS_CUSTOM) && (((away != 0) != data->bAway.bValue) || _cmp(_msg, data->AwayMessage.ptr)))) { unsigned long old_status = STATUS_UNKNOWN; unsigned style = 0; const char *statusIcon = NULL; contactInfo(data, old_status, style, statusIcon); time_t now; time(&now); now -= idle; if (data->Status.value == YAHOO_STATUS_OFFLINE) data->OnlineTime.value = now; data->Status.value = state; data->bAway.bValue = (away != 0); data->StatusTime.value = now; unsigned long new_status = STATUS_UNKNOWN; contactInfo(data, old_status, style, statusIcon); if (old_status != new_status) { StatusMessage m; m.setContact(contact->id()); m.setClient(dataName(data).c_str()); m.setFlags(MESSAGE_RECEIVED); m.setStatus(STATUS_OFFLINE); Event e(EventMessageReceived, &m); e.process(); if ((new_status == STATUS_ONLINE) && !contact->getIgnore()) { Event e(EventContactOnline, contact); e.process(); } } else { Event e(EventContactStatus, contact); e.process(); } } }
void BuddyModel::removeFriend(int id) { int index = findContact(id); if (index == -1) return; beginRemoveRows(QModelIndex(), index, index); m_buddyList.removeAt(index); endRemoveRows(); }
bool JabberClient::isMyData(clientData *_data, Contact *&contact) { if (_data->Sign != JABBER_SIGN) return false; JabberUserData *data = (JabberUserData*)_data; if (findContact(data->ID, NULL, false, contact) == NULL) contact = NULL; return true; }
void JabberClient::auth_request(const char *jid, unsigned type, const char *text, bool bCreate) { Contact *contact; JabberUserData *data = findContact(jid, NULL, NULL, false, contact); if ((data == NULL) && bCreate){ data = findContact(jid, NULL, NULL, true, contact); contact->setTemporary(CONTACT_TEMP); } if (data == NULL) return; AuthMessage msg(type); msg.setContact(contact->id()); msg.setClient(dataName(data).c_str()); msg.setFlags(MESSAGE_RECEIVED); if (text) msg.setText(QString::fromUtf8(unquoteText(text).c_str())); Event e(EventMessageReceived, &msg); e.process(); }
void YahooClient::loadList(const char *str) { Contact *contact; ContactList::ContactIterator it; while ((contact = ++it) != NULL) { YahooUserData *data; ClientDataIterator itd(contact->clientData, this); while ((data = (YahooUserData*)(++itd)) != NULL) { data->bChecked.bValue = (contact->getGroup() == 0); } } if (str) { string s = str; while (!s.empty()) { string line = getToken(s, '\n'); string grp = getToken(line, ':'); if (line.empty()) { line = grp; grp = ""; } while (!line.empty()) { string id = getToken(line, ','); Contact *contact; YahooUserData *data = findContact(id.c_str(), grp.c_str(), contact, false); data->bChecked.bValue = true; } } } it.reset(); list<Contact*> forRemove; while ((contact = ++it) != NULL) { YahooUserData *data; ClientDataIterator itd(contact->clientData, this); list<YahooUserData*> dataForRemove; bool bChanged = false; while ((data = (YahooUserData*)(++itd)) != NULL) { if (!data->bChecked.bValue) { dataForRemove.push_back(data); bChanged = true; } } if (!bChanged) continue; for (list<YahooUserData*>::iterator it = dataForRemove.begin(); it != dataForRemove.end(); ++it) contact->clientData.freeData(*it); if (contact->clientData.size()) { Event e(EventContactChanged, contact); e.process(); } else { forRemove.push_back(contact); } } for (list<Contact*>::iterator itr = forRemove.begin(); itr != forRemove.end(); ++itr) delete *itr; }
ICQUserData *ICQClient::findInfoRequest(unsigned short seq, Contact *&contact) { INFO_REQ_MAP::iterator it = m_info_req.find(seq); if (it == m_info_req.end()){ log(L_WARN, "Info req %u not found", seq); return NULL; } string screen = (*it).second; m_info_req.erase(it); return findContact(screen.c_str(), NULL, false, contact); }
bool SSIManager::removeContact( const QString &contact ) { Oscar::SSI ct = findContact( contact ); if ( ct.isValid() && removeContact( ct ) ) return true; else kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Contact " << contact << " not found." << endl; return false; }
void promptDel() { contact *ptr; ptr = findContact(); if(ptr != NULL) { ptr = remove(ptr); free(ptr); puts("Contact removed."); } else { puts("No such contact found."); } }
void LiveJournalClient::statusChanged() { Contact *contact = NULL; ContactList::ContactIterator it; while ((contact = ++it) != NULL) { ClientDataIterator itc(contact->clientData, this); if ((++itc) != NULL) { Event e(EventContactChanged, contact); e.process(); } } findContact(data.owner.User.ptr, contact); }
void YahooClient::messageReceived(Message *msg, const char *id) { msg->setFlags(msg->getFlags() | MESSAGE_RECEIVED); if (msg->contact() == 0) { Contact *contact; YahooUserData *data = findContact(id, NULL, contact); if (data == NULL) { data = findContact(id, "", contact); if (data == NULL) { delete msg; return; } contact->setTemporary(CONTACT_TEMP); Event e(EventContactChanged, contact); e.process(); } msg->setClient(dataName(data).c_str()); msg->setContact(contact->id()); } Event e(EventMessageReceived, msg); e.process(); }
void promptEdit() { contact *ptr; char data[32]; char number[8]; memset(number, 0, 8); ptr = findContact(); if(ptr == NULL) { puts("No such contact."); return; } editUser(ptr); }
bool JabberClient::isMyData(clientData *&_data, Contact *&contact) { if (_data->Sign != JABBER_SIGN) return false; JabberUserData *data = (JabberUserData*)_data; JabberUserData *my_data = findContact(data->ID, NULL, false, contact); if (my_data){ data = my_data; }else{ contact = NULL; } return true; }
void JabberClient::setOffline(JabberUserData *data) { data->Status = STATUS_OFFLINE; data->composeId = 0; if (data->TypingId && *data->TypingId){ set_str(&data->TypingId, NULL); Contact *contact; if (findContact(data->ID, NULL, false, contact)){ Event e(EventContactStatus, contact); e.process(); } } }
void LiveJournalClient::messageUpdated() { Contact *contact; LiveJournalUserData *data = findContact(this->data.owner.User.ptr, contact); if (data == NULL) return; Message *msg = new Message(MessageUpdated); msg->setContact(contact->id()); msg->setClient(dataName(data).c_str()); msg->setFlags(MESSAGE_TEMP | MESSAGE_NOVIEW); Event e(EventMessageReceived, msg); if (!e.process()) delete msg; }
void BusinessCardHandling::storeAvatarToContact(QString phoneNumber, QString filename, QPixmap pixmap) { // Create QContactManager if (!m_contactManager) { createContactManager(); } // Search contacts and save avatar QContact contact; if (findContact(phoneNumber, contact)) { saveAvatar(filename, pixmap, contact); } }
void YahooClient::notify(const char *id, const char *msg, const char *state) { Contact *contact; YahooUserData *data = findContact(id, NULL, contact); if (data == NULL) return; bool bState = false; if (state && atol(state)) bState = true; if (!strcasecmp(msg, "TYPING")) { if (data->bTyping.bValue != bState) { data->bTyping.bValue = bState; Event e(EventContactStatus, contact); e.process(); } } }
bool JabberClient::add_contact(const char *jid) { Contact *contact; if (findContact(jid, NULL, false, contact)) { Event e(EventContactChanged, contact); e.process(); return false; } AddRequest *req = new AddRequest(this, jid); req->start_element("query"); req->add_attribute("xmlns", "jabber:iq:roster"); req->start_element("item"); req->add_attribute("jid", jid); req->send(); m_requests.push_back(req); return true; }
int main(void) { int key; init(); while(1) { printf("\n 1.Add New Contact\n"); printf("\n 2.Find Contact\n"); printf("\n 3.Delete Contact\n"); printf("\n 3.Update Contact\n"); printf("\n Enter the choice\n"); scanf("%d",&key); switch(key) { case 1: addContact(); break; case 2: { char *p ="123"; Contact *a = findContact(p); if(a) { printf("%s \n %s\n%s \n%s",a->firstName,a->secondName,a->firstNumber,a->secondNumber); } break; } case 3: deleteContact(); break; case 4: updateContact(); break; case 0: default: { close(); printf("\n : Exitting\n"); } return 0; } } return 0; }
void NotifyProvider::GotSMSMessageL(QString txt, const TPtrC aSender,TInt32 id) { // new sms QString number=QString::fromRawData(reinterpret_cast<const QChar*>(aSender.Ptr()),aSender.Length()); //QString txt=QString::fromRawData(reinterpret_cast<const QChar*>(aMessage.Ptr()),aMessage.Length());; QDateTime dt=QDateTime::currentDateTime(); dt=dt.toLocalTime(); TNotifyInfo info; info.time=dt.toString("dd.M.yy hh:ss"); info.timeStamp=dt; info.sender=findContact(number); info.text=txt; info.type=ESMS; info.id=id; iNotifiers.insert(0,info); qDebug()<<"store sms from"<<info.sender<<info.text; qDebug()<<"id"<<id; prepareNotifier(ESMS); }
void JabberClient::add_contact(const char *id, const char *host) { Contact *contact; if (findContact(id, host, NULL, false, contact)){ Event e(EventContactChanged, contact); e.process(); return; } string name = id; name += '@'; name += host; AddRequest *req = new AddRequest(this, id, host); req->start_element("query"); req->add_attribute("xmlns", "jabber:iq:roster"); req->start_element("item"); req->add_attribute("jid", name.c_str()); req->send(); m_requests.push_back(req); }
bool SSIManager::updateContact( const Oscar::SSI& contact ) { Oscar::SSI oldContact = findContact( contact.name() ); if ( oldContact.isValid() ) { removeID( oldContact ); d->SSIList.remove( oldContact ); } if ( d->SSIList.findIndex( contact ) != -1 ) { kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "New contact is already in list." << endl; return false; } kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Updating contact '" << contact.name() << "' in SSI list" << endl; addID( contact ); d->SSIList.append( contact ); emit contactUpdated( contact ); return true; }
AddressBook::AddressBook(QWidget *parent) : QWidget(parent) { QLabel *nameLabel = new QLabel(tr("Name:")); nameLine = new QLineEdit; nameLine->setReadOnly(true); QLabel *addressLabel = new QLabel(tr("Address:")); addressText = new QTextEdit; addressText->setReadOnly(true); addButton = new QPushButton(tr("&Add")); editButton = new QPushButton(tr("&Edit")); editButton->setEnabled(false); removeButton = new QPushButton(tr("&Remove")); removeButton->setEnabled(false); findButton = new QPushButton(tr("&Find")); findButton->setEnabled(false); submitButton = new QPushButton(tr("&Submit")); submitButton->hide(); cancelButton = new QPushButton(tr("&Cancel")); cancelButton->hide(); nextButton = new QPushButton(tr("&Next")); nextButton->setEnabled(false); previousButton = new QPushButton(tr("&Previous")); previousButton->setEnabled(false); loadButton = new QPushButton(tr("&Load...")); //! [tooltip 1] loadButton->setToolTip(tr("Load contacts from a file")); //! [tooltip 1] saveButton = new QPushButton(tr("&Save...")); //! [tooltip 2] saveButton->setToolTip(tr("Save contacts to a file")); //! [tooltip 2] saveButton->setEnabled(false); dialog = new FindDialog; connect(addButton, SIGNAL(clicked()), this, SLOT(addContact())); connect(submitButton, SIGNAL(clicked()), this, SLOT(submitContact())); connect(editButton, SIGNAL(clicked()), this, SLOT(editContact())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeContact())); connect(findButton, SIGNAL(clicked()), this, SLOT(findContact())); connect(nextButton, SIGNAL(clicked()), this, SLOT(next())); connect(previousButton, SIGNAL(clicked()), this, SLOT(previous())); connect(loadButton, SIGNAL(clicked()), this, SLOT(loadFromFile())); connect(saveButton, SIGNAL(clicked()), this, SLOT(saveToFile())); QVBoxLayout *buttonLayout1 = new QVBoxLayout; buttonLayout1->addWidget(addButton); buttonLayout1->addWidget(editButton); buttonLayout1->addWidget(removeButton); buttonLayout1->addWidget(findButton); buttonLayout1->addWidget(submitButton); buttonLayout1->addWidget(cancelButton); buttonLayout1->addWidget(loadButton); buttonLayout1->addWidget(saveButton); buttonLayout1->addStretch(); QHBoxLayout *buttonLayout2 = new QHBoxLayout; buttonLayout2->addWidget(previousButton); buttonLayout2->addWidget(nextButton); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(nameLabel, 0, 0); mainLayout->addWidget(nameLine, 0, 1); mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop); mainLayout->addWidget(addressText, 1, 1); mainLayout->addLayout(buttonLayout1, 1, 2); mainLayout->addLayout(buttonLayout2, 2, 1); setLayout(mainLayout); setWindowTitle(tr("Simple Address Book")); }
AddressBook::AddressBook(QWidget *parent) : QWidget(parent) { QLabel *nameLabel = new QLabel(tr("Name:")); nameLine = new QLineEdit; nameLine->setReadOnly(true); QLabel *addressLabel = new QLabel(tr("Address:")); addressText = new QTextEdit; addressText->setReadOnly(true); addButton = new QPushButton(tr("&Add")); editButton = new QPushButton(tr("&Edit")); editButton->setEnabled(false); removeButton = new QPushButton(tr("&Remove")); removeButton->setEnabled(false); //! [instantiating findButton] findButton = new QPushButton(tr("&Find")); findButton->setEnabled(false); //! [instantiating findButton] submitButton = new QPushButton(tr("&Submit")); submitButton->hide(); cancelButton = new QPushButton(tr("&Cancel")); cancelButton->hide(); nextButton = new QPushButton(tr("&Next")); nextButton->setEnabled(false); previousButton = new QPushButton(tr("&Previous")); previousButton->setEnabled(false); //! [instantiating FindDialog] dialog = new FindDialog; //! [instantiating FindDialog] connect(addButton, SIGNAL(clicked()), this, SLOT(addContact())); connect(submitButton, SIGNAL(clicked()), this, SLOT(submitContact())); connect(editButton, SIGNAL(clicked()), this, SLOT(editContact())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeContact())); //! [signals and slots for find] connect(findButton, SIGNAL(clicked()), this, SLOT(findContact())); //! [signals and slots for find] connect(nextButton, SIGNAL(clicked()), this, SLOT(next())); connect(previousButton, SIGNAL(clicked()), this, SLOT(previous())); QVBoxLayout *buttonLayout1 = new QVBoxLayout; buttonLayout1->addWidget(addButton); buttonLayout1->addWidget(editButton); buttonLayout1->addWidget(removeButton); //! [adding findButton to layout] buttonLayout1->addWidget(findButton); //! [adding findButton to layout] buttonLayout1->addWidget(submitButton); buttonLayout1->addWidget(cancelButton); buttonLayout1->addStretch(); QHBoxLayout *buttonLayout2 = new QHBoxLayout; buttonLayout2->addWidget(previousButton); buttonLayout2->addWidget(nextButton); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(nameLabel, 0, 0); mainLayout->addWidget(nameLine, 0, 1); mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop); mainLayout->addWidget(addressText, 1, 1); mainLayout->addLayout(buttonLayout1, 1, 2); mainLayout->addLayout(buttonLayout2, 2, 1); setLayout(mainLayout); setWindowTitle(tr("Simple Address Book")); }
void ICQClient::snac_icmb(unsigned short type, unsigned short seq) { switch (type){ case ICQ_SNACxMSG_RIGHTSxGRANTED: log(L_DEBUG, "Message rights granted"); break; case ICQ_SNACxMSG_MTN:{ m_socket->readBuffer.incReadPos(10); string screen = m_socket->readBuffer.unpackScreen(); unsigned short type; m_socket->readBuffer >> type; bool bType = (type > 1); Contact *contact; ICQUserData *data = findContact(screen.c_str(), NULL, false, contact); if (data == NULL) break; if ((bool)(data->bTyping) == bType) break; data->bTyping = bType; Event e(EventContactStatus, contact); e.process(); break; } case ICQ_SNACxMSG_ERROR:{ unsigned short error; m_socket->readBuffer >> error; const char *err_str = I18N_NOOP("Unknown error"); if (error == 0x0009){ err_str = I18N_NOOP("Not supported by client"); Contact *contact; ICQUserData *data = findContact(m_send.screen.c_str(), NULL, false, contact); if (data){ for (list<SendMsg>::iterator it = sendQueue.begin(); it != sendQueue.end();){ if ((*it).screen != m_send.screen){ ++it; continue; } if ((*it).msg){ (*it).flags = 0; ++it; continue; } sendQueue.erase(it); it = sendQueue.begin(); } data->bBadClient = true; if (m_send.msg) sendThruServer(m_send.msg, data); m_send.msg = NULL; m_send.screen = ""; m_sendTimer->stop(); send(true); break; } }else{ err_str = error_message(error); } if (m_send.msg){ if ((m_send.msg->type() == MessageCheckInvisible) && (error == 14)) { Contact *contact; ICQUserData *data = findContact(m_send.screen.c_str(), NULL, false, contact); if (data && (data->bInvisible == 0)) { data->bInvisible = true; Event e(EventContactStatus, contact); e.process(); } } else { m_send.msg->setError(err_str); Event e(EventMessageSent, m_send.msg); e.process(); } delete m_send.msg; } m_send.msg = NULL; m_send.screen = ""; m_sendTimer->stop(); send(true); break; } case ICQ_SNACxMSG_SRV_MISSED_MSG: { unsigned short mFormat; // missed channel string screen; // screen unsigned short wrnLevel;// warning level unsigned short nTlv; // number of tlvs TlvList lTlv; // all tlvs in message unsigned short missed; // number of missed messages unsigned short error; // error reason m_socket->readBuffer >> mFormat; screen = m_socket->readBuffer.unpackScreen(); m_socket->readBuffer >> wrnLevel; m_socket->readBuffer >> nTlv; for(unsigned short i = 0; i < nTlv; i++) { unsigned short num; unsigned short size; const char* data; m_socket->readBuffer >> num >> size; data = m_socket->readBuffer.data(m_socket->readBuffer.readPos()); Tlv* tlv = new Tlv(num,size,data); lTlv = lTlv + tlv; } m_socket->readBuffer >> missed >> error; const char *err_str = NULL; switch (error) { case 0x00: err_str = I18N_NOOP("Invalid message"); break; case 0x01: err_str = I18N_NOOP("Message was too large"); break; case 0x02: err_str = I18N_NOOP("Message rate exceeded"); break; case 0x03: err_str = I18N_NOOP("Sender too evil"); break; case 0x04: err_str = I18N_NOOP("We are to evil :("); break; default: err_str = I18N_NOOP("Unknown error"); } log(L_DEBUG, "ICMB error %u (%s) - screen(%s)", error, err_str, screen.c_str()); break; } case ICQ_SNACxMSG_BLAMExSRVxACK: if ((m_send.id.id_l == seq) && m_send.msg){ unsigned short oldLevel, newLevel; m_socket->readBuffer >> oldLevel >> newLevel; WarningMessage *msg = static_cast<WarningMessage*>(m_send.msg); msg->setOldLevel(newLevel - oldLevel); msg->setNewLevel(newLevel); ackMessage(m_send); } break; case ICQ_SNACxMSG_ACK: { log(L_DEBUG, "Ack message"); MessageId id; m_socket->readBuffer >> id.id_l >> id.id_h; m_socket->readBuffer.incReadPos(2); string screen = m_socket->readBuffer.unpackScreen(); bool bAck = false; if (m_send.id == id){ const char *p1 = screen.c_str(); const char *p2 = m_send.screen.c_str(); for (; *p1 && *p2; p1++, p2++) if (tolower(*p1) != tolower(*p2)) break; if ((*p1 == 0) && (*p2 == 0)) bAck = true; } if (bAck){ if (m_send.msg){ if (m_send.msg->type() == MessageCheckInvisible){ Contact *contact; ICQUserData *data = findContact(m_send.screen.c_str(), NULL, false, contact); if (data && !(bool)(data->bInvisible)) { data->bInvisible = true; Event e(EventContactStatus, contact); e.process(); } delete m_send.msg; }else{ Contact *contact; ICQUserData *data = findContact(screen.c_str(), NULL, false, contact); if ((data == NULL) || (data->Status == ICQ_STATUS_OFFLINE)){ ackMessage(m_send); }else{ replyQueue.push_back(m_send); } } }else{ replyQueue.push_back(m_send); } } m_send.msg = NULL; m_send.screen = ""; m_sendTimer->stop(); send(true); break; } case ICQ_SNACxMSG_AUTOREPLY:{ MessageId id; m_socket->readBuffer >> id.id_l >> id.id_h; m_socket->readBuffer.incReadPos(2); string screen = m_socket->readBuffer.unpackScreen(); m_socket->readBuffer.incReadPos(2); unsigned short len; m_socket->readBuffer.unpack(len); m_socket->readBuffer.incReadPos(2); plugin p; m_socket->readBuffer.unpack((char*)p, sizeof(p)); m_socket->readBuffer.incReadPos(len - sizeof(plugin) + 2); m_socket->readBuffer.unpack(len); m_socket->readBuffer.incReadPos(len + 12); unsigned short ackFlags, msgFlags; m_socket->readBuffer.unpack(ackFlags); m_socket->readBuffer.unpack(msgFlags); list<SendMsg>::iterator it; for (it = replyQueue.begin(); it != replyQueue.end(); ++it){ SendMsg &s = *it; if ((s.id == id) && (s.screen == screen)) break; } if (it == replyQueue.end()) break; unsigned plugin_type = (*it).flags; if ((*it).msg){ string answer; m_socket->readBuffer >> answer; if (ackMessage((*it).msg, ackFlags, answer.c_str())){ ackMessage(*it); }else{ Event e(EventMessageSent, (*it).msg); e.process(); delete (*it).msg; } replyQueue.erase(it); break; } replyQueue.erase(it); Contact *contact; ICQUserData *data = findContact(screen.c_str(), NULL, false, contact); if (memcmp(p, plugins[PLUGIN_NULL], sizeof(plugin))){ unsigned plugin_index; for (plugin_index = 0; plugin_index < PLUGIN_NULL; plugin_index++){ if (memcmp(p, plugins[plugin_index], sizeof(plugin)) == 0) break; } if (plugin_index == PLUGIN_NULL){ string plugin_str; unsigned i; for (i = 0; i < sizeof(plugin); i++){ char b[4]; sprintf(b, "%02X ", p[i]); plugin_str += b; } log(L_DEBUG, "Unknown plugin sign in reply %s", plugin_str.c_str()); break; } if ((data == NULL) && (plugin_index != PLUGIN_RANDOMxCHAT)) break; parsePluginPacket(m_socket->readBuffer, plugin_type, data, atol(screen.c_str()), false); break; } if (plugin_type == PLUGIN_AR){ string answer; m_socket->readBuffer >> answer; log(L_DEBUG, "Autoreply from %s %s", screen.c_str(), answer.c_str()); Contact *contact; ICQUserData *data = findContact(screen.c_str(), NULL, false, contact); if (data && set_str(&data->AutoReply, answer.c_str())){ Event e(EventContactChanged, contact); e.process(); } }