ButeoSynchronizationFramework
ClientThread.h
1 /*
2  * This file is part of buteo-syncfw package
3  *
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * version 2.1 as published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23 #ifndef CLIENTTHREAD_H
24 #define CLIENTTHREAD_H
25 
26 #include <QThread>
27 #include <QMutex>
28 #include <SyncResults.h>
29 
30 #include "SignOn/AuthService"
31 #include "SignOn/Identity"
32 
33 namespace Buteo {
34 
35 class ClientPlugin;
36 
40 class ClientThread : public QThread
41 {
42  Q_OBJECT;
43 public:
44 
48  ClientThread();
49 
53  virtual ~ClientThread();
54 
59  QString getProfileName() const;
60 
65  ClientPlugin* getPlugin() const;
66 
73  bool startThread( ClientPlugin* aClientPlugin );
74 
78  void stopThread();
79 
84 
85 signals:
86 
94  void initError( const QString &aProfileName, const QString &aMessage,
95  int aErrorCode);
96 
97 protected:
100  virtual void run();
101 
102 private:
103 
104  ClientPlugin* iClientPlugin;
105 
106  SyncResults iSyncResults;
107 
108  SignOn::Identity *iIdentity;
109  SignOn::AuthService *iService;
110  SignOn::AuthSession *iSession;
111  QString iProvider;
112 
113  bool iRunning;
114 
115  mutable QMutex iMutex;
116 
117 #ifdef SYNCFW_UNIT_TESTS
118  friend class ClientThreadTest;
119 #endif
120 
134  bool startSync();
135 
136 private slots:
137  void identities(const QList<SignOn::IdentityInfo> &identityList);
138  void identityResponse(const SignOn::SessionData &session);
139  void identityError(SignOn::Error error);
140 };
141 
142 }
143 
144 #endif // CLIENTTHREAD_H
Contains information about a completed synchronization session.
Definition: SyncResults.h:58
void stopThread()
Stops client thread.
Definition: ClientThread.cpp:117
Definition: AccountsHelper.h:31
Thread for client plugins.
Definition: ClientThread.h:40
bool startThread(ClientPlugin *aClientPlugin)
Starts client thread.
Definition: ClientThread.cpp:69
QString getProfileName() const
Returns profile that this thread is running.
Definition: ClientThread.cpp:49
ClientThread()
Constructor.
Definition: ClientThread.cpp:30
ClientPlugin * getPlugin() const
Returns plugin that this thread is running.
Definition: ClientThread.cpp:62
virtual ~ClientThread()
Destructor.
Definition: ClientThread.cpp:40
Base class for client plugins.
Definition: ClientPlugin.h:37
SyncResults getSyncResults()
Returns the results for this particular thread.
Definition: ClientThread.cpp:155
void initError(const QString &aProfileName, const QString &aMessage, int aErrorCode)
Emitted when synchronization cannot be started due to an error in plugin initialization.
Definition: moc_ClientThread.cpp:178
Definition: SyncBackupAdaptor.h:40
virtual void run()
overriding method for QThread::run
Definition: ClientThread.cpp:123