Make chat and change telescope working

parent 3d3bb04e
...@@ -2,6 +2,23 @@ ...@@ -2,6 +2,23 @@
<head> <head>
<title>SkyliveX 0.1.0</title> <title>SkyliveX 0.1.0</title>
<script type="text/javascript" src="SkyliveX.js"></script> <script type="text/javascript" src="SkyliveX.js"></script>
<script type="text/javascript">
function sendMsg()
{
//publicReceived('me', document.forms.messagesend.msginput.value);
SkyliveX.chat_message_send(document.forms.messagesend.msginput.value);
document.forms.messagesend.msginput.value="";
}
function msgInputKey(event)
{
if(event.keyCode==13)
{
sendMsg();
}
}
</script>
<style> <style>
#page { #page {
background-color: #FFFFFF; background-color: #FFFFFF;
...@@ -76,12 +93,32 @@ ...@@ -76,12 +93,32 @@
left: 0px; left: 0px;
border: 1px solid #0000FF; border: 1px solid #0000FF;
} }
#msginput {
height: 100%;
left:0;
right:100;
position:absolute;
}
#msgsend {
position:absolute;
right:5;
height: 100%;
width: 90;
}
</style> </style>
</head> </head>
<body> <body>
<div id="page"> <div id="page">
<div id="top"> <div id="top">
<select id="telescopes" onChange="SkyliveX.change_telescope(this.options[this.selectedIndex].value);">
<option value="1">telescope 1</option>
<option value="2">telescope 2</option>
<option value="3">telescope 3</option>
<option value="4">telescope 4</option>
<option value="5">telescope 5</option>
</select>
</div> </div>
<div id="left"> <div id="left">
<div id="livearea"> <div id="livearea">
...@@ -99,7 +136,10 @@ ...@@ -99,7 +136,10 @@
<p>user2</p> <p>user2</p>
</div> </div>
<div id="chatinput"> <div id="chatinput">
<p>INPUT</p> <form name="messagesend" >
<textarea id="msginput" name="msginput" onKeyDown="msgInputKey(event);"></textarea>
<input id="msgsend" type="submit" name="msgsend" value="Invia" onClick="sendMsg();" />
</form>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -49,6 +49,7 @@ void SkyliveProtocol::startPlugin() ...@@ -49,6 +49,7 @@ void SkyliveProtocol::startPlugin()
registerHandler((QString)"connectTelescopes", &SkyliveProtocol::handle_connect); registerHandler((QString)"connectTelescopes", &SkyliveProtocol::handle_connect);
registerHandler((QString)"putlogin", &SkyliveProtocol::handle_putlogin); registerHandler((QString)"putlogin", &SkyliveProtocol::handle_putlogin);
registerHandler((QString)"publicChatSend", &SkyliveProtocol::handle_publicsend); registerHandler((QString)"publicChatSend", &SkyliveProtocol::handle_publicsend);
registerHandler((QString)"changeTelescope", &SkyliveProtocol::handle_changetelescope);
//pktTimer = new QTimer(); //pktTimer = new QTimer();
//QObject::connect(pktTimer, SIGNAL(timeout()), this, SLOT(processPackets())); //QObject::connect(pktTimer, SIGNAL(timeout()), this, SLOT(processPackets()));
...@@ -347,12 +348,24 @@ void SkyliveProtocol::handle_publicsend(SKMessage msg) ...@@ -347,12 +348,24 @@ void SkyliveProtocol::handle_publicsend(SKMessage msg)
{ {
QString cmd("CPUBLIC"); QString cmd("CPUBLIC");
QList<QString> paramlist; QList<QString> paramlist;
QByteArray message(msg.parameters[0].toLocal8Bit()); QByteArray message(msg.parameters["msg"].toLocal8Bit());
paramlist.append(message.toPercentEncoding()); paramlist.append(message.toPercentEncoding());
sendPacket(cmd, paramlist); sendPacket(cmd, paramlist);
} }
} }
void SkyliveProtocol::handle_changetelescope(SKMessage msg)
{
if(msg.parameters.size() > 0)
{
QString cmd("CHTELE");
QList<QString> paramlist;
paramlist.append(msg.parameters["telescope"]);
sendPacket(cmd, paramlist);
}
}
void SkyliveProtocol::clientConnected() void SkyliveProtocol::clientConnected()
{ {
SM_TCPCLIENT = CONNECTED; SM_TCPCLIENT = CONNECTED;
...@@ -402,3 +415,4 @@ void SkyliveProtocol::displayError(QAbstractSocket::SocketError socketError) ...@@ -402,3 +415,4 @@ void SkyliveProtocol::displayError(QAbstractSocket::SocketError socketError)
SM_TCPCLIENT = HOME; SM_TCPCLIENT = HOME;
} }
...@@ -109,6 +109,7 @@ class SkyliveProtocol : public QObject, SkylivexPluginInterface ...@@ -109,6 +109,7 @@ class SkyliveProtocol : public QObject, SkylivexPluginInterface
void handle_connect(SKMessage msg); void handle_connect(SKMessage msg);
void handle_putlogin(SKMessage msg); void handle_putlogin(SKMessage msg);
void handle_publicsend(SKMessage msg); void handle_publicsend(SKMessage msg);
void handle_changetelescope(SKMessage msg);
void sendPacket(const char* cmd, const char* params); void sendPacket(const char* cmd, const char* params);
void sendPacket(QString &cmd, QString &params); void sendPacket(QString &cmd, QString &params);
void sendPacket(SKProtoMsg &pkt); void sendPacket(SKProtoMsg &pkt);
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by Qt Creator 2.6.2, 2013-02-23T23:53:04. --> <!-- Written by Qt Creator 2.6.1, 2013-02-24T21:44:10. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>ProjectExplorer.Project.ActiveTarget</variable> <variable>ProjectExplorer.Project.ActiveTarget</variable>
...@@ -51,10 +51,10 @@ ...@@ -51,10 +51,10 @@
<data> <data>
<variable>ProjectExplorer.Project.Target.0</variable> <variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.0.1 MinGW 32bit</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.0.0 GCC 64bit (SDK)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.0.1 MinGW 32bit</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.0.0 GCC 64bit (SDK)</value>
<value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">qt.501.win32_mingw47.essentials_kit</value> <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">qt.500.gcc_64.essentials_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
...@@ -78,7 +78,16 @@ ...@@ -78,7 +78,16 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap> </valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.2">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">install</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">3</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
...@@ -105,7 +114,7 @@ ...@@ -105,7 +114,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value> <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">C:/Users/Ivan/Documents/GitHub/skylivex-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug</value> <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/nextime/skylivex/</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
...@@ -129,7 +138,16 @@ ...@@ -129,7 +138,16 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap> </valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.2">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">install</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">3</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
...@@ -156,7 +174,7 @@ ...@@ -156,7 +174,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">C:/Users/Ivan/Documents/GitHub/skylivex-build-Desktop_Qt_5_0_1_MinGW_32bit-Release</value> <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/nextime/skylivex/</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap> </valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value> <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
...@@ -207,7 +225,7 @@ ...@@ -207,7 +225,7 @@
</valuelist> </valuelist>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">skylivex</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">skylivex</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Ivan/Documents/GitHub/skylivex/src/skylivex.pro</value> <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/nextime/skylivex/src/skylivex.pro</value>
<value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value> <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">src/skylivex.pro</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">src/skylivex.pro</value>
...@@ -230,7 +248,7 @@ ...@@ -230,7 +248,7 @@
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.Updater.EnvironmentId</variable> <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
<value type="QString">{70fe70e9-61e4-4722-95de-00b652476132}</value> <value type="QString">{d2672f72-ce2b-4ab4-891e-45453a7867e7}</value>
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable> <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
......
...@@ -67,3 +67,26 @@ void JSBridge::toggleTransparentBackground(bool transparentbg) ...@@ -67,3 +67,26 @@ void JSBridge::toggleTransparentBackground(bool transparentbg)
wwin->toggleTransparentBackground(transparentbg); wwin->toggleTransparentBackground(transparentbg);
} }
/* a private message */
void JSBridge::chat_message_send(QString dest, QString message)
{
}
/* a public message */
void JSBridge::chat_message_send(QString message)
{
std::cout << "public message send called from JS" << std::endl;
SKMessage chatmsg("publicChatSend");
chatmsg.parameters.insert("msg", message);
wwin->sendMessage(chatmsg);
}
void JSBridge::change_telescope(QString tele)
{
std::cout << "Telescope change requested from JS" << std::endl;
SKMessage msg("changeTelescope");
msg.parameters.insert("telescope", tele);
wwin->sendMessage(msg);
}
...@@ -65,7 +65,9 @@ class JSBridge : public QObject ...@@ -65,7 +65,9 @@ class JSBridge : public QObject
void resizeWin(int width, int height); void resizeWin(int width, int height);
void toggleBorders(bool borders); void toggleBorders(bool borders);
void toggleTransparentBackground(bool transparentbg); void toggleTransparentBackground(bool transparentbg);
void chat_message_send(QString dest, QString message);
void chat_message_send(QString message);
void change_telescope(QString tele);
}; };
......
...@@ -61,6 +61,7 @@ MainWin::MainWin(QString &htmlfile) ...@@ -61,6 +61,7 @@ MainWin::MainWin(QString &htmlfile)
registerHandler((QString)"publicchatrcv", (SKHandlerFunction)&MainWin::handle_chatreceived); registerHandler((QString)"publicchatrcv", (SKHandlerFunction)&MainWin::handle_chatreceived);
msgsender = SENDER;
} }
......
...@@ -57,6 +57,7 @@ class MainWin : public WebWin ...@@ -57,6 +57,7 @@ class MainWin : public WebWin
public: public:
MainWin(QString &htmlfile); MainWin(QString &htmlfile);
~MainWin(); ~MainWin();
QString msgsender;
void handle_corestarted(SKMessage &msg); void handle_corestarted(SKMessage &msg);
void handle_connected(SKMessage &msg); void handle_connected(SKMessage &msg);
void handle_asklogin(SKMessage &msg); void handle_asklogin(SKMessage &msg);
......
...@@ -69,6 +69,8 @@ WebWin::WebWin(QString &htmlfile) ...@@ -69,6 +69,8 @@ WebWin::WebWin(QString &htmlfile)
connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(refreshJsObject())); connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(refreshJsObject()));
msgsender = SENDER;
} }
...@@ -125,7 +127,7 @@ void WebWin::setHtmlCont(QString cont, QUrl baseUrl, bool borders, bool transpar ...@@ -125,7 +127,7 @@ void WebWin::setHtmlCont(QString cont, QUrl baseUrl, bool borders, bool transpar
void WebWin::msgFromCore(SKMessage &msg) void WebWin::msgFromCore(SKMessage &msg)
{ {
std::cout << "WebWindow msg reveived: " << msg.handle.toStdString() << std::endl; std::cout << "WebWindow msg reveived: " << msg.handle.toStdString() << std::endl;
if(_handlers.contains(msg.handle) && msg.sender != SENDER) if(_handlers.contains(msg.handle) && msg.sender != msgsender)
{ {
SKHandlerFunction mf =_handlers[msg.handle]; SKHandlerFunction mf =_handlers[msg.handle];
(this->*mf)(msg); (this->*mf)(msg);
...@@ -178,7 +180,8 @@ void WebWin::toggleTransparentBackground(bool transparentbg) ...@@ -178,7 +180,8 @@ void WebWin::toggleTransparentBackground(bool transparentbg)
void WebWin::sendMessage(SKMessage &msg) void WebWin::sendMessage(SKMessage &msg)
{ {
msg.sender=SENDER; //msg.sender=SENDER;
msg.sender = msgsender;
emit putMessage(msg); emit putMessage(msg);
} }
......
...@@ -79,6 +79,7 @@ class WebWin : public QWebView ...@@ -79,6 +79,7 @@ class WebWin : public QWebView
void toggleBorders(bool borders); void toggleBorders(bool borders);
void toggleTransparentBackground(bool transparentbg); void toggleTransparentBackground(bool transparentbg);
JSBridge* jsbridge; JSBridge* jsbridge;
QString msgsender;
private slots: private slots:
void refreshJsObject(); void refreshJsObject();
......
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