1 | /* |
2 | Copyright (c) 2011 Volker Krause <vkrause@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or modify it |
5 | under the terms of the GNU Library General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or (at your |
7 | option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, but WITHOUT |
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public |
12 | License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to the |
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef AKDBUS_H |
21 | #define AKDBUS_H |
22 | |
23 | class QString; |
24 | |
25 | /** |
26 | * Helper methods for obtaining D-Bus identifiers. |
27 | * This should be used instead of hardcoded identifiers or constants to support multi-instance namespacing |
28 | * @since 1.7 |
29 | */ |
30 | namespace AkDBus { |
31 | /** D-Bus service types used by the Akonadi server processes. */ |
32 | enum ServiceType { |
33 | Server, |
34 | Control, |
35 | ControlLock, |
36 | AgentServer, |
37 | StorageJanitor, |
38 | UpgradeIndicator |
39 | }; |
40 | |
41 | /** |
42 | * Returns the service name for the given @p serviceType. |
43 | */ |
44 | QString serviceName(ServiceType serviceType); |
45 | |
46 | /** Known D-Bus service name types for agents. */ |
47 | enum AgentType { |
48 | Unknown, |
49 | Agent, |
50 | Resource, |
51 | Preprocessor |
52 | }; |
53 | |
54 | /** |
55 | * Parses a D-Bus service name and checks if it belongs to an agent of this instance. |
56 | * @param serviceName The service name to parse. |
57 | * @param agentType Output parameter containing the agent type. |
58 | * @return The identifier of the agent, empty string if that's not an agent (or an agent of a different Akonadi instance) |
59 | */ |
60 | QString parseAgentServiceName(const QString &serviceName, AkDBus::AgentType &agentType); |
61 | |
62 | /** |
63 | * Returns the D-Bus service name of the agent @p agentIdentifier for type @p agentType. |
64 | */ |
65 | QString agentServiceName(const QString &agentIdentifier, AkDBus::AgentType agentType); |
66 | } |
67 | |
68 | #endif |
69 | |