#include <vector>
+#include "common/logger.h"
+#include "common/file_utils.h"
+
namespace wrt {
namespace {
pkg_id_ = GetPackageIdByAppId(appid);
if (!pkg_id_.empty()) {
- pkg_root_path_ = GetPackageRootPath(pkg_id_);
- }
-
- if (!pkg_root_path_.empty()) {
- config_xml_path_ = pkg_root_path_ + kPathSeparator +
- app_id_ + kPathSeparator + kConfigXml;
+ application_path_ = GetPackageRootPath(pkg_id_) + kPathSeparator +
+ appid + kPathSeparator;
}
-
- LoadManifestData();
}
ApplicationData::~ApplicationData() {}
}
bool ApplicationData::LoadManifestData() {
- if (config_xml_path_.empty()) {
+ std::string config_xml_path(application_path_ + kConfigXml);
+ if (!utils::Exists(config_xml_path)) {
+ LoggerE("Failed to load manifest data. : No such file '%s'",
+ config_xml_path.c_str());
return false;
}
registry.reset(new parser::ManifestHandlerRegistry(handlers));
parser::ManifestParser manifest_parser(std::move(registry));
- if (!manifest_parser.ParseManifest(config_xml_path_)) {
+ if (!manifest_parser.ParseManifest(config_xml_path)) {
for (auto iter = handlers.begin(); iter != handlers.end(); ++iter) {
delete *iter;
}
+ LoggerE("Failed to load manifest data. : %s",
+ manifest_parser.GetErrorMessage().c_str());
return false;
}
explicit ApplicationData(const std::string& appid);
~ApplicationData();
+ bool LoadManifestData();
+
std::shared_ptr<const wgt::parse::ApplicationIconsInfo>
application_icons_info() const;
std::shared_ptr<const wgt::parse::AppWidgetInfo>
std::shared_ptr<const wgt::parse::WidgetInfo>
widget_info() const;
- std::string config_xml_path() const { return config_xml_path_; }
- const std::string pkg_root_path() const { return pkg_root_path_; }
+ const std::string application_path() const { return application_path_; }
const std::string pkg_id() const { return pkg_id_; }
const std::string app_id() const { return app_id_; }
private:
- bool LoadManifestData();
-
std::shared_ptr<const wgt::parse::ApplicationIconsInfo>
application_icons_info_;
std::shared_ptr<const wgt::parse::AppWidgetInfo>
std::shared_ptr<const wgt::parse::WidgetInfo>
widget_info_;
- std::string config_xml_path_;
- std::string pkg_root_path_;
+ std::string application_path_;
std::string pkg_id_;
std::string app_id_;
};
// TODO(yons.kim): tizen content src
// content src
- const AppWidgetVector app_widgets =
- application_data_->app_widget_info()->app_widgets();
- for (auto iter = app_widgets.begin();
- iter != app_widgets.end(); ++iter) {
- if (iter->id == appid_) {
- default_src = iter->content_src;
- break;
+ auto app_widget_info = application_data_->app_widget_info();
+ if (app_widget_info) {
+ const AppWidgetVector app_widgets = app_widget_info->app_widgets();
+ for (auto iter = app_widgets.begin();
+ iter != app_widgets.end(); ++iter) {
+ if (iter->id == appid_) {
+ default_src = iter->content_src;
+ break;
+ }
}
+ } else {
+ LoggerW("AppWidgetInfo is NULL.");
}
+
if (!default_src.empty()) {
return InsertPrefixPath(default_src);
}
#include "common/command_line.h"
#include "runtime/native_app_window.h"
#include "runtime/app_control.h"
+#include "runtime/application_data.h"
namespace wrt {
std::string appid = CommandLine::ForCurrentProcess()->appid();
// Process First Launch
+ std::unique_ptr<ApplicationData> appdata(new ApplicationData(appid));
+ if (!appdata->LoadManifestData()) {
+ return false;
+ }
+
native_window_ = CreateNativeWindow();
- application_ = new WebApplication(native_window_, appid);
+ application_ = new WebApplication(native_window_, std::move(appdata));
application_->set_terminator([](){ ui_app_exit(); });
// Start DBus Server for Runtime
namespace wrt {
WebApplication::WebApplication(
- NativeWindow* window, const std::string& appid)
- : WebApplication(
- window,
- std::unique_ptr<ApplicationData>(new ApplicationData(appid))) {
-}
-
-WebApplication::WebApplication(
NativeWindow* window, std::unique_ptr<ApplicationData> app_data)
: launched_(false),
debug_mode_(false),
resource_manager_.reset(
new ResourceManager(app_data_.get(), locale_manager_.get()));
resource_manager_->set_base_resource_path(
- app_data_->pkg_root_path() + "/" + appid_ + "/");
+ app_data_->application_path());
Initialize();
}
vibration_stop_callback,
NULL);
- // send widget info to injected bundle
- // TODO(wy80.choi): ewk_send_widget_info should be fixed to receive uuid of
- // application instead of widget_id.
- // Currently, uuid is passed as theme argument temporarily.
- ewk_send_widget_info(ewk_context_, 1, 0.0, uuid_.c_str(), "");
// TODO(sngn.lee): Find the path of certificate file
// ewk_context_certificate_file_set(ewk_context_, .... );
WebView* view = new WebView(window_, ewk_context_);
view->SetEventListener(this);
+ // send widget info to injected bundle
+ // TODO(wy80.choi): ewk_send_widget_info should be fixed to receive uuid of
+ // application instead of widget_id.
+ // Currently, uuid is passed as encoded_bundle argument temporarily.
+ // ewk_send_widget_info(ewk_context_, 1,
+ // elm_config_scale_get(),
+ // elm_theme_get(NULL),
+ // uuid_.c_str());
+
+ // view->LoadUrl("file:///home/owner/apps_rw/33CFo0eFJe/"
+ // "33CFo0eFJe.annex/index.html");
view->LoadUrl(resource_manager_->GetStartURL());
+
view_stack_.push_front(view);
window_->SetContent(view->evas_object());
class WebApplication : public WebView::EventListener {
public:
- explicit WebApplication(NativeWindow* window, const std::string& appid);
- explicit WebApplication(NativeWindow* window,
- std::unique_ptr<ApplicationData> app_data);
+ WebApplication(NativeWindow* window,
+ std::unique_ptr<ApplicationData> app_data);
virtual ~WebApplication();
void AppControl(std::unique_ptr<wrt::AppControl> appcontrol);