Notifier.hpp 2.42 KB
Newer Older
1 2
/*
 * Notifier.hpp
3
 * Copyright (C) 2017-2018  Belledonne Communications, Grenoble, France
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *  Created on: February 2, 2017
 *      Author: Ronan Abhamon
 */

23 24
#ifndef NOTIFIER_H_
#define NOTIFIER_H_
25

26 27
#include <memory>

28 29
#include <QObject>

30
// =============================================================================
31

32
class QMutex;
Ronan's avatar
Ronan committed
33 34
class QQmlComponent;

35 36 37 38 39
namespace linphone {
  class Call;
  class ChatMessage;
}

40
class Notifier : public QObject {
Ronan's avatar
Ronan committed
41
  Q_OBJECT;
42 43

public:
44
  Notifier (QObject *parent = Q_NULLPTR);
45
  ~Notifier ();
Ronan's avatar
Ronan committed
46

47
  enum NotificationType {
48 49 50
    ReceivedMessage,
    ReceivedFileMessage,
    ReceivedCall,
51
    NewVersionAvailable,
52 53
    SnapshotWasTaken,
    RecordingCompleted
Ronan's avatar
Ronan committed
54 55
  };

56 57 58
  void notifyReceivedMessage (const std::shared_ptr<linphone::ChatMessage> &message);
  void notifyReceivedFileMessage (const std::shared_ptr<linphone::ChatMessage> &message);
  void notifyReceivedCall (const std::shared_ptr<linphone::Call> &call);
59
  void notifyNewVersionAvailable (const QString &version, const QString &url);
60
  void notifySnapshotWasTaken (const QString &filePath);
61
  void notifyRecordingCompleted (const QString &filePath);
Ronan's avatar
Ronan committed
62

63 64 65
public slots:
  void deleteNotification (QVariant notification);

Ronan's avatar
Ronan committed
66
private:
67 68 69 70 71 72 73 74 75 76
  struct Notification {
    Notification (const QString &filename = QString(""), int timeout = 0) {
      this->filename = filename;
      this->timeout = timeout;
    }

    QString filename;
    int timeout;
  };

77 78 79
  QObject *createNotification (NotificationType type);
  void showNotification (QObject *notification, int timeout);

80 81
  int mOffset = 0;
  int mInstancesNumber = 0;
82 83 84 85

  QMutex *mMutex = nullptr;
  QQmlComponent **mComponents = nullptr;

86
  static const QHash<int, Notification> Notifications;
87 88
};

89
#endif // NOTIFIER_H_