96de6fb8b92dcb3cc88b82fe0a388d62c83ef09d
[apps/osp/Dial.git] / src / PhnLogsDetailForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file    PhnLogsDetailForm.cpp
19  * @brief       Call log details form
20  */
21 #include <FApp.h>
22 #include <FGraphics.h>
23 #include <FMedia.h>
24 #include <FSocial.h>
25 #include "PhnPhoneApp.h"
26 #include "PhnAppUtility.h"
27 #include "PhnLogsDetailForm.h"
28 #include "PhnSceneRegister.h"
29 #include "PhnCalllogManager.h"
30 #include "PhnCallLogPresentationModel.h"
31 #include "PhnCallRejectInfo.h"
32 #include "PhnDialPresentationModel.h"
33 #include "PhnSettingsPresentationModel.h"
34 #include "PhnTypes.h"
35
36 using namespace Tizen::App;
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Collection;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Media;
41 using namespace Tizen::Social;
42 using namespace Tizen::Ui;
43 using namespace Tizen::Ui::Controls;
44 using namespace Tizen::Ui::Scenes;
45 //resources
46 const wchar_t* IDL_CALL_LOG_DETAIL_FORM = L"IDL_CALL_LOG_DETAIL_FORM";
47 const wchar_t* IDC_BUTTON_CONTACT_IMAGE = L"IDC_BUTTON_CONTACT_IMAGE";
48 const wchar_t* IDC_LABEL_NAME = L"IDC_LABEL_NAME";
49 const wchar_t* IDC_LABEL_NUMBER_COUNT = L"IDC_LABEL_NUMBER_COUNT";
50 const wchar_t* IDC_LABEL_UNSAVED_NUMBER = L"IDC_LABEL_UNSAVED_NUMBER";
51 const wchar_t* IDC_LABEL_COUNT = L"IDC_LABEL_COUNT";
52 const wchar_t* IDC_LABEL_NUMBER = L"IDC_LABEL_NUMBER";
53 const wchar_t* IDC_LABEL_NUMBER_UNSAVED = L"IDC_LABEL_NUMBER_UNSAVED";
54 const wchar_t* IDC_LABEL_BLOCKED = L"IDC_LABEL_BLOCKED";
55 const wchar_t* IDC_BUTTON_MESSAGE = L"IDC_BUTTON_MESSAGE";
56 const wchar_t* IDC_SELECTALL = L"IDC_SELECTALL";
57 const wchar_t* IDC_LABEL_DETAIL_SELECTED = L"IDC_LABEL_DETAIL_SELECTED";
58 const wchar_t* IDC_PANEL_NAME = L"IDC_PANEL_NAME";
59 const wchar_t* IDC_PANEL_NUMBER_UNSAVED = L"IDC_PANEL_NUMBER_UNSAVED";
60 const wchar_t* IDS_ALREADY_USED_MSG = L"IDS_ALREADY_USED_MSG";
61
62 const int IDA_CALL_LOG_CALL = 201;
63 const int IDA_CALL_LOG_MESSAGE = 202;
64 const int IDA_FOOTER_BUTTON_LEFT = 203;
65 const int IDA_FOOTER_BUTTON_RIGHT = 204;
66 const int IDA_SELECT_ALL_CHECKED = 205;
67 const int IDA_SELECT_ALL_UNCHECKED = 206;
68 const int IDA_POPUP_DELETE_CANCEL = 207;
69 const int IDA_FOOTER_LOG_MORE = 208;
70 const int IDA_CONTEXTMENU_DETAILS = 209;
71 const int IDA_CONTEXTMENU_ADDTOCONTACT = 210;
72 const int IDA_CONTEXTMENU_BLOCK = 211;
73
74 const int W_BUTTON = 48;
75 const int H_BUTTON = 48;
76 const int W_BLOCKED_ICON = 56;
77 const int H_BLOCKED_ICON = 56;
78 //static const int X_MORE = 55;
79
80 const wchar_t* FORMAT_STR = L"%ls (%d)";
81
82 static const int W_DELETE_POPUP = 720;
83 static const int H_DELETE_POPUP = 308;
84 static const int Y_DELETE_POPUP_TITLE = 20;
85 static const int H_DELETE_POPUP_ELEMENT = 60;
86 static const int H_DELETE_POPUP_PROGRESS = 34;
87 static const int Y_DELETE_POPUP_CANCEL_BUTTON = 214;
88 static const int H_DELETE_POPUP_CANCEL_BUTTON = 74;
89 static const int W_DELETE_POPUP_CANCEL_BUTTON = 394;
90
91 static const int FONT_SIZE_DELETE_POPUP_TEXT = 36;
92
93 static const unsigned int COLOR_DELETE_POPUP_TEXT = Color32<128, 128, 128>::Value;
94 static const unsigned int COLOR_DELAIL_LABEL_SELECTED = Color32<215, 225, 232, 255>::Value;
95
96
97 DlLogsDetailForm::DlLogsDetailForm(void)
98 {
99         __pDataProvider = new LogsDetailItemProvider();
100
101         __listHeight = 0;
102         __pButtonCall = null;
103         __pButtonMessage = null;
104         __pButtonContactImage = null;
105         __pPanelNumberUnsaved = null;
106         __pPanelName = null;
107         __pLabelNumber = null;
108         __pFormFooter = null;
109         __pList = null;
110         __isEditMode = false;
111         __isSelectAll = false;
112         __isPresentInContacts = false;
113         __listItemCount = 0;
114         __selectedItemCount = 0;
115         __calllogListByNum = null;
116         __pLogPresentor = null;
117         __calllogCount = 0;
118         __isMsgAppControlLaunched = false;
119         __deleteLogsTimer.Construct(*this);
120         __deleteGroupIndex = 0;
121         __deleteItemIndex = 0;
122         __pDeletePopup = null;
123         __isDeleteInProgress = false;
124         __pCallLogId = null;
125         __isSceneVisible = false;
126         __pLogsBlockPopup = null;\r
127         __isContactAppControlLaunched = false;
128         __isCallBeRejected = false;
129         __isCallAppControlLaunched = false;
130         __isMsgBeRejected = false;
131         __pOptionMenu = null;
132 }
133
134 DlLogsDetailForm::~DlLogsDetailForm(void)
135 {
136         if (__pDataProvider != null)
137         {
138                 delete __pDataProvider;
139                 __pDataProvider = null;
140         }
141         if (__pLogPresentor != null)
142         {
143                 __pLogPresentor->RemoveCalllogChangeListner(*this);
144                 __pLogPresentor = null;
145         }
146         if (__pCallLogId != null)
147         {
148                 __pCallLogId->RemoveAll();
149                 delete __pCallLogId;
150                 __pCallLogId = null;
151         }
152         if(__pLogsBlockPopup != null)\r
153         {
154                 delete __pLogsBlockPopup;\r
155                 __pLogsBlockPopup = null;\r
156         }
157 }
158
159 bool
160 DlLogsDetailForm::Initialize()
161 {
162         result r = Construct(IDL_CALL_LOG_DETAIL_FORM);
163         __pCallLogId = new(std::nothrow) ArrayList();
164         r = __pCallLogId->Construct();
165
166         TryCatch(r == E_SUCCESS, , "DlLogsDetailForm::Initialize Fail to initialize Call log detail form");
167         return true;
168 CATCH:
169         return false;
170
171 }
172
173 result
174 DlLogsDetailForm::OnInitializing(void)
175 {
176         result r = E_SUCCESS;
177
178         AddOrientationEventListener(*this);
179         SetFormMenuEventListener(this);
180         SetFormBackEventListener(this);
181         AppResource* pAppResource = App::GetInstance()->GetAppResource();
182
183         __pFormFooter = GetFooter();
184         if (__pFormFooter != null)
185         {
186                 __pFormFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
187                 __pFormFooter->AddActionEventListener(*this);
188
189                 __pFooterItemDelete.Construct(IDA_FOOTER_BUTTON_LEFT);
190                 __pFooterItemDelete.SetText(AppUtility::GetResourceString(IDS_CALLLOG_DELETE_FOOTER));
191                 __pFormFooter->AddItem(__pFooterItemDelete);
192
193                 __pFooterItemCancel.Construct(IDA_FOOTER_BUTTON_RIGHT);
194                 __pFooterItemCancel.SetText(AppUtility::GetResourceString(IDS_CALLLOG_CANCEL_FOOTER));
195         }
196
197         __pButtonContactImage = static_cast<Button*>(GetControl(IDC_BUTTON_CONTACT_IMAGE));
198         if (__pButtonContactImage != null)
199         {
200                 //todo: set image & show if present in contacts
201                 __pButtonContactImage->SetShowState(false);
202         }
203
204         __pPanelName = static_cast<Panel*>(GetControl(IDC_PANEL_NAME));
205         __pPanelNumberUnsaved = static_cast<Panel*>(GetControl(IDC_PANEL_NUMBER_UNSAVED));
206
207         __pLabelNumber = static_cast<Label*>(GetControl(IDC_LABEL_NUMBER));
208         if (__pLabelNumber != null)
209         {
210                 __pLabelNumber->SetTextColor(Color::GetColor(COLOR_ID_BLACK));
211                 __pLabelNumber->SetTextConfig(32, LABEL_TEXT_STYLE_BOLD);
212         }
213
214         __pLabelBlocked = static_cast<Label*>(GetControl(IDC_LABEL_BLOCKED));
215         if (__pLabelBlocked != null)
216         {
217                 __pLabelBlocked->SetShowState(false);
218         }
219
220         Bitmap* pBgNormal = pAppResource->GetBitmapN(IDB_CIRCLE_BUTTON_NORMAL ,BITMAP_PIXEL_FORMAT_ARGB8888);
221         Bitmap* pBgPressed = pAppResource->GetBitmapN(IDB_CIRCLE_BUTTON_PRESSED ,BITMAP_PIXEL_FORMAT_ARGB8888);
222         Bitmap* pCallNormal = pAppResource->GetBitmapN(IDB_LOG_DETAIL_CALL_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888);
223         Bitmap* pCallPressed = pAppResource->GetBitmapN(IDB_LOG_DETAIL_CALL_PRESSED_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888);
224
225         __pButtonCall = static_cast<Button*>(GetControl(IDC_BUTTON_CALL));
226         if (__pButtonCall != null)
227         {
228                 __pButtonCall->SetActionId(IDA_CALL_LOG_CALL);
229                 __pButtonCall->AddActionEventListener(*this);
230         }
231         if (pBgNormal != null)
232         {
233                 __pButtonCall->SetNormalBackgroundBitmap(*pBgNormal);
234                 delete pBgNormal;
235                 pBgNormal = null;
236         }
237         if (pBgPressed != null)
238         {
239                 __pButtonCall->SetPressedBackgroundBitmap(*pBgPressed);
240                 delete pBgPressed;
241                 pBgPressed = null;
242         }
243         if (pCallNormal != null)
244         {
245                 __pButtonCall->SetNormalBitmap(Point(0, 0), *pCallNormal);
246                 delete pCallNormal;
247                 pCallNormal = null;
248         }
249         if (pCallPressed != null)
250         {
251                 __pButtonCall->SetPressedBitmap(Point(0, 0), *pCallPressed);
252                 delete pCallPressed;
253                 pCallPressed = null;
254         }
255
256         pBgNormal = pAppResource->GetBitmapN(IDB_CIRCLE_BUTTON_NORMAL ,BITMAP_PIXEL_FORMAT_ARGB8888);
257         pBgPressed = pAppResource->GetBitmapN(IDB_CIRCLE_BUTTON_PRESSED ,BITMAP_PIXEL_FORMAT_ARGB8888);
258         Bitmap* pMsgNormal = pAppResource->GetBitmapN(IDB_LOG_DETAIL_MSG_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888);
259         Bitmap* pMsgPressed = pAppResource->GetBitmapN(IDB_LOG_DETAIL_MSG_PRESSED_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888);
260
261         __pButtonMessage = static_cast<Button*>(GetControl(IDC_BUTTON_MESSAGE));
262         if (__pButtonMessage != null)
263         {
264                 __pButtonMessage->SetActionId(IDA_CALL_LOG_MESSAGE);
265                 __pButtonMessage->AddActionEventListener(*this);
266         }
267         if (pBgNormal != null)
268         {
269                 __pButtonMessage->SetNormalBackgroundBitmap(*pBgNormal);
270                 delete pBgNormal;
271                 pBgNormal = null;
272         }
273         if (pBgPressed != null)
274         {
275                 __pButtonMessage->SetPressedBackgroundBitmap(*pBgPressed);
276                 delete pBgPressed;
277                 pBgPressed = null;
278         }
279         if (pMsgNormal != null)
280         {
281                 __pButtonMessage->SetNormalBitmap(Point(0, 0), *pMsgNormal);
282                 delete pMsgNormal;
283                 pMsgNormal = null;
284         }
285         if (pMsgPressed != null)
286         {
287                 __pButtonMessage->SetPressedBitmap(Point(0, 0), *pMsgPressed);
288                 delete pMsgPressed;
289                 pMsgPressed = null;
290         }
291
292         __pSelectAll = static_cast<CheckButton*>(GetControl(IDC_SELECTALL));
293         if(__pSelectAll != null)
294         {
295                 __pSelectAll->SetActionId(IDA_SELECT_ALL_CHECKED, IDA_SELECT_ALL_UNCHECKED);
296                 __pSelectAll->SetSize(GetClientAreaBounds().width, 112);
297                 __pSelectAll->SetShowState(false);
298                 __pSelectAll->AddActionEventListener(*this);
299         }
300         __pList = new (std::nothrow) GroupedListView();
301         if (__pList != null)
302         {
303                 __listHeight = GetClientAreaBounds().height - __pButtonContactImage->GetBounds().height - __pButtonMessage->GetBounds().height - 40;
304                 int listY = __pButtonContactImage->GetBounds().height + __pButtonMessage->GetBounds().height + 40;
305                 __pList->Construct(Rectangle(0, listY, GetClientAreaBounds().width, __listHeight), GROUPED_LIST_VIEW_STYLE_INDEXED, true, SCROLL_STYLE_FADE_OUT);
306
307                 __pList->AddGroupedListViewItemEventListener(*this);
308                 r = AddControl(__pList);
309                 TryCatch(r == E_SUCCESS, , "call log detail list control not added");
310         }
311
312         __pSelectedLabel = static_cast<Label*>(GetControl(IDC_LABEL_DETAIL_SELECTED));
313         if(__pSelectedLabel != null)
314         {
315                 SetControlAlwaysOnTop(*__pSelectedLabel,true);
316                 __pSelectedLabel->SetBackgroundColor(COLOR_DELAIL_LABEL_SELECTED);
317                 __pSelectedLabel->SetShowState(false);
318         }
319         return r;
320 CATCH:
321         return r;
322 }
323
324 result
325 DlLogsDetailForm::OnTerminating(void)
326 {
327         result r = E_SUCCESS;
328
329         return r;
330 }
331
332 bool
333 DlLogsDetailForm::DeleteSelectedCalllog(void)
334 {
335
336         return false;
337 }
338
339
340 void
341 DlLogsDetailForm::OnActionPerformed(const Control& source, int actionId)
342 {
343         switch (actionId)
344         {
345
346         case IDA_CALL_LOG_CALL:
347         {
348                 if(__isCallAppControlLaunched == true)
349                 {
350                         AppLogDebug("Call AppControl is already launched");
351                         return;
352                 }
353                 if (__number.IsEmpty() == false)
354                 {
355                         PhoneApp* pPhoneApp = static_cast<PhoneApp*>(UiApp::GetInstance());
356                         if (pPhoneApp->IsOpenAsAppControl() == false)
357                         {
358                         CalLogPresentationModel* pLogPresentor = CalLogPresentationModel::GetInstance();
359                         pLogPresentor->DialCall(__number);
360                                 __isCallAppControlLaunched = true;
361                         }
362                         else
363                         {
364                                 //launched as AppControl
365                                 HashMap resultData;
366                                 resultData.Construct();
367                                 resultData.Add(new (std::nothrow) String(PARAM_PHONE_NUMBER), new (std::nothrow) String(__number));
368                                 //send "APP_CTRL_RESULT_SUCCEEDED" and 'contactNumber' as result.
369                                 pPhoneApp->SendAppControlResponseMessage(APP_CTRL_RESULT_SUCCEEDED, &resultData);
370                                 resultData.RemoveAll(true);
371                                 pPhoneApp->Terminate();
372                         }
373                 }
374         }
375         break;
376
377         case IDA_CALL_LOG_MESSAGE:
378         {
379                 if(__isMsgAppControlLaunched == true)
380                 {
381                         //Message AppControl is already launched
382                         return;
383                 }
384
385                 //launch message
386                 __isMsgAppControlLaunched = true;
387                 result r = E_SUCCESS;
388                 HashMap extraData;
389                 extraData.Construct();
390
391                 extraData.Add(new (std::nothrow) String(MESSAGE_TYPE), new (std::nothrow) String(MESSAGE_SMS_TYPE));
392                 extraData.Add(new (std::nothrow) String(MESSAGE_TO), new (std::nothrow) String(__number));
393
394                 AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE);
395                 if (pAc != null)
396                 {
397                         r = pAc->Start(null, null, &extraData, this);
398                         if(r != E_SUCCESS)
399                         {
400                                 //AppControl failed.
401                                 __isMsgAppControlLaunched = false;
402                         }
403                         delete pAc;
404                 }
405                 extraData.RemoveAll(true);
406         }
407         break;
408
409         case IDA_FOOTER_BUTTON_LEFT:
410         {
411                 if(__isContactAppControlLaunched == true || __isMsgAppControlLaunched == true || __isCallAppControlLaunched == true)
412                 {
413                         AppLog("AppControl lunching. Can not do delete operation");
414                         return;
415                 }
416                 const wchar_t* pContact = __number.GetPointer();
417                 int len = __number.GetLength() + 1;
418                 char* pNumber = new (std::nothrow) char[len];
419                 wcstombs(pNumber, pContact, len);
420                 if (__isEditMode == false)
421                 {
422                         SetFormMode(true);
423                         UnCheckAllItems();
424                         __calllogListByNum = __pLogPresentor->GetCallogListByNumberFromDatabaseN(pNumber);
425                         __pList->UpdateList();
426                         __pList->Invalidate(false);
427                 }
428                 else
429                 {
430                         ShowDeletePopup();
431                 }
432                 delete[] pNumber;
433                 pNumber = null;
434         }
435         break;
436
437         case IDA_FOOTER_BUTTON_RIGHT:
438         {
439                 __pCallLogId->RemoveAll();
440                 UpdateForm();
441                 SetFormMode(false);
442                 __pList->UpdateList();
443         }
444         break;
445
446         case IDA_SELECT_ALL_UNCHECKED:
447         {
448                 SetListItemSelectStatus(false);
449                 __pCallLogId->RemoveAll();
450                 __selectedItemCount = 0;
451                 String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
452                 __pSelectedLabel->SetText(selStr);
453                 __pSelectedLabel->Invalidate(false);
454         }
455         break;
456         case IDA_SELECT_ALL_CHECKED:
457         {
458                 __pCallLogId->RemoveAll();
459                 SetAllListItems(true);
460                 __selectedItemCount = __listItemCount;
461                 String text;
462                 String selItemStr = L"";
463                 if(__selectedItemCount > 1)
464                 {
465                         selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
466                 }
467                 else
468                 {
469                         selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
470                 }
471                 text.Format(100, selItemStr.GetPointer(), __listItemCount);
472                 __pSelectedLabel->SetText(text);
473                 __pSelectedLabel->Invalidate(false);
474         }
475         break;
476         case IDA_POPUP_DELETE_CANCEL:
477         {
478                 __deleteLogsTimer.Cancel();
479                 HideDeletePopup();
480         }
481         break;
482
483         case IDA_CONTEXTMENU_DETAILS:
484         {
485                 ViewContactDetail();
486         }
487         break;
488
489         case IDA_CONTEXTMENU_ADDTOCONTACT:
490         {
491                 result r = __pLogPresentor->LaunchAddContactsAppControl(__number);
492                 if(r == E_SUCCESS)
493                 {
494                         __isContactAppControlLaunched = true;
495                 }
496         }
497         break;
498
499         case IDA_CONTEXTMENU_BLOCK:
500         {
501                 ShowBlockPopup();\r
502         }
503         break;
504
505         default:
506                 break;
507         }
508 }
509
510 void
511 DlLogsDetailForm::GetUpdatedListFromDatabase(char* number)
512 {
513         AppLogDebug("Enter");
514         if(__calllogListByNum != null)
515         {
516                 AppLog(" list already present, UPDATE");
517                 __calllogListByNum->RemoveAll();
518                 delete __calllogListByNum;
519         }
520
521         __calllogListByNum = __pLogPresentor->GetCallogListByNumberFromDatabaseN(number);
522         __calllogCount = __pLogPresentor->GetCalllogCountByNumber();
523 }
524
525 void
526 DlLogsDetailForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
527 {
528         AppLogDebug("Enter");
529         PhoneApp* pPhoneApp = static_cast<PhoneApp*>(PhoneApp::GetInstance());
530         pPhoneApp->AddAppStateChangeListener(*this);
531         Tizen::System::SettingInfo::AddSettingEventListener(*this);
532         __pLogPresentor = CalLogPresentationModel::GetInstance();
533         __pLogPresentor->AddCalllogChangeListener(*this);
534         __isPresentInContacts = false;
535         __selectedItemCount =0;
536         __isMsgAppControlLaunched = false;
537         __isCallAppControlLaunched = false;
538         if(pArgs != null)
539         {
540                 __number.Clear();
541                 String* pNumberStr = static_cast<String*> (pArgs->GetAt(0));
542                 __number.Append(*pNumberStr);
543                 //UpdateForm();
544                 pArgs->RemoveAll();
545                 delete pArgs;
546                 pArgs = null;
547         }
548         __pList->SetItemProvider(*__pDataProvider);
549         UpdateForm();
550         SetFormMode(false);
551         SetSceneVisible(true);
552 }
553
554 void
555 DlLogsDetailForm::UpdateForm(void)
556 {
557         AppLogDebug("Enter");
558         SettingsPresentationModel* pSettingsPresentationModel = SettingsPresentationModel::GetInstance();
559         bool isCallToBeRejected = pSettingsPresentationModel->IsCallToBeRejected(__number);
560         __isCallBeRejected = isCallToBeRejected;
561         __isPresentInContacts = false;
562
563         const wchar_t* pContact = __number.GetPointer();
564         int len = __number.GetLength() + 1;
565         char* pNumber = new (std::nothrow) char[len];
566         wcstombs(pNumber, pContact, len);
567
568         GetUpdatedListFromDatabase(pNumber);
569         delete[] pNumber;
570         AppLog("__calllogCount = %d", __calllogCount);
571         if(__calllogCount == 0)
572         {
573                 return;
574         }
575         __contactName = L"";
576         Bitmap* pBitmap = null;
577         Addressbook* pAddressBook =  AddressbookManager::GetInstance()->GetAddressbookN();
578         if (pAddressBook != null)
579         {
580                 IList* pNumberContactsList = null;
581                 if(__number.Contains(L"@"))
582                 {
583                         pNumberContactsList = pAddressBook->SearchContactsByEmailN(__number);
584                 }
585                 else
586                 {
587                         pNumberContactsList = pAddressBook->SearchContactsByPhoneNumberN(__number);
588                 }
589                 if(pNumberContactsList != null)
590                 {
591                         IEnumerator* pContactListEnum = pNumberContactsList->GetEnumeratorN();
592                         while (pContactListEnum->MoveNext() == E_SUCCESS)
593                         {
594                                 Contact* pContact = static_cast<Contact*>(pContactListEnum->GetCurrent());
595                                 if(pContact != null)
596                                 {
597                                         IList* pPhoneNumberList = null;
598                                         if(__number.Contains(L"@"))
599                                         {
600                                                 pPhoneNumberList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_EMAILS);
601                                                 if (pPhoneNumberList != null)
602                                                 {
603                                                         IEnumerator* pEnum = pPhoneNumberList->GetEnumeratorN();
604                                                         while (E_SUCCESS == pEnum->MoveNext())
605                                                         {
606                                                                 Email* pPhoneNumber = (Email*) pEnum->GetCurrent();
607                                                                 if(pPhoneNumber->GetEmail().Equals(__number) == true)
608                                                                 {
609                                                                         __isPresentInContacts = true;
610                                                                         break;
611                                                                 }
612                                                         }
613                                                         delete pEnum;
614                                                         pPhoneNumberList->RemoveAll(true);
615                                                         delete pPhoneNumberList;
616                                                 }
617                                         }
618                                         else
619                                         {
620                                                 pPhoneNumberList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
621                                                 if (pPhoneNumberList != null)
622                                                 {
623                                                         IEnumerator* pEnum = pPhoneNumberList->GetEnumeratorN();
624                                                         while (E_SUCCESS == pEnum->MoveNext())
625                                                         {
626                                                                 PhoneNumber* pPhoneNumber = (PhoneNumber*) pEnum->GetCurrent();
627                                                                 if(pPhoneNumber->GetPhoneNumber().Equals(__number) == true)
628                                                                 {
629                                                                         __isPresentInContacts = true;
630                                                                         break;
631                                                                 }
632                                                         }
633                                                         delete pEnum;
634                                                         pPhoneNumberList->RemoveAll(true);
635                                                         delete pPhoneNumberList;
636                                                 }
637                                         }
638
639
640                                         if(__isPresentInContacts == true)
641                                         {
642                                                 //fetch contact name
643                                                 __contactName.Clear();
644                                                 pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, __contactName);
645                                                 //fetch person's photo
646                                                 pBitmap = pContact->GetThumbnailN(); //In case of big image, it will return null.
647                                                 if(pBitmap == null)
648                                                 {
649                                                         AppLog("Fetch big image");
650                                                         String thumbnailPath;
651                                                         pContact->GetValue(CONTACT_PROPERTY_ID_THUMBNAIL, thumbnailPath);
652                                                         if(thumbnailPath.IsEmpty() == true)
653                                                         {
654                                                                 IList* pCategoryList = pAddressBook->GetCategoriesByContactN(pContact->GetRecordId());
655                                                                 if(pCategoryList != null && pCategoryList->GetCount() > 0)
656                                                                 {
657                                                                         AppLogDebug("Changes to get thumbnail group photo");
658                                                                         Category* pCategory = static_cast<Category*>(pCategoryList->GetAt(0));
659                                                                         thumbnailPath = pCategory->GetThumbnailPath();
660                                                                 }
661                                                         }
662                                                         ImageBuffer thumbnailImageBuffer;
663                                                         if (thumbnailImageBuffer.Construct(thumbnailPath) == E_SUCCESS)
664                                                         {
665                                                                 pBitmap = thumbnailImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, BUFFER_SCALING_NONE);
666                                                         }
667                                                 }
668                                                 ManageUserDetail();
669                                                 //todo: set the contact button image
670                                                 Canvas* pCanvas = null;
671                                                 pCanvas = new (std::nothrow) Canvas();
672                                                 pCanvas->Construct(Rectangle(0,0,__pButtonContactImage->GetBounds().width,__pButtonContactImage->GetBounds().height));
673                                                 //set bitmap to button
674                                                 if (pBitmap == null)
675                                                 {
676                                                         pBitmap = AppUtility::GetBitmapFromResourcesN(L"C01-1_icon_contacts.png", W_CONTACT_BITMAP_ITEM, H_CONTACT_BITMAP_ITEM);
677                                                 }
678                                                 else
679                                                 {
680                                                         //scale bitmap to predefined size
681                                                         pBitmap->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
682                                                         pBitmap->Scale(Dimension(W_CONTACT_BITMAP_ITEM, H_CONTACT_BITMAP_ITEM));
683                                                 }
684
685                                                 pCanvas->DrawBitmap(Rectangle(Point(0, 0), Dimension(pBitmap->GetWidth(), pBitmap->GetHeight())), *pBitmap);
686                                                 delete pBitmap;
687                                                 pBitmap = null;
688                                                 //TODO: chk whether the number is blocked and add icon in top right
689                                                 bool isMsgBeRejected = SettingsPresentationModel::GetInstance()->GetMsgFilterListIndex(__number);
690                                                 if (isCallToBeRejected == true || isMsgBeRejected == true)
691                                                 {
692                                                         pBitmap = AppUtility::GetBitmapFromResourcesN(L"C01-4_icon_Blocked.png", W_BLOCKED_ICON, H_BLOCKED_ICON);
693                                                         pCanvas->DrawBitmap(Rectangle(Point(86, 0), Dimension(pBitmap->GetWidth(), pBitmap->GetHeight())), *pBitmap);
694                                                         delete pBitmap;
695                                                         pBitmap = null;
696                                                 }
697                                                 if(__isEditMode == false)
698                                                 {
699                                                         Bitmap* pActualBgBmp = new Bitmap();
700                                                         pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds());
701                                                         __pButtonContactImage->SetNormalBackgroundBitmap(*pActualBgBmp);
702                                                         __pButtonContactImage->SetPressedBackgroundBitmap(*pActualBgBmp);
703                                                         __pButtonContactImage->SetHighlightedBackgroundBitmap(*pActualBgBmp);
704                                                         __pButtonContactImage->SetShowState(true);
705                                                         __pButtonContactImage->Invalidate(false);
706                                                         delete pCanvas;
707                                                         delete pActualBgBmp;
708                                                 }
709                                                 break;
710                                         }
711                                 }
712                         }
713                         delete pContactListEnum;
714                         pNumberContactsList->RemoveAll(true);
715                         delete pNumberContactsList;
716                         delete pAddressBook;
717                         pAddressBook = null;
718                 }
719         }
720
721         if (__isPresentInContacts == false)
722         {
723                 __isPresentInContacts = false;
724                 //not in contacts rearrage the icons
725                 ManageUserDetail();
726                 //if(__isEditMode == false)
727                 {
728                         //todo set bitmap
729                         bool isMsgBeRejected = SettingsPresentationModel::GetInstance()->GetMsgFilterListIndex(__number);
730                         if (isCallToBeRejected == true || isMsgBeRejected == true)
731                         {
732                                 pBitmap = AppUtility::GetBitmapFromResourcesN(L"C01-4_icon_Blocked.png", W_BLOCKED_ICON, H_BLOCKED_ICON);
733                                 __pLabelBlocked->SetBackgroundBitmap(*pBitmap);
734                                 delete pBitmap;
735                                 pBitmap = null;
736                         }
737                         else
738                         {
739                                 Canvas* pCanvas = null;
740                                 pCanvas = new (std::nothrow) Canvas();
741                                 pCanvas->Construct(Rectangle(0,0,__pLabelBlocked->GetBounds().width,__pButtonContactImage->GetBounds().height));
742                                 Bitmap* pActualBgBmp = new Bitmap();
743                                 pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds());
744                                 __pLabelBlocked->SetBackgroundBitmap(*pActualBgBmp);
745                                 delete pCanvas;
746                                 delete pActualBgBmp;
747                         }
748                         __pLabelBlocked->SetShowState(true);
749                         __pLabelBlocked->Invalidate(false);
750                 }
751         }
752         if (__pDataProvider != null)
753         {
754                 __pDataProvider->ResetDetailsList();
755         }
756         __pList->UpdateList();
757         __pList->Invalidate(true);
758         if(__number.Contains(L"@"))
759         {
760                 __pButtonCall->SetEnabled(false);
761         }
762         else
763         {
764                 __pButtonCall->SetEnabled(true);
765         }
766 }
767
768 void
769 DlLogsDetailForm::ManageUserDetail()
770 {
771         if(__isEditMode == false)
772         {
773                 AppLogDebug("Enter");
774                 float fontSize;
775                 float itemHeight;
776                 AppUtility::GetGlobalFontAndItemHeight(&fontSize, &itemHeight);
777                 if(fontSize == 44.0f)
778                 {
779                         fontSize = 50.0f; //normal fort size
780                 }
781                 if(__isPresentInContacts == true)
782                 {
783                         String contactNameStr;
784                         contactNameStr.Format(100, L"%ls",__contactName.GetPointer(), __calllogCount);
785                         TextElement* pTextElement = new (std::nothrow) TextElement();
786                         pTextElement->Construct(contactNameStr);
787                         Font* ContactNameTextfont = new (std::nothrow) Font();
788                         ContactNameTextfont->Construct(FONT_STYLE_BOLD, fontSize);
789                         FloatDimension textDimension;
790                         ContactNameTextfont->GetTextExtent(contactNameStr, contactNameStr.GetLength(), textDimension);
791                         float width = 0.0;
792                         String countString = L"(" + Integer::ToString(__calllogCount) + L")";
793                         float countStringWidth = 0.0;
794                         float stringHeight = 0.0;
795                         GetTextWidthHeight(countString, fontSize, &countStringWidth, &stringHeight);
796                         __pPanelName->SetSize(__pPanelName->GetWidthF(), stringHeight);
797                         width = __pPanelName->GetWidthF() - countStringWidth;
798                         Label* pLabelName = static_cast<Label*>(GetControl(IDC_LABEL_NAME, true));
799                         Label* pLabelCount = static_cast<Label*>(GetControl(IDC_LABEL_NUMBER_COUNT, true));
800                         if(pLabelName != null && pLabelCount != null)
801                         {
802                                 pLabelName->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
803                                 pLabelCount->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
804
805                                 pLabelName->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
806                                 pLabelCount->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
807                                 if(textDimension.width > width)
808                                 {
809                                         pLabelName->SetBounds(FloatRectangle(0, 0, width, __pPanelName->GetHeightF()));
810                                         pLabelName->SetText(contactNameStr);
811                                         pLabelName->SetShowState(true);
812                                         pLabelName->Invalidate(false);
813
814                                         pLabelCount->SetBounds(FloatRectangle(width, 0, __pPanelName->GetWidthF() - countStringWidth, __pPanelName->GetHeightF()));
815                                         pLabelCount->SetText(countString);
816                                         pLabelCount->SetShowState(true);
817                                         pLabelCount->Invalidate(false);
818                                 }
819                                 else
820                                 {
821                                         contactNameStr.Format(100, L"%ls (%d)",__contactName.GetPointer(), __calllogCount);
822                                         pLabelName->SetBounds(FloatRectangle(0, 0, __pPanelName->GetWidthF(), __pPanelName->GetHeightF()));
823                                         pLabelName->SetText(contactNameStr);
824                                         pLabelName->SetShowState(true);
825                                         pLabelName->Invalidate(false);
826                                         pLabelCount->SetShowState(false);
827                                 }
828                         }
829
830                         __pPanelName->SetShowState(true);
831                         __pPanelName->Invalidate(true);
832                         __pLabelNumber->SetText(__number);
833                         __pLabelNumber->SetShowState(true);
834                         __pLabelNumber->Invalidate(false);
835                         __pPanelNumberUnsaved->SetShowState(false);
836                         __pPanelNumberUnsaved->Invalidate(true);
837                         __pLabelBlocked->SetShowState(false);
838                         __pLabelBlocked->Invalidate(false);
839                 }
840                 else
841                 {
842                         String contactNameStr;
843                         contactNameStr.Format(100, L"%ls",__number.GetPointer(), __calllogCount);
844                         TextElement* pTextElement = new (std::nothrow) TextElement();
845                         pTextElement->Construct(contactNameStr);
846                         Font* ContactNameTextfont = new (std::nothrow) Font();
847                         ContactNameTextfont->Construct(FONT_STYLE_BOLD, fontSize);
848                         FloatDimension textDimension;
849                         ContactNameTextfont->GetTextExtent(contactNameStr, contactNameStr.GetLength(), textDimension);
850                         float width = 0.0;
851                         String countString = L"(" + Integer::ToString(__calllogCount) + L")";
852                         float countStringWidth = 0.0;
853                         float stringHeight = 0.0;
854                         GetTextWidthHeight(countString, fontSize, &countStringWidth, &stringHeight);
855                         __pPanelNumberUnsaved->SetSize(__pPanelNumberUnsaved->GetWidthF(), stringHeight);
856                         width = __pPanelNumberUnsaved->GetWidthF() - countStringWidth;
857                         Label* pLabelNumber = static_cast<Label*>(GetControl(IDC_LABEL_UNSAVED_NUMBER, true));
858                         Label* pLabelCount = static_cast<Label*>(GetControl(IDC_LABEL_COUNT, true));
859
860                         if(pLabelNumber != null && pLabelCount != null)
861                         {
862                                 pLabelNumber->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
863                                 pLabelCount->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
864
865                                 pLabelNumber->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
866                                 pLabelCount->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
867                                 if(textDimension.width > width)
868                                 {
869                                         pLabelNumber->SetBounds(FloatRectangle(0, 0, width, __pPanelNumberUnsaved->GetHeightF()));
870                                         pLabelNumber->SetText(contactNameStr);
871                                         pLabelNumber->SetShowState(true);
872                                         pLabelNumber->Invalidate(false);
873
874                                         pLabelCount->SetBounds(FloatRectangle(width, 0, __pPanelNumberUnsaved->GetWidthF() - countStringWidth, __pPanelNumberUnsaved->GetHeightF()));
875                                         pLabelCount->SetText(countString);
876                                         pLabelCount->SetShowState(true);
877                                         pLabelCount->Invalidate(false);
878                                 }
879                                 else
880                                 {
881                                         pLabelNumber->SetBounds(FloatRectangle(0, 0, __pPanelNumberUnsaved->GetWidthF(), __pPanelNumberUnsaved->GetHeightF()));
882                                         contactNameStr.Format(100, L"%ls (%d)",__number.GetPointer(), __calllogCount);
883                                         pLabelNumber->SetText(contactNameStr);
884                                         pLabelNumber->SetShowState(true);
885                                         pLabelNumber->Invalidate(false);
886                                         pLabelCount->SetShowState(false);
887                                 }
888                         }
889
890                         __pPanelNumberUnsaved->SetShowState(true);
891                         __pPanelNumberUnsaved->Invalidate(true);
892                         __pPanelName->SetShowState(false);
893                         __pPanelName->Invalidate(true);
894                         __pLabelNumber->SetShowState(false);
895                         __pLabelNumber->Invalidate(false);
896                         __pButtonContactImage->SetShowState(false);
897                         __pButtonContactImage->Invalidate(true);
898                 }
899         }
900 }
901
902 void
903 DlLogsDetailForm::GetTextWidthHeight(String str, float fontSize, float *width, float *height)
904 {
905         TextElement* pTextElement = new (std::nothrow) TextElement();
906         pTextElement->Construct(str);
907         Font* ContactNameTextfont = new (std::nothrow) Font();
908         ContactNameTextfont->Construct(FONT_STYLE_BOLD, fontSize);
909         FloatDimension textDimension;
910         ContactNameTextfont->GetTextExtent(str, str.GetLength(), textDimension);
911         *width = textDimension.width;
912         *height = textDimension.height;
913 }
914
915 void
916 DlLogsDetailForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
917 {
918         PhoneApp* pPhoneApp = static_cast<PhoneApp*>(PhoneApp::GetInstance());
919         pPhoneApp->RemoveAppStateChangeListener(*this);
920         Tizen::System::SettingInfo::RemoveSettingEventListener(*this);
921         SetSceneVisible(false);
922         __pLogPresentor->RemoveCalllogChangeListner(*this);
923         if (__pDataProvider != null)
924         {
925                 __pDataProvider->ResetDetailsList();
926         }
927         if (__pLogPresentor != null)
928         {
929                 __pLogPresentor = null;
930         }
931 }
932
933
934 void
935 DlLogsDetailForm::SetFormMode(bool editMode)
936 {
937         AppLogDebug("Enter");
938         if (editMode == false)
939         {
940                 //UpdateForm();
941                 __isEditMode = false;
942                 __pSelectAll->SetShowState(false);
943                 __pDataProvider->SetViewMode(false);
944                 __pFormFooter->RemoveItemAt(1);
945                 if (__isPresentInContacts == false)
946                 {
947                         __pLabelBlocked->SetShowState(true);
948                         __pPanelNumberUnsaved->SetShowState(true);
949                         __pPanelName->SetShowState(false);
950                         __pLabelNumber->SetShowState(false);
951                         __pButtonContactImage->SetShowState(false);
952                 }
953                 else
954                 {
955                         __pPanelNumberUnsaved->SetShowState(false);
956                         __pLabelBlocked->SetShowState(false);
957                         __pPanelName->SetShowState(true);
958                         __pLabelNumber->SetShowState(true);
959                         __pButtonContactImage->SetShowState(true);
960                 }
961                 __pButtonCall->SetShowState(true);
962                 __pButtonMessage->SetShowState(true);
963                 int listY = __pButtonContactImage->GetBounds().height + __pButtonMessage->GetBounds().height + 40;
964                 __listHeight = GetClientAreaBounds().height - __pButtonContactImage->GetBounds().height - __pButtonMessage->GetBounds().height - 40;
965                 __pList->SetBounds(Rectangle(0, listY, GetClientAreaBounds().width, __listHeight));
966                 __listItemCount = __pLogPresentor->GetCalllogCountByNumber();
967                 __pFormFooter->SetItemEnabled(0, true);
968                 __pList->RemoveGroupedListViewItemEventListener(*this);
969                 __pSelectAll->SetSelected(false);
970                 __pSelectedLabel->SetShowState(false);
971                 __pSelectedLabel->Invalidate(false);
972                 __pList->Invalidate(true);
973         }
974         else
975         {
976                 __isEditMode = true;
977                 __pSelectAll->SetShowState(true);
978                 __pDataProvider->SetViewMode(true);
979                 __pFormFooter->AddItem(__pFooterItemCancel);
980                 __pList->AddGroupedListViewItemEventListener(*this);
981                 if (__isPresentInContacts == false)
982                 {
983                         __pLabelBlocked->SetShowState(false);
984                         __pPanelNumberUnsaved->SetShowState(false);
985                         __pPanelName->SetShowState(false);
986                         __pLabelNumber->SetShowState(false);
987                         __pButtonContactImage->SetShowState(false);
988                 }
989                 else
990                 {
991                         __pPanelNumberUnsaved->SetShowState(false);
992                         __pLabelBlocked->SetShowState(false);
993                         __pPanelName->SetShowState(false);
994                         __pLabelNumber->SetShowState(false);
995                         __pButtonContactImage->SetShowState(false);
996                 }
997                 __pButtonCall->SetShowState(false);
998                 __pButtonMessage->SetShowState(false);
999                 __pList->SetBounds(GetClientAreaBounds().x, __pSelectAll->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - (__pSelectAll->GetHeight()+__pSelectedLabel->GetHeight()));
1000                 __listItemCount = __pLogPresentor->GetCalllogCountByNumber();
1001                 __pFormFooter->SetItemEnabled(0, false);
1002                 __selectedItemCount = 0;
1003                 String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
1004                 __pSelectedLabel->SetText(selStr);
1005                 __pSelectedLabel->SetShowState(true);
1006                 __pSelectedLabel->Invalidate(false);
1007         }
1008         __pSelectAll->Invalidate(true);
1009         if(__number.Contains(L"@"))
1010         {
1011                 __pButtonCall->SetEnabled(false);
1012         }
1013         else
1014         {
1015                 __pButtonCall->SetEnabled(true);
1016         }
1017         __pButtonCall->Draw();
1018         __pFormFooter->Draw();
1019 }
1020
1021 void
1022 DlLogsDetailForm::UnCheckAllItems(void)
1023 {
1024         AppLogDebug("Enter");
1025         SetListItemSelectStatus(false);
1026         __selectedItemCount = 0;
1027 }
1028 void
1029 DlLogsDetailForm::SetAllListItems(bool checked)
1030 {
1031         AppLogDebug("Enter");
1032         SetListItemSelectStatus(true);
1033         __listItemCount = __pLogPresentor->GetCalllogCountByNumber();
1034         __selectedItemCount = __listItemCount;
1035         String text;
1036         String selItemStr = L"";
1037         if(__selectedItemCount > 1)
1038         {
1039                 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
1040         }
1041         else
1042         {
1043                 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
1044         }
1045         text.Format(100, selItemStr.GetPointer(), __listItemCount);
1046         __pSelectedLabel->SetText(text);
1047         __pSelectedLabel->Invalidate(false);
1048 }
1049
1050 void
1051 DlLogsDetailForm::SetListItemSelectStatus(bool status)
1052 {
1053         int groupIndex = 0;
1054         int itemIndex = 0;
1055         int itemCount = 0;
1056
1057         __isSelectAll = status;
1058         CallLogDetails* pCalllogInfo = null;
1059         for (; groupIndex < __pList->GetGroupCount(); groupIndex++)
1060         {
1061                 itemCount = __pList->GetItemCountAt(groupIndex);
1062                 for (itemIndex = 0; itemIndex < itemCount; itemIndex++)
1063                 {
1064                         __pList->SetItemChecked(groupIndex, itemIndex, status);
1065                         if(status == true)
1066                         {
1067                                 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1068                                 __pCallLogId->Add(new Integer(pCalllogInfo->GetCalllogDbId()));
1069                         }
1070                 }
1071         }
1072         __pFormFooter->SetItemEnabled(0, status);
1073         __pFormFooter->Invalidate(true);
1074         __pList->Invalidate(true);
1075 }
1076
1077 void
1078 DlLogsDetailForm::OnFormBackRequested(Form& source)
1079 {
1080         AppLog("Enter");
1081         SceneManager* pSceneManager = SceneManager::GetInstance();
1082         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CALL_LOG, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
1083                                                                                                                         SCENE_HISTORY_OPTION_NO_HISTORY));
1084 }
1085
1086 void
1087 DlLogsDetailForm::OnAppControlCompleteResponseReceived(const AppId& appId, const String& operationId, AppCtrlResult appControlResult, const IMap* pExtraData)
1088 {
1089         if (__isMsgAppControlLaunched == true)
1090         {
1091                 //Message AppControl request completed.
1092                 __isMsgAppControlLaunched = false;
1093         }
1094         if (__isCallAppControlLaunched == true)
1095         {
1096                 //Call AppControl request completed.
1097                 __isCallAppControlLaunched = false;
1098         }
1099 }
1100 void
1101 DlLogsDetailForm::ShowDeletePopup(void)
1102 {
1103         __isDeleteInProgress = true;
1104         if (__pDeletePopup != null)
1105         {
1106                 delete __pDeletePopup;
1107                 __pDeletePopup = null;
1108         }
1109         __deleteGroupIndex = 0;
1110         __deleteItemIndex = 0;
1111         __pDeletePopup = new (std::nothrow) Popup();
1112         __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
1113         __pDeletePopup->AddWindowEventListener(*this);
1114         __pDeletePopup->SetPropagatedKeyEventListener(this);
1115
1116         Rectangle clientBounds = __pDeletePopup->GetClientAreaBounds();
1117
1118         Label* pLabelTitle = new (std::nothrow) Label();
1119         pLabelTitle->Construct(Rectangle(0, Y_DELETE_POPUP_TITLE, clientBounds.width, H_DELETE_POPUP_ELEMENT), AppUtility::GetResourceString(IDS_DELETING_CALL_LOGS));
1120         pLabelTitle->SetTextColor(COLOR_DELETE_POPUP_TEXT);
1121         pLabelTitle->SetTextConfig(FONT_SIZE_DELETE_POPUP_TEXT, LABEL_TEXT_STYLE_BOLD);
1122         pLabelTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1123
1124         __pDeletePopup->AddControl(*pLabelTitle);
1125
1126         Progress* pProgress = new (std::nothrow) Progress();
1127         pProgress->Construct(Rectangle(0, Y_DELETE_POPUP_TITLE + H_DELETE_POPUP_ELEMENT, clientBounds.width, H_DELETE_POPUP_PROGRESS), 0, __selectedItemCount);
1128
1129         __pDeletePopup->AddControl(*pProgress);
1130
1131         Label* pLabelPercentage = new (std::nothrow) Label();
1132         pLabelPercentage->Construct(Rectangle(0, pProgress->GetY() + pProgress->GetHeight(), clientBounds.width / 2, H_DELETE_POPUP_ELEMENT), Integer::ToString(pProgress->GetPercentComplete()) + L"%");
1133         pLabelPercentage->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1134         pLabelPercentage->SetTextColor(COLOR_DELETE_POPUP_TEXT);
1135         pLabelPercentage->SetTextConfig(FONT_SIZE_DELETE_POPUP_TEXT, LABEL_TEXT_STYLE_NORMAL);
1136
1137         __pDeletePopup->AddControl(*pLabelPercentage);
1138
1139         String currentOfTotal(Integer::ToString(pProgress->GetValue()) + L" / " + Integer::ToString(__selectedItemCount));
1140         Label* pLabelTotal = new (std::nothrow) Label();
1141         pLabelTotal->Construct(Rectangle(clientBounds.width / 2, pLabelPercentage->GetY(), clientBounds.width / 2, H_DELETE_POPUP_ELEMENT), currentOfTotal);
1142         pLabelTotal->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
1143         pLabelTotal->SetTextColor(COLOR_DELETE_POPUP_TEXT);
1144         pLabelTotal->SetTextConfig(FONT_SIZE_DELETE_POPUP_TEXT, LABEL_TEXT_STYLE_NORMAL);
1145
1146         __pDeletePopup->AddControl(*pLabelTotal);
1147
1148         Button* pCancelButton = new (std::nothrow) Button();
1149         pCancelButton->Construct(Rectangle((clientBounds.width - W_DELETE_POPUP_CANCEL_BUTTON) / 2, Y_DELETE_POPUP_CANCEL_BUTTON, W_DELETE_POPUP_CANCEL_BUTTON, H_DELETE_POPUP_CANCEL_BUTTON));
1150         pCancelButton->SetText(AppUtility::GetResourceString(IDS_CANCEL_DELETING_CALL_LOGS));
1151         pCancelButton->SetActionId(IDA_POPUP_DELETE_CANCEL);
1152         pCancelButton->AddActionEventListener(*this);
1153
1154         __pDeletePopup->AddControl(pCancelButton);
1155         __pDeletePopup->Show();
1156 }
1157
1158 void
1159 DlLogsDetailForm::OnWindowActivated (const Tizen::Ui::Window &source)
1160 {
1161         __deleteLogsTimer.Start(1);
1162 }
1163
1164 void
1165 DlLogsDetailForm::OnTimerExpired(Tizen::Base::Runtime::Timer &timer)
1166 {
1167         Progress* pProgress = static_cast<Progress *>(__pDeletePopup->GetControl(1));
1168
1169         pProgress->SetValue(pProgress->GetValue() + 1);
1170         pProgress->Invalidate(false);
1171
1172         Label* pLabelPercentage = static_cast<Label *>(__pDeletePopup->GetControl(2));
1173
1174         pLabelPercentage->SetText(Integer::ToString(pProgress->GetPercentComplete()) + L"%");
1175         pLabelPercentage->Invalidate(false);
1176
1177         Label* pLabelTotal = static_cast<Label *>(__pDeletePopup->GetControl(3));
1178
1179         String currentOfTotal = pLabelTotal->GetText();
1180         currentOfTotal.Remove(0, Integer::ToString(pProgress->GetValue() - 1).GetLength());
1181         currentOfTotal.Insert(Integer::ToString(pProgress->GetValue()), 0);
1182         pLabelTotal->SetText(currentOfTotal);
1183         pLabelTotal->Invalidate(false);
1184
1185         if (RemoveLogsList() == E_SUCCESS)
1186         {
1187                 __deleteLogsTimer.Start(1);
1188         }
1189         else
1190         {
1191                 HideDeletePopup();
1192         }
1193 }
1194
1195 result
1196 DlLogsDetailForm::RemoveLogsList()
1197 {
1198         result r = E_SUCCESS;
1199
1200                 CallLogDetails* pCalllogInfo = null;
1201                 for(int groupIndex = __deleteGroupIndex; groupIndex < __pList->GetGroupCount(); groupIndex++)
1202                 {
1203                         int itemCount = __pList->GetItemCountAt(groupIndex);
1204                         for(int itemIndex = __deleteItemIndex; itemIndex < itemCount; itemIndex++)
1205                         {
1206                                 bool isSelected = __pList->IsItemChecked(groupIndex, itemIndex);
1207                                 if(isSelected == true)
1208                                 {
1209                                         __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1210                                         if(pCalllogInfo != null)
1211                                         {
1212                                                 __pLogPresentor->DeleteCalllogByDbId(pCalllogInfo->GetCalllogDbId());
1213                                                 __pCallLogId->Remove(*(new Integer(pCalllogInfo->GetCalllogDbId())));
1214                                                 __deleteGroupIndex = groupIndex;
1215                                                 __deleteItemIndex = ++itemIndex;
1216                                                 return r;
1217                                         }
1218                                 }
1219                         }
1220                         __deleteItemIndex = 0;
1221                 }
1222                 __deleteGroupIndex = 0;
1223                 __deleteItemIndex = 0;
1224
1225                 return E_FAILURE;
1226 }
1227
1228 void
1229 DlLogsDetailForm::HideDeletePopup(void)
1230 {
1231         __isDeleteInProgress = false;
1232         __deleteGroupIndex = 0;
1233         __deleteItemIndex = 0;
1234         if (__pDeletePopup != null)
1235         {
1236                 __pDeletePopup->SetShowState(false);
1237                 __pDeletePopup->Invalidate(true);
1238         }
1239         if (__calllogListByNum->GetItemsN(0, __calllogListByNum->GetCount())->GetCount() != __selectedItemCount)
1240         {
1241                 const wchar_t* pContact = __number.GetPointer();
1242                 int len = __number.GetLength() + 1;
1243                 char* pNumber = new (std::nothrow) char[len];
1244                 wcstombs(pNumber, pContact, len);
1245                 __calllogListByNum = __pLogPresentor->GetCallogListByNumberFromDatabaseN(pNumber);
1246                 UpdateForm();
1247                 SetFormMode(false);
1248                 __pList->UpdateList();
1249         }
1250         else
1251         {
1252                 SetFormMode(false);
1253                 SceneManager* pSceneManager = SceneManager::GetInstance();
1254                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CALL_LOG, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
1255                                                                                                                                 SCENE_HISTORY_OPTION_NO_HISTORY));
1256         }
1257 }
1258
1259 void
1260 DlLogsDetailForm::OnForeground(void)
1261 {
1262         SetSceneVisible(true);
1263         if(__calllogCount == 0)
1264         {
1265                 UpdateForm();
1266                 SetFormMode(false);
1267                 SceneManager* pSceneManager = SceneManager::GetInstance();
1268                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CALL_LOG, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
1269                                                                                                                                                 SCENE_HISTORY_OPTION_NO_HISTORY));
1270                 return;
1271         }
1272         if(__isContactAppControlLaunched == false)
1273         {
1274                 ManageItemSelection();
1275         }
1276         else
1277         {
1278                 __isContactAppControlLaunched = false;
1279         }
1280         if(__isEditMode == false)
1281         {
1282                 UpdateForm();
1283         }
1284         if (__isMsgAppControlLaunched == true)
1285         {
1286                 //Message AppControl request completed.
1287                 __isMsgAppControlLaunched = false;
1288         }
1289         if(__isCallAppControlLaunched == true)
1290         {
1291                 __isCallAppControlLaunched = false;
1292         }
1293 }
1294
1295 void
1296 DlLogsDetailForm::OnBackground(void)
1297 {
1298         SetSceneVisible(false);
1299 }
1300
1301 void
1302 DlLogsDetailForm::OnGroupedListViewItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListItemStatus state)
1303 {
1304         String text;
1305         if (state == LIST_ITEM_STATUS_CHECKED)
1306         {
1307                 __selectedItemCount++;
1308                 StoreItemselection(groupIndex, itemIndex, elementId, state);
1309         }
1310         else if (state == LIST_ITEM_STATUS_UNCHECKED)
1311         {
1312                 __selectedItemCount--;
1313                 StoreItemselection(groupIndex, itemIndex, elementId, state);
1314         }
1315
1316         if (__selectedItemCount == __listItemCount)
1317         {
1318                 __pSelectAll->SetSelected(true);
1319         }
1320         else
1321         {
1322                 __pSelectAll->SetSelected(false);
1323         }
1324         __pSelectAll->Invalidate(false);
1325         if (__selectedItemCount == 0)
1326         {
1327                 __pFormFooter->SetItemEnabled(0, false);
1328                 String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
1329                 __pSelectedLabel->SetText(selStr);
1330         }
1331         else
1332         {
1333                 __pFormFooter->SetItemEnabled(0, true);
1334                 String selItemStr = L"";
1335                 if(__selectedItemCount > 1)
1336                 {
1337                         selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
1338                 }
1339                 else
1340                 {
1341                         selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
1342                 }
1343                 text.Format(100, selItemStr.GetPointer(), __selectedItemCount);
1344                 __pSelectedLabel->SetText(text);
1345         }
1346         __pFormFooter->Draw();
1347         __pSelectedLabel->Invalidate(false);
1348 }
1349
1350 void
1351 DlLogsDetailForm::OnCalllogChanged(void)
1352 {
1353         if(__isEditMode == false)
1354         {
1355                 UpdateForm();
1356                 SetFormMode(false);
1357         }
1358         //Update the log list for all MO/MT/MSG if the log list is in edit mode and delete is not on progress
1359         if(__isEditMode == true && __isDeleteInProgress == false)
1360         {
1361                 UpdateForm();
1362         }
1363         if(IsScecneVisible() == true && __isDeleteInProgress == false)
1364         {
1365                 ManageItemSelection();
1366         }
1367 }
1368
1369 void
1370 DlLogsDetailForm::StoreItemselection(int groupIndex, int itemIndex, int elementId, ListItemStatus state)
1371 {
1372         CallLogDetails* pCalllogInfo = null;
1373         if (state == LIST_ITEM_STATUS_CHECKED)
1374         {
1375                 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1376                 __pCallLogId->Add(new Integer(pCalllogInfo->GetCalllogDbId()));
1377         }
1378         else if (state == LIST_ITEM_STATUS_UNCHECKED)
1379         {
1380                 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1381                 __pCallLogId->Remove(*(new Integer(pCalllogInfo->GetCalllogDbId())));
1382         }
1383 }
1384 void
1385 DlLogsDetailForm:: ManageItemSelection(void)
1386 {
1387         if(__isEditMode == true && __selectedItemCount > 0 && __listItemCount != __pLogPresentor->GetCalllogCountByNumber())
1388         {
1389                 UnCheckAllItems();
1390                 int itemCount = 0;
1391                 CallLogDetails* pCalllogInfo = null;
1392                 for(int groupIndex = 0; groupIndex < __pList->GetGroupCount(); groupIndex++)
1393                 {
1394                         itemCount = __pList->GetItemCountAt(groupIndex);
1395                         for(int itemIndex = itemCount-1; itemIndex >=0 ; itemIndex--)
1396                         {
1397                                 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1398                                 if(__pCallLogId->Contains(*(new Integer(pCalllogInfo->GetCalllogDbId()))))
1399                                 {
1400                                         __pList->SetItemChecked(groupIndex,itemIndex,true);
1401                                         ++__selectedItemCount;
1402                                 }
1403                         }
1404                 }
1405                 __listItemCount = __pLogPresentor->GetCalllogCountByNumber();
1406                 if(__selectedItemCount == __listItemCount)
1407                 {
1408                         __pSelectAll->SetSelected(true);
1409                 }
1410                 else
1411                 {
1412                         __pSelectAll->SetSelected(false);
1413                 }
1414                 String selItemStr = L"";
1415                 String text;
1416                 if(__selectedItemCount == 0)
1417                 {
1418                         __pFormFooter->SetItemEnabled(0, false);
1419                         String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
1420                         __pSelectedLabel->SetText(selStr);
1421                 }
1422                 else
1423                 {
1424                         if(__selectedItemCount > 1)
1425                         {
1426                                 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
1427                         }
1428                         else
1429                         {
1430                                 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
1431                         }
1432                         __pFormFooter->SetItemEnabled(0, true);
1433                         text.Format(100, selItemStr.GetPointer(), __selectedItemCount);
1434                         __pSelectedLabel->SetText(text);
1435                 }
1436                 __pSelectedLabel->Invalidate(false);
1437                 __pSelectAll->SetShowState(true);
1438                 __pLabelBlocked->SetShowState(false);
1439                 __pPanelNumberUnsaved->SetShowState(false);
1440                 __pPanelName->SetShowState(false);
1441                 __pLabelNumber->SetShowState(false);
1442                 __pButtonContactImage->SetShowState(false);
1443                 __listItemCount = __pLogPresentor->GetCalllogCountByNumber();
1444         }
1445 }
1446
1447 bool
1448 DlLogsDetailForm::IsScecneVisible()
1449 {
1450         AppLogDebug("Enter");
1451         return __isSceneVisible;
1452 }
1453
1454
1455 void
1456 DlLogsDetailForm::SetSceneVisible(bool sceneMode)
1457 {
1458         AppLogDebug("Enter");
1459         __isSceneVisible = sceneMode;
1460 }
1461
1462 void
1463 DlLogsDetailForm::ShowBlockPopup(void)\r
1464 {
1465         if(__pLogsBlockPopup != null)\r
1466         {
1467                 delete __pLogsBlockPopup;\r
1468                 __pLogsBlockPopup = null;\r
1469         }
1470         SettingsPresentationModel* pSettingsPresentationModel = SettingsPresentationModel::GetInstance();
1471         __isCallBeRejected = pSettingsPresentationModel->IsCallToBeRejected(__number);
1472
1473         __isMsgBeRejected = SettingsPresentationModel::GetInstance()->GetMsgFilterListIndex(__number);\r
1474         __pLogsBlockPopup = new (std::nothrow) CallLogViewByPopup(*this);\r
1475         __pLogsBlockPopup->ConstructBlockPopup(__number, __isCallBeRejected, __isMsgBeRejected);\r
1476         __pLogsBlockPopup->SetShowState(true);\r
1477         __pLogsBlockPopup->Draw();\r
1478         __pLogsBlockPopup->Show();\r
1479 }
1480
1481 void
1482 DlLogsDetailForm::OnItemSelected()
1483 {
1484         SendUserEvent(REQUEST_CHANGE_BLOCK, null);
1485 }
1486
1487 void
1488 DlLogsDetailForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1489 {
1490         switch(requestId)
1491         {
1492                 case REQUEST_CHANGE_BLOCK:
1493                 {
1494                         if(__pLogsBlockPopup->GetCallBlock() == true)\r
1495                         {
1496                                 result r = SettingsPresentationModel::GetInstance()->AddToCallRejectList(__number, CALL_REJECT_MATCH_EXACTLY,true);
1497                                 if(r == E_OBJ_ALREADY_EXIST)
1498                                 {
1499                                         IListT<CallRejectInfo>* pRejList = SettingsPresentationModel::GetInstance()->GetCallRejectList();
1500                                         IEnumeratorT<CallRejectInfo>* pRejEnum =pRejList->GetEnumeratorN();
1501                                         while(pRejEnum->MoveNext() == E_SUCCESS)
1502                                         {
1503                                                 CallRejectInfo rejectInfo;
1504                                                 pRejEnum->GetCurrent(rejectInfo);
1505                                                 if(rejectInfo.phoneNumber.Equals(__number))
1506                                                 {
1507                                                         SettingsPresentationModel::GetInstance()->UpdateCallRejectRow(rejectInfo.rowId,rejectInfo.phoneNumber,true,rejectInfo.rejectCondition);
1508                                                 }
1509                                         }
1510                                         delete pRejEnum;
1511                                 }
1512                                 UpdateForm();
1513
1514                         }
1515
1516                         if(__pLogsBlockPopup->GetMessageBlock() == true)\r
1517                         {
1518                                 AppLog("block message");
1519                                 SettingsPresentationModel::GetInstance()->AddToMessageRejectList(__number, 1);
1520                                 UpdateForm();
1521                         }
1522                 }
1523                 break;
1524         }
1525 }
1526
1527 void
1528 DlLogsDetailForm::ShowDuplicateErrorMessageBox(String& message)
1529 {
1530         // Creates an instance of MessageBox
1531         MessageBox duplicateMsgBox;
1532         duplicateMsgBox.Construct(L"", message, MSGBOX_STYLE_NONE, 2000);
1533
1534         int modalResult = 0;
1535         // Calls ShowAndWait() : Draws and Shows itself and processes events
1536         duplicateMsgBox.ShowAndWait(modalResult);
1537 }
1538
1539 void
1540 DlLogsDetailForm::ViewContactDetail(void)
1541 {
1542         AppLogDebug("Enter");
1543         //Launch Contact AppControl
1544         Contact* pContact = null;
1545         AppControl* pAc = null;
1546         result r = E_SUCCESS;
1547         HashMap extraData;
1548         extraData.Construct();
1549         Addressbook* pAddressBook =  AddressbookManager::GetInstance()->GetAddressbookN();
1550         if (pAddressBook != null)
1551         {
1552                 IList* pNumberContactsList = null;
1553                 if(__number.Contains(L"@"))
1554                 {
1555                         pNumberContactsList = pAddressBook->SearchContactsByEmailN(__number);
1556                 }
1557                 else
1558                 {
1559                         pNumberContactsList = pAddressBook->SearchContactsByPhoneNumberN(__number);
1560                 }
1561                 if(pNumberContactsList != null)
1562                 {
1563                         IEnumerator* pContactListEnum = pNumberContactsList->GetEnumeratorN();
1564                         while (pContactListEnum->MoveNext() == E_SUCCESS)
1565                         {
1566                                 pContact = static_cast<Contact*>(pContactListEnum->GetCurrent());
1567                                 if (pContact != null)
1568                                 {
1569                                         IList* pPhoneNumberList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
1570                                         if (pPhoneNumberList != null)
1571                                         {
1572                                                 IEnumerator* pPhoneEnum = pPhoneNumberList->GetEnumeratorN();
1573                                                 while (E_SUCCESS == pPhoneEnum->MoveNext())
1574                                                 {
1575                                                         PhoneNumber* pPhoneNumber = (PhoneNumber*) pPhoneEnum->GetCurrent();
1576                                                         //Check if this is the correct contact
1577                                                         if (pPhoneNumber->GetPhoneNumber().Equals(__number))
1578                                                         {
1579                                                                 //save newly fetched contact info.
1580                                                                 AppLogDebug("View Contact");
1581                                                                 //View Contact
1582                                                                 String idVal;
1583                                                                 idVal.Append(pContact->GetRecordId());
1584                                                                 extraData.Add(new (std::nothrow) String(CONTACTS_VIEW_TYPE), new (std::nothrow) String(CONTACTS_VIEW_TYPE_CONTACT));
1585                                                                 extraData.Add(new (std::nothrow) String(CONTACTS_VIEW_TYPE_CONTACT), new (std::nothrow) String(CONTACTS_VIEW_TYPE_CONTACT));
1586                                                                 extraData.Add(new (std::nothrow) String(CONTACT_KEY_ITEM_ID), new (std::nothrow) String(idVal));
1587                                                                 extraData.Add(new (std::nothrow) String(CONTACTS_ID_KEY), new (std::nothrow) String(idVal));
1588                                                                 extraData.Add(new (std::nothrow) String(CONTACT_KEY_ITEM_TYPE), new (std::nothrow) String(ITEM_TYPE_PERSON));
1589                                                                 pAc = AppManager::FindAppControlN(PROVIDER_ID_CONTACTS, OPERATION_ID_VIEW);
1590
1591                                                                 if (pAc != null)
1592                                                                 {
1593                                                                         r = pAc->Start(null, null, &extraData, this);
1594                                                                         __isContactAppControlLaunched = true;
1595                                                                         delete pAc;
1596                                                                 }
1597                                                                 break;
1598                                                         }
1599                                                 }
1600                                                 delete pPhoneEnum;
1601                                                 pPhoneNumberList->RemoveAll(true);
1602                                                 delete pPhoneNumberList;
1603                                                 if(__isContactAppControlLaunched == true)
1604                                                 {
1605                                                         break;
1606                                                 }
1607                                         }
1608
1609                                 }
1610                         }
1611                 }
1612         }
1613 }
1614
1615 void
1616 DlLogsDetailForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1617 {
1618         if((GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )&& __isEditMode == true)
1619         {
1620                 __pList->SetBounds(GetClientAreaBounds().x, __pSelectAll->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - (__pSelectAll->GetHeight()+__pSelectedLabel->GetHeight()));
1621         }
1622         else if((GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE) && __isEditMode == false)
1623         {
1624                 int listY = __pButtonContactImage->GetBounds().height + __pButtonMessage->GetBounds().height + 40;
1625                 int listHeight = GetClientAreaBounds().height - __pButtonContactImage->GetBounds().height - __pButtonMessage->GetBounds().height - 40;
1626                 __pList->SetBounds(Rectangle(0, listY, GetClientAreaBounds().width, listHeight));
1627         }
1628         else if(__isEditMode == true)
1629         {
1630                 __pList->SetBounds(GetClientAreaBounds().x, __pSelectAll->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - (__pSelectAll->GetHeight()+__pSelectedLabel->GetHeight()));
1631         }
1632         else
1633         {
1634                 int listHeight = GetClientAreaBounds().height - __pButtonContactImage->GetBounds().height - __pButtonMessage->GetBounds().height - 40;
1635                 int listY = __pButtonContactImage->GetBounds().height + __pButtonMessage->GetBounds().height + 40;
1636                 __pList->SetBounds(Rectangle(0, listY, GetClientAreaBounds().width, listHeight));
1637         }
1638         ManageUserDetail();
1639 }
1640
1641 void
1642 DlLogsDetailForm::OnSettingChanged(Tizen::Base::String& key)
1643 {
1644         AppLog("Enter");
1645         if(key.Equals(String(SETTING_INFO_KEY_TIME_FORMAT)) == true)
1646         {
1647                 __pList->UpdateList();
1648         }
1649         AppLog("Exit");
1650 }
1651
1652 void
1653 DlLogsDetailForm::OnFormMenuRequested(Controls::Form& source)
1654 {
1655         if(__isEditMode == false)
1656         {
1657                 ShowOptionsMenu();
1658         }
1659 }
1660
1661 void
1662 DlLogsDetailForm::ShowOptionsMenu()
1663 {
1664         if(__pOptionMenu != null)
1665         {
1666                 delete __pOptionMenu;
1667                 __pOptionMenu = null;
1668         }
1669         __pOptionMenu = new (std::nothrow) OptionMenu();
1670         __pOptionMenu->Construct();
1671         __pOptionMenu->AddActionEventListener(*this);
1672         __pOptionMenu->RemoveAllItems();
1673
1674         if(__isPresentInContacts == true)
1675         {
1676         __pOptionMenu->AddItem(AppUtility::GetResourceString(IDS_CONTEXTMENU_ITEM_DETAILS), IDA_CONTEXTMENU_DETAILS);
1677                 if(!(__number.Contains(L"@")))
1678                 {
1679                         __pOptionMenu->AddItem(AppUtility::GetResourceString(IDS_CONTEXTMENU_ITEM_BLOCK), IDA_CONTEXTMENU_BLOCK);
1680                 }
1681         }
1682         else
1683         {
1684                 __pOptionMenu->AddItem(AppUtility::GetResourceString(IDS_CONTEXTMENU_ITEM_ADDTOCONTACT), IDA_CONTEXTMENU_ADDTOCONTACT);
1685                 if(!(__number.Contains(L"@")))
1686                 {
1687                         __pOptionMenu->AddItem(AppUtility::GetResourceString(IDS_CONTEXTMENU_ITEM_BLOCK), IDA_CONTEXTMENU_BLOCK);
1688                 }
1689         }
1690         __pOptionMenu->SetShowState(true);
1691         __pOptionMenu->Show();
1692 }
1693
1694 bool
1695 DlLogsDetailForm::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
1696 {
1697         AppLog("Enter");
1698         if(keyEventInfo.GetKeyCode() == KEY_BACK)
1699         {
1700                 if(__pDeletePopup != null && __pDeletePopup->GetShowState() == true)
1701                 {
1702                         HideDeletePopup();
1703                 }
1704         }
1705         return false;
1706 }