Store the dbus connection while launching the service
[platform/core/context/context-service.git] / src / agent / legacy / ContextManager.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef _CONTEXT_CONTEXT_MANAGER_H_
18 #define _CONTEXT_CONTEXT_MANAGER_H_
19
20 #include <map>
21 #include <IContextManager.h>
22 #include <ICustomRegister.h>
23
24 namespace ctx {
25
26         /* Forward declaration */
27         class Credentials;
28         class RequestInfo;
29
30         class ContextManager : public IContextManager, ICustomRegister {
31         public:
32                 ~ContextManager();
33
34                 bool init();
35                 void release();
36
37                 void assignRequest(ctx::RequestInfo *request);
38                 bool isSupported(const char *subject);
39                 bool isAllowed(const Credentials *creds, const char *subject);
40
41                 /* From the interface class */
42                 bool publish(const char *subject, ctx::CtxJson1 &option, int error, ctx::CtxJson1 &dataUpdated);
43                 bool replyToRead(const char *subject, ctx::CtxJson1 &option, int error, ctx::CtxJson1 &dataRead);
44                 bool registerCustomProvider(const char* subject, int operation, ctx::CtxJson1 &attribute, ctx::CtxJson1 &option, const char* owner);
45                 bool unregisterCustomProvider(const char* subject);
46
47                 bool popTriggerTemplate(std::string &subject, int &operation, CtxJson1 &attribute, CtxJson1 &option);
48
49         private:
50                 ContextManager();
51
52                 static gboolean __threadSwitcher(gpointer data);
53
54                 void __publish(const char *subject, ctx::CtxJson1 &option, int error, ctx::CtxJson1 &dataUpdated);
55                 void __replyToRead(const char *subject, ctx::CtxJson1 &option, int error, ctx::CtxJson1 &dataRead);
56
57                 friend class Server;
58
59         };      /* class ContextManager */
60
61 }       /* namespace ctx */
62
63 #endif  /* _CONTEXT_CONTEXT_MANAGER_H_ */