IOSAD-94 global passive mode
authorDirk Zimmermann <dirk@pep-project.org>
Wed, 13 Jun 2018 09:53:43 +0200
changeset 6256da48501887b
parent 624 fb142cf04649
child 626 d5283b7c9ef2
IOSAD-94 global passive mode
pEpObjCAdapter/PEPObjCAdapter+Internal.h
pEpObjCAdapter/PEPObjCAdapter.m
pEpObjCAdapter/PEPSessionProvider.m
     1.1 --- a/pEpObjCAdapter/PEPObjCAdapter+Internal.h	Wed Jun 13 09:53:42 2018 +0200
     1.2 +++ b/pEpObjCAdapter/PEPObjCAdapter+Internal.h	Wed Jun 13 09:53:43 2018 +0200
     1.3 @@ -23,6 +23,17 @@
     1.4   */
     1.5  + (BOOL)unEncryptedSubjectEnabled;
     1.6  
     1.7 +/**
     1.8 + @note That global value is used for all new sessions
     1.9 + @return The current status of passive mode (enabled or not)
    1.10 + */
    1.11 ++ (BOOL)passiveModeEnabled;
    1.12 +
    1.13 +/**
    1.14 + Enable or disable passive mode for all sessions.
    1.15 + */
    1.16 ++ (void)setPassiveModeEnabled:(BOOL)enabled;
    1.17 +
    1.18  // this messages are for internal use only; do not call
    1.19  
    1.20  + (void)registerExamineFunction:(PEP_SESSION)session;
     2.1 --- a/pEpObjCAdapter/PEPObjCAdapter.m	Wed Jun 13 09:53:42 2018 +0200
     2.2 +++ b/pEpObjCAdapter/PEPObjCAdapter.m	Wed Jun 13 09:53:43 2018 +0200
     2.3 @@ -104,7 +104,9 @@
     2.4  const char* _Nullable SystemDB = NULL;
     2.5  NSURL *s_homeURL;
     2.6  static NSLock *s_writeLock;
     2.7 +
     2.8  static BOOL s_unEncryptedSubjectEnabled = NO;
     2.9 +static BOOL s_passiveModeEnabled = NO;
    2.10  
    2.11  @implementation PEPObjCAdapter
    2.12  
    2.13 @@ -120,6 +122,18 @@
    2.14      s_unEncryptedSubjectEnabled = enabled;
    2.15  }
    2.16  
    2.17 +#pragma mark - Passive Mode
    2.18 +
    2.19 ++ (BOOL)passiveModeEnabled
    2.20 +{
    2.21 +    return s_passiveModeEnabled;
    2.22 +}
    2.23 +
    2.24 ++ (void)setPassiveModeEnabled:(BOOL)enabled
    2.25 +{
    2.26 +    s_passiveModeEnabled = enabled;
    2.27 +}
    2.28 +
    2.29  #pragma mark - DB PATHS
    2.30  
    2.31  + (void)initialize
     3.1 --- a/pEpObjCAdapter/PEPSessionProvider.m	Wed Jun 13 09:53:42 2018 +0200
     3.2 +++ b/pEpObjCAdapter/PEPSessionProvider.m	Wed Jun 13 09:53:43 2018 +0200
     3.3 @@ -44,7 +44,11 @@
     3.4          newOrExistingSession = [PEPInternalSession new];
     3.5          dict[currentThread] = newOrExistingSession;
     3.6      }
     3.7 +
     3.8 +    // configuration
     3.9      [self setConfigUnEncryptedSubjectOnSession:newOrExistingSession];
    3.10 +    [self setPassiveModeOnSession:newOrExistingSession];
    3.11 +
    3.12      [self nullifySessionsOfFinishedThreads];
    3.13  
    3.14      [[self sessionForThreadLock] unlock];
    3.15 @@ -81,7 +85,7 @@
    3.16      return s_sessionForThreadDict;
    3.17  }
    3.18  
    3.19 -#pragma mark -
    3.20 +#pragma mark - configuration
    3.21  
    3.22  + (void)setConfigUnEncryptedSubjectOnSession:(PEPInternalSession *)session
    3.23  {
    3.24 @@ -89,6 +93,14 @@
    3.25      [session configUnEncryptedSubjectEnabled:unEncryptedSubjectEnabled];
    3.26  }
    3.27  
    3.28 ++ (void)setPassiveModeOnSession:(PEPInternalSession *)session
    3.29 +{
    3.30 +    BOOL passiveModeEnabled = [PEPObjCAdapter passiveModeEnabled];
    3.31 +    [session configurePassiveModeEnabled:passiveModeEnabled];
    3.32 +}
    3.33 +
    3.34 +#pragma mark -
    3.35 +
    3.36  /**
    3.37   Assures a session for the main thread is set.
    3.38   */
    3.39 @@ -104,6 +116,7 @@
    3.40          }
    3.41          s_sessionForMainThread = [PEPInternalSession new];
    3.42          [self setConfigUnEncryptedSubjectOnSession:s_sessionForMainThread];
    3.43 +        [self setPassiveModeOnSession:s_sessionForMainThread];
    3.44      };
    3.45  
    3.46