]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1251 d1b88da0-ebda-0310...
authorwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 8 Nov 2007 19:59:20 +0000 (19:59 +0000)
committerwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 8 Nov 2007 19:59:20 +0000 (19:59 +0000)
ChangeLog
Main/SOGo.m
SoObjects/Appointments/SOGoAppointmentObject.m
SoObjects/SOGo/GNUmakefile
SoObjects/SOGo/SOGoGCSFolder.m
SoObjects/SOGo/SOGoParentFolder.m
SoObjects/SOGo/WORequest+SOGo.h [new file with mode: 0644]
SoObjects/SOGo/WORequest+SOGo.m [new file with mode: 0644]
UI/Contacts/UIxContactFoldersView.m

index 6fed7866f9356541d6c1c15272cb0a0d8d5e97d9..fddc5fa7caae25e29d5d23c2e00e0715eea5fa5c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2007-11-08  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
 
+       * SoObjects/SOGo/SOGoParentFolder.m ([SOGoParentFolder
+       -newFolderWithName:nameandNameInContainer:newNameInContainer]):
+       fixed method to make use of the parameters instead of the useless
+       remains that weren't even initialized.
+
+       * SoObjects/Appointments/SOGoAppointmentObject.m
+       ([SOGoAppointmentObject -saveContentString:_iCalbaseSequence:_v]):
+       don't propagate the event among the attendees if this is not an
+       "so" request.
+       ([SOGoAppointmentObject -deleteWithBaseSequence:]): same as above.
+
+       * Main/SOGo.m ([SOGo -authenticatorInContext:context]): make use
+       of the new category method below.
+
+       * SoObjects/SOGo/WORequest+SOGo.m ([WORequest
+       -handledByDefaultHandler]): new method that returns whether this
+       is an "so" or alike request.
+
+       * SoObjects/SOGo/WORequest+SOGo.[hm]: new category module.
+
+       * SoObjects/SOGo/SOGoParentFolder.m ([SOGoParentFolder
+       -newFolderWithName:nameandNameInContainer:newNameInContainer]):
+       write the new folder's name in the folder cache.
+
        * UI/Scheduler/UIxCalendarSelector.m ([UIxCalendarSelector
        -calendars]): same as below.
 
index e7690fda574677c6a60c5ebaca885afcb30037eb..32be4cedd250a429633e0d73bd5241a3799dc212 100644 (file)
@@ -47,6 +47,7 @@
 #import <SoObjects/SOGo/SOGoUserFolder.h>
 #import <SoObjects/SOGo/SOGoUser.h>
 #import <SoObjects/SOGo/SOGoWebAuthenticator.h>
+#import <SoObjects/SOGo/WORequest+SOGo.h>
 
 #import "build.h"
 #import "SOGoProductLoader.h"
@@ -236,13 +237,11 @@ static BOOL debugObjectAllocation = NO;
 - (id) authenticatorInContext: (WOContext *) context
 {
   id authenticator;
-  NSString *key;
 
-  key = [[context request] requestHandlerKey];
-  if ([key isEqualToString: @"dav"])
-    authenticator = [SOGoDAVAuthenticator sharedSOGoDAVAuthenticator];
-  else
+  if ([[context request] handledByDefaultHandler])
     authenticator = [SOGoWebAuthenticator sharedSOGoWebAuthenticator];
+  else
+    authenticator = [SOGoDAVAuthenticator sharedSOGoDAVAuthenticator];
 
   return authenticator;
 }
index 8b2f12b541c9e8f97fd0f72fef5c40203384383b..7cc44e230b1961cd1b2b6977d928108a91bd8727 100644 (file)
@@ -22,6 +22,7 @@
 #import <Foundation/NSCalendarDate.h>
 
 #import <NGObjWeb/NSException+HTTP.h>
+#import <NGObjWeb/WOContext.h>
 #import <NGExtensions/NSNull+misc.h>
 #import <NGExtensions/NSObject+Logs.h>
 #import <NGCards/iCalCalendar.h>
@@ -32,6 +33,7 @@
 #import <SoObjects/SOGo/LDAPUserManager.h>
 #import <SoObjects/SOGo/SOGoObject.h>
 #import <SoObjects/SOGo/SOGoPermissions.h>
+#import <SoObjects/SOGo/WORequest+SOGo.h>
 
 #import "NSArray+Appointments.h"
 #import "SOGoAppointmentFolder.h"
   NSException *storeError, *delError;
   BOOL updateForcesReconsider;
   
-  updateForcesReconsider = NO;
+  if ([[context request] handledByDefaultHandler])
+    {
+      updateForcesReconsider = NO;
 
-  if ([_iCal length] == 0)
-    return [NSException exceptionWithHTTPStatus: 400 /* Bad Request */
-                       reason: @"got no iCalendar content to store!"];
+      if ([_iCal length] == 0)
+       return [NSException exceptionWithHTTPStatus: 400 /* Bad Request */
+                           reason: @"got no iCalendar content to store!"];
 
-  um = [LDAPUserManager sharedUserManager];
+      um = [LDAPUserManager sharedUserManager];
 
-  /* handle old content */
+      /* handle old content */
   
-  oldContent = [self contentAsString]; /* if nil, this is a new appointment */
-  if ([oldContent length] == 0)
-    {
-    /* new appointment */
-      [self debugWithFormat:@"saving new appointment: %@", _iCal];
-      oldApt = nil;
-    }
-  else
-    oldApt = (iCalEvent *) [self component: NO];
+      oldContent = [self contentAsString]; /* if nil, this is a new appointment */
+      if ([oldContent length] == 0)
+       {
+         /* new appointment */
+         [self debugWithFormat:@"saving new appointment: %@", _iCal];
+         oldApt = nil;
+       }
+      else
+       oldApt = (iCalEvent *) [self component: NO];
   
-  /* compare sequence if requested */
-
-  if (_v != 0) {
-    // TODO
-  }
+      /* compare sequence if requested */
+      if (_v != 0) {
+       // TODO
+      }
   
-  /* handle new content */
+      /* handle new content */
   
-  newApt = (iCalEvent *) [self component: NO];
-  if (!newApt)
-    return [NSException exceptionWithHTTPStatus: 400 /* Bad Request */
-                       reason: @"could not parse iCalendar content!"];
+      newApt = (iCalEvent *) [self component: NO];
+      if (!newApt)
+       return [NSException exceptionWithHTTPStatus: 400 /* Bad Request */
+                           reason: @"could not parse iCalendar content!"];
 
-  /* diff */
+      /* diff */
   
-  changes = [iCalEventChanges changesFromEvent: oldApt toEvent: newApt];
-  uids = [self getUIDsForICalPersons: [changes deletedAttendees]];
-  removedUIDs = [NSMutableArray arrayWithArray: uids];
-
-  uids = [self getUIDsForICalPersons: [newApt attendees]];
-  storeUIDs = [NSMutableArray arrayWithArray: uids];
-  props = [changes updatedProperties];
-
-  /* detect whether sequence has to be increased */
-  if ([changes hasChanges])
-    [newApt increaseSequence];
-
-  /* preserve organizer */
-
-  organizer = [newApt organizer];
-  uid = [self getUIDForICalPerson: organizer];
-  if (!uid)
-    uid = [self ownerInContext: nil];
-  if (uid) {
-    if (![storeUIDs containsObject:uid])
-      [storeUIDs addObject:uid];
-    [removedUIDs removeObject:uid];
-  }
+      changes = [iCalEventChanges changesFromEvent: oldApt toEvent: newApt];
+      uids = [self getUIDsForICalPersons: [changes deletedAttendees]];
+      removedUIDs = [NSMutableArray arrayWithArray: uids];
+
+      uids = [self getUIDsForICalPersons: [newApt attendees]];
+      storeUIDs = [NSMutableArray arrayWithArray: uids];
+      props = [changes updatedProperties];
+
+      /* detect whether sequence has to be increased */
+      if ([changes hasChanges])
+       [newApt increaseSequence];
+
+      /* preserve organizer */
+
+      organizer = [newApt organizer];
+      uid = [self getUIDForICalPerson: organizer];
+      if (!uid)
+       uid = [self ownerInContext: nil];
+      if (uid) {
+       if (![storeUIDs containsObject:uid])
+         [storeUIDs addObject:uid];
+       [removedUIDs removeObject:uid];
+      }
 
-  /* organizer might have changed completely */
+      /* organizer might have changed completely */
 
-  if (oldApt && ([props containsObject: @"organizer"])) {
-    uid = [self getUIDForICalPerson:[oldApt organizer]];
-    if (uid) {
-      if (![storeUIDs containsObject:uid]) {
-        if (![removedUIDs containsObject:uid]) {
-          [removedUIDs addObject:uid];
-        }
+      if (oldApt && ([props containsObject: @"organizer"])) {
+       uid = [self getUIDForICalPerson:[oldApt organizer]];
+       if (uid) {
+         if (![storeUIDs containsObject:uid]) {
+           if (![removedUIDs containsObject:uid]) {
+             [removedUIDs addObject:uid];
+           }
+         }
+       }
       }
-    }
-  }
 
-  [self debugWithFormat:@"UID ops:\n  store: %@\n  remove: %@",
-                        storeUIDs, removedUIDs];
+      [self debugWithFormat:@"UID ops:\n  store: %@\n  remove: %@",
+           storeUIDs, removedUIDs];
 
-  /* if time did change, all participants have to re-decide ...
-   * ... exception from that rule: the organizer
-   */
+      /* if time did change, all participants have to re-decide ...
+       * ... exception from that rule: the organizer
+       */
 
-  if (oldApt != nil &&
-      ([props containsObject: @"startDate"] ||
-       [props containsObject: @"endDate"]   ||
-       [props containsObject: @"duration"]))
-  {
-    NSArray  *ps;
-    unsigned i, count;
+      if (oldApt != nil &&
+         ([props containsObject: @"startDate"] ||
+          [props containsObject: @"endDate"]   ||
+          [props containsObject: @"duration"]))
+       {
+         NSArray  *ps;
+         unsigned i, count;
     
-    ps    = [newApt attendees];
-    count = [ps count];
-    for (i = 0; i < count; i++) {
-      iCalPerson *p;
+         ps    = [newApt attendees];
+         count = [ps count];
+         for (i = 0; i < count; i++) {
+           iCalPerson *p;
       
-      p = [ps objectAtIndex:i];
-      if (![p hasSameEmailAddress:organizer])
-        [p setParticipationStatus:iCalPersonPartStatNeedsAction];
-    }
-    _iCal = [[newApt parent] versitString];
-    updateForcesReconsider = YES;
-  }
-
-  /* perform storing */
+           p = [ps objectAtIndex:i];
+           if (![p hasSameEmailAddress:organizer])
+             [p setParticipationStatus:iCalPersonPartStatNeedsAction];
+         }
+         _iCal = [[newApt parent] versitString];
+         updateForcesReconsider = YES;
+       }
 
-  storeError = [self saveContentString: _iCal inUIDs: storeUIDs];
-  delError = [self deleteInUIDs: removedUIDs];
+      /* perform storing */
 
-  // TODO: make compound
-  if (storeError != nil) return storeError;
-  if (delError   != nil) return delError;
+      storeError = [self saveContentString: _iCal inUIDs: storeUIDs];
+      delError = [self deleteInUIDs: removedUIDs];
 
-  /* email notifications */
-  if ([self sendEMailNotifications]
-      && [self _aptIsStillRelevant: newApt])
-    {
-      attendees
-       = [NSMutableArray arrayWithArray: [changes insertedAttendees]];
-      [attendees removePerson: organizer];
-      [self sendEMailUsingTemplateNamed: @"Invitation"
-            forOldObject: nil
-            andNewObject: newApt
-            toAttendees: attendees];
-
-      if (updateForcesReconsider) {
-        attendees = [NSMutableArray arrayWithArray:[newApt attendees]];
-        [attendees removeObjectsInArray:[changes insertedAttendees]];
-        [attendees removePerson:organizer];
-        [self sendEMailUsingTemplateNamed: @"Update"
-              forOldObject: oldApt
-              andNewObject: newApt
-              toAttendees: attendees];
-      }
+      // TODO: make compound
+      if (storeError != nil) return storeError;
+      if (delError   != nil) return delError;
 
-      attendees
-       = [NSMutableArray arrayWithArray: [changes deletedAttendees]];
-      [attendees removePerson: organizer];
-      if ([attendees count])
-        {
-          iCalEvent *cancelledApt;
+      /* email notifications */
+      if ([self sendEMailNotifications]
+         && [self _aptIsStillRelevant: newApt])
+       {
+         attendees
+           = [NSMutableArray arrayWithArray: [changes insertedAttendees]];
+         [attendees removePerson: organizer];
+         [self sendEMailUsingTemplateNamed: @"Invitation"
+               forOldObject: nil
+               andNewObject: newApt
+               toAttendees: attendees];
+
+         if (updateForcesReconsider) {
+           attendees = [NSMutableArray arrayWithArray:[newApt attendees]];
+           [attendees removeObjectsInArray:[changes insertedAttendees]];
+           [attendees removePerson:organizer];
+           [self sendEMailUsingTemplateNamed: @"Update"
+                 forOldObject: oldApt
+                 andNewObject: newApt
+                 toAttendees: attendees];
+         }
+
+         attendees
+           = [NSMutableArray arrayWithArray: [changes deletedAttendees]];
+         [attendees removePerson: organizer];
+         if ([attendees count])
+           {
+             iCalEvent *cancelledApt;
     
-          cancelledApt = [newApt copy];
-          [(iCalCalendar *) [cancelledApt parent] setMethod: @"cancel"];
-          [self sendEMailUsingTemplateNamed: @"Removal"
-                forOldObject: nil
-                andNewObject: cancelledApt
-                toAttendees: attendees];
-          [cancelledApt release];
-        }
+             cancelledApt = [newApt copy];
+             [(iCalCalendar *) [cancelledApt parent] setMethod: @"cancel"];
+             [self sendEMailUsingTemplateNamed: @"Removal"
+                   forOldObject: nil
+                   andNewObject: cancelledApt
+                   toAttendees: attendees];
+             [cancelledApt release];
+           }
+       }
     }
+  else
+    [self primarySaveContentString: _iCal];
 
   return nil;
 }
 
-- (NSException *)deleteWithBaseSequence:(int)_v {
+- (NSException *) deleteWithBaseSequence: (int)_v
+{
   /* 
      Note: We need to delete in all participants folders and send iMIP messages
            for all external accounts.
   */
   iCalEvent *apt;
   NSMutableArray *attendees, *removedUIDs;
+  NSException *error;
 
+  if ([[context request] handledByDefaultHandler])
+    {
   /* load existing content */
-
-  apt = (iCalEvent *) [self component: NO];
+      apt = (iCalEvent *) [self component: NO];
   
   /* compare sequence if requested */
 
 //     // TODO
 //   }
   
-  removedUIDs = [NSMutableArray arrayWithArray:
-                                 [self attendeeUIDsFromAppointment: apt]];
-  if (![removedUIDs containsObject: owner])
-    [removedUIDs addObject: owner];
+      removedUIDs = [NSMutableArray arrayWithArray:
+                                     [self attendeeUIDsFromAppointment: apt]];
+      if (![removedUIDs containsObject: owner])
+       [removedUIDs addObject: owner];
 
-  if ([self sendEMailNotifications]
-      && [self _aptIsStillRelevant: apt])
-    {
-      /* send notification email to attendees excluding organizer */
-      attendees = [NSMutableArray arrayWithArray:[apt attendees]];
-      [attendees removePerson:[apt organizer]];
+      if ([self sendEMailNotifications]
+         && [self _aptIsStillRelevant: apt])
+       {
+         /* send notification email to attendees excluding organizer */
+         attendees = [NSMutableArray arrayWithArray:[apt attendees]];
+         [attendees removePerson:[apt organizer]];
   
-      /* flag appointment as being cancelled */
-      [(iCalCalendar *) [apt parent] setMethod: @"cancel"];
-      [apt increaseSequence];
-
-      /* remove all attendees to signal complete removal */
-      [apt removeAllAttendees];
-
-      /* send notification email */
-      [self sendEMailUsingTemplateNamed: @"Deletion"
-            forOldObject: nil
-            andNewObject: apt
-            toAttendees: attendees];
-    }
+         /* flag appointment as being cancelled */
+         [(iCalCalendar *) [apt parent] setMethod: @"cancel"];
+         [apt increaseSequence];
+
+         /* remove all attendees to signal complete removal */
+         [apt removeAllAttendees];
+
+         /* send notification email */
+         [self sendEMailUsingTemplateNamed: @"Deletion"
+               forOldObject: nil
+               andNewObject: apt
+               toAttendees: attendees];
+       }
 
-  /* perform */
+      error = [self deleteInUIDs: removedUIDs];
+    }
+  else
+    error = [self primaryDelete];
 
-  return [self deleteInUIDs: removedUIDs];
+  return error;
 }
 
 - (NSException *) saveContentString: (NSString *) _iCalString
index 46c94b95bcefa8e9764b721e2bb9245e5bf9b12e..1d9df45cfed3f7aae4eaa3f8a7047f089f4c3d6b 100644 (file)
@@ -48,6 +48,8 @@ libSOGo_HEADER_FILES = \
        SOGoWebAuthenticator.h          \
        SOGoMailer.h                    \
        SOGoUser.h                      \
+       \
+       WORequest+SOGo.h
 
 libSOGo_OBJC_FILES = \
        SOGoObject.m                    \
@@ -79,6 +81,8 @@ libSOGo_OBJC_FILES = \
        SOGoWebAuthenticator.m          \
        SOGoMailer.m                    \
        SOGoUser.m                      \
+       \
+       WORequest+SOGo.m
 
 # tools
 
index 42c5974a73c5970947bb1fbcfdacef3496091e7b..45cf066361c86681d9283784cfed4dd7a368adcc 100644 (file)
@@ -246,7 +246,6 @@ static NSString *defaultUserID = @"<default>";
   [page send];
 }
 
-
 //   if (!result) [self sendFolderAdvisoryTemplate: @"Addition"];
 
 - (BOOL) create
index c73ed9f12afff0b0ef20dc9fb45d05757f256b20..c2b5c9b342e3ebac2bd0994bef754070ed54f343 100644 (file)
 - (NSException *) newFolderWithName: (NSString *) name
                 andNameInContainer: (NSString *) newNameInContainer
 {
-  NSString *newFolderID;
   SOGoGCSFolder *newFolder;
   NSException *error;
 
   if (!subFolderClass)
     subFolderClass = [[self class] subFolderClass];
 
-  newFolder = [subFolderClass objectWithName: newFolderID inContainer: self];
+  newFolder = [subFolderClass objectWithName: newNameInContainer
+                             inContainer: self];
   if ([newFolder isKindOfClass: [NSException class]])
     error = (NSException *) newFolder;
   else
     {
       [newFolder setDisplayName: name];
       [newFolder setOCSPath: [NSString stringWithFormat: @"%@/%@",
-                                       OCSPath, newFolderID]];
+                                       OCSPath, newNameInContainer]];
       if ([newFolder create])
-       error = nil;
+       {
+         [subFolders setObject: newFolder forKey: newNameInContainer];
+         error = nil;
+       }
       else
         error = [NSException exceptionWithHTTPStatus: 400
                             reason: @"The new folder could not be created"];
diff --git a/SoObjects/SOGo/WORequest+SOGo.h b/SoObjects/SOGo/WORequest+SOGo.h
new file mode 100644 (file)
index 0000000..647f0de
--- /dev/null
@@ -0,0 +1,34 @@
+/* WORequest+SOGo.h - this file is part of SOGo
+ *
+ * Copyright (C) 2007 Inverse groupe conseil
+ *
+ * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef WOREQUEST_SOGo_H
+#define WOREQUEST_SOGo_H
+
+#import <NGObjWeb/WORequest.h>
+
+@interface WORequest (SOGoSOPEUtilities)
+
+- (BOOL) handledByDefaultHandler;
+
+@end
+
+#endif /* WOREQUEST_SOGo_H */
diff --git a/SoObjects/SOGo/WORequest+SOGo.m b/SoObjects/SOGo/WORequest+SOGo.m
new file mode 100644 (file)
index 0000000..776cacf
--- /dev/null
@@ -0,0 +1,36 @@
+/* WORequest+SOGo.m - this file is part of SOGo
+ *
+ * Copyright (C) 2007 Inverse groupe conseil
+ *
+ * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#import <NGObjWeb/SoObjectRequestHandler.h>
+#import <NGObjWeb/WOApplication.h>
+
+#import "WORequest+SOGo.h"
+
+@implementation WORequest (SOGoSOPEUtilities)
+
+- (BOOL) handledByDefaultHandler
+{
+#warning this should be changed someday
+  return (![requestHandlerKey isEqualToString: @"dav"]);
+}
+
+@end
index 8adba727cc027cca601e0ecaeed7a2dc27c6d6d3..07d47e4478431820e13e42606d32386af0754f1e 100644 (file)
          currentDictionary
            = [NSMutableDictionary dictionaryWithCapacity: 3];
          [currentDictionary setObject: [currentFolder displayName]
-                        forKey: @"displayName"];
+                            forKey: @"displayName"];
          [currentDictionary setObject: folderName forKey: @"name"];
          [currentDictionary setObject: [currentFolder folderType]
                             forKey: @"type"];