Browse Source

register for examine keys added

async_key_management
Volker Birk 7 years ago
parent
commit
23d0861052
6 changed files with 37 additions and 10 deletions
  1. BIN
      pEpiOSAdapter.xcodeproj/project.xcworkspace/xcuserdata/vb.xcuserdatad/UserInterfaceState.xcuserstate
  2. +1
    -1
      pEpiOSAdapter/PEPQueue.h
  3. +1
    -1
      pEpiOSAdapter/PEPQueue.m
  4. +2
    -0
      pEpiOSAdapter/PEPSession.m
  5. +5
    -0
      pEpiOSAdapter/PEPiOSAdapter.h
  6. +28
    -8
      pEpiOSAdapter/PEPiOSAdapter.m

BIN
pEpiOSAdapter.xcodeproj/project.xcworkspace/xcuserdata/vb.xcuserdatad/UserInterfaceState.xcuserstate View File


+ 1
- 1
pEpiOSAdapter/PEPQueue.h View File

@ -10,7 +10,7 @@
@interface PEPQueue : NSMutableArray
- (void)queue:(id)object;
- (void)enqueue:(id)object;
- (id)dequeue;
@end

+ 1
- 1
pEpiOSAdapter/PEPQueue.m View File

@ -10,7 +10,7 @@
@implementation PEPQueue
- (void)queue:(id)object
- (void)enqueue:(id)object
{
@synchronized(self) {
[self insertObject:object atIndex:0];


+ 2
- 0
pEpiOSAdapter/PEPSession.m View File

@ -32,6 +32,8 @@ PEP_SESSION _session;
@throw myException;
}
[PEPiOSAdapter registerExamineFunction:_session];
return self;
}


+ 5
- 0
pEpiOSAdapter/PEPiOSAdapter.h View File

@ -7,6 +7,7 @@
//
#import <Foundation/Foundation.h>
#include "pEpEngine.h"
@interface PEPiOSAdapter : NSObject
@ -16,4 +17,8 @@
+ (void)startKeyserverLookup;
+ (void)stopKeyserverLookup;
// this message is for internal use only
+ (void)registerExamineFunction:(PEP_SESSION)session;
@end

+ 28
- 8
pEpiOSAdapter/PEPiOSAdapter.m View File

@ -14,14 +14,30 @@
#import "PEPQueue.h"
#include "keymanagement.h"
int examine_identity(pEp_identity *ident, void *management)
{
PEPQueue *q = (__bridge PEPQueue *)management;
NSDictionary *identity = [NSDictionary dictionary];
PEP_identityFromStruct(identity, ident);
[q enqueue::identity];
return 0;
}
static pEp_identity *retrieve_next_identity(void *management)
{
PEPQueue *q = (__bridge PEPQueue *)management;
while (![q count])
sleep(100);
usleep(100);
NSDictionary *ident = [q dequeue];
return PEP_identityToStruct([q dequeue]);
if ([ident objectForKey:@"THE_END"])
return NULL;
else
return PEP_identityToStruct(ident);
}
@implementation PEPiOSAdapter
@ -31,17 +47,14 @@ static NSThread *keyserver_thread = nil;
+ (void)keyserverThread:(id)object
{
do_keymanagement(retrieve_next_identity, (void *)queue);
}
+ (void)startKeyserverLookup
{
if (!queue) {
queue = [PEPQueue init];
if (!keyserver_thread)
keyserver_thread = [[NSThread alloc] initWithTarget:self selector:@selector(keyserverThread:) object:nil];
keyserver_thread = [[NSThread alloc] initWithTarget:self selector:@selector(keyserverThread:) object:nil];
[keyserver_thread start];
}
}
@ -49,8 +62,15 @@ static NSThread *keyserver_thread = nil;
+ (void)stopKeyserverLookup
{
if (queue) {
[queue queue: ]
[queue enqueue:[NSDictionary dictionaryWithObject:@"THE_END" forKey:@"THE_END"]];
keyserver_thread = nil;
queue = nil;
}
}
+ (void)registerExamineFunction:(PEP_SESSION)session
{
register_examine_function(session, examine_identity, (void *)queue);
}
@end

Loading…
Cancel
Save