2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "GUIDialogAccessPoints.h"
22 #include "guilib/GUIKeyboardFactory.h"
24 #include "linux/NetworkLinux.h"
26 #include "Application.h"
28 #include "guilib/Key.h"
29 #include "guilib/LocalizeStrings.h"
31 #define CONTROL_ACCESS_POINTS 3
33 CGUIDialogAccessPoints::CGUIDialogAccessPoints(void)
34 : CGUIDialog(WINDOW_DIALOG_ACCESS_POINTS, "DialogAccessPoints.xml")
36 m_accessPoints = new CFileItemList;
39 CGUIDialogAccessPoints::~CGUIDialogAccessPoints(void)
41 delete m_accessPoints;
44 bool CGUIDialogAccessPoints::OnAction(const CAction &action)
46 if (action.GetID() == ACTION_SELECT_ITEM)
48 CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_ACCESS_POINTS);
50 int iItem = msg.GetParam1();
52 if (iItem == (int) m_aps.size())
54 m_selectedAPEssId = "";
55 if (CGUIKeyboardFactory::ShowAndGetInput(m_selectedAPEssId, g_localizeStrings.Get(789), false))
57 m_selectedAPEncMode = m_aps[iItem].getEncryptionMode();
58 m_wasItemSelected = true;
65 m_selectedAPEssId = m_aps[iItem].getEssId();
66 m_selectedAPEncMode = m_aps[iItem].getEncryptionMode();
67 m_wasItemSelected = true;
73 return CGUIDialog::OnAction(action);
76 void CGUIDialogAccessPoints::OnInitWindow()
78 m_wasItemSelected = false;
80 CGUIDialog::OnInitWindow();
82 CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_ACCESS_POINTS);
85 m_accessPoints->Clear();
87 CStdString ifaceName(m_interfaceName);
88 CNetworkInterface* iface = g_application.getNetwork().GetInterfaceByName(ifaceName);
89 m_aps = iface->GetAccessPoints();
91 for (int i = 0; i < (int) m_aps.size(); i++)
93 CFileItemPtr item(new CFileItem(m_aps[i].getEssId()));
95 int q = m_aps[i].getQuality();
96 if (q <= 20) item->SetArt("thumb", "ap-signal1.png");
97 else if (q <= 40) item->SetArt("thumb", "ap-signal2.png");
98 else if (q <= 60) item->SetArt("thumb", "ap-signal3.png");
99 else if (q <= 80) item->SetArt("thumb", "ap-signal4.png");
100 else if (q <= 100) item->SetArt("thumb", "ap-signal5.png");
102 if (m_aps[i].getEncryptionMode() != ENC_NONE)
103 item->SetIconImage("ap-lock.png");
105 m_accessPoints->Add(item);
108 CFileItemPtr item(new CFileItem(g_localizeStrings.Get(1047)));
109 m_accessPoints->Add(item);
111 CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_ACCESS_POINTS, 0, 0, m_accessPoints);
115 void CGUIDialogAccessPoints::SetInterfaceName(CStdString interfaceName)
117 m_interfaceName = interfaceName;
120 CStdString CGUIDialogAccessPoints::GetSelectedAccessPointEssId()
122 return m_selectedAPEssId;
125 EncMode CGUIDialogAccessPoints::GetSelectedAccessPointEncMode()
127 return m_selectedAPEncMode;
130 bool CGUIDialogAccessPoints::WasItemSelected()
132 return m_wasItemSelected;