]> err.no Git - scalable-opengroupware.org/commitdiff
added SOGoMailManager object
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 28 Sep 2004 14:17:13 +0000 (14:17 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 28 Sep 2004 14:17:13 +0000 (14:17 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@325 d1b88da0-ebda-0310-925b-ed51d893ca5b

19 files changed:
SOGo/SoObjects/Mailer/ChangeLog
SOGo/SoObjects/Mailer/GNUmakefile
SOGo/SoObjects/Mailer/SOGoMailBaseObject.h
SOGo/SoObjects/Mailer/SOGoMailBaseObject.m
SOGo/SoObjects/Mailer/SOGoMailFolder.m
SOGo/SoObjects/Mailer/SOGoMailManager.h [new file with mode: 0644]
SOGo/SoObjects/Mailer/SOGoMailManager.m [new file with mode: 0644]
SOGo/SoObjects/Mailer/Version
SOGo/UI/Mailer/Images/tbtv_account_17x17.gif [new file with mode: 0644]
SOGo/UI/Mailer/Images/tbtv_drafts_17x17.gif [new file with mode: 0644]
SOGo/UI/Mailer/Images/tbtv_inbox_17x17.gif [new file with mode: 0644]
SOGo/UI/Mailer/Images/tbtv_junction2_17x17.gif [new file with mode: 0644]
SOGo/UI/Mailer/Images/tbtv_junction_17x17.gif [new file with mode: 0644]
SOGo/UI/Mailer/Images/tbtv_leaf_corner_17x17.gif [new file with mode: 0644]
SOGo/UI/Mailer/Images/tbtv_line_17x17.gif [new file with mode: 0644]
SOGo/UI/Mailer/Images/tbtv_minus_17x17.gif [new file with mode: 0644]
SOGo/UI/Mailer/Images/tbtv_plus_17x17.gif [new file with mode: 0644]
SOGo/UI/Mailer/Images/tbtv_sent_17x17.gif [new file with mode: 0644]
SOGo/UI/Mailer/Images/tbtv_trash_17x17.gif [new file with mode: 0644]

index ee2ccf2dec2e915b8559293081a1412d1a2d8151..87a3e750ff74adf216ea298fa85a518742020bfc 100644 (file)
@@ -1,4 +1,12 @@
 2004-09-28  Helge Hess  <helge.hess@opengroupware.org>
+       
+       * v0.9.9
+       
+       * SOGoMailBaseObject.m: added -mailManager method to retrieve the
+         mail manager object for a folder/mail/account
+
+       * added SOGoMailManager class, will probably be moved to SOGoLogic
+         in the long run
 
        * SOGoMailBaseObject.m, SOGoMailAccount.m: added -mailAccountFolder
          method to find the active root folder along the SOPE chain (v0.9.8)
index b14a2948dc41661b2a57827b24f9a05dfcc96fab..f033de565c14bd1eda1934030303fd8cd5750e79 100644 (file)
@@ -8,7 +8,9 @@ Mailer_PRINCIPAL_CLASS = SOGoMailerProduct
 
 Mailer_OBJC_FILES += \
        Product.m               \
-                               \
+       \
+       SOGoMailManager.m       \
+       \
        SOGoMailBaseObject.m    \
        SOGoMailAccounts.m      \
        SOGoMailAccount.m       \
index e5d5007001a2f862da1778ed8666e7ab875a0900..5ca0a908ef9d4d7bce4bc21dc3a9fb5f76d74d8f 100644 (file)
@@ -33,6 +33,7 @@
 
 @class NSURL;
 @class NGImap4Client;
+@class SOGoMailManager;
 @class SOGoMailAccount;
 
 @interface SOGoMailBaseObject : SOGoObject
@@ -48,7 +49,9 @@
 
 /* IMAP4 */
 
+- (SOGoMailManager *)mailManager;
 - (NSURL *)imap4URL;
+- (NSString *)imap4Password;
 - (NSString *)imap4FolderName;
 - (NGImap4Client *)imap4Client;
 
index 589d063b64e9d7dad0248e346363f9a1e6e521a0..3eac2157b55c7d23508f344688fc4eb59876bafe 100644 (file)
@@ -21,6 +21,7 @@
 // $Id$
 
 #include "SOGoMailBaseObject.h"
+#include "SOGoMailManager.h"
 #include "common.h"
 #include <NGExtensions/NSURL+misc.h>
 
 
 /* IMAP4 */
 
+- (SOGoMailManager *)mailManager {
+  return [SOGoMailManager defaultMailManager];
+}
+
 - (NSString *)relativeImap4Name {
   [self logWithFormat:@"WARNING: subclass should override %@", 
          NSStringFromSelector(_cmd)];
   return self->imap4URL;
 }
 
-- (NSString *)imap4Separator {
-  return @".";
-}
-
 - (NSString *)imap4FolderName {
-  /* a bit hackish, but should be OK */
-  NSString *folderName;
-  
-  folderName = [[self imap4URL] path];
-  if ([folderName length] == 0)
-    return nil;
-  if ([folderName characterAtIndex:0] == '/')
-    folderName = [folderName substringFromIndex:1];
-  
-  [self logWithFormat:@"FOLDER: %@", folderName];
-  return [[folderName pathComponents] componentsJoinedByString:
-                                       [self imap4Separator]];
+  return [[self mailManager] imap4FolderNameForURL:[self imap4URL]];
 }
 
 - (NSString *)imap4Password {
 }
 
 - (NGImap4Client *)imap4ClientForURL:(NSURL *)_url password:(NSString *)_pwd {
-  // TODO: move to some global IMAP4 connection pool manager
-  NGImap4Client *client;
-  NSDictionary  *result;
-  
-  if (_url == nil)
-    return nil;
-  
-  if ((client = [NGImap4Client clientWithURL:_url]) == nil)
-    return nil;
-  
-  result = [client login:[_url user] password:_pwd];
-  if (![[result valueForKey:@"result"] boolValue]) {
-    [self logWithFormat:@"ERROR: IMAP4 login failed!"];
-    return nil;
-  }
-  
-  return client;
+  return [[self mailManager] imap4ClientForURL:_url password:_pwd];
 }
 
 - (NGImap4Client *)imap4Client {
index f26d4c892d02428dd58b7a519616b4795f962b21..9f8d20c2944c6b6bbda92e497a0b94daa8e0149f 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "SOGoMailFolder.h"
 #include "SOGoMailObject.h"
+#include "SOGoMailManager.h"
 #include "common.h"
 
 @implementation SOGoMailFolder
 
 /* listing the available folders */
 
-- (NSArray *)_getDirectChildren:(NSArray *)_array folderName:(NSString *)_fn {
-  // TODO: we should get the full list of folders _once_ and work on that
-  //       (we could cache it in the context)
-  NSMutableArray *ma;
-  unsigned i, count, prefixlen;
-  
-  if ((count = [_array count]) < 2)
-    /* one entry is the folder itself, so we need at least two */
-    return [NSArray array];
-  
-  prefixlen = [_fn length] + 1;
-  ma = [NSMutableArray arrayWithCapacity:count];
-  for (i = 0; i < count; i++) {
-    NSString *p;
-    
-    p = [_array objectAtIndex:i];
-    if ([p length] <= prefixlen)
-      continue;
-    p = [p substringFromIndex:prefixlen];
-    
-    if ([p rangeOfString:@"/"].length > 0)
-      continue;
-    
-    [ma addObject:p];
-  }
-  
-  [ma sortUsingSelector:@selector(compare:)];
-  return ma;
-}
-
 - (NSArray *)toManyRelationshipKeys {
-  // TODO
-  NGImap4Client *client;
-  NSDictionary  *result;
-  NSString      *folderName;
-  
-  if ((client = [self imap4Client]) == nil)
-    return nil;
-  
-  folderName = [self imap4FolderName];
-  
-  /* maybe we want to use a cache over here */
-  result = [client list:folderName pattern:@"*"];
-  if (![[result valueForKey:@"result"] boolValue]) {
-    [self logWithFormat:@"ERROR: listing of folder failed!"];
-    return nil;
-  }
-  
-  /* extract list */
-  result = [result valueForKey:@"list"];
-  return [self _getDirectChildren:[result allKeys] folderName:folderName];
+  return [[self mailManager] subfoldersForURL:[self imap4URL] 
+                            password:[self imap4Password]];
 }
 
 /* name lookup */
diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.h b/SOGo/SoObjects/Mailer/SOGoMailManager.h
new file mode 100644 (file)
index 0000000..4fa50e5
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+  Copyright (C) 2004 SKYRIX Software AG
+
+  This file is part of OpenGroupware.org.
+
+  OGo is free software; you can redistribute it and/or modify it under
+  the terms of the GNU Lesser General Public License as published by the
+  Free Software Foundation; either version 2, or (at your option) any
+  later version.
+
+  OGo 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 Lesser General Public
+  License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with OGo; see the file COPYING.  If not, write to the
+  Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+  02111-1307, USA.
+*/
+
+#ifndef __Mailer_SOGoMailManager_H__
+#define __Mailer_SOGoMailManager_H__
+
+#import <Foundation/NSObject.h>
+
+/*
+  SOGoMailManager
+  
+  Coordinates access to IMAP4 mailboxes, caches folder hierarchies, etc.
+*/
+
+@class NSString, NSURL, NSArray;
+@class NGImap4Client;
+
+@interface SOGoMailManager : NSObject
+{
+}
+
++ (id)defaultMailManager;
+
+/* client object */
+
+- (NGImap4Client *)imap4ClientForURL:(NSURL *)_url password:(NSString *)_pwd;
+
+/* folder hierarchy */
+
+- (NSString *)imap4Separator;
+- (NSString *)imap4FolderNameForURL:(NSURL *)_url;
+- (NSArray *)subfoldersForURL:(NSURL *)_url password:(NSString *)_pwd;
+
+@end
+
+#endif /* __Mailer_SOGoMailManager_H__ */
diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.m b/SOGo/SoObjects/Mailer/SOGoMailManager.m
new file mode 100644 (file)
index 0000000..00b0cc4
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+  Copyright (C) 2004 SKYRIX Software AG
+
+  This file is part of OpenGroupware.org.
+
+  OGo is free software; you can redistribute it and/or modify it under
+  the terms of the GNU Lesser General Public License as published by the
+  Free Software Foundation; either version 2, or (at your option) any
+  later version.
+
+  OGo 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 Lesser General Public
+  License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with OGo; see the file COPYING.  If not, write to the
+  Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+  02111-1307, USA.
+*/
+
+#include "SOGoMailManager.h"
+#include "common.h"
+
+@implementation SOGoMailManager
+
+static BOOL debugOn = YES;
+
++ (id)defaultMailManager {
+  static SOGoMailManager *manager = nil; // THREAD
+  if (manager == nil) 
+    manager = [[self alloc] init];
+  return manager;
+}
+
+- (void)dealloc {
+  [super dealloc];
+}
+
+/* client object */
+
+- (NGImap4Client *)imap4ClientForURL:(NSURL *)_url password:(NSString *)_pwd {
+  // TODO: move to some global IMAP4 connection pool manager
+  NGImap4Client *client;
+  NSDictionary  *result;
+  
+  if (_url == nil)
+    return nil;
+  
+  if ((client = [NGImap4Client clientWithURL:_url]) == nil)
+    return nil;
+  
+  result = [client login:[_url user] password:_pwd];
+  if (![[result valueForKey:@"result"] boolValue]) {
+    [self logWithFormat:@"ERROR: IMAP4 login failed!"];
+    return nil;
+  }
+  
+  return client;
+}
+
+/* folder hierarchy */
+
+- (NSArray *)_getDirectChildren:(NSArray *)_array folderName:(NSString *)_fn {
+  // TODO: we should get the full list of folders _once_ and work on that
+  //       (we could cache it in the context)
+  NSMutableArray *ma;
+  unsigned i, count, prefixlen;
+  
+  if ((count = [_array count]) < 2)
+    /* one entry is the folder itself, so we need at least two */
+    return [NSArray array];
+  
+  prefixlen = [_fn length] + 1;
+  ma = [NSMutableArray arrayWithCapacity:count];
+  for (i = 0; i < count; i++) {
+    NSString *p;
+    
+    p = [_array objectAtIndex:i];
+    if ([p length] <= prefixlen)
+      continue;
+    p = [p substringFromIndex:prefixlen];
+    
+    if ([p rangeOfString:@"/"].length > 0)
+      continue;
+    
+    [ma addObject:p];
+  }
+  
+  [ma sortUsingSelector:@selector(compare:)];
+  return ma;
+}
+
+- (NSString *)imap4Separator {
+  return @".";
+}
+
+- (NSString *)imap4FolderNameForURL:(NSURL *)_url {
+  /* a bit hackish, but should be OK */
+  NSString *folderName;
+
+  if (_url == nil)
+    return nil;
+  
+  folderName = [_url path];
+  if ([folderName length] == 0)
+    return nil;
+  if ([folderName characterAtIndex:0] == '/')
+    folderName = [folderName substringFromIndex:1];
+  
+  return [[folderName pathComponents] componentsJoinedByString:
+                                       [self imap4Separator]];
+}
+
+- (NSArray *)subfoldersForURL:(NSURL *)_url password:(NSString *)_pwd {
+  // TODO: add caching
+  NGImap4Client *client;
+  NSDictionary  *result;
+  NSString      *folderName;
+  
+  if ((client = [self imap4ClientForURL:_url password:_pwd]) == nil)
+    return nil;
+  
+  folderName = [self imap4FolderNameForURL:_url];
+  
+  /* maybe we want to use a cache over here */
+  result = [client list:folderName pattern:@"*"];
+  if (![[result valueForKey:@"result"] boolValue]) {
+    [self logWithFormat:@"ERROR: listing of folder failed!"];
+    return nil;
+  }
+  
+  /* extract list */
+  result = [result valueForKey:@"list"];
+  return [self _getDirectChildren:[result allKeys] folderName:folderName];
+}
+
+/* debugging */
+
+- (BOOL)isDebuggingEnabled {
+  return debugOn;
+}
+
+@end /* SOGoMailManager */
index 28292b549059af8a6800e33ac74ed5ab727067ed..81be7eb6e79defb0b93e0ca78f8a44c310c033c2 100644 (file)
@@ -1,3 +1,3 @@
 # $Id$
 
-SUBMINOR_VERSION:=8
+SUBMINOR_VERSION:=9
diff --git a/SOGo/UI/Mailer/Images/tbtv_account_17x17.gif b/SOGo/UI/Mailer/Images/tbtv_account_17x17.gif
new file mode 100644 (file)
index 0000000..fbbdd1e
Binary files /dev/null and b/SOGo/UI/Mailer/Images/tbtv_account_17x17.gif differ
diff --git a/SOGo/UI/Mailer/Images/tbtv_drafts_17x17.gif b/SOGo/UI/Mailer/Images/tbtv_drafts_17x17.gif
new file mode 100644 (file)
index 0000000..c6a82e6
Binary files /dev/null and b/SOGo/UI/Mailer/Images/tbtv_drafts_17x17.gif differ
diff --git a/SOGo/UI/Mailer/Images/tbtv_inbox_17x17.gif b/SOGo/UI/Mailer/Images/tbtv_inbox_17x17.gif
new file mode 100644 (file)
index 0000000..745709d
Binary files /dev/null and b/SOGo/UI/Mailer/Images/tbtv_inbox_17x17.gif differ
diff --git a/SOGo/UI/Mailer/Images/tbtv_junction2_17x17.gif b/SOGo/UI/Mailer/Images/tbtv_junction2_17x17.gif
new file mode 100644 (file)
index 0000000..f3c2270
Binary files /dev/null and b/SOGo/UI/Mailer/Images/tbtv_junction2_17x17.gif differ
diff --git a/SOGo/UI/Mailer/Images/tbtv_junction_17x17.gif b/SOGo/UI/Mailer/Images/tbtv_junction_17x17.gif
new file mode 100644 (file)
index 0000000..3c55552
Binary files /dev/null and b/SOGo/UI/Mailer/Images/tbtv_junction_17x17.gif differ
diff --git a/SOGo/UI/Mailer/Images/tbtv_leaf_corner_17x17.gif b/SOGo/UI/Mailer/Images/tbtv_leaf_corner_17x17.gif
new file mode 100644 (file)
index 0000000..33c9708
Binary files /dev/null and b/SOGo/UI/Mailer/Images/tbtv_leaf_corner_17x17.gif differ
diff --git a/SOGo/UI/Mailer/Images/tbtv_line_17x17.gif b/SOGo/UI/Mailer/Images/tbtv_line_17x17.gif
new file mode 100644 (file)
index 0000000..962791f
Binary files /dev/null and b/SOGo/UI/Mailer/Images/tbtv_line_17x17.gif differ
diff --git a/SOGo/UI/Mailer/Images/tbtv_minus_17x17.gif b/SOGo/UI/Mailer/Images/tbtv_minus_17x17.gif
new file mode 100644 (file)
index 0000000..ca17de6
Binary files /dev/null and b/SOGo/UI/Mailer/Images/tbtv_minus_17x17.gif differ
diff --git a/SOGo/UI/Mailer/Images/tbtv_plus_17x17.gif b/SOGo/UI/Mailer/Images/tbtv_plus_17x17.gif
new file mode 100644 (file)
index 0000000..21eb597
Binary files /dev/null and b/SOGo/UI/Mailer/Images/tbtv_plus_17x17.gif differ
diff --git a/SOGo/UI/Mailer/Images/tbtv_sent_17x17.gif b/SOGo/UI/Mailer/Images/tbtv_sent_17x17.gif
new file mode 100644 (file)
index 0000000..aabe79a
Binary files /dev/null and b/SOGo/UI/Mailer/Images/tbtv_sent_17x17.gif differ
diff --git a/SOGo/UI/Mailer/Images/tbtv_trash_17x17.gif b/SOGo/UI/Mailer/Images/tbtv_trash_17x17.gif
new file mode 100644 (file)
index 0000000..da3c01a
Binary files /dev/null and b/SOGo/UI/Mailer/Images/tbtv_trash_17x17.gif differ