89f486c95071293d58d2c0e0920984dcd4a498ee
[apps/osp/Call.git] / src / CallIncomingCallForm.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    CallIncomingCallForm.cpp
19  * @brief       Incoming Call form implementation
20  */
21 #include <FBaseColIList.h>
22 #include "CallIncomingCallForm.h"
23 #include "CallAppUtility.h"
24 #include "CallSettingsManager.h"
25 #include "CallPresentationModel.h"
26 #include "CallSceneRegister.h"
27 #include "CallTypes.h"
28 #include "CallApp.h"
29
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Animations;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
38
39 //Constants
40 const int W_DIAL_BITMAP = 100;
41 const int H_DIAL_BITMAP = 100;
42 const int W_CREATE_BITMAP = 56;
43 const int H_CREATE_BITMAP = 56;
44 const int X_CREATE_BITMAP = 8;
45 const int Y_CREATE_BITMAP = 8;
46 const int W_MESSAGE_BG_BITMAP = 720;
47 const int H_MESSAGE_BG_BITMAP = 110;
48 const int W_ARROW_BITMAP = 28;
49 const int H_ARROW_BITMAP = 36;
50 const int W_MESSAGE_BITMAP = 50;
51 const int H_MESSAGE_BITMAP = 50;
52 const int X_MESSAGE_BITMAP = 185;
53 const int Y_MESSAGE_BITMAP = 50;
54 const int MESSAGE_TEXT_X_MARGIN = 20;
55 const int MESSAGE_TEXT_Y_MARGIN = 10;
56 const int SEND_TEXT_X_MARGIN = 78;
57 const int SEND_TEXT_Y_MARGIN = 20;
58 const int SEND_BUTTON_ROUND_DIMENSION = 5;
59 const int W_DIAL_LABEL = 188;
60 const int H_DIAL_LABEL = 188;
61 const int DIAL_ICON_X_OFFSET = 44;
62 const int DIAL_ICON_Y_OFFSET = 44;
63 const int REJECT_LABEL_X_OFFSET = 492;
64 const int X_CALL_PANEL = 20;
65 const int Y_CALL_PANEL = 110;
66 const int H_CALL_PANEL = 188;
67 const int Y_ARROW_LABEL = 79;
68 const int W_ARROW_LABEL = 20;
69 const int H_ARROW_LABEL = 32;
70 const int VALID_TOUCH_X_OFFSET = 158;
71 const int VALID_TOUCH_Y_OFFSET = 158;
72 const int X_ARROW_LABEL_STARTPOS = 206; // 188 circle wodth , 18 GUI spec
73 const int X_ARROW_REJECT_LABEL_STARTPOS = 454; // 700 width of panel - 20 offset - 188 circle width - 18 GUI spec - 20 width of image
74 const int ARROW_LABEL_X_MARGIN = 48; //20 width of arrow and 28 GUI spec
75 const int ACCEPT_LABEL_RELATIVE_POS = -384; //relative pos of accept labels right to reject labels left
76 const int MAX_LIST_HEIGHT = 448;//678;
77 const int H_REJECT_VIEW_FOOTER = 98;
78 const int X_LIST_TEXT_ITEM = 16;
79 const int W_LIST_TEXT_ITEM = 452;
80 const int H_LIST_TEXT_ITEM = 111;
81 const int X_SEND_TEXT_ITEM = 484;
82 const int Y_SEND_TEXT_ITEM = 20;
83 const int W_SEND_TEXT_ITEM = 220;
84 const int W_SEND_BUTTON_MARGIN = 14;
85 const int H_SEND_TEXT_ITEM = 72;
86 const int X_PHOTO_LBL = 166;
87 const int Y_PHOTO_LBL = 232;
88 const int W_PHOTO_LBL = 388;
89 const int H_PHOTO_LBL = 388;
90 const int W_PHOTO_LABEL = 720;
91 const int H_PHOTO_LABEL = 720;
92 const int COUNT_ARROW_ELEMENTS = 3;
93
94 const unsigned int COLOR_SEND_BUTTON_PRESSED = Color32<130, 142, 150>::Value;
95 const unsigned int COLOR_SEND_BUTTON_NORMAL = Color32<64, 156, 211>::Value;
96 const unsigned int COLOR_SWIPE_PANEL = Color32<0, 0, 0, 255>::Value;
97 const unsigned int COLOR_LIST_TEXT_NORMAL = Color32<0, 0, 0>::Value;
98 const unsigned int COLOR_LIST_TEXT_PRESSED = Color32<249, 249, 249>::Value;
99
100 const int FONT_SIZE_MSG_TXT = 44;
101
102 static const wchar_t* IDL_INCOMING_CALL_FORM = L"IDL_INCOMING_CALL_FORM";
103 static const wchar_t* IDB_REJECT_MESSAGE_BG = L"C01-1_Reject_message_bg.png";
104 static const wchar_t* IDB_REJECT_MESSAGE_UP_ARROW = L"C01-1_Reject_message_arrow_01.png";
105 static const wchar_t* IDB_REJECT_MESSAGE_DOWN_ARROW = L"C01-1_Reject_message_arrow_02.png";
106 static const wchar_t* IDB_REJECT_MESSAGE_ICON = L"C01-1_icon_Reject_with_Message.png";
107 static const wchar_t* IDB_ACCEPT_CIRCLE_ICON = L"C01-1_accept_left.png";
108 static const wchar_t* IDB_REJECT_CIRCLE_ICON = L"C01-1_reject_right.png";
109 static const wchar_t* IDB_CALL_ACCEPT_ICON = L"C01-1_accept_left_dial_answer.png";
110 static const wchar_t* IDB_CALL_REJECT_ICON = L"C01-1_reject_right_dial_decline.png";
111 static const wchar_t* IDB_ACCEPT_ARROW_ICON = L"C01-1_arrow_g.png";
112 static const wchar_t* IDB_REJECT_ARROW_ICON = L"C01-1_arrow_r.png";
113 static const wchar_t* IDB_CALL_BG = L"C01-1_calling_BG_01.png";
114 static const wchar_t* IDC_REJECT_MESSAGE_BUTTON = L"IDC_REJECT_MESSAGE_BUTTON";
115 static const wchar_t* IDC_REJECT_PANEL = L"IDC_REJECT_PANEL";
116 static const wchar_t* IDC_REJECT_MESSAGE_CANCEL_BUTTON = L"IDC_REJECT_MESSAGE_CANCEL_BUTTON";
117 static const wchar_t* IDC_MSG_TABLEVIEW = L"IDC_MSG_TABLEVIEW";
118 static const wchar_t* IDC_CALLER_LABEL = L"IDC_CALLER_LABEL";
119 static const wchar_t* IDC_NUMBER_LABEL = L"IDC_NUMBER_LABEL";
120 static const wchar_t* IDC_BIG_PHOTO_LABEL = L"IDC_BIG_PHOTO_LABEL";
121 static const wchar_t* IDC_CALLHANDEL_PANEL = L"IDC_CALLHANDEL_PANEL";
122 static const wchar_t* IDC_ACCEPT_LABEL = L"IDC_ACCEPT_LABEL";
123 static const wchar_t* IDC_REJECT_LEBEL = L"IDC_REJECT_LEBEL";
124 static const wchar_t* IDC_ACCEPT_ARROW = L"IDC_ACCEPT_ARROW_";
125 static const wchar_t* IDC_REJECT_ARROW = L"IDC_REJECT_ARROW_";
126 const wchar_t* IDS_REJECT_MESSAGE_BTN = L"IDS_REJECT_MESSAGE_BTN";
127 const wchar_t* IDS_LIST_SEND_BUTTON = L"IDS_LIST_SEND_BUTTON";
128 const wchar_t* IDS_NO_MESSAGE_STR = L"IDS_NO_MESSAGE_STR";
129
130 const wchar_t* IDI_FORM_VISUAL_ELE_NAME = L"FormVisEle";
131 const wchar_t* IDI_PANEL_VISUAL_ELE_NAME = L"PanelVisEle";
132 const wchar_t* IDI_ACCEPT_VISUAL_ELE_NAME = L"AcceptVisEle";
133 const wchar_t* IDI_REJECT_VISUAL_ELE_NAME = L"RejectVisEle";
134 const wchar_t* IDI_ACCEPT_ARROW_VISUAL_ELE_NAME = L"AcceptArrowVisEle";
135 const wchar_t* IDI_REJECT_ARROW_VISUAL_ELE_NAME = L"RejectArrowVisEle";
136 const wchar_t* IDI_REJECT_FINAL_VISUAL_ELE_NAME = L"RejectFinalVisEle";
137 const wchar_t* IDI_ACCEPT_FINAL_VISUAL_ELE_NAME = L"AcceptFinalVisEle";
138
139 IncomingCallForm::IncomingCallForm(void)
140         : BaseForm(FORMTYPE_INCOMINGCALL)
141 {
142         __pActiveContactNo = null;
143         __pRejectMessageList = null;
144         __incomingCallHandle = -1;
145         __isAnswerCallStarted = false;
146         __isRejectCallStarted = false;
147         __pAcceptArrowLabelsList = null;
148         __pRejectArrowLabelsList = null;
149         __pRejectCircle = null;
150         __pAcceptCircle = null;
151         __pAcceptDial = null;
152         __pRejectDial = null;
153         __pAcceptArrow = null;
154         __pRejectArrow = null;
155         __pAcceptLabel = null;
156         __pRejectLabel = null;
157         __pAcceptArrowLabel = null;
158         __pRejectArrowLabel = null;
159         __pCallHandlePanel = null;
160         __pAcceptVisElem = null;
161         __pRejectVisElem = null;
162         __pRejectFinalVisElem = null;
163         __pAcceptFinalVisElem = null;
164         __pAcceptArrowVisElem = null;
165         __pRejectArrowVisElem = null;
166         __pCallPresentor = null;
167         __pOptionPopup = null;
168         __pSmallPhotoLabel = null;
169 }
170
171 IncomingCallForm::~IncomingCallForm(void)
172 {
173 }
174
175 void
176 IncomingCallForm::Initialize(void)
177 {
178         Construct(IDL_INCOMING_CALL_FORM);
179 }
180
181 result
182 IncomingCallForm::OnInitializing(void)
183 {
184         result r = E_SUCCESS;
185         Canvas* pCanvas = null;
186
187         InitializeFooter();
188
189
190         VisualElement* pFormVisElem = new (std::nothrow) VisualElement();
191         r = pFormVisElem->Construct();
192         pFormVisElem->SetBounds(FloatRectangle(GetBounds().x, GetBounds().y, GetBounds().width, GetBounds().height));
193         pFormVisElem->SetShowState(true);
194         pFormVisElem->SetOpacity(1.0f);
195         pFormVisElem->SetName(IDI_FORM_VISUAL_ELE_NAME);
196         GetVisualElement()->AttachChild(*pFormVisElem);
197         pCanvas = pFormVisElem->GetCanvasN();
198         if(pCanvas != null)
199         {
200                 pCanvas->Clear();
201                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
202                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
203                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(GetBounds().x, GetBounds().y, GetBounds().width, GetBounds().height));
204                 delete pCanvas;
205                 pCanvas = null;
206         }
207         HideRejectPanel();
208
209
210         InitializeTableView();
211
212         __pAcceptCircle = AppUtility::GetBitmapFromResourcesN(IDB_ACCEPT_CIRCLE_ICON, W_DIAL_LABEL, H_DIAL_LABEL);
213         __pRejectCircle = AppUtility::GetBitmapFromResourcesN(IDB_REJECT_CIRCLE_ICON, W_DIAL_LABEL, H_DIAL_LABEL);
214         __pAcceptDial = AppUtility::GetBitmapFromResourcesN(IDB_CALL_ACCEPT_ICON, W_DIAL_BITMAP, H_DIAL_BITMAP);
215         __pRejectDial = AppUtility::GetBitmapFromResourcesN(IDB_CALL_REJECT_ICON, W_DIAL_BITMAP, H_DIAL_BITMAP);
216         __pAcceptArrow = AppUtility::GetBitmapFromResourcesN(IDB_ACCEPT_ARROW_ICON, W_ARROW_LABEL, H_ARROW_LABEL);
217         __pRejectArrow = AppUtility::GetBitmapFromResourcesN(IDB_REJECT_ARROW_ICON, W_ARROW_LABEL, H_ARROW_LABEL);
218
219
220         if(__pRejectDial == null)
221         {
222                 AppLogDebug("Null");
223         }
224         //Panel for showing accept and reject call buttons.
225         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_BIG_PHOTO_LABEL, true));
226          int yPos = pPhotoLbl->GetX()+pPhotoLbl->GetHeight()+ Y_CALL_PANEL;
227
228         __pCallHandlePanel = static_cast<Panel*>(GetControl(IDC_CALLHANDEL_PANEL, true));
229         __pCallHandlePanel->AddTouchEventListener(*this);
230         __pCallHandlePanel->SetBackgroundColor(COLOR_SWIPE_PANEL);
231         VisualElement* pCallPanelVisElem = new (std::nothrow) VisualElement();
232         r = pCallPanelVisElem->Construct();
233         pCallPanelVisElem->SetBounds(FloatRectangle(__pCallHandlePanel->GetBoundsF()));
234         pCallPanelVisElem->SetShowState(true);
235         pCallPanelVisElem->SetOpacity(1.0f);
236         pCallPanelVisElem->SetName(IDI_PANEL_VISUAL_ELE_NAME);
237         __pCallHandlePanel->GetVisualElement()->AttachChild(*pCallPanelVisElem);
238         pCanvas = pCallPanelVisElem->GetCanvasN();
239         if(pCanvas != null)
240         {
241                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
242                 pCanvas->Clear();
243                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
244                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
245                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(X_CALL_PANEL, yPos, GetClientAreaBounds().width, H_CALL_PANEL));
246                 delete pCanvas;
247                 pCanvas = null;
248         }
249         //Lock Label for animation
250         __pAcceptLabel = static_cast<Label*>(GetControl(IDC_ACCEPT_LABEL, true));
251         __pAcceptLabel->SetBackgroundColor(COLOR_SWIPE_PANEL);
252         __pAcceptLabel->AddTouchEventListener(*this);
253         //left dial icon
254         __pAcceptVisElem = new (std::nothrow) VisualElement();
255         r = __pAcceptVisElem->Construct();
256         __pAcceptVisElem->SetBounds(FloatRectangle(0, 0, __pAcceptLabel->GetWidth(), __pAcceptLabel->GetHeight()));
257         __pAcceptVisElem->SetShowState(true);
258         __pAcceptVisElem->SetOpacity(1.0f);
259         __pAcceptVisElem->SetName(IDI_ACCEPT_VISUAL_ELE_NAME);
260         __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem);
261         pCanvas = __pAcceptVisElem->GetCanvasN();
262         if(pCanvas != null)
263         {
264                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
265                 pCanvas->Clear();
266                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
267                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
268                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
269                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pAcceptCircle);
270                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pAcceptDial);
271                 delete pCanvas;
272                 pCanvas = null;
273         }
274         //UnLock Label for animation
275         __pRejectLabel = static_cast<Label*>(GetControl(IDC_REJECT_LEBEL, true));
276         __pRejectLabel->AddTouchEventListener(*this);
277         __pRejectLabel->SetBackgroundColor(COLOR_SWIPE_PANEL);
278         SetControlAlwaysAtBottom(*__pCallHandlePanel, true);
279
280         //Right reject icon
281         __pRejectVisElem = new (std::nothrow) VisualElement();
282         r = __pRejectVisElem->Construct();
283         __pRejectVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
284         __pRejectVisElem->SetShowState(true);
285         __pRejectVisElem->SetOpacity(1.00f);
286         __pRejectVisElem->SetName(IDI_REJECT_VISUAL_ELE_NAME);
287         __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem);
288         pCanvas = __pRejectVisElem->GetCanvasN();
289         if(pCanvas != null)
290         {
291                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
292                 pCanvas->Clear();
293                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
294                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
295                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
296                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pRejectCircle);
297                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pRejectDial);
298                 delete pCanvas;
299                 pCanvas = null;
300         }
301
302         //! Constructs an array list to store the unlock labels
303         __pAcceptArrowLabelsList = new (std::nothrow) ArrayList();
304         r = __pAcceptArrowLabelsList->Construct();
305
306         //! Constructs the Unlock Labels with the bitmap as background, adds the touch event Listener and adds them to the panel.
307         int x = X_ARROW_LABEL_STARTPOS;
308         for (int index = 0; index < COUNT_ARROW_ELEMENTS; index++)
309         {
310                 String LabelName(IDC_ACCEPT_ARROW);
311                 LabelName.Append(index+1);
312                 __pAcceptArrowLabel = static_cast<Label*>(GetControl(LabelName, true));
313                 __pAcceptArrowLabel->AddTouchEventListener(*this);
314                 __pAcceptArrowLabelsList->Add(*__pAcceptArrowLabel);
315                 __pAcceptArrowVisElem = new (std::nothrow) VisualElement();
316                 r = __pAcceptArrowVisElem->Construct();
317                 __pAcceptArrowVisElem->SetBounds(FloatRectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
318                 __pAcceptArrowVisElem->SetShowState(true);
319                 __pAcceptArrowVisElem->SetOpacity(0.0f);
320                 String VisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
321                 VisualEleName.Append(index);
322                 __pAcceptArrowVisElem->SetName(VisualEleName);
323                 __pAcceptArrowLabel->GetVisualElement()->AttachChild(*__pAcceptArrowVisElem);
324                 pCanvas = __pAcceptArrowVisElem->GetCanvasN();
325                 if(pCanvas != null)
326                 {
327                         pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
328                         pCanvas->Clear();
329                         pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
330                         pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
331                         pCanvas->DrawRectangle(Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
332                         pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
333                         pCanvas->DrawBitmap(Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL), *__pAcceptArrow);
334                         delete pCanvas;
335                         pCanvas = null;
336                 }
337                 x += ARROW_LABEL_X_MARGIN;
338         }
339         //! Constructs an array list to store the unlock labels
340         __pRejectArrowLabelsList = new (std::nothrow) ArrayList();
341         r = __pRejectArrowLabelsList->Construct();
342
343         x = X_ARROW_REJECT_LABEL_STARTPOS;
344         for (int index = 0; index < COUNT_ARROW_ELEMENTS; index++)
345         {
346                 String LabelName(IDC_REJECT_ARROW);
347                 LabelName.Append(index+1);
348                 __pRejectArrowLabel = static_cast<Label*>(GetControl(LabelName, true));
349                 __pRejectArrowLabel->AddTouchEventListener(*this);
350                 __pRejectArrowLabelsList->Add(*__pRejectArrowLabel);
351                 __pRejectArrowVisElem = new (std::nothrow) VisualElement();
352                 r = __pRejectArrowVisElem->Construct();
353                 __pRejectArrowVisElem->SetBounds(FloatRectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
354                 __pRejectArrowVisElem->SetShowState(true);
355                 __pRejectArrowVisElem->SetOpacity(0.0f);
356                 String VisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
357                 VisualEleName.Append(index);
358                 __pRejectArrowVisElem->SetName(VisualEleName);
359                 __pRejectArrowLabel->GetVisualElement()->AttachChild(*__pRejectArrowVisElem);
360                 pCanvas = __pRejectArrowVisElem->GetCanvasN();
361                 if(pCanvas != null)
362                 {
363                         pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
364                         pCanvas->Clear();
365                         pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
366                         pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
367                         pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL));
368                         pCanvas->DrawBitmap(Rectangle(0, 0, W_ARROW_LABEL, H_ARROW_LABEL), *__pRejectArrow);
369                         delete pCanvas;
370                         pCanvas = null;
371                 }
372                 x -= ARROW_LABEL_X_MARGIN;
373         }
374
375
376         return r;
377 }
378
379 void
380 IncomingCallForm::InitializeFooter(void)
381 {
382         Footer* pFooter = GetFooter();
383         FooterItem footerItemCreate;
384
385         SetFormBackEventListener(this);
386         if(pFooter != null)
387         {
388                 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
389                 pFooter->AddActionEventListener(*this);
390
391                 footerItemCreate.Construct(IDA_CREATE_REJECT_CALL_MESSAGE);
392                 footerItemCreate.SetText(AppUtility::GetResourceString(IDS_REJECT_MESSAGE_CREATE));
393                 pFooter->AddItem(footerItemCreate);
394                 pFooter->SetShowState(false);
395         }
396 }
397
398 void
399 IncomingCallForm::ShowRejectMessageFooter(void)
400 {
401         Footer* pFooter = GetFooter();
402         if(pFooter != null)
403         {
404                 AppLogDebug("SetShowState");
405                 pFooter->SetShowState(true);
406
407         }
408 }
409
410 void
411 IncomingCallForm::HideRejectMessageFooter(void)
412 {
413         Footer* pFooter = GetFooter();
414         if(pFooter != null)
415         {
416                 pFooter->SetShowState(false);
417         }
418 }
419
420 result
421 IncomingCallForm::OnTerminating(void)
422 {
423         result r = E_SUCCESS;
424
425         if (__pRejectMessageList != null)
426         {
427                 delete __pRejectMessageList;
428                 __pRejectMessageList = null;
429         }
430         if (__pActiveContactNo != null)
431         {
432                 delete __pActiveContactNo;
433                 __pActiveContactNo = null;
434         }
435         __incomingCallHandle = -1;
436         __pCallPresentor = null;
437
438         /* Deleting fails in A4RC* SDK. Remove if not necessary
439         if (__pAcceptVisElem != null)
440         {
441                 __pAcceptVisElem->Destroy();
442                 __pAcceptVisElem = null;
443         }
444
445         if (__pRejectVisElem != null)
446         {
447                 __pRejectVisElem->Destroy();
448                 __pRejectVisElem = null;
449         }
450
451         if (__pRejectFinalVisElem != null)
452         {
453                 __pRejectFinalVisElem->Destroy();
454                 __pRejectFinalVisElem = null;
455         }
456
457         if (__pAcceptFinalVisElem != null)
458         {
459                 __pAcceptFinalVisElem->Destroy();
460                 __pAcceptFinalVisElem = null;
461         }
462
463         for (int i = 0; i < 7; i++)
464         {
465                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
466                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement();
467                 if (__pRejectArrowVisElem != null)
468                 {
469                         __pRejectArrowVisElem->Destroy();
470                         __pRejectArrowVisElem = null;
471                 }
472
473                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
474                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement();
475                 if (__pAcceptArrowVisElem != null)
476                 {
477                         __pAcceptArrowVisElem->Destroy();
478                         __pAcceptArrowVisElem = null;
479                 }
480         }
481
482         if (__pAcceptArrowVisElem != null)
483         {
484                 __pAcceptArrowVisElem = null;
485         }
486
487         if (__pRejectArrowVisElem != null)
488         {
489                 __pRejectArrowVisElem = null;
490         }
491 */
492         if (__pAcceptArrowLabelsList != null)
493         {
494                 __pAcceptArrowLabelsList->RemoveAll(false);
495                 delete __pAcceptArrowLabelsList;
496                 __pAcceptArrowLabelsList = null;
497         }
498
499         if (__pRejectArrowLabelsList != null)
500         {
501                 __pRejectArrowLabelsList->RemoveAll(false);
502                 delete __pRejectArrowLabelsList;
503                 __pRejectArrowLabelsList = null;
504         }
505
506         if (__pRejectCircle != null)
507         {
508                 delete __pRejectCircle;
509                 __pRejectCircle = null;
510         }
511
512         if (__pAcceptCircle != null)
513         {
514                 delete __pAcceptCircle;
515                 __pAcceptCircle = null;
516         }
517
518         if (__pAcceptDial != null)
519         {
520                 delete __pAcceptDial;
521                 __pAcceptDial = null;
522         }
523
524         if (__pRejectDial != null)
525         {
526                 delete __pRejectDial;
527                 __pRejectDial = null;
528         }
529
530         if (__pAcceptArrow != null)
531         {
532                 delete __pAcceptArrow;
533                 __pAcceptArrow = null;
534         }
535
536         if (__pRejectArrow != null)
537         {
538                 delete __pRejectArrow;
539                 __pRejectArrow = null;
540         }
541         __pCallHandlePanel->RemoveTouchEventListener(*this);
542         __pAcceptLabel->RemoveTouchEventListener(*this);
543         __pRejectLabel->RemoveTouchEventListener(*this);
544         __pAcceptArrowLabel->RemoveTouchEventListener(*this);
545         __pRejectArrowLabel->RemoveTouchEventListener(*this);
546         __pAcceptLabel = null;
547         __pRejectLabel = null;
548         __pAcceptArrowLabel = null;
549         __pRejectArrowLabel = null;
550         __pCallHandlePanel = null;
551         return r;
552 }
553
554 void
555 IncomingCallForm::ShowRejectMessagePanel(void)
556         {
557                 Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
558                 if (pKeysPanel)
559                 {
560                         pKeysPanel->SetShowState(true);
561                         TableView* pMessageList = static_cast<TableView*>(pKeysPanel->GetControl(IDC_MSG_TABLEVIEW));
562                         Rectangle tmpRect = pMessageList->GetBounds();
563                         SetControlAlwaysOnTop(*pKeysPanel,true);
564
565                         //Set Height to Reject Message Panel
566                         int listHeight = H_LIST_NORMAL_MENU_ITEM; //If no messages
567                         if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0)
568                         {
569                                 listHeight = H_LIST_NORMAL_MENU_ITEM * (__pRejectMessageList->GetCount()); //multiply by number of items
570                         }
571                         if (listHeight > MAX_LIST_HEIGHT)
572                         {
573                                 listHeight = MAX_LIST_HEIGHT;
574                         }
575
576                         pMessageList->SetBounds(tmpRect.x, tmpRect.y, tmpRect.width, listHeight);
577                         pMessageList->UpdateTableView();
578                         tmpRect = pKeysPanel->GetBounds();
579                         pKeysPanel->SetBounds(tmpRect.x, tmpRect.y, tmpRect.width, H_MESSAGE_BG_BITMAP /*+ H_REJECT_VIEW_FOOTER*/ + listHeight);
580
581                         Button* pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
582                         pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL);
583                         pButtonReject->AddActionEventListener(*this);
584                         pButtonReject->SetEnabled(true);
585                         //pButtonReject->SetFocus();
586
587                         ShowRejectMessageFooter();
588
589
590                         pKeysPanel->SetFocus();
591                         pKeysPanel->Draw();
592                 }
593                 Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
594                 if (pButtonRejectMessage)
595                 {
596                         pButtonRejectMessage->SetShowState(false);
597                         pButtonRejectMessage->Invalidate(true);
598                         pButtonRejectMessage->Draw();
599                 }
600         }
601 void
602 IncomingCallForm::HideRejectMessagePanel(void)
603 {
604         HideRejectPanel();
605         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
606         if (pButtonRejectMessage)
607         {
608                 pButtonRejectMessage->SetShowState(true);
609                 RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(GetLandscapeLayoutN());
610                 if (pRelativeLayout != null)
611                 {
612                         pRelativeLayout->SetRelation(*pButtonRejectMessage,*this,RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM);
613                         pRelativeLayout->Update();
614                         delete pRelativeLayout;
615                 }
616         }
617 }
618
619 void
620 IncomingCallForm::OnActionPerformed(const Control& source, int actionId)
621 {
622         switch (actionId)
623         {
624         case IDA_SHOW_REJECT_CALL_MESSAGE_PANEL: // applicable in all form states
625         {
626                 ShowRejectMessagePanel();
627         }
628         break;
629
630         case IDA_CREATE_REJECT_CALL_MESSAGE:
631         {
632                 __pCallPresentor->RejectCall(__incomingCallHandle, true,*__pActiveContactNo);
633                 ArrayListT<AppCallInfo>* pCallList  = static_cast<ArrayListT<AppCallInfo>*>(__pCallPresentor->GetCallListN());
634                 if(pCallList != null && pCallList->GetCount() > 0)
635                 {
636                         __pCallPresentor->HandleCallConnected(*pCallList);
637                 }
638                 pCallList = null;
639         }
640         break;
641
642         case IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL:
643         {
644                 HideRejectMessagePanel();
645         }
646         break;
647
648         case IDA_SEND_REJECT_MSG1:
649         case IDA_SEND_REJECT_MSG2:
650         case IDA_SEND_REJECT_MSG3:
651         case IDA_SEND_REJECT_MSG4:
652         case IDA_SEND_REJECT_MSG5:
653         case IDA_SEND_REJECT_MSG6:
654         {
655                 __pCallPresentor->RejectCall(__incomingCallHandle, false,*__pActiveContactNo);
656                 String textToBeSent;
657                 //calculate msgIndex
658                 int msgIndex = IDA_SEND_REJECT_MSG1;
659                 msgIndex = actionId - msgIndex;
660                 __pRejectMessageList->GetAt(msgIndex, textToBeSent);
661                 __pCallPresentor->SendMessage(textToBeSent,*__pActiveContactNo);
662         }
663         break;
664
665         default:
666                 break;
667         }
668 }
669
670 void
671 IncomingCallForm::OnSceneActivatedN(const SceneId& previousSceneId,     const SceneId& currentSceneId, IList* pArgs)
672 {
673         AddOrientationEventListener(*this);
674         //Get Reject list from Settings Manager
675         IMapT<int,String>* pMsgMap = SettingsManager::GetInstance()->GetRejectMessageListN();
676         if(pMsgMap != null)
677         {
678                 if (__pRejectMessageList != null)
679                 {
680                         delete __pRejectMessageList;
681                         __pRejectMessageList = null;
682                 }
683                 __pRejectMessageList = pMsgMap->GetValuesN();
684                 delete pMsgMap;
685                 pMsgMap = null;
686         }
687         //No reject messages
688         else
689         {
690                 if (__pRejectMessageList != null)
691                 {
692                         delete __pRejectMessageList;
693                         __pRejectMessageList = null;
694                 }
695         }
696         //listen to Foreground events
697         CallApp* pPhoneApp = static_cast<CallApp*>(CallApp::GetInstance());
698         pPhoneApp->AddAppStateChangeListener(*this);
699         if(__pCallPresentor == null)
700         {
701                 __pCallPresentor = CallPresentationModel::GetInstance();
702         }
703         __pCallPresentor->SetTelEventListener(this);
704         //Abort any AppControl Request running already to show incoming call screen
705         if (__pCallPresentor->IsAppControlRunning() == true)
706         {
707                 __pCallPresentor->AbortAppControlRequest();
708         }
709
710         HideRejectPanel();
711
712         if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_VISUAL_ELE_NAME,true) == null)
713         {
714                 __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem);
715         }
716         if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_VISUAL_ELE_NAME,true) == null)
717         {
718                 __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem);
719         }
720
721         __pAcceptVisElem->SetOpacity(1.0f);
722         __pRejectVisElem->SetOpacity(1.00f);
723         for (int i = 0; i < COUNT_ARROW_ELEMENTS; i++)
724         {
725                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
726                 String RejectVisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
727                 RejectVisualEleName.Append(i);
728                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(RejectVisualEleName,true);
729                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
730                 String AcceptVisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
731                 AcceptVisualEleName.Append(i);
732                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(AcceptVisualEleName,true);
733                 switch(i)
734                 {
735                         case 0:
736                                 __pAcceptArrowVisElem->SetOpacity(0.6f);
737                                 __pRejectArrowVisElem->SetOpacity(0.6f);
738                         break;
739                         case 1:
740                                 __pAcceptArrowVisElem->SetOpacity(0.8f);
741                                 __pRejectArrowVisElem->SetOpacity(0.8f);
742                         break;
743                         case 2:
744                                 __pAcceptArrowVisElem->SetOpacity(1.0f);
745                                 __pRejectArrowVisElem->SetOpacity(1.0f);
746                         break;
747                 }
748
749         }
750
751
752         if (pArgs != null)
753         {
754                 //get Call Info
755                 AppCallInfo* pIncomingCall = static_cast<AppCallInfo*>(pArgs->GetAt(0));
756                 if (pIncomingCall != null)
757                 {
758                         //start alert with contact's custom ringtone
759                         __pCallPresentor->StartAlert(*pIncomingCall);
760                         //show contact number
761                         String contactNo;
762                         contactNo.Append(pIncomingCall->GetContactNumber());
763                         if (__pActiveContactNo)
764                         {
765                                 delete __pActiveContactNo;
766                                 __pActiveContactNo = null;
767                         }
768                         __incomingCallHandle = pIncomingCall->GetCallHandle()->ToLong();
769                         __pActiveContactNo = new (std::nothrow) String();
770
771                         if(contactNo.IsEmpty())
772                         {
773                                 AppLogDebug("Number empty");
774                                 contactNo.Append(AppUtility::GetResourceString(IDS_NUMBER_UNKNOWN));
775                                 AppLogDebug("%ls",contactNo.GetPointer());
776                         }
777                         __pActiveContactNo->Append(contactNo);
778                         //Show person details
779                         ShowPersonDetails(*__pActiveContactNo, IDC_NUMBER_LABEL, IDC_CALLER_LABEL, pIncomingCall);
780                         //Check if incoming call is hidden call, then do not show "Reject with Message" button
781                         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
782                         if (pButtonRejectMessage)
783                         {
784                                 //for hidden call, contact number is not present
785                                 bool showRejectMsgButton = (pIncomingCall->GetContactNumber().IsEmpty() == false);
786                                 pButtonRejectMessage->SetShowState(showRejectMsgButton);
787                                 pButtonRejectMessage->Invalidate(true);
788                         }
789                 }
790                 pArgs->RemoveAll();
791                 delete pArgs;
792                 pArgs = null;
793         }
794         CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
795         pCallApp->SetTopMostWindow(true);
796         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
797         if (pButtonRejectMessage)
798         {
799                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
800                                                                            IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, false);
801                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
802                                                                            IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, true);
803                 pButtonRejectMessage->SetActionId(IDA_SHOW_REJECT_CALL_MESSAGE_PANEL);
804                 pButtonRejectMessage->AddActionEventListener(*this);
805         }
806
807         //This called here to handle the case when incoming call comes when
808         // add call is in foreground.
809         //__pCallPresentor->OnAppForeground();
810
811 }
812
813 void
814 IncomingCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
815 {
816         RemoveOrientationEventListener(*this);
817         if (__pSmallPhotoLabel != null)
818         {
819                 RemoveControl(*__pSmallPhotoLabel);
820                 __pSmallPhotoLabel = null;
821         }
822         for (int i = 0; i < COUNT_ARROW_ELEMENTS; i++)
823         {
824                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
825                 String RejectVisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
826                 RejectVisualEleName.Append(i);
827                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(RejectVisualEleName,true);
828                 __pRejectArrowVisElem->SetOpacity(0.0f);
829                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
830                 String AcceptVisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
831                 AcceptVisualEleName.Append(i);
832                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(AcceptVisualEleName,true);
833                 __pAcceptArrowVisElem->SetOpacity(0.0f);
834         }
835         if(__pAcceptLabel != null)
836         {
837                 if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_FINAL_VISUAL_ELE_NAME,true) != null)
838                 {
839                         AppLogDebug("__pAcceptLabel Detatach child");
840                         __pAcceptLabel->GetVisualElement()->DetachChild(*__pAcceptFinalVisElem);
841                 }
842         }
843         if(__pRejectLabel != null)
844         {
845                 if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_FINAL_VISUAL_ELE_NAME,true) != null)
846                 {
847                         AppLogDebug("__pRejectLabel Detatach child");
848                         __pRejectLabel->GetVisualElement()->DetachChild(*__pRejectFinalVisElem);
849                 }
850
851         }
852         CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
853         pCallApp->RemoveAppStateChangeListener(*this);
854 }
855
856 result
857 IncomingCallForm::OnDraw(void)
858 {
859         Bitmap* pBackgroundWp = null;
860         // get a Canvas instance
861         Canvas* pCanvas = GetCanvasN();
862
863         pBackgroundWp = AppResource::GetInstance()->GetBitmapN(IDB_CALL_BG);
864
865         if (pCanvas)
866         {
867
868                 if (pBackgroundWp)
869                 {
870                         pCanvas->DrawBitmap(pCanvas->GetBounds(), *pBackgroundWp);
871                 }
872         }
873
874         delete pBackgroundWp;
875         pBackgroundWp = null;
876
877         delete pCanvas;
878         pCanvas = null;
879
880         return E_SUCCESS;
881 }
882
883 void
884 IncomingCallForm::HideRejectPanel(void)
885 {
886         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
887         if (pKeysPanel)
888         {
889                 pKeysPanel->SetShowState(false);
890                 Button* pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
891                 pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL);
892                 pButtonReject->AddActionEventListener(*this);
893                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
894                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, false);
895                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
896                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, true);
897
898                 HideRejectMessageFooter();
899                 pKeysPanel->Invalidate(true);
900         }
901 }
902
903 void
904 IncomingCallForm::InitializeTableView(void)
905 {
906         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
907
908         TableView* pMessageList = static_cast<TableView*>(pKeysPanel->GetControl(IDC_MSG_TABLEVIEW));
909         pMessageList->SetItemProvider(this);
910         pMessageList->AddTableViewItemEventListener(*this);
911 }
912
913 ///////////////////////////////////////////////////////////////////////////////
914 /////                   Table View Functionality supporting functions                    /////
915 //////////////////////////////////////////////////////////////////////////////
916 int
917 IncomingCallForm::GetItemCount(void)
918 {
919         if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0)
920         {
921                 return (__pRejectMessageList->GetCount());
922         }
923         return 1;
924 }
925
926 TableViewItem*
927 IncomingCallForm::CreateItem(int itemIndex, int itemWidth)
928 {
929         //create a new item
930         TableViewItem* pItem = new (std::nothrow) TableViewItem();
931         pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL);
932
933         //Message text item rectangle
934         Rectangle itemRect(X_LIST_TEXT_ITEM, 0, W_LIST_TEXT_ITEM, H_LIST_NORMAL_MENU_ITEM);
935
936         //Message
937         String itemName(L"");
938         bool isShowSendButton = true;
939         if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0)
940         {
941                 __pRejectMessageList->GetAt(itemIndex, itemName);
942         }
943         else
944         {
945                 itemName.Append(AppUtility::GetResourceString(IDS_NO_MESSAGE_STR));
946                 isShowSendButton = false;
947         }
948
949         Label* pMsgLbl = new (std::nothrow) Label();
950         pMsgLbl->Construct(itemRect, itemName);
951         pMsgLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
952         pMsgLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
953         pMsgLbl->SetTextConfig(FONT_SIZE_MSG_TXT, LABEL_TEXT_STYLE_NORMAL);
954         pMsgLbl->SetTextColor(COLOR_LIST_TEXT_NORMAL);
955         pItem->AddControl(pMsgLbl);
956
957         //Send Button
958         if(isShowSendButton == true)
959         {
960                 String sendText = AppUtility::GetResourceString(IDS_LIST_SEND_BUTTON);
961                 Button* pSendButton = new (std::nothrow) Button();
962                 pSendButton->Construct(Rectangle(GetClientAreaBounds().width - W_SEND_BUTTON_MARGIN -W_SEND_TEXT_ITEM, Y_SEND_TEXT_ITEM, W_SEND_TEXT_ITEM, H_SEND_TEXT_ITEM), sendText);
963                 //set action id and listener
964                 int actionId = IDA_SEND_REJECT_MSG1;
965                 switch(itemIndex)
966                 {
967                 case 0:
968                         actionId = IDA_SEND_REJECT_MSG1;
969                         break;
970                 case 1:
971                         actionId = IDA_SEND_REJECT_MSG2;
972                         break;
973                 case 2:
974                         actionId = IDA_SEND_REJECT_MSG3;
975                         break;
976                 case 3:
977                         actionId = IDA_SEND_REJECT_MSG4;
978                         break;
979                 case 4:
980                         actionId = IDA_SEND_REJECT_MSG5;
981                         break;
982                 case 5:
983                         actionId = IDA_SEND_REJECT_MSG6;
984                         break;
985                 }
986                 pSendButton->SetActionId(actionId);
987                 pSendButton->AddActionEventListener(*this);
988                 pItem->AddControl(*pSendButton);
989                 pItem->SetIndividualSelectionEnabled(pSendButton, true);
990         }
991         else
992         {
993                 pItem->SetEnabled(false);
994         }
995
996         return pItem;
997 }
998
999 bool
1000 IncomingCallForm::DeleteItem(int itemIndex, TableViewItem* pItem)
1001 {
1002         delete pItem;
1003         pItem = null;
1004         return true;
1005 }
1006
1007 int
1008 IncomingCallForm::GetDefaultItemHeight(void)
1009 {
1010         return H_LIST_NORMAL_MENU_ITEM;
1011 }
1012
1013 void
1014 IncomingCallForm::ShowPersonDetails(const String& phoneNumber, const String& contactLblName, const String& nameLblName, AppCallInfo* pCallInfo)
1015 {
1016         //call individual methods to show contact number, caller name & photo
1017         SetTextToLabel(phoneNumber, contactLblName);
1018
1019         //fetch contact details based on phone number
1020         String* pDisplayName = pCallInfo->FetchLatestCallerNameN(phoneNumber);
1021         Bitmap* pPhotoBitmap = pCallInfo->FetchLatestCallerPhotoN(phoneNumber);
1022         ShowCallerPhoto(pPhotoBitmap);
1023
1024         //free resources
1025         if (pDisplayName)
1026         {
1027                 SetTextToLabel(*pDisplayName, nameLblName);
1028                 delete pDisplayName;
1029                 pDisplayName = null;
1030         }
1031
1032         if (pPhotoBitmap)
1033         {
1034                 delete pPhotoBitmap;
1035                 pPhotoBitmap = null;
1036         }
1037 }
1038
1039 void
1040 IncomingCallForm::SetTextToLabel(const String& textToBeSet, const String& lblName)
1041 {
1042         Label* pContactLbl = static_cast<Label*>(GetControl(lblName));
1043         //passing an empty string to SetText fails in label,
1044         //if previously valid text has been set
1045         if (textToBeSet.IsEmpty() == true && pContactLbl->GetText().IsEmpty() == false)
1046         {
1047                 String stringToBeSet(L"");
1048                 pContactLbl->SetText(stringToBeSet);
1049         }
1050
1051         else
1052         {
1053                 pContactLbl->SetText(textToBeSet);
1054         }
1055 }
1056
1057 void
1058 IncomingCallForm::ShowCallerPhoto(const Bitmap* pPhotoId)
1059 {
1060         bool showSmallPhoto = false;
1061         //show photo - for Big Photo Id, Animated Call Image
1062         if (pPhotoId == null)
1063         {
1064                 pPhotoId = AppUtility::GetBitmapFromResourcesN(IDB_ACTIVE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO);
1065         }
1066         else
1067         {
1068                 //Check the size of photo
1069                 // Now checking the condition with && but actually it should be ||
1070                 //But for now keeping it as && because _pContact->GetThubNail() returns image width as
1071                 // height 270 and width = 480 . So all images set thru gallery is show as small image
1072                 if(pPhotoId->GetHeight() <= H_SMALL_PHOTO
1073                                 && pPhotoId->GetWidth() <= W_SMALL_PHOTO)
1074                 {
1075                         showSmallPhoto = true;
1076                 }
1077         }
1078
1079         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_BIG_PHOTO_LABEL));
1080         if(showSmallPhoto == true)
1081         {
1082                 ShowThumbnailImage(pPhotoId);
1083         }
1084         else
1085         {
1086                 if (pPhotoLbl != null && pPhotoId != null)
1087                 {
1088                         Canvas* pCanvas = new (std::nothrow) Canvas;
1089                         Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1090                         pCanvas->Construct(canvasRect);
1091                         //draw the contact bitmap
1092                         pCanvas->DrawBitmap(canvasRect,*pPhotoId);
1093                         Bitmap* pNewPhotoId = new Bitmap();
1094                         pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1095                         delete pCanvas;
1096
1097                         pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1098                         pPhotoLbl->Invalidate(true);
1099                         delete pNewPhotoId;
1100                 }
1101         }
1102 }
1103
1104 void
1105 IncomingCallForm::ShowThumbnailImage(const Bitmap* pPhotoId)
1106 {
1107         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_BIG_PHOTO_LABEL));
1108
1109         if (pPhotoLbl != null && pPhotoId != null)
1110         {
1111                 Canvas* pCanvas = new (std::nothrow) Canvas;
1112                 Bitmap* pBackground = AppUtility::GetBitmapFromResourcesN(IDB_CALL_THUMBNAIL_BACKGROUND,W_CALL_THUMBNAIL,H_CALL_THUMBNAIL);
1113                 Bitmap* pShadow = AppUtility::GetBitmapFromResourcesN(IDB_CALL_THUMBNAIL_SHADOW,W_CALL_THUMBNAIL_SHADOW,H_CALL_THUMBNAIL_SHADOW);
1114                 Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1115                 pCanvas->Construct(canvasRect);
1116                 //draw the back ground
1117                 pCanvas->DrawBitmap(canvasRect,*pBackground);
1118                 //draw shadow (to be enabled after correct shadow image is provided )
1119                 //pCanvas->DrawBitmap(Rectangle((pPhotoLbl->GetBounds().width/2)-(W_CALL_THUMBNAIL_SHADOW/2),
1120                         //      (pPhotoLbl->GetBounds().height/2)-(H_CALL_THUMBNAIL_SHADOW/2),W_CALL_THUMBNAIL_SHADOW,H_CALL_THUMBNAIL_SHADOW),*pShadow);
1121                 //draw the contact bitmap
1122                 pCanvas->DrawBitmap(Rectangle((pPhotoLbl->GetBounds().width/2)-(W_SMALL_PHOTO/2),
1123                                 (pPhotoLbl->GetBounds().height/2)-(H_SMALL_PHOTO/2),W_SMALL_PHOTO,H_SMALL_PHOTO),*pPhotoId);
1124                 Bitmap* pNewPhotoId = new Bitmap();
1125                 pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1126                 delete pCanvas;
1127
1128                 pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1129                 pPhotoLbl->Invalidate(true);
1130                 delete pNewPhotoId;
1131                 delete pBackground;
1132                 delete pShadow;
1133         }
1134
1135 }
1136
1137 void
1138 IncomingCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
1139 {
1140         //Draw Small Photo and show on small photo label
1141         __pSmallPhotoLabel  = new (std::nothrow) Label();//static_cast<Label*>(GetControl(IDC_SMALL_PHOTO_LABEL));
1142         __pSmallPhotoLabel->Construct(Rectangle(X_PHOTO_LBL, Y_PHOTO_LBL, W_PHOTO_LBL, H_PHOTO_LBL), L"");
1143         __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0));
1144         __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId);
1145         // Add a Label to the Form
1146         AddControl(*__pSmallPhotoLabel);
1147         __pSmallPhotoLabel->Invalidate(true);
1148 }
1149
1150 void
1151 IncomingCallForm::ShowTimerInfo(const String& timerLblName, const String& textToBeDisplayed)
1152 {
1153         Label* pTimerLbl = static_cast<Label*>(GetControl(timerLblName));
1154         if (pTimerLbl != null)
1155         {
1156                 pTimerLbl->SetText(textToBeDisplayed);
1157         }
1158 }
1159
1160 void
1161 IncomingCallForm::SetBitmapToRejectMessageButton(const String& btnName, const String& bgBitmap
1162                                                                                                 , const String& arrowBitmap, const String& messageIconBitmap, bool isButtonInPanel, bool setButtonPressBitmap)
1163 {
1164
1165         Button* pButton = null;
1166         if (isButtonInPanel == false)
1167         {
1168                 pButton = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
1169         }
1170         else
1171         {
1172                 Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
1173                 pButton = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
1174         }
1175         Bitmap* pHoldBmp = null;
1176         Canvas* pCanvas = null;
1177         pCanvas = new (std::nothrow) Canvas();
1178         pCanvas->Construct(Rectangle(0,0,pButton->GetBounds().width,pButton->GetBounds().height));
1179         //set bitmap to button
1180         pHoldBmp = AppUtility::GetBitmapFromResourcesN(bgBitmap);
1181         if (pHoldBmp)
1182         {
1183                 //scale bitmap to predefined size
1184                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1185                 pHoldBmp->Scale(Dimension(pButton->GetBounds().width, H_MESSAGE_BG_BITMAP));
1186                 pCanvas->DrawBitmap(Rectangle(Point(0, 0), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1187         }
1188         delete pHoldBmp;
1189         pHoldBmp = null;
1190         pHoldBmp = AppUtility::GetBitmapFromResourcesN(arrowBitmap);
1191         if (pHoldBmp)
1192         {
1193                 //scale bitmap to predefined size
1194                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1195                 pHoldBmp->Scale(Dimension(W_ARROW_BITMAP, H_ARROW_BITMAP));
1196                 pCanvas->DrawBitmap(Rectangle(Point((pButton->GetBounds().width / 2 - 17/*Width of arrow / 2*/), 0), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1197         }
1198         delete pHoldBmp;
1199         pHoldBmp = null;
1200
1201
1202
1203         //set button name
1204         String holdBtnName = AppUtility::GetResourceString(btnName);
1205         FloatDimension textDimension;
1206         if (!holdBtnName.IsEmpty())
1207         {
1208                 Font font;
1209                 font.Construct(FONT_STYLE_PLAIN, pButton->GetTextSize());
1210                 font.GetTextExtent(holdBtnName, holdBtnName.GetLength(), textDimension);
1211                 textDimension.height = textDimension.height + font.GetDescender();
1212                 TextElement* pTextElement = new (std::nothrow) TextElement();
1213                 pTextElement->Construct(holdBtnName);
1214                 Color textColor(249, 249, 249);
1215                 if (setButtonPressBitmap)
1216                 {
1217                         textColor.SetAlpha(255);
1218                 }
1219                 else
1220                 {
1221                         textColor.SetAlpha(127);
1222                 }
1223
1224                 pTextElement->SetTextColor(textColor);
1225                 pTextElement->SetFont(font);
1226
1227                 EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText();
1228                 pEnrichedText->Construct(textDimension);
1229                 pEnrichedText->Add(*pTextElement);
1230                 //Point textPos((X_MESSAGE_BITMAP + pHoldBmp->GetWidth() + MESSAGE_TEXT_X_MARGIN), Y_MESSAGE_BITMAP + MESSAGE_TEXT_Y_MARGIN);
1231                 Point textPos((pButton->GetWidth()/2)-(textDimension.width/2) + MESSAGE_TEXT_X_MARGIN,Y_MESSAGE_BITMAP + MESSAGE_TEXT_Y_MARGIN);
1232                 pCanvas->DrawText(textPos, *pEnrichedText);
1233                 // Cleans up
1234                 pEnrichedText->RemoveAll(true);
1235                 delete pEnrichedText;
1236         }
1237
1238
1239         pHoldBmp = AppUtility::GetBitmapFromResourcesN(messageIconBitmap);
1240         if (pHoldBmp)
1241         {
1242                 //scale bitmap to predefined size
1243                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1244                 pHoldBmp->Scale(Dimension(W_MESSAGE_BITMAP, H_MESSAGE_BITMAP));
1245                 //pCanvas->DrawBitmap(Rectangle(Point(X_MESSAGE_BITMAP, Y_MESSAGE_BITMAP), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1246                 pCanvas->DrawBitmap(Rectangle(Point((pButton->GetWidth()/2)-(textDimension.width/2) -pHoldBmp->GetWidth(), Y_MESSAGE_BITMAP), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1247         }
1248
1249         //set background bitmpa to button
1250         Bitmap* pActualBgBmp = new (std::nothrow) Bitmap();
1251         pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds());
1252         if (setButtonPressBitmap)
1253         {
1254                 pButton->SetPressedBackgroundBitmap(*pActualBgBmp);
1255         }
1256         else
1257         {
1258                 pButton->SetNormalBackgroundBitmap(*pActualBgBmp);
1259         }
1260         delete pActualBgBmp;
1261         delete pHoldBmp;
1262         delete pCanvas;
1263 }
1264
1265 /*!In OnTouchPressed, It creates the three visual elements and starts the animation of opacity and rotation variation
1266   */
1267 void
1268 IncomingCallForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1269 {
1270         //__pCallPresentor->StopAlert();
1271         if (currentPosition.x < VALID_TOUCH_X_OFFSET && currentPosition.y < VALID_TOUCH_Y_OFFSET)
1272         {
1273                 Rectangle rect = source.GetBounds();
1274                 if (source.Equals(*__pAcceptLabel))
1275                 {
1276                         __isAnswerCallStarted = true;
1277                         __isRejectCallStarted = false;
1278                 }
1279                 else if (source.Equals(*__pRejectLabel))
1280                 {
1281                         __isAnswerCallStarted = false;
1282                         __isRejectCallStarted = true;
1283                 }
1284                 else
1285                 {
1286                         // touch event between the 2 labels. So Do nothing
1287                         return;
1288                 }
1289
1290         }
1291 }
1292
1293 // On Touch released, the animation and the visual elements disappear
1294 void
1295 IncomingCallForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1296 {
1297         AppLogDebug("%d",currentPosition.x);
1298         if (__isAnswerCallStarted == true)
1299         {
1300                 if (currentPosition.x > __pRejectLabel->GetBounds().x)
1301                 {
1302                         //Right reject icon
1303                         if(__pRejectFinalVisElem == null)
1304                         {
1305                                 __pRejectFinalVisElem = new (std::nothrow) VisualElement();
1306                                 __pRejectFinalVisElem->Construct();
1307                                 __pRejectFinalVisElem->SetName(IDI_REJECT_FINAL_VISUAL_ELE_NAME);
1308                         }
1309                         __pRejectFinalVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1310                         __pRejectFinalVisElem->SetShowState(true);
1311                         __pRejectFinalVisElem->SetOpacity(1.00f);
1312                         if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_FINAL_VISUAL_ELE_NAME,true) == null)
1313                         {
1314                                 AppLogDebug("AttachChild __pRejectFinalVisElem");
1315                                 __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectFinalVisElem);
1316                         }
1317                         Canvas* pCanvas = __pRejectFinalVisElem->GetCanvasN();
1318                         if(pCanvas != null)
1319                         {
1320                                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
1321                                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1322                                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, W_DIAL_LABEL), *__pAcceptCircle);
1323                                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pAcceptDial);
1324                                 delete pCanvas;
1325                         }
1326
1327                         __pAcceptVisElem->SetOpacity(0.0f);
1328                         //fetch already active call list
1329                         ArrayListT<AppCallInfo>* pCallList  = static_cast<ArrayListT<AppCallInfo>*>(__pCallPresentor->GetCallListN());
1330                         if (pCallList != null && pCallList->GetCount() > 0)
1331                         {
1332                                 //then atleast 1 active call exist.
1333                                 AppCallInfo phnCallInfo;
1334                                 pCallList->GetAt(0,phnCallInfo);
1335                                 //Check if only 1 call exist and it is on Hold
1336                                 if(pCallList->GetCount() == 1 && phnCallInfo.IsOnHold())
1337                                 {
1338                                         //directly accept call
1339                                         __pCallPresentor->AcceptIncomingCall(ANSERWING_OPTION_ACCEPT_CALL,__incomingCallHandle);
1340                                 }
1341                                 else
1342                                 {
1343                                         //Either 1 call exist and not "on Hold".
1344                                         //Or 2 calls exist.
1345                                         if(__pOptionPopup != null)
1346                                         {
1347                                                 delete __pOptionPopup;
1348                                                 __pOptionPopup = null;
1349                                         }
1350                                         __pOptionPopup = new (std::nothrow) CallOptionPopup(*this,*(__pCallPresentor));
1351                                         __pOptionPopup->Initialize();
1352                                         __pOptionPopup->SetShowState(true);
1353                                         __pOptionPopup->Draw();
1354                                         __pOptionPopup->Show();
1355                                 }
1356                                 pCallList->RemoveAll();
1357                         }
1358                         else
1359                         {
1360                                 //no active call - Accept the  incoming call
1361                                 __pCallPresentor->AcceptIncomingCall(ANSERWING_OPTION_ACCEPT_CALL,__incomingCallHandle);
1362                         }
1363                         delete pCallList;
1364                         pCallList = null;
1365                 }
1366                 else
1367                 {
1368                         __pAcceptVisElem->SetOpacity(1.0f);
1369                         __pRejectVisElem->SetOpacity(1.00f);
1370
1371                 }
1372         }
1373         else if (__isRejectCallStarted == true)
1374         {
1375                 if (currentPosition.x < ((__pAcceptLabel->GetBounds().x + __pAcceptLabel->GetWidth())- __pRejectLabel->GetBounds().x))
1376                 {
1377                         //left dial icon
1378                         if(__pAcceptFinalVisElem == null)
1379                         {
1380                                 __pAcceptFinalVisElem = new (std::nothrow) VisualElement();
1381                                 __pAcceptFinalVisElem->Construct();
1382                                 __pAcceptFinalVisElem->SetName(IDI_ACCEPT_FINAL_VISUAL_ELE_NAME);
1383                         }
1384                         __pAcceptFinalVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1385                         __pAcceptFinalVisElem->SetOpacity(1.0f);
1386
1387
1388                         if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_FINAL_VISUAL_ELE_NAME,true) == null)
1389                         {
1390                                 AppLogDebug("AttachChild __pAcceptFinalVisElem");
1391                                 __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptFinalVisElem);
1392                         }
1393                         Canvas* pCanvas = __pAcceptFinalVisElem->GetCanvasN();
1394                         if(pCanvas != null)
1395                         {
1396                                 AppLogDebug("__pAcceptFinalVisElem drawing");
1397                                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
1398                                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
1399                                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1400                                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pRejectCircle);
1401                                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pRejectDial);
1402                                 delete pCanvas;
1403                         }
1404                         __pRejectVisElem->SetOpacity(0.0f);
1405                         //Reject the call
1406                         __pCallPresentor->RejectCall(__incomingCallHandle, false,*__pActiveContactNo);
1407                 }
1408                 else
1409                 {
1410                         __pAcceptVisElem->SetOpacity(1.0f);
1411                         __pRejectVisElem->SetOpacity(1.00f);
1412
1413                 }
1414         }
1415         __isAnswerCallStarted = false;
1416         __isRejectCallStarted = false;
1417 }
1418
1419 void
1420 IncomingCallForm::OnTouchMoved(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1421 {
1422         if (__isAnswerCallStarted == true)
1423         {
1424                 if (currentPosition.x > 170 && currentPosition.x < 578)
1425                 {
1426                         if (currentPosition.x > REJECT_LABEL_X_OFFSET)
1427                         {
1428                                 __pRejectVisElem->SetOpacity(0.60f);
1429                                 __pAcceptVisElem->SetOpacity(0.60f);
1430                         }
1431                         else
1432                         {
1433                                 __pRejectVisElem->SetOpacity(1.0f);
1434                                 __pAcceptVisElem->SetOpacity(1.0f);
1435                         }
1436
1437                 }
1438         }
1439         if (__isRejectCallStarted == true)
1440         {
1441                 if (currentPosition.x < 0 && currentPosition.x > -522)
1442                 {
1443                         if (currentPosition.x < ACCEPT_LABEL_RELATIVE_POS)
1444                         {
1445                                 __pRejectVisElem->SetOpacity(0.60f);
1446                                 __pAcceptVisElem->SetOpacity(0.60f);
1447                         }
1448                         else
1449                         {
1450                                 __pRejectVisElem->SetOpacity(1.0f);
1451                                 __pAcceptVisElem->SetOpacity(1.0f);
1452                         }
1453                 }
1454         }
1455 }
1456
1457 void
1458 IncomingCallForm::OnItemSelected(int itemIndex)
1459 {
1460         ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1461         pArgs->Construct();
1462
1463         //display name, mobile number
1464         Integer* argIndex = new (std::nothrow) Integer(itemIndex);
1465         pArgs->Add(argIndex);
1466         SendUserEvent(REQUEST_ITEM_SELECTED,pArgs);
1467 }
1468
1469 void
1470 IncomingCallForm::HandleMultipleCallSelection(int itemIndex)
1471 {
1472         if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_VISUAL_ELE_NAME,true) == null)
1473         {
1474                 __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem);
1475         }
1476         if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_VISUAL_ELE_NAME,true) == null)
1477         {
1478                 __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem);
1479         }
1480
1481         __pAcceptVisElem->SetOpacity(1.0f);
1482         __pRejectVisElem->SetOpacity(1.00f);
1483
1484         if (__pRejectFinalVisElem != null)
1485         {
1486                 __pRejectFinalVisElem->Destroy();
1487                 __pRejectFinalVisElem = null;
1488         }
1489         if (__pAcceptFinalVisElem != null)
1490         {
1491                 __pAcceptFinalVisElem->Destroy();
1492                 __pAcceptFinalVisElem = null;
1493         }
1494
1495         if (__pOptionPopup)
1496         {
1497                 delete __pOptionPopup;
1498                 __pOptionPopup = null;
1499         }
1500         //accept call
1501         if(itemIndex != IDA_BUTTON_CANCEL_OPTIONS_POPUP)
1502         {
1503                 __pCallPresentor->AcceptIncomingCall(CallAnsweringOptions(itemIndex),__incomingCallHandle);
1504         }
1505 }
1506
1507 void
1508 IncomingCallForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1509 {
1510         switch(requestId)
1511         {
1512                 case REQUEST_ITEM_SELECTED:
1513                 {
1514                         if(pArgs != null)
1515                         {
1516                                 Integer *index = static_cast<Integer*>(pArgs->GetAt(0));
1517                                 if(index != null)
1518                                 {
1519                                         HandleMultipleCallSelection(index->ToInt());
1520                                 }
1521                         }
1522                 }
1523                 break;
1524         }
1525 }
1526
1527 void
1528 IncomingCallForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1529 {
1530         AppLogDebug("Enter");
1531         HideRejectPanel();
1532         SetFocus();
1533         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
1534         if (pButtonRejectMessage)
1535         {
1536                 pButtonRejectMessage->SetShowState(true);
1537                 pButtonRejectMessage->Invalidate(true);
1538                 pButtonRejectMessage->Draw();
1539         }
1540         RequestRedraw(true);
1541
1542 }
1543
1544 void
1545 IncomingCallForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1546 {
1547         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
1548         if(pKeysPanel->GetShowState() == true)
1549         {
1550                 HideRejectMessagePanel();
1551                 ShowRejectMessagePanel();
1552         }
1553
1554         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
1555         if (pButtonRejectMessage != null)
1556         {
1557                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
1558                                                                            IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, false);
1559                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
1560                                                                            IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, true);
1561                 pButtonRejectMessage->Invalidate(true);
1562         }
1563
1564         Button* pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
1565         if (pButtonReject != null)
1566         {
1567                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
1568                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, false);
1569                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
1570                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, true);
1571                 pButtonReject->Invalidate(true);
1572         }
1573 }
1574
1575 void
1576 IncomingCallForm::OnForeground(void)
1577 {
1578         AppLogDebug("Enter");
1579 //      __pCallPresentor->OnAppForeground();
1580 }
1581
1582 void
1583 IncomingCallForm::OnScreenOff(void)
1584 {
1585         __pCallPresentor->StopAlert();
1586 }
1587
1588 void
1589 IncomingCallForm::CallDisconnected(void)
1590 {
1591         //check if no call option popup is shown, then remain on incoming call screen.
1592         //As user has neither accepted nor rejected incoming call.
1593         if (__pOptionPopup == null)
1594         {
1595                 return;
1596         }
1597
1598         //fetch already active call list and show updated option popup
1599         ArrayListT<AppCallInfo>* pCallList  = static_cast<ArrayListT<AppCallInfo>*>(__pCallPresentor->GetCallListN());
1600         if (pCallList != null && pCallList->GetCount() > 0)
1601         {
1602                 //then atleast 1 active call exist.
1603                 AppCallInfo phnCallInfo;
1604                 pCallList->GetAt(0,phnCallInfo);
1605                 //Check if only 1 call exist and it is on Hold
1606                 if(pCallList->GetCount() == 1 && phnCallInfo.IsOnHold())
1607                 {
1608                         //directly accept call
1609                         __pCallPresentor->AcceptIncomingCall(ANSERWING_OPTION_ACCEPT_CALL,__incomingCallHandle);
1610                 }
1611                 else
1612                 {
1613                         //Either 1 call exist and not "on Hold".
1614                         //Or 2 calls exist.
1615                         if(__pOptionPopup != null)
1616                         {
1617                                 delete __pOptionPopup;
1618                                 __pOptionPopup = null;
1619                         }
1620                         __pOptionPopup = new (std::nothrow) CallOptionPopup(*this,*(__pCallPresentor));
1621                         __pOptionPopup->Initialize();
1622                         __pOptionPopup->SetShowState(true);
1623                         __pOptionPopup->Draw();
1624                         __pOptionPopup->Show();
1625                 }
1626                 pCallList->RemoveAll();
1627         }
1628         else
1629         {
1630                 //no active call - Accept the  incoming call
1631                 __pCallPresentor->AcceptIncomingCall(ANSERWING_OPTION_ACCEPT_CALL,__incomingCallHandle);
1632         }
1633         delete pCallList;
1634         pCallList = null;
1635 }