Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Application / 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
18 #ifndef TIZENAPIS_PLATFORM_APPLICATION_H_
19 #define TIZENAPIS_PLATFORM_APPLICATION_H_
20
21 #include <map>
22 #include <API/Application/IApplication.h>
23 #include <API/Application/ApplicationFactory.h>
24 #include <API/Application/EventListInstalledApplications.h>
25 #include <API/Application/EventGetApplication.h>
26 #include <API/Application/EventManageApplication.h>
27 #include <API/Application/EventInstalledApplicationChanged.h>
28 #include <API/Application/EventLaunchService.h>
29
30 #include <app_manager.h>
31 #include <app_service.h> 
32 using namespace TizenApis::Api::Application;
33
34 namespace TizenApis {
35 namespace Platform {
36 namespace Application {
37
38 class Application: public IApplication {
39     friend class ApplicationFactory;
40
41 public:
42         Application();
43         virtual ~Application();
44         virtual void launch(const EventManageApplicationPtr& event);
45         virtual void kill(const EventManageApplicationPtr& event);
46         virtual void exit();
47         virtual void hide(const EventManageApplicationPtr& event);      
48         virtual void listApplications(const EventListInstalledApplicationsPtr& event);
49         virtual void getApplication(const EventGetApplicationPtr& event);
50         virtual long addApplicationInformationEventListener(const EventInstalledApplicationChangedEmitterPtr& emitter);
51         virtual void removeApplicationInformationEventListener(const EventInstalledApplicationChangedEmitter::IdType id);
52         virtual void launchService(const EventLaunchServicePtr& event);
53         virtual void getApplicationService(const EventLaunchServicePtr& event);
54         void launchServiceManualAnswer(service_h request, service_h reply, service_result_e result);            
55         void InstalledApplicationChanged(app_manger_event_type_e event_type,const char *package);
56
57 protected:
58         virtual void OnRequestReceived(const EventListInstalledApplicationsPtr& event);
59         virtual void OnRequestReceived(const EventManageApplicationPtr& event);
60         virtual void OnRequestReceived(const EventGetApplicationPtr& event);
61         virtual void OnRequestReceived(const EventLaunchServicePtr& event);     
62  
63 private:
64         void initialize();
65
66         DPL::Mutex m_initializationMutex;
67         bool m_initialized;
68         Api::Application::EventLaunchServicePtr m_eventLaunchServicePtr;        
69         EventInstalledApplicationChangedEmitterPtr m_installedApplicationsEmitterPtr;
70 };
71
72 }
73 }
74 }
75
76 #endif