1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CPWATCHDOG_H |
|
19 #define CPWATCHDOG_H |
|
20 |
|
21 #include <QObject> |
|
22 #include <QVector> |
|
23 |
|
24 #define gWatchDog CpWatchDog::instance() |
|
25 |
|
26 #define BEGIN_WATCHDOG_QUARANTINE(PLUGINID) \ |
|
27 gWatchDog->quarantine(PLUGINID); |
|
28 |
|
29 #define END_WATCHDOG_QUARANTINE(PLUGINID) \ |
|
30 gWatchDog->removeFromQuarantine(PLUGINID); |
|
31 |
|
32 class QSettings; |
|
33 class CpWatchDog : public QObject |
|
34 { |
|
35 Q_OBJECT |
|
36 public: |
|
37 static CpWatchDog *instance(); |
|
38 void quarantine(int uid); |
|
39 void removeFromQuarantine(int uid); |
|
40 bool isActive() const; |
|
41 bool wasCleanExit() const; |
|
42 void reportCleanExit(); |
|
43 bool isInBlackList(int uid); |
|
44 private: |
|
45 void init(); |
|
46 void readState(); |
|
47 void storeState(); |
|
48 void readQuarantine(); |
|
49 void storeQuarantine(); |
|
50 void readBlackList(); |
|
51 void storeBlackList(); |
|
52 void updateBlackListedPluginRunCounters(); |
|
53 public slots: |
|
54 void destroy(); |
|
55 private: |
|
56 Q_DISABLE_COPY(CpWatchDog) |
|
57 CpWatchDog(); |
|
58 virtual ~CpWatchDog(); |
|
59 private: |
|
60 struct PluginQuarantine |
|
61 { |
|
62 PluginQuarantine(); |
|
63 void read(QSettings &settings); |
|
64 void store(QSettings &settings); |
|
65 int mUid; |
|
66 int mRunsAfterCrash; |
|
67 }; |
|
68 private: |
|
69 bool mActive; |
|
70 int mCrashCounter; |
|
71 bool mAppRunning; |
|
72 int mMaxPluginBlackListedRuns; |
|
73 int mWatchdogActivationLimit; |
|
74 QVector<PluginQuarantine> mBlackList; |
|
75 QVector<int> mQuarantine; |
|
76 static CpWatchDog *self; |
|
77 }; |
|
78 |
|
79 #endif /* CPWATCHDOG_H */ |
|