IOSAD-172 Can return stored passphrases IOSAD-172
authorDirk Zimmermann <dz@pep.security>
Thu, 25 Jun 2020 17:08:21 +0200
branchIOSAD-172
changeset 145798e4f0837759
parent 1456 752e8d0380a1
child 1458 8e31ce01a795
IOSAD-172 Can return stored passphrases
pEpObjCAdapter/PEPPassphraseCache.m
     1.1 --- a/pEpObjCAdapter/PEPPassphraseCache.m	Thu Jun 25 17:08:21 2020 +0200
     1.2 +++ b/pEpObjCAdapter/PEPPassphraseCache.m	Thu Jun 25 17:08:21 2020 +0200
     1.3 @@ -8,9 +8,12 @@
     1.4  
     1.5  #import "PEPPassphraseCache.h"
     1.6  
     1.7 +static NSUInteger s_numberOfPassphrases = 20;
     1.8 +
     1.9  @interface PEPPassphraseCache ()
    1.10  
    1.11  @property (nonatomic) dispatch_queue_t queue;
    1.12 +@property (nonatomic) NSMutableArray *mutablePassphrases;
    1.13  
    1.14  @end
    1.15  
    1.16 @@ -23,6 +26,7 @@
    1.17      if (self) {
    1.18          _timeout = timeout;
    1.19          _queue = dispatch_queue_create("PEPPassphraseCache Queue", DISPATCH_QUEUE_SERIAL);
    1.20 +        _mutablePassphrases = [NSMutableArray arrayWithCapacity:s_numberOfPassphrases];
    1.21      }
    1.22      return self;
    1.23  }
    1.24 @@ -39,7 +43,15 @@
    1.25  
    1.26  - (NSArray *)passphrases
    1.27  {
    1.28 -    return @[];
    1.29 +    NSMutableArray *resultingPassphrases = [NSMutableArray
    1.30 +                                            arrayWithCapacity:s_numberOfPassphrases + 1];
    1.31 +    [resultingPassphrases addObject:@""];
    1.32 +    dispatch_sync(self.queue, ^{
    1.33 +        for (NSString *passphrase in self.mutablePassphrases) {
    1.34 +            [resultingPassphrases addObject:passphrase];
    1.35 +        }
    1.36 +    });
    1.37 +    return [NSArray arrayWithArray:resultingPassphrases];
    1.38  }
    1.39  
    1.40  @end