ButeoSynchronizationFramework
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 
29 namespace Buteo {
30 
31 class ServerPlugin;
32 
36 class ServerThread : public QThread
37 {
38  Q_OBJECT;
39 public:
40 
44  ServerThread();
45 
49  virtual ~ServerThread();
50 
55  QString getProfileName() const;
56 
61  ServerPlugin* getPlugin() const;
62 
69  bool startThread( ServerPlugin* aServerPlugin );
70 
74  void stopThread();
75 
76 signals:
77 
85  void initError( const QString &aProfileName, const QString &aMessage,
86  int aErrorCode);
87 
88 protected:
89 
91  virtual void run();
92 
93 private:
94 
95  ServerPlugin *iServerPlugin;
96 
97  bool iRunning;
98 
99  mutable QMutex iMutex;
100 
101 #ifdef SYNCFW_UNIT_TESTS
102  friend class ServerThreadTest;
103 #endif
104 
105 };
106 
107 }
108 
109 #endif // SERVERTHREAD_H
ServerPlugin * getPlugin() const
Returns plugin that this thread is running.
Definition: ServerThread.cpp:57
ServerThread()
Constructor.
Definition: ServerThread.cpp:32
Definition: AccountsHelper.h:31
Base class for server plugins.
Definition: ServerPlugin.h:36
QString getProfileName() const
Returns profile that this thread is running.
Definition: ServerThread.cpp:44
bool startThread(ServerPlugin *aServerPlugin)
Starts server thread.
Definition: ServerThread.cpp:65
void stopThread()
Stops server thread.
Definition: ServerThread.cpp:93
Thread for server plugin.
Definition: ServerThread.h:36
virtual ~ServerThread()
Destructor.
Definition: ServerThread.cpp:39
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_ServerThread.cpp:125
virtual void run()
overriding method of QThread::run
Definition: ServerThread.cpp:100