]> err.no Git - scalable-opengroupware.org/blob - UI/Contacts/UIxContactsListView.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1026 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / Contacts / UIxContactsListView.m
1 /*
2   Copyright (C) 2004-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 #import <Contacts/SOGoContactObject.h>
23 #import <Contacts/SOGoContactFolder.h>
24 #import <Contacts/SOGoContactFolders.h>
25
26 #import "common.h"
27
28 #import "UIxContactsListView.h"
29
30 @implementation UIxContactsListView
31
32 - (id) init
33 {
34   if ((self = [super init]))
35     {
36       selectorComponentClass = nil;
37     }
38
39   return self;
40 }
41
42 - (void) dealloc
43 {
44   if (searchText)
45     [searchText release];
46   [super dealloc];
47 }
48
49 /* accessors */
50
51 - (void) setCurrentContact: (NSDictionary *) _contact
52 {
53   currentContact = _contact;
54 }
55
56 - (NSDictionary *) currentContact
57 {
58   return currentContact;
59 }
60
61 - (void) setSearchText: (NSString *) _txt
62 {
63   ASSIGNCOPY (searchText, _txt);
64 }
65
66 - (id) searchText
67 {
68   if (!searchText)
69     [self setSearchText: [self queryParameterForKey:@"search"]];
70
71   return searchText;
72 }
73
74 - (NSString *) selectorComponentClass
75 {
76   return selectorComponentClass;
77 }
78
79 - (id) mailerContactsAction
80 {
81   selectorComponentClass = @"UIxContactsMailerSelection";
82
83   return self;
84 }
85
86 - (id) calendarsContactsAction
87 {
88   selectorComponentClass = @"UIxContactsCalendarsSelection";
89
90   return self;
91 }
92
93 - (id) addressBooksContactsAction
94 {
95   selectorComponentClass = @"UIxContactsAddressBooksSelection";
96
97   return self;
98 }
99
100 - (id) aclsContactsAction
101 {
102   selectorComponentClass = @"UIxContactsAclsSelection";
103
104   return self;
105 }
106
107 - (NSString *) defaultSortKey
108 {
109   return @"fn";
110 }
111
112 - (NSString *) displayName
113 {
114   NSString *displayName;
115
116   displayName = [currentContact objectForKey: @"displayName"];
117   if (!(displayName && [displayName length] > 0))
118     displayName = [currentContact objectForKey: @"cn"];
119
120   return displayName;
121 }
122
123 - (NSString *) sortKey
124 {
125   NSString *s;
126   
127   s = [self queryParameterForKey: @"sort"];
128   if ([s length] == 0)
129     s = [self defaultSortKey];
130
131   return s;
132 }
133
134 - (NSComparisonResult) sortOrdering
135 {
136   return ([[self queryParameterForKey:@"desc"] boolValue]
137           ? NSOrderedDescending
138           : NSOrderedAscending);
139 }
140
141 - (NSArray *) contactInfos
142 {
143   id <SOGoContactFolder> folder;
144
145   folder = [self clientObject];
146
147   return [folder lookupContactsWithFilter: [self searchText]
148                  sortBy: [self sortKey]
149                  ordering: [self sortOrdering]];
150 }
151
152 /* notifications */
153
154 - (void) sleep
155 {
156   if (searchText)
157     {
158       [searchText release];
159       searchText = nil;
160     }
161   currentContact = nil;
162 //   [allRecords release];
163 //   allRecords = nil;
164 //   [filteredRecords release];
165 //   filteredRecords = nil;
166   [super sleep];
167 }
168
169 /* actions */
170
171 - (BOOL) shouldTakeValuesFromRequest: (WORequest *) _rq
172                            inContext: (WOContext*) _c
173 {
174   return YES;
175 }
176
177 @end /* UIxContactsListView */