Develop and Download Open Source Software

Browse CVS Repository

Contents of /undmail/guiproto/DUMMail.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Wed Jan 29 18:30:41 2003 UTC (21 years, 2 months ago) by footashida
Branch: MAIN
Changes since 1.1: +14 -10 lines
*** empty log message ***

1 #import "DUMMail.h"
2
3 @implementation DUMMail
4 // Private Method
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 = [[DUMMailAddress alloc]
17 initWithMailAddressString:[line substringFromIndex:[@"From: " length]]];
18 [from retain];
19 }else if([line hasPrefix:@"To: "]){
20 to = [[DUMMailAddress alloc]
21 initWithMailAddressString:[line substringFromIndex:[@"To: " length]]];
22 }else if([line hasPrefix:@"Subject: "]){
23 subject = [line substringFromIndex:[@"Subject: " length]];
24 [subject retain];
25 }else if([line hasPrefix:@"Date: "]){
26 NSString *dateString = [line substringFromIndex:[@"Date: " length]];
27 date = [NSCalendarDate dateWithString:dateString
28 calendarFormat:@"%a, %d %b %Y %H:%M:%S %z"];
29 [date retain];
30 }else if([line isEqual:@"\r\n"]){
31 content = [mailData substringFromIndex:textRange.location];
32 [content retain];
33 return;
34 }else{
35 //������
36 }
37
38 textRange.location = NSMaxRange(lineRange);
39 textRange.length -= lineRange.length;
40 }
41 }
42 // Public Method
43 -(id)initWithMailData:(NSString *)mailData{
44 self = [super init];
45 subject = nil;
46 date = nil;
47 content = nil;
48 isUnread = YES;
49 [self parseMailData:mailData];
50 return self;
51 }
52 -(void)dealloc{
53 [from release];
54 [to release];
55 [subject release];
56 [date release];
57 [content release];
58 [super dealloc];
59 }
60 -(DUMMailAddress *)from{
61 return from;
62 }
63 -(DUMMailAddress *)to{
64 return to;
65 }
66 -(NSString *)subject{
67 return subject;
68 }
69 -(NSCalendarDate *)date{
70 return date;
71 }
72 -(NSString *)content{
73 return content;
74 }
75 -(BOOL)isUnread{
76 return isUnread;
77 }
78 -(void)setIsUnread:(BOOL)flag{
79 isUnread = flag;
80 }
81 - (NSString *)description{
82 return [NSString stringWithFormat:@"From:%@\nTo:%@\nSubject:%@\n%@"
83 ,from, to, subject, content];
84 }
85 @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26