[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeplasma-addons/applets/incomingmsg
From: Christian Weilbach <christian () whiletaker ! homeip ! net>
Date: 2010-08-20 19:18:54
Message-ID: 20100820191854.340BDAC855 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1166081 by weilbach:
Patch from Ruslan Nigmatullin for qutIM support and some cleanups.
M +1 -0 AUTHORS
M +2 -0 ChangeLog
M +1 -1 README
M +126 -4 incomingmsg.cpp
M +13 -4 incomingmsg.h
M +25 -6 widget.ui
--- trunk/KDE/kdeplasma-addons/applets/incomingmsg/AUTHORS #1166080:1166081
@@ -1 +1,2 @@
Created by Christian Weilbach <dunsens@web.de>
+qutIM support added by Ruslan Nigmatullin <euroelessar@ya.ru>
--- trunk/KDE/kdeplasma-addons/applets/incomingmsg/ChangeLog #1166080:1166081
@@ -1,2 +1,4 @@
v 0.01
* First usable release.
+v 0.02
+* Added qutIM support
--- trunk/KDE/kdeplasma-addons/applets/incomingmsg/README #1166080:1166081
@@ -7,5 +7,5 @@
It uses DBus and only adds information for apps that are
running (it checks for the dbus interface). At the moment
sadly only kmail notifies over DBus for new messages.
-Hopefully Kopete can be added soon.
+Also qutIM notifies about count of unreaded messages.
Hack on it as you like.
--- trunk/KDE/kdeplasma-addons/applets/incomingmsg/incomingmsg.cpp #1166080:1166081
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2008 Christian Weilbach <dunsens@web.de>
+ * Copyright (C) 2008-2010 Christian Weilbach <dunsens@web.de>
+ * Copyright (C) 2010 Ruslan Nigmatullin <euroelessar@ya.ru>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
@@ -53,10 +54,12 @@
mXChatLabel(0), mXChatIconLabel(0),
mKopeteLabel(0), mKopeteIconLabel(0),
mPidginLabel(0), mPidginIconLabel(0),
+ mQutIMLabel(0), mQutIMIconLabel(0),
mErrorLabel(0), mLayout(0),
mEvolutionLayout(0), mKMailLayout(0),
mXChatLayout(0), mKopeteLayout(0),
- mPidginLayout(0)
+ mPidginLayout(0), mQutIMLayout(0),
+ mQutIUnreadCount(0)
{
// this will get us the standard applet background, for free!
setBackgroundHints(DefaultBackground);
@@ -80,6 +83,10 @@
delete mPidginLayout;
delete mPidginIconLabel;
delete mPidginLabel;
+
+ delete mQutIMLayout;
+ delete mQutIMIconLabel;
+ delete mQutIMLabel;
}
void IncomingMsg::init()
@@ -91,6 +98,7 @@
mShowXChat = cg.readEntry("showXChat", true);
mShowKopete = cg.readEntry("showKopete", true);
mShowPidgin = cg.readEntry("showPidgin", true);
+ mShowQutIM = cg.readEntry("showQutIM", true);
initLayout();
}
@@ -289,6 +297,71 @@
}
}
+void IncomingMsg::initQutIMLayout()
+{
+ if (mShowQutIM) {
+ QDBusInterface qutimDBusTest("org.qutim", "/ChatLayer", \
"org.qutim.ChatLayer"); + QDBusReply<QList<QDBusObjectPath> > sessionsReply = \
qutimDBusTest.call("sessions"); + if (!sessionsReply.isValid())
+ kDebug() << "qutIM DBus interface test error: " << \
sessionsReply.error(); + else {
+ QList<QDBusObjectPath> sessions = sessionsReply.value();
+ for (int i = 0; i < sessions.size(); i++) {
+ QDBusInterface qutimSession("org.qutim", sessions.at(i).path(),
+ "org.freedesktop.DBus.Properties");
+ QDBusMessage msg = qutimSession.call("Get", "org.qutim.ChatSession", \
"unread"); + slotNewQutIM(msg, sessions.at(i).path());
+ }
+ QDBusConnection mDBus = QDBusConnection::sessionBus();
+ if (!mDBus.connect("org.qutim", QString(),
+ "org.qutim.ChatSession", "unreadChanged",
+ this, SLOT(slotNewQutIM(QDBusMessage))))
+ kDebug() << "Could not connect to qutIM on DBus.";
+ else {
+ mQutIMLayout = new QGraphicsLinearLayout(Qt::Horizontal);
+ mQutIMLabel = new Plasma::Label(this);
+ mQutIMIconLabel = new Plasma::Label(this);
+ mQutIMIconLabel->setMinimumWidth(32);
+ mQutIMIconLabel->setMinimumHeight(32);
+
+ updateQutIMStatus(false);
+
+ mQutIMLayout->addItem(mQutIMIconLabel);
+ mQutIMLayout->addItem(mQutIMLabel);
+ mQutIMLayout->setAlignment(mQutIMLabel, Qt::AlignLeft);
+
+ mLayout->addItem(mQutIMLayout);
+ }
+ }
+ }
+}
+
+void IncomingMsg::updateQutIMStatus(bool saveIcon)
+{
+ if (!saveIcon) {
+ KIcon icon("qutim");
+ if (mQutIUnreadCount == 0) {
+ KIconEffect effect;
+ mQutIMIconLabel->nativeWidget()->setPixmap(
+ effect.apply(icon.pixmap(32, 32), KIconEffect::ToGray, 1, QColor(), \
QColor(), true) + );
+ } else {
+ mQutIMIconLabel->nativeWidget()->setPixmap(icon.pixmap(32, 32));
+ }
+ }
+ if (mQutIUnreadCount > 0) {
+ kDebug() << i18np("You have new qutIM message.",
+ "You have new %1 qutIM messages.",
+ mQutIUnreadCount);
+ mQutIMLabel->setText(i18np("You have new qutIM message.",
+ "You have new %1 qutIM messages.",
+ mQutIUnreadCount));
+ } else {
+ kDebug() << i18n("No new qutIM messages.");
+ mQutIMLabel->setText(i18n("No new qutIM messages."));
+ }
+}
+
void IncomingMsg::clearLayout()
{
delete mKMailLayout;
@@ -319,6 +392,15 @@
delete mPidginLabel;
mPidginLabel = NULL;
+ delete mQutIMLayout;
+ mQutIMLayout = NULL;
+ delete mQutIMIconLabel;
+ mQutIMIconLabel = NULL;
+ delete mQutIMLabel;
+ mQutIMLabel = NULL;
+ mQutIMUnread.clear();
+ mQutIUnreadCount = 0;
+
delete mErrorLabel;
mErrorLabel = NULL;
}
@@ -332,12 +414,13 @@
initXChatLayout();
initKopeteLayout();
initPidginLayout();
+ initQutIMLayout();
if (!mLayout->count()) {
mErrorLabel = new Plasma::Label();
- mErrorLabel->setText(i18n("No running messaging apps found. Supported apps \
are %1, %2, %3, %4.", + mErrorLabel->setText(i18n("No running messaging apps \
found. Supported apps are %1, %2, %3, %4, %5.",
QString("KMail"), QString("XChat"), \
QString("Kopete"),
- QString("Pidgin")));
+ QString("Pidgin"), QString("qutIM")));
mLayout->addItem(mErrorLabel);
}
@@ -354,6 +437,7 @@
ui.showXChat->setChecked(cg.readEntry("showXChat", true));
ui.showKopete->setChecked(cg.readEntry("showKopete", true));
ui.showPidgin->setChecked(cg.readEntry("showPidgin", true));
+ ui.showQutIM->setChecked(cg.readEntry("showQutIM", true));
connect(dialog, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
connect(dialog, SIGNAL(okClicked()), this, SLOT(configAccepted()));
@@ -368,12 +452,14 @@
mShowXChat = ui.showXChat->isChecked();
mShowKopete = ui.showKopete->isChecked();
mShowPidgin = ui.showPidgin->isChecked();
+ mShowQutIM = ui.showQutIM->isChecked();
KConfigGroup cg = config();
cg.writeEntry("showKMail", ui.showKMail->isChecked());
cg.writeEntry("showXChat", ui.showXChat->isChecked());
cg.writeEntry("showKopete", ui.showKopete->isChecked());
cg.writeEntry("showPidgin", ui.showPidgin->isChecked());
+ cg.writeEntry("showQutIM", ui.showQutIM->isChecked());
clearLayout();
initLayout();
@@ -400,6 +486,42 @@
mXChatLabel->setText(i18n("You have new XChat messages."));
}
+void IncomingMsg::slotNewQutIM(const QDBusMessage &msg, QString path)
+{
+ if (path.isNull())
+ path = msg.path();
+ bool hasUnread = mQutIUnreadCount > 0;
+ QVariant var = msg.arguments().value(0);
+ if (var.canConvert<QDBusVariant>())
+ var = var.value<QDBusVariant>().variant();
+ int currentCount = mQutIMUnread.value(path, 0);
+ int count = 0;
+ const QDBusArgument arg = qvariant_cast<QDBusArgument>(var);
+ // Parse aa{sv} value
+ arg.beginArray();
+ while (!arg.atEnd()) {
+ arg.beginMap();
+ while (!arg.atEnd()) {
+ QString key;
+ QVariant value;
+ arg.beginMapEntry();
+ arg >> key >> value;
+ arg.endMapEntry();
+ }
+ arg.endMap();
+ count++;
+ }
+ arg.endArray();
+ mQutIUnreadCount -= currentCount;
+ mQutIUnreadCount += count;
+ if (count > 0)
+ mQutIMUnread.insert(path, count);
+ else
+ mQutIMUnread.remove(path);
+ if (mQutIMLayout)
+ updateQutIMStatus(hasUnread == (mQutIUnreadCount > 0));
+}
+
void IncomingMsg::slotNewKopeteIM(const QString& contactId)
{
QDBusInterface kopeteDBusTest("org.kde.kopete", "/Kopete", "org.kde.Kopete");
--- trunk/KDE/kdeplasma-addons/applets/incomingmsg/incomingmsg.h #1166080:1166081
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2008 Christian Weilbach <dunsens@web.de>
+ * Copyright (C) 2008-2010 Christian Weilbach <dunsens@web.de>
+ * Copyright (C) 2010 Ruslan Nigmatullin <euroelessar@ya.ru>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
@@ -29,6 +30,7 @@
#include "ui_widget.h"
class QGraphicsLinearLayout;
+class QDBusObjectPath;
namespace Plasma
{
@@ -53,6 +55,7 @@
void initXChatLayout();
void initKopeteLayout();
void initPidginLayout();
+ void initQutIMLayout();
protected slots:
void configAccepted();
@@ -60,19 +63,24 @@
private:
void clearLayout();
void initLayout();
+ void updateQutIMStatus(bool saveIcon);
// text labels
Plasma::Label *mEvolutionLabel, *mEvolutionIconLabel,
*mKMailLabel, *mKMailIconLabel, *mXChatLabel,
*mXChatIconLabel, *mKopeteLabel, *mKopeteIconLabel,
- *mPidginLabel, *mPidginIconLabel, *mErrorLabel;
+ *mPidginLabel, *mPidginIconLabel, *mQutIMLabel,
+ *mQutIMIconLabel, *mErrorLabel;
QGraphicsLinearLayout *mLayout, *mEvolutionLayout,
*mKMailLayout, *mXChatLayout, *mKopeteLayout,
- *mPidginLayout;
+ *mPidginLayout, *mQutIMLayout;
- bool mShowKMail, mShowXChat, mShowKopete, mShowPidgin;
+ bool mShowKMail, mShowXChat, mShowKopete, mShowPidgin, mShowQutIM;
+ QHash<QString, int> mQutIMUnread;
+ int mQutIUnreadCount;
+
Ui::incomingmsgConfig ui;
private slots:
@@ -81,6 +89,7 @@
void slotNewPidginIM();
void slotNewKopeteIM(const QString&);
void slotNewXChatIM();
+ void slotNewQutIM(const QDBusMessage &msg, QString path = QString());
};
// This is the command that links your applet to the .desktop file
--- trunk/KDE/kdeplasma-addons/applets/incomingmsg/widget.ui #1166080:1166081
@@ -1,6 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0" >
<class>incomingmsgConfig</class>
<widget class="QWidget" name="incomingmsgConfig" >
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>284</width>
+ <height>175</height>
+ </rect>
+ </property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" colspan="2" >
<widget class="QLabel" name="topLabel" >
@@ -28,7 +37,7 @@
<item row="1" column="1" >
<widget class="QCheckBox" name="showKMail" >
<property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -44,7 +53,7 @@
<item row="2" column="1" >
<widget class="QCheckBox" name="showKopete" >
<property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -60,7 +69,7 @@
<item row="3" column="1" >
<widget class="QCheckBox" name="showPidgin" >
<property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -73,10 +82,10 @@
</property>
</widget>
</item>
- <item row="4" column="1" >
+ <item row="5" column="1">
<widget class="QCheckBox" name="showXChat" >
<property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -89,7 +98,7 @@
</property>
</widget>
</item>
- <item row="5" column="1" >
+ <item row="6" column="1">
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
@@ -102,6 +111,16 @@
</property>
</spacer>
</item>
+ <item row="4" column="1">
+ <widget class="QCheckBox" name="showQutIM">
+ <property name="text">
+ <string>qutIM</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<layoutdefault spacing="4" margin="4" />
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic