[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/base/plasma/applets/incomingmsg
From:       Christian Weilbach <christian () whiletaker ! homeip ! net>
Date:       2008-08-19 20:51:38
Message-ID: 1219179098.155456.25825.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 849637 by weilbach:

Added Kopete with its current temporary DBus interface. Layout automatically \
increased. Fixes.


 M  +99 -12    plasma-incomingmsg.cpp  
 M  +7 -1      plasma-incomingmsg.h  


--- trunk/playground/base/plasma/applets/incomingmsg/plasma-incomingmsg.cpp \
#849636:849637 @@ -50,8 +50,8 @@
 {
     // this will get us the standard applet background, for free!
    setBackgroundHints(DefaultBackground);
-   resize(280, 50);
-   setMinimumSize(280, 50);
+   resize(280, 30);
+   setMinimumSize(280, 30);
 }
 
 IncomingMsg::~IncomingMsg()
@@ -63,6 +63,42 @@
    /* initialize layout */
    mLayout = new QGraphicsLinearLayout(Qt::Vertical);
 
+   /* test for the evolution dbus interface */
+   // TODO find out why evolution does not expose dbus on a kde session here
+//    QDBusInterface evolutionDBusTest( "org.freedesktop.Notification", 
+//                                      "‘/org/freedesktop/Notifications",
+//                                      "org.freedesktop.Notifications" );
+//    QDBusReply<QString>evolutionReply = evolutionDBusTest.call( "New Email" );
+//    if(/*!evolutionReply.isValid()*/false)
+//        kDebug() << "Evolution DBus interface test error: " << \
evolutionReply.error(); +//    else{
+//        QDBusConnection mDBus = QDBusConnection::sessionBus();
+// 
+//        if( !mDBus.connect ( "org.gnome.evolution", "/Evolution", \
"org.gnome.evolution.mail.dbus.Signal",  +//                         "Newmail", 
+//                         this, SLOT(slotNewMail()) ) )
+//            kDebug() << "Could not connect Evolution to slot.";
+//        else{
+//            mEvolutionLayout = new QGraphicsLinearLayout(Qt::Horizontal);
+//            mEvolutionLabel = new Plasma::Label(this);
+//            mEvolutionLabel->setText( i18n("No new mail."));
+//            KIcon icon( "evolution" );
+//            mEvolutionIconLabel = new Plasma::Label(this);
+//            mEvolutionIconLabel->setMinimumWidth(32);
+//            mEvolutionIconLabel->setMinimumHeight(32);
+//            KIconEffect effect;
+//            mEvolutionIconLabel->nativeWidget()->setPixmap( 
+//                effect.apply( icon.pixmap(32,32), KIconEffect::ToGray, 1, \
QColor(),QColor(), true ) +//                                                );
+// 
+//            mEvolutionLayout->addItem(mEvolutionIconLabel);
+//            mEvolutionLayout->addItem(mEvolutionLabel);
+//            mEvolutionLayout->setAlignment(mEvolutionLabel, Qt::AlignLeft);
+// 
+//            mLayout->addItem(mEvolutionLayout);
+//        }
+//    }
+
    /* test for the kmail dbus interface */
    QDBusInterface kmailDBusTest( "org.kde.kmail", "/KMail", \
"org.freedesktop.DBus.Introspectable" );  QDBusReply<QString>kmailReply = \
kmailDBusTest.call( "Introspect" ); @@ -73,8 +109,8 @@
 
        if( !mDBus.connect ( "org.kde.kmail", "/KMail", "org.kde.kmail.kmail", 
                         "unreadCountChanged", 
-                        this, SLOT(slotNewMail()) ) )
-           kDebug() << "Could not connect to KMail on DBus.";
+                        this, SLOT(slotNewKMailMail()) ) )
+           kDebug() << "Could not connect KMail to slot.";
        else{
            mKMailLayout = new QGraphicsLinearLayout(Qt::Horizontal);
            mKMailLabel = new Plasma::Label(this);
@@ -101,7 +137,7 @@
    // got this working code from \
http://arstechnica.com/reviews/hardware/tux-droid-review.ars/3  // we need to hook it \
up first. this first call is not only for interface testing but also for  // setup.
-   QDBusInterface xchatDBusTest( \
"org.xchat.service","/org/xchat/Remote","org.xchat.plugin" ); +   QDBusInterface \
xchatDBusTest( "org.xchat.service","/org/xchat/Remote", "org.xchat.plugin" );  \
QDBusReply<void> xchatReply = xchatDBusTest.call( "HookPrint", "Channel Msg Hilight", \
0, 0 );  if(!xchatReply.isValid())
        kDebug() << "XChat DBus interface test error: " << xchatReply.error();
@@ -110,7 +146,7 @@
        if( !mDBus.connect ( "org.xchat.service", "/org/xchat/Remote", 
                             "org.xchat.plugin", "PrintSignal", 
                         this, SLOT(slotNewXChatIM()) ) )
-           kDebug() << "Could not connect to XChat on DBus.";
+           kDebug() << "Could not connect XChat to slot.";
        else{
            mXChatLayout = new QGraphicsLinearLayout(Qt::Horizontal);
            mXChatLabel = new Plasma::Label(this);
@@ -132,6 +168,39 @@
        }
    }
 
+   /* test for the kopete dbus interface */
+   QDBusInterface kopeteDBusTest( "org.kde.kopete", "/kopete", \
"org.freedesktop.DBus.Introspectable" ); +   QDBusReply<QString>kopeteReply = \
kopeteDBusTest.call( "Introspect" ); +   if(!kopeteReply.isValid())
+       kDebug() << "Kopete DBus interface test error: " << kopeteReply.error();
+   else{
+       QDBusConnection mDBus = QDBusConnection::sessionBus();
+
+       if( !mDBus.connect ( "org.kde.kopete", "/Kopete", "org.kde.Kopete", 
+                        "contactChanged", 
+                        this, SLOT(slotNewKopeteIM(const QString&)) ) )
+           kDebug() << "Could not connect Kopete to slot.";
+       else{
+           mKopeteLayout = new QGraphicsLinearLayout(Qt::Horizontal);
+           mKopeteLabel = new Plasma::Label(this);
+           mKopeteLabel->setText( i18n("No new IM messages."));
+           KIcon icon( "kopete" );
+           mKopeteIconLabel = new Plasma::Label(this);
+           mKopeteIconLabel->setMinimumWidth(32);
+           mKopeteIconLabel->setMinimumHeight(32);
+           KIconEffect effect;
+           mKopeteIconLabel->nativeWidget()->setPixmap( 
+               effect.apply( icon.pixmap(32,32), KIconEffect::ToGray, 1, \
QColor(),QColor(), true ) +                                               );
+
+           mKopeteLayout->addItem(mKopeteIconLabel);
+           mKopeteLayout->addItem(mKopeteLabel);
+           mKopeteLayout->setAlignment(mKopeteLabel, Qt::AlignLeft);
+
+           mLayout->addItem(mKopeteLayout);
+       }
+   }
+
    /* test for the pidgin dbus interface */
    // FIXME introspect does not work here with qdbus trying sth. else
    QDBusInterface pidginDBusTest( "im.pidgin.purple.PurpleService", \
"/im/pidgin/purple/PurpleObject",  @@ -169,14 +238,15 @@
 
    if(!mLayout->count()){
        Plasma::Label *errorLabel = new Plasma::Label();
-       errorLabel->setText( i18n( "No running messaging apps found. Supported apps \
are KMail and Pidgin." ) ); +       errorLabel->setText( i18n( "No running messaging \
apps found. Supported apps are %1, %2, %3, %4.", +                                   \
QString("KMail"), QString("XChat"), QString("Kopete"), +                              \
QString( "Pidgin" ) ) );  mLayout->addItem(errorLabel);
    }
 
    setLayout(mLayout);
 }
 
-
 void IncomingMsg::constraintsEvent(Plasma::Constraints constraints)
 {
     setBackgroundHints(Plasma::Applet::DefaultBackground);
@@ -188,22 +258,39 @@
     setGeometry( appletRectF );
 }
 
-void IncomingMsg::slotNewMail(){
+void IncomingMsg::slotNewEvolutionMail(){
+    KIcon icon( "evolution" );
+    mEvolutionIconLabel->nativeWidget()->setPixmap(icon.pixmap(32,32));
+    mEvolutionLabel->setText( i18n("Your Evolution mail has changed.") );
+}
+
+void IncomingMsg::slotNewKMailMail(){
     KIcon icon( "kmail" );
     mKMailIconLabel->nativeWidget()->setPixmap(icon.pixmap(32,32));
-    mKMailLabel->setText( i18n("Your mail has changed.") );
+    mKMailLabel->setText( i18n("Your KMail mail count has changed.") );
 }
 
 void IncomingMsg::slotNewXChatIM(){
     KIcon icon( "xchat" );
     mXChatIconLabel->nativeWidget()->setPixmap(icon.pixmap(32,32));
-    mXChatLabel->setText( i18n("You have new IM messages.") );
+    mXChatLabel->setText( i18n("You have new XChat messages.") );
 }
 
+void IncomingMsg::slotNewKopeteIM(const QString& contactId){
+    QDBusInterface kopeteDBusTest( "org.kde.kopete", "/Kopete", "org.kde.Kopete" );
+    QDBusReply<QVariantMap>kopeteReply = kopeteDBusTest.call( "contactProperties", \
contactId ); +    if(kopeteReply.isValid() 
+       && !kopeteReply.value()["pending_messages"].toStringList().empty() ){
+        KIcon icon( "kopete" );
+        mKopeteIconLabel->nativeWidget()->setPixmap(icon.pixmap(32,32));
+        mKopeteLabel->setText( i18n("You have new Kopete messages.") );
+    }
+}
+
 void IncomingMsg::slotNewPidginIM(){
     KIcon icon( "pidgin" );
     mPidginIconLabel->nativeWidget()->setPixmap(icon.pixmap(32,32));
-    mPidginLabel->setText( i18n("You have new IM messages.") );
+    mPidginLabel->setText( i18n("You have new Pidgin messages.") );
 }
 
 #include "plasma-incomingmsg.moc"
--- trunk/playground/base/plasma/applets/incomingmsg/plasma-incomingmsg.h \
#849636:849637 @@ -48,21 +48,27 @@
    private:
       // text labels
       Plasma::Label *mLabel, 
+                    *mEvolutionLabel, *mEvolutionIconLabel,
                     *mKMailLabel, *mKMailIconLabel,
                     *mXChatLabel, *mXChatIconLabel,
+                    *mKopeteLabel, *mKopeteIconLabel,
                     *mPidginLabel, *mPidginIconLabel;
 
       QGraphicsLinearLayout *mLayout, 
+                            *mEvolutionLayout,
                             *mKMailLayout,
                             *mXChatLayout,
+                            *mKopeteLayout,
                             *mPidginLayout;
 
     protected:
       void constraintsEvent(Plasma::Constraints);
 
     private slots:
-      void slotNewMail();
+      void slotNewEvolutionMail();
+      void slotNewKMailMail();
       void slotNewPidginIM();
+      void slotNewKopeteIM(const QString&);
       void slotNewXChatIM();
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic