mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-01 18:01:06 +02:00
gui/nfs: implement mac address lookup
Conflicts:
src/gui/moviebrowser.cpp
src/gui/nfs.cpp
Origin commit data
------------------
Commit: 706ea95092
Author: martii <m4rtii@gmx.de>
Date: 2013-06-29 (Sat, 29 Jun 2013)
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <system/helpers.h>
|
||||
#include <global.h>
|
||||
|
||||
#include <errno.h>
|
||||
@@ -54,6 +55,8 @@
|
||||
#include <neutrino.h>
|
||||
#include <zapit/client/zapittools.h>
|
||||
|
||||
extern int pinghost (const std::string &hostname, std::string *ip = NULL);
|
||||
|
||||
CNFSMountGui::CNFSMountGui()
|
||||
{
|
||||
// FIXME #warning move probing from exec() to fsmounter
|
||||
@@ -134,6 +137,27 @@ int CNFSMountGui::exec( CMenuTarget* parent, const std::string & actionKey )
|
||||
ISO_8859_1_entry[i] = ZapitTools::UTF8_to_Latin1(m_entry[i].c_str());
|
||||
}
|
||||
}
|
||||
else if(actionKey.substr(0,10)=="refreshMAC")
|
||||
{
|
||||
int nr=atoi(actionKey.substr(10,1));
|
||||
std::string h;
|
||||
pinghost(g_settings.network_nfs[nr].ip, &h);
|
||||
if (!h.empty()) {
|
||||
FILE *arptable = fopen("/proc/net/arp", "r");
|
||||
if (arptable) {
|
||||
char line[120], ip[120], mac[120];
|
||||
while (fgets(line, sizeof(line), arptable)) {
|
||||
if (2 == sscanf(line, "%s %*s %*s %s %*[^\n]", ip, mac)) {
|
||||
if (!strcmp(ip, h.c_str())) {
|
||||
g_settings.network_nfs[nr].mac = std::string(mac);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(arptable);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(actionKey.substr(0,10)=="mountentry")
|
||||
{
|
||||
parent->hide();
|
||||
@@ -261,7 +285,9 @@ int CNFSMountGui::menuEntry(int nr)
|
||||
CMenuForwarder *password_fwd = new CMenuForwarder(LOCALE_NFS_PASSWORD, (type != (int)CFSMounter::NFS), NULL, &passInput);
|
||||
|
||||
CMACInput macInput(LOCALE_RECORDINGMENU_SERVER_MAC, &g_settings.network_nfs[nr].mac, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2);
|
||||
CMenuForwarder * macInput_fwd = new CMenuForwarder(LOCALE_RECORDINGMENU_SERVER_MAC, true, g_settings.network_nfs[nr].mac, &macInput);
|
||||
CMenuForwarder *macInput_fwd = new CMenuForwarder(LOCALE_RECORDINGMENU_SERVER_MAC, true, g_settings.network_nfs[nr].mac, &macInput);
|
||||
|
||||
CMenuForwarder *refreshMAC_fwd = new CMenuForwarder(LOCALE_NFS_REFRESH_MAC, true, NULL, this, ("refreshMAC" + to_string(nr)).c_str(), CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW);
|
||||
|
||||
CMenuForwarder *mountnow_fwd = new CMenuForwarder(LOCALE_NFS_MOUNTNOW, !(CFSMounter::isMounted(g_settings.network_nfs[nr].local_dir)), NULL, this, cmd);
|
||||
|
||||
@@ -280,6 +306,8 @@ int CNFSMountGui::menuEntry(int nr)
|
||||
mountMenuEntryW.addItem(username_fwd);
|
||||
mountMenuEntryW.addItem(password_fwd);
|
||||
mountMenuEntryW.addItem(macInput_fwd);
|
||||
mountMenuEntryW.addItem(refreshMAC_fwd);
|
||||
mountMenuEntryW.addItem(GenericMenuSeparatorLine);
|
||||
mountMenuEntryW.addItem(mountnow_fwd);
|
||||
|
||||
int ret = mountMenuEntryW.exec(this,"");
|
||||
|
Reference in New Issue
Block a user