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