fix for 38107
[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         //This called here to handle the case when incoming call comes when
844         // add call is in foreground.
845         __pCallPresentor->OnAppForeground();
846
847 }
848
849 void
850 IncomingCallForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
851 {
852         RemoveOrientationEventListener(*this);
853         if (__pSmallPhotoLabel != null)
854         {
855                 RemoveControl(*__pSmallPhotoLabel);
856                 __pSmallPhotoLabel = null;
857         }
858         for (int i = 0; i < COUNT_ARROW_ELEMENTS; i++)
859         {
860                 __pRejectArrowLabel = static_cast<Label*>(__pRejectArrowLabelsList->GetAt(i));
861                 String RejectVisualEleName(IDI_REJECT_ARROW_VISUAL_ELE_NAME);
862                 RejectVisualEleName.Append(i);
863                 __pRejectArrowVisElem = __pRejectArrowLabel->GetVisualElement()->GetChild(RejectVisualEleName,true);
864                 __pRejectArrowVisElem->SetOpacity(0.0f);
865                 __pAcceptArrowLabel = static_cast<Label*>(__pAcceptArrowLabelsList->GetAt(i));
866                 String AcceptVisualEleName(IDI_ACCEPT_ARROW_VISUAL_ELE_NAME);
867                 AcceptVisualEleName.Append(i);
868                 __pAcceptArrowVisElem = __pAcceptArrowLabel->GetVisualElement()->GetChild(AcceptVisualEleName,true);
869                 __pAcceptArrowVisElem->SetOpacity(0.0f);
870         }
871         if(__pAcceptLabel != null)
872         {
873                 if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_FINAL_VISUAL_ELE_NAME,true) != null)
874                 {
875                         AppLogDebug("__pAcceptLabel Detatach child");
876                         __pAcceptLabel->GetVisualElement()->DetachChild(*__pAcceptFinalVisElem);
877                 }
878         }
879         if(__pRejectLabel != null)
880         {
881                 if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_FINAL_VISUAL_ELE_NAME,true) != null)
882                 {
883                         AppLogDebug("__pRejectLabel Detatach child");
884                         __pRejectLabel->GetVisualElement()->DetachChild(*__pRejectFinalVisElem);
885                 }
886
887         }
888         CallApp* pCallApp = static_cast<CallApp*>(CallApp::GetInstance());
889         pCallApp->RemoveAppStateChangeListener(*this);
890 }
891
892 result
893 IncomingCallForm::OnDraw(void)
894 {
895         Bitmap* pBackgroundWp = null;
896         // get a Canvas instance
897         Canvas* pCanvas = GetCanvasN();
898
899         pBackgroundWp = AppResource::GetInstance()->GetBitmapN(IDB_CALL_BG);
900
901         if (pCanvas)
902         {
903
904                 if (pBackgroundWp)
905                 {
906                         pCanvas->DrawBitmap(pCanvas->GetBounds(), *pBackgroundWp);
907                 }
908         }
909
910         delete pBackgroundWp;
911         pBackgroundWp = null;
912
913         delete pCanvas;
914         pCanvas = null;
915
916         return E_SUCCESS;
917 }
918
919 void
920 IncomingCallForm::HideRejectPanel(void)
921 {
922         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
923         if (pKeysPanel)
924         {
925                 pKeysPanel->SetShowState(false);
926                 Button* pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
927                 pButtonReject->SetActionId(IDA_CANCEL_REJECT_CALL_MESSAGE_PANEL);
928                 pButtonReject->AddActionEventListener(*this);
929                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
930                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, false);
931                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
932                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, true);
933
934                 HideRejectMessageFooter();
935                 pKeysPanel->Invalidate(true);
936         }
937 }
938
939 void
940 IncomingCallForm::InitializeTableView(void)
941 {
942         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
943
944         TableView* pMessageList = static_cast<TableView*>(pKeysPanel->GetControl(IDC_MSG_TABLEVIEW));
945         pMessageList->SetItemProvider(this);
946         pMessageList->AddTableViewItemEventListener(*this);
947 }
948
949 ///////////////////////////////////////////////////////////////////////////////
950 /////                   Table View Functionality supporting functions                    /////
951 //////////////////////////////////////////////////////////////////////////////
952 int
953 IncomingCallForm::GetItemCount(void)
954 {
955         if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0)
956         {
957                 return (__pRejectMessageList->GetCount());
958         }
959         return 1;
960 }
961
962 TableViewItem*
963 IncomingCallForm::CreateItem(int itemIndex, int itemWidth)
964 {
965         //create a new item
966         TableViewItem* pItem = new (std::nothrow) TableViewItem();
967         pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL);
968
969         //Message text item rectangle
970         Rectangle itemRect(X_LIST_TEXT_ITEM, 0, W_LIST_TEXT_ITEM, H_LIST_NORMAL_MENU_ITEM);
971
972         //Message
973         String itemName(L"");
974         bool isShowSendButton = true;
975         if(__pRejectMessageList != null && __pRejectMessageList->GetCount() > 0)
976         {
977                 __pRejectMessageList->GetAt(itemIndex, itemName);
978         }
979         else
980         {
981                 itemName.Append(AppUtility::GetResourceString(IDS_NO_MESSAGE_STR));
982                 isShowSendButton = false;
983         }
984
985         Label* pMsgLbl = new (std::nothrow) Label();
986         pMsgLbl->Construct(itemRect, itemName);
987         pMsgLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
988         pMsgLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
989         pMsgLbl->SetTextConfig(FONT_SIZE_MSG_TXT, LABEL_TEXT_STYLE_NORMAL);
990         pMsgLbl->SetTextColor(COLOR_LIST_TEXT_NORMAL);
991         pItem->AddControl(*pMsgLbl);
992
993         //Send Button
994         if(isShowSendButton == true)
995         {
996                 String sendText = AppUtility::GetResourceString(IDS_LIST_SEND_BUTTON);
997                 Button* pSendButton = new (std::nothrow) Button();
998                 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);
999                 //set action id and listener
1000                 int actionId = IDA_SEND_REJECT_MSG1;
1001                 switch(itemIndex)
1002                 {
1003                 case 0:
1004                         actionId = IDA_SEND_REJECT_MSG1;
1005                         break;
1006                 case 1:
1007                         actionId = IDA_SEND_REJECT_MSG2;
1008                         break;
1009                 case 2:
1010                         actionId = IDA_SEND_REJECT_MSG3;
1011                         break;
1012                 case 3:
1013                         actionId = IDA_SEND_REJECT_MSG4;
1014                         break;
1015                 case 4:
1016                         actionId = IDA_SEND_REJECT_MSG5;
1017                         break;
1018                 case 5:
1019                         actionId = IDA_SEND_REJECT_MSG6;
1020                         break;
1021                 }
1022                 pSendButton->SetActionId(actionId);
1023                 pSendButton->AddActionEventListener(*this);
1024                 pItem->AddControl(*pSendButton);
1025                 pItem->SetIndividualSelectionEnabled(pSendButton, true);
1026         }
1027         else
1028         {
1029                 pItem->SetEnabled(false);
1030         }
1031
1032         return pItem;
1033 }
1034
1035 bool
1036 IncomingCallForm::DeleteItem(int itemIndex, TableViewItem* pItem)
1037 {
1038         delete pItem;
1039         pItem = null;
1040         return true;
1041 }
1042
1043 int
1044 IncomingCallForm::GetDefaultItemHeight(void)
1045 {
1046         return H_LIST_NORMAL_MENU_ITEM;
1047 }
1048
1049 void
1050 IncomingCallForm::ShowPersonDetails(const String& phoneNumber, const String& contactLblName, const String& nameLblName, AppCallInfo* pCallInfo)
1051 {
1052         //call individual methods to show contact number, caller name & photo
1053         SetTextToLabel(phoneNumber, contactLblName);
1054
1055         //fetch contact details based on phone number
1056         String* pDisplayName = pCallInfo->FetchCallerNameN();
1057         Bitmap* pPhotoBitmap = pCallInfo->FetchCallerPhotoN();
1058         ShowCallerPhoto(pPhotoBitmap);
1059
1060         //free resources
1061         if (pDisplayName)
1062         {
1063                 SetTextToLabel(*pDisplayName, nameLblName);
1064                 delete pDisplayName;
1065                 pDisplayName = null;
1066         }
1067
1068         if (pPhotoBitmap)
1069         {
1070                 delete pPhotoBitmap;
1071                 pPhotoBitmap = null;
1072         }
1073 }
1074
1075 void
1076 IncomingCallForm::SetTextToLabel(const String& textToBeSet, const String& lblName)
1077 {
1078         Label* pContactLbl = static_cast<Label*>(GetControl(lblName));
1079         //passing an empty string to SetText fails in label,
1080         //if previously valid text has been set
1081         if (textToBeSet.IsEmpty() == true && pContactLbl->GetText().IsEmpty() == false)
1082         {
1083                 String stringToBeSet(L"");
1084                 pContactLbl->SetText(stringToBeSet);
1085         }
1086
1087         else
1088         {
1089                 pContactLbl->SetText(textToBeSet);
1090         }
1091 }
1092
1093 void
1094 IncomingCallForm::ShowCallerPhoto(const Bitmap* pPhotoId)
1095 {
1096         bool showSmallPhoto = false;
1097         //show photo - for Big Photo Id, Animated Call Image
1098         if (pPhotoId == null)
1099         {
1100                 pPhotoId = AppUtility::GetBitmapFromResourcesN(IDB_ACTIVE_CALL_DEFAULT_ICON,W_CONFERENCE_PHOTO,W_CONFERENCE_PHOTO);
1101         }
1102         else
1103         {
1104                 //Check the size of photo
1105                 // Now checking the condition with && but actually it should be ||
1106                 //But for now keeping it as && because _pContact->GetThubNail() returns image width as
1107                 // height 270 and width = 480 . So all images set thru gallery is show as small image
1108                 if(pPhotoId->GetHeight() <= H_SMALL_PHOTO
1109                                 && pPhotoId->GetWidth() <= W_SMALL_PHOTO)
1110                 {
1111                         showSmallPhoto = true;
1112                 }
1113         }
1114
1115         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_BIG_PHOTO_LABEL));
1116         if(showSmallPhoto == true)
1117         {
1118                 ShowThumbnailImage(pPhotoId);
1119         }
1120         else
1121         {
1122                 if (pPhotoLbl != null && pPhotoId != null)
1123                 {
1124                         Canvas* pCanvas = new (std::nothrow) Canvas;
1125                         Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1126                         pCanvas->Construct(canvasRect);
1127                         //draw the contact bitmap
1128                         pCanvas->DrawBitmap(canvasRect,*pPhotoId);
1129                         Bitmap* pNewPhotoId = new Bitmap();
1130                         pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1131                         delete pCanvas;
1132
1133                         pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1134                         pPhotoLbl->Invalidate(true);
1135                         delete pNewPhotoId;
1136                 }
1137         }
1138 }
1139
1140 void
1141 IncomingCallForm::ShowThumbnailImage(const Bitmap* pPhotoId)
1142 {
1143         Label* pPhotoLbl = static_cast<Label*>(GetControl(IDC_BIG_PHOTO_LABEL));
1144
1145         if (pPhotoLbl != null && pPhotoId != null)
1146         {
1147                 Canvas* pCanvas = new (std::nothrow) Canvas;
1148                 Bitmap* pBackground = AppUtility::GetBitmapFromResourcesN(IDB_CALL_THUMBNAIL_BACKGROUND,W_CALL_THUMBNAIL,H_CALL_THUMBNAIL);
1149                 Bitmap* pShadow = AppUtility::GetBitmapFromResourcesN(IDB_CALL_THUMBNAIL_SHADOW,W_CALL_THUMBNAIL_SHADOW,H_CALL_THUMBNAIL_SHADOW);
1150                 Rectangle canvasRect(Rectangle(0, 0, pPhotoLbl->GetBounds().width, pPhotoLbl->GetBounds().height));
1151                 pCanvas->Construct(canvasRect);
1152                 //draw the back ground
1153                 pCanvas->DrawBitmap(canvasRect,*pBackground);
1154                 //draw shadow (to be enabled after correct shadow image is provided )
1155                 //pCanvas->DrawBitmap(Rectangle((pPhotoLbl->GetBounds().width/2)-(W_CALL_THUMBNAIL_SHADOW/2),
1156                         //      (pPhotoLbl->GetBounds().height/2)-(H_CALL_THUMBNAIL_SHADOW/2),W_CALL_THUMBNAIL_SHADOW,H_CALL_THUMBNAIL_SHADOW),*pShadow);
1157                 //draw the contact bitmap
1158                 pCanvas->DrawBitmap(Rectangle((pPhotoLbl->GetBounds().width/2)-(W_SMALL_PHOTO/2),
1159                                 (pPhotoLbl->GetBounds().height/2)-(H_SMALL_PHOTO/2),W_SMALL_PHOTO,H_SMALL_PHOTO),*pPhotoId);
1160                 Bitmap* pNewPhotoId = new Bitmap();
1161                 pNewPhotoId->Construct(*pCanvas, pCanvas->GetBounds());
1162                 delete pCanvas;
1163
1164                 pPhotoLbl->SetBackgroundBitmap(*pNewPhotoId);
1165                 pPhotoLbl->Invalidate(true);
1166                 delete pNewPhotoId;
1167                 delete pBackground;
1168                 delete pShadow;
1169         }
1170
1171 }
1172
1173 void
1174 IncomingCallForm::ShowCallersPhotoThumbnail(const Bitmap& pPhotoId)
1175 {
1176         //Draw Small Photo and show on small photo label
1177         __pSmallPhotoLabel  = new (std::nothrow) Label();//static_cast<Label*>(GetControl(IDC_SMALL_PHOTO_LABEL));
1178         __pSmallPhotoLabel->Construct(Rectangle(X_PHOTO_LBL, Y_PHOTO_LBL, W_PHOTO_LBL, H_PHOTO_LBL), L"");
1179         __pSmallPhotoLabel->SetBackgroundColor(Color(0,0,0));
1180         __pSmallPhotoLabel->SetBackgroundBitmap(pPhotoId);
1181         // Add a Label to the Form
1182         AddControl(*__pSmallPhotoLabel);
1183         __pSmallPhotoLabel->Invalidate(true);
1184 }
1185
1186 void
1187 IncomingCallForm::ShowTimerInfo(const String& timerLblName, const String& textToBeDisplayed)
1188 {
1189         Label* pTimerLbl = static_cast<Label*>(GetControl(timerLblName));
1190         if (pTimerLbl != null)
1191         {
1192                 pTimerLbl->SetText(textToBeDisplayed);
1193         }
1194 }
1195
1196 void
1197 IncomingCallForm::SetBitmapToRejectMessageButton(const String& btnName, const String& bgBitmap
1198                                                                                                 , const String& arrowBitmap, const String& messageIconBitmap, bool isButtonInPanel, bool setButtonPressBitmap)
1199 {
1200
1201         Button* pButton = null;
1202         if (isButtonInPanel == false)
1203         {
1204                 pButton = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
1205         }
1206         else
1207         {
1208                 Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
1209                 pButton = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
1210         }
1211         Bitmap* pHoldBmp = null;
1212         Canvas* pCanvas = null;
1213         pCanvas = new (std::nothrow) Canvas();
1214         pCanvas->Construct(Rectangle(0,0,pButton->GetBounds().width,pButton->GetBounds().height));
1215         //set bitmap to button
1216         pHoldBmp = AppUtility::GetBitmapFromResourcesN(bgBitmap);
1217         if (pHoldBmp)
1218         {
1219                 //scale bitmap to predefined size
1220                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1221                 pHoldBmp->Scale(Dimension(pButton->GetBounds().width, H_MESSAGE_BG_BITMAP));
1222                 pCanvas->DrawBitmap(Rectangle(Point(0, 0), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1223         }
1224         delete pHoldBmp;
1225         pHoldBmp = null;
1226         pHoldBmp = AppUtility::GetBitmapFromResourcesN(arrowBitmap);
1227         if (pHoldBmp)
1228         {
1229                 //scale bitmap to predefined size
1230                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1231                 pHoldBmp->Scale(Dimension(W_ARROW_BITMAP, H_ARROW_BITMAP));
1232                 pCanvas->DrawBitmap(Rectangle(Point((pButton->GetBounds().width / 2 - 17/*Width of arrow / 2*/), 0), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1233         }
1234         delete pHoldBmp;
1235         pHoldBmp = null;
1236
1237
1238
1239         //set button name
1240         String holdBtnName = AppUtility::GetResourceString(btnName);
1241         FloatDimension textDimension;
1242         if (!holdBtnName.IsEmpty())
1243         {
1244                 Font font;
1245                 font.Construct(FONT_STYLE_PLAIN, pButton->GetTextSize());
1246                 font.GetTextExtent(holdBtnName, holdBtnName.GetLength(), textDimension);
1247                 textDimension.height = textDimension.height + font.GetDescender();
1248                 TextElement* pTextElement = new (std::nothrow) TextElement();
1249                 pTextElement->Construct(holdBtnName);
1250                 Color textColor(249, 249, 249);
1251                 if (setButtonPressBitmap)
1252                 {
1253                         textColor.SetAlpha(255);
1254                 }
1255                 else
1256                 {
1257                         textColor.SetAlpha(127);
1258                 }
1259
1260                 pTextElement->SetTextColor(textColor);
1261                 pTextElement->SetFont(font);
1262
1263                 EnrichedText* pEnrichedText = new (std::nothrow) EnrichedText();
1264                 pEnrichedText->Construct(textDimension);
1265                 pEnrichedText->Add(*pTextElement);
1266                 //Point textPos((X_MESSAGE_BITMAP + pHoldBmp->GetWidth() + MESSAGE_TEXT_X_MARGIN), Y_MESSAGE_BITMAP + MESSAGE_TEXT_Y_MARGIN);
1267                 Point textPos((pButton->GetWidth()/2)-(textDimension.width/2) + MESSAGE_TEXT_X_MARGIN,Y_MESSAGE_BITMAP + MESSAGE_TEXT_Y_MARGIN);
1268                 pCanvas->DrawText(textPos, *pEnrichedText);
1269                 // Cleans up
1270                 pEnrichedText->RemoveAll(true);
1271                 delete pEnrichedText;
1272         }
1273
1274
1275         pHoldBmp = AppUtility::GetBitmapFromResourcesN(messageIconBitmap);
1276         if (pHoldBmp)
1277         {
1278                 //scale bitmap to predefined size
1279                 pHoldBmp->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
1280                 pHoldBmp->Scale(Dimension(W_MESSAGE_BITMAP, H_MESSAGE_BITMAP));
1281                 //pCanvas->DrawBitmap(Rectangle(Point(X_MESSAGE_BITMAP, Y_MESSAGE_BITMAP), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1282                 pCanvas->DrawBitmap(Rectangle(Point((pButton->GetWidth()/2)-(textDimension.width/2) -pHoldBmp->GetWidth(), Y_MESSAGE_BITMAP), Dimension(pHoldBmp->GetWidth(), pHoldBmp->GetHeight())), *pHoldBmp);
1283         }
1284
1285         //set background bitmpa to button
1286         Bitmap* pActualBgBmp = new (std::nothrow) Bitmap();
1287         pActualBgBmp->Construct(*pCanvas, pCanvas->GetBounds());
1288         if (setButtonPressBitmap)
1289         {
1290                 pButton->SetPressedBackgroundBitmap(*pActualBgBmp);
1291         }
1292         else
1293         {
1294                 pButton->SetNormalBackgroundBitmap(*pActualBgBmp);
1295         }
1296         delete pActualBgBmp;
1297         delete pHoldBmp;
1298         delete pCanvas;
1299 }
1300
1301 /*!In OnTouchPressed, It creates the three visual elements and starts the animation of opacity and rotation variation
1302   */
1303 void
1304 IncomingCallForm::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1305 {
1306         //__pCallPresentor->StopAlert();
1307         if (currentPosition.x < VALID_TOUCH_X_OFFSET && currentPosition.y < VALID_TOUCH_Y_OFFSET)
1308         {
1309                 Rectangle rect = source.GetBounds();
1310                 if (source.Equals(*__pAcceptLabel))
1311                 {
1312                         __isAnswerCallStarted = true;
1313                         __isRejectCallStarted = false;
1314                 }
1315                 else if (source.Equals(*__pRejectLabel))
1316                 {
1317                         __isAnswerCallStarted = false;
1318                         __isRejectCallStarted = true;
1319                 }
1320                 else
1321                 {
1322                         // touch event between the 2 labels. So Do nothing
1323                         return;
1324                 }
1325
1326         }
1327 }
1328
1329 // On Touch released, the animation and the visual elements disappear
1330 void
1331 IncomingCallForm::OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1332 {
1333         AppLogDebug("%d",currentPosition.x);
1334         if (__isAnswerCallStarted == true)
1335         {
1336                 if (currentPosition.x > __pRejectLabel->GetBounds().x)
1337                 {
1338                         //Right reject icon
1339                         if(__pRejectFinalVisElem == null)
1340                         {
1341                                 __pRejectFinalVisElem = new (std::nothrow) VisualElement();
1342                                 __pRejectFinalVisElem->Construct();
1343                                 __pRejectFinalVisElem->SetName(IDI_REJECT_FINAL_VISUAL_ELE_NAME);
1344                         }
1345                         __pRejectFinalVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1346                         __pRejectFinalVisElem->SetShowState(true);
1347                         __pRejectFinalVisElem->SetOpacity(1.00f);
1348                         if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_FINAL_VISUAL_ELE_NAME,true) == null)
1349                         {
1350                                 AppLogDebug("AttachChild __pRejectFinalVisElem");
1351                                 __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectFinalVisElem);
1352                         }
1353                         Canvas* pCanvas = __pRejectFinalVisElem->GetCanvasN();
1354                         if(pCanvas != null)
1355                         {
1356                                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
1357                                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1358                                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, W_DIAL_LABEL), *__pAcceptCircle);
1359                                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pAcceptDial);
1360                                 delete pCanvas;
1361                         }
1362
1363                         __pAcceptVisElem->SetOpacity(0.0f);
1364                         //fetch already active call list
1365                         ArrayListT<AppCallInfo>* pCallList  = static_cast<ArrayListT<AppCallInfo>*>(__pCallPresentor->GetCallListN());
1366                         if (pCallList != null && pCallList->GetCount() > 0)
1367                         {
1368                                 //then atleast 1 active call exist.
1369                                 AppCallInfo phnCallInfo;
1370                                 pCallList->GetAt(0,phnCallInfo);
1371                                 //Check if only 1 call exist and it is on Hold
1372                                 if(pCallList->GetCount() == 1 && phnCallInfo.IsOnHold())
1373                                 {
1374                                         //directly accept call
1375                                         __pCallPresentor->AcceptIncomingCall(ANSERWING_OPTION_ACCEPT_CALL,__incomingCallHandle);
1376                                 }
1377                                 else
1378                                 {
1379                                         //Either 1 call exist and not "on Hold".
1380                                         //Or 2 calls exist.
1381                                         if(__pOptionPopup != null)
1382                                         {
1383                                                 delete __pOptionPopup;
1384                                                 __pOptionPopup = null;
1385                                         }
1386                                         __pOptionPopup = new (std::nothrow) CallOptionPopup(*this,*(__pCallPresentor));
1387                                         __pOptionPopup->Initialize();
1388                                         __pOptionPopup->SetShowState(true);
1389                                         __pOptionPopup->Draw();
1390                                         __pOptionPopup->Show();
1391                                 }
1392                                 pCallList->RemoveAll();
1393                         }
1394                         else
1395                         {
1396                                 //no active call - Accept the  incoming call
1397                                 __pCallPresentor->AcceptIncomingCall(ANSERWING_OPTION_ACCEPT_CALL,__incomingCallHandle);
1398                         }
1399                         delete pCallList;
1400                         pCallList = null;
1401                 }
1402                 else
1403                 {
1404                         __pAcceptVisElem->SetOpacity(1.0f);
1405                         __pRejectVisElem->SetOpacity(1.00f);
1406
1407                 }
1408         }
1409         else if (__isRejectCallStarted == true)
1410         {
1411                 if (currentPosition.x < ((__pAcceptLabel->GetBounds().x + __pAcceptLabel->GetWidth())- __pRejectLabel->GetBounds().x))
1412                 {
1413                         //left dial icon
1414                         if(__pAcceptFinalVisElem == null)
1415                         {
1416                                 __pAcceptFinalVisElem = new (std::nothrow) VisualElement();
1417                                 __pAcceptFinalVisElem->Construct();
1418                                 __pAcceptFinalVisElem->SetName(IDI_ACCEPT_FINAL_VISUAL_ELE_NAME);
1419                         }
1420                         __pAcceptFinalVisElem->SetBounds(FloatRectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1421                         __pAcceptFinalVisElem->SetOpacity(1.0f);
1422
1423
1424                         if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_FINAL_VISUAL_ELE_NAME,true) == null)
1425                         {
1426                                 AppLogDebug("AttachChild __pAcceptFinalVisElem");
1427                                 __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptFinalVisElem);
1428                         }
1429                         Canvas* pCanvas = __pAcceptFinalVisElem->GetCanvasN();
1430                         if(pCanvas != null)
1431                         {
1432                                 AppLogDebug("__pAcceptFinalVisElem drawing");
1433                                 pCanvas->SetBackgroundColor(COLOR_SWIPE_PANEL);
1434                                 pCanvas->SetForegroundColor(COLOR_SWIPE_PANEL);
1435                                 pCanvas->FillRectangle(COLOR_SWIPE_PANEL, Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL));
1436                                 pCanvas->DrawBitmap(Rectangle(0, 0, W_DIAL_LABEL, H_DIAL_LABEL), *__pRejectCircle);
1437                                 pCanvas->DrawBitmap(Rectangle(DIAL_ICON_X_OFFSET, DIAL_ICON_Y_OFFSET, W_DIAL_BITMAP, H_DIAL_BITMAP), *__pRejectDial);
1438                                 delete pCanvas;
1439                         }
1440                         __pRejectVisElem->SetOpacity(0.0f);
1441                         //Reject the call
1442                         __pCallPresentor->RejectCall(__incomingCallHandle, false,*__pActiveContactNo);
1443                 }
1444                 else
1445                 {
1446                         __pAcceptVisElem->SetOpacity(1.0f);
1447                         __pRejectVisElem->SetOpacity(1.00f);
1448
1449                 }
1450         }
1451         __isAnswerCallStarted = false;
1452         __isRejectCallStarted = false;
1453 }
1454
1455 void
1456 IncomingCallForm::OnTouchMoved(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
1457 {
1458         if (__isAnswerCallStarted == true)
1459         {
1460                 if (currentPosition.x > 170 && currentPosition.x < 578)
1461                 {
1462                         if (currentPosition.x > REJECT_LABEL_X_OFFSET)
1463                         {
1464                                 __pRejectVisElem->SetOpacity(0.60f);
1465                                 __pAcceptVisElem->SetOpacity(0.60f);
1466                         }
1467                         else
1468                         {
1469                                 __pRejectVisElem->SetOpacity(1.0f);
1470                                 __pAcceptVisElem->SetOpacity(1.0f);
1471                         }
1472
1473                 }
1474         }
1475         if (__isRejectCallStarted == true)
1476         {
1477                 if (currentPosition.x < 0 && currentPosition.x > -522)
1478                 {
1479                         if (currentPosition.x < ACCEPT_LABEL_RELATIVE_POS)
1480                         {
1481                                 __pRejectVisElem->SetOpacity(0.60f);
1482                                 __pAcceptVisElem->SetOpacity(0.60f);
1483                         }
1484                         else
1485                         {
1486                                 __pRejectVisElem->SetOpacity(1.0f);
1487                                 __pAcceptVisElem->SetOpacity(1.0f);
1488                         }
1489                 }
1490         }
1491 }
1492
1493 void
1494 IncomingCallForm::OnItemSelected(int itemIndex)
1495 {
1496         ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
1497         pArgs->Construct();
1498
1499         //display name, mobile number
1500         Integer* argIndex = new (std::nothrow) Integer(itemIndex);
1501         pArgs->Add(argIndex);
1502         SendUserEvent(REQUEST_ITEM_SELECTED,pArgs);
1503 }
1504
1505 void
1506 IncomingCallForm::HandleMultipleCallSelection(int itemIndex)
1507 {
1508         if(__pAcceptLabel->GetVisualElement()->GetChild(IDI_ACCEPT_VISUAL_ELE_NAME,true) == null)
1509         {
1510                 __pAcceptLabel->GetVisualElement()->AttachChild(*__pAcceptVisElem);
1511         }
1512         if(__pRejectLabel->GetVisualElement()->GetChild(IDI_REJECT_VISUAL_ELE_NAME,true) == null)
1513         {
1514                 __pRejectLabel->GetVisualElement()->AttachChild(*__pRejectVisElem);
1515         }
1516
1517         __pAcceptVisElem->SetOpacity(1.0f);
1518         __pRejectVisElem->SetOpacity(1.00f);
1519
1520         if (__pRejectFinalVisElem != null)
1521         {
1522                 __pRejectFinalVisElem->Destroy();
1523                 __pRejectFinalVisElem = null;
1524         }
1525         if (__pAcceptFinalVisElem != null)
1526         {
1527                 __pAcceptFinalVisElem->Destroy();
1528                 __pAcceptFinalVisElem = null;
1529         }
1530
1531         if (__pOptionPopup)
1532         {
1533                 delete __pOptionPopup;
1534                 __pOptionPopup = null;
1535         }
1536         //accept call
1537         if(itemIndex != IDA_BUTTON_CANCEL_OPTIONS_POPUP)
1538         {
1539                 __pCallPresentor->AcceptIncomingCall(CallAnsweringOptions(itemIndex),__incomingCallHandle);
1540         }
1541 }
1542
1543 void
1544 IncomingCallForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1545 {
1546         switch(requestId)
1547         {
1548                 case REQUEST_ITEM_SELECTED:
1549                 {
1550                         if(pArgs != null)
1551                         {
1552                                 Integer *index = static_cast<Integer*>(pArgs->GetAt(0));
1553                                 if(index != null)
1554                                 {
1555                                         HandleMultipleCallSelection(index->ToInt());
1556                                 }
1557                         }
1558                 }
1559                 break;
1560         }
1561 }
1562
1563 void
1564 IncomingCallForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1565 {
1566         AppLogDebug("Enter");
1567         HideRejectPanel();
1568         SetFocus();
1569         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
1570         if (pButtonRejectMessage)
1571         {
1572                 pButtonRejectMessage->SetShowState(true);
1573                 pButtonRejectMessage->Invalidate(true);
1574                 pButtonRejectMessage->Draw();
1575         }
1576         RequestRedraw(true);
1577
1578 }
1579
1580 void
1581 IncomingCallForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1582 {
1583         Panel* pKeysPanel = static_cast<Panel*>(GetControl(IDC_REJECT_PANEL));
1584         if(pKeysPanel->GetShowState() == true)
1585         {
1586                 HideRejectMessagePanel();
1587                 ShowRejectMessagePanel();
1588         }
1589
1590         Button* pButtonRejectMessage = static_cast<Button*>(GetControl(IDC_REJECT_MESSAGE_BUTTON));
1591         if (pButtonRejectMessage != null)
1592         {
1593                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
1594                                                                            IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, false);
1595                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
1596                                                                            IDB_REJECT_MESSAGE_UP_ARROW, IDB_REJECT_MESSAGE_ICON, false, true);
1597                 pButtonRejectMessage->Invalidate(true);
1598         }
1599
1600         Button* pButtonReject = static_cast<Button*>(pKeysPanel->GetControl(IDC_REJECT_MESSAGE_CANCEL_BUTTON));
1601         if (pButtonReject != null)
1602         {
1603                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
1604                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, false);
1605                 SetBitmapToRejectMessageButton(IDS_REJECT_MESSAGE_BTN,IDB_REJECT_MESSAGE_BG,
1606                                                                            IDB_REJECT_MESSAGE_DOWN_ARROW, IDB_REJECT_MESSAGE_ICON, true, true);
1607                 pButtonReject->Invalidate(true);
1608         }
1609 }
1610
1611 void
1612 IncomingCallForm::OnForeground(void)
1613 {
1614         AppLogDebug("Enter");
1615         __pCallPresentor->OnAppForeground();
1616 }
1617
1618 void
1619 IncomingCallForm::OnScreenOff(void)
1620 {
1621         __pCallPresentor->StopAlert();
1622 }
1623
1624 void
1625 IncomingCallForm::CallDisconnected(void)
1626 {
1627         //check if no call option popup is shown, then remain on incoming call screen.
1628         //As user has neither accepted nor rejected incoming call.
1629         if (__pOptionPopup == null)
1630         {
1631                 return;
1632         }
1633
1634         //fetch already active call list and show updated option popup
1635         ArrayListT<AppCallInfo>* pCallList  = static_cast<ArrayListT<AppCallInfo>*>(__pCallPresentor->GetCallListN());
1636         if (pCallList != null && pCallList->GetCount() > 0)
1637         {
1638                 //then atleast 1 active call exist.
1639                 AppCallInfo phnCallInfo;
1640                 pCallList->GetAt(0,phnCallInfo);
1641                 //Check if only 1 call exist and it is on Hold
1642                 if(pCallList->GetCount() == 1 && phnCallInfo.IsOnHold())
1643                 {
1644                         //directly accept call
1645                         __pCallPresentor->AcceptIncomingCall(ANSERWING_OPTION_ACCEPT_CALL,__incomingCallHandle);
1646                 }
1647                 else
1648                 {
1649                         //Either 1 call exist and not "on Hold".
1650                         //Or 2 calls exist.
1651                         if(__pOptionPopup != null)
1652                         {
1653                                 delete __pOptionPopup;
1654                                 __pOptionPopup = null;
1655                         }
1656                         __pOptionPopup = new (std::nothrow) CallOptionPopup(*this,*(__pCallPresentor));
1657                         __pOptionPopup->Initialize();
1658                         __pOptionPopup->SetShowState(true);
1659                         __pOptionPopup->Draw();
1660                         __pOptionPopup->Show();
1661                 }
1662                 pCallList->RemoveAll();
1663         }
1664         else
1665         {
1666                 //no active call - Accept the  incoming call
1667                 __pCallPresentor->AcceptIncomingCall(ANSERWING_OPTION_ACCEPT_CALL,__incomingCallHandle);
1668         }
1669         delete pCallList;
1670         pCallList = null;
1671 }