]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@83 d1b88da0-ebda-0310-925b-ed51d8...
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 29 Jun 2004 21:37:27 +0000 (21:37 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 29 Jun 2004 21:37:27 +0000 (21:37 +0000)
OGoContentStore/GNUmakefile
OGoContentStore/GNUmakefile.preamble
OGoContentStore/OCSFolder.h
OGoContentStore/OCSFolder.m
OGoContentStore/OCSFolderManager.m
OGoContentStore/misc/icaltest.ical [new file with mode: 0644]
OGoContentStore/ocs_cat.m [new file with mode: 0644]
OGoContentStore/sql/testapt-hh.psql [new file with mode: 0644]

index dc7ed786150f29b20b6f7b6fa6acac16bc4a44b6..90983adba12bdc5695e070bb312998a1da17b697 100644 (file)
@@ -4,7 +4,7 @@ include $(GNUSTEP_MAKEFILES)/common.make
 include ./Version
 
 LIBRARY_NAME = libOGoContentStore
-TOOL_NAME = ocs_ls ocs_mkdir
+TOOL_NAME = ocs_ls ocs_mkdir ocs_cat
 
 libOGoContentStore_HEADER_FILES += \
        NSURL+OCS.h             \
@@ -30,6 +30,7 @@ libOGoContentStore_OBJC_FILES += \
 
 ocs_ls_OBJC_FILES    += ocs_ls.m
 ocs_mkdir_OBJC_FILES += ocs_mkdir.m
+ocs_cat_OBJC_FILES   += ocs_cat.m
 
 -include GNUmakefile.preamble
 include $(GNUSTEP_MAKEFILES)/library.make
index 176803b0fecdd5830abde76afda0dbda7712f30d..39f119faafec74460a9149e704a3c31bd6e8303f 100644 (file)
@@ -11,6 +11,7 @@ OCS_TOOL_LIBS += \
 
 ocs_ls_TOOL_LIBS    += $(OCS_TOOL_LIBS)
 ocs_mkdir_TOOL_LIBS += $(OCS_TOOL_LIBS)
+ocs_cat_TOOL_LIBS   += $(OCS_TOOL_LIBS)
 
 ADDITIONAL_INCLUDE_DIRS += -I. -I..
 
index db7c90a2d2fa8499f7da2df74a1b2deaf1f7c637..abf361433f3e255e0567b864090220ab2590ad6f 100644 (file)
@@ -76,6 +76,8 @@
 - (NSArray *)subFolderNames;
 - (NSArray *)allSubFolderNames;
 
+- (NSString *)fetchContentWithName:(NSString *)_name;
+
 @end
 
 #endif /* __OGoContentStore_OCSFolder_H__ */
index 2bde8671bec7f8eb4eb11c57d81267beef37df82..1879528224a89cc13362a37b4862ccf6327965bb 100644 (file)
@@ -145,6 +145,52 @@ static BOOL debugOn = YES;
                               recursive:YES];
 }
 
+- (NSString *)fetchContentWithName:(NSString *)_name {
+  EOAdaptorChannel *channel;
+  NSException  *error;
+  NSDictionary *row;
+  NSArray      *attrs;
+  NSString     *result;
+  NSString     *sql;
+  
+  if ((channel = [self acquireStoreChannel]) == nil) {
+    [self logWithFormat:@"ERROR(%s): could not open storage channel!"];
+    return nil;
+  }
+  
+  /* generate SQL */
+  
+  sql = @"SELECT \"c_content\" FROM ";
+  sql = [sql stringByAppendingString:[self storeTableName]];
+  sql = [sql stringByAppendingString:@" WHERE \"c_name\" = '"];
+  sql = [sql stringByAppendingString:_name];
+  sql = [sql stringByAppendingString:@"'"];
+  
+  /* run SQL */
+
+  if ((error = [channel evaluateExpressionX:sql]) != nil) {
+    [self logWithFormat:@"ERROR(%s): cannot execute blob-fetch SQL '%@': %@", 
+           __PRETTY_FUNCTION__, sql, error];
+    [self releaseChannel:channel];
+    return nil;
+  }
+  
+  /* fetch results */
+  
+  result = nil;
+  attrs  = [channel describeResults];
+  if ((row = [channel fetchAttributes:attrs withZone:NULL]) != nil) {
+    result = [[[row objectForKey:@"cContent"] copy] autorelease];
+    if (![result isNotNull]) result = nil;
+    [channel cancelFetch];
+  }
+  
+  /* release and return result */
+  
+  [self releaseChannel:channel];
+  return result;
+}
+
 /* description */
 
 - (NSString *)description {
index 27604255f73c3844b91ef1857701d7d17e00bee7..cb1cb3ac1eee9508895f5d2a9f694c6eed2d328f 100644 (file)
@@ -167,7 +167,9 @@ static const char *OCSPathColumnPattern     = "c_path%i";
   
   /* run SQL */
   
-  if ((ex = [channel evaluateExpressionX:_sql])) {
+  if ((ex = [channel evaluateExpressionX:_sql]) != nil) {
+    [self logWithFormat:@"ERROR(%s): cannot execute SQL '%@': %@", 
+           __PRETTY_FUNCTION__, _sql, ex];
     [self releaseChannel:channel];
     return nil;
   }
@@ -176,7 +178,7 @@ static const char *OCSPathColumnPattern     = "c_path%i";
   
   attrs = [channel describeResults];
   rows = [NSMutableArray arrayWithCapacity:16];
-  while ((row = [channel fetchAttributes:attrs withZone:NULL]))
+  while ((row = [channel fetchAttributes:attrs withZone:NULL]) != nil)
     [rows addObject:row];
   
   [self releaseChannel:channel];
diff --git a/OGoContentStore/misc/icaltest.ical b/OGoContentStore/misc/icaltest.ical
new file mode 100644 (file)
index 0000000..d048821
--- /dev/null
@@ -0,0 +1,30 @@
+BEGIN:VEVENT\r
+DURATION:PT1H\r
+ATTENDEE;CN="Elke Bethke";DIR="addressbook://B156F3F0-9CFD-11D8-8561-000\r
+ D93C1A604:ABPerson":mailto:E.Bethke@Sachsen-Anhalt-Lotto.de\r
+ATTENDEE;CN="Erik Doernenburg";DIR="addressbook://B15FCB0F-9CFD-11D8-8561\r
+ -000D93C1A604:ABPerson":mailto:erik@x101.net\r
+ATTENDEE;CN="Christian Schnelle";DIR="addressbook://B1418D4E-9CFD-11D8-8\r
+ 561-000D93C1A604:ABPerson":mailto:cs@enervation.de\r
+ATTENDEE;CN="Chris Herrenberger";DIR="addressbook://B14A390C-9CFD-11D8-8\r
+ 561-000D93C1A604:ABPerson":invalid:nomail\r
+ATTENDEE;CN="Horst Parplies";DIR="addressbook://B19B47E5-9CFD-11D8-8561-\r
+ 000D93C1A604:ABPerson":mailto:horst.parplies@freenet.de\r
+ATTENDEE;CN="Imdat Solak";DIR="addressbook://B19EDB62-9CFD-11D8-8561-000\r
+ D93C1A604:ABPerson":mailto:imdat@solak.de\r
+ATTENDEE;CN="Jens Enders";DIR="addressbook://B1B6819F-9CFD-11D8-8561-000\r
+ D93C1A604:ABPerson":mailto:jens.enders@skyrix.com\r
+ATTENDEE;CN="Jens Muenster";DIR="addressbook://B1BBA42E-9CFD-11D8-8561-00\r
+ 0D93C1A604:ABPerson":mailto:jens.muenster@skyrix.com\r
+ATTENDEE;CN="Laurent Pierre";DIR="addressbook://9337C270-A825-11D8-B930-\r
+ 000D93C1A604:ABPerson":mailto:laurent.pierre@linagora.com\r
+ATTENDEE;CN="Marcel Weiher";DIR="addressbook://B1F9BB12-9CFD-11D8-8561-0\r
+ 00D93C1A604:ABPerson":mailto:marcel@metaobject.co\r
+DTSTAMP:20040520T140002Z\r
+UID:BD91C454-AA65-11D8-84CA-000D93C1A604\r
+SEQUENCE:3\r
+STATUS:CONFIRMED\r
+DTSTART;TZID=Europe/Berlin:20040618T160000\r
+SUMMARY:SIZE EVENT\r
+X-WR-ITIPSTATUSML:UNCLEAN\r
+END:VEVENT\r
diff --git a/OGoContentStore/ocs_cat.m b/OGoContentStore/ocs_cat.m
new file mode 100644 (file)
index 0000000..bdc1142
--- /dev/null
@@ -0,0 +1,101 @@
+// $Id$
+
+#import <Foundation/NSObject.h>
+
+@class NSUserDefaults;
+@class OCSFolderManager;
+
+@interface Tool : NSObject
+{
+  NSUserDefaults   *ud;
+  OCSFolderManager *folderManager;
+}
+
++ (int)run;
+
+@end
+
+#include <OGoContentStore/OCSFolder.h>
+#include <OGoContentStore/OCSFolderManager.h>
+#include "common.h"
+
+@implementation Tool
+
+- (id)init {
+  if ((self = [super init])) {
+    self->ud            = [[NSUserDefaults standardUserDefaults]   retain];
+    self->folderManager = [[OCSFolderManager defaultFolderManager] retain];
+  }
+  return self;
+}
+- (void)dealloc {
+  [self->ud            release];
+  [self->folderManager release];
+  [super dealloc];
+}
+
+/* operation */
+
+- (int)runOnPath:(NSString *)_path {
+  OCSFolder   *folder;
+  NSString    *dirname, *filename;
+  NSString    *content;
+  
+  dirname  = [_path stringByDeletingLastPathComponent];
+  filename = [_path lastPathComponent];
+  
+  if ((folder = [self->folderManager folderAtPath:dirname]) == nil) {
+    [self logWithFormat:@"did not find folder for file: '%@'", dirname];
+    return 1;
+  }
+  
+  if ((content = [folder fetchContentWithName:filename]) == nil) {
+    [self logWithFormat:@"did not find file: '%@'", _path];
+    return 1;
+  }
+  
+  printf("%s\n", [content cString]);
+  
+  return 0;
+}
+
+- (int)run {
+  NSEnumerator *e;
+  NSString *path;
+  
+  [self logWithFormat:@"manager: %@", self->folderManager];
+  
+  if (![self->folderManager canConnect]) {
+    [self logWithFormat:@"cannot connect folder-info database!"];
+    return 1;
+  }
+  
+  e = [[[NSProcessInfo processInfo] argumentsWithoutDefaults] 
+                       objectEnumerator];
+  [e nextObject]; // skip tool name
+  
+  while ((path = [e nextObject]))
+    [self runOnPath:path];
+  
+  return 0;
+}
++ (int)run {
+  return [(Tool *)[[[self alloc] init] autorelease] run];
+}
+
+@end /* Tool */
+
+int main(int argc, char **argv, char **env) {
+  NSAutoreleasePool *pool;
+  int rc;
+
+  pool = [[NSAutoreleasePool alloc] init];
+#if LIB_FOUNDATION_LIBRARY  
+  [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
+#endif
+
+  rc = [Tool run];
+  
+  [pool release];
+  return rc;
+}
diff --git a/OGoContentStore/sql/testapt-hh.psql b/OGoContentStore/sql/testapt-hh.psql
new file mode 100644 (file)
index 0000000..1ced113
--- /dev/null
@@ -0,0 +1,63 @@
+-- $Id$
+--
+-- (C) 2004 SKYRIX Software AG
+--
+
+DELETE FROM SOGo_helge_privcal 
+  WHERE c_name = 'BD91C454-AA65-11D8-84CA-000D93C1A604';
+DELETE FROM SOGo_helge_privcal_quick
+  WHERE c_name = 'BD91C454-AA65-11D8-84CA-000D93C1A604';
+
+
+
+INSERT INTO SOGo_helge_privcal
+  ( c_name, c_creationdate, c_lastmodified, c_version, c_content )
+VALUES (
+  'BD91C454-AA65-11D8-84CA-000D93C1A604',
+  928383,
+  928383,
+  1,
+
+  'BEGIN:VEVENT\r
+DURATION:PT1H\r
+ATTENDEE;CN="Elke Bethke";DIR="addressbook://B156F3F0-9CFD-11D8-8561-000\r
+ D93C1A604:ABPerson":mailto:E.Bethke@Sachsen-Anhalt-Lotto.de\r
+ATTENDEE;CN="Erik Doernenburg";DIR="addressbook://B15FCB0F-9CFD-11D8-8561\r
+ -000D93C1A604:ABPerson":mailto:erik@x101.net\r
+ATTENDEE;CN="Christian Schnelle";DIR="addressbook://B1418D4E-9CFD-11D8-8\r
+ 561-000D93C1A604:ABPerson":mailto:cs@enervation.de\r
+ATTENDEE;CN="Chris Herrenberger";DIR="addressbook://B14A390C-9CFD-11D8-8\r
+ 561-000D93C1A604:ABPerson":invalid:nomail\r
+ATTENDEE;CN="Horst Parplies";DIR="addressbook://B19B47E5-9CFD-11D8-8561-\r
+ 000D93C1A604:ABPerson":mailto:horst.parplies@freenet.de\r
+ATTENDEE;CN="Imdat Solak";DIR="addressbook://B19EDB62-9CFD-11D8-8561-000\r
+ D93C1A604:ABPerson":mailto:imdat@solak.de\r
+ATTENDEE;CN="Jens Enders";DIR="addressbook://B1B6819F-9CFD-11D8-8561-000\r
+ D93C1A604:ABPerson":mailto:jens.enders@skyrix.com\r
+ATTENDEE;CN="Jens Muenster";DIR="addressbook://B1BBA42E-9CFD-11D8-8561-00\r
+ 0D93C1A604:ABPerson":mailto:jens.muenster@skyrix.com\r
+ATTENDEE;CN="Laurent Pierre";DIR="addressbook://9337C270-A825-11D8-B930-\r
+ 000D93C1A604:ABPerson":mailto:laurent.pierre@linagora.com\r
+ATTENDEE;CN="Marcel Weiher";DIR="addressbook://B1F9BB12-9CFD-11D8-8561-0\r
+ 00D93C1A604:ABPerson":mailto:marcel@metaobject.co\r
+DTSTAMP:20040520T140002Z\r
+UID:BD91C454-AA65-11D8-84CA-000D93C1A604\r
+SEQUENCE:3\r
+STATUS:CONFIRMED\r
+DTSTART;TZID=Europe/Berlin:20040618T160000\r
+SUMMARY:SIZE EVENT\r
+X-WR-ITIPSTATUSML:UNCLEAN\r
+END:VEVENT\r
+'
+);
+
+INSERT INTO SOGo_helge_privcal_quick
+  ( c_name, uid, startdate, enddate, title, participants )
+VALUES (
+  'BD91C454-AA65-11D8-84CA-000D93C1A604',
+  'BD91C454-AA65-11D8-84CA-000D93C1A604',
+  8928837,
+  8929000,
+  'SIZE EVENT',
+  'Elke Bethke, Erik Doernenburg, Christian Schnelle, Chris Herrenberger, Horst Parplies, Imdat Solak, Jens Enders, Jens Muenster, Laurent Pierre, Marcel Weiher'
+);