Debian Codegraph @

Framework/Pantomime/CWVirtualFolder.m

raw
1 /*
2 ** CWVirtualFolder.m
3 **
4 ** Copyright (c) 2003-2004 Ludovic Marcotte
5 ** Copyright (C) 2022 Riccardo Mottola
6 **
7 ** Author: Ludovic Marcotte <[email protected]>
8 **
9 ** This library is free software; you can redistribute it and/or
10 ** modify it under the terms of the GNU Lesser General Public
11 ** License as published by the Free Software Foundation; either
12 ** version 2.1 of the License, or (at your option) any later version.
13 **
14 ** This library is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ** Lesser General Public License for more details.
18 **
19 ** You should have received a copy of the GNU General Public License
20 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #import <Pantomime/CWVirtualFolder.h>
24
25 #import <Pantomime/CWConstants.h>
26
27 //
28 //
29 //
30 @implementation CWVirtualFolder
31
32 - (id) initWithName: (NSString *) theName
33 {
34 self = [super initWithName: theName];
35 if (self)
36 {
37 _allFolders = [[NSMutableArray alloc] init];
38 }
39 return self;
40 }
41
42
43 //
44 //
45 //
46 - (void) dealloc
47 {
48 RELEASE(_allFolders);
49 [super dealloc];
50 }
51
52
53 //
54 // New, VitualFolder specific methods.
55 //
56 - (void) addFolder: (CWFolder *) theFolder
57 {
58 NSMutableArray *aMutableArray;
59
60 if (!theFolder) return;
61
62 [_allFolders addObject: theFolder];
63
64 aMutableArray = [[NSMutableArray alloc] initWithArray: self->_allMessages];
65 [aMutableArray addObjectsFromArray: [theFolder messages]];
66 [super setMessages: aMutableArray];
67 RELEASE(aMutableArray);
68 }
69
70 - (void) removeFolder: (CWFolder *) theFolder
71 {
72 if (!theFolder) return;
73
74 [_allFolders removeObject: theFolder];
75 }
76
77
78 //
79 // Re-implementations of some methods
80 //
81 - (void) close
82 {
83 [_allFolders makeObjectsPerformSelector: @selector(close)];
84 [_allFolders removeAllObjects];
85 }
86
87
88 //
89 // When doing an expunge on a virtual folder, we must re-initialize
90 // the allMessages ivar since it's holding messages potentially removed
91 // from the real Folder objects.
92 //
93 #warning FIXME
94 - (void) expunge: (BOOL) returnDeletedMessages
95 {
96 #if 0
97 NSMutableArray *aMutableArray;
98 int i;
99
100 aMutableArray = [[NSMutableArray alloc] init];
101 [self->allMessages removeAllObjects];
102
103 for (i = 0; i < [_allFolders count]; i++)
104 {
105 // We first expunge all messages
106 [aMutableArray addObjectsFromArray: [[_allFolders objectAtIndex: i] expunge: returnDeletedMessages]];
107
108 // We add back our messages...
109 [self->allMessages addObjectsFromArray: ((Folder *)[_allFolders objectAtIndex: i])->allMessages];
110 }
111
112 [self updateCache];
113
114 return AUTORELEASE(aMutableArray);
115 #endif
116 }
117
118
119 //
120 // When we search in a virtual folder, we search in all folders and
121 // we concatenate all the search results.
122 //
123 - (void) search: (NSString *) theString
124 mask: (PantomimeSearchMask) theMask
125 options: (PantomimeSearchOption) theOptions
126 {
127 #warning FIXME
128 #if 0
129 NSMutableArray *aMutableArray;
130 int i;
131
132 aMutableArray = [[NSMutableArray alloc] init];
133
134 for (i = 0; i < [_allFolders count]; i++)
135 {
136 [aMutableArray addObjectsFromArray: [[_allFolders objectAtIndex: i] search: theString
137 mask: theMask
138 options: theOptions]];
139 }
140
141 AUTORELEASE(aMutableArray);
142 #endif
143 }
144
145
146 - (void) setDelegate: (id) theDelegate
147 {
148 // Go through all IMAP folder and set it.
149 }
150
151 @end