[Release] wrt-setting_0.0.50
[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 #include <efl_assist.h>
20
21 #include <dpl/wrt-dao-rw/widget_dao.h>
22 #include <dpl/foreach.h>
23 #include <dpl/assert.h>
24 #include <dpl/utils/wrt_global_settings.h>
25 #include <dpl/localization/w3c_file_localization.h>
26
27 #include <ui-gadget-module.h>
28
29 #include "detailview.h"
30 #include "advancedview.h"
31 #include "util.h"
32
33 namespace WebAppDetailSetting {
34 namespace {
35 const int MAX_PATH_LENGTH  = 255;
36 const int ERROR_READ_LINK = -1;
37 // need to move widget_config.h
38 const char* const WRT_LAUNCHER = "wrt-launcher";
39 const char* const WRT_LAUNCHER_WK_MODE_CHANGE_OPTION = "-w";
40 }
41
42 void DetailView::getLocalizedInfo(void)
43 {
44     m_localizedInfo = W3CFileLocalization::getLocalizedInfo(m_appID);
45 }
46
47 Evas_Object *DetailView::loadView(void)
48 {
49     Evas_Object *win;
50
51     resetBase();
52     try {
53         win = static_cast<Evas_Object *>(ug_get_window());
54         Assert(win);
55         ea_object_event_callback_add(m_naviframe,
56             EA_CALLBACK_BACK,
57             onBackBtnClicked,
58             this);
59         m_dao.Reset(new WrtDB::WidgetDAO(m_appID));
60         getLocalizedInfo();
61
62         bindtextdomain("ug-webapp-common-efl", "/usr/ug/res/locale");
63
64         m_advancedView.Reset(
65             new AdvancedView(m_naviframe,
66             m_appID));
67         m_advancedView->loadView();
68         return win;
69     } catch (const std::bad_alloc &) {
70          return NULL;
71     }
72 }
73
74 void DetailView::onBackBtnClicked(void *data,
75                                 Evas_Object */*obj*/,
76                                 void */*event_info*/)
77 {
78     DetailView* This;
79
80     This= static_cast<DetailView *>(data);
81     Assert(This);
82     ug_destroy_me(This->m_ug);
83 }
84
85 DetailView::DetailView(Evas_Object* navi, ui_gadget_h ug, DPL::String appID) :
86     m_naviframe(navi),
87     m_bx(NULL),
88     m_appID(appID),
89     m_licenseInfo(NULL),
90     m_ug(ug)
91 {
92     Assert(navi);
93     m_dao.Reset();
94 }
95
96 DetailView::~DetailView(void)
97 {
98     if (m_licenseInfo)
99         delete m_licenseInfo;
100 }
101 }