mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 13:46:49 +00:00
xbmc-dharma: remove unneeded patches
Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
parent
bc81f450df
commit
f74de9951e
@ -1 +0,0 @@
|
|||||||
http://trac.xbmc.org/ticket/7248
|
|
@ -1,91 +0,0 @@
|
|||||||
diff -Naur xbmc-dharma-35100/xbmc/utils/Variant.cpp xbmc-dharma-35100.patch/xbmc/utils/Variant.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/utils/Variant.cpp 2010-10-30 05:38:22.000000000 +0200
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/utils/Variant.cpp 2010-11-01 21:11:23.929841377 +0100
|
|
||||||
@@ -19,7 +19,6 @@
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include "Variant.h"
|
|
||||||
-#include "PlatformDefs.h"
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
@@ -182,6 +181,14 @@
|
|
||||||
return ConstNullVariant;
|
|
||||||
}
|
|
||||||
|
|
||||||
+const CVariant &CVariant::operator[](std::string key) const
|
|
||||||
+{
|
|
||||||
+ if (isObject())
|
|
||||||
+ return (*m_data.map)[key];
|
|
||||||
+ else
|
|
||||||
+ return ConstNullVariant;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
CVariant &CVariant::operator[](unsigned int position)
|
|
||||||
{
|
|
||||||
if (isArray() && size() > position)
|
|
||||||
@@ -190,6 +197,14 @@
|
|
||||||
return ConstNullVariant;
|
|
||||||
}
|
|
||||||
|
|
||||||
+const CVariant &CVariant::operator[](unsigned int position) const
|
|
||||||
+{
|
|
||||||
+ if (isArray() && size() > position)
|
|
||||||
+ return (*m_data.array)[position];
|
|
||||||
+ else
|
|
||||||
+ return ConstNullVariant;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
CVariant &CVariant::operator=(const CVariant &rhs)
|
|
||||||
{
|
|
||||||
if (m_type == VariantTypeConstNull)
|
|
||||||
@@ -289,21 +304,21 @@
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
-void CVariant::debug()
|
|
||||||
+void CVariant::debug() const
|
|
||||||
{
|
|
||||||
internaldebug();
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
-void CVariant::internaldebug()
|
|
||||||
+void CVariant::internaldebug() const
|
|
||||||
{
|
|
||||||
switch (m_type)
|
|
||||||
{
|
|
||||||
case VariantTypeInteger:
|
|
||||||
- printf("int: %"PRIu64"", m_data.integer);
|
|
||||||
+ printf("int: %lld", (long long int)m_data.integer);
|
|
||||||
break;
|
|
||||||
case VariantTypeUnsignedInteger:
|
|
||||||
- printf("uint: %"PRIu64"", m_data.unsignedinteger);
|
|
||||||
+ printf("uint: %lld", (long long int)m_data.unsignedinteger);
|
|
||||||
break;
|
|
||||||
case VariantTypeBoolean:
|
|
||||||
printf("bool: %s", m_data.boolean ? "true" : "false");
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/utils/Variant.h xbmc-dharma-35100.patch/xbmc/utils/Variant.h
|
|
||||||
--- xbmc-dharma-35100/xbmc/utils/Variant.h 2010-10-30 05:38:21.000000000 +0200
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/utils/Variant.h 2010-11-01 21:11:23.929841377 +0100
|
|
||||||
@@ -64,7 +64,9 @@
|
|
||||||
const char *asString(const char *fallback = "") const;
|
|
||||||
|
|
||||||
CVariant &operator[](std::string key);
|
|
||||||
+ const CVariant &operator[](std::string key) const;
|
|
||||||
CVariant &operator[](unsigned int position);
|
|
||||||
+ const CVariant &operator[](unsigned int position) const;
|
|
||||||
|
|
||||||
CVariant &operator=(const CVariant &rhs);
|
|
||||||
|
|
||||||
@@ -76,8 +78,8 @@
|
|
||||||
void erase(std::string key);
|
|
||||||
void erase(unsigned int position);
|
|
||||||
|
|
||||||
- void debug();
|
|
||||||
- void internaldebug();
|
|
||||||
+ void debug() const;
|
|
||||||
+ void internaldebug() const;
|
|
||||||
private:
|
|
||||||
VariantType m_type;
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,539 +0,0 @@
|
|||||||
diff -Naur xbmc-dharma-35100/addons/skin.confluence/720p/DialogAccessPoints.xml xbmc-dharma-35100.patch/addons/skin.confluence/720p/DialogAccessPoints.xml
|
|
||||||
diff -Naur xbmc-dharma-35100/addons/skin.confluence/720p/DialogConnections.xml xbmc-dharma-35100.patch/addons/skin.confluence/720p/DialogConnections.xml
|
|
||||||
diff -Naur xbmc-dharma-35100/guilib/Key.h xbmc-dharma-35100.patch/guilib/Key.h
|
|
||||||
--- xbmc-dharma-35100/guilib/Key.h 2010-10-30 05:36:40.000000000 +0200
|
|
||||||
+++ xbmc-dharma-35100.patch/guilib/Key.h 2010-11-01 21:23:48.525628797 +0100
|
|
||||||
@@ -355,7 +355,7 @@
|
|
||||||
#define WINDOW_DIALOG_BUSY 10138
|
|
||||||
#define WINDOW_DIALOG_PICTURE_INFO 10139
|
|
||||||
#define WINDOW_DIALOG_ADDON_SETTINGS 10140
|
|
||||||
-#define WINDOW_DIALOG_ACCESS_POINTS 10141
|
|
||||||
+#define WINDOW_DIALOG_CONNECTIONS 10141
|
|
||||||
#define WINDOW_DIALOG_FULLSCREEN_INFO 10142
|
|
||||||
#define WINDOW_DIALOG_KARAOKE_SONGSELECT 10143
|
|
||||||
#define WINDOW_DIALOG_KARAOKE_SELECTOR 10144
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/Application.cpp xbmc-dharma-35100.patch/xbmc/Application.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/Application.cpp 2010-11-01 21:23:31.934434454 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/Application.cpp 2010-11-01 21:23:48.530628857 +0100
|
|
||||||
@@ -212,7 +212,7 @@
|
|
||||||
#include "GUIDialogPictureInfo.h"
|
|
||||||
#include "GUIDialogAddonSettings.h"
|
|
||||||
#include "GUIDialogAddonInfo.h"
|
|
||||||
-#include "GUIDialogAccessPoints.h"
|
|
||||||
+#include "GUIDialogConnections.h"
|
|
||||||
#include "GUIDialogFullScreenInfo.h"
|
|
||||||
#include "GUIDialogTeletext.h"
|
|
||||||
#include "GUIDialogSlider.h"
|
|
||||||
@@ -1055,7 +1055,7 @@
|
|
||||||
g_windowManager.Add(new CGUIDialogPictureInfo); // window id = 139
|
|
||||||
g_windowManager.Add(new CGUIDialogAddonInfo);
|
|
||||||
g_windowManager.Add(new CGUIDialogAddonSettings); // window id = 140
|
|
||||||
- g_windowManager.Add(new CGUIDialogAccessPoints); // window id = 141
|
|
||||||
+ g_windowManager.Add(new CGUIDialogConnections); // window id = 141
|
|
||||||
|
|
||||||
g_windowManager.Add(new CGUIDialogLockSettings); // window id = 131
|
|
||||||
|
|
||||||
@@ -3138,7 +3138,7 @@
|
|
||||||
g_windowManager.Delete(WINDOW_DIALOG_PICTURE_INFO);
|
|
||||||
g_windowManager.Delete(WINDOW_DIALOG_ADDON_INFO);
|
|
||||||
g_windowManager.Delete(WINDOW_DIALOG_ADDON_SETTINGS);
|
|
||||||
- g_windowManager.Delete(WINDOW_DIALOG_ACCESS_POINTS);
|
|
||||||
+ g_windowManager.Delete(WINDOW_DIALOG_CONNECTIONS);
|
|
||||||
g_windowManager.Delete(WINDOW_DIALOG_SLIDER);
|
|
||||||
|
|
||||||
g_windowManager.Delete(WINDOW_DIALOG_OSD_TELETEXT);
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/ButtonTranslator.cpp xbmc-dharma-35100.patch/xbmc/ButtonTranslator.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/ButtonTranslator.cpp 2010-10-30 05:36:51.000000000 +0200
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/ButtonTranslator.cpp 2010-11-01 21:23:48.533628890 +0100
|
|
||||||
@@ -255,7 +255,7 @@
|
|
||||||
{"smartplaylistrule" , WINDOW_DIALOG_SMART_PLAYLIST_RULE},
|
|
||||||
{"busydialog" , WINDOW_DIALOG_BUSY},
|
|
||||||
{"pictureinfo" , WINDOW_DIALOG_PICTURE_INFO},
|
|
||||||
- {"accesspoints" , WINDOW_DIALOG_ACCESS_POINTS},
|
|
||||||
+ {"connections" , WINDOW_DIALOG_CONNECTIONS},
|
|
||||||
{"fullscreeninfo" , WINDOW_DIALOG_FULLSCREEN_INFO},
|
|
||||||
{"karaokeselector" , WINDOW_DIALOG_KARAOKE_SONGSELECT},
|
|
||||||
{"karaokelargeselector" , WINDOW_DIALOG_KARAOKE_SELECTOR},
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/GUIDialogAccessPoints.cpp xbmc-dharma-35100.patch/xbmc/GUIDialogAccessPoints.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/GUIDialogAccessPoints.cpp 2010-11-01 21:23:31.950434640 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/GUIDialogAccessPoints.cpp 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
@@ -1,163 +0,0 @@
|
|
||||||
-/*
|
|
||||||
- * Copyright (C) 2005-2008 Team XBMC
|
|
||||||
- * http://www.xbmc.org
|
|
||||||
- *
|
|
||||||
- * This Program is free software; you can redistribute it and/or modify
|
|
||||||
- * it under the terms of the GNU General Public License as published by
|
|
||||||
- * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
- * any later version.
|
|
||||||
- *
|
|
||||||
- * This Program is distributed in the hope that it will be useful,
|
|
||||||
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
- * GNU General Public License for more details.
|
|
||||||
- *
|
|
||||||
- * You should have received a copy of the GNU General Public License
|
|
||||||
- * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
- * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
- *
|
|
||||||
- */
|
|
||||||
-
|
|
||||||
-#include "GUIDialogAccessPoints.h"
|
|
||||||
-#include "GUIDialogKeyboard.h"
|
|
||||||
-#include "Application.h"
|
|
||||||
-#include "FileItem.h"
|
|
||||||
-#include "LocalizeStrings.h"
|
|
||||||
-#include "JobManager.h"
|
|
||||||
-#include "ConnectionJob.h"
|
|
||||||
-
|
|
||||||
-#define CONTROL_ACCESS_POINTS 3
|
|
||||||
-
|
|
||||||
-const char *ConnectionStateToString(ConnectionState state)
|
|
||||||
-{
|
|
||||||
- switch (state)
|
|
||||||
- {
|
|
||||||
- case NETWORK_CONNECTION_STATE_DISCONNECTED:
|
|
||||||
- return "disconnected";
|
|
||||||
- case NETWORK_CONNECTION_STATE_CONNECTING:
|
|
||||||
- return "connecting";
|
|
||||||
- case NETWORK_CONNECTION_STATE_CONNECTED:
|
|
||||||
- return "connected";
|
|
||||||
- case NETWORK_CONNECTION_STATE_FAILURE:
|
|
||||||
- return "failure";
|
|
||||||
- case NETWORK_CONNECTION_STATE_UNKNOWN:
|
|
||||||
- default:
|
|
||||||
- return "unknown";
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- return "";
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-const char *ConnectionTypeToString(ConnectionType type)
|
|
||||||
-{
|
|
||||||
- switch (type)
|
|
||||||
- {
|
|
||||||
- case NETWORK_CONNECTION_TYPE_WIRED:
|
|
||||||
- return "wired";
|
|
||||||
- case NETWORK_CONNECTION_TYPE_WIFI:
|
|
||||||
- return "wifi";
|
|
||||||
- case NETWORK_CONNECTION_TYPE_UNKNOWN:
|
|
||||||
- default:
|
|
||||||
- return "unknown";
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- return "";
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-const char *EncryptionToString(EncryptionType type)
|
|
||||||
-{
|
|
||||||
- switch (type)
|
|
||||||
- {
|
|
||||||
- case NETWORK_CONNECTION_ENCRYPTION_NONE:
|
|
||||||
- return "";
|
|
||||||
- case NETWORK_CONNECTION_ENCRYPTION_WEP:
|
|
||||||
- return "wep";
|
|
||||||
- case NETWORK_CONNECTION_ENCRYPTION_WPA:
|
|
||||||
- return "wpa";
|
|
||||||
- case NETWORK_CONNECTION_ENCRYPTION_WPA2:
|
|
||||||
- return "wpa2";
|
|
||||||
- case NETWORK_CONNECTION_ENCRYPTION_IEEE8021x:
|
|
||||||
- return "wpa-rsn";
|
|
||||||
- case NETWORK_CONNECTION_ENCRYPTION_UNKNOWN:
|
|
||||||
- default:
|
|
||||||
- return "unknown";
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- return "";
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-CGUIDialogAccessPoints::CGUIDialogAccessPoints(void)
|
|
||||||
- : CGUIDialog(WINDOW_DIALOG_ACCESS_POINTS, "DialogAccessPoints.xml")
|
|
||||||
-{
|
|
||||||
- m_connectionsFileList = new CFileItemList;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-CGUIDialogAccessPoints::~CGUIDialogAccessPoints(void)
|
|
||||||
-{
|
|
||||||
- delete m_connectionsFileList;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-bool CGUIDialogAccessPoints::OnAction(const CAction &action)
|
|
||||||
-{
|
|
||||||
- if (action.GetID() == ACTION_SELECT_ITEM)
|
|
||||||
- {
|
|
||||||
- CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_ACCESS_POINTS);
|
|
||||||
- OnMessage(msg);
|
|
||||||
- int iItem = msg.GetParam1();
|
|
||||||
-
|
|
||||||
- ConnectionList connections = g_application.getNetworkManager().GetConnections();
|
|
||||||
- CJobManager::GetInstance().AddJob(new CConnectionJob(connections[iItem]), this);
|
|
||||||
-
|
|
||||||
- return true;
|
|
||||||
- }
|
|
||||||
- else if (action.GetID() == 300)
|
|
||||||
- {
|
|
||||||
- UpdateConnectionList();
|
|
||||||
- return true;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- return CGUIDialog::OnAction(action);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-void CGUIDialogAccessPoints::OnInitWindow()
|
|
||||||
-{
|
|
||||||
- CGUIDialog::OnInitWindow();
|
|
||||||
-
|
|
||||||
- UpdateConnectionList();
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-void CGUIDialogAccessPoints::UpdateConnectionList()
|
|
||||||
-{
|
|
||||||
- m_connectionsFileList->Clear();
|
|
||||||
-
|
|
||||||
- CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_ACCESS_POINTS);
|
|
||||||
- OnMessage(msgReset);
|
|
||||||
-
|
|
||||||
- ConnectionList connections = g_application.getNetworkManager().GetConnections();
|
|
||||||
-
|
|
||||||
- for (int i = 0; i < (int) connections.size(); i++)
|
|
||||||
- {
|
|
||||||
- CFileItemPtr item(new CFileItem(connections[i]->GetName()));
|
|
||||||
-
|
|
||||||
- if (connections[i]->GetConnectionType() == NETWORK_CONNECTION_TYPE_WIFI)
|
|
||||||
- {
|
|
||||||
- item->SetProperty("signal", (int)(connections[i]->GetStrength() / 20));
|
|
||||||
- item->SetProperty("encryption", EncryptionToString(connections[i]->GetEncryption()));
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- item->SetProperty("type", ConnectionTypeToString(connections[i]->GetConnectionType()));
|
|
||||||
- item->SetProperty("state", ConnectionStateToString(connections[i]->GetConnectionState()));
|
|
||||||
-
|
|
||||||
- m_connectionsFileList->Add(item);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_ACCESS_POINTS, 0, 0, m_connectionsFileList);
|
|
||||||
- OnMessage(msg);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-void CGUIDialogAccessPoints::OnJobComplete(unsigned int jobID, bool success, CJob *job)
|
|
||||||
-{
|
|
||||||
- if (success)
|
|
||||||
- Close();
|
|
||||||
-}
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/GUIDialogAccessPoints.h xbmc-dharma-35100.patch/xbmc/GUIDialogAccessPoints.h
|
|
||||||
--- xbmc-dharma-35100/xbmc/GUIDialogAccessPoints.h 2010-11-01 21:23:31.950434640 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/GUIDialogAccessPoints.h 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
@@ -1,48 +0,0 @@
|
|
||||||
-#ifndef GUI_DIALOG_ACCES_POINTS
|
|
||||||
-#define GUI_DIALOG_ACCES_POINTS
|
|
||||||
-
|
|
||||||
-/*
|
|
||||||
- * Copyright (C) 2005-2008 Team XBMC
|
|
||||||
- * http://www.xbmc.org
|
|
||||||
- *
|
|
||||||
- * This Program is free software; you can redistribute it and/or modify
|
|
||||||
- * it under the terms of the GNU General Public License as published by
|
|
||||||
- * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
- * any later version.
|
|
||||||
- *
|
|
||||||
- * This Program is distributed in the hope that it will be useful,
|
|
||||||
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
- * GNU General Public License for more details.
|
|
||||||
- *
|
|
||||||
- * You should have received a copy of the GNU General Public License
|
|
||||||
- * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
- * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
- *
|
|
||||||
- */
|
|
||||||
-
|
|
||||||
-#pragma once
|
|
||||||
-
|
|
||||||
-#include <vector>
|
|
||||||
-#include "GUIDialog.h"
|
|
||||||
-#include "IConnection.h"
|
|
||||||
-#include "Job.h"
|
|
||||||
-
|
|
||||||
-class CFileItemList;
|
|
||||||
-
|
|
||||||
-class CGUIDialogAccessPoints : public CGUIDialog, public IJobCallback
|
|
||||||
-{
|
|
||||||
-public:
|
|
||||||
- CGUIDialogAccessPoints(void);
|
|
||||||
- virtual ~CGUIDialogAccessPoints(void);
|
|
||||||
- virtual void OnInitWindow();
|
|
||||||
- virtual bool OnAction(const CAction &action);
|
|
||||||
-
|
|
||||||
- virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job);
|
|
||||||
-private:
|
|
||||||
- void UpdateConnectionList();
|
|
||||||
-
|
|
||||||
- CFileItemList *m_connectionsFileList;
|
|
||||||
-};
|
|
||||||
-#endif
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/GUIDialogConnections.cpp xbmc-dharma-35100.patch/xbmc/GUIDialogConnections.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/GUIDialogConnections.cpp 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/GUIDialogConnections.cpp 2010-11-01 21:23:48.548629067 +0100
|
|
||||||
@@ -0,0 +1,163 @@
|
|
||||||
+/*
|
|
||||||
+ * Copyright (C) 2005-2008 Team XBMC
|
|
||||||
+ * http://www.xbmc.org
|
|
||||||
+ *
|
|
||||||
+ * This Program is free software; you can redistribute it and/or modify
|
|
||||||
+ * it under the terms of the GNU General Public License as published by
|
|
||||||
+ * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
+ * any later version.
|
|
||||||
+ *
|
|
||||||
+ * This Program is distributed in the hope that it will be useful,
|
|
||||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+ * GNU General Public License for more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License
|
|
||||||
+ * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
+ * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "GUIDialogConnections.h"
|
|
||||||
+#include "GUIDialogKeyboard.h"
|
|
||||||
+#include "Application.h"
|
|
||||||
+#include "FileItem.h"
|
|
||||||
+#include "LocalizeStrings.h"
|
|
||||||
+#include "JobManager.h"
|
|
||||||
+#include "ConnectionJob.h"
|
|
||||||
+
|
|
||||||
+#define CONTROL_ACCESS_POINTS 3
|
|
||||||
+
|
|
||||||
+const char *ConnectionStateToString(ConnectionState state)
|
|
||||||
+{
|
|
||||||
+ switch (state)
|
|
||||||
+ {
|
|
||||||
+ case NETWORK_CONNECTION_STATE_DISCONNECTED:
|
|
||||||
+ return "disconnected";
|
|
||||||
+ case NETWORK_CONNECTION_STATE_CONNECTING:
|
|
||||||
+ return "connecting";
|
|
||||||
+ case NETWORK_CONNECTION_STATE_CONNECTED:
|
|
||||||
+ return "connected";
|
|
||||||
+ case NETWORK_CONNECTION_STATE_FAILURE:
|
|
||||||
+ return "failure";
|
|
||||||
+ case NETWORK_CONNECTION_STATE_UNKNOWN:
|
|
||||||
+ default:
|
|
||||||
+ return "unknown";
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return "";
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+const char *ConnectionTypeToString(ConnectionType type)
|
|
||||||
+{
|
|
||||||
+ switch (type)
|
|
||||||
+ {
|
|
||||||
+ case NETWORK_CONNECTION_TYPE_WIRED:
|
|
||||||
+ return "wired";
|
|
||||||
+ case NETWORK_CONNECTION_TYPE_WIFI:
|
|
||||||
+ return "wifi";
|
|
||||||
+ case NETWORK_CONNECTION_TYPE_UNKNOWN:
|
|
||||||
+ default:
|
|
||||||
+ return "unknown";
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return "";
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+const char *EncryptionToString(EncryptionType type)
|
|
||||||
+{
|
|
||||||
+ switch (type)
|
|
||||||
+ {
|
|
||||||
+ case NETWORK_CONNECTION_ENCRYPTION_NONE:
|
|
||||||
+ return "";
|
|
||||||
+ case NETWORK_CONNECTION_ENCRYPTION_WEP:
|
|
||||||
+ return "wep";
|
|
||||||
+ case NETWORK_CONNECTION_ENCRYPTION_WPA:
|
|
||||||
+ return "wpa";
|
|
||||||
+ case NETWORK_CONNECTION_ENCRYPTION_WPA2:
|
|
||||||
+ return "wpa2";
|
|
||||||
+ case NETWORK_CONNECTION_ENCRYPTION_IEEE8021x:
|
|
||||||
+ return "wpa-rsn";
|
|
||||||
+ case NETWORK_CONNECTION_ENCRYPTION_UNKNOWN:
|
|
||||||
+ default:
|
|
||||||
+ return "unknown";
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return "";
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+CGUIDialogConnections::CGUIDialogConnections(void)
|
|
||||||
+ : CGUIDialog(WINDOW_DIALOG_CONNECTIONS, "DialogConnections.xml")
|
|
||||||
+{
|
|
||||||
+ m_connectionsFileList = new CFileItemList;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+CGUIDialogConnections::~CGUIDialogConnections(void)
|
|
||||||
+{
|
|
||||||
+ delete m_connectionsFileList;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+bool CGUIDialogConnections::OnAction(const CAction &action)
|
|
||||||
+{
|
|
||||||
+ if (action.GetID() == ACTION_SELECT_ITEM)
|
|
||||||
+ {
|
|
||||||
+ CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_ACCESS_POINTS);
|
|
||||||
+ OnMessage(msg);
|
|
||||||
+ int iItem = msg.GetParam1();
|
|
||||||
+
|
|
||||||
+ ConnectionList connections = g_application.getNetworkManager().GetConnections();
|
|
||||||
+ CJobManager::GetInstance().AddJob(new CConnectionJob(connections[iItem]), this);
|
|
||||||
+
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+ else if (action.GetID() == 300)
|
|
||||||
+ {
|
|
||||||
+ UpdateConnectionList();
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return CGUIDialog::OnAction(action);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void CGUIDialogConnections::OnInitWindow()
|
|
||||||
+{
|
|
||||||
+ CGUIDialog::OnInitWindow();
|
|
||||||
+
|
|
||||||
+ UpdateConnectionList();
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void CGUIDialogConnections::UpdateConnectionList()
|
|
||||||
+{
|
|
||||||
+ m_connectionsFileList->Clear();
|
|
||||||
+
|
|
||||||
+ CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_ACCESS_POINTS);
|
|
||||||
+ OnMessage(msgReset);
|
|
||||||
+
|
|
||||||
+ ConnectionList connections = g_application.getNetworkManager().GetConnections();
|
|
||||||
+
|
|
||||||
+ for (int i = 0; i < (int) connections.size(); i++)
|
|
||||||
+ {
|
|
||||||
+ CFileItemPtr item(new CFileItem(connections[i]->GetName()));
|
|
||||||
+
|
|
||||||
+ if (connections[i]->GetConnectionType() == NETWORK_CONNECTION_TYPE_WIFI)
|
|
||||||
+ {
|
|
||||||
+ item->SetProperty("signal", (int)(connections[i]->GetStrength() / 20));
|
|
||||||
+ item->SetProperty("encryption", EncryptionToString(connections[i]->GetEncryption()));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ item->SetProperty("type", ConnectionTypeToString(connections[i]->GetConnectionType()));
|
|
||||||
+ item->SetProperty("state", ConnectionStateToString(connections[i]->GetConnectionState()));
|
|
||||||
+
|
|
||||||
+ m_connectionsFileList->Add(item);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_ACCESS_POINTS, 0, 0, m_connectionsFileList);
|
|
||||||
+ OnMessage(msg);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void CGUIDialogConnections::OnJobComplete(unsigned int jobID, bool success, CJob *job)
|
|
||||||
+{
|
|
||||||
+ if (success)
|
|
||||||
+ Close();
|
|
||||||
+}
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/GUIDialogConnections.h xbmc-dharma-35100.patch/xbmc/GUIDialogConnections.h
|
|
||||||
--- xbmc-dharma-35100/xbmc/GUIDialogConnections.h 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/GUIDialogConnections.h 2010-11-01 21:23:48.548629067 +0100
|
|
||||||
@@ -0,0 +1,48 @@
|
|
||||||
+#ifndef GUI_DIALOG_ACCES_POINTS
|
|
||||||
+#define GUI_DIALOG_ACCES_POINTS
|
|
||||||
+
|
|
||||||
+/*
|
|
||||||
+ * Copyright (C) 2005-2008 Team XBMC
|
|
||||||
+ * http://www.xbmc.org
|
|
||||||
+ *
|
|
||||||
+ * This Program is free software; you can redistribute it and/or modify
|
|
||||||
+ * it under the terms of the GNU General Public License as published by
|
|
||||||
+ * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
+ * any later version.
|
|
||||||
+ *
|
|
||||||
+ * This Program is distributed in the hope that it will be useful,
|
|
||||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+ * GNU General Public License for more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License
|
|
||||||
+ * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
+ * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#pragma once
|
|
||||||
+
|
|
||||||
+#include <vector>
|
|
||||||
+#include "GUIDialog.h"
|
|
||||||
+#include "IConnection.h"
|
|
||||||
+#include "Job.h"
|
|
||||||
+
|
|
||||||
+class CFileItemList;
|
|
||||||
+
|
|
||||||
+class CGUIDialogConnections : public CGUIDialog, public IJobCallback
|
|
||||||
+{
|
|
||||||
+public:
|
|
||||||
+ CGUIDialogConnections(void);
|
|
||||||
+ virtual ~CGUIDialogConnections(void);
|
|
||||||
+ virtual void OnInitWindow();
|
|
||||||
+ virtual bool OnAction(const CAction &action);
|
|
||||||
+
|
|
||||||
+ virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job);
|
|
||||||
+private:
|
|
||||||
+ void UpdateConnectionList();
|
|
||||||
+
|
|
||||||
+ CFileItemList *m_connectionsFileList;
|
|
||||||
+};
|
|
||||||
+#endif
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/GUIWindowSettingsCategory.cpp xbmc-dharma-35100.patch/xbmc/GUIWindowSettingsCategory.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/GUIWindowSettingsCategory.cpp 2010-11-01 21:23:31.959434747 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/GUIWindowSettingsCategory.cpp 2010-11-01 21:23:48.551629102 +0100
|
|
||||||
@@ -78,7 +78,7 @@
|
|
||||||
#include "CoreAudio.h"
|
|
||||||
#include "XBMCHelper.h"
|
|
||||||
#endif
|
|
||||||
-#include "GUIDialogAccessPoints.h"
|
|
||||||
+#include "GUIDialogConnections.h"
|
|
||||||
#include "FileSystem/Directory.h"
|
|
||||||
|
|
||||||
#include "FileItem.h"
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/Makefile.in xbmc-dharma-35100.patch/xbmc/Makefile.in
|
|
||||||
--- xbmc-dharma-35100/xbmc/Makefile.in 2010-11-01 21:23:32.029435567 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/Makefile.in 2010-11-01 21:23:48.553629126 +0100
|
|
||||||
@@ -189,7 +189,7 @@
|
|
||||||
GUILargeTextureManager.cpp \
|
|
||||||
GUIDialogKaiToast.cpp \
|
|
||||||
KeyboardLayoutConfiguration.cpp \
|
|
||||||
- GUIDialogAccessPoints.cpp \
|
|
||||||
+ GUIDialogConnections.cpp \
|
|
||||||
Artist.cpp \
|
|
||||||
Album.cpp \
|
|
||||||
MediaSource.cpp \
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/NetworkManager.cpp xbmc-dharma-35100.patch/xbmc/NetworkManager.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/NetworkManager.cpp 2010-11-01 21:23:32.033435613 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/NetworkManager.cpp 2010-11-01 21:23:48.553629126 +0100
|
|
||||||
@@ -105,7 +105,7 @@
|
|
||||||
m_defaultConnection = connection;
|
|
||||||
|
|
||||||
CAction action(300);
|
|
||||||
- g_application.getApplicationMessenger().SendAction(action, WINDOW_DIALOG_ACCESS_POINTS);
|
|
||||||
+ g_application.getApplicationMessenger().SendAction(action, WINDOW_DIALOG_CONNECTIONS);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNetworkManager::OnConnectionListChange(ConnectionList list)
|
|
||||||
@@ -123,7 +123,7 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
CAction action(300);
|
|
||||||
- g_application.getApplicationMessenger().SendAction(action, WINDOW_DIALOG_ACCESS_POINTS);
|
|
||||||
+ g_application.getApplicationMessenger().SendAction(action, WINDOW_DIALOG_CONNECTIONS);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNetworkManager::StartServices()
|
|
@ -1,513 +0,0 @@
|
|||||||
diff -Naur xbmc-dharma-35100/xbmc/Application.cpp.orig xbmc-dharma-35100.patch/xbmc/Application.cpp.orig
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/linux/ConnmanConnection.cpp xbmc-dharma-35100.patch/xbmc/linux/ConnmanConnection.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/linux/ConnmanConnection.cpp 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/linux/ConnmanConnection.cpp 2010-11-01 21:26:01.472185976 +0100
|
|
||||||
@@ -0,0 +1,224 @@
|
|
||||||
+#include "ConnmanConnection.h"
|
|
||||||
+
|
|
||||||
+#ifdef HAS_DBUS
|
|
||||||
+#include "DBusUtil.h"
|
|
||||||
+#include "DBusMessage.h"
|
|
||||||
+#include "log.h"
|
|
||||||
+#include <string.h>
|
|
||||||
+#include <stdio.h>
|
|
||||||
+
|
|
||||||
+CConnmanConnection::CConnmanConnection(const char *serviceObject)
|
|
||||||
+{
|
|
||||||
+ m_serviceObject = serviceObject;
|
|
||||||
+
|
|
||||||
+ CDBusMessage message("org.moblin.connman", serviceObject, "org.moblin.connman.Service", "GetProperties");
|
|
||||||
+ CDBusReplyPtr reply = message.SendSystem();
|
|
||||||
+ m_properties = reply->GetNextArgument();
|
|
||||||
+
|
|
||||||
+ UpdateConnection();
|
|
||||||
+
|
|
||||||
+ dbus_error_init (&m_error);
|
|
||||||
+
|
|
||||||
+ // TODO: do not use dbus_connection_pop_message() that requires the use of a
|
|
||||||
+ // private connection
|
|
||||||
+ m_connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &m_error);
|
|
||||||
+ if (m_connection)
|
|
||||||
+ {
|
|
||||||
+ dbus_connection_set_exit_on_disconnect(m_connection, false);
|
|
||||||
+
|
|
||||||
+ dbus_bus_add_match(m_connection, "type='signal',interface='org.moblin.connman.Service'", &m_error);
|
|
||||||
+ dbus_connection_flush(m_connection);
|
|
||||||
+ if (dbus_error_is_set(&m_error))
|
|
||||||
+ {
|
|
||||||
+ CLog::Log(LOGERROR, "ConnmanConnection: %s Failed to attach to signal %s", serviceObject, m_error.message);
|
|
||||||
+ dbus_connection_close(m_connection);
|
|
||||||
+ dbus_connection_unref(m_connection);
|
|
||||||
+ m_connection = NULL;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ CLog::Log(LOGERROR, "ConnmanConnection: %s Failed to get a DBus connection %s", serviceObject, m_error.message);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+CConnmanConnection::~CConnmanConnection()
|
|
||||||
+{
|
|
||||||
+ if (m_connection)
|
|
||||||
+ {
|
|
||||||
+ dbus_connection_close(m_connection);
|
|
||||||
+ dbus_connection_unref(m_connection);
|
|
||||||
+ m_connection = NULL;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ dbus_error_free (&m_error);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+bool CConnmanConnection::Connect(IPassphraseStorage *storage, const CIPConfig &ipconfig)
|
|
||||||
+{
|
|
||||||
+ if (m_encryption != NETWORK_CONNECTION_ENCRYPTION_NONE)
|
|
||||||
+ {
|
|
||||||
+ std::string passphrase;
|
|
||||||
+ if (!storage->GetPassphrase(m_serviceObject, passphrase))
|
|
||||||
+ return false;
|
|
||||||
+
|
|
||||||
+ CDBusMessage message("org.moblin.connman", m_serviceObject.c_str(), "org.moblin.connman.Service", "SetProperties");
|
|
||||||
+ message.AppendArgument("Passphrase");
|
|
||||||
+ message.AppendArgument(passphrase.c_str());
|
|
||||||
+
|
|
||||||
+ CDBusReplyPtr reply = message.SendSystem();
|
|
||||||
+ if (reply->IsErrorSet())
|
|
||||||
+ {
|
|
||||||
+ CLog::Log(LOGERROR, "ConnmanConnection: Failed to set passphrase");
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ CDBusMessage message("org.moblin.connman", m_serviceObject.c_str(), "org.moblin.connman.Service", "Connect");
|
|
||||||
+ return message.SendAsyncSystem();
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+ConnectionState CConnmanConnection::GetConnectionState() const
|
|
||||||
+{
|
|
||||||
+ return m_state;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CConnmanConnection::GetName() const
|
|
||||||
+{
|
|
||||||
+ return m_name;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CConnmanConnection::GetIP() const
|
|
||||||
+{
|
|
||||||
+ return m_IP;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CConnmanConnection::GetNetmask() const
|
|
||||||
+{
|
|
||||||
+ return m_netmask;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CConnmanConnection::GetMacAddress() const
|
|
||||||
+{
|
|
||||||
+ return m_macaddress;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CConnmanConnection::GetGateway() const
|
|
||||||
+{
|
|
||||||
+ return m_gateway;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+unsigned int CConnmanConnection::GetStrength() const
|
|
||||||
+{
|
|
||||||
+ return m_strength;;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+EncryptionType CConnmanConnection::GetEncryption() const
|
|
||||||
+{
|
|
||||||
+ return m_encryption;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+unsigned int CConnmanConnection::GetConnectionSpeed() const
|
|
||||||
+{
|
|
||||||
+ return m_speed;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+ConnectionType CConnmanConnection::GetConnectionType() const
|
|
||||||
+{
|
|
||||||
+ return m_type;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+bool CConnmanConnection::PumpNetworkEvents()
|
|
||||||
+{
|
|
||||||
+ bool result = false;
|
|
||||||
+
|
|
||||||
+ if (m_connection)
|
|
||||||
+ {
|
|
||||||
+ dbus_connection_read_write(m_connection, 0);
|
|
||||||
+ DBusMessage *msg = dbus_connection_pop_message(m_connection);
|
|
||||||
+
|
|
||||||
+ if (msg)
|
|
||||||
+ {
|
|
||||||
+ CDBusReplyPtr reply = CDBusReplyPtr(new CDBusReply(msg));
|
|
||||||
+
|
|
||||||
+ if (dbus_message_is_signal(msg, "org.moblin.connman.Service", "PropertyChanged"))
|
|
||||||
+ {
|
|
||||||
+ CVariant key = reply->GetNextArgument();
|
|
||||||
+ m_properties[key.asString()] = reply->GetNextArgument();
|
|
||||||
+
|
|
||||||
+ UpdateConnection();
|
|
||||||
+ result = true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ dbus_message_unref(msg);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return result;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+ConnectionState CConnmanConnection::ParseConnectionState(const char *stateString)
|
|
||||||
+{
|
|
||||||
+ if (strcmp(stateString, "online") == 0)
|
|
||||||
+ return NETWORK_CONNECTION_STATE_CONNECTED;
|
|
||||||
+ else if (strcmp(stateString, "association") == 0)
|
|
||||||
+ return NETWORK_CONNECTION_STATE_CONNECTING;
|
|
||||||
+ else if (strcmp(stateString, "configuration") == 0)
|
|
||||||
+ return NETWORK_CONNECTION_STATE_CONNECTING;
|
|
||||||
+ else if (strcmp(stateString, "failure") == 0)
|
|
||||||
+ return NETWORK_CONNECTION_STATE_FAILURE;
|
|
||||||
+ else
|
|
||||||
+ {
|
|
||||||
+ // The state can be ready which means that the connection have been setup and is ready to be used.
|
|
||||||
+ // Perhaps we want to differentiate this in GUI? Its not used but might be in case the active connection is lost.
|
|
||||||
+ return NETWORK_CONNECTION_STATE_DISCONNECTED;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void CConnmanConnection::UpdateConnection()
|
|
||||||
+{
|
|
||||||
+ m_name = m_properties["Name"].asString();
|
|
||||||
+
|
|
||||||
+ m_state = ParseConnectionState(m_properties["State"].asString());
|
|
||||||
+
|
|
||||||
+ if (strcmp(m_properties["Type"].asString(), "ethernet") == 0)
|
|
||||||
+ m_type = NETWORK_CONNECTION_TYPE_WIRED;
|
|
||||||
+ else if (strcmp(m_properties["Type"].asString(), "wifi") == 0)
|
|
||||||
+ m_type = NETWORK_CONNECTION_TYPE_WIFI;
|
|
||||||
+ else
|
|
||||||
+ m_type = NETWORK_CONNECTION_TYPE_UNKNOWN;
|
|
||||||
+
|
|
||||||
+ m_IP = m_properties["IPv4"]["Address"].asString();
|
|
||||||
+ m_netmask = m_properties["IPv4"]["Netmask"].asString();
|
|
||||||
+ m_macaddress = m_properties["Ethernet"]["Address"].asString();
|
|
||||||
+ m_gateway = m_properties["IPv4"]["Gateway"].asString();
|
|
||||||
+
|
|
||||||
+ if (m_type == NETWORK_CONNECTION_TYPE_WIFI)
|
|
||||||
+ {
|
|
||||||
+ m_strength = m_properties["Strength"].asInteger();
|
|
||||||
+ m_speed = m_properties["Ethernet"]["Speed"].asInteger();
|
|
||||||
+
|
|
||||||
+ if (strcmp(m_properties["Security"].asString(), "none") == 0)
|
|
||||||
+ m_encryption = NETWORK_CONNECTION_ENCRYPTION_NONE;
|
|
||||||
+ else if (strcmp(m_properties["Security"].asString(), "wep") == 0)
|
|
||||||
+ m_encryption = NETWORK_CONNECTION_ENCRYPTION_WEP;
|
|
||||||
+ else if (strcmp(m_properties["Security"].asString(), "wpa") == 0)
|
|
||||||
+ m_encryption = NETWORK_CONNECTION_ENCRYPTION_WPA;
|
|
||||||
+ else if (strcmp(m_properties["Security"].asString(), "psk") == 0)
|
|
||||||
+ m_encryption = NETWORK_CONNECTION_ENCRYPTION_WPA;
|
|
||||||
+ else if (strcmp(m_properties["Security"].asString(), "rsn") == 0)
|
|
||||||
+ m_encryption = NETWORK_CONNECTION_ENCRYPTION_WPA;
|
|
||||||
+ else if (strcmp(m_properties["Security"].asString(), "ieee8021x") == 0)
|
|
||||||
+ m_encryption = NETWORK_CONNECTION_ENCRYPTION_IEEE8021x;
|
|
||||||
+ else
|
|
||||||
+ {
|
|
||||||
+ CLog::Log(LOGWARNING, "Connman: unkown connection encryption %s", m_properties["Security"].asString());
|
|
||||||
+ m_encryption = NETWORK_CONNECTION_ENCRYPTION_UNKNOWN;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ {
|
|
||||||
+ m_strength = 100;
|
|
||||||
+ m_speed = m_properties["Ethernet"]["Speed"].asInteger();
|
|
||||||
+ m_encryption = NETWORK_CONNECTION_ENCRYPTION_NONE;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/linux/ConnmanConnection.h xbmc-dharma-35100.patch/xbmc/linux/ConnmanConnection.h
|
|
||||||
--- xbmc-dharma-35100/xbmc/linux/ConnmanConnection.h 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/linux/ConnmanConnection.h 2010-11-01 21:26:01.480186069 +0100
|
|
||||||
@@ -0,0 +1,57 @@
|
|
||||||
+#pragma once
|
|
||||||
+
|
|
||||||
+#include "system.h"
|
|
||||||
+#ifdef HAS_DBUS
|
|
||||||
+#include "IConnection.h"
|
|
||||||
+#include "DBusUtil.h"
|
|
||||||
+#include <dbus/dbus.h>
|
|
||||||
+
|
|
||||||
+class CConnmanConnection : public IConnection
|
|
||||||
+{
|
|
||||||
+public:
|
|
||||||
+ CConnmanConnection(const char *serviceObject);
|
|
||||||
+ virtual ~CConnmanConnection();
|
|
||||||
+
|
|
||||||
+ virtual bool Connect(IPassphraseStorage *storage, const CIPConfig &ipconfig);
|
|
||||||
+ virtual ConnectionState GetConnectionState() const;
|
|
||||||
+
|
|
||||||
+ virtual std::string GetName() const;
|
|
||||||
+
|
|
||||||
+ virtual std::string GetIP() const;
|
|
||||||
+ virtual std::string GetNetmask() const;
|
|
||||||
+ virtual std::string GetMacAddress() const;
|
|
||||||
+ virtual std::string GetGateway() const;
|
|
||||||
+
|
|
||||||
+ virtual unsigned int GetStrength() const;
|
|
||||||
+ virtual EncryptionType GetEncryption() const;
|
|
||||||
+ virtual unsigned int GetConnectionSpeed() const;
|
|
||||||
+
|
|
||||||
+ virtual ConnectionType GetConnectionType() const;
|
|
||||||
+
|
|
||||||
+ bool PumpNetworkEvents();
|
|
||||||
+
|
|
||||||
+ static ConnectionState ParseConnectionState(const char *stateString);
|
|
||||||
+private:
|
|
||||||
+ void UpdateConnection();
|
|
||||||
+
|
|
||||||
+ CVariant m_properties;
|
|
||||||
+
|
|
||||||
+ std::string m_name;
|
|
||||||
+ std::string m_IP;
|
|
||||||
+ std::string m_netmask;
|
|
||||||
+ std::string m_macaddress;
|
|
||||||
+ std::string m_gateway;
|
|
||||||
+
|
|
||||||
+ std::string m_serviceObject;
|
|
||||||
+
|
|
||||||
+ unsigned int m_strength;
|
|
||||||
+ unsigned int m_speed;
|
|
||||||
+
|
|
||||||
+ ConnectionState m_state;
|
|
||||||
+ EncryptionType m_encryption;
|
|
||||||
+ ConnectionType m_type;
|
|
||||||
+
|
|
||||||
+ DBusConnection *m_connection;
|
|
||||||
+ DBusError m_error;
|
|
||||||
+};
|
|
||||||
+#endif
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/linux/ConnmanNetworkManager.cpp xbmc-dharma-35100.patch/xbmc/linux/ConnmanNetworkManager.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/linux/ConnmanNetworkManager.cpp 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/linux/ConnmanNetworkManager.cpp 2010-11-01 21:26:01.481186080 +0100
|
|
||||||
@@ -0,0 +1,150 @@
|
|
||||||
+#include "ConnmanNetworkManager.h"
|
|
||||||
+
|
|
||||||
+#ifdef HAS_DBUS
|
|
||||||
+#include "ConnmanConnection.h"
|
|
||||||
+#include "DBusUtil.h"
|
|
||||||
+#include "DBusMessage.h"
|
|
||||||
+#include "log.h"
|
|
||||||
+
|
|
||||||
+#include <string.h>
|
|
||||||
+
|
|
||||||
+using namespace std;
|
|
||||||
+
|
|
||||||
+CConnmanNetworkManager::CConnmanNetworkManager()
|
|
||||||
+{
|
|
||||||
+ CDBusMessage message("org.moblin.connman", "/", "org.moblin.connman.Manager", "GetProperties");
|
|
||||||
+ CDBusReplyPtr reply = message.SendSystem();
|
|
||||||
+ m_properties = reply->GetNextArgument();
|
|
||||||
+
|
|
||||||
+ UpdateNetworkManager();
|
|
||||||
+
|
|
||||||
+ dbus_error_init (&m_error);
|
|
||||||
+ // TODO: do not use dbus_connection_pop_message() that requires the use of a
|
|
||||||
+ // private connection
|
|
||||||
+ m_connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &m_error);
|
|
||||||
+ if (m_connection)
|
|
||||||
+ {
|
|
||||||
+ dbus_connection_set_exit_on_disconnect(m_connection, false);
|
|
||||||
+
|
|
||||||
+ dbus_bus_add_match(m_connection, "type='signal',interface='org.moblin.connman.Manager'", &m_error);
|
|
||||||
+ dbus_connection_flush(m_connection);
|
|
||||||
+ if (dbus_error_is_set(&m_error))
|
|
||||||
+ {
|
|
||||||
+ CLog::Log(LOGERROR, "ConnmanNetworkManager: Failed to attach to signal %s", m_error.message);
|
|
||||||
+ dbus_connection_close(m_connection);
|
|
||||||
+ dbus_connection_unref(m_connection);
|
|
||||||
+ m_connection = NULL;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ CLog::Log(LOGERROR, "ConnmanNetworkManager: Failed to get a DBus connection %s", m_error.message);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+CConnmanNetworkManager::~CConnmanNetworkManager()
|
|
||||||
+{
|
|
||||||
+ if (m_connection)
|
|
||||||
+ {
|
|
||||||
+ dbus_connection_close(m_connection);
|
|
||||||
+ dbus_connection_unref(m_connection);
|
|
||||||
+ m_connection = NULL;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ dbus_error_free (&m_error);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+bool CConnmanNetworkManager::CanManageConnections()
|
|
||||||
+{
|
|
||||||
+ // TODO Only return true if we are registered as agent
|
|
||||||
+ return true;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+ConnectionList CConnmanNetworkManager::GetConnections()
|
|
||||||
+{
|
|
||||||
+ return m_connections;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+bool CConnmanNetworkManager::PumpNetworkEvents(INetworkEventsCallback *callback)
|
|
||||||
+{
|
|
||||||
+ bool result = false;
|
|
||||||
+
|
|
||||||
+ if (m_connection)
|
|
||||||
+ {
|
|
||||||
+ dbus_connection_read_write(m_connection, 0);
|
|
||||||
+ DBusMessage *msg = dbus_connection_pop_message(m_connection);
|
|
||||||
+
|
|
||||||
+ if (msg)
|
|
||||||
+ {
|
|
||||||
+ CDBusReplyPtr reply = CDBusReplyPtr(new CDBusReply(msg));
|
|
||||||
+
|
|
||||||
+ if (dbus_message_is_signal(msg, "org.moblin.connman.Manager", "PropertyChanged"))
|
|
||||||
+ {
|
|
||||||
+ CVariant key = reply->GetNextArgument();
|
|
||||||
+ m_properties[key.asString()] = reply->GetNextArgument();
|
|
||||||
+
|
|
||||||
+ UpdateNetworkManager();
|
|
||||||
+
|
|
||||||
+ if (strcmp(key.asString(), "Services") == 0)
|
|
||||||
+ callback->OnConnectionListChange(m_connections);
|
|
||||||
+
|
|
||||||
+ result = true;
|
|
||||||
+ }
|
|
||||||
+ else if (dbus_message_is_signal(msg, "org.moblin.connman.Manager", "StateChanged"))
|
|
||||||
+ {
|
|
||||||
+ CVariant stateString = reply->GetNextArgument();
|
|
||||||
+ result = true;
|
|
||||||
+ callback->OnConnectionStateChange(CConnmanConnection::ParseConnectionState(stateString.asString()));
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ CLog::Log(LOGINFO, "ConnmanNetworkManager: Recieved an unknown signal %s", dbus_message_get_member(msg));
|
|
||||||
+
|
|
||||||
+ dbus_message_unref(msg);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ for (unsigned int i = 0; i < m_connections.size(); i++)
|
|
||||||
+ {
|
|
||||||
+ if (((CConnmanConnection *)m_connections[i].get())->PumpNetworkEvents())
|
|
||||||
+ {
|
|
||||||
+ callback->OnConnectionChange(m_connections[i]);
|
|
||||||
+ result = true;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return result;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+bool CConnmanNetworkManager::HasConnman()
|
|
||||||
+{
|
|
||||||
+ CDBusMessage message("org.moblin.connman", "/", "org.moblin.connman.Manager", "GetProperties");
|
|
||||||
+
|
|
||||||
+ DBusError error;
|
|
||||||
+ dbus_error_init (&error);
|
|
||||||
+ DBusConnection *connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
|
|
||||||
+
|
|
||||||
+ message.Send(connection, &error);
|
|
||||||
+
|
|
||||||
+ if (!dbus_error_is_set(&error))
|
|
||||||
+ return true;
|
|
||||||
+ else
|
|
||||||
+ {
|
|
||||||
+ CLog::Log(LOGDEBUG, "ConnmanNetworkManager: %s - %s", error.name, error.message);
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void CConnmanNetworkManager::UpdateNetworkManager()
|
|
||||||
+{
|
|
||||||
+ m_connections.clear();
|
|
||||||
+
|
|
||||||
+ CVariant services = m_properties["Services"];
|
|
||||||
+
|
|
||||||
+ for (unsigned int i = 0; i < services.size(); i++)
|
|
||||||
+ {
|
|
||||||
+ if (strcmp(services[i].asString(), "") == 0)
|
|
||||||
+ continue;
|
|
||||||
+
|
|
||||||
+ IConnection *connection = new CConnmanConnection(services[i].asString());
|
|
||||||
+ m_connections.push_back(CConnectionPtr(connection));
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/linux/ConnmanNetworkManager.h xbmc-dharma-35100.patch/xbmc/linux/ConnmanNetworkManager.h
|
|
||||||
--- xbmc-dharma-35100/xbmc/linux/ConnmanNetworkManager.h 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/linux/ConnmanNetworkManager.h 2010-11-01 21:26:01.481186080 +0100
|
|
||||||
@@ -0,0 +1,30 @@
|
|
||||||
+#pragma once
|
|
||||||
+
|
|
||||||
+#include "system.h"
|
|
||||||
+#ifdef HAS_DBUS
|
|
||||||
+#include "INetworkManager.h"
|
|
||||||
+#include "Variant.h"
|
|
||||||
+#include <dbus/dbus.h>
|
|
||||||
+
|
|
||||||
+class CConnmanNetworkManager : public INetworkManager
|
|
||||||
+{
|
|
||||||
+public:
|
|
||||||
+ CConnmanNetworkManager();
|
|
||||||
+ virtual ~CConnmanNetworkManager();
|
|
||||||
+
|
|
||||||
+ virtual bool CanManageConnections();
|
|
||||||
+
|
|
||||||
+ virtual ConnectionList GetConnections();
|
|
||||||
+
|
|
||||||
+ virtual bool PumpNetworkEvents(INetworkEventsCallback *callback);
|
|
||||||
+
|
|
||||||
+ static bool HasConnman();
|
|
||||||
+private:
|
|
||||||
+ void UpdateNetworkManager();
|
|
||||||
+
|
|
||||||
+ ConnectionList m_connections;
|
|
||||||
+ CVariant m_properties;
|
|
||||||
+ DBusConnection *m_connection;
|
|
||||||
+ DBusError m_error;
|
|
||||||
+};
|
|
||||||
+#endif
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/linux/Makefile.in xbmc-dharma-35100.patch/xbmc/linux/Makefile.in
|
|
||||||
--- xbmc-dharma-35100/xbmc/linux/Makefile.in 2010-11-01 21:23:32.008435321 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/linux/Makefile.in 2010-11-01 21:26:01.482186092 +0100
|
|
||||||
@@ -7,7 +7,7 @@
|
|
||||||
|
|
||||||
CXXFLAGS+=-fPIC #-DHAS_SDL
|
|
||||||
|
|
||||||
-SRCS=ConvUtils.cpp XEventUtils.cpp XFileUtils.cpp XHandle.cpp XSyncUtils.cpp XTimeUtils.cpp XMemUtils.cpp XThreadUtils.cpp LinuxResourceCounter.cpp LinuxTimezone.cpp XRandR.cpp XCriticalSection.cpp XLCDproc.cpp HALManager.cpp HALPowerSyscall.cpp ConsoleDeviceKitPowerSyscall.cpp ConsoleUPowerSyscall.cpp DBusUtil.cpp DBusReply.cpp DBusMessage.cpp ZeroconfAvahi.cpp ZeroconfBrowserAvahi.cpp HALProvider.cpp PosixMountProvider.cpp DeviceKitDisksProvider.cpp UDisksProvider.cpp
|
|
||||||
+SRCS=ConvUtils.cpp XEventUtils.cpp XFileUtils.cpp XHandle.cpp XSyncUtils.cpp XTimeUtils.cpp XMemUtils.cpp XThreadUtils.cpp LinuxResourceCounter.cpp LinuxTimezone.cpp XRandR.cpp XCriticalSection.cpp XLCDproc.cpp HALManager.cpp HALPowerSyscall.cpp ConsoleDeviceKitPowerSyscall.cpp ConsoleUPowerSyscall.cpp DBusUtil.cpp DBusReply.cpp DBusMessage.cpp ZeroconfAvahi.cpp ZeroconfBrowserAvahi.cpp HALProvider.cpp PosixMountProvider.cpp DeviceKitDisksProvider.cpp UDisksProvider.cpp ConnmanNetworkManager.cpp ConnmanConnection.cpp
|
|
||||||
|
|
||||||
LIB=linux.a
|
|
||||||
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/NetworkManager.cpp xbmc-dharma-35100.patch/xbmc/NetworkManager.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/NetworkManager.cpp 2010-11-01 21:26:39.296628972 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/NetworkManager.cpp 2010-11-01 21:26:01.453185752 +0100
|
|
||||||
@@ -5,6 +5,7 @@
|
|
||||||
#include "lib/libscrobbler/librefmscrobbler.h"
|
|
||||||
#include "RssReader.h"
|
|
||||||
#include "ApplicationMessenger.h"
|
|
||||||
+#include "linux/ConnmanNetworkManager.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
@@ -21,7 +22,10 @@
|
|
||||||
|
|
||||||
void CNetworkManager::Initialize()
|
|
||||||
{
|
|
||||||
- // Here should platform specific go
|
|
||||||
+#ifdef HAS_DBUS
|
|
||||||
+ if (CConnmanNetworkManager::HasConnman())
|
|
||||||
+ m_instance = new CConnmanNetworkManager();
|
|
||||||
+#endif
|
|
||||||
|
|
||||||
if (m_instance == NULL)
|
|
||||||
m_instance = new CNullNetworkManager();
|
|
@ -1,489 +0,0 @@
|
|||||||
diff -Naur xbmc-dharma-35100/xbmc/NetworkManager.cpp xbmc-dharma-35100.patch/xbmc/NetworkManager.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/NetworkManager.cpp 2010-11-01 21:56:06.630336721 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/NetworkManager.cpp 2010-11-01 21:56:49.532841969 +0100
|
|
||||||
@@ -6,6 +6,7 @@
|
|
||||||
#include "RssReader.h"
|
|
||||||
#include "ApplicationMessenger.h"
|
|
||||||
#include "linux/ConnmanNetworkManager.h"
|
|
||||||
+#include "posix/PosixNetworkManager.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
@@ -27,6 +28,11 @@
|
|
||||||
m_instance = new CConnmanNetworkManager();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+#ifdef _LINUX
|
|
||||||
+ if (m_instance == NULL)
|
|
||||||
+ m_instance = new CPosixNetworkManager();
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
if (m_instance == NULL)
|
|
||||||
m_instance = new CNullNetworkManager();
|
|
||||||
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/posix/Makefile xbmc-dharma-35100.patch/xbmc/posix/Makefile
|
|
||||||
--- xbmc-dharma-35100/xbmc/posix/Makefile 2010-10-30 05:36:54.000000000 +0200
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/posix/Makefile 2010-11-01 21:56:49.532841969 +0100
|
|
||||||
@@ -1,6 +1,8 @@
|
|
||||||
-INCLUDES+= -I../utils
|
|
||||||
+INCLUDES+= -I../utils -I../ -I../../guilib
|
|
||||||
|
|
||||||
SRCS= \
|
|
||||||
+ PosixConnection.cpp \
|
|
||||||
+ PosixNetworkManager.cpp \
|
|
||||||
SemaphorePOSIX.cpp
|
|
||||||
|
|
||||||
LIB=posix.a
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/posix/PosixConnection.cpp xbmc-dharma-35100.patch/xbmc/posix/PosixConnection.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/posix/PosixConnection.cpp 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/posix/PosixConnection.cpp 2010-11-01 21:56:49.539842049 +0100
|
|
||||||
@@ -0,0 +1,223 @@
|
|
||||||
+/*
|
|
||||||
+ * Copyright (C) 2005-2010 Team XBMC
|
|
||||||
+ * http://www.xbmc.org
|
|
||||||
+ *
|
|
||||||
+ * This Program is free software; you can redistribute it and/or modify
|
|
||||||
+ * it under the terms of the GNU General Public License as published by
|
|
||||||
+ * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
+ * any later version.
|
|
||||||
+ *
|
|
||||||
+ * This Program is distributed in the hope that it will be useful,
|
|
||||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+ * GNU General Public License for more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License
|
|
||||||
+ * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
+ * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "PosixConnection.h"
|
|
||||||
+#include "StdString.h"
|
|
||||||
+
|
|
||||||
+#include <sys/ioctl.h>
|
|
||||||
+#include <sys/socket.h>
|
|
||||||
+#include <netinet/in.h>
|
|
||||||
+#include <arpa/inet.h>
|
|
||||||
+#ifndef __APPLE__
|
|
||||||
+#include <linux/if.h>
|
|
||||||
+#include <linux/wireless.h>
|
|
||||||
+#include <linux/sockios.h>
|
|
||||||
+#endif
|
|
||||||
+#include <errno.h>
|
|
||||||
+#include <resolv.h>
|
|
||||||
+#ifdef __APPLE__
|
|
||||||
+#include <sys/sockio.h>
|
|
||||||
+#include <net/if.h>
|
|
||||||
+#include <ifaddrs.h>
|
|
||||||
+#endif
|
|
||||||
+#include <net/if_arp.h>
|
|
||||||
+#include <string.h>
|
|
||||||
+
|
|
||||||
+CPosixConnection::CPosixConnection(int socket, const char *interfaceName)
|
|
||||||
+{
|
|
||||||
+ m_socket = socket;
|
|
||||||
+ m_interfaceName = interfaceName;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+CPosixConnection::~CPosixConnection()
|
|
||||||
+{
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+bool CPosixConnection::Connect(IPassphraseStorage *storage, const CIPConfig &ipconfig)
|
|
||||||
+{
|
|
||||||
+ return false;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+ConnectionState CPosixConnection::GetConnectionState() const
|
|
||||||
+{
|
|
||||||
+ struct ifreq ifr;
|
|
||||||
+ int zero = 0;
|
|
||||||
+ memset(&ifr,0,sizeof(struct ifreq));
|
|
||||||
+ strcpy(ifr.ifr_name, m_interfaceName.c_str());
|
|
||||||
+ if (ioctl(m_socket, SIOCGIFFLAGS, &ifr) < 0)
|
|
||||||
+ return NETWORK_CONNECTION_STATE_DISCONNECTED;
|
|
||||||
+
|
|
||||||
+ // ignore loopback
|
|
||||||
+ int iRunning = ( (ifr.ifr_flags & IFF_RUNNING) && (!(ifr.ifr_flags & IFF_LOOPBACK)));
|
|
||||||
+
|
|
||||||
+ if (ioctl(m_socket, SIOCGIFADDR, &ifr) < 0)
|
|
||||||
+ return NETWORK_CONNECTION_STATE_DISCONNECTED;
|
|
||||||
+
|
|
||||||
+ // return only interfaces which has ip address
|
|
||||||
+ if (iRunning && (0 != memcmp(ifr.ifr_addr.sa_data+sizeof(short), &zero, sizeof(int))))
|
|
||||||
+ return NETWORK_CONNECTION_STATE_CONNECTED;
|
|
||||||
+ else
|
|
||||||
+ return NETWORK_CONNECTION_STATE_DISCONNECTED;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CPosixConnection::GetName() const
|
|
||||||
+{
|
|
||||||
+ return m_interfaceName;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+std::string CPosixConnection::GetIP() const
|
|
||||||
+{
|
|
||||||
+ struct ifreq ifr;
|
|
||||||
+ strcpy(ifr.ifr_name, m_interfaceName.c_str());
|
|
||||||
+ ifr.ifr_addr.sa_family = AF_INET;
|
|
||||||
+
|
|
||||||
+ if (ioctl(m_socket, SIOCGIFADDR, &ifr) >= 0)
|
|
||||||
+ return inet_ntoa((*((struct sockaddr_in *)&ifr.ifr_addr)).sin_addr);
|
|
||||||
+ else
|
|
||||||
+ return "";
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CPosixConnection::GetNetmask() const
|
|
||||||
+{
|
|
||||||
+ struct ifreq ifr;
|
|
||||||
+ strcpy(ifr.ifr_name, m_interfaceName.c_str());
|
|
||||||
+ ifr.ifr_addr.sa_family = AF_INET;
|
|
||||||
+
|
|
||||||
+ if (ioctl(m_socket, SIOCGIFNETMASK, &ifr) >= 0)
|
|
||||||
+ return inet_ntoa((*((struct sockaddr_in*)&ifr.ifr_addr)).sin_addr);
|
|
||||||
+ else
|
|
||||||
+ return "";
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CPosixConnection::GetMacAddress() const
|
|
||||||
+{
|
|
||||||
+ CStdString result = "";
|
|
||||||
+
|
|
||||||
+#ifdef __APPLE__
|
|
||||||
+ result.Format("00:00:00:00:00:00");
|
|
||||||
+#else
|
|
||||||
+ struct ifreq ifr;
|
|
||||||
+ strcpy(ifr.ifr_name, m_interfaceName.c_str());
|
|
||||||
+ if (ioctl(m_socket, SIOCGIFHWADDR, &ifr) >= 0)
|
|
||||||
+ {
|
|
||||||
+ result.Format("%hhX:%hhX:%hhX:%hhX:%hhX:%hhX", ifr.ifr_hwaddr.sa_data[0],
|
|
||||||
+ ifr.ifr_hwaddr.sa_data[1],
|
|
||||||
+ ifr.ifr_hwaddr.sa_data[2],
|
|
||||||
+ ifr.ifr_hwaddr.sa_data[3],
|
|
||||||
+ ifr.ifr_hwaddr.sa_data[4],
|
|
||||||
+ ifr.ifr_hwaddr.sa_data[5]);
|
|
||||||
+ }
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+ return result.c_str();
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CPosixConnection::GetGateway() const
|
|
||||||
+{
|
|
||||||
+ std::string result = "";
|
|
||||||
+
|
|
||||||
+#ifndef __APPLE__
|
|
||||||
+ FILE* fp = fopen("/proc/net/route", "r");
|
|
||||||
+ if (!fp)
|
|
||||||
+ return result;
|
|
||||||
+
|
|
||||||
+ char* line = NULL;
|
|
||||||
+ char iface[16];
|
|
||||||
+ char dst[128];
|
|
||||||
+ char gateway[128];
|
|
||||||
+ size_t linel = 0;
|
|
||||||
+ int n;
|
|
||||||
+ int linenum = 0;
|
|
||||||
+ while (getdelim(&line, &linel, '\n', fp) > 0)
|
|
||||||
+ {
|
|
||||||
+ // skip first two lines
|
|
||||||
+ if (linenum++ < 1)
|
|
||||||
+ continue;
|
|
||||||
+
|
|
||||||
+ // search where the word begins
|
|
||||||
+ n = sscanf(line, "%16s %128s %128s",
|
|
||||||
+ iface, dst, gateway);
|
|
||||||
+
|
|
||||||
+ if (n < 3)
|
|
||||||
+ continue;
|
|
||||||
+
|
|
||||||
+ if (strcmp(iface, m_interfaceName.c_str()) == 0 &&
|
|
||||||
+ strcmp(dst, "00000000") == 0 &&
|
|
||||||
+ strcmp(gateway, "00000000") != 0)
|
|
||||||
+ {
|
|
||||||
+ unsigned char gatewayAddr[4];
|
|
||||||
+ int len = ParseHex(gateway, gatewayAddr);
|
|
||||||
+ if (len == 4)
|
|
||||||
+ {
|
|
||||||
+ struct in_addr in;
|
|
||||||
+ in.s_addr = (gatewayAddr[0] << 24) | (gatewayAddr[1] << 16) |
|
|
||||||
+ (gatewayAddr[2] << 8) | (gatewayAddr[3]);
|
|
||||||
+ result = inet_ntoa(in);
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ free(line);
|
|
||||||
+ fclose(fp);
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+ return result;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+unsigned int CPosixConnection::GetStrength() const
|
|
||||||
+{
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+EncryptionType CPosixConnection::GetEncryption() const
|
|
||||||
+{
|
|
||||||
+ return NETWORK_CONNECTION_ENCRYPTION_NONE;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+unsigned int CPosixConnection::GetConnectionSpeed() const
|
|
||||||
+{
|
|
||||||
+ return 100;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+ConnectionType CPosixConnection::GetConnectionType() const
|
|
||||||
+{
|
|
||||||
+ return NETWORK_CONNECTION_TYPE_WIRED;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int CPosixConnection::ParseHex(char *str, unsigned char *addr)
|
|
||||||
+{
|
|
||||||
+ int len = 0;
|
|
||||||
+
|
|
||||||
+ while (*str)
|
|
||||||
+ {
|
|
||||||
+ int tmp;
|
|
||||||
+ if (str[1] == 0)
|
|
||||||
+ return -1;
|
|
||||||
+ if (sscanf(str, "%02x", (unsigned int *)&tmp) != 1)
|
|
||||||
+ return -1;
|
|
||||||
+ addr[len] = tmp;
|
|
||||||
+ len++;
|
|
||||||
+ str += 2;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return len;
|
|
||||||
+}
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/posix/PosixConnection.h xbmc-dharma-35100.patch/xbmc/posix/PosixConnection.h
|
|
||||||
--- xbmc-dharma-35100/xbmc/posix/PosixConnection.h 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/posix/PosixConnection.h 2010-11-01 21:56:49.540842060 +0100
|
|
||||||
@@ -0,0 +1,51 @@
|
|
||||||
+#pragma once
|
|
||||||
+/*
|
|
||||||
+ * Copyright (C) 2005-2010 Team XBMC
|
|
||||||
+ * http://www.xbmc.org
|
|
||||||
+ *
|
|
||||||
+ * This Program is free software; you can redistribute it and/or modify
|
|
||||||
+ * it under the terms of the GNU General Public License as published by
|
|
||||||
+ * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
+ * any later version.
|
|
||||||
+ *
|
|
||||||
+ * This Program is distributed in the hope that it will be useful,
|
|
||||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+ * GNU General Public License for more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License
|
|
||||||
+ * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
+ * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "IConnection.h"
|
|
||||||
+
|
|
||||||
+class CPosixConnection : public IConnection
|
|
||||||
+{
|
|
||||||
+public:
|
|
||||||
+ CPosixConnection(int socket, const char *interfaceName);
|
|
||||||
+ virtual ~CPosixConnection();
|
|
||||||
+
|
|
||||||
+ virtual bool Connect(IPassphraseStorage *storage, const CIPConfig &ipconfig);
|
|
||||||
+ virtual ConnectionState GetConnectionState() const;
|
|
||||||
+
|
|
||||||
+ virtual std::string GetName() const;
|
|
||||||
+
|
|
||||||
+ virtual std::string GetIP() const;
|
|
||||||
+ virtual std::string GetNetmask() const;
|
|
||||||
+ virtual std::string GetMacAddress() const;
|
|
||||||
+ virtual std::string GetGateway() const;
|
|
||||||
+
|
|
||||||
+ virtual unsigned int GetStrength() const;
|
|
||||||
+ virtual EncryptionType GetEncryption() const;
|
|
||||||
+ virtual unsigned int GetConnectionSpeed() const;
|
|
||||||
+
|
|
||||||
+ virtual ConnectionType GetConnectionType() const;
|
|
||||||
+private:
|
|
||||||
+ static int ParseHex(char *str, unsigned char *addr);
|
|
||||||
+
|
|
||||||
+ int m_socket;
|
|
||||||
+ std::string m_interfaceName;
|
|
||||||
+};
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/posix/PosixNetworkManager.cpp xbmc-dharma-35100.patch/xbmc/posix/PosixNetworkManager.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/posix/PosixNetworkManager.cpp 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/posix/PosixNetworkManager.cpp 2010-11-01 21:56:49.541842072 +0100
|
|
||||||
@@ -0,0 +1,125 @@
|
|
||||||
+/*
|
|
||||||
+ * Copyright (C) 2005-2010 Team XBMC
|
|
||||||
+ * http://www.xbmc.org
|
|
||||||
+ *
|
|
||||||
+ * This Program is free software; you can redistribute it and/or modify
|
|
||||||
+ * it under the terms of the GNU General Public License as published by
|
|
||||||
+ * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
+ * any later version.
|
|
||||||
+ *
|
|
||||||
+ * This Program is distributed in the hope that it will be useful,
|
|
||||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+ * GNU General Public License for more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License
|
|
||||||
+ * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
+ * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "PosixNetworkManager.h"
|
|
||||||
+#include "PosixConnection.h"
|
|
||||||
+
|
|
||||||
+#include <sys/ioctl.h>
|
|
||||||
+#include <sys/socket.h>
|
|
||||||
+#include <netinet/in.h>
|
|
||||||
+#include <arpa/inet.h>
|
|
||||||
+#ifndef __APPLE__
|
|
||||||
+#include <linux/if.h>
|
|
||||||
+#include <linux/wireless.h>
|
|
||||||
+#include <linux/sockios.h>
|
|
||||||
+#endif
|
|
||||||
+#include <errno.h>
|
|
||||||
+#include <resolv.h>
|
|
||||||
+#ifdef __APPLE__
|
|
||||||
+#include <sys/sockio.h>
|
|
||||||
+#include <net/if.h>
|
|
||||||
+#include <ifaddrs.h>
|
|
||||||
+#endif
|
|
||||||
+#include <net/if_arp.h>
|
|
||||||
+#include <string.h>
|
|
||||||
+
|
|
||||||
+CPosixNetworkManager::CPosixNetworkManager()
|
|
||||||
+{
|
|
||||||
+ m_socket = socket(AF_INET, SOCK_DGRAM, 0);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+CPosixNetworkManager::~CPosixNetworkManager()
|
|
||||||
+{
|
|
||||||
+ if (m_socket != -1)
|
|
||||||
+ close(m_socket);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+bool CPosixNetworkManager::CanManageConnections()
|
|
||||||
+{
|
|
||||||
+ return false;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+ConnectionList CPosixNetworkManager::GetConnections()
|
|
||||||
+{
|
|
||||||
+ ConnectionList connections;
|
|
||||||
+
|
|
||||||
+#ifdef __APPLE__
|
|
||||||
+ // Query the list of interfaces.
|
|
||||||
+ struct ifaddrs *list;
|
|
||||||
+
|
|
||||||
+ if (getifaddrs(&list) < 0)
|
|
||||||
+ return connections;
|
|
||||||
+
|
|
||||||
+ struct ifaddrs *cur;
|
|
||||||
+ for(cur = list; cur != NULL; cur = cur->ifa_next)
|
|
||||||
+ {
|
|
||||||
+ if(cur->ifa_addr->sa_family != AF_INET)
|
|
||||||
+ continue;
|
|
||||||
+
|
|
||||||
+ // Add the interface
|
|
||||||
+ connections.push_back(CConnectionPtr(new CPosixConnection(m_socket, cur->ifa_name));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ freeifaddrs(list);
|
|
||||||
+#else
|
|
||||||
+ FILE* fp = fopen("/proc/net/dev", "r");
|
|
||||||
+ if (!fp)
|
|
||||||
+ return connections;
|
|
||||||
+
|
|
||||||
+ char* line = NULL;
|
|
||||||
+ size_t linel = 0;
|
|
||||||
+ int n;
|
|
||||||
+ char* interfaceName;
|
|
||||||
+ int linenum = 0;
|
|
||||||
+
|
|
||||||
+ while (getdelim(&line, &linel, '\n', fp) > 0)
|
|
||||||
+ {
|
|
||||||
+ // skip first two lines
|
|
||||||
+ if (linenum++ < 2)
|
|
||||||
+ continue;
|
|
||||||
+
|
|
||||||
+ // search where the word begins
|
|
||||||
+ interfaceName = line;
|
|
||||||
+ while (isspace(*interfaceName))
|
|
||||||
+ ++interfaceName;
|
|
||||||
+
|
|
||||||
+ // read word until :
|
|
||||||
+ n = strcspn(interfaceName, ": \t");
|
|
||||||
+ interfaceName[n] = 0;
|
|
||||||
+
|
|
||||||
+ // make sure the device has ethernet encapsulation
|
|
||||||
+ struct ifreq ifr;
|
|
||||||
+ strcpy(ifr.ifr_name, interfaceName);
|
|
||||||
+ if (ioctl(m_socket, SIOCGIFHWADDR, &ifr) >= 0 && ifr.ifr_hwaddr.sa_family == ARPHRD_ETHER)
|
|
||||||
+ connections.push_back(CConnectionPtr(new CPosixConnection(m_socket, interfaceName)));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ free(line);
|
|
||||||
+ fclose(fp);
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+ return connections;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+bool CPosixNetworkManager::PumpNetworkEvents(INetworkEventsCallback *callback)
|
|
||||||
+{
|
|
||||||
+ return false;
|
|
||||||
+}
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/posix/PosixNetworkManager.h xbmc-dharma-35100.patch/xbmc/posix/PosixNetworkManager.h
|
|
||||||
--- xbmc-dharma-35100/xbmc/posix/PosixNetworkManager.h 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/posix/PosixNetworkManager.h 2010-11-01 21:56:49.541842072 +0100
|
|
||||||
@@ -0,0 +1,38 @@
|
|
||||||
+#pragma once
|
|
||||||
+/*
|
|
||||||
+ * Copyright (C) 2005-2010 Team XBMC
|
|
||||||
+ * http://www.xbmc.org
|
|
||||||
+ *
|
|
||||||
+ * This Program is free software; you can redistribute it and/or modify
|
|
||||||
+ * it under the terms of the GNU General Public License as published by
|
|
||||||
+ * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
+ * any later version.
|
|
||||||
+ *
|
|
||||||
+ * This Program is distributed in the hope that it will be useful,
|
|
||||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+ * GNU General Public License for more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License
|
|
||||||
+ * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
+ * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "INetworkManager.h"
|
|
||||||
+
|
|
||||||
+class CPosixNetworkManager : public INetworkManager
|
|
||||||
+{
|
|
||||||
+public:
|
|
||||||
+ CPosixNetworkManager();
|
|
||||||
+ virtual ~CPosixNetworkManager();
|
|
||||||
+
|
|
||||||
+ virtual bool CanManageConnections();
|
|
||||||
+
|
|
||||||
+ virtual ConnectionList GetConnections();
|
|
||||||
+
|
|
||||||
+ virtual bool PumpNetworkEvents(INetworkEventsCallback *callback);
|
|
||||||
+private:
|
|
||||||
+ int m_socket;
|
|
||||||
+};
|
|
@ -1,827 +0,0 @@
|
|||||||
diff -Naur xbmc-dharma-35100/xbmc/NetworkManager.cpp xbmc-dharma-35100.patch/xbmc/NetworkManager.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/NetworkManager.cpp 2010-11-01 22:09:49.135996215 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/NetworkManager.cpp 2010-11-01 22:10:13.499273830 +0100
|
|
||||||
@@ -7,6 +7,7 @@
|
|
||||||
#include "ApplicationMessenger.h"
|
|
||||||
#include "linux/ConnmanNetworkManager.h"
|
|
||||||
#include "posix/PosixNetworkManager.h"
|
|
||||||
+#include "win32/WinNetworkManager.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
@@ -33,6 +34,10 @@
|
|
||||||
m_instance = new CPosixNetworkManager();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+#ifdef _WIN32
|
|
||||||
+ m_instance = new CWinNetworkManager();
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
if (m_instance == NULL)
|
|
||||||
m_instance = new CNullNetworkManager();
|
|
||||||
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/win32/NetworkWin32.cpp xbmc-dharma-35100.patch/xbmc/win32/NetworkWin32.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/win32/NetworkWin32.cpp 2010-10-30 05:36:42.000000000 +0200
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/win32/NetworkWin32.cpp 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
@@ -1,421 +0,0 @@
|
|
||||||
-/*
|
|
||||||
- * Copyright (C) 2005-2008 Team XBMC
|
|
||||||
- * http://www.xbmc.org
|
|
||||||
- *
|
|
||||||
- * This Program is free software; you can redistribute it and/or modify
|
|
||||||
- * it under the terms of the GNU General Public License as published by
|
|
||||||
- * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
- * any later version.
|
|
||||||
- *
|
|
||||||
- * This Program is distributed in the hope that it will be useful,
|
|
||||||
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
- * GNU General Public License for more details.
|
|
||||||
- *
|
|
||||||
- * You should have received a copy of the GNU General Public License
|
|
||||||
- * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
- * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
- *
|
|
||||||
- */
|
|
||||||
-
|
|
||||||
-#include <errno.h>
|
|
||||||
-#include "PlatformDefs.h"
|
|
||||||
-#include "NetworkWin32.h"
|
|
||||||
-#include "log.h"
|
|
||||||
-#include "SingleLock.h"
|
|
||||||
-#include "CharsetConverter.h"
|
|
||||||
-
|
|
||||||
-// undefine if you want to build without the wlan stuff
|
|
||||||
-// might be needed for VS2003
|
|
||||||
-//#define HAS_WIN32_WLAN_API
|
|
||||||
-
|
|
||||||
-#ifdef HAS_WIN32_WLAN_API
|
|
||||||
-#include "Wlanapi.h"
|
|
||||||
-#pragma comment (lib,"Wlanapi.lib")
|
|
||||||
-#endif
|
|
||||||
-
|
|
||||||
-
|
|
||||||
-using namespace std;
|
|
||||||
-
|
|
||||||
-CNetworkInterfaceWin32::CNetworkInterfaceWin32(CNetworkWin32* network, IP_ADAPTER_INFO adapter)
|
|
||||||
-
|
|
||||||
-{
|
|
||||||
- m_network = network;
|
|
||||||
- m_adapter = adapter;
|
|
||||||
- m_adaptername = adapter.Description;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-CNetworkInterfaceWin32::~CNetworkInterfaceWin32(void)
|
|
||||||
-{
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-CStdString& CNetworkInterfaceWin32::GetName(void)
|
|
||||||
-{
|
|
||||||
- if (!g_charsetConverter.isValidUtf8(m_adaptername))
|
|
||||||
- g_charsetConverter.unknownToUTF8(m_adaptername);
|
|
||||||
- return m_adaptername;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-bool CNetworkInterfaceWin32::IsWireless()
|
|
||||||
-{
|
|
||||||
- return (m_adapter.Type == IF_TYPE_IEEE80211);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-bool CNetworkInterfaceWin32::IsEnabled()
|
|
||||||
-{
|
|
||||||
- return true;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-bool CNetworkInterfaceWin32::IsConnected()
|
|
||||||
-{
|
|
||||||
- CStdString strIP = m_adapter.IpAddressList.IpAddress.String;
|
|
||||||
- return (strIP != "0.0.0.0");
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-CStdString CNetworkInterfaceWin32::GetMacAddress()
|
|
||||||
-{
|
|
||||||
- CStdString result = "";
|
|
||||||
- result = CStdString((char*)m_adapter.Address);
|
|
||||||
- return result;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-CStdString CNetworkInterfaceWin32::GetCurrentIPAddress(void)
|
|
||||||
-{
|
|
||||||
- return m_adapter.IpAddressList.IpAddress.String;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-CStdString CNetworkInterfaceWin32::GetCurrentNetmask(void)
|
|
||||||
-{
|
|
||||||
- return m_adapter.IpAddressList.IpMask.String;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-CStdString CNetworkInterfaceWin32::GetCurrentWirelessEssId(void)
|
|
||||||
-{
|
|
||||||
- CStdString result = "";
|
|
||||||
-
|
|
||||||
-#ifdef HAS_WIN32_WLAN_API
|
|
||||||
- if(IsWireless())
|
|
||||||
- {
|
|
||||||
- HANDLE hClientHdl = NULL;
|
|
||||||
- DWORD dwVersion = 0;
|
|
||||||
- DWORD dwret = 0;
|
|
||||||
- PWLAN_CONNECTION_ATTRIBUTES pAttributes;
|
|
||||||
- DWORD dwSize = 0;
|
|
||||||
-
|
|
||||||
- if(WlanOpenHandle(1,NULL,&dwVersion, &hClientHdl) == ERROR_SUCCESS)
|
|
||||||
- {
|
|
||||||
- PWLAN_INTERFACE_INFO_LIST ppInterfaceList;
|
|
||||||
- if(WlanEnumInterfaces(hClientHdl,NULL, &ppInterfaceList ) == ERROR_SUCCESS)
|
|
||||||
- {
|
|
||||||
- for(int i=0; i<ppInterfaceList->dwNumberOfItems;i++)
|
|
||||||
- {
|
|
||||||
- GUID guid = ppInterfaceList->InterfaceInfo[i].InterfaceGuid;
|
|
||||||
- WCHAR wcguid[64];
|
|
||||||
- StringFromGUID2(guid, (LPOLESTR)&wcguid, 64);
|
|
||||||
- CStdStringW strGuid = wcguid;
|
|
||||||
- CStdStringW strAdaptername = m_adapter.AdapterName;
|
|
||||||
- if( strGuid == strAdaptername)
|
|
||||||
- {
|
|
||||||
- if(WlanQueryInterface(hClientHdl,&ppInterfaceList->InterfaceInfo[i].InterfaceGuid,wlan_intf_opcode_current_connection, NULL, &dwSize, (PVOID*)&pAttributes, NULL ) == ERROR_SUCCESS)
|
|
||||||
- {
|
|
||||||
- result = (char*)pAttributes->wlanAssociationAttributes.dot11Ssid.ucSSID;
|
|
||||||
- WlanFreeMemory((PVOID*)&pAttributes);
|
|
||||||
- }
|
|
||||||
- else
|
|
||||||
- OutputDebugString("Can't query wlan interface\n");
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- WlanCloseHandle(&hClientHdl, NULL);
|
|
||||||
- }
|
|
||||||
- else
|
|
||||||
- OutputDebugString("Can't open wlan handle\n");
|
|
||||||
- }
|
|
||||||
-#endif
|
|
||||||
- return result;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-CStdString CNetworkInterfaceWin32::GetCurrentDefaultGateway(void)
|
|
||||||
-{
|
|
||||||
- return m_adapter.GatewayList.IpAddress.String;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-CNetworkWin32::CNetworkWin32(void)
|
|
||||||
-{
|
|
||||||
- queryInterfaceList();
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-CNetworkWin32::~CNetworkWin32(void)
|
|
||||||
-{
|
|
||||||
- CleanInterfaceList();
|
|
||||||
- m_netrefreshTimer.Stop();
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-void CNetworkWin32::CleanInterfaceList()
|
|
||||||
-{
|
|
||||||
- vector<CNetworkInterface*>::iterator it = m_interfaces.begin();
|
|
||||||
- while(it != m_interfaces.end())
|
|
||||||
- {
|
|
||||||
- CNetworkInterface* nInt = *it;
|
|
||||||
- delete nInt;
|
|
||||||
- it = m_interfaces.erase(it);
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-std::vector<CNetworkInterface*>& CNetworkWin32::GetInterfaceList(void)
|
|
||||||
-{
|
|
||||||
- CSingleLock lock (m_critSection);
|
|
||||||
- if(m_netrefreshTimer.GetElapsedSeconds() >= 5.0f)
|
|
||||||
- queryInterfaceList();
|
|
||||||
-
|
|
||||||
- return m_interfaces;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-void CNetworkWin32::queryInterfaceList()
|
|
||||||
-{
|
|
||||||
- CleanInterfaceList();
|
|
||||||
- m_netrefreshTimer.StartZero();
|
|
||||||
-
|
|
||||||
- PIP_ADAPTER_INFO adapterInfo;
|
|
||||||
- PIP_ADAPTER_INFO adapter = NULL;
|
|
||||||
-
|
|
||||||
- ULONG ulOutBufLen = sizeof (IP_ADAPTER_INFO);
|
|
||||||
-
|
|
||||||
- adapterInfo = (IP_ADAPTER_INFO *) malloc(sizeof (IP_ADAPTER_INFO));
|
|
||||||
- if (adapterInfo == NULL)
|
|
||||||
- return;
|
|
||||||
-
|
|
||||||
- if (GetAdaptersInfo(adapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW)
|
|
||||||
- {
|
|
||||||
- free(adapterInfo);
|
|
||||||
- adapterInfo = (IP_ADAPTER_INFO *) malloc(ulOutBufLen);
|
|
||||||
- if (adapterInfo == NULL)
|
|
||||||
- {
|
|
||||||
- OutputDebugString("Error allocating memory needed to call GetAdaptersinfo\n");
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if ((GetAdaptersInfo(adapterInfo, &ulOutBufLen)) == NO_ERROR)
|
|
||||||
- {
|
|
||||||
- adapter = adapterInfo;
|
|
||||||
- while (adapter)
|
|
||||||
- {
|
|
||||||
- m_interfaces.push_back(new CNetworkInterfaceWin32(this, *adapter));
|
|
||||||
-
|
|
||||||
- adapter = adapter->Next;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- free(adapterInfo);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-std::vector<CStdString> CNetworkWin32::GetNameServers(void)
|
|
||||||
-{
|
|
||||||
- std::vector<CStdString> result;
|
|
||||||
-
|
|
||||||
- FIXED_INFO *pFixedInfo;
|
|
||||||
- ULONG ulOutBufLen;
|
|
||||||
- IP_ADDR_STRING *pIPAddr;
|
|
||||||
-
|
|
||||||
- pFixedInfo = (FIXED_INFO *) malloc(sizeof (FIXED_INFO));
|
|
||||||
- if (pFixedInfo == NULL)
|
|
||||||
- {
|
|
||||||
- OutputDebugString("Error allocating memory needed to call GetNetworkParams\n");
|
|
||||||
- return result;
|
|
||||||
- }
|
|
||||||
- ulOutBufLen = sizeof (FIXED_INFO);
|
|
||||||
- if (GetNetworkParams(pFixedInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW)
|
|
||||||
- {
|
|
||||||
- free(pFixedInfo);
|
|
||||||
- pFixedInfo = (FIXED_INFO *) malloc(ulOutBufLen);
|
|
||||||
- if (pFixedInfo == NULL)
|
|
||||||
- {
|
|
||||||
- OutputDebugString("Error allocating memory needed to call GetNetworkParams\n");
|
|
||||||
- return result;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (GetNetworkParams(pFixedInfo, &ulOutBufLen) == NO_ERROR)
|
|
||||||
- {
|
|
||||||
- result.push_back(pFixedInfo->DnsServerList.IpAddress.String);
|
|
||||||
- pIPAddr = pFixedInfo->DnsServerList.Next;
|
|
||||||
- while(pIPAddr)
|
|
||||||
- {
|
|
||||||
- result.push_back(pIPAddr->IpAddress.String);
|
|
||||||
- pIPAddr = pIPAddr->Next;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- }
|
|
||||||
- free(pFixedInfo);
|
|
||||||
-
|
|
||||||
- return result;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-void CNetworkWin32::SetNameServers(std::vector<CStdString> nameServers)
|
|
||||||
-{
|
|
||||||
- FILE* fp = fopen("/etc/resolv.conf", "w");
|
|
||||||
- if (fp != NULL)
|
|
||||||
- {
|
|
||||||
- for (unsigned int i = 0; i < nameServers.size(); i++)
|
|
||||||
- {
|
|
||||||
- fprintf(fp, "nameserver %s\n", nameServers[i].c_str());
|
|
||||||
- }
|
|
||||||
- fclose(fp);
|
|
||||||
- }
|
|
||||||
- else
|
|
||||||
- {
|
|
||||||
- // TODO:
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-std::vector<NetworkAccessPoint> CNetworkInterfaceWin32::GetAccessPoints(void)
|
|
||||||
-{
|
|
||||||
- std::vector<NetworkAccessPoint> result;
|
|
||||||
-
|
|
||||||
- /*if (!IsWireless())
|
|
||||||
- return result;*/
|
|
||||||
-
|
|
||||||
- return result;
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-void CNetworkInterfaceWin32::GetSettings(NetworkAssignment& assignment, CStdString& ipAddress, CStdString& networkMask, CStdString& defaultGateway, CStdString& essId, CStdString& key, EncMode& encryptionMode)
|
|
||||||
-{
|
|
||||||
- ipAddress = "0.0.0.0";
|
|
||||||
- networkMask = "0.0.0.0";
|
|
||||||
- defaultGateway = "0.0.0.0";
|
|
||||||
- essId = "";
|
|
||||||
- key = "";
|
|
||||||
- encryptionMode = ENC_NONE;
|
|
||||||
- assignment = NETWORK_DISABLED;
|
|
||||||
-
|
|
||||||
-
|
|
||||||
- PIP_ADAPTER_INFO adapterInfo;
|
|
||||||
- PIP_ADAPTER_INFO adapter = NULL;
|
|
||||||
-
|
|
||||||
- ULONG ulOutBufLen = sizeof (IP_ADAPTER_INFO);
|
|
||||||
-
|
|
||||||
- adapterInfo = (IP_ADAPTER_INFO *) malloc(sizeof (IP_ADAPTER_INFO));
|
|
||||||
- if (adapterInfo == NULL)
|
|
||||||
- return;
|
|
||||||
-
|
|
||||||
- if (GetAdaptersInfo(adapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW)
|
|
||||||
- {
|
|
||||||
- free(adapterInfo);
|
|
||||||
- adapterInfo = (IP_ADAPTER_INFO *) malloc(ulOutBufLen);
|
|
||||||
- if (adapterInfo == NULL)
|
|
||||||
- {
|
|
||||||
- OutputDebugString("Error allocating memory needed to call GetAdaptersinfo\n");
|
|
||||||
- return;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if ((GetAdaptersInfo(adapterInfo, &ulOutBufLen)) == NO_ERROR)
|
|
||||||
- {
|
|
||||||
- adapter = adapterInfo;
|
|
||||||
- while (adapter)
|
|
||||||
- {
|
|
||||||
- if(m_adapter.Index == adapter->Index)
|
|
||||||
- {
|
|
||||||
- ipAddress = adapter->IpAddressList.IpAddress.String;
|
|
||||||
- networkMask = adapter->IpAddressList.IpMask.String;
|
|
||||||
- defaultGateway = adapter->GatewayList.IpAddress.String;
|
|
||||||
- if (adapter->DhcpEnabled)
|
|
||||||
- assignment = NETWORK_DHCP;
|
|
||||||
- else
|
|
||||||
- assignment = NETWORK_STATIC;
|
|
||||||
-
|
|
||||||
- }
|
|
||||||
- adapter = adapter->Next;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- free(adapterInfo);
|
|
||||||
-
|
|
||||||
-#ifdef HAS_WIN32_WLAN_API
|
|
||||||
- if(IsWireless())
|
|
||||||
- {
|
|
||||||
- HANDLE hClientHdl = NULL;
|
|
||||||
- DWORD dwVersion = 0;
|
|
||||||
- DWORD dwret = 0;
|
|
||||||
- PWLAN_CONNECTION_ATTRIBUTES pAttributes;
|
|
||||||
- DWORD dwSize = 0;
|
|
||||||
-
|
|
||||||
- if(WlanOpenHandle(1,NULL,&dwVersion, &hClientHdl) == ERROR_SUCCESS)
|
|
||||||
- {
|
|
||||||
- PWLAN_INTERFACE_INFO_LIST ppInterfaceList;
|
|
||||||
- if(WlanEnumInterfaces(hClientHdl,NULL, &ppInterfaceList ) == ERROR_SUCCESS)
|
|
||||||
- {
|
|
||||||
- for(int i=0; i<ppInterfaceList->dwNumberOfItems;i++)
|
|
||||||
- {
|
|
||||||
- GUID guid = ppInterfaceList->InterfaceInfo[i].InterfaceGuid;
|
|
||||||
- WCHAR wcguid[64];
|
|
||||||
- StringFromGUID2(guid, (LPOLESTR)&wcguid, 64);
|
|
||||||
- CStdStringW strGuid = wcguid;
|
|
||||||
- CStdStringW strAdaptername = m_adapter.AdapterName;
|
|
||||||
- if( strGuid == strAdaptername)
|
|
||||||
- {
|
|
||||||
- if(WlanQueryInterface(hClientHdl,&ppInterfaceList->InterfaceInfo[i].InterfaceGuid,wlan_intf_opcode_current_connection, NULL, &dwSize, (PVOID*)&pAttributes, NULL ) == ERROR_SUCCESS)
|
|
||||||
- {
|
|
||||||
- essId = (char*)pAttributes->wlanAssociationAttributes.dot11Ssid.ucSSID;
|
|
||||||
- if(pAttributes->wlanSecurityAttributes.bSecurityEnabled)
|
|
||||||
- {
|
|
||||||
- switch(pAttributes->wlanSecurityAttributes.dot11AuthAlgorithm)
|
|
||||||
- {
|
|
||||||
- case DOT11_AUTH_ALGO_80211_SHARED_KEY:
|
|
||||||
- encryptionMode = ENC_WEP;
|
|
||||||
- break;
|
|
||||||
- case DOT11_AUTH_ALGO_WPA:
|
|
||||||
- case DOT11_AUTH_ALGO_WPA_PSK:
|
|
||||||
- encryptionMode = ENC_WPA;
|
|
||||||
- break;
|
|
||||||
- case DOT11_AUTH_ALGO_RSNA:
|
|
||||||
- case DOT11_AUTH_ALGO_RSNA_PSK:
|
|
||||||
- encryptionMode = ENC_WPA2;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- WlanFreeMemory((PVOID*)&pAttributes);
|
|
||||||
- }
|
|
||||||
- else
|
|
||||||
- OutputDebugString("Can't query wlan interface\n");
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- WlanCloseHandle(&hClientHdl, NULL);
|
|
||||||
- }
|
|
||||||
- else
|
|
||||||
- OutputDebugString("Can't open wlan handle\n");
|
|
||||||
- }
|
|
||||||
- // Todo: get the key (WlanGetProfile, CryptUnprotectData?)
|
|
||||||
-#endif
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-void CNetworkInterfaceWin32::SetSettings(NetworkAssignment& assignment, CStdString& ipAddress, CStdString& networkMask, CStdString& defaultGateway, CStdString& essId, CStdString& key, EncMode& encryptionMode)
|
|
||||||
-{
|
|
||||||
- if(IsWireless())
|
|
||||||
- {
|
|
||||||
- }
|
|
||||||
- else
|
|
||||||
- {
|
|
||||||
- /*if(assignment == NETWORK_STATIC)
|
|
||||||
- {
|
|
||||||
- DWORD dwRet = 0;
|
|
||||||
- ULONG NTEContext = 0;
|
|
||||||
- ULONG NTEInstance;
|
|
||||||
-
|
|
||||||
- if((dwRet = AddIPAddress(inet_addr(ipAddress.c_str()), inet_addr(networkMask.c_str()), m_adapter.Index, &NTEContext, &NTEInstance)) == NO_ERROR)
|
|
||||||
- {
|
|
||||||
- if((dwRet = DeleteIPAddress(m_adapter.IpAddressList.Context)) != NO_ERROR)
|
|
||||||
- CLog::Log(LOGERROR, "Unable to delete IP entry: %s, Error code: %d",m_adapter.IpAddressList.IpAddress.String, dwRet);
|
|
||||||
- }
|
|
||||||
- else
|
|
||||||
- CLog::Log(LOGERROR, "Unable to add IP entry: %s, Error code: %d", ipAddress.c_str(),dwRet);
|
|
||||||
- }*/
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-void CNetworkInterfaceWin32::WriteSettings(FILE* fw, NetworkAssignment assignment, CStdString& ipAddress, CStdString& networkMask, CStdString& defaultGateway, CStdString& essId, CStdString& key, EncMode& encryptionMode)
|
|
||||||
-{
|
|
||||||
- return;
|
|
||||||
-}
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/win32/NetworkWin32.h xbmc-dharma-35100.patch/xbmc/win32/NetworkWin32.h
|
|
||||||
--- xbmc-dharma-35100/xbmc/win32/NetworkWin32.h 2010-10-30 05:36:42.000000000 +0200
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/win32/NetworkWin32.h 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
@@ -1,91 +0,0 @@
|
|
||||||
-#ifndef NETWORK_LINUX_H_
|
|
||||||
-#define NETWORK_LINUX_H_
|
|
||||||
-
|
|
||||||
-/*
|
|
||||||
- * Copyright (C) 2005-2008 Team XBMC
|
|
||||||
- * http://www.xbmc.org
|
|
||||||
- *
|
|
||||||
- * This Program is free software; you can redistribute it and/or modify
|
|
||||||
- * it under the terms of the GNU General Public License as published by
|
|
||||||
- * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
- * any later version.
|
|
||||||
- *
|
|
||||||
- * This Program is distributed in the hope that it will be useful,
|
|
||||||
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
- * GNU General Public License for more details.
|
|
||||||
- *
|
|
||||||
- * You should have received a copy of the GNU General Public License
|
|
||||||
- * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
- * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
- *
|
|
||||||
- */
|
|
||||||
-
|
|
||||||
-#include <vector>
|
|
||||||
-#include "StdString.h"
|
|
||||||
-#include "utils/Network.h"
|
|
||||||
-#include "Iphlpapi.h"
|
|
||||||
-#include "stopwatch.h"
|
|
||||||
-#include "utils/CriticalSection.h"
|
|
||||||
-
|
|
||||||
-class CNetworkWin32;
|
|
||||||
-
|
|
||||||
-class CNetworkInterfaceWin32 : public CNetworkInterface
|
|
||||||
-{
|
|
||||||
-public:
|
|
||||||
- CNetworkInterfaceWin32(CNetworkWin32* network, IP_ADAPTER_INFO adapter);
|
|
||||||
- ~CNetworkInterfaceWin32(void);
|
|
||||||
-
|
|
||||||
- virtual CStdString& GetName(void);
|
|
||||||
-
|
|
||||||
- virtual bool IsEnabled(void);
|
|
||||||
- virtual bool IsConnected(void);
|
|
||||||
- virtual bool IsWireless(void);
|
|
||||||
-
|
|
||||||
- virtual CStdString GetMacAddress(void);
|
|
||||||
-
|
|
||||||
- virtual CStdString GetCurrentIPAddress();
|
|
||||||
- virtual CStdString GetCurrentNetmask();
|
|
||||||
- virtual CStdString GetCurrentDefaultGateway(void);
|
|
||||||
- virtual CStdString GetCurrentWirelessEssId(void);
|
|
||||||
-
|
|
||||||
- virtual void GetSettings(NetworkAssignment& assignment, CStdString& ipAddress, CStdString& networkMask, CStdString& defaultGateway, CStdString& essId, CStdString& key, EncMode& encryptionMode);
|
|
||||||
- virtual void SetSettings(NetworkAssignment& assignment, CStdString& ipAddress, CStdString& networkMask, CStdString& defaultGateway, CStdString& essId, CStdString& key, EncMode& encryptionMode);
|
|
||||||
-
|
|
||||||
- // Returns the list of access points in the area
|
|
||||||
- virtual std::vector<NetworkAccessPoint> GetAccessPoints(void);
|
|
||||||
-
|
|
||||||
-private:
|
|
||||||
- void WriteSettings(FILE* fw, NetworkAssignment assignment, CStdString& ipAddress, CStdString& networkMask, CStdString& defaultGateway, CStdString& essId, CStdString& key, EncMode& encryptionMode);
|
|
||||||
- IP_ADAPTER_INFO m_adapter;
|
|
||||||
- CNetworkWin32* m_network;
|
|
||||||
- CStdString m_adaptername;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-class CNetworkWin32 : public CNetwork
|
|
||||||
-{
|
|
||||||
-public:
|
|
||||||
- CNetworkWin32(void);
|
|
||||||
- virtual ~CNetworkWin32(void);
|
|
||||||
-
|
|
||||||
- // Return the list of interfaces
|
|
||||||
- virtual std::vector<CNetworkInterface*>& GetInterfaceList(void);
|
|
||||||
-
|
|
||||||
- // Get/set the nameserver(s)
|
|
||||||
- virtual std::vector<CStdString> GetNameServers(void);
|
|
||||||
- virtual void SetNameServers(std::vector<CStdString> nameServers);
|
|
||||||
-
|
|
||||||
- friend class CNetworkInterfaceWin32;
|
|
||||||
-
|
|
||||||
-private:
|
|
||||||
- int GetSocket() { return m_sock; }
|
|
||||||
- void queryInterfaceList();
|
|
||||||
- void CleanInterfaceList();
|
|
||||||
- std::vector<CNetworkInterface*> m_interfaces;
|
|
||||||
- int m_sock;
|
|
||||||
- CStopWatch m_netrefreshTimer;
|
|
||||||
- CCriticalSection m_critSection;
|
|
||||||
-};
|
|
||||||
-
|
|
||||||
-#endif
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/win32/WinConnection.cpp xbmc-dharma-35100.patch/xbmc/win32/WinConnection.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/win32/WinConnection.cpp 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/win32/WinConnection.cpp 2010-11-01 22:10:13.522274091 +0100
|
|
||||||
@@ -0,0 +1,95 @@
|
|
||||||
+/*
|
|
||||||
+ * Copyright (C) 2005-2010 Team XBMC
|
|
||||||
+ * http://www.xbmc.org
|
|
||||||
+ *
|
|
||||||
+ * This Program is free software; you can redistribute it and/or modify
|
|
||||||
+ * it under the terms of the GNU General Public License as published by
|
|
||||||
+ * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
+ * any later version.
|
|
||||||
+ *
|
|
||||||
+ * This Program is distributed in the hope that it will be useful,
|
|
||||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+ * GNU General Public License for more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License
|
|
||||||
+ * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
+ * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "WinConnection.h"
|
|
||||||
+#ifdef _WIN32
|
|
||||||
+#include "StdString.h"
|
|
||||||
+
|
|
||||||
+CWinConnection::CWinConnection(IP_ADAPTER_INFO adapter)
|
|
||||||
+{
|
|
||||||
+ m_adapter = adapter;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+CWinConnection::~CWinConnection()
|
|
||||||
+{
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+bool CWinConnection::Connect(IPassphraseStorage *storage, const CIPConfig &ipconfig)
|
|
||||||
+{
|
|
||||||
+ return false;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+ConnectionState CWinConnection::GetConnectionState() const
|
|
||||||
+{
|
|
||||||
+ CStdString strIP = m_adapter.IpAddressList.IpAddress.String;
|
|
||||||
+
|
|
||||||
+ if (strIP != "0.0.0.0")
|
|
||||||
+ return NETWORK_CONNECTION_STATE_CONNECTED;
|
|
||||||
+ else
|
|
||||||
+ return NETWORK_CONNECTION_STATE_DISCONNECTED;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CWinConnection::GetName() const
|
|
||||||
+{
|
|
||||||
+ return adapter.Description;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+std::string CWinConnection::GetIP() const
|
|
||||||
+{
|
|
||||||
+ return m_adapter.IpAddressList.IpAddress.String;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CWinConnection::GetNetmask() const
|
|
||||||
+{
|
|
||||||
+ return m_adapter.IpAddressList.IpMask.String;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CWinConnection::GetMacAddress() const
|
|
||||||
+{
|
|
||||||
+ return std::string((char*)m_adapter.Address);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+std::string CWinConnection::GetGateway() const
|
|
||||||
+{
|
|
||||||
+ return m_adapter.GatewayList.IpAddress.String;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+unsigned int CWinConnection::GetStrength() const
|
|
||||||
+{
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+EncryptionType CWinConnection::GetEncryption() const
|
|
||||||
+{
|
|
||||||
+ return NETWORK_CONNECTION_ENCRYPTION_NONE;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+unsigned int CWinConnection::GetConnectionSpeed() const
|
|
||||||
+{
|
|
||||||
+ return 100;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+ConnectionType CWinConnection::GetConnectionType() const
|
|
||||||
+{
|
|
||||||
+ return NETWORK_CONNECTION_TYPE_WIRED;
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/win32/WinConnection.h xbmc-dharma-35100.patch/xbmc/win32/WinConnection.h
|
|
||||||
--- xbmc-dharma-35100/xbmc/win32/WinConnection.h 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/win32/WinConnection.h 2010-11-01 22:10:13.525274127 +0100
|
|
||||||
@@ -0,0 +1,52 @@
|
|
||||||
+#pragma once
|
|
||||||
+/*
|
|
||||||
+ * Copyright (C) 2005-2010 Team XBMC
|
|
||||||
+ * http://www.xbmc.org
|
|
||||||
+ *
|
|
||||||
+ * This Program is free software; you can redistribute it and/or modify
|
|
||||||
+ * it under the terms of the GNU General Public License as published by
|
|
||||||
+ * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
+ * any later version.
|
|
||||||
+ *
|
|
||||||
+ * This Program is distributed in the hope that it will be useful,
|
|
||||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+ * GNU General Public License for more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License
|
|
||||||
+ * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
+ * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "system.h"
|
|
||||||
+#ifdef _WIN32
|
|
||||||
+#include "IConnection.h"
|
|
||||||
+#include "Iphlpapi.h"
|
|
||||||
+
|
|
||||||
+class CWinConnection : public IConnection
|
|
||||||
+{
|
|
||||||
+public:
|
|
||||||
+ CWinConnection(IP_ADAPTER_INFO adapter);
|
|
||||||
+ virtual ~CWinConnection();
|
|
||||||
+
|
|
||||||
+ virtual bool Connect(IPassphraseStorage *storage, const CIPConfig &ipconfig);
|
|
||||||
+ virtual ConnectionState GetConnectionState() const;
|
|
||||||
+
|
|
||||||
+ virtual std::string GetName() const;
|
|
||||||
+
|
|
||||||
+ virtual std::string GetIP() const;
|
|
||||||
+ virtual std::string GetNetmask() const;
|
|
||||||
+ virtual std::string GetMacAddress() const;
|
|
||||||
+ virtual std::string GetGateway() const;
|
|
||||||
+
|
|
||||||
+ virtual unsigned int GetStrength() const;
|
|
||||||
+ virtual EncryptionType GetEncryption() const;
|
|
||||||
+ virtual unsigned int GetConnectionSpeed() const;
|
|
||||||
+
|
|
||||||
+ virtual ConnectionType GetConnectionType() const;
|
|
||||||
+private:
|
|
||||||
+ IP_ADAPTER_INFO m_adapter;
|
|
||||||
+};
|
|
||||||
+#endif
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/win32/WinNetworkManager.cpp xbmc-dharma-35100.patch/xbmc/win32/WinNetworkManager.cpp
|
|
||||||
--- xbmc-dharma-35100/xbmc/win32/WinNetworkManager.cpp 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/win32/WinNetworkManager.cpp 2010-11-01 22:10:13.533274216 +0100
|
|
||||||
@@ -0,0 +1,83 @@
|
|
||||||
+/*
|
|
||||||
+ * Copyright (C) 2005-2010 Team XBMC
|
|
||||||
+ * http://www.xbmc.org
|
|
||||||
+ *
|
|
||||||
+ * This Program is free software; you can redistribute it and/or modify
|
|
||||||
+ * it under the terms of the GNU General Public License as published by
|
|
||||||
+ * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
+ * any later version.
|
|
||||||
+ *
|
|
||||||
+ * This Program is distributed in the hope that it will be useful,
|
|
||||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+ * GNU General Public License for more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License
|
|
||||||
+ * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
+ * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "WinNetworkManager.h"
|
|
||||||
+#ifdef _WIN32
|
|
||||||
+#include "WinConnection.h"
|
|
||||||
+
|
|
||||||
+CWinNetworkManager::CWinNetworkManager()
|
|
||||||
+{
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+CWinNetworkManager::~CWinNetworkManager()
|
|
||||||
+{
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+bool CWinNetworkManager::CanManageConnections()
|
|
||||||
+{
|
|
||||||
+ return false;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+ConnectionList CWinNetworkManager::GetConnections()
|
|
||||||
+{
|
|
||||||
+ ConnectionList connections;
|
|
||||||
+
|
|
||||||
+ PIP_ADAPTER_INFO adapterInfo;
|
|
||||||
+ PIP_ADAPTER_INFO adapter = NULL;
|
|
||||||
+
|
|
||||||
+ ULONG ulOutBufLen = sizeof (IP_ADAPTER_INFO);
|
|
||||||
+
|
|
||||||
+ adapterInfo = (IP_ADAPTER_INFO *) malloc(sizeof (IP_ADAPTER_INFO));
|
|
||||||
+ if (adapterInfo == NULL)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ if (GetAdaptersInfo(adapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW)
|
|
||||||
+ {
|
|
||||||
+ free(adapterInfo);
|
|
||||||
+ adapterInfo = (IP_ADAPTER_INFO *) malloc(ulOutBufLen);
|
|
||||||
+ if (adapterInfo == NULL)
|
|
||||||
+ {
|
|
||||||
+ OutputDebugString("Error allocating memory needed to call GetAdaptersinfo\n");
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if ((GetAdaptersInfo(adapterInfo, &ulOutBufLen)) == NO_ERROR)
|
|
||||||
+ {
|
|
||||||
+ adapter = adapterInfo;
|
|
||||||
+ while (adapter)
|
|
||||||
+ {
|
|
||||||
+ connections.push_back(CConnectionPtr(new CWinConnection(*adapter)));
|
|
||||||
+
|
|
||||||
+ adapter = adapter->Next;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ free(adapterInfo);
|
|
||||||
+
|
|
||||||
+ return connections;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+bool CWinNetworkManager::PumpNetworkEvents(INetworkEventsCallback *callback)
|
|
||||||
+{
|
|
||||||
+ return false;
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
diff -Naur xbmc-dharma-35100/xbmc/win32/WinNetworkManager.h xbmc-dharma-35100.patch/xbmc/win32/WinNetworkManager.h
|
|
||||||
--- xbmc-dharma-35100/xbmc/win32/WinNetworkManager.h 1970-01-01 01:00:00.000000000 +0100
|
|
||||||
+++ xbmc-dharma-35100.patch/xbmc/win32/WinNetworkManager.h 2010-11-01 22:10:13.533274216 +0100
|
|
||||||
@@ -0,0 +1,39 @@
|
|
||||||
+#pragma once
|
|
||||||
+/*
|
|
||||||
+ * Copyright (C) 2005-2010 Team XBMC
|
|
||||||
+ * http://www.xbmc.org
|
|
||||||
+ *
|
|
||||||
+ * This Program is free software; you can redistribute it and/or modify
|
|
||||||
+ * it under the terms of the GNU General Public License as published by
|
|
||||||
+ * the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
+ * any later version.
|
|
||||||
+ *
|
|
||||||
+ * This Program is distributed in the hope that it will be useful,
|
|
||||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+ * GNU General Public License for more details.
|
|
||||||
+ *
|
|
||||||
+ * You should have received a copy of the GNU General Public License
|
|
||||||
+ * along with XBMC; see the file COPYING. If not, write to
|
|
||||||
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
+ * http://www.gnu.org/copyleft/gpl.html
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "system.h"
|
|
||||||
+#ifdef _WIN32
|
|
||||||
+#include "INetworkManager.h"
|
|
||||||
+
|
|
||||||
+class CWinNetworkManager : public INetworkManager
|
|
||||||
+{
|
|
||||||
+public:
|
|
||||||
+ CWinNetworkManager();
|
|
||||||
+ virtual ~CWinNetworkManager();
|
|
||||||
+
|
|
||||||
+ virtual bool CanManageConnections();
|
|
||||||
+
|
|
||||||
+ virtual ConnectionList GetConnections();
|
|
||||||
+
|
|
||||||
+ virtual bool PumpNetworkEvents(INetworkEventsCallback *callback);
|
|
||||||
+};
|
|
||||||
+#endif
|
|
Loading…
x
Reference in New Issue
Block a user