]> git.saurik.com Git - apple/security.git/blob - keychain/ot/OTLocalStore.h
Security-58286.70.7.tar.gz
[apple/security.git] / keychain / ot / OTLocalStore.h
1 /*
2 * Copyright (c) 2017 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef OTLocalStore_h
25 #define OTLocalStore_h
26 #if OCTAGON
27
28 #import <Foundation/Foundation.h>
29 #import <Prequelite/Prequelite.h>
30 #import <dispatch/dispatch.h>
31 #import "keychain/ot/OTBottledPeerRecord.h"
32 #import "keychain/ot/OTContextRecord.h"
33
34 NS_ASSUME_NONNULL_BEGIN
35
36 @interface OTLocalStore : NSObject
37
38 @property (nonatomic, readonly) NSString* dbPath;
39 @property (nonatomic, readonly) PQLConnection* pDB;
40 @property (nonatomic, readonly) dispatch_queue_t serialQ;
41 @property (nonatomic, readonly) NSString* contextID;
42 @property (nonatomic, readonly) NSString* dsid;
43 @property (nonatomic, readonly) sqlite3* _db;
44
45 -(instancetype) initWithContextID:(NSString*)contextID dsid:(NSString*)dsid path:(nullable NSString*)path error:(NSError**)error;
46
47 -(BOOL)isProposedColumnNameInTable:(NSString*)proposedColumnName tableName:(NSString*)tableName;
48
49 // OT Context Record routines
50 -(BOOL)initializeContextTable:(NSString*)contextID dsid:(NSString*)dsid error:(NSError**)error;
51 -(OTContextRecord* _Nullable)readLocalContextRecordForContextIDAndDSID:(NSString*)contextAndDSID error:(NSError**)error;
52 -(BOOL)insertLocalContextRecord:(NSDictionary*)attributes error:(NSError**)error;
53 -(BOOL)updateLocalContextRecordRowWithContextID:(NSString*)contextIDAndDSID columnName:(NSString*)columnName newValue:(void*)newValue error:(NSError**)error;
54 -(BOOL)deleteLocalContext:(NSString*)contextIDAndDSID error:(NSError**)error;
55 -(BOOL) deleteAllContexts:(NSError**)error;
56
57 //OT Bottled Peer routines
58 - (nullable OTBottledPeerRecord *)readLocalBottledPeerRecordWithRecordID:(NSString *)recordID
59 error:(NSError**)error;
60 - (nullable NSArray*) readAllLocalBottledPeerRecords:(NSError**)error;
61 -(BOOL)deleteBottledPeer:(NSString*) recordID error:(NSError**)error;
62 -(BOOL) deleteBottledPeersForContextAndDSID:(NSString*)contextIDAndDSID
63 error:(NSError**)error;
64 -(BOOL)removeAllBottledPeerRecords:(NSError**)error;
65 -(BOOL)insertBottledPeerRecord:(OTBottledPeerRecord *)bp
66 escrowRecordID:(NSString *)escrowRecordID
67 error:(NSError**)error;
68 - (nullable NSArray*) readLocalBottledPeerRecordsWithMatchingPeerID:(NSString*)peerID error:(NSError**)error;
69
70 // generic DB routines
71 -(BOOL)openDBWithError:(NSError**)error;
72 -(BOOL)closeDBWithError:(NSError**)error;;
73 -(BOOL)createDirectoryAtPath:(NSString*)path error:(NSError **)error;
74 @end
75 NS_ASSUME_NONNULL_END
76 #endif
77 #endif /* OTLocalStore_h */