Browse Source

moving inject_sync_event to init()

generate_api
Volker Birk 4 years ago
parent
commit
a8076c670a
11 changed files with 45 additions and 43 deletions
  1. +3
    -1
      src/pEpEngine.c
  2. +30
    -12
      src/pEpEngine.h
  3. +2
    -5
      src/sync_api.c
  4. +0
    -16
      src/sync_api.h
  5. +3
    -1
      sync/gen_statemachine.ysl2
  6. +1
    -1
      test/convenience_scripts/mime_decrypt.cc
  7. +1
    -1
      test/convenience_scripts/mime_encrypt.cc
  8. +1
    -1
      test/convenience_scripts/mime_encrypt_decrypt.cc
  9. +2
    -2
      test/pEpEngineTest.cc
  10. +1
    -1
      test/src/EngineTestSuite.cc
  11. +1
    -2
      test/src/engine_tests/SyncTests.cc

+ 3
- 1
src/pEpEngine.c View File

@ -491,7 +491,8 @@ PEP_STATUS pgp_import_ultimately_trusted_keypairs(PEP_SESSION session);
DYNAMIC_API PEP_STATUS init(
PEP_SESSION *session,
messageToSend_t messageToSend
messageToSend_t messageToSend,
inject_sync_event_t inject_sync_event
)
{
PEP_STATUS status = PEP_STATUS_OK;
@ -540,6 +541,7 @@ DYNAMIC_API PEP_STATUS init(
_session->version = PEP_ENGINE_VERSION;
_session->messageToSend = messageToSend;
_session->inject_sync_event = inject_sync_event;
#ifdef DEBUG_ERRORSTACK
_session->errorstack = new_stringlist("init()");


+ 30
- 12
src/pEpEngine.h View File

@ -92,6 +92,7 @@ typedef enum {
PEP_SYNC_ILLEGAL_MESSAGE = 0x0902,
PEP_SYNC_NO_INJECT_CALLBACK = 0x0903,
PEP_SYNC_NO_CHANNEL = 0x0904,
PEP_SYNC_CANNOT_ENCRYPT = 0x0905,
PEP_CANNOT_INCREASE_SEQUENCE = 0x0971,
@ -134,24 +135,40 @@ struct _message;
typedef PEP_STATUS (*messageToSend_t)(void *obj, struct _message *msg);
struct Sync_event;
typedef struct Sync_event *SYNC_EVENT;
// inject_sync_event - inject sync protocol message
//
// parameters:
// ev (in) event to inject
// management (in) application defined; usually a locked queue
//
// return value:
// 0 if event could be stored successfully or nonzero otherwise
typedef int (*inject_sync_event_t)(SYNC_EVENT ev, void *management);
// INIT_STATUS init() - initialize pEpEngine for a thread
//
// parameters:
// session (out) init() allocates session memory and
// session (out) init() allocates session memory and
// returns a pointer as a handle
// messageToSend (in) callback for sending message by the
// messageToSend (in) callback for sending message by the
// application
// inject_sync_event (in) callback for injecting a sync event
//
// return value:
// PEP_STATUS_OK = 0 if init() succeeds
// PEP_INIT_SQLITE3_WITHOUT_MUTEX if SQLite3 was compiled with
// SQLITE_THREADSAFE 0
// PEP_INIT_CANNOT_LOAD_GPGME if libgpgme.dll cannot be found
// PEP_INIT_GPGME_INIT_FAILED if GPGME init fails
// PEP_INIT_CANNOT_OPEN_DB if user's management db cannot be
// opened
// PEP_INIT_CANNOT_OPEN_SYSTEM_DB if system's management db cannot be
// opened
// PEP_STATUS_OK = 0 if init() succeeds
// PEP_INIT_SQLITE3_WITHOUT_MUTEX if SQLite3 was compiled with
// SQLITE_THREADSAFE 0
// PEP_INIT_CANNOT_LOAD_GPGME if libgpgme.dll cannot be found
// PEP_INIT_GPGME_INIT_FAILED if GPGME init fails
// PEP_INIT_CANNOT_OPEN_DB if user's management db cannot be
// opened
// PEP_INIT_CANNOT_OPEN_SYSTEM_DB if system's management db cannot be
// opened
//
// caveat:
// THE CALLER MUST GUARD THIS CALL EXTERNALLY WITH A MUTEX. release()
@ -169,7 +186,8 @@ typedef PEP_STATUS (*messageToSend_t)(void *obj, struct _message *msg);
DYNAMIC_API PEP_STATUS init(
PEP_SESSION *session,
messageToSend_t messageToSend
messageToSend_t messageToSend,
inject_sync_event_t inject_sync_event
);


+ 2
- 5
src/sync_api.c View File

@ -12,17 +12,15 @@ DYNAMIC_API PEP_STATUS register_sync_callbacks(
PEP_SESSION session,
void *management,
notifyHandshake_t notifyHandshake,
inject_sync_event_t inject_sync_event,
retrieve_next_sync_event_t retrieve_next_sync_event
)
{
assert(session && management && notifyHandshake && inject_sync_event && retrieve_next_sync_event);
if (!(session && management && notifyHandshake && inject_sync_event && retrieve_next_sync_event))
assert(session && management && notifyHandshake && retrieve_next_sync_event);
if (!(session && management && notifyHandshake && retrieve_next_sync_event))
return PEP_ILLEGAL_VALUE;
session->sync_management = management;
session->notifyHandshake = notifyHandshake;
session->inject_sync_event = inject_sync_event;
session->retrieve_next_sync_event = retrieve_next_sync_event;
// start state machine
@ -36,7 +34,6 @@ DYNAMIC_API void unregister_sync_callbacks(PEP_SESSION session) {
// unregister
session->sync_management = NULL;
session->notifyHandshake = NULL;
session->inject_sync_event = NULL;
session->retrieve_next_sync_event = NULL;
}


+ 0
- 16
src/sync_api.h View File

@ -74,21 +74,6 @@ DYNAMIC_API PEP_STATUS deliverHandshakeResult(
);
struct Sync_event;
typedef struct Sync_event *SYNC_EVENT;
// inject_sync_event - inject sync protocol message
//
// parameters:
// ev (in) event to inject
// management (in) application defined; usually a locked queue
//
// return value:
// 0 if event could be stored successfully or nonzero otherwise
typedef int (*inject_sync_event_t)(SYNC_EVENT ev, void *management);
// retrieve_next_sync_event - receive next sync event
//
// parameters:
@ -118,7 +103,6 @@ DYNAMIC_API PEP_STATUS register_sync_callbacks(
PEP_SESSION session,
void *management,
notifyHandshake_t notifyHandshake,
inject_sync_event_t inject_sync_event,
retrieve_next_sync_event_t retrieve_next_sync_event
);


+ 3
- 1
sync/gen_statemachine.ysl2 View File

@ -421,8 +421,10 @@ tstylesheet {
default:
status = encrypt_message(session, _m, NULL, &m, PEP_enc_PEP, 0);
if (status)
if (status) {
status = PEP_SYNC_CANNOT_ENCRYPT;
goto the_end;
}
free_message(_m);
}


+ 1
- 1
test/convenience_scripts/mime_decrypt.cc View File

@ -20,7 +20,7 @@ int main(int argc, char* argv[]) {
PEP_SESSION session;
cout << "calling init()\n";
PEP_STATUS status = init(&session, NULL);
PEP_STATUS status = init(&session, NULL, NULL);
assert(status == PEP_STATUS_OK);
assert(session);
cout << "init() completed.\n";


+ 1
- 1
test/convenience_scripts/mime_encrypt.cc View File

@ -20,7 +20,7 @@ int main(int argc, char* argv[]) {
PEP_SESSION session;
cout << "calling init()\n";
PEP_STATUS status = init(&session);
PEP_STATUS status = init(&session, NULL, NULL);
assert(status == PEP_STATUS_OK);
assert(session);
cout << "init() completed.\n";


+ 1
- 1
test/convenience_scripts/mime_encrypt_decrypt.cc View File

@ -20,7 +20,7 @@ int main(int argc, char* argv[]) {
PEP_SESSION session;
cout << "calling init()\n";
PEP_STATUS status = init(&session, NULL);
PEP_STATUS status = init(&session, NULL, NULL);
assert(status == PEP_STATUS_OK);
assert(session);
cout << "init() completed.\n";


+ 2
- 2
test/pEpEngineTest.cc View File

@ -96,14 +96,14 @@ int main(int argc, char* argv[])
PEP_SESSION session;
cout << "calling init()\n";
PEP_STATUS init_result = init(&session, NULL);
PEP_STATUS init_result = init(&session, NULL, NULL);
cout << "returning from init() with result == " << status(init_result) << endl;
assert(init_result == PEP_STATUS_OK);
PEP_SESSION second_session;
cout << "second session test\n";
PEP_STATUS second_init_result = init(&second_session, NULL);
PEP_STATUS second_init_result = init(&second_session, NULL, NULL);
cout << "returning from second init() with result == " << status(second_init_result) << endl;
assert(second_init_result == PEP_STATUS_OK);
assert(second_session);


+ 1
- 1
test/src/EngineTestSuite.cc View File

@ -116,7 +116,7 @@ void EngineTestSuite::set_full_env() {
gpg_agent_conf(true);
// cout << "calling init()\n";
PEP_STATUS status = init(&session, NULL);
PEP_STATUS status = init(&session, NULL, NULL);
assert(status == PEP_STATUS_OK);
assert(session);
// cout << "init() completed.\n";


+ 1
- 2
test/src/engine_tests/SyncTests.cc View File

@ -104,7 +104,7 @@ void SyncTests::check_sync()
cout << "fpr: " << self->fpr << "\n";
free_identity(self);
status = init(&sync, Sync_Adapter::messageToSend);
status = init(&sync, Sync_Adapter::messageToSend, Sync_Adapter::inject_sync_event);
TEST_ASSERT(status == PEP_STATUS_OK);
cout << "initialize sync and start first state machine\n";
@ -112,7 +112,6 @@ void SyncTests::check_sync()
sync,
&adapter.q,
Sync_Adapter::notifyHandshake,
Sync_Adapter::inject_sync_event,
Sync_Adapter::retrieve_next_sync_event
);
TEST_ASSERT(status == PEP_STATUS_OK);


Loading…
Cancel
Save