Update User Agent String
[framework/web/wrt-commons.git] / modules / core / include / dpl / application.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
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  * @file        application.h
18  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
19  * @version     1.0
20  * @brief       This file is the implementation file of MVC application support
21  */
22 #ifndef DPL_APPLICATION_H
23 #define DPL_APPLICATION_H
24
25 #include <dpl/exception.h>
26 #include <dpl/framework_efl.h>
27 #include <dpl/framework_appcore.h>
28 #include <dpl/atomic.h>
29 #include <string>
30
31 namespace DPL
32 {
33 class Application
34 {
35 public:
36     class Exception
37     {
38     public:
39         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
40         DECLARE_EXCEPTION_TYPE(Base, TooManyInstances)
41         DECLARE_EXCEPTION_TYPE(Base, FrameworkError)
42     };
43
44 private:
45     static int app_create(void *data);
46     static int app_terminate(void *data);
47     static int app_pause(void *data);
48     static int app_resume(void *data);
49     static int app_reset(bundle *b, void *data);
50
51 protected:
52     int m_argc;
53     char **m_argv;
54     std::string m_applicationName;
55
56     bool m_mainWindowVisible;
57
58     virtual void OnCreate();
59     virtual void OnStart();
60     virtual void OnStop();
61     virtual void OnResume();
62     virtual void OnPause();
63     virtual void OnRelaunch();
64     virtual void OnReset(bundle *b);
65     virtual void OnTerminate();
66     virtual void OnLowMemory();
67     virtual void OnLowBattery();
68     virtual void OnLanguageChanged();
69
70 public:
71     Application(int argc, char **argv, const std::string &applicationName, bool showMainWindow = true);
72     virtual ~Application();
73
74     /**
75      * @brief Execute application and start message processing
76      */
77     virtual int Exec();
78     
79     /*
80      * @brief Sends quit message to application message loop
81      */
82     virtual void Quit();
83 };
84
85 class ApplicationExt : public Application
86 {
87 public:
88     ApplicationExt(int argc, char **argv, const std::string &applicationName, bool showMainWindow = true);
89     virtual ~ApplicationExt();
90
91     /**
92      * @brief Execute application and start message processing
93      */
94     virtual int Exec();
95
96     /*
97      * @brief Sends quit message to application message loop
98      */
99     virtual void Quit();
100 private:
101     static DPL::Atomic m_useCount;
102 };
103
104 } // namespace DPL
105
106 #endif // DPL_APPLICATION_H