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.
23 #include <appsvc/appsvc.h>
25 #include <FBaseSysLog.h>
26 #include <FAppAppControl.h>
27 #include <FBaseColHashMap.h>
29 #include <FApp_AppControlManager.h>
30 #include <FApp_AppMessageImpl.h>
33 using namespace Tizen::App;
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
42 result _OSP_EXPORT_ StartAppControl(int req, const String&, const String&, const String*, const String*, const IMap*);
43 result _OSP_EXPORT_ TerminateAppControl(int req);
44 void OnAppControlResult(void*, int, service_result_e, void*);
46 static int __req = -1;
47 static int __processId = -1;
51 StartAppControl(int req, const String& aId, const String& oId, const String* pUri, const String* pMime, const IMap* pMap)
54 SysLog(NID_APP, "StartAppControl: Entry to Camera AppControl");
56 if (aId == "osp.appcontrol.CAMERA"
57 || aId == L"osp.appcontrol.provider.camera"
58 || aId == L"tizen.camera"
59 || aId == L"http://tizen.org/appcontrol/provider/camera")
61 SysLog(NID_APP, "oId : %ls", oId.GetPointer());
65 char buffer[10] = {0, };
70 const String& str = msg.GetValue(L"type");
71 if (str == L"camcorder")
73 strncpy(buffer, "video/3gp", 9);
77 strncpy(buffer, "image/jpg", 9);
81 __processId = _AppControlManager::GetInstance()->Launch(msg, "camera-efl", APPSVC_OPERATION_CREATE_CONTENT, buffer, NULL, OnAppControlResult, 0);
83 SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Camera AppControl is failed.");
86 SysLog(NID_APP, "StartAppControl: Launching Camera AppControl succeeded");
93 TerminateAppControl(int req)
97 _Aul::TerminateApplicationByPid(__processId);
103 OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
106 bundle* pBundle = static_cast<bundle*>(b);
108 HashMap* pResult = new (std::nothrow) HashMap();
109 SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
111 r = pResult->Construct();
115 case SERVICE_RESULT_SUCCEEDED:
117 const char* pFile = appsvc_get_data(pBundle, SERVICE_DATA_SELECTED);
120 pResult->Add(new (std::nothrow) String(L"path"), new (std::nothrow) String(pFile));
124 case SERVICE_RESULT_FAILED:
126 case SERVICE_RESULT_CANCELED:
132 _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);