1 /* 2 * Notifier.hpp 3 * Copyright (C) 2017 Belledonne Communications, Grenoble, France 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 * 19 * Created on: February 2, 2017 20 * Author: Ronan Abhamon 21 */ 22 23 #ifndef NOTIFIER_H_ 24 #define NOTIFIER_H_ 25 26 #include <linphone++/linphone.hh> 27 #include <QObject> 28 29 // ============================================================================= 30 31 class QMutex; 32 class QQmlComponent; 33 34 class Notifier : public QObject { 35 Q_OBJECT; 36 37 public: 38 Notifier (QObject *parent = Q_NULLPTR); 39 ~Notifier (); 40 41 enum NotificationType { 42 ReceivedMessage, 43 ReceivedFileMessage, 44 ReceivedCall, 45 NewVersionAvailable, 46 SnapshotWasTaken, 47 RecordingCompleted 48 }; 49 50 void notifyReceivedMessage (const std::shared_ptr<linphone::ChatMessage> &message); 51 void notifyReceivedFileMessage (const std::shared_ptr<linphone::ChatMessage> &message); 52 void notifyReceivedCall (const std::shared_ptr<linphone::Call> &call); 53 void notifyNewVersionAvailable (const QString &version, const QString &url); 54 void notifySnapshotWasTaken (const QString &filePath); 55 void notifyRecordingCompleted (const QString &filePath); 56 57 public slots: 58 void deleteNotification (QVariant notification); 59 60 private: 61 struct Notification { NotificationNotifier::Notification62 Notification (const QString &filename = QString(""), int timeout = 0) { 63 this->filename = filename; 64 this->timeout = timeout; 65 } 66 67 QString filename; 68 int timeout; 69 }; 70 71 QObject *createNotification (NotificationType type); 72 void showNotification (QObject *notification, int timeout); 73 74 int mOffset = 0; 75 int mInstancesNumber = 0; 76 77 QMutex *mMutex = nullptr; 78 QQmlComponent **mComponents = nullptr; 79 80 static const QHash<int, Notification> mNotifications; 81 }; 82 83 #endif // NOTIFIER_H_ 84