NABI issues N_SE-50115, N_SE-50067, N_SE-49946, N_SE-49897, N_SE-49884, N_SE-48837...
[apps/osp/Settings.git] / src / StNfcForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                StNfcForm.cpp
19  * @brief               This is the implementation file for NfcForm class.
20  */
21
22 #include <FSystem.h>
23 #include "StNfcForm.h"
24 #include "StResourceManager.h"
25 #include "StSettingScenesList.h"
26 #include "StTypes.h"
27
28 using namespace Tizen::App;
29 using namespace Tizen::App::Package;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::System;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Controls;
36 using namespace Tizen::Ui::Scenes;
37
38 static const int ID_GROUP_NFC = 0;
39 static const int ID_GROUP_NFC_ITEM_COUNT = 1;
40
41 static const int ID_GROUP_NFC_HELP = 1;
42 static const int ID_GROUP_NFC_HELP_TEXT_LABEL = -1;
43
44 static const int ID_GROUP_NFC_PREDEFINED_ITEM = 2;
45 static const int ID_GROUP_NFC_PREDEFINED_ITEM_COUNT = 1;
46 static const int ID_GROUP_ITEM_NFC_PREDEFINED_ITEM = 0;
47
48 static const int ID_GROUP_NFC_PREDEFINED_ITEM_HELP = 3;
49 static const int ID_GROUP_NFC_PREDEFINED_ITEM_HELP_TEXT_LABEL = -1;
50
51 static const int NFC_NOT_SUPPORT_PREDEFINED_ITEM_GROUP_COUNT = 2;
52 static const int NFC_SUPPORT_PREDEFINED_ITEM_GROUP_COUNT = 4;
53 static const int W_TEXT_GAP = 30;
54 static const int H_TEXT_GAP = 20;
55
56 NfcForm::NfcForm(void)
57         : __pNfcPresentationModelInstance(null)
58         , __pNfcPredefinedItemPresentationModelInstance(null)
59         , __isPredefinedItem(false)
60         , __isNfcBusy(false)
61 {
62 }
63
64 NfcForm::~NfcForm(void)
65 {
66 }
67
68 void
69 NfcForm::CreateFooter(void)
70 {
71         Footer* pFooter = GetFooter();
72         AppAssert(pFooter);
73
74         SetFormBackEventListener(this);
75 }
76
77 result
78 NfcForm::OnInitializing(void)
79 {
80         CreateHeader(ResourceManager::GetString(L"IDS_NFC_BODY_NFC"));
81         CreateTableView();
82
83         if (__pNfcPresentationModelInstance == null)
84         {
85                 __pNfcPresentationModelInstance = NfcPresentationModel::GetInstance();
86                 if (__pNfcPresentationModelInstance != null)
87                 {
88                         __pNfcPresentationModelInstance->SetNfcEventListener(this);
89                 }
90         }
91
92         return E_SUCCESS;
93 }
94
95 result
96 NfcForm::OnTerminating(void)
97 {
98         SetFormBackEventListener(null);
99         __pNfcPresentationModelInstance->SetNfcEventListener(null);
100         return E_SUCCESS;
101 }
102
103 void
104 NfcForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
105 {
106         if (__pNfcPredefinedItemPresentationModelInstance == null)
107         {
108                 __pNfcPredefinedItemPresentationModelInstance = NfcPredefinedItemPresentationModel::GetInstance();
109         }
110
111         if (__pNfcPredefinedItemPresentationModelInstance == null)
112         {
113                 AppLogDebug("__pNfcPredefinedItemPresentationModelInstance == null");
114                 return;
115         }
116
117         if (__pNfcPredefinedItemPresentationModelInstance != null)
118         {
119                 __pNfcPredefinedItemPresentationModelInstance->InitReservedPushCandidatesList();
120                 __pResevedPushCandidatesAppidList = __pNfcPredefinedItemPresentationModelInstance->GetAllListReservedPushCandidatesAppIdList();
121                 if (__pResevedPushCandidatesAppidList != null)
122                 {
123                         if (__pResevedPushCandidatesAppidList->GetCount() > 0)
124                         {
125                                 __isPredefinedItem = true;
126                         }
127                 }
128         }
129         __pTableView->UpdateTableView();
130         bool nfcActivated = false;
131         if (__pNfcPresentationModelInstance != null)
132         {
133                 nfcActivated = __pNfcPresentationModelInstance->IsNfcActivated();
134                 __pTableView->SetItemChecked(0, 0, nfcActivated);
135         }
136         if (__isPredefinedItem)
137         {
138                 __pTableView->SetItemEnabled(ID_GROUP_NFC_PREDEFINED_ITEM, 0, nfcActivated);
139                 bool NfcReservedPushActivated = __pNfcPredefinedItemPresentationModelInstance->IsNfcReservedPushActivated();
140                 __pTableView->SetItemChecked(ID_GROUP_NFC_PREDEFINED_ITEM, ID_GROUP_ITEM_NFC_PREDEFINED_ITEM, NfcReservedPushActivated);
141         }
142 }
143
144 void
145 NfcForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
146 {
147 }
148
149 void
150 NfcForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
151 {
152         SceneManager* pSceneManager = SceneManager::GetInstance();
153         AppAssert(pSceneManager);
154
155         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
156 }
157
158 int
159 NfcForm::GetGroupCount(void)
160 {
161         int groupCount = 0;
162         if (__isPredefinedItem)
163         {
164                 groupCount = NFC_SUPPORT_PREDEFINED_ITEM_GROUP_COUNT;
165         }
166         else
167         {
168                 groupCount = NFC_NOT_SUPPORT_PREDEFINED_ITEM_GROUP_COUNT;
169         }
170         return groupCount;
171 }
172
173 int
174 NfcForm::GetItemCount(int groupIndex)
175 {
176         int itemCount = 0;
177         if (groupIndex == ID_GROUP_NFC)
178         {
179                 itemCount = ID_GROUP_NFC_ITEM_COUNT;
180         }
181         else if (groupIndex == ID_GROUP_NFC_PREDEFINED_ITEM)
182         {
183                 itemCount = ID_GROUP_NFC_PREDEFINED_ITEM_COUNT;
184         }
185         return itemCount;
186 }
187
188 TableViewGroupItem*
189 NfcForm::CreateGroupItem(int groupIndex, int itemWidth)
190 {
191         AppLogDebug("ENTER");
192         AppLogDebug("group[%d] width[%d]", groupIndex, itemWidth);
193
194         int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
195         int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
196         LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
197         Rectangle itemMainRectangle;
198         int fontSize = GetFontSize();
199         String groupText;
200         Label* pLabel = null;
201
202         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
203
204         switch (groupIndex)
205         {
206         case ID_GROUP_NFC:
207                 {
208                         yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
209                         itemHeight = 0;
210                 }
211                 break;
212
213         case ID_GROUP_NFC_HELP:
214                 {
215                         yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP / DIVIDE_BY_TWO;
216                         groupText = ResourceManager::GetString(L"IDS_NFC_BODY_WHEN_NFC_IS_ON_YOU_CAN_SEND_OR_RECEIVE_DATA_WHEN_YOUR_DEVICE_TOUCHES_OTHER_NFC_CAPABLE_DEVICES_OR_NFC_TAGS");
217                         itemHeight = GetHeightForStringArea(groupText, itemWidth - W_TEXT_GAP, fontSize) + H_TEXT_GAP;
218                 }
219                 break;
220
221         case ID_GROUP_NFC_PREDEFINED_ITEM:
222                 {
223                         yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
224                         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
225                 }
226                 break;
227
228         case ID_GROUP_NFC_PREDEFINED_ITEM_HELP:
229                 {
230                         yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP / DIVIDE_BY_TWO;
231                         groupText = ResourceManager::GetString(L"IDS_NFC_BODY_YOU_CAN_BEAM_PREDEFINED_ITEMS_TO_ANOTHER_NFC_DEVICE_JUST_BRING_THE_DEVICES_CLOSE_TOGETHER_MSG");
232                         itemHeight = GetHeightForStringArea(groupText, itemWidth - W_TEXT_GAP, fontSize) + H_TEXT_GAP;
233                 }
234                 break;
235
236         default:
237                 {
238                         yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
239                         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
240                 }
241                 break;
242         }
243
244         itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
245         itemMainRectangle.y = yItemOffset;
246         itemMainRectangle.width = itemWidth;
247         itemMainRectangle.height = itemHeight + H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
248
249         RelativeLayout relativeLayout;
250         relativeLayout.Construct();
251
252         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
253         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
254
255         pLabel = new (std::nothrow) Label();
256         pLabel->Construct(itemMainRectangle, groupText);
257         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
258         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
259         pLabel->SetTextConfig(fontSize, style);
260         pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
261
262         pItem->AddControl(pLabel);
263         pItem->SetEnabled(false);
264         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, 0, 0, 0);
265         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
266         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
267
268         return pItem;
269 }
270
271 TableViewItem*
272 NfcForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
273 {
274         AppLogDebug("group[%d] item[%d] width[%d]", groupIndex, itemIndex, itemWidth);
275         int itemHeight = H_GROUP_ITEM_DEFAULT;
276         int fontSize = GetFontSize();
277         Rectangle itemMainRectangle;
278         Rectangle itemSubRectangle;
279
280         String itemMainText;
281         String itemSubText;
282
283         ItemTypeOneLine(itemMainRectangle);
284         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
285
286         TableViewItem* pItem = new (std::nothrow) TableViewItem();
287         if (pItem == null)
288         {
289                 return null;
290         }
291
292         switch (groupIndex)
293         {
294         case ID_GROUP_NFC:
295                 {
296                         itemMainText = ResourceManager::GetString(L"IDS_NFC_BODY_NFC");
297                         style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
298                 }
299                 break;
300
301         case ID_GROUP_NFC_PREDEFINED_ITEM:
302                 {
303                         if (__pResevedPushCandidatesAppidList->GetCount() != 0)
304                         {
305                                 int selectItemIndex = __pNfcPredefinedItemPresentationModelInstance->GetSelectNfcReservedPushCandidatesAppIdIndex();
306                                 itemSubText = *static_cast<String*>(__pResevedPushCandidatesAppidList->GetAt(selectItemIndex));
307                         }
308                         ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
309                         itemMainText = ResourceManager::GetString(L"IDS_NFC_BODY_PREDEFINED_ITEM_ABB");
310                         style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
311                 }
312                 break;
313
314         default:
315                 {
316                         AppLogDebug("CreateItem is error");
317                         delete pItem;
318                         return null;
319                 }
320         }
321
322         RelativeLayout relativeLayout;
323         relativeLayout.Construct();
324
325         result r = pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
326         if (IsFailed(r))
327         {
328                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
329                 delete pItem;
330                 return null;
331         }
332
333         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
334
335         Label* pLabel = new (std::nothrow) Label();
336         if (pLabel == null)
337         {
338                 AppLogDebug("pLabel is null");
339                 return pItem;
340         }
341
342         r = pLabel->Construct(itemMainRectangle, itemMainText);
343         if (IsFailed(r))
344         {
345                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
346                 delete pLabel;
347                 return pItem;
348         }
349
350         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
351         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
352         pLabel->SetTextColor(COLOR_MAIN_TEXT);
353
354         pItem->AddControl(pLabel);
355         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
356         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
357         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
358
359         if (groupIndex == ID_GROUP_NFC_PREDEFINED_ITEM)
360         {
361                 Label* pSecondLineLabel = new (std::nothrow) Label();
362                 if (pSecondLineLabel == null)
363                 {
364                         AppLogDebug("pLabel is null");
365                         return pItem;
366                 }
367
368                 r = pSecondLineLabel->Construct(itemSubRectangle, itemSubText);
369                 if (IsFailed(r))
370                 {
371                         AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
372                         delete pSecondLineLabel;
373                         return pItem;
374                 }
375
376                 pSecondLineLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
377                 pSecondLineLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
378                 pSecondLineLabel->SetTextColor(COLOR_SUB_TEXT);
379
380                 pItem->AddControl(pSecondLineLabel);
381                 relativeLayout.SetMargin(*pSecondLineLabel, itemSubRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
382                 relativeLayout.SetRelation(*pSecondLineLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
383                 relativeLayout.SetRelation(*pSecondLineLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
384         }
385         return pItem;
386 }
387
388 bool
389 NfcForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
390 {
391         AppLogDebug("ENTER");
392
393         delete pItem;
394         pItem = null;
395
396         return true;
397 }
398
399 bool
400 NfcForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
401 {
402         AppLogDebug("ENTER");
403
404         delete pItem;
405         pItem = null;
406
407         return true;
408 }
409
410 void
411 NfcForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
412 {
413         AppLogDebug("groupIndex [%d] itemIndex [%d]", groupIndex, itemIndex);
414         if ((groupIndex != 0)
415                 && (itemIndex != 0))
416         {
417                 AppLogDebug("OnGroupedTableViewGroupItemStateChanged is Error");
418                 return;
419         }
420         if (__pNfcPresentationModelInstance == null)
421         {
422                 AppLogDebug("__pNfcPresentationModelInstance is null");
423                 return;
424         }
425
426         switch (groupIndex)
427         {
428         case ID_GROUP_NFC:
429                 {
430                         if (__isNfcBusy)
431                         {
432                                 AppLogDebug("nfc turn on or off");
433                                 __pTableView->SetItemChecked(groupIndex, itemIndex, !__pTableView->IsItemChecked(groupIndex, itemIndex));
434                                 return;
435                         }
436                         __isNfcBusy = true;
437                         ToggleNfcActivateStatus(status);
438                 }
439                 break;
440
441         case ID_GROUP_NFC_PREDEFINED_ITEM:
442                 {
443                         bool NfcReservedPushActivated = __pNfcPredefinedItemPresentationModelInstance->IsNfcReservedPushActivated();
444                         __pTableView->SetItemChecked(ID_GROUP_NFC_PREDEFINED_ITEM, ID_GROUP_ITEM_NFC_PREDEFINED_ITEM, NfcReservedPushActivated);
445                         SceneManager* pSceneManager = SceneManager::GetInstance();
446                         AppAssert(pSceneManager);
447                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_NFC_PREDEFINED_ITEM, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
448                 }
449                 break;
450
451         default:
452                 {
453                         AppLogDebug("OnGroupedTableViewItemStateChanged is error");
454                 }
455                 break;
456         }
457 }
458
459 void
460 NfcForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
461 {
462 }
463
464 int
465 NfcForm::GetDefaultGroupItemHeight(void)
466 {
467         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
468 }
469
470 int
471 NfcForm::GetDefaultItemHeight(void)
472 {
473         return H_GROUP_ITEM_DEFAULT;
474 }
475
476 void
477 NfcForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
478 {
479         if ((groupIndex != ID_GROUP_NFC_HELP)
480                 && (groupIndex != ID_GROUP_NFC_PREDEFINED_ITEM_HELP))
481         {
482                 AppLogDebug("groupIndex is not ID_GROUP_FONT_TEXT");
483                 return;
484         }
485
486         Label* pLabel = static_cast<Label*>(pItem->GetControl(0));
487         if (pLabel == null)
488         {
489                 AppLogDebug("pLabel is null");
490                 return;
491         }
492
493         Rectangle clientRect = GetClientAreaBounds();
494         Rectangle itemRect = pItem->GetBounds();
495         String groupText = pLabel->GetText();
496         int fontSize = GetFontSize();
497         int itemHeight = GetHeightForStringArea(groupText, clientRect.width, fontSize) + H_TEXT_GAP;
498
499         itemRect.height = itemHeight;
500
501         pLabel->SetBounds(pLabel->GetX(), pLabel->GetY(), clientRect.width, itemHeight);
502         pItem->SetBounds(itemRect);
503 }
504
505 void
506 NfcForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
507 {
508 }
509
510 void
511 NfcForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
512 {
513 }
514
515 void
516 NfcForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
517 {
518 }
519
520 void
521 NfcForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
522 {
523         __pTableView->RefreshItem(ID_GROUP_NFC_HELP, ID_GROUP_NFC_HELP_TEXT_LABEL, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
524         if (__isPredefinedItem)
525         {
526                 __pTableView->RefreshItem(ID_GROUP_NFC_PREDEFINED_ITEM_HELP, ID_GROUP_NFC_PREDEFINED_ITEM_HELP_TEXT_LABEL, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
527         }
528         Invalidate(true);
529 }
530
531 void
532 NfcForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
533 {
534         AppLog("Enter");
535         if (requestId == REFRESH_REQUEST_EVENT)
536         {
537                 if (__pTableView)
538                 {
539                         if (__pNfcPredefinedItemPresentationModelInstance == null)
540                         {
541                                 __pNfcPredefinedItemPresentationModelInstance = NfcPredefinedItemPresentationModel::GetInstance();
542                         }
543
544                         if (__pNfcPredefinedItemPresentationModelInstance == null)
545                         {
546                                 AppLogDebug("__pNfcPredefinedItemPresentationModelInstance == null");
547                                 return;
548                         }
549
550                         if (__pNfcPredefinedItemPresentationModelInstance != null)
551                         {
552                                 __pNfcPredefinedItemPresentationModelInstance->InitReservedPushCandidatesList();
553                                 __pResevedPushCandidatesAppidList = __pNfcPredefinedItemPresentationModelInstance->GetAllListReservedPushCandidatesAppIdList();
554                                 if (__pResevedPushCandidatesAppidList != null)
555                                 {
556                                         if (__pResevedPushCandidatesAppidList->GetCount() > 0)
557                                         {
558                                                 __isPredefinedItem = true;
559                                         }
560                                         else
561                                         {
562                                                 __isPredefinedItem = false;
563                                         }
564                                 }
565                         }
566                         __pTableView->UpdateTableView();
567                         bool nfcActivated = false;
568                         if (__pNfcPresentationModelInstance != null)
569                         {
570                                 nfcActivated = __pNfcPresentationModelInstance->IsNfcActivated();
571                         }
572                         __pTableView->SetItemChecked(0, 0, nfcActivated);
573                         if (__isPredefinedItem)
574                         {
575                                 __pTableView->SetItemEnabled(ID_GROUP_NFC_PREDEFINED_ITEM, 0, nfcActivated);
576                                 bool NfcReservedPushActivated = __pNfcPredefinedItemPresentationModelInstance->IsNfcReservedPushActivated();
577                                 __pTableView->SetItemChecked(ID_GROUP_NFC_PREDEFINED_ITEM, ID_GROUP_ITEM_NFC_PREDEFINED_ITEM, NfcReservedPushActivated);
578                         }
579                 }
580                 if (pArgs)
581                 {
582                         pArgs->RemoveAll(true);
583                         delete pArgs;
584                 }
585         }
586 }
587
588 result
589 NfcForm::ToggleNfcActivateStatus(Tizen::Ui::Controls::TableViewItemStatus itemStatus)
590 {
591         if (__pNfcPresentationModelInstance == null)
592         {
593                 AppLogDebug("__pNfcPresentationModelInstance is null");
594                 return E_FAILURE;
595         }
596         result r = E_SUCCESS;
597
598         switch (itemStatus)
599         {
600         case TABLE_VIEW_ITEM_STATUS_CHECKED:
601                 {
602                         r = __pNfcPresentationModelInstance->ActivateNfc();
603                         if (IsFailed(r))
604                         {
605                                 AppLogDebug("Nfc active is failed %s", GetErrorMessage(r));
606                                 __isNfcBusy = false;
607                         }
608
609                         if (__isPredefinedItem)
610                         {
611                                 __pTableView->SetItemEnabled(ID_GROUP_NFC_PREDEFINED_ITEM, 0, true);
612                         }
613                 }
614                 break;
615
616         case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
617                 {
618                         r = __pNfcPresentationModelInstance->DeactivateNfc();
619                         if (IsFailed(r))
620                         {
621                                 AppLogDebug("Nfc deactive is failed %s", GetErrorMessage(r));
622                                 __isNfcBusy = false;
623                         }
624
625                         if (__isPredefinedItem)
626                         {
627                                 __pTableView->SetItemEnabled(ID_GROUP_NFC_PREDEFINED_ITEM, 0, false);
628                         }
629                 }
630                 break;
631
632         default:
633                 break;
634         }
635
636         return E_SUCCESS;
637 }
638
639 void
640 NfcForm::OnNfcPresentationModelEventCompleted(NfcPresentationModelEvent requestEvent, result r)
641 {
642         AppLog("requestEvent = %d", requestEvent);
643         if ((requestEvent == NFC_PRESENTATION_MODEL_EVENT_ACTIVATED)
644                 || (requestEvent == NFC_PRESENTATION_MODEL_EVENT_DEACTIVATED))
645         {
646                 __isNfcBusy = false;
647         }
648 }