KDE PIM support for the p≡p engine
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.

54 lines
1.2 KiB

  1. #include "syncthread.h"
  2. #include <kde_pep_common/pephelpers.h>
  3. #include <QDebug>
  4. pEpSyncThread *pEpSyncThread::hackinstance = nullptr;
  5. void pEpSyncThread::slotMessageToSend(message *msg)
  6. {
  7. }
  8. void pEpSyncThread::slotNotifyHandshake(_pEp_identity *, _pEp_identity *, _sync_handshake_signal)
  9. {
  10. }
  11. PEP_STATUS pEpSyncThread::messageToSend(message *msg)
  12. {
  13. if (pEpSyncThread::hackinstance) {
  14. pEpSyncThread::hackinstance->slotMessageToSend(msg);
  15. }
  16. return PEP_STATUS_OK;
  17. }
  18. PEP_STATUS pEpSyncThread::notifyHandshake(_pEp_identity *id1, _pEp_identity *id2, _sync_handshake_signal sig)
  19. {
  20. if (pEpSyncThread::hackinstance) {
  21. pEpSyncThread::hackinstance->slotNotifyHandshake(id1, id2, sig);
  22. }
  23. return PEP_STATUS_OK;
  24. }
  25. pEpSyncThread::pEpSyncThread(QObject *parent)
  26. : QThread(parent)
  27. {
  28. hackinstance = this;
  29. pEp::Adapter::session.initialize(pEp::Adapter::SyncModes::Sync, true, messageToSend, notifyHandshake);
  30. // pEp::Adapter::session.initialize();
  31. }
  32. pEpSyncThread::~pEpSyncThread()
  33. {
  34. mutex.lock();
  35. pEp::Adapter::session.release();
  36. mutex.unlock();
  37. wait();
  38. }
  39. void pEpSyncThread::run()
  40. {
  41. mutex.lock();
  42. pEp::Adapter::start_sync();
  43. mutex.unlock();
  44. }