pEpObjCAdapter/PEPSession.m
author buff <andreas@pep-project.org>
Wed, 11 Oct 2017 12:40:46 +0200
branchIOSAD-50
changeset 272 c456123edfa7
parent 270 e500cb5119bd
child 280 505c8528010c
child 286 3dd765037407
permissions -rw-r--r--
IOSAD-50 moves internal stuff to PEPInternalSession
andreas@270
     1
//
andreas@270
     2
//  PEPSession.m
andreas@270
     3
//  pEpObjCAdapter
andreas@270
     4
//
andreas@270
     5
//  Created by Andreas Buff on 11.10.17.
andreas@270
     6
//  Copyright © 2017 p≡p. All rights reserved.
andreas@270
     7
//
andreas@270
     8
andreas@270
     9
#import "PEPSession.h"
andreas@270
    10
andreas@272
    11
#import "PEPInternalSession.h"
andreas@272
    12
#import "PEPSessionProvider.h"
andreas@272
    13
andreas@270
    14
@implementation PEPSession
andreas@270
    15
andreas@272
    16
#pragma mark - Public API
andreas@272
    17
andreas@272
    18
- (void)cleanup
andreas@272
    19
{
andreas@272
    20
    [PEPSessionProvider cleanup];
andreas@272
    21
}
andreas@272
    22
andreas@272
    23
- (PEP_rating)decryptMessageDict:(nonnull PEPDict *)src
andreas@272
    24
                            dest:(PEPDict * _Nullable * _Nullable)dst
andreas@272
    25
                            keys:(PEPStringList * _Nullable * _Nullable)keys
andreas@272
    26
{
andreas@272
    27
    return [PEPSession decryptMessageDict:src dest:(PEPDict * _Nullable * _Nullable)dst
andreas@272
    28
                                         keys:(PEPStringList * _Nullable * _Nullable)keys];
andreas@272
    29
}
andreas@272
    30
andreas@272
    31
- (PEP_rating)reEvaluateMessageRating:(nonnull PEPDict *)src
andreas@272
    32
{
andreas@272
    33
    return [PEPSession reEvaluateMessageRating:src];
andreas@272
    34
}
andreas@272
    35
andreas@272
    36
- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
andreas@272
    37
                           extra:(nullable PEPStringList *)keys
andreas@272
    38
                            dest:(PEPDict * _Nullable * _Nullable)dst
andreas@272
    39
{
andreas@272
    40
    return [PEPSession encryptMessageDict:src extra:keys dest:dst];
andreas@272
    41
}
andreas@272
    42
andreas@272
    43
- (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
andreas@272
    44
                        identity:(nonnull PEPDict *)identity
andreas@272
    45
                            dest:(PEPDict * _Nullable * _Nullable)dst
andreas@272
    46
{
andreas@272
    47
    return [PEPSession encryptMessageDict:src identity:identity dest:dst];
andreas@272
    48
}
andreas@272
    49
andreas@272
    50
- (PEP_rating)outgoingMessageColor:(nonnull PEPDict *)msg
andreas@272
    51
{
andreas@272
    52
    return [PEPSession outgoingMessageColor:msg];
andreas@272
    53
}
andreas@272
    54
andreas@272
    55
- (PEP_rating)identityRating:(nonnull PEPDict *)identity
andreas@272
    56
{
andreas@272
    57
    return [PEPSession identityRating:identity];
andreas@272
    58
}
andreas@272
    59
andreas@272
    60
- (nonnull NSArray *)trustwords:(nonnull NSString *)fpr forLanguage:(nonnull NSString *)languageID
andreas@272
    61
                      shortened:(BOOL)shortened
andreas@272
    62
{
andreas@272
    63
    return [PEPSession trustwords:fpr forLanguage:languageID shortened:shortened];
andreas@272
    64
}
andreas@272
    65
andreas@272
    66
- (void)mySelf:(nonnull PEPMutableDict *)identity
andreas@272
    67
{
andreas@272
    68
    [PEPSession mySelf:identity];
andreas@272
    69
}
andreas@272
    70
andreas@272
    71
- (void)updateIdentity:(nonnull PEPMutableDict *)identity
andreas@272
    72
{
andreas@272
    73
    [PEPSession updateIdentity:identity];
andreas@272
    74
}
andreas@272
    75
andreas@272
    76
- (void)trustPersonalKey:(nonnull PEPMutableDict *)identity
andreas@272
    77
{
andreas@272
    78
    [PEPSession trustPersonalKey:identity];
andreas@272
    79
}
andreas@272
    80
andreas@272
    81
- (void)keyMistrusted:(nonnull PEPMutableDict *)identity
andreas@272
    82
{
andreas@272
    83
    [PEPSession keyMistrusted:identity];
andreas@272
    84
}
andreas@272
    85
andreas@272
    86
- (void)keyResetTrust:(nonnull PEPMutableDict *)identity
andreas@272
    87
{
andreas@272
    88
    [PEPSession keyResetTrust:identity];
andreas@272
    89
}
andreas@272
    90
andreas@272
    91
#pragma mark Internal API (testing etc.)
andreas@272
    92
andreas@272
    93
- (void)importKey:(nonnull NSString *)keydata
andreas@272
    94
{
andreas@272
    95
    [PEPSession importKey:keydata];
andreas@272
    96
}
andreas@272
    97
andreas@272
    98
- (void)logTitle:(nonnull NSString *)title entity:(nonnull NSString *)entity
andreas@272
    99
     description:(nullable NSString *)description comment:(nullable NSString *)comment
andreas@272
   100
{
andreas@272
   101
    [PEPSession logTitle:title entity:entity description:description comment:comment];
andreas@272
   102
}
andreas@272
   103
andreas@272
   104
- (nonnull NSString *)getLog
andreas@272
   105
{
andreas@272
   106
    return [PEPSession getLog];
andreas@272
   107
}
andreas@272
   108
andreas@272
   109
- (nullable NSString *)getTrustwordsIdentity1:(nonnull PEPDict *)identity1
andreas@272
   110
                                    identity2:(nonnull PEPDict *)identity2
andreas@272
   111
                                     language:(nullable NSString *)language
andreas@272
   112
                                         full:(BOOL)full
andreas@272
   113
{
andreas@272
   114
    return [PEPSession getTrustwordsIdentity1:identity1
andreas@272
   115
                                        identity2:identity2
andreas@272
   116
                                         language:language
andreas@272
   117
                                             full:full];
andreas@272
   118
}
andreas@272
   119
andreas@272
   120
- (nullable NSString *)getTrustwordsMessageDict:(nonnull PEPDict *)messageDict
andreas@272
   121
                                   receiverDict:(nonnull PEPDict *)receiverDict
andreas@272
   122
                                      keysArray:(PEPStringList * _Nullable)keysArray
andreas@272
   123
                                       language:(nullable NSString *)language
andreas@272
   124
                                           full:(BOOL)full
andreas@272
   125
                                resultingStatus:(PEP_STATUS * _Nullable)resultingStatus
andreas@272
   126
{
andreas@272
   127
    return [PEPSession getTrustwordsMessageDict:messageDict
andreas@272
   128
                                       receiverDict:receiverDict
andreas@272
   129
                                          keysArray:keysArray
andreas@272
   130
                                           language:language
andreas@272
   131
                                               full:full
andreas@272
   132
                                    resultingStatus:resultingStatus];
andreas@272
   133
}
andreas@272
   134
andreas@272
   135
- (NSArray<PEPLanguage *> * _Nonnull)languageList
andreas@272
   136
{
andreas@272
   137
    return [PEPSession languageList];
andreas@272
   138
}
andreas@272
   139
andreas@272
   140
- (PEP_STATUS)undoLastMistrust
andreas@272
   141
{
andreas@272
   142
    return [PEPSession undoLastMistrust];
andreas@272
   143
}
andreas@272
   144
andreas@272
   145
#pragma mark - Static 
andreas@272
   146
andreas@272
   147
+ (PEP_rating)decryptMessageDict:(nonnull PEPDict *)src
andreas@272
   148
                            dest:(PEPDict * _Nullable * _Nullable)dst
andreas@272
   149
                            keys:(PEPStringList * _Nullable * _Nullable)keys
andreas@272
   150
{
andreas@272
   151
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   152
    return [session decryptMessageDict:src dest:dst keys:keys];
andreas@272
   153
}
andreas@272
   154
andreas@272
   155
+ (PEP_rating)reEvaluateMessageRating:(nonnull PEPDict *)src
andreas@272
   156
{
andreas@272
   157
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   158
    return [session reEvaluateMessageRating:src];
andreas@272
   159
}
andreas@272
   160
andreas@272
   161
+ (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
andreas@272
   162
                           extra:(nullable PEPStringList *)keys
andreas@272
   163
                            dest:(PEPDict * _Nullable * _Nullable)dst
andreas@272
   164
{
andreas@272
   165
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   166
    return [session encryptMessageDict:src extra:keys dest:dst];
andreas@272
   167
}
andreas@272
   168
andreas@272
   169
+ (PEP_STATUS)encryptMessageDict:(nonnull PEPDict *)src
andreas@272
   170
                        identity:(nonnull PEPDict *)identity
andreas@272
   171
                            dest:(PEPDict * _Nullable * _Nullable)dst
andreas@272
   172
{
andreas@272
   173
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   174
    return [session encryptMessageDict:src identity:identity dest:dst];
andreas@272
   175
}
andreas@272
   176
andreas@272
   177
+ (PEP_rating)outgoingMessageColor:(nonnull PEPDict *)msg
andreas@272
   178
{
andreas@272
   179
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   180
    return [session outgoingMessageColor:msg];
andreas@272
   181
}
andreas@272
   182
andreas@272
   183
+ (PEP_rating)identityRating:(nonnull PEPDict *)identity
andreas@272
   184
{
andreas@272
   185
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   186
    return [session identityRating:identity];
andreas@272
   187
}
andreas@272
   188
andreas@272
   189
+ (nonnull NSArray *)trustwords:(nonnull NSString *)fpr forLanguage:(nonnull NSString *)languageID
andreas@272
   190
                      shortened:(BOOL)shortened
andreas@272
   191
{
andreas@272
   192
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   193
    return [session trustwords:fpr forLanguage:languageID shortened:shortened];
andreas@272
   194
}
andreas@272
   195
andreas@272
   196
+ (void)mySelf:(nonnull PEPMutableDict *)identity
andreas@272
   197
{
andreas@272
   198
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   199
    [session mySelf:identity];
andreas@272
   200
}
andreas@272
   201
andreas@272
   202
+ (void)updateIdentity:(nonnull PEPMutableDict *)identity
andreas@272
   203
{
andreas@272
   204
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   205
    [session updateIdentity:identity];
andreas@272
   206
}
andreas@272
   207
andreas@272
   208
+ (void)trustPersonalKey:(nonnull PEPMutableDict *)identity
andreas@272
   209
{
andreas@272
   210
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   211
    [session trustPersonalKey:identity];
andreas@272
   212
}
andreas@272
   213
andreas@272
   214
+ (void)keyMistrusted:(nonnull PEPMutableDict *)identity
andreas@272
   215
{
andreas@272
   216
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   217
    [session keyMistrusted:identity];
andreas@272
   218
}
andreas@272
   219
andreas@272
   220
+ (void)keyResetTrust:(nonnull PEPMutableDict *)identity
andreas@272
   221
{
andreas@272
   222
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   223
    [session keyResetTrust:identity];
andreas@272
   224
}
andreas@272
   225
andreas@272
   226
#pragma mark Internal API (testing etc.)
andreas@272
   227
andreas@272
   228
+ (void)importKey:(nonnull NSString *)keydata
andreas@272
   229
{
andreas@272
   230
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   231
    [session importKey:keydata];
andreas@272
   232
}
andreas@272
   233
andreas@272
   234
+ (void)logTitle:(nonnull NSString *)title entity:(nonnull NSString *)entity
andreas@272
   235
     description:(nullable NSString *)description comment:(nullable NSString *)comment
andreas@272
   236
{
andreas@272
   237
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   238
    [session logTitle:title entity:entity description:description comment:comment];
andreas@272
   239
}
andreas@272
   240
andreas@272
   241
+ (nonnull NSString *)getLog
andreas@272
   242
{
andreas@272
   243
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   244
    return [session getLog];
andreas@272
   245
}
andreas@272
   246
andreas@272
   247
+ (nullable NSString *)getTrustwordsIdentity1:(nonnull PEPDict *)identity1
andreas@272
   248
                                    identity2:(nonnull PEPDict *)identity2
andreas@272
   249
                                     language:(nullable NSString *)language
andreas@272
   250
                                         full:(BOOL)full
andreas@272
   251
{
andreas@272
   252
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   253
    return [session getTrustwordsIdentity1:identity1 identity2:identity2 language:language full:full];
andreas@272
   254
}
andreas@272
   255
andreas@272
   256
+ (nullable NSString *)getTrustwordsMessageDict:(nonnull PEPDict *)messageDict
andreas@272
   257
                                   receiverDict:(nonnull PEPDict *)receiverDict
andreas@272
   258
                                      keysArray:(PEPStringList * _Nullable)keysArray
andreas@272
   259
                                       language:(nullable NSString *)language
andreas@272
   260
                                           full:(BOOL)full
andreas@272
   261
                                resultingStatus:(PEP_STATUS * _Nullable)resultingStatus
andreas@272
   262
{
andreas@272
   263
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   264
    return [session getTrustwordsMessageDict:messageDict receiverDict:receiverDict keysArray:keysArray language:language full:full resultingStatus:resultingStatus];
andreas@272
   265
}
andreas@272
   266
andreas@272
   267
+ (NSArray<PEPLanguage *> * _Nonnull)languageList
andreas@272
   268
{
andreas@272
   269
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   270
    return [session languageList];
andreas@272
   271
}
andreas@272
   272
andreas@272
   273
+ (PEP_STATUS)undoLastMistrust
andreas@272
   274
{
andreas@272
   275
    PEPInternalSession *session = [PEPSessionProvider session];
andreas@272
   276
    return [session undoLastMistrust];
andreas@272
   277
}
andreas@272
   278
andreas@270
   279
@end