]> err.no Git - sope/blobdiff - sope-appserver/NGObjWeb/WOResourceManager.m
minor improvement to WOHttpAdaptor, bumped framework revisions
[sope] / sope-appserver / NGObjWeb / WOResourceManager.m
index 71d4297572f18df2e97147befcf415b41d287cc3..ec67480a78eeb678cc82d12bdbeed2d99d652542 100644 (file)
@@ -1,20 +1,20 @@
 /*
-  Copyright (C) 2000-2004 SKYRIX Software AG
+  Copyright (C) 2000-2005 SKYRIX Software AG
 
-  This file is part of OpenGroupware.org.
+  This file is part of SOPE.
 
-  OGo is free software; you can redistribute it and/or modify it under
+  SOPE 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
+  SOPE 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
+  License along with SOPE; see the file COPYING.  If not, write to the
   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.
 */
@@ -203,7 +203,7 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
   return debugOn;
 }
 - (NSString *)loggingPrefix {
-  unsigned char buf[32];
+  char buf[32];
   sprintf(buf, "[wo-rm-0x%08X]", (unsigned)self);
   return [NSString stringWithCString:buf];
 }
@@ -280,7 +280,7 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
 }
 
 - (NSString *)resourcesPathForFramework:(NSString *)_fw {
-  if (_fw == nil) 
+  if (_fw == nil || (_fw == rapidTurnAroundPath)
     return [self resourcesPath];
   
 #if RSRCDIR_CONTENTS
@@ -537,12 +537,11 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
 
 /* string tables */
 
-- (NSString *)stringForKey:(NSString *)_key
-  inTableNamed:(NSString *)_tableName
-  withDefaultValue:(NSString *)_defaultValue
+- (id)stringTableWithName:(NSString *)_tableName
   inFramework:(NSString *)_framework
-  languages:(NSArray *)_languages;
+  languages:(NSArray *)_languages
 {
+  /* side effect: tables are cached (currently not affected by default!) */
   NSFileManager  *fm;
   _WOStringTable *table     = nil;
   NSString       *path      = nil;
@@ -550,7 +549,7 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
   fm = [self fileManager];
   
   if (_tableName == nil)
-    _tableName = @"default";
+    _tableName = @"Localizable";
 
   /* take a look whether a matching table is already loaded */
   
@@ -558,21 +557,34 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
   path = [self pathForResourceNamed:path inFramework:_framework 
                languages:_languages];
   
-  if (path != nil) {
-    if ((table = NSMapGet(self->stringTables, path)) == NULL) {
-      if ([fm fileExistsAtPath:path]) {
-       table = [_WOStringTable allocWithZone:[self zone]]; /* for gcc */
-        table = [table initWithPath:path];
-        NSMapInsert(self->stringTables, path, table);
-        [table release];
-      }
+  if (path == nil)
+    return nil;
+  
+  if ((table = NSMapGet(self->stringTables, path)) == NULL) {
+    if ([fm fileExistsAtPath:path]) {
+      table = [_WOStringTable allocWithZone:[self zone]]; /* for gcc */
+      table = [table initWithPath:path];
+      NSMapInsert(self->stringTables, path, table);
+      [table release];
     }
-    if (table != nil)
-      return [table stringForKey:_key withDefaultValue:_defaultValue];
   }
-  /* didn't found table in cache */
+  return table;
+}
+
+- (NSString *)stringForKey:(NSString *)_key
+  inTableNamed:(NSString *)_tableName
+  withDefaultValue:(NSString *)_defaultValue
+  inFramework:(NSString *)_framework
+  languages:(NSArray *)_languages
+{
+  _WOStringTable *table     = nil;
   
-  return _defaultValue;
+  table = [self stringTableWithName:_tableName inFramework:_framework 
+               languages:_languages];
+  
+  return (table != nil)
+    ? [table stringForKey:_key withDefaultValue:_defaultValue]
+    : _defaultValue;
 }
 
 - (NSString *)stringForKey:(NSString *)_key
@@ -767,32 +779,31 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
            _nameOrURL, _framework];
   }
 
+  /* look for .wox component */
     
-    /* look for .wox component */
+  path = [self pathForResourceNamed:
+                [self resourceNameForComponentNamed:*name_]
+              inFramework:_framework
+              languages:_languages];
     
-    path = [self pathForResourceNamed:
-                   [self resourceNameForComponentNamed:*name_]
-                 inFramework:_framework
-                 languages:_languages];
+  if (debugComponentLookup)
+    [self logWithFormat:@"  .wox path: '%@'", path];
     
-    if (debugComponentLookup)
-      [self logWithFormat:@"  path: '%@'", path];
-    
-    /* look for .wo component */
+  /* look for .wo component */
     
-    if ([path length] == 0) {
-      path = [self pathToComponentNamed:*name_
-                   inFramework:_framework
-                   languages:_languages];
-      if (debugComponentLookup)
-        [self logWithFormat:@"  path: '%@'", path];
-    }
+  if ([path length] == 0) {
+    path = [self pathToComponentNamed:*name_
+                inFramework:_framework
+                languages:_languages];
+    if (debugComponentLookup)
+      [self logWithFormat:@"  .wo  path: '%@'", path];
+  }
     
-    /* make URL from path */
+  /* make URL from path */
     
-    *url_ = ([path length] > 0)
-      ? [[[UrlClass alloc] initFileURLWithPath:path] autorelease]
-      : nil;
+  *url_ = ([path length] > 0)
+    ? [[[UrlClass alloc] initFileURLWithPath:path] autorelease]
+    : nil;
 }
 
 - (WOComponentDefinition *)definitionForFileURL:(NSURL *)componentURL
@@ -923,6 +934,7 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
   
   /* lookup component path */
   
+  // TODO: Explain why _framework and _languages are NOT passed!
   [self _getComponentURL:&componentURL andName:&_name 
        forNameOrURL:_name inFramework:nil languages:nil];
   
@@ -1056,12 +1068,13 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
   WOComponentDefinition *cdef;
   
   cdef = [self __definitionForComponent:_name languages:_languages];
-  if (cdef == nil) return nil;
+  if (cdef == nil)
+    return nil;
   
   return (WOElement *)[cdef template];
 }
 
-- (WOComponent *)pageWithName:(NSString *)_name languages:(NSArray *)_langs {
+- (id)pageWithName:(NSString *)_name languages:(NSArray *)_langs {
   /* 
      TODO: this appears to be deprecated since the WOComponent initializer
            is now -initWithContext: and we have no context over here ...
@@ -1084,14 +1097,6 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
   return [component autorelease];
 }
 
-/* description */
-
-- (NSString *)description {
-  return [NSString stringWithFormat:@"<%@[0x%08X]: path=%@>",
-                     [self class], self, self->base];
-                   
-}
-
 /* KeyedData */
 
 - (void)setData:(NSData *)_data
@@ -1160,4 +1165,17 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path)
   [self unlock];
 }
 
+/* description */
+
+- (NSString *)description {
+  NSMutableString *ms;
+
+  ms = [NSMutableString stringWithCapacity:32];
+  [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
+  if ([self->base length] > 0)
+    [ms appendFormat:@" path='%@'", self->base];
+  [ms appendString:@">"];
+  return ms;
+}
+
 @end /* WOResourceManager */