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

List:       kopete-devel
Subject:    [kopete-devel] Allow plugins to change status bar text. Event
From:       Marc Cramdal <bruno.virlet () gmail ! com>
Date:       2005-01-09 16:15:21
Message-ID: 200501091714.30259.marc.cramdal () gmail ! com
[Download RAW message or body]

Hello,

In order to learn a little Jabber Kopete API, I was looking at this JJ  
http://bugs.kde.org/show_bug.cgi?id=81961 (JEP-022: 
http://www.jabber.org/jeps/jep-0022.html#sect-id2602313)

But such notifications are useful if they can be seen somewhere : I have asked 
on IRC for the utility of some API to let protocols be able to write in the 
statusbar and here is it in the patch.

For Jabber, it is _not_ finished, I'm trying to change the thing to be 
respectul of the JEP (as Till said we should do).

----------------------
So for Jabber, changes are the following :
- JabberContact::handleIncomingMessage to follow the JEP022 : if message body 
is empty, it is a notification else, it is a request for such notifications 
so we set booleans. TODO: use this booleans to send notifications only if 
they were requested.
- JabberChatSession::slotMessageSent : add the notification requests to each 
message (I assume we want them)

This code in action : server answer now with offline notification event if 
your contact is offline (because we request all notifications now in 
slotMessageSent). So the code in handleIncomingMessage will set statusbar 
text to confirm that the message was stored offline by the server.

Last thing for Jabber : I have had to to a change ("offline" event seems to 
have been forgotten) in the following file : 
protocols/jabber/libiris/iris/xmpp-im/types.cpp.
So if it is correct, I will do the patch file as Till asked for libiris.
---------------------

Patch need to be finalized, even for kopete/ and libkopete/ (doxygen 
comments).

Marc(oPolo)

["jabber-statusbar.diff" (text/x-diff)]

? libkopete/compat/Makefile
? libkopete/compat/Makefile.in
Index: kopete/chatwindow/chatview.h
===================================================================
RCS file: /home/kde/kdenetwork/kopete/kopete/chatwindow/chatview.h,v
retrieving revision 1.62
diff -u -p -r1.62 chatview.h
--- kopete/chatwindow/chatview.h	24 Dec 2004 00:00:06 -0000	1.62
+++ kopete/chatwindow/chatview.h	9 Jan 2005 16:01:58 -0000
@@ -74,12 +74,6 @@ public:
 	void saveOptions();
 
 	/**
-	 * Sets the text to be displayed on the status label
-	 * @param text The text to be displayed
-	 */
-	void setStatusText( const QString &text );
-
-	/**
 	 * Tells this view it is the active view
 	 */
 	void setActive( bool value );
@@ -246,6 +240,12 @@ public slots:
 	 */
 	void remoteTyping( const Kopete::Contact *contact, bool typing );
 
+    /**
+     * Sets the text to be displayed on the status label
+     * @param text The text to be displayed
+     */
+    void setStatusText( const QString &text );    
+    
 	/** Reimplemented from KopeteView **/
 	virtual void messageSentSuccessfully();
 
Index: kopete/chatwindow/kopeteviewmanager.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kopete/kopete/chatwindow/kopeteviewmanager.cpp,v
retrieving revision 1.41
diff -u -p -r1.41 kopeteviewmanager.cpp
--- kopete/chatwindow/kopeteviewmanager.cpp	7 Nov 2004 21:49:04 -0000	1.41
+++ kopete/chatwindow/kopeteviewmanager.cpp	9 Jan 2005 16:01:58 -0000
@@ -131,6 +131,7 @@ KopeteView *KopeteViewManager::view( Kop
 
 			connect (newViewWidget, SIGNAL( typing(bool) ), manager, SLOT( typing(bool) ) );
 			connect (manager, SIGNAL( remoteTyping( const Kopete::Contact *, bool) ), \
newViewWidget, SLOT( remoteTyping(const Kopete::Contact *, bool) ) ); +            \
connect (manager, SIGNAL( remoteEventNotification( const QString& ) ), newViewWidget, \
SLOT( setStatusText( const QString& ) ) );  }
 		else
 		{
Index: libkopete/kopetemessagemanager.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kopete/libkopete/kopetemessagemanager.cpp,v
retrieving revision 1.221
diff -u -p -r1.221 kopetemessagemanager.cpp
--- libkopete/kopetemessagemanager.cpp	23 Nov 2004 09:27:26 -0000	1.221
+++ libkopete/kopetemessagemanager.cpp	9 Jan 2005 16:01:58 -0000
@@ -387,6 +387,11 @@ void Kopete::ChatSession::typing( bool t
 	emit myselfTyping( t );
 }
 
+void Kopete::ChatSession::receivedEventNotification( const QString& \
notificationText) +{
+    emit remoteEventNotification( notificationText );
+}
+
 void Kopete::ChatSession::setCanBeDeleted ( bool b )
 {
 	d->mCanBeDeleted = b;
Index: libkopete/kopetemessagemanager.h
===================================================================
RCS file: /home/kde/kdenetwork/kopete/libkopete/kopetemessagemanager.h,v
retrieving revision 1.104
diff -u -p -r1.104 kopetemessagemanager.h
--- libkopete/kopetemessagemanager.h	23 Nov 2004 09:27:26 -0000	1.104
+++ libkopete/kopetemessagemanager.h	9 Jan 2005 16:01:58 -0000
@@ -242,6 +242,11 @@ signals:
 	 */
 	void remoteTyping( const Kopete::Contact *contact, bool isTyping );
 
+    /**
+     *
+     */
+     void remoteEventNotification( const QString& notificationText);
+    
 public slots:
 	/**
 	 * @brief Got a typing notification from a user
@@ -255,6 +260,11 @@ public slots:
 	 */
 	void receivedTypingMsg( const QString &contactId, bool isTyping = true );
 
+    /**
+     * 
+     */
+    void receivedEventNotification(  const QString& notificationText );
+     
 	/**
 	 * Show a message to the chatwindow, or append it to the queue.
 	 * This is the function protocols HAVE TO call for both incoming and outgoing \
                messages
Index: protocols/jabber/jabbercontact.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kopete/protocols/jabber/jabbercontact.cpp,v
retrieving revision 1.200
diff -u -p -r1.200 jabbercontact.cpp
--- protocols/jabber/jabbercontact.cpp	9 Nov 2004 17:05:21 -0000	1.200
+++ protocols/jabber/jabbercontact.cpp	9 Jan 2005 16:01:58 -0000
@@ -89,6 +89,10 @@ JabberContact::JabberContact (const XMPP
 	// call moved from superclass, see JabberBaseContact for details
 	reevaluateStatus ();
 
+    requestOfflineEvent = false;
+    requestDisplayedEvent = false;
+    requestTransmittedEvent = false;
+    requestTypingEvent = false;
 }
 
 QPtrList<KAction> *JabberContact::customContextMenuActions ()
@@ -227,11 +231,31 @@ void JabberContact::handleIncomingMessag
 	// evaluate typing notifications
 	if ( message.type () != "error" )
 	{
-		if ( message.containsEvent ( CancelEvent ) )
-			mManager->receivedTypingMsg ( this, false );
-		else
-			if ( message.containsEvent ( ComposingEvent ) )
-				mManager->receivedTypingMsg ( this, true );
+		if (message.body().isEmpty())
+        // Then here could be event notifications
+        {
+            if (message.containsEvent ( CancelEvent ) )
+                mManager->receivedTypingMsg ( this, false );
+            else if (message.containsEvent ( ComposingEvent ) )
+                mManager->receivedTypingMsg ( this, true );
+            else if (message.containsEvent ( DisplayedEvent ) )
+                mManager->receivedEventNotification ( i18n("Message has been \
displayed") ); +            else if (message.containsEvent ( DeliveredEvent ) )
+                mManager->receivedEventNotification ( i18n("Message has been \
delivered") ); +            else if (message.containsEvent ( OfflineEvent ) )
+            {
+                mManager->receivedEventNotification( i18n("Message stored on the \
server, contact offline") ); +                kdDebug() << "JABBER PATCH message \
offline added on server" << endl; +            }
+        }
+        else
+        // Then here could be event notification requests
+        {
+            requestTypingEvent = message.containsEvent ( ComposingEvent ) ? true : \
false; +            requestOfflineEvent = message.containsEvent ( OfflineEvent ) ? \
true : false; +            requestTransmittedEvent = message.containsEvent ( \
DeliveredEvent ) ? true : false; +            requestDisplayedEvent = \
message.containsEvent ( DisplayedEvent) ? true : false; +        }
 	}
 
 	/**
Index: protocols/jabber/jabbercontact.h
===================================================================
RCS file: /home/kde/kdenetwork/kopete/protocols/jabber/jabbercontact.h,v
retrieving revision 1.101
diff -u -p -r1.101 jabbercontact.h
--- protocols/jabber/jabbercontact.h	7 Nov 2004 21:49:13 -0000	1.101
+++ protocols/jabber/jabbercontact.h	9 Jan 2005 16:01:58 -0000
@@ -195,6 +195,11 @@ private:
 	 * being updated or not.
 	 */
 	bool mVCardUpdateInProgress;
+    
+    bool requestTypingEvent;
+    bool requestOfflineEvent;
+    bool requestDisplayedEvent;
+    bool requestTransmittedEvent;
 
 };
 
Index: protocols/jabber/jabbermessagemanager.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kopete/protocols/jabber/jabbermessagemanager.cpp,v
retrieving revision 1.17
diff -u -p -r1.17 jabbermessagemanager.cpp
--- protocols/jabber/jabbermessagemanager.cpp	23 Nov 2004 09:27:31 -0000	1.17
+++ protocols/jabber/jabbermessagemanager.cpp	9 Jan 2005 16:01:58 -0000
@@ -204,7 +204,14 @@ void JabberChatSession::slotMessageSent 
 			jabberMessage.setType ( "normal" );
 		}
 
-		// send the message
+        // add request for offline storage notification
+        jabberMessage.addEvent( OfflineEvent );
+        jabberMessage.addEvent( ComposingEvent );
+        jabberMessage.addEvent( DeliveredEvent );
+        jabberMessage.addEvent( DisplayedEvent );
+        
+        
+        // send the message
 		account()->client()->sendMessage ( jabberMessage );
 
 		// append the message to the manager
Index: protocols/jabber/libiris/iris/xmpp-im/types.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kopete/protocols/jabber/libiris/iris/xmpp-im/types.cpp,v
 retrieving revision 1.3
diff -u -p -r1.3 types.cpp
--- protocols/jabber/libiris/iris/xmpp-im/types.cpp	21 May 2004 14:35:44 -0000	1.3
+++ protocols/jabber/libiris/iris/xmpp-im/types.cpp	9 Jan 2005 16:01:58 -0000
@@ -639,6 +639,8 @@ bool Message::fromStanza(const Stanza &s
 				d->eventList += ComposingEvent;
 			else if (evtag == "delivered")
 				d->eventList += DeliveredEvent;
+            else if (evtag == "offline")
+                d->eventList += OfflineEvent;
 		}
 		if (d->eventList.isEmpty())
 			d->eventList += CancelEvent;



_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel


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

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