Browse CVS Repository
Annotation of /undmail/guiproto/DUMMail.m
Parent Directory
| Revision Log
| Revision Graph
Revision 1.1 -
( hide annotations)
( download)
Sat Jan 25 13:23:47 2003 UTC
(21 years, 2 months ago)
by footashida
Branch: MAIN
*** empty log message ***
| 1 |
footashida |
1.1 |
#import "DUMMail.h" |
| 2 |
|
|
|
| 3 |
|
|
|
| 4 |
|
|
@implementation DUMMail |
| 5 |
|
|
-(void)parseMailData:(NSString *)mailData{ |
| 6 |
|
|
NSRange textRange; |
| 7 |
|
|
NSRange lineRange; |
| 8 |
|
|
NSString *line; |
| 9 |
|
|
|
| 10 |
|
|
textRange = NSMakeRange(0, [mailData length]); |
| 11 |
|
|
while(textRange.length > 0){ |
| 12 |
|
|
lineRange = [mailData lineRangeForRange: |
| 13 |
|
|
NSMakeRange(textRange.location, 0)]; |
| 14 |
|
|
line = [mailData substringWithRange:lineRange]; |
| 15 |
|
|
if([line hasPrefix:@"From: "]){ |
| 16 |
|
|
from = [line substringFromIndex:[@"From: " length]]; |
| 17 |
|
|
[from retain]; |
| 18 |
|
|
}else if([line hasPrefix:@"To: "]){ |
| 19 |
|
|
to = [line substringFromIndex:[@"To: " length]]; |
| 20 |
|
|
[to retain]; |
| 21 |
|
|
}else if([line hasPrefix:@"Subject: "]){ |
| 22 |
|
|
subject = [line substringFromIndex:[@"Subject: " length]]; |
| 23 |
|
|
[subject retain]; |
| 24 |
|
|
}else if([line isEqual:@"\r\n"]){ |
| 25 |
|
|
content = [mailData substringFromIndex:textRange.location]; |
| 26 |
|
|
[content retain]; |
| 27 |
|
|
return; |
| 28 |
|
|
}else{ |
| 29 |
|
|
//無視 |
| 30 |
|
|
} |
| 31 |
|
|
|
| 32 |
|
|
textRange.location = NSMaxRange(lineRange); |
| 33 |
|
|
textRange.length -= lineRange.length; |
| 34 |
|
|
} |
| 35 |
|
|
} |
| 36 |
|
|
|
| 37 |
|
|
-(id)initWithMailData:(NSString *)mailData{ |
| 38 |
|
|
self = [super init]; |
| 39 |
|
|
from = nil; |
| 40 |
|
|
to = nil; |
| 41 |
|
|
subject = nil; |
| 42 |
|
|
date = nil; |
| 43 |
|
|
content = nil; |
| 44 |
|
|
isUnread = YES; |
| 45 |
|
|
[self parseMailData:mailData]; |
| 46 |
|
|
return self; |
| 47 |
|
|
} |
| 48 |
|
|
-(void)dealloc{ |
| 49 |
|
|
[from release]; |
| 50 |
|
|
[to release]; |
| 51 |
|
|
[subject release]; |
| 52 |
|
|
[date release]; |
| 53 |
|
|
[content release]; |
| 54 |
|
|
[super dealloc]; |
| 55 |
|
|
} |
| 56 |
|
|
-(NSString *)from{ |
| 57 |
|
|
return from; |
| 58 |
|
|
} |
| 59 |
|
|
-(NSString *)to{ |
| 60 |
|
|
return to; |
| 61 |
|
|
} |
| 62 |
|
|
-(NSString *)subject{ |
| 63 |
|
|
return subject; |
| 64 |
|
|
} |
| 65 |
|
|
-(NSDate *)date{ |
| 66 |
|
|
return date; |
| 67 |
|
|
} |
| 68 |
|
|
-(NSString *)content{ |
| 69 |
|
|
return content; |
| 70 |
|
|
} |
| 71 |
|
|
-(BOOL)isUnread{ |
| 72 |
|
|
return isUnread; |
| 73 |
|
|
} |
| 74 |
|
|
-(void)setIsUnread:(BOOL)flag{ |
| 75 |
|
|
isUnread = flag; |
| 76 |
|
|
} |
| 77 |
|
|
- (NSString *)description{ |
| 78 |
|
|
return [NSString stringWithFormat:@"From:%@\nTo:%@\nSubject:%@\n%@" |
| 79 |
|
|
,from, to, subject, content]; |
| 80 |
|
|
} |
| 81 |
|
|
@end |
|