fix AppControl E_MAX_EXCEEDED result
[platform/framework/native/app-controls.git] / src / calendar-app-control / CalendarAppControlDllEntry.cpp
index 4ac2c95..283c787 100644 (file)
@@ -50,6 +50,7 @@ extern "C" {
 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*);
@@ -66,6 +67,7 @@ static const char __allowedAppControlPickTable[][2][96] =
        {"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] =
@@ -73,6 +75,7 @@ static const char __allowedAppControlViewTable[][2][96] =
        {"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 char __allowedAppControlEditTable[][2][96] =
@@ -83,6 +86,7 @@ static const char __allowedAppControlEditTable[][2][96] =
 static const char __allowedAppControlVcsViewTable[][2][96] =
 {
        {"tizen.calendar", "http://tizen.org/appcontrol/operation/view"},
+       {"tizen.todo", "http://tizen.org/appcontrol/operation/view"},
 };
 
 result
@@ -95,9 +99,9 @@ StartAppControl(int req, const String& aId, const String& oId, const String* pUr
 
        __req = req;
 
-       const bool isCalendarVcsView = _AppControlManager::IsAllowedAppControl(__allowedAppControlVcsViewTable, 1, aId, oId);
-       const bool isCalendarView = _AppControlManager::IsAllowedAppControl(__allowedAppControlViewTable, 3, aId, oId);
-       const bool isCalendarPick = _AppControlManager::IsAllowedAppControl(__allowedAppControlPickTable, 4, 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, 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());
@@ -107,6 +111,7 @@ StartAppControl(int req, const String& aId, const String& oId, const String* pUr
 
        AppSvcResFn pCb = NULL;
 
+       String providerAppId;
        String package;
        String operation;
        String uri;
@@ -136,15 +141,35 @@ StartAppControl(int req, const String& aId, const String& oId, const String* pUr
 #endif
 
                pCb = OnAppControlResultTizen;
+               providerAppId = L"tizen.calendar_list";
                operation = L"http://tizen.org/appcontrol/operation/social/pick";
 
-               msg.AddData(CALENDAR_ITEM_TYPE, L"event");
+               const String& tmpItemType = msg.GetValue(L"itemType");
+               if (!tmpItemType.IsEmpty())
+               {
+                       msg.AddData(CALENDAR_ITEM_TYPE, tmpItemType);
+               }
+               else if (aId == L"tizen.todo")
+               {
+                       msg.AddData(CALENDAR_ITEM_TYPE, L"todo");
+               }
+               else
+               {
+                       msg.AddData(CALENDAR_ITEM_TYPE, L"event");
+               }
 
-               const String& tmp = msg.GetValue(L"itemType");
-               if (!tmp.IsEmpty())
+               const String& tmpSelMode = msg.GetValue(L"selectionMode");
+               if (!tmpSelMode.IsEmpty())
                {
-                       msg.AddData(CALENDAR_RESULT_TYPE, tmp);
+                       msg.AddData(CALENDAR_SELECTION_MODE, tmpSelMode);
                }
+
+               const String& tmpResultType = msg.GetValue(CALENDAR_RESULT_TYPE);
+               if (tmpResultType.IsEmpty())
+               {
+                       msg.AddData(CALENDAR_RESULT_TYPE, L"vcs");
+               }
+
        }
        else if (isCalendarEdit)
        {
@@ -152,6 +177,7 @@ StartAppControl(int req, const String& aId, const String& oId, const String* pUr
                
                hasOutput = true;
                pCb = OnAppControlResultTizen;
+               providerAppId = L"tizen.calendar_edit";
                operation = L"http://tizen.org/appcontrol/operation/social/edit";
 
                msg.AddData(CALENDAR_ITEM_TYPE, L"event");
@@ -168,6 +194,8 @@ StartAppControl(int req, const String& aId, const String& oId, const String* pUr
                        }
                }
 
+               providerAppId = L"tizen.calendar_detail";
+
                if (pActualUri)
                {
                        SysLog(NID_APP, "Calendar AppControl : VIEW operation (vcs).");
@@ -179,32 +207,47 @@ StartAppControl(int req, const String& aId, const String& oId, const String* pUr
 
                        operation = L"http://tizen.org/appcontrol/operation/social/view";
 
-                       msg.AddData(CALENDAR_ITEM_TYPE, L"event");
+                       const String& tmpItemType = msg.GetValue(L"viewType");
+                       if (!tmpItemType.IsEmpty())
+                       {
+                               msg.AddData(CALENDAR_ITEM_TYPE, tmpItemType);
+                       }
+                       else if (aId == L"tizen.todo")
+                       {
+                               msg.AddData(CALENDAR_ITEM_TYPE, L"todo");
+                       }
+                       else
+                       {
+                               msg.AddData(CALENDAR_ITEM_TYPE, L"event");
+                       }
 
-                       const String& tmp = msg.GetValue(L"eventId");
-                       if (!tmp.IsEmpty())
+                       const String& tmpEventId = msg.GetValue(L"eventId");
+                       const String& tmpTodoId = msg.GetValue(L"todoId");
+                       if (!tmpEventId.IsEmpty())
                        {
-                               msg.AddData(CALENDAR_ITEM_ID, tmp);
+                               msg.AddData(CALENDAR_ITEM_ID, tmpEventId);
+                       }
+                       else if (!tmpTodoId.IsEmpty())
+                       {
+                               msg.AddData(CALENDAR_ITEM_ID, tmpTodoId);
                        }
                }
        }
-       else
-       {
-               operation = oId;
-       }
 
-       package = _AppControlManager::GetAliasAppId(aId);
-       SysLog(NID_APP, "Actual packageId is %ls.", package.GetPointer());
+       package = _AppControlManager::GetAliasAppId(providerAppId);
+       SysLog(NID_APP, "Actual app is %ls.", package.GetPointer());
 
        __req = req; 
        __processId = _AppControlManager::GetInstance()->Launch(msg, package, operation, pActualUri, pMime, pCb, 0);
 
-       SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Calendar AppControl is failed.");
+       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)
@@ -214,6 +257,7 @@ CATCH:
 
        __req = -1;
        return r;
+#endif
 }
 
 result