ChatControlMessageLocation::ChatControlMessageLocation(WhatsappMessage &message, int width, ImageDecoder &imageDecoder) : ChatControlMessageWithPreview(message, width, imageDecoder) { latitude = message.getLatitude(); longitude = message.getLongitude(); swprintf(text, 256, L"%f, %f", latitude, longitude); }
WhatsappMessage *QueryMessagesThread::findByMessageId(const std::string &messageId) { for(std::vector<WhatsappMessage *>::iterator it = messages.begin(); it != messages.end(); ++it) { WhatsappMessage *message = *it; if (message->getMessageId() == messageId) { return message; } } return NULL; }
void ChatControlMessageText::splitMessage(WhatsappMessage &message) { std::string messageString = message.getData(); int lastSplit = 0; for (std::string::iterator it = messageString.begin(); it != messageString.end();) { bool begin = (it - messageString.begin()) == lastSplit; std::string::iterator before = it; int character = utf8::next(it, messageString.end()); if (isSmiley(character)) { if (!begin) { int start = lastSplit; int end = before - messageString.begin(); std::string leftPart = messageString.substr(start, end - start); elements.push_back(new ChatControlMessageElement(leftPart)); } elements.push_back(new ChatControlMessageElement(character)); lastSplit = (it - messageString.begin()); } } int length = messageString.length(); if (lastSplit < length) { std::string part = messageString.substr(lastSplit, length); elements.push_back(new ChatControlMessageElement(part)); } }
std::string ChatExporterHtml::convertMessageToHtml(WhatsappMessage &message, std::set<int> &usedEmoticons) { std::string messageString = message.getData(); std::stringstream output; try { for (std::string::iterator it = messageString.begin(); it != messageString.end();) { std::string::iterator before = it; int character = utf8::next(it, messageString.end()); if (isSmiley(character)) { usedEmoticons.insert(character); output << "<span class=\"emoticon_" << std::hex << character << "\"></span>"; } else { output << std::string(before, it); } } } catch (utf8::exception &exception) { output << "[INVALID DATA: " << messageString << "]"; } return output.str(); }