-
Notifications
You must be signed in to change notification settings - Fork 0
/
sender.h
119 lines (107 loc) · 3.35 KB
/
sender.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* sender.h - Sof Game Psi plugin
* Copyright (C) 2010 Aleksey Andreev
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* You can also redistribute and/or modify this program under the
* terms of the Psi License, specified in the accompanied COPYING
* file, as published by the Psi Project; either dated January 1st,
* 2005, or (at your option) any later version.
*
* This program 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 this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef SENDER_H
#define SENDER_H
#include <QtCore>
#include "applicationinfoaccessinghost.h"
#include "stanzasendinghost.h"
extern StanzaSendingHost* sender_;
extern QStringList chatJids;
class Sender: public QObject
{
Q_OBJECT
public:
struct jid_status {
QString jid;
int status;
QDateTime last_status;
QDateTime last_send;
QDateTime last_recv_game; // Последнее игровое сообщение (ответ на запрос)
QDateTime last_send_ping;
QDateTime last_recv_ping;
int probe_count;
float resp_average;
};
static Sender *instance();
static void reset();
void changeAccount(int, const QString &);
void setAccountStatus(int curr_status);
void insertGameJid(const QString &, int);
void removeGameJid(const QString &);
int getGameJidIndex(const QString &) const;
QStringList getGameJids() const;
const struct jid_status* getGameJidInfo(int) const;
bool setGameJidStatus(int, qint32);
int getGameMirrorsMode() const {return gameMirrorsMode;}
bool setGameMirrorsMode(int mirrorsMode);
bool setSendDelta(int);
int getSendDelta() const;
bool setServerTimeoutDuration(int);
int getServerTimeoutDuration() const;
bool doGameAsk(const QString &mirrorJid, const QString &message);
bool sendString(const QString &str);
bool sendSystemString(const QString &stringPtr);
int getGameQueueLength() const;
void resetGameQueue();
private:
static Sender *instanse_;
int currentAccount;
QString currentAccJid;
QVector<struct jid_status> gameJidsEx;
int jidActiveCount;
bool pingMirrors;
int jidInterval;
QDateTime lastSend;
//QDateTime lastReceive;
//QTimer* mirrorsProbeTimer;
QQueue<int> pingQueue;
QQueue<QString> gameQueue;
QQueue<QString> systemQueue;
int gameMirrorsMode;
int currGameJidIndex;
int lastSendIndex; // TODO объединить с предыдущим
bool waitingForReceive;
int waitForReceivePeriod;
int sendCommandRetries;
QString lastCommand;
QRegExp fastSendReg;
QTimer gameSenderTimer;
QString prefix;
private:
Sender();
~Sender();
void startPingMirrors();
void stopPingMirrors();
void clearPingQueue(int mirrorIndex);
private slots:
void doPingJob();
void doSendGameStringJob();
signals:
void accountChanged(const QString);
bool gameTextReceived(const QString, const QString);
void errorOccurred(int);
void queueSizeChanged(int);
};
#endif