fix bug opening connection to mail server

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32797 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2011-04-07 10:58:07 +00:00
parent 03ea086c00
commit 5750a59f45
2 changed files with 51 additions and 20 deletions

View file

@ -1,3 +1,7 @@
2011-04-07 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSMime.m: Fix failure to connect to mail server.
2011-04-07 Richard Frith-Macdonald <rfm@gnu.org> 2011-04-07 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSNmberFormatter.m: Tweak macros to avoid compiler warnings. * Source/NSNmberFormatter.m: Tweak macros to avoid compiler warnings.

View file

@ -6297,7 +6297,14 @@ GS_PRIVATE_INTERNAL(GSMimeSMTPClient)
{ {
GSMimeDocument *d = [internal->queue objectAtIndex: c]; GSMimeDocument *d = [internal->queue objectAtIndex: c];
[internal->delegate smtpClient: self mimeUnsent: d]; if (nil == internal->delegate)
{
NSDebugMLLog(@"GSMime", @"-smtpClient:mimeUnsent: %@ %@", self, d);
}
else
{
[internal->delegate smtpClient: self mimeUnsent: d];
}
} }
[internal->queue removeAllObjects]; [internal->queue removeAllObjects];
} }
@ -7057,7 +7064,15 @@ GS_PRIVATE_INTERNAL(GSMimeSMTPClient)
internal->current = nil; internal->current = nil;
[internal->queue removeObjectAtIndex: 0]; [internal->queue removeObjectAtIndex: 0];
[internal->delegate smtpClient: self mimeSent: d]; if (nil == internal->delegate)
{
NSDebugMLLog(@"GSMime", @"-smtpClient:mimeSent: %@ %@",
self, d);
}
else
{
[internal->delegate smtpClient: self mimeSent: d];
}
[d release]; [d release];
} }
[self _doMessage]; [self _doMessage];
@ -7151,7 +7166,14 @@ GS_PRIVATE_INTERNAL(GSMimeSMTPClient)
[internal->queue removeObjectAtIndex: 0]; [internal->queue removeObjectAtIndex: 0];
internal->current = nil; internal->current = nil;
[internal->delegate smtpClient: self mimeFailed: d]; if (nil == internal->delegate)
{
NSDebugMLLog(@"GSMime", @"-smtpClient:mimeFailed: %@ %@", self, d);
}
else
{
[internal->delegate smtpClient: self mimeFailed: d];
}
[d release]; [d release];
} }
if ([internal->queue count] > 0) if ([internal->queue count] > 0)
@ -7171,8 +7193,10 @@ GS_PRIVATE_INTERNAL(GSMimeSMTPClient)
NSHost *h; NSHost *h;
NSString *n = internal->hostname; NSString *n = internal->hostname;
NSString *p = internal->port; NSString *p = internal->port;
int pnum;
DESTROY(internal->lastError); DESTROY(internal->lastError);
/* Need to start up ... /* Need to start up ...
*/ */
if (n == nil) if (n == nil)
@ -7195,27 +7219,30 @@ GS_PRIVATE_INTERNAL(GSMimeSMTPClient)
if (p == nil) if (p == nil)
{ {
int pnum;
p = [defs stringForKey: @"GSMimeSMTPClientPort"]; p = [defs stringForKey: @"GSMimeSMTPClientPort"];
if ((pnum = [p intValue]) <= 0 || pnum > 65535) if ([p length] == 0)
{ {
p = @"25"; p = @"25";
pnum = 25;
} }
[NSStream getStreamsToHost: h }
port: pnum if ((pnum = [p intValue]) <= 0 || pnum > 65535)
inputStream: &internal->istream {
outputStream: &internal->ostream]; NSLog(@"Bad port '%@' ... using 25", p);
[internal->istream retain]; pnum = 25;
[internal->ostream retain]; }
if (internal->istream == nil || internal->ostream == nil)
{ [NSStream getStreamsToHost: h
NSLog(@"Unable to connect to %@:%@", n, p); port: pnum
[self _shutdown: nil]; inputStream: &internal->istream
return; outputStream: &internal->ostream];
} [internal->istream retain];
} [internal->ostream retain];
if (internal->istream == nil || internal->ostream == nil)
{
NSLog(@"Unable to connect to %@:%@", n, p);
[self _shutdown: nil];
return;
}
[internal->istream setDelegate: self]; [internal->istream setDelegate: self];
[internal->ostream setDelegate: self]; [internal->ostream setDelegate: self];