#include #include "misc_settings.h" #include "mv_common.h" #include #include #include #include #include #include "mythprogressdialog.h" #include "mythsystemlegacy.h" #include "mythuihelper.h" #include "fileshare.h" extern HostParms hostparm; using namespace std; //________________Client (NFS) Screen SETTINGS_________________________ static HostComboBox *HostHaveCentralNFS() { HostComboBox *gc = new HostComboBox("HostHaveCentralNFS"); gc->setLabel(QObject::tr("Central NFS Server")); gc->addSelection("no"); gc->addSelection("yes") ; gc->setHelpText(QObject::tr("Select yes, if your media is stored on an NFS server different than the master backend. Select no if you are unsure.")); return gc; } static HostComboBox *HostCentralNFSIP() { HostComboBox *gc = new HostComboBox("HostCentralNFSIP",true); gc->setLabel(QObject::tr("NFS Server")); gc->setHelpText(QObject::tr("Format should be IP:/SHARENAME, For example 192.168.1.6:/media. file:nfsmap will load shares from the nfsmap file.")); gc->addSelection("example ip:share") ; gc->addSelection("file:nfsmap_auto") ; gc->addSelection("file:nfsmap") ; gc->addSelection("silverraid:/raid0/data/media/"); gc->addSelection("") ; return gc; }; static HostComboBox *HostNFSmountpoint() { // #ifdef __MVAPP__ // HostComboBox *gc = new HostComboBox("HostNFSmountpoint"); // gc->addSelection("/data/storage/central_nfs"); // #else // HostComboBox *gc = new HostComboBox("HostNFSmountpoint",true); // gc->addSelection("/myth"); // #endif HostComboBox *gc = new HostComboBox("HostNFSmountpoint",true); gc->addSelection("/data/storage/central_nfs"); gc->setLabel(QObject::tr("Mount Point")); gc->setHelpText(QObject::tr("")); return gc; } static HostCheckBox *HostCentralNFSallhosts() { HostCheckBox *gc = new HostCheckBox("HostCentralNFSallhosts"); gc->setLabel(QObject::tr("All Hosts Use This Share")); gc->setValue(true); gc->setHelpText(QObject::tr("If checked then all new hosts added to the cluster will try to access the same share.")); return gc; }; ClientNFSSettings::ClientNFSSettings(): TriggeredConfigurationGroup(false,false,false,true,true,false,false,true) { setLabel(QObject::tr("Client NFS configuration")); Setting* havenfs = HostHaveCentralNFS(); addChild(havenfs); setTrigger(havenfs); ConfigurationGroup* settings = new VerticalConfigurationGroup(); QString systemtype = gCoreContext->GetSetting("HostSystemType"); if ( systemtype == "Master_backend" ) { settings->addChild(HostCentralNFSallhosts()); } settings->addChild(HostCentralNFSIP()); settings->addChild(HostNFSmountpoint()); addTarget("no", new VerticalConfigurationGroup()); addTarget("yes", settings); }; //_______________Client NFS Frame FileShareMainFrameClient::FileShareMainFrameClient(): VerticalConfigurationGroup(false,false,false,false) { setLabel(QObject::tr("File Sharing Settings (1/2)")); VerticalConfigurationGroup* fileshareframeclientsettings = new VerticalConfigurationGroup(false, true,false,false); ClientNFSSettings *clientnfssettings = new ClientNFSSettings(); fileshareframeclientsettings->addChild(clientnfssettings); addChild(fileshareframeclientsettings); } //-------------------------------------- static HostCheckBox *HostServiceNFS() { HostCheckBox *gc = new HostCheckBox("HostServiceNFS"); gc->setLabel(QObject::tr("File Sharing using NFS")); gc->setValue(true); gc->setHelpText(QObject::tr("If checked, any device on the network can access media via NFS.")); return gc; }; static HostCheckBox *HostServiceSamba() { HostCheckBox *gc = new HostCheckBox("HostServiceSamba"); gc->setLabel(QObject::tr("File Sharing using SMB (Windows Sharing)")); gc->setValue(false); gc->setHelpText(QObject::tr("If checked, any device on the network can access media via Windows SMB file sharing.")); return gc; }; static HostCheckBox *HostServiceSamba_write() { HostCheckBox *gc = new HostCheckBox("HostServiceSamba_write"); gc->setLabel(QObject::tr("ReadOnly")); gc->setValue(false); gc->setHelpText(QObject::tr("If checked, all remote connections will be read only. If not checked, remote clients will have write and delete abilities.")); return gc; }; static HostCheckBox *HostServiceSamba_writehome() { HostCheckBox *gc = new HostCheckBox("HostServiceSamba_writehome"); gc->setLabel(QObject::tr("ReadOnly")); gc->setValue(false); gc->setHelpText(QObject::tr("If checked, all remote connections will be read only. If not checked, remote clients will have write and delete abilities.")); return gc; }; static HostCheckBox *HostServiceSamba_media() { HostCheckBox *gc = new HostCheckBox("HostServiceSamba_media"); gc->setLabel(QObject::tr("Share media")); gc->setValue(true); gc->setHelpText(QObject::tr(" ")); return gc; }; static HostCheckBox *HostServiceSamba_home() { HostCheckBox *gc = new HostCheckBox("HostServiceSamba_home"); gc->setLabel(QObject::tr("Share home")); gc->setValue(true); gc->setHelpText(QObject::tr(" ")); return gc; }; static HostComboBox *HostServiceSamba_domain() { HostComboBox *gc = new HostComboBox("HostServiceSamba_domain",true); gc->setLabel(QObject::tr("Workgroup")); gc->setHelpText(QObject::tr("Workgroup for Windows SMB shares.")); gc->addSelection("WORKGROUP"); QString currentitem; QString line; QFile file("/tmp/smbdomainlist"); if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) { QTextStream t( &file ); // use a text stream while ( !t.atEnd() ) { line = t.readLine(); if ( line.startsWith("domain")) { currentitem = line.section( " ", 1, 1 ); if ( currentitem != "-" ) gc->addSelection(currentitem); } } file.close(); } gc->addSelection("type_workgroup_here"); return gc; }; class SAMBAsettings: public TriggeredConfigurationGroup { public: SAMBAsettings(): TriggeredConfigurationGroup(false, true, true, true,false, false, true, true) { SetVertical(true); Setting* trigger = HostServiceSamba() ; addChild(trigger); setTrigger(trigger); ConfigurationGroup* settings = new GridConfigurationGroup(2,false,false); //settings->addChild(HostServiceSamba()); settings->addChild(HostServiceSamba_media()); settings->addChild(HostServiceSamba_write()); settings->addChild(HostServiceSamba_home()); settings->addChild(HostServiceSamba_writehome()); settings->addChild(HostServiceSamba_domain()); addTarget("0", new GridConfigurationGroup(2,false, false)); addTarget("1", settings); }; }; void smb_busy_box() { system ("nmbscan -d > /tmp/smbdomainlist & "); QString msgtext="Searching for Windows Workgroups"; int return_code; MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythUIBusyDialog *busyPopup = new MythUIBusyDialog(msgtext, popupStack, "installbusy"); if (busyPopup->Create()) { popupStack->AddScreen(busyPopup, false); } else { delete busyPopup; busyPopup = NULL; } int progressbar=1; MythProgressDialog *popupProgress = NULL; popupProgress = new MythProgressDialog(msgtext, 50); if (popupProgress) { popupProgress->setProgress(progressbar); } while ( return_code == 0 ) { progressbar++; popupProgress->setProgress(progressbar); if (progressbar > 50 ) progressbar = 10; return_code = myth_system("ps -ef|grep nmbscan|grep -v grep > /dev/null"); qApp->processEvents (); usleep(900); } if (busyPopup) { busyPopup->Close(); busyPopup = NULL; } if (popupProgress) { popupProgress->Close(); popupProgress->deleteLater(); } } //_______________Server NFS Frame FileShareMainFrameServer::FileShareMainFrameServer(): VerticalConfigurationGroup(false,false,false,false) { setLabel(QObject::tr("File Sharing Settings (2/2)")); VerticalConfigurationGroup* denied = new VerticalConfigurationGroup(false,false,true,true); TransLabelSetting *deniedlabel = new TransLabelSetting(); deniedlabel->setValue(" File sharing is not available for frontend_only systems." ); denied->addChild(deniedlabel); VerticalConfigurationGroup* fileshare_frame_serversettings = new VerticalConfigurationGroup(false,false,false,false); fileshare_frame_serversettings->addChild(HostServiceNFS()); fileshare_frame_serversettings->addChild(new SAMBAsettings); hostparm.ThisSystemType = gCoreContext->GetSetting("HostSystemType"); if (hostparm.ThisSystemType == "Frontend_only" ) { addChild(denied); } else { smb_busy_box(); addChild(fileshare_frame_serversettings); } }