mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 09:21:18 +02:00
- upnpbrowser: formatting code using astyle; some manual code nicenings
Conflicts: src/gui/upnpbrowser.cpp Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include <gui/audiomute.h>
|
#include <gui/audiomute.h>
|
||||||
#include <gui/color.h>
|
#include <gui/color.h>
|
||||||
|
|
||||||
#include <gui/movieplayer.h>
|
#include <gui/movieplayer.h>
|
||||||
#include <gui/components/cc.h>
|
#include <gui/components/cc.h>
|
||||||
#include <gui/widget/msgbox.h>
|
#include <gui/widget/msgbox.h>
|
||||||
@@ -65,7 +66,7 @@ const struct button_label BrowseButtons[] =
|
|||||||
{ NEUTRINO_ICON_BUTTON_GREEN, LOCALE_FILEBROWSER_PREVPAGE },
|
{ NEUTRINO_ICON_BUTTON_GREEN, LOCALE_FILEBROWSER_PREVPAGE },
|
||||||
{ NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_AUDIOPLAYER_STOP },
|
{ NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_AUDIOPLAYER_STOP },
|
||||||
{ NEUTRINO_ICON_BUTTON_OKAY, LOCALE_AUDIOPLAYER_PLAY },
|
{ NEUTRINO_ICON_BUTTON_OKAY, LOCALE_AUDIOPLAYER_PLAY },
|
||||||
{ NEUTRINO_ICON_BUTTON_HOME, LOCALE_MENU_BACK, }
|
{ NEUTRINO_ICON_BUTTON_HOME, LOCALE_MENU_BACK, }
|
||||||
};
|
};
|
||||||
|
|
||||||
CUpnpBrowserGui::CUpnpBrowserGui()
|
CUpnpBrowserGui::CUpnpBrowserGui()
|
||||||
@@ -253,7 +254,7 @@ void CUpnpBrowserGui::splitProtocol(std::string &protocol, std::string &prot, st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//printf("%s -> %s - %s - %s - %s\n", protocol.c_str(), prot.c_str(), network.c_str(), mime.c_str(), additional.c_str());
|
//printf("%s -> %s - %s - %s - %s\n", protocol.c_str(), prot.c_str(), network.c_str(), mime.c_str(), additional.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUpnpBrowserGui::discoverDevices()
|
bool CUpnpBrowserGui::discoverDevices()
|
||||||
@@ -261,7 +262,7 @@ bool CUpnpBrowserGui::discoverDevices()
|
|||||||
if (!m_devices.empty())
|
if (!m_devices.empty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
CHintBox hintbox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_UPNPBROWSER_SCANNING)); // UTF-8
|
CHintBox hintbox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_UPNPBROWSER_SCANNING));
|
||||||
hintbox.paint();
|
hintbox.paint();
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -313,7 +314,7 @@ bool CUpnpBrowserGui::getResults(std::string id, unsigned int start, unsigned in
|
|||||||
|
|
||||||
std::vector<UPnPEntry> *CUpnpBrowserGui::decodeResult(std::string result)
|
std::vector<UPnPEntry> *CUpnpBrowserGui::decodeResult(std::string result)
|
||||||
{
|
{
|
||||||
xmlNodePtr root, node, snode;
|
xmlNodePtr root, node, snode;
|
||||||
xmlDocPtr parser = parseXml(result.c_str(), "UTF-8");
|
xmlDocPtr parser = parseXml(result.c_str(), "UTF-8");
|
||||||
root = xmlDocGetRootElement(parser);
|
root = xmlDocGetRootElement(parser);
|
||||||
if (!root)
|
if (!root)
|
||||||
@@ -532,7 +533,7 @@ void CUpnpBrowserGui::selectDevice()
|
|||||||
{
|
{
|
||||||
bool loop = true;
|
bool loop = true;
|
||||||
bool refresh = true;
|
bool refresh = true;
|
||||||
neutrino_msg_t msg;
|
neutrino_msg_t msg;
|
||||||
neutrino_msg_data_t data;
|
neutrino_msg_data_t data;
|
||||||
|
|
||||||
if (!discoverDevices())
|
if (!discoverDevices())
|
||||||
@@ -602,7 +603,6 @@ void CUpnpBrowserGui::selectDevice()
|
|||||||
{
|
{
|
||||||
CNeutrinoApp::getInstance()->handleMsg(msg, data);
|
CNeutrinoApp::getInstance()->handleMsg(msg, data);
|
||||||
}
|
}
|
||||||
else if (msg > CRCInput::RC_MaxRC)
|
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -612,6 +612,7 @@ void CUpnpBrowserGui::selectDevice()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
CAudioMute::getInstance()->enableMuteIcon(true);
|
CAudioMute::getInstance()->enableMuteIcon(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUpnpBrowserGui::playnext(void)
|
void CUpnpBrowserGui::playnext(void)
|
||||||
@@ -687,7 +688,7 @@ void CUpnpBrowserGui::playnext(void)
|
|||||||
delete entries;
|
delete entries;
|
||||||
entries = NULL;
|
entries = NULL;
|
||||||
}
|
}
|
||||||
neutrino_msg_t msg;
|
neutrino_msg_t msg;
|
||||||
neutrino_msg_data_t data;
|
neutrino_msg_data_t data;
|
||||||
g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display
|
g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display
|
||||||
|
|
||||||
@@ -706,7 +707,7 @@ void CUpnpBrowserGui::playnext(void)
|
|||||||
m_frameBuffer->Clear();
|
m_frameBuffer->Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUpnpBrowserGui::getItems(std::string id, unsigned int index, std::vector<UPnPEntry>*&entries, unsigned int &total)
|
bool CUpnpBrowserGui::getItems(std::string id, unsigned int index, std::vector<UPnPEntry> *&entries, unsigned int &total)
|
||||||
{
|
{
|
||||||
bool tfound = false;
|
bool tfound = false;
|
||||||
bool rfound = false;
|
bool rfound = false;
|
||||||
@@ -752,7 +753,7 @@ bool CUpnpBrowserGui::getItems(std::string id, unsigned int index, std::vector<U
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUpnpBrowserGui::updateItemSelection(std::string id, std::vector<UPnPEntry>*&entries, int newpos, unsigned int &selected, unsigned int &liststart)
|
bool CUpnpBrowserGui::updateItemSelection(std::string id, std::vector<UPnPEntry> *&entries, int newpos, unsigned int &selected, unsigned int &liststart)
|
||||||
{
|
{
|
||||||
if ((int) selected != newpos)
|
if ((int) selected != newpos)
|
||||||
{
|
{
|
||||||
@@ -783,7 +784,7 @@ bool CUpnpBrowserGui::selectItem(std::string id)
|
|||||||
bool loop = true;
|
bool loop = true;
|
||||||
bool endall = false;
|
bool endall = false;
|
||||||
bool refresh = true;
|
bool refresh = true;
|
||||||
neutrino_msg_t msg;
|
neutrino_msg_t msg;
|
||||||
neutrino_msg_data_t data;
|
neutrino_msg_data_t data;
|
||||||
std::vector<UPnPEntry> *entries = NULL;
|
std::vector<UPnPEntry> *entries = NULL;
|
||||||
|
|
||||||
@@ -835,7 +836,7 @@ bool CUpnpBrowserGui::selectItem(std::string id)
|
|||||||
}
|
}
|
||||||
else if (!timeout && (msg_repeatok == CRCInput::RC_up || (int) msg == g_settings.key_pageup))
|
else if (!timeout && (msg_repeatok == CRCInput::RC_up || (int) msg == g_settings.key_pageup))
|
||||||
{
|
{
|
||||||
int step = ((int) msg == g_settings.key_pageup) ? m_listmaxshow : 1; // browse or step 1
|
int step = ((int) msg == g_settings.key_pageup) ? m_listmaxshow : 1; // browse or step 1
|
||||||
int new_selected = selected - step;
|
int new_selected = selected - step;
|
||||||
if (new_selected < 0)
|
if (new_selected < 0)
|
||||||
{
|
{
|
||||||
@@ -848,7 +849,7 @@ bool CUpnpBrowserGui::selectItem(std::string id)
|
|||||||
}
|
}
|
||||||
else if (!timeout && (msg_repeatok == CRCInput::RC_down || (int) msg == g_settings.key_pagedown))
|
else if (!timeout && (msg_repeatok == CRCInput::RC_down || (int) msg == g_settings.key_pagedown))
|
||||||
{
|
{
|
||||||
int step = ((int) msg == g_settings.key_pagedown) ? m_listmaxshow : 1; // browse or step 1
|
int step = ((int) msg == g_settings.key_pagedown) ? m_listmaxshow : 1; // browse or step 1
|
||||||
int new_selected = selected + step;
|
int new_selected = selected + step;
|
||||||
if (new_selected >= (int) total)
|
if (new_selected >= (int) total)
|
||||||
{
|
{
|
||||||
@@ -1080,7 +1081,7 @@ void CUpnpBrowserGui::paintDevices()
|
|||||||
// Head
|
// Head
|
||||||
CComponentsHeader header(m_x, m_header_y, m_width, m_header_height, LOCALE_UPNPBROWSER_HEAD, NEUTRINO_ICON_UPNP);
|
CComponentsHeader header(m_x, m_header_y, m_width, m_header_height, LOCALE_UPNPBROWSER_HEAD, NEUTRINO_ICON_UPNP);
|
||||||
header.enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true);
|
header.enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true);
|
||||||
if (CNeutrinoApp::getInstance()->isMuted()) //TODO: consider mute mode on runtime
|
if (CNeutrinoApp::getInstance()->isMuted()) // TODO: consider mute mode on runtime
|
||||||
header.addContextButton(NEUTRINO_ICON_BUTTON_MUTE_SMALL);
|
header.addContextButton(NEUTRINO_ICON_BUTTON_MUTE_SMALL);
|
||||||
else
|
else
|
||||||
header.removeContextButtons();
|
header.removeContextButtons();
|
||||||
@@ -1208,7 +1209,7 @@ void CUpnpBrowserGui::paintItemInfo(UPnPEntry *entry)
|
|||||||
}
|
}
|
||||||
tmp += "\n";
|
tmp += "\n";
|
||||||
|
|
||||||
//third line
|
// third line
|
||||||
if (!entry->isdir && preferred != -1)
|
if (!entry->isdir && preferred != -1)
|
||||||
tmp += "URL: " + entry->resources[preferred].url;
|
tmp += "URL: " + entry->resources[preferred].url;
|
||||||
|
|
||||||
@@ -1247,7 +1248,7 @@ void CUpnpBrowserGui::paintItems(std::vector<UPnPEntry> *entry, unsigned int sel
|
|||||||
{
|
{
|
||||||
printf("CUpnpBrowserGui::paintItem:s selected %d max %d offset %d\n", selected, max, offset);
|
printf("CUpnpBrowserGui::paintItem:s selected %d max %d offset %d\n", selected, max, offset);
|
||||||
|
|
||||||
//block infoclock
|
// block infoclock
|
||||||
CInfoClock::getInstance()->block();
|
CInfoClock::getInstance()->block();
|
||||||
|
|
||||||
// LCD
|
// LCD
|
||||||
@@ -1266,7 +1267,7 @@ void CUpnpBrowserGui::paintItems(std::vector<UPnPEntry> *entry, unsigned int sel
|
|||||||
for (unsigned int count = 0; count < m_listmaxshow; count++)
|
for (unsigned int count = 0; count < m_listmaxshow; count++)
|
||||||
paintItem(entry, count, selected);
|
paintItem(entry, count, selected);
|
||||||
|
|
||||||
//scrollbar
|
// scrollbar
|
||||||
int total_pages;
|
int total_pages;
|
||||||
int current_page;
|
int current_page;
|
||||||
getScrollBarData(&total_pages, ¤t_page, max + offset, m_listmaxshow, selected + offset);
|
getScrollBarData(&total_pages, ¤t_page, max + offset, m_listmaxshow, selected + offset);
|
||||||
@@ -1339,7 +1340,7 @@ void CUpnpBrowserGui::paintItem2DetailsLine(int pos)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int xpos = m_x - DETAILSLINE_WIDTH;
|
int xpos = m_x - DETAILSLINE_WIDTH;
|
||||||
int ypos1 = m_item_y + pos * m_item_height;
|
int ypos1 = m_item_y + pos * m_item_height;
|
||||||
int ypos2 = infobox.getYPos() + infobox.getHeight() - infobox.getHeight() / 2;
|
int ypos2 = infobox.getYPos() + infobox.getHeight() - infobox.getHeight() / 2;
|
||||||
|
|
||||||
@@ -1377,7 +1378,7 @@ void CUpnpBrowserGui::updateTimes(const bool force)
|
|||||||
|
|
||||||
void CUpnpBrowserGui::updateMode()
|
void CUpnpBrowserGui::updateMode()
|
||||||
{
|
{
|
||||||
/* switch back to mode_upnp if audio has stopped automatically */
|
// switch back to mode_upnp if audio has stopped automatically
|
||||||
if ((CAudioPlayer::getInstance()->getState() == CBaseDec::STOP) && (CNeutrinoApp::getInstance()->getMode() == NeutrinoModes::mode_audio))
|
if ((CAudioPlayer::getInstance()->getState() == CBaseDec::STOP) && (CNeutrinoApp::getInstance()->getMode() == NeutrinoModes::mode_audio))
|
||||||
{
|
{
|
||||||
CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, NeutrinoModes::mode_upnp | NeutrinoModes::norezap);
|
CNeutrinoApp::getInstance()->handleMsg(NeutrinoMessages::CHANGEMODE, NeutrinoModes::mode_upnp | NeutrinoModes::norezap);
|
||||||
|
@@ -116,8 +116,8 @@ class CUpnpBrowserGui : public CMenuTarget, public CListHelpers
|
|||||||
void paintDeviceInfo();
|
void paintDeviceInfo();
|
||||||
void playnext();
|
void playnext();
|
||||||
|
|
||||||
bool getItems(std::string id, unsigned int index, std::vector<UPnPEntry>*&entries, unsigned int &total);
|
bool getItems(std::string id, unsigned int index, std::vector<UPnPEntry> *&entries, unsigned int &total);
|
||||||
bool updateItemSelection(std::string id, std::vector<UPnPEntry>*&entries, int newpos, unsigned int &selected, unsigned int &liststart);
|
bool updateItemSelection(std::string id, std::vector<UPnPEntry> *&entries, int newpos, unsigned int &selected, unsigned int &liststart);
|
||||||
bool selectItem(std::string);
|
bool selectItem(std::string);
|
||||||
void paintItems(std::vector<UPnPEntry> *entry, unsigned int selected, unsigned int max, unsigned int offset);
|
void paintItems(std::vector<UPnPEntry> *entry, unsigned int selected, unsigned int max, unsigned int offset);
|
||||||
void paintItem(std::vector<UPnPEntry> *entry, unsigned int pos, unsigned int selected);
|
void paintItem(std::vector<UPnPEntry> *entry, unsigned int pos, unsigned int selected);
|
||||||
|
Reference in New Issue
Block a user