C++11 library providing functionality common to all adapters.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5 KiB

4 years ago
4 years ago
4 years ago
4 years ago
  1. // This file is under GNU General Public License 3.0
  2. // see LICENSE.txt
  3. #include "framework/framework.hh"
  4. #include "framework/utils.hh"
  5. #include <iostream>
  6. #include <assert.h>
  7. #include <pEp/sync_api.h>
  8. #include <pEp/keymanagement.h>
  9. #include "../src/Adapter.hh"
  10. #include "../src/utils.hh"
  11. using namespace std;
  12. using namespace pEp;
  13. PEP_STATUS messageToSend(struct _message *msg)
  14. {
  15. TESTLOG("called()");
  16. return PEP_STATUS_OK;
  17. }
  18. PEP_STATUS notifyHandshake(::pEp_identity *me, ::pEp_identity *partner, ::sync_handshake_signal signal)
  19. {
  20. TESTLOG("called()");
  21. return PEP_STATUS_OK;
  22. }
  23. int main(int argc, char **argv)
  24. {
  25. Test::setup(argc, argv);
  26. Adapter::pEpLog::set_enabled(true);
  27. Adapter::session.initialize(Adapter::SyncModes::Async, false, messageToSend, notifyHandshake);
  28. // Create new identity
  29. TESTLOG("updating or creating identity for me");
  30. ::pEp_identity *me = new_identity("alice@peptest.ch", NULL, "23", "Who the F* is Alice");
  31. assert(me);
  32. ::PEP_STATUS status = ::myself(Adapter::session(), me);
  33. ::free_identity(me);
  34. pEp::throw_status(status);
  35. // start and stop sync repeatedly
  36. useconds_t sleepuSec = 1000 * 100;
  37. unsigned long long int nrIters = 1000 * 1000 * 1000;
  38. for (int i = 0; i < nrIters; i++) {
  39. TESTLOG("RUN NR: ");
  40. TESTLOG(i);
  41. TESTLOG("SYNC START");
  42. TESTLOG("starting the adapter including sync");
  43. Adapter::startup();
  44. TESTLOG("SYNC STOP");
  45. usleep(sleepuSec);
  46. Adapter::stop_sync();
  47. }
  48. return 0;
  49. }