mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-17 18:33:41 +02:00
gui/nfs: implement mac address lookup
Conflicts: src/gui/moviebrowser.cpp src/gui/nfs.cpp
This commit is contained in:
@@ -3089,7 +3089,7 @@ int CMovieBrowser::showMovieInfoMenu(MI_MOVIE_INFO* movie_info)
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" int pinghost( const char *hostname );
|
||||
extern int pinghost (const std::string &hostname, std::string *ip = NULL);
|
||||
bool CMovieBrowser::showMenu(MI_MOVIE_INFO* /*movie_info*/)
|
||||
{
|
||||
/* first clear screen */
|
||||
@@ -4085,7 +4085,7 @@ void CDirMenu::updateDirState(void)
|
||||
printf("updateDirState: %d: state %d nfs %d\n", i, dirState[i], dirNfsMountNr[i]);
|
||||
if(dirNfsMountNr[i] != -1)
|
||||
{
|
||||
int retvalue = pinghost(g_settings.network_nfs[dirNfsMountNr[i]].ip.c_str());
|
||||
int retvalue = pinghost(g_settings.network_nfs[dirNfsMountNr[i]].ip);
|
||||
if (retvalue == 0)//LOCALE_PING_UNREACHABLE
|
||||
{
|
||||
dirOptionText[i]="Server, offline";
|
||||
|
@@ -58,7 +58,7 @@
|
||||
#include <libnet.h>
|
||||
#include <libiw/iwscan.h>
|
||||
|
||||
extern "C" int pinghost( const char *hostname );
|
||||
extern int pinghost (const std::string &hostname, std::string *ip = NULL);
|
||||
|
||||
CNetworkSetup::CNetworkSetup(bool wizard_mode)
|
||||
{
|
||||
@@ -702,7 +702,7 @@ void CNetworkSetup::showCurrentNetworkSettings()
|
||||
|
||||
const char * CNetworkSetup::mypinghost(std::string &host)
|
||||
{
|
||||
int retvalue = pinghost(host.c_str());
|
||||
int retvalue = pinghost(host);
|
||||
switch (retvalue)
|
||||
{
|
||||
case 1: return (g_Locale->getText(LOCALE_PING_OK));
|
||||
@@ -776,7 +776,7 @@ void CNetworkSetup::testNetworkSettings()
|
||||
text += (std::string)g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER) + ":\n";
|
||||
text += offset + our_nameserver + " " + mypinghost(our_nameserver) + "\n";
|
||||
//NTPserver
|
||||
if ( (pinghost(our_nameserver.c_str()) == 1) && g_settings.network_ntpenable && (g_settings.network_ntpserver != "") )
|
||||
if ( (pinghost(our_nameserver) == 1) && g_settings.network_ntpenable && (g_settings.network_ntpserver != "") )
|
||||
{
|
||||
text += std::string(g_Locale->getText(LOCALE_NETWORKMENU_NTPSERVER)) + ":\n";
|
||||
text += offset + g_settings.network_ntpserver + " " + mypinghost(g_settings.network_ntpserver) + "\n";
|
||||
@@ -784,7 +784,7 @@ void CNetworkSetup::testNetworkSettings()
|
||||
//Wiki
|
||||
text += wiki_URL + ":\n";
|
||||
text += offset + "via IP (" + wiki_IP + "): " + mypinghost(wiki_IP) + "\n";
|
||||
if (pinghost(our_nameserver.c_str()) == 1)
|
||||
if (pinghost(our_nameserver) == 1)
|
||||
{
|
||||
text += offset + "via DNS: " + mypinghost(wiki_URL) + "\n";
|
||||
//testsite (or defaultsite)
|
||||
|
@@ -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