#include <FApp_AppControlManager.h>
#include <FApp_AppMessageImpl.h>
#include <FApp_Aul.h>
+#include <FApp_AppArg.h>
using namespace Tizen::App;
extern "C" {
#endif
+static const wchar_t CALENDAR_ITEM_TYPE[] = L"http://tizen.org/appcontrol/data/social/item_type";
+static const wchar_t CALENDAR_RESULT_TYPE[] = L"http://tizen.org/appcontrol/data/social/result_type";
+static const wchar_t CALENDAR_ITEM_ID[] = L"http://tizen.org/appcontrol/data/social/item_id";
+static const wchar_t CALENDAR_SELECTION_MODE[] = L"http://tizen.org/appcontrol/data/selection_mode";
+
result _OSP_EXPORT_ StartAppControl(int req, const String&, const String&, const String*, const String*, const IMap*);
result _OSP_EXPORT_ TerminateAppControl(int req);
void OnAppControlResult(void*, int, service_result_e, void*);
+void OnAppControlResultTizen(void*, int, service_result_e, void*);
static int __req = -1;
static int __processId = -1;
-static const wchar_t __allowedAppControlPickTable[][2][64] =
+static const char __allowedAppControlPickTable[][2][96] =
+{
+ {"osp.appcontrol.CALENDAR", "osp.appcontrol.operation.PICK"},
+ {"osp.appcontrol.provider.calendar", "osp.appcontrol.operation.pick"},
+ {"tizen.calendar", "http://tizen.org/appcontrol/operation/pick"},
+ {"tizen.calendar", "http://tizen.org/appcontrol/operation/social/pick"},
+ {"tizen.todo", "http://tizen.org/appcontrol/operation/social/pick"},
+};
+
+static const char __allowedAppControlViewTable[][2][96] =
{
- {L"osp.appcontrol.CALENDAR", L"osp.appcontrol.operation.PICK"},
- {L"osp.appcontrol.provider.calendar", L"osp.appcontrol.operation.pick"},
- {L"http://tizen.org/appcontrol/provider/calendar", L"http://tizen.org/appcontrol/operation/pick"},
- {L"tizen.calendar", L"http://tizen.org/appcontrol/operation/pick"},
+ {"osp.appcontrol.CALENDAR", "osp.appcontrol.operation.VIEW"},
+ {"osp.appcontrol.provider.calendar", "osp.appcontrol.operation.view"},
+ {"tizen.calendar", "http://tizen.org/appcontrol/operation/social/view"},
+ {"tizen.todo", "http://tizen.org/appcontrol/operation/social/view"},
};
-static const wchar_t __allowedAppControlViewTable[][2][64] =
+static const char __allowedAppControlEditTable[][2][96] =
{
- {L"osp.appcontrol.CALENDAR", L"osp.appcontrol.operation.VIEW"},
- {L"osp.appcontrol.provider.calendar", L"osp.appcontrol.operation.view"},
- {L"http://tizen.org/appcontrol/provider/calendar", L"http://tizen.org/appcontrol/operation/view"},
- {L"tizen.calendar", L"http://tizen.org/appcontrol/operation/social/view"},
+ {"tizen.calendar", "http://tizen.org/appcontrol/operation/social/edit"},
};
-static const wchar_t __allowedAppControlVcsViewTable[][2][64] =
+static const char __allowedAppControlVcsViewTable[][2][96] =
{
- {L"tizen.calendar", L"http://tizen.org/appcontrol/operation/view"},
+ {"tizen.calendar", "http://tizen.org/appcontrol/operation/view"},
+ {"tizen.todo", "http://tizen.org/appcontrol/operation/view"},
};
result
__req = req;
- const bool isCalendarVcsView = _AppControlManager::IsAllowedAppControl(__allowedAppControlVcsViewTable, 1, aId, oId);
+ const bool isCalendarVcsView = _AppControlManager::IsAllowedAppControl(__allowedAppControlVcsViewTable, 2, aId, oId);
const bool isCalendarView = _AppControlManager::IsAllowedAppControl(__allowedAppControlViewTable, 4, aId, oId);
- const bool isCalendarPick = _AppControlManager::IsAllowedAppControl(__allowedAppControlPickTable, 4, aId, oId);
+ const bool isCalendarPick = _AppControlManager::IsAllowedAppControl(__allowedAppControlPickTable, 5, aId, oId);
+ const bool isCalendarEdit = _AppControlManager::IsAllowedAppControl(__allowedAppControlEditTable, 1, aId, oId);
+
+ SysTryReturnResult(NID_APP, isCalendarPick || isCalendarEdit || isCalendarView || isCalendarVcsView, E_SYSTEM, "Invalid AppControl entry for (%ls, %ls).", aId.GetPointer(), oId.GetPointer());
+
+ _AppMessageImpl msg;
+ msg.AddData(pMap);
+
+ AppSvcResFn pCb = NULL;
+
+ String providerAppId;
+ String package;
+ String operation;
+ String uri;
+ const String* pActualUri = pUri;
if (isCalendarPick)
{
hasOutput = true;
+#if 0
const String* pItemTypeValue = static_cast<const String*>(pMap->GetValue(String(L"itemType")));
if (pItemTypeValue == null || (*pItemTypeValue != L"event" && *pItemTypeValue != L"todo"))
{
r = E_SUCCESS;
goto CATCH;
}
+#endif
- _AppMessageImpl msg;
- if (pMap != null)
+ pCb = OnAppControlResultTizen;
+ providerAppId = L"tizen.calendar_list";
+ operation = L"http://tizen.org/appcontrol/operation/social/pick";
+
+ const String& tmpItemType = msg.GetValue(L"itemType");
+ if (!tmpItemType.IsEmpty())
{
- msg.AddData(pMap);
+ msg.AddData(CALENDAR_ITEM_TYPE, tmpItemType);
}
-
- __processId = _AppControlManager::GetInstance()->Launch(msg, "calendar-efl", APPSVC_OPERATION_PICK, NULL, NULL, OnAppControlResult, 0);
- SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Calendar AppControl is failed.");
- SysLog(NID_APP, "StartAppControl: Launching Calendar AppControl succeeded.");
- }
- else if (isCalendarVcsView)
- {
- SysLog(NID_APP, "Calendar AppControl : VIEW operation (vcs).");
-
- std::unique_ptr<char[]> pConvertedUri;
- if (pUri)
+ else if (aId == L"tizen.todo")
{
- pConvertedUri.reset(_StringConverter::CopyToCharArrayN(*pUri));
+ msg.AddData(CALENDAR_ITEM_TYPE, L"todo");
+ }
+ else
+ {
+ msg.AddData(CALENDAR_ITEM_TYPE, L"event");
}
- std::unique_ptr<char[]> pConvertedMime;
- if (pMime)
+ const String& tmpSelMode = msg.GetValue(L"selectionMode");
+ if (!tmpSelMode.IsEmpty())
{
- pConvertedMime.reset(_StringConverter::CopyToCharArrayN(*pMime));
+ msg.AddData(CALENDAR_SELECTION_MODE, tmpSelMode);
}
- _AppMessageImpl msg;
- if (pMap != null)
+ const String& tmpResultType = msg.GetValue(CALENDAR_RESULT_TYPE);
+ if (tmpResultType.IsEmpty())
{
- msg.AddData(pMap);
+ msg.AddData(CALENDAR_RESULT_TYPE, L"vcs");
}
- __processId = _AppControlManager::GetInstance()->Launch(msg, "calendar-detail-efl", APPSVC_OPERATION_VIEW, pConvertedMime.get(), pConvertedUri.get(), NULL, 0);
- SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Calendar AppControl is failed.");
- SysLog(NID_APP, "StartAppControl: Launching Calendar AppControl(vcs) succeeded.");
}
- else if (isCalendarView)
+ else if (isCalendarEdit)
{
- SysLog(NID_APP, "Calendar AppControl : VIEW operation.");
+ SysLog(NID_APP, "Calendar AppControl : EDIT operation.");
+
+ hasOutput = true;
+ pCb = OnAppControlResultTizen;
+ providerAppId = L"tizen.calendar_edit";
+ operation = L"http://tizen.org/appcontrol/operation/social/edit";
- _AppMessageImpl msg;
- if (pMap != null)
+ msg.AddData(CALENDAR_ITEM_TYPE, L"event");
+ }
+ else if (isCalendarVcsView || isCalendarView)
+ {
+ if (pUri == null)
{
- msg.AddData(pMap);
-
- const String* pViewTypeValue = static_cast<const String*>(pMap->GetValue(String(L"viewType")));
- if (pViewTypeValue == null)
+ const String& path = msg.GetValue(L"path");
+ if (!path.IsEmpty())
{
- SysLog(NID_APP, "viewType is invalid.");
- r = E_SUCCESS;
- goto CATCH;
+ uri = path;
+ pActualUri = &uri;
}
+ }
- if (*pViewTypeValue == L"vcs")
+ providerAppId = L"tizen.calendar_detail";
+
+ if (pActualUri)
+ {
+ SysLog(NID_APP, "Calendar AppControl : VIEW operation (vcs).");
+ operation = L"http://tizen.org/appcontrol/operation/view";
+ }
+ else
+ {
+ SysLog(NID_APP, "Calendar AppControl : VIEW operation.");
+
+ operation = L"http://tizen.org/appcontrol/operation/social/view";
+
+ const String& tmpItemType = msg.GetValue(L"viewType");
+ if (!tmpItemType.IsEmpty())
{
- const String* pPathValue = static_cast<const String*>(pMap->GetValue(String(L"path")));
- if (pPathValue == null || pPathValue->GetLength() == 0)
- {
- SysLog(NID_APP, "path is invalid.");
- r = E_SUCCESS;
- goto CATCH;
- }
+ msg.AddData(CALENDAR_ITEM_TYPE, tmpItemType);
}
- else if (*pViewTypeValue == L"event")
+ else if (aId == L"tizen.todo")
{
- const String* pEventIdValue = static_cast<const String*>(pMap->GetValue(String(L"eventId")));
- if (pEventIdValue == null || pEventIdValue->GetLength() == 0)
- {
- SysLog(NID_APP, "eventId is invalid.");
- r = E_SUCCESS;
- goto CATCH;
- }
+ msg.AddData(CALENDAR_ITEM_TYPE, L"todo");
}
- else if (*pViewTypeValue == L"todo")
+ else
{
- const String* pTodoIdValue = static_cast<const String*>(pMap->GetValue(String(L"todoId")));
- if (pTodoIdValue == null || pTodoIdValue->GetLength() == 0)
- {
- SysLog(NID_APP, "todoId is invalid.");
- r = E_SUCCESS;
- goto CATCH;
- }
+ msg.AddData(CALENDAR_ITEM_TYPE, L"event");
}
- else
+
+ const String& tmpEventId = msg.GetValue(L"eventId");
+ const String& tmpTodoId = msg.GetValue(L"todoId");
+ if (!tmpEventId.IsEmpty())
+ {
+ msg.AddData(CALENDAR_ITEM_ID, tmpEventId);
+ }
+ else if (!tmpTodoId.IsEmpty())
{
- SysLog(NID_APP, "viewType is invalid.");
- r = E_SUCCESS;
- goto CATCH;
+ msg.AddData(CALENDAR_ITEM_ID, tmpTodoId);
}
}
+ }
- const String& tmp = msg.GetValue(L"viewType");
- if (!tmp.IsEmpty())
- {
- msg.AddData(L"itemType", tmp);
- }
+ package = _AppControlManager::GetAliasAppId(providerAppId);
+ SysLog(NID_APP, "Actual app is %ls.", package.GetPointer());
- __processId = _AppControlManager::GetInstance()->Launch(msg, "calendar-detail-efl", APPSVC_OPERATION_VIEW, NULL, NULL, NULL, 0);
- SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Calendar AppControl is failed.");
- SysLog(NID_APP, "StartAppControl: Launching Calendar AppControl succeeded.");
- }
+ __req = req;
+ __processId = _AppControlManager::GetInstance()->Launch(msg, package, operation, pActualUri, pMime, pCb, 0);
+
+ r = GetLastResult();
+ SysTryReturnResult(NID_APP, __processId >= 0, r, "StartAppControl: Launching Calendar AppControl is failed.");
+
+ SysLog(NID_APP, "StartAppControl: Launching Calendar AppControl succeeded");
return E_SUCCESS;
+#if 0
CATCH:
if (hasOutput)
__req = -1;
return r;
+#endif
}
result
}
+void
+OnAppControlResultTizen(void* b, int requestCode, service_result_e res, void* userData)
+{
+ result r = E_SYSTEM;
+ bundle* pBundle = static_cast<bundle*>(b);
+
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
+
+ r = pResult->Construct();
+
+ _AppArg::SetArgMap(pBundle, pResult);
+
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
+
+CATCH:
+ __req = -1;
+}
+
#ifdef __cplusplus
}