]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1210 d1b88da0-ebda-0310...
authorwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 1 Nov 2007 13:07:22 +0000 (13:07 +0000)
committerwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 1 Nov 2007 13:07:22 +0000 (13:07 +0000)
13 files changed:
ChangeLog
SoObjects/Mailer/SOGoMailAccount.h
SoObjects/Mailer/SOGoMailAccount.m
SoObjects/Mailer/SOGoMailBaseObject.m
SoObjects/Mailer/SOGoMailFolder.m
SoObjects/SOGo/AgenorUserDefaults.m
UI/MailerUI/English.lproj/Localizable.strings
UI/MailerUI/French.lproj/Localizable.strings
UI/MailerUI/German.lproj/Localizable.strings
UI/MailerUI/UIxMailAccountActions.h
UI/MailerUI/UIxMailAccountActions.m
UI/MailerUI/UIxMailFolderActions.m
UI/WebServerResources/MailerUI.js

index a2ec7f33907cf06b452e7ad270b1ed60a9eba9a2..14fbeaa35c90d02472044667418a596c100b4462 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,64 @@
+2007-11-01  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
+
+       * UI/MailerUI/UIxMailFolderActions.m ([UIxMailFolderActions
+       -deleteFolderAction]): no longer prefix the target folder with
+       "folder".
+
+       * UI/MailerUI/UIxMailAccountActions.m ([UIxMailAccountActions
+       -listMailboxesAction]): base the folder type on the folder
+       traversal path.
+
+       * SoObjects/Mailer/SOGoMailFolder.m ([SOGoMailFolder
+       -lookupName:_keyinContext:acquire:_acquire]): compare the full
+       traversal to the potential looked up folder with the special
+       folder names and return an object with the appropriate
+       SOGoMailFolder subclass.
+
+       * SoObjects/Mailer/SOGoMailBaseObject.m ([SOGoMailBaseObject
+       -traversalFromMailAccount]): don't prepend the whole string with
+       "/".
+
+       * SoObjects/Mailer/SOGoMailAccount.m
+       ([-lookupSentFolder:_keyinContext:_ctx])
+       ([-lookupDraftsFolder:_keyinContext:_ctx])
+       ([-lookupTrashFolder:_keyinContext:_ctx])
+       ([-lookupFiltersFolder:_key:_ctx]): removed methods.
+       ([SOGoMailAccount -inboxFolderNameInContext:])
+       ([SOGoMailAccount -draftsFolderNameInContext:_ctx])
+       ([SOGoMailAccount -sentFolderNameInContext:])
+       ([SOGoMailAccount -trashFolderNameInContext:]): no longer prefixes
+       the resulting name with "prefix" since we might return a nested
+       foldername.
+       ([SOGoMailAccount -allFolderPaths]): prefixes all special folder
+       names with "/". Sorts the resulting folder list with
+       localizedCaseInsensitiveCompare: instead of
+       caseInsensitiveCompare:. No longer use the -[lookupXXX] methods
+       that were removed, instead, we choose the appropriate class
+       depending on the folder name. And since we are in SOGoMailAccount,
+       we don't have to compute a traversal path to match the key with
+       the foldernames.
+       ([SOGoMailAccount
+       -folderWithTraversal:traversalandClassName:className]): new method
+       that returns an instance of the specified SOGoMailFolder subclass,
+       based on the traversal path passed as parameter.
+       ([SOGoMailAccount -inboxFolderInContext:_ctx])
+       ([SOGoMailAccount -draftsFolderInContext:_ctx])
+       ([-sentFolderInContext:_ctx])
+       ([SOGoMailAccount -trashFolderInContext:_ctx]): invoke the new
+       -folderWithTraversal:andClassName: method described above.
+
+       * SoObjects/SOGo/AgenorUserDefaults.m ([AgenorUserDefaults
+       -primaryFetchProfile]): make use of -[NSPropertyListSerialization
+       propertyListFromData:mutabilityOption:format:errorDescription:] to
+       deserialize the plist. Removed variant for libFoundation since it
+       should support the above.
+       ([AgenorUserDefaults -generateSQLForInsert])
+       ([AgenorUserDefaults -generateSQLForUpdate]): make use of
+       -[NSPropertyListSerialization
+       dataFromPropertyList:format:errorDescription:] to serialize the
+       plist. Removed variant for libFoundation since it should support
+       the above. Escape the backslashes from the resulting string.
+
 2007-10-31  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
 
        * SoObjects/Mailer/SOGoMailFolder.[hm]: added a new subclass of
index dff405376a427f958593061328bde394dca823fe..e6e55ebb6b8cfc1d831619d8498b4c74a60a9517 100644 (file)
 
 @class NSArray;
 @class NSString;
+
 @class SOGoDraftsFolder;
 @class SOGoMailFolder;
+@class SOGoSentFolder;
+@class SOGoTrashFolder;
 
 @interface SOGoMailAccount : SOGoMailBaseObject
 {
   SOGoMailFolder *inboxFolder;
   SOGoDraftsFolder *draftsFolder;
-  SOGoMailFolder *sentFolder;
-  SOGoMailFolder *trashFolder;
+  SOGoSentFolder *sentFolder;
+  SOGoTrashFolder *trashFolder;
 }
 
 /* folder pathes */
 
 - (NSString *) inboxFolderNameInContext: (id)_ctx;
 - (NSString *) draftsFolderNameInContext: (id)_ctx;
-- (NSString *) sieveFolderNameInContext: (id)_ctx;
+// - (NSString *) sieveFolderNameInContext: (id)_ctx;
 - (NSString *) sentFolderNameInContext: (id)_ctx;
 - (NSString *) trashFolderNameInContext: (id)_ctx;
 
 - (SOGoMailFolder *) inboxFolderInContext: (id)_ctx;
 - (SOGoDraftsFolder *) draftsFolderInContext: (id)_ctx;
-- (SOGoMailFolder *) sentFolderInContext: (id)_ctx;
-- (SOGoMailFolder *) trashFolderInContext: (id)_ctx;
+- (SOGoSentFolder *) sentFolderInContext: (id)_ctx;
+- (SOGoTrashFolder *) trashFolderInContext: (id)_ctx;
 
 /* user defaults */
 - (NSString *) sharedFolderName;
index 25b99b70bdb1af4af7a8b69370244f017c63764c..f702e21fbd49ab0470531d06d9a379489621487a 100644 (file)
 #import <SoObjects/SOGo/NSArray+Utilities.h>
 #import <SoObjects/SOGo/SOGoUser.h>
 
+#import "SOGoDraftsFolder.h"
 #import "SOGoMailFolder.h"
 #import "SOGoMailManager.h"
-#import "SOGoDraftsFolder.h"
+#import "SOGoSentFolder.h"
+#import "SOGoTrashFolder.h"
 
 #import "SOGoMailAccount.h"
 
@@ -177,30 +179,25 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default
 
 - (NSArray *) allFolderPaths
 {
-  NSMutableArray *newFolders;
+  NSMutableArray *folderPaths;
   NSArray *rawFolders, *mainFolders;
-  NSString *realDraftsFolderName, *realSentFolderName, *realTrashFolderName;
 
   rawFolders = [[self imap4Connection] allFoldersForURL: [self imap4URL]];
 
-  realDraftsFolderName
-    = [[self draftsFolderInContext: context] traversalFromMailAccount];
-  realSentFolderName
-    = [[self sentFolderInContext: context] traversalFromMailAccount];
-  realTrashFolderName
-    = [[self trashFolderInContext: context] traversalFromMailAccount];
-
-  mainFolders = [NSArray arrayWithObjects: inboxFolderName,
-                        realDraftsFolderName,
-                        realSentFolderName,
-                        realTrashFolderName, nil];
-  newFolders = [NSMutableArray arrayWithArray: rawFolders];
-  [newFolders removeObjectsInArray: mainFolders];
-  [newFolders sortUsingSelector: @selector (caseInsensitiveCompare:)];
-  [newFolders replaceObjectsInRange: NSMakeRange (0, 0)
-             withObjectsFromArray: mainFolders];
+  mainFolders = [[NSArray arrayWithObjects:
+                           [self inboxFolderNameInContext: context],
+                         [self draftsFolderNameInContext: context],
+                         [self sentFolderNameInContext: context],
+                         [self trashFolderNameInContext: context],
+                         nil] stringsWithFormat: @"/%@"];
+  folderPaths = [NSMutableArray arrayWithArray: rawFolders];
+  [folderPaths removeObjectsInArray: mainFolders];
+  [folderPaths
+    sortUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
+  [folderPaths replaceObjectsInRange: NSMakeRange (0, 0)
+              withObjectsFromArray: mainFolders];
 
-  return newFolders;
+  return folderPaths;
 }
 
 /* IMAP4 */
@@ -268,74 +265,32 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default
 
 /* name lookup */
 
-- (id) lookupFolder: (NSString *) _key
-       ofClassNamed: (NSString *) _cn
-         inContext: (id) _cx
-{
-  Class clazz;
-  SOGoMailFolder *folder;
-
-  if ((clazz = NSClassFromString(_cn)) == Nil)
-    {
-      [self logWithFormat:@"ERROR: did not find class '%@' for key: '%@'", 
-           _cn, _key];
-      return [NSException exceptionWithHTTPStatus:500 /* server error */
-                         reason:@"did not find mail folder class!"];
-    }
-
-  folder = [clazz objectWithName: _key inContainer: self];
-
-  return folder;
-}
-
-- (id) lookupSentFolder: (NSString *) _key
-             inContext: (id) _ctx
-{
-  return [self lookupFolder: _key ofClassNamed: @"SOGoSentFolder" 
-              inContext: _ctx];
-}
-
-- (id) lookupDraftsFolder: (NSString *) _key
-               inContext: (id) _ctx
-{
-  return [self lookupFolder: _key ofClassNamed: @"SOGoDraftsFolder" 
-              inContext: _ctx];
-}
-
-- (id) lookupTrashFolder: (NSString *) _key
-              inContext: (id) _ctx
-{
-  return [self lookupFolder: _key ofClassNamed: @"SOGoTrashFolder" 
-              inContext: _ctx];
-}
-
-- (id) lookupFiltersFolder: (NSString *) _key inContext: (id) _ctx
-{
-  return [self lookupFolder:_key ofClassNamed:@"SOGoSieveScriptsFolder" 
-              inContext:_ctx];
-}
-
 - (id) lookupName: (NSString *) _key
        inContext: (id)_ctx
          acquire: (BOOL) _flag
 {
+  NSString *folderName;
+  Class klazz;
   id obj;
 
   if ([_key hasPrefix: @"folder"])
     {
-  // TODO: those should be product.plist bindings? (can't be class bindings
-  //       though because they are 'per-account')
-      if ([_key isEqualToString: [self sentFolderNameInContext: _ctx]])
-       obj = [self lookupSentFolder: _key inContext: _ctx];
-      else if ([_key isEqualToString: [self draftsFolderNameInContext: _ctx]])
-       obj = [self lookupDraftsFolder: _key inContext: _ctx];
-      else if ([_key isEqualToString: [self trashFolderNameInContext: _ctx]])
-       obj = [self lookupTrashFolder: _key inContext: _ctx];
-//       else if ([_key isEqualToString: [self sieveFolderNameInContext: _ctx]])
-//     obj = [self lookupFiltersFolder: _key inContext: _ctx];
+      folderName = [_key substringFromIndex: 6];
+      if ([folderName
+           isEqualToString: [self sentFolderNameInContext: _ctx]])
+       klazz = [SOGoSentFolder class];
+      else if ([folderName
+                isEqualToString: [self draftsFolderNameInContext: _ctx]])
+       klazz = [SOGoDraftsFolder class];
+      else if ([folderName
+                isEqualToString: [self trashFolderNameInContext: _ctx]])
+       klazz = [SOGoTrashFolder class];
+/*       else if ([folderName isEqualToString: [self sieveFolderNameInContext: _ctx]])
+        obj = [self lookupFiltersFolder: _key inContext: _ctx]; */
       else
-       obj = [self lookupFolder: _key ofClassNamed: @"SOGoMailFolder"
-                   inContext: _ctx];
+       klazz = [SOGoMailFolder class];
+
+      obj = [klazz objectWithName: _key inContainer: self];
     }
   else
     obj = [super lookupName: _key inContext: _ctx acquire: NO];
@@ -352,7 +307,7 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default
 - (NSString *) inboxFolderNameInContext: (id)_ctx
 {
   /* cannot be changed in Cyrus ? */
-  return [NSString stringWithFormat: @"folder%@", inboxFolderName];
+  return inboxFolderName;
 }
 
 - (NSString *) _userFolderNameWithPurpose: (NSString *) purpose
@@ -380,13 +335,13 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default
   if (!folderName)
     folderName = draftsFolderName;
 
-  return [NSString stringWithFormat: @"folder%@", folderName];
+  return folderName;
 }
 
-- (NSString *) sieveFolderNameInContext: (id) _ctx
-{
-  return [NSString stringWithFormat: @"folder%@", sieveFolderName];
-}
+// - (NSString *) sieveFolderNameInContext: (id) _ctx
+// {
+//   return sieveFolderName;
+// }
 
 - (NSString *) sentFolderNameInContext: (id)_ctx
 {
@@ -396,7 +351,7 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default
   if (!folderName)
     folderName = sentFolderName;
 
-  return [NSString stringWithFormat: @"folder%@", folderName];
+  return folderName;
 }
 
 - (NSString *) trashFolderNameInContext: (id)_ctx
@@ -407,7 +362,38 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default
   if (!folderName)
     folderName = trashFolderName;
 
-  return [NSString stringWithFormat: @"folder%@", folderName];
+  return folderName;
+}
+
+- (id) folderWithTraversal: (NSString *) traversal
+             andClassName: (NSString *) className
+{
+  NSArray *paths;
+  NSString *currentName;
+  id currentContainer;
+  unsigned int count, max;
+  Class clazz;
+
+  currentContainer = self;
+  paths = [traversal componentsSeparatedByString: @"/"];
+
+  if (!className)
+    clazz = [SOGoMailFolder class];
+  else
+    clazz = NSClassFromString (className);
+
+  max = [paths count];
+  for (count = 0; count < max - 1; count++)
+    {
+      currentName = [NSString stringWithFormat: @"folder%@",
+                             [paths objectAtIndex: count]];
+      currentContainer = [SOGoMailFolder objectWithName: currentName
+                                        inContainer: currentContainer];
+    }
+  currentName = [NSString stringWithFormat: @"folder%@",
+                         [paths objectAtIndex: max - 1]];
+
+  return [clazz objectWithName: currentName inContainer: currentContainer];
 }
 
 - (SOGoMailFolder *) inboxFolderInContext: (id) _ctx
@@ -415,8 +401,9 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default
   // TODO: use some profile to determine real location, use a -traverse lookup
   if (!inboxFolder)
     {
-      inboxFolder = [self lookupName: [self inboxFolderNameInContext: _ctx]
-                         inContext: _ctx acquire: NO];
+      inboxFolder
+       = [self folderWithTraversal: [self inboxFolderNameInContext: _ctx]
+               andClassName: nil];
       [inboxFolder retain];
     }
 
@@ -430,43 +417,36 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default
   if (!draftsFolder)
     {
       draftsFolder
-       = [self lookupName: [self draftsFolderNameInContext:_ctx]
-               inContext: _ctx acquire: NO];
-//       if (![draftsFolder isNotNull])
-//     draftsFolder = [NSException exceptionWithHTTPStatus: 404 /* not found */
-//                                 reason: @"did not find Drafts folder!"];
+       = [self folderWithTraversal: [self draftsFolderNameInContext: _ctx]
+               andClassName: @"SOGoDraftsFolder"];
       [draftsFolder retain];
     }
 
   return draftsFolder;
 }
 
-- (SOGoMailFolder *) sentFolderInContext: (id) _ctx
+- (SOGoSentFolder *) sentFolderInContext: (id) _ctx
 {
   // TODO: use some profile to determine real location, use a -traverse lookup
 
   if (!sentFolder)
     {
-      sentFolder = [self lookupName: [self sentFolderNameInContext:_ctx]
-                        inContext: _ctx acquire: NO];
-//       if (![sentFolder isNotNull])
-//     sentFolder = [NSException exceptionWithHTTPStatus: 404 /* not found */
-//                               reason: @"did not find Sent folder!"];
+      sentFolder
+       = [self folderWithTraversal: [self sentFolderNameInContext: _ctx]
+               andClassName: @"SOGoSentFolder"];
       [sentFolder retain];
     }
 
   return sentFolder;
 }
 
-- (SOGoMailFolder *) trashFolderInContext: (id) _ctx
+- (SOGoTrashFolder *) trashFolderInContext: (id) _ctx
 {
   if (!trashFolder)
     {
-      trashFolder = [self lookupName: [self trashFolderNameInContext: _ctx]
-                         inContext: _ctx acquire: NO];
-//       if (![trashFolder isNotNull])
-//     trashFolder = [NSException exceptionWithHTTPStatus: 404 /* not found */
-//                               reason: @"did not find Trash folder!"];
+      trashFolder
+       = [self folderWithTraversal: [self trashFolderNameInContext: _ctx]
+               andClassName: @"SOGoTrashFolder"];
       [trashFolder retain];
     }
 
index 60d6c22aead6abcccb09476682b133e5a87d531a..6feb888a78a57bbf124e75d7abb20cc1b539236b 100644 (file)
@@ -191,7 +191,10 @@ static BOOL debugOn = YES;
   NSMutableString *currentTraversal;
 
   currentTraversal = [container traversalFromMailAccount];
-  [currentTraversal appendFormat: @"/%@", [self relativeImap4Name]];
+  if ([container isKindOfClass: [SOGoMailAccount class]])
+    [currentTraversal appendString: [self relativeImap4Name]];
+  else
+    [currentTraversal appendFormat: @"/%@", [self relativeImap4Name]];
 
   return currentTraversal;
 }
index 15f5b660ba2a8036e0308e95183e259cec26238b..96be316136f8cf82b2adce845b5dcd705ea8fb3a 100644 (file)
@@ -299,10 +299,34 @@ static NSString *defaultUserID =  @"anyone";
        inContext: (id)_ctx
          acquire: (BOOL) _acquire
 {
+  NSString *folderName, *className;
+  SOGoMailAccount *mailAccount;
   id obj;
 
   if ([_key hasPrefix: @"folder"])
-    obj = [SOGoMailFolder objectWithName: _key inContainer: self];
+    {
+      mailAccount = [self mailAccountFolder];
+      folderName = [NSString stringWithFormat: @"%@/%@",
+                            [self traversalFromMailAccount],
+                            [_key substringFromIndex: 6]];
+      if ([folderName
+           isEqualToString: [mailAccount sentFolderNameInContext: _ctx]])
+       className = @"SOGoSentFolder";
+      else if ([folderName isEqualToString:
+                            [mailAccount draftsFolderNameInContext: _ctx]])
+       className = @"SOGoDraftsFolder";
+      else if ([folderName isEqualToString:
+                            [mailAccount trashFolderNameInContext: _ctx]])
+       className = @"SOGoTrashFolder";
+/*       else if ([folderName isEqualToString:
+        [mailAccount sieveFolderNameInContext: _ctx]])
+        obj = [self lookupFiltersFolder: _key inContext: _ctx]; */
+      else
+       className = @"SOGoMailFolder";
+
+      obj = [NSClassFromString (className)
+                              objectWithName: _key inContainer: self];
+    }
   else
     {
       if ([[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]])
@@ -394,22 +418,24 @@ static NSString *defaultUserID =  @"anyone";
 {
   // TODO: detect Trash/Sent/Drafts folders
   SOGoMailAccount *account;
-  NSString *n;
+  NSString *name;
 
-  if (folderType != nil)
-    return folderType;
-  
-  account = [self mailAccountFolder];
-  n = nameInContainer;
-
-  if ([n isEqualToString:[account trashFolderNameInContext:nil]])
-    folderType = @"IPF.Trash";
-  else if ([n isEqualToString:[account inboxFolderNameInContext:nil]])
-    folderType = @"IPF.Inbox";
-  else if ([n isEqualToString:[account sentFolderNameInContext:nil]])
-    folderType = @"IPF.Sent";
-  else
-    folderType = @"IPF.Folder";
+  if (!folderType)
+    {
+      account = [self mailAccountFolder];
+      name = [self traversalFromMailAccount];
+
+      if ([name isEqualToString: [account trashFolderNameInContext: nil]])
+       folderType = @"IPF.Trash";
+      else if ([name
+                isEqualToString: [account inboxFolderNameInContext: nil]])
+       folderType = @"IPF.Inbox";
+      else if ([name
+                isEqualToString: [account sentFolderNameInContext: nil]])
+       folderType = @"IPF.Sent";
+      else
+       folderType = @"IPF.Folder";
+    }
   
   return folderType;
 }
index 15743275f8b18aec223d748144ec8d0acb6039b7..39778f76fb1db69cb4a1cb16912cb3bd708c4d6c 100644 (file)
@@ -113,12 +113,10 @@ static NSString *uidColumnName = @"c_uid";
   EOAdaptorChannel *channel;
   NSDictionary *row;
   NSException *ex;
-  NSString *sql, *value;
+  NSString *sql, *value, *error;
   NSArray *attrs;
   BOOL rc;
-#if LIB_FOUNDATION_LIBRARY
   NSData *plistData;
-#endif
 
   rc = NO;
   
@@ -134,7 +132,6 @@ static NSString *uidColumnName = @"c_uid";
                      uidColumnName, [self uid]];
       
       [values release];
-      values = [NSMutableDictionary new];
 
       /* run SQL */
 
@@ -155,15 +152,13 @@ static NSString *uidColumnName = @"c_uid";
          value = [row objectForKey: fieldName];
          if ([value isNotNull])
            {
-#if LIB_FOUNDATION_LIBRARY
              plistData = [value dataUsingEncoding: NSUTF8StringEncoding];
-             [values setDictionary: [NSDeserializer
-                                      deserializePropertyListFromData: plistData
-                                      mutableContainers: YES]];
-
-#else
-             [values setDictionary: [value propertyList]];
-#endif
+             values
+               = [NSPropertyListSerialization propertyListFromData: plistData
+                                              mutabilityOption: NSPropertyListMutableContainers
+                                              format: NULL
+                                              errorDescription: &error];
+             [values retain];
            }
 
          ASSIGN (lastFetch, [NSCalendarDate date]);
@@ -180,22 +175,9 @@ static NSString *uidColumnName = @"c_uid";
   return rc;
 }
 
-- (NSString *) generateSQLForInsert
+- (NSString *) _serializedDefaults
 {
-  NSMutableString *sql;
-  NSString *serializedDefaults;
-
-#if LIB_FOUNDATION_LIBRARY
-  serializedDefaults = [values stringRepresentation];
-
-  sql = [NSString stringWithFormat: (@"INSERT INTO %@"
-                                    @"            (%@, %@)"
-                                    @"     VALUES ('%@', '%@')"),
-                 [[self tableURL] gcsTableName], uidColumnName, fieldName,
-                 [self uid],
-                 [serializedDefaults stringByReplacingString: @"'"
-                                     withString:@"''"]];
-#else
+  NSMutableString *serializedDefaults;
   NSData *serializedDefaultsData;
   NSString *error;
 
@@ -204,75 +186,57 @@ static NSString *uidColumnName = @"c_uid";
     = [NSPropertyListSerialization dataFromPropertyList: values
                                   format: NSPropertyListOpenStepFormat
                                   errorDescription: &error];
-
   if (error)
     {
-      sql = nil;
+      [self errorWithFormat: @"serializing the defaults: %@", error];
+      serializedDefaults = nil;
       [error release];
     }
   else
     {
-      serializedDefaults = [[NSString alloc] initWithData: serializedDefaultsData
-                                            encoding: NSUTF8StringEncoding];
-
-      sql = [NSString stringWithFormat: (@"INSERT INTO %@"
-                                        @"            (%@, %@)"
-                                        @"     VALUES ('%@', '%@')"),
-                     [[self tableURL] gcsTableName], uidColumnName, fieldName,
-                     [self uid],
-                     [serializedDefaults stringByReplacingString:@"'" withString:@"''"]];
-      [serializedDefaults release];
+      serializedDefaults
+       = [[NSMutableString alloc] initWithData: serializedDefaultsData
+                                  encoding: NSUTF8StringEncoding];
+      [serializedDefaults autorelease];
+      [serializedDefaults replaceString: @"\\" withString: @"\\\\"];
+      [serializedDefaults replaceString: @"'" withString: @"''"];
     }
-#endif
+
+  return serializedDefaults;
+}
+
+- (NSString *) generateSQLForInsert
+{
+  NSString *sql, *serializedDefaults;
+
+  serializedDefaults = [self _serializedDefaults];
+  if (serializedDefaults)
+    sql = [NSString stringWithFormat: (@"INSERT INTO %@"
+                                      @"            (%@, %@)"
+                                      @"     VALUES ('%@', '%@')"),
+                   [[self tableURL] gcsTableName], uidColumnName, fieldName,
+                   [self uid], serializedDefaults];
+  else
+    sql = nil;
 
   return sql;
 }
 
 - (NSString *) generateSQLForUpdate
 {
-  NSMutableString *sql;
-  NSString *serializedDefaults;
-
-#if LIB_FOUNDATION_LIBRARY
-  serializedDefaults = [values stringRepresentation];
-
-  sql = [NSString stringWithFormat: (@"UPDATE %@"
-                                    @"     SET %@ = '%@'"
-                                    @"   WHERE %@ = '%@'"),
-                 [[self tableURL] gcsTableName],
-                 fieldName,
-                 [serializedDefaults stringByReplacingString:@"'" withString:@"''"],
-                 uidColumnName, [self uid]];
-#else
-  NSData *serializedDefaultsData;
-  NSString *error;
-
-  error = nil;
-  serializedDefaultsData
-    = [NSPropertyListSerialization dataFromPropertyList: values
-                                  format: NSPropertyListOpenStepFormat
-                                  errorDescription: &error];
-  if (error)
-    {
-      sql = nil;
-      [error release];
-    }
+  NSString *sql, *serializedDefaults;
+
+  serializedDefaults = [self _serializedDefaults];
+  if (serializedDefaults)
+    sql = [NSString stringWithFormat: (@"UPDATE %@"
+                                      @"     SET %@ = '%@'"
+                                      @"   WHERE %@ = '%@'"),
+                   [[self tableURL] gcsTableName],
+                   fieldName,
+                   serializedDefaults,
+                   uidColumnName, [self uid]];
   else
-    {
-      serializedDefaults = [[NSString alloc] initWithData: serializedDefaultsData
-                                            encoding: NSUTF8StringEncoding];
-
-      sql = [NSString stringWithFormat: (@"UPDATE %@"
-                                        @"     SET %@ = '%@'"
-                                        @"   WHERE %@ = '%@'"),
-                     [[self tableURL] gcsTableName],
-                     fieldName,
-                     [serializedDefaults stringByReplacingString: @"'"
-                                         withString: @"''"],
-                     uidColumnName, [self uid]];
-      [serializedDefaults release];
-    }
-#endif
+    sql = nil;
 
   return sql;
 }
index 5bf7ababf97069fea3d0b282ce959939edafb292..d3d7eb06ad4d2a6bf05879b68a211a428c814564 100644 (file)
 "Please select only one message to print." = "Please select only one message to print.";
 
 "You need to choose a non-virtual folder!" = "You need to choose a non-virtual folder!";
-"You need to choose a root subfolder!" = "You need to choose a root subfolder!";
 
 "Moving a message into its own folder is impossible!"
 = "Moving a message into its own folder is impossible!";
index 6f9acb86b7ec50c9690cc8787e53779e2113e4f2..a818ceb0a54ac92da07c2f11234bd58614a4080a 100644 (file)
 "Please select only one message to print." = "Veuillez ne sélectionner qu'un seul message à imprimer.";
 
 "You need to choose a non-virtual folder!" = "Vous devez choisir un dossier non-virtuel.";
-"You need to choose a root subfolder!" = "Vous devez choisir un sous-dossier de la racine.";
 
 "Moving a message into its own folder is impossible!"
 = "Le déplacement d'un message dans son propre dossier est impossible.";
index 4f5f989005ad12e7e043fe08c0d479f54f945af7..4dd0652b303ec99291795b4e41e9528e0d6d19df 100644 (file)
 "Please select only one message to print." = "Bitte wählen Sie nur eine Nachricht zum Drucken aus.";
 
 "You need to choose a non-virtual folder!" = "You need to choose a non-virtual folder!";
-"You need to choose a root subfolder!" = "You need to choose a root subfolder!";
 
 "Moving a message into its own folder is impossible!"
 = "Moving a message into its own folder is impossible!";
index e6c84f7d0cf0f408cbc7feee0dfabec8c2a18a3c..f06d7fd12c4982ff18be8fdf0114ae066e0c8c0f 100644 (file)
@@ -29,7 +29,8 @@
 
 @interface UIxMailAccountActions : WODirectAction
 {
-  NSString *draftFolderName;
+  NSString *inboxFolderName;
+  NSString *draftsFolderName;
   NSString *sentFolderName;
   NSString *trashFolderName;
 }
index 7f3a66cb3f19639d5d46541c6afeed8811c4b11e..f9d4d2b82dc7e427f1e9fcf2a8fe0055690bfe6d 100644 (file)
@@ -31,6 +31,7 @@
 #import <SoObjects/Mailer/SOGoMailAccount.h>
 #import <SoObjects/Mailer/SOGoDraftObject.h>
 #import <SoObjects/Mailer/SOGoDraftsFolder.h>
+#import <SoObjects/SOGo/NSArray+Utilities.h>
 #import <SoObjects/SOGo/NSObject+Utilities.h>
 #import <SoObjects/SOGo/NSString+Utilities.h>
 
 
 @implementation UIxMailAccountActions
 
-- (NSString *) _folderType: (NSString *) baseName
+- (id) init
+{
+  if ((self = [super init]))
+    {
+      inboxFolderName = nil;
+      draftsFolderName = nil;
+      sentFolderName = nil;
+      trashFolderName = nil;
+    }
+
+  return self;
+}
+
+- (void) dealloc
+{
+  [inboxFolderName release];
+  [draftsFolderName release];
+  [sentFolderName release];
+  [trashFolderName release];
+  [super dealloc];
+}
+
+- (NSString *) _folderType: (NSString *) folderName
 {
   NSString *folderType;
+  SOGoMailAccount *co;
+  NSArray *specialFolders;
 
-  if ([baseName isEqualToString: @"INBOX"])
+  if (!inboxFolderName)
+    {
+      co = [self clientObject];
+      specialFolders = [[NSArray arrayWithObjects:
+                                  [co inboxFolderNameInContext: context],
+                                [co draftsFolderNameInContext: context],
+                                [co sentFolderNameInContext: context],
+                                [co trashFolderNameInContext: context],
+                                nil] stringsWithFormat: @"/%@"];
+      ASSIGN (inboxFolderName, [specialFolders objectAtIndex: 0]);
+      ASSIGN (draftsFolderName, [specialFolders objectAtIndex: 1]);
+      ASSIGN (sentFolderName, [specialFolders objectAtIndex: 2]);
+      ASSIGN (trashFolderName, [specialFolders objectAtIndex: 3]);
+    }
+
+  if ([folderName isEqualToString: inboxFolderName])
     folderType = @"inbox";
-  else if ([baseName isEqualToString: draftFolderName])
+  else if ([folderName isEqualToString: draftsFolderName])
     folderType = @"draft";
-  else if ([baseName isEqualToString: sentFolderName])
+  else if ([folderName isEqualToString: sentFolderName])
     folderType = @"sent";
-  else if ([baseName isEqualToString: trashFolderName])
+  else if ([folderName isEqualToString: trashFolderName])
     folderType = @"trash";
   else
     folderType = @"folder";
   return folderType;
 }
 
-- (NSDictionary *) _lineForFolder: (NSString *) folder
-{
-  NSArray *parts;
-  NSMutableDictionary *folderData;
-  NSString *baseName;
-
-  folderData = [NSMutableDictionary dictionary];
-  parts = [folder componentsSeparatedByString: @"/"];
-  baseName = [parts lastObject];
-  [folderData setObject: folder forKey: @"path"];
-  [folderData setObject: [self _folderType: baseName]
-             forKey: @"type"];
-
-  return folderData;
-}
-
 - (NSArray *) _jsonFolders: (NSEnumerator *) rawFolders
 {
   NSMutableArray *folders;
   NSString *currentFolder;
+  NSDictionary *folderData;
 
   folders = [NSMutableArray array];
-
-  currentFolder = [rawFolders nextObject];
-  while (currentFolder)
+  while ((currentFolder = [rawFolders nextObject]))
     {
-      [folders addObject: [self _lineForFolder: currentFolder]];
-      currentFolder = [rawFolders nextObject];
+      folderData = [NSDictionary dictionaryWithObjectsAndKeys:
+                                  currentFolder, @"path",
+                                [self _folderType: currentFolder], @"type",
+                                nil];
+      [folders addObject: folderData];
     }
 
   return folders;
 - (WOResponse *) listMailboxesAction
 {
   SOGoMailAccount *co;
-  NSArray *rawFolders, *folders;
+  NSEnumerator *rawFolders;
+  NSArray *folders;
   WOResponse *response;
 
   co = [self clientObject];
-  draftFolderName = [[co draftsFolderNameInContext: context]
-                     substringFromIndex: 6];
-  sentFolderName = [[co sentFolderNameInContext: context]
-                    substringFromIndex: 6];
-  trashFolderName = [[co trashFolderNameInContext: context]
-                     substringFromIndex: 6];
-
-  rawFolders = [co allFolderPaths];
-  folders = [self _jsonFolders: [rawFolders objectEnumerator]];
+
+  rawFolders = [[co allFolderPaths] objectEnumerator];
+  folders = [self _jsonFolders: rawFolders];
 
   response = [self responseWithStatus: 200];
   [response setHeader: @"text/plain; charset=utf-8"
index c78fade8b4cb95a61f6522c9d0083261e3fffa7e..c80cc99b423da168e4c48ea46bf49de32a2819d7 100644 (file)
   trashFolderName
     = [[co mailAccountFolder] trashFolderNameInContext: context];
   path = [NSString stringWithFormat: @"/%@/%@",
-                  [trashFolderName substringFromIndex: 6], folderName];
+                  trashFolderName, folderName];
   destURL = [[NSURL alloc] initWithScheme: [srcURL scheme]
                           host: [srcURL host] path: path];
   [destURL autorelease];
          [mailSettings autorelease];
        }
       [ud setObject: mailSettings forKey: @"Mail"];
-      [mailSettings setObject: [co relativeImap4Name]
+      [mailSettings setObject: [co traversalFromMailAccount]
                    forKey: [NSString stringWithFormat: @"%@Folder",
                                      purpose]];
       [ud synchronize];
index 9c4ba4bdbc4c5c755c8d6e34a34f6a14ec5b78a7..adbf3bbd49d546441c00eeb437b9a92dc3d72e30 100644 (file)
@@ -1393,13 +1393,8 @@ function _onMenuChangeToXXXFolder(event, folder) {
     window.alert(labels["You need to choose a non-virtual folder!"]);
   else {
     var folderID = document.menuTarget.getAttribute("dataname");
-    var number = folderID.split("/").length;
-    if (number > 3)
-      window.alert(labels["You need to choose a root subfolder!"]);
-    else {
-      var urlstr = URLForFolderID(folderID) + "/setAs" + folder + "Folder";
-      triggerAjaxRequest(urlstr, folderOperationCallback);
-    }
+    var urlstr = URLForFolderID(folderID) + "/setAs" + folder + "Folder";
+    triggerAjaxRequest(urlstr, folderOperationCallback);
   }
 }