/**************************************************************************** ** ** Copyright (C) 2020 Elias Steurer (Kelteseth) ** Contact: https://screen-play.app ** ** This file is part of ScreenPlay. ScreenPlay is licensed under a dual license in ** order to ensure its sustainability. When you contribute to ScreenPlay ** you accept that your work will be available under the two following licenses: ** ** $SCREENPLAY_BEGIN_LICENSE$ ** ** #### Affero General Public License Usage (AGPLv3) ** Alternatively, this file may be used under the terms of the GNU Affero ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file "ScreenPlay License.md" included in the ** packaging of this App. Please review the following information to ** ensure the GNU Affero Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/agpl-3.0.en.html. ** ** #### Commercial License ** This code is owned by Elias Steurer. By changing/adding to the code you agree to the ** terms written in: ** * Legal/corporate_contributor_license_agreement.md - For corporate contributors ** * Legal/individual_contributor_license_agreement.md - For individual contributors ** ** #### Additional Limitations to the AGPLv3 and Commercial Lincese ** This License does not grant any rights in the trademarks, ** service marks, or logos. ** ** ** $SCREENPLAY_END_LICENSE$ ** ****************************************************************************/ #pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include class ScreenPlaySDK : public QQuickItem { Q_OBJECT Q_DISABLE_COPY(ScreenPlaySDK) public: ScreenPlaySDK(QQuickItem* parent = nullptr); ScreenPlaySDK(const QString& appID, const QString& type, QQuickItem* parent = nullptr); ~ScreenPlaySDK(); Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged) Q_PROPERTY(bool isConnected READ isConnected WRITE setIsConnected NOTIFY isConnectedChanged) Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged) QString type() const { return m_type; } bool isConnected() const { return m_isConnected; } QString appID() const { return m_appID; } public slots: void sendMessage(const QJsonObject& obj); void connected(); void disconnected(); void readyRead(); void error(QLocalSocket::LocalSocketError socketError); void redirectMessage(QByteArray& msg); void pingAlive(); void start(); void setType(QString type) { if (m_type == type) return; m_type = type; emit typeChanged(m_type); } void setIsConnected(bool isConnected) { if (m_isConnected == isConnected) return; m_isConnected = isConnected; emit isConnectedChanged(m_isConnected); } void setAppID(QString appID) { if (m_appID == appID) return; m_appID = appID; emit appIDChanged(m_appID); } static void redirectMessageOutputToMainWindow(QtMsgType type, const QMessageLogContext& context, const QString& msg); signals: void incommingMessage(QString key, QString value); void incommingMessageError(QString msg); void sdkConnected(); void sdkDisconnected(); void typeChanged(QString type); void isConnectedChanged(bool isConnected); void appIDChanged(QString appID); void newRedirectMessage(QByteArray& msg); void replaceWallpaper( const QString absolutePath, const QString file, const float volume, const QString fillMode, const QString type, const bool checkWallpaperVisible); private: QLocalSocket m_socket; QString m_type = "undefined"; bool m_isConnected = false; QString m_appID; QTimer m_pingAliveTimer; QTimer m_firstConnectionTimer; };