f43601217a434cbbef6197159da7acde381b1b91
[platform/framework/web/wrt.git] / src / api_new / core_module.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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  * @file    core_module.cpp
18  * @author  Przemyslaw Ciezkowski (p.ciezkowski@samsung.com)
19  * @authir  Andrzej Surdej (a.surdej@gmail.com)
20  * @version 1.0
21  * @brief   File contains declarations of wrt core module.
22  */
23
24 #ifndef CORE_MODULE_H_
25 #define CORE_MODULE_H_
26
27 #include <dpl/wrt-dao-ro/wrt_db_types.h>
28 #include "i_runnable_widget_object.h"
29 #include <dpl/singleton.h>
30 #include <memory>
31
32 #include <EWebKit2.h>
33
34 namespace WRT {
35
36 class CoreModuleImpl; // forward declaration
37
38 class CoreModule
39 {
40   public:
41     /**
42      * Network access mode enum.
43      */
44     enum NetworkAccessMode
45     {
46         NEVER_CONNECT,
47         ALWAYS_ASK,
48         CONNECT_AUTOMATICALLY
49     };
50
51     /**
52      * Initialize needed by WRT components (database etc).
53      * Will not throw exception. elm_init() is NOT called in this function.
54      * You MUST call it before running widget.
55      * @return true on success, false when it fails
56      */
57     bool Init();
58     bool Init(Ewk_Context* ewk_context);
59     /**
60      * Deinitialize CoreModule. If it called without Init() some internal
61      * asserts will fail.
62      */
63     void Terminate();
64     /**
65      * Create model with given package name.
66      * Init must be called earlier. You MUST destroy all
67      * RunnableWidgetObjectPtr before calling Terminate.
68      * @param packageName
69      * @return NULL on fail
70      */
71     RunnableWidgetObjectPtr getRunnableWidgetObject(
72             const std::string& tizenId);
73     /**
74      * Gets from database global property of homeNetworkAccess
75      * @return homeNetworkAccess value
76      */
77     NetworkAccessMode homeNetworkAccess();
78     /**
79      * Gets from database global property of roamingNetworkAccess
80      * @return roamingNetworkAccess value
81      */
82     NetworkAccessMode roamingNetworkAccess();
83     /**
84      * Returns actual value of developer mode.
85      * @return is developer mode on
86      */
87     bool developerMode();
88
89   private:
90     CoreModule();
91     ~CoreModule();
92     std::unique_ptr<CoreModuleImpl> m_impl;
93
94     friend class DPL::Singleton<CoreModule>;
95 };
96
97 typedef DPL::Singleton<CoreModule> CoreModuleSingleton;
98
99 } /* namespace WRT */
100 #endif /* CORE_MODULE_H_ */