summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2013-06-01 08:26:46 (GMT)
committerKevin Smith <git@kismith.co.uk>2013-08-01 09:22:45 (GMT)
commitdb698bbb6d8c7e878e2cb997e18e572f3646e11d (patch)
tree61aa3ff72c64dd8f309a2fe4b31b5b2d3f22f04b /Swift/QtUI
parentb45602bcd36fb9d2e7a22998434e31014f072d33 (diff)
downloadswift-db698bbb6d8c7e878e2cb997e18e572f3646e11d.zip
swift-db698bbb6d8c7e878e2cb997e18e572f3646e11d.tar.bz2
Refactor chat messages so parsing of links/emoticons happens in controllers.
Change-Id: I07256f23ffbb6520f5063bdfbed9111946c46746
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/ChatSnippet.cpp15
-rw-r--r--Swift/QtUI/ChatSnippet.h7
-rw-r--r--Swift/QtUI/QtChatView.cpp12
-rw-r--r--Swift/QtUI/QtChatWindow.cpp93
-rw-r--r--Swift/QtUI/QtChatWindow.h24
-rw-r--r--Swift/QtUI/QtChatWindowFactory.cpp4
-rw-r--r--Swift/QtUI/QtChatWindowFactory.h3
-rw-r--r--Swift/QtUI/QtSwift.cpp64
-rw-r--r--Swift/QtUI/QtSwift.h2
9 files changed, 140 insertions, 84 deletions
diff --git a/Swift/QtUI/ChatSnippet.cpp b/Swift/QtUI/ChatSnippet.cpp
index 666dd00..3436531 100644
--- a/Swift/QtUI/ChatSnippet.cpp
+++ b/Swift/QtUI/ChatSnippet.cpp
@@ -4,9 +4,10 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
+#include <Swift/QtUI/ChatSnippet.h>
+
#include <QFile>
-#include "ChatSnippet.h"
#include <Swift/QtUI/QtSwiftUtil.h>
namespace Swift {
@@ -44,6 +45,18 @@ QString ChatSnippet::directionToCSS(Direction direction) {
return direction == RTL ? QString("rtl") : QString("ltr");
}
+ChatSnippet::Direction ChatSnippet::getDirection(const ChatWindow::ChatMessage& message) {
+ boost::shared_ptr<ChatWindow::ChatTextMessagePart> textPart;
+ std::string text = "";
+ foreach (boost::shared_ptr<ChatWindow::ChatMessagePart> part, message.getParts()) {
+ if ((textPart = boost::dynamic_pointer_cast<ChatWindow::ChatTextMessagePart>(part))) {
+ text = textPart->text;
+ break;
+ }
+ }
+ return getDirection(text);
+}
+
ChatSnippet::Direction ChatSnippet::getDirection(const std::string& message) {
return getDirection(P2QSTRING(message));
}
diff --git a/Swift/QtUI/ChatSnippet.h b/Swift/QtUI/ChatSnippet.h
index d43947f..f60d486 100644
--- a/Swift/QtUI/ChatSnippet.h
+++ b/Swift/QtUI/ChatSnippet.h
@@ -10,7 +10,11 @@
#include <QString>
#include <QDateTime>
-#include "QtChatTheme.h"
+
+#include <Swiften/Base/foreach.h>
+#include <Swift/Controllers/UIInterfaces/ChatWindow.h>
+#include <Swift/QtUI/QtChatTheme.h>
+
namespace Swift {
class ChatSnippet {
@@ -48,6 +52,7 @@ namespace Swift {
static QString timeToEscapedString(const QDateTime& time);
static Direction getDirection(const std::string& message);
+ static Direction getDirection(const ChatWindow::ChatMessage& message);
static Direction getDirection(const QString& message);
protected:
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 18c6e91..2536d39 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -128,7 +128,7 @@ void QtChatView::addMessageTop(boost::shared_ptr<ChatSnippet> snippet) {
double size = 1.0 + 0.2 * fontSizeSteps_;
QString sizeString(QString().setNum(size, 'g', 3) + "em");
const QWebElementCollection spans = firstElement_.findAll("span.swift_resizable");
- foreach (QWebElement span, spans) {
+ Q_FOREACH (QWebElement span, spans) {
span.setStyleProperty("font-size", sizeString);
}
}
@@ -161,7 +161,7 @@ void QtChatView::addToDOM(boost::shared_ptr<ChatSnippet> snippet) {
double size = 1.0 + 0.2 * fontSizeSteps_;
QString sizeString(QString().setNum(size, 'g', 3) + "em");
const QWebElementCollection spans = lastElement_.findAll("span.swift_resizable");
- foreach (QWebElement span, spans) {
+ Q_FOREACH (QWebElement span, spans) {
span.setStyleProperty("font-size", sizeString);
}
}
@@ -229,13 +229,13 @@ void QtChatView::replaceMessage(const QString& newMessage, const QString& id, co
void QtChatView::showEmoticons(bool show) {
{
const QWebElementCollection spans = document_.findAll("span.swift_emoticon_image");
- foreach (QWebElement span, spans) {
+ Q_FOREACH (QWebElement span, spans) {
span.setStyleProperty("display", show ? "inline" : "none");
}
}
{
const QWebElementCollection spans = document_.findAll("span.swift_emoticon_text");
- foreach (QWebElement span, spans) {
+ Q_FOREACH (QWebElement span, spans) {
span.setStyleProperty("display", show ? "none" : "inline");
}
}
@@ -324,7 +324,7 @@ void QtChatView::resizeFont(int fontSizeSteps) {
QString sizeString(QString().setNum(size, 'g', 3) + "em");
//qDebug() << "Setting to " << sizeString;
const QWebElementCollection spans = document_.findAll("span.swift_resizable");
- foreach (QWebElement span, spans) {
+ Q_FOREACH (QWebElement span, spans) {
span.setStyleProperty("font-size", sizeString);
}
webView_->setFontSizeIsMinimal(size == 1.0);
@@ -370,7 +370,7 @@ void QtChatView::resetView() {
static QWebElement findElementWithID(QWebElement document, QString elementName, QString id) {
QWebElementCollection elements = document.findAll(elementName);
- foreach(QWebElement element, elements) {
+ Q_FOREACH(QWebElement element, elements) {
if (element.attribute("id") == id) {
return element;
}
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index 6dde1cc..d81de61 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -68,7 +68,7 @@ const QString QtChatWindow::ButtonFileTransferAcceptRequest = QString("filetrans
const QString QtChatWindow::ButtonMUCInvite = QString("mucinvite");
-QtChatWindow::QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream, SettingsProvider* settings, QMap<QString, QString> emoticons) : QtTabbable(), contact_(contact), previousMessageWasSelf_(false), previousMessageKind_(PreviosuMessageWasNone), eventStream_(eventStream), emoticons_(emoticons), blockingState_(BlockingUnsupported) {
+QtChatWindow::QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream, SettingsProvider* settings) : QtTabbable(), contact_(contact), previousMessageWasSelf_(false), previousMessageKind_(PreviosuMessageWasNone), eventStream_(eventStream), blockingState_(BlockingUnsupported) {
settings_ = settings;
unreadCount_ = 0;
idCounter_ = 0;
@@ -222,7 +222,7 @@ bool QtChatWindow::appendToPreviousCheck(QtChatWindow::PreviousMessageKind messa
return previousMessageKind_ == messageKind && ((senderIsSelf && previousMessageWasSelf_) || (!senderIsSelf && !previousMessageWasSelf_&& previousSenderName_ == P2QSTRING(senderName)));
}
-ChatSnippet::Direction QtChatWindow::getActualDirection(const std::string& message, Direction direction) {
+ChatSnippet::Direction QtChatWindow::getActualDirection(const ChatMessage& message, Direction direction) {
if (direction == DefaultDirection) {
return QCoreApplication::translate("QApplication", "QT_LAYOUT_DIRECTION") == "RTL" ? ChatSnippet::RTL : ChatSnippet::LTR;
}
@@ -497,17 +497,51 @@ void QtChatWindow::updateTitleWithUnreadCount() {
}
std::string QtChatWindow::addMessage(
- const std::string& message,
+ const ChatMessage& message,
const std::string& senderName,
bool senderIsSelf,
boost::shared_ptr<SecurityLabel> label,
const std::string& avatarPath,
const boost::posix_time::ptime& time,
const HighlightAction& highlight) {
- return addMessage(linkimoticonify(message), senderName, senderIsSelf, label, avatarPath, "", time, highlight, ChatSnippet::getDirection(message));
+ return addMessage(chatMessageToHTML(message), senderName, senderIsSelf, label, avatarPath, "", time, highlight, ChatSnippet::getDirection(message));
+}
+
+QString QtChatWindow::chatMessageToHTML(const ChatMessage& message) {
+ QString result;
+ foreach (boost::shared_ptr<ChatMessagePart> part, message.getParts()) {
+ boost::shared_ptr<ChatTextMessagePart> textPart;
+ boost::shared_ptr<ChatURIMessagePart> uriPart;
+ boost::shared_ptr<ChatEmoticonMessagePart> emoticonPart;
+ boost::shared_ptr<ChatHighlightingMessagePart> highlightPart;
+
+ if ((textPart = boost::dynamic_pointer_cast<ChatTextMessagePart>(part))) {
+ QString text = QtUtilities::htmlEscape(P2QSTRING(textPart->text));
+ text.replace("\n","<br/>");
+ result += text;
+ continue;
+ }
+ if ((uriPart = boost::dynamic_pointer_cast<ChatURIMessagePart>(part))) {
+ QString uri = QtUtilities::htmlEscape(P2QSTRING(uriPart->target));
+ result += "<a href='" + uri + "' >" + uri + "</a>";
+ continue;
+ }
+ if ((emoticonPart = boost::dynamic_pointer_cast<ChatEmoticonMessagePart>(part))) {
+ QString textStyle = showEmoticons_ ? "style='display:none'" : "";
+ QString imageStyle = showEmoticons_ ? "" : "style='display:none'";
+ result += "<span class='swift_emoticon_image' " + imageStyle + "><img src='" + P2QSTRING(emoticonPart->imagePath) + "'/></span><span class='swift_emoticon_text' " + textStyle + ">" + QtUtilities::htmlEscape(P2QSTRING(emoticonPart->alternativeText)) + "</span>";
+ continue;
+ }
+ if ((highlightPart = boost::dynamic_pointer_cast<ChatHighlightingMessagePart>(part))) {
+ //FIXME: Maybe do something here. Anything, really.
+ continue;
+ }
+
+ }
+ return result;
}
-QString QtChatWindow::linkimoticonify(const std::string& message) const {
+/*QString QtChatWindow::linkimoticonify(const std::string& message) const {
return linkimoticonify(P2QSTRING(message));
}
@@ -515,18 +549,17 @@ QString QtChatWindow::linkimoticonify(const QString& message) const {
QString messageHTML(message);
messageHTML = QtUtilities::htmlEscape(messageHTML);
QMapIterator<QString, QString> it(emoticons_);
- QString textStyle = showEmoticons_ ? "style='display:none'" : "";
- QString imageStyle = showEmoticons_ ? "" : "style='display:none'";
+
if (messageHTML.length() < 500) {
while (it.hasNext()) {
it.next();
- messageHTML.replace(it.key(), "<span class='swift_emoticon_image' " + imageStyle + "><img src='" + it.value() + "'/></span><span class='swift_emoticon_text' " + textStyle + ">"+it.key() + "</span>");
+ messageHTML.replace(it.key(), );
}
messageHTML = P2QSTRING(Linkify::linkify(Q2PSTRING(messageHTML)));
}
messageHTML.replace("\n","<br/>");
return messageHTML;
-}
+}*/
QString QtChatWindow::getHighlightSpanStart(const HighlightAction& highlight) {
QString color = QtUtilities::htmlEscape(P2QSTRING(highlight.getTextColor()));
@@ -562,12 +595,12 @@ std::string QtChatWindow::addMessage(
htmlString = QString("<span style=\"border: thin dashed grey; padding-left: .5em; padding-right: .5em; color: %1; background-color: %2; font-size: 90%; margin-right: .5em; \" class='swift_label'>").arg(QtUtilities::htmlEscape(P2QSTRING(label->getForegroundColor()))).arg(QtUtilities::htmlEscape(P2QSTRING(label->getBackgroundColor())));
htmlString += QString("%1</span> ").arg(QtUtilities::htmlEscape(P2QSTRING(label->getDisplayMarking())));
}
- QString messageHTML(message);
+
QString styleSpanStart = style == "" ? "" : "<span style=\"" + style + "\">";
QString styleSpanEnd = style == "" ? "" : "</span>";
QString highlightSpanStart = highlight.highlightText() ? getHighlightSpanStart(highlight) : "";
QString highlightSpanEnd = highlight.highlightText() ? "</span>" : "";
- htmlString += "<span class='swift_inner_message'>" + styleSpanStart + highlightSpanStart + messageHTML + highlightSpanEnd + styleSpanEnd + "</span>" ;
+ htmlString += "<span class='swift_inner_message'>" + styleSpanStart + highlightSpanStart + message + highlightSpanEnd + styleSpanEnd + "</span>" ;
bool appendToPrevious = appendToPreviousCheck(PreviousMessageWasMessage, senderName, senderIsSelf);
if (lastLineTracker_.getShouldMoveLastLine()) {
@@ -623,8 +656,8 @@ int QtChatWindow::getCount() {
return unreadCount_;
}
-std::string QtChatWindow::addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time, const HighlightAction& highlight) {
- return addMessage(" *" + linkimoticonify(message) + "*", senderName, senderIsSelf, label, avatarPath, "font-style:italic ", time, highlight, ChatSnippet::getDirection(message));
+std::string QtChatWindow::addAction(const ChatMessage& message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time, const HighlightAction& highlight) {
+ return addMessage(" *" + chatMessageToHTML(message) + "*", senderName, senderIsSelf, label, avatarPath, "font-style:italic ", time, highlight, ChatSnippet::getDirection(message));
}
// FIXME: Move this to a different file
@@ -802,36 +835,36 @@ void QtChatWindow::handleHTMLButtonClicked(QString id, QString encodedArgument1,
}
}
-void QtChatWindow::addErrorMessage(const std::string& errorMessage) {
+void QtChatWindow::addErrorMessage(const ChatMessage& errorMessage) {
if (isWidgetSelected()) {
onAllMessagesRead();
}
- QString errorMessageHTML(linkimoticonify(errorMessage));
- errorMessageHTML.replace("\n","<br/>");
+ QString errorMessageHTML(chatMessageToHTML(errorMessage));
+
messageLog_->addMessageBottom(boost::make_shared<SystemMessageSnippet>("<span class=\"error\">" + errorMessageHTML + "</span>", QDateTime::currentDateTime(), false, theme_, ChatSnippet::getDirection(errorMessage)));
previousMessageWasSelf_ = false;
previousMessageKind_ = PreviousMessageWasSystem;
}
-void QtChatWindow::addSystemMessage(const std::string& message, Direction direction) {
+void QtChatWindow::addSystemMessage(const ChatMessage& message, Direction direction) {
if (isWidgetSelected()) {
onAllMessagesRead();
}
- QString messageHTML = linkimoticonify(message);
+ QString messageHTML = chatMessageToHTML(message);
messageLog_->addMessageBottom(boost::make_shared<SystemMessageSnippet>(messageHTML, QDateTime::currentDateTime(), false, theme_, getActualDirection(message, direction)));
previousMessageKind_ = PreviousMessageWasSystem;
}
-void QtChatWindow::replaceWithAction(const std::string& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight) {
- replaceMessage(" *" + linkimoticonify(message) + "*", id, time, "font-style:italic ", highlight);
+void QtChatWindow::replaceWithAction(const ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight) {
+ replaceMessage(" *" + chatMessageToHTML(message) + "*", id, time, "font-style:italic ", highlight);
}
-void QtChatWindow::replaceMessage(const std::string& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight) {
- replaceMessage(linkimoticonify(message), id, time, "", highlight);
+void QtChatWindow::replaceMessage(const ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight) {
+ replaceMessage(chatMessageToHTML(message), id, time, "", highlight);
}
void QtChatWindow::replaceMessage(const QString& message, const std::string& id, const boost::posix_time::ptime& time, const QString& style, const HighlightAction& highlight) {
@@ -855,12 +888,12 @@ void QtChatWindow::replaceMessage(const QString& message, const std::string& id,
}
}
-void QtChatWindow::addPresenceMessage(const std::string& message, Direction direction) {
+void QtChatWindow::addPresenceMessage(const ChatMessage& message, Direction direction) {
if (isWidgetSelected()) {
onAllMessagesRead();
}
- QString messageHTML = linkimoticonify(message);
+ QString messageHTML = chatMessageToHTML(message);
messageLog_->addMessageBottom(boost::make_shared<SystemMessageSnippet>(messageHTML, QDateTime::currentDateTime(), false, theme_, getActualDirection(message, direction)));
previousMessageKind_ = PreviousMessageWasPresence;
@@ -932,13 +965,15 @@ void QtChatWindow::dropEvent(QDropEvent *event) {
if (event->mimeData()->urls().size() == 1) {
onSendFileRequest(Q2PSTRING(event->mimeData()->urls().at(0).toLocalFile()));
} else {
- std::string message(Q2PSTRING(tr("Sending of multiple files at once isn't supported at this time.")));
+ std::string messageText(Q2PSTRING(tr("Sending of multiple files at once isn't supported at this time.")));
+ ChatMessage message;
+ message.append(boost::make_shared<ChatTextMessagePart>(messageText));
addSystemMessage(message, DefaultDirection);
}
}
-void QtChatWindow::replaceLastMessage(const std::string& message) {
- messageLog_->replaceLastMessage(linkimoticonify(message));
+void QtChatWindow::replaceLastMessage(const ChatMessage& message) {
+ messageLog_->replaceLastMessage(chatMessageToHTML(message));
}
void QtChatWindow::setAvailableOccupantActions(const std::vector<OccupantAction>& actions) {
@@ -1066,12 +1101,12 @@ void QtChatWindow::addMUCInvitation(const std::string& senderName, const JID& ji
if (!direct) {
htmlString += QObject::tr("This person may not have really sent this invitation!") + "\n";
}
- htmlString = linkimoticonify(htmlString);
+ htmlString = chatMessageToHTML(ChatMessage(Q2PSTRING(htmlString)));
QString id = QString(ButtonMUCInvite + "%1").arg(P2QSTRING(boost::lexical_cast<std::string>(idCounter_++)));
htmlString += "<div id='" + id + "'>" +
- buildChatWindowButton(linkimoticonify(tr("Accept Invite")), ButtonMUCInvite, QtUtilities::htmlEscape(P2QSTRING(jid.toString())), QtUtilities::htmlEscape(P2QSTRING(password)), id) +
+ buildChatWindowButton(chatMessageToHTML(ChatMessage(Q2PSTRING((tr("Accept Invite"))))), ButtonMUCInvite, QtUtilities::htmlEscape(P2QSTRING(jid.toString())), QtUtilities::htmlEscape(P2QSTRING(password)), id) +
"</div>";
bool appendToPrevious = appendToPreviousCheck(PreviousMessageWasMUCInvite, senderName, false);
diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h
index a9600d4..a29edad 100644
--- a/Swift/QtUI/QtChatWindow.h
+++ b/Swift/QtUI/QtChatWindow.h
@@ -87,17 +87,17 @@ namespace Swift {
static const QString ButtonMUCInvite;
public:
- QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream, SettingsProvider* settings, QMap<QString, QString> emoticons);
+ QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream, SettingsProvider* settings);
~QtChatWindow();
- std::string addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time, const HighlightAction& highlight);
- std::string addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time, const HighlightAction& highlight);
+ std::string addMessage(const ChatMessage& message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time, const HighlightAction& highlight);
+ std::string addAction(const ChatMessage& message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time, const HighlightAction& highlight);
- void addSystemMessage(const std::string& message, Direction direction);
- void addPresenceMessage(const std::string& message, Direction direction);
- void addErrorMessage(const std::string& errorMessage);
+ void addSystemMessage(const ChatMessage& message, Direction direction);
+ void addPresenceMessage(const ChatMessage& message, Direction direction);
+ void addErrorMessage(const ChatMessage& message);
- void replaceMessage(const std::string& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight);
- void replaceWithAction(const std::string& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight);
+ void replaceMessage(const ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight);
+ void replaceWithAction(const ChatMessage& message, const std::string& id, const boost::posix_time::ptime& time, const HighlightAction& highlight);
// File transfer related stuff
std::string addFileTransfer(const std::string& senderName, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes);
void setFileTransferProgress(std::string id, const int percentageDone);
@@ -122,7 +122,7 @@ namespace Swift {
void setRosterModel(Roster* roster);
void setTabComplete(TabComplete* completer);
int getCount();
- void replaceLastMessage(const std::string& message);
+ void replaceLastMessage(const ChatMessage& message);
void setAckState(const std::string& id, AckState state);
// message receipts
@@ -214,9 +214,8 @@ namespace Swift {
const HighlightAction& highlight);
void handleOccupantSelectionChanged(RosterItem* item);
bool appendToPreviousCheck(PreviousMessageKind messageKind, const std::string& senderName, bool senderIsSelf) const;
- static ChatSnippet::Direction getActualDirection(const std::string& message, Direction direction);
- QString linkimoticonify(const std::string& message) const;
- QString linkimoticonify(const QString& message) const;
+ static ChatSnippet::Direction getActualDirection(const ChatMessage& message, Direction direction);
+ QString chatMessageToHTML(const ChatMessage& message);
QString getHighlightSpanStart(const HighlightAction& highlight);
int unreadCount_;
@@ -256,7 +255,6 @@ namespace Swift {
int idCounter_;
SettingsProvider* settings_;
std::vector<ChatWindow::RoomAction> availableRoomActions_;
- QMap<QString, QString> emoticons_;
bool showEmoticons_;
QPalette defaultLabelsPalette_;
LabelModel* labelModel_;
diff --git a/Swift/QtUI/QtChatWindowFactory.cpp b/Swift/QtUI/QtChatWindowFactory.cpp
index bc5d7f4..78c04c9 100644
--- a/Swift/QtUI/QtChatWindowFactory.cpp
+++ b/Swift/QtUI/QtChatWindowFactory.cpp
@@ -21,7 +21,7 @@ namespace Swift {
static const QString SPLITTER_STATE = "mucSplitterState";
static const QString CHAT_TABS_GEOMETRY = "chatTabsGeometry";
-QtChatWindowFactory::QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath, QMap<QString, QString> emoticons) : themePath_(themePath), emoticons_(emoticons) {
+QtChatWindowFactory::QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath) : themePath_(themePath) {
qtOnlySettings_ = qtSettings;
settings_ = settings;
tabs_ = tabs;
@@ -50,7 +50,7 @@ ChatWindow* QtChatWindowFactory::createChatWindow(const JID &contact,UIEventStre
}
}
- QtChatWindow *chatWindow = new QtChatWindow(P2QSTRING(contact.toString()), theme_, eventStream, settings_, emoticons_);
+ QtChatWindow *chatWindow = new QtChatWindow(P2QSTRING(contact.toString()), theme_, eventStream, settings_);
connect(chatWindow, SIGNAL(splitterMoved()), this, SLOT(handleSplitterMoved()));
connect(this, SIGNAL(changeSplitterState(QByteArray)), chatWindow, SLOT(handleChangeSplitterState(QByteArray)));
diff --git a/Swift/QtUI/QtChatWindowFactory.h b/Swift/QtUI/QtChatWindowFactory.h
index 89a322f..63da514 100644
--- a/Swift/QtUI/QtChatWindowFactory.h
+++ b/Swift/QtUI/QtChatWindowFactory.h
@@ -23,7 +23,7 @@ namespace Swift {
class QtChatWindowFactory : public QObject, public ChatWindowFactory {
Q_OBJECT
public:
- QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath, QMap<QString, QString> emoticons);
+ QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath);
~QtChatWindowFactory();
ChatWindow* createChatWindow(const JID &contact, UIEventStream* eventStream);
signals:
@@ -37,7 +37,6 @@ namespace Swift {
QtSettingsProvider* qtOnlySettings_;
QtChatTabs* tabs_;
QtChatTheme* theme_;
- QMap<QString, QString> emoticons_;
};
}
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index b563c53..4d4cef9 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -4,65 +4,70 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#include "QtSwift.h"
+#include <Swift/QtUI/QtSwift.h>
#include <string>
-#include <QFile>
+#include <map>
+
#include <boost/bind.hpp>
+
+#include <QFile>
#include <QMessageBox>
#include <QApplication>
#include <QMap>
#include <qdebug.h>
-#include <QtLoginWindow.h>
-#include <QtChatTabs.h>
-#include <QtSystemTray.h>
-#include <QtSoundPlayer.h>
-#include <QtSwiftUtil.h>
-#include <QtUIFactory.h>
-#include <QtChatWindowFactory.h>
-#include <QtSingleWindow.h>
#include <Swiften/Base/Log.h>
#include <Swiften/Base/Path.h>
-#include <Swift/Controllers/Storages/CertificateFileStorageFactory.h>
-#include <Swift/Controllers/Storages/FileStoragesFactory.h>
-#include <SwifTools/Application/PlatformApplicationPathProvider.h>
-#include <string>
#include <Swiften/Base/Platform.h>
#include <Swiften/Elements/Presence.h>
#include <Swiften/Client/Client.h>
+#include <Swiften/Base/Paths.h>
+
+#include <SwifTools/Application/PlatformApplicationPathProvider.h>
+#include <SwifTools/AutoUpdater/AutoUpdater.h>
+#include <SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h>
+
+#include <Swift/Controllers/Storages/CertificateFileStorageFactory.h>
+#include <Swift/Controllers/Storages/FileStoragesFactory.h>
#include <Swift/Controllers/Settings/XMLSettingsProvider.h>
#include <Swift/Controllers/Settings/SettingsProviderHierachy.h>
#include <Swift/Controllers/MainController.h>
#include <Swift/Controllers/ApplicationInfo.h>
#include <Swift/Controllers/BuildVersion.h>
-#include <SwifTools/AutoUpdater/AutoUpdater.h>
-#include <SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h>
-#include "Swiften/Base/Paths.h"
#include <Swift/Controllers/StatusCache.h>
+#include <Swift/QtUI/QtLoginWindow.h>
+#include <Swift/QtUI/QtChatTabs.h>
+#include <Swift/QtUI/QtSystemTray.h>
+#include <Swift/QtUI/QtSoundPlayer.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
+#include <Swift/QtUI/QtUIFactory.h>
+#include <Swift/QtUI/QtChatWindowFactory.h>
+#include <Swift/QtUI/QtSingleWindow.h>
+
#if defined(SWIFTEN_PLATFORM_WINDOWS)
-#include "WindowsNotifier.h"
+#include <Swift/QtUI/WindowsNotifier.h>
#elif defined(HAVE_GROWL)
-#include "SwifTools/Notifier/GrowlNotifier.h"
+#include <SwifTools/Notifier/GrowlNotifier.h>
#elif defined(SWIFTEN_PLATFORM_LINUX)
-#include "FreeDesktopNotifier.h"
+#include <Swift/QtUI/FreeDesktopNotifier.h>
#else
-#include "SwifTools/Notifier/NullNotifier.h"
+#include <SwifTools/Notifier/NullNotifier.h>
#endif
#if defined(SWIFTEN_PLATFORM_MACOSX)
-#include "SwifTools/Dock/MacOSXDock.h"
+#include <SwifTools/Dock/MacOSXDock.h>
#else
-#include "SwifTools/Dock/NullDock.h"
+#include <SwifTools/Dock/NullDock.h>
#endif
#if defined(SWIFTEN_PLATFORM_MACOSX)
-#include "QtURIHandler.h"
+#include <Swift/QtUI/QtURIHandler.h>
#elif defined(SWIFTEN_PLATFORM_WIN32)
#include <SwifTools/URIHandler/NullURIHandler.h>
#else
-#include "QtDBUSURIHandler.h"
+#include <Swift/QtUI/QtDBUSURIHandler.h>
#endif
namespace Swift{
@@ -104,7 +109,7 @@ XMLSettingsProvider* QtSwift::loadSettingsFile(const QString& fileName) {
return new XMLSettingsProvider("");
}
-void QtSwift::loadEmoticonsFile(const QString& fileName, QMap<QString, QString>& emoticons) {
+void QtSwift::loadEmoticonsFile(const QString& fileName, std::map<std::string, std::string>& emoticons) {
QFile file(fileName);
if (file.exists() && file.open(QIODevice::ReadOnly)) {
while (!file.atEnd()) {
@@ -117,7 +122,7 @@ void QtSwift::loadEmoticonsFile(const QString& fileName, QMap<QString, QString>&
if (!emoticonFile.startsWith(":/") && !emoticonFile.startsWith("qrc:/")) {
emoticonFile = "file://" + emoticonFile;
}
- emoticons[tokens[0]] = emoticonFile;
+ emoticons[Q2PSTRING(tokens[0])] = Q2PSTRING(emoticonFile);
}
}
}
@@ -135,7 +140,7 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa
settingsHierachy_->addProviderToTopOfStack(xmlSettings_);
settingsHierachy_->addProviderToTopOfStack(qtSettings_);
- QMap<QString, QString> emoticons;
+ std::map<std::string, std::string> emoticons;
loadEmoticonsFile(":/emoticons/emoticons.txt", emoticons);
loadEmoticonsFile(P2QSTRING(pathToString(Paths::getExecutablePath() / "emoticons.txt")), emoticons);
@@ -162,7 +167,7 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa
applicationPathProvider_ = new PlatformApplicationPathProvider(SWIFT_APPLICATION_NAME);
storagesFactory_ = new FileStoragesFactory(applicationPathProvider_->getDataDir(), networkFactories_.getCryptoProvider());
certificateStorageFactory_ = new CertificateFileStorageFactory(applicationPathProvider_->getDataDir(), tlsFactories_.getCertificateFactory(), networkFactories_.getCryptoProvider());
- chatWindowFactory_ = new QtChatWindowFactory(splitter_, settingsHierachy_, qtSettings_, tabs_, "", emoticons);
+ chatWindowFactory_ = new QtChatWindowFactory(splitter_, settingsHierachy_, qtSettings_, tabs_, "");
soundPlayer_ = new QtSoundPlayer(applicationPathProvider_);
// Ugly, because the dock depends on the tray, but the temporary
@@ -220,6 +225,7 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa
notifier_,
uriHandler_,
&idleDetector_,
+ emoticons,
options.count("latency-debug") > 0);
mainControllers_.push_back(mainController);
}
diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h
index 216527d..1ea8886 100644
--- a/Swift/QtUI/QtSwift.h
+++ b/Swift/QtUI/QtSwift.h
@@ -61,7 +61,7 @@ namespace Swift {
~QtSwift();
private:
XMLSettingsProvider* loadSettingsFile(const QString& fileName);
- void loadEmoticonsFile(const QString& fileName, QMap<QString, QString>& emoticons);
+ void loadEmoticonsFile(const QString& fileName, std::map<std::string, std::string>& emoticons);
private:
QtEventLoop clientMainThreadCaller_;
PlatformTLSFactories tlsFactories_;