-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_p.h
135 lines (120 loc) · 3.52 KB
/
client_p.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/****************************************************************************
**
** Ireen — cross-platform OSCAR protocol library
**
** Copyright © 2012 Ruslan Nigmatullin <[email protected]>
** Alexey Prokhin <[email protected]>
**
*****************************************************************************
**
** $IREEN_BEGIN_LICENSE$
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as
** published by the Free Software Foundation, either version 3
** of the License, 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 Lesser General Public License
** along with this program. If not, see http://www.gnu.org/licenses/.
** $IREEN_END_LICENSE$
**
****************************************************************************/
#ifndef IREEN_CLIENT_P_H
#define IREEN_CLIENT_P_H
#include "client.h"
#include "abstractconnection_p.h"
#include "capability.h"
#include "feedbag.h"
#include <k8json/k8json.h>
namespace Ireen {
class DetectCodec : public QTextCodec
{
public:
inline DetectCodec(QTextCodec **asciiCodec) : m_asciiCodec(asciiCodec) {}
protected:
QByteArray name() const { return "ireen-detect-codec"; }
QString convertToUnicode(const char *chars, int len, ConverterState *state) const
{
if (K8JSON::isValidUtf8(reinterpret_cast<const uchar*>(chars), len, false))
return Util::utf8Codec()->toUnicode(chars, len, state);
else
return (*m_asciiCodec)->toUnicode(chars, len, state);
}
QByteArray convertFromUnicode(const QChar *input, int number, ConverterState *state) const
{
return Util::utf8Codec()->fromUnicode(input, number, state);
}
int mibEnum() const { return 0; }
private:
QTextCodec **m_asciiCodec;
};
class MD5LoginDataPrivate : public QSharedData
{
public:
#if IREEN_SSL_SUPPORT
bool ssl;
#endif
QString password;
QString server;
quint16 port;
};
#if IREEN_SSL_SUPPORT
class OAuthLoginDataPrivate : public QSharedData
{
public:
bool ssl;
int versionMajor;
int versionMinor;
int versionSecMinor;
int versionPatch;
QString password;
QString devId;
QString clienName;
QString distId;
QVariant lastToken;
};
#endif
class AbstractLoginMethod
{
public:
virtual void login() = 0;
virtual QAbstractSocket::SocketState socketState() = 0;
virtual QObject *toObject() = 0;
QString errorString() const { return m_errorString; }
protected:
QString m_errorString;
};
class ClientPrivate : public AbstractConnectionPrivate
{
public:
ClientPrivate(Client *q_ptr) : q(q_ptr) {}
void setCapability(const Capability &capability, const QString &type);
bool removeCapability(const Capability &capability);
bool removeCapability(const QString &type);
void finishLogin();
void connectToBOSS(const QString &host, quint16 port, const QByteArray &cookie);
void sendUserInfo(bool force = false);
void setFeedbag(Feedbag *feedbag);
void login(AbstractLoginMethod *auth);
bool stopLogin();
public:
bool isIdle;
quint16 statusFlags;
QString uin;
QHash<quint64, Cookie> cookies;
Status status;
QByteArray auth_cookie;
Capabilities caps;
QHash<QString, Capability> typedCaps;
Feedbag *feedbag;
Client *q;
QTextCodec *asciiCodec;
DetectCodec *detectCodec;
AbstractLoginMethod *auth;
};
} // namespace Ireen
#endif // IREEN_CLIENT_P_H