void ICQClient::processMsgQueueSMS() { list<ICQEvent*>::iterator it; for (it = msgQueue.begin(); it != msgQueue.end();){ ICQEvent *e = *it; if (e->message() == NULL){ it++; continue; } if (e->message()->Type() != ICQ_MSGxSMS){ it++; continue; } ICQSMS *msg = static_cast<ICQSMS*>(e->message()); XmlBranch xmltree("icq_sms_message"); string destination = "+"; for (const char *p = msg->Phone.c_str(); *p; p++){ if ((*p >= '0') && (*p <= '9')) destination += *p; } string text = clearHTML(msg->Message.c_str()); toUTF(text); string sender = name(true); char uin[13]; snprintf(uin, sizeof(uin), "%lu", Uin()); xmltree.pushnode(new XmlLeaf("destination",destination)); xmltree.pushnode(new XmlLeaf("text",text)); xmltree.pushnode(new XmlLeaf("codepage","1252")); xmltree.pushnode(new XmlLeaf("encoding","urf8")); xmltree.pushnode(new XmlLeaf("senders_UIN",uin)); xmltree.pushnode(new XmlLeaf("senders_name",sender)); xmltree.pushnode(new XmlLeaf("delivery_receipt","Yes")); /* Time string, format: Wkd, DD Mnm YYYY HH:MM:SS TMZ */ char timestr[30]; time_t t; struct tm *tm; time(&t); tm = gmtime(&t); strftime(timestr, 30, "%a, %d %b %Y %T %Z", tm); xmltree.pushnode(new XmlLeaf("time",string(timestr))); string xmlstr = xmltree.toString(0); serverRequest(ICQ_SRVxREQ_MORE); writeBuffer << ICQ_SRVxREQ_SEND_SMS << 0x00010016L << 0x00000000L << 0x00000000L << 0x00000000L << 0x00000000L << (unsigned long)(xmlstr.size()); writeBuffer << xmlstr.c_str(); sendServerRequest(); msgQueue.remove(e); e->m_nId = m_nMsgSequence; varEvents.push_back(e); it = msgQueue.begin(); } }
void ICQClient::processMsgQueueAuth() { list<ICQEvent*>::iterator it; for (it = msgQueue.begin(); it != msgQueue.end();){ ICQEvent *e = *it; if (e->message() == NULL){ msgQueue.remove(e); e->state = ICQEvent::Fail; process_event(e); it = msgQueue.begin(); continue; } switch (e->message()->Type()){ case ICQ_MSGxAUTHxREQUEST:{ ICQAuthRequest *msg = static_cast<ICQAuthRequest*>(e->message()); snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_REQUEST_AUTH); ICQUser *u = getUser(msg->getUin()); writeBuffer.packUin(msg->getUin()); string message = clearHTML(msg->Message.c_str()); toServer(message, u); writeBuffer << (unsigned short)(message.length()); writeBuffer << message.c_str(); writeBuffer << (unsigned short)0; sendPacket(); (*it)->state = ICQEvent::Success; break; } case ICQ_MSGxAUTHxGRANTED:{ ICQAuthRequest *msg = static_cast<ICQAuthRequest*>(e->message()); snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_AUTHxSEND); writeBuffer.packUin(msg->getUin()); writeBuffer << (char)0x01 << (unsigned long)0; sendPacket(); (*it)->state = ICQEvent::Success; break; } case ICQ_MSGxAUTHxREFUSED:{ ICQAuthRequest *msg = static_cast<ICQAuthRequest*>(e->message()); snac(ICQ_SNACxFAM_LISTS, ICQ_SNACxLISTS_REQUEST_AUTH); ICQUser *u = getUser(msg->getUin()); writeBuffer.packUin(msg->getUin()); string message = clearHTML(msg->Message.c_str()); string original = message; toServer(message, u); writeBuffer << (char) 0 << message << (unsigned long)0x00010001; if (message == original){ writeBuffer << (unsigned char)0; }else{ string charset = "utf-8"; writeBuffer << charset; } writeBuffer << (unsigned short)0; sendPacket(); (*it)->state = ICQEvent::Success; break; } } if (e->state != ICQEvent::Success){ it++; continue; } msgQueue.remove(e); process_event(e); it = msgQueue.begin(); } }