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

List:       kde-pim
Subject:    [Kde-pim] [PATCH] Update resources in eGroupware wizard
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2004-07-31 14:56:11
Message-ID: 20040731145611.GA4552 () ghostdog ! localnet
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi,

the attached patch adds functionality to the eGroupware wizard to
support updates of resources. At the moment you have to remove the old
resources manually before you can change the settings of the wizard and
let create new ones...

The slox resource already supports this concept, so could somebody
please review this patch?

Ciao,
Tobias
--=20
Separate politics from religion and economy!

["egwwizard.patch" (text/plain)]

Index: egroupwarewizard.cpp
===================================================================
RCS file: /home/kde/kdepim/wizards/egroupwarewizard.cpp,v
retrieving revision 1.2
diff -p -u -b -r1.2 egroupwarewizard.cpp
--- egroupwarewizard.cpp	1 Jun 2004 15:55:49 -0000	1.2
+++ egroupwarewizard.cpp	31 Jul 2004 14:23:04 -0000
@@ -76,6 +76,45 @@ class CreateEGroupwareKabcResource : pub
     }
 };
 
+// TODO: fix the i18n strings after freeze...
+class ChangeEGroupwareKabcResource : public KConfigPropagator::Change
+{
+  public:
+    ChangeEGroupwareKabcResource( const QString &identifier )
+      : KConfigPropagator::Change( i18n("Create eGroupware Addressbook Resource") ),
+        mIdentifier( identifier )
+    {
+    }
+
+    void apply()
+    {
+      kdDebug() << "Change eGroupware Addressbook Resource" << endl;
+
+      KRES::Manager<KABC::Resource> manager( "contact" );
+      manager.readConfig();
+
+      KRES::Manager<KABC::Resource>::Iterator it;
+      for ( it = manager.begin(); it != manager.end(); ++it ) {
+        if ( (*it)->identifier() == mIdentifier ) {
+          KABC::ResourceXMLRPC *resource = static_cast<KABC::ResourceXMLRPC*>( *it );
+
+          resource->setURL( createURL( EGroupwareConfig::self()->server(),
+                                       EGroupwareConfig::self()->useSSLConnection() ) );
+          resource->setDomain( EGroupwareConfig::self()->domain() );
+          resource->setUser( EGroupwareConfig::self()->user() );
+          resource->setPassword( EGroupwareConfig::self()->password() );
+
+          manager.change( resource );
+          manager.writeConfig();
+          return;
+        }
+      }
+    }
+
+  private:
+    QString mIdentifier;
+};
+
 class CreateEGroupwareKcalResource : public KConfigPropagator::Change
 {
   public:
@@ -102,6 +141,44 @@ class CreateEGroupwareKcalResource : pub
     }
 };
 
+class ChangeEGroupwareKcalResource : public KConfigPropagator::Change
+{
+  public:
+    ChangeEGroupwareKcalResource( const QString &identifier )
+      : KConfigPropagator::Change( i18n( "Create eGroupware Calendar Resource" ) ),
+        mIdentifier( identifier )
+    {
+    }
+
+    void apply()
+    {
+      kdDebug() << "Change eGroupware Calendar Resource" << endl;
+
+      KCal::CalendarResourceManager manager( "calendar" );
+      manager.readConfig();
+
+      KCal::CalendarResourceManager::Iterator it;
+      for ( it = manager.begin(); it != manager.end(); ++it ) {
+        if ( (*it)->identifier() == mIdentifier ) {
+          KCal::ResourceXMLRPC *resource = static_cast<KCal::ResourceXMLRPC*>( *it );
+
+          resource->setURL( createURL( EGroupwareConfig::self()->server(),
+                                       EGroupwareConfig::self()->useSSLConnection() ) );
+          resource->setDomain( EGroupwareConfig::self()->domain() );
+          resource->setUser( EGroupwareConfig::self()->user() );
+          resource->setPassword( EGroupwareConfig::self()->password() );
+
+          manager.change( resource );
+          manager.writeConfig();
+          return;
+        }
+      }
+    }
+
+  private:
+    QString mIdentifier;
+};
+
 class CreateEGroupwareKnotesResource : public KConfigPropagator::Change
 {
   public:
@@ -130,6 +207,44 @@ class CreateEGroupwareKnotesResource : p
     }
 };
 
+class ChangeEGroupwareKnotesResource : public KConfigPropagator::Change
+{
+  public:
+    ChangeEGroupwareKnotesResource( const QString &identifier )
+      : KConfigPropagator::Change( i18n("Create eGroupware Notes Resource") ),
+        mIdentifier( identifier )
+    {
+    }
+
+    void apply()
+    {
+      kdDebug() << "Change eGroupware Notes Resource" << endl;
+
+      KRES::Manager<ResourceNotes> manager( "notes" );
+      manager.readConfig();
+
+      KRES::Manager<ResourceNotes>::Iterator it;
+      for ( it = manager.begin(); it != manager.end(); ++it ) {
+        if ( (*it)->identifier() == mIdentifier ) {
+          KNotes::ResourceXMLRPC *resource = static_cast<KNotes::ResourceXMLRPC*>( *it );
+
+          resource->setURL( createURL( EGroupwareConfig::self()->server(),
+                                       EGroupwareConfig::self()->useSSLConnection() ) );
+          resource->setDomain( EGroupwareConfig::self()->domain() );
+          resource->setUser( EGroupwareConfig::self()->user() );
+          resource->setPassword( EGroupwareConfig::self()->password() );
+
+          manager.change( resource );
+          manager.writeConfig();
+          return;
+        }
+      }
+    }
+
+  private:
+    QString mIdentifier;
+};
+
 class EGroupwarePropagator : public KConfigPropagator
 {
   public:
@@ -149,6 +264,8 @@ class EGroupwarePropagator : public KCon
       }
       if ( kcalIt == kcalManager.end() ) {
         changes.append( new CreateEGroupwareKcalResource );
+      } else {
+        changes.append( new ChangeEGroupwareKcalResource( (*kcalIt)->identifier() ) );
       }
 
       KRES::Manager<KABC::Resource> kabcManager( "contact" );
@@ -159,6 +276,8 @@ class EGroupwarePropagator : public KCon
       }
       if ( kabcIt == kabcManager.end() ) {
         changes.append( new CreateEGroupwareKabcResource );
+      } else {
+        changes.append( new ChangeEGroupwareKabcResource( (*kabcIt)->identifier() ) );
       }
 
       KRES::Manager<ResourceNotes> knotesManager( "notes" );
@@ -169,6 +288,8 @@ class EGroupwarePropagator : public KCon
       }
       if ( knotesIt == knotesManager.end() ) {
         changes.append( new CreateEGroupwareKnotesResource );
+      } else {
+        changes.append( new ChangeEGroupwareKnotesResource( (*knotesIt)->identifier() ) );
       }
     }
 };

["signature.asc" (application/pgp-signature)]

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