mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-21 03:15:25 +00:00
Monotone-Parent: bacf416c77fa06cce947c93f090428795613d178
Monotone-Revision: 7f4d04c212fb046155310ec6e6fc96cc8c263d9f Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-08-02T20:04:23 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -199,11 +199,6 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)isWriteableClientObject {
|
||||
return [[self clientObject]
|
||||
respondsToSelector:@selector(saveContentString:)];
|
||||
}
|
||||
|
||||
- (NSString *)viewActionName {
|
||||
/* this is overridden in the mail based contacts UI to redirect to tb.edit */
|
||||
return @"";
|
||||
@@ -213,41 +208,55 @@
|
||||
return @"edit";
|
||||
}
|
||||
|
||||
- (id)saveAction {
|
||||
- (id) saveAction
|
||||
{
|
||||
NSException *ex;
|
||||
NSString *recstr, *uri;
|
||||
id record;
|
||||
NSString *uri;
|
||||
NSDictionary *record;
|
||||
NSMutableDictionary *newRecord;
|
||||
|
||||
if (![self isWriteableClientObject]) {
|
||||
return [NSException exceptionWithHTTPStatus:400 /* Bad Request */
|
||||
reason:@"method cannot be invoked on "
|
||||
@"the specified object"];
|
||||
}
|
||||
|
||||
if ((record = [self contentString]) == nil) {
|
||||
[self setErrorText:@"Missing object content!"]; // localize
|
||||
return self;
|
||||
}
|
||||
record = [[[record propertyList] mutableCopy] autorelease];
|
||||
if (record == nil) {
|
||||
[self setErrorText:@"Invalid property list data ..."]; // localize
|
||||
return self;
|
||||
}
|
||||
|
||||
[self saveValuesIntoRecord:record];
|
||||
|
||||
// TODO: directly hacking the content, hm, not so nice or reasonable?
|
||||
recstr = [record description]; // make plist
|
||||
ex = [[self clientObject] saveContentString:recstr];
|
||||
if (ex != nil) {
|
||||
[self setErrorText:[ex reason]];
|
||||
return self;
|
||||
}
|
||||
|
||||
uri = ([(uri = [self viewActionName]) length] > 0)
|
||||
? [self viewActionName] : @"..";
|
||||
uri = [self _completeURIForMethod:uri];
|
||||
return [self redirectToLocation:uri];
|
||||
if ([[self clientObject]
|
||||
respondsToSelector: @selector (saveContentString:)])
|
||||
{
|
||||
if (contentString)
|
||||
{
|
||||
record = [contentString propertyList];
|
||||
if (record)
|
||||
{
|
||||
newRecord = [[record mutableCopy] autorelease];
|
||||
[self saveValuesIntoRecord: newRecord];
|
||||
ex = [[self clientObject] saveRecord: newRecord];
|
||||
if (ex)
|
||||
{
|
||||
[self setErrorText: [ex reason]];
|
||||
|
||||
return self;
|
||||
}
|
||||
else
|
||||
{
|
||||
uri = [self viewActionName];
|
||||
if ([uri length] <= 0)
|
||||
uri = @"..";
|
||||
|
||||
return [self redirectToLocation: [self _completeURIForMethod: uri]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setErrorText: @"Invalid property list data ..."]; // localize
|
||||
return self;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setErrorText: @"Missing object content!"]; // localize
|
||||
return self;
|
||||
}
|
||||
}
|
||||
else
|
||||
return [NSException exceptionWithHTTPStatus: 400 /* Bad Request */
|
||||
reason: @"method cannot be invoked on "
|
||||
@"the specified object"];
|
||||
}
|
||||
|
||||
- (id)testAction {
|
||||
|
||||
Reference in New Issue
Block a user