1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-05 18:42:29 +01:00
ScreenPlay/ScreenPlaySDK/inc/screenplaysdk.h

136 lines
3.9 KiB
C
Raw Normal View History

/****************************************************************************
**
** 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
2018-04-18 18:39:25 +02:00
#include <QByteArray>
#include <QJsonArray>
#include <QJsonDocument>
2018-04-18 18:39:25 +02:00
#include <QJsonObject>
#include <QJsonParseError>
2018-04-18 18:39:25 +02:00
#include <QLocalServer>
#include <QLocalSocket>
#include <QObject>
2018-09-06 13:57:36 +02:00
#include <QPluginLoader>
2018-04-18 18:39:25 +02:00
#include <QQuickItem>
#include <QSharedDataPointer>
#include <QSharedPointer>
#include <QTimer>
2018-09-06 13:57:36 +02:00
#include <QtGlobal>
class ScreenPlaySDK : public QObject {
Q_OBJECT
public:
ScreenPlaySDK(const QString& appID, const QString& type);
~ScreenPlaySDK();
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(bool isConnected READ isConnected WRITE setIsConnected NOTIFY isConnectedChanged)
2018-03-12 16:20:48 +01:00
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; }
2018-03-12 16:20:48 +01:00
public slots:
void sendMessage(const QJsonObject& obj);
void connected();
void disconnected();
void readyRead();
void error(QLocalSocket::LocalSocketError socketError);
2018-09-08 13:46:31 +02:00
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);
}
2018-03-12 16:20:48 +01:00
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:
2018-03-12 16:20:48 +01:00
void incommingMessage(QString key, QString value);
void incommingMessageError(QString msg);
void sdkConnected();
void sdkDisconnected();
void typeChanged(QString type);
void isConnectedChanged(bool isConnected);
2018-03-12 16:20:48 +01:00
void appIDChanged(QString appID);
2018-09-08 13:46:31 +02:00
void newRedirectMessage(QByteArray& msg);
2018-03-12 16:20:48 +01:00
void replaceWallpaper(
const QString absolutePath,
const QString file,
const float volume,
const QString fillMode,
const QString type,
const bool checkWallpaperVisible);
private:
2018-09-06 13:57:36 +02:00
QLocalSocket m_socket;
QString m_type;
bool m_isConnected = false;
2018-03-12 16:20:48 +01:00
QString m_appID;
QTimer m_pingAliveTimer;
2021-05-16 11:57:50 +02:00
QTimer m_firstConnectionTimer;
};