Applied changed calendar-service API
authorHosang Kim <hosang.kim@samsung.com>
Fri, 29 Mar 2013 09:08:47 +0000 (18:08 +0900)
committerHosang Kim <hosang.kim@samsung.com>
Fri, 29 Mar 2013 09:25:02 +0000 (18:25 +0900)
Change-Id: I743cefb58be8baba21b4d553a7d741eea2e59472
Signed-off-by: Hosang Kim <hosang.kim@samsung.com>
packaging/osp-app-service.spec
plugins/calendar-condition-handler/CMakeLists.txt
plugins/calendar-condition-handler/CalendarConditionHandler.cpp
plugins/calendar-condition-handler/CalendarConditionHandler.h

index e238c29..a03cfd2 100755 (executable)
@@ -35,7 +35,6 @@ BuildRequires:        pkgconfig(elementary)
 BuildRequires: pkgconfig(dbus-1)
 BuildRequires: pkgconfig(edbus)
 BuildRequires: pkgconfig(calendar-service2)
-BuildRequires: pkgconfig(bundle)
 BuildRequires: pkgconfig(osp-appfw-server)
 BuildRequires: osp-appfw-internal-devel
 
index 03d82fa..3f0bb8d 100755 (executable)
@@ -28,5 +28,5 @@ ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
 ADD_DEPENDENCIES(${this_target} osp-appfw)
 
 SET_TARGET_PROPERTIES(${this_target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${PLUGIN_INSTALL_DIR}/lib")
-TARGET_LINK_LIBRARIES(${this_target} -L/usr/lib/osp -losp-appfw -lbundle -Wl,--no-undefined -Wl,--as-needed)
+TARGET_LINK_LIBRARIES(${this_target} -L/usr/lib/osp -losp-appfw -Wl,--no-undefined -Wl,--as-needed)
 TARGET_LINK_LIBRARIES(${this_target} "-lcalendar-service2" )
\ No newline at end of file
index a0c2664..1feddc8 100644 (file)
@@ -27,6 +27,7 @@
 #include <FBaseLongLong.h>
 #include <FBaseDateTime.h>
 #include <FBaseString.h>
+#include <FBaseUtilStringTokenizer.h>
 #include <FBaseColHashMap.h>
 #include <FBaseColAllElementsDeleter.h>
 
@@ -37,15 +38,16 @@ using namespace std;
 using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
 
-static const char* REMINDER_CB_KEY_ID = "id";
-static const char* REMINDER_CB_KEY_TYPE = "type";
-static const char* REMINDER_CB_KEY_TIME = "time";
-static const char* REMINDER_CB_KEY_TICK = "tick";
-static const char* REMINDER_CB_KEY_UNIT = "unit";
+static const wchar_t* REMINDER_CB_KEY_ID = L"id";
+static const wchar_t* REMINDER_CB_KEY_TYPE = L"type";
+static const wchar_t* REMINDER_CB_KEY_TIME = L"time";
+static const wchar_t* REMINDER_CB_KEY_TICK = L"tick";
+static const wchar_t* REMINDER_CB_KEY_UNIT = L"unit";
 
-static const char* REMINDER_CB_VALUE_TYPE_EVENT = "1";
-static const char* REMINDER_CB_VALUE_TYPE_TODO = "2";
+static const wchar_t* REMINDER_CB_VALUE_TYPE_EVENT = L"1";
+static const wchar_t* REMINDER_CB_VALUE_TYPE_TODO = L"2";
 
 static const wchar_t* REMINDER_ARG_KEY_RECORD_ID = L"recordid";
 static const wchar_t* REMINDER_ARG_KEY_TYPE = L"recordtype";
@@ -150,7 +152,7 @@ _CalendarConditionHandler::Unregister( _AppLaunchCondition& appLaunchCondition)
 }
 
 void
-_CalendarConditionHandler::ReminderCallback(bundle* pBundle, void* pUserData)
+_CalendarConditionHandler::ReminderCallback(const char *pArg, void* pUserData)
 {
        _AppLaunchCondition* pAppLaunchCondition = static_cast<_AppLaunchCondition*>(pUserData);
        SysTryReturnVoidResult(NID_APP, pAppLaunchCondition != null, E_INVALID_STATE, "[E_INVALID_STATE] pUserData should NOT be null.");
@@ -158,7 +160,9 @@ _CalendarConditionHandler::ReminderCallback(bundle* pBundle, void* pUserData)
        _CalendarConditionHandler* pHandler = dynamic_cast<_CalendarConditionHandler*>(pAppLaunchCondition->GetUserData());
        SysTryReturnVoidResult(NID_APP, pHandler != null, E_INVALID_STATE, "user data is null");
 
-       SysTryReturnVoidResult(NID_APP, pBundle != null, E_INVALID_STATE, "[E_INVALID_STATE] pBundle should NOT be null.");
+       SysTryReturnVoidResult(NID_APP, pArg != null, E_INVALID_STATE, "[E_INVALID_STATE] pArg should NOT be null.");
+
+       SysLog(NID_APP, "Reminder callback is called. arg : %s", pArg);
 
        std::unique_ptr<HashMap, AllElementsDeleter> pResultMap(new (std::nothrow) HashMap());
        SysTryReturnVoidResult(NID_APP, pResultMap != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
@@ -167,38 +171,74 @@ _CalendarConditionHandler::ReminderCallback(bundle* pBundle, void* pUserData)
        SysTryReturnVoidResult(NID_APP, !IsFailed(r), r, "[%s] Propagating.", GetErrorMessage(r));
 
        // get values
-       const char* pStrRecordId = bundle_get_val(pBundle, REMINDER_CB_KEY_ID);
-       SysTryReturnVoidResult(NID_APP, pStrRecordId != null, E_INVALID_STATE, "[E_INVALID_STATE] id should NOT be null.");
+       String strRecordId;
+       String strTime;
+       String strTick;
+       String strUnit;
+       String strType;
 
-       const char* pStrType = bundle_get_val(pBundle, REMINDER_CB_KEY_TYPE);
-       SysTryReturnVoidResult(NID_APP, pStrType != null, E_INVALID_STATE, "[E_INVALID_STATE] type should NOT be null.");
+       String strArg(pArg);
+       String delim(L"&=");
 
-       const char* pStrTime = bundle_get_val(pBundle, REMINDER_CB_KEY_TIME);
-       SysTryReturnVoidResult(NID_APP, pStrTime != null, E_INVALID_STATE, "[E_INVALID_STATE] time should NOT be null.");
+       StringTokenizer strTok(strArg, delim);
 
-       const char* pStrTick = bundle_get_val(pBundle, REMINDER_CB_KEY_TICK);
-       SysTryReturnVoidResult(NID_APP, pStrTick != null, E_INVALID_STATE, "[E_INVALID_STATE] tick should NOT be null.");
+       int count = strTok.GetTokenCount();
+       SysTryReturnVoidResult(NID_APP, count == 10, E_INVALID_STATE, "[E_INVALID_STATE] pArg should have 5 key-value pairs.");
 
-       const char* pStrUnit = bundle_get_val(pBundle, REMINDER_CB_KEY_UNIT);
-       SysTryReturnVoidResult(NID_APP, pStrUnit != null, E_INVALID_STATE, "[E_INVALID_STATE] unit should NOT be null.");
+       String token;
+       while (strTok.HasMoreTokens())
+       {
+               strTok.GetNextToken(token);
+
+               if (token == REMINDER_CB_KEY_ID)
+               {
+                       strTok.GetNextToken(strRecordId);
+               }
+               else if (token == REMINDER_CB_KEY_TIME)
+               {
+                       strTok.GetNextToken(strTime);
+               }
+               else if (token == REMINDER_CB_KEY_TICK)
+               {
+                       strTok.GetNextToken(strTick);
+               }
+               else if (token == REMINDER_CB_KEY_UNIT)
+               {
+                       strTok.GetNextToken(strUnit);
+               }
+               else if (token == REMINDER_CB_KEY_TYPE)
+               {
+                       strTok.GetNextToken(strType);
+               }
+               else
+               {
+                       SysLog(NID_APP, "This token is illegal. : %S", token.GetPointer());
+                       strTok.GetNextToken(token);
+                       continue;
+               }
+       }
 
-       SysLog(NID_APP, "Reminder callback is called. id : %s, type : %s, time : %s, tick : %s, unit : %s", pStrRecordId, pStrType, pStrTime, pStrTick, pStrUnit);
+       SysTryReturnVoidResult(NID_APP, !strRecordId.IsEmpty(), E_INVALID_STATE, "[E_INVALID_STATE] id should NOT be null.");
+       SysTryReturnVoidResult(NID_APP, !strType.IsEmpty(), E_INVALID_STATE, "[E_INVALID_STATE] type should NOT be null.");
+       SysTryReturnVoidResult(NID_APP, !strTime.IsEmpty(), E_INVALID_STATE, "[E_INVALID_STATE] time should NOT be null.");
+       SysTryReturnVoidResult(NID_APP, !strTick.IsEmpty(), E_INVALID_STATE, "[E_INVALID_STATE] tick should NOT be null.");
+       SysTryReturnVoidResult(NID_APP, !strUnit.IsEmpty(), E_INVALID_STATE, "[E_INVALID_STATE] unit should NOT be null.");
 
        // convert
        std::unique_ptr<String> pRecordType;
-       if (strcmp(pStrType, REMINDER_CB_VALUE_TYPE_EVENT) == 0)
+       if (strType == REMINDER_CB_VALUE_TYPE_EVENT)
        {
                pRecordType.reset(new (std::nothrow) String(REMINDER_ARG_VALUE_TYPE_EVENT));
        }
-       else if (strcmp(pStrType, REMINDER_CB_VALUE_TYPE_TODO) == 0)
+       else if (strType == REMINDER_CB_VALUE_TYPE_TODO)
        {
                pRecordType.reset(new (std::nothrow) String(REMINDER_ARG_VALUE_TYPE_TODO));
        }
 
        int unit = 0;
-       r = Integer::Parse(pStrUnit, unit);
+       r = Integer::Parse(strUnit, unit);
        int offset = 0;
-       r = Integer::Parse(pStrTick, offset);
+       r = Integer::Parse(strTick, offset);
 
        std::unique_ptr<String> pReminderUnit;
        switch (unit)
@@ -232,10 +272,10 @@ _CalendarConditionHandler::ReminderCallback(bundle* pBundle, void* pUserData)
        pReminderOffset->Append(offset);
 
        long long time = 0;
-       r = LongLong::Parse(pStrTime, time);
+       r = LongLong::Parse(strTime, time);
        std::unique_ptr<String> pTime(new (std::nothrow) String(ConvertEpochTimeToDateTime(time).ToString()));
 
-       r = pResultMap->Add(new String(REMINDER_ARG_KEY_RECORD_ID), new String(pStrRecordId));
+       r = pResultMap->Add(new String(REMINDER_ARG_KEY_RECORD_ID), new (std::nothrow) String(strRecordId));
        SysTryReturnVoidResult(NID_APP, r == E_SUCCESS, r, "[%s] Failed to add id to the hash map.", GetErrorMessage(r));
 
        r = pResultMap->Add(new String(REMINDER_ARG_KEY_TYPE), pRecordType.release());
index e9b76d0..b2d2628 100644 (file)
@@ -20,7 +20,6 @@
  * @brief      This is the implementation file of the _CalendarConditionHandler class.
  *
  */
-#include <bundle.h>
 #include <calendar2.h>
 #include "FApp_AppLaunchConditionHandlerBase.h"
 
@@ -45,7 +44,7 @@ public:
        virtual result Register( Tizen::App::_AppLaunchCondition& appLaunchCondition);
        virtual result Unregister( Tizen::App::_AppLaunchCondition& appLaunchCondition);
 
-       static void ReminderCallback(bundle* pBundle, void* pUserData);
+       static void ReminderCallback(const char *pArg, void* pUserData);
 
 private:
        _CalendarConditionHandler(void);