moviebrowser settings: move storage settings into own struct

For planned usage with user interaction.


Origin commit data
------------------
Branch: ni/coolstream
Commit: 78430789de
Author: Thilo Graf <dbt@novatux.de>
Date: 2019-05-09 (Thu, 09 May 2019)



------------------
This commit was generated by Migit
This commit is contained in:
2019-05-09 00:05:58 +02:00
committed by vanhofen
parent 90364f9ab1
commit f5d882dda2
2 changed files with 43 additions and 29 deletions

View File

@@ -434,6 +434,18 @@ void CMovieBrowser::init(void)
imdb = CIMDB::getInstance(); imdb = CIMDB::getInstance();
} }
void CMovieBrowser::initGlobalStorageSettings(void)
{
m_settings.store.storageDirMovieUsed = true;
m_settings.store.storageDirRecUsed = true;
for (int i = 0; i < MB_MAX_DIRS; i++)
{
m_settings.store.storageDir[i] = "";
m_settings.store.storageDirUsed[i] = 0;
}
}
void CMovieBrowser::initGlobalSettings(void) void CMovieBrowser::initGlobalSettings(void)
{ {
//TRACE("[mb]->initGlobalSettings\n"); //TRACE("[mb]->initGlobalSettings\n");
@@ -456,17 +468,11 @@ void CMovieBrowser::initGlobalSettings(void)
m_settings.parentalLockAge = MI_PARENTAL_OVER18; m_settings.parentalLockAge = MI_PARENTAL_OVER18;
m_settings.parentalLock = MB_PARENTAL_LOCK_OFF; m_settings.parentalLock = MB_PARENTAL_LOCK_OFF;
m_settings.storageDirMovieUsed = true;
m_settings.storageDirRecUsed = true;
m_settings.reload = true; m_settings.reload = true;
m_settings.remount = false; m_settings.remount = false;
for (int i = 0; i < MB_MAX_DIRS; i++) // storage
{ initGlobalStorageSettings();
m_settings.storageDir[i] = "";
m_settings.storageDirUsed[i] = 0;
}
/***** Browser List **************/ /***** Browser List **************/
m_settings.browserFrameHeight = 65; /* percent */ m_settings.browserFrameHeight = 65; /* percent */
@@ -643,16 +649,16 @@ bool CMovieBrowser::loadSettings(MB_SETTINGS* settings)
settings->parentalLockAge = (MI_PARENTAL_LOCKAGE)configfile.getInt32("mb_parentalLockAge", MI_PARENTAL_OVER18); settings->parentalLockAge = (MI_PARENTAL_LOCKAGE)configfile.getInt32("mb_parentalLockAge", MI_PARENTAL_OVER18);
settings->parentalLock = (MB_PARENTAL_LOCK)configfile.getInt32("mb_parentalLock", MB_PARENTAL_LOCK_ACTIVE); settings->parentalLock = (MB_PARENTAL_LOCK)configfile.getInt32("mb_parentalLock", MB_PARENTAL_LOCK_ACTIVE);
settings->storageDirRecUsed = (bool)configfile.getInt32("mb_storageDir_rec", true); settings->store.storageDirRecUsed = (bool)configfile.getInt32("mb_storageDir_rec", true);
settings->storageDirMovieUsed = (bool)configfile.getInt32("mb_storageDir_movie", true); settings->store.storageDirMovieUsed = (bool)configfile.getInt32("mb_storageDir_movie", true);
settings->reload = (bool)configfile.getInt32("mb_reload", true); settings->reload = (bool)configfile.getInt32("mb_reload", true);
settings->remount = (bool)configfile.getInt32("mb_remount", false); settings->remount = (bool)configfile.getInt32("mb_remount", false);
for (int i = 0; i < MB_MAX_DIRS; i++) for (int i = 0; i < MB_MAX_DIRS; i++)
{ {
settings->storageDir[i] = configfile.getString("mb_dir_" + to_string(i), ""); settings->store.storageDir[i] = configfile.getString("mb_dir_" + to_string(i), "");
settings->storageDirUsed[i] = configfile.getInt32("mb_dir_used" + to_string(i), false); settings->store.storageDirUsed[i] = configfile.getInt32("mb_dir_used" + to_string(i), false);
} }
/* these variables are used for the listframes */ /* these variables are used for the listframes */
settings->browserFrameHeight = configfile.getInt32("mb_browserFrameHeight", 50); settings->browserFrameHeight = configfile.getInt32("mb_browserFrameHeight", 50);
@@ -708,8 +714,8 @@ bool CMovieBrowser::saveSettings(MB_SETTINGS* settings)
configfile.setString("mb_filter_optionString", settings->filter.optionString); configfile.setString("mb_filter_optionString", settings->filter.optionString);
configfile.setInt32("mb_filter_optionVar", settings->filter.optionVar); configfile.setInt32("mb_filter_optionVar", settings->filter.optionVar);
configfile.setInt32("mb_storageDir_rec", settings->storageDirRecUsed); configfile.setInt32("mb_storageDir_rec", settings->store.storageDirRecUsed);
configfile.setInt32("mb_storageDir_movie", settings->storageDirMovieUsed); configfile.setInt32("mb_storageDir_movie", settings->store.storageDirMovieUsed);
configfile.setInt32("mb_parentalLockAge", settings->parentalLockAge); configfile.setInt32("mb_parentalLockAge", settings->parentalLockAge);
configfile.setInt32("mb_parentalLock", settings->parentalLock); configfile.setInt32("mb_parentalLock", settings->parentalLock);
@@ -719,8 +725,8 @@ bool CMovieBrowser::saveSettings(MB_SETTINGS* settings)
for (int i = 0; i < MB_MAX_DIRS; i++) for (int i = 0; i < MB_MAX_DIRS; i++)
{ {
configfile.setString("mb_dir_" + to_string(i), settings->storageDir[i]); configfile.setString("mb_dir_" + to_string(i), settings->store.storageDir[i]);
configfile.setInt32("mb_dir_used" + to_string(i), settings->storageDirUsed[i]); // do not save this so far configfile.setInt32("mb_dir_used" + to_string(i), settings->store.storageDirUsed[i]); // do not save this so far
} }
/* these variables are used for the listframes */ /* these variables are used for the listframes */
configfile.setInt32("mb_browserFrameHeight", settings->browserFrameHeight); configfile.setInt32("mb_browserFrameHeight", settings->browserFrameHeight);
@@ -2916,20 +2922,20 @@ void CMovieBrowser::updateDir(void)
if (g_settings.network_nfs_moviedir[0] != 0) if (g_settings.network_nfs_moviedir[0] != 0)
{ {
std::string name = g_settings.network_nfs_moviedir; std::string name = g_settings.network_nfs_moviedir;
addDir(name,&m_settings.storageDirMovieUsed); addDir(name,&m_settings.store.storageDirMovieUsed);
} }
#endif #endif
// check if there is a record dir and if we should use it // check if there is a record dir and if we should use it
if (!g_settings.network_nfs_recordingdir.empty()) if (!g_settings.network_nfs_recordingdir.empty())
{ {
addDir(g_settings.network_nfs_recordingdir, &m_settings.storageDirRecUsed); addDir(g_settings.network_nfs_recordingdir, &m_settings.store.storageDirRecUsed);
cHddStat::getInstance()->statOnce(); cHddStat::getInstance()->statOnce();
} }
for (int i = 0; i < MB_MAX_DIRS; i++) for (int i = 0; i < MB_MAX_DIRS; i++)
{ {
if (!m_settings.storageDir[i].empty()) if (!m_settings.store.storageDir[i].empty())
addDir(m_settings.storageDir[i],&m_settings.storageDirUsed[i]); addDir(m_settings.store.storageDir[i],&m_settings.store.storageDirUsed[i]);
} }
} }
@@ -3548,21 +3554,21 @@ bool CMovieBrowser::showMenu(bool calledExternally)
/** optionsVerzeichnisse **************************************************/ /** optionsVerzeichnisse **************************************************/
CMenuWidget optionsMenuDir(LOCALE_MOVIEBROWSER_HEAD, NEUTRINO_ICON_MOVIEPLAYER); CMenuWidget optionsMenuDir(LOCALE_MOVIEBROWSER_HEAD, NEUTRINO_ICON_MOVIEPLAYER);
optionsMenuDir.addIntroItems(LOCALE_MOVIEBROWSER_MENU_DIRECTORIES_HEAD); optionsMenuDir.addIntroItems(LOCALE_MOVIEBROWSER_MENU_DIRECTORIES_HEAD);
optionsMenuDir.addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_REC_DIR, (int*)(&m_settings.storageDirRecUsed), MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true)); optionsMenuDir.addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_REC_DIR, (int*)(&m_settings.store.storageDirRecUsed), MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true));
optionsMenuDir.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_DIR, false, g_settings.network_nfs_recordingdir)); optionsMenuDir.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_DIR, false, g_settings.network_nfs_recordingdir));
optionsMenuDir.addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_MOVIE_DIR, (int*)(&m_settings.storageDirMovieUsed), MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true)); optionsMenuDir.addItem(new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_MOVIE_DIR, (int*)(&m_settings.store.storageDirMovieUsed), MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true));
optionsMenuDir.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_DIR, false, g_settings.network_nfs_moviedir)); optionsMenuDir.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_DIR, false, g_settings.network_nfs_moviedir));
optionsMenuDir.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_MOVIEBROWSER_DIRECTORIES_ADDITIONAL)); optionsMenuDir.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_MOVIEBROWSER_DIRECTORIES_ADDITIONAL));
COnOffNotifier* notifier[MB_MAX_DIRS]; COnOffNotifier* notifier[MB_MAX_DIRS];
for (i = 0; i < MB_MAX_DIRS ; i++) for (i = 0; i < MB_MAX_DIRS ; i++)
{ {
CFileChooser *dirInput = new CFileChooser(&m_settings.storageDir[i]); CFileChooser *dirInput = new CFileChooser(&m_settings.store.storageDir[i]);
CMenuForwarder *forwarder = new CMenuDForwarder(LOCALE_MOVIEBROWSER_DIR, m_settings.storageDirUsed[i], m_settings.storageDir[i], dirInput); CMenuForwarder *forwarder = new CMenuDForwarder(LOCALE_MOVIEBROWSER_DIR, m_settings.store.storageDirUsed[i], m_settings.store.storageDir[i], dirInput);
notifier[i] = new COnOffNotifier(); notifier[i] = new COnOffNotifier();
notifier[i]->addItem(forwarder); notifier[i]->addItem(forwarder);
CMenuOptionChooser *chooser = new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_DIR, &m_settings.storageDirUsed[i], MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true,notifier[i]); CMenuOptionChooser *chooser = new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_DIR, &m_settings.store.storageDirUsed[i], MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true,notifier[i]);
optionsMenuDir.addItem(chooser); optionsMenuDir.addItem(chooser);
optionsMenuDir.addItem(forwarder); optionsMenuDir.addItem(forwarder);
if (i != (MB_MAX_DIRS - 1)) if (i != (MB_MAX_DIRS - 1))

View File

@@ -69,7 +69,16 @@
#define MB_MAX_ROWS LF_MAX_ROWS #define MB_MAX_ROWS LF_MAX_ROWS
#define MB_MAX_DIRS NETWORK_NFS_NR_OF_ENTRIES #define MB_MAX_DIRS NETWORK_NFS_NR_OF_ENTRIES
/* MB_SETTINGS to be stored in g_settings anytime ....*/ /* MB_SETTINGS to be stored in g_settings anytime ....*/
struct MBStorageSettings
{
std::string storageDir[MB_MAX_DIRS];
int storageDirUsed[MB_MAX_DIRS];
int storageDirRecUsed;
int storageDirMovieUsed;
};
typedef struct typedef struct
{ {
// moviebrowser // moviebrowser
@@ -79,10 +88,7 @@ typedef struct
MI_PARENTAL_LOCKAGE parentalLockAge ;//MI_PARENTAL_LOCKAGE MI_PARENTAL_LOCKAGE parentalLockAge ;//MI_PARENTAL_LOCKAGE
MB_PARENTAL_LOCK parentalLock;//MB_PARENTAL_LOCK MB_PARENTAL_LOCK parentalLock;//MB_PARENTAL_LOCK
std::string storageDir[MB_MAX_DIRS]; MBStorageSettings store;
int storageDirUsed[MB_MAX_DIRS];
int storageDirRecUsed;
int storageDirMovieUsed;
int reload; int reload;
int remount; int remount;
@@ -124,6 +130,7 @@ typedef struct
std::list<std::string> ytsearch_history; std::list<std::string> ytsearch_history;
} MB_SETTINGS; } MB_SETTINGS;
class CMovieBrowser; class CMovieBrowser;
class CYTCacheSelectorTarget : public CMenuTarget class CYTCacheSelectorTarget : public CMenuTarget
@@ -282,6 +289,7 @@ class CMovieBrowser : public CMenuTarget, public CProgressSignals
///// MovieBrowser init /////////////// ///// MovieBrowser init ///////////////
void init(void); //P1 void init(void); //P1
void initGlobalSettings(void); //P1 void initGlobalSettings(void); //P1
void initGlobalStorageSettings(void);
void initFrames(void); void initFrames(void);
void initRows(void); void initRows(void);
void reinit(void); //P1 void reinit(void); //P1