The license change version 1.0 to version 1.1
[apps/home/wrt-setting.git] / webapp-detail / detailview.cpp
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 #include <sstream>
18 #include <Elementary.h>
19
20 #include <dpl/wrt-dao-rw/widget_dao.h>
21 #include <dpl/foreach.h>
22 #include <dpl/assert.h>
23 #include <dpl/utils/wrt_global_settings.h>
24 #include <dpl/localization/w3c_file_localization.h>
25
26 #include <ui-gadget-module.h>
27
28 #include "detailview.h"
29 #include "advancedview.h"
30 #include "util.h"
31
32 namespace WebAppDetailSetting {
33 namespace {
34 const int MAX_PATH_LENGTH  = 255;
35 const int ERROR_READ_LINK = -1;
36 // need to move widget_config.h
37 const char* const WRT_LAUNCHER = "wrt-launcher";
38 const char* const WRT_LAUNCHER_WK_MODE_CHANGE_OPTION = "-w";
39 }
40
41 void DetailView::getLocalizedInfo(void)
42 {
43     m_localizedInfo = W3CFileLocalization::getLocalizedInfo(m_appID);
44 }
45
46 Evas_Object *DetailView::loadView(void)
47 {
48     Evas_Object *win;
49
50     resetBase();
51     try {
52         win = static_cast<Evas_Object *>(ug_get_window());
53         Assert(win);
54         m_gl = elm_genlist_add(m_naviframe);
55         elm_object_style_set(m_gl, "dialogue");
56
57         m_dao.Reset(new WrtDB::WidgetDAO(m_appID));
58         getLocalizedInfo();
59
60         if (!m_gl) {
61             evas_object_del(m_naviframe);
62             return NULL;
63         }
64         bindtextdomain("ug-webapp-common-efl", "/usr/ug/res/locale");
65
66         m_advancedView.Reset(
67             new AdvancedView(m_naviframe,
68             m_appID));
69         m_advancedView->loadSecuritySettingsMenu(m_gl);
70         pushToNaviFrame();
71         return win;
72     } catch (const std::bad_alloc &) {
73          return NULL;
74     }
75 }
76
77 void DetailView::onBackBtnClicked(void *data,
78                                 Evas_Object */*obj*/,
79                                 void */*event_info*/)
80 {
81     DetailView* This;
82
83     This= static_cast<DetailView *>(data);
84     Assert(This);
85     ug_destroy_me(This->m_ug);
86 }
87 bool DetailView::pushToNaviFrame(void)
88 {
89     Evas_Object *btn;
90
91     Assert(m_naviframe);
92     btn = elm_button_add(m_naviframe);
93     if (!btn)
94         return false;
95
96     elm_object_style_set(btn, "naviframe/end_btn/default");
97     evas_object_smart_callback_add(btn, "clicked", onBackBtnClicked, this);
98     bindtextdomain("ug-webapp-common-efl", "/usr/ug/res/locale");
99     elm_naviframe_item_push(m_naviframe,
100                             "Allow list",
101                             btn,
102                             NULL,
103                             m_gl,
104                             NULL);
105     return true;
106 }
107
108 DetailView::DetailView(Evas_Object* navi, ui_gadget_h ug, DPL::String appID) :
109     m_naviframe(navi),
110     m_bx(NULL),
111     m_appID(appID),
112     m_licenseInfo(NULL),
113     m_ug(ug)
114 {
115     Assert(navi);
116     m_dao.Reset();
117 }
118
119 DetailView::~DetailView(void)
120 {
121     if (m_licenseInfo)
122         delete m_licenseInfo;
123 }
124 }