mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-02 18:31:22 +02:00
upnpbrowser: change code format
This commit is contained in:
@@ -165,10 +165,12 @@ CUpnpBrowserGui::~CUpnpBrowserGui()
|
||||
sigPall.disconnect();
|
||||
|
||||
delete m_socket;
|
||||
if (dline){
|
||||
if (dline)
|
||||
{
|
||||
delete dline; dline = NULL;
|
||||
}
|
||||
if (image){
|
||||
if (image)
|
||||
{
|
||||
delete image; image = NULL;
|
||||
}
|
||||
}
|
||||
@@ -262,7 +264,8 @@ bool CUpnpBrowserGui::discoverDevices()
|
||||
CHintBox hintbox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_UPNPBROWSER_SCANNING)); // UTF-8
|
||||
hintbox.paint();
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
m_devices = m_socket->Discover("urn:schemas-upnp-org:service:ContentDirectory:1");
|
||||
}
|
||||
catch (std::runtime_error &error)
|
||||
@@ -313,7 +316,8 @@ std::vector<UPnPEntry> *CUpnpBrowserGui::decodeResult(std::string result)
|
||||
xmlNodePtr root, node, snode;
|
||||
xmlDocPtr parser = parseXml(result.c_str(), "UTF-8");
|
||||
root = xmlDocGetRootElement(parser);
|
||||
if (!root) {
|
||||
if (!root)
|
||||
{
|
||||
xmlFreeDoc(parser);
|
||||
return NULL;
|
||||
}
|
||||
@@ -507,7 +511,8 @@ void CUpnpBrowserGui::updateDeviceSelection(int newpos)
|
||||
{
|
||||
if (newpos < 0) /* do not explode if called with -1 arg... */
|
||||
return;
|
||||
if((int) m_selecteddevice != newpos) {
|
||||
if ((int) m_selecteddevice != newpos)
|
||||
{
|
||||
int prev_selected = m_selecteddevice;
|
||||
unsigned int oldliststart = m_deviceliststart;
|
||||
|
||||
@@ -515,7 +520,8 @@ void CUpnpBrowserGui::updateDeviceSelection(int newpos)
|
||||
m_deviceliststart = (m_selecteddevice / m_listmaxshow) * m_listmaxshow;
|
||||
if (oldliststart != m_deviceliststart)
|
||||
paintDevices();
|
||||
else {
|
||||
else
|
||||
{
|
||||
paintDevice(prev_selected - m_deviceliststart);
|
||||
paintDevice(m_selecteddevice - m_deviceliststart);
|
||||
}
|
||||
@@ -553,10 +559,12 @@ void CUpnpBrowserGui::selectDevice()
|
||||
{
|
||||
loop = false;
|
||||
}
|
||||
else if (msg_repeatok == (neutrino_msg_t) g_settings.key_list_start) {
|
||||
else if (msg_repeatok == (neutrino_msg_t) g_settings.key_list_start)
|
||||
{
|
||||
updateDeviceSelection(0);
|
||||
}
|
||||
else if (msg_repeatok == (neutrino_msg_t) g_settings.key_list_end) {
|
||||
else if (msg_repeatok == (neutrino_msg_t) g_settings.key_list_end)
|
||||
{
|
||||
updateDeviceSelection(m_devices.size() - 1);
|
||||
}
|
||||
else if (msg_repeatok == CRCInput::RC_up || (int)msg == g_settings.key_pageup ||
|
||||
@@ -617,7 +625,8 @@ void CUpnpBrowserGui::playnext(void)
|
||||
std::list<UPnPAttribute>::iterator i;
|
||||
|
||||
printf("playnext: getResults m_playfolder %s m_playid %d\n", m_playfolder.c_str(), m_playid);
|
||||
if (!getResults(m_playfolder, m_playid, 1, results)) {
|
||||
if (!getResults(m_playfolder, m_playid, 1, results))
|
||||
{
|
||||
m_folderplay = false;
|
||||
return;
|
||||
}
|
||||
@@ -643,17 +652,20 @@ void CUpnpBrowserGui::playnext(void)
|
||||
if (preferred != -1)
|
||||
{
|
||||
std::string &mime = (*entries)[0].mime;
|
||||
if (mime.substr(0,6) == "audio/") {
|
||||
if (mime.substr(0, 6) == "audio/")
|
||||
{
|
||||
m_playing_entry = (*entries)[0];
|
||||
m_playing_entry_is_shown = false;
|
||||
playAudio((*entries)[0].resources[preferred].url, (*entries)[0].type);
|
||||
}
|
||||
else if (mime.substr(0,6) == "video/") {
|
||||
else if (mime.substr(0, 6) == "video/")
|
||||
{
|
||||
m_frameBuffer->Clear();
|
||||
m_folderplay = true;
|
||||
playVideo((*entries)[0].title, (*entries)[0].resources[preferred].url);
|
||||
}
|
||||
else if (mime.substr(0,6) == "image/") {
|
||||
else if (mime.substr(0, 6) == "image/")
|
||||
{
|
||||
if (m_folderplay)
|
||||
timeout = time(NULL) + g_settings.picviewer_slide_time;
|
||||
showPicture((*entries)[0].resources[preferred].url);
|
||||
@@ -661,12 +673,17 @@ void CUpnpBrowserGui::playnext(void)
|
||||
delete entries;
|
||||
entries = NULL;
|
||||
return;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
delete entries;
|
||||
entries = NULL;
|
||||
}
|
||||
} else {
|
||||
if(entries){
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entries)
|
||||
{
|
||||
delete entries;
|
||||
entries = NULL;
|
||||
}
|
||||
@@ -681,7 +698,8 @@ void CUpnpBrowserGui::playnext(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(entries){
|
||||
if (entries)
|
||||
{
|
||||
delete entries;
|
||||
entries = NULL;
|
||||
}
|
||||
@@ -704,20 +722,28 @@ bool CUpnpBrowserGui::getItems(std::string id, unsigned int index, std::vector<U
|
||||
if (!getResults(id, index, m_listmaxshow, results))
|
||||
return false;
|
||||
|
||||
for (i=results.begin(); i!=results.end(); ++i) {
|
||||
if (i->first=="NumberReturned") {
|
||||
for (i = results.begin(); i != results.end(); ++i)
|
||||
{
|
||||
if (i->first == "NumberReturned")
|
||||
{
|
||||
returned = atoi(i->second.c_str());
|
||||
nfound = true;
|
||||
} else if (i->first=="TotalMatches") {
|
||||
}
|
||||
else if (i->first == "TotalMatches")
|
||||
{
|
||||
total = atoi(i->second.c_str());
|
||||
tfound = true;
|
||||
} else if (i->first=="Result") {
|
||||
}
|
||||
else if (i->first == "Result")
|
||||
{
|
||||
entries = decodeResult(i->second);
|
||||
rfound = true;
|
||||
}
|
||||
}
|
||||
if (!entries || !nfound || !tfound || !rfound || returned != entries->size() || returned == 0){
|
||||
if(entries){
|
||||
if (!entries || !nfound || !tfound || !rfound || returned != entries->size() || returned == 0)
|
||||
{
|
||||
if (entries)
|
||||
{
|
||||
delete entries;
|
||||
entries = NULL;
|
||||
}
|
||||
@@ -728,19 +754,23 @@ bool CUpnpBrowserGui::getItems(std::string id, unsigned int index, std::vector<U
|
||||
|
||||
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)
|
||||
{
|
||||
int prev_selected = selected;
|
||||
unsigned int oldliststart = liststart;
|
||||
|
||||
selected = newpos;
|
||||
liststart = (selected / m_listmaxshow) * m_listmaxshow;
|
||||
printf("updateItemSelection: list start old %u new %d selected old %d new %d\n", oldliststart, liststart, prev_selected, selected);
|
||||
if (oldliststart != liststart) {
|
||||
if (oldliststart != liststart)
|
||||
{
|
||||
unsigned int total;
|
||||
if (!getItems(id, liststart, entries, total))
|
||||
return false;
|
||||
paintItems(entries, selected - liststart, total - liststart, liststart);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
paintItem(entries, prev_selected - liststart, selected - liststart);
|
||||
paintItem(entries, selected - liststart, selected - liststart);
|
||||
}
|
||||
@@ -766,11 +796,13 @@ bool CUpnpBrowserGui::selectItem(std::string id)
|
||||
if (!getItems(id, liststart, entries, total))
|
||||
return endall;
|
||||
|
||||
while (loop && entries!=NULL) {
|
||||
while (loop && entries != NULL)
|
||||
{
|
||||
updateTimes();
|
||||
updateMode();
|
||||
|
||||
if (refresh) {
|
||||
if (refresh)
|
||||
{
|
||||
printf("selectItem: refresh, timeout = %d\n", (int) timeout);
|
||||
if (!timeout)
|
||||
paintItems(entries, selected - liststart, total - liststart, liststart);
|
||||
@@ -780,26 +812,33 @@ bool CUpnpBrowserGui::selectItem(std::string id)
|
||||
g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display
|
||||
neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat;
|
||||
|
||||
if (msg == CRCInput::RC_timeout) {
|
||||
if (msg == CRCInput::RC_timeout)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
else if (msg == CRCInput::RC_home) {
|
||||
else if (msg == CRCInput::RC_home)
|
||||
{
|
||||
loop = false;
|
||||
endall = true;
|
||||
}
|
||||
else if (!timeout && (msg == CRCInput::RC_left)) {
|
||||
else if (!timeout && (msg == CRCInput::RC_left))
|
||||
{
|
||||
loop = false;
|
||||
}
|
||||
else if (!timeout && (msg_repeatok == (neutrino_msg_t) g_settings.key_list_start)) {
|
||||
else if (!timeout && (msg_repeatok == (neutrino_msg_t) g_settings.key_list_start))
|
||||
{
|
||||
updateItemSelection(id, entries, 0, selected, liststart);
|
||||
}
|
||||
else if (!timeout && (msg_repeatok == (neutrino_msg_t) g_settings.key_list_end)) {
|
||||
else if (!timeout && (msg_repeatok == (neutrino_msg_t) g_settings.key_list_end))
|
||||
{
|
||||
updateItemSelection(id, entries, total - 1, selected, liststart);
|
||||
}
|
||||
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 new_selected = selected - step;
|
||||
if (new_selected < 0) {
|
||||
if (new_selected < 0)
|
||||
{
|
||||
if (selected != 0 && step != 1)
|
||||
new_selected = 0;
|
||||
else
|
||||
@@ -807,10 +846,12 @@ bool CUpnpBrowserGui::selectItem(std::string id)
|
||||
}
|
||||
updateItemSelection(id, entries, new_selected, selected, liststart);
|
||||
}
|
||||
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 new_selected = selected + step;
|
||||
if (new_selected >= (int) total) {
|
||||
if (new_selected >= (int) total)
|
||||
{
|
||||
if ((total - m_listmaxshow - 1 < selected) && (selected != (total - 1)) && (step != 1))
|
||||
new_selected = total - 1;
|
||||
else if (((total / m_listmaxshow) + 1) * m_listmaxshow == total + m_listmaxshow) // last page has full entries
|
||||
@@ -820,15 +861,19 @@ bool CUpnpBrowserGui::selectItem(std::string id)
|
||||
}
|
||||
updateItemSelection(id, entries, new_selected, selected, liststart);
|
||||
}
|
||||
else if (!timeout && (msg == CRCInput::RC_ok || msg == CRCInput::RC_right)) {
|
||||
else if (!timeout && (msg == CRCInput::RC_ok || msg == CRCInput::RC_right))
|
||||
{
|
||||
if ((selected - liststart) >= (*entries).size())
|
||||
continue;
|
||||
if ((*entries)[selected - liststart].isdir) {
|
||||
if ((*entries)[selected - liststart].isdir)
|
||||
{
|
||||
endall = selectItem((*entries)[selected - liststart].id);
|
||||
if (endall)
|
||||
loop = false;
|
||||
refresh = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_folderplay = false;
|
||||
int preferred = (*entries)[selected - liststart].preferred;
|
||||
if (preferred != -1)
|
||||
@@ -858,18 +903,21 @@ bool CUpnpBrowserGui::selectItem(std::string id)
|
||||
|
||||
if (msg == CRCInput::RC_home || msg == CRCInput::RC_ok)
|
||||
break;
|
||||
else if (msg == CRCInput::RC_right || msg == CRCInput::RC_down) {
|
||||
else if (msg == CRCInput::RC_right || msg == CRCInput::RC_down)
|
||||
{
|
||||
m_playfolder = id;
|
||||
m_playid = (m_playid + 1) % total;
|
||||
playnext();
|
||||
}
|
||||
else if (msg == CRCInput::RC_left || msg == CRCInput::RC_up) {
|
||||
else if (msg == CRCInput::RC_left || msg == CRCInput::RC_up)
|
||||
{
|
||||
m_playfolder = id;
|
||||
m_playid--;
|
||||
if (m_playid < 0)
|
||||
m_playid = total - 1;
|
||||
playnext();
|
||||
} else
|
||||
}
|
||||
else
|
||||
CNeutrinoApp::getInstance()->handleMsg(msg, data);
|
||||
}
|
||||
m_frameBuffer->Clear();
|
||||
@@ -879,7 +927,8 @@ bool CUpnpBrowserGui::selectItem(std::string id)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (msg == CRCInput::RC_play || msg == CRCInput::RC_playpause) {
|
||||
else if (msg == CRCInput::RC_play || msg == CRCInput::RC_playpause)
|
||||
{
|
||||
if ((selected - liststart) >= (*entries).size())
|
||||
continue;
|
||||
m_folderplay = true;
|
||||
@@ -888,26 +937,30 @@ bool CUpnpBrowserGui::selectItem(std::string id)
|
||||
playnext();
|
||||
m_playid++;
|
||||
}
|
||||
else if (msg == CRCInput::RC_yellow) {
|
||||
else if (msg == CRCInput::RC_yellow)
|
||||
{
|
||||
m_folderplay = false;
|
||||
stopAudio();
|
||||
}
|
||||
else if (m_folderplay && (msg == (neutrino_msg_t) CRCInput::RC_stop
|
||||
|| video_key_msg == CMoviePlayerGui::PLUGIN_PLAYSTATE_STOP
|
||||
|| video_key_msg == CMoviePlayerGui::PLUGIN_PLAYSTATE_LEAVE_ALL)){
|
||||
|| video_key_msg == CMoviePlayerGui::PLUGIN_PLAYSTATE_LEAVE_ALL))
|
||||
{
|
||||
timeout = 0;
|
||||
m_folderplay = false;
|
||||
m_frameBuffer->Clear();
|
||||
refresh = true;
|
||||
}
|
||||
else if (m_folderplay && ((msg == (neutrino_msg_t) CRCInput::RC_prev) || video_key_msg == CMoviePlayerGui::PLUGIN_PLAYSTATE_PREV)){
|
||||
else if (m_folderplay && ((msg == (neutrino_msg_t) CRCInput::RC_prev) || video_key_msg == CMoviePlayerGui::PLUGIN_PLAYSTATE_PREV))
|
||||
{
|
||||
timeout = 0;
|
||||
m_playid -= 2;
|
||||
if (m_playid < 0)
|
||||
m_playid = 0;
|
||||
}
|
||||
else if (m_folderplay && (msg == (neutrino_msg_t) CRCInput::RC_next
|
||||
|| video_key_msg == CMoviePlayerGui::PLUGIN_PLAYSTATE_NEXT)){
|
||||
|| video_key_msg == CMoviePlayerGui::PLUGIN_PLAYSTATE_NEXT))
|
||||
{
|
||||
timeout = 0;
|
||||
stopAudio();
|
||||
}
|
||||
@@ -935,7 +988,8 @@ bool CUpnpBrowserGui::selectItem(std::string id)
|
||||
//refresh=true;
|
||||
}
|
||||
|
||||
if (m_folderplay && ((!timeout || (timeout <= time(NULL))) && (CAudioPlayer::getInstance()->getState() == CBaseDec::STOP))) {
|
||||
if (m_folderplay && ((!timeout || (timeout <= time(NULL))) && (CAudioPlayer::getInstance()->getState() == CBaseDec::STOP)))
|
||||
{
|
||||
playnext();
|
||||
m_playid++;
|
||||
}
|
||||
@@ -1165,7 +1219,8 @@ void CUpnpBrowserGui::paintItemInfo(UPnPEntry *entry)
|
||||
tmpname = g_PicViewer->DownloadImage(tmpname);
|
||||
int h_image = infobox.getHeight() - OFFSET_INTER - infobox.getCornerRadius();
|
||||
int y_image = infobox.getYPos() + infobox.getHeight() / 2 - h_image / 2;
|
||||
if (!image){
|
||||
if (!image)
|
||||
{
|
||||
image = new CComponentsPicture(0, y_image, tmpname, NULL, CC_SHADOW_OFF, COL_MENUCONTENTDARK_PLUS_0);
|
||||
image->doPaintBg(false);
|
||||
image->SetTransparent(CFrameBuffer::TM_BLACK);
|
||||
@@ -1174,8 +1229,11 @@ void CUpnpBrowserGui::paintItemInfo(UPnPEntry *entry)
|
||||
image->setHeight(h_image);
|
||||
int x_image = infobox.getXPos() + infobox.getWidth() - image->getWidth() - OFFSET_INTER - infobox.getCornerRadius();
|
||||
image->setXPos(x_image);
|
||||
}else{
|
||||
if (image){
|
||||
}
|
||||
else
|
||||
{
|
||||
if (image)
|
||||
{
|
||||
delete image; image = NULL;
|
||||
}
|
||||
}
|
||||
@@ -1230,14 +1288,19 @@ void CUpnpBrowserGui::paintDetails(UPnPEntry *entry, bool use_playing)
|
||||
timebox.setCorner(RADIUS_LARGE);
|
||||
|
||||
printf("paintDetails: use_playing %d shown %d\n", use_playing, m_playing_entry_is_shown);
|
||||
if ((!use_playing) && entry->isdir){
|
||||
if ((!use_playing) && entry->isdir)
|
||||
{
|
||||
infobox.kill();
|
||||
timebox.kill();
|
||||
m_playing_entry_is_shown = false;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string text = "";
|
||||
if (use_playing){
|
||||
if (!m_playing_entry_is_shown){
|
||||
if (use_playing)
|
||||
{
|
||||
if (!m_playing_entry_is_shown)
|
||||
{
|
||||
m_playing_entry_is_shown = true;
|
||||
text = m_playing_entry.title;
|
||||
text += !m_playing_entry.artist.empty() ? " - " + m_playing_entry.artist : "";
|
||||
@@ -1245,7 +1308,9 @@ void CUpnpBrowserGui::paintDetails(UPnPEntry *entry, bool use_playing)
|
||||
if (infobox.setText(text, CTextBox::AUTO_WIDTH))
|
||||
infobox.paint0();
|
||||
}
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!entry)
|
||||
return;
|
||||
m_playing_entry_is_shown = false;
|
||||
@@ -1263,8 +1328,10 @@ void CUpnpBrowserGui::paintDetails(UPnPEntry *entry, bool use_playing)
|
||||
|
||||
void CUpnpBrowserGui::paintItem2DetailsLine(int pos)
|
||||
{
|
||||
if (pos < 0){
|
||||
if (dline){
|
||||
if (pos < 0)
|
||||
{
|
||||
if (dline)
|
||||
{
|
||||
dline->kill();
|
||||
infobox.kill();
|
||||
timebox.kill();
|
||||
@@ -1286,10 +1353,12 @@ void CUpnpBrowserGui::paintItem2DetailsLine(int pos)
|
||||
|
||||
void CUpnpBrowserGui::updateTimes(const bool force)
|
||||
{
|
||||
if (CAudioPlayer::getInstance()->getState() != CBaseDec::STOP){
|
||||
if (CAudioPlayer::getInstance()->getState() != CBaseDec::STOP)
|
||||
{
|
||||
bool updatePlayed = force;
|
||||
|
||||
if ((m_time_played != CAudioPlayer::getInstance()->getTimePlayed())){
|
||||
if ((m_time_played != CAudioPlayer::getInstance()->getTimePlayed()))
|
||||
{
|
||||
m_time_played = CAudioPlayer::getInstance()->getTimePlayed();
|
||||
updatePlayed = true;
|
||||
}
|
||||
@@ -1298,7 +1367,8 @@ void CUpnpBrowserGui::updateTimes(const bool force)
|
||||
char play_time[14];
|
||||
snprintf(play_time, sizeof(play_time), "%ld:%02ld", m_time_played / 60, m_time_played % 60);
|
||||
|
||||
if (updatePlayed){
|
||||
if (updatePlayed)
|
||||
{
|
||||
timebox.setText(play_time, CTextBox::CENTER);
|
||||
timebox.paint0();
|
||||
}
|
||||
|
Reference in New Issue
Block a user