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
|
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#ifndef CLIENT_H
#define CLIENT_H
#include <QThread>
#include <QDataStream>
#include <QSize>
#include <QDir>
#include <QLocalSocket>
#include <QSemaphore>
#include "mthemedaemonclient.h"
class TestClient;
class ClientManager;
class MRemoteThemeDaemon;
class ClientThread : public QThread
{
public:
ClientThread(ClientManager* manager);
void setId(const QString &id);
const QString &getId() const;
protected:
virtual void run();
private:
ClientManager* manager;
QString identifier;
};
class TestClient : public QObject
{
Q_OBJECT
static const int MAX_OPERATION_COUNT = 250;
static const int TASK_EXECUTION_INTERVAL = 50;
enum Task {
RegisterToServer,
RequestPixmap,
ReleasePixmap,
CheckConsistency,
NumberOfTasks
};
public:
TestClient(const QString &identifier);
~TestClient();
const QString& getId() const;
QString getImageDirectory() const;
void pixmapVerified(const QString& imageId, const QSize& size);
signals:
void pixmapReady(const QString& theme, TestClient* client, quint32 handle, const QString&, const QSize&);
protected:
void registerToServer();
void requestPixmap(M::MThemeDaemonProtocol::PixmapIdentifier &);
void releasePixmap(M::MThemeDaemonProtocol::PixmapIdentifier &);
void checkConsistency();
private slots:
void pixmapChangedSlot(const QString &imageId, const QSize &size, Qt::HANDLE pixmapHandle);
void themeChangedSlot(const QStringList &themeInheritance, const QStringList& libraryNames);
void connected();
void disconnected();
void sendPacket();
private:
bool isDataConsistent(const M::MThemeDaemonProtocol::ClientList *reply);
void quit();
MRemoteThemeDaemon *daemon;
QSet<M::MThemeDaemonProtocol::PixmapIdentifier> requestedPixmaps;
QSet<M::MThemeDaemonProtocol::PixmapIdentifier> readyPixmaps;
QString identifier;
int operationCount;
QString currentTheme;
QSemaphore waitVerify;
};
#endif
|