]> err.no Git - sope/blob - sope-mime/NGMime/NGImap4/NGImap4MessageGlobalID.m
more directory hierarchy reorganisations,
[sope] / sope-mime / NGMime / NGImap4 / NGImap4MessageGlobalID.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OGo
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 // $Id$
22
23 #include "NGImap4MessageGlobalID.h"
24 #include "common.h"
25
26 @implementation NGImap4MessageGlobalID
27
28 + (id)imap4MessageGlobalIDWithFolderGlobalID:(EOGlobalID *)_gid 
29   andUid:(unsigned int)_uid
30 {
31   NGImap4MessageGlobalID *gid;
32   
33   gid = [[self alloc] initWithFolderGlobalID:_gid andUid:_uid];
34   return [gid autorelease];
35 }
36
37 - (id)initWithFolderGlobalID:(EOGlobalID *)_gid andUid:(unsigned int)_uid {
38   if ((self = [super init])) {
39     self->folderGlobalID = [_gid retain];
40     self->uid            = _uid;
41   }
42   return self;
43 }
44 - (id)init {
45   return [self initWithFolderGlobalID:nil andUid:0];
46 }
47
48 - (void)dealloc {
49   [self->folderGlobalID release];
50   [super dealloc];
51 }
52
53 /* accessors */
54
55 - (EOGlobalID *)folderGlobalID {
56   return self->folderGlobalID;
57 }
58 - (unsigned int)uid {
59   return self->uid;
60 }
61
62 /* comparison */
63
64 - (unsigned)hash {
65   return self->uid;
66 }
67
68 - (BOOL)isEqualToImap4MessageGlobalID:(NGImap4MessageGlobalID *)_other {
69   if (_other == nil)
70     return NO;
71   if (self == _other)
72     return YES;
73   if (self->uid != _other->uid)
74     return NO;
75   
76   return (self->folderGlobalID == _other->folderGlobalID)
77     ? YES
78     : [self->folderGlobalID isEqual:_other->folderGlobalID];
79 }
80
81 - (BOOL)isEqual:(id)_otherObject {
82   if (_otherObject == self)
83     return YES;
84   if (![_otherObject isKindOfClass:[self class]])
85     return NO;
86   
87   return [self isEqualToImap4MessageGlobalID:_otherObject];
88 }
89
90 /* NSCopying */
91
92 - (id)copyWithZone:(NSZone *)_zone {
93   return [self retain];
94 }
95
96 /* compatibility to some older stuff */
97
98 - (NSString *)entityName {
99   return @"NGImap4Message";
100 }
101
102 // TODO: emulate EOKeyGlobalID
103
104 @end /* NGImap4MessageGlobalID */