Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
skylivex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
astronomy
skylivex
Commits
02eafc95
Commit
02eafc95
authored
Feb 20, 2013
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Login page and login sequence complete!
There is also a command SERMES to be added!
parent
6bff57e7
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
189 additions
and
19 deletions
+189
-19
SkyliveX.js
gui/SkyliveX.js
+1
-1
logo.png
gui/img/logo.png
+0
-0
login.html
gui/login.html
+31
-0
splash.html
gui/splash.html
+12
-3
skauth.cpp
plugins/skauth.cpp
+31
-0
skauth.h
plugins/skauth.h
+19
-0
skproto.cpp
plugins/skproto.cpp
+21
-1
skproto.h
plugins/skproto.h
+6
-0
ipcmsg.cpp
src/ipcmsg.cpp
+7
-0
ipcmsg.h
src/ipcmsg.h
+1
-0
main.cpp
src/main.cpp
+2
-2
mainwin.cpp
src/mainwin.cpp
+47
-7
mainwin.h
src/mainwin.h
+10
-4
skylivex.cpp
src/skylivex.cpp
+1
-1
No files found.
gui/SkyliveX.js
View file @
02eafc95
...
...
@@ -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
View replaced file @
6bff57e7
View file @
02eafc95
25.9 KB
|
W:
|
H:
23.6 KB
|
W:
|
H:
2-up
Swipe
Onion skin
gui/login.html
0 → 100644
View file @
02eafc95
<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>
gui/splash.html
View file @
02eafc95
...
...
@@ -2,15 +2,24 @@
<head>
<title>
SkyliveX
</title>
<script
type=
"text/javascript"
>
function
notifycb
(
c
ontent
)
function
notifycb
(
c
)
{
document
.
getElementById
(
"loadstring"
).
innerHTML
=
c
ontent
;
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>
...
...
plugins/skauth.cpp
View file @
02eafc95
...
...
@@ -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
);
}
plugins/skauth.h
View file @
02eafc95
...
...
@@ -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
plugins/skproto.cpp
View file @
02eafc95
...
...
@@ -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
);
}
...
...
plugins/skproto.h
View file @
02eafc95
...
...
@@ -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
);
...
...
src/ipcmsg.cpp
View file @
02eafc95
...
...
@@ -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"
);
...
...
src/ipcmsg.h
View file @
02eafc95
...
...
@@ -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
);
};
...
...
src/main.cpp
View file @
02eafc95
...
...
@@ -35,7 +35,7 @@
*
*/
#include <QApplication>
#include <Q
File
>
#include <Q
String
>
#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
Q
File
splashfile
(
"gui/splash.html"
);
Q
String
splashfile
(
"gui/splash.html"
);
MainWin
mainw
(
splashfile
);
mainw
.
show
();
...
...
src/mainwin.cpp
View file @
02eafc95
...
...
@@ -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
);
setHtml
File
(
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
);
}
src/mainwin.h
View file @
02eafc95
...
...
@@ -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
base
u
rl
;
Q
File
htmlfile
;
QString
htmlFile
Name
;
QUrl
base
U
rl
;
Q
String
htmlfile
;
QString
htmlFile
Cont
;
JSBridge
jsbridge
;
private
:
QHash
<
QString
,
SKHandlerFunction
>
_handlers
;
void
setHtmlFile
(
QString
&
fname
);
public
:
MainWin
(
Q
File
&
htmlfile
);
MainWin
(
Q
String
&
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
);
...
...
src/skylivex.cpp
View file @
02eafc95
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment