pEpObjCTests/TestUtils/PEPTestSyncDelegate.m
author Dirk Zimmermann <dirk@pep-project.org>
Tue, 24 Apr 2018 13:29:19 +0200
branchIOSAD-92
changeset 594 a9cae3a6f78d
parent 391 3a63cf867f1f
permissions -rw-r--r--
IOSAD-92 PEPIdentity using hashBasedOnKeys etc.
andreas@391
     1
//
andreas@391
     2
//  PEPTestSyncDelegate.m
andreas@391
     3
//  pEpObjCAdapter
andreas@391
     4
//
andreas@391
     5
//  Created by Andreas Buff on 18.01.18.
andreas@391
     6
//  Copyright © 2018 p≡p. All rights reserved.
andreas@391
     7
//
andreas@391
     8
andreas@391
     9
#import "PEPTestSyncDelegate.h"
andreas@391
    10
andreas@391
    11
@implementation PEPTestSyncDelegate
andreas@391
    12
andreas@391
    13
- (id)init
andreas@391
    14
{
andreas@391
    15
    if (self = [super init])  {
andreas@391
    16
        self.sendWasCalled = false;
andreas@391
    17
        self.cond = [[NSCondition alloc] init];
andreas@391
    18
    }
andreas@391
    19
    return self;
andreas@391
    20
}
andreas@391
    21
andreas@391
    22
- (PEP_STATUS)notifyHandshakeWithSignal:(sync_handshake_signal)signal me:(id)me
andreas@391
    23
partner:(id)partner
andreas@391
    24
{
andreas@391
    25
    return PEP_STATUS_OK;
andreas@391
    26
}
andreas@391
    27
andreas@391
    28
- (PEP_STATUS)sendMessage:(id)msg
andreas@391
    29
{
andreas@391
    30
    [_cond lock];
andreas@391
    31
andreas@391
    32
    self.sendWasCalled = true;
andreas@391
    33
    [_cond signal];
andreas@391
    34
    [_cond unlock];
andreas@391
    35
andreas@391
    36
    return PEP_STATUS_OK;
andreas@391
    37
}
andreas@391
    38
andreas@391
    39
- (PEP_STATUS)fastPolling:(bool)isfast
andreas@391
    40
{
andreas@391
    41
    return PEP_STATUS_OK;
andreas@391
    42
}
andreas@391
    43
andreas@391
    44
- (BOOL)waitUntilSent:(time_t)maxSec
andreas@391
    45
{
andreas@391
    46
    bool res;
andreas@391
    47
    [_cond lock];
andreas@391
    48
    [_cond waitUntilDate:[NSDate dateWithTimeIntervalSinceNow:maxSec]];
andreas@391
    49
    res = _sendWasCalled;
andreas@391
    50
    [_cond unlock];
andreas@391
    51
    return res;
andreas@391
    52
}
andreas@391
    53
andreas@391
    54
@end