-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTBContentId.m
executable file
·73 lines (57 loc) · 1.4 KB
/
TBContentId.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* TBContentId.m created by todd on Fri 16-Jun-2000 */
#import "TBContentId.h"
#import "TBPrivateUtilities.h"
@interface TBContentId (PrivateAccessor)
-(NSString *)__cid;
@end
@implementation TBContentId (PrivateAccessor)
-(NSString *)__cid { return _id; }
@end
@implementation TBContentId
+(id)headerWithString:(NSString *)str
{
return [[[self alloc] initWithString: str] autorelease];
}
-initWithString:(NSString *)str
{
// remove < and >
NSString *s = [str trimmedString];
NSRange r = { 0, [s length] };
if(([s characterAtIndex: 0] == '<') && ([s characterAtIndex: [s length]-1] == '>'))
{
r.length -= 2;
r.location += 1;
s = [s substringWithRange: r];
}
_id = [s retain];
return self;
}
-init
{
[super init];
_id = [[[NSProcessInfo processInfo] globallyUniqueString] retain];
return self;
}
-(NSData *)messageData
{
return [[NSString stringWithFormat:@"%@",_id] dataUsingEncoding: NSASCIIStringEncoding];
}
-(NSString *)idString
// returns the contentId value as a string, e.g. khawk1_234_5678_3.
{
return [NSString stringWithFormat:@"%@", _id];
}
-(NSString *)description
{
return [[[self class] description] stringByAppendingFormat: @": <%@>",_id];
}
-(BOOL)isEqual:(id)object
{
return ([self class] == [object class]) && [_id isEqualToString: [object __cid]];
}
-(void)dealloc
{
[_id release];
[super dealloc];
}
@end