Poco::SharedPtr<MessageData> Util::dataFromMessage(const MessageRef &message) { int messageType = message->GetProp(Message::P_TYPE).toInt(); SEString author; SEString authorName; SEString bodyXmlString; unsigned int timeStamp; message->GetPropAuthor(author); message->GetPropAuthorDisplayname(authorName); message->GetPropBodyXml(bodyXmlString); message->GetPropTimestamp(timeStamp); Poco::SharedPtr<MessageData> data = new MessageData; data->author = author.data(); data->authorDisplayname = authorName.data(); data->body = bodyXmlString.data(); data->timestamp = timeStamp; data->isEmote = (messageType == Message::POSTED_EMOTE); return data; }
void MyConversation::OnMessage (const MessageRef &message) { int messageType = message->GetProp(Message::P_TYPE).toInt(); if (messageType == Message::POSTED_FILES) { MyTransfer::Refs transferList; message->GetTransfers(transferList); fetch(transferList); // In case of incoming transfers, let's auto-accept them.. Transfer::TYPE transferType; Transfer::STATUS transferStatus; for (uint i=0; i < transferList.size(); i++) { // To keep getting MyTransfer class events, we need to store the references globalTransferList->append(transferList[i]); // For incomings, we need to check for transfer status, just to be sure. // In some cases, a transfer can appear with STATUS == PLACEHOLDER // As such transfers cannot be accepted, we will need to just store // the reference to Transfer Object and then check for further // status changes in Transfer::OnChange transferList[i]->GetPropType(transferType); transferList[i]->GetPropStatus(transferStatus); if ( (transferType == Transfer::INCOMING) && (transferStatus == Transfer::NEW) ) { transferList[i]->AutoAccept(); }; }; SEString bodyXml; message->GetPropBodyXml(bodyXml); printf("File transfer msg BodyXML:\n%s\n", (const char*)bodyXml); }; };