Develop and Download Open Source Software

Browse CVS Repository

Annotation of /undmail/guiproto/DUMMail.m

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


Revision 1.3 - (hide annotations) (download)
Fri Jan 31 17:49:12 2003 UTC (21 years, 2 months ago) by footashida
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +12 -1 lines
*** empty log message ***

1 footashida 1.1 #import "DUMMail.h"
2    
3     @implementation DUMMail
4 footashida 1.2 // Private Method
5 footashida 1.1 -(void)parseMailData:(NSString *)mailData{
6 footashida 1.3 // かなりいい加減な実装
7 footashida 1.1 NSRange textRange;
8     NSRange lineRange;
9     NSString *line;
10 footashida 1.3 NSMutableString *headerTextBuf;
11    
12     headerTextBuf = [NSMutableString stringWithCapacity:500];
13 footashida 1.1 textRange = NSMakeRange(0, [mailData length]);
14     while(textRange.length > 0){
15     lineRange = [mailData lineRangeForRange:
16     NSMakeRange(textRange.location, 0)];
17     line = [mailData substringWithRange:lineRange];
18     if([line hasPrefix:@"From: "]){
19 footashida 1.3 [headerTextBuf appendString:line];
20 footashida 1.2 from = [[DUMMailAddress alloc]
21     initWithMailAddressString:[line substringFromIndex:[@"From: " length]]];
22 footashida 1.1 [from retain];
23     }else if([line hasPrefix:@"To: "]){
24 footashida 1.3 [headerTextBuf appendString:line];
25 footashida 1.2 to = [[DUMMailAddress alloc]
26     initWithMailAddressString:[line substringFromIndex:[@"To: " length]]];
27 footashida 1.1 }else if([line hasPrefix:@"Subject: "]){
28 footashida 1.3 [headerTextBuf appendString:line];
29 footashida 1.1 subject = [line substringFromIndex:[@"Subject: " length]];
30     [subject retain];
31 footashida 1.2 }else if([line hasPrefix:@"Date: "]){
32 footashida 1.3 [headerTextBuf appendString:line];
33 footashida 1.2 NSString *dateString = [line substringFromIndex:[@"Date: " length]];
34     date = [NSCalendarDate dateWithString:dateString
35     calendarFormat:@"%a, %d %b %Y %H:%M:%S %z"];
36     [date retain];
37 footashida 1.1 }else if([line isEqual:@"\r\n"]){
38     content = [mailData substringFromIndex:textRange.location];
39     [content retain];
40 footashida 1.3 headerText = [[headerTextBuf description] retain];
41 footashida 1.1 return;
42     }else{
43     //無視
44     }
45    
46     textRange.location = NSMaxRange(lineRange);
47     textRange.length -= lineRange.length;
48     }
49     }
50 footashida 1.2 // Public Method
51 footashida 1.1 -(id)initWithMailData:(NSString *)mailData{
52     self = [super init];
53     subject = nil;
54     date = nil;
55     content = nil;
56     isUnread = YES;
57     [self parseMailData:mailData];
58     return self;
59     }
60     -(void)dealloc{
61     [from release];
62     [to release];
63     [subject release];
64     [date release];
65     [content release];
66     [super dealloc];
67     }
68 footashida 1.2 -(DUMMailAddress *)from{
69 footashida 1.1 return from;
70     }
71 footashida 1.2 -(DUMMailAddress *)to{
72 footashida 1.1 return to;
73     }
74     -(NSString *)subject{
75     return subject;
76     }
77 footashida 1.2 -(NSCalendarDate *)date{
78 footashida 1.1 return date;
79 footashida 1.3 }
80     -(NSString *)headerText{
81     return headerText;
82 footashida 1.1 }
83     -(NSString *)content{
84     return content;
85     }
86     -(BOOL)isUnread{
87     return isUnread;
88     }
89     -(void)setIsUnread:(BOOL)flag{
90     isUnread = flag;
91     }
92     - (NSString *)description{
93     return [NSString stringWithFormat:@"From:%@\nTo:%@\nSubject:%@\n%@"
94     ,from, to, subject, content];
95     }
96     @end

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