Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / platform / API / Application / EventLaunchService.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 #ifndef TIZENAPIS_API_EVENT_LAUNCH_SERVICE_H_
18 #define TIZENAPIS_API_EVENT_LAUNCH_SERVICE_H_
19
20
21
22 #include <Commons/IEvent.h>
23 #include <dpl/shared_ptr.h>
24 #include "ApplicationService.h"
25 //#include "ApplicationServiceReply.h"
26 #include "ApplicationServiceData.h"
27 #include <dpl/log/log.h>
28
29 namespace TizenApis {
30 namespace Api {
31 namespace Application {
32
33 class EventLaunchService: public WrtDeviceApis::Commons::IEvent<EventLaunchService> {
34
35 private:
36         ApplicationServicePtr m_service;
37         int callbackType;
38         int m_eventType;
39
40 public:
41 /* CALLBACK TYPE */
42         static const int APPLICATION_SERVICE_UNKNOWN = 0;
43         static const int APPLICATION_SERVICE_CALLBACK = 1;
44         static const int APPLICATION_SERVICE_REPLY_SUCCESS_CALLBACK = 2;
45         static const int APPLICATION_SERVICE_REPLY_FAIL_CALLBACK = 3;
46 /* EVENT TYPE */        
47         static const int APPLICATION_SERVICE_LAUNCH = 4;
48         static const int APPLICATION_SERVICE_GET_REQUEST = 5;
49  public:        
50  
51         void addServiceData(std::string &key, std::vector<std::string> &value) {
52                 
53                 ApplicationServiceDataPtr serviceData(new ApplicationServiceData());
54                 serviceData->setKey(key);
55                 serviceData->setValue(value);
56
57                 m_service->addServiceData(serviceData);
58 #if 0
59                 
60                 LogError("===[WS] create servicedata array");
61                 std::vector<ApplicationServiceDataPtr> resultValue;
62                 resultValue.push_back(serviceData);
63                 LogError("===[WS] set service data array to event.");
64                 LogError("===[WS] m_service:"<<m_service);
65                 m_service->setServiceDataArray(resultValue);
66
67                 if( !m_reply )
68                 {
69                         ApplicationServiceReplyPtr reply(new ApplicationServiceReply());
70                         
71                         //ApplicationServiceDataPtr extraDataArray(new ApplicationServiceData());
72                         reply->setServiceDataArray(extraData);
73                         setService(reply);
74                 }
75                 //m_reply->addExtraData(extraData);
76 #endif          
77         }
78  
79         void setService(ApplicationServicePtr &appservice){
80                 m_service = appservice;
81         }
82
83         ApplicationServicePtr getService() const{
84                 return m_service;
85         }
86
87         void setCallbackType(int callbacktype){
88                 callbackType = callbacktype;
89         }
90
91         int getCallbackType() const{
92                 return callbackType;
93         }
94
95         void setEventType(int type){
96                 m_eventType = type;
97         }
98
99         int getEventType(){
100                 return m_eventType;
101         }       
102         
103         EventLaunchService() 
104         {
105         }               
106 };
107
108 typedef DPL::SharedPtr<EventLaunchService> EventLaunchServicePtr;
109
110 } // Application
111 } // Api
112 } // TizenApis
113
114 #endif