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
22 #include <dpl/application.h>
23 #include <dpl/log/log.h>
25 namespace // anonymous
27 static DPL::Application *g_application = NULL;
28 } // 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,
72 m_applicationName(applicationName),
73 m_mainWindowVisible(showMainWindow)
75 if (g_application != NULL)
76 ThrowMsg(Exception::TooManyInstances, "Only single instance of Application allowed at one time!");
81 Application::~Application()
86 int Application::Exec()
88 LogPedantic("Starting application framework...");
90 struct appcore_ops ops;
91 ops.create = app_create;
92 ops.terminate = app_terminate;
93 ops.pause = app_pause;
94 ops.resume = app_resume;
95 ops.reset = app_reset;
98 int result = appcore_efl_main(m_applicationName.c_str(), &m_argc, &m_argv, &ops);
100 LogPedantic("Exited application framework");
105 void Application::OnCreate()
107 LogPedantic("On application create");
110 void Application::OnStart()
112 LogPedantic("On application start");
115 void Application::OnStop()
117 LogPedantic("On application stop");
120 void Application::OnResume()
122 LogPedantic("On application resume");
125 void Application::OnPause()
127 LogPedantic("On application pause");
130 void Application::OnRelaunch()
132 LogPedantic("On application relaunch");
135 void Application::OnReset(bundle *b)
138 LogPedantic("On application reset");
141 void Application::OnTerminate()
143 LogPedantic("On application terminate");
146 void Application::OnLowMemory()
148 LogPedantic("On application low memory");
151 void Application::OnLowBattery()
153 LogPedantic("On application low battery");
156 void Application::OnLanguageChanged()
158 LogPedantic("On application language changed");
161 void Application::Quit()
166 DPL::Atomic ApplicationExt::m_useCount(0);
168 ApplicationExt::ApplicationExt(int argc, char** argv, const std::string& applicationName, bool showMainWindow) :
169 Application(argc, argv, applicationName, showMainWindow)
173 ApplicationExt::~ApplicationExt()
177 int ApplicationExt::Exec()
179 if (0 == m_useCount.CompareAndExchange(0, 1))
181 return Application::Exec();
190 void ApplicationExt::Quit()