]> err.no Git - sope/blob - sope-mime/NGImap4/NGImap4MailboxInfo.m
synced with latest additions and bumped framework versions
[sope] / sope-mime / NGImap4 / NGImap4MailboxInfo.m
1 /*
2   Copyright (C) 2005 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 "NGImap4MailboxInfo.h"
23 #include "imCommon.h"
24
25 @implementation NGImap4MailboxInfo
26
27 - (id)initWithURL:(NSURL *)_url folderName:(NSString *)_name
28   selectDictionary:(NSDictionary *)_dict
29 {
30   if (_dict == nil || (_url == nil && _name == nil)) {
31     [self release];
32     return nil;
33   }
34   
35   if ((self = [super init])) {
36     self->timestamp    = [[NSDate alloc] init];
37     self->url          = [_url  copy];
38     self->name         = [_name copy];
39     self->allowedFlags = [[_dict objectForKey:@"flags"]  copy];
40     self->access       = [[_dict objectForKey:@"access"] copy];
41     self->recent       = [[_dict objectForKey:@"recent"] unsignedIntValue];
42   }
43   return self;
44 }
45 - (id)init {
46   return [self initWithURL:nil folderName: nil selectDictionary:nil];
47 }
48
49 - (void)dealloc {
50   [self->timestamp    release];
51   [self->url          release];
52   [self->name         release];
53   [self->allowedFlags release];
54   [self->access       release];
55   [super dealloc];
56 }
57
58 /* accessors */
59
60 - (NSDate *)timestamp {
61   return self->timestamp;
62 }
63 - (NSURL *)url {
64   return self->url;
65 }
66 - (NSString *)name {
67   return self->name;
68 }
69 - (NSArray *)allowedFlags {
70   return self->allowedFlags;
71 }
72 - (NSString *)access {
73   return self->access;
74 }
75 - (unsigned int)recent {
76   return self->recent;
77 }
78
79 /* description */
80
81 - (void)appendAttributesToDescription:(NSMutableString *)_ms {
82   if (self->name)   [_ms appendFormat:@" name=%@",  self->name];
83   if (self->access) [_ms appendFormat:@" access=%@",  self->access];
84   
85   if (self->recent != 0) [_ms appendFormat:@" recent=%d", self->recent];
86
87   [_ms appendFormat:@" flags=%@", 
88        [[self allowedFlags] componentsJoinedByString:@","]];
89 }
90
91 - (NSString *)description {
92   NSMutableString *ms;
93
94   ms = [NSMutableString stringWithCapacity:64];
95   [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
96   [self appendAttributesToDescription:ms];
97   [ms appendString:@">"];
98   return ms;
99 }
100
101 @end /* NGImap4MailboxInfo */