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