~ubuntu-branches/ubuntu/lucid/konversation/lucid-updates

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
From 425d2ba6f75053784b1b304646aea745fc4aeb94 Mon Sep 17 00:00:00 2001
From: Aurelien Gateau <aurelien.gateau@canonical.com>
Date: Fri, 22 Jan 2010 15:12:15 +0100
Subject: [PATCH] Adds support for Message Indicator

---
 CMakeLists.txt                        |    5 ++
 config-konversation.h.cmake           |    3 +-
 src/CMakeLists.txt                    |    9 ++-
 src/config/konversation.kcfg          |   17 +++++
 src/config/messageindicator_config.ui |   69 ++++++++++++++++++
 src/config/settingsdialog.cpp         |   13 ++++
 src/notificationhandler.cpp           |  126 +++++++++++++++++++++++++++++++++
 src/notificationhandler.h             |   20 +++++-
 8 files changed, 259 insertions(+), 3 deletions(-)
 create mode 100644 src/config/messageindicator_config.ui

Index: konversation-1.2.3/CMakeLists.txt
===================================================================
--- konversation-1.2.3.orig/CMakeLists.txt
+++ konversation-1.2.3/CMakeLists.txt
@@ -8,6 +8,7 @@ set(KDE_MIN_VERSION "4.00.82")
 #atm this gets us FindQt4 and FindX11 (provided that the default cmake FindQt4 doesn't get used)
 find_package(KDE4 REQUIRED)
 find_package(KdepimLibs REQUIRED)
+find_package(PkgConfig REQUIRED)
 include(KDE4Defaults)
 include(MacroLibrary)
 include(CheckIncludeFile)
@@ -37,6 +38,10 @@ macro_optional_find_package(QCA2)
 macro_bool_to_01(QCA2_FOUND HAVE_QCA2)
 macro_log_feature(QCA2_FOUND "QCA" "Qt Cryptographic Architecture" "http://delta.affinix.com/qca" FALSE "2.0.0" "Required for using encryption in IRC")
 
+pkg_check_modules(INDICATEQT indicate-qt)
+macro_bool_to_01(INDICATEQT_FOUND HAVE_INDICATEQT)
+macro_log_feature(INDICATEQT_FOUND "libindicate-qt" "Qt binding for libindicate" "http://launchpad.net/libindicate-qt" FALSE "" "Support for message indicator")
+
 #check for greater than 4.3.80
 macro_ensure_version( "4.3.80" ${KDE_VERSION} HAVEKDE4_4 )
 macro_bool_to_01(HAVEKDE4_4 HAVE_KSTATUSNOTIFIERITEM)
Index: konversation-1.2.3/config-konversation.h.cmake
===================================================================
--- konversation-1.2.3.orig/config-konversation.h.cmake
+++ konversation-1.2.3/config-konversation.h.cmake
@@ -2,4 +2,5 @@
 #cmakedefine HAVE_X11 1
 #cmakedefine HAVE_XUTIL 1
 #cmakedefine HAVE_QCA2 1
-#cmakedefine HAVE_KSTATUSNOTIFIERITEM 1
\ No newline at end of file
+#cmakedefine HAVE_KSTATUSNOTIFIERITEM 1
+#cmakedefine HAVE_INDICATEQT 1
Index: konversation-1.2.3/src/CMakeLists.txt
===================================================================
--- konversation-1.2.3.orig/src/CMakeLists.txt
+++ konversation-1.2.3/src/CMakeLists.txt
@@ -126,6 +126,7 @@ kde4_add_ui_files(config_SRCS
     config/theme_configui.ui
     config/warnings_configui.ui
     config/watchednicknames_configui.ui
+    config/messageindicator_config.ui
 )
 
     #=== Viewer
@@ -198,6 +199,11 @@ if (QCA2_FOUND)
         cipher.cpp)
 endif (QCA2_FOUND)
 
+if (INDICATEQT_FOUND)
+    include_directories(${INDICATEQT_INCLUDE_DIRS})
+    link_directories(${INDICATEQT_LIBRARY_DIRS})
+endif (INDICATEQT_FOUND)
+
 set(upnp_SRCS
     upnp/soap.cpp
     upnp/upnpdescriptionparser.cpp
@@ -230,7 +236,8 @@ kde4_add_executable(konversation ${konve
 
 target_link_libraries(konversation ${KDE4_KIO_LIBS} ${KDE4_KUTILS_LIBS} ${KDE4_KPARTS_LIBS}
                             ${KDE4_KDE3SUPPORT_LIBS} ${KDE4_KABC_LIBS}
-                            ${KDE4_KNOTIFYCONFIG_LIBRARY} ${PHONON_LIBRARY} ${KDE4_SOLID_LIBS})
+                            ${KDE4_KNOTIFYCONFIG_LIBRARY} ${PHONON_LIBRARY} ${KDE4_SOLID_LIBS}
+                            ${INDICATEQT_LIBRARIES})
 
 if (X11_FOUND AND X11_Xutil_FOUND)
     target_link_libraries(konversation ${X11_X11_LIB})
Index: konversation-1.2.3/src/config/konversation.kcfg
===================================================================
--- konversation-1.2.3.orig/src/config/konversation.kcfg
+++ konversation-1.2.3/src/config/konversation.kcfg
@@ -518,6 +518,23 @@
       <whatsthis></whatsthis>
     </entry>
   </group>
+  <group name="MessageIndicator">
+    <entry key="MessageIndicatorShowOwnNick" type="Bool">
+      <default>true</default>
+      <label></label>
+      <whatsthis></whatsthis>
+    </entry>
+    <entry key="MessageIndicatorShowChannel" type="Bool">
+      <default>false</default>
+      <label></label>
+      <whatsthis></whatsthis>
+    </entry>
+    <entry key="MessageIndicatorShowQuery" type="Bool">
+      <default>true</default>
+      <label></label>
+      <whatsthis></whatsthis>
+    </entry>
+  </group>
   <group name="Notify List">
     <entry key="NotifyDelay" type="Int">
       <default>20</default>
Index: konversation-1.2.3/src/config/messageindicator_config.ui
===================================================================
--- /dev/null
+++ konversation-1.2.3/src/config/messageindicator_config.ui
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MessageIndicator_Config</class>
+ <widget class="QWidget" name="MessageIndicator_Config">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>155</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Use Message Indicator</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_2">
+      <item>
+       <widget class="QCheckBox" name="kcfg_MessageIndicatorShowOwnNick">
+        <property name="text">
+         <string>If own nick appears in channel message</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="kcfg_MessageIndicatorShowChannel">
+        <property name="text">
+         <string>On any channel message</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="kcfg_MessageIndicatorShowQuery">
+        <property name="text">
+         <string>On query activity</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>kcfg_MessageIndicatorShowOwnNick</tabstop>
+  <tabstop>kcfg_MessageIndicatorShowChannel</tabstop>
+  <tabstop>kcfg_MessageIndicatorShowQuery</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
Index: konversation-1.2.3/src/config/settingsdialog.cpp
===================================================================
--- konversation-1.2.3.orig/src/config/settingsdialog.cpp
+++ konversation-1.2.3/src/config/settingsdialog.cpp
@@ -10,6 +10,7 @@
   Copyright (C) 2006 Eike Hein <hein@kde.org>
 */
 
+#include "config-konversation.h"
 #include "settingsdialog.h"
 #include "configdialog.h"
 #include "preferences.h"
@@ -36,6 +37,10 @@
 
 #include <config-konversation.h>
 
+#ifdef HAVE_INDICATEQT
+#include "ui_messageindicator_config.h"
+#endif
+
 
 KonviSettingsDialog::KonviSettingsDialog( QWidget *parent) :
     KonviConfigDialog( parent, "settings", Preferences::self(), KPageDialog::Tree)
@@ -176,6 +181,14 @@ KonviSettingsDialog::KonviSettingsDialog
   //no modified connection needed - it's all kcfg widgets
   m_pages.append(m_confOSDWdg);
 
+  #ifdef HAVE_INDICATEQT
+  //Notification/Message Indicator
+  Ui::MessageIndicator_Config confMessageIndicator;
+  w = new QWidget();
+  confMessageIndicator.setupUi(w);
+  addPage(w, notificationGroup, "mail-unread-new", i18n("Message Indicator"));
+  #endif
+
   //Notification/Warning Dialogs
   m_confWarningsWdg = new Warnings_Config( this, "Warnings" );
   addPage ( m_confWarningsWdg, notificationGroup, "dialog-warning", i18n("Warning Dialogs") );
Index: konversation-1.2.3/src/notificationhandler.cpp
===================================================================
--- konversation-1.2.3.orig/src/notificationhandler.cpp
+++ konversation-1.2.3/src/notificationhandler.cpp
@@ -18,11 +18,27 @@
 #include "viewcontainer.h"
 #include "trayicon.h"
 #include "server.h"
+#include "config-konversation.h"
 
 #include <QTextDocument>
 
 #include <KNotification>
+#include <KWindowSystem>
 
+#ifdef HAVE_INDICATEQT
+#include <qindicateindicator.h>
+#include <qindicateserver.h>
+
+class Indicator : public QIndicate::Indicator
+{
+    public:
+        Indicator(QIndicate::Server* server)
+        : QIndicate::Indicator(server)
+        {}
+
+        QPointer<ChatWindow> m_chatWin;
+};
+#endif
 
 namespace Konversation
 {
@@ -31,6 +47,23 @@ namespace Konversation
         : QObject(parent)
     {
         m_mainWindow = parent->getMainWindow();
+        #ifdef HAVE_INDICATEQT
+        m_indicateServer = QIndicate::Server::defaultInstance();
+        m_indicateServer->setType("message.irc");
+        QString appName = KGlobal::mainComponent().componentName();
+        kDebug() << "appName" << appName;
+        KService::Ptr service = KService::serviceByDesktopName(appName);
+        if (service) {
+            m_indicateServer->setDesktopFile(service->entryPath());
+        } else {
+            kWarning() << "Could not find desktop file for application";
+        }
+        connect(m_indicateServer, SIGNAL(serverDisplay()),
+            SLOT(slotIndicateServerDisplay()));
+        m_indicateServer->show();
+
+        m_mainWindow->installEventFilter(this);
+        #endif
     }
 
     NotificationHandler::~NotificationHandler()
@@ -48,6 +81,9 @@ namespace Konversation
         if (!chatWin || !chatWin->notificationsEnabled())
             return;
 
+        if (Preferences::self()->messageIndicatorShowChannel())
+            addIndicator(chatWin, fromNick);
+
         if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
             return;
 
@@ -76,6 +112,9 @@ namespace Konversation
         if (!chatWin || !chatWin->notificationsEnabled())
             return;
 
+        if (Preferences::self()->messageIndicatorShowOwnNick())
+            addIndicator(chatWin, fromNick);
+
         if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
             return;
 
@@ -102,6 +141,9 @@ namespace Konversation
         if (!chatWin || !chatWin->notificationsEnabled())
             return;
 
+        if (Preferences::self()->messageIndicatorShowQuery())
+            addIndicator(chatWin, fromNick);
+
         if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
             return;
 
@@ -378,6 +420,90 @@ namespace Konversation
         return cutup;
     }
 
+    void NotificationHandler::addIndicator(ChatWindow* chatWin, const QString& nick)
+    {
+        #ifdef HAVE_INDICATEQT
+        ViewContainer* viewContainer = m_mainWindow->getViewContainer();
+        if (m_mainWindow->isActiveWindow() && chatWin == viewContainer->getFrontView()) {
+            // Do not show indicator if the user is already using this chat
+            // window
+            return;
+        }
+        Indicator* indicator = m_indicatorForChatWindow.value(chatWin);
+        if (!indicator) {
+            indicator = new Indicator(m_indicateServer);
+            indicator->m_chatWin = chatWin;
+            m_indicatorForChatWindow.insert(chatWin, indicator);
+            connect(chatWin, SIGNAL(closing(ChatWindow*)), SLOT(deleteIndicatorForChatWindow(ChatWindow*)));
+            connect(viewContainer, SIGNAL(viewChanged(ChatWindow*)), SLOT(slotViewChanged(ChatWindow*)));
+
+            connect(indicator, SIGNAL(display(QIndicate::Indicator*)), SLOT(slotIndicatorDisplay(QIndicate::Indicator*)));
+            indicator->show();
+        }
+        QString name;
+        if (chatWin->getType() == ChatWindow::Query) {
+            name = nick;
+        } else {
+            name = QString("%1 (%2)").arg(chatWin->getName()).arg(nick);
+        }
+        indicator->setNameProperty(name);
+        indicator->setTimeProperty(QDateTime::currentDateTime());
+        indicator->setDrawAttentionProperty(true);
+        #endif
+    }
+
+    void NotificationHandler::slotIndicatorDisplay(QIndicate::Indicator* _indicator)
+    {
+        #ifdef HAVE_INDICATEQT
+        Indicator* indicator = static_cast<Indicator*>(_indicator);
+        ChatWindow* chatWin = indicator->m_chatWin;
+        m_indicatorForChatWindow.remove(chatWin);
+        delete indicator;
+
+        m_mainWindow->show();
+        KWindowSystem::forceActiveWindow(m_mainWindow->winId());
+        if (chatWin) {
+            m_mainWindow->getViewContainer()->showView(chatWin);
+            chatWin->adjustFocus();
+        }
+        #endif
+    }
+
+    void NotificationHandler::slotIndicateServerDisplay()
+    {
+        m_mainWindow->show();
+        KWindowSystem::forceActiveWindow(m_mainWindow->winId());
+    }
+
+    void NotificationHandler::deleteIndicatorForChatWindow(ChatWindow* chatWin)
+    {
+        #ifdef HAVE_INDICATEQT
+        delete m_indicatorForChatWindow.take(chatWin);
+        #endif
+    }
+
+    void NotificationHandler::slotViewChanged(ChatWindow* chatWin)
+    {
+        #ifdef HAVE_INDICATEQT
+        deleteIndicatorForChatWindow(chatWin);
+        #endif
+    }
+
+    bool NotificationHandler::eventFilter(QObject*, QEvent* event)
+    {
+        #ifdef HAVE_INDICATEQT
+        if (event->type() == QEvent::WindowActivate) {
+            ViewContainer* viewContainer = m_mainWindow->getViewContainer();
+            QPointer<ChatWindow> chatWin = viewContainer->getFrontView();
+            if (chatWin) {
+                deleteIndicatorForChatWindow(chatWin);
+            }
+        }
+        #else
+        Q_UNUSED(event);
+        #endif
+        return false;
+    }
 }
 
 #include "notificationhandler.moc"
Index: konversation-1.2.3/src/notificationhandler.h
===================================================================
--- konversation-1.2.3.orig/src/notificationhandler.h
+++ konversation-1.2.3/src/notificationhandler.h
@@ -12,6 +12,7 @@
 #ifndef KONVERSATIONNOTIFICATIONHANDLER_H
 #define KONVERSATIONNOTIFICATIONHANDLER_H
 
+#include <QHash>
 #include <QObject>
 
 
@@ -19,9 +20,15 @@ class ChatWindow;
 class Application;
 class MainWindow;
 
-namespace Konversation
+namespace QIndicate
 {
+    class Server;
+    class Indicator;
+}
+class Indicator;
 
+namespace Konversation
+{
     class NotificationHandler : public QObject
     {
         Q_OBJECT
@@ -54,9 +61,20 @@ namespace Konversation
         protected:
             void startTrayNotification(ChatWindow* chatWin);
             QString addLineBreaks(const QString& string);
+            virtual bool eventFilter(QObject*, QEvent*);
+
+        private slots:
+            void slotIndicatorDisplay(QIndicate::Indicator*);
+            void slotIndicateServerDisplay();
+            void deleteIndicatorForChatWindow(ChatWindow*);
+            void slotViewChanged(ChatWindow* chatWin);
 
         private:
             MainWindow* m_mainWindow;
+            QIndicate::Server* m_indicateServer;
+            QHash<ChatWindow*, Indicator*> m_indicatorForChatWindow;
+
+            void addIndicator(ChatWindow*, const QString& nick);
     };
 
 }