Login page and login sequence complete!

There is also a command SERMES to be added!
parent 6bff57e7
......@@ -2,7 +2,7 @@ function changeContent(id, content)
{
var n=document.getElementById(id);
if(typeof(n)!="undefined")
n.innerHTML=content;
n.innerHTML="ESTICAZZI";
}
function notify(content)
......
gui/img/logo.png

25.9 KB | W: | H:

gui/img/logo.png

23.6 KB | W: | H:

gui/img/logo.png
gui/img/logo.png
gui/img/logo.png
gui/img/logo.png
  • 2-up
  • Swipe
  • Onion skin
<html>
<head>
<title>SkyliveX</title>
<script type="text/javascript" src="SkyliveX.js"></script>
<script type="text/javascript">
function sendLogin()
{
SkyliveX.pushLogin(document.forms.loginform.user.value, document.forms.loginform.pass.value);
}
</script>
<style>
#page {
background-color: #0000FF;
color: #FFFFFF;
text-align: center;
margin: 0 auto;
}
</style>
</head>
<body>
<div id="page">
<b>SkyliveX 0.1.0 Login</b>
<form id="login" name="loginform">
Username: <input type="text" value="" name="user" placeholder="username">
Password: <input type="password" value="" name="pass" placeholder="password">
<input type="submit" value="Login" onClick="sendLogin();">
</form>
</div>
</body>
</html>
......@@ -2,15 +2,24 @@
<head>
<title>SkyliveX</title>
<script type="text/javascript">
function notifycb(content)
function notifycb(c)
{
document.getElementById("loadstring").innerHTML=content;
document.getElementById("loadstring").innerHTML=c;
}
</script>
<script type="text/javascript" src="SkyliveX.js"></script>
<style>
#loading {
color: #ff0000;
color: #FFFFFF;
text-align: center;
margin: 0 auto;
}
#loading h3 {
background-color: #0000ff;
width:100%;
text-align: center;
padding-bottom:5px;
padding-top: 3px;
}
</style>
</head>
......
......@@ -40,16 +40,47 @@
void SkyliveAuth::startPlugin()
{
std::cout << "SkyliveAuth initialized in thread " << thread() << std::endl;
registerHandler((QString)"getlogin", &SkyliveAuth::handle_getlogin);
}
void SkyliveAuth::receiveMessage(SKMessage::SKMessage msg)
{
std::cout << "SkyliveAuth msg received: " << msg.handle.toStdString() << std::endl;
if(_handlers.contains(msg.handle) && msg.sender != SENDER)
{
SKHandlerFunction mf =_handlers[msg.handle];
(this->*mf)(msg);
}
}
void SkyliveAuth::sendMessage(SKMessage::SKMessage msg)
{
msg.sender=SENDER;
emit putMessage(msg);
}
void SkyliveAuth::registerHandler(QString type, SKHandlerFunction handler)
{
_handlers[type] = handler;
}
void SkyliveAuth::handle_getlogin(SKMessage::SKMessage msg)
{
std::cout << "Auth module handle Login by " << msg.sender.toStdString() << std::endl;
/*
* XXX: This is, for the moment, a dummy plugin.
* Here we should check if we have a saved user and pass,
* and ask the main process only if we donesn't yet have one
* or if the user has logged out.
*/
SKMessage::SKMessage smsg("asklogin");
sendMessage(smsg);
}
......@@ -32,20 +32,38 @@
* Purpose:
*
*/
#ifndef SKAUTH_H
#define SKAUTH_H
#define SENDER "skauth"
#include <QObject>
#include <QHash>
#include <QString>
#include <QtPlugin>
#include "pluginsinterfaces.h"
#include "ipcmsg.h"
class SkyliveAuth;
typedef void (SkyliveAuth::*SKHandlerFunction)(SKMessage::SKMessage);
class SkyliveAuth : public QObject, SkylivexPluginInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "com.skylivex.SkylivexPlugin/1.0" FILE "skauth.json")
Q_INTERFACES(SkylivexPluginInterface)
private:
QHash<QString, SKHandlerFunction> _handlers;
public:
void startPlugin();
void sendMessage(SKMessage::SKMessage msg);
void registerHandler(QString type, SKHandlerFunction handler);
void handle_getlogin(SKMessage::SKMessage msg);
public slots:
void receiveMessage(SKMessage::SKMessage msg);
signals:
......@@ -53,3 +71,4 @@ class SkyliveAuth : public QObject, SkylivexPluginInterface
};
#endif
......@@ -44,13 +44,16 @@
void SkyliveProtocol::startPlugin()
{
SM_TCPCLIENT = HOME;
cver=CLIENTVERSION;
std::cout << "SkyliveProtocol initialized in thread " << thread() << std::endl;
registerHandler((QString)"connectTelescopes", &SkyliveProtocol::handle_connect);
registerHandler((QString)"putlogin", &SkyliveProtocol::handle_putlogin);
pktTimer = new QTimer();
QObject::connect(pktTimer, SIGNAL(timeout()), this, SLOT(processPackets()));
pktTimer->start();
}
......@@ -121,6 +124,8 @@ void SkyliveProtocol::processPackets()
std::cout << "Packet CRC OK command: " << pkt.cmd.toStdString() <<std::endl;
if(pkt.cmd=="LOGIN")
{
SKMessage::SKMessage msg("getlogin");
sendMessage(msg);
}
else if(pkt.cmd=="PING")
......@@ -260,16 +265,30 @@ void SkyliveProtocol::handle_connect(SKMessage::SKMessage msg)
tcpSocket->connectToHost(SERVERHOST, SERVERPORT);
}
void SkyliveProtocol::handle_putlogin(SKMessage::SKMessage msg)
{
QString cmd("LOGIN");
QList<QString> paramlist;
paramlist.append(msg.parameters["username"]);
paramlist.append(msg.parameters["password"]);
paramlist.append(cver);
sendPacket(cmd, paramlist);
}
void SkyliveProtocol::clientConnected()
{
SM_TCPCLIENT = CONNECTED;
SKMessage::SKMessage msg("telescopeConnected");
sendMessage(msg);
}
void SkyliveProtocol::receiveMessage(SKMessage::SKMessage msg)
{
std::cout << "SkyliveProtocol msg received: " << msg.handle.toStdString() << std::endl;
if(_handlers.contains(msg.handle))
if(_handlers.contains(msg.handle) && msg.sender!=SENDER)
{
SKHandlerFunction mf =_handlers[msg.handle];
(this->*mf)(msg);
......@@ -279,6 +298,7 @@ void SkyliveProtocol::receiveMessage(SKMessage::SKMessage msg)
void SkyliveProtocol::sendMessage(SKMessage::SKMessage msg)
{
msg.sender=SENDER;
emit putMessage(msg);
}
......
......@@ -47,9 +47,13 @@
#include "pluginsinterfaces.h"
#include "ipcmsg.h"
#define SENDER "skproto"
#define SERVERHOST "www.skylive.name"
#define SERVERPORT 8080
#define CLIENTVERSION "X_0.1.0"
#define MAX_PACKETREAD 2048
struct SKProtoMsg
......@@ -96,12 +100,14 @@ class SkyliveProtocol : public QObject, SkylivexPluginInterface
QQueue<SKProtoMsg> protoQueue;
QTimer* pktTimer;
void clearPkt();
QString cver;
public:
void startPlugin();
void sendMessage(SKMessage::SKMessage msg);
void registerHandler(QString type, SKHandlerFunction handler);
void handle_connect(SKMessage::SKMessage msg);
void handle_putlogin(SKMessage::SKMessage msg);
void sendPacket(const char* cmd, const char* params);
void sendPacket(QString &cmd, QString &params);
void sendPacket(SKProtoMsg &pkt);
......
......@@ -57,6 +57,13 @@ SKMessage::SKMessage(QString h, QHash<QString, QString > p)
handle = h;
}
SKMessage::SKMessage(QString s, QString h)
{
sender = s;
handle = h;
time = QTime::currentTime();
}
SKMessage::SKMessage(QString h)
{
sender= QString("unknown");
......
......@@ -60,6 +60,7 @@ class SKMessage
SKMessage(QString s, QString h, QHash<QString, QString > p);
SKMessage(QString h, QHash<QString, QString > p);
SKMessage(QString s, QString h);
SKMessage(QString h);
};
......
......@@ -35,7 +35,7 @@
*
*/
#include <QApplication>
#include <QFile>
#include <QString>
#include <QTimer>
#include "mainwin.h"
#include "skylivex.h"
......@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
// Start the splash screen. also
// the splash screen is a (transparent) webkit object
QFile splashfile("gui/splash.html");
QString splashfile("gui/splash.html");
MainWin mainw(splashfile);
mainw.show();
......
......@@ -36,18 +36,20 @@
#include <QWebView>
#include <QWebFrame>
#include <QFile>
#include <QUrl>
#include <QDir>
#include <QString>
#include <QPalette>
#include <iostream>
#include "ipcmsg.h"
MainWin::MainWin(QFile &htmlfile)
#define SENDER "maingui"
MainWin::MainWin(QString &htmlfile)
: QWebView(0)
{
htmlfile.open(QIODevice::ReadOnly);
htmlFileName = QString::fromUtf8(htmlfile.readAll().constData());
QUrl baseUrl = QUrl::fromLocalFile(QDir::current().absoluteFilePath("gui/dummy.html"));
baseUrl = QUrl::fromLocalFile(QDir::current().absoluteFilePath("gui/dummy.html"));
QPalette pal = palette();
pal.setBrush(QPalette::Base, Qt::transparent);
......@@ -57,12 +59,14 @@ MainWin::MainWin(QFile &htmlfile)
setAttribute(Qt::WA_TranslucentBackground, true);
setAttribute(Qt::WA_OpaquePaintEvent, false);
setHtml(htmlFileName, baseUrl);
setHtmlFile(htmlfile);
resize(250,200);
page()->mainFrame()->addToJavaScriptWindowObject("SkyliveX", &jsbridge);
jsbridge.mwin=qobject_cast<MainWin *>(this);
registerHandler((QString)"coreStarted", &MainWin::handle_corestarted);
registerHandler((QString)"telescopeConnected", &MainWin::handle_connected);
registerHandler((QString)"asklogin", &MainWin::handle_asklogin);
}
MainWin::~MainWin()
......@@ -70,10 +74,21 @@ MainWin::~MainWin()
}
void MainWin::setHtmlFile(QString &fname)
{
QFile filename(fname);
filename.open(QIODevice::ReadOnly);
htmlFileCont = QString::fromUtf8(filename.readAll().constData());
setHtml(htmlFileCont, baseUrl);
page()->mainFrame()->addToJavaScriptWindowObject("SkyliveX", &jsbridge);
}
void MainWin::msgFromCore(SKMessage::SKMessage &msg)
{
std::cout << "MainWindow msg reveived: " << msg.handle.toStdString() << std::endl;
if(_handlers.contains(msg.handle))
if(_handlers.contains(msg.handle) && msg.sender != SENDER)
{
SKHandlerFunction mf =_handlers[msg.handle];
(this->*mf)(msg);
......@@ -84,6 +99,7 @@ void MainWin::msgFromCore(SKMessage::SKMessage &msg)
void MainWin::sendMessage(SKMessage::SKMessage &msg)
{
msg.sender=SENDER;
emit putMessage(msg);
}
......@@ -102,8 +118,32 @@ void MainWin::handle_corestarted(SKMessage::SKMessage &msg)
}
void MainWin::handle_connected(SKMessage::SKMessage &msg)
{
std::cout << "Connected by " << msg.sender.toStdString() << std::endl;
jsbridge.notify("Connected");
}
void MainWin::handle_asklogin(SKMessage::SKMessage &msg)
{
std::cout << "asklogin by " << msg.sender.toStdString() << std::endl;
jsbridge.notify("Logging in");
QString html("gui/login.html");
setHtmlFile(html);
resize(250, 200);
}
void JSBridge::changePageContent(QString elementid, QString content)
{
emit changeContent(elementid, content);
}
void JSBridge::pushLogin(QString username, QString password)
{
std::cout << "pushLogin called from JS" << std::endl;
SKMessage::SKMessage loginmsg("putlogin");
loginmsg.parameters.insert("username", username);
loginmsg.parameters.insert("password", password);
mwin->sendMessage(loginmsg);
}
......@@ -59,11 +59,14 @@ class JSBridge : public QObject
Q_OBJECT
public:
MainWin* mwin;
void changePageContent(QString elementid, QString content);
signals:
void changeContent(QString elementid, QString content);
void notify(QString content);
public slots:
void pushLogin(QString username, QString password);
};
......@@ -78,20 +81,23 @@ class MainWin : public QWebView
Q_OBJECT
QUrl baseurl;
QFile htmlfile;
QString htmlFileName;
QUrl baseUrl;
QString htmlfile;
QString htmlFileCont;
JSBridge jsbridge;
private:
QHash<QString, SKHandlerFunction> _handlers;
void setHtmlFile(QString &fname);
public:
MainWin(QFile &htmlfile);
MainWin(QString &htmlfile);
~MainWin();
void sendMessage(SKMessage::SKMessage &msg);
void registerHandler(QString type, SKHandlerFunction handler);
void handle_corestarted(SKMessage::SKMessage &msg);
void handle_connected(SKMessage::SKMessage &msg);
void handle_asklogin(SKMessage::SKMessage &msg);
public slots:
void msgFromCore(SKMessage::SKMessage &msg);
......
......@@ -119,7 +119,7 @@ void SkyliveX::sendMessage(SKMessage::SKMessage &msg)
void SkyliveX::receiveFromMainWin(SKMessage::SKMessage &msg)
{
std::cout << "received from MainWin " << msg.handle.toStdString() << std::endl;
//emit msgForPlugins(msg);
emit msgForPlugins(msg);
}
void SkyliveX::receiveFromPlugins(SKMessage::SKMessage msg)
......
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