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