mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-19 18:35:25 +00:00
progress
This commit is contained in:
+3
-1
@@ -9,7 +9,9 @@ API_PRINCIPAL_CLASS = SOGoAPIProduct
|
||||
|
||||
API_OBJC_FILES = \
|
||||
SOGoAPIProduct.m \
|
||||
SOGoAPI.m
|
||||
SOGoAPI.m \
|
||||
SOGoAPIVersion.m \
|
||||
SOGoAPIDispatcher.m
|
||||
|
||||
API_RESOURCE_FILES += \
|
||||
product.plist
|
||||
|
||||
+4
-1
@@ -22,7 +22,10 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSArray.h>
|
||||
|
||||
@interface SOGoAPI : NSObject
|
||||
- (NSDictionary *) sogoVersionAction;
|
||||
- (NSArray *) methodAllowed;
|
||||
- (NSDictionary *) action;
|
||||
|
||||
@end
|
||||
|
||||
+28
-9
@@ -7,16 +7,35 @@
|
||||
|
||||
@implementation SOGoAPI
|
||||
|
||||
- (NSDictionary *) sogoVersionAction {
|
||||
NSDictionary* result;
|
||||
- (id) init
|
||||
{
|
||||
[super init];
|
||||
|
||||
result = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
@"major", SOGO_MAJOR_VERSION,
|
||||
@"minor", SOGO_MINOR_VERSION,
|
||||
@"patch", SOGO_PATCH_VERSION,
|
||||
nil];
|
||||
[result autorelease];
|
||||
return result;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSArray *) methodAllowed
|
||||
{
|
||||
NSArray *result;
|
||||
|
||||
result = [NSArray arrayWithObjects:@"GET",nil];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSDictionary *) action
|
||||
{
|
||||
NSDictionary* result;
|
||||
|
||||
result = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
@"API not defined", @"error",
|
||||
nil];
|
||||
[result autorelease];
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2014-2015, Inverse inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Inverse inc. nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <SOGo/WORequest+SOGo.h>
|
||||
#import <SOGo/WOResponse+SOGo.h>
|
||||
|
||||
@class NSCalendarDate;
|
||||
@class NSException;
|
||||
@class NSMutableDictionary;
|
||||
@class NSURL;
|
||||
@class NSNumber;
|
||||
|
||||
static volatile BOOL apiShouldTerminate = NO;
|
||||
|
||||
@interface SOGoAPIDispatcher : NSObject
|
||||
{
|
||||
|
||||
id context;
|
||||
BOOL debugOn;
|
||||
}
|
||||
|
||||
- (NSException *) dispatchRequest: (WORequest*) theRequest
|
||||
inResponse: (WOResponse*) theResponse
|
||||
context: (id) theContext;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2014, Inverse inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Inverse inc. nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "SOGoAPIDispatcher.h"
|
||||
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSProcessInfo.h>
|
||||
#import <Foundation/NSTimeZone.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
#import <NGObjWeb/NSException+HTTP.h>
|
||||
#import <NGObjWeb/SoPermissions.h>
|
||||
#import <NGObjWeb/SoSecurityManager.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <NGObjWeb/WOCoreApplication.h>
|
||||
|
||||
#import <NGCards/iCalCalendar.h>
|
||||
#import <NGCards/iCalEvent.h>
|
||||
#import <NGCards/iCalAlarm.h>
|
||||
#import <NGCards/iCalPerson.h>
|
||||
|
||||
#import <NGExtensions/NGBase64Coding.h>
|
||||
|
||||
#import <NGExtensions/NSCalendarDate+misc.h>
|
||||
#import <NGExtensions/NGCalendarDateRange.h>
|
||||
#import <NGExtensions/NGHashMap.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
#import <NGExtensions/NSString+misc.h>
|
||||
#import <NGExtensions/NSString+Encoding.h>
|
||||
|
||||
#import <SOGo/NSArray+DAV.h>
|
||||
#import <SOGo/NSDictionary+DAV.h>
|
||||
#import <SOGo/SOGoCache.h>
|
||||
#import <SOGo/SOGoCacheGCSObject.h>
|
||||
#import <SOGo/SOGoDAVAuthenticator.h>
|
||||
#import <SOGo/SOGoMailer.h>
|
||||
#import <SOGo/SOGoSystemDefaults.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoUserFolder.h>
|
||||
#import <SOGo/SOGoUserManager.h>
|
||||
#import <SOGo/GCSSpecialQueries+SOGoCacheObject.h>
|
||||
#import <SOGo/NSString+Utilities.h>
|
||||
#import <SOGo/WORequest+SOGo.h>
|
||||
#import <SOGo/WOResponse+SOGo.h>
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
#import <SOGo/NSString+Utilities.h>
|
||||
#import <SOGo/SOGoPermissions.h>
|
||||
|
||||
void handle_api_terminate(int signum)
|
||||
{
|
||||
NSLog(@"Forcing termination of API loop.");
|
||||
apiShouldTerminate = YES;
|
||||
[[WOCoreApplication application] terminateAfterTimeInterval: 1];
|
||||
}
|
||||
|
||||
@implementation SOGoAPIDispatcher
|
||||
|
||||
- (id) init
|
||||
{
|
||||
[super init];
|
||||
|
||||
debugOn = [[SOGoSystemDefaults sharedSystemDefaults] apiDebugEnabled];
|
||||
apiShouldTerminate = NO;
|
||||
|
||||
signal(SIGTERM, handle_api_terminate);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSException *) dispatchRequest: (WORequest*) theRequest
|
||||
inResponse: (WOResponse*) theResponse
|
||||
context: (id) theContext
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
id activeUser;
|
||||
NSString *method, *action;
|
||||
NSDictionary *form;
|
||||
NSMutableDictionary *ret;
|
||||
NSBundle *bundle;
|
||||
id classAction;
|
||||
Class clazz;
|
||||
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
ASSIGN(context, theContext);
|
||||
|
||||
activeUser = [context activeUser];
|
||||
|
||||
//Get the api action, check it
|
||||
action = [theRequest uri]; //il retourne /SOGo/SOGoAPI
|
||||
|
||||
|
||||
bundle = [NSBundle bundleForClass: NSClassFromString(@"SOGoAPIProduct")];
|
||||
clazz = [bundle classNamed: @"SOGoAPIVersion"];
|
||||
classAction = [[clazz alloc] init];
|
||||
|
||||
//Check user auth
|
||||
|
||||
//retreive data if needed and execute action
|
||||
ret = [classAction action];
|
||||
|
||||
//Make the response
|
||||
[theResponse setContent: [ret jsonRepresentation]];
|
||||
|
||||
RELEASE(context);
|
||||
RELEASE(pool);
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of SOPE.
|
||||
|
||||
SOPE is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
SOPE 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with SOPE; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <SOGoAPI.h>
|
||||
|
||||
@interface SOGoAPIVersion : SOGoAPI
|
||||
- (NSArray *) methodAllowed;
|
||||
- (NSDictionary *) action;
|
||||
@end
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright (C) todo...
|
||||
*/
|
||||
|
||||
#import <SOGoAPIVersion.h>
|
||||
|
||||
|
||||
@implementation SOGoAPIVersion
|
||||
|
||||
- (id) init
|
||||
{
|
||||
[super init];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSDictionary *) action {
|
||||
NSDictionary* result;
|
||||
|
||||
result = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
[NSNumber numberWithInt:SOGO_MAJOR_VERSION], @"major",
|
||||
[NSNumber numberWithInt:SOGO_MINOR_VERSION], @"minor",
|
||||
[NSNumber numberWithInt:SOGO_PATCH_VERSION], @"patch",
|
||||
nil];
|
||||
|
||||
[result autorelease];
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@end /* SOGoAPIVersion */
|
||||
@@ -48,12 +48,12 @@
|
||||
Class clazz;
|
||||
|
||||
request = (WORequest *)[context request];
|
||||
response = [context response];
|
||||
response = (WOResponse *)[context response];
|
||||
[response setStatus: 200];
|
||||
[response setHeader: @"text/plain; charset=utf-8" forKey: @"content-type"];
|
||||
[response setHeader: @"application/json; charset=utf-8" forKey: @"content-type"];
|
||||
|
||||
bundle = [NSBundle bundleForClass: NSClassFromString(@"SOGoAPIProduct")];
|
||||
clazz = [bundle classNamed: @"SOGoApiDispatcher"];
|
||||
clazz = [bundle classNamed: @"SOGoAPIDispatcher"];
|
||||
dispatcher = [[clazz alloc] init];
|
||||
|
||||
ex = [dispatcher dispatchRequest: request inResponse: response context: context];
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
RELEASE(dispatcher);
|
||||
|
||||
[[SOGoCache sharedCache] killCache];
|
||||
//[[SOGoCache sharedCache] killCache];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
SOGoAPI = {
|
||||
protectedBy = "<public>";
|
||||
actionClass = "SOGoAPIActions";
|
||||
actionName = "sogoAPIAction";
|
||||
actionName = "sogoAPI";
|
||||
};
|
||||
casProxy = {
|
||||
protectedBy = "<public>";
|
||||
|
||||
Reference in New Issue
Block a user