2c2975c90ae022c329ca5f14949a50d37950ed6a
[apps/osp/Settings.git] / src / StWifiDirectForm.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                StWifiDirectForm.cpp
19  * @brief               This is the implementation file for WifiDirectForm class.
20  */
21
22 #include "StResourceManager.h"
23 #include "StSettingScenesList.h"
24 #include "StTypes.h"
25 #include "StWifiDirectForm.h"
26
27 using namespace Tizen::App;
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Net::Wifi;
32 using namespace Tizen::System;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Ui::Controls;
35 using namespace Tizen::Ui::Scenes;
36
37 #define WIFI_DIRECT_DEBUG_CODE
38 #define WIFI_DIRECT_BUG_REPORT
39
40 static const int DURATION = 500;
41 static const int FRAME_COUNT = 30;
42 static const int ID_WIFI_DIRECT_IN_PROGRESS_ANIMATION_DEFAULT = -1;
43 static const int ID_WIFI_DIRECT_IN_PROGRESS_REPEAT_COUNT = 1000;
44 static const int X_IN_PROGRESS_ANIMATION = 620;
45 static const int Y_IN_PROGRESS_ANIMATION = 31;
46 static const int W_IN_PROGRESS_ANIMATION = 62;
47 static const int H_IN_PROGRESS_ANIMATION = 62;
48
49 static const int ID_WIFIDIRECT_COUNT_DEFAULT = 1;
50 static const int ID_FOOTER_ITEM_INDEX_1 = 0;
51
52 static const int W_WIFI_DIRECT_MULTI_CONNECT_ITEM = (W_GROUP_DEFAULT - (X_GROUP_DEFAULT * WIDTH_GAP * WIDTH_GAP));
53
54 static const int IDA_WIFI_DIRECT_ACTION_ID_BASE = 100;
55 static const int IDA_WIFI_DIRECT_FOOTER_SCAN = IDA_WIFI_DIRECT_ACTION_ID_BASE + 1;
56 static const int IDA_WIFI_DIRECT_FOOTER_CANCEL = IDA_WIFI_DIRECT_ACTION_ID_BASE + 2;
57 static const int IDA_WIFI_DIRECT_MULTI_CONNECT = IDA_WIFI_DIRECT_ACTION_ID_BASE + 3;
58 static const int IDA_WIFI_DIRECT_DISCONNECT = IDA_WIFI_DIRECT_ACTION_ID_BASE + 4;
59 static const int IDA_WIFI_DIRECT_CANCEL_CONNECT = IDA_WIFI_DIRECT_ACTION_ID_BASE + 5;
60 static const int IDA_WIFI_DIRECT_DISCONNECT_ALL = IDA_WIFI_DIRECT_ACTION_ID_BASE + 6;
61
62 static const int WIFI_DIRECT_DEFAULT_COUNT = 1;
63
64 enum WifiDirectGroupIndex
65 {
66         WIFI_DIRECT_GROUP_INDEX_BASE,
67         WIFI_DIRECT_GROUP_INDEX_0 = WIFI_DIRECT_GROUP_INDEX_BASE,
68         WIFI_DIRECT_GROUP_INDEX_1,
69         WIFI_DIRECT_GROUP_INDEX_2,
70         WIFI_DIRECT_GROUP_INDEX_3,
71         WIFI_DIRECT_GROUP_INDEX_4,
72         WIFI_DIRECT_GROUP_INDEX_5,
73         WIFI_DIRECT_GROUP_INDEX_6,
74         WIFI_DIRECT_GROUP_INDEX_7,
75         WIFI_DIRECT_GROUP_INDEX_MAX
76 };
77
78 enum WifiDirectGroup
79 {
80         WIFI_DIRECT_GROUP_ITEM_BASE,
81         WIFI_DIRECT_GROUP_ITEM_NONE = WIFI_DIRECT_GROUP_ITEM_BASE,
82         WIFI_DIRECT_GROUP_TURN_ON_OFF_CONTROL_ITEM,
83         WIFI_DIRECT_GROUP_CONNECTED_DEVICES_ITEM,
84         WIFI_DIRECT_GROUP_AVAILABLE_DEVICES_ITEM,
85         WIFI_DIRECT_GROUP_MULTI_CONNECT_ITEM,
86         WIFI_DIRECT_GROUP_BUSY_DEVICES_ITEM,
87         WIFI_DIRECT_GROUP_ABOUT_WIFIDIRECT_ITEM,
88         WIFI_DIRECT_GROUP_ITEM_TOTOAL_COUNT,
89         WIFI_DIRECT_GROUP_ITEM_MAX
90 };
91
92 WifiDirectForm::WifiDirectForm(void)
93         : __pWifiDirectManagerInstance(null)
94         , __localDeviceName(L"")
95         , __localDeviceMemberType(WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
96         , __pAnimationFrameList(null)
97         , __pAnimation(null)
98         , __isAppControlRequest(false)
99 {
100         __positionInProgressAnimation.groupIndex = 0;
101         __positionInProgressAnimation.itemIndex = 0;
102 }
103
104 WifiDirectForm::~WifiDirectForm(void)
105 {
106 }
107
108 void
109 WifiDirectForm::CreateFooter(void)
110 {
111         Footer* pFooter = GetFooter();
112         AppAssert(pFooter);
113
114         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
115
116         FooterItem footerScan;
117         footerScan.Construct(IDA_WIFI_DIRECT_FOOTER_SCAN);
118         footerScan.SetText(ResourceManager::GetString(L"IDS_ST_BODY_SCAN"));
119
120         pFooter->AddItem(footerScan);
121         pFooter->AddActionEventListener(*this);
122         pFooter->SetItemEnabled(ID_FOOTER_ITEM_INDEX_1, false);
123
124         SetFormBackEventListener(this);
125 }
126
127 void
128 WifiDirectForm::DisableScanFooter(void)
129 {
130         Footer* pFooter = GetFooter();
131         AppAssert(pFooter);
132
133         pFooter->SetItemEnabled(0, false);
134         pFooter->Invalidate(true);
135 }
136
137 void
138 WifiDirectForm::EnableScanFooter(void)
139 {
140         Footer* pFooter = GetFooter();
141         AppAssert(pFooter);
142
143         pFooter->SetItemEnabled(0, true);
144         pFooter->Invalidate(true);
145 }
146
147 void
148 WifiDirectForm::SetFooterText(const int actionId, Tizen::Base::String itemText)
149 {
150         Footer* pFooter = GetFooter();
151         AppAssert(pFooter);
152
153         FooterItem footerItem;
154         footerItem.Construct(actionId);
155         footerItem.SetText(itemText);
156
157         pFooter->RemoveItemAt(0);
158         pFooter->InsertItemAt(0, footerItem);
159 }
160
161 result
162 WifiDirectForm::OnInitializing(void)
163 {
164         SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
165         CreateHeader(ResourceManager::GetString(L"IDS_ST_HEADER_WI_FI_DIRECT"));
166         CreateFooter();
167         CreateTableView();
168
169         DisableScanFooter();
170         result r = InitWifiDirectManagerInstance();
171         if (!IsFailed(r))
172         {
173                 TableViewItemInit();
174                 SetLocalDeviceName();
175                 ReAdjustGroupItemToIndex();
176                 __pWifiDirectManagerInstance->QueryAllGroupMemberInfoList();
177                 CreateInPorgressAnimationFrame();
178         }
179
180         return r;
181 }
182
183 result
184 WifiDirectForm::OnTerminating(void)
185 {
186         DestoryInPorgressAnimationFrame();
187         __pWifiDirectManagerInstance = null;
188
189         __pTableView = null;
190
191         SetFormBackEventListener(null);
192         return E_SUCCESS;
193 }
194
195 void
196 WifiDirectForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
197 {
198         __pTableView->UpdateTableView();
199         if (previousSceneId.Equals(String(IDSCN_WIFI_DIRECT_CONNECTION)))
200         {
201                 InitWifiDirectManagerInstance();
202
203                 ReAdjustGroupItemToIndex();
204                 UpdateTableView();
205         }
206         else if (pArgs != null)
207         {
208                 String categoryCheck = static_cast<String*>(pArgs->GetAt(0))->GetPointer();
209
210                 if (categoryCheck == L"category:WifiDirect")
211                 {
212                         __isAppControlRequest = true;
213                 }
214                 delete pArgs;
215         }
216 }
217
218 void
219 WifiDirectForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
220 {
221 }
222
223 void
224 WifiDirectForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
225 {
226         SceneManager* pSceneManager = SceneManager::GetInstance();
227         AppAssert(pSceneManager);
228
229         if (__isAppControlRequest == true)
230         {
231                 UiApp* pApp = UiApp::GetInstance();
232                 AppAssert(pApp);
233
234                 pApp->Terminate();
235         }
236         else
237         {
238                 if (__pWifiDirectManagerInstance)
239                 {
240                         __pWifiDirectManagerInstance->CancelRemoteDeviceScan();
241                 }
242                 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
243         }
244 }
245
246 void
247 WifiDirectForm::OnWifiDirectManagerEventCompleted(WifiDirectManagerEvent requestEvent, result r)
248 {
249         result returnResult = r;
250         static bool isUpdateTableview = false;
251
252         if (__pWifiDirectManagerInstance == null)
253         {
254                 return;
255         }
256
257         switch (requestEvent)
258         {
259         case WIFI_DIRECT_MANAGER_EVENT_DEVICE_ACTIVATED:
260                 {
261                         if (!IsFailed(returnResult))
262                         {
263                                 returnResult = __pWifiDirectManagerInstance->RemoteDeviceScan();
264                                 if (!IsFailed(returnResult))
265                                 {
266                                         SetFooterText(IDA_WIFI_DIRECT_FOOTER_CANCEL, ResourceManager::GetString(L"IDS_COM_BODY_STOP"));
267                                         ReAdjustGroupItemToIndex(true);
268                                         UpdateTableView();
269                                 }
270                                 else
271                                 {
272                                         AppLogDebug("Error Message = [%ls]", GetErrorMessage(returnResult));
273                                         __pWifiDirectManagerInstance->Deactivate();
274                                 }
275                                 EnableScanFooter();
276                         }
277                 }
278                 break;
279
280         case WIFI_DIRECT_MANAGER_EVENT_DEVICE_DEACTIVATED:
281                 {
282                         if (!IsFailed(returnResult))
283                         {
284                                 SetFooterText(IDA_WIFI_DIRECT_FOOTER_SCAN, ResourceManager::GetString(L"IDS_ST_BODY_SCAN"));
285                                 DisableScanFooter();
286                                 ReAdjustGroupItemToIndex();
287                                 UpdateTableView();
288                         }
289                         else
290                         {
291                                 AppLogDebug("Error Message = [%ls]", GetErrorMessage(returnResult));
292                         }
293                 }
294                 break;
295
296         case WIFI_DIRECT_MANAGER_EVENT_SCAN_COMPLETED_N:
297                 {
298                         DisableScanFooter();
299                         SetFooterText(IDA_WIFI_DIRECT_FOOTER_SCAN, ResourceManager::GetString(L"IDS_ST_BODY_SCAN"));
300                         EnableScanFooter();
301                         ReAdjustGroupItemToIndex(true);
302                         UpdateTableView();
303                 }
304                 break;
305
306         case WIFI_DIRECT_MANAGER_EVENT_ASSOCIATION_COMPLETED:
307                 //fall through
308         case WIFI_DIRECT_MANAGER_EVENT_GROUP_CREATED_N:
309                 {
310                         if ((!IsFailed(returnResult))
311                                 || (returnResult == E_OPERATION_CANCELED))
312                         {
313                                 SetFooterText(IDA_WIFI_DIRECT_FOOTER_SCAN, ResourceManager::GetString(L"IDS_ST_BODY_SCAN"));
314                                 EnableScanFooter();
315                                 ReAdjustGroupItemToIndex();
316                                 UpdateTableView();
317
318                                 returnResult = E_SUCCESS;
319                         }
320                         else
321                         {
322                                 AppLogDebug("Error Message = [%s]", GetErrorMessage(returnResult));
323                                 __pWifiDirectManagerInstance->Deactivate();
324                         }
325                 }
326                 break;
327
328         case WIFI_DIRECT_EVENT_CANCELCREATEGROUP:
329                 {
330                         AppLogDebug("WIFI_DIRECT_EVENT_CANCELCREATEGROUP");
331                 }
332                 break;
333
334         case WIFI_DIRECT_MANAGER_EVENT_ASSOCITION_TERMINATED:
335                 // fall through
336         case WIFI_DIRECT_MAMAGER_EVENT_GROUP_DESTRORYED:
337                 {
338                         returnResult = __pWifiDirectManagerInstance->RemoteDeviceScan();
339                         if (!IsFailed(returnResult))
340                         {
341                                 SetFooterText(IDA_WIFI_DIRECT_FOOTER_CANCEL, ResourceManager::GetString(L"IDS_COM_BODY_STOP"));
342                                 ReAdjustGroupItemToIndex(true);
343                         }
344                         else
345                         {
346                                 ReAdjustGroupItemToIndex();
347                         }
348                         EnableScanFooter();
349                         UpdateTableView();
350                 }
351                 break;
352
353         case WIFI_DIRECT_MANAGER_EVENT_CLIENT_ASSOCIATED:
354                 {
355                         if (!IsFailed(returnResult))
356                         {
357                                 ReAdjustGroupItemToIndex();
358                                 UpdateTableView();
359                         }
360                         else
361                         {
362                                 AppLogDebug("Error Message = [%ls]", GetErrorMessage(returnResult));
363                                 __pWifiDirectManagerInstance->Deactivate();
364                         }
365                 }
366                 break;
367
368         case WIFI_DIRECT_MANAGER_EVENT_CLIENT_DISASSOCIATED:
369                 {
370                         if (!IsFailed(returnResult))
371                         {
372                                 ReAdjustGroupItemToIndex();
373                                 UpdateTableView();
374                         }
375                         else
376                         {
377                                 AppLogDebug("Error Message = [%ls]", GetErrorMessage(returnResult));
378                                 __pWifiDirectManagerInstance->Deactivate();
379                         }
380                 }
381                 break;
382
383         case WIFI_DIRECT_EVENT_CANCELSCAN:
384                 {
385                         AppLogDebug("WIFI_DIRECT_EVENT_CANCELSCAN");
386                 }
387                 break;
388
389         case WIFI_DIRECT_MANAGER_EVENT_GROUP_OWNER_INFO_RECEIVED:
390                 {
391                         AppLogDebug("WIFI_DIRECT_MANAGER_EVENT_GROUP_OWNER_INFO_RECEIVED");
392                 }
393                 break;
394
395         case WIFI_DIRECT_MANAGER_EVENT_REQUESTED_ALL_GROUP_MEMBER_INFO_RECEIVED_N:
396                 {
397                         ReAdjustGroupItemToIndex();
398                         if (isUpdateTableview)
399                         {
400                                 UpdateTableView();
401                         }
402                         isUpdateTableview = false;
403                 }
404                 break;
405
406         case WIFI_DIRECT_MANAGER_EVENT_ALL_GROUP_MEMBER_INFO_RECEIVED_N:
407                 {
408                         AppLogDebug("WIFI_DIRECT_MANAGER_EVENT_ALL_GROUP_MEMBER_INFO_RECEIVED_N");
409                 }
410                 break;
411
412         default:
413                 break;
414         }
415
416         AppLogDebug("EXIT[requestEvent:%d]", requestEvent);
417 #ifdef WIFI_DIRECT_DEBUG_CODE
418         if (IsFailed(returnResult))
419         {
420                 String resultError = GetErrorMessage(returnResult);
421                 ShowMessageBox(L"WIFI_DIRECT_DEBUG_CODE", resultError);
422         }
423 #endif
424 }
425
426 int
427 WifiDirectForm::GetGroupCount(void)
428 {
429         AppLogDebug("__groupIndex[GROUP_TOTAL_COUNT]=%d", __groupIndex[GROUP_TOTAL_COUNT]);
430         return __groupIndex[GROUP_TOTAL_COUNT];
431 }
432
433 int
434 WifiDirectForm::GetItemCount(int groupIndex)
435 {
436         int itemCount = 0;
437
438         switch (groupIndex)
439         {
440         case WIFI_DIRECT_GROUP_INDEX_0:
441                 {
442                         itemCount = __groupItemCount[WIFI_DIRECT_GROUP_INDEX_0];
443                 }
444                 break;
445
446         case WIFI_DIRECT_GROUP_INDEX_1:
447                 {
448                         itemCount = __groupItemCount[WIFI_DIRECT_GROUP_INDEX_1];
449                 }
450                 break;
451
452         case WIFI_DIRECT_GROUP_INDEX_2:
453                 {
454                         itemCount = __groupItemCount[WIFI_DIRECT_GROUP_INDEX_2];
455                 }
456                 break;
457
458         case WIFI_DIRECT_GROUP_INDEX_3:
459                 {
460                         itemCount = __groupItemCount[WIFI_DIRECT_GROUP_INDEX_3];
461                 }
462                 break;
463
464         case WIFI_DIRECT_GROUP_INDEX_4:
465                 {
466                         itemCount = __groupItemCount[WIFI_DIRECT_GROUP_INDEX_4];
467                 }
468                 break;
469
470         case WIFI_DIRECT_GROUP_INDEX_5:
471                 {
472                         itemCount = __groupItemCount[WIFI_DIRECT_GROUP_INDEX_5];
473                 }
474                 break;
475
476         default:
477                 break;
478         }
479
480         AppLogDebug("[groupIndex:%d]GetItemCount %d", groupIndex, itemCount);
481         return itemCount;
482 }
483
484 TableViewGroupItem*
485 WifiDirectForm::CreateGroupItem(int groupIndex, int itemWidth)
486 {
487         int itemHeight = H_GROUP_INDEX_DEFAULT;
488         LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
489         Rectangle itemRectangle;
490         String groupText;
491         Label* pLabel = null;
492
493         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
494         if (pItem == null)
495         {
496                 return pItem;
497         }
498
499         itemRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
500         itemRectangle.y = H_GROUP_INDEX_TITLE_TEXT;
501         itemRectangle.width = itemWidth;
502         itemRectangle.height = H_GROUP_INDEX_DEFAULT - H_GROUP_INDEX_TITLE_TEXT;
503
504         switch (__groupIndex[groupIndex])
505         {
506         case WIFI_DIRECT_GROUP_TURN_ON_OFF_CONTROL_ITEM:
507                 {
508                         itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
509                         itemRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
510                         itemRectangle.y = Y_GROUP_ITEM_DEFAULT_LABEL;
511                         itemRectangle.width = itemWidth;
512                         itemRectangle.height = itemHeight;
513                 }
514                 break;
515
516         case WIFI_DIRECT_GROUP_BUSY_DEVICES_ITEM:
517                 {
518                         groupText = ResourceManager::GetString(L"IDS_ST_HEADER_BUSY_DEVICES");
519                 }
520                 break;
521
522         case WIFI_DIRECT_GROUP_AVAILABLE_DEVICES_ITEM:
523                 {
524                         int itemCount = __pWifiDirectManagerInstance->GetScanDeviceListInfoCount();
525                         if (itemCount != 0)
526                         {
527                                 groupText = ResourceManager::GetString(L"IDS_ST_HEADER_AVAILABLE_DEVICES");
528                         }
529                         else
530                         {
531                                 groupText = ResourceManager::GetString(L"IDS_WIFI_BODY_WI_FI_DIRECT_DEVICES");
532                         }
533                 }
534                 break;
535
536         case WIFI_DIRECT_GROUP_CONNECTED_DEVICES_ITEM:
537                 {
538                         groupText = ResourceManager::GetString(L"IDS_ST_HEADER_CONNECTED_DEVICES");
539                 }
540                 break;
541
542         default:
543                 break;
544         }
545
546         RelativeLayout relativeLayout;
547         relativeLayout.Construct();
548
549         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
550         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
551
552         pLabel = new (std::nothrow) Label();
553         pLabel->Construct(itemRectangle, groupText);
554         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
555         pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
556         pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
557         pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
558
559         pItem->AddControl(pLabel);
560         relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
561         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
562         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
563         pItem->SetEnabled(false);
564
565         return pItem;
566 }
567
568 TableViewItem*
569 WifiDirectForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
570 {
571         bool isTwoLineItemText = false;
572         bool isCreateButtonControl = false;
573         bool isCreateIcon = false;
574         bool isCreaetInProgressAnimation = false;
575         int buttonActionId = IDA_WIFI_DIRECT_ACTION_ID_BASE;
576         int itemHeight = H_GROUP_ITEM_DEFAULT;
577         Rectangle itemIconRect;
578         Rectangle itemRectangle;
579         Rectangle itemRectSecondLabel;
580         Rectangle itemInPorgressAnimationRect;
581         String itemText;
582         String itemTextTwoLine;
583         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
584         Label* pLabel = null;
585         Label* pSecondLabel = null;
586         Bitmap* pBitmap = null;
587         int fontSize = GetFontSize();
588
589         TableViewItem* pItem = new (std::nothrow) TableViewItem();
590         if ((pItem == null)
591                 || (__pTableView == null )
592                 || (__pWifiDirectManagerInstance == null))
593         {
594                 delete pItem;
595                 return null;
596         }
597
598         itemHeight = H_GROUP_ITEM_DEFAULT;
599         ItemTypeOneLine(itemRectangle);
600
601         switch (__groupIndex[groupIndex])
602         {
603         case WIFI_DIRECT_GROUP_TURN_ON_OFF_CONTROL_ITEM:
604                 {
605                         int lastEvent = __pWifiDirectManagerInstance->GetLastEventToPerform();
606                         if (lastEvent == WIFI_DIRECT_MANAGER_EVENT_DEVICE_ACTIVATING)
607                         {
608                                 itemText = ResourceManager::GetString(L"IDS_COM_POP_ACTIVATING");
609                                 style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
610                         }
611                         else if (lastEvent == WIFI_DIRECT_MANAGER_EVENT_DEVICE_DEACTIVATING)
612                         {
613                                 itemText = ResourceManager::GetString(L"IDS_ST_POP_DEACTIVATING_ING");
614                                 style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
615                         }
616                         else
617                         {
618                                 if (__pWifiDirectManagerInstance->IsActivated())
619                                 {
620                                         __pTableView->SetItemChecked(groupIndex, itemIndex, true);
621                                 }
622
623                                 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
624                                 itemText = ResourceManager::GetString(L"IDS_ST_HEADER_WI_FI_DIRECT");
625                         }
626
627                         isTwoLineItemText = true;
628                         itemTextTwoLine = GetLocalDeviceName();
629                         ItemTypeTwoLine(itemRectangle, itemRectSecondLabel, fontSize);
630                         itemHeight = (itemRectangle.height + itemRectSecondLabel.height);
631                 }
632                 break;
633
634         case WIFI_DIRECT_GROUP_CONNECTED_DEVICES_ITEM:
635                 {
636                         WifiDirectDeviceInfo* pConnectDevice = __pWifiDirectManagerInstance->GetGroupMemberListInfoAt(itemIndex);
637                         if (pConnectDevice != null)
638                         {
639                                 itemText = pConnectDevice->GetDeviceName();
640                                 pBitmap = ResourceManager::GetBitmapN(IDB_ABOUT_PHONE);
641                         }
642                         else
643                         {
644                                 delete pItem;
645                                 return null;
646                         }
647
648                         isTwoLineItemText = true;
649                         isCreateIcon = true;
650
651                         ItemTypeIconAndTwoLine(itemIconRect, itemRectangle, itemRectSecondLabel, fontSize);
652                         itemHeight = (itemRectangle.height + itemRectSecondLabel.height);
653
654                         itemTextTwoLine = ResourceManager::GetString(L"IDS_WIFI_BODY_CONNECTED");
655                 }
656                 break;
657
658         case WIFI_DIRECT_GROUP_AVAILABLE_DEVICES_ITEM:
659                 {
660                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_NO_DEVICES_FOUND");
661
662                         WifiDirectDeviceInfo* pScanRemoteDevice = __pWifiDirectManagerInstance->GetScanDeviceListInfoAt(itemIndex);
663                         if (pScanRemoteDevice != null)
664                         {
665                                 itemText = pScanRemoteDevice->GetDeviceName();
666                                 if (itemText.IsEmpty() == false)
667                                 {
668                                         int localDeviceLastEvent = __pWifiDirectManagerInstance->GetLastEventToPerform();
669
670                                         if ((localDeviceLastEvent == WIFI_DIRECT_MANAGER_EVENT_GROUP_CREATING)
671                                                 || ( localDeviceLastEvent == WIFI_DIRECT_MANAGER_EVENT_ASSOCIATING))
672                                         {
673                                                 itemTextTwoLine = ResourceManager::GetString(L"IDS_ST_BODY_TAP_TO_CONNECT_ABB");
674
675                                                 TableViewIndex positionInPorgressAnimation = GetPositionInProgressAnimation();
676                                                 if ((positionInPorgressAnimation.groupIndex == groupIndex)
677                                                         && (positionInPorgressAnimation.itemIndex == itemIndex))
678                                                 {
679                                                         isCreaetInProgressAnimation = true;
680                                                         itemInPorgressAnimationRect = Rectangle(X_IN_PROGRESS_ANIMATION, Y_IN_PROGRESS_ANIMATION
681                                                                                                                                 , W_IN_PROGRESS_ANIMATION, H_IN_PROGRESS_ANIMATION);
682
683                                                         itemTextTwoLine = ResourceManager::GetString(L"IDS_WIFI_BODY_CONNECTING_ING");
684                                                 }
685                                         }
686                                         else
687                                         {
688                                                 itemTextTwoLine = ResourceManager::GetString(L"IDS_ST_BODY_TAP_TO_CONNECT_ABB");
689                                         }
690
691                                         isCreateIcon = true;
692                                         isTwoLineItemText = true;
693
694                                         ItemTypeIconAndTwoLine(itemIconRect, itemRectangle, itemRectSecondLabel, fontSize);
695                                         itemHeight = (itemRectangle.height + itemRectSecondLabel.height);
696                                         pBitmap = ResourceManager::GetBitmapN(IDB_ABOUT_PHONE);
697                                 }
698                         }
699                 }
700                 break;
701
702         case WIFI_DIRECT_GROUP_MULTI_CONNECT_ITEM:
703                 {
704                         int localDeviceMemberType = GetLocalDeviceMemberType();
705                         int localDeviceLastEvent = __pWifiDirectManagerInstance->GetLastEventToPerform();
706
707                         if (localDeviceMemberType != WIFI_DIRECT_GROUP_MEMBER_TYPE_NONE)
708                         {
709                                 int connectedDeviceCount = __pWifiDirectManagerInstance->GetGroupMemberInfoListCount();
710                                 if (connectedDeviceCount > ID_WIFIDIRECT_COUNT_DEFAULT)
711                                 {
712                                         itemText = ResourceManager::GetString(L"IDS_WIFI_BUTTON_DISCONNECT_ALL");
713                                         buttonActionId = IDA_WIFI_DIRECT_DISCONNECT_ALL;
714                                 }
715                                 else
716                                 {
717                                         itemText = ResourceManager::GetString(L"IDS_WIFI_SK_DISCONNECT");
718                                         buttonActionId = IDA_WIFI_DIRECT_DISCONNECT;
719                                 }
720                         }
721                         else if ((localDeviceLastEvent == WIFI_DIRECT_MANAGER_EVENT_ASSOCIATING)
722                                         || (localDeviceLastEvent == WIFI_DIRECT_MANAGER_EVENT_GROUP_CREATING))
723                         {
724                                 itemText = ResourceManager::GetString(L"IDS_WIFI_SK2_CANCEL_CONNECTION");
725                                 buttonActionId = IDA_WIFI_DIRECT_CANCEL_CONNECT;
726                         }
727                         else
728                         {
729                                 itemText = ResourceManager::GetString(L"IDS_WIFI_BUTTON_MULTI_CONNECT");
730                                 buttonActionId = IDA_WIFI_DIRECT_MULTI_CONNECT;
731                         }
732
733                         itemHeight = H_GROUP_ITEM_DEFAULT_BUTTON;
734
735                         itemRectangle = Rectangle(X_GROUP_DEFAULT, Y_GROUP_DEFAULT
736                                                                         , W_WIFI_DIRECT_MULTI_CONNECT_ITEM, H_GROUP_ITEM_DEFAULT_BUTTON);
737
738                         isCreateButtonControl = true;
739                 }
740                 break;
741
742         case WIFI_DIRECT_GROUP_BUSY_DEVICES_ITEM:
743                 {
744                         WifiDirectDeviceInfo* pBusyDevice = __pWifiDirectManagerInstance->GetBusyDeviceListInfoAt(itemIndex);
745                         if (pBusyDevice != null)
746                         {
747                                 itemText = pBusyDevice->GetDeviceName();
748                                 pBitmap = ResourceManager::GetBitmapN(IDB_ABOUT_PHONE);
749                         }
750                         else
751                         {
752                                 delete pItem;
753                                 return null;
754                         }
755
756                         isTwoLineItemText = true;
757                         isCreateIcon = true;
758
759                         itemHeight = H_GROUP_ITEM_TWO_LINE_DEFAULT;
760                         ItemTypeIconAndTwoLine(itemIconRect, itemRectangle, itemRectSecondLabel, fontSize);
761                         itemHeight = (itemRectangle.height + itemRectSecondLabel.height);
762                 }
763                 break;
764
765         case WIFI_DIRECT_GROUP_ABOUT_WIFIDIRECT_ITEM:
766                 {
767                         itemText = ResourceManager::GetString(L"IDS_WIFI_BODY_ABOUT_WI_FI_DIRECT_ABB");
768                 }
769                 break;
770
771         default:
772                 {
773                         delete pItem;
774                         return null;
775                 }
776                 break;
777         }
778
779         RelativeLayout relativeLayout;
780         relativeLayout.Construct();
781
782         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
783         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
784
785         if (isCreateButtonControl)
786         {
787                 Button* pButton = new (std::nothrow) Button();
788                 pButton->Construct(itemRectangle, itemText);
789                 pButton->SetActionId(buttonActionId);
790                 pButton->AddActionEventListener(*this);
791
792                 pItem->AddControl(pButton);
793         }
794         else
795         {
796                 if (isCreateIcon)
797                 {
798                         pLabel = new (std::nothrow) Label();
799                         pLabel->Construct(itemIconRect, L"");
800                         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
801                         pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
802                         pLabel->SetBackgroundBitmap(*pBitmap);
803
804                         pItem->AddControl(pLabel);
805
806                         delete pBitmap;
807                 }
808
809                 pLabel = new (std::nothrow) Label();
810                 pLabel->Construct(itemRectangle, itemText);
811                 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
812                 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
813                 pLabel->SetTextColor(COLOR_MAIN_TEXT);
814
815                 pItem->AddControl(pLabel);
816                 relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
817                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
818                 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
819
820                 if (isTwoLineItemText)
821                 {
822                         pSecondLabel = new (std::nothrow) Label();
823                         pSecondLabel->Construct(itemRectSecondLabel, itemTextTwoLine);
824                         pSecondLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
825                         pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
826                         pSecondLabel->SetTextColor(COLOR_SUB_TEXT);
827
828                         pItem->AddControl(pSecondLabel);
829                         relativeLayout.SetMargin(*pLabel, itemRectSecondLabel.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
830                         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
831                         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
832                 }
833
834                 if (isCreaetInProgressAnimation)
835                 {
836                         Animation* pAnimation = new (std::nothrow) Animation();
837                         if (pAnimation->Construct(itemInPorgressAnimationRect, *__pAnimationFrameList) == E_SUCCESS)
838                         {
839                                 pAnimation->SetRepeatCount(WIFI_DIRECT_DEFAULT_COUNT);
840
841                                 pItem->AddControl(pAnimation);
842
843                                 SetHandlerInProgressAnimation(pAnimation);
844                                 pAnimation = null;
845                         }
846                 }
847         }
848
849         if (__groupIndex[groupIndex] == WIFI_DIRECT_GROUP_ABOUT_WIFIDIRECT_ITEM)
850         {
851                 PlayInPorgressAnimation();
852         }
853
854         return pItem;
855 }
856
857 bool
858 WifiDirectForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
859 {
860         delete pItem;
861         pItem = null;   
862
863         return true;
864 }
865
866 bool
867 WifiDirectForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
868 {
869         TableViewIndex positionInProgressAnimation = GetPositionInProgressAnimation();
870         if ((positionInProgressAnimation.groupIndex == groupIndex)
871                 && (positionInProgressAnimation.itemIndex == itemIndex))
872         {
873                 StopInPorgressAnimation();
874                 RemoveHandlerInProgressAnimation(groupIndex, itemIndex);
875         }
876
877         delete pItem;
878         pItem = null;
879
880         return true;
881 }
882
883 void
884 WifiDirectForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
885 {
886         result returnResult = E_SUCCESS;
887         SceneManager* pSceneManager = SceneManager::GetInstance();
888         AppAssert(pSceneManager);
889
890         if (__pWifiDirectManagerInstance == null)
891         {
892                 return;
893         }
894         __pWifiDirectManagerInstance->CancelRemoteDeviceScan();
895
896         switch (__groupIndex[groupIndex])
897         {
898         case WIFI_DIRECT_GROUP_TURN_ON_OFF_CONTROL_ITEM:
899                 {
900                         if (status == TABLE_VIEW_ITEM_STATUS_SELECTED)
901                         {
902                                 if (tableView.IsItemChecked(groupIndex, itemIndex) == true)
903                                 {
904                                         tableView.SetItemChecked(groupIndex, itemIndex, false);
905                                         status = TABLE_VIEW_ITEM_STATUS_UNCHECKED;
906                                 }
907                                 else
908                                 {
909                                         tableView.SetItemChecked(groupIndex, itemIndex, true);
910                                         status = TABLE_VIEW_ITEM_STATUS_CHECKED;
911                                 }
912                         }
913
914                         if (status == TABLE_VIEW_ITEM_STATUS_CHECKED)
915                         {
916                                 returnResult = __pWifiDirectManagerInstance->Activate();
917                                 if (!IsFailed(returnResult))
918                                 {
919                                         DisableScanFooter();
920                                         ModifyTableViewItem(groupIndex, itemIndex);
921                                 }
922                         }
923                         else
924                         {
925                                 returnResult = __pWifiDirectManagerInstance->Deactivate();
926                                 if (!IsFailed(returnResult))
927                                 {
928                                         DisableScanFooter();
929                                         ModifyTableViewItem(groupIndex, itemIndex);
930                                 }
931                         }
932                 }
933                 break;
934
935         case WIFI_DIRECT_GROUP_AVAILABLE_DEVICES_ITEM:
936                 {
937                         WifiDirectDeviceInfo* pRemoteDeviceInfo = __pWifiDirectManagerInstance->GetScanDeviceListInfoAt(itemIndex);
938                         if (pRemoteDeviceInfo == null)
939                         {
940                                 returnResult = GetLastResult();
941                         }
942                         else
943                         {
944                                 returnResult = __pWifiDirectManagerInstance->ConnectTo(*pRemoteDeviceInfo);
945                                 if (!IsFailed(returnResult))
946                                 {
947                                         DisableScanFooter();
948                                         SetPositionInProgressAnimation(groupIndex, itemIndex);
949
950 #ifdef WIFI_DIRECT_BUG_REPORT
951                                         AppLogDebug("WIFI_DIRECT_BUG_REPORT[Call RefreshItem method, operate createitem before delete item");
952                                         UpdateTableView();
953 #else
954                                         ModifyTableViewItem(itemTag.groupIndex, itemTag.itemIndex);
955                                         int groupIndex = GetGroupItemToIndex(WIFI_DIRECT_GROUP_MULTI_CONNECT_ITEM);
956                                         ModifyTableViewItem(groupIndex, 0);
957 #endif
958                                 }
959                         }
960                 }
961                 break;
962
963         case WIFI_DIRECT_GROUP_ABOUT_WIFIDIRECT_ITEM:
964                 {
965                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WIFI_DIRECT_ABOUT, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
966                 }
967                 break;
968
969         default:
970                 break;
971         }
972
973 #ifdef WIFI_DIRECT_DEBUG_CODE
974         if (IsFailed(returnResult))
975         {
976                 String resultError = GetErrorMessage(returnResult);
977                 ShowMessageBox(L"WIFI_DIRECT_DEBUG_CODE", resultError);
978         }
979 #endif
980 }
981
982 void
983 WifiDirectForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
984 {
985         result returnResult = E_SUCCESS;
986
987         if (__pWifiDirectManagerInstance == null)
988         {
989                 return;
990         }
991
992         switch (actionId)
993         {
994         case IDA_WIFI_DIRECT_FOOTER_SCAN:
995                 {
996                         DisableScanFooter();
997                         returnResult = __pWifiDirectManagerInstance->RemoteDeviceScan();
998
999                         if (!IsFailed(returnResult))
1000                         {
1001                                 SetFooterText(IDA_WIFI_DIRECT_FOOTER_CANCEL, ResourceManager::GetString(L"IDS_COM_BODY_STOP"));
1002                                 ReAdjustGroupItemToIndex(true);
1003                                 UpdateTableView();
1004                         }
1005                         else
1006                         {
1007                                 __pWifiDirectManagerInstance->Deactivate();
1008                         }
1009                         EnableScanFooter();
1010                 }
1011                 break;
1012
1013         case IDA_WIFI_DIRECT_FOOTER_CANCEL:
1014                 {
1015                         DisableScanFooter();
1016                         returnResult = __pWifiDirectManagerInstance->CancelRemoteDeviceScan();
1017                         EnableScanFooter();
1018                 }
1019                 break;
1020
1021         case IDA_WIFI_DIRECT_DISCONNECT:
1022                 {
1023                         returnResult = __pWifiDirectManagerInstance->DisconnectAll();
1024                 }
1025                 break;
1026
1027         case IDA_WIFI_DIRECT_CANCEL_CONNECT:
1028                 {
1029                         returnResult = __pWifiDirectManagerInstance->CancelConnect();
1030                 }
1031                 break;
1032
1033         case IDA_WIFI_DIRECT_MULTI_CONNECT:
1034                 {
1035                         SceneManager* pSceneManager = SceneManager::GetInstance();
1036                         AppAssert(pSceneManager);
1037
1038                         pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WIFI_DIRECT_CONNECTION, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
1039                 }
1040                 break;
1041
1042         case IDA_WIFI_DIRECT_DISCONNECT_ALL:
1043                 {
1044                         returnResult = __pWifiDirectManagerInstance->DisconnectAll();
1045                 }
1046                 break;
1047
1048         default:
1049                 break;
1050         }
1051
1052 #ifdef WIFI_DIRECT_DEBUG_CODE
1053         if (IsFailed(returnResult))
1054         {
1055                 String resultError = GetErrorMessage(returnResult);
1056                 ShowMessageBox(L"WIFI_DIRECT_DEBUG_CODE", resultError);
1057         }
1058 #endif
1059 }
1060
1061 result
1062 WifiDirectForm::InitWifiDirectManagerInstance(void)
1063 {
1064         __pWifiDirectManagerInstance = WifiDirectManager::GetInstance();
1065         if (__pWifiDirectManagerInstance == null)
1066         {
1067                 return E_FAILURE;
1068         }
1069
1070         __pWifiDirectManagerInstance->RemoveIWifiDirectManagerEventListener();
1071         __pWifiDirectManagerInstance->SetIWifiDirectManagerEventListener(*this);
1072
1073         if (__pWifiDirectManagerInstance->IsActivated() == true)
1074         {
1075                 EnableScanFooter();
1076         }
1077
1078         return E_SUCCESS;
1079 }
1080
1081 void
1082 WifiDirectForm::CreateInPorgressAnimationFrame(void)
1083 {
1084         int count = 0;
1085         long duration = DURATION / FRAME_COUNT;
1086
1087         Bitmap* pBitmap = null;
1088         AnimationFrame* pAniFrame = null;
1089
1090         __pAnimationFrameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1091         __pAnimationFrameList->Construct();
1092
1093         for (count = 0; count < FRAME_COUNT; count++)
1094         {
1095                 String searchIconFilePath;
1096                 searchIconFilePath.Format(searchIconFilePath.GetLength(), IDB_SEARCH_ICON_SIZE_LAGER_IMAGE_PATH_FORMAT, count);
1097                 pBitmap = ResourceManager::GetBitmapN(searchIconFilePath);
1098                 if (pBitmap == null)
1099                 {
1100                         AppLogDebug("GetBitmapN fail");
1101                         continue;
1102                 }
1103                 pAniFrame = new (std::nothrow) AnimationFrame(*pBitmap, duration);
1104                 __pAnimationFrameList->Add(*pAniFrame);
1105                 delete pBitmap;
1106         }
1107 }
1108
1109 void
1110 WifiDirectForm::DestoryInPorgressAnimationFrame(void)
1111 {
1112         if (__pAnimationFrameList != null)
1113         {
1114                 delete __pAnimationFrameList;
1115                 __pAnimationFrameList = null;
1116         }
1117 }
1118
1119 void
1120 WifiDirectForm::SetHandlerInProgressAnimation(Tizen::Ui::Controls::Animation* pAnimation)
1121 {
1122         if ((pAnimation != null)
1123                 && (__pAnimation == null )
1124                 && (__positionInProgressAnimation.groupIndex != ID_WIFI_DIRECT_IN_PROGRESS_ANIMATION_DEFAULT)
1125                 && (__positionInProgressAnimation.itemIndex != ID_WIFI_DIRECT_IN_PROGRESS_ANIMATION_DEFAULT))
1126         {
1127                 __pAnimation = pAnimation;
1128                 __pAnimation->AddAnimationEventListener(*this);
1129         }
1130 }
1131
1132 void
1133 WifiDirectForm::PlayInPorgressAnimation(void)
1134 {
1135         if (__pAnimation != null)
1136         {
1137                 __pAnimation->SetRepeatCount(ID_WIFI_DIRECT_IN_PROGRESS_REPEAT_COUNT);
1138                 __pAnimation->SetShowState(true);
1139                 __pAnimation->Play();
1140         }
1141 }
1142
1143 void
1144 WifiDirectForm::StopInPorgressAnimation(void)
1145 {
1146         if (__pAnimation != null)
1147         {
1148                 __pAnimation->Stop();
1149                 __pAnimation->SetShowState(false);
1150         }
1151 }
1152
1153 TableViewIndex
1154 WifiDirectForm::GetPositionInProgressAnimation(void)
1155 {
1156         return __positionInProgressAnimation;
1157 }
1158
1159 void
1160 WifiDirectForm::SetPositionInProgressAnimation(int groupIndex, int itemIndex)
1161 {
1162         if (__pAnimation == null)
1163         {
1164                 __positionInProgressAnimation.groupIndex = groupIndex;
1165                 __positionInProgressAnimation.itemIndex = itemIndex;
1166         }
1167 }
1168
1169 void
1170 WifiDirectForm::RemoveHandlerInProgressAnimation(int groupIndex, int itemIndex)
1171 {
1172         if ((__positionInProgressAnimation.groupIndex == groupIndex)
1173                 && (__positionInProgressAnimation.itemIndex == itemIndex)
1174                 && (__pAnimation != null))
1175         {
1176                 __positionInProgressAnimation.groupIndex = ID_WIFI_DIRECT_IN_PROGRESS_ANIMATION_DEFAULT;
1177                 __positionInProgressAnimation.itemIndex = ID_WIFI_DIRECT_IN_PROGRESS_ANIMATION_DEFAULT;
1178                 __pAnimation = null;
1179         }
1180 }
1181
1182 void
1183 WifiDirectForm::TableViewItemInit(void)
1184 {
1185         __groupItemCount[WIFI_DIRECT_GROUP_INDEX_0] = ID_WIFIDIRECT_COUNT_DEFAULT;
1186         __groupItemCount[WIFI_DIRECT_GROUP_INDEX_1] = 0;
1187         __groupItemCount[WIFI_DIRECT_GROUP_INDEX_2] = 0;
1188         __groupItemCount[WIFI_DIRECT_GROUP_INDEX_3] = 0;
1189         __groupItemCount[WIFI_DIRECT_GROUP_INDEX_4] = ID_WIFIDIRECT_COUNT_DEFAULT;
1190 }
1191
1192 void
1193 WifiDirectForm::ModifyTableViewItem(int groupIndex, int itemIndex)
1194 {
1195         if (__pTableView == null)
1196         {
1197                 AppLogDebug("__pTableView is null");
1198                 return;
1199         }
1200
1201         __pTableView->RefreshItem(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1202 }
1203
1204 void
1205 WifiDirectForm::ShowMessageBox(const Tizen::Base::String& title, const Tizen::Base::String& text)
1206 {
1207         MessageBox messageBox;
1208         int result = E_SUCCESS;
1209
1210         messageBox.Construct(title, text, MSGBOX_STYLE_NONE, MESSAGEBOX_DISPLAY_TIME_2_SEC);
1211         messageBox.ShowAndWait(result);
1212 }
1213
1214 Tizen::Base::String
1215 WifiDirectForm::GetLocalDeviceName(void)
1216 {
1217         return __localDeviceName;
1218 }
1219
1220 void
1221 WifiDirectForm::SetLocalDeviceName(void)
1222 {
1223         if (__pWifiDirectManagerInstance == null)
1224         {
1225                 AppLogDebug("__pWifiDirectManagerInstance is null");
1226                 return;
1227         }
1228
1229         __localDeviceName = __pWifiDirectManagerInstance->GetLocalDeviceName();
1230 }
1231
1232 void
1233 WifiDirectForm::SetLocalDeviceMemberType(void)
1234 {
1235         if (__pWifiDirectManagerInstance == null)
1236         {
1237                 AppLogDebug("__pWifiDirectManagerInstance is null");
1238                 return;
1239         }
1240
1241         __localDeviceMemberType = __pWifiDirectManagerInstance->GetLocalDeviceGroupMemberType();
1242 }
1243
1244 Tizen::Net::Wifi::WifiDirectGroupMemberType
1245 WifiDirectForm::GetLocalDeviceMemberType(void)
1246 {
1247         return __localDeviceMemberType;
1248 }
1249
1250 void
1251 WifiDirectForm::ReAdjustGroupItemToIndex(bool insertDefaultItemIngroupIndexAvailable)
1252 {
1253         if ((__pWifiDirectManagerInstance == null)
1254                 || (__pTableView == null))
1255         {
1256                 AppLogDebug("__pWifiDirectManagerInstance or __pTableView is null");
1257                 return;
1258         }
1259
1260         int itemCount = 0;
1261         int groupIndex = 0;
1262
1263         __groupItemCount[groupIndex] = ID_WIFIDIRECT_COUNT_DEFAULT;
1264         __groupIndex[groupIndex] = WIFI_DIRECT_GROUP_TURN_ON_OFF_CONTROL_ITEM;
1265         groupIndex = groupIndex + ID_WIFIDIRECT_COUNT_DEFAULT;
1266
1267         itemCount = __pWifiDirectManagerInstance->GetGroupMemberInfoListCount();
1268         if (itemCount != 0)
1269         {
1270                 __groupItemCount[groupIndex] = itemCount;
1271                 __groupIndex[groupIndex] = WIFI_DIRECT_GROUP_CONNECTED_DEVICES_ITEM;
1272                 groupIndex = groupIndex + ID_WIFIDIRECT_COUNT_DEFAULT;
1273         }
1274
1275         itemCount = __pWifiDirectManagerInstance->GetScanDeviceListInfoCount();
1276         if (itemCount != 0)
1277         {
1278                 __groupItemCount[groupIndex] = itemCount;
1279                 __groupIndex[groupIndex] = WIFI_DIRECT_GROUP_AVAILABLE_DEVICES_ITEM;
1280                 groupIndex = groupIndex + ID_WIFIDIRECT_COUNT_DEFAULT;
1281         }
1282         else if (insertDefaultItemIngroupIndexAvailable)
1283         {
1284                 __groupItemCount[groupIndex] = ID_WIFIDIRECT_COUNT_DEFAULT;
1285                 __groupIndex[groupIndex] = WIFI_DIRECT_GROUP_AVAILABLE_DEVICES_ITEM;
1286                 groupIndex = groupIndex + ID_WIFIDIRECT_COUNT_DEFAULT;
1287         }
1288
1289         itemCount = __pWifiDirectManagerInstance->GetBusyDeviceListInfoCount();
1290         if (itemCount != 0)
1291         {
1292                 __groupItemCount[groupIndex] = itemCount;
1293                 __groupIndex[groupIndex] = WIFI_DIRECT_GROUP_BUSY_DEVICES_ITEM;
1294                 groupIndex = groupIndex + ID_WIFIDIRECT_COUNT_DEFAULT;
1295         }
1296
1297         if ((__pWifiDirectManagerInstance->GetGroupMemberInfoListCount() != 0)
1298                 || (__pWifiDirectManagerInstance->GetScanDeviceListInfoCount() > ID_WIFIDIRECT_COUNT_DEFAULT))
1299         {
1300                 __groupItemCount[groupIndex] = ID_WIFIDIRECT_COUNT_DEFAULT;
1301                 __groupIndex[groupIndex] = WIFI_DIRECT_GROUP_MULTI_CONNECT_ITEM;
1302                 groupIndex = groupIndex + ID_WIFIDIRECT_COUNT_DEFAULT;
1303                 SetLocalDeviceMemberType();
1304         }
1305
1306         __groupItemCount[groupIndex] = ID_WIFIDIRECT_COUNT_DEFAULT;
1307         __groupIndex[groupIndex] = WIFI_DIRECT_GROUP_ABOUT_WIFIDIRECT_ITEM;
1308         groupIndex = groupIndex + ID_WIFIDIRECT_COUNT_DEFAULT;
1309
1310         __groupIndex[GROUP_TOTAL_COUNT] = groupIndex;
1311 }
1312
1313 int
1314 WifiDirectForm::GetGroupItemToIndex(int groupItem)
1315 {
1316         for (int loopCount = 0; loopCount < __groupIndex[GROUP_TOTAL_COUNT]; loopCount++)
1317         {
1318                 if (__groupIndex[loopCount] == groupItem)
1319                 {
1320                         return loopCount;
1321                 }
1322         }
1323         AppLogDebug("GroupItem not found");
1324         return 0;
1325 }
1326
1327 void
1328 WifiDirectForm::UpdateTableView(void)
1329 {
1330         if (__pTableView == null)
1331         {
1332                 AppLogDebug("__pTableView is null");
1333                 return;
1334         }
1335         __pTableView->UpdateTableView();
1336 }
1337
1338 int
1339 WifiDirectForm::GetDefaultGroupItemHeight(void)
1340 {
1341         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1342 }
1343
1344 int
1345 WifiDirectForm::GetDefaultItemHeight(void)
1346 {
1347         return H_GROUP_ITEM_DEFAULT;
1348 }
1349
1350 void
1351 WifiDirectForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1352 {
1353 }
1354
1355 void
1356 WifiDirectForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1357 {
1358 }
1359
1360 void
1361 WifiDirectForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1362 {
1363 }
1364
1365 void
1366 WifiDirectForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1367 {
1368 }