[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-14 17:53:02
Message-ID: 1218736382.607282.26129.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 847083 by weilbach:

Add XChat support.


 M  +48 -6     plasma-incomingmsg.cpp  
 M  +3 -0      plasma-incomingmsg.h  


--- trunk/playground/base/plasma/applets/incomingmsg/plasma-incomingmsg.cpp #847082:847083
@@ -65,9 +65,9 @@
 
    /* test for the kmail dbus interface */
    QDBusInterface kmailDBusTest( "org.kde.kmail", "/KMail", "org.freedesktop.DBus.Introspectable" );
-   QDBusReply<QString>reply = kmailDBusTest.call( "Introspect" );
-   if(!reply.isValid())
-       kDebug() << "KMail DBus interface test error: " << reply.error();
+   QDBusReply<QString>kmailReply = kmailDBusTest.call( "Introspect" );
+   if(!kmailReply.isValid())
+       kDebug() << "KMail DBus interface test error: " << kmailReply.error();
    else{
        QDBusConnection mDBus = QDBusConnection::sessionBus();
 
@@ -96,13 +96,49 @@
        }
    }
 
+   /* test for the xchat dbus interface */
+   // do not really understand how this interface works
+   // 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" );
+   QDBusReply<void> xchatReply = xchatDBusTest.call( "HookPrint", "Channel Msg Hilight", 0, 0 );
+   if(!xchatReply.isValid())
+       kDebug() << "XChat DBus interface test error: " << xchatReply.error();
+   else{
+       QDBusConnection mDBus = QDBusConnection::sessionBus();
+       if( !mDBus.connect ( "org.xchat.service", "/org/xchat/Remote", 
+                            "org.xchat.plugin", "PrintSignal", 
+                        this, SLOT(slotNewXChatIM()) ) )
+           kDebug() << "Could not connect to XChat on DBus.";
+       else{
+           mXChatLayout = new QGraphicsLinearLayout(Qt::Horizontal);
+           mXChatLabel = new Plasma::Label(this);
+           mXChatLabel->setText( i18n("No new IM messages."));
+           KIcon icon( "xchat" );
+           mXChatIconLabel = new Plasma::Label(this);
+           mXChatIconLabel->setMinimumWidth(32);
+           mXChatIconLabel->setMinimumHeight(32);
+           KIconEffect effect;
+           mXChatIconLabel->nativeWidget()->setPixmap( 
+               effect.apply( icon.pixmap(32,32), KIconEffect::ToGray, 1, QColor(),QColor(), true )
+                                               );
+
+           mXChatLayout->addItem(mXChatIconLabel);
+           mXChatLayout->addItem(mXChatLabel);
+           mXChatLayout->setAlignment(mXChatLabel, Qt::AlignLeft);
+
+           mLayout->addItem(mXChatLayout);
+       }
+   }
+
    /* 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", 
                             "im.pidgin.purple.PurpleInterface" );
-   reply = pidginDBusTest.call( "PurpleBuddyGetName", int(0) );
-   if(!reply.isValid())
-       kDebug() << "Pidgin DBus interface test error: " << reply.error();
+   QDBusReply<QString> pidginReply = pidginDBusTest.call( "PurpleBuddyGetName", int(0) );
+   if(!pidginReply.isValid())
+       kDebug() << "Pidgin DBus interface test error: " << pidginReply.error();
    else{
        QDBusConnection mDBus = QDBusConnection::sessionBus();
 
@@ -146,6 +182,12 @@
     mKMailLabel->setText( i18n("Your mail has changed.") );
 }
 
+void IncomingMsg::slotNewXChatIM(){
+    KIcon icon( "xchat" );
+    mXChatIconLabel->nativeWidget()->setPixmap(icon.pixmap(32,32));
+    mXChatLabel->setText( i18n("You have new IM messages.") );
+}
+
 void IncomingMsg::slotNewPidginIM(){
     KIcon icon( "pidgin" );
     mPidginIconLabel->nativeWidget()->setPixmap(icon.pixmap(32,32));
--- trunk/playground/base/plasma/applets/incomingmsg/plasma-incomingmsg.h #847082:847083
@@ -49,15 +49,18 @@
       // text labels
       Plasma::Label *mLabel, 
                     *mKMailLabel, *mKMailIconLabel,
+                    *mXChatLabel, *mXChatIconLabel,
                     *mPidginLabel, *mPidginIconLabel;
 
       QGraphicsLinearLayout *mLayout, 
                             *mKMailLayout,
+                            *mXChatLayout,
                             *mPidginLayout;
 
     private slots:
       void slotNewMail();
       void slotNewPidginIM();
+      void slotNewXChatIM();
 };
 
 // This is the command that links your applet to the .desktop file
[prev in list] [next in list] [prev in thread] [next in thread] 

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