Commit 351479e5 authored by Romain Bertozzi's avatar Romain Bertozzi

system adapter: add files

This patchs adds the system adapter files.
They are meant to make the bridge between the daemon and the app
concerning system related communications.
It also registers handles to daemon callbacks.

Tuleap: #1550
Change-Id: Ib07c391afb1ddb0ec1207cc36c4b2a05675fe41b
Reviewed-by: default avatarSilbino Gonçalves Matado <silbino.gmatado@savoirfairelinux.com>
parent 37f3359d
......@@ -108,6 +108,7 @@
5557FD4D1E81AFF50043E394 /* ConfigKeyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02DD80CC1E1EB2E4009A3510 /* ConfigKeyModel.swift */; };
5557FD4E1E81B1F20043E394 /* AccountModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5516C29E1E71CEFF009D3D2D /* AccountModelHelper.swift */; };
5557FD4F1E81B2990043E394 /* AccountCredentialsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02DD80C91E1EAF1A009A3510 /* AccountCredentialsModel.swift */; };
557086521E8ADB9D001A7CE4 /* SystemAdapter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 557086511E8ADB9D001A7CE4 /* SystemAdapter.mm */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -238,6 +239,8 @@
5516C29E1E71CEFF009D3D2D /* AccountModelHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AccountModelHelper.swift; path = Account/AccountModelHelper.swift; sourceTree = "<group>"; };
56AC64D41E7C7F4000EA1AA9 /* WelcomeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WelcomeViewController.swift; sourceTree = "<group>"; };
5557FD491E81AE850043E394 /* AccountModelHelperTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountModelHelperTests.swift; sourceTree = "<group>"; };
557086501E8ADB9D001A7CE4 /* SystemAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SystemAdapter.h; path = Bridging/SystemAdapter.h; sourceTree = "<group>"; };
557086511E8ADB9D001A7CE4 /* SystemAdapter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SystemAdapter.mm; path = Bridging/SystemAdapter.mm; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -403,6 +406,8 @@
04399AA91D1C304300E99CD9 /* Ring-Bridging-Header.h */,
04399AA51D1C304300E99CD9 /* AccountAdapter.h */,
04399AA61D1C304300E99CD9 /* AccountAdapter.mm */,
557086501E8ADB9D001A7CE4 /* SystemAdapter.h */,
557086511E8ADB9D001A7CE4 /* SystemAdapter.mm */,
04399AA71D1C304300E99CD9 /* DRingAdapter.h */,
04399AA81D1C304300E99CD9 /* DRingAdapter.mm */,
04399AAA1D1C304300E99CD9 /* Utils.h */,
......@@ -739,6 +744,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
557086521E8ADB9D001A7CE4 /* SystemAdapter.mm in Sources */,
0273C3051E0C68B100CF00BA /* CreateProfileViewController.swift in Sources */,
02E1A0251DDE4ABA00D75B59 /* BoolStringExtension.swift in Sources */,
04399AAC1D1C304300E99CD9 /* AccountAdapter.mm in Sources */,
......
......@@ -26,9 +26,10 @@ import CoreData
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let daemonService = DaemonService.init(dRingAdaptor: DRingAdapter())
let daemonService = DaemonService(dRingAdaptor: DRingAdapter())
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
SystemAdapter().registerConfigurationHandler()
self.startDaemon()
return true
}
......
......@@ -23,4 +23,5 @@
Expose Objective-C bridging classes to Swift.
*/
#import "AccountAdapter.h"
#import "SystemAdapter.h"
#import "DRingAdapter.h"
/*
* Copyright (C) 2017 Savoir-faire Linux Inc.
*
* Author: Romain Bertozzi <romain.bertozzi@savoirfairelinux.com>
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Foundation/Foundation.h>
@interface SystemAdapter : NSObject
- (void)registerConfigurationHandler;
@end
/*
* Copyright (C) 2017 Savoir-faire Linux Inc.
*
* Author: Romain Bertozzi <romain.bertozzi@savoirfairelinux.com>
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import "Ring-Swift.h"
#import "SystemAdapter.h"
#import "dring/configurationmanager_interface.h"
@implementation SystemAdapter
using namespace DRing;
#pragma mark Callbacks registration
- (void)registerConfigurationHandler {
std::map<std::string, std::shared_ptr<CallbackWrapperBase>> confHandlers;
confHandlers.insert(exportable_callback<ConfigurationSignal::GetAppDataPath>([&](const std::string& name,
std::vector<std::string>* ret) {
if (name == "cache") {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
ret->push_back(std::string([documentsDirectory UTF8String]));
}
else {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
ret->push_back(std::string([documentsDirectory UTF8String]));
}
}));
registerConfHandlers(confHandlers);
}
#pragma mark -
@end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment