public:
const Tizen::Base::String* GetArgument(const Tizen::Base::String& key) const;
const Tizen::Base::String& GetInitialScene(void) const;
- const Tizen::Base::Collection::IList* GetInitialSceneArgument(void) const;
+ const Tizen::Base::Collection::IList* GetInitialSceneArgumentN(void) const;
const Tizen::Base::String& GetMimeType(void) const;
OperationType GetOperationType(void) const;
RequestId GetRequestId(void) const;
static Tizen::Base::DateTime ConvertUtcTimeToWallTime(const Tizen::Base::DateTime& utcTime);
static Tizen::Base::DateTime ConvertWallTimeToUtcTime(const Tizen::Base::DateTime& wallTime);
+
+ static Tizen::Base::Collection::IList* ParseVcsFileN(const Tizen::Base::String& filePath);
private:
result Construct(void);
#ifndef _CL_SETTING_FORM_H_
#define _CL_SETTING_FORM_H_
+#include <FApp.h>
#include <FBase.h>
#include <FUi.h>
class SettingForm
: public Tizen::Ui::Controls::Form
+ , public virtual Tizen::App::IAppControlResponseListener
, public virtual Tizen::Ui::Controls::IFormBackEventListener
, public virtual Tizen::Ui::Controls::ISectionTableViewItemEventListener
, public virtual Tizen::Ui::Controls::ISectionTableViewItemProvider
virtual result OnInitializing(void);
virtual result OnTerminating(void);
+ virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId,
+ Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData);
+
virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
virtual int GetSectionCount(void);
extern const wchar_t* ID_OPERATION_SOCIAL_PICK;
extern const wchar_t* ID_OPERATION_SOCIAL_VIEW;
+extern const wchar_t* MIME_TYPE_DIRECTORY;
extern const wchar_t* MIME_TYPE_VCALENDAR;
extern const wchar_t* KEY_DATA_PATH;
+extern const wchar_t* KEY_DATA_SELECTED;
extern const wchar_t* KEY_DATA_SELECTION_MODE;
extern const wchar_t* KEY_DATA_RETURN_RESULT;
#include <FSocial.h>
#include "ClCalendarApp.h"
#include "ClMainFrame.h"
+#include "ClResourceManager.h"
using namespace Tizen::App;
using namespace Tizen::Base;
using namespace Tizen::Ui::Scenes;
-IList*
-ParseVcsFileN(String& vcsFilePath)
-{
- ArrayList* pResultList = null;
- IList* pEvents = Calendarbook::ParseEventsFromVcalendarN(vcsFilePath);
- TryReturn(pEvents != null, null, "[%s] Unable to get event from vcs file.", GetErrorMessage(GetLastResult()));
-
- IList* pTodos = Calendarbook::ParseTodosFromVcalendarN(vcsFilePath);
- TryCatch(pTodos != null, , "[%s] Unable to get todo from vcs file.", GetErrorMessage(GetLastResult()));
-
- pResultList = new (std::nothrow) ArrayList(SingleObjectDeleter);
- pResultList->Construct(pEvents->GetCount() + pTodos->GetCount());
-
- while (pEvents->GetCount() > 0 && pTodos->GetCount() > 0)
- {
- if (static_cast<CalEvent*>(pEvents->GetAt(0))->GetStartTime() > static_cast<CalTodo*>(pTodos->GetAt(0))->GetStartDate())
- {
- pResultList->Add(pTodos->GetAt(0));
- pTodos->RemoveAt(0, false);
- }
- else
- {
- pResultList->Add(pEvents->GetAt(0));
- pEvents->RemoveAt(0, false);
- }
- }
- while (pEvents->GetCount() > 0)
- {
- pResultList->Add(pEvents->GetAt(0));
- pEvents->RemoveAt(0, false);
- }
- while (pTodos->GetCount() > 0)
- {
- pResultList->Add(pTodos->GetAt(0));
- pTodos->RemoveAt(0, false);
- }
-
-CATCH:
- delete pEvents;
- delete pTodos;
-
- return pResultList;
-}
-
-
CalendarApp::CalendarApp(void)
: __type(OPERATION_TYPE_MAIN)
, __requestId(INVALID_REQUEST_ID)
}
const IList*
-CalendarApp::GetInitialSceneArgument(void) const
+CalendarApp::GetInitialSceneArgumentN(void) const
{
- return __pInitialSceneArgument;
+ ArrayList* pArgs = null;
+ if (__pInitialSceneArgument != null)
+ {
+ pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
+ pArgs->Construct(__pInitialSceneArgument->GetCount());
+ IEnumerator* pEnum = __pInitialSceneArgument->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ if (dynamic_cast<const CalEvent*>(pEnum->GetCurrent()) != null)
+ {
+ pArgs->Add(new (std::nothrow) CalEvent(static_cast<const CalEvent&>(*pEnum->GetCurrent())));
+ }
+ else if (dynamic_cast<const CalTodo*>(pEnum->GetCurrent()) != null)
+ {
+ pArgs->Add(new (std::nothrow) CalTodo(static_cast<const CalTodo&>(*pEnum->GetCurrent())));
+ }
+ }
+ delete pEnum;
+ }
+ return pArgs;
}
const String&
String path = __uriScheme;
path.Replace(FILE_URL_HEADER, L"");
- __pInitialSceneArgument = ParseVcsFileN(path);
+ __pInitialSceneArgument = ResourceManager::ParseVcsFileN(path);
if (__pInitialSceneArgument != null)
{
__initialScene = IDSCN_VCS_SELECTOR;
result
ImportForm::OnTerminating(void)
{
+ delete __pList;
delete __pDateTimeFormatter;
delete __pDateFormatter;
delete __pTimeFormatter;
ImportForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
{
AppLogDebug("Enter.");
- SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
+ ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
+ pArgs->Construct(__pList->GetCount());
+ IEnumerator* pEnum = __pList->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ if (dynamic_cast<CalEvent*>(pEnum->GetCurrent()) != null)
+ {
+ pArgs->Add(new (std::nothrow) CalEvent(static_cast<CalEvent&>(*pEnum->GetCurrent())));
+ }
+ else if (dynamic_cast<CalTodo*>(pEnum->GetCurrent()) != null)
+ {
+ pArgs->Add(new (std::nothrow) CalTodo(static_cast<CalTodo&>(*pEnum->GetCurrent())));
+ }
+ }
+ delete pEnum;
+ SceneManager::GetInstance()->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), pArgs);
AppLogDebug("Exit.");
}
ImportForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
{
AppLogDebug("Enter.");
- __pList = null;
AppLogDebug("Exit.");
}
CalendarApp* pApp = static_cast<CalendarApp*>(UiApp::GetInstance());
AppAssertf(pApp != null, "[E_FAILURE] Unable to get calendarapp.");
- SceneManager::GetInstance()->GoForward(ForwardSceneTransition(pApp->GetInitialScene()), pApp->GetInitialSceneArgument());
+ SceneManager::GetInstance()->GoForward(ForwardSceneTransition(pApp->GetInitialScene()), pApp->GetInitialSceneArgumentN());
return E_SUCCESS;
}
#include <cstdlib>
#include <new>
#include <FMedia.h>
+#include <FSocial.h>
#include <FSystem.h>
#include "ClResourceManager.h"
#include "ClTypes.h"
+using namespace Tizen;
using namespace Tizen::App;
using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
using namespace Tizen::Graphics;
using namespace Tizen::Locales;
using namespace Tizen::Media;
static const int BASE_DAY = 7;
+class EventComparer
+ : public virtual IComparer
+{
+ virtual result Compare(const Object& obj1, const Object& obj2, int& cmp) const;
+};
+
+result
+EventComparer::Compare(const Object& obj1, const Object& obj2, int& cmp) const
+{
+ const Social::CalEvent* pEvent1 = dynamic_cast<const Social::CalEvent*>(&obj1);
+ TryReturn(pEvent1 != null, E_FAILURE, "[E_FAILURE] Unable to convert CalEvent.");
+ const Social::CalEvent* pEvent2 = dynamic_cast<const Social::CalEvent*>(&obj2);
+ TryReturn(pEvent2 != null, E_FAILURE, "[E_FAILURE] Unable to convert CalEvent.");
+
+ long long time1 = pEvent1->GetStartTime().GetTicks();
+ long long time2 = pEvent2->GetStartTime().GetTicks();
+ if (time1 > time2)
+ {
+ cmp = 1;
+ }
+ else if (time1 < time2)
+ {
+ cmp = -1;
+ }
+ else
+ {
+ cmp = 0;
+ }
+ return E_SUCCESS;
+}
+
+class TodoComparer
+ : public virtual IComparer
+{
+ virtual result Compare(const Object& obj1, const Object& obj2, int& cmp) const;
+};
+
+result
+TodoComparer::Compare(const Object& obj1, const Object& obj2, int& cmp) const
+{
+ const Social::CalTodo* pTodo1 = dynamic_cast<const Social::CalTodo*>(&obj1);
+ TryReturn(pTodo1 != null, E_FAILURE, "[E_FAILURE] Unable to convert CalTodo.");
+ const Social::CalTodo* pTodo2 = dynamic_cast<const Social::CalTodo*>(&obj2);
+ TryReturn(pTodo2 != null, E_FAILURE, "[E_FAILURE] Unable to convert CalTodo.");
+
+ DateTime time1 = pTodo1->GetStartDate();
+ DateTime time2 = pTodo2->GetStartDate();
+ if (time1 > time2)
+ {
+ cmp = 1;
+ }
+ else if (time1 < time2)
+ {
+ cmp = -1;
+ }
+ else
+ {
+ cmp = 0;
+ }
+ return E_SUCCESS;
+}
+
+
ResourceManager* ResourceManager::__pInstance = null;
ResourceManager::ResourceManager(void)
return GetInstance()->__timeZone.WallTimeToUtcTime(wallTime);
}
+IList*
+ResourceManager::ParseVcsFileN(const String& filePath)
+{
+ ArrayList* pResultList = null;
+ EventComparer eventComparer;
+ TodoComparer todoComparer;
+
+ IList* pEvents = Social::Calendarbook::ParseEventsFromVcalendarN(filePath);
+ TryReturn(pEvents != null, null, "[%s] Unable to get event from vcs file.", GetErrorMessage(GetLastResult()));
+
+ IList* pTodos = Social::Calendarbook::ParseTodosFromVcalendarN(filePath);
+ TryCatch(pTodos != null, , "[%s] Unable to get todo from vcs file.", GetErrorMessage(GetLastResult()));
+
+ pEvents->Sort(eventComparer);
+ pTodos->Sort(todoComparer);
+
+ pResultList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+ pResultList->Construct(pEvents->GetCount() + pTodos->GetCount());
+
+ while (pEvents->GetCount() > 0 && pTodos->GetCount() > 0)
+ {
+ if (static_cast<Social::CalEvent*>(pEvents->GetAt(0))->GetStartTime() > static_cast<Social::CalTodo*>(pTodos->GetAt(0))->GetStartDate())
+ {
+ pResultList->Add(pTodos->GetAt(0));
+ pTodos->RemoveAt(0, false);
+ }
+ else
+ {
+ pResultList->Add(pEvents->GetAt(0));
+ pEvents->RemoveAt(0, false);
+ }
+ }
+ while (pEvents->GetCount() > 0)
+ {
+ pResultList->Add(pEvents->GetAt(0));
+ pEvents->RemoveAt(0, false);
+ }
+ while (pTodos->GetCount() > 0)
+ {
+ pResultList->Add(pTodos->GetAt(0));
+ pTodos->RemoveAt(0, false);
+ }
+
+CATCH:
+ delete pEvents;
+ delete pTodos;
+
+ return pResultList;
+}
+
result
ResourceManager::Construct(void)
{
*/
#include <new>
-#include <FApp.h>
#include <FGraphics.h>
+#include <FSocial.h>
#include <FSystem.h>
#include "ClCalendarApp.h"
#include "ClResourceManager.h"
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
using namespace Tizen::Graphics;
+using namespace Tizen::Social;
using namespace Tizen::System;
using namespace Tizen::Ui;
using namespace Tizen::Ui::Controls;
using namespace Tizen::Ui::Scenes;
+// This options is used for import/export function development.
+//#define _ENABLE_IMPORT_EXPORT_
+
enum
{
GROUP_ITEM_INDEX = -1,
// GROUP_LOCK_TIME_ZONE = 0,
GROUP_FIRST_DAY_OF_WEEK,
-// GROUP_IMPORT_EXPORT,
+#ifdef _ENABLE_IMPORT_EXPORT_
+ GROUP_IMPORT_EXPORT,
+#endif
GROUP_COUNT,
// LOCK_TIME_ZONE_ITEM_ONOFF = 0,
FIRST_DAY_OF_WEEK_ITEM_COUNT_EXPANDED,
FIRST_DAY_OF_WEEK_ITEM_COUNT_COLLAPSED = FIRST_DAY_OF_WEEK_ITEM_SUNDAY,
-// IMPORT_EXPORT_ITEM_IMPORT = 0,
+#ifdef _ENABLE_IMPORT_EXPORT_
+ IMPORT_EXPORT_ITEM_IMPORT = 0,
// IMPORT_EXPORT_ITEM_EXPORT,
-// IMPORT_EXPORT_ITEM_COUNT
+ IMPORT_EXPORT_ITEM_COUNT
+#endif
};
static const int H_ITEM = 112;
static const int FONT_SIZE_DETAIL03 = 32;
static const unsigned int COLOR_DETAIL03 = Color32<128, 128, 128>::Value;
+
SettingForm::SettingForm(void)
: __pTableView(null)
, __pLabelLockTimeZone(null)
}
void
+SettingForm::OnAppControlCompleteResponseReceived(const AppId& appId, const String& operationId,
+ AppCtrlResult appControlResult, const IMap* pExtraData)
+{
+ AppLogDebug("Enter.");
+ AppLogDebug("AppId : %ls", appId.GetPointer());
+ AppLogDebug("OperationId : %ls", operationId.GetPointer());
+ if (appControlResult == APP_CTRL_RESULT_SUCCEEDED)
+ {
+ if (operationId.Equals(ID_OPERATION_PICK, false) == true && pExtraData != null)
+ {
+ const IList* pPaths = dynamic_cast<const IList*>(pExtraData->GetValue(String(KEY_DATA_SELECTED)));
+ if (pPaths != null && pPaths->GetCount() > 0)
+ {
+ IList* pList = ResourceManager::ParseVcsFileN(static_cast<const String&>(*pPaths->GetAt(0)));
+ if (pList != null)
+ {
+ SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_IMPORT, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pList);
+ }
+ }
+ }
+ }
+ AppLogDebug("Exit.");
+}
+
+void
SettingForm::OnFormBackRequested(Form& source)
{
CalendarApp* pApp = static_cast<CalendarApp*>(UiApp::GetInstance());
// return (__isLockTimeZoneSet == true) ? LOCK_TIME_ZONE_ITEM_COUNT_ON : LOCK_TIME_ZONE_ITEM_COUNT_OFF;
case GROUP_FIRST_DAY_OF_WEEK:
return (__isFirstDayOfWeekSelectionItemExpanded == true) ? FIRST_DAY_OF_WEEK_ITEM_COUNT_EXPANDED : FIRST_DAY_OF_WEEK_ITEM_COUNT_COLLAPSED;
-// case GROUP_IMPORT_EXPORT:
-// return IMPORT_EXPORT_ITEM_COUNT;
+#ifdef _ENABLE_IMPORT_EXPORT_
+ case GROUP_IMPORT_EXPORT:
+ return IMPORT_EXPORT_ITEM_COUNT;
+#endif
}
return 0;
}
break;
}
break;
-// case GROUP_IMPORT_EXPORT:
-// switch (itemIndex)
-// {
-// case IMPORT_EXPORT_ITEM_IMPORT:
-// pItem = CreateImportItemN(itemWidth);
-// break;
+#ifdef _ENABLE_IMPORT_EXPORT_
+ case GROUP_IMPORT_EXPORT:
+ switch (itemIndex)
+ {
+ case IMPORT_EXPORT_ITEM_IMPORT:
+ pItem = CreateImportItemN(itemWidth);
+ break;
// case IMPORT_EXPORT_ITEM_EXPORT:
// pItem = CreateExportItemN(itemWidth);
// break;
-// }
-// break;
+ }
+ break;
+#endif
}
return pItem;
bool
SettingForm::HasSectionHeader(int sectionIndex)
{
- return false;
+ if (sectionIndex == 0)
+ {
+ return false;
+ }
+ return true;
}
String
SettingForm::GetSectionFooter(int sectionIndex)
{
- switch (sectionIndex)
- {
+// switch (sectionIndex)
+// {
// case GROUP_LOCK_TIME_ZONE:
// if (__isLockTimeZoneSet == false)
// {
// return ResourceManager::GetString(IDS_CLD_BODY_LOCK_TIME_ZONE_DESCRIPTION_MSG);
// }
// break;
- case GROUP_FIRST_DAY_OF_WEEK:
- break;
-// case GROUP_IMPORT_EXPORT:
-// break;
- }
+// }
return L"";
}
bool
SettingForm::HasSectionFooter(int sectionIndex)
{
- switch (sectionIndex)
- {
+// switch (sectionIndex)
+// {
// case GROUP_LOCK_TIME_ZONE:
// return __isLockTimeZoneSet == false;
- case GROUP_FIRST_DAY_OF_WEEK:
- break;
-// case GROUP_IMPORT_EXPORT:
-// break;
- }
+// }
return false;
}
}
}
break;
+#ifdef _ENABLE_IMPORT_EXPORT_
+ case GROUP_IMPORT_EXPORT:
+ switch (itemIndex)
+ {
+ case IMPORT_EXPORT_ITEM_IMPORT:
+ {
+ String mimeType = MIME_TYPE_VCALENDAR;
+ AppControl* pApp = AppManager::FindAppControlN(AppId(L"tizen.filemanager"), ID_OPERATION_PICK);
+ if (pApp != null)
+ {
+ pApp->Start(null, &mimeType, null, this);
+ delete pApp;
+ }
+
+ // Todo: Change upper codes to below codes.
+// String mimeType = MIME_TYPE_VCALENDAR;
+// AppControl::FindAndStart(ID_OPERATION_PICK, null, &mimeType, null, null, this);
+ break;
+ }
+// case IMPORT_EXPORT_ITEM_EXPORT:
+// break;
+ }
+ break;
+#endif
}
break;
case TABLE_VIEW_ITEM_STATUS_CHECKED:
__pTableView->SetItemChecked(GROUP_FIRST_DAY_OF_WEEK, FIRST_DAY_OF_WEEK_ITEM_MONDAY, true);
}
}
+
+ delete pArgs;
}
void
const wchar_t* ID_OPERATION_SOCIAL_PICK = L"http://tizen.org/appcontrol/operation/social/pick";
const wchar_t* ID_OPERATION_SOCIAL_VIEW = L"http://tizen.org/appcontrol/operation/social/view";
+const wchar_t* MIME_TYPE_DIRECTORY = L"inode/directory";
const wchar_t* MIME_TYPE_VCALENDAR = L"text/x-vcalendar";
const wchar_t* KEY_DATA_PATH = L"http://tizen.org/appcontrol/data/path";
+const wchar_t* KEY_DATA_SELECTED = L"http://tizen.org/appcontrol/data/selected";
const wchar_t* KEY_DATA_SELECTION_MODE = L"http://tizen.org/appcontrol/data/selection_mode";
const wchar_t* KEY_DATA_RETURN_RESULT = L"http://tizen.org/appcontrol/data/return_result";
result
VcsSelectorForm::OnTerminating(void)
{
+ delete __pList;
delete __pContextMenuSub;
delete __pDateTimeFormatter;
delete __pDateFormatter;
__pContextMenuSub->Show();
break;
case IDA_VCS_SELECTOR_FORM_SUB_MENU_ADD_TO_CALENDAR:
- SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_IMPORT, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), __pList);
+ {
+ ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
+ pArgs->Construct(__pList->GetCount());
+ IEnumerator* pEnum = __pList->GetEnumeratorN();
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ if (dynamic_cast<CalEvent*>(pEnum->GetCurrent()) != null)
+ {
+ pArgs->Add(new (std::nothrow) CalEvent(static_cast<CalEvent&>(*pEnum->GetCurrent())));
+ }
+ else if (dynamic_cast<CalTodo*>(pEnum->GetCurrent()) != null)
+ {
+ pArgs->Add(new (std::nothrow) CalTodo(static_cast<CalTodo&>(*pEnum->GetCurrent())));
+ }
+ }
+ delete pEnum;
+ SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_IMPORT, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
break;
}
+ }
}
void
}
else if (dynamic_cast<CalEvent*>(pArgs->GetAt(0)) != null || dynamic_cast<CalTodo*>(pArgs->GetAt(0)) != null)
{
+ delete __pList;
__pList = pArgs;
pArgs = null;
}