-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocketreader.h
85 lines (77 loc) · 2.62 KB
/
socketreader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// This file is part of Twiccian.
//
// Twiccian 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 3 of the License, or
// (at your option) any later version.
//
// Twiccian 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 Twiccian. If not, see <http://www.gnu.org/licenses/>.
#include <QTcpSocket>
#include <QQmlContext>
#include <QNetworkSession>
#include <QSettings>
#include "account.h"
#include "result.h"
#include "main.h"
#include <time.h>
class SocketReader : public QObject
{
Q_OBJECT
public:
SocketReader();
~SocketReader();
QByteArray *sendYtDlUrl(QString cmd);
QByteArray *searchStreams(QString query);
QByteArray *searchGames(QString query); //
QByteArray *getFollowing();
QByteArray *getGames(); //
QByteArray *getAuthState();
QByteArray *changeChat(QString username);
private:
QTcpSocket *sock;
QString lastResponse;
QNetworkSession *networkSession;
QString lastUrl;
QString lastDesc;
quint16 blocksize;
};
class SubmitUrlObj : public QObject
{
Q_OBJECT
Q_PROPERTY(QList<QObject*> results READ getResults)
Q_PROPERTY(QObject* streamer READ getStreamer)
Q_PROPERTY(QObject* user READ getUser)
QString submittedUrl;
private:
Account* streamer;
Account* user;
Result* curResult;
QList<QObject*> results;
QList<QObject*> searches;
QQmlContext *context;
public:
Q_INVOKABLE void requestUrl(QString submittedUrl);
Q_INVOKABLE void changeChat(QString username);
Q_INVOKABLE void requestFollowing();
Q_INVOKABLE void requestGames(); //
Q_INVOKABLE void requestStreamSearch(QString query);
Q_INVOKABLE void requestGameSearch(QString query); //
Q_INVOKABLE QString getUrl();
Q_INVOKABLE QList<QObject*> getResults();
Q_INVOKABLE QList<QObject*> getSearches();
Q_INVOKABLE QObject* getStreamer();
Q_INVOKABLE QObject* getResult();
Q_INVOKABLE void setResult(int index, int list);
Q_INVOKABLE void setStreamer(int index);
Q_INVOKABLE void setStreamerSearch(int index);
Q_INVOKABLE QObject* getUser();
Q_INVOKABLE void setContext(QQmlContext *ctxt);
Q_INVOKABLE bool isAuthenticated();
Q_INVOKABLE bool isLightTheme();
};