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

List:       kopete-devel
Subject:    Re: [Kopete-devel] KMM talks
From:       ",,," <kde3 () andres ! mail ! kde ! org>
Date:       2002-05-12 1:35:30
[Download RAW message or body]

On Sunday 12 May 2002 03:09, Martijn Klingens wrote:
> On Saturday 11 May 2002 04:33, Nick Betcher wrote:
> > 	Everyone should know that Ian Geiser is working heavily on KMM and KMMF
> > in his local tree. Any serious changes should be discussed with him
> > before attempting to do something in KMM. He is working on making things
> > abstracted more, and also providing me the ability to add MDI support
> > transparently to KMM.

cool!

here's a patch against libkopete(KMM_BRANCH) which modifies some behaviour of 
the KMM and KMMF (see previous discussions on the list). i don't have Ian's 
mail, so i post the patch here... Ian, what do you think of the patch ? is it 
ok to commit it ?

cheers,

-- 
Andres

["kmm.patch" (text/x-diff)]

Index: kopetemessagemanager.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/kopetemessagemanager.cpp,v
retrieving revision 1.18.2.8
diff -u -r1.18.2.8 kopetemessagemanager.cpp
--- kopetemessagemanager.cpp	2002/05/11 20:43:31	1.18.2.8
+++ kopetemessagemanager.cpp	2002/05/12 01:29:39
@@ -17,26 +17,30 @@
 */
 
 #include "kopetemessagemanager.h"
+
+#include "kopete.h"
 #include "kopetechatwindow.h"
 #include "kopeteevent.h"
-#include "kopete.h"
+#include "kopetemessage.h"
+#include "kopeteprotocol.h"
 
 #include "messagelog.h"
 #include <kdebug.h>
 #include <klocale.h>
 
 KopeteMessageManager::KopeteMessageManager( const KopeteContact *user, \
                KopeteContactList others,
-		QString logFile, QObject *parent, const char *name) : QObject( parent, name)
+		KopeteProtocol* protocol, QString logFile, QObject *parent, const char *name) : \
QObject( parent, name)  {
 
 	mContactList = others;
 	mUser = user;
+	mProtocol = protocol;
 	mChatWindow = 0L;
 	mUnreadMessageEvent = 0L;
 
 	readModeChanged();
 	connect( kopeteapp->appearance(), SIGNAL(queueChanged()), this, \
                SLOT(readModeChanged()) );
-	
+
 	if (!logFile.isEmpty())
 	{
 		QString logFileName = "kopete/" + logFile;
@@ -46,7 +50,7 @@
 	{
 		mLogger = 0L;
 	}
-
+	
 }
 
 KopeteMessageManager::~KopeteMessageManager()
@@ -91,14 +95,16 @@
 		connect ( mChatWindow, SIGNAL(sendMessage(const QString &)), this, \
SLOT(messageSentFromWindow(const QString &)) );  connect ( mChatWindow, \
SIGNAL(closeClicked()), this, SLOT(chatWindowClosing()) );  }
-	
-	for (KopeteMessageList::Iterator it = mMessageQueue.begin(); it != \
mMessageQueue.end(); it++) +
+	for (KopeteMessageList::Iterator it = mMessageQueue.begin(); mMessageQueue.end() != \
it; ++it)  {
 		kdDebug() << "[KopeteMessageManager] Inserting message from " << \
                (*it).from()->name() << endl;
-		mChatWindow->messageReceived((*it));
+		mChatWindow->messageReceived(*it);
 	}
 	mMessageQueue.clear();
-	mChatWindow->show();	// show message window again
+	mChatWindow->setActiveWindow();
+	mChatWindow->show();
+	cancelUnreadMessageEvent();
 }
 
 void KopeteMessageManager::slotReadMessages()
@@ -108,15 +114,20 @@
 
 void KopeteMessageManager::messageSentFromWindow(const QString &message)
 {
+	// Create the kopete message
 	QString body = message;
-	KopeteMessage tmpmessage(mUser, mContactList, body, KopeteMessage::Outbound);
-	emit messageSent ( tmpmessage );
+	KopeteMessage tmpMessage(mUser, mContactList, body, KopeteMessage::Outbound);
+
+	// Send the message
+	mProtocol->sendMessage(tmpMessage);
+
+	// What is this doing here ???? messages should be read when they arrive, not when \
they're sent  readMessages();
 }
 
 void KopeteMessageManager::chatWindowClosing()
 {
-	kdDebug() << "[KopeteMessageManager] Chat Window closed, now 0L" << endl;	
+	kdDebug() << "[KopeteMessageManager] Chat Window closed, now 0L" << endl;
 	mChatWindow = 0L;
 }
 
@@ -132,7 +143,7 @@
 		delete mUnreadMessageEvent;
 		mUnreadMessageEvent = 0L;
 		kdDebug() << "[KopeteMessageManager] cancelUnreadMessageEvent Event Deleted" << \
                endl;
-	}		
+	}
 }
 
 void KopeteMessageManager::slotEventDeleted(KopeteEvent *e)
@@ -141,10 +152,8 @@
 	if ( e == mUnreadMessageEvent)
 		mUnreadMessageEvent = 0L;
 }
-
-
 
-void KopeteMessageManager::appendMessage( const KopeteMessage &msg )
+void KopeteMessageManager::appendMessage( const KopeteMessage& msg )
 {
 	bool isvisible = false;
 
@@ -225,4 +234,11 @@
 	{
                 mReadMode = Popup;
 	}
+}
+
+void KopeteMessageManager::messageSent( const KopeteMessage& message ) {
+
+	kdDebug() << "[KopeteMessageManager] messageSent" << endl;
+	mChatWindow->messageReceived(message);
+
 }
Index: kopetemessagemanager.h
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/kopetemessagemanager.h,v
retrieving revision 1.11.2.5
diff -u -r1.11.2.5 kopetemessagemanager.h
--- kopetemessagemanager.h	2002/05/03 06:52:57	1.11.2.5
+++ kopetemessagemanager.h	2002/05/12 01:29:39
@@ -18,19 +18,18 @@
 #define __KOPETEMESSAGEMANAGER_H__
 
 #include <qptrlist.h>
-#include <qvaluelist.h>
 #include <qobject.h>
 
-#include "kopetemessage.h"
 #include "kopetecontact.h"
+#include "kopetemessage.h"
 
 class KopeteContact;
-class KopeteMessage;
 class KopeteMessageManager;
 class QObject;
 class KopeteChatWindow;
 class KopeteEvent;
 class KopeteMessageLog;
+class KopeteProtocol;
 
 
 typedef QPtrList<KopeteContact>        KopeteContactList;
@@ -54,7 +53,7 @@
 	/**
 	 * Append a message to the queue
 	 */
-	void appendMessage( const KopeteMessage &msg );
+	void appendMessage( const KopeteMessage& msg );
 
 	/**
 	 * Add a contact to the session
@@ -86,35 +85,41 @@
 	 * Get a list of all contacts in the session
 	 */
 	const KopeteContactList& members() const { return mContactList; }; /* Sorry, had to \
                change this to members(), it was conflicting with kxContact */
-    /**
+	/**
 	 * Get athe local user in the session
 	 */
 	const KopeteContact* user() const { return mUser; };
 
+	/**
+	 * Call when a message is actually sent over the wire
+	 */
+	void messageSent( const KopeteMessage& message );
+
+
 signals:
 	/**
 	 * A message has been sent by the user or a plugin. The protocol should
 	 * connect to this signal to actually send the message over the wire.
 	 */
-	void messageSent( const KopeteMessage msg );
 	void dying( KopeteMessageManager *);
 
 public slots:
 	void readModeChanged();
-	
+
 protected slots:
 	void cancelUnreadMessageEvent();
 	void slotEventDeleted(KopeteEvent *);
-    void chatWindowClosing();
+	void chatWindowClosing();
 	void messageSentFromWindow( const QString &message);
 	void slotReadMessages();
+
 private:
 	/**
 	 * Create a message manager. This constructor is private, because the
 	 * static factory method createSession() creates the object. You may
 	 * not create instances yourself directly!
 	 */
-	KopeteMessageManager( const KopeteContact *user, KopeteContactList others,
+	KopeteMessageManager( const KopeteContact *user, KopeteContactList others, \
KopeteProtocol* protocol,  QString logFile = QString::null, QObject *parent = 0, \
const char *name = 0 );  
 	KopeteContactList mContactList;
@@ -123,6 +128,7 @@
 	KopeteEvent *mUnreadMessageEvent;
 	KopeteMessageList mMessageQueue;
 	KopeteMessageLog *mLogger;
+	KopeteProtocol* mProtocol;
 	int mReadMode;
 };
 
Index: kopetemessagemanagerfactory.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/kopetemessagemanagerfactory.cpp,v
retrieving revision 1.7.2.2
diff -u -r1.7.2.2 kopetemessagemanagerfactory.cpp
--- kopetemessagemanagerfactory.cpp	2002/05/03 06:52:57	1.7.2.2
+++ kopetemessagemanagerfactory.cpp	2002/05/12 01:29:39
@@ -29,41 +29,50 @@
 {
 }
 
+KopeteMessageManager* KopeteMessageManagerFactory::create(
+	const KopeteContact *user, KopeteContact* other, KopeteProtocol* protocol,
+	QString logFile)
+{
+	KopeteContactList tempKcl;
+	tempKcl.append(other);
+	return (create(user, tempKcl, protocol, logFile));
+}
+
 KopeteMessageManager *KopeteMessageManagerFactory::create(
 	const KopeteContact *user, KopeteContactList _contacts, /* Touch that underscore \
                and you die, along with ICQ not compiling */
-	QString logFile )
+	KopeteProtocol* protocol, QString logFile )
 {
-	bool createNewSession = false;
+	bool createNewSession = true;
 	KopeteMessageManager *tmp;
 	for ( tmp = mSessionList.first(); tmp ; tmp = mSessionList.next() )
 	{
-    	if ( user == tmp->user() )
+	if ( user == tmp->user() )
 		{
-			kdDebug() << "[KopeteMessageManagerFactory] User match, looking session members" \
<< endl;	 +			kdDebug() << "[KopeteMessageManagerFactory] User match, looking session \
members" << endl;  KopeteContact *tmp_contact;
 			KopeteContactList contactlist = tmp->members();
-            for (  tmp_contact = contactlist.first(); tmp_contact ; tmp_contact = \
contactlist.next() ) +			for (  tmp_contact = contactlist.first(); tmp_contact ; \
tmp_contact = contactlist.next() )  {
 				if ( !_contacts.containsRef( tmp_contact ) )
 				{
-					kdDebug() << "[KopeteMessageManagerFactory] create() Oops, contact not found! \
                new session needed!" << endl;	
-					createNewSession = true;
+					kdDebug() << "[KopeteMessageManagerFactory] create() Oops, contact \"" << \
tmp_contact->name() << "\" not found! new session needed!" << endl;  break;
 				}
+				createNewSession = false;
 			}
 			if ( createNewSession == false )
 			{
 				/* current session (tmp) is the same session the user is requesting */
 				return tmp;
-			}		
+			}
 		}
 		else
 		{
-			kdDebug() << "[KopeteMessageManagerFactory] User doesnt match, trying next \
session" << endl;	 +			kdDebug() << "[KopeteMessageManagerFactory] User doesnt match, \
trying next session" << endl;  }
 	}
-	
-	KopeteMessageManager *session = new KopeteMessageManager ( user, _contacts , \
logFile); +
+	KopeteMessageManager *session = new KopeteMessageManager ( user, _contacts, \
protocol, logFile);  connect( session, SIGNAL(dying(KopeteMessageManager*)), this, \
SLOT(slotRemoveSession(KopeteMessageManager*)));  (mSessionList).append(session);
 	return (session);
@@ -77,4 +86,3 @@
 }
 
 // vim: set noet ts=4 sts=4 sw=4:
-
Index: kopetemessagemanagerfactory.h
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/kopetemessagemanagerfactory.h,v
retrieving revision 1.7.2.1
diff -u -r1.7.2.1 kopetemessagemanagerfactory.h
--- kopetemessagemanagerfactory.h	2002/05/03 06:52:57	1.7.2.1
+++ kopetemessagemanagerfactory.h	2002/05/12 01:29:39
@@ -27,9 +27,9 @@
 class KopeteMessageManager;
 class KopeteMessage;
 class KopeteContact;
+class KopeteProtocol;
 
 typedef QPtrList<KopeteContact>        KopeteContactList;
-typedef QValueList<KopeteMessage>        KopeteMessageList;
 typedef QPtrList<KopeteMessageManager> KopeteMessageManagerList;
 
 class KopeteMessageManagerFactory : public QObject
@@ -46,8 +46,14 @@
 	 * it will be reused. Otherwise a new session is created.
 	 */
 	KopeteMessageManager* create( const KopeteContact *user,
-		KopeteContactList _contacts , QString logFile = QString::null );
-	
+		KopeteContactList _contacts, KopeteProtocol* protocol, QString logFile = \
QString::null ); +
+	/**
+	 * Overloaded function for convenience. Use for one-to-one KMM creation
+	 */
+	KopeteMessageManager* create( const KopeteContact *user,
+		KopeteContact* other, KopeteProtocol* protocol, QString logFile = QString::null );
+
 	/**
 	 * Get a list of all open sessions
 	 */
Index: kopeteprotocol.h
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/kopeteprotocol.h,v
retrieving revision 1.2
diff -u -r1.2 kopeteprotocol.h
--- kopeteprotocol.h	2002/04/13 03:45:41	1.2
+++ kopeteprotocol.h	2002/05/12 01:29:39
@@ -24,6 +24,7 @@
 
 class AddContactPage;
 class QString;
+class KopeteMessage;
 
 /**
  * @author duncan
@@ -52,7 +53,10 @@
 	// plugins should also return TRUE for modes like occupied not-vailable etc.
 	virtual bool isAway(void) const = 0;
 
-	virtual AddContactPage *createAddContactWidget(QWidget *parent)=0;
+	virtual AddContactPage *createAddContactWidget(QWidget *parent) = 0;
+
+	// This method HAS to be reimplemented by subclasses. it will be virtual pure soon.
+	virtual void sendMessage(const KopeteMessage&) {};
 
 	/**
 	 * The icon of the plugin as shown in the status bar


_______________________________________________
Kopete-devel mailing list
Kopete-devel@mail.kde.org
http://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