Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
harbour-SailHN
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Andrea Scarpino
harbour-SailHN
Commits
958dc85c
Commit
958dc85c
authored
Jun 03, 2016
by
Andrea Scarpino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save the username
parent
a11bd14b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
37 additions
and
16 deletions
+37
-16
Settings.qml
qml/pages/Settings.qml
+1
-2
harbour-sailhn.changes
rpm/harbour-sailhn.changes
+2
-1
harbour-sailhn.spec
rpm/harbour-sailhn.spec
+1
-1
harbour-sailhn.yaml
rpm/harbour-sailhn.yaml
+1
-1
hnmanager.cpp
src/hnmanager.cpp
+22
-5
hnmanager.h
src/hnmanager.h
+4
-0
harbour-sailhn-it.ts
translations/harbour-sailhn-it.ts
+2
-2
harbour-sailhn-tr.ts
translations/harbour-sailhn-tr.ts
+2
-2
harbour-sailhn.ts
translations/harbour-sailhn.ts
+2
-2
No files found.
qml/pages/Settings.qml
View file @
958dc85c
...
...
@@ -160,6 +160,7 @@ Page {
}
Component.onCompleted
:
{
username
.
text
=
manager
.
getUsername
();
var
isAuth
=
manager
.
isAuthenticated
();
isAuthenticated
(
isAuth
);
...
...
@@ -177,14 +178,12 @@ Page {
}
else
{
login
.
text
=
qsTr
(
"Login"
);
details
.
visible
=
false
;
username
.
text
=
""
;
password
.
text
=
""
;
}
}
function
updateDetails
()
{
var
user
=
manager
.
loggedUser
();
username
.
text
=
user
.
id
;
details
.
visible
=
true
;
created
.
value
=
Qt
.
formatDateTime
(
user
.
created
);
karma
.
value
=
user
.
karma
;
...
...
rpm/harbour-sailhn.changes
View file @
958dc85c
*
Thu Mar 04
2016 Andrea Scarpino <me@andreascarpino.it> 0.8.1-1
*
Fri Jun 03
2016 Andrea Scarpino <me@andreascarpino.it> 0.8.1-1
- Add the capability to post comments
- Fix new comments non visible when refreshing
- Show logged user details in the settings
- Save the username
* Thu Mar 03 2016 Andrea Scarpino <me@andreascarpino.it> 0.8-1
- Implement authentication
...
...
rpm/harbour-sailhn.spec
View file @
958dc85c
...
...
@@ -13,7 +13,7 @@ Name: harbour-sailhn
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Unofficial Hacker News client
Version: 0.8
Version: 0.8
.1
Release: 1
Group: Qt/Qt
License: MIT
...
...
rpm/harbour-sailhn.yaml
View file @
958dc85c
Name
:
harbour-sailhn
Summary
:
Unofficial Hacker News client
Version
:
0.8
Version
:
0.8
.1
Release
:
1
# The contents of the Group field should be one of the groups listed here:
# http://gitorious.org/meego-developer-tools/spectacle/blobs/master/data/GROUPS
...
...
src/hnmanager.cpp
View file @
958dc85c
...
...
@@ -24,6 +24,7 @@
#include "hnmanager.h"
#include <QCoreApplication>
#include <QDebug>
#include <QEventLoop>
#include <QNetworkAccessManager>
...
...
@@ -32,6 +33,7 @@
#include <QNetworkReply>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QSettings>
#include <QUrlQuery>
#include "hackernewsapi.h"
...
...
@@ -43,8 +45,10 @@ HNManager::HNManager(QObject *parent) :
,
api
(
new
HackerNewsAPI
(
this
))
,
network
(
new
QNetworkAccessManager
(
this
))
,
m_loggedUser
(
0
)
,
m_loggedUsername
(
QString
())
{
m_settings
=
new
QSettings
(
QCoreApplication
::
applicationName
(),
QCoreApplication
::
applicationName
(),
this
);
setUsername
(
m_settings
->
value
(
"Username"
).
toString
());
network
->
setCookieJar
(
new
QNetworkCookieJar
(
this
));
}
...
...
@@ -53,12 +57,13 @@ HNManager::~HNManager()
delete
api
;
delete
network
;
delete
m_loggedUser
;
delete
m_settings
;
}
void
HNManager
::
authenticate
(
const
QString
&
username
,
const
QString
&
password
)
{
qDebug
()
<<
"Log in with username"
<<
username
;
m_loggedUsername
=
username
;
setUsername
(
username
)
;
QNetworkRequest
req
(
QUrl
(
BASE_URL
+
QLatin1String
(
"/login"
)));
req
.
setHeader
(
QNetworkRequest
::
ContentTypeHeader
,
QLatin1String
(
"application/x-www-form-urlencoded"
));
...
...
@@ -104,9 +109,20 @@ void HNManager::onLoggedUserFetched(User *user)
bool
HNManager
::
isAuthenticated
()
const
{
//qDebug() << "Is authenticated as:" << m_loggedUsername;
//qDebug() << "Is authenticated as:" << m_loggedUser->id();
return
m_loggedUser
!=
0
;
}
void
HNManager
::
setUsername
(
const
QString
&
username
)
{
m_loggedUsername
=
username
;
m_settings
->
setValue
(
"Username"
,
username
);
}
return
!
m_loggedUsername
.
isEmpty
();
QString
HNManager
::
getUsername
()
const
{
return
m_loggedUsername
;
}
User
*
HNManager
::
loggedUser
()
...
...
@@ -116,7 +132,8 @@ User* HNManager::loggedUser()
void
HNManager
::
logout
()
{
m_loggedUsername
.
clear
();
setUsername
(
QString
());
delete
m_loggedUser
;
// FIXME: is there a better way?
network
->
cookieJar
()
->
deleteLater
();
...
...
src/hnmanager.h
View file @
958dc85c
...
...
@@ -34,6 +34,7 @@ class HackerNewsAPI;
class
QNetworkAccessManager
;
class
QNetworkReply
;
class
QRegularExpression
;
class
QSettings
;
class
HNManager
:
public
QObject
{
...
...
@@ -46,6 +47,7 @@ public:
Q_INVOKABLE
void
authenticate
(
const
QString
&
username
,
const
QString
&
password
);
Q_INVOKABLE
bool
isAuthenticated
()
const
;
Q_INVOKABLE
User
*
loggedUser
();
Q_INVOKABLE
QString
getUsername
()
const
;
Q_INVOKABLE
void
logout
();
Q_INVOKABLE
void
submit
(
const
QString
&
title
,
const
QString
&
url
,
const
QString
&
text
);
Q_INVOKABLE
void
comment
(
const
int
parentId
,
const
QString
&
text
);
...
...
@@ -65,11 +67,13 @@ private:
QString
getSubmitCSRF
()
const
;
QString
getCommentCSRF
(
const
int
itemId
)
const
;
QString
getCSRF
(
QNetworkReply
*
reply
,
const
QRegularExpression
&
regexp
)
const
;
void
setUsername
(
const
QString
&
username
);
HackerNewsAPI
*
api
;
QNetworkAccessManager
*
network
;
User
*
m_loggedUser
;
QString
m_loggedUsername
;
QSettings
*
m_settings
;
};
#endif // HNMANAGER_H
translations/harbour-sailhn-it.ts
View file @
958dc85c
...
...
@@ -119,7 +119,7 @@
<
context
>
<
name
>
Settings
<
/name
>
<
message
>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"17
6
"
/>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"17
7
"
/>
<
source
>
Logged
<
/source
>
<
translation
>
Connesso
<
/translation
>
<
/message
>
...
...
@@ -150,7 +150,7 @@
<
/message
>
<
message
>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"95"
/>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"17
8
"
/>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"17
9
"
/>
<
source
>
Login
<
/source
>
<
translation
>
Entra
<
/translation
>
<
/message
>
...
...
translations/harbour-sailhn-tr.ts
View file @
958dc85c
...
...
@@ -119,7 +119,7 @@
<
context
>
<
name
>
Settings
<
/name
>
<
message
>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"17
6
"
/>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"17
7
"
/>
<
source
>
Logged
<
/source
>
<
translation
type
=
"unfinished"
><
/translation
>
<
/message
>
...
...
@@ -150,7 +150,7 @@
<
/message
>
<
message
>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"95"
/>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"17
8
"
/>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"17
9
"
/>
<
source
>
Login
<
/source
>
<
translation
type
=
"unfinished"
><
/translation
>
<
/message
>
...
...
translations/harbour-sailhn.ts
View file @
958dc85c
...
...
@@ -119,7 +119,7 @@
<
context
>
<
name
>
Settings
<
/name
>
<
message
>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"17
6
"
/>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"17
7
"
/>
<
source
>
Logged
<
/source
>
<
translation
type
=
"unfinished"
><
/translation
>
<
/message
>
...
...
@@ -150,7 +150,7 @@
<
/message
>
<
message
>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"95"
/>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"17
8
"
/>
<
location
filename
=
"../qml/pages/Settings.qml"
line
=
"17
9
"
/>
<
source
>
Login
<
/source
>
<
translation
type
=
"unfinished"
><
/translation
>
<
/message
>
...
...
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