Support to manage userlist on the protocol side

parent 04de2912
...@@ -29,9 +29,26 @@ skyliveClass.prototype.publicReceived = function(user, msg){ ...@@ -29,9 +29,26 @@ skyliveClass.prototype.publicReceived = function(user, msg){
} }
} }
}; };
skyliveClass.prototype.userlistChange = function(action, u){
if(typeof(userlist_change)=="function")
{
userlist_change(action, u);
} else {
switch(action)
{
case "new":
break;
case "add":
break;
case "del":
break;
}
}
};
SkyliveXPage = new skyliveClass(); SkyliveXPage = new skyliveClass();
SkyliveX.changeContent.connect(SkyliveXPage.changeContent); SkyliveX.changeContent.connect(SkyliveXPage.changeContent);
SkyliveX.notify.connect(SkyliveXPage.notify); SkyliveX.notify.connect(SkyliveXPage.notify);
SkyliveX.alertmsg.connect(SkyliveXPage.msgalert); SkyliveX.alertmsg.connect(SkyliveXPage.msgalert);
SkyliveX.public_received.connect(SkyliveXPage.publicReceived); SkyliveX.public_received.connect(SkyliveXPage.publicReceived);
SkyliveX.userlist_change.connect(SkyliveXPage.userlistChange);
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
</div> </div>
<div id="livearea"> <div id="livearea">
<img src="http://live1.skylive.name/tele1/live640.jpg"></img> <img id="liveimg" src="http://live1.skylive.name/tele1/live640.jpg"></img>
</div> </div>
<div id="telescope"> <div id="telescope">
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
</div> </div>
<div id="numteleselect"> <div id="numteleselect">
<select name="numtele" onChange="SkyliveX.change_telescope(this.options[this.selectedIndex].value);"> <select id="telsel" name="numtele" onChange="SkyliveX.change_telescope(this.options[this.selectedIndex].value); updateLiveImage();">
<option selected>1</option> <option selected>1</option>
<option>2</option> <option>2</option>
<option>3</option> <option>3</option>
...@@ -92,9 +92,28 @@ ...@@ -92,9 +92,28 @@
</select> </select>
</div> </div>
<script type="text/javascript" > <script type="text/javascript" >
function showLiveImage(img)
{
if(img.complete)
{
document.getElementById("liveimg").src=img.src;
} else {
setTimeout(function(){showLiveImage(img);}, 250);
}
}
function updateLiveImage()
{
var tele=document.getElementById("numtele").options[document.getElementById("numtele").selectedIndex].value;
var newImage = new Image();
newImage.src="http://live1.skylive.name/tele"+tele+"live640.jpg?"+new Date().getTime();
}
document.addEventListener('DOMContentLoaded',function(){ document.addEventListener('DOMContentLoaded',function(){
SkyliveX.open_window("chatgui.html", false); SkyliveX.open_window("chatgui.html", false);
setTimeout(function() { SkyliveX.resizeWin(636, 420); }, 500); setTimeout(function() { SkyliveX.resizeWin(636, 420); }, 500);
setInterval(updateLiveImage, 5000);
}); });
</script> </script>
</body> </body>
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <QTcpSocket> #include <QTcpSocket>
#include <QByteArray> #include <QByteArray>
#include <QtNetwork> #include <QtNetwork>
#include <QChar>
void SkyliveProtocol::startPlugin() void SkyliveProtocol::startPlugin()
{ {
...@@ -158,9 +158,55 @@ void SkyliveProtocol::processPackets() ...@@ -158,9 +158,55 @@ void SkyliveProtocol::processPackets()
else if(pkt.cmd=="STATUS") else if(pkt.cmd=="STATUS")
{ {
}
else if(pkt.cmd=="CLIST")
{
SKMessage pmsg("userlist");
QList<QString> paramlist = pkt.params.split(PARAM_SEPARATOR);
QList<QString> admins;
QList<QString> enableds;
QList<QString> users;
for(int i=0;i<paramlist.size();i++)
{
if(paramlist[i].length() > 2)
{
if(paramlist[i].startsWith("!"))
admins.append(paramlist[i].remove(0, 1));
else if(paramlist[i].startsWith("@"))
enableds.append(paramlist[i].remove(0, 1));
else
users.append(paramlist[i].remove(0, 1));
}
}
pmsg.listparams.insert("admins", admins);
pmsg.listparams.insert("enableds", enableds);
pmsg.listparams.insert("users", users);
pmsg.parameters.insert("type", "all");
sendMessage(pmsg);
} }
else if(pkt.cmd=="ULIST") else if(pkt.cmd=="ULIST")
{ {
SKMessage pmsg("userlist");
QList<QString> paramlist = pkt.params.split(PARAM_SEPARATOR);
if(paramlist[0].length() > 2)
{
if(paramlist[1]=="IN")
pmsg.parameters.insert("type", "in");
else
pmsg.parameters.insert("type", "out");
if(paramlist[0].startsWith("!"))
pmsg.parameters.insert("usertype", "admin");
else if(paramlist[0].startsWith("@"))
pmsg.parameters.insert("usertype", "enabled");
else
pmsg.parameters.insert("usertype", "user");
pmsg.parameters.insert("user", paramlist[0].remove(0, 1));
sendMessage(pmsg);
}
} }
else if(pkt.cmd=="ENABLE") else if(pkt.cmd=="ENABLE")
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include <QTime> #include <QTime>
#include <QHash> #include <QHash>
#include <QString> #include <QString>
#include <QList>
// Forward declarations // Forward declarations
class SkylivexWin; class SkylivexWin;
...@@ -68,6 +68,7 @@ class SKMessage ...@@ -68,6 +68,7 @@ class SKMessage
QString handle; // the message type QString handle; // the message type
SkylivexWin* webwin; // sometime we need to transport a qobject representing a WebView SkylivexWin* webwin; // sometime we need to transport a qobject representing a WebView
QHash<QString, QString > parameters; // mixed parameters in form of hash QHash<QString, QString > parameters; // mixed parameters in form of hash
QHash<QString, QList<QString> > listparams; // mixed parameters lists, when needed
SKMessage(QString s, QString h, QHash<QString, QString > p); SKMessage(QString s, QString h, QHash<QString, QString > p);
SKMessage(QString h, QHash<QString, QString > p); SKMessage(QString h, QHash<QString, QString > p);
......
...@@ -273,7 +273,6 @@ SkylivexWin::SkylivexWin(QString &htmlfile) ...@@ -273,7 +273,6 @@ SkylivexWin::SkylivexWin(QString &htmlfile)
registerHandler((QString)"notify", (SKHandlerFunction)&SkylivexWin::handle_notify); registerHandler((QString)"notify", (SKHandlerFunction)&SkylivexWin::handle_notify);
registerHandler((QString)"publicchatrcv", (SKHandlerFunction)&SkylivexWin::handle_chatreceived); registerHandler((QString)"publicchatrcv", (SKHandlerFunction)&SkylivexWin::handle_chatreceived);
} }
SkylivexWin::SkylivexWin() SkylivexWin::SkylivexWin()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment