1 | /* |
2 | Copyright (c) 2007 Volker Krause <vkrause@kde.org> |
3 | Copyright (c) 2008 Kevin Krammer <kevin.krammer@gmx.at> |
4 | |
5 | This library is free software; you can redistribute it and/or modify it |
6 | under the terms of the GNU Library General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or (at your |
8 | option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, but WITHOUT |
11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
13 | License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to the |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
18 | 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef AKONADI_AGENTBASE_P_H |
22 | #define AKONADI_AGENTBASE_P_H |
23 | |
24 | #include "agentbase.h" |
25 | #include "tracerinterface.h" |
26 | |
27 | #include <klocalizedstring.h> |
28 | |
29 | #include <solid/networking.h> |
30 | |
31 | class QSettings; |
32 | class QTimer; |
33 | |
34 | namespace Akonadi { |
35 | |
36 | /** |
37 | * @internal |
38 | */ |
39 | class AgentBasePrivate : public QObject |
40 | { |
41 | Q_OBJECT |
42 | Q_CLASSINFO("D-Bus Interface" , "org.kde.dfaure" ) |
43 | |
44 | public: |
45 | explicit AgentBasePrivate(AgentBase *parent); |
46 | virtual ~AgentBasePrivate(); |
47 | void init(); |
48 | virtual void delayedInit(); |
49 | |
50 | void slotStatus(int status, const QString &message); |
51 | void slotPercent(int progress); |
52 | void slotWarning(const QString &message); |
53 | void slotError(const QString &message); |
54 | void slotNetworkStatusChange(Solid::Networking::Status); |
55 | void slotResumedFromSuspend(); |
56 | void slotTemporaryOfflineTimeout(); |
57 | |
58 | virtual void changeProcessed(); |
59 | |
60 | QString defaultReadyMessage() const |
61 | { |
62 | if (mOnline) { |
63 | return i18nc("@info:status Application ready for work" , "Ready" ); |
64 | } |
65 | return i18nc("@info:status" , "Offline" ); |
66 | } |
67 | |
68 | QString defaultSyncingMessage() const |
69 | { |
70 | return i18nc("@info:status" , "Syncing..." ); |
71 | } |
72 | |
73 | QString defaultErrorMessage() const |
74 | { |
75 | return i18nc("@info:status" , "Error." ); |
76 | } |
77 | |
78 | QString defaultUnconfiguredMessage() const |
79 | { |
80 | return i18nc("@info:status" , "Not configured" ); |
81 | } |
82 | |
83 | void setProgramName(); |
84 | |
85 | AgentBase *q_ptr; |
86 | Q_DECLARE_PUBLIC(AgentBase) |
87 | |
88 | QString mId; |
89 | QString mName; |
90 | QString mResourceTypeName; |
91 | |
92 | /// Use sessionBus() to access the connection. |
93 | QDBusConnection mDBusConnection; |
94 | |
95 | int mStatusCode; |
96 | QString mStatusMessage; |
97 | |
98 | uint mProgress; |
99 | QString mProgressMessage; |
100 | |
101 | bool mNeedsNetwork; |
102 | bool mOnline; |
103 | bool mDesiredOnlineState; |
104 | |
105 | QSettings *mSettings; |
106 | |
107 | ChangeRecorder *mChangeRecorder; |
108 | |
109 | org::freedesktop::Akonadi::Tracer *mTracer; |
110 | |
111 | AgentBase::Observer *mObserver; |
112 | |
113 | QTimer *mTemporaryOfflineTimer; |
114 | |
115 | public Q_SLOTS: |
116 | // Dump the contents of the current ChangeReplay |
117 | Q_SCRIPTABLE QString dumpNotificationListToString() const; |
118 | Q_SCRIPTABLE void dumpMemoryInfo() const; |
119 | Q_SCRIPTABLE QString dumpMemoryInfoToString() const; |
120 | |
121 | virtual void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection); |
122 | virtual void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers); |
123 | virtual void itemMoved(const Akonadi::Item &, const Akonadi::Collection &source, const Akonadi::Collection &destination); |
124 | virtual void itemRemoved(const Akonadi::Item &item); |
125 | void itemLinked(const Akonadi::Item &item, const Akonadi::Collection &collection); |
126 | void itemUnlinked(const Akonadi::Item &item, const Akonadi::Collection &collection); |
127 | |
128 | virtual void itemsFlagsChanged(const Akonadi::Item::List &items, const QSet<QByteArray> &addedFlags, const QSet<QByteArray> &removedFlags); |
129 | virtual void itemsMoved(const Akonadi::Item::List &items, const Akonadi::Collection &source, const Akonadi::Collection &destination); |
130 | virtual void itemsRemoved(const Akonadi::Item::List &items); |
131 | virtual void itemsLinked(const Akonadi::Item::List &items, const Akonadi::Collection &collection); |
132 | virtual void itemsUnlinked(const Akonadi::Item::List &items, const Akonadi::Collection &collection); |
133 | |
134 | virtual void collectionAdded(const Akonadi::Collection &collection, const Akonadi::Collection &parent); |
135 | virtual void collectionChanged(const Akonadi::Collection &collection); |
136 | virtual void collectionChanged(const Akonadi::Collection &collection, const QSet<QByteArray> &changedAttributes); |
137 | virtual void collectionMoved(const Akonadi::Collection &collection, const Akonadi::Collection &source, const Akonadi::Collection &destination); |
138 | virtual void collectionRemoved(const Akonadi::Collection &collection); |
139 | void collectionSubscribed(const Akonadi::Collection &collection, const Akonadi::Collection &parent); |
140 | void collectionUnsubscribed(const Akonadi::Collection &collection); |
141 | |
142 | virtual void tagAdded(const Akonadi::Tag &tag); |
143 | virtual void tagChanged(const Akonadi::Tag &tag); |
144 | virtual void tagRemoved(const Akonadi::Tag &tag); |
145 | virtual void itemsTagsChanged(const Akonadi::Item::List &items, const QSet<Akonadi::Tag> &addedTags, const QSet<Akonadi::Tag> &removedTags); |
146 | }; |
147 | |
148 | } |
149 | |
150 | #endif |
151 | |