src/pEpEngine.c
branchtest_diphoton
changeset 1749 32084f52dada
parent 1670 8e2509f0ddad
child 1860 1975a3b9bc37
     1.1 --- a/src/pEpEngine.c	Tue Mar 21 15:26:12 2017 +0100
     1.2 +++ b/src/pEpEngine.c	Thu May 04 15:16:47 2017 +0200
     1.3 @@ -1318,6 +1318,20 @@
     1.4      if (!(session && identity && identity->address && identity->user_id))
     1.5          return PEP_ILLEGAL_VALUE;
     1.6  
     1.7 +    // test_diphoton : dirty hack to prevent more than one sync enabled account
     1.8 +    if (flags & PEP_idf_not_for_sync){
     1.9 +        identity_list *own_identities = NULL;
    1.10 +        if (_own_identities_retrieve(session, &own_identities, PEP_idf_not_for_sync) == PEP_STATUS_OK)
    1.11 +            // if at least one _other_ own address is sync enabled, prevent unseting exclusion
    1.12 +            for (identity_list *_i = own_identities; _i && _i->ident; _i = _i->next) {
    1.13 +                pEp_identity *me = _i->ident;
    1.14 +                if(me->address && strcmp(me->address, identity->address) != 0)
    1.15 +                flags &= ~PEP_idf_not_for_sync;
    1.16 +                break;
    1.17 +            }
    1.18 +        free_identity_list(own_identities);
    1.19 +    }
    1.20 +
    1.21      sqlite3_reset(session->unset_identity_flags);
    1.22      sqlite3_bind_int(session->unset_identity_flags, 1, flags);
    1.23      sqlite3_bind_text(session->unset_identity_flags, 2, identity->address, -1,
    1.24 @@ -2267,5 +2281,8 @@
    1.25      );
    1.26      assert(int_result == SQLITE_OK);
    1.27  
    1.28 +    if (int_result != SQLITE_OK)
    1.29 +        return PEP_UNKNOWN_ERROR;
    1.30 +
    1.31      return PEP_STATUS_OK;
    1.32  }