fix N_SE-35508 for dialer setting
[platform/framework/native/app-controls.git] / src / call-app-control / PhoneAppControlDllEntry.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file         AppControlDllEntry.cpp
20  * @brief       This is the implementation for the AppControlDllEntry.cpp class.
21  */
22
23 #include <appsvc/appsvc.h>
24
25 #include <FBaseSysLog.h>
26 #include <FBaseColHashMap.h>
27 #include <FAppAppControl.h>
28
29 #include <FBase_StringConverter.h>
30 #include <FApp_AppControlManager.h>
31 #include <FApp_AppMessageImpl.h>
32 #include <FApp_AppArg.h>
33
34
35 using namespace Tizen::App;
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44
45 result _OSP_EXPORT_ StartAppControl(int req, const String&, const String&, const String*, const String*, const IMap*);
46 result _OSP_EXPORT_ TerminateAppControl(int req);
47 static void OnAppControlResult(void*, int, service_result_e, void*);
48
49 static int __req = -1;
50
51 result
52 StartAppControl(int req, const String& aId, const String& operationId, const String* pUri, const String* pMime, const IMap* pMap)
53 {
54         SysLog(NID_APP, "StartAppControl: Entry to Call AppControl");
55
56         result r = E_SUCCESS;
57
58         _AppMessageImpl msg;
59
60         const String* pActualUri = pUri;
61         String tmp;
62
63         msg.AddData(pMap);
64
65         if (pUri == null)
66         {
67                 // if there is not pUri, then search for "url" key.
68                 String data = msg.GetValue(L"tel");
69                 if (!data.IsEmpty())
70                 {
71                         tmp = L"tel:" + data;
72                         pActualUri = &tmp;
73                 }
74
75                 data = msg.GetValue(L"type");
76                 if (!data.IsEmpty())
77                 {
78                         msg.AddData(L"http://tizen.org/appcontrol/data/call/type", data);
79                         msg.RemoveData(L"type");
80                 }
81         }
82
83         const String& package = _AppControlManager::GetAliasAppId(aId);
84         SysLog(NID_APP, "Actual packageId is %ls.", package.GetPointer());
85
86         __req = req;
87         int pid = _AppControlManager::GetInstance()->Launch(msg, package, operationId, pActualUri, pMime, OnAppControlResult, 0);
88         if (pid <= 0)
89         {
90                 r = GetLastResult();
91                 SysLog(NID_APP, "[%s] System error.", GetErrorMessage(r));
92         }
93
94         SysLog(NID_APP, "StartAppControl: Launching Call AppControl succeeded");
95
96         return r;
97 }
98
99 result
100 TerminateAppControl(int req)
101 {
102         return E_SUCCESS;
103 }
104
105 void
106 OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
107 {
108         SysLog(NID_APP, "Received request %d.", requestCode);
109
110         result r = E_SYSTEM;
111         bundle* pBundle = static_cast<bundle*>(b);
112
113         HashMap* pResult = new (std::nothrow) HashMap();
114         SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
115
116         r = pResult->Construct();
117
118         _AppArg::SetArgMap(pBundle, pResult);
119
120         _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
121
122 CATCH:
123         __req = -1;
124 }
125
126 #ifdef __cplusplus
127 }
128 #endif