Buteo Synchronization Framework
ServerThread.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 SERVERTHREAD_H
24 #define SERVERTHREAD_H
25 
26 #include <QThread>
27 #include <QMutex>
28 #include <SyncResults.h>
29 
30 namespace Buteo {
31 
32 class ServerPlugin;
33 
37 class ServerThread : public QThread
38 {
39  Q_OBJECT
40 public:
41 
45  ServerThread();
46 
50  virtual ~ServerThread();
51 
56  QString getProfileName() const;
57 
62  ServerPlugin *getPlugin() const;
63 
70  bool startThread( ServerPlugin *aServerPlugin);
71 
75  void stopThread();
76 
77 signals:
78 
86  void initError(const QString &aProfileName, const QString &aMessage,
87  SyncResults::MinorCode aErrorCode);
88 
89 protected:
90 
92  virtual void run();
93 
94 private:
95  ServerPlugin *iServerPlugin;
96  bool iRunning;
97  mutable QMutex iMutex;
98 
99 #ifdef SYNCFW_UNIT_TESTS
100  friend class ServerThreadTest;
101 #endif
102 
103 };
104 
105 }
106 
107 #endif // SERVERTHREAD_H
Base class for server plugins.
Definition: ServerPlugin.h:37
Thread for server plugin.
Definition: ServerThread.h:38
QString getProfileName() const
Returns profile that this thread is running.
Definition: ServerThread.cpp:44
void stopThread()
Stops server thread.
Definition: ServerThread.cpp:90
void initError(const QString &aProfileName, const QString &aMessage, SyncResults::MinorCode aErrorCode)
Emitted when synchronization cannot be started due to an error in plugin initialization.
Definition: moc_ServerThread.cpp:134
bool startThread(ServerPlugin *aServerPlugin)
Starts server thread.
Definition: ServerThread.cpp:64
virtual ~ServerThread()
Destructor.
Definition: ServerThread.cpp:39
virtual void run()
overriding method of QThread::run
Definition: ServerThread.cpp:96
ServerThread()
Constructor.
Definition: ServerThread.cpp:32
ServerPlugin * getPlugin() const
Returns plugin that this thread is running.
Definition: ServerThread.cpp:56
MinorCode
enum value
Definition: SyncResults.h:77