This repository was archived by the owner on Jun 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 683
/
Copy pathManagers.swift
59 lines (46 loc) · 2.34 KB
/
Managers.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// Managers.swift
// Owncloud iOs Client
//
// Created by Gonzalo Gonzalez on 10/3/15.
//
/*
Copyright (C) 2016, ownCloud GmbH.
This code is covered by the GNU Public License Version 3.
For distribution utilizing Apple mechanisms please see https://owncloud.org/contribute/iOS-license-exception/
You should have received a copy of this license
along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.en.html>.
*/
import UIKit
@objc class Managers: NSObject {
//MARK: FMDatabaseQueue
@objc class var sharedDatabase: FMDatabaseQueue {
struct Static {
static let sharedDatabase: FMDatabaseQueue = FMDatabaseQueue(path:((UtilsUrls.getOwnCloudFilePath()).appending("DB.sqlite")), flags: SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE|SQLITE_OPEN_FILEPROTECTION_NONE)
}
return Static.sharedDatabase
}
}
//MARK: OCCommunication
extension OCCommunication {
@objc static var shared: OCCommunication = {
//Code
let networkConfiguration: URLSessionConfiguration = URLSessionConfiguration.default
networkConfiguration.httpShouldUsePipelining = true
networkConfiguration.httpMaximumConnectionsPerHost = 1
networkConfiguration.requestCachePolicy = .reloadIgnoringLocalCacheData
let networkSessionManager: OCURLSessionManager = OCURLSessionManager(sessionConfiguration: networkConfiguration)
networkSessionManager.operationQueue.maxConcurrentOperationCount = 1
networkSessionManager.responseSerializer = AFHTTPResponseSerializer()
let sharedOCCommunication: OCCommunication = OCCommunication(uploadSessionManager: nil, andDownloadSessionManager: nil, andNetworkSessionManager: networkSessionManager)
sharedOCCommunication.isCookiesAvailable = true
let ocOAuth2conf: OCOAuth2Configuration = OCOAuth2Configuration(clientId: k_oauth2_client_id, clientSecret: k_oauth2_client_secret, redirectUri: k_oauth2_redirect_uri, authorizationEndpoint: k_oauth2_authorization_endpoint, tokenEndpoint: k_oauth2_token_endpoint)
sharedOCCommunication.setValueOauth2Configuration(ocOAuth2conf)
sharedOCCommunication.setValueOfUserAgent(UtilsUrls.getUserAgent());
let ocKeychain = OCKeychain()
sharedOCCommunication.setValueCredentialsStorage(ocKeychain)
let sslCertificateManager = SSLCertificateManager()
sharedOCCommunication.setValueTrustedCertificatesStore(sslCertificateManager)
return sharedOCCommunication
}()
}