]> err.no Git - sope/blob - sope-mime/NGImap4/NGImap4MessageGlobalID.m
new Xcode projects
[sope] / sope-mime / NGImap4 / NGImap4MessageGlobalID.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #include "NGImap4MessageGlobalID.h"
23 #include "imCommon.h"
24
25 @implementation NGImap4MessageGlobalID
26
27 + (id)imap4MessageGlobalIDWithFolderGlobalID:(EOGlobalID *)_gid 
28   andUid:(unsigned int)_uid
29 {
30   NGImap4MessageGlobalID *gid;
31   
32   gid = [[self alloc] initWithFolderGlobalID:_gid andUid:_uid];
33   return [gid autorelease];
34 }
35
36 - (id)initWithFolderGlobalID:(EOGlobalID *)_gid andUid:(unsigned int)_uid {
37   if ((self = [super init])) {
38     self->folderGlobalID = [_gid retain];
39     self->uid            = _uid;
40   }
41   return self;
42 }
43 - (id)init {
44   return [self initWithFolderGlobalID:nil andUid:0];
45 }
46
47 - (void)dealloc {
48   [self->folderGlobalID release];
49   [super dealloc];
50 }
51
52 /* accessors */
53
54 - (EOGlobalID *)folderGlobalID {
55   return self->folderGlobalID;
56 }
57 - (unsigned int)uid {
58   return self->uid;
59 }
60
61 /* comparison */
62
63 - (unsigned)hash {
64   return self->uid;
65 }
66
67 - (BOOL)isEqualToImap4MessageGlobalID:(NGImap4MessageGlobalID *)_other {
68   if (_other == nil)
69     return NO;
70   if (self == _other)
71     return YES;
72   if (self->uid != _other->uid)
73     return NO;
74   
75   return (self->folderGlobalID == _other->folderGlobalID)
76     ? YES
77     : [self->folderGlobalID isEqual:_other->folderGlobalID];
78 }
79
80 - (BOOL)isEqual:(id)_otherObject {
81   if (_otherObject == self)
82     return YES;
83   if (![_otherObject isKindOfClass:[self class]])
84     return NO;
85   
86   return [self isEqualToImap4MessageGlobalID:_otherObject];
87 }
88
89 /* NSCopying */
90
91 - (id)copyWithZone:(NSZone *)_zone {
92   return [self retain];
93 }
94
95 /* compatibility to some older stuff */
96
97 - (NSString *)entityName {
98   return @"NGImap4Message";
99 }
100
101 // TODO: emulate EOKeyGlobalID
102
103 @end /* NGImap4MessageGlobalID */