[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:24:49 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=8810090
The following commit has been merged in the master branch:
commit 881009073c1728470c94c8cde08087bd2a521857
Author: Marcin Ziemiński <zieminn at gmail.com>
Date: Sun Aug 17 18:49:09 2014 +0200
Added notification about authentication events and changes in OTR sessions.
---
lib/CMakeLists.txt | 1 +
lib/chat-widget.cpp | 29 +++++-
lib/otr-notifications.cpp | 112 +++++++++++++++++++++
.../appearance-config.h => lib/otr-notifications.h | 37 +++----
4 files changed, 154 insertions(+), 25 deletions(-)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index e368194..796ff1b 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -24,6 +24,7 @@ set(ktpchat_SRCS
proxy-service.cpp
otr-utils.cpp
authenticationwizard.cpp
+ otr-notifications.cpp
)
set(ktpchat_UI
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index bcd10e7..deff57c 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -31,6 +31,7 @@
#include "contact-delegate.h"
#include "channel-adapter.h"
#include "authenticationwizard.h"
+#include "otr-notifications.h"
#include <QtGui/QKeyEvent>
#include <QtGui/QAction>
@@ -741,6 +742,9 @@ void ChatWidget::onOTRTrustLevelChanged(Tp::OTRTrustLevel trustLevel, Tp::OTRTru
}
else {
d->ui.chatArea->addStatusMessage(i18n("Unverified OTR session started"));
+ if(!this->isActiveWindow()) {
+ OTRNotifications::otrSessionStarted(this, d->channel.textChannel()->targetContact(), false);
+ }
}
break;
case Tp::OTRTrustLevelPrivate:
@@ -749,10 +753,16 @@ void ChatWidget::onOTRTrustLevelChanged(Tp::OTRTrustLevel trustLevel, Tp::OTRTru
}
else {
d->ui.chatArea->addStatusMessage(i18n("Private OTR session started"));
+ if(!this->isActiveWindow()) {
+ OTRNotifications::otrSessionStarted(this, d->channel.textChannel()->targetContact(), true);
+ }
}
break;
case Tp::OTRTrustLevelFinished:
d->ui.chatArea->addStatusMessage(i18n("%1 has ended the OTR session. You should do the same", d->contactName));
+ if(!this->isActiveWindow()) {
+ OTRNotifications::otrSessionFinished(this, d->channel.textChannel()->targetContact());
+ }
break;
default: break;
@@ -769,12 +779,18 @@ void ChatWidget::onOTRsessionRefreshed()
void ChatWidget::onPeerAuthenticationRequestedQA(const QString &question)
{
- new AuthenticationWizard(&d->channel, d->contactName, this, false, question);
+ AuthenticationWizard *wizard = new AuthenticationWizard(&d->channel, d->contactName, this, false, question);
+ if(!wizard->isActiveWindow()) {
+ OTRNotifications::authenticationRequested(wizard, d->channel.textChannel()->targetContact());
+ }
}
void ChatWidget::onPeerAuthenticationRequestedSS()
{
- new AuthenticationWizard(&d->channel, d->contactName, this, false);
+ AuthenticationWizard *wizard = new AuthenticationWizard(&d->channel, d->contactName, this, false);
+ if(!wizard->isActiveWindow()) {
+ OTRNotifications::authenticationRequested(wizard, d->channel.textChannel()->targetContact());
+ }
}
void ChatWidget::onPeerAuthenticationConcluded(bool authenticated)
@@ -785,6 +801,9 @@ void ChatWidget::onPeerAuthenticationConcluded(bool authenticated)
wizard->showNormal();
wizard->finished(authenticated);
}
+ if(!wizard->isActiveWindow()) {
+ OTRNotifications::authenticationConcluded(wizard, d->channel.textChannel()->targetContact(), authenticated);
+ }
}
void ChatWidget::onPeerAuthenticationInProgress()
@@ -805,6 +824,9 @@ void ChatWidget::onPeerAuthenticationAborted()
wizard->showNormal();
wizard->aborted();
}
+ if(!wizard->isActiveWindow()) {
+ OTRNotifications::authenticationAborted(wizard, d->channel.textChannel()->targetContact());
+ }
}
void ChatWidget::onPeerAuthenticationFailed()
@@ -815,6 +837,9 @@ void ChatWidget::onPeerAuthenticationFailed()
wizard->showNormal();
wizard->finished(false);
}
+ if(!wizard->isActiveWindow()) {
+ OTRNotifications::authenticationFailed(wizard, d->channel.textChannel()->targetContact());
+ }
}
void ChatWidget::handleIncomingMessage(const Tp::ReceivedMessage &message, bool alreadyNotified)
diff --git a/lib/otr-notifications.cpp b/lib/otr-notifications.cpp
new file mode 100644
index 0000000..883ac41
--- /dev/null
+++ b/lib/otr-notifications.cpp
@@ -0,0 +1,112 @@
+/***************************************************************************
+ * Copyright (C) 2014 by Marcin Ziemiński <zieminn at gmail.com> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+
+#include "otr-notifications.h"
+
+#include <TelepathyQt/AvatarData>
+
+#include <QWidget>
+
+#include <KAboutData>
+#include <KComponentData>
+#include <KNotification>
+
+namespace OTRNotifications
+{
+
+ static KNotification* prepareNotification(QWidget *widget, const Tp::ContactPtr &contact)
+ {
+ const QString notificationType = QLatin1String("kde_telepathy_info_event");
+
+ KNotification *notification = new KNotification(
+ notificationType, widget,
+ KNotification::RaiseWidgetOnActivation
+ | KNotification::CloseWhenWidgetActivated
+ | KNotification::CloseOnTimeout);
+
+ KAboutData telepathySharedAboutData("ktelepathy", 0, KLocalizedString(), 0);
+ notification->setComponentData(KComponentData(telepathySharedAboutData));
+
+ QPixmap notificationPixmap;
+ if(notificationPixmap.load(contact->avatarData().fileName)) {
+ notification->setPixmap(notificationPixmap);
+ }
+
+ notification->setActions(QStringList(i18n("View")));
+
+ return notification;
+ }
+
+ void otrSessionStarted(QWidget *widget, const Tp::ContactPtr &targetContact, bool verified)
+ {
+ KNotification *notification = prepareNotification(widget, targetContact);
+ if(verified) {
+ notification->setText(i18n("Private OTR session started with %1", targetContact->id()));
+ } else {
+ notification->setText(i18n("Unverified OTR session started with %1", targetContact->id()));
+ }
+
+ notification->sendEvent();
+ }
+
+ void otrSessionFinished(QWidget *widget, const Tp::ContactPtr &targetContact)
+ {
+ KNotification *notification = prepareNotification(widget, targetContact);
+ notification->setText(i18n("Finished OTR session with %1", targetContact->id()));
+
+ notification->sendEvent();
+ }
+
+ void authenticationRequested(QWidget *widget, const Tp::ContactPtr &targetContact)
+ {
+ KNotification *notification = prepareNotification(widget, targetContact);
+ notification->setText(i18n("%1 has requested your authentication", targetContact->id()));
+
+ notification->sendEvent();
+ }
+
+ void authenticationConcluded(QWidget *widget, const Tp::ContactPtr &targetContact, bool success)
+ {
+ KNotification *notification = prepareNotification(widget, targetContact);
+ if(success) {
+ notification->setText(i18n("Authentication with %1 completed successfully", targetContact->id()));
+ } else {
+ notification->setText(i18n("Authentication with %1 failed", targetContact->id()));
+ }
+
+ notification->sendEvent();
+ }
+
+ void authenticationAborted(QWidget *widget, const Tp::ContactPtr &targetContact)
+ {
+ KNotification *notification = prepareNotification(widget, targetContact);
+ notification->setText(i18n("Authentication with %1 was aborted", targetContact->id()));
+
+ notification->sendEvent();
+ }
+
+ void authenticationFailed(QWidget *widget, const Tp::ContactPtr &targetContact)
+ {
+ KNotification *notification = prepareNotification(widget, targetContact);
+ notification->setText(i18n("Authentication with %1 failed", targetContact->id()));
+
+ notification->sendEvent();
+ }
+}
diff --git a/config/appearance-config.h b/lib/otr-notifications.h
similarity index 63%
copy from config/appearance-config.h
copy to lib/otr-notifications.h
index f0e1168..fdbc28a 100644
--- a/config/appearance-config.h
+++ b/lib/otr-notifications.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2011 by David Edmundson <kde at davidedmundson.co.uk> *
+ * Copyright (C) 2014 by Marcin Ziemiński <zieminn at gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -17,35 +17,26 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#ifndef APPEARANCE_CONFIG_H
-#define APPEARANCE_CONFIG_H
+#ifndef OTR_NOTIFICATIONS_HEADER
+#define OTR_NOTIFICATIONS_HEADER
-#include "adium-theme-header-info.h"
-#include "appearance-config-tab.h"
+#include <TelepathyQt/Contact>
-#include <KCModule>
+class QWidget;
-class AppearanceConfig : public KCModule
+namespace OTRNotifications
{
- Q_OBJECT
+ void otrSessionStarted(QWidget *widget, const Tp::ContactPtr &targetContact, bool verified);
-public:
- explicit AppearanceConfig(QWidget *parent = 0,
- const QVariantList &args = QVariantList());
- ~AppearanceConfig();
+ void otrSessionFinished(QWidget *widget, const Tp::ContactPtr &targetContact);
-public Q_SLOTS:
- virtual void save();
- virtual void load();
- virtual void defaults();
+ void authenticationRequested(QWidget *widget, const Tp::ContactPtr &targetContact);
-Q_SIGNALS:
- void reloadTheme();
+ void authenticationConcluded(QWidget *widget, const Tp::ContactPtr &targetContact, bool success);
-protected:
- AppearanceConfigTab *m_singleTab;
- AppearanceConfigTab *m_groupTab;
+ void authenticationAborted(QWidget *widget, const Tp::ContactPtr &targetContact);
-};
+ void authenticationFailed(QWidget *widget, const Tp::ContactPtr &targetContact);
+}
-#endif // APPEARANCE_CONFIG_H
+#endif
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list