]> err.no Git - sope/blob - sope-mime/NGImap4/NGImap4ServerGlobalID.m
Add libxml2-dev to libsope-xml4.7-dev deps
[sope] / sope-mime / NGImap4 / NGImap4ServerGlobalID.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE 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   SOPE 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 SOPE; 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 "NGImap4ServerGlobalID.h"
23 #include "imCommon.h"
24
25 @implementation NGImap4ServerGlobalID
26
27 + (id)imap4ServerGlobalIDForHostname:(NSString *)_host port:(int)_port
28   login:(NSString *)_login
29 {
30   NGImap4ServerGlobalID *gid;
31
32   gid = [[self alloc] initWithHostname:_host port:_port login:_login];
33   return [gid autorelease];
34 }
35
36 - (id)initWithHostname:(NSString *)_host port:(int)_p login:(NSString *)_l {
37   if ((self = [super init])) {
38     self->hostName = [_host copy];
39     self->login    = [_l    copy];
40     self->port     = _p;
41   }
42   return self;
43 }
44 - (id)init {
45   return [self initWithHostname:nil port:0 login:nil];
46 }
47
48 - (void)dealloc {
49   [self->hostName release];
50   [self->login    release];
51   [super dealloc];
52 }
53
54 /* accessors */
55
56 - (NSString *)hostName {
57   return self->hostName;
58 }
59 - (NSString *)login {
60   return self->login;
61 }
62 - (int)port {
63   return self->port;
64 }
65
66 /* comparison */
67
68 - (unsigned)hash {
69   return [self->login hash];
70 }
71
72 - (BOOL)isEqualToImap4ServerGlobalID:(NGImap4ServerGlobalID *)_other {
73   if (_other == nil)
74     return NO;
75   if (self == _other)
76     return YES;
77   
78   if (self->login != _other->login) {
79     if (![self->login isEqualToString:_other->login])
80       return NO;
81   }
82   if (self->hostName != _other->hostName) {
83     if (![self->hostName isEqualToString:_other->hostName])
84       return NO;
85   }
86   if (self->port != _other->port)
87     return NO;
88   
89   return YES;
90 }
91
92 - (BOOL)isEqual:(id)_otherObject {
93   if (_otherObject == self)
94     return YES;
95   if (![_otherObject isKindOfClass:[self class]])
96     return NO;
97   
98   return [self isEqualToImap4ServerGlobalID:_otherObject];
99 }
100
101 /* NSCopying */
102
103 - (id)copyWithZone:(NSZone *)_zone {
104   return [self retain];
105 }
106
107 /* support for some older code expecting only EO global IDs */
108
109 - (NSString *)entityName {
110   return @"NGImap4Client";
111 }
112
113 @end /* NGImap4ServerGlobalID */