1 /*=============================================================================
2 
3   Library: CTK
4 
5   Copyright (c) German Cancer Research Center,
6     Division of Medical and Biological Informatics
7 
8   Licensed under the Apache License, Version 2.0 (the "License");
9   you may not use this file except in compliance with the License.
10   You may obtain a copy of the License at
11 
12     http://www.apache.org/licenses/LICENSE-2.0
13 
14   Unless required by applicable law or agreed to in writing, software
15   distributed under the License is distributed on an "AS IS" BASIS,
16   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   See the License for the specific language governing permissions and
18   limitations under the License.
19 
20 =============================================================================*/
21 
22 
23 #ifndef CTKCONFIGURATIONADMINFACTORY_P_H
24 #define CTKCONFIGURATIONADMINFACTORY_P_H
25 
26 #include <QObject>
27 
28 #include <ctkPluginEvent.h>
29 #include <ctkServiceFactory.h>
30 #include <service/cm/ctkConfigurationListener.h>
31 
32 #include "ctkCMEventDispatcher_p.h"
33 #include "ctkCMPluginManager_p.h"
34 #include "ctkConfigurationStore_p.h"
35 #include "ctkManagedServiceTracker_p.h"
36 #include "ctkManagedServiceFactoryTracker_p.h"
37 
38 struct ctkLogService;
39 class ctkConfigurationAdminImpl;
40 class ctkConfigurationImpl;
41 
42 /**
43  * ctkConfigurationAdminFactory provides a Configuration Admin ServiceFactory but more significantly
44  * launches the whole implementation.
45  */
46 class ctkConfigurationAdminFactory : public QObject, public ctkServiceFactory
47 {
48   Q_OBJECT
49   Q_INTERFACES(ctkServiceFactory)
50 
51 public:
52 
53   ctkConfigurationAdminFactory(ctkPluginContext* context, ctkLogService* log);
54   ~ctkConfigurationAdminFactory();
55 
56   void start();
57   void stop();
58 
59   QObject* getService(QSharedPointer<ctkPlugin> plugin, ctkServiceRegistration registration);
60   void ungetService(QSharedPointer<ctkPlugin> plugin, ctkServiceRegistration registration, QObject* service);
61 
62   void checkConfigurationPermission();
63 
64   ctkLogService* getLogService() const;
65 
66   void dispatchEvent(ctkConfigurationEvent::Type type, const QString& factoryPid, const QString& pid);
67 
68   void notifyConfigurationUpdated(ctkConfigurationImpl* config, bool isFactory);
69   void notifyConfigurationDeleted(ctkConfigurationImpl* config, bool isFactory);
70 
71   void modifyConfiguration(const ctkServiceReference& reference, ctkDictionary& properties);
72 
73 public Q_SLOTS:
74 
75   void pluginChanged(const ctkPluginEvent& event);
76 
77 private:
78 
79   //Permission configurationPermission = new ConfigurationPermission("*", ConfigurationPermission.CONFIGURE); //$NON-NLS-1$
80   ctkCMEventDispatcher eventDispatcher;
81   ctkCMPluginManager pluginManager;
82   ctkLogService* logService;
83   ctkConfigurationStore configurationStore;
84   ctkManagedServiceTracker managedServiceTracker;
85   ctkManagedServiceFactoryTracker managedServiceFactoryTracker;
86 
87   QList<ctkConfigurationAdminImpl*> configAdmins;
88 };
89 
90 #endif // CTKCONFIGURATIONADMINFACTORY_P_H
91