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 BluetoothAppControlDllEntry.cpp
20 * @brief This is the implementation for the BluetoothAppControlDllEntry.cpp class.
23 #include <appsvc/appsvc.h>
25 #include <FBaseSysLog.h>
26 #include <FAppAppControl.h>
28 #include <FBase_StringConverter.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;
43 result _OSP_EXPORT_ StartAppControl(int req, const String&, const String&, const String*, const String*, const IMap*);
44 result _OSP_EXPORT_ TerminateAppControl(int req);
45 static int __processId = -1;
47 static const wchar_t __allowedAppControlMessageTable[][2][64] =
49 {L"osp.appcontrol.MESSAGE", L"osp.appcontrol.operation.EDIT"},
50 {L"osp.appcontrol.provider.message", L"osp.appcontrol.operation.compose"},
51 {L"http://tizen.org/appcontrol/provider/message", L"http://tizen.org/appcontrol/operation/compose"},
52 {L"tizen.messages", L"http://tizen.org/appcontrol/operation/compose"},
55 static const wchar_t __allowedAppControlEmailTable[][2][64] =
57 {L"osp.appcontrol.EMAIL", L"osp.appcontrol.operation.EDIT"},
58 {L"osp.appcontrol.provider.email", L"osp.appcontrol.operation.compose"},
59 {L"http://tizen.org/appcontrol/provider/email", L"http://tizen.org/appcontrol/operation/compose"},
60 {L"tizen.email", L"http://tizen.org/appcontrol/operation/compose"},
65 StartAppControl(int req, const String& aId, const String& oId, const String* pUri, const String* pMime, const IMap* pMap)
67 SysLog(NID_APP, "StartAppControl: Entry to Message AppControl");
71 SysLog(NID_APP, "aId : %ls, oId : %ls", aId.GetPointer(), oId.GetPointer());
73 const bool isMessage = _AppControlManager::IsAllowedAppControl(__allowedAppControlMessageTable, 4, aId, oId);
74 const bool isEmail = _AppControlManager::IsAllowedAppControl(__allowedAppControlEmailTable, 4, aId, oId);
76 SysTryReturnResult(NID_APP, isMessage || isEmail, E_SYSTEM, "Invalid AppControl entry for (%ls, %ls).", aId.GetPointer(), oId.GetPointer());
80 SysLog(NID_APP, "Message AppControl starts..");
86 String tmp = msg.GetValue(L"to");
90 String tmpCc = msg.GetValue(L"cc");
93 tmp.Append(L';' + tmpCc);
97 String tmpBcc = msg.GetValue(L"bcc");
98 if (!tmpBcc.IsEmpty())
100 tmp.Append(L';' + tmpBcc);
103 tmp.Replace(L';', L',');
104 msg.AddData(SERVICE_DATA_TO, tmp);
108 tmp = msg.GetValue(L"subject");
111 SysLog(NID_APP, "subject: [%ls]", tmp.GetPointer());
112 msg.AddData(SERVICE_DATA_SUBJECT, tmp);
116 tmp = msg.GetValue(L"text");
119 SysLog(NID_APP, "text: [%ls]", tmp.GetPointer());
120 msg.AddData(SERVICE_DATA_TEXT, tmp);
124 String tmpVcard = msg.GetValue(L"attachVcard");
127 String tmpVcal = msg.GetValue(L"attachVcalendar");
130 String tmpVideo = msg.GetValue(L"attachVideo");
131 if (!tmpVideo.IsEmpty())
134 String tmpTotal = tmpVcard + delim + tmpVcal + delim + tmpVideo;
135 SysLog(NID_APP, "total: [%ls]", tmpTotal.GetPointer());
136 msg.AddData(L"ATTACHFILE", tmpTotal);
141 String tmpImage = msg.GetValue(L"attachImage");
144 String tmpAudio = msg.GetValue(L"attachAudio");
147 String tmpTotal = tmpVcard + delim + tmpVcal + delim + tmpImage + delim + tmpAudio;
148 SysLog(NID_APP, "total: [%ls]", tmpTotal.GetPointer());
149 msg.AddData(L"ATTACHFILE", tmpTotal);
152 __processId = _AppControlManager::GetInstance()->Launch(msg, "msg-composer-efl", APPSVC_OPERATION_SEND, NULL, NULL, NULL, 0);
154 SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Email AppControl is failed.");
155 SysLog(NID_APP, "StartAppControl: Launching Message AppControl succeeded.");
160 SysLog(NID_APP, "Email AppControl starts..");
166 String attach = msg.GetValue(L"attachments");
167 if (!attach.IsEmpty())
169 pUri = _StringConverter::CopyToCharArrayN(attach);
172 String tmp = msg.GetValue(L"to");
175 msg.AddData(SERVICE_DATA_TO, tmp);
178 tmp = msg.GetValue(L"cc");
181 msg.AddData(SERVICE_DATA_CC, tmp);
184 tmp = msg.GetValue(L"bcc");
187 msg.AddData(SERVICE_DATA_BCC, tmp);
190 tmp = msg.GetValue(L"subject");
193 msg.AddData(SERVICE_DATA_SUBJECT, tmp);
196 tmp = msg.GetValue(L"text");
199 msg.AddData(SERVICE_DATA_TEXT, tmp);
202 __processId = _AppControlManager::GetInstance()->Launch(msg, "email-composer-efl", APPSVC_OPERATION_SEND, NULL, pUri, NULL, 0);
206 SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Email AppControl is failed.");
207 SysLog(NID_APP, "StartAppControl: Launching Email AppControl succeeded.");
214 TerminateAppControl(int req)
216 if (__processId >= 0)
218 _Aul::TerminateApplicationByPid(__processId);