2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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.
18 * @file CallAppControlRequestMgr.cpp
19 * @brief Manages AppControl Request to other apps.
22 #include "CallAppControlRequestMgr.h"
23 #include "CallTypes.h"
25 using namespace Tizen::App;
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Collection;
29 CallAppControlRequestMgr* CallAppControlRequestMgr::__pInstance = null;
31 CallAppControlRequestMgr::CallAppControlRequestMgr(void)
33 __pOpenedAppControl = null;
36 CallAppControlRequestMgr::~CallAppControlRequestMgr(void)
38 if (__pOpenedAppControl != null)
40 delete __pOpenedAppControl;
41 __pOpenedAppControl = null;
46 CallAppControlRequestMgr::CreateInstance(void)
48 __pInstance = new (std::nothrow) CallAppControlRequestMgr();
49 result r = __pInstance->Construct();
57 std::atexit(DestroyInstance);
60 CallAppControlRequestMgr*
61 CallAppControlRequestMgr::GetInstance(void)
63 if (__pInstance == null)
71 CallAppControlRequestMgr::DestroyInstance(void)
73 if (__pInstance != null)
81 CallAppControlRequestMgr::Construct(void)
87 CallAppControlRequestMgr::IsAppControlRunning(void)
90 return (__pOpenedAppControl != null);
94 CallAppControlRequestMgr::AbortAppControlRequest(void)
97 if (__pOpenedAppControl != null)
99 result r = __pOpenedAppControl->Stop();
100 AppLog("Abort failed with r=%d", r);
101 delete __pOpenedAppControl;
102 __pOpenedAppControl = null;
108 CallAppControlRequestMgr::AppControlRequestCompleted(void)
111 if (__pOpenedAppControl != null)
113 delete __pOpenedAppControl;
114 __pOpenedAppControl = null;
119 CallAppControlRequestMgr::LaunchComposeMessageAppControl(String& contactNumber, IAppControlResponseListener* pListener)
121 if (__pOpenedAppControl != null)
123 //An AppControl is already running.
124 String provider = __pOpenedAppControl->GetAppControlProviderId();
125 String operation = __pOpenedAppControl->GetOperationId();
126 AppLog( "Error:- AppControl is already running for provider id = %ls, operation id = %ls",
127 provider.GetPointer(), operation.GetPointer());
131 result r = E_FAILURE;
134 extraData.Construct();
135 extraData.Add(new (std::nothrow) String(MESSAGE_TYPE), new (std::nothrow) String(MESSAGE_SMS_TYPE));
136 extraData.Add(new (std::nothrow) String(MESSAGE_TO), new (std::nothrow) String(contactNumber));
138 __pOpenedAppControl = AppManager::FindAppControlN(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE);
139 if (__pOpenedAppControl != null)
141 r = __pOpenedAppControl->Start(null, null, &extraData, pListener);
143 extraData.RemoveAll(true);
147 //AppControl request failed, delete AppControl.
148 delete __pOpenedAppControl;
149 __pOpenedAppControl = null;
154 //AppControl request was successful.
160 CallAppControlRequestMgr::LaunchViewContactAppControl(String& contactId, IAppControlResponseListener* pListener)
162 AppLogDebug("ENTER");
163 if (__pOpenedAppControl != null)
165 //An AppControl is already running.
166 String provider = __pOpenedAppControl->GetAppControlProviderId();
167 String operation = __pOpenedAppControl->GetOperationId();
168 AppLog( "Error:- AppControl is already running for provider id = %ls, operation id = %ls",
169 provider.GetPointer(), operation.GetPointer());
173 result r = E_FAILURE;
176 extraData.Construct();
177 extraData.Add(new (std::nothrow) String(CONTACTS_VIEW_TYPE), new (std::nothrow) String(CONTACTS_VIEW_TYPE_CONTACT));
178 extraData.Add(new (std::nothrow) String(CONTACTS_VIEW_TYPE_CONTACT), new (std::nothrow) String(CONTACTS_VIEW_TYPE_CONTACT));
179 extraData.Add(new (std::nothrow) String(CONTACT_KEY_ITEM_ID), new (std::nothrow) String(contactId));
180 extraData.Add(new (std::nothrow) String(CONTACTS_ID_KEY), new (std::nothrow) String(contactId));
181 extraData.Add(new (std::nothrow) String(CONTACT_KEY_ITEM_TYPE), new (std::nothrow) String(ITEM_TYPE_PERSON));
183 __pOpenedAppControl = AppManager::FindAppControlN(PROVIDER_ID_CONTACTS, OPERATION_ID_VIEW);
184 if (__pOpenedAppControl != null)
186 r = __pOpenedAppControl->Start(null, null, &extraData, pListener);
188 extraData.RemoveAll(true);
192 //AppControl request failed, delete AppControl.
193 delete __pOpenedAppControl;
194 __pOpenedAppControl = null;
199 //AppControl request was successful.
205 CallAppControlRequestMgr::LaunchAddContactAppControl(String& contactNumber, IAppControlResponseListener* pListener)
207 AppLogDebug("ENTER");
208 if (__pOpenedAppControl != null)
210 //An AppControl is already running.
211 String provider = __pOpenedAppControl->GetAppControlProviderId();
212 String operation = __pOpenedAppControl->GetOperationId();
213 AppLog( "Error:- AppControl is already running for provider id = %ls, operation id = %ls",
214 provider.GetPointer(), operation.GetPointer());
218 result r = E_FAILURE;
221 extraData.Construct();
222 extraData.Add(new (std::nothrow) String(INPUT_TYPE_PHONE), new (std::nothrow) String(contactNumber));
223 extraData.Add(new (std::nothrow) String(CONTACT_KEY_ITEM_TYPE), new (std::nothrow) String(ITEM_TYPE_CONTACT));
225 __pOpenedAppControl = AppManager::FindAppControlN(PROVIDER_ID_CONTACTS, OPERATION_ID_ADD);
226 if (__pOpenedAppControl != null)
228 r = __pOpenedAppControl->Start(null, null, &extraData, pListener);
230 extraData.RemoveAll(true);
234 //AppControl request failed, delete AppControl.
235 delete __pOpenedAppControl;
236 __pOpenedAppControl = null;
241 //AppControl request was successful.
247 CallAppControlRequestMgr::LaunchDialerAppControl(IAppControlResponseListener* pListener)
249 AppLogDebug("ENTER");
250 if (__pOpenedAppControl != null)
252 //An AppControl is already running.
253 String provider = __pOpenedAppControl->GetAppControlProviderId();
254 String operation = __pOpenedAppControl->GetOperationId();
255 AppLog( "Error:- AppControl is already running for provider id = %ls, operation id = %ls",
256 provider.GetPointer(), operation.GetPointer());
260 result r = E_FAILURE;
262 extraData.Construct();
263 extraData.Add(new (std::nothrow) String(PARAM_PHONE_NUMBER), new (std::nothrow) String(L""));
265 __pOpenedAppControl = AppManager::FindAppControlN(PROVIDER_ID_PHONE, OPERATION_ID_DIAL);
266 if (__pOpenedAppControl != null)
268 r = __pOpenedAppControl->Start(null, null, &extraData, pListener);
270 extraData.RemoveAll(true);
274 //AppControl request failed, delete AppControl.
275 delete __pOpenedAppControl;
276 __pOpenedAppControl = null;
281 //AppControl request was successful.