implement yt search history

Origin commit data
------------------
Branch: ni/coolstream
Commit: 4a0fdba710
Author: martii <m4rtii@gmx.de>
Date: 2013-08-15 (Thu, 15 Aug 2013)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
martii
2013-08-15 20:33:03 +02:00
committed by Jacek Jendrzej
parent 5e13124e57
commit 7f0c1551bd
7 changed files with 110 additions and 4 deletions

View File

@@ -1418,6 +1418,8 @@ moviebrowser.use_dir Verzeichnis verwenden
moviebrowser.use_movie_dir Wiedergabeverzeichnis verwenden
moviebrowser.use_rec_dir Aufnahmeverzeichnis verwenden
moviebrowser.yt_concurrent_connections Gleichzeitige Verbindungen
moviebrowser.yt_history Frühere Suchen
moviebrowser.yt_max_history Max. Anzahl früherer Suchen
moviebrowser.yt_error Fehler beim laden des Youtube Feed
moviebrowser.yt_max_results Max. Anzahl der zu holenden Feeds
moviebrowser.yt_most_discussed Am meisten diskutiert

View File

@@ -1419,6 +1419,8 @@ moviebrowser.use_movie_dir Use movie directory
moviebrowser.use_rec_dir Use record directory
moviebrowser.yt_concurrent_connections Concurrent connections
moviebrowser.yt_error Failed to load youtube feed
moviebrowser.yt_history Search history
moviebrowser.yt_max_history Max search history size
moviebrowser.yt_max_results Max results to fetch
moviebrowser.yt_most_discussed Most discussed
moviebrowser.yt_most_popular Most popular

View File

@@ -778,6 +778,17 @@ bool CMovieBrowser::loadSettings(MB_SETTINGS* settings)
settings->ytregion = configfile.getString("mb_ytregion", "default");
settings->ytsearch = configfile.getString("mb_ytsearch", "");
settings->ytvid = configfile.getString("mb_ytvid", "");
settings->ytsearch_history_max = configfile.getInt32("mb_ytsearch_history_max", 10);
settings->ytsearch_history_size = configfile.getInt32("mb_ytsearch_history_size", 0);
if (settings->ytsearch_history_size > settings->ytsearch_history_max)
settings->ytsearch_history_size = settings->ytsearch_history_max;
settings->ytsearch_history.clear();
for(int i = 0; i < settings->ytsearch_history_size; i++) {
std::string s = configfile.getString("mb_ytsearch_history_" + to_string(i));
if (s != "")
settings->ytsearch_history.push_back(configfile.getString("mb_ytsearch_history_" + to_string(i), ""));
}
settings->ytsearch_history_size = settings->ytsearch_history.size();
return (result);
}
@@ -835,6 +846,15 @@ bool CMovieBrowser::saveSettings(MB_SETTINGS* settings)
configfile.setString("mb_ytsearch", settings->ytsearch);
configfile.setString("mb_ytvid", settings->ytvid);
settings->ytsearch_history_size = settings->ytsearch_history.size();
if (settings->ytsearch_history_size > settings->ytsearch_history_max)
settings->ytsearch_history_size = settings->ytsearch_history_max;
configfile.setInt32("mb_ytsearch_history_max", settings->ytsearch_history_max);
configfile.setInt32("mb_ytsearch_history_size", settings->ytsearch_history_size);
std::list<std::string>:: iterator it = settings->ytsearch_history.begin();
for(int i = 0; i < settings->ytsearch_history_size; i++, ++it)
configfile.setString("mb_ytsearch_history_" + to_string(i), *it);
if (configfile.getModifiedFlag())
configfile.saveConfig(MOVIEBROWSER_SETTINGS_FILE);
return (result);
@@ -3639,6 +3659,55 @@ neutrino_locale_t CMovieBrowser::getFeedLocale(void)
return ret;
}
class CYTHistory : public CMenuTarget
{
private:
int width;
int selected;
std::string *search;
MB_SETTINGS *settings;
public:
CYTHistory(MB_SETTINGS &_settings, std::string &_search);
int exec(CMenuTarget* parent, const std::string & actionKey);
};
CYTHistory::CYTHistory(MB_SETTINGS &_settings, std::string &_search)
{
width = w_max (40, 10);
selected = -1;
settings = &_settings;
search = &_search;
}
int CYTHistory::exec(CMenuTarget* parent, const std::string &actionKey)
{
if (actionKey == "") {
if (parent)
parent->hide();
CMenuWidget* m = new CMenuWidget(LOCALE_MOVIEBROWSER_YT_HISTORY, NEUTRINO_ICON_MOVIEPLAYER, width);
m->addKey(CRCInput::RC_spkr, this, "clear");
m->setSelected(selected);
m->addItem(GenericMenuSeparator);
m->addItem(GenericMenuBack);
m->addItem(GenericMenuSeparatorLine);
std::list<std::string>::iterator it = settings->ytsearch_history.begin();
for (int i = 0; i < settings->ytsearch_history_size; i++, ++it)
m->addItem(new CMenuForwarderNonLocalized((*it).c_str(), true, NULL, this, (*it).c_str(), CRCInput::convertDigitToKey(i + 1)));
m->exec(NULL, "");
m->hide();
delete m;
return menu_return::RETURN_REPAINT;
}
if (actionKey == "clear") {
settings->ytsearch_history.clear();
settings->ytsearch_history_size = 0;
return menu_return::RETURN_EXIT;
}
*search = actionKey;
g_RCInput->postMsg((neutrino_msg_t) CRCInput::RC_blue, 0);
return menu_return::RETURN_EXIT;
}
bool CMovieBrowser::showYTMenu()
{
m_pcWindow->paintBackground();
@@ -3663,18 +3732,23 @@ bool CMovieBrowser::showYTMenu()
sprintf(cnt, "%d", cYTFeedParser::NEXT);
mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_NEXT_RESULTS, ytparser.HaveNext(), NULL, selector, cnt, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN));
sprintf(cnt, "%d", cYTFeedParser::PREV);
mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_PREV_RESULTS, ytparser.HavePrev(), NULL, selector, cnt, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW));
mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_PREV_RESULTS, ytparser.HavePrev(), NULL, selector, cnt, CRCInput::RC_nokey, ""));
mainMenu.addItem(GenericMenuSeparatorLine);
std::string search = m_settings.ytsearch;
CStringInputSMS stringInput(LOCALE_MOVIEBROWSER_YT_SEARCH, &search, 20, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789 -_/()<>=+.,:!?\\'");
mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_SEARCH, true, search, &stringInput, NULL, CRCInput::RC_nokey, ""));
mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_SEARCH, true, search, &stringInput, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW));
sprintf(cnt, "%d", cYTFeedParser::SEARCH);
mainMenu.addItem(new CMenuForwarder(LOCALE_EVENTFINDER_START_SEARCH, true, NULL, selector, cnt, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE));
CYTHistory ytHistory(m_settings, search);
if (m_settings.ytsearch_history_size > 0)
mainMenu.addItem(new CMenuForwarder(LOCALE_MOVIEBROWSER_YT_HISTORY, true, NULL, &ytHistory, "", CRCInput::RC_0));
mainMenu.addItem(GenericMenuSeparatorLine);
mainMenu.addItem(new CMenuOptionNumberChooser(LOCALE_MOVIEBROWSER_YT_MAX_RESULTS, &m_settings.ytresults, true, 10, 50, NULL));
mainMenu.addItem(new CMenuOptionNumberChooser(LOCALE_MOVIEBROWSER_YT_MAX_HISTORY, &m_settings.ytsearch_history_max, true, 10, 50, NULL));
char rstr[20];
sprintf(rstr, "%s", m_settings.ytregion.c_str());
@@ -3730,6 +3804,18 @@ bool CMovieBrowser::showYTMenu()
reload = true;
m_settings.ytsearch = search;
m_settings.ytmode = newmode;
m_settings.ytsearch_history.push_front(search);
std::list<std::string>::iterator it = m_settings.ytsearch_history.begin();
it++;
while (it != m_settings.ytsearch_history.end()) {
if (*it == search)
it = m_settings.ytsearch_history.erase(it);
else
++it;
}
m_settings.ytsearch_history_size = m_settings.ytsearch_history.size();
if (m_settings.ytsearch_history_size > m_settings.ytsearch_history_max)
m_settings.ytsearch_history_size = m_settings.ytsearch_history_max;
}
}
else if (m_settings.ytmode != newmode) {

View File

@@ -73,6 +73,7 @@
#include <string>
#include <vector>
#include <list>
#include <gui/widget/listframe.h>
#include <gui/widget/menue.h>
#include <gui/widget/textbox.h>
@@ -231,9 +232,12 @@ typedef struct
int ytresults;
int ytquality;
int ytconcconn;
int ytsearch_history_size;
int ytsearch_history_max;
std::string ytregion;
std::string ytvid;
std::string ytsearch;
std::list<std::string> ytsearch_history;
} MB_SETTINGS;
// Priorities for Developmemt: P1: critical feature, P2: important feature, P3: for next release, P4: looks nice, lets see

View File

@@ -24,6 +24,7 @@
#include <stdint.h>
#include <string>
#include <sstream>
int my_system(const char * cmd);
int my_system(int argc, const char *arg, ...); /* argc is number of arguments including command */
@@ -64,4 +65,11 @@ class CFileHelpers
};
template<class C> std::string to_string(C i)
{
std::stringstream s;
s << i;
return s.str();
}
#endif

View File

@@ -1446,6 +1446,8 @@ typedef enum
LOCALE_MOVIEBROWSER_USE_REC_DIR,
LOCALE_MOVIEBROWSER_YT_CONCURRENT_CONNECTIONS,
LOCALE_MOVIEBROWSER_YT_ERROR,
LOCALE_MOVIEBROWSER_YT_HISTORY,
LOCALE_MOVIEBROWSER_YT_MAX_HISTORY,
LOCALE_MOVIEBROWSER_YT_MAX_RESULTS,
LOCALE_MOVIEBROWSER_YT_MOST_DISCUSSED,
LOCALE_MOVIEBROWSER_YT_MOST_POPULAR,

View File

@@ -1446,6 +1446,8 @@ const char * locale_real_names[] =
"moviebrowser.use_rec_dir",
"moviebrowser.yt_concurrent_connections",
"moviebrowser.yt_error",
"moviebrowser.yt_history",
"moviebrowser.yt_max_history",
"moviebrowser.yt_max_results",
"moviebrowser.yt_most_discussed",
"moviebrowser.yt_most_popular",