1 /*
2  * %kadu copyright begin%
3  * %kadu copyright end%
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 as
7  * published by the Free Software Foundation; either version 2 of
8  * 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, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include "gui/windows/main-configuration-window.h"
22 
23 #include "notification/notifier.h"
24 
25 #include <QtCore/QObject>
26 #include <QtCore/QPointer>
27 #include <QtCore/QString>
28 #include <QtWidgets/QWidget>
29 #include <injeqt/injeqt.h>
30 
31 #if defined(Q_OS_UNIX)
32 #include <QtX11Extras/QX11Info>
33 #endif
34 
35 class Configuration;
36 class PluginInjectedFactory;
37 
38 class PCSpeakerNotifier : public QObject, public Notifier
39 {
40 	Q_OBJECT
41 
42 public:
43 	Q_INVOKABLE explicit PCSpeakerNotifier(QObject *parent = nullptr);
44 	~PCSpeakerNotifier();
45 
46 	virtual void notify(const Notification &notification) override;
47 	virtual NotifierConfigurationWidget *createConfigurationWidget(QWidget *parent = nullptr) override;
48 
49 	void parseAndPlay(QString linia);
50 
51 private:
52 	QPointer<Configuration> m_configuration;
53 	QPointer<PluginInjectedFactory> m_pluginInjectedFactory;
54 
55 #if defined(Q_OS_UNIX)
56 	Display *xdisplay;
57 #endif
58 	int volume;
59 
60 	void createDefaultConfiguration();
61 	void parseStringToSound(QString linia, int tablica[21], int tablica2[20]);
62 	void beep(int pitch, int duration);
63 	void play(int sound[21], int soundlength[20]);
64 
65 private slots:
66 	INJEQT_SET void setConfiguration(Configuration *configuration);
67 	INJEQT_SET void setPluginInjectedFactory(PluginInjectedFactory *pluginInjectedFactory);
68 
69 };
70