2015-11-04 16:38:24 +01:00
|
|
|
/* UIxContactFolderProperties.m - this file is part of SOGo
|
|
|
|
*
|
2018-08-31 04:09:17 +02:00
|
|
|
* Copyright (C) 2015-2018 Inverse inc.
|
2015-11-04 16:38:24 +01:00
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSValue.h>
|
|
|
|
|
2018-08-31 04:09:17 +02:00
|
|
|
#import <NGObjWeb/NSException+HTTP.h>
|
2015-11-04 16:38:24 +01:00
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
|
2018-08-31 04:09:17 +02:00
|
|
|
#import <SOGo/NSDictionary+Utilities.h>
|
2015-11-04 16:38:24 +01:00
|
|
|
#import <SOGo/NSString+Utilities.h>
|
|
|
|
|
|
|
|
#import <Contacts/SOGoContactGCSFolder.h>
|
|
|
|
|
|
|
|
#import "UIxContactFolderProperties.h"
|
|
|
|
|
|
|
|
@implementation UIxContactFolderProperties
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
addressbook = [self clientObject];
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @api {post} /so/:username/Contacts/:addressbookId/save Save addressbook
|
|
|
|
* @apiDescription Save an addressbook's properties.
|
|
|
|
* @apiVersion 1.0.0
|
|
|
|
* @apiName PostSaveProperties
|
|
|
|
* @apiGroup AddressBook
|
|
|
|
*
|
|
|
|
* @apiParam {String} name Human readable name
|
|
|
|
* @apiParam {Number} synchronize 1 if we enable EAS synchronization for this addressbook
|
|
|
|
*/
|
|
|
|
- (WOResponse *) savePropertiesAction
|
|
|
|
{
|
|
|
|
WORequest *request;
|
2018-08-31 04:09:17 +02:00
|
|
|
WOResponse *response;
|
|
|
|
NSDictionary *params, *message;
|
2016-02-10 21:17:19 +01:00
|
|
|
id o;
|
2015-11-04 16:38:24 +01:00
|
|
|
|
|
|
|
request = [context request];
|
|
|
|
params = [[request contentAsString] objectFromJSONString];
|
2018-08-31 04:09:17 +02:00
|
|
|
response = [self responseWith204];
|
2015-11-04 16:38:24 +01:00
|
|
|
|
2018-08-31 04:09:17 +02:00
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
o = [params objectForKey: @"name"];
|
2019-03-19 19:41:02 +01:00
|
|
|
if ([o isKindOfClass: [NSString class]] && ![o isEqualToString: [addressbook displayName]])
|
2018-08-31 04:09:17 +02:00
|
|
|
[addressbook renameTo: o];
|
2015-11-04 16:38:24 +01:00
|
|
|
|
2018-08-31 04:09:17 +02:00
|
|
|
o = [params objectForKey: @"synchronize"];
|
|
|
|
if ([o isKindOfClass: [NSNumber class]])
|
|
|
|
[addressbook setSynchronize: [o boolValue]];
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
message = [NSDictionary dictionaryWithObject: [localException reason] forKey: @"message"];
|
|
|
|
response = [self responseWithStatus: 400 /* Bad Request */
|
|
|
|
andString: [message jsonRepresentation]];
|
|
|
|
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
2015-11-04 16:38:24 +01:00
|
|
|
|
2018-08-31 04:09:17 +02:00
|
|
|
return response;
|
2015-11-04 16:38:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|