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

List:       kopete-devel
Subject:    [Kopete-devel] Updated DCOP file transfer exposure
From:       Jason Keirstead <jason () keirstead ! org>
Date:       2002-12-11 19:13:58
[Download RAW message or body]

Fixed up the .patch file (removed some fuzzies)

-- 
Jason Keirstead, BCS
http://www.keirstead.org
["kopete-2002.12.11.patch" (text/x-diff)]

Index: kopete/kopeteiface.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/kopete/kopeteiface.cpp,v
retrieving revision 1.3
diff -u -3 -p -r1.3 kopeteiface.cpp
--- kopete/kopeteiface.cpp	2 Aug 2002 17:02:42 -0000	1.3
+++ kopete/kopeteiface.cpp	11 Dec 2002 19:07:22 -0000
@@ -42,6 +42,16 @@ QStringList KopeteIface::contactsStatus(
 	return KopeteContactList::contactList()->contactStatuses();
 }
 
+QStringList KopeteIface::fileTransferContacts()
+{
+	return KopeteContactList::contactList()->fileTransferContacts();
+}
+
+void KopeteIface::sendFile(QString displayName, QString fileName)
+{
+	return KopeteContactList::contactList()->sendFile(displayName, fileName);
+}
+
 
 
 /*
Index: kopete/kopeteiface.h
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/kopete/kopeteiface.h,v
retrieving revision 1.3
diff -u -3 -p -r1.3 kopeteiface.h
--- kopete/kopeteiface.h	2 Aug 2002 17:02:42 -0000	1.3
+++ kopete/kopeteiface.h	11 Dec 2002 19:07:23 -0000
@@ -35,7 +35,8 @@ k_dcop:
 	QStringList contacts();
 	QStringList reachableContacts();
 	QStringList onlineContacts();
-
+	QStringList fileTransferContacts();
+	void sendFile(QString displayName, QString fileName);
 	// FIXME: Do we *need* this one? Sounds error prone to me, because
 	// nicknames can contain parentheses too.
 	// Better add a contactStatus( const QString id ) I'd say - Martijn
Index: libkopete/kopetecontact.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/kopetecontact.cpp,v
retrieving revision 1.49
diff -u -3 -p -r1.49 kopetecontact.cpp
--- libkopete/kopetecontact.cpp	8 Dec 2002 19:38:51 -0000	1.49
+++ libkopete/kopetecontact.cpp	11 Dec 2002 19:07:23 -0000
@@ -30,6 +30,7 @@
 #include <kpopupmenu.h>
 #include <kaction.h>
 #include <klineeditdlg.h>
+#include <kmessagebox.h>
 
 #include "kopete.h"
 #include "kopetecontactlist.h"
@@ -200,7 +201,7 @@ void KopeteContact::slotHistoryDialogDes
 	m_historyDialog = 0L;
 }
 
-void KopeteContact::slotSendFile()
+void KopeteContact::slotSendFile(QString fileName = QString::null)
 {
 	kdDebug() << "[KopeteContact] Opps, the plugin hasn't implemented file sending, yet \
it was turned on! :(" << endl;  }
Index: libkopete/kopetecontact.h
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/kopetecontact.h,v
retrieving revision 1.46
diff -u -3 -p -r1.46 kopetecontact.h
--- libkopete/kopetecontact.h	8 Dec 2002 19:38:51 -0000	1.46
+++ libkopete/kopetecontact.h	11 Dec 2002 19:07:23 -0000
@@ -256,6 +256,11 @@ public:
 	  * virtual slotSendFile
 	  */
 	  void setFileCapable(bool filecap) { mFileCapable = filecap; }
+	  
+	 /*
+	  * Returns if this contact can accept file transfers
+	  */ 
+	  bool canAcceptFiles() const { return isOnline() && mFileCapable; }
 
 public slots:
 	/**
@@ -287,7 +292,7 @@ public slots:
 	/**
 	 * Method to send a file. Should be implemented by the protocols
 	 */
-	 virtual void slotSendFile();
+	 virtual void slotSendFile(QString fileName = QString::null);
 
 private slots:
 	/**
Index: libkopete/kopetecontactlist.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/kopetecontactlist.cpp,v
retrieving revision 1.56
diff -u -3 -p -r1.56 kopetecontactlist.cpp
--- libkopete/kopetecontactlist.cpp	8 Dec 2002 16:25:21 -0000	1.56
+++ libkopete/kopetecontactlist.cpp	11 Dec 2002 19:07:23 -0000
@@ -277,6 +277,38 @@ QStringList KopeteContactList::onlineCon
 	return contacts;
 }
 
+QStringList KopeteContactList::fileTransferContacts() const
+{
+	QStringList contacts;
+	QPtrListIterator<KopeteMetaContact> it( m_contacts );
+	for( ; it.current(); ++it )
+	{
+		if ( it.current()->canAcceptFiles() )
+			contacts.append( it.current()->displayName() );
+	}
+	return contacts;
+}
+
+void KopeteContactList::sendFile( QString displayName, QString fileName)
+{
+	/*
+	 * FIXME: We should be using either some kind of unique ID (kabc ID??)
+	 * here, or force user to only enter unique display names. A
+	 * unique identifier is needed for external DCOP refs like this!
+	 */
+	kdDebug() << "Send To Display Name: " << displayName << "\n";
+	QPtrListIterator<KopeteMetaContact> it( m_contacts );
+	for( ; it.current(); ++it )
+	{
+		kdDebug() << "Display Name: " << it.current()->displayName() << "\n";
+		if( it.current()->displayName() == displayName ) {
+			it.current()->sendFile( fileName );
+			return;
+		}
+	}
+	return;
+}
+
 KopeteGroupList KopeteContactList::groups() const
 {
 	return m_groupList;
Index: libkopete/kopetecontactlist.h
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/kopetecontactlist.h,v
retrieving revision 1.32
diff -u -3 -p -r1.32 kopetecontactlist.h
--- libkopete/kopetecontactlist.h	8 Dec 2002 16:25:21 -0000	1.32
+++ libkopete/kopetecontactlist.h	11 Dec 2002 19:07:23 -0000
@@ -76,6 +76,13 @@ public:
 	QStringList onlineContacts() const;
 
 	/**
+	 * Returns all contacts which can accept file transfers
+	 */
+	QStringList fileTransferContacts() const;
+	
+	void sendFile(QString displayName, QString fileName);
+	
+	/**
 	 * Return all meta contacts with their current status
 	 *
 	 * FIXME: Do we *need* this one? Sounds error prone to me, because
Index: libkopete/kopetemetacontact.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/kopetemetacontact.cpp,v
retrieving revision 1.83
diff -u -3 -p -r1.83 kopetemetacontact.cpp
--- libkopete/kopetemetacontact.cpp	11 Dec 2002 16:33:52 -0000	1.83
+++ libkopete/kopetemetacontact.cpp	11 Dec 2002 19:07:23 -0000
@@ -338,6 +338,35 @@ bool KopeteMetaContact::isReachable() co
 	return false;
 }
 
+bool KopeteMetaContact::canAcceptFiles() const
+{
+	if( !isOnline() )
+		return false;
+
+	QPtrListIterator<KopeteContact> it( m_contacts );
+	for( ; it.current(); ++it )
+	{
+		if( it.current()->canAcceptFiles() )
+			return true;
+	}
+	return false;
+}
+
+void KopeteMetaContact::sendFile( QString fileName = QString::null )
+{
+	if( m_contacts.isEmpty() || !canAcceptFiles() )
+		return;
+
+	KopeteContact *c=m_contacts.first();
+	for(QPtrListIterator<KopeteContact> it( m_contacts ) ; it.current(); ++it )
+	{
+		if( (*it)->importance() > c->importance())
+			c=*it;
+	}
+	
+	c->slotSendFile( fileName );
+}
+
 void KopeteMetaContact::slotContactStatusChanged( KopeteContact * c,
 	KopeteContact::ContactStatus /* s */ )
 {
Index: libkopete/kopetemetacontact.h
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/kopetemetacontact.h,v
retrieving revision 1.46
diff -u -3 -p -r1.46 kopetemetacontact.h
--- libkopete/kopetemetacontact.h	11 Dec 2002 16:33:52 -0000	1.46
+++ libkopete/kopetemetacontact.h	11 Dec 2002 19:07:23 -0000
@@ -82,7 +82,11 @@ public:
 	 *        protocols
 	 */
 	bool isOnline() const;
-
+	
+	/**
+	 * Returns weather this contact can accept files
+	 */
+	bool canAcceptFiles() const;
 	/**
 	 * Contact's status
 	 */
@@ -219,6 +223,8 @@ public slots:
 	 * ICQ the only true difference is the GUI shown to the user.
 	 */
 	void startChat();
+	
+	void sendFile(QString fileName = QString::null);
 
 signals:
 	/**
Index: libkopete/ui/kopetemetacontactlvi.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/libkopete/ui/kopetemetacontactlvi.cpp,v
retrieving revision 1.72
diff -u -3 -p -r1.72 kopetemetacontactlvi.cpp
--- libkopete/ui/kopetemetacontactlvi.cpp	10 Dec 2002 18:50:32 -0000	1.72
+++ libkopete/ui/kopetemetacontactlvi.cpp	11 Dec 2002 19:07:23 -0000
@@ -180,8 +180,20 @@ void KopeteMetaContactLVI::showContextMe
 		SLOT( startChat() ), popup, "actionChat" );
 	KAction *actionSendMessage = KopeteStdAction::sendMessage( m_metaContact,
 		SLOT( sendMessage() ), popup, "actionSendMessage" );
+	
 	actionChat->plug( popup );
 	actionSendMessage->plug( popup );
+	
+	/*
+	 * If the contact can accept file transfers, add this to the top popup window
+	 * It will use the highest priority protocol to send the file
+	 */
+	if(m_metaContact->canAcceptFiles())
+	{
+		KAction *actionFile = KopeteStdAction::sendFile( m_metaContact,
+			SLOT( sendFile() ), popup, "actionSendFile" );
+		actionFile->plug( popup );
+	}
 
 	//-- MetaContact actions
 	KAction *m_actionRemoveFromGroup=0l;
Index: protocols/msn/msncontact.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/protocols/msn/msncontact.cpp,v
retrieving revision 1.83
diff -u -3 -p -r1.83 msncontact.cpp
--- protocols/msn/msncontact.cpp	11 Dec 2002 16:33:53 -0000	1.83
+++ protocols/msn/msncontact.cpp	11 Dec 2002 19:07:24 -0000
@@ -50,7 +50,6 @@ MSNContact::MSNContact( const QString &m
 	m_allowed = false;
 	m_blocked = false;
 	m_reversed = false;
-
 	m_moving=false;
 
 	m_msnId = msnId;
@@ -638,10 +637,13 @@ void MSNContact::slotMoved(KopeteMetaCon
 
 }
 
-void MSNContact::slotSendFile()
+void MSNContact::slotSendFile(QString fileName = QString::null )
 {
-	QString fileName = KFileDialog::getOpenFileName( QString::null , "*.*",
-		0L, i18n( "Kopete File Transfer" ) );
+        if(fileName.isNull())
+               fileName = KFileDialog::getOpenFileName( QString::null ,"*.*", 0l  , \
i18n( "Kopete File Transfer" )); +
+        kdDebug() << "File chosen to send:" << fileName.ascii() << "\n";
+
 	if ( !fileName.isNull() )
 	{
 		KopeteContactPtrList chatmembers;
Index: protocols/msn/msncontact.h
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/protocols/msn/msncontact.h,v
retrieving revision 1.57
diff -u -3 -p -r1.57 msncontact.h
--- protocols/msn/msncontact.h	8 Dec 2002 19:39:25 -0000	1.57
+++ protocols/msn/msncontact.h	11 Dec 2002 19:07:24 -0000
@@ -122,7 +122,7 @@ public slots:
 	virtual void slotUserInfo();
 	virtual void slotDeleteContact();
 	virtual void execute();
-	virtual void slotSendFile();
+	virtual void slotSendFile(QString fileName);
 
 	void removedFromGroup(QString group);
 	void addedToGroup(QString group);


_______________________________________________
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