Tizen 2.0 Release
[apps/osp/Phone.git] / src / PhnLogsDetailForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (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 "PhnCallPresentationModel.h"
31 #include "PhnSettingsPresentationModel.h"
32 #include "PhnTypes.h"
33
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Media;
39 using namespace Tizen::Social;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Controls;
42 using namespace Tizen::Ui::Scenes;
43 //resources
44 const wchar_t* IDL_CALL_LOG_DETAIL_FORM = L"IDL_CALL_LOG_DETAIL_FORM";
45 const wchar_t* IDC_BUTTON_CONTACT_IMAGE = L"IDC_BUTTON_CONTACT_IMAGE";
46 const wchar_t* IDC_LABEL_NAME = L"IDC_LABEL_NAME";
47 const wchar_t* IDC_LABEL_NUMBER = L"IDC_LABEL_NUMBER";
48 const wchar_t* IDC_LABEL_NUMBER_UNSAVED = L"IDC_LABEL_NUMBER_UNSAVED";
49 const wchar_t* IDC_LABEL_BLOCKED = L"IDC_LABEL_BLOCKED";
50 const wchar_t* IDC_BUTTON_MESSAGE = L"IDC_BUTTON_MESSAGE";
51 const wchar_t* IDC_SELECTALL = L"IDC_SELECTALL";
52 const wchar_t* IDC_BUTTON_CALL = L"IDC_BUTTON_CALL";
53 const wchar_t* IDC_LABEL_DETAIL_SELECTED = L"IDC_LABEL_DETAIL_SELECTED";
54
55 const int IDA_CALL_LOG_CALL = 201;
56 const int IDA_CALL_LOG_MESSAGE = 202;
57 const int IDA_FOOTER_BUTTON_LEFT = 203;
58 const int IDA_FOOTER_BUTTON_RIGHT = 204;
59 const int IDA_SELECT_ALL_CHECKED = 205;
60 const int IDA_SELECT_ALL_UNCHECKED = 206;
61 const int W_BUTTON = 48;
62 const int H_BUTTON = 48;
63 const int W_BLOCKED_ICON = 56;
64 const int H_BLOCKED_ICON = 56;
65
66 const wchar_t* FORMAT_STR = L"%ls (%d)";
67
68 static const unsigned int COLOR_DELAIL_LABEL_SELECTED = Color32<215, 225, 232, 255>::Value;
69
70
71 DlLogsDetailForm::DlLogsDetailForm(void)
72 {
73         __pDataProvider = new DlLogsDetailItemDataProvider();
74
75         __listHeight = 0;
76         __pButtonCall = null;
77         __pButtonMessage = null;
78         __pButtonContactImage = null;
79         __pLabelName = null;
80         __pLabelNumber = null;
81         __pFormFooter = null;
82         __pList = null;
83         __isEditMode = false;
84         __isSelectAll = false;
85         __isPresentInContacts = false;
86         __listItemCount = 0;
87         __selectedItemCount = 0;
88         __calllogListByNum = null;
89         __pCallMgr = null;
90         __calllogCount = 0;
91         __isMsgAppControlLaunched = false;
92 }
93
94 DlLogsDetailForm::~DlLogsDetailForm(void)
95 {
96         if (__pDataProvider != null)
97         {
98                 delete __pDataProvider;
99                 __pDataProvider = null;
100         }
101 }
102
103 bool
104 DlLogsDetailForm::Initialize()
105 {
106         result r = Construct(IDL_CALL_LOG_DETAIL_FORM);
107         TryCatch(r == E_SUCCESS, , "DlLogsDetailForm::Initialize Fail to initialize Call log detail form");
108         return true;
109 CATCH:
110         return false;
111
112 }
113
114 result
115 DlLogsDetailForm::OnInitializing(void)
116 {
117         AppLog(" OnInitializing SceneManager::AddSceneEventListener()");
118         result r = E_SUCCESS;
119         Bitmap* pBitmap = null;
120         AppResource* pAppResource = App::GetInstance()->GetAppResource();
121
122         __pFormFooter = GetFooter();
123         if (__pFormFooter != null)
124         {
125                 __pFormFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
126                 __pFormFooter->SetBackButton();
127                 __pFormFooter->AddActionEventListener(*this);
128                 SetFormBackEventListener(this);
129
130                 __pFooterItemDelete.Construct(IDA_FOOTER_BUTTON_LEFT);
131                 __pFooterItemDelete.SetText(AppUtility::GetResourceString(IDS_CALLLOG_DELETE_FOOTER));
132                 __pFormFooter->AddItem(__pFooterItemDelete);
133
134                 __pFooterItemCancel.Construct(IDA_FOOTER_BUTTON_RIGHT);
135                 __pFooterItemCancel.SetText(AppUtility::GetResourceString(IDS_CALLLOG_CANCEL_FOOTER));
136         }
137
138         __pButtonContactImage = static_cast<Button*>(GetControl(IDC_BUTTON_CONTACT_IMAGE));
139         if (__pButtonContactImage != null)
140         {
141                 //todo: set image & show if present in contacts
142                 __pButtonContactImage->SetShowState(false);
143         }
144
145         __pLabelName = static_cast<Label*>(GetControl(IDC_LABEL_NAME));
146         if (__pLabelName != null)
147         {
148                 __pLabelName->SetTextColor(Color::GetColor(COLOR_ID_BLACK));
149                 __pLabelName->SetTextConfig(50, LABEL_TEXT_STYLE_BOLD);
150         }
151
152         __pLabelNumber = static_cast<Label*>(GetControl(IDC_LABEL_NUMBER));
153         if (__pLabelNumber != null)
154         {
155                 __pLabelNumber->SetTextColor(Color::GetColor(COLOR_ID_BLACK));
156                 __pLabelNumber->SetTextConfig(32, LABEL_TEXT_STYLE_BOLD);
157                 __pLabelNumber->SetTextColor(Color::GetColor(COLOR_ID_GREY));
158         }
159
160         __pLabelNumberUnsaved = static_cast<Label*>(GetControl(IDC_LABEL_NUMBER_UNSAVED));
161         if (__pLabelNumberUnsaved != null)
162         {
163                 __pLabelNumberUnsaved->SetTextColor(Color::GetColor(COLOR_ID_BLACK));
164                 __pLabelNumberUnsaved->SetTextConfig(50, LABEL_TEXT_STYLE_BOLD);
165         }
166
167         __pLabelBlocked = static_cast<Label*>(GetControl(IDC_LABEL_BLOCKED));
168         if (__pLabelBlocked != null)
169         {
170                 __pLabelBlocked->SetShowState(false);
171         }
172
173         pBitmap = pAppResource->GetBitmapN(IDB_LOG_DETAIL_CALL_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888);
174         pBitmap->Scale(Dimension(W_BUTTON, H_BUTTON));
175         __pButtonCall = static_cast<Button*>(GetControl(IDC_BUTTON_CALL));
176         if (__pButtonCall != null)
177         {
178                 __pButtonCall->SetActionId(IDA_CALL_LOG_CALL);
179                 __pButtonCall->SetNormalBitmap(Point(__pButtonCall->GetBounds().width / 2 - W_BUTTON / 2, __pButtonCall->GetBounds().height / 2 - H_BUTTON / 2), *pBitmap); //not working
180                 __pButtonCall->SetPressedBitmap(Point(__pButtonCall->GetBounds().width / 2 - W_BUTTON / 2, __pButtonCall->GetBounds().height / 2 - H_BUTTON / 2), *pBitmap); //not working
181                 __pButtonCall->AddActionEventListener(*this);
182                 delete pBitmap;
183                 pBitmap = null;
184         }
185
186         pBitmap = pAppResource->GetBitmapN(IDB_LOG_DETAIL_MSG_ICON ,BITMAP_PIXEL_FORMAT_ARGB8888);
187         pBitmap->Scale(Dimension(W_BUTTON, H_BUTTON));
188
189         __pButtonMessage = static_cast<Button*>(GetControl(IDC_BUTTON_MESSAGE));
190         if (__pButtonMessage != null)
191         {
192                 __pButtonMessage->SetActionId(IDA_CALL_LOG_MESSAGE);
193                 __pButtonMessage->SetNormalBitmap(Point(__pButtonMessage->GetBounds().width / 2 - W_BUTTON / 2, __pButtonMessage->GetBounds().height / 2 - H_BUTTON / 2), *pBitmap); //not working
194                 __pButtonMessage->SetPressedBitmap(Point(__pButtonMessage->GetBounds().width / 2 - W_BUTTON / 2, __pButtonMessage->GetBounds().height / 2 - H_BUTTON / 2), *pBitmap); //not working
195                 __pButtonMessage->AddActionEventListener(*this);
196
197                 delete pBitmap;
198                 pBitmap = null;
199         }
200
201         __pSelectAll = static_cast<CheckButton*>(GetControl(IDC_SELECTALL));
202         if(__pSelectAll != null)
203         {
204                 __pSelectAll->SetActionId(IDA_SELECT_ALL_CHECKED, IDA_SELECT_ALL_UNCHECKED);
205                 __pSelectAll->SetSize(GetClientAreaBounds().width, 112);
206                 __pSelectAll->SetShowState(false);
207                 __pSelectAll->AddActionEventListener(*this);
208         }
209
210         __pList = new (std::nothrow) ListView();
211         if (__pList != null)
212         {
213                 __listHeight = GetClientAreaBounds().height - __pButtonContactImage->GetBounds().height - __pButtonMessage->GetBounds().height - 40;
214                 int listY = __pButtonContactImage->GetBounds().height + __pButtonMessage->GetBounds().height + 40;
215                 __pList->Construct(Rectangle(0, listY, GetClientAreaBounds().width, __listHeight), true, SCROLL_STYLE_FADE_OUT);
216
217                 r = AddControl(*__pList);
218                 TryCatch(r == E_SUCCESS, , "call log detail list control not added");
219         }
220
221         __pSelectedLabel = static_cast<Label*>(GetControl(IDC_LABEL_DETAIL_SELECTED));
222         if(__pSelectedLabel != null)
223         {
224                 SetControlAlwaysOnTop(*__pSelectedLabel,true);
225                 __pSelectedLabel->SetBackgroundColor(COLOR_DELAIL_LABEL_SELECTED);
226                 __pSelectedLabel->SetShowState(false);
227         }
228         return r;
229 CATCH:
230         return r;
231 }
232
233 result
234 DlLogsDetailForm::OnTerminating(void)
235 {
236         result r = E_SUCCESS;
237
238         return r;
239 }
240
241 bool
242 DlLogsDetailForm::DeleteSelectedCalllog(void)
243 {
244         int checkedItemCount = 0;
245         CallLogDetails pCalllogInfo;
246         Tizen::Base::Collection::IListT<CallLogDetails>* pCalllogByNumberList;
247         //pCalllogByNumberList = __calllogListByNum->GetValuesN();
248         pCalllogByNumberList = __calllogListByNum->GetItemsN(0, __calllogListByNum->GetCount()); //to be verified
249         __calllogCount = pCalllogByNumberList->GetCount();
250         for(int index = 0; index < __calllogCount; index++)
251         {
252                 pCalllogByNumberList->GetAt(index,pCalllogInfo);
253                 AppLog(" info from Map list %d %d %s",  pCalllogInfo.GetCalllogType(), pCalllogInfo.GetDuration(), pCalllogInfo.GetPhoneNumber());
254                 if(__pList->IsItemChecked(index) == true )
255                 {
256                         checkedItemCount++;
257                         __pCallMgr->DeleteCalllogByDbId(pCalllogInfo.GetCalllogDbId());
258                 }
259         }
260         delete pCalllogByNumberList;
261         // return to call logs list if all items deleted
262         if (checkedItemCount == __calllogCount)
263         {
264                 return true;
265         }
266         return false;
267 }
268
269
270 void
271 DlLogsDetailForm::OnActionPerformed(const Control& source, int actionId)
272 {
273         switch (actionId)
274         {
275
276         case IDA_CALL_LOG_CALL:
277         {
278                 SceneManager* pSceneManager = SceneManager::GetInstance();
279                 CallPresentationModel* pCallPresentor = CallPresentationModel::GetInstance();
280                 //make an outgoing call with given number
281                 String* contactTxt = new (std::nothrow) String(__number);
282                 //switch to dialing outgoing call form
283                 IList* pContact = new (std::nothrow) ArrayList(SingleObjectDeleter);
284                 pContact->Add(contactTxt);
285                 //Check if dialing an emergency call
286                 bool isEmergencyCall = pCallPresentor->IsEmergencyNumber(*contactTxt, true);
287                 if (isEmergencyCall)
288                 {
289                         pSceneManager->GoForward( ForwardSceneTransition( IDSCN_SCENE_OUT_EMERGENCYCALL), pContact);
290                 }
291                 else
292                 {
293                         pSceneManager->GoForward( ForwardSceneTransition(IDSCN_SCENE_OUTCALL), pContact);
294                 }
295         }
296         break;
297
298         case IDA_CALL_LOG_MESSAGE:
299         {
300                 if(__isMsgAppControlLaunched == true)
301                 {
302                         //Message AppControl is already launched
303                         return;
304                 }
305
306                 //launch message
307                 __isMsgAppControlLaunched = true;
308                 result r = E_SUCCESS;
309                 HashMap extraData;
310                 extraData.Construct();
311
312                 extraData.Add(new (std::nothrow) String(MESSAGE_TYPE), new (std::nothrow) String(MESSAGE_SMS_TYPE));
313                 extraData.Add(new (std::nothrow) String(MESSAGE_TO), new (std::nothrow) String(__number));
314
315                 AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE);
316                 if (pAc != null)
317                 {
318                         r = pAc->Start(null, null, &extraData, this);
319                         if(r != E_SUCCESS)
320                         {
321                                 //AppControl failed.
322                                 __isMsgAppControlLaunched = false;
323                         }
324                         delete pAc;
325                 }
326                 extraData.RemoveAll(true);
327         }
328         break;
329
330         case IDA_FOOTER_BUTTON_LEFT:
331         {
332                 const wchar_t* pContact = __number.GetPointer();
333                 int len = __number.GetLength() + 1;
334                 char* pNumber = new (std::nothrow) char[len];
335                 wcstombs(pNumber, pContact, len);
336                 if (__isEditMode == false)
337                 {
338                         SetFormMode(true);
339                         __calllogListByNum = __pCallMgr->GetCallogListByNumberFromDatabaseN(pNumber);
340                         __pList->UpdateList();
341                         __pList->Invalidate(false);
342                 }
343                 else
344                 {
345                         bool switchtoCallLogView = DeleteSelectedCalllog();
346                         if (switchtoCallLogView == false)
347                         {
348                                 __calllogListByNum = __pCallMgr->GetCallogListByNumberFromDatabaseN(pNumber);
349                                 UpdateForm();
350                                 SetFormMode(false);
351                         }
352                         else
353                         {
354                                 SetFormMode(false);
355                                 SceneManager* pSceneManager = SceneManager::GetInstance();
356                                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CALL_LOG, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
357                                                                                                                                                 SCENE_HISTORY_OPTION_NO_HISTORY));
358                         }
359                 }
360                 delete[] pNumber;
361                 pNumber = null;
362         }
363         break;
364
365         case IDA_FOOTER_BUTTON_RIGHT:
366         {
367                 SetFormMode(false);
368         }
369         break;
370
371         case IDA_SELECT_ALL_UNCHECKED:
372         {
373                 SetAllListItems(false);
374                 __selectedItemCount = 0;
375                 String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
376                 __pSelectedLabel->SetText(selStr);
377                 __pSelectedLabel->Invalidate(false);
378         }
379         break;
380         case IDA_SELECT_ALL_CHECKED:
381         {
382                 SetAllListItems(true);
383                 __selectedItemCount = __listItemCount;
384                 String text;
385                 String selItemStr = L"";
386                 if(__selectedItemCount > 1)
387                 {
388                         selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
389                 }
390                 else
391                 {
392                         selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
393                 }
394                 text.Format(100, selItemStr.GetPointer(), __listItemCount);
395                 __pSelectedLabel->SetText(text);
396                 __pSelectedLabel->Invalidate(false);
397         }
398         break;
399         default:
400                 break;
401         }
402 }
403
404 void
405 DlLogsDetailForm::GetUpdatedListFromDatabase(char* number)
406 {
407         if(__calllogListByNum != null)
408         {
409                 AppLog(" list already present, UPDATE");
410                 __calllogListByNum->RemoveAll();
411                 delete __calllogListByNum;
412         }
413
414         __calllogListByNum = __pCallMgr->GetCallogListByNumberFromDatabaseN(number);
415         __calllogCount = __pCallMgr->GetCalllogCountByNumber();
416 }
417
418 void
419 DlLogsDetailForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
420 {
421         AppLog(" activated");
422         __pCallMgr = CallLogManager::GetInstance();
423         __isPresentInContacts = false;
424         __selectedItemCount =0;
425         __isMsgAppControlLaunched = false;
426         if(pArgs != null)
427         {
428                 __number.Clear();
429                 String* pNumberStr = static_cast<String*> (pArgs->GetAt(0));
430                 __number.Append(*pNumberStr);
431                 UpdateForm();
432                 pArgs->RemoveAll();
433                 delete pArgs;
434                 pArgs = null;
435         }
436         __pList->SetItemProvider(*__pDataProvider);
437         __pList->UpdateList();
438         SetFormMode(false);
439 }
440
441 void
442 DlLogsDetailForm::UpdateForm(void)
443 {
444         SettingsPresentationModel* pSettingsPresentationModel = SettingsPresentationModel::GetInstance();
445         bool isCallToBeRejected = pSettingsPresentationModel->IsCallToBeRejected(__number);
446
447         const wchar_t* pContact = __number.GetPointer();
448         int len = __number.GetLength() + 1;
449         char* pNumber = new (std::nothrow) char[len];
450         wcstombs(pNumber, pContact, len);
451
452         GetUpdatedListFromDatabase(pNumber);
453         delete[] pNumber;
454
455         String contactName;
456         Bitmap* pBitmap = null;
457         Addressbook* pAddressBook =  AddressbookManager::GetInstance()->GetAddressbookN();
458         if (pAddressBook != null)
459         {
460                 IList* pNumberContactsList = pAddressBook->SearchContactsByPhoneNumberN(__number);
461                 if(pNumberContactsList != null)
462                 {
463                         Contact* pContact = static_cast<Contact*>(pNumberContactsList->GetAt(0));
464                         if(pContact != null)
465                         {
466                                 IList* pPhoneNumberList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
467                                 if (pPhoneNumberList != null)
468                                 {
469                                         IEnumerator* pEnum = pPhoneNumberList->GetEnumeratorN();
470                                         while (E_SUCCESS == pEnum->MoveNext())
471                                         {
472                                                 PhoneNumber* pPhoneNumber = (PhoneNumber*) pEnum->GetCurrent();
473                                                 if(pPhoneNumber->GetPhoneNumber().Equals(__number) == true)
474                                                 {
475                                                         __isPresentInContacts = true;
476                                                         break;
477                                                 }
478                                         }
479                                         delete pEnum;
480                                         pPhoneNumberList->RemoveAll(true);
481                                         delete pPhoneNumberList;
482                                 }
483
484                                 if(__isPresentInContacts == true)
485                                 {
486                                         __pLabelNumberUnsaved->SetShowState(false);
487                                         //fetch contact name
488                                         contactName.Clear();
489                                         pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, contactName);
490                                         //fetch person's photo
491                                         pBitmap = pContact->GetThumbnailN();
492
493                                         String contactNameStr;
494                                         contactNameStr.Format(100, FORMAT_STR,contactName.GetPointer(), __calllogCount);
495                                         __pLabelName->SetText(contactNameStr);
496                                         __pLabelName->Invalidate(false);
497                                         __pLabelNumber->SetText(__number);
498                                         __pLabelNumber->Invalidate(false);
499                                         __pLabelNumberUnsaved->SetShowState(false);
500                                         __pLabelBlocked->SetShowState(false);
501                                         __pLabelName->SetShowState(true);
502                                         __pLabelNumber->SetShowState(true);
503                                         //todo: set the contact button image
504                                         Canvas* pCanvas = null;
505                                         pCanvas = new (std::nothrow) Canvas();
506                                         pCanvas->Construct(Rectangle(0,0,__pButtonContactImage->GetBounds().width,__pButtonContactImage->GetBounds().height));
507                                         //set bitmap to button
508                                         if (pBitmap == null)
509                                         {
510                                                 pBitmap = AppUtility::GetBitmapFromResourcesN(L"C01-1_icon_contacts.png", W_CONTACT_BITMAP_ITEM, H_CONTACT_BITMAP_ITEM);
511                                         }
512                                         else
513                                         {
514                                                 //scale bitmap to predefined size
515                                                 pBitmap->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
516                                                 pBitmap->Scale(Dimension(W_CONTACT_BITMAP_ITEM, H_CONTACT_BITMAP_ITEM));
517                                         }
518
519                                         pCanvas->DrawBitmap(Rectangle(Point(0, 0), Dimension(pBitmap->GetWidth(), pBitmap->GetHeight())), *pBitmap);
520                                         delete pBitmap;
521                                         pBitmap = null;
522                                         //TODO: chk whether the number is blocked and add icon in top right
523                                         if (isCallToBeRejected == true)
524                                         {
525                                                 pBitmap = AppUtility::GetBitmapFromResourcesN(L"C01-4_icon_Blocked.png", W_BLOCKED_ICON, H_BLOCKED_ICON);
526                                                 pCanvas->DrawBitmap(Rectangle(Point(86, 0), Dimension(pBitmap->GetWidth(), pBitmap->GetHeight())), *pBitmap);
527                                                 delete pBitmap;
528                                                 pBitmap = null;
529                                         }
530                                         Bitmap* pActualBgBmp = new Bitmap();
531                                         pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds());
532                                         __pButtonContactImage->SetNormalBackgroundBitmap(*pActualBgBmp);
533                                         __pButtonContactImage->SetShowState(true);
534                                         __pButtonContactImage->Invalidate(false);
535                                         delete pCanvas;
536                                         delete pActualBgBmp;
537                                 }
538                         }
539                         pNumberContactsList->RemoveAll(true);
540                         delete pNumberContactsList;
541                         delete pAddressBook;
542                         pAddressBook = null;
543                 }
544         }
545
546         if (__isPresentInContacts == false)
547         {
548                 __isPresentInContacts = false;
549                 //not in contacts rearrage the icons
550                 String contactNameStr;
551                 contactNameStr.Format(100, FORMAT_STR,__number.GetPointer(), __calllogCount);
552                 __pLabelNumberUnsaved->SetText(contactNameStr);
553                 __pLabelNumberUnsaved->Invalidate(false);
554                 __pLabelNumberUnsaved->SetShowState(true);
555                 __pLabelName->SetShowState(false);
556                 __pLabelNumber->SetShowState(false);
557                 __pButtonContactImage->SetShowState(false);
558                 //todo set bitmap
559                 if (isCallToBeRejected == true)
560                 {
561                         pBitmap = AppUtility::GetBitmapFromResourcesN(L"C01-4_icon_Blocked.png", W_BLOCKED_ICON, H_BLOCKED_ICON);
562                         __pLabelBlocked->SetBackgroundBitmap(*pBitmap);
563                         delete pBitmap;
564                         pBitmap = null;
565                 }
566                 else
567                 {
568                         Canvas* pCanvas = null;
569                         pCanvas = new (std::nothrow) Canvas();
570                         pCanvas->Construct(Rectangle(0,0,__pLabelBlocked->GetBounds().width,__pButtonContactImage->GetBounds().height));
571                         Bitmap* pActualBgBmp = new Bitmap();
572                         pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds());
573                         __pLabelBlocked->SetBackgroundBitmap(*pActualBgBmp);
574                         delete pCanvas;
575                         delete pActualBgBmp;
576                 }
577                 __pLabelBlocked->Invalidate(false);
578                 __pLabelBlocked->SetShowState(true);
579         }
580         if (__pDataProvider != null)
581         {
582                 __pDataProvider->ResetDetailsList();
583         }
584         __pList->UpdateList();
585         __pList->Invalidate(false);
586 }
587
588 void
589 DlLogsDetailForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
590 {
591         if (__pDataProvider != null)
592         {
593                 __pDataProvider->ResetDetailsList();
594         }
595         if (__pCallMgr != null)
596         {
597                 __pCallMgr = null;
598         }
599 }
600
601
602 void
603 DlLogsDetailForm::SetFormMode(bool editMode)
604 {
605
606         if (editMode == false)
607         {
608                 __isEditMode = false;
609                 __pSelectAll->SetShowState(false);
610                 __pDataProvider->SetViewMode(false);
611                 __pFormFooter->RemoveItemAt(1);
612                 __pFormFooter->SetBackButton();
613                 __pList->UpdateList();
614                 if (__isPresentInContacts == false)
615                 {
616                         __pLabelBlocked->SetShowState(true);
617                         __pLabelNumberUnsaved->SetShowState(true);
618                         __pLabelName->SetShowState(false);
619                         __pLabelNumber->SetShowState(false);
620                         __pButtonContactImage->SetShowState(false);
621                 }
622                 else
623                 {
624                         __pLabelNumberUnsaved->SetShowState(false);
625                         __pLabelBlocked->SetShowState(false);
626                         __pLabelName->SetShowState(true);
627                         __pLabelNumber->SetShowState(true);
628                         __pButtonContactImage->SetShowState(true);
629                 }
630                 __pButtonCall->SetShowState(true);
631                 __pButtonMessage->SetShowState(true);
632                 int listY = __pButtonContactImage->GetBounds().height + __pButtonMessage->GetBounds().height + 40;
633                 __pList->SetBounds(Rectangle(0, listY, GetClientAreaBounds().width, __listHeight));
634                 __listItemCount = __pList->GetItemCount();
635                 __pFormFooter->SetItemEnabled(0, true);
636                 __pList->RemoveListViewItemEventListener(*this);
637                 __pSelectAll->SetSelected(false);
638                 __pSelectAll->Invalidate(false);
639                 __pSelectedLabel->SetShowState(false);
640                 __pSelectedLabel->Invalidate(false);
641         }
642         else
643         {
644                 __isEditMode = true;
645                 __pSelectAll->SetShowState(true);
646                 __pDataProvider->SetViewMode(true);
647                 __pFormFooter->AddItem(__pFooterItemCancel);
648                 __pFormFooter->RemoveBackButton();
649                 __pList->AddListViewItemEventListener(*this);
650                 __pList->UpdateList();
651                 UnCheckAllItems();
652                 if (__isPresentInContacts == false)
653                 {
654                         __pLabelBlocked->SetShowState(false);
655                         __pLabelNumberUnsaved->SetShowState(false);
656                         __pLabelName->SetShowState(false);
657                         __pLabelNumber->SetShowState(false);
658                         __pButtonContactImage->SetShowState(false);
659                 }
660                 else
661                 {
662                         __pLabelNumberUnsaved->SetShowState(false);
663                         __pLabelBlocked->SetShowState(false);
664                         __pLabelName->SetShowState(false);
665                         __pLabelNumber->SetShowState(false);
666                         __pButtonContactImage->SetShowState(false);
667                 }
668                 __pButtonCall->SetShowState(false);
669                 __pButtonMessage->SetShowState(false);
670                 __pList->SetBounds(GetClientAreaBounds().x, __pSelectAll->GetHeight(), GetClientAreaBounds().width, GetClientAreaBounds().height - (__pSelectAll->GetHeight()+__pSelectedLabel->GetHeight()));
671                 __listItemCount = __pList->GetItemCount();
672                 __pFormFooter->SetItemEnabled(0, false);
673                 __selectedItemCount = 0;
674                 String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
675                 __pSelectedLabel->SetText(selStr);
676                 __pSelectedLabel->SetShowState(true);
677                 __pSelectedLabel->Invalidate(false);
678         }
679         __pSelectAll->Invalidate(true);
680         Draw();
681 }
682
683 void
684 DlLogsDetailForm::UnCheckAllItems(void)
685 {
686         int i = 0;
687         for (; i <= __pList->GetItemCount(); i++)
688         {
689                 __pList->SetItemChecked(i, 0);
690         }
691         __selectedItemCount = 0;
692 }
693 void
694 DlLogsDetailForm::SetAllListItems(bool checked)
695 {
696         int i = 0;
697         __isSelectAll = checked;
698         for (; i <= __pList->GetItemCount(); i++)
699         {
700                 __pList->SetItemChecked(i, checked);
701         }
702         __pList->UpdateList();
703         __pFormFooter->SetItemEnabled(0, checked);
704         __pFormFooter->Invalidate(false);
705         __pFormFooter->Draw();
706 }
707 void
708 DlLogsDetailForm::OnFormBackRequested(Form& source)
709 {
710         SceneManager* pSceneManager = SceneManager::GetInstance();
711         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CALL_LOG, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
712                                                                                                                         SCENE_HISTORY_OPTION_NO_HISTORY));
713 }
714
715
716 void
717 DlLogsDetailForm::OnListViewContextItemStateChanged(ListView& listView, int index, int elementId, ListContextItemStatus status)
718 {
719
720 }
721
722 void
723 DlLogsDetailForm::OnListViewItemLongPressed(ListView& listView, int index, int elementId, bool& invokeListViewItemCallback)
724 {
725
726 }
727
728 void
729 DlLogsDetailForm::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
730 {
731         String text;
732         if (status == LIST_ITEM_STATUS_CHECKED)
733         {
734                 __selectedItemCount++;
735         }
736         else if (status == LIST_ITEM_STATUS_UNCHECKED)
737         {
738                 __selectedItemCount--;
739         }
740
741         if (__selectedItemCount == __listItemCount)
742         {
743                 __pSelectAll->SetSelected(true);
744         }
745         else
746         {
747                 __pSelectAll->SetSelected(false);
748         }
749         __pSelectAll->Invalidate(false);
750         if (__selectedItemCount == 0)
751         {
752                 __pFormFooter->SetItemEnabled(0, false);
753                 String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
754                 __pSelectedLabel->SetText(selStr);
755         }
756         else
757         {
758                 __pFormFooter->SetItemEnabled(0, true);
759                 String selItemStr = L"";
760                 if(__selectedItemCount > 1)
761                 {
762                         selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
763                 }
764                 else
765                 {
766                         selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
767                 }
768                 text.Format(100, selItemStr.GetPointer(), __selectedItemCount);
769                 __pSelectedLabel->SetText(text);
770         }
771         __pFormFooter->Draw();
772         __pSelectedLabel->Invalidate(false);
773 }
774
775 void
776 DlLogsDetailForm::OnListViewItemSwept(ListView& listView, int index, SweepDirection direction)
777 {
778
779 }
780
781 void
782 DlLogsDetailForm::OnAppControlCompleteResponseReceived(const AppId& appId, const String& operationId, AppCtrlResult appControlResult, const IMap* pExtraData)
783 {
784         if (__isMsgAppControlLaunched == true)
785         {
786                 //Message AppControl request completed.
787                 __isMsgAppControlLaunched = false;
788         }
789 }