From 3d27a5e1fc8c40e954217480250c293838941d0c Mon Sep 17 00:00:00 2001 From: nextime <nextime@nexlab.it> Date: Wed, 27 Feb 2013 23:05:16 +0100 Subject: [PATCH] Added open url --- plugins/skproto.cpp | 17 +++++++++++++++++ src/mainwin.cpp | 22 ++++++++++++++++++++++ src/mainwin.h | 1 + src/webwin.cpp | 1 - 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/plugins/skproto.cpp b/plugins/skproto.cpp index 638e529..9de5c26 100644 --- a/plugins/skproto.cpp +++ b/plugins/skproto.cpp @@ -206,6 +206,23 @@ void SkyliveProtocol::processPackets() } } } + else if(pkt.cmd=="OPENYOUTUBE") + { + QList<QString> paramlist = pkt.params.split(PARAM_SEPARATOR); + if(paramlist.size()==3) + { + //SKMessage mmsg("youtubevideo"); + //QString yt("http://youtube.googleapis.com/v/"); + SKMessage mmsg("openurl"); + QString yt("http://www.youtube.com/embed/"); + yt.append(paramlist[0]); + yt.append("?html5=1&autoplay=1&start="); + yt.append(paramlist[1]); + mmsg.parameters.insert("url", yt); + //mmsg.parameters.insert("volume", paramlist[2]); + sendMessage(mmsg); + } + } else { std::cout << "Unknown command from server" <<std::endl; diff --git a/src/mainwin.cpp b/src/mainwin.cpp index 494917f..6895cb7 100644 --- a/src/mainwin.cpp +++ b/src/mainwin.cpp @@ -57,6 +57,7 @@ MainWin::MainWin(QString &htmlfile) registerHandler((QString)"loginok", (SKHandlerFunction)&MainWin::handle_loginres); registerHandler((QString)"loginfailed", (SKHandlerFunction)&MainWin::handle_loginres); + registerHandler((QString)"openurl", (SKHandlerFunction)&MainWin::handle_openurl); msgsender = SENDER; @@ -106,3 +107,24 @@ void MainWin::handle_loginres(SKMessage &msg) } } +void MainWin::handle_openurl(SKMessage &msg) +{ + if(msg.handle=="openurl") + { + if(msg.parameters.contains("url")) + { + std::cout << "OPEN URL " << msg.parameters["url"].toStdString() << std::endl; + //if(msg.parameters.contains("width") + //if(msg.parameters.contains("height); + WebWin *wv = new WebWin; + QWebPage *newWeb = new QWebPage(wv); + + wv->setPage(newWeb); + wv->setAttribute(Qt::WA_DeleteOnClose, true); + + wv->setUrl(QUrl(msg.parameters["url"])); + wv->show(); + + } + } +} diff --git a/src/mainwin.h b/src/mainwin.h index 0e68489..23a3057 100644 --- a/src/mainwin.h +++ b/src/mainwin.h @@ -62,6 +62,7 @@ class MainWin : public SkylivexWin void handle_connected(SKMessage &msg); void handle_asklogin(SKMessage &msg); void handle_loginres(SKMessage &msg); + void handle_openurl(SKMessage &msg); }; diff --git a/src/webwin.cpp b/src/webwin.cpp index 06e84e0..950bd50 100644 --- a/src/webwin.cpp +++ b/src/webwin.cpp @@ -241,7 +241,6 @@ SkylivexWin::SkylivexWin() registerHandler((QString)"notify", (SKHandlerFunction)&SkylivexWin::handle_notify); registerHandler((QString)"publicchatrcv", (SKHandlerFunction)&SkylivexWin::handle_chatreceived); - } SkylivexWin* SkylivexWin::createSkyliveWindow(QString url, QWebPage::WebWindowType type) -- 2.18.1