]> err.no Git - sope/blobdiff - sope-appserver/NGObjWeb/WORequest.m
bugfix, bumped dyld versions
[sope] / sope-appserver / NGObjWeb / WORequest.m
index e0abe594dc157a77c7811571088f30642fe6e586..c37f972ed2182c8ee46d0bd0f29d798600041cc2 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.
 */
@@ -45,6 +45,10 @@ NGObjWeb_DECLARE NSString *WORequestValueSenderID   = @"_i";
 NGObjWeb_DECLARE NSString *WORequestValueSessionID  = @"wosid";
 NGObjWeb_DECLARE NSString *WONoSelectionString      = @"WONoSelectionString";
 
+@interface WOCoreApplication(Resources)
++ (NSString *)findNGObjWebResource:(NSString *)_name ofType:(NSString *)_ext;
+@end
+
 @implementation WORequest
 
 static BOOL debugOn = NO;
@@ -53,56 +57,6 @@ static BOOL debugOn = NO;
   return [super version] + 2 /* v7 */;
 }
 
-+ (NSString *)lookupLanguagesPlist {
-  NSString *apath;
-#if !COMPILE_AS_FRAMEWORK
-  NSFileManager *fm = [NSFileManager defaultManager];
-  NSDictionary  *env;
-  NSString      *relPath;
-#else
-  NSBundle *bundle;
-#endif
-  
-#if COMPILE_AS_FRAMEWORK
-  bundle = [NSBundle bundleForClass:self];
-  apath  = [bundle pathForResource:@"Languages" ofType:@"plist"];
-#else
-  env  = [[NSProcessInfo processInfo] environment];
-
-  /* 
-       TODO: the following is a dirty hack because GNUstep people decided
-             to change the directory structure. SIGH!
-  */
-#if APPLE_FOUNDATION_LIBRARY || NeXT_Foundation_LIBRARY || GNUSTEP_BASE_LIBRARY
-  relPath = @"Library/Libraries";
-#else    
-  relPath = @"Libraries";
-#endif
-  relPath = [relPath stringByAppendingPathComponent:@"Resources"];
-  relPath = [relPath stringByAppendingPathComponent:@"NGObjWeb"];
-  relPath = [relPath stringByAppendingPathComponent:@"Languages.plist"];
-    
-  apath = [env objectForKey:@"GNUSTEP_USER_ROOT"];
-  apath = [apath stringByAppendingPathComponent:relPath];
-  if (![fm fileExistsAtPath:apath]) {
-    apath = [env objectForKey:@"GNUSTEP_LOCAL_ROOT"];
-    apath = [apath stringByAppendingPathComponent:relPath];
-  }
-  if (![fm fileExistsAtPath:apath]) {
-    apath = [env objectForKey:@"GNUSTEP_SYSTEM_ROOT"];
-    apath = [apath stringByAppendingPathComponent:relPath];
-  }
-  if (![fm fileExistsAtPath:apath]) {
-    apath = relPath;
-  }
-  if (![fm fileExistsAtPath:apath]) {
-    NSLog(@"ERROR: cannot find Languages.plist resource "
-         @"of NGObjWeb library !");
-  }
-#endif
-  return apath;
-}
-
 + (void)initialize {
   static BOOL isInitialized = NO;
   NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
@@ -132,10 +86,16 @@ static BOOL debugOn = NO;
   
   /* load language mappings */
     
-  apath = [self lookupLanguagesPlist];
-  langMap = [NSDictionary dictionaryWithContentsOfFile:apath];
+  apath = [WOApplication findNGObjWebResource:@"Languages" ofType:@"plist"];
+  if (apath == nil) {
+    [self errorWithFormat:@"cannot find Languages.plist resource "
+            @"of NGObjWeb library !"];
+    langMap = nil;
+  }
+  else
+    langMap = [NSDictionary dictionaryWithContentsOfFile:apath];
   
-  if (langMap) {
+  if (langMap != nil) {
     NSDictionary *defs;
     
     defs = [NSDictionary dictionaryWithObject:langMap
@@ -143,7 +103,8 @@ static BOOL debugOn = NO;
     [ud registerDefaults:defs];
   }
   else
-    NSLog(@"WARNING: did not register browser language mappings: %@", apath);
+    [self warnWithFormat:
+            @"did not register browser language mappings: %@", apath];
 }
 
 /* parse URI */
@@ -441,10 +402,15 @@ static BOOL debugOn = NO;
 }
 
 - (NGHashMap *)_getFormParameters {
-  if (self->formContent) 
+  if (self->formContent != nil
     return self->formContent;
   
-  if (self->request == nil) {
+  if (self->request != nil) {
+    self->formContent = [[self->request formParameters] retain];
+    return self->formContent;
+  }
+  
+  {
     /*
       TODO: add parsing of form values
       
@@ -468,7 +434,7 @@ static BOOL debugOn = NO;
     if ((ctype = [self headerForKey:@"content-type"]) != nil) {
       isFormContent = [ctype hasPrefix:@"application/x-www-form-urlencoded"];
       if (!isFormContent)
-       isMultiPartContent = [ctype hasPrefix:@"multipart/form-data"];
+        isMultiPartContent = [ctype hasPrefix:@"multipart/form-data"];
     }
     
     if (query != nil || isFormContent || isMultiPartContent) {
@@ -479,16 +445,15 @@ static BOOL debugOn = NO;
       
       /* parse query string */
       if (query)
-       [self _parseQueryParameters:query intoMap:self->formContent];
+        [self _parseQueryParameters:query intoMap:self->formContent];
       
       /* parse content (if form content) */
       if (isFormContent) {
-       [self _parseQueryParameters:[self contentAsString]
+        [self _parseQueryParameters:[self contentAsString]
              intoMap:self->formContent];
       }
       else if (isMultiPartContent) {
-       [self logWithFormat:
-               @"ERROR: missing NGHttpRequest, cannot parse multipart"];
+        [self errorWithFormat:@"missing NGHttpRequest, cannot parse multipart"];
       }
       
       [pool release];
@@ -496,8 +461,6 @@ static BOOL debugOn = NO;
     else
       self->formContent = [[NGHashMap alloc] init];
   }
-  else
-    self->formContent = [[self->request formParameters] retain];
   return self->formContent;
 }
 
@@ -541,8 +504,8 @@ static BOOL debugOn = NO;
   if ([paras isKindOfClass:[NSDictionary class]])
     return paras;
   
-  [self logWithFormat:
-         @"ERROR(%s): don't know how to deal with form object: %@", paras];
+  [self errorWithFormat:@"(%s): don't know how to deal with form object: %@",
+          paras];
   return nil;
 }
 
@@ -559,8 +522,7 @@ static BOOL debugOn = NO;
     
     langMap = [[ud dictionaryForKey:@"WOBrowserLanguageMappings"] copy];
     if (langMap == nil) {
-      [self debugWithFormat:
-              @"WARNING: did not find browser language mappings!"];
+      [self warnWithFormat:@"did not find browser language mappings!"];
     }
   }