]> err.no Git - sope/blob - sope-mime/NGImap4/NGImap4FolderFlags.m
fixed OGo bug #1899
[sope] / sope-mime / NGImap4 / NGImap4FolderFlags.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 "NGImap4FolderFlags.h"
23 #include "imCommon.h"
24
25 @implementation NGImap4FolderFlags
26
27 - (id)initWithFlagArray:(NSArray *)_array {
28   if ((self = [super init])) {
29     self->flags = [_array copy];
30
31     // TODO: this is pretty weird
32     self->listFlags.noselect    = [self->flags containsObject:@"noselect"];
33     self->listFlags.noinferiors = [self->flags containsObject:@"noinferiors"];
34     self->listFlags.nonexistent = [self->flags containsObject:@"nonexistent"];
35     self->listFlags.haschildren = [self->flags containsObject:@"haschildren"];
36     self->listFlags.marked      = [self->flags containsObject:@"marked"];
37     self->listFlags.unmarked    = [self->flags containsObject:@"unmarked"];
38     
39     self->listFlags.hasnochildren = 
40       [self->flags containsObject:@"hasnochildren"];
41   }
42   return self;
43 }
44 - (id)init {
45   return [self initWithFlagArray:nil];
46 }
47
48 - (void)dealloc {
49   [self->flags release];
50   [super dealloc];
51 }
52
53 /* accessors */
54
55 - (NSArray *)flagArray {
56   return self->flags;
57 }
58
59 - (BOOL)doNotSelectFolder {
60   return self->listFlags.noselect ? YES : NO;
61 }
62 - (BOOL)doesNotSupportSubfolders {
63   return self->listFlags.noinferiors ? YES : NO;
64 }
65 - (BOOL)doesNotExist {
66   return self->listFlags.nonexistent ? YES : NO;
67 }
68 - (BOOL)hasSubfolders {
69   return self->listFlags.haschildren ? YES : NO;
70 }
71 - (BOOL)hasNoSubfolders {
72   return self->listFlags.hasnochildren ? YES : NO;
73 }
74 - (BOOL)isMarked {
75   return self->listFlags.marked ? YES : NO;
76 }
77 - (BOOL)isUnmarked {
78   return self->listFlags.unmarked ? YES : NO;
79 }
80
81 /* operations */
82
83 - (void)allowFolderSelect {
84   NSMutableArray *ma;
85   NSArray *tmp;
86   
87   self->listFlags.noselect = NO;
88   
89   tmp = self->flags;
90   ma = [tmp mutableCopy];
91   [ma removeObject:@"noselect"];
92   self->flags = [ma copy];
93   [tmp release];
94 }
95
96 @end /* NGImap4FolderFlags */