Fixes and optimzations

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@21054 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mguesdon 2005-04-05 15:54:24 +00:00
parent c7c42d697f
commit 0fa6a5270a
13 changed files with 238 additions and 97 deletions

View file

@ -1,3 +1,36 @@
2005-04-05 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWActiveImage.m:
o avoid string formatting
* GSWeb.framework/GSWImageButton.m:
o avoid string formatting
* GSWeb.framework/GSWForm.m:
o avoid string formatting
o fix https bug in -_appendCGIActionToResponse:inContext:
* GSWeb.framework/GSWGenericContainer.m:
o avoid string formatting
* GSWeb.framework/GSWHTMLDynamicElement.m:
o avoid string formatting
o IMPs optimizations
* GSWeb.framework/GSWMailDelivery.m:
o avoid string formatting
* GSWeb.framework/GSWComponent.h:
o added -logString:
* GSWeb.framework/GSWComponent.m:
o added -logString:
o implemented -logWithFormat:
o implemented -logWithFormat:arguments:
o implemented +logWithFormat:
* GSWeb.framework/GSWDefaultAdaptor.m:
o removed -logWithFormat: and +logWithFormat:
o added -workerThreadCount and -setWorkerThreadCount:
o replaced -statusLogWithFormat: calls by -statusLogString: calls
* GSWeb.framework/GSWDefaultAdaptor.h:
o removed -logWithFormat: and +logWithFormat:
* GSWeb.framework/GSWDefaultAdaptorThread.m:
o replaced -statusLogWithFormat: calls by -statusLogString: calls
* GSWeb.framework/GSWMultiKeyDictionary.m:
o better logs
2005-04-05 Manuel Guesdon <mguesdon@orange-concept.com> 2005-04-05 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWContext.m: * GSWeb.framework/GSWContext.m:
o add contextAndElementID caching and optimizations o add contextAndElementID caching and optimizations

View file

@ -253,10 +253,8 @@ RCS_ID("$Id$")
if (wasFormSubmitted) if (wasFormSubmitted)
{ {
NSString* nameInContext=[self nameInContext:aContext]; NSString* nameInContext=[self nameInContext:aContext];
NSString* formValueX=[request formValueForKey:[NSString stringWithFormat:@"%@.x", NSString* formValueX=[request formValueForKey:[nameInContext stringByAppendingString:@".x"]];
nameInContext]]; NSString* formValueY=[request formValueForKey:[nameInContext stringByAppendingString:@".y"]];
NSString* formValueY=[request formValueForKey:[NSString stringWithFormat:@"%@.y",
nameInContext]];
NSDebugMLLog(@"gswdync",@"formValueX=%@",formValueX); NSDebugMLLog(@"gswdync",@"formValueX=%@",formValueX);
NSDebugMLLog(@"gswdync",@"formValueY=%@",formValueY); NSDebugMLLog(@"gswdync",@"formValueY=%@",formValueY);
if (formValueX && formValueY) if (formValueX && formValueY)

View file

@ -214,6 +214,7 @@ associationsKeys:(NSArray*)associationsKeys
keyPath:(id)_keyPath; keyPath:(id)_keyPath;
-(void)_debugWithString:(NSString*)string; -(void)_debugWithString:(NSString*)string;
-(void)debugWithFormat:(NSString*)format,...; -(void)debugWithFormat:(NSString*)format,...;
-(void)logString:(NSString*)aString;
-(void)logWithFormat:(NSString*)format,...; -(void)logWithFormat:(NSString*)format,...;
-(void)logWithFormat:(NSString*)format -(void)logWithFormat:(NSString*)format
arguments:(va_list)argList; arguments:(va_list)argList;

View file

@ -219,21 +219,35 @@ RCS_ID("$Id$")
return aFrameworkName; return aFrameworkName;
}; };
//--------------------------------------------------------------------
// logString:
-(void)logString:(NSString*)aString
{
[[self application] logString:aString];
};
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// logWithFormat: // logWithFormat:
-(void)logWithFormat:(NSString*)format,... -(void)logWithFormat:(NSString*)aFormat,...
{ {
LOGObjectFnNotImplemented(); //TODOFN va_list ap;
va_start(ap,aFormat);
[self logWithFormat:aFormat
arguments:ap];
va_end(ap);
}; };
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// logWithFormat:arguments: // logWithFormat:arguments:
-(void)logWithFormat:(NSString*)format -(void)logWithFormat:(NSString*)aFormat
arguments:(va_list)arguments arguments:(va_list)arguments
{ {
LOGObjectFnNotImplemented(); //TODOFN NSString* string=[NSString stringWithFormat:aFormat
arguments:arguments];
[self logString:string];
}; };
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -1571,28 +1585,44 @@ associationsKeys:(NSArray*)associationsKeys
}; };
//-------------------------------------------------------------------- //--------------------------------------------------------------------
-(void)debugWithFormat:(NSString*)format,... -(void)debugWithFormat:(NSString*)aFormat,...
{ {
LOGObjectFnNotImplemented(); //TODOFN LOGObjectFnNotImplemented(); //TODOFN
}; };
//-------------------------------------------------------------------- //--------------------------------------------------------------------
-(void)logWithFormat:(NSString*)format,... -(void)logWithFormat:(NSString*)aFormat,...
{ {
LOGObjectFnNotImplemented(); //TODOFN va_list ap;
va_start(ap,aFormat);
[self logWithFormat:aFormat
arguments:ap];
va_end(ap);
}; };
//-------------------------------------------------------------------- //--------------------------------------------------------------------
-(void)logWithFormat:(NSString*)format -(void)logWithFormat:(NSString*)aFormat
arguments:(va_list)argList arguments:(va_list)arguments
{ {
LOGObjectFnNotImplemented(); //TODOFN NSString* string=[NSString stringWithFormat:aFormat
arguments:arguments];
[self logString:string];
}; };
//-------------------------------------------------------------------- //--------------------------------------------------------------------
+(void)logWithFormat:(NSString*)format,... +(void)logWithFormat:(NSString*)aFormat,...
{ {
LOGClassFnNotImplemented(); //TODOFN va_list ap;
va_start(ap,aFormat);
[[GSWApplication application] logWithFormat:aFormat
arguments:ap];
va_end(ap);
};
//--------------------------------------------------------------------
-(void)logString:(NSString*)aString
{
[[self application] logString:aString];
}; };
@end @end

View file

@ -55,9 +55,6 @@ GSWEB_EXPORT int iBlock;
-(void)registerForEvents; -(void)registerForEvents;
-(void)unregisterForEvents; -(void)unregisterForEvents;
-(void)logWithFormat:(NSString*)format,...;
+(void)logWithFormat:(NSString*)format,...;
-(void)runOnce; -(void)runOnce;
-(BOOL)doesBusyRunOnce; -(BOOL)doesBusyRunOnce;
-(BOOL)dispatchesRequestsConcurrently; -(BOOL)dispatchesRequestsConcurrently;

View file

@ -155,18 +155,6 @@ int allow_severity = LOG_INFO;
DESTROY(_fileHandle); DESTROY(_fileHandle);
}; };
//--------------------------------------------------------------------
-(void)logWithFormat:(NSString*)format,...
{
LOGObjectFnNotImplemented(); //TODOFN
};
//--------------------------------------------------------------------
+(void)logWithFormat:(NSString*)format,...
{
LOGClassFnNotImplemented(); //TODOFN
};
//-------------------------------------------------------------------- //--------------------------------------------------------------------
-(void)runOnce -(void)runOnce
{ {
@ -201,6 +189,36 @@ int allow_severity = LOG_INFO;
}; };
//--------------------------------------------------------------------
-(id)workerThreadCount
{
return GSWIntNumber(_workerThreadCount);
};
//--------------------------------------------------------------------
-(void)setWorkerThreadCount:(id)workerThreadCount
{
if ([self tryLock])
{
NS_DURING
{
_workerThreadCount=[workerThreadCount intValue];
}
NS_HANDLER
{
LOGException(@"%@ (%@)",
localException,
[localException reason]);
}
NS_ENDHANDLER;
[self unlock];
}
else
{
//TODO
};
};
//-------------------------------------------------------------------- //--------------------------------------------------------------------
-(void)setWorkerThreadCountMin:(id)workerThreadCount -(void)setWorkerThreadCountMin:(id)workerThreadCount
{ {
@ -457,7 +475,7 @@ int allow_severity = LOG_INFO;
} }
else else
{ {
[GSWApplication statusLogWithFormat:@"Set Thread to wait"]; [GSWApplication statusLogString:@"Set Thread to wait"];
NSDebugLockMLLog(@"info", NSDebugLockMLLog(@"info",
@"Set Thread to wait %p", @"Set Thread to wait %p",
(void*)newThread); (void*)newThread);
@ -654,7 +672,7 @@ int allow_severity = LOG_INFO;
#ifndef NDEBUG #ifndef NDEBUG
pool=[NSAutoreleasePool new]; pool=[NSAutoreleasePool new];
GSWLogMemCF("New NSAutoreleasePool: %p",pool); GSWLogMemCF("New NSAutoreleasePool: %p",pool);
[GSWApplication statusLogWithFormat:@"Lauch waiting Thread"]; [GSWApplication statusLogString:@"Lauch waiting Thread"];
NSDebugLockMLLog(@"info", NSDebugLockMLLog(@"info",
@"Lauch waiting Thread %p", @"Lauch waiting Thread %p",
(void*)thread); (void*)thread);

View file

@ -137,7 +137,7 @@ static NSData* lineFeedData=nil;
_pool=[NSAutoreleasePool new]; _pool=[NSAutoreleasePool new];
GSWLogMemCF("New NSAutoreleasePool: %p",_pool); GSWLogMemCF("New NSAutoreleasePool: %p",_pool);
#ifdef GSWDEBUG_DEEP #ifdef GSWDEBUG_DEEP
[GSWApplication logWithFormat:@"pool allocated!"]; [GSWApplication logString:@"pool allocated!"];
#endif #endif
_runTS=GSWTime_now(); _runTS=GSWTime_now();
@ -146,7 +146,7 @@ static NSData* lineFeedData=nil;
_sendResponseTS=GSWTime_zero(); _sendResponseTS=GSWTime_zero();
#ifdef GSWDEBUG_DEEP #ifdef GSWDEBUG_DEEP
[GSWApplication statusLogWithFormat:@"Thread run START"]; [GSWApplication statusLogString:@"Thread run START"];
#endif #endif
if (_isMultiThread) if (_isMultiThread)
{ {
@ -256,11 +256,11 @@ static NSData* lineFeedData=nil;
_application); _application);
LOGObjectFnStop(); LOGObjectFnStop();
#ifdef DEBUG #ifdef DEBUG
[GSWApplication statusLogWithFormat:@"threadWillExit START"]; [GSWApplication statusLogString:@"threadWillExit START"];
#endif #endif
[_application threadWillExit]; [_application threadWillExit];
#ifdef DEBUG #ifdef DEBUG
[GSWApplication statusLogWithFormat:@"threadWillExit STOP"]; [GSWApplication statusLogString:@"threadWillExit STOP"];
#endif #endif
if (_isMultiThread) if (_isMultiThread)
{ {
@ -270,7 +270,7 @@ static NSData* lineFeedData=nil;
else else
[self threadExited]; [self threadExited];
#ifdef DEBUG #ifdef DEBUG
[GSWApplication statusLogWithFormat:@"run STOP"]; [GSWApplication statusLogString:@"run STOP"];
#endif #endif
}; };
@ -785,7 +785,7 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
localException,[localException reason]); localException,[localException reason]);
NSDebugMLog(@"EXCEPTION GSWDefaultAdaptorThread: sendResponse Exception:%@ (%@)", NSDebugMLog(@"EXCEPTION GSWDefaultAdaptorThread: sendResponse Exception:%@ (%@)",
localException,[localException reason]); localException,[localException reason]);
[GSWApplication statusLogWithFormat:@"\nException while sending response\n"]; [GSWApplication statusLogString:@"\nException while sending response\n"];
} }
NS_ENDHANDLER; NS_ENDHANDLER;
@ -813,7 +813,7 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
NS_DURING NS_DURING
{ {
[aStream writeData:responseData]; [aStream writeData:responseData];
[GSWApplication statusLogWithFormat:@"\nResponse Sent\n"]; [GSWApplication statusLogString:@"\nResponse Sent\n"];
} }
NS_HANDLER NS_HANDLER
{ {
@ -822,7 +822,7 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
localException,[localException reason]); localException,[localException reason]);
NSDebugMLog(@"EXCEPTION GSWDefaultAdaptorThread: sendResponse Exception:%@ (%@)", NSDebugMLog(@"EXCEPTION GSWDefaultAdaptorThread: sendResponse Exception:%@ (%@)",
localException,[localException reason]); localException,[localException reason]);
[GSWApplication statusLogWithFormat:@"\nException while sending response\n"]; [GSWApplication statusLogString:@"\nException while sending response\n"];
} }
NS_ENDHANDLER; NS_ENDHANDLER;
NSDebugDeepMLLog0(@"info",@"Response content Written"); NSDebugDeepMLLog0(@"info",@"Response content Written");

View file

@ -1,6 +1,6 @@
/** GSWForm.m - <title>GSWeb: Class GSWForm</title> /** GSWForm.m - <title>GSWeb: Class GSWForm</title>
Copyright (C) 1999-2004 Free Software Foundation, Inc. Copyright (C) 1999-2005 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com> Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999 Date: Jan 1999
@ -564,8 +564,13 @@ static Class standardClass = Nil;
id fragment=[_fragmentIdentifier valueInComponent:component]; id fragment=[_fragmentIdentifier valueInComponent:component];
NSDebugMLLog(@"gswdync",@"fragment=%@",fragment); NSDebugMLLog(@"gswdync",@"fragment=%@",fragment);
if (fragment) if (fragment)
actionValue=[NSString stringWithFormat:@"%@#%@", {
actionValue,fragment]; if (actionValue)
actionValue=[NSStringWithObject(actionValue) stringByAppendingString:@"#"];
else
actionValue=@"#";
actionValue=[actionValue stringByAppendingString:NSStringWithObject(fragment)];
};
}; };
NSDebugMLLog(@"gswdync",@"actionValue=%@",actionValue); NSDebugMLLog(@"gswdync",@"actionValue=%@",actionValue);
//TODO emit a warning ! //TODO emit a warning !
@ -612,8 +617,7 @@ static Class standardClass = Nil;
NSDebugMLLog(@"gswdync",@"actionString=%@",actionString); NSDebugMLLog(@"gswdync",@"actionString=%@",actionString);
anUrl=(NSString*)[aContext directActionURLForActionNamed:actionString anUrl=(NSString*)[aContext directActionURLForActionNamed:actionString
queryDictionary:nil queryDictionary:nil];
isSecure:NO];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl); NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
if (_fragmentIdentifier) if (_fragmentIdentifier)
@ -621,8 +625,13 @@ static Class standardClass = Nil;
id fragment=[_fragmentIdentifier valueInComponent:GSWContext_component(aContext)]; id fragment=[_fragmentIdentifier valueInComponent:GSWContext_component(aContext)];
NSDebugMLLog(@"gswdync",@"fragment=%@",fragment); NSDebugMLLog(@"gswdync",@"fragment=%@",fragment);
if (fragment) if (fragment)
anUrl=[NSString stringWithFormat:@"%@#%@", {
anUrl,fragment]; if (anUrl)
anUrl=[NSStringWithObject(anUrl) stringByAppendingString:@"#"];
else
anUrl=@"#";
anUrl=[anUrl stringByAppendingString:NSStringWithObject(fragment)];
};
}; };
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl); NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);

View file

@ -131,12 +131,14 @@ RCS_ID("$Id$")
assocEnumer = [_associations keyEnumerator]; assocEnumer = [_associations keyEnumerator];
while ((currentAssocKey = [assocEnumer nextObject])) while ((currentAssocKey = [assocEnumer nextObject]))
{ {
theValue = [[_associations objectForKey:currentAssocKey] theValue = NSStringWithObject([[_associations objectForKey:currentAssocKey]
valueInComponent:component]; valueInComponent:component]);
GSWResponse_appendContentString(aResponse, GSWResponse_appendContentCharacter(aResponse,' ');
([NSString stringWithFormat:@" %@=\"%@\"", GSWResponse_appendContentString(aResponse,currentAssocKey);
currentAssocKey,theValue])); GSWResponse_appendContentAsciiString(aResponse,@"=\"");
GSWResponse_appendContentString(aResponse,theValue);
GSWResponse_appendContentCharacter(aResponse,'"');
} }
GSWResponse_appendContentCharacter(aResponse,'>'); GSWResponse_appendContentCharacter(aResponse,'>');

View file

@ -1,6 +1,6 @@
/** GSWHTMLDynamicElement.m - <title>GSWeb: Class GSWHTMLDynamicElement</title> /** GSWHTMLDynamicElement.m - <title>GSWeb: Class GSWHTMLDynamicElement</title>
Copyright (C) 1999-2004 Free Software Foundation, Inc. Copyright (C) 1999-2005 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com> Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999 Date: Feb 1999
@ -35,6 +35,7 @@
RCS_ID("$Id$") RCS_ID("$Id$")
#include "GSWeb.h" #include "GSWeb.h"
#include "GSWPrivate.h"
static SEL objectAtIndexSEL = NULL; static SEL objectAtIndexSEL = NULL;
@ -808,29 +809,39 @@ attributeAssociations:(NSDictionary*)attributeAssociations
{ {
//OK //OK
GSWComponent* component=nil; GSWComponent* component=nil;
id tmpDirectActionString=nil; NSMutableString* tmpDirectActionString=nil;
id directActionNameValue=nil; id directActionNameValue=nil;
id actionClassValue=nil; id actionClassValue=nil;
IMP das_appendStringIMP=NULL;
LOGObjectFnStart(); LOGObjectFnStart();
component=GSWContext_component(aContext); component=GSWContext_component(aContext);
if (directActionName) if (directActionName)
directActionNameValue=[directActionName valueInComponent:component]; directActionNameValue=NSStringWithObject([directActionName valueInComponent:component]);
if (actionClass) if (actionClass)
actionClassValue=[actionClass valueInComponent:component]; actionClassValue=NSStringWithObject([actionClass valueInComponent:component]);
if (actionClassValue) if (actionClassValue)
{ {
tmpDirectActionString=(NSMutableString*)
[NSMutableString stringWithString:actionClassValue];
if (directActionNameValue) if (directActionNameValue)
tmpDirectActionString=[NSString stringWithFormat:@"%@/%@", {
actionClassValue, // append /directActionNameValue
directActionNameValue]; GSWeb_appendStringWithImpPtr(tmpDirectActionString,
else &das_appendStringIMP,
tmpDirectActionString=actionClassValue; @"/");
GSWeb_appendStringWithImpPtr(tmpDirectActionString,
&das_appendStringIMP,
directActionNameValue);
};
} }
else if (directActionNameValue) else if (directActionNameValue)
tmpDirectActionString=directActionNameValue; {
tmpDirectActionString=(NSMutableString*)
[NSMutableString stringWithString:directActionNameValue];
}
else else
{ {
LOGSeriousError(@"No actionClass (for %@) and no directActionName (for %@)", LOGSeriousError(@"No actionClass (for %@) and no directActionName (for %@)",
@ -899,6 +910,7 @@ attributeAssociations:(NSDictionary*)attributeAssociations
unsigned int count = 0; unsigned int count = 0;
unsigned int i = 0; unsigned int i = 0;
// We sort keys so URL are always the same for same parameters // We sort keys so URL are always the same for same parameters
keys=[[finalDictionary allKeys]sortedArrayUsingSelector:@selector(compare:)]; keys=[[finalDictionary allKeys]sortedArrayUsingSelector:@selector(compare:)];
count=[keys count]; count=[keys count];
@ -910,9 +922,19 @@ attributeAssociations:(NSDictionary*)attributeAssociations
id value = [finalDictionary valueForKey:key]; id value = [finalDictionary valueForKey:key];
NSDebugMLLog(@"gswdync",@"key=%@",key); NSDebugMLLog(@"gswdync",@"key=%@",key);
NSDebugMLLog(@"gswdync",@"value=%@",value); NSDebugMLLog(@"gswdync",@"value=%@",value);
tmpDirectActionString=[tmpDirectActionString stringByAppendingFormat:@"/%@=%@", // append /key=value
key, GSWeb_appendStringWithImpPtr(tmpDirectActionString,
value]; &das_appendStringIMP,
@"/");
GSWeb_appendStringWithImpPtr(tmpDirectActionString,
&das_appendStringIMP,
NSStringWithObject(key));
GSWeb_appendStringWithImpPtr(tmpDirectActionString,
&das_appendStringIMP,
@"=");
GSWeb_appendStringWithImpPtr(tmpDirectActionString,
&das_appendStringIMP,
NSStringWithObject(value));
}; };
}; };
}; };
@ -1031,20 +1053,13 @@ in GSWHyperlink, it was
GSWComponent* component=GSWContext_component(aContext); GSWComponent* component=GSWContext_component(aContext);
cidObject=[cidStore valueInComponent:component]; cidObject=[cidStore valueInComponent:component];
NSDebugMLog(@"cidObject=%@",cidObject); NSDebugMLog(@"cidObject=%@",cidObject);
/* if (!cidObject)
{
cidObject=(NSMutableDictionary*)[NSMutableDictionary dictionary];
[_cidStore setValue:cidObject
inComponent:component];
};
*/
if (cidObject) if (cidObject)
{ {
if (![cidObject valueForKey:cidKeyValue]) if (![cidObject valueForKey:cidKeyValue])
[cidObject takeValue:cidElement [cidObject takeValue:cidElement
forKey:cidKeyValue]; forKey:cidKeyValue];
newURL=[NSString stringWithFormat:@"cid:%@", newURL=[@"cid:" stringByAppendingString:NSStringWithObject(cidKeyValue)];
cidKeyValue];
}; };
NSDebugMLog(@"newURL=%@",newURL); NSDebugMLog(@"newURL=%@",newURL);
}; };

View file

@ -432,10 +432,8 @@ RCS_ID("$Id$")
if (wasFormSubmitted) if (wasFormSubmitted)
{ {
NSString* nameInContext=[self nameInContext:aContext]; NSString* nameInContext=[self nameInContext:aContext];
NSString* formValueX=[request formValueForKey:[NSString stringWithFormat:@"%@.x", NSString* formValueX=[request formValueForKey:[nameInContext stringByAppendingString:@".x"]];
nameInContext]]; NSString* formValueY=[request formValueForKey:[nameInContext stringByAppendingString:@".y"]];
NSString* formValueY=[request formValueForKey:[NSString stringWithFormat:@"%@.y",
nameInContext]];
NSDebugMLLog(@"gswdync",@"formValueX=%@",formValueX); NSDebugMLLog(@"gswdync",@"formValueX=%@",formValueX);
NSDebugMLLog(@"gswdync",@"formValueY=%@",formValueY); NSDebugMLLog(@"gswdync",@"formValueY=%@",formValueY);
if (formValueX && formValueY) if (formValueX && formValueY)

View file

@ -1,6 +1,6 @@
/** GSWMailDelivery.m - <title>GSWeb: Class GSWMailDelivery</title> /** GSWMailDelivery.m - <title>GSWeb: Class GSWMailDelivery</title>
Copyright (C) 1999-2003 Free Software Foundation, Inc. Copyright (C) 1999-2005 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com> Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999 Date: Feb 1999
@ -113,7 +113,7 @@ static GSWMailDelivery *sharedInstance;
plainText:(NSString*)plainTextMessage plainText:(NSString*)plainTextMessage
send:(BOOL)sendNow send:(BOOL)sendNow
{ {
NSString* messageString=nil; NSMutableString* messageString=nil;
NSMutableString* toString=nil; NSMutableString* toString=nil;
int i=0; int i=0;
int count=0; int count=0;
@ -133,12 +133,26 @@ static GSWMailDelivery *sharedInstance;
for(i=0;i<count;i++) for(i=0;i<count;i++)
{ {
if (!toString) if (!toString)
toString=(NSMutableString*)[NSMutableString stringWithFormat:@"%@",[to objectAtIndex:i]]; toString=(NSMutableString*)[NSMutableString stringWithString:NSStringWithObject([to objectAtIndex:i])];
else else
[toString appendFormat:@", %@",[to objectAtIndex:i]]; {
[toString appendString:@", "];
[toString appendString:NSStringWithObject([to objectAtIndex:i])];
};
}; };
NSDebugMLog(@"toString=%@",toString); NSDebugMLog(@"toString=%@",toString);
messageString=[NSString stringWithFormat:@"From: %@\nTo: %@\n",sender,toString]; messageString=(NSMutableString*)[NSMutableString string];
// From:
[messageString appendString:@"From: "];
[messageString appendString:NSStringWithObject(sender)];
[messageString appendString:@"\n"];
// To:
[messageString appendString:@"To: "];
[messageString appendString:toString];
[messageString appendString:@"\n"];
NSDebugMLog(@"messageString=%@",messageString); NSDebugMLog(@"messageString=%@",messageString);
count=[cc count]; count=[cc count];
if (count) if (count)
@ -147,12 +161,19 @@ static GSWMailDelivery *sharedInstance;
for(i=0;i<count;i++) for(i=0;i<count;i++)
{ {
if (!ccString) if (!ccString)
ccString=(NSMutableString*)[NSMutableString stringWithFormat:@"%@",[cc objectAtIndex:i]]; ccString=(NSMutableString*)[NSMutableString stringWithString:NSStringWithObject([cc objectAtIndex:i])];
else else
[ccString appendFormat:@", %@",[cc objectAtIndex:i]]; {
[ccString appendString:@", "];
[ccString appendString:NSStringWithObject([cc objectAtIndex:i])];
};
}; };
NSDebugMLog(@"ccString=%@",ccString); NSDebugMLog(@"ccString=%@",ccString);
messageString=[messageString stringByAppendingFormat:@"Cc: %@\n",ccString];
// cc:
[messageString appendString:@"Cc: "];
[messageString appendString:ccString];
[messageString appendString:@"\n"];
NSDebugMLog(@"messageString=%@",messageString); NSDebugMLog(@"messageString=%@",messageString);
}; };
count=[bcc count]; count=[bcc count];
@ -162,16 +183,31 @@ static GSWMailDelivery *sharedInstance;
for(i=0;i<count;i++) for(i=0;i<count;i++)
{ {
if (!bccString) if (!bccString)
bccString=(NSMutableString*)[NSMutableString stringWithFormat:@"%@",[bcc objectAtIndex:i]]; bccString=(NSMutableString*)[NSMutableString stringWithString:NSStringWithObject([bcc objectAtIndex:i])];
else else
[bccString appendFormat:@", %@",[bcc objectAtIndex:i]]; {
[bccString appendString:@", "];
[bccString appendString:NSStringWithObject([bcc objectAtIndex:i])];
};
}; };
NSDebugMLog(@"bccString=%@",bccString); NSDebugMLog(@"bccString=%@",bccString);
messageString=[messageString stringByAppendingFormat:@"Bcc: %@\n",bccString];
// Bcc:
[messageString appendString:@"Bcc: "];
[messageString appendString:bccString];
[messageString appendString:@"\n"];
NSDebugMLog(@"messageString=%@",messageString); NSDebugMLog(@"messageString=%@",messageString);
}; };
messageString=[messageString stringByAppendingFormat:@"Subject: %@\n\n%@",subject,plainTextMessage];
//Subject
[messageString appendString:@"Subject: "];
[messageString appendString:NSStringWithObject(subject)];
[messageString appendString:@"\n\n"];
// plainTextMessage
[messageString appendString:NSStringWithObject(plainTextMessage)];
NSDebugMLog(@"messageString=%@",messageString); NSDebugMLog(@"messageString=%@",messageString);
if (sendNow) if (sendNow)
[self sendEmail:messageString]; [self sendEmail:messageString];
LOGObjectFnStop(); LOGObjectFnStop();
@ -264,7 +300,7 @@ static GSWMailDelivery *sharedInstance;
NSDebugMLog(@"sendmailPath=%@",sendmailPath); NSDebugMLog(@"sendmailPath=%@",sendmailPath);
// -i When reading a message from standard input, don't treat a line with only a . character as the end of input. // -i When reading a message from standard input, don't treat a line with only a . character as the end of input.
// -t Extract recipients from message headers. This requires that no recipients be specified on the command line. // -t Extract recipients from message headers. This requires that no recipients be specified on the command line.
sendmailCommand=[NSString stringWithFormat:@"%@ -i -t",sendmailPath]; sendmailCommand=[sendmailPath stringByAppendingString:@" -i -t"];
NSDebugMLog(@"sendmailCommand=%@",sendmailCommand); NSDebugMLog(@"sendmailCommand=%@",sendmailCommand);
sendmailFile=popen([sendmailCommand lossyCString],"w"); sendmailFile=popen([sendmailCommand lossyCString],"w");
if (sendmailFile) if (sendmailFile)

View file

@ -1112,12 +1112,13 @@ static void GSWMapBaseInitWithZoneAndCapacity(GSWMapBase base,
if (keysCount==0) if (keysCount==0)
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"Tried to add empty keys array to dictionary"]; format: @"Tried to add empty keys array to multi-keys dictionary. Object: %@",
object];
} }
else if (object == nil) else if (object == nil)
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"Tried to add nil value to dictionary"]; format: @"Tried to add nil value to multi-keys dictionary"];
} }
else else
{ {
@ -1151,17 +1152,20 @@ static void GSWMapBaseInitWithZoneAndCapacity(GSWMapBase base,
if (count==0) if (count==0)
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"Tried to add object to dictionary with no key"]; format: @"Tried to add object to multi-keys dictionary with no key. Object: %@",
object];
} }
else if (*keys == nil) else if (*keys == nil)
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"Tried to add nil key to dictionary"]; format: @"Tried to add nil key to multi-keys dictionary. Object: %@",
object];
} }
else if (object == nil) else if (object == nil)
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"Tried to add nil value to dictionary"]; format: @"Tried to add nil value to multi-keys dictionary. First key: %@",
*keys];
} }
else else
{ {