From 6105ce8e8d5017128ab64259ae20620c12e1fb3c Mon Sep 17 00:00:00 2001 From: liuch Date: Wed, 26 Jul 2017 19:45:25 +0300 Subject: [PATCH] Updated new-history patch: some functionality went to upstream --- patches/dev/psi-new-history.patch | 518 ------------------------------ 1 file changed, 518 deletions(-) diff --git a/patches/dev/psi-new-history.patch b/patches/dev/psi-new-history.patch index 339e771..2ec0d80 100644 --- a/patches/dev/psi-new-history.patch +++ b/patches/dev/psi-new-history.patch @@ -106,28 +106,6 @@ done mkdir -p $contentsdir/Plugins/crypto ---- git.orig/options/default.xml -+++ git/options/default.xml -@@ -128,6 +128,9 @@ - false - auto - -+ -+ 5 -+ - - - -@@ -672,6 +675,9 @@ QLineEdit#le_status_text { - - false - -+ -+ false -+ - - - --- git.orig/psi.qc +++ git/psi.qc @@ -17,6 +17,9 @@ @@ -309,373 +287,6 @@ +#endif + } +}; ---- git.orig/src/chatdlg.cpp -+++ git/src/chatdlg.cpp -@@ -73,8 +73,8 @@ - #include "psicontactlist.h" - #include "accountlabel.h" - #include "psirichtext.h" --#include "messageview.h" - #include "chatview.h" -+#include "eventdb.h" - - #ifdef Q_OS_WIN - #include -@@ -98,6 +98,7 @@ ChatDlg* ChatDlg::create(const Jid& jid, - ChatDlg::ChatDlg(const Jid& jid, PsiAccount* pa, TabManager* tabManager) - : TabbableWidget(jid, pa, tabManager) - , highlightersInstalled_(false) -+ , delayedMessages(0) - { - pending_ = 0; - keepOpen_ = false; -@@ -110,6 +111,9 @@ ChatDlg::ChatDlg(const Jid& jid, PsiAcco - - status_ = -1; - -+ historyState = false; -+ preloadHistory(); -+ - autoSelectContact_ = false; - if (PsiOptions::instance()->getOption("options.ui.chat.default-jid-mode").toString() == "auto") { - UserListItem *uli = account()->findFirstRelevant(jid); -@@ -168,6 +172,8 @@ void ChatDlg::init() - - ChatDlg::~ChatDlg() - { -+ if (delayedMessages) -+ delete delayedMessages; - account()->dialogUnregister(this); - } - -@@ -433,6 +439,43 @@ UserStatus ChatDlg::userStatusFor(const - return u; - } - -+void ChatDlg::preloadHistory() -+{ -+ int cnt =PsiOptions::instance()->getOption("options.ui.chat.history.preload-history-size").toInt(); -+ if (cnt > 0) { -+ holdMessages(true); -+ if (cnt > 100) -+ cnt = 100; -+ EDBHandle *h = new EDBHandle(account()->edb()); -+ connect(h, SIGNAL(finished()), this, SLOT(getHistory())); -+ Jid j = jid(); -+ if (!account()->findGCContact(j)) -+ j = jid().bare(); -+ int start = account()->eventQueue()->count(jid(), false); -+ h->get(account()->id(), j, QDateTime(), EDB::Backward, start, cnt); -+ } -+} -+ -+void ChatDlg::getHistory() -+{ -+ EDBHandle *h = qobject_cast(sender()); -+ if (!h) -+ return; -+ -+ historyState = true; -+ const EDBResult &r = h->result(); -+ for (int i = r.count() - 1; i >= 0; --i) { -+ const EDBItemPtr &item = r.at(i); -+ PsiEvent::Ptr e = item->event(); -+ if (e->type() == PsiEvent::Message) { -+ MessageEvent::Ptr me = e.staticCast(); -+ appendMessage(me->message(), me->originLocal()); -+ } -+ } -+ delete h; -+ holdMessages(false); -+} -+ - void ChatDlg::ensureTabbedCorrectly() - { - TabbableWidget::ensureTabbedCorrectly(); -@@ -494,7 +537,7 @@ void ChatDlg::updateContact(const Jid &j - if (PsiOptions::instance()->getOption("options.ui.chat.show-status-changes").toBool() - && fromPresence && statusChanged) - { -- chatView()->dispatchMessage(MessageView::statusMessage( -+ dispatchMessage(MessageView::statusMessage( - dispNick_, status_, - statusString_, priority_)); - } -@@ -789,6 +832,7 @@ void ChatDlg::doSend() - - void ChatDlg::doneSend() - { -+ historyState = false; - appendMessage(m_, true); - disconnect(chatEdit(), SIGNAL(textChanged()), this, SLOT(setComposing())); - chatEdit()->clear(); -@@ -817,6 +861,7 @@ void ChatDlg::encryptedMessageSent(int x - - void ChatDlg::incomingMessage(const Message &m) - { -+ historyState = false; - if (m.body().isEmpty() && m.subject().isEmpty() && m.urlList().isEmpty()) { - // Event message - if (m.containsEvent(CancelEvent)) { -@@ -877,14 +922,16 @@ void ChatDlg::appendMessage(const Messag - // figure out the encryption state - bool encChanged = false; - bool encEnabled = false; -- if (lastWasEncrypted_ != m.wasEncrypted()) { -- encChanged = true; -+ if (!historyState) { -+ if (lastWasEncrypted_ != m.wasEncrypted()) { -+ encChanged = true; -+ } -+ lastWasEncrypted_ = m.wasEncrypted(); -+ encEnabled = lastWasEncrypted_; - } -- lastWasEncrypted_ = m.wasEncrypted(); -- encEnabled = lastWasEncrypted_; - - if (encChanged) { -- chatView()->dispatchMessage(MessageView::fromHtml( -+ dispatchMessage(MessageView::fromHtml( - encEnabled? QString(" ") + tr("Encryption Enabled"): - QString(" ") + tr("Encryption Disabled"), - MessageView::System -@@ -900,7 +947,9 @@ void ChatDlg::appendMessage(const Messag - } - - if (!m.subject().isEmpty()) { -- chatView()->dispatchMessage(MessageView::subjectMessage(m.subject())); -+ MessageView smv = MessageView::subjectMessage(m.subject()); -+ smv.setSpooled(historyState); -+ dispatchMessage(smv); - } - - MessageView mv(MessageView::Message); -@@ -930,10 +979,11 @@ void ChatDlg::appendMessage(const Messag - mv.setNick(whoNick(local)); - mv.setUserId(local?account()->jid().full():jid().full()); // theoretically, this can be inferred from the chat dialog properties - mv.setDateTime(m.timeStamp()); -- mv.setSpooled(m.spooled()); -+ mv.setSpooled(historyState); - mv.setAwaitingReceipt(local && m.messageReceipt() == ReceiptRequest); - mv.setReplaceId(m.replaceId()); -- chatView()->dispatchMessage(mv); -+ mv.setCarbonDirection(m.carbonDirection()); -+ dispatchMessage(mv); - - if (!m.urlList().isEmpty()) { - UrlList urls = m.urlList(); -@@ -943,12 +993,52 @@ void ChatDlg::appendMessage(const Messag - } - // Some XMPP clients send links to HTTP uploaded files both in body and in jabber:x:oob. - // It's convenient to show only body if OOB data brings no additional information. -- if (!(urlsMap.size() == 1 && urlsMap.contains(body) && urlsMap.value(body).isEmpty())) -- chatView()->dispatchMessage(MessageView::urlsMessage(urlsMap)); -+ if (!(urlsMap.size() == 1 && urlsMap.contains(body) && urlsMap.value(body).isEmpty())) { -+ MessageView umv = MessageView::urlsMessage(urlsMap); -+ umv.setSpooled(historyState); -+ dispatchMessage(umv); -+ } - } -+ emit messageAppended(body, chatView()->textWidget()); -+} -+ -+void ChatDlg::holdMessages(bool hold) -+{ -+ if (hold) { -+ if (!delayedMessages) -+ delayedMessages = new QList(); -+ } -+ else if (delayedMessages) { -+ foreach (const MessageView &mv, *delayedMessages) -+ { -+ if (mv.isSpooled()) -+ displayMessage(mv); -+ } -+ foreach (const MessageView &mv, *delayedMessages) -+ { -+ if (!mv.isSpooled()) -+ displayMessage(mv); -+ } -+ delete delayedMessages; -+ delayedMessages = 0; -+ } -+} -+ -+void ChatDlg::dispatchMessage(const MessageView &mv) -+{ -+ if (delayedMessages) -+ delayedMessages->append(mv); -+ else -+ displayMessage(mv); -+} -+ -+void ChatDlg::displayMessage(const MessageView &mv) -+{ -+ chatView()->dispatchMessage(mv); - - // if we're not active, notify the user by changing the title -- if (!isActiveTab() && m.carbonDirection() != Message::Sent) { -+ MessageView::Type type = mv.type(); -+ if (type != MessageView::System && type != MessageView::Status && !mv.isSpooled() && !isActiveTab() && mv.carbonDirection() != Message::Sent) { - ++pending_; - invalidateTab(); - if (PsiOptions::instance()->getOption("options.ui.flash-windows").toBool()) { -@@ -970,11 +1060,10 @@ void ChatDlg::appendMessage(const Messag - // messagesRead(jid()); - //} - -- if (!local) { -+ if (!mv.isLocal()) { - keepOpen_ = true; - QTimer::singleShot(1000, this, SLOT(setKeepOpenFalse())); - } -- emit messageAppended(body, chatView()->textWidget()); - } - - void ChatDlg::updateIsComposing(bool b) ---- git.orig/src/chatdlg.h -+++ git/src/chatdlg.h -@@ -33,6 +33,7 @@ - #include "advwidget.h" - - #include "tabbablewidget.h" -+#include "messageview.h" - - - namespace XMPP -@@ -88,6 +89,7 @@ public: - Jid realJid() const; - bool autoSelectContact() const {return autoSelectContact_;}; - static UserStatus userStatusFor(const Jid& jid, QList ul, bool forceEmptyResource); -+ void preloadHistory(); - - signals: - void aInfo(const Jid &); -@@ -148,6 +150,7 @@ private slots: - void addEmoticon(QString text); - void initComposing(); - void setComposing(); -+ void getHistory(); - - protected slots: - void checkComposing(); -@@ -159,6 +162,9 @@ protected: - void updateRealJid(); - void resetComposing(); - void doneSend(); -+ void holdMessages(bool hold); -+ void dispatchMessage(const MessageView &mv); -+ void displayMessage(const MessageView &mv); - virtual void setLooks(); - void setSelfDestruct(int); - virtual void chatEditCreated(); -@@ -214,9 +220,11 @@ private: - QTimer* composingTimer_; - bool isComposing_; - bool sendComposingEvents_; -+ bool historyState; - QString eventId_; - ChatState contactChatState_; - ChatState lastChatState_; -+ QList *delayedMessages; - }; - - #endif ---- git.orig/src/chatview_te.cpp -+++ git/src/chatview_te.cpp -@@ -88,6 +88,7 @@ ChatView::ChatView(QWidget *parent) - logIconTime = IconsetFactory::iconPixmap("psi/notification_chat_time").scaledToHeight(logIconsSize, Qt::SmoothTransformation); - logIconInfo = IconsetFactory::iconPixmap("psi/notification_chat_info").scaledToHeight(logIconsSize, Qt::SmoothTransformation); - logIconCorrected = IconsetFactory::iconPixmap("psi/action_templates_edit").scaledToHeight(logIconsSize, Qt::SmoothTransformation); -+ logIconHistory = IconsetFactory::iconPixmap("psi/history").scaledToHeight(logIconsSize, Qt::SmoothTransformation); - } else { - logIconReceive = IconsetFactory::iconPixmap("psi/notification_chat_receive"); - logIconSend = IconsetFactory::iconPixmap("psi/notification_chat_send"); -@@ -98,6 +99,7 @@ ChatView::ChatView(QWidget *parent) - logIconTime = IconsetFactory::iconPixmap("psi/notification_chat_time"); - logIconInfo = IconsetFactory::iconPixmap("psi/notification_chat_info"); - logIconCorrected = IconsetFactory::iconPixmap("psi/action_templates_edit"); -+ logIconHistory = IconsetFactory::iconPixmap("psi/history"); - } - addLogIconsResources(); - } -@@ -177,6 +179,7 @@ void ChatView::addLogIconsResources() - document()->addResource(QTextDocument::ImageResource, QUrl("icon:log_icon_delivered"), logIconDelivered); - document()->addResource(QTextDocument::ImageResource, QUrl("icon:log_icon_delivered_pgp"), logIconDeliveredPgp); - document()->addResource(QTextDocument::ImageResource, QUrl("icon:log_icon_corrected"), logIconCorrected); -+ document()->addResource(QTextDocument::ImageResource, QUrl("icon:log_icon_history"), logIconHistory); - } - - void ChatView::markReceived(QString id) -@@ -459,28 +462,49 @@ void ChatView::renderMucMessage(const Me - void ChatView::renderMessage(const MessageView &mv) - { - QString timestr = formatTimeStamp(mv.dateTime()); -- QString color = colorString(mv.isLocal(), mv.isSpooled()); -+ QString color = colorString(mv.isLocal(), false); - if (useMessageIcons_ && mv.isAwaitingReceipt()) { - document()->addResource(QTextDocument::ImageResource, QUrl(QString("icon:delivery") + mv.messageId()), - isEncryptionEnabled_ ? logIconSendPgp : logIconSend); - } -- QString icon = useMessageIcons_ ? -- (QString("").arg(mv.isLocal()? -- (mv.isAwaitingReceipt() ? QString("icon:delivery") + mv.messageId() -- : isEncryptionEnabled_ ? "icon:log_icon_send_pgp" : "icon:log_icon_send") -- : isEncryptionEnabled_ ? "icon:log_icon_receive_pgp" : "icon:log_icon_receive")) : ""; -+ QString icon; -+ if (useMessageIcons_) { -+ QString sRes; -+ if (mv.isSpooled()) -+ sRes = "icon:log_icon_history"; -+ else if (mv.isLocal()) { -+ if (mv.isAwaitingReceipt()) -+ sRes = QString("icon:delivery") + mv.messageId(); -+ else if (isEncryptionEnabled_) -+ sRes = "icon:log_icon_receive_pgp"; -+ else -+ sRes = "icon:log_icon_send"; -+ } else { -+ if (isEncryptionEnabled_) -+ sRes = "icon:log_icon_receive_pgp"; -+ else -+ sRes = "icon:log_icon_receive"; -+ } -+ icon = QString("").arg(sRes); -+ } -+ QString str; - - QString inner = mv.formattedText() + replaceMarker(mv); - if (mv.isEmote()) { -- appendText(icon + QString("").arg(color) + QString("[%1]").arg(timestr) + QString(" *%1 ").arg(TextUtil::escape(mv.nick())) + inner + ""); -+ str = icon + QString("").arg(color) + QString("[%1]").arg(timestr) + QString(" *%1 ").arg(TextUtil::escape(mv.nick())) + inner + ""; - } else { - if (PsiOptions::instance()->getOption("options.ui.chat.use-chat-says-style").toBool()) { -- appendText(icon + QString("").arg(color) + QString("[%1] ").arg(timestr) + tr("%1 says:").arg(TextUtil::escape(mv.nick())) + "
" + inner); -+ str = icon + QString("").arg(color) + QString("[%1] ").arg(timestr) + tr("%1 says:").arg(TextUtil::escape(mv.nick())) + "
"; - } - else { -- appendText(icon + QString("").arg(color) + QString("[%1] <").arg(timestr) + TextUtil::escape(mv.nick()) + QString("> ") + inner); -+ str = icon + QString("").arg(color) + QString("[%1] <").arg(timestr) + TextUtil::escape(mv.nick()) + QString("> "); - } -+ if (mv.isSpooled()) -+ str.append(QString("%2").arg(ColorOpt::instance()->color("options.ui.look.colors.messages.usertext").name()).arg(inner)); -+ else -+ str.append(inner); - } -+ appendText(str); - - if (mv.isLocal() && PsiOptions::instance()->getOption("options.ui.chat.auto-scroll-to-bottom").toBool() ) { - deferredScroll(); ---- git.orig/src/chatview_te.h -+++ git/src/chatview_te.h -@@ -121,6 +121,7 @@ private: - QPixmap logIconTime; - QPixmap logIconInfo; - QPixmap logIconCorrected; -+ QPixmap logIconHistory; - QAction *actQuote_; - }; - --- git.orig/src/edbsqlite.cpp +++ git/src/edbsqlite.cpp @@ -0,0 +1,874 @@ @@ -2122,57 +1733,6 @@ +}; + +#endif ---- git.orig/src/messageview.cpp -+++ git/src/messageview.cpp -@@ -32,7 +32,8 @@ MessageView::MessageView(Type t) : - _flags(0), - _status(0), - _statusPriority(0), -- _dateTime(QDateTime::currentDateTime()) -+ _dateTime(QDateTime::currentDateTime()), -+ _carbon(XMPP::Message::NoCarbon) - { - } - ---- git.orig/src/messageview.h -+++ git/src/messageview.h -@@ -24,6 +24,8 @@ - #include - #include - -+#include "xmpp_message.h" -+ - #if QT_VERSION < QT_VERSION_CHECK(5,7,0) - # define SET_QFLAG(flags, flag, state) if (state) flags |= flag; else flags &= ~flag - #else -@@ -123,6 +125,8 @@ public: - inline QMap urls() const { return _urls; } - inline void setReplaceId(const QString &id) { _replaceId = id; } - inline const QString &replaceId() const { return _replaceId; } -+ inline void setCarbonDirection(XMPP::Message::CarbonDir c) {_carbon = c; } -+ inline XMPP::Message::CarbonDir carbonDirection() const { return _carbon; } - - QVariantMap toVariantMap(bool isMuc, bool formatted = false) const; - -@@ -139,6 +143,7 @@ private: - QDateTime _dateTime; - QMap _urls; - QString _replaceId; -+ XMPP::Message::CarbonDir _carbon; - }; - - Q_DECLARE_OPERATORS_FOR_FLAGS(MessageView::Flags) ---- git.orig/src/psichatdlg.cpp -+++ git/src/psichatdlg.cpp -@@ -925,7 +925,7 @@ bool PsiChatDlg::isEncryptionEnabled() c - - void PsiChatDlg::appendSysMsg(const QString &str) - { -- chatView()->dispatchMessage(MessageView::fromHtml(str, MessageView::System)); -+ dispatchMessage(MessageView::fromHtml(str, MessageView::System)); - } - - ChatView* PsiChatDlg::chatView() const --- git.orig/src/psicon.cpp +++ git/src/psicon.cpp @@ -62,7 +62,7 @@ @@ -2184,26 +1744,6 @@ #include "proxy.h" #ifdef PSIMNG #include "psimng.h" -@@ -359,8 +359,7 @@ PsiCon::PsiCon() - d->ftwin = 0; - #endif - -- d->edb = new EDBFlatFile(this); -- -+ d->edb = 0; - d->s5bServer = 0; - d->tuneManager = 0; - d->autoUpdater = 0; -@@ -381,7 +380,8 @@ PsiCon::~PsiCon() - - delete d->autoUpdater; - delete d->actionList; -- delete d->edb; -+ if (d->edb) -+ delete d->edb; - delete d->defaultMenuBar; - delete d->tabManager; - delete d->popupManager; @@ -656,6 +656,12 @@ bool PsiCon::init() checkAccountsEmpty(); @@ -2245,61 +1785,3 @@ $$PWD/historycontactlistmodel.cpp \ $$PWD/searchdlg.cpp \ $$PWD/registrationdlg.cpp \ ---- git.orig/themes/chatview/psi/adapter.js -+++ git/themes/chatview/psi/adapter.js -@@ -271,7 +271,11 @@ function psiThemeAdapter(chat) { - } - if (!template) { - data.nextOfGroup = false; //can't group w/o template -- template = data.local?shared.templates.sentMessage:shared.templates.receivedMessage; -+ if (data.spooled) { -+ template = shared.templates.spooledMessage; -+ } else { -+ template = data.local?shared.templates.sentMessage:shared.templates.receivedMessage; -+ } - } - break; - case "join": ---- git.orig/themes/chatview/psi/classic/index.html -+++ git/themes/chatview/psi/classic/index.html -@@ -80,7 +80,9 @@ function startPsiTheme(shared) { - receivedMessage: shared.isMuc? - "
%icon%[%time%] %sender% %alertedmessage%
" - : null, -- spooledMessage: "
%icon%[%time%] %sender% %message%
", -+ spooledMessage: shared.isMuc? -+ "
%icon%[%time%] %sender% %message%
" -+ : "
%icon%[%time%] %sender% %message%
", - sys: "
%icon%%message%
", - sysMessage: "
%icon%[%time%] *** %message%
", - sysMessageUT: "
%icon%[%time%] *** %message%: %usertext%
", -@@ -104,7 +106,7 @@ function startPsiTheme(shared) { - } - if (shared.cdata.mtype == "message") { - var template = shared.cdata.emote && shared.templates.messageNC || -- (shared.cdata.spooled && shared.templates.message || null); -+ (shared.cdata.spooled && shared.templates.spooledMessage || null); - if (template) { - shared.appendHtml(template.toString(), shared.cdata.local?true:null); - return false; -@@ -127,8 +129,7 @@ function startPsiTheme(shared) { - shared.cdata.message+"":shared.cdata.message; - return shared.cdata.id? util.replaceableMessage(shared.isMuc, shared.cdata.local, shared.cdata.sender, shared.cdata.id, msg) : msg; - }, -- sentrec : function() {return shared.cdata.spooled?"infmsg": -- (shared.cdata.local?"sent":"received");}, -+ sentrec : function() {return shared.cdata.local?"sent":"received";}, - nickcolor : function() { - return util.nickColor(shared.cdata.sender); - }, -@@ -137,6 +138,10 @@ function startPsiTheme(shared) { - if (useMessageIcons) { - switch (shared.cdata.mtype) { - case "message": -+ if (shared.cdata.spooled) { -+ icon = "psi/history"; -+ break; -+ } - icon = shared.cdata.local?(shared.cdata.awaitingReceipt? - "psi/notification_chat_send":"psi/notification_chat_delivery_ok") - : "psi/notification_chat_receive";