CoreManager.hpp 912 Bytes
Newer Older
Ronan Abhamon's avatar
Ronan Abhamon committed
1 2 3 4 5 6
#ifndef CORE_MANAGER_H_
#define CORE_MANAGER_H_

#include <QObject>
#include <linphone++/linphone.hh>

7 8
#include "../contact/VcardModel.hpp"

9
// =============================================================================
Ronan Abhamon's avatar
Ronan Abhamon committed
10 11 12 13 14

class CoreManager : public QObject {
  Q_OBJECT;

public:
15 16 17 18 19 20
  ~CoreManager () = default;

  std::shared_ptr<linphone::Core> getCore () {
    return m_core;
  }

Ronan Abhamon's avatar
Ronan Abhamon committed
21 22 23 24 25 26 27 28 29 30
  static void init () {
    if (!m_instance) {
      m_instance = new CoreManager();
    }
  }

  static CoreManager *getInstance () {
    return m_instance;
  }

31
public slots:
32 33
  // Must be used in a qml scene.
  // The ownership of `VcardModel` is `QQmlEngine::JavaScriptOwnership` by default.
34 35
  VcardModel *createDetachedVcardModel ();

Ronan Abhamon's avatar
Ronan Abhamon committed
36 37 38
private:
  CoreManager (QObject *parent = Q_NULLPTR);

Ronan Abhamon's avatar
Ronan Abhamon committed
39
  void setDatabasesPaths ();
Ronan Abhamon's avatar
Ronan Abhamon committed
40

Ronan Abhamon's avatar
Ronan Abhamon committed
41
  std::shared_ptr<linphone::Core> m_core;
42
  static CoreManager *m_instance;
Ronan Abhamon's avatar
Ronan Abhamon committed
43 44 45
};

#endif // CORE_MANAGER_H_