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
33 int Application::app_create(void *data)
35 Application *This=static_cast<Application *>(data);
40 int Application::app_terminate(void *data)
42 Application *This=static_cast<Application *>(data);
47 int Application::app_pause(void *data)
49 Application *This=static_cast<Application *>(data);
54 int Application::app_resume(void *data)
56 Application *This=static_cast<Application *>(data);
61 int Application::app_reset(bundle *b, void *data)
63 Application *This=static_cast<Application *>(data);
68 Application::Application(int argc, char** argv,
69 const std::string& applicationName,
73 m_applicationName(applicationName),
74 m_mainWindowVisible(showMainWindow)
76 if (g_application != NULL)
77 ThrowMsg(Exception::TooManyInstances, "Only single instance of Application allowed at one time!");
82 Application::~Application()
87 int Application::Exec()
89 LogPedantic("Starting application framework...");
91 struct appcore_ops ops;
92 ops.create = app_create;
93 ops.terminate = app_terminate;
94 ops.pause = app_pause;
95 ops.resume = app_resume;
96 ops.reset = app_reset;
99 int result = appcore_efl_main(m_applicationName.c_str(), &m_argc, &m_argv, &ops);
101 LogPedantic("Exited application framework");
106 void Application::OnCreate()
108 LogPedantic("On application create");
111 void Application::OnStart()
113 LogPedantic("On application start");
116 void Application::OnStop()
118 LogPedantic("On application stop");
121 void Application::OnResume()
123 LogPedantic("On application resume");
126 void Application::OnPause()
128 LogPedantic("On application pause");
131 void Application::OnRelaunch()
133 LogPedantic("On application relaunch");
136 void Application::OnReset(bundle *b)
139 LogPedantic("On application reset");
142 void Application::OnTerminate()
144 LogPedantic("On application terminate");
147 void Application::OnLowMemory()
149 LogPedantic("On application low memory");
152 void Application::OnLowBattery()
154 LogPedantic("On application low battery");
157 void Application::OnLanguageChanged()
159 LogPedantic("On application language changed");
162 void Application::Quit()
167 DPL::Atomic ApplicationExt::m_useCount(0);
169 ApplicationExt::ApplicationExt(int argc, char** argv, const std::string& applicationName, bool showMainWindow) :
170 Application(argc, argv, applicationName, showMainWindow)
174 ApplicationExt::~ApplicationExt()
178 int ApplicationExt::Exec()
180 if (0 == m_useCount.CompareAndExchange(0, 1))
182 return Application::Exec();
191 void ApplicationExt::Quit()