bool Game::showQuote() { Aurora::Language language = Aurora::kLanguageInvalid; _engine->getLanguage(language); const float length = (language == Aurora::kLanguageJapanese) ? 236.0f : 256.0f; const float align = (language == Aurora::kLanguageJapanese) ? 0.0f : 0.5f; Common::UString quote = TalkMan.getString(21712); _guiFont.getFont().split(quote, length, 0.0f, false); Graphics::Aurora::Text quoteText(_quoteFont, quote, 1.0f, 1.0f, 1.0f, 1.0f, align); const float quoteTextX = kTopScreenX + ((kScreenWidth - quoteText.getWidth()) / 2.0f); const float quoteTextY = kTopScreenY + ((kScreenHeight - quoteText.getHeight()) / 2.0f); quoteText.setPosition(quoteTextX, quoteTextY, 0.0f); quoteText.show(); GfxMan.unlockFrame(); if (!waitClick()) return false; GfxMan.lockFrame(); quoteText.hide(); return true; }
bool Game::showQuote() { Aurora::Language language = Aurora::kLanguageInvalid; _engine->getLanguage(language); Common::UString quote = TalkMan.getString(21712); const float halign = (language == Aurora::kLanguageJapanese) ? Graphics::Aurora::kHAlignLeft : Graphics::Aurora::kHAlignCenter; Graphics::Aurora::Text quoteText(_quoteFont, kScreenWidth, kScreenHeight, quote, 1.0f, 1.0f, 1.0f, 1.0f, halign, Graphics::Aurora::kVAlignMiddle); quoteText.setPosition(kTopScreenX, kTopScreenY, 0.0f); quoteText.show(); GfxMan.unlockFrame(); if (!waitClick()) return false; GfxMan.lockFrame(); quoteText.hide(); return true; }
QString MsgViewBase::messageText(Message *msg) { QString color; color.sprintf("%06lX", ((msg->getFlags() & MESSAGE_RECEIVED) ? CorePlugin::m_plugin->getColorReceiver() : CorePlugin::m_plugin->getColorSender()) & 0xFFFFFF); const char *icon = "message"; const CommandDef *def = CorePlugin::m_plugin->messageTypes.find(msg->type()); if (def) icon = def->icon; QString contactName; Client *client = NULL; Contact *contact = getContacts()->contact(msg->contact()); if (contact){ ClientDataIterator it(contact->clientData); void *data; while ((data = ++it) != NULL){ if (it.client()->dataName(data) == msg->client()){ client = it.client(); break; } } } if (msg->type() == MessageStatus){ icon = "empty"; StatusMessage *sm = static_cast<StatusMessage*>(msg); if (client == NULL) client = getContacts()->getClient(0); if (client){ for (def = client->protocol()->statusList(); def->text; def++){ if (def->id == sm->getStatus()){ icon = def->icon; break; } } } } bool bUnread = false; if (msg->getFlags() & MESSAGE_RECEIVED){ if (contact) contactName = contact->getName(); for (list<msg_id>::iterator it = CorePlugin::m_plugin->unread.begin(); it != CorePlugin::m_plugin->unread.end(); ++it){ msg_id &m = (*it); if ((m.id == msg->id()) && (m.contact == msg->contact()) && (m.client == msg->client())){ bUnread = true; break; } } }else{ if (client) contactName = client->ownerName(); if (contactName.isEmpty()) contactName = getContacts()->owner()->getName(); } if (contactName.isEmpty()) contactName = "???"; QString id = QString::number(msg->id()); id += ","; if (msg->getBackground() != msg->getForeground()) id += QString::number(msg->getBackground() & 0xFFFFFF); string client_str; if (msg->client()) client_str = msg->client(); if (!client_str.empty()){ id += ","; id += quoteText(client_str.c_str()); } QString s = QString("<p><nobr>" "<a href=\"msg://%1\"><img src=\"icon:%2\"></a>%3" " %4<font color=\"#%5\">%6</font> " "<font size=-1>%7</font>%8" "</nobr></p>") .arg(id) .arg(icon) .arg((msg->getFlags() & MESSAGE_SECURE) ? "<img src=\"icon:encrypted\">" : "") .arg(bUnread ? "<b>" : "") .arg(color) .arg(quoteString(contactName)) .arg(formatTime(msg->getTime())) .arg(bUnread ? "</b>" : ""); if (msg->type() != MessageStatus){ QString msgText = msg->presentation(); if (msgText.isEmpty()){ unsigned type = msg->type(); for (;;){ CommandDef *cmd = CorePlugin::m_plugin->messageTypes.find(type); if (cmd == NULL) break; MessageDef *def = (MessageDef*)(cmd->param); if (def->base_type){ type = def->base_type; continue; } msgText += "<p>"; msgText += i18n(def->singular, def->plural, 1); msgText += "</p>"; break; } QString text = msg->getRichText(); if (!text.isEmpty()){ msgText += "<p>"; msgText += text; msgText += "</p>"; } } string msg_text; msg_text = msgText.utf8(); Event e(EventEncodeText, &msg_text); e.process(); s += parseText(msg_text.c_str(), CorePlugin::m_plugin->getOwnColors(), CorePlugin::m_plugin->getUseSmiles()); } return s; }
QString TextShow::makeMessageText(ICQMessage *msg, bool bIgnore) { QString s; switch (msg->Type()){ case ICQ_MSGxMSG: s += MainWindow::ParseText((static_cast<ICQMsg*>(msg))->Message, bIgnore); break; case ICQ_MSGxURL:{ ICQUrl *url = static_cast<ICQUrl*>(msg); s += quoteText(url->URL); if (*url->Message.c_str()){ s += "<br>"; s += MainWindow::ParseText(url->Message, true); } break; } case ICQ_MSGxAUTHxREQUEST:{ ICQAuthRequest *req = static_cast<ICQAuthRequest*>(msg); s += i18n("Authorization request"); if (*req->Message.c_str()){ s += "<br>"; s += MainWindow::ParseText(req->Message, true); } break; } case ICQ_MSGxAUTHxREFUSED:{ ICQAuthRefused *req = static_cast<ICQAuthRefused*>(msg); s += i18n("Authorization refused"); if (*req->Message.c_str()){ s += "<br>"; s += MainWindow::ParseText(req->Message, true); } break; } case ICQ_MSGxAUTHxGRANTED: s += i18n("Authorization granted"); break; case ICQ_MSGxADDEDxTOxLIST: s += i18n("Added to contact list"); break; case ICQ_MSGxCONTACTxREQUEST:{ ICQContactRequest *req = static_cast<ICQContactRequest*>(msg); s += i18n("Contact request"); if (*req->Message.c_str()){ s += "<br>"; s += MainWindow::ParseText(req->Message, true); } break; } case ICQ_MSGxFILE:{ ICQFile *file = static_cast<ICQFile*>(msg); s += i18n("File: "); s += file->Name.c_str(); s += " ("; s += QString::number(file->Size); s += " "; s += i18n("bytes"); s += ")"; s += "<br>"; s += MainWindow::ParseText(file->Description, true); break; } case ICQ_MSGxCHAT:{ ICQChat *chat = static_cast<ICQChat*>(msg); s += MainWindow::ParseText(chat->Reason, true); break; } case ICQ_MSGxCONTACTxLIST:{ ICQContacts *contacts = static_cast<ICQContacts*>(msg); s += msg->Received ? i18n("Contact list received") : i18n("Contact list sent"); s += "<br>"; s += "<table>"; for (ContactList::iterator it = contacts->Contacts.begin(); it != contacts->Contacts.end(); it++){ Contact *contact = static_cast<Contact*>(*it); s += "<tr><td align=right>" + QString::number(contact->Uin) + "</td><td>"; s += quoteText(contact->Alias.c_str()); s += "</td></tr>"; } s += "</table>"; break; } case ICQ_MSGxSMS:{ ICQSMS *sms = static_cast<ICQSMS*>(msg); s += MainWindow::ParseText(sms->Message, true); if (*sms->Phone.c_str()){ s += "<br>"; s += quoteText(sms->Phone); if (*sms->Network.c_str()) s += " (" + quoteText(sms->Network) + ")"; } break; } case ICQ_MSGxWEBxPANEL:{ ICQWebPanel *m = static_cast<ICQWebPanel*>(msg); s += MainWindow::ParseText(m->Message, true); break; } case ICQ_MSGxEMAILxPAGER:{ ICQEmailPager *m = static_cast<ICQEmailPager*>(msg); s += MainWindow::ParseText(m->Message, true); break; } default: log(L_WARN, "Unknown message type %u", msg->Type()); s += "???"; } string txt; txt = s.local8Bit(); return s; }
QString MsgViewBase::messageText(Message *msg) { QString color; unsigned long c_sender = 0x800000; unsigned long c_receiver = 0x000080; unsigned long c_send = 0x000000; unsigned long c_receive = 0x000000; if (CorePlugin::m_plugin->getOwnColors()) { c_send = (CorePlugin::m_plugin->getColorSend()) & 0xFFFFFF; c_receive = (CorePlugin::m_plugin->getColorReceive()) & 0xFFFFFF; c_sender = (CorePlugin::m_plugin->getColorSender()) & 0xFFFFFF; c_receiver = (CorePlugin::m_plugin->getColorReceiver())& 0xFFFFFF; } color.sprintf(FONT_FORMAT, ((msg->getFlags() & MESSAGE_RECEIVED) ? c_receiver : c_sender)); const char *icon = "message"; const CommandDef *def = CorePlugin::m_plugin->messageTypes.find(msg->type()); if (def) icon = def->icon; QString contactName; Client *client = NULL; Contact *contact = getContacts()->contact(msg->contact()); if (contact) { ClientDataIterator it(contact->clientData); void *data; while ((data = ++it) != NULL) { if (it.client()->dataName(data) == msg->client()) { client = it.client(); break; } } } if (msg->type() == MessageStatus) { icon = "empty"; StatusMessage *sm = static_cast<StatusMessage*>(msg); if (client == NULL) client = getContacts()->getClient(0); if (client) { for (def = client->protocol()->statusList(); def->text; def++) { if (def->id == sm->getStatus()) { icon = def->icon; break; } } } } bool bUnread = false; if (msg->getFlags() & MESSAGE_RECEIVED) { if (contact) contactName = contact->getName(); for (list<msg_id>::iterator it = CorePlugin::m_plugin->unread.begin(); it != CorePlugin::m_plugin->unread.end(); ++it) { msg_id &m = (*it); if ((m.id == msg->id()) && (m.contact == msg->contact()) && (m.client == msg->client())) { bUnread = true; break; } } } else { if (client) contactName = client->ownerName(); if (contactName.isEmpty()) contactName = getContacts()->owner()->getName(); } if (contactName.isEmpty()) contactName = "???"; QString id = QString::number(msg->id()); id += ","; if (msg->getBackground() != msg->getForeground()) id += QString::number(msg->getBackground() & 0xFFFFFF); string client_str; if (msg->client()) client_str = msg->client(); if (!client_str.empty()) { id += ","; id += quoteText(client_str.c_str()); } QString icons; if (msg->getFlags() & MESSAGE_SECURE) icons += "<img src=\"icon:encrypted\">"; if (msg->getFlags() & MESSAGE_URGENT) icons += "<img src=\"icon:urgentmsg\">"; if (msg->getFlags() & MESSAGE_LIST) icons += "<img src=\"icon:listmsg\">"; QString s = QString("<p><nobr>" "<a href=\"msg://%1\"><img src=\"icon:%2\"></a>%3" " %4<span style=\"color:#%5\">%6</span> " "<span style=\"font-size:10pt\">%7</span>%8" "</nobr></p>") .arg(id) .arg(icon) .arg(icons) .arg(bUnread ? "<b>" : "") .arg(color) .arg(quoteString(contactName)) .arg(formatTime(msg->getTime())) .arg(bUnread ? "</b>" : ""); if (msg->type() != MessageStatus) { QString msgText = msg->presentation(); // replace font color if we use own colors // some of the incoming messages are saved as html with an extra <font> - tag // so we need to replace until no more <font> - tag is found // this behaviour should be checked! if (CorePlugin::m_plugin->getOwnColors()) { int pos = msgText.find("font color=\"#",0); while (pos != -1) { pos += 13; QString color; color.sprintf(FONT_FORMAT, (msg->getFlags() & MESSAGE_RECEIVED) ? c_receive : c_send); msgText.replace(pos,6,color); pos = msgText.find("font color=\"#",pos); } } if (msgText.isEmpty()) { unsigned type = msg->type(); for (;;) { CommandDef *cmd = CorePlugin::m_plugin->messageTypes.find(type); if (cmd == NULL) break; MessageDef *def = (MessageDef*)(cmd->param); if (def->base_type) { type = def->base_type; continue; } msgText += "<p>"; msgText += i18n(def->singular, def->plural, 1); msgText += "</p>"; break; } QString text = msg->getRichText(); msgText += text; } Event e(EventEncodeText, &msgText); e.process(); msgText = parseText(msgText, false, CorePlugin::m_plugin->getUseSmiles()); s += msgText; } return s; }
void MessageView::reply(MainWindow *mainWindow, Composer::ReplyMode mode) { if (!message.isValid()) return; QByteArray messageId = message.data(Imap::Mailbox::RoleMessageMessageId).toByteArray(); ComposeWidget *w = mainWindow->invokeComposeDialog( Composer::Util::replySubject(message.data(Imap::Mailbox::RoleMessageSubject).toString()), quoteText(), QList<QPair<Composer::RecipientKind,QString> >(), QList<QByteArray>() << messageId, message.data(Imap::Mailbox::RoleMessageHeaderReferences).value<QList<QByteArray> >() << messageId, message ); if (!w) return; bool ok = w->setReplyMode(mode); if (!ok) { QString err; switch (mode) { case Composer::REPLY_ALL: case Composer::REPLY_ALL_BUT_ME: // do nothing break; case Composer::REPLY_LIST: err = tr("It doesn't look like this is a message to the mailing list. Please fill in the recipients manually."); break; case Composer::REPLY_PRIVATE: err = trUtf8("Trojitá was unable to safely determine the real e-mail address of the author of the message. " "You might want to use the \"Reply All\" function and trim the list of addresses manually."); break; } if (!err.isEmpty()) QMessageBox::warning(w, tr("Cannot Determine Recipients"), err); } }