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 ImageAppControlDllEntry.cpp
20 * @brief This is the implementation for the ImageAppControlDllEntry.cpp class.
23 #include <appsvc/appsvc.h>
25 #include <FBaseSysLog.h>
26 #include <FAppAppControl.h>
27 #include <FBaseColHashMap.h>
29 #include <FBase_StringConverter.h>
30 #include <FApp_AppControlManager.h>
31 #include <FApp_AppMessageImpl.h>
33 #include <FApp_AppArg.h>
36 using namespace Tizen::App;
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Collection;
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 void OnAppControlResult(void*, int, service_result_e, void*);
49 static int __req = -1;
50 static int __processId = -1;
52 static const char __allowedAppControlImageTable[][2][96] =
54 {"osp.appcontrol.IMAGE", "osp.appcontrol.operation.VIEW"},
55 {"osp.appcontrol.provider.image", "osp.appcontrol.operation.view"},
56 {"http://tizen.org/appcontrol/provider/image", "http://tizen.org/appcontrol/operation/view"},
57 {"tizen.imageviewer", "http://tizen.org/appcontrol/operation/view"},
60 static const char __allowedAppControlCropTable[][2][96] =
62 {"tizen.imageviewer", "http://tizen.org/appcontrol/operation/image/crop"},
66 StartAppControl(int req, const String& aId, const String& oId, const String* pUri, const String* pMime, const IMap* pMap)
69 SysLog(NID_APP, "StartAppControl: Entry to Image AppControl");
71 const bool isImage = _AppControlManager::IsAllowedAppControl(__allowedAppControlImageTable, 4, aId, oId);
72 const bool isCrop = _AppControlManager::IsAllowedAppControl(__allowedAppControlCropTable, 1, aId, oId);
73 SysTryReturnResult(NID_APP, isImage || isCrop, E_SYSTEM, "Invalid AppControl entry for (%ls, %ls).", aId.GetPointer(), oId.GetPointer());
78 String path = msg.GetValue(L"path");
79 const String* pActualUri = pUri;
89 const String& package = _AppControlManager::GetAliasAppId(aId);
90 SysLog(NID_APP, "Actual app is %ls.", package.GetPointer());
94 __processId = _AppControlManager::GetInstance()->Launch(msg, package, oId, pActualUri, pMime, NULL, 0);
99 __processId = _AppControlManager::GetInstance()->Launch(msg, package, oId, pActualUri, pMime, OnAppControlResult, 0);
102 SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Image AppControl is failed.");
105 SysLog(NID_APP, "StartAppControl: Launching ImageViewer AppControl succeeded");
111 TerminateAppControl(int req)
113 if (__processId >= 0)
115 _Aul::TerminateApplicationByPid(__processId);
121 OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
123 SysLog(NID_APP, "@@@@@@ OnAppControlResult");
126 bundle* pBundle = static_cast<bundle*>(b);
128 HashMap* pResult = new (std::nothrow) HashMap();
129 SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
131 r = pResult->Construct();
133 _AppArg::SetArgMap(pBundle, pResult);
135 _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);