2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file EmMailListForm.cpp
19 * @brief Keeps the implementation of Inbox Form
22 #include "EmEmailApp.h"
23 #include "EmMailListForm.h"
24 #include "EmEmailSettingPresentationModel.h"
25 #include "EmStateInfo.h"
27 using namespace Tizen::App;
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Io;
32 using namespace Tizen::Locales;
33 using namespace Tizen::System;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Animations;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
39 MailListForm::MailListForm(void)
43 , __downloadAttachments(0)
46 , __headerTouchPosition(-1)
47 , __waitForDelete(false)
48 , __waitForMove(false)
49 , __futureAction(EmailTypesNS::NONE)
50 , __userCancelledAttachmentDownload(false)
51 , __mailboxType(EMAIL_MAILBOX_TYPE_INBOX)
52 , __mailboxViewType(INBOX_VIEW)
53 , __pFolderContextMenuItemsList(null)
54 , __pAttachmentDownloadHandleMap(null)
56 , __pDeleteAllIcon(null)
57 , __pAddAccountIcon(null)
58 , __pMarkReadUnreadIcon(null)
60 , __pAllAccountsIcon(null)
61 , __pHeaderAllAccountsIcon(null)
62 , __pFavouriteIcon(null)
63 , __pSortByPopupCloseButton(null)
64 , __pMarkAllAsPopupCloseButton(null)
65 , __pSetAllAsPopupCancelButton(null)
66 , __pMoreOptionMenu(null)
67 , __pFolderContextMenu(null)
68 , __pAccountsContextMenu(null)
69 , __pMailGroupedListView(null)
70 , __pSelectedLabel(null)
71 , __pSortByListView(null)
72 , __pMarkAllAsListView(null)
73 , __pSetAllAsListView(null)
74 , __pAccountsListView(null)
75 , __pAccountsListPanel(null)
76 , __pSortByPopup(null)
77 , __pMarkAllAsPopup(null)
78 , __pSetAllAsPopup(null)
79 , __pDeleteConfirmationPopup(null)
80 , __pAttachmentDownloadFailedPopup(null)
81 , __pMoveOrDeleteFailedPopup(null)
82 , __pProgressPopup(null)
83 , __pDownloadAttachmentsPopup(null)
84 , __pSortByListViewItemProvider(null)
85 , __pMarkAllAsListViewItemProvider(null)
86 , __pSetAllAsListViewItemProvider(null)
87 , __pBaseListViewItemProvider(null)
88 , __pPresentationModel(null)
90 , __viewByType(SORT_BY_DATE)
92 __pPresentationModel = InboxPresentationModel::GetInstance();
95 MailListForm::~MailListForm(void)
97 // Empty Implementation
101 MailListForm::Initialize(void)
103 AppLogDebug("ENTER");
105 result r = Construct(IDL_INBOX_LIST_FORM);
107 AppLogDebug("EXIT: r = %s", GetErrorMessage(r));
112 MailListForm::InitMoreOptionMenu(void)
114 AppLogDebug("ENTER");
116 __pMoreOptionMenu = new (std::nothrow) OptionMenu();
117 __pMoreOptionMenu->Construct();
118 __pMoreOptionMenu->AddActionEventListener(*this);
119 __pMoreOptionMenu->SetShowState(false);
125 MailListForm::InitFolderContextMenu(void)
127 AppLogDebug("ENTER");
131 Footer* pFooter = GetFooter();
136 pFooter->AddActionEventListener(*this);
137 pFooter->GetPosition(xPosition, yPosition);
138 tmpRect = pFooter->GetButtonBounds(BUTTON_POSITION_RIGHT);
140 xPosition = xPosition + (2*pFooter->GetWidth()/3);
143 __pFolderContextMenu = new (std::nothrow) ContextMenu();
144 __pFolderContextMenu->Construct(Point(xPosition,yPosition), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
145 __pFolderContextMenu->SetAnchorPosition(Point(xPosition, yPosition));
146 __pFolderContextMenu->AddActionEventListener(*this);
147 __pFolderContextMenu->SetShowState(false);
153 MailListForm::InitAccountsContextMenu(void)
155 AppLogDebug("ENTER");
157 __pAccountsContextMenu = new (std::nothrow) ContextMenu();
158 __pAccountsContextMenu->Construct(Point(0, GetHeader()->GetHeight()), CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_AUTO);
159 __pAccountsContextMenu->AddActionEventListener(*this);
160 __pAccountsContextMenu->SetShowState(false);
166 MailListForm::InitDeleteConfirmationPopup(void)
168 AppLogDebug("ENTER");
170 __pDeleteConfirmationPopup = new (std::nothrow) Popup();
171 __pDeleteConfirmationPopup->Construct(L"IDL_POPUP_DELETE");
172 __pDeleteConfirmationPopup->SetPropagatedKeyEventListener(this);
174 Button* pDeleteButton = static_cast<Button*>(__pDeleteConfirmationPopup->GetControl(L"IDC_BUTTON_DELETE", true));
175 pDeleteButton->AddActionEventListener(*this);
176 pDeleteButton->SetActionId(IDA_INBOX_FORM_DELETE_CONFIRMATION_YES);
178 Button* pCancelButton = static_cast<Button*>(__pDeleteConfirmationPopup->GetControl(L"IDC_BUTTON_CANCEL", true));
179 pCancelButton->AddActionEventListener(*this);
180 pCancelButton->SetActionId(IDA_INBOX_FORM_DELETE_CONFIRMATION_NO);
186 MailListForm::InitAttachmentDownloadFailedPopup(void)
188 AppLogDebug("ENTER");
190 __pAttachmentDownloadFailedPopup = new Popup();
191 __pAttachmentDownloadFailedPopup->Construct(L"IDL_POPUP_ATTACHMENT_FAILED");
193 Button* pOkButton = static_cast<Button*>(__pAttachmentDownloadFailedPopup->GetControl(L"IDC_BUTTON_OK", true));
194 pOkButton->AddActionEventListener(*this);
195 pOkButton->SetActionId(IDA_ATTACHMENT_DOWNLOAD_FAILED_OK);
201 MailListForm::InitMoveOrDeleteFailedPopup(void)
203 AppLogDebug("ENTER");
205 __pMoveOrDeleteFailedPopup = new Popup();
206 __pMoveOrDeleteFailedPopup->Construct(L"IDL_POPUP_MOVE_OR_DELETE_FAILED");
208 Button* pOkButton = static_cast<Button*>(__pMoveOrDeleteFailedPopup->GetControl(L"IDC_BUTTON_OK", true));
209 pOkButton->AddActionEventListener(*this);
210 pOkButton->SetActionId(IDA_MOVE_OR_DELETE_FAILED_OK);
216 MailListForm::SetDeleteConfirmationPopupTitle(const String& title)
218 AppLogDebug("ENTER, title:(%ls)", title.GetPointer());
220 if (__pDeleteConfirmationPopup == null)
222 InitDeleteConfirmationPopup();
225 Label* pTitleLabel = static_cast<Label*>(__pDeleteConfirmationPopup->GetControl(L"IDC_LABEL_TITLE", true));
226 pTitleLabel->SetText(title);
232 MailListForm::SetMoveOrDeleteFailedPopupTitle(const String& title)
234 AppLogDebug("ENTER, title:(%ls)", title.GetPointer());
236 if (__pMoveOrDeleteFailedPopup == null)
238 InitMoveOrDeleteFailedPopup();
241 Label* pTitleLabel = static_cast<Label*>(__pMoveOrDeleteFailedPopup->GetControl(L"IDC_LABEL_TITLE", true));
242 pTitleLabel->SetText(title);
248 MailListForm::LoadIcons(void)
250 AppLogDebug("ENTER");
252 result r = E_SUCCESS;
254 __pSortByIcon = AppResource::GetInstance()->GetBitmapN(IDB_SORT_BY);
256 TryCatch(r == E_SUCCESS, , "[%s] Failed to get Sort by icon", GetErrorMessage(r));
258 __pDeleteAllIcon = AppResource::GetInstance()->GetBitmapN(IDB_DELETE_ALL);
260 TryCatch(r == E_SUCCESS, , "[%s] Failed to get Delete all icon", GetErrorMessage(r));
262 __pAddAccountIcon = AppResource::GetInstance()->GetBitmapN(IDB_ADD_ACCOUNT);
264 TryCatch(r == E_SUCCESS, , "[%s] Failed to get Add account icon", GetErrorMessage(r));
266 __pSettingsIcon = AppResource::GetInstance()->GetBitmapN(IDB_SETTINGS);
268 TryCatch(r == E_SUCCESS, , "[%s] Failed to get Add account icon", GetErrorMessage(r));
270 __pMarkReadUnreadIcon = AppResource::GetInstance()->GetBitmapN(IDB_MARK_UNREAD);
272 TryCatch(r == E_SUCCESS, , "[%s] Failed to get mark as unread icon", GetErrorMessage(r));
274 __pBlockIcon = AppResource::GetInstance()->GetBitmapN(IDB_BLOCK);
276 TryCatch(r == E_SUCCESS, , "[%s] Failed to get block icon", GetErrorMessage(r));
278 __pAllAccountsIcon = AppResource::GetInstance()->GetBitmapN(IDB_ALL_ACCOUNTS);
280 TryCatch(r == E_SUCCESS, , "[%s] Failed to get all accounts icon", GetErrorMessage(r));
282 __pHeaderAllAccountsIcon = AppResource::GetInstance()->GetBitmapN(IDB_HEADER_ALL_ACCOUNTS_ICON);
284 TryCatch(r == E_SUCCESS, , "[%s] Failed to get all accounts headericon", GetErrorMessage(r));
286 __pFavouriteIcon = AppResource::GetInstance()->GetBitmapN(IDB_FAVOURITES);
288 TryCatch(r == E_SUCCESS, , "[%s] Failed to get favourites icon", GetErrorMessage(r));
296 MailListForm::OnInitializing(void)
298 AppLogDebug("ENTER");
300 result r = E_SUCCESS;
301 Rectangle clientRect = GetClientAreaBounds();
302 Header* pHeader = GetHeader();
304 SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
305 AddOrientationEventListener(*this);
309 pHeader->AddActionEventListener(*this);
310 pHeader->AddTouchEventListener(*this);
313 SetFormBackEventListener(this);
314 SetFormMenuEventListener(this);
316 __pBaseListViewItemProvider = new (std::nothrow) EmailBaseListViewItemProvider(__pPresentationModel, false);
317 TryCatch(__pBaseListViewItemProvider != null, r = E_FAILURE,"Failed to create Grouped listview item provider");
319 __pMailGroupedListView = dynamic_cast<GroupedListView*>(GetControl(IDC_INBOX_GROUPEDLISTVIEW));
320 TryCatch(__pMailGroupedListView != null, r = E_FAILURE,"Failed to get Grouped listview");
322 __pMailGroupedListView->AddGroupedListViewItemEventListener(*this);
324 __pSelectedLabel = dynamic_cast<Label*>(GetControl(IDC_INBOX_SELECTED_LABEL));
325 TryCatch(__pSelectedLabel != null, r = E_FAILURE,"Failed to get selected label");
327 __pSelectedLabel->SetShowState(false);
329 __pAccountsListPanel = dynamic_cast<Panel*>(GetControl(IDC_INBOX_ACCOUNTS_LIST_PANEL));
330 TryCatch(__pAccountsListPanel != null, r = E_FAILURE,"Failed to get accounts list panel");
332 __pAccountsListPanel->AddTouchEventListener(*this);
333 __pAccountsListPanel->SetShowState(false);
335 __pAccountsListView = dynamic_cast<ListView*>(GetControl(IDC_INBOX_ACCOUNTS_LISTVIEW, true));
336 TryCatch(__pAccountsListView != null, r = E_FAILURE,"Failed to get accounts list view");
338 __pAccountsListView->AddListViewItemEventListener(*this);
340 __pFolderContextMenuItemsList = new (std::nothrow) ArrayList();
341 TryCatch(__pFolderContextMenuItemsList != null, r = E_FAILURE,"Failed to create folder context menu items map");
343 r = __pFolderContextMenuItemsList->Construct();
344 TryCatch(r == E_SUCCESS, r = E_FAILURE,"Failed to construct folder context menu items map");
346 __pFolderContextMenuItemsList->InsertAt(new (std::nothrow) String(Utils::GetResourceString(L"IDS_EMAIL_BODY_INBOX")) , INBOX_VIEW);
347 // __pFolderContextMenuItemsList->InsertAt(new (std::nothrow) String(L"Starred"), FAVORITES_VIEW);
348 __pFolderContextMenuItemsList->InsertAt(new (std::nothrow) String(Utils::GetResourceString(L"IDS_EMAIL_BODY_DRAFTS")) , DRAFTS_VIEW);
349 __pFolderContextMenuItemsList->InsertAt(new (std::nothrow) String(Utils::GetResourceString(L"IDS_EMAIL_BODY_SENTBOX")) , SENTBOX_VIEW);
350 __pFolderContextMenuItemsList->InsertAt(new (std::nothrow) String(Utils::GetResourceString(L"IDS_EMAIL_BODY_SHOW_ALL_FOLDERS_ABB")), ALL_FOLDERS_VIEW);
352 __pProgressPopup = new (std::nothrow) ProgressPopup();
353 __pProgressPopup->Construct(false, false);
355 SetControlAlwaysOnTop(*__pSelectedLabel, true);
358 TryCatch(r == E_SUCCESS, r = E_FAILURE, "Load icons failed");
359 __pMailGroupedListView->SetSize(clientRect.width, clientRect.height);
361 InitFolderContextMenu();
362 InitAccountsContextMenu();
363 __prevOrientation = GetOrientationStatus();
370 MailListForm::OnTerminating(void)
372 AppLogDebug("ENTER");
373 result r = E_SUCCESS;
375 if (__pAccountsContextMenu != null)
377 __pAccountsContextMenu->RemoveAllControls();
378 delete __pAccountsContextMenu;
379 __pAccountsContextMenu = null;
382 delete __pSortByIcon;
383 delete __pDeleteAllIcon;
384 delete __pAddAccountIcon;
385 delete __pAllAccountsIcon;
386 delete __pHeaderAllAccountsIcon;
387 delete __pMarkReadUnreadIcon;
389 delete __pFavouriteIcon;
390 delete __pSettingsIcon;
392 __pFolderContextMenuItemsList->RemoveAll(true);
393 delete __pFolderContextMenuItemsList;
395 delete __pProgressPopup;
396 __pProgressPopup = null;
398 if (__pBaseListViewItemProvider != null)
400 delete __pBaseListViewItemProvider;
401 __pBaseListViewItemProvider = null;
404 if (__pFolderContextMenu != null)
406 __pFolderContextMenu->RemoveAllItems();
407 delete __pFolderContextMenu;
408 __pFolderContextMenu = null;
411 if (__pMoreOptionMenu != null)
413 __pMoreOptionMenu->RemoveAllItems();
414 delete __pMoreOptionMenu;
415 __pMoreOptionMenu = null;
418 if (__pDownloadAttachmentsPopup != null)
420 delete __pDownloadAttachmentsPopup;
421 __pDownloadAttachmentsPopup = null;
424 if (__pSortByPopup != null)
426 __pSortByPopup->RemoveAllControls();
427 delete __pSortByPopup;
428 __pSortByPopup = null;
431 if (__pSortByListViewItemProvider != null)
433 delete __pSortByListViewItemProvider;
434 __pSortByListViewItemProvider = null;
437 if (__pMarkAllAsPopup != null)
439 __pMarkAllAsPopup->RemoveAllControls();
440 delete __pMarkAllAsPopup;
441 __pMarkAllAsPopup = null;
444 if (__pMarkAllAsListViewItemProvider != null)
446 delete __pMarkAllAsListViewItemProvider;
447 __pMarkAllAsListViewItemProvider = null;
450 if (__pSetAllAsPopup != null)
452 __pSetAllAsPopup->RemoveAllControls();
453 delete __pSetAllAsPopup;
454 __pSetAllAsPopup = null;
457 if (__pSetAllAsListViewItemProvider != null)
459 delete __pSetAllAsListViewItemProvider;
460 __pSetAllAsListViewItemProvider = null;
463 if (__pDeleteConfirmationPopup != null)
465 __pDeleteConfirmationPopup->RemoveAllControls();
466 delete __pDeleteConfirmationPopup;
467 __pDeleteConfirmationPopup = null;
470 if (__pAttachmentDownloadFailedPopup != null)
472 __pAttachmentDownloadFailedPopup->RemoveAllControls();
473 delete __pAttachmentDownloadFailedPopup;
474 __pAttachmentDownloadFailedPopup = null;
477 AppLogDebug("EXIT : r = %s", GetErrorMessage(r));
482 MailListForm::CreateSortByPopup(void)
484 AppLogDebug("ENTER");
485 result r = E_SUCCESS;
487 /*-- 'Sort by' popup and child controls --*/
488 __pSortByPopup = new (std::nothrow) Popup();
489 TryCatch(__pSortByPopup != null, r = E_FAILURE,"Failed to create view as popup");
491 r = __pSortByPopup->Construct(true, Dimension(W_VIEW_AS_POPUP, H_VIEW_AS_POPUP));
492 TryCatch(r == E_SUCCESS, r = E_FAILURE,"[%s] Failed to construct view as popup", GetErrorMessage(r));
493 __pSortByPopup->SetPropagatedKeyEventListener(this);
495 __pSortByPopup->SetTitleText(Utils::GetResourceString(L"IDS_EMAIL_OPT_VIEW"));
497 __pSortByListViewItemProvider = new (std::nothrow) SortByListViewItemProvider();
498 __pSortByListViewItemProvider->SetEventListener(this);
500 __pSortByPopupCloseButton = new (std::nothrow) Button();
501 TryCatch(__pSortByPopupCloseButton != null, r = E_FAILURE,"Failed to create popup close button");
503 r = __pSortByPopupCloseButton->Construct(Rectangle(0, 0, W_POPUP_CLOSE_BUTTON, H_POPUP_CLOSE_BUTTON), Utils::GetResourceString(L"IDS_EMAIL_SK3_CANCEL"));
504 TryCatch(r == E_SUCCESS, r = E_FAILURE, "[%s] Failed to construct popup close button", GetErrorMessage(r));
506 __pSortByPopupCloseButton->SetActionId(IDA_INBOX_FORM_BTN_POPUP_CANCEL);
507 __pSortByPopupCloseButton->AddActionEventListener(*this);
508 __pSortByPopup->AddControl(__pSortByPopupCloseButton);
510 __pSortByListView = new (std::nothrow) ListView();
511 TryCatch(__pSortByListView != null, r = GetLastResult(), "Failed to create ListView Control For Popup");
513 r = __pSortByListView->Construct(Rectangle(0, 0, W_VIEW_AS_POPUP, H_VIEW_AS_POPUP), true, SCROLL_STYLE_FADE_OUT);
514 TryCatch(r == E_SUCCESS, r = E_FAILURE, "[%s] Failed to construct SortBy ListView", GetErrorMessage(r));
516 __pSortByListView->AddListViewItemEventListener(*__pSortByListViewItemProvider);
517 __pSortByListView->SetItemProvider(*__pSortByListViewItemProvider);
518 __pSortByPopup->AddControl(__pSortByListView);
526 MailListForm::CreateMarkAllAsPopup(void)
528 AppLogDebug("ENTER");
529 result r = E_SUCCESS;
531 /*-- Popup and child controls of 'Mark all as' popup --*/
532 __pMarkAllAsPopup = new (std::nothrow) Popup();
533 TryCatch(__pMarkAllAsPopup != null, r = E_FAILURE,"Failed to create mark all as popup");
535 r = __pMarkAllAsPopup->Construct(true, Dimension(W_VIEW_AS_POPUP, H_MARK_ALL_AS_POPUP));
536 TryCatch(r == E_SUCCESS, r = E_FAILURE,"[%s] Failed to construct mark all as popup", GetErrorMessage(r));
537 __pMarkAllAsPopup->SetPropagatedKeyEventListener(this);
539 __pMarkAllAsPopup->SetTitleText(Utils::GetResourceString(L"IDS_EMAIL_OPT_MARK_ALL_AS_ABB"));
541 __pMarkAllAsListViewItemProvider = new (std::nothrow) MarkAllAsListViewItemProvider();
542 __pMarkAllAsListViewItemProvider->SetEventListener(this);
544 __pMarkAllAsPopupCloseButton = new (std::nothrow) Button();
545 TryCatch(__pMarkAllAsPopupCloseButton != null, r = E_FAILURE,"Failed to create mark all as popup close button");
547 r = __pMarkAllAsPopupCloseButton->Construct(Rectangle(0, 0, W_POPUP_CLOSE_BUTTON, H_POPUP_CLOSE_BUTTON), Utils::GetResourceString(L"IDS_EMAIL_SK3_CANCEL"));
548 TryCatch(r == E_SUCCESS, r = E_FAILURE, "[%s] Failed to construct mark all as popup close button", GetErrorMessage(r));
550 __pMarkAllAsPopupCloseButton->SetActionId(IDA_INBOX_FORM_BTN_MARK_ALL_AS_POPUP_CLOSE);
551 __pMarkAllAsPopupCloseButton->AddActionEventListener(*this);
552 __pMarkAllAsPopup->AddControl(__pMarkAllAsPopupCloseButton);
554 __pMarkAllAsListView = new (std::nothrow) ListView();
555 TryCatch(__pMarkAllAsListView != null, r = GetLastResult(), "Failed to create ListView Control For Mark all as Popup");
557 r = __pMarkAllAsListView->Construct(Rectangle(0, 0, W_VIEW_AS_POPUP, H_MARK_ALL_AS_POPUP), true, SCROLL_STYLE_FADE_OUT);
558 TryCatch(r == E_SUCCESS, r = E_FAILURE, "[%s] Failed to construct Mark all as ListView", GetErrorMessage(r));
560 __pMarkAllAsListView->AddListViewItemEventListener(*__pMarkAllAsListViewItemProvider);
561 __pMarkAllAsListView->SetItemProvider(*__pMarkAllAsListViewItemProvider);
562 __pMarkAllAsPopup->AddControl(__pMarkAllAsListView);
570 MailListForm::CreateSetAllAsPopup(void)
572 AppLogDebug("ENTER");
573 result r = E_SUCCESS;
575 /*-- Popup and child controls of 'Set all as' popup --*/
576 __pSetAllAsPopup = new (std::nothrow) Popup();
577 TryCatch(__pSetAllAsPopup != null, r = E_FAILURE,"Failed to create set all as popup");
579 r = __pSetAllAsPopup->Construct(true, Dimension(W_VIEW_AS_POPUP, H_MARK_ALL_AS_POPUP));
580 TryCatch(r == E_SUCCESS, r = E_FAILURE,"[%s] Failed to construct set all as popup", GetErrorMessage(r));
581 __pSetAllAsPopup->SetPropagatedKeyEventListener(this);
583 __pSetAllAsPopup->SetTitleText(Utils::GetResourceString(L"IDS_EMAIL_OPT_SET_ALL_AS_ABB"));
585 __pSetAllAsListViewItemProvider = new (std::nothrow) SetAllAsListViewItemProvider();
586 __pSetAllAsListViewItemProvider->SetEventListener(this);
588 __pSetAllAsPopupCancelButton = new (std::nothrow) Button();
589 TryCatch(__pSetAllAsPopupCancelButton != null, r = E_FAILURE,"Failed to create set all as popup cancel button");
591 r = __pSetAllAsPopupCancelButton->Construct(Rectangle(0, 0, W_POPUP_CLOSE_BUTTON, H_POPUP_CLOSE_BUTTON), Utils::GetResourceString(L"IDS_EMAIL_SK3_CANCEL"));
592 TryCatch(r == E_SUCCESS, r = E_FAILURE, "[%s] Failed to construct set all as popup cancel button", GetErrorMessage(r));
594 __pSetAllAsPopupCancelButton->SetActionId(IDA_INBOX_FORM_BTN_SET_ALL_AS_POPUP_CANCEL);
595 __pSetAllAsPopupCancelButton->AddActionEventListener(*this);
596 __pSetAllAsPopup->AddControl(__pSetAllAsPopupCancelButton);
598 __pSetAllAsListView = new (std::nothrow) ListView();
599 TryCatch(__pSetAllAsListView != null, r = GetLastResult(), "Failed to create ListView Control For Set all as Popup");
601 r = __pSetAllAsListView->Construct(Rectangle(0, 0, W_VIEW_AS_POPUP, H_MARK_ALL_AS_POPUP), true, SCROLL_STYLE_FADE_OUT);
602 TryCatch(r == E_SUCCESS, r = E_FAILURE, "[%s] Failed to construct Set all as ListView", GetErrorMessage(r));
604 __pSetAllAsListView->AddListViewItemEventListener(*__pSetAllAsListViewItemProvider);
605 __pSetAllAsListView->SetItemProvider(*__pSetAllAsListViewItemProvider);
606 __pSetAllAsPopup->AddControl(__pSetAllAsListView);
614 MailListForm::UnCheckAllListviewItems(void)
616 AppLogDebug("ENTER");
619 int groupCount = __pMailGroupedListView->GetGroupCount();
621 for (int i=0; i<groupCount; i++)
623 itemCount = __pMailGroupedListView->GetItemCountAt(i);
625 for (int j=0; j<itemCount; j++)
627 if (__pMailGroupedListView->IsItemChecked(i, j) == true)
629 __pMailGroupedListView->SetItemChecked(i, j, false);
638 MailListForm::CheckSelectedListviewItems(void)
640 AppLogDebug("ENTER");
643 int groupCount = __pMailGroupedListView->GetGroupCount();
644 EmailMessageListItem* pMail = null;
645 HashMap* pSelectedMailsMap = new (std::nothrow) HashMap();
646 pSelectedMailsMap->Construct();
648 for (int i = 0; i < __pPresentationModel->GetNumberOfSelectedItems(); i++)
650 pMail = __pPresentationModel->GetSelectedMailAtIndex(i);
651 mailId = pMail->GetMailId();
652 pSelectedMailsMap->Add(new (std::nothrow) Integer(mailId), new (std::nothrow) Integer(mailId));
655 __pPresentationModel->ClearSelectedMailList();
657 for (int groupIndex = 0; groupIndex < groupCount; groupIndex++)
659 itemCount = __pMailGroupedListView->GetItemCountAt(groupIndex);
661 for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
663 pMail = __pPresentationModel->GetMailData(groupIndex, itemIndex);
664 mailId = pMail->GetMailId();
666 AppLogDebug("Got mailId:(%d)", mailId);
667 if (pSelectedMailsMap->ContainsKey(Integer(mailId)))
669 AppLogDebug("Setting groupIndex:(%d), itemIndex:(%d) to checked state", groupIndex, itemIndex);
670 __pMailGroupedListView->SetItemChecked(groupIndex, itemIndex, true);
671 __pPresentationModel->AddSelectedMail(groupIndex, itemIndex);
676 pSelectedMailsMap->RemoveAll(true);
677 delete pSelectedMailsMap;
683 MailListForm::OnFormBackRequested(Form& source)
685 AppLogDebug("ENTER");
686 result r = E_SUCCESS;
688 if (__pAccountsListPanel->GetShowState() == false)
690 if (__mode == NORMAL_MODE)
692 if (__accountId != -1)
694 if (__mailboxType == EMAIL_MAILBOX_TYPE_USER_DEFINED || __mailboxType == EMAIL_MAILBOX_TYPE_ALL_EMAILS || __mailboxType == EMAIL_MAILBOX_TYPE_SEARCH_RESULT || __mailboxType == EMAIL_MAILBOX_TYPE_FLAGGED)
696 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
700 __pPresentationModel->FetchData(__accountId);
705 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
708 __pPresentationModel->SortBy(SORT_BY_DATE);
709 r = Scenes::SceneManager::GetInstance()->GoBackward(BackwardSceneTransition());
711 if (r == E_UNDERFLOW)
713 App::GetInstance()->Terminate();
716 else if (__mode == EDIT_MODE)
718 UnCheckAllListviewItems();
719 GoToNormalMode(false);
720 __pPresentationModel->ClearSelectedMailList();
725 Header* pHeader = GetHeader();
727 if (__mode != EDIT_MODE)
729 pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
732 pHeader->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
733 GetFooter()->SetEnabled(true);
735 __pMailGroupedListView->SetEnabled(true);
736 __pAccountsListPanel->SetShowState(false);
738 GetFooter()->Invalidate(true);
739 pHeader->Invalidate(true);
746 MailListForm::OnFormMenuRequested(Form& source)
748 AppLogDebug("ENTER");
750 if (__pAccountsListPanel->GetShowState() == false)
752 __pPresentationModel->SetSelectionModes();
754 if (__pMoreOptionMenu == null)
756 InitMoreOptionMenu();
759 PopulateMoreOptionMenu(__mode, __pPresentationModel->GetSelectionMode(), __pPresentationModel->GetFavouriteSelectionMode());
760 __pMoreOptionMenu->SetShowState(true);
761 __pMoreOptionMenu->Show();
768 MailListForm::GoToEditMode(void)
770 FooterItem deleteItem;
774 GetFooter()->RemoveAllItems();
775 deleteItem.Construct(IDA_INBOX_FORM_FOOTER_DELETE_BUTTON);
776 deleteItem.SetText(Utils::GetResourceString(L"IDS_EMAIL_HEADER_DELETE"));
777 GetFooter()->InsertItemAt(0, deleteItem);
779 if (__mailboxType != EMAIL_MAILBOX_TYPE_DRAFT && __mailboxType != EMAIL_MAILBOX_TYPE_OUTBOX)
781 moveItem.Construct(IDA_INBOX_FORM_FOOTER_MOVE_BUTTON);
782 moveItem.SetText(Utils::GetResourceString(L"IDS_EMAIL_SK_MOVE"));
783 GetFooter()->InsertItemAt(1, moveItem);
786 GetHeader()->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
787 ControlAnimator* pAnimator = __pSelectedLabel->GetControlAnimator();
788 pAnimator->StopAllAnimations();
789 result r = pAnimator->StartUserAnimation(ANIMATION_TARGET_ALPHA, IntegerAnimation(0, 1, 250, ANIMATION_INTERPOLATOR_LINEAR));
790 AppLogDebug("EmailApp: Error message in StartUserAnimation %s", GetErrorMessage(r));
792 __pMailGroupedListView->SetSize(__pMailGroupedListView->GetWidth(), this->GetClientAreaBounds().height -__pSelectedLabel->GetHeight());
798 MailListForm::GoToNormalMode(bool animationFlag)
800 AppLogDebug("ENTER, flag:(%d)", animationFlag);
802 FooterItem composeItem;
803 FooterItem folderItem;
805 __mode = NORMAL_MODE;
807 GetFooter()->RemoveAllItems();
808 composeItem.Construct(IDA_INBOX_FORM_FOOTER_COMPOSE_BUTTON);
809 composeItem.SetText(Utils::GetResourceString(L"IDS_EMAIL_SK_COMPOSE"));
811 folderItem.Construct(IDA_INBOX_FORM_FOOTER_FOLDER_BUTTON);
812 folderItem.SetText(Utils::GetResourceString(L"IDS_EMAIL_HEADER_FOLDERS"));
814 GetFooter()->InsertItemAt(0, composeItem);
815 GetFooter()->InsertItemAt(1, folderItem);
817 if (__pAccountsListPanel->GetShowState() == false)
819 GetHeader()->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
824 ControlAnimator* pAnimator = __pSelectedLabel->GetControlAnimator();
825 pAnimator->StopAllAnimations();
826 result r = pAnimator->StartUserAnimation(ANIMATION_TARGET_ALPHA, IntegerAnimation(1, 0, 250, ANIMATION_INTERPOLATOR_LINEAR));
827 AppLogDebug("Result of StartUserAnimation %s", GetErrorMessage(r));
831 __pSelectedLabel->SetShowState(false);
834 __pMailGroupedListView->SetSize(__pMailGroupedListView->GetWidth(), this->GetClientAreaBounds().height);
842 MailListForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus status)
844 AppLogDebug("ENTER, groupIndex:(%d), itemIndex:(%d), elementId:(%d), status:(%d)", groupIndex, itemIndex, elementId, status);
846 EmailMessageListItem* pMail = null;
847 ArrayList* pArgs = null;
848 AppLogDebug("Item status:(%d), elementId:(%d)", status, elementId);
850 if (elementId == IDA_BASE_LISTVIEW_ITEM_PROVIDER_EMPTY_ELEMENT ||
851 elementId == IDA_BASE_LISTVIEW_ITEM_PROVIDER_SUBJECT_ELEMENT ||
852 elementId == IDA_BASE_LISTVIEW_ITEM_PROVIDER_RECIPIENT_ELEMENT ||
853 elementId == IDA_BASE_LISTVIEW_ITEM_PROVIDER_MESSAGE_ELEMENT ||
854 elementId == IDA_BASE_LISTVIEW_ITEM_PROVIDER_DATE_ELEMENT ||
855 elementId == IDA_BASE_LISTVIEW_ITEM_PROVIDER_ATTACH_ELEMENT)
857 pArgs = new (std::nothrow) ArrayList();
859 pMail = __pPresentationModel->GetMailData(groupIndex, itemIndex);
861 if (__mailboxType != EMAIL_MAILBOX_TYPE_DRAFT)
863 if (!pMail->isFlagsSeenField())
865 __pPresentationModel->SetFlag(groupIndex, itemIndex, EMAIL_FLAGS_SEEN_FIELD, true, true);
868 StateInfo* pStateInfo = new (std::nothrow) StateInfo();
869 pStateInfo->accountId = __accountId;
870 pStateInfo->mailboxId = __mailboxId;
871 pStateInfo->pPresentationModel = __pPresentationModel;
872 pStateInfo->mailboxType = __mailboxType;
873 pStateInfo->mailId = pMail->GetMailId();
874 pArgs->Add(pStateInfo);
876 Scenes::SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_EMAIL_DETAIL, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
880 EmailMessageItem* pDetailedMail = __pPresentationModel->GetCompleteMailDataN(pMail->GetMailId());
882 if (pDetailedMail != null && pDetailedMail->GetHasAttachment() == true && IsAttachmentDownload(pDetailedMail) == false)
884 __futureAction = EmailTypesNS::COMPOSE_AFTER_DOWNLOAD;
885 __groupIndex = groupIndex;
886 __itemIndex = itemIndex;
887 DownloadAllAttachments(pDetailedMail, EMAIL_DRAFT_DOWNLOAD);
889 else if (pDetailedMail != null)
896 StateInfo* pStateInfo = new (std::nothrow) StateInfo();
898 pStateInfo->accountId = __accountId;
899 pStateInfo->mailboxId = __mailboxId;
900 pStateInfo->pPresentationModel = __pPresentationModel;
901 pStateInfo->mailboxType = __mailboxType;
903 // pArgs->Add(new (std::nothrow) Integer(__accountId));
904 // pArgs->Add(new (std::nothrow) Integer(__mailboxId));
905 // pArgs->Add(__pPresentationModel);
906 // pArgs->Add(new (std::nothrow) Integer(__mailboxType));
908 Utils::BuildEmailIdStringFromFullAddress(pDetailedMail->GetFullAddressTo(), emailId);
909 // pArgs->Add(new (std::nothrow) String(emailId)); // to field
910 pStateInfo->toFieldValue = emailId;
912 Utils::BuildEmailIdStringFromFullAddress(pDetailedMail->GetFullAddressCc(), emailId);
913 // pArgs->Add(new (std::nothrow) String(emailId)); // cc field
914 pStateInfo->ccFieldValue = emailId;
916 Utils::BuildEmailIdStringFromFullAddress(pDetailedMail->GetFullAddressBcc(), emailId);
917 // pArgs->Add(new (std::nothrow) String(emailId)); // bcc field
918 pStateInfo->bccFieldValue = emailId;
920 // pArgs->Add(new (std::nothrow) String(pDetailedMail->GetSubject())); // subject field
921 pStateInfo->subjectFieldValue = pDetailedMail->GetSubject();
923 fileName.Append(pDetailedMail->GetFilePathPlain());
925 if (fileName.IsEmpty() == false)
928 result r = file.Construct(fileName, L"r");
932 while (file.Read(tmpText) == E_SUCCESS)
934 mailBody.Append(tmpText);
939 // pArgs->Add(new (std::nothrow) String(mailBody));
940 pStateInfo->bodyFieldValue = mailBody;
943 if (pDetailedMail->GetHasAttachment() == true)
946 EmailAttachment* pTmpAttachment = null;
947 ArrayList* pAttachmentList = __pPresentationModel->GetAllAttachmentListN(pMail->GetMailId());
949 for (int i=0; i<pAttachmentList->GetCount(); i++)
951 pTmpAttachment = static_cast<EmailAttachment*>(pAttachmentList->GetAt(i));
953 destFilePath.Clear();
954 destFilePath.Append(App::GetInstance()->GetAppSharedPath()+L"data/");
955 destFilePath.Append(pTmpAttachment->GetAttachmentName());
957 if (File::Copy(pTmpAttachment->GetAttachmentPath(), destFilePath, false) == E_SUCCESS)
959 EmailMailboxManager::GetInstance()->DeleteAttachment(pTmpAttachment->GetAttachmentId());
960 tmpText.Append(destFilePath);
961 tmpText.Append(IDS_DELIM_SEMICOLON);
965 // pArgs->Add(new (std::nothrow) String(tmpText));
966 pStateInfo->attachmentsPath = tmpText;
968 if (__pPresentationModel->IsMailSelected(pMail))
970 __pPresentationModel->RemoveMailFromSelectedMailList(pMail);
971 // pArgs->Add(new (std::nothrow) Boolean(true));
972 pStateInfo->isMailSelected = true;
975 pArgs->Add(pStateInfo);
977 EmailMailboxManager::GetInstance()->DeleteMailMessage(pMail->GetMailboxId(), pMail->GetMailId(), false);
979 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_EMAIL_COMPOSER, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
983 __pMailGroupedListView->SetItemChecked(groupIndex, itemIndex, false);
985 else if (elementId == IDA_INBOX_FORM_FORMAT_IMPORTANT)
987 pMail = __pPresentationModel->GetMailData(groupIndex, itemIndex);
989 if (pMail != null && pMail->isFlagsFlaggedField())
991 __pPresentationModel->SetFlag(pMail, EMAIL_FLAGS_FLAGGED_FIELD, false, true);
995 __pPresentationModel->SetFlag(pMail, EMAIL_FLAGS_FLAGGED_FIELD, true, true);
998 if (pMail != null && __pPresentationModel->IsMailSelected(pMail) == true)
1000 __pMailGroupedListView->SetItemChecked(groupIndex, itemIndex, true);
1004 __pMailGroupedListView->SetItemChecked(groupIndex, itemIndex, false);
1007 __pMailGroupedListView->RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1009 if (__pPresentationModel->GetSortType() == SORT_BY_IMPORTANT)
1011 if (__pPresentationModel->GetNumberOfSelectedItems() > 0)
1013 UnCheckAllListviewItems();
1016 __pPresentationModel->SortBy(SORT_BY_IMPORTANT);
1017 __pMailGroupedListView->UpdateList();
1019 if (__pPresentationModel->GetNumberOfSelectedItems() > 0)
1021 CheckSelectedListviewItems();
1025 else if (status == LIST_ITEM_STATUS_CHECKED)
1029 if (__pPresentationModel->GetNumberOfSelectedItems() == 0)
1031 int tmpItemIndex, tmpGroupIndex;
1035 // If the last item in the list was clicked, scroll it up a little bit so its not hidden by the toast.
1036 __pMailGroupedListView->GetBottomDrawnItemIndex(tmpGroupIndex, tmpItemIndex);
1038 if (itemIndex == tmpItemIndex && groupIndex == tmpGroupIndex)
1040 __pMailGroupedListView->ScrollToItem(groupIndex, itemIndex, LIST_SCROLL_ITEM_ALIGNMENT_BOTTOM);
1044 __pPresentationModel->AddSelectedMail(groupIndex, itemIndex);
1046 if (__pPresentationModel->GetNumberOfSelectedItems() != 0)
1048 text.Append(Utils::GetResourceString(L"IDS_COM_OPT_SELECTED"));
1049 text.Append(L"\x200E");
1051 text.Append(__pPresentationModel->GetNumberOfSelectedItems());
1053 text.Append(L"\x200E");
1054 __pSelectedLabel->SetText(text);
1055 __pSelectedLabel->Invalidate(true);
1058 else if (status == LIST_ITEM_STATUS_UNCHECKED)
1062 if (__pPresentationModel->GetNumberOfSelectedItems() == 1)
1064 GoToNormalMode(true);
1067 __pPresentationModel->RemoveSelectedMail(groupIndex, itemIndex);
1069 if (__pPresentationModel->GetNumberOfSelectedItems() != 0)
1071 text.Append(Utils::GetResourceString(L"IDS_COM_OPT_SELECTED"));
1072 text.Append(L"\x200E");
1074 text.Append(__pPresentationModel->GetNumberOfSelectedItems());
1076 text.Append(L"\x200E");
1077 __pSelectedLabel->SetText(text);
1078 __pSelectedLabel->Invalidate(true);
1082 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1087 MailListForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction)
1089 // Empty implementation
1093 MailListForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus status)
1095 AppLogDebug("ENTER, groupIndex:(%d), itemIndex:(%d), elementId:(%d), status:(%d)", groupIndex, itemIndex, elementId, status);
1097 ArrayList* pArgs = new (std::nothrow) ArrayList();
1099 if (elementId == IDA_INBOX_FORM_REPLY_BUTTON)
1101 if (pArgs != null && E_SUCCESS == pArgs->Construct())
1105 EmailMessageListItem* pMail = __pPresentationModel->GetMailData(groupIndex, itemIndex);
1106 EmailMessageItem* pDetailedMail = __pPresentationModel->GetCompleteMailDataN(pMail->GetMailId());
1107 EmailAccount* pAccount = EmailSettingsProvider::GetInstance()->GetAccountById(__accountId);
1108 StateInfo* pStateInfo = new (std::nothrow) StateInfo();
1110 pStateInfo->accountId = __accountId;
1111 pStateInfo->mailboxId = __mailboxId;
1112 pStateInfo->pPresentationModel = __pPresentationModel;
1113 pStateInfo->mailboxType = __mailboxType;
1114 pStateInfo->ccFieldValue = L"";
1115 pStateInfo->bccFieldValue = L"";
1117 if (pDetailedMail != null)
1119 String subject = L"Re: ";
1120 subject.Append(pDetailedMail->GetSubject());
1121 pStateInfo->subjectFieldValue = subject;
1123 if (__mailboxType == EMAIL_MAILBOX_TYPE_OUTBOX || __mailboxType == EMAIL_MAILBOX_TYPE_SENTBOX)
1126 Utils::BuildEmailIdStringFromFullAddress(pDetailedMail->GetFullAddressTo(), emailIds);
1127 pStateInfo->toFieldValue = emailIds;
1129 Utils::BuildEmailIdStringFromFullAddress(pDetailedMail->GetFullAddressCc(), emailIds);
1130 pStateInfo->ccFieldValue = emailIds;
1134 pStateInfo->toFieldValue = pDetailedMail->GetEmailAddressSender();
1137 if (pAccount->GetOptions()->GetReplyWithBody() == true)
1139 body.Append(L"\n\n----Original Message----\n");
1140 body.Append(L"From: ");
1141 body.Append(pDetailedMail->GetFullAddressFrom());
1142 body.Append(L"\nSent: ");
1143 body.Append(pDetailedMail->GetLocalDateTime().ToString());
1144 body.Append(L"\nTo: ");
1145 Utils::ExtractEmailIdFromFullAddress(pDetailedMail->GetFullAddressTo(), emailId);
1146 body.Append(emailId);
1147 body.Append(L"\nSubject: ");
1148 body.Append(pDetailedMail->GetSubject());
1152 result r = file.Construct(pDetailedMail->GetFilePathPlain(), L"r");
1156 while (file.Read(mailBody) == E_SUCCESS)
1158 body.Append(mailBody);
1164 pStateInfo->bodyFieldValue = body;
1165 pStateInfo->attachmentsPath = L"";
1167 pArgs->Add(pStateInfo);
1169 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_EMAIL_COMPOSER), pArgs);
1172 else if (elementId == IDA_INBOX_FORM_MARK_AS_READ_BUTTON)
1174 __pPresentationModel->SetFlag(groupIndex, itemIndex, EMAIL_FLAGS_SEEN_FIELD, true, true);
1175 __pMailGroupedListView->RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1177 if (__viewByType == SORT_BY_UNREAD)
1179 if (__pPresentationModel->GetNumberOfSelectedItems() > 0)
1181 UnCheckAllListviewItems();
1184 __pPresentationModel->SortBy(SORT_BY_UNREAD);
1185 __pMailGroupedListView->UpdateList();
1187 if (__pPresentationModel->GetNumberOfSelectedItems() > 0)
1189 CheckSelectedListviewItems();
1193 else if (elementId == IDA_INBOX_FORM_MARK_AS_UNREAD_BUTTON)
1195 __pPresentationModel->SetFlag(groupIndex, itemIndex, EMAIL_FLAGS_SEEN_FIELD, false, true);
1196 __pMailGroupedListView->RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
1198 if (__viewByType == SORT_BY_UNREAD)
1200 if (__pPresentationModel->GetNumberOfSelectedItems() > 0)
1202 UnCheckAllListviewItems();
1205 __pPresentationModel->SortBy(SORT_BY_UNREAD);
1206 __pMailGroupedListView->UpdateList();
1208 if (__pPresentationModel->GetNumberOfSelectedItems() > 0)
1210 CheckSelectedListviewItems();
1214 else if (elementId == IDA_INBOX_FORM_FORWARD_BUTTON)
1216 EmailMessageListItem* pMail = __pPresentationModel->GetMailData(groupIndex, itemIndex);
1217 EmailMessageItem* pDetailedMail = __pPresentationModel->GetCompleteMailDataN(pMail->GetMailId());
1218 EmailAccount* pAccount = EmailSettingsProvider::GetInstance()->GetAccountById(__accountId);
1220 if (pDetailedMail != null && pDetailedMail->GetHasAttachment() == true && pAccount->GetOptions()->GetForwardWithFiles() == true && IsAttachmentDownload(pDetailedMail) == false)
1222 __futureAction = EmailTypesNS::FORWARD_AFTER_DOWNLOAD;
1223 __groupIndex = groupIndex;
1224 __itemIndex = itemIndex;
1225 DownloadAllAttachments(pDetailedMail, EMAIL_SWIPE_FORWARD);
1229 ArrayList* pArgs = new (std::nothrow) ArrayList();
1231 if (pArgs != null && E_SUCCESS == pArgs->Construct())
1235 String fullAddressFrom;
1236 String localDateTime;
1237 String fullAddressTo;
1238 String filePathPlain;
1239 String attachmentStr = L"";
1240 StateInfo* pStateInfo = new (std::nothrow) StateInfo();
1242 pStateInfo->accountId = __accountId;
1243 pStateInfo->mailboxId = __mailboxId;
1244 pStateInfo->pPresentationModel = __pPresentationModel;
1245 pStateInfo->mailboxType = __mailboxType;
1246 pStateInfo->toFieldValue = L"";
1247 pStateInfo->ccFieldValue = L"";
1248 pStateInfo->bccFieldValue = L"";
1250 // pArgs->Add(new (std::nothrow) Integer(__accountId));
1251 // pArgs->Add(new (std::nothrow) Integer(__mailboxId));
1252 // pArgs->Add(__pPresentationModel);
1253 // pArgs->Add(new (std::nothrow) Integer(__mailboxType));
1255 // pArgs->Add(new (std::nothrow) String(L"")); // to field
1256 // pArgs->Add(new (std::nothrow) String(L"")); // cc field
1257 // pArgs->Add(new (std::nothrow) String(L"")); // bcc field
1259 if (pDetailedMail != null)
1261 tmpSubject = pDetailedMail->GetSubject();
1262 fullAddressFrom = pDetailedMail->GetFullAddressFrom();
1263 localDateTime = pDetailedMail->GetLocalDateTime().ToString();
1264 fullAddressTo = pDetailedMail->GetFullAddressTo();
1265 filePathPlain = pDetailedMail->GetFilePathPlain();
1267 if (pDetailedMail->GetHasAttachment() == true && pAccount->GetOptions()->GetForwardWithFiles() == true)
1269 ArrayList* pAttachments = __pPresentationModel->GetAllAttachmentListN(pDetailedMail->GetMailId());
1271 for (int i=0; i < pAttachments->GetCount(); i++)
1273 attachmentStr.Append(static_cast<EmailAttachment*>(pAttachments->GetAt(i))->GetAttachmentPath());
1274 attachmentStr.Append(';');
1278 delete pDetailedMail;
1281 String subject = L"Fwd: ";
1282 subject.Append(tmpSubject);
1283 // pArgs->Add(subject); // subject field
1284 pStateInfo->subjectFieldValue = subject;
1286 String body = L"\n\n----Original Message----\n";
1287 body.Append(L"From: ");
1288 body.Append(fullAddressFrom);
1289 body.Append(L"\nSent: ");
1290 body.Append(localDateTime);
1291 body.Append(L"\nTo: ");
1292 Utils::ExtractEmailIdFromFullAddress(fullAddressTo, emailId);
1293 body.Append(emailId);
1294 body.Append(L"\nSubject: ");
1295 body.Append(tmpSubject);
1298 if (filePathPlain.IsEmpty() == false)
1302 result r = file.Construct(filePathPlain, L"r");
1306 while (file.Read(mailBody) == E_SUCCESS)
1308 body.Append(mailBody);
1313 // pArgs->Add(body); // body field
1314 // pArgs->Add(attachmentStr); // attachments field
1316 pStateInfo->bodyFieldValue = body;
1317 pStateInfo->attachmentsPath = attachmentStr;
1319 pArgs->Add(pStateInfo);
1322 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_EMAIL_COMPOSER), pArgs);
1325 else if (elementId == IDA_INBOX_FORM_DELETE_BUTTON)
1327 EmailMessageListItem* pMsg = __pPresentationModel->GetMailData(groupIndex, itemIndex);
1331 EmailApp::GetInstance()->SetShowDeletePopupStatus(EMAIL_SWIPE_DELETE, pMsg->GetMailId());
1333 SetDeleteConfirmationPopupTitle(Utils::GetResourceString(L"IDS_COM_POP_DELETE_Q"));
1335 __pDeleteConfirmationPopup->SetShowState(true);
1336 __pDeleteConfirmationPopup->Show();
1340 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
1345 MailListForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1347 AppLogDebug("ENTER, actionId:(%d)", actionId);
1348 result r = E_SUCCESS;
1350 if (actionId == IDA_INBOX_FORM_HEADER_SEARCH_BUTTON)
1352 ArrayList* pArgs = new (std::nothrow) ArrayList();
1355 StateInfo* pStateInfo = new (std::nothrow) StateInfo();
1357 pStateInfo->accountId = __accountId;
1358 pStateInfo->mailboxId = __mailboxId;
1359 pStateInfo->pPresentationModel = __pPresentationModel;
1360 pStateInfo->mailboxType = __mailboxType;
1362 pArgs->Add(pStateInfo);
1364 SearchPresentationModel* pSearchPresentationModel = SearchPresentationModel::GetInstance();
1366 if (pSearchPresentationModel != null)
1368 BasePresentationModel* pBasePresentationModel = pSearchPresentationModel->GetPresentationModel();
1370 if (pBasePresentationModel != null)
1372 pBasePresentationModel->FetchData(__accountId, true);
1373 pSearchPresentationModel->Initialize(pBasePresentationModel);
1374 pSearchPresentationModel->PerformSearch(L"");
1378 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SEARCH, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
1379 AppLogDebug("Result of go forward:(%s)", GetErrorMessage(r));
1381 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_INBOX)
1383 __mailboxViewType = INBOX_VIEW;
1384 __mailboxId = __pPresentationModel->GetMailboxIdByType(__accountId, EMAIL_MAILBOX_TYPE_INBOX);
1385 __mailboxType = EMAIL_MAILBOX_TYPE_INBOX;
1387 if (__accountId > 0)
1389 __mailboxId = __pPresentationModel->GetMailboxIdByType(__accountId, EMAIL_MAILBOX_TYPE_INBOX);
1390 __pPresentationModel = InboxPresentationModel::GetInstance();
1391 __pPresentationModel->FetchData(__accountId);
1392 __pPresentationModel->SortBy(__viewByType);
1393 __pBaseListViewItemProvider->SetPresentationModel(__pPresentationModel);
1395 else if (__accountId == -1)
1398 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
1399 __pPresentationModel->SortBy(__viewByType);
1403 __pMailGroupedListView->UpdateList();
1404 UnCheckAllListviewItems();
1406 // else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_FAVORITES)
1408 // __mailboxViewType = FAVORITES_VIEW;
1410 // __mailboxId = -1;
1411 // __mailboxType = EMAIL_MAILBOX_TYPE_FLAGGED;
1412 // __pPresentationModel = AllMailsPresentationModel::GetInstance();
1413 // __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
1414 // __pPresentationModel->SortBy(__viewByType);
1415 // __pMailGroupedListView->UpdateList();
1416 // UnCheckAllListviewItems();
1417 // PopulateHeader();
1419 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_DRAFTS)
1421 __mailboxViewType = DRAFTS_VIEW;
1423 __mailboxId = __pPresentationModel->GetMailboxIdByType(__accountId, EMAIL_MAILBOX_TYPE_DRAFT);
1424 __mailboxType = EMAIL_MAILBOX_TYPE_DRAFT;
1426 if (__accountId > 0)
1428 __mailboxId = __pPresentationModel->GetMailboxIdByType(__accountId, EMAIL_MAILBOX_TYPE_DRAFT);
1429 __pPresentationModel = DraftListPresentationModel::GetInstance();
1430 __pPresentationModel->FetchData(__accountId);
1431 __pPresentationModel->SortBy(__viewByType);
1432 __pBaseListViewItemProvider->SetPresentationModel(__pPresentationModel);
1434 else if (__accountId == -1)
1437 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
1438 __pPresentationModel->SortBy(__viewByType);
1442 __pMailGroupedListView->UpdateList();
1443 UnCheckAllListviewItems();
1445 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_SENTBOX)
1447 __mailboxViewType = SENTBOX_VIEW;
1449 __mailboxId = __pPresentationModel->GetMailboxIdByType(__accountId, EMAIL_MAILBOX_TYPE_SENTBOX);
1450 __mailboxType = EMAIL_MAILBOX_TYPE_SENTBOX;
1452 if (__accountId > 0)
1454 __mailboxId = __pPresentationModel->GetMailboxIdByType(__accountId, EMAIL_MAILBOX_TYPE_SENTBOX);
1455 __pPresentationModel = SentboxPresentationModel::GetInstance();
1456 __pPresentationModel->FetchData(__accountId);
1457 __pPresentationModel->SortBy(__viewByType);
1458 __pBaseListViewItemProvider->SetPresentationModel(__pPresentationModel);
1460 else if (__accountId == -1)
1463 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
1464 __pPresentationModel->SortBy(__viewByType);
1468 __pMailGroupedListView->UpdateList();
1469 UnCheckAllListviewItems();
1471 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_ALL_FOLDERS)
1473 __mailboxViewType = ALL_FOLDERS_VIEW;
1475 ArrayList* pArgs = new (std::nothrow) ArrayList();
1478 StateInfo* pStateInfo = new (std::nothrow) StateInfo();
1480 pStateInfo->accountId = __accountId;
1481 pStateInfo->mailboxId = __mailboxId;
1482 pStateInfo->pPresentationModel = __pPresentationModel;
1483 pStateInfo->mailboxType = __mailboxType;
1485 pArgs->Add(pStateInfo);
1487 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_FOLDERS_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
1489 else if (actionId == IDA_INBOX_FORM_HEADER_UPDATE_BUTTON)
1491 EmailMailboxManager* pMgr = EmailMailboxManager::GetInstance();
1493 pMgr->SyncHeader(__accountId, __mailboxId);
1495 else if (actionId == IDA_INBOX_FORM_FOOTER_COMPOSE_BUTTON)
1497 ArrayList* pArgs = new (std::nothrow) ArrayList();
1500 StateInfo* pStateInfo = new (std::nothrow) StateInfo();
1502 pStateInfo->accountId = __accountId;
1503 pStateInfo->mailboxId = __mailboxId;
1504 pStateInfo->pPresentationModel = __pPresentationModel;
1505 pStateInfo->mailboxType = __mailboxType;
1506 pStateInfo->toFieldValue = L"";
1507 pStateInfo->ccFieldValue = L"";
1508 pStateInfo->bccFieldValue = L"";
1509 pStateInfo->subjectFieldValue = L"";
1510 pStateInfo->bodyFieldValue = L"";
1511 pStateInfo->attachmentsPath = L"";
1513 pArgs->Add(pStateInfo);
1515 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_EMAIL_COMPOSER, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
1517 else if (actionId == IDA_INBOX_FORM_FOOTER_FOLDER_BUTTON)
1519 PopulateFolderContextMenu();
1521 __pFolderContextMenu->SetFocusable(true);
1522 __pFolderContextMenu->SetShowState(true);
1523 __pFolderContextMenu->Show();
1525 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_SORT_BY)
1527 InitSortByPopup(POPUP_LISTVIEW_ITEM_COUNT);
1529 __pSortByPopup->SetShowState(true);
1530 __pSortByPopup->Show();
1532 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_DELETE_ALL)
1534 SetDeleteConfirmationPopupTitle(Utils::GetResourceString(L"IDS_EMAIL_POP_DELETE_ALL_Q"));
1536 __pDeleteConfirmationPopup->SetShowState(true);
1537 __pDeleteConfirmationPopup->Show();
1539 EmailApp::GetInstance()->SetShowDeletePopupStatus(EMAIL_DELETE_ALL, -1);
1541 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_ADD_ACCOUNT)
1543 ArrayList* pArgs = new (std::nothrow) ArrayList();
1546 StateInfo* pStateInfo = new (std::nothrow) StateInfo();
1548 pStateInfo->accountId = __accountId;
1549 pStateInfo->mailboxId = __mailboxId;
1550 pStateInfo->pPresentationModel = __pPresentationModel;
1551 pStateInfo->mailboxType = __mailboxType;
1553 pArgs->Add(pStateInfo);
1555 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ADD_ACCOUNT, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
1557 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_SETTINGS)
1559 ArrayList* pArgs = new (std::nothrow) ArrayList();
1562 StateInfo* pStateInfo = new (std::nothrow) StateInfo();
1564 pStateInfo->accountId = __accountId;
1565 pStateInfo->mailboxId = __mailboxId;
1566 pStateInfo->pPresentationModel = __pPresentationModel;
1567 pStateInfo->mailboxType = __mailboxType;
1569 pArgs->Add(pStateInfo);
1571 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_EMAIL_SETTING, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
1573 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_MARK_UNREAD)
1575 __pPresentationModel->SetFlag(EMAIL_FLAGS_SEEN_FIELD, false, true);
1576 UnCheckAllListviewItems();
1577 GoToNormalMode(true);
1578 __pPresentationModel->ClearSelectedMailList();
1580 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_MARK_READ)
1582 __pPresentationModel->SetFlag(EMAIL_FLAGS_SEEN_FIELD, true, true);
1583 UnCheckAllListviewItems();
1584 GoToNormalMode(true);
1585 __pPresentationModel->ClearSelectedMailList();
1587 if (__viewByType == SORT_BY_UNREAD)
1589 __pPresentationModel->SortBy(SORT_BY_UNREAD);
1590 __pMailGroupedListView->UpdateList();
1593 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_MARK_ALL_AS)
1595 InitMarkAllAsPopup();
1596 __pMarkAllAsPopup->SetShowState(true);
1597 __pMarkAllAsPopup->Show();
1599 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_SET_UNFAVOURITES)
1601 __pPresentationModel->SetFlag(EMAIL_FLAGS_FLAGGED_FIELD, false, true);
1602 UnCheckAllListviewItems();
1603 GoToNormalMode(true);
1604 __pPresentationModel->ClearSelectedMailList();
1606 if (__viewByType == SORT_BY_IMPORTANT)
1608 __pPresentationModel->SortBy(SORT_BY_IMPORTANT);
1609 __pMailGroupedListView->UpdateList();
1612 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_SET_FAVOURITES)
1614 __pPresentationModel->SetFlag(EMAIL_FLAGS_FLAGGED_FIELD, true, true);
1615 UnCheckAllListviewItems();
1616 GoToNormalMode(true);
1617 __pPresentationModel->ClearSelectedMailList();
1619 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_SET_ALL_AS)
1621 InitSetAllAsPopup();
1622 __pSetAllAsPopup->SetShowState(true);
1623 __pSetAllAsPopup->Show();
1625 else if (actionId == IDA_INBOX_FORM_BTN_POPUP_CANCEL)
1627 __pSortByPopup->SetShowState(false);
1630 else if (actionId == IDA_INBOX_FORM_FOOTER_MOVE_BUTTON)
1632 ArrayList* pArgs = new (std::nothrow) ArrayList();
1635 if (__mailboxId != -1)
1637 StateInfo* pStateInfo = new (std::nothrow) StateInfo();
1639 pStateInfo->accountId = __accountId;
1640 pStateInfo->mailboxId = __mailboxId;
1641 pStateInfo->pPresentationModel = __pPresentationModel;
1642 pStateInfo->mailboxType = __mailboxType;
1644 pArgs->Add(pStateInfo);
1646 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MOVEMAIL, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
1650 int isMultipleAccountsItemsSelected = __pPresentationModel->IsMultipleAccountsSelected();
1652 if (isMultipleAccountsItemsSelected > 0)
1654 StateInfo* pStateInfo = new (std::nothrow) StateInfo();
1656 pStateInfo->accountId = isMultipleAccountsItemsSelected;;
1657 pStateInfo->mailboxId = __mailboxId;
1658 pStateInfo->pPresentationModel = __pPresentationModel;
1659 pStateInfo->mailboxType = __mailboxType;
1661 pArgs->Add(pStateInfo);
1663 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MOVEMAIL, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
1669 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), L"Unable to move emails from multiple accounts at once!", MSGBOX_STYLE_OK, 300000);
1670 msgBox.ShowAndWait(modRes);
1671 __pPresentationModel->ClearSelectedMailList();
1672 UnCheckAllListviewItems();
1673 GoToNormalMode(true);
1677 else if (actionId == IDA_INBOX_FORM_BTN_MARK_ALL_AS_POPUP_CLOSE)
1679 __pMarkAllAsPopup->SetShowState(false);
1682 else if (actionId == IDA_INBOX_FORM_BTN_SET_ALL_AS_POPUP_CANCEL)
1684 __pSetAllAsPopup->SetShowState(false);
1687 else if (actionId == IDA_INBOX_FORM_FOOTER_DELETE_BUTTON)
1689 EmailApp::GetInstance()->SetShowDeletePopupStatus(EMAIL_SELECTED_DELETE, -1);
1691 SetDeleteConfirmationPopupTitle(Utils::GetResourceString(L"IDS_COM_POP_DELETE_Q"));
1692 __pDeleteConfirmationPopup->SetShowState(true);
1693 __pDeleteConfirmationPopup->Show();
1695 else if (actionId == IDA_INBOX_FORM_CONTEXT_MENU_BLOCK)
1697 __pPresentationModel->BlockEmails();
1699 if (__accountId == -1)
1701 r = __pPresentationModel->MoveMail(EMAIL_MAILBOX_TYPE_SPAMBOX);
1705 int mailboxId = EmailMailboxManager::GetInstance()->GetMailboxIdByType(__accountId, EMAIL_MAILBOX_TYPE_SPAMBOX);
1706 r = __pPresentationModel->MoveMail(mailboxId);
1711 ShowPopUp(Utils::GetResourceString(L"IDS_BLOCKING"));
1712 __waitForMove = true;
1716 EmailApp::GetInstance()->SetMoveOrDeleteFailedPopupStatus(true);
1717 SetMoveOrDeleteFailedPopupTitle(Utils::GetResourceString(L"IDS_COM_POP_MOVING_FAILED"));
1718 __pMoveOrDeleteFailedPopup->SetShowState(true);
1719 __pMoveOrDeleteFailedPopup->Show();
1720 UnCheckAllListviewItems();
1721 GoToNormalMode(true);
1725 else if (actionId == IDA_INBOX_FORM_DELETE_CONFIRMATION_NO)
1727 EmailApp::GetInstance()->ClearShowDeletePopupStatus();
1729 __pDeleteConfirmationPopup->SetShowState(false);
1732 else if (actionId == IDA_INBOX_FORM_DELETE_CONFIRMATION_YES)
1734 __pDeleteConfirmationPopup->SetShowState(false);
1739 if (EmailApp::GetInstance()->GetShowDeletePopupStatus(mailId, mode) == true)
1741 if (mode == EMAIL_SWIPE_DELETE)
1743 int groupIndex, itemIndex;
1744 __pPresentationModel->GetMailIndex(mailId, groupIndex, itemIndex);
1746 EmailApp::GetInstance()->ClearShowDeletePopupStatus();
1748 if (groupIndex != -1 && itemIndex != -1 && groupIndex <= __pPresentationModel->GetGroupCount()-1 && itemIndex <= __pPresentationModel->GetItemCount(groupIndex)-1)
1750 if (__accountId == -1)
1752 if (__mailboxType == EMAIL_MAILBOX_TYPE_TRASH)
1754 __pPresentationModel->DeleteMail(groupIndex, itemIndex, false);
1758 r = __pPresentationModel->MoveMail(groupIndex, itemIndex, EMAIL_MAILBOX_TYPE_TRASH);
1763 email_mailbox_type_e mailboxType = __pPresentationModel->GetMailboxType(__mailboxId);
1765 if (mailboxType == EMAIL_MAILBOX_TYPE_TRASH)
1767 __pPresentationModel->DeleteMail(groupIndex, itemIndex, false);
1771 int mailboxId = EmailMailboxManager::GetInstance()->GetMailboxIdByType(__accountId, EMAIL_MAILBOX_TYPE_TRASH);
1772 r = __pPresentationModel->MoveMail(groupIndex, itemIndex, mailboxId);
1779 ShowPopUp(Utils::GetResourceString(L"IDS_EMAIL_POP_DELETING_ING"));
1780 __waitForDelete = true;
1784 EmailApp::GetInstance()->SetMoveOrDeleteFailedPopupStatus(false);
1785 SetMoveOrDeleteFailedPopupTitle(Utils::GetResourceString(L"IDS_COM_POP_DELETE_FAILED"));
1786 __pMoveOrDeleteFailedPopup->SetShowState(true);
1787 __pMoveOrDeleteFailedPopup->Show();
1792 else if (mode == EMAIL_DELETE_ALL)
1795 int groupCount = __pMailGroupedListView->GetGroupCount();
1797 EmailApp::GetInstance()->ClearShowDeletePopupStatus();
1799 __pDeleteConfirmationPopup->SetShowState(false);
1802 for (int groupIndex = 0; groupIndex < groupCount; groupIndex++)
1804 itemCount = __pMailGroupedListView->GetItemCountAt(groupIndex);
1806 for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
1808 __pPresentationModel->AddSelectedMail(groupIndex, itemIndex);
1812 if (__accountId == -1)
1814 if (__mailboxType == EMAIL_MAILBOX_TYPE_TRASH)
1816 __pPresentationModel->DeleteMail(false, true);
1820 r = __pPresentationModel->MoveMail(EMAIL_MAILBOX_TYPE_TRASH);
1825 email_mailbox_type_e mailboxType = __pPresentationModel->GetMailboxType(__mailboxId);
1827 if (mailboxType == EMAIL_MAILBOX_TYPE_TRASH)
1829 __pPresentationModel->DeleteMail(false);
1833 int mailboxId = EmailMailboxManager::GetInstance()->GetMailboxIdByType(__accountId, EMAIL_MAILBOX_TYPE_TRASH);
1834 r = __pPresentationModel->MoveMail(mailboxId);
1840 ShowPopUp(Utils::GetResourceString(L"IDS_EMAIL_POP_DELETING_ING"));
1841 __waitForDelete = true;
1845 EmailApp::GetInstance()->SetMoveOrDeleteFailedPopupStatus(false);
1846 SetMoveOrDeleteFailedPopupTitle(Utils::GetResourceString(L"IDS_COM_POP_DELETE_FAILED"));
1847 __pMoveOrDeleteFailedPopup->SetShowState(true);
1848 __pMoveOrDeleteFailedPopup->Show();
1852 else if (mode == EMAIL_SELECTED_DELETE)
1854 EmailApp::GetInstance()->ClearShowDeletePopupStatus();
1856 __pDeleteConfirmationPopup->SetShowState(false);
1859 if (__accountId == -1)
1861 if (__mailboxType == EMAIL_MAILBOX_TYPE_TRASH)
1863 __pPresentationModel->DeleteMail(false, true);
1867 r = __pPresentationModel->MoveMail(EMAIL_MAILBOX_TYPE_TRASH);
1872 email_mailbox_type_e mailboxType = __pPresentationModel->GetMailboxType(__mailboxId);
1874 if (mailboxType == EMAIL_MAILBOX_TYPE_TRASH)
1876 __pPresentationModel->DeleteMail(false);
1880 int mailboxId = EmailMailboxManager::GetInstance()->GetMailboxIdByType(__accountId, EMAIL_MAILBOX_TYPE_TRASH);
1881 r = __pPresentationModel->MoveMail(mailboxId);
1887 ShowPopUp(Utils::GetResourceString(L"IDS_EMAIL_POP_DELETING_ING"));
1888 __waitForDelete = true;
1892 EmailApp::GetInstance()->SetMoveOrDeleteFailedPopupStatus(false);
1893 SetMoveOrDeleteFailedPopupTitle(Utils::GetResourceString(L"IDS_COM_POP_DELETE_FAILED"));
1894 __pMoveOrDeleteFailedPopup->SetShowState(true);
1895 __pMoveOrDeleteFailedPopup->Show();
1896 UnCheckAllListviewItems();
1897 GoToNormalMode(true);
1903 else if (actionId == IDA_ATTACHMENT_DOWNLOAD_FAILED_OK)
1905 EmailApp::GetInstance()->SetDownloadFailedPopupStatus(false);
1907 __pAttachmentDownloadFailedPopup->SetShowState(false);
1910 else if (actionId == IDA_MOVE_OR_DELETE_FAILED_OK)
1912 EmailApp::GetInstance()->ClearMoveOrDeleteFailedPopupStatus();
1914 __pMoveOrDeleteFailedPopup->SetShowState(false);
1918 AppLogDebug("EXIT");
1922 MailListForm::InitSortByPopup(int count)
1924 AppLogDebug("ENTER");
1927 Rectangle popupBounds;
1929 email_mailbox_type_e mailboxType = __pPresentationModel->GetMailboxType(__mailboxId);
1931 if (__pSortByPopup == null)
1933 CreateSortByPopup();
1936 if (mailboxType == EMAIL_MAILBOX_TYPE_SENTBOX || mailboxType == EMAIL_MAILBOX_TYPE_DRAFT)
1938 __pSortByListViewItemProvider->SetViewBySenderOrRecipient(false);
1942 __pSortByListViewItemProvider->SetViewBySenderOrRecipient(true);
1945 popupBounds = __pSortByPopup->GetClientAreaBounds();
1947 xPos = (popupBounds.width-W_POPUP_CLOSE_BUTTON)/2;
1948 yPos = popupBounds.height - GENERIC_OFFSET_16 - H_POPUP_CLOSE_BUTTON;
1950 __pSortByPopupCloseButton->SetPosition(xPos, yPos);
1952 __pSortByListView->SetPosition(0, 0);
1954 xPos = popupBounds.width;
1955 yPos = popupBounds.height - H_POPUP_CLOSE_BUTTON - (2*GENERIC_OFFSET_16);
1956 __pSortByListView->SetSize(xPos, yPos);
1958 __pSortByListView->SetItemChecked(0, false);
1959 __pSortByListView->SetItemChecked(1, false);
1960 __pSortByListView->SetItemChecked(2, false);
1961 __pSortByListView->SetItemChecked(3, false);
1963 __pSortByListView->UpdateList();
1964 __pSortByListView->SetItemChecked(__viewByType, true);
1965 __pSortByListView->Invalidate(true);
1967 AppLogDebug("EXIT");
1972 MailListForm::InitMarkAllAsPopup(void)
1974 AppLogDebug("ENTER");
1977 Rectangle popupBounds;
1979 if (__pMarkAllAsPopup == null)
1981 CreateMarkAllAsPopup();
1984 popupBounds = __pMarkAllAsPopup->GetClientAreaBounds();
1985 AppLogDebug("Got popup bounds:(%d),(%d),(%d),(%d)", popupBounds.x,popupBounds.y,popupBounds.width,popupBounds.height);
1987 xPos = (popupBounds.width-W_POPUP_CLOSE_BUTTON)/2;
1988 yPos = popupBounds.height - GENERIC_OFFSET_16 - H_POPUP_CLOSE_BUTTON;
1990 __pMarkAllAsPopupCloseButton->SetPosition(xPos, yPos);
1991 __pMarkAllAsListView->SetPosition(0, 0);
1993 xPos = popupBounds.width;
1994 yPos = popupBounds.height - H_POPUP_CLOSE_BUTTON - (2*GENERIC_OFFSET_16);
1995 __pMarkAllAsListView->SetSize(xPos, yPos);
1996 __pMarkAllAsListView->UpdateList();
1997 __pMarkAllAsListView->Invalidate(true);
1999 AppLogDebug("EXIT");
2004 MailListForm::InitSetAllAsPopup(void)
2006 AppLogDebug("ENTER");
2009 Rectangle popupBounds;
2011 if (__pSetAllAsPopup == null)
2013 CreateSetAllAsPopup();
2016 popupBounds = __pSetAllAsPopup->GetClientAreaBounds();
2017 AppLogDebug("Got popup bounds:(%d),(%d),(%d),(%d)", popupBounds.x,popupBounds.y,popupBounds.width,popupBounds.height);
2019 xPos = (popupBounds.width-W_POPUP_CLOSE_BUTTON)/2;
2020 yPos = popupBounds.height - GENERIC_OFFSET_16 - H_POPUP_CLOSE_BUTTON;
2022 __pSetAllAsPopupCancelButton->SetPosition(xPos, yPos);
2023 __pSetAllAsListView->SetPosition(0, 0);
2025 xPos = popupBounds.width;
2026 yPos = popupBounds.height - H_POPUP_CLOSE_BUTTON - (2*GENERIC_OFFSET_16);
2027 __pSetAllAsListView->SetSize(xPos, yPos);
2028 __pSetAllAsListView->UpdateList();
2029 __pSetAllAsListView->Invalidate(true);
2031 AppLogDebug("EXIT");
2036 MailListForm::OnSortTypeChanged(SortType viewByType)
2038 AppLogDebug("ENTER");
2040 __viewByType = viewByType;
2041 __pPresentationModel->SortBy(__viewByType);
2042 __pMailGroupedListView->UpdateList();
2044 __pSortByPopup->SetShowState(false);
2047 AppLogDebug("EXIT");
2051 MailListForm::OnMarkAllAsOptionChanged(int selectedOption)
2053 AppLogDebug("ENTER");
2055 if (selectedOption == 0)
2057 __pPresentationModel->SetFlag(EMAIL_FLAGS_SEEN_FIELD, true, true);
2059 else if (selectedOption == 1)
2061 __pPresentationModel->SetFlag(EMAIL_FLAGS_SEEN_FIELD, false, true);
2064 UnCheckAllListviewItems();
2065 GoToNormalMode(true);
2066 __pPresentationModel->ClearSelectedMailList();
2067 __pMarkAllAsPopup->SetShowState(false);
2069 AppLogDebug("EXIT");
2073 MailListForm::OnSetAllAsOptionChanged(int selectedOption)
2075 AppLogDebug("ENTER");
2077 if (selectedOption == 0)
2079 __pPresentationModel->SetFlag(EMAIL_FLAGS_FLAGGED_FIELD, true, true);
2081 else if (selectedOption == 1)
2083 __pPresentationModel->SetFlag(EMAIL_FLAGS_FLAGGED_FIELD, false, true);
2086 UnCheckAllListviewItems();
2087 GoToNormalMode(true);
2088 __pPresentationModel->ClearSelectedMailList();
2089 __pSetAllAsPopup->SetShowState(false);
2091 AppLogDebug("EXIT");
2095 MailListForm::PopulateHeader()
2097 Bitmap* pLogo = null;
2098 Header* pHeader = GetHeader();
2100 // pHeader->RemoveAllItems();
2102 if (__accountId > 0)
2104 EmailAccount* pAccount = __pPresentationModel->GetAccountById(__accountId);
2105 EmailMailbox* pMailbox = __pPresentationModel->GetMailboxById(__mailboxId);
2107 if (pAccount != null && pMailbox != null)
2109 String headerLogoPath = L"header_images/";
2110 headerLogoPath.Append(File::GetFileName(pAccount->GetLogoIconPath()));
2111 pLogo = App::GetInstance()->GetAppResource()->GetBitmapN(headerLogoPath);
2112 pHeader->SetTitleIcon(pLogo);
2113 pHeader->SetTitleText(pAccount->GetAccountName());
2114 pHeader->SetDescriptionText(pMailbox->GetMailboxAlias());
2120 pHeader->SetTitleIcon(__pHeaderAllAccountsIcon);
2121 pHeader->SetTitleText(Utils::GetResourceString(L"IDS_EMAIL_BODY_ALL_ACCOUNTS"));
2123 switch(__mailboxType)
2125 case EMAIL_MAILBOX_TYPE_INBOX:
2127 pHeader->SetDescriptionText(Utils::GetResourceString(L"IDS_EMAIL_BODY_INBOX"));
2131 case EMAIL_MAILBOX_TYPE_SENTBOX:
2133 pHeader->SetDescriptionText(Utils::GetResourceString(L"IDS_EMAIL_BODY_SENTBOX"));
2137 case EMAIL_MAILBOX_TYPE_DRAFT:
2139 pHeader->SetDescriptionText(Utils::GetResourceString(L"IDS_EMAIL_BODY_DRAFTS"));
2143 case EMAIL_MAILBOX_TYPE_TRASH:
2145 pHeader->SetDescriptionText(Utils::GetResourceString(L"IDS_EMAIL_BODY_TRASH"));
2149 case EMAIL_MAILBOX_TYPE_SPAMBOX:
2151 pHeader->SetDescriptionText(Utils::GetResourceString(L"IDS_EMAIL_BODY_SPAMBOX"));
2155 case EMAIL_MAILBOX_TYPE_OUTBOX:
2157 pHeader->SetDescriptionText(Utils::GetResourceString(L"IDS_EMAIL_HEADER_OUTBOX"));
2161 case EMAIL_MAILBOX_TYPE_FLAGGED:
2163 pHeader->SetDescriptionText(L"Starred");
2172 pHeader->Invalidate(true);
2176 BasePresentationModel*
2177 MailListForm::GetPresentationModelForMailboxType(int mailboxId)
2179 BasePresentationModel* pModel = InboxPresentationModel::GetInstance();
2181 email_mailbox_type_e mailboxType = pModel->GetMailboxType(mailboxId);
2183 switch (mailboxType)
2186 case EMAIL_MAILBOX_TYPE_DRAFT:
2187 pModel = DraftListPresentationModel::GetInstance();
2190 case EMAIL_MAILBOX_TYPE_OUTBOX:
2191 pModel = OutboxPresentationModel::GetInstance();
2194 case EMAIL_MAILBOX_TYPE_SENTBOX:
2195 pModel = SentboxPresentationModel::GetInstance();
2198 case EMAIL_MAILBOX_TYPE_SPAMBOX:
2199 pModel = SpamPresentationModel::GetInstance();
2202 case EMAIL_MAILBOX_TYPE_TRASH:
2203 pModel = TrashPresentationModel::GetInstance();
2214 MailListForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2216 AppLogDebug("ENTER");
2220 StateInfo* pStateInfo = static_cast<StateInfo*>(pArgs->GetAt(0));
2222 __accountId = pStateInfo->accountId;
2223 __mailboxId = pStateInfo->mailboxId;
2224 __pPresentationModel = pStateInfo->pPresentationModel;
2225 __mailboxType = pStateInfo->mailboxType;
2227 if (__mailboxType != EMAIL_MAILBOX_TYPE_USER_DEFINED && __accountId != -1)
2229 EmailMailbox* pTmpMailbox = static_cast<EmailMailbox*>(__pPresentationModel->GetMailboxByType(__accountId, __mailboxType));
2231 if (pTmpMailbox != null && __mailboxId != pTmpMailbox->GetMailboxId())
2233 __mailboxId = pTmpMailbox->GetMailboxId();
2237 pArgs->RemoveAll(true);
2242 __accountId = __pPresentationModel->GetDefaultAccountId();
2243 __mailboxId = __pPresentationModel->GetMailboxIdByType(__accountId, EMAIL_MAILBOX_TYPE_INBOX);
2244 __pPresentationModel = InboxPresentationModel::GetInstance();
2245 __mailboxType = EMAIL_MAILBOX_TYPE_INBOX;
2248 if (__accountId != -1)
2250 if (__mailboxType == EMAIL_MAILBOX_TYPE_USER_DEFINED || __mailboxType == EMAIL_MAILBOX_TYPE_ALL_EMAILS || __mailboxType == EMAIL_MAILBOX_TYPE_SEARCH_RESULT || __mailboxType == EMAIL_MAILBOX_TYPE_FLAGGED)
2252 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
2256 __pPresentationModel->FetchData(__accountId);
2261 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
2264 switch (__mailboxType)
2266 case EMAIL_MAILBOX_TYPE_USER_DEFINED: // fall through
2267 case EMAIL_MAILBOX_TYPE_ALL_EMAILS: // fall through
2268 case EMAIL_MAILBOX_TYPE_SEARCH_RESULT:
2269 __mailboxViewType = ALL_FOLDERS_VIEW;
2272 case EMAIL_MAILBOX_TYPE_INBOX:
2273 __mailboxViewType = INBOX_VIEW;
2276 case EMAIL_MAILBOX_TYPE_DRAFT:
2277 __mailboxViewType = DRAFTS_VIEW;
2280 case EMAIL_MAILBOX_TYPE_SENTBOX:
2281 __mailboxViewType = SENTBOX_VIEW;
2284 // case EMAIL_MAILBOX_TYPE_FLAGGED:
2285 // __mailboxViewType = FAVORITES_VIEW;
2293 __viewByType = __pPresentationModel->GetSortType();
2294 __pBaseListViewItemProvider->SetPresentationModel(__pPresentationModel);
2295 __pPresentationModel->SortBy(__pPresentationModel->GetSortType());
2297 __pMailGroupedListView->SetItemProvider(*__pBaseListViewItemProvider);
2298 __pMailGroupedListView->UpdateList();
2300 __pAccountsListView->SetItemProvider(*this);
2302 __waitForMove = false;
2303 __waitForDelete = false;
2305 CheckSelectedListviewItems();
2307 if (__pPresentationModel->GetNumberOfSelectedItems() > 0)
2310 text.Append(Utils::GetResourceString(L"IDS_COM_OPT_SELECTED"));
2311 text.Append(L"\x200E");
2313 text.Append(__pPresentationModel->GetNumberOfSelectedItems());
2315 text.Append(L"\x200E");
2316 __pSelectedLabel->SetText(text);
2317 __pSelectedLabel->Invalidate(true);
2319 if (__mode != EDIT_MODE)
2327 if (__mode != NORMAL_MODE)
2329 GoToNormalMode(false);
2333 UnCheckAllListviewItems();
2339 if (EmailApp::GetInstance()->GetShowDeletePopupStatus(mailId, mode) == true)
2341 bool hideDelPopup = false;
2343 if (mode == EMAIL_DELETE_ALL)
2345 if (__pPresentationModel->GetItemCount(0) > 0)
2347 SetDeleteConfirmationPopupTitle(Utils::GetResourceString(L"IDS_EMAIL_POP_DELETE_ALL_Q"));
2348 __pDeleteConfirmationPopup->SetShowState(true);
2349 __pDeleteConfirmationPopup->Show();
2353 hideDelPopup = true;
2356 else if (mode == EMAIL_SELECTED_DELETE)
2358 if (__pPresentationModel->CheckIfSelectedMailExists() == true)
2360 SetDeleteConfirmationPopupTitle(Utils::GetResourceString(L"IDS_COM_POP_DELETE_Q"));
2361 __pDeleteConfirmationPopup->SetShowState(true);
2362 __pDeleteConfirmationPopup->Show();
2366 hideDelPopup = true;
2371 int groupIndex, itemIndex;
2372 __pPresentationModel->GetMailIndex(mailId, groupIndex, itemIndex);
2374 if (groupIndex != -1 && itemIndex != -1 && groupIndex <= __pPresentationModel->GetGroupCount()-1 && itemIndex <= __pPresentationModel->GetItemCount(groupIndex)-1)
2376 SetDeleteConfirmationPopupTitle(Utils::GetResourceString(L"IDS_COM_POP_DELETE_Q"));
2378 __pDeleteConfirmationPopup->SetShowState(true);
2379 __pDeleteConfirmationPopup->Show();
2383 hideDelPopup = true;
2387 if (hideDelPopup == true)
2389 EmailApp::GetInstance()->ClearShowDeletePopupStatus();
2394 DownloadInitiatorMode downloadMode;
2396 if (EmailApp::GetInstance()->GetDownloadAttachmentPopupStatus(downloadMailId, downloadMode) == true)
2398 if (downloadMode == EMAIL_SWIPE_FORWARD)
2400 int groupIndex = -1;
2402 EmailMessageItem* pDetailedMail = __pPresentationModel->GetCompleteMailDataN(downloadMailId);
2404 if (pDetailedMail != null)
2406 DownloadAllAttachments(pDetailedMail, EMAIL_SWIPE_FORWARD);
2407 __pPresentationModel->GetMailIndex(downloadMailId, groupIndex, itemIndex);
2408 __futureAction = EmailTypesNS::FORWARD_AFTER_DOWNLOAD;
2409 __groupIndex = groupIndex;
2410 __itemIndex = itemIndex;
2413 else if (downloadMode == EMAIL_DRAFT_DOWNLOAD)
2415 int groupIndex = -1;
2417 EmailMessageItem* pDetailedMail = __pPresentationModel->GetCompleteMailDataN(downloadMailId);
2419 if (pDetailedMail != null)
2421 DownloadAllAttachments(pDetailedMail, EMAIL_DRAFT_DOWNLOAD);
2422 __pPresentationModel->GetMailIndex(downloadMailId, groupIndex, itemIndex);
2423 __futureAction = EmailTypesNS::COMPOSE_AFTER_DOWNLOAD;
2424 __groupIndex = groupIndex;
2425 __itemIndex = itemIndex;
2430 if (EmailApp::GetInstance()->GetDownloadFailedPopupStatus() == true)
2432 EmailApp::GetInstance()->ClearDownloadAttachmentPopupStatus();
2434 if (__pAttachmentDownloadFailedPopup == null)
2436 InitAttachmentDownloadFailedPopup();
2439 __pAttachmentDownloadFailedPopup->SetShowState(true);
2440 __pAttachmentDownloadFailedPopup->Show();
2445 if (EmailApp::GetInstance()->GetMoveOrDeleteFailedPopupStatus(isMoveFailed) == true)
2449 SetMoveOrDeleteFailedPopupTitle(Utils::GetResourceString(L"IDS_COM_POP_MOVING_FAILED"));
2453 SetMoveOrDeleteFailedPopupTitle(Utils::GetResourceString(L"IDS_COM_POP_DELETE_FAILED"));
2456 __pMoveOrDeleteFailedPopup->SetShowState(true);
2457 __pMoveOrDeleteFailedPopup->Show();
2460 AppLogDebug("EXIT");
2465 MailListForm::ShowPopUp(const String& popupTitle)
2467 AppLogDebug("ENTER");
2469 __pProgressPopup->SetTitleText(popupTitle);
2470 __pProgressPopup->SetShowState(true);
2471 __pProgressPopup->Show();
2473 AppLogDebug("EXIT: r = %s", GetErrorMessage(GetLastResult()));
2477 MailListForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
2479 AppLogDebug("ENTER, currentSceneId:(%ls), nextSceneId:(%ls)", currentSceneId.GetPointer(), nextSceneId.GetPointer());
2481 UnCheckAllListviewItems();
2483 if (__pDeleteConfirmationPopup != null)
2485 __pDeleteConfirmationPopup->RemoveAllControls();
2486 delete __pDeleteConfirmationPopup;
2487 __pDeleteConfirmationPopup = null;
2490 if (__pAttachmentDownloadFailedPopup != null)
2492 __pAttachmentDownloadFailedPopup->RemoveAllControls();
2493 delete __pAttachmentDownloadFailedPopup;
2494 __pAttachmentDownloadFailedPopup = null;
2497 if (__pDownloadAttachmentsPopup != null)
2499 delete __pDownloadAttachmentsPopup;
2500 __pDownloadAttachmentsPopup = null;
2503 if (__pMoveOrDeleteFailedPopup != null)
2505 __pMoveOrDeleteFailedPopup->RemoveAllControls();
2506 delete __pMoveOrDeleteFailedPopup;
2507 __pMoveOrDeleteFailedPopup = null;
2510 if (__pSortByPopup != null)
2512 __pSortByPopup->RemoveAllControls();
2513 delete __pSortByPopup;
2514 __pSortByPopup = null;
2517 if (__pSortByListViewItemProvider != null)
2519 delete __pSortByListViewItemProvider;
2520 __pSortByListViewItemProvider = null;
2523 if (__pMarkAllAsPopup != null)
2525 __pMarkAllAsPopup->RemoveAllControls();
2526 delete __pMarkAllAsPopup;
2527 __pMarkAllAsPopup = null;
2530 if (__pMarkAllAsListViewItemProvider != null)
2532 delete __pMarkAllAsListViewItemProvider;
2533 __pMarkAllAsListViewItemProvider = null;
2536 if (__pSetAllAsPopup != null)
2538 __pSetAllAsPopup->RemoveAllControls();
2539 delete __pSetAllAsPopup;
2540 __pSetAllAsPopup = null;
2543 if (__pSetAllAsListViewItemProvider != null)
2545 delete __pSetAllAsListViewItemProvider;
2546 __pSetAllAsListViewItemProvider = null;
2549 /*if (__pMoreOptionMenu != null)
2551 __pMoreOptionMenu->RemoveAllItems();
2552 delete __pMoreOptionMenu;
2553 __pMoreOptionMenu = null;
2556 AppLogDebug("EXIT");
2560 MailListForm::OnUserEventReceivedN(RequestId requestId, IList *pArgs)
2562 AppLogDebug("ENTER, requestId:(%d), pArgs:(%x)", requestId, pArgs);
2563 AppLogDebugIf(pArgs != null, "pArgs count:(%d)", pArgs->GetCount());
2565 result r = E_SUCCESS;
2567 if (requestId == IDA_NOTI_MAIL_ADD || requestId == IDA_NOTI_MAIL_UPDATE)
2569 if (pArgs != null && pArgs->GetCount() >= 3)
2571 if (requestId == IDA_NOTI_MAIL_UPDATE)
2573 int groupIndex=0, itemIndex=0;
2574 int mailId = static_cast<Integer*>(pArgs->GetAt(1))->ToInt();
2575 AppLogDebug("Got mail Id:(%d)", mailId);
2577 __pPresentationModel->GetMailIndex(mailId, groupIndex, itemIndex);
2578 AppLogDebug("Got groupIndex:(%d), itemIndex:(%d)", groupIndex, itemIndex);
2580 EmailMessageListItem* pMsg = static_cast<EmailMessageListItem*>(__pPresentationModel->GetMailData(groupIndex, itemIndex));
2581 AppLogDebugIf(pMsg == null, "pMsg was null");
2585 int mailIdToBeAdded = 0;
2586 if (__pPresentationModel->IsMailSelected(pMsg))
2588 mailIdToBeAdded = pMsg->GetMailId();
2589 __pPresentationModel->RemoveMailFromSelectedMailList(pMsg);
2592 if (__accountId == -1)
2594 r = __pPresentationModel->GetData()->Remove(*pMsg);
2598 if (__mailboxType == EMAIL_MAILBOX_TYPE_USER_DEFINED || __mailboxType == EMAIL_MAILBOX_TYPE_ALL_EMAILS || __mailboxType == EMAIL_MAILBOX_TYPE_SEARCH_RESULT || __mailboxType == EMAIL_MAILBOX_TYPE_FLAGGED)
2600 r = __pPresentationModel->GetData()->Remove(*pMsg);
2604 r = __pPresentationModel->GetData()->Remove(*pMsg, true);
2607 AppLogDebug("Result r:(%s)", GetErrorMessage(r));
2609 __pPresentationModel->UpdateUnreadCount(__accountId);
2610 // __pPresentationModel->FetchData(__accountId, true);
2612 if (__accountId == -1)
2614 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
2618 if (__mailboxType == EMAIL_MAILBOX_TYPE_USER_DEFINED || __mailboxType == EMAIL_MAILBOX_TYPE_ALL_EMAILS || __mailboxType == EMAIL_MAILBOX_TYPE_SEARCH_RESULT || __mailboxType == EMAIL_MAILBOX_TYPE_FLAGGED)
2620 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
2624 __pPresentationModel->FetchData(__accountId, true);
2628 __pPresentationModel->SortBy(__viewByType);
2629 __pMailGroupedListView->UpdateList();
2631 if (mailIdToBeAdded > 0)
2633 EmailMessageListItem* pTmpMsg = __pPresentationModel->GetMailData(mailIdToBeAdded);
2635 if (pTmpMsg != null)
2637 __pPresentationModel->AddMailToSelectedMailList(pTmpMsg);
2644 else if (requestId == IDA_NOTI_MAIL_ADD)
2646 int mailboxId = static_cast<Integer*>(pArgs->GetAt(2))->ToInt();
2647 AppLogDebug("Current mailboxId:(%d), got mailboxId:(%d)", __mailboxId, mailboxId);
2649 if (mailboxId == __mailboxId)
2651 if (__pPresentationModel->GetNumberOfSelectedItems() > 0)
2653 UnCheckAllListviewItems();
2656 __pPresentationModel->UpdateUnreadCount(__accountId);
2657 // __pPresentationModel->FetchData(__accountId, true);
2659 if (__accountId == -1)
2661 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
2665 if (__mailboxType == EMAIL_MAILBOX_TYPE_USER_DEFINED || __mailboxType == EMAIL_MAILBOX_TYPE_ALL_EMAILS || __mailboxType == EMAIL_MAILBOX_TYPE_SEARCH_RESULT || __mailboxType == EMAIL_MAILBOX_TYPE_FLAGGED)
2667 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
2671 __pPresentationModel->FetchData(__accountId, true);
2675 __pPresentationModel->SortBy(__viewByType);
2676 __pMailGroupedListView->UpdateList();
2678 if (__pPresentationModel->GetNumberOfSelectedItems() > 0)
2680 CheckSelectedListviewItems();
2687 pArgs->RemoveAll(true);
2691 else if (requestId == IDA_NOTI_MAIL_FIELD_UPDATE && pArgs != null)
2694 int groupIndex=0, itemIndex=0;
2696 __pPresentationModel->UpdateUnreadCount(__accountId);
2698 for (int i=0; i<pArgs->GetCount(); i++)
2700 mailId = static_cast<Integer*>(pArgs->GetAt(i))->ToInt();
2701 __pPresentationModel->GetMailIndex(mailId, groupIndex, itemIndex);
2702 __pMailGroupedListView->RefreshList(groupIndex, itemIndex, LIST_REFRESH_TYPE_ITEM_MODIFY);
2705 if (__mailboxType == EMAIL_MAILBOX_TYPE_OUTBOX)
2707 UnCheckAllListviewItems();
2709 if (__accountId == -1)
2711 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
2715 if (__mailboxType == EMAIL_MAILBOX_TYPE_USER_DEFINED || __mailboxType == EMAIL_MAILBOX_TYPE_ALL_EMAILS || __mailboxType == EMAIL_MAILBOX_TYPE_SEARCH_RESULT || __mailboxType == EMAIL_MAILBOX_TYPE_FLAGGED)
2717 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
2721 __pPresentationModel->FetchData(__accountId);
2726 if (__viewByType == SORT_BY_UNREAD || __viewByType == SORT_BY_IMPORTANT)
2728 __pPresentationModel->SortBy(__viewByType);
2729 __pMailGroupedListView->UpdateList();
2732 if (__mailboxType == EMAIL_MAILBOX_TYPE_OUTBOX)
2734 CheckSelectedListviewItems();
2736 if (__pPresentationModel->GetNumberOfSelectedItems() > 0)
2740 if (__mode != EDIT_MODE)
2745 text.Append(Utils::GetResourceString(L"IDS_COM_OPT_SELECTED"));
2746 text.Append(L"\x200E");
2748 text.Append(__pPresentationModel->GetNumberOfSelectedItems());
2750 text.Append(L"\x200E");
2751 __pSelectedLabel->SetText(text);
2752 __pSelectedLabel->Invalidate(true);
2756 if (__mode == EDIT_MODE && __pMoreOptionMenu != null && __pMoreOptionMenu->GetShowState() == true)
2758 __pMoreOptionMenu->SetShowState(false);
2759 __pMoreOptionMenu->Invalidate(true);
2761 else if (__mode == NORMAL_MODE && __pMoreOptionMenu != null && __pMoreOptionMenu->GetShowState() == true && __pPresentationModel->GetGroupCount() == 0)
2763 __pMoreOptionMenu->SetShowState(false);
2764 PopulateMoreOptionMenu(__mode, __pPresentationModel->GetSelectionMode(), __pPresentationModel->GetFavouriteSelectionMode());
2765 __pMoreOptionMenu->SetShowState(true);
2766 __pMoreOptionMenu->Show();
2769 if (__mode == EDIT_MODE)
2771 GoToNormalMode(true);
2774 if (__pDeleteConfirmationPopup != null && __pDeleteConfirmationPopup->GetShowState() == true)
2776 EmailApp::GetInstance()->ClearShowDeletePopupStatus();
2778 __pDeleteConfirmationPopup->SetShowState(false);
2784 pArgs->RemoveAll(true);
2788 else if (requestId == IDA_NOTI_MAIL_MOVE_FINISHED || requestId == IDA_NOTI_DELETE_FINISHED)
2790 __pPresentationModel->UpdateUnreadCount(__accountId);
2792 if (__accountId == -1)
2794 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
2798 if (__mailboxType == EMAIL_MAILBOX_TYPE_USER_DEFINED || __mailboxType == EMAIL_MAILBOX_TYPE_ALL_EMAILS || __mailboxType == EMAIL_MAILBOX_TYPE_SEARCH_RESULT || __mailboxType == EMAIL_MAILBOX_TYPE_FLAGGED)
2800 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType);
2804 __pPresentationModel->FetchData(__accountId);
2808 __pPresentationModel->SortBy(__viewByType);
2810 if (__waitForDelete == true || __waitForMove == true)
2812 if (__waitForDelete == true)
2814 __waitForDelete = false;
2817 if (__waitForMove == true)
2819 __waitForMove = false;
2822 UnCheckAllListviewItems();
2825 __pPresentationModel->ClearSelectedMailList();
2827 if (__mode != NORMAL_MODE)
2829 GoToNormalMode(true);
2833 if (__pPresentationModel->GetNumberOfSelectedItems() == 0)
2835 UnCheckAllListviewItems();
2839 if (__mode != NORMAL_MODE)
2841 GoToNormalMode(true);
2845 __pMailGroupedListView->UpdateList();
2847 else if (requestId == IDA_NOTI_MAIL_MOVE_FAIL)
2849 if (__waitForDelete == true || __waitForMove == true)
2851 if (__waitForDelete == true)
2853 __waitForDelete = false;
2854 EmailApp::GetInstance()->SetMoveOrDeleteFailedPopupStatus(false);
2855 SetMoveOrDeleteFailedPopupTitle(Utils::GetResourceString(L"IDS_COM_POP_DELETE_FAILED"));
2858 if (__waitForMove == true)
2860 __waitForMove = false;
2861 EmailApp::GetInstance()->SetMoveOrDeleteFailedPopupStatus(true);
2862 SetMoveOrDeleteFailedPopupTitle(Utils::GetResourceString(L"IDS_COM_POP_MOVING_FAILED"));
2867 __pMoveOrDeleteFailedPopup->SetShowState(true);
2868 __pMoveOrDeleteFailedPopup->Show();
2872 else if (requestId == IDA_NOTI_DOWNLOAD_FINISH)
2874 __pPresentationModel->UpdateUnreadCount(__accountId);
2875 __pPresentationModel->FetchData(__accountId, true);
2876 __pPresentationModel->SortBy(__viewByType);
2877 __pMailGroupedListView->UpdateList();
2879 else if ((requestId == IDA_NOTI_DOWNLOAD_ATTACH_START ||
2880 requestId == IDA_NOTI_DOWNLOAD_ATTACH_FINISH ||
2881 requestId == IDA_NOTI_DOWNLOAD_ATTACH_FAIL) && pArgs != null)
2883 if (__downloadAttachments > 0)
2885 if (requestId == IDA_NOTI_DOWNLOAD_ATTACH_FAIL)
2887 if (__userCancelledAttachmentDownload == false)
2889 EmailApp::GetInstance()->ClearDownloadAttachmentPopupStatus();
2890 EmailApp::GetInstance()->SetDownloadFailedPopupStatus(true);
2892 if (__pAttachmentDownloadFailedPopup == null)
2894 InitAttachmentDownloadFailedPopup();
2897 __pAttachmentDownloadFailedPopup->SetShowState(true);
2898 __pAttachmentDownloadFailedPopup->Show();
2901 OnProgressPopupCanceled();
2902 __userCancelledAttachmentDownload = false;
2906 if (requestId == IDA_NOTI_DOWNLOAD_ATTACH_FINISH)
2908 __downloadAttachments--;
2909 AppLogDebug("Decrementing download attachment count to:(%d)", __downloadAttachments);
2912 if (__downloadAttachments == 0)
2914 EmailApp::GetInstance()->ClearDownloadAttachmentPopupStatus();
2916 if (__futureAction == EmailTypesNS::FORWARD_AFTER_DOWNLOAD)
2918 OnGroupedListViewContextItemStateChanged(*__pMailGroupedListView, __groupIndex, __itemIndex, IDA_INBOX_FORM_FORWARD_BUTTON, LIST_CONTEXT_ITEM_STATUS_SELECTED);
2920 else if (__futureAction == EmailTypesNS::COMPOSE_AFTER_DOWNLOAD)
2922 OnGroupedListViewItemStateChanged(*__pMailGroupedListView, __groupIndex, __itemIndex, IDA_BASE_LISTVIEW_ITEM_PROVIDER_EMPTY_ELEMENT, LIST_ITEM_STATUS_SELECTED);
2925 OnProgressPopupCanceled();
2930 else if (requestId == IDA_INBOX_FORM_FOOTER_DELETE_BUTTON)
2932 OnActionPerformed(*(GetFooter()), IDA_INBOX_FORM_FOOTER_DELETE_BUTTON);
2934 else if (requestId == IDA_INBOX_FORM_CONTEXT_MENU_DELETE_ALL)
2936 OnActionPerformed(*(GetFooter()), IDA_INBOX_FORM_CONTEXT_MENU_DELETE_ALL);
2939 AppLogDebug("EXIT");
2944 MailListForm::HidePopUp(void)
2946 AppLogDebug("ENTER");
2948 if (__pProgressPopup != null)
2950 __pProgressPopup->SetShowState(false);
2955 AppLogDebug("EXIT");
2959 MailListForm::PopulateMoreOptionMenu(Mode mode, SelectionMode selectionMode, FavouriteSelectionMode favouriteSelectionMode)
2961 AppLogDebug("ENTER");
2963 __pMoreOptionMenu->RemoveAllItems();
2969 __pMoreOptionMenu->AddItem(Utils::GetResourceString(L"IDS_EMAIL_OPT_VIEW"), IDA_INBOX_FORM_CONTEXT_MENU_SORT_BY, *__pSortByIcon);
2971 if (__pPresentationModel->GetGroupCount() != 0)
2973 __pMoreOptionMenu->AddItem(Utils::GetResourceString(L"IDS_EMAIL_OPT_DELETE_ALL"), IDA_INBOX_FORM_CONTEXT_MENU_DELETE_ALL, *__pDeleteAllIcon);
2976 __pMoreOptionMenu->AddItem(Utils::GetResourceString(L"IDS_MA_HEADER_ADD_ACCOUNT"), IDA_INBOX_FORM_CONTEXT_MENU_ADD_ACCOUNT, *__pAddAccountIcon);
2977 __pMoreOptionMenu->AddItem(Utils::GetResourceString(L"IDS_EMAIL_OPT2_SETTINGS"), IDA_INBOX_FORM_CONTEXT_MENU_SETTINGS, *__pSettingsIcon);
2981 if (selectionMode == SELECTION_READ)
2983 __pMoreOptionMenu->AddItem(Utils::GetResourceString(L"IDS_EMAIL_OPT_MARK_AS_UNREAD"), IDA_INBOX_FORM_CONTEXT_MENU_MARK_UNREAD, *__pMarkReadUnreadIcon);
2985 else if (selectionMode == SELECTION_UNREAD)
2987 __pMoreOptionMenu->AddItem(Utils::GetResourceString(L"IDS_EMAIL_OPT_MARK_AS_READ"), IDA_INBOX_FORM_CONTEXT_MENU_MARK_READ, *__pMarkReadUnreadIcon);
2989 else if (selectionMode == SELECTION_MIXED)
2991 __pMoreOptionMenu->AddItem(Utils::GetResourceString(L"IDS_EMAIL_OPT_MARK_ALL_AS_ABB"), IDA_INBOX_FORM_CONTEXT_MENU_MARK_ALL_AS, *__pMarkReadUnreadIcon);
2994 if (__mailboxType != EMAIL_MAILBOX_TYPE_OUTBOX)
2996 if (favouriteSelectionMode == FAVOURITE_SELECTION_FAVOURITE)
2998 __pMoreOptionMenu->AddItem(Utils::GetResourceString(L"IDS_EMAIL_OPT_UNMARK_AS_FAVOURITES_ABB1"), IDA_INBOX_FORM_CONTEXT_MENU_SET_UNFAVOURITES, *__pFavouriteIcon);
3000 else if (favouriteSelectionMode == FAVOURITE_SELECTION_UNFAVOURITE)
3002 __pMoreOptionMenu->AddItem(Utils::GetResourceString(L"IDS_EMAIL_OPT_SET_AS_FAVOURITES_ABB"), IDA_INBOX_FORM_CONTEXT_MENU_SET_FAVOURITES, *__pFavouriteIcon);
3004 else if (favouriteSelectionMode == FAVOURITE_SELECTION_MIXED)
3006 __pMoreOptionMenu->AddItem(Utils::GetResourceString(L"IDS_EMAIL_OPT_SET_ALL_AS_ABB"), IDA_INBOX_FORM_CONTEXT_MENU_SET_ALL_AS, *__pFavouriteIcon);
3010 if (__mailboxType != EMAIL_MAILBOX_TYPE_SPAMBOX && __mailboxType != EMAIL_MAILBOX_TYPE_DRAFT && __mailboxType != EMAIL_MAILBOX_TYPE_OUTBOX && __mailboxType != EMAIL_MAILBOX_TYPE_SENTBOX)
3012 __pMoreOptionMenu->AddItem(Utils::GetResourceString(L"IDS_EMAIL_OPT_BLOCK"), IDA_INBOX_FORM_CONTEXT_MENU_BLOCK, *__pBlockIcon);
3018 AppLogDebug("EXIT");
3022 MailListForm::PopulateFolderContextMenu(void)
3024 int xPosition, yPosition;
3025 Footer* pFooter = GetFooter();
3027 if (pFooter != null)
3029 pFooter->GetPosition(xPosition, yPosition);
3030 xPosition = xPosition + (2*pFooter->GetWidth()/3);
3031 __pFolderContextMenu->SetAnchorPosition(Point(xPosition, yPosition));
3034 __pFolderContextMenu->RemoveAllItems();
3036 for (int i=0; i<__pFolderContextMenuItemsList->GetCount(); i++)
3038 if (__mailboxViewType == ALL_FOLDERS_VIEW || __mailboxViewType != i)
3040 // if ((__accountId > 0 && i != FAVORITES_VIEW) || (__accountId == -1 /*&& i != ALL_FOLDERS_VIEW*/))
3042 __pFolderContextMenu->AddItem(*static_cast<String*>(__pFolderContextMenuItemsList->GetAt(i)), IDA_INBOX_FORM_CONTEXT_MENU_FOLDER_VIEW+i);
3049 MailListForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo & touchInfo)
3051 AppLogDebug("source touch position %d %d", currentPosition.x, currentPosition.y);
3052 __headerTouchPosition = currentPosition.y;
3056 MailListForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3058 int hashCode = source.GetHashCode();
3059 AppLogDebug("source touch position %d %d", currentPosition.x, currentPosition.y);
3061 Header* pHeader = GetHeader();
3063 // if (hashCode == pHeader->GetHashCode() && (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE || __headerTouchPosition > 10) && __pAccountsListPanel->GetShowState() == false)
3064 if (hashCode == pHeader->GetHashCode() && (GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE || __headerTouchPosition == currentPosition.y || __headerTouchPosition > 10) && __pAccountsListPanel->GetShowState() == false)
3065 // if (hashCode == pHeader->GetHashCode() && __headerTouchPosition == currentPosition.y && __pAccountsListPanel->GetShowState() == false)
3067 pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
3068 pHeader->SetButtonEnabled(BUTTON_POSITION_RIGHT, false);
3069 GetFooter()->SetEnabled(false);
3071 // if(__mode == EDIT_MODE)
3073 // __pAccountsListPanel->SetSize(Dimension(__pAccountsListPanel->GetWidth(), __pAccountsListPanel->GetHeight() - __pSelectedLabel->GetHeight()));
3076 __pAccountsListView->UpdateList();
3078 __pMailGroupedListView->SetEnabled(false);
3079 __pAccountsListPanel->SetShowState(true);
3081 else if (hashCode == pHeader->GetHashCode() && __pAccountsListPanel->GetShowState() == true)
3083 if (__mode != EDIT_MODE)
3085 pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
3089 __pAccountsListPanel->SetSize(Dimension(__pAccountsListPanel->GetWidth(), __pAccountsListPanel->GetHeight() + __pSelectedLabel->GetHeight()));
3092 pHeader->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
3093 GetFooter()->SetEnabled(true);
3095 __pMailGroupedListView->SetEnabled(true);
3096 __pMailGroupedListView->Invalidate(true);
3097 __pAccountsListPanel->SetShowState(false);
3099 else if (hashCode == __pAccountsListPanel->GetHashCode())
3101 if (__mode != EDIT_MODE)
3103 pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
3107 __pAccountsListPanel->SetSize(Dimension(__pAccountsListPanel->GetWidth(), __pAccountsListPanel->GetHeight() + __pSelectedLabel->GetHeight()));
3110 pHeader->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
3111 GetFooter()->SetEnabled(true);
3113 __pMailGroupedListView->SetEnabled(true);
3114 __pMailGroupedListView->Invalidate(true);
3115 __pAccountsListPanel->SetShowState(false);
3118 GetFooter()->Invalidate(true);
3119 pHeader->Invalidate(true);
3123 MailListForm::OnTouchMoved(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3129 MailListForm::OnTouchFocusIn(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3135 MailListForm::OnTouchFocusOut(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3141 MailListForm::GetItemCount(void)
3143 AppLogDebug("ENTER");
3145 int count = __pPresentationModel->GetAccountCount();
3146 int listViewWidth = __pAccountsListView->GetWidth();
3150 // Include an 'All Accounts' item as well
3154 height = count*H_ACCOUNTCUSTOM_ITEM;
3155 if (height >= __pAccountsListPanel->GetHeight() - (GENERIC_OFFSET_16))
3157 height = __pAccountsListPanel->GetHeight() - (GENERIC_OFFSET_16);
3160 if (__mode == EDIT_MODE && height >= __pAccountsListPanel->GetHeight() - (GENERIC_OFFSET_16) - __pSelectedLabel->GetHeight())
3162 height = height - __pSelectedLabel->GetHeight();
3165 __pAccountsListView->SetSize(listViewWidth, height);
3167 AppLogDebug("EXIT");
3172 MailListForm::CreateItem(int index, int itemWidth)
3174 AppLogDebug("ENTER");
3175 AppResource* pAppResource = Tizen::App::Application::GetInstance()->GetAppResource();
3176 Bitmap* pTextBackground = pAppResource->GetBitmapN(IDB_UNREADCOUNT_BACKGROUND, BITMAP_PIXEL_FORMAT_ARGB8888);
3177 Bitmap* pTextPressedBackground = pAppResource->GetBitmapN(IDB_UNREADCOUNT_PRESSED_BACKGROUND, BITMAP_PIXEL_FORMAT_ARGB8888);
3178 CustomItem* pItem = new (std::nothrow) CustomItem();
3179 pItem->Construct(Dimension(itemWidth, H_ACCOUNTCUSTOM_ITEM), LIST_ANNEX_STYLE_NORMAL);
3181 EmailAccount* pAccount = null;
3183 if (__pPresentationModel->GetAccountCount() > 1)
3187 pItem->AddElement(Rectangle(32, 24, 64, 64), 2, *__pAllAccountsIcon);
3188 pItem->AddElement(Rectangle(112,0,itemWidth-218, 112), 3, Utils::GetResourceString(L"IDS_EMAIL_BODY_ALL_ACCOUNTS"), 40, Color::GetColor(COLOR_ID_BLACK), Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), false);
3192 pAccount = __pPresentationModel->GetAccountByIndex(index-1);
3194 if (pAccount != null)
3196 AccountColorCustomListElement* pAccountColor = new (std::nothrow) AccountColorCustomListElement();
3197 pAccountColor->SetAccountId(pAccount->GetAccountId());
3199 pItem->AddElement(Rectangle(0,4,16,104), 1, *pAccountColor);
3201 Bitmap* pAccountLogo = App::GetInstance()->GetAppResource()->GetBitmapN(File::GetFileName(pAccount->GetLogoIconPath()));
3202 pItem->AddElement(Rectangle(32, 24, 64, 64), 2, *pAccountLogo);
3203 delete pAccountLogo;
3205 pItem->AddElement(Rectangle(112,0,itemWidth-218, 70), 3, pAccount->GetAccountName(), 40, Color::GetColor(COLOR_ID_BLACK), Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), false);
3206 pItem->AddElement(Rectangle(112,65,itemWidth-218, 40), 4, pAccount->GetUserEmailAddress(), 32, Color::GetColor(COLOR_ID_GREY), Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), true);
3209 pItem->AddElement(Rectangle(itemWidth-80,24,50,50), 6, *pTextBackground, pTextPressedBackground);
3211 if (__pPresentationModel->GetUnreadCount(pAccount) > 99)
3213 pItem->AddElement(Rectangle(itemWidth-80,24,50,50), 5, Integer::ToString(__pPresentationModel->GetUnreadCount(pAccount)), 28, COLOR_LIST_UNREAD_COUNT_BG_NORMAL, COLOR_LIST_UNREAD_COUNT_BG_PRESSED, null);
3215 else if (__pPresentationModel->GetUnreadCount(pAccount) > 9)
3217 pItem->AddElement(Rectangle(itemWidth-70,24,40,50), 5, Integer::ToString(__pPresentationModel->GetUnreadCount(pAccount)), 28, COLOR_LIST_UNREAD_COUNT_BG_NORMAL, COLOR_LIST_UNREAD_COUNT_BG_PRESSED, null);
3221 pItem->AddElement(Rectangle(itemWidth-65,24,40,50), 5, Integer::ToString(__pPresentationModel->GetUnreadCount(pAccount)), 28, COLOR_LIST_UNREAD_COUNT_BG_NORMAL, COLOR_LIST_UNREAD_COUNT_BG_PRESSED, null);
3228 pAccount = __pPresentationModel->GetAccountByIndex(index);
3230 if (pAccount != null)
3232 AccountColorCustomListElement* pAccountColor = new (std::nothrow) AccountColorCustomListElement();
3233 pAccountColor->SetAccountId(pAccount->GetAccountId());
3235 __pPresentationModel->UpdateUnreadCount(pAccount->GetAccountId());
3237 pItem->AddElement(Rectangle(0,4,16,104), 1, *pAccountColor);
3239 Bitmap* pAccountLogo = App::GetInstance()->GetAppResource()->GetBitmapN(File::GetFileName(pAccount->GetLogoIconPath()));
3240 pItem->AddElement(Rectangle(32, 24, 64, 64), 2, *pAccountLogo);
3241 delete pAccountLogo;
3243 pItem->AddElement(Rectangle(112,0,itemWidth-218, 70), 3, pAccount->GetAccountName(), 40, Color::GetColor(COLOR_ID_BLACK), Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), false);
3244 pItem->AddElement(Rectangle(112,65,itemWidth-218, 40), 4, pAccount->GetUserEmailAddress(), 32, Color::GetColor(COLOR_ID_GREY), Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE), true);
3246 pItem->AddElement(Rectangle(itemWidth-80,24,50,50), 6, *pTextBackground, pTextPressedBackground);
3248 if (__pPresentationModel->GetUnreadCount(pAccount) > 99)
3250 pItem->AddElement(Rectangle(itemWidth-80,24,50,50), 5, Integer::ToString(__pPresentationModel->GetUnreadCount(pAccount)), 28, COLOR_LIST_UNREAD_COUNT_BG_NORMAL, COLOR_LIST_UNREAD_COUNT_BG_PRESSED, null);
3252 else if (__pPresentationModel->GetUnreadCount(pAccount) > 9)
3254 pItem->AddElement(Rectangle(itemWidth-70,24,40,50), 5, Integer::ToString(__pPresentationModel->GetUnreadCount(pAccount)), 28, COLOR_LIST_UNREAD_COUNT_BG_NORMAL, COLOR_LIST_UNREAD_COUNT_BG_PRESSED, null);
3258 pItem->AddElement(Rectangle(itemWidth-65,24,40,50), 5, Integer::ToString(__pPresentationModel->GetUnreadCount(pAccount)), 28, COLOR_LIST_UNREAD_COUNT_BG_NORMAL, COLOR_LIST_UNREAD_COUNT_BG_PRESSED, null);
3263 delete pTextBackground;
3264 delete pTextPressedBackground;
3266 AppLogDebug("EXIT");
3271 MailListForm::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
3273 AppLogDebug("ENTER");
3274 CustomItem* pCustomItem = null;
3278 pCustomItem = static_cast<CustomItem*>(pItem);
3280 pCustomItem->RemoveAllElements();
3284 AppLogDebug("EXIT");
3289 MailListForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
3291 AppLogDebug("ENTER");
3293 if (__mode == EDIT_MODE)
3295 GoToNormalMode(true);
3296 UnCheckAllListviewItems();
3297 __pPresentationModel->ClearSelectedMailList();
3300 if (__pPresentationModel->GetAccountCount() > 1)
3306 __mailboxType = EMAIL_MAILBOX_TYPE_INBOX;
3307 __pPresentationModel = AllMailsPresentationModel::GetInstance();
3308 __pBaseListViewItemProvider->SetPresentationModel(__pPresentationModel);
3309 __pPresentationModel->FetchData(__accountId, __mailboxId, __mailboxType); // Fetches data from all accounts corresponding to the mailbox type
3313 EmailAccount* pAccount = __pPresentationModel->GetAccountByIndex(index-1);
3315 if (pAccount != null)
3317 __accountId = pAccount->GetAccountId();
3318 __pPresentationModel = InboxPresentationModel::GetInstance();
3319 __pBaseListViewItemProvider->SetPresentationModel(__pPresentationModel);
3320 __mailboxId = __pPresentationModel->GetMailboxIdByType(__accountId, EMAIL_MAILBOX_TYPE_INBOX);
3321 __pPresentationModel->FetchData(__accountId); // Fetches data for the account id
3322 __mailboxType = EMAIL_MAILBOX_TYPE_INBOX;
3326 __mailboxViewType = INBOX_VIEW;
3327 __pPresentationModel->SortBy(__viewByType);
3329 __pMailGroupedListView->UpdateList();
3333 GetHeader()->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
3334 GetHeader()->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
3335 GetFooter()->SetEnabled(true);
3337 GetHeader()->Invalidate(true);
3338 GetFooter()->Invalidate(true);
3340 __pAccountsListPanel->SetShowState(false);
3341 // __pAccountsListPanel->GetControlAnimator()->StartUserAnimation(ANIMATION_TARGET_ALPHA, IntegerAnimation(1, 0, 250, ANIMATION_INTERPOLATOR_LINEAR));
3342 __pMailGroupedListView->SetEnabled(true);
3347 GetHeader()->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
3348 GetHeader()->SetButtonEnabled(BUTTON_POSITION_RIGHT, true);
3349 GetFooter()->SetEnabled(true);
3351 GetHeader()->Invalidate(true);
3352 GetFooter()->Invalidate(true);
3354 __pAccountsListPanel->SetShowState(false);
3355 // __pAccountsListPanel->GetControlAnimator()->StartUserAnimation(ANIMATION_TARGET_ALPHA, IntegerAnimation(1, 0, 250, ANIMATION_INTERPOLATOR_LINEAR));
3356 __pMailGroupedListView->SetEnabled(true);
3360 AppLogDebug("EXIT");
3364 MailListForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
3370 MailListForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status)
3376 MailListForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
3378 AppLogDebug("ENTER");
3380 if (__mode == EDIT_MODE)
3382 FloatDimension d = FloatDimension(__pMailGroupedListView->GetWidthF(), this->GetClientAreaBoundsF().height -__pSelectedLabel->GetHeightF());
3383 __pMailGroupedListView->SetSize(CoordinateSystem::AlignToDevice(d));
3385 // __pMailGroupedListView->SetSize(__pMailGroupedListView->GetWidth(), this->GetClientAreaBounds().height -__pSelectedLabel->GetHeight());
3387 if(__pAccountsListPanel->GetShowState() == true)
3389 __pAccountsListPanel->SetSize(Dimension(__pAccountsListPanel->GetWidth(), __pAccountsListPanel->GetHeight() - __pSelectedLabel->GetHeight()));
3395 if(!(((__prevOrientation == ORIENTATION_STATUS_PORTRAIT) && (orientationStatus == ORIENTATION_STATUS_PORTRAIT_REVERSE)) ||
3396 ((__prevOrientation == ORIENTATION_STATUS_PORTRAIT_REVERSE) && (orientationStatus == ORIENTATION_STATUS_PORTRAIT))))
3397 __pMailGroupedListView->SetSize(__pMailGroupedListView->GetWidth(), this->GetClientAreaBounds().height);
3400 if (__pAccountsListPanel->GetShowState() == true)
3402 __pAccountsListPanel->Invalidate(true);
3403 __pAccountsListView->UpdateList();
3406 __prevOrientation = orientationStatus;
3407 AppLogDebug("EXIT");
3412 MailListForm::OnProgressPopupCanceled(void)
3414 AppLogDebug("ENTER");
3416 if (__pDownloadAttachmentsPopup != null && __pDownloadAttachmentsPopup->GetShowState() == true)
3418 AppLogDebug("User cancelled download of attachments");
3420 if (__pAttachmentDownloadHandleMap != null)
3422 IMapEnumerator* pMapEnum = __pAttachmentDownloadHandleMap->GetMapEnumeratorN();
3424 if (pMapEnum != null)
3426 while (!IsFailed(pMapEnum->MoveNext()))
3428 int accountId = static_cast<Integer*>(pMapEnum->GetKey())->ToInt();
3429 int handle = static_cast<Integer*>(pMapEnum->GetValue())->ToInt();
3430 __pPresentationModel->CancelJob(accountId, handle, EMAIL_CANCELED_BY_USER);
3436 if (__pAttachmentDownloadHandleMap != null)
3438 __pAttachmentDownloadHandleMap->RemoveAll(true);
3439 delete __pAttachmentDownloadHandleMap;
3440 __pAttachmentDownloadHandleMap = null;
3443 __futureAction = EmailTypesNS::NONE;
3444 __downloadAttachments = 0;
3445 __userCancelledAttachmentDownload = true;
3447 if (__pDownloadAttachmentsPopup != null)
3449 __pDownloadAttachmentsPopup->SetShowState(false);
3452 EmailApp::GetInstance()->ClearDownloadAttachmentPopupStatus();
3456 AppLogDebug("EXIT");
3460 MailListForm::IsAttachmentDownload(const EmailMessageItem* pDetailedMail)
3462 AppLogDebug("ENTER, pDetailedMsg:(%x)", pDetailedMail);
3463 AppLogDebugIf(pDetailedMail != null, "mailId:(%d)", pDetailedMail->GetMailId());
3465 ArrayList* pAttachments = __pPresentationModel->GetAllAttachmentListN(pDetailedMail->GetMailId());
3467 for (int i=0; i<pAttachments->GetCount(); i++)
3469 EmailAttachment* pTmpAttachment = static_cast<EmailAttachment*>(pAttachments->GetAt(i));
3471 if (pTmpAttachment->GetSaveStatus() == false)
3473 pAttachments->RemoveAll(true);
3474 delete pAttachments;
3476 AppLogDebug("EXIT, returning false");
3481 pAttachments->RemoveAll(true);
3482 delete pAttachments;
3484 AppLogDebug("EXIT, returning true");
3489 MailListForm::DownloadAllAttachments(const EmailMessageItem* pDetailedMail, DownloadInitiatorMode downloadMode)
3491 AppLogDebug("ENTER, pDetailedMsg:(%x)", pDetailedMail);
3492 AppLogDebugIf(pDetailedMail != null, "mailId:(%d)", pDetailedMail->GetMailId());
3494 result r = E_SUCCESS;
3496 __downloadAttachments = 0;
3498 if (__pDownloadAttachmentsPopup == null)
3500 __pDownloadAttachmentsPopup = new (std::nothrow) ProgressPopup();
3501 __pDownloadAttachmentsPopup->Construct(true, false);
3502 __pDownloadAttachmentsPopup->SetTitleText(Utils::GetResourceString(L"IDS_EMAIL_POP_DOWNLOADING_ATTACHMENT_ING"));
3503 __pDownloadAttachmentsPopup->AddProgressPopupEventListener(*this);
3506 __pDownloadAttachmentsPopup->SetShowState(true);
3507 __pDownloadAttachmentsPopup->Show();
3508 EmailApp::GetInstance()->SetDownloadAttachmentPopupStatus(pDetailedMail->GetMailId(), downloadMode);
3510 if (__pAttachmentDownloadHandleMap == null)
3512 __pAttachmentDownloadHandleMap = new (std::nothrow) HashMap();
3513 __pAttachmentDownloadHandleMap->Construct();
3516 __pAttachmentDownloadHandleMap->RemoveAll(true);
3518 ArrayList* pAttachments = __pPresentationModel->GetAllAttachmentListN(pDetailedMail->GetMailId());
3520 for (int i=0; i<pAttachments->GetCount(); i++)
3523 EmailAttachment* pTmpAttachment = static_cast<EmailAttachment*>(pAttachments->GetAt(i));
3525 if (pTmpAttachment->GetSaveStatus() == false)
3527 __downloadAttachments++;
3528 r = __pPresentationModel->DownloadAttachment(pDetailedMail->GetMailId(), i+1, handle);
3532 AppLogDebug("Adding accountId:(%d), handle:(%d) to map", pDetailedMail->GetAccountId(), handle);
3533 r = __pAttachmentDownloadHandleMap->Add(new (std::nothrow) Integer(pDetailedMail->GetAccountId()), new (std::nothrow) Integer(handle));
3534 AppLogDebugIf(r != E_SUCCESS, "Failed to add attachment download handle to map");
3539 pAttachments->RemoveAll(true);
3540 delete pAttachments;
3542 AppLogDebug("EXIT, download attachment count:(%d)", __downloadAttachments);
3546 MailListForm::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
3548 AppLogDebug("ENTER, keyCode:(%d)", keyEventInfo.GetKeyCode());
3549 AppLogDebug("EXIT");
3554 MailListForm::OnKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
3556 AppLogDebug("ENTER, keyCode:(%d)", keyEventInfo.GetKeyCode());
3558 if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
3560 if (__pDeleteConfirmationPopup != null && __pDeleteConfirmationPopup->GetShowState() == true)
3562 AppLogDebug("Delete popup");
3563 EmailApp::GetInstance()->ClearShowDeletePopupStatus();
3565 __pDeleteConfirmationPopup->SetShowState(false);
3568 else if (__pSortByPopup != null && __pSortByPopup->GetShowState() == true)
3570 AppLogDebug("sort by popup");
3571 __pSortByPopup->SetShowState(false);
3574 else if (__pMarkAllAsPopup != null && __pMarkAllAsPopup->GetShowState() == true)
3576 AppLogDebug("Mark all as popup");
3577 __pMarkAllAsPopup->SetShowState(false);
3580 else if (__pSetAllAsPopup != null && __pSetAllAsPopup->GetShowState() == true)
3582 AppLogDebug("set all as popup");
3583 __pSetAllAsPopup->SetShowState(false);
3588 AppLogDebug("EXIT");
3593 MailListForm::OnPreviewKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
3595 AppLogDebug("ENTER, keyCode:(%d)", keyEventInfo.GetKeyCode());
3596 AppLogDebug("EXIT");
3601 MailListForm::OnPreviewKeyReleased(Control& source, const KeyEventInfo& keyEventInfo)
3603 AppLogDebug("ENTER, keyCode:(%d)", keyEventInfo.GetKeyCode());
3604 AppLogDebug("EXIT");