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

List:       kde-pim
Subject:    [Kde-pim] [PATCH] Exchange plugin and International Exchange servers
From:       "Best, Jan-Pascal van" <j.p.vanbest () tbm ! tudelft ! nl>
Date:       2002-11-15 9:02:38
[Download RAW message or body]

Hi all,

Julien Gilles from France wrote in to let me know that 
the Exchange plugin didn't work for him. He was very helpful
in tracking down a in libkpimexchange: it turns out that 
international versions of Exchange also translate folder names,
so that the calendar is stored in the "Calendrier" folder instead
of the "Calendar" folder. 

Fortunately, there is a way to find out the proper location 
of the calendar folder, it is a webdav property of the user's
mailbox.

Please look at the attached patch. It's very isolated and I don't 
expect many problems, and it is a showstopper for users of 
International exchange servers, so if there are no major problems
I'll check it in tonight (CET).

Cheers

Jan-Pascal

["account.diff" (application/octet-stream)]

Index: core/exchangeaccount.h
===================================================================
RCS file: /home/kde/kdepim/libkpimexchange/core/exchangeaccount.h,v
retrieving revision 1.4
diff -u -3 -p -r1.4 exchangeaccount.h
--- core/exchangeaccount.h	2002/08/26 14:47:57	1.4
+++ core/exchangeaccount.h	2002/11/15 08:53:39
@@ -26,10 +26,12 @@
 #include <qstring.h>
 
 #include <kurl.h>
+#include <kio/job.h>
 
 namespace KPIM {
 	
-class ExchangeAccount {
+class ExchangeAccount : public QObject {
+  Q_OBJECT
   public:
     ExchangeAccount( QString host, QString account, QString password );
     /** 
@@ -59,10 +61,17 @@ class ExchangeAccount {
 
   private:
     void authenticate( int windowId );
+    void calcFolderURLs();
 
+  private slots:
+    void slotFolderResult( KIO::Job * );
+
+  private:
     QString mHost;
     QString mAccount;
     QString mPassword;
+
+    KURL* mCalendarURL;
 };
 
 }
Index: core/exchangeaccount.cpp
===================================================================
RCS file: /home/kde/kdepim/libkpimexchange/core/exchangeaccount.cpp,v
retrieving revision 1.6
diff -u -3 -p -r1.6 exchangeaccount.cpp
--- core/exchangeaccount.cpp	2002/09/16 09:44:27	1.6
+++ core/exchangeaccount.cpp	2002/11/15 08:53:39
@@ -20,6 +20,7 @@
 
 #include <qstring.h>
 #include <qapplication.h>
+#include <qdom.h>
 #include <qwidgetlist.h>
 #include <qwidget.h>
 
@@ -28,9 +29,14 @@
 #include <kdebug.h>
 #include <kconfig.h>
 #include <dcopclient.h>
+#include <kcursor.h>
+
 #include <kio/authinfo.h>
+#include <kio/davjob.h>
+#include <kio/job.h>
 
 #include "exchangeaccount.h"
+#include "utils.h"
 
 using namespace KPIM;
 
@@ -39,6 +45,8 @@ ExchangeAccount::ExchangeAccount( QStrin
   mHost = host;
   mAccount = account;
   mPassword = password;
+
+  mCalendarURL = 0;
 }
 
 ExchangeAccount::ExchangeAccount( QString group )
@@ -96,9 +104,13 @@ KURL ExchangeAccount::baseURL()
 
 KURL ExchangeAccount::calendarURL()
 {
-  KURL url = baseURL();
-  url.addPath( "Calendar" );
-  return url;
+  if ( mCalendarURL ) {
+    return *mCalendarURL;
+  } else {
+    KURL url = baseURL();
+    url.addPath( "Calendar" );
+    return url;
+  }
 }
 
 void ExchangeAccount::authenticate( QWidget* window )
@@ -145,4 +157,64 @@ void ExchangeAccount::authenticate( int 
 
   dcopClient->detach();
   delete dcopClient;
+
+  mCalendarURL = 0;
+
+  calcFolderURLs();
+
+  QApplication::setOverrideCursor( KCursor::waitCursor() );
+  do {
+    qApp->processEvents();
+  } while ( !mCalendarURL );
+  QApplication::restoreOverrideCursor();  
+}
+
+void ExchangeAccount::calcFolderURLs()
+{
+  kdDebug() << "Calculating folder URLs" << endl;
+  QDomDocument doc;
+  QDomElement root = addElement( doc, doc, "DAV:", "propfind" );
+  QDomElement prop = addElement( doc, root, "DAV:", "prop" );
+  addElement( doc, prop, "urn:schemas:httpmail:", "calendar" );
+// For later use:
+// urn:schemas:httpmail:contacts Contacts 
+// urn:schemas:httpmail:deleteditems Deleted Items 
+// urn:schemas:httpmail:drafts Drafts 
+// urn:schemas:httpmail:inbox Inbox 
+// urn:schemas:httpmail:journal Journal 
+// urn:schemas:httpmail:notes Notes 
+// urn:schemas:httpmail:outbox Outbox 
+// urn:schemas:httpmail:sentitems Sent Items 
+// urn:schemas:httpmail:tasks Tasks 
+// urn:schemas:httpmail:sendmsg Exchange Mail Submission URI 
+// urn:schemas:httpmail:msgfolderroot Mailbox folder (root) 
+
+  KIO::DavJob* job = KIO::davPropFind( baseURL(), doc, "0", false );
+  job->addMetaData( "errorPage", "false" );
+  connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotFolderResult( \
KIO::Job * ) ) ); +}
+
+void ExchangeAccount::slotFolderResult( KIO::Job * job ) 
+{
+  kdDebug() << "ExchangeAccount::slotFolderResult()" << endl;
+  if ( job->error() ) {
+    kdError() << "Error: Cannot get well-know folder names; " << job->error() << \
endl; +    job->showErrorDialog( 0L );
+    return;
+  }
+  QDomDocument& response = static_cast<KIO::DavJob *>( job )->response();
+
+  QDomElement prop = response.documentElement().namedItem( "response" ).namedItem( \
"propstat" ).namedItem( "prop" ).toElement(); + 
+  QDomElement calElement = prop.namedItem( "calendar" ).toElement();
+  if ( calElement.isNull() ) {
+    kdError() << "Error: no calendar URL in Exchange server reply" << endl;
+    return;
+  }
+  QString calendar = calElement.text();
+  mCalendarURL = new KURL( calendar );
+  mCalendarURL->setProtocol("webdav");
+  kdDebug() << "Calendar URL: " << mCalendarURL->url() << endl;
 }
+
+#include "exchangeaccount.moc"


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