[Release] wrt_0.8.274
[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 <dpl/optional_typedefs.h>
31 #include <memory>
32
33 namespace WRT {
34 class CoreModuleImpl; // forward declaration
35
36 class CoreModule
37 {
38   public:
39     /**
40      * Network access mode enum.
41      */
42     enum NetworkAccessMode
43     {
44         NEVER_CONNECT,
45         ALWAYS_ASK,
46         CONNECT_AUTOMATICALLY
47     };
48
49     /**
50      * Initialize needed by WRT components (database etc).
51      * Will not throw exception. elm_init() is NOT called in this function.
52      * You MUST call it before running widget.
53      * @return true on success, false when it fails
54      */
55     bool Init();
56     /**
57      * Deinitialize CoreModule. If it called without Init() some internal
58      * asserts will fail.
59      */
60     void Terminate();
61     /**
62      * Create model with given package name.
63      * Init must be called earlier. You MUST destroy all
64      * RunnableWidgetObjectPtr before calling Terminate.
65      * @param packageName
66      * @return NULL on fail
67      */
68     RunnableWidgetObjectPtr getRunnableWidgetObject(
69         const std::string& tizenId);
70     /**
71      * Gets from database global property of homeNetworkAccess
72      * @return homeNetworkAccess value
73      */
74     NetworkAccessMode homeNetworkAccess();
75     /**
76      * Gets from database global property of roamingNetworkAccess
77      * @return roamingNetworkAccess value
78      */
79     NetworkAccessMode roamingNetworkAccess();
80
81   private:
82     CoreModule();
83     ~CoreModule();
84     std::unique_ptr<CoreModuleImpl> m_impl;
85
86     friend class DPL::Singleton<CoreModule>;
87 };
88
89 typedef DPL::Singleton<CoreModule> CoreModuleSingleton;
90 } /* namespace WRT */
91 #endif /* CORE_MODULE_H_ */