2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file CameraAppControlDllEntry.cpp
20 * @brief This is the implementation for the CameraAppControlDllEntry.cpp class.
24 #include <appsvc/appsvc.h>
26 #include <FBaseSysLog.h>
27 #include <FAppAppControl.h>
28 #include <FBaseColHashMap.h>
30 #include <FApp_AppControlManager.h>
31 #include <FApp_AppMessageImpl.h>
33 #include <FApp_AppArg.h>
34 #include <FApp_AppMessageImpl.h>
37 using namespace Tizen::App;
38 using namespace Tizen::Base;
39 using namespace Tizen::Base::Collection;
46 result _OSP_EXPORT_ StartAppControl(int req, const String&, const String&, const String*, const String*, const IMap*);
47 result _OSP_EXPORT_ TerminateAppControl(int req);
48 void OnAppControlResult(void*, int, service_result_e, void*);
50 static int __req = -1;
51 static int __processId = -1;
55 StartAppControl(int req, const String& aId, const String& oId, const String* pUri, const String* pMime, const IMap* pMap)
58 SysLog(NID_APP, "StartAppControl: Entry to Camera AppControl");
60 if (aId == "osp.appcontrol.CAMERA"
61 || aId == "osp.appcontrol.provider.camera"
62 || aId == "tizen.camera")
64 SysLog(NID_APP, "oId : %ls", oId.GetPointer());
68 const String* pActualMime = pMime;
77 const String& str = msg.GetValue(L"type");
78 if (str == L"camcorder")
87 msg.RemoveData(L"type");
92 const String& package = _AppControlManager::GetAliasAppId(aId);
93 SysLog(NID_APP, "Actual packageId is %ls.", package.GetPointer());
96 __processId = _AppControlManager::GetInstance()->Launch(msg, package, String(APPSVC_OPERATION_CREATE_CONTENT), pUri, pActualMime, OnAppControlResult, 0);
98 SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Camera AppControl is failed.");
101 SysLog(NID_APP, "StartAppControl: Launching Camera AppControl succeeded");
108 TerminateAppControl(int req)
110 if (__processId >= 0)
112 _Aul::TerminateApplicationByPid(__processId);
118 OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
120 SysLog(NID_APP, "Camera AppControl result");
123 int type = BUNDLE_TYPE_NONE;
124 bundle* pBundle = static_cast<bundle*>(b);
126 HashMap* pResult = new (std::nothrow) HashMap();
127 SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
129 r = pResult->Construct();
131 _AppArg::SetArgMap(pBundle, pResult);
133 type = bundle_get_type(pBundle, SERVICE_DATA_SELECTED);
136 case BUNDLE_TYPE_STR:
138 const char* pFile = appsvc_get_data(pBundle, SERVICE_DATA_SELECTED);
141 pResult->Add(new (std::nothrow) String(L"path"), new (std::nothrow) String(pFile));
145 case BUNDLE_TYPE_STR_ARRAY:
147 ArrayList* pArray = _AppMessageImpl::GetValueArrayN(pBundle, SERVICE_DATA_SELECTED);
148 pResult->Add(new (std::nothrow) String(L"path"), pArray);
151 case BUNDLE_TYPE_NONE:
156 _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);