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