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

List:       kde-pim
Subject:    [Kde-pim] [PATCH] Sieve authentication
From:       Szombathelyi "György" <gyurco () freemail ! hu>
Date:       2004-11-08 21:26:31
Message-ID: 200411082226.31826.gyurco () freemail ! hu
[Download RAW message or body]

Hello!

The attached patch does:
- Allow the SASL authentication mechanism to be specified in the sieve url, in 
the form of sieve://sievehost/scriptname?x-mech=AUTHMETHOD. Kio_ldap works in 
a similar way. This can be useful for specifying the authentication method 
e.g. in Konqueror. Also helps closing #91436.
- In kmail, if the reuse imap setting selected in sieve config, correctly 
re-use the authentication method setting. With the patch in kio_sieve, also 
the user-defined url can contain the auth method.

May I commit?

Bye,
György

____________________________________________________________________
Miert fizetsz az internetert? Korlatlan, ingyenes internet hozzaferes a FreeStarttol.
Probald ki most! http://www.freestart.hu

["sieve.diff" (text/x-diff)]

? kmail/custommimeheader.cpp
? kmail/custommimeheader.h
? kmail/replyphrases.cpp
? kmail/replyphrases.h
Index: kmail/sievejob.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/sievejob.cpp,v
retrieving revision 1.7
diff -u -p -u -r1.7 sievejob.cpp
--- kmail/sievejob.cpp	11 Jan 2004 21:57:08 -0000	1.7
+++ kmail/sievejob.cpp	8 Nov 2004 21:28:20 -0000
@@ -81,7 +81,9 @@ namespace KMail {
       kdDebug(5006) << "SieveJob::schedule: listDir( " << mUrl.prettyURL() << " )" \
<< endl;  {
 	KURL url = mUrl;
+	QString query = url.query(); //save query part, because KURL::cd() erases it
 	url.cd("..");
+	url.setQuery( query );
 	kdDebug(5006) << "SieveJob::schedule: listDir's real URL: " << url.prettyURL()
 		  << endl;
 	mJob = KIO::listDir( url );
Index: kmail/vacation.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/vacation.cpp,v
retrieving revision 1.27
diff -u -p -u -r1.27 vacation.cpp
--- kmail/vacation.cpp	4 Jun 2004 00:04:09 -0000	1.27
+++ kmail/vacation.cpp	8 Nov 2004 21:28:21 -0000
@@ -228,6 +228,7 @@ namespace KMail {
       u.setUser( a->login() );
       u.setPass( a->passwd() );
       u.setPort( sieve.port() );
+      u.setQuery( "x-mech=" + (a->auth() == "*" ? "PLAIN" : a->auth()) ); \
//translate IMAP LOGIN to PLAIN  return u;
     } else {
       return sieve.alternateURL();
Index: kioslaves/sieve/sieve.cpp
===================================================================
RCS file: /home/kde/kdepim/kioslaves/sieve/sieve.cpp,v
retrieving revision 1.17
diff -u -p -u -r1.17 sieve.cpp
--- kioslaves/sieve/sieve.cpp	4 Nov 2004 18:15:16 -0000	1.17
+++ kioslaves/sieve/sieve.cpp	8 Nov 2004 21:28:24 -0000
@@ -282,6 +282,39 @@ bool kio_sieveProtocol::parseCapabilitie
 	return ret;
 }
 
+
+/* ---------------------------------------------------------------------------------- \
*/ +/**
+ * Checks if connection parameters (currently - auth method) have changed.
+ * If it it, close the current connection
+ */
+void kio_sieveProtocol::changeCheck( const KURL &url )
+{
+	QString auth;
+
+	if (!metaData("sasl").isEmpty())
+		auth = metaData("sasl").upper();
+	else {
+		QString query = url.query();
+		if ( query.startsWith("?") ) query.remove( 0, 1 );
+		QStringList q = QStringList::split( ",", query );
+		QStringList::iterator it;
+  
+		for ( it = q.begin(); it != q.end(); ++it ) {
+			if ( ( (*it).section('=',0,0) ).lower() == "x-mech" ) {
+				auth = ( (*it).section('=',1) ).upper();
+				break;
+			}
+		}
+	}
+	ksDebug() << "auth: " << auth << " m_sAuth: " << m_sAuth << endl;
+	if ( m_sAuth != auth ) {
+		m_sAuth = auth;
+		if ( isConnectionValid() )
+			disconnect();
+	}
+}
+
 /* ---------------------------------------------------------------------------------- \
*/  /**
  * Connects to the server.
@@ -407,6 +440,7 @@ void kio_sieveProtocol::special(const QB
 /* ---------------------------------------------------------------------------------- \
*/  bool kio_sieveProtocol::activate(const KURL& url)
 {
+	changeCheck( url );
 	if (!connect())
 		return false;
 
@@ -468,6 +502,7 @@ static void append_lf2crlf( QByteArray &
 
 void kio_sieveProtocol::put(const KURL& url, int /*permissions*/, bool \
/*overwrite*/, bool /*resume*/)  {
+	changeCheck( url );
 	if (!connect())
 		return;
 
@@ -628,6 +663,7 @@ static void inplace_crlf2lf( QByteArray 
 /* ---------------------------------------------------------------------------------- \
*/  void kio_sieveProtocol::get(const KURL& url)
 {
+	changeCheck( url );
 	if (!connect())
 		return;
 
@@ -704,6 +740,7 @@ void kio_sieveProtocol::del(const KURL &
 		return;
 	}
 
+	changeCheck( url );
 	if (!connect())
 		return;
 
@@ -754,6 +791,7 @@ void kio_sieveProtocol::chmod(const KURL
 
 void kio_sieveProtocol::stat(const KURL& url)
 {
+	changeCheck( url );
 	if (!connect())
 		return;
 
@@ -823,8 +861,9 @@ void kio_sieveProtocol::stat(const KURL&
 	finished();
 }
 
-void kio_sieveProtocol::listDir(const KURL& /*url*/)
+void kio_sieveProtocol::listDir(const KURL& url)
 {
+	changeCheck( url );
 	if (!connect())
 		return;
 
@@ -963,10 +1002,10 @@ bool kio_sieveProtocol::authenticate()
 	QStringList strList;
 //	strList.append("NTLM");
 
-  if (!metaData("sasl").isEmpty())
-    strList.append(metaData("sasl").latin1());
+  if ( !m_sAuth.isEmpty() )
+    strList.append( m_sAuth );
   else
-    strList = m_sasl_caps;	
+    strList = m_sasl_caps;
 
   do {
     result = sasl_client_start(conn, strList.join(" ").latin1(), &client_interact,
Index: kioslaves/sieve/sieve.h
===================================================================
RCS file: /home/kde/kdepim/kioslaves/sieve/sieve.h,v
retrieving revision 1.3
diff -u -p -u -r1.3 sieve.h
--- kioslaves/sieve/sieve.h	7 Sep 2004 20:33:06 -0000	1.3
+++ kioslaves/sieve/sieve.h	8 Nov 2004 21:28:24 -0000
@@ -96,6 +96,7 @@ protected:
 	bool connect(bool useTLSIfAvailable = true);
 	bool authenticate();
 	void disconnect(bool forcibly = false);
+	void changeCheck( const KURL &url );
 
 	bool sendData(const QCString &data);
 	bool receiveData(bool waitForData = true, QCString *reparse = 0);
@@ -119,6 +120,7 @@ protected:
 	QString				m_sServer;
 	QString				m_sUser;
 	QString				m_sPass;
+	QString				m_sAuth;
 	bool				m_shouldBeConnected;
 };
 



_______________________________________________
kde-pim mailing list
kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/

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

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