From 1c7e5b8680e4ae39137cf35062275eaec8bfacad Mon Sep 17 00:00:00 2001 From: C Robert Date: Fri, 21 Aug 2009 17:41:52 +0000 Subject: [PATCH] Improvement for list display Monotone-Parent: 08fdc5d0a9471051564e0739b2dd3367c1e5143a Monotone-Revision: de4013a540009902497a1085be5975e4ff6c3a83 Monotone-Author: crobert@inverse.ca Monotone-Date: 2009-08-21T17:41:52 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 2 ++ UI/Contacts/UIxListView.h | 2 ++ UI/Contacts/UIxListView.m | 45 +++++++++++++++++++++++++++++++++++---- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f747412c8..ad5ec27ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2009-08-21 Cyril Robert * UI/Contacts/UIxListView.m: Implementation, allows VLISTs to be displayed. + * UI/Contacts/UIxListView.m (checkListReferences): Added list integrity + verification (make sure all references are valid). 2009-08-21 Wolfgang Sourdeau diff --git a/UI/Contacts/UIxListView.h b/UI/Contacts/UIxListView.h index 40f43ab84..09d89b000 100644 --- a/UI/Contacts/UIxListView.h +++ b/UI/Contacts/UIxListView.h @@ -24,10 +24,12 @@ #define UIXLISTVIEW_H #import +#import @interface UIxListView : UIxComponent { NGVList *list; + SOGoContactGCSList *co; id item; } diff --git a/UI/Contacts/UIxListView.m b/UI/Contacts/UIxListView.m index b23aa3bd5..b075c80c7 100644 --- a/UI/Contacts/UIxListView.m +++ b/UI/Contacts/UIxListView.m @@ -24,6 +24,7 @@ #import #import #import +#import #import "UIxListView.h" @@ -61,20 +62,56 @@ { NSString *rc; - rc = [NSString stringWithFormat: @"%@ <%@>", [item fn], [item email]]; + rc = [NSString stringWithFormat: @"%@ <%@>", + [item fn], [item email]]; return rc; } +- (void) checkListReferences +{ + NSMutableArray *invalid; + NGVCardReference *card; + int i, count; + id test; + + invalid = [NSMutableArray array]; + + count = [[list cardReferences] count]; + for (i = 0; i < count; i++) + { + card = [[list cardReferences] objectAtIndex: i]; + test = [[co container] lookupName: [card reference] + inContext: context + acquire: NO]; + if ([test isKindOfClass: [NSException class]]) + { + NSLog (@"%@ not found", [card reference]); + [invalid addObject: [card copy]]; + } + } + + count = [invalid count]; + if (count > 0) + { + for (i = 0; i < count; i++) + [list deleteCardReference: [invalid objectAtIndex: i]]; + [co save]; + } +} + - (id ) defaultAction { id rc; - list = [[self clientObject] vList]; - //TODO: make sure references are valid + co = [self clientObject]; + list = [co vList]; if (list) - rc = self; + { + [self checkListReferences]; + rc = self; + } else rc = [NSException exceptionWithHTTPStatus: 404 /* Not Found */ reason: @"could not locate contact"];