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

List:       kopete-devel
Subject:    [Kopete-devel] DCOP file transfer exposure, patch, konq plugin
From:       Jason Keirstead <jason () keirstead ! org>
Date:       2002-12-11 6:19:46
[Download RAW message or body]

Here is a patch to add right click file transfer abilities in Konqueror using 
kopete

The first file is the patch that exposes the DCOP interface for accessing file 
transfers in Kopete. The name of the function that gets the list of 
accessable contacts I think needs work (fileTransferContacts? It is 2am, I 
can't think of anything better right now!).  As well, there is a problem in 
that the file transfer is working off of the metacontact name only until we 
get a unique ID for the metacontacts.

The second file is a tar of a Konqueror plugin using this functionality to let 
you send files from the right click menu as in Windows Explorer using ICQ. 
The code is based off of the kuick_copy plugin in kdeaddons/konqplugins. I 
havent messed around with the Makefile madness at all so it probably won't 
build "out of the box" at all, but if someone more educated in Makefiles than 
me could fix this up, it would be much appreciated.


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

===================================================================
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 02:30:55 -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 02:30:55 -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.48
diff -u -3 -p -r1.48 kopetecontact.cpp
--- libkopete/kopetecontact.cpp	4 Dec 2002 21:44:07 -0000	1.48
+++ libkopete/kopetecontact.cpp	11 Dec 2002 02:30:57 -0000
@@ -30,6 +30,7 @@
 #include <kpopupmenu.h>
 #include <kaction.h>
 #include <klineeditdlg.h>
+#include <kmessagebox.h>
 
 #include "kopete.h"
 #include "kopetemetacontact.h"
@@ -165,10 +166,10 @@ void KopeteContact::initActions()
 	actionDeleteContact = KopeteStdAction::deleteContact( this, \
SLOT(slotDeleteContact()), this, "actionDeleteContact" );  actionUserInfo = \
KopeteStdAction::contactInfo( this, SLOT(slotUserInfo()), this, "actionUserInfo" );  \
actionChangeAlias = KopeteStdAction::changeAlias( this, \
                SLOT(slotChangeDisplayName()), this, "actionChangeAlias" );
-	actionSendFile = KopeteStdAction::sendFile( this, SLOT(slotSendFile()), this, \
"actionSendFile"); +	actionSendFile = KopeteStdAction::sendFile( this, \
SLOT(slotSendFile() ), this, "actionSendFile");  }
 
-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.44
diff -u -3 -p -r1.44 kopetecontact.h
--- libkopete/kopetecontact.h	13 Nov 2002 18:21:38 -0000	1.44
+++ libkopete/kopetecontact.h	11 Dec 2002 02:30:57 -0000
@@ -255,6 +255,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:
 	/**
@@ -291,7 +296,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.55
diff -u -3 -p -r1.55 kopetecontactlist.cpp
--- libkopete/kopetecontactlist.cpp	30 Nov 2002 12:27:06 -0000	1.55
+++ libkopete/kopetecontactlist.cpp	11 Dec 2002 02:30:57 -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.31
diff -u -3 -p -r1.31 kopetecontactlist.h
--- libkopete/kopetecontactlist.h	5 Dec 2002 20:54:24 -0000	1.31
+++ libkopete/kopetecontactlist.h	11 Dec 2002 02:30:57 -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.80
diff -u -3 -p -r1.80 kopetemetacontact.cpp
--- libkopete/kopetemetacontact.cpp	2 Dec 2002 22:35:55 -0000	1.80
+++ libkopete/kopetemetacontact.cpp	11 Dec 2002 02:30:57 -0000
@@ -335,6 +335,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 )
+{
+	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.45
diff -u -3 -p -r1.45 kopetemetacontact.h
--- libkopete/kopetemetacontact.h	2 Dec 2002 22:35:55 -0000	1.45
+++ libkopete/kopetemetacontact.h	11 Dec 2002 02:30:57 -0000
@@ -83,7 +83,11 @@ public:
 	 *        protocols
 	 */
 	bool isOnline() const;
-
+	
+	/**
+	 * Returns weather this contact can accept files
+	 */
+	bool canAcceptFiles() const;
 	/**
 	 * Contact's status
 	 */
@@ -198,6 +202,8 @@ public slots:
 	 * ICQ the only true difference is the GUI shown to the user.
 	 */
 	void startChat();
+	
+	void sendFile(QString fileName);
 
 	/**
 	 * Get or set a field for the KDE address book backend. Fields not
Index: protocols/msn/msncontact.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/protocols/msn/msncontact.cpp,v
retrieving revision 1.80
diff -u -3 -p -r1.80 msncontact.cpp
--- protocols/msn/msncontact.cpp	4 Dec 2002 20:54:20 -0000	1.80
+++ protocols/msn/msncontact.cpp	11 Dec 2002 02:31:20 -0000
@@ -53,7 +53,6 @@ MSNContact::MSNContact( const QString &m
 	m_allowed = false;
 	m_blocked = false;
 	m_reversed = false;
-
 	m_moving=false;
 
 	historyDialog = 0L;
@@ -658,10 +657,14 @@ void MSNContact::slotMoved(KopeteMetaCon
 
 }
 
-void MSNContact::slotSendFile()
-{
-	QString fileName = KFileDialog::getOpenFileName( QString::null ,"*.*", 0l  , i18n( \
                "Kopete File Transfer" ) );
-	if ( !fileName.isNull())
+void MSNContact::slotSendFile(QString fileName = QString::null )
+{	
+	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;
 		chatmembers.append(this);
Index: protocols/msn/msncontact.h
===================================================================
RCS file: /home/kde/kdenonbeta/kopete/protocols/msn/msncontact.h,v
retrieving revision 1.56
diff -u -3 -p -r1.56 msncontact.h
--- protocols/msn/msncontact.h	2 Dec 2002 22:35:56 -0000	1.56
+++ protocols/msn/msncontact.h	11 Dec 2002 02:31:20 -0000
@@ -127,7 +127,7 @@ public slots:
 	virtual void execute();
 	virtual void slotViewHistory();
   /** No descriptions */
-  virtual void slotSendFile();
+  virtual void slotSendFile(QString fileName);
 
 	void removedFromGroup(QString group);
 	void addedToGroup(QString group);


["konqPlugin.tar.gz" (application/x-tgz)]
_______________________________________________
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