2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file application.cpp
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief This file is the implementation file of MVC application support
23 #include <dpl/application.h>
24 #include <dpl/log/log.h>
26 namespace // anonymous
28 static DPL::Application *g_application = NULL;
29 } // namespace anonymous
32 int Application::app_create(void *data)
34 Application *This = static_cast<Application *>(data);
39 int Application::app_terminate(void *data)
41 Application *This = static_cast<Application *>(data);
46 int Application::app_pause(void *data)
48 Application *This = static_cast<Application *>(data);
53 int Application::app_resume(void *data)
55 Application *This = static_cast<Application *>(data);
60 int Application::app_reset(bundle *b, void *data)
62 Application *This = static_cast<Application *>(data);
67 Application::Application(int argc, char** argv,
68 const std::string& applicationName,
69 bool showMainWindow) :
72 m_applicationName(applicationName),
73 m_mainWindowVisible(showMainWindow)
75 if (g_application != NULL) {
76 ThrowMsg(Exception::TooManyInstances,
77 "Only single instance of Application allowed at one time!");
83 Application::~Application()
88 int Application::Exec()
90 LogPedantic("Starting application framework...");
92 struct appcore_ops ops;
93 ops.create = app_create;
94 ops.terminate = app_terminate;
95 ops.pause = app_pause;
96 ops.resume = app_resume;
97 ops.reset = app_reset;
100 int result = appcore_efl_main(
101 m_applicationName.c_str(), &m_argc, &m_argv, &ops);
103 LogPedantic("Exited application framework");
108 void Application::OnCreate()
110 LogPedantic("On application create");
113 void Application::OnStart()
115 LogPedantic("On application start");
118 void Application::OnStop()
120 LogPedantic("On application stop");
123 void Application::OnResume()
125 LogPedantic("On application resume");
128 void Application::OnPause()
130 LogPedantic("On application pause");
133 void Application::OnRelaunch()
135 LogPedantic("On application relaunch");
138 void Application::OnReset(bundle *b)
141 LogPedantic("On application reset");
144 void Application::OnTerminate()
146 LogPedantic("On application terminate");
149 void Application::OnLowMemory()
151 LogPedantic("On application low memory");
154 void Application::OnLowBattery()
156 LogPedantic("On application low battery");
159 void Application::OnLanguageChanged()
161 LogPedantic("On application language changed");
164 void Application::Quit()
169 DPL::Atomic ApplicationExt::m_useCount(0);
171 ApplicationExt::ApplicationExt(int argc,
173 const std::string& applicationName,
174 bool showMainWindow) :
175 Application(argc, argv, applicationName, showMainWindow)
178 ApplicationExt::~ApplicationExt()
181 int ApplicationExt::Exec()
183 if (0 == m_useCount.CompareAndExchange(0, 1)) {
184 return Application::Exec();
191 void ApplicationExt::Quit()