Version 0.002 with working Favorite Combobox
This commit is contained in:
parent
42de63fe63
commit
571c9046d0
42 changed files with 1948 additions and 814 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.001" android:versionCode="1" android:installLocation="auto">
|
||||
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.002" android:versionCode="2" android:installLocation="auto">
|
||||
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Friendiqa" android:icon="@drawable/icon">
|
||||
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="Friendiqa" android:screenOrientation="unspecified" android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -3,7 +3,6 @@
|
|||
<file>js/layout.js</file>
|
||||
<file>js/photoworker.js</file>
|
||||
<file>js/service.js</file>
|
||||
<file>qml/FriendComponent.qml</file>
|
||||
<file>qml/MessageSend.qml</file>
|
||||
<file>qml/Newsitem.qml</file>
|
||||
<file>qml/PhotoComponent.qml</file>
|
||||
|
@ -20,5 +19,7 @@
|
|||
<file>images/defaultcontact.jpg</file>
|
||||
<file>qml/InfoBox.qml</file>
|
||||
<file>qml/GroupComponent.qml</file>
|
||||
<file>qml/ContactComponent.qml</file>
|
||||
<file>qml/PermissionDialog.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
|
|||
view.rootContext()->setContextProperty("xhr", xhr);
|
||||
FILESYSTEM* filesystem = FILESYSTEM::instance();
|
||||
view.rootContext()->setContextProperty("filesystem", filesystem);
|
||||
view.setSource(QUrl("qrc:/qml/friendiqa.qml"));
|
||||
view.setSource(QUrl("qrc:/qml/friendiqa.qml"));
|
||||
view.show();
|
||||
view.connect(view.rootContext()->engine(), SIGNAL(quit()), &app, SLOT(quit()));
|
||||
return app.exec();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "xhr.h"
|
||||
#include "xhr.h"
|
||||
|
||||
#include <QHttpPart>
|
||||
#include <QTextCodec>
|
||||
|
@ -14,7 +14,7 @@ XHR *XHR::instance()
|
|||
|
||||
XHR::XHR(QObject *parent) : QObject(parent)
|
||||
{
|
||||
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
||||
// request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
||||
}
|
||||
|
||||
void XHR::setUrl(QString url)
|
||||
|
@ -32,6 +32,15 @@ void XHR::setLogin(QString login)
|
|||
emit loginChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void XHR::setFilename(QString filename)
|
||||
{
|
||||
if (filename!=m_filename) {
|
||||
m_filename = filename;
|
||||
emit filenameChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString XHR::url() const
|
||||
{
|
||||
return m_url;
|
||||
|
@ -42,6 +51,11 @@ QString XHR::login() const
|
|||
return m_login;
|
||||
}
|
||||
|
||||
QString XHR::filename() const
|
||||
{
|
||||
return m_filename;
|
||||
}
|
||||
|
||||
void XHR::setParam(QString name, QString value)
|
||||
{
|
||||
params.insert(name, value);
|
||||
|
@ -58,6 +72,21 @@ void XHR::clearParams()
|
|||
params.clear();
|
||||
}
|
||||
|
||||
void XHR::download()
|
||||
{
|
||||
QUrl requrl(m_url);
|
||||
// qDebug() << "start download of " << requrl;
|
||||
request.setUrl(requrl);
|
||||
reply = manager.get(request);
|
||||
// qDebug() << "reply " << reply->header(QNetworkRequest::LocationHeader)<<reply->header(QNetworkRequest::LastModifiedHeader);
|
||||
// qDebug() << "request " << request.url();
|
||||
// qDebug() << "error " << reply->error();
|
||||
// reply->ignoreSslErrors();
|
||||
connect(reply, &QNetworkReply::readyRead,this, &XHR::onRequestFinished);
|
||||
connect(reply, &QNetworkReply::sslErrors, this, &XHR::onSSLError);
|
||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
||||
void XHR::get()
|
||||
{
|
||||
QUrlQuery query;
|
||||
|
@ -82,7 +111,7 @@ void XHR::get()
|
|||
connect(reply, &QNetworkReply::finished, this, &XHR::onReplySuccess);
|
||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
|
||||
connect(reply, &QNetworkReply::readyRead, this, &XHR::onReadyRead);
|
||||
|
||||
connect(reply, &QNetworkReply::sslErrors, this, &XHR::onSSLError);
|
||||
}
|
||||
|
||||
void XHR::post()
|
||||
|
@ -145,6 +174,22 @@ void XHR::onReplySuccess()
|
|||
reply->deleteLater();
|
||||
}
|
||||
|
||||
void XHR::onRequestFinished()
|
||||
{
|
||||
// Save the file here
|
||||
QByteArray b = reply->readAll();
|
||||
QImage image = QImage::fromData(b);
|
||||
if (image.isNull()){qDebug() << "Image empty"<<m_url;}
|
||||
QFile file(m_filename);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
image.save(&file, "JPG");
|
||||
b.clear();
|
||||
file.close();
|
||||
// qDebug() << m_url << "File downloaded "<<file.fileName();
|
||||
emit this->downloaded();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
void XHR::onReadyRead()
|
||||
{
|
||||
qDebug() << ".";
|
||||
|
|
|
@ -11,35 +11,43 @@ class XHR : public QObject
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged)
|
||||
Q_PROPERTY(QString login READ login WRITE setLogin NOTIFY loginChanged)
|
||||
|
||||
Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged)
|
||||
public:
|
||||
static XHR *instance();
|
||||
|
||||
explicit XHR(QObject *parent = 0);
|
||||
|
||||
void setUrl(QString url);
|
||||
// void setLogin(QString login);
|
||||
|
||||
// void setLogin(QString login);
|
||||
|
||||
QString url() const;
|
||||
QString login() const;
|
||||
QString filename() const;
|
||||
|
||||
signals:
|
||||
void urlChanged();
|
||||
void loginChanged();
|
||||
void filenameChanged();
|
||||
void downloaded();
|
||||
void success(QString data);
|
||||
void error(QString data, int code);
|
||||
|
||||
public slots:
|
||||
void setUrl(QString url);
|
||||
void setLogin(QString login);
|
||||
void setFilename(QString filename);
|
||||
void setParam(QString name, QString value);
|
||||
void setImageFileParam(QString name, QString url);
|
||||
void clearParams();
|
||||
void post();
|
||||
void get();
|
||||
void download();
|
||||
|
||||
private slots:
|
||||
void onReplyError(QNetworkReply::NetworkError code);
|
||||
void onReplySuccess();
|
||||
void onRequestFinished();
|
||||
//void onFileWritten();
|
||||
void onReadyRead();
|
||||
void onSSLError(const QList<QSslError> &errors);
|
||||
|
||||
|
@ -47,6 +55,7 @@ private:
|
|||
QByteArray buffer;
|
||||
QString m_url;
|
||||
QString m_login;
|
||||
QString m_filename;
|
||||
QHash<QString, QString> params;
|
||||
QHash<QString, QString> files;
|
||||
|
||||
|
|
|
@ -4,18 +4,19 @@
|
|||
function friendicaRequest(login,api,rootwindow,callback) {
|
||||
var xhrequest= new XMLHttpRequest();
|
||||
xhrequest.onreadystatechange = function() {
|
||||
if (xhrequest.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
||||
} else if(xhrequest.readyState === XMLHttpRequest.DONE) {
|
||||
// if (xhrequest.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
||||
// } else
|
||||
if(xhrequest.readyState === XMLHttpRequest.DONE) {
|
||||
try{ if (xhrequest.responseText!=""){
|
||||
callback(xhrequest.responseText)
|
||||
}else{
|
||||
showMessage("Error",api+" NO RESPONSE",rootwindow)
|
||||
callback(xhrequest.responseText)
|
||||
}else{
|
||||
showMessage("Error",api+" NO RESPONSE",rootwindow);
|
||||
callback(xhrequest.responseText)
|
||||
}
|
||||
}
|
||||
catch (e){
|
||||
showMessage("Error", api+" "+e,rootwindow)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
xhrequest.open("GET", login.server+api,true,login.username,Qt.atob(login.password));
|
||||
|
@ -65,12 +66,15 @@ function readData(database,table,username,callback,filter,filtervalue) { // read
|
|||
if (filter){
|
||||
var where = " AND "+ filter +" = '" + filtervalue+"'";
|
||||
} else { var where="";}
|
||||
if (username){
|
||||
var user = ' where username= "'+ username +'"';
|
||||
} else { var user='';}
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
if(!db) { return; }
|
||||
db.transaction( function(tx) {
|
||||
// print('select * from '+table'+where username= "'+username+'"'+'where);
|
||||
//print('select * from '+table+user+where);
|
||||
var rsArray=[];
|
||||
var rs = tx.executeSql('select * from '+table+' where username= "'+username+'"'+where);
|
||||
var rs = tx.executeSql('select * from '+table+user+where);
|
||||
for(var i = 0; i < rs.rows.length; i++) {
|
||||
rsArray.push(rs.rows.item(i))
|
||||
}
|
||||
|
@ -85,19 +89,20 @@ var where = " AND "+ filter +" = '" + filtervalue+"'";
|
|||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
if(!db) { return; }
|
||||
db.transaction( function(tx) {
|
||||
// print('... read from database ' + field)
|
||||
var rsArray=[];
|
||||
print('select DISTINCT '+field+' from '+table+' WHERE username="'+username+'"'+where+' ORDER BY '+field+' ASC');
|
||||
var rs = tx.executeSql('select DISTINCT '+field+' from '+table+' WHERE username="'+username+'"'+where+' ORDER BY '+field+' ASC');
|
||||
for(var i = 0; i < rs.rows.length; i++) {
|
||||
rsArray.push(rs.rows.item(i)[field])
|
||||
}
|
||||
callback(rsArray);
|
||||
//print('... read from database ' + field)
|
||||
var rsArray=[];
|
||||
//print('select DISTINCT '+field+' from '+table+' WHERE username="'+username+'"'+where+' ORDER BY '+field+' ASC');
|
||||
var rs = tx.executeSql('select DISTINCT '+field+' from '+table+' WHERE username="'+username+'"'+where+' ORDER BY '+field+' ASC');
|
||||
for(var i = 0; i < rs.rows.length; i++) {
|
||||
rsArray.push(rs.rows.item(i)[field])
|
||||
}
|
||||
callback(rsArray);
|
||||
});
|
||||
}
|
||||
|
||||
function showMessage(header,message,rootwindow){
|
||||
var messageString='import QtQuick 2.0; import QtQuick.Dialogs 1.2; MessageDialog{ visible: true; title:"'+header+'";standardButtons: StandardButton.Ok; text:" '+message+'"}';
|
||||
var cleanmessage=message.replace(/"/g,"-");
|
||||
var messageString='import QtQuick 2.0; import QtQuick.Dialogs 1.2; MessageDialog{ visible: true; title:"'+header+'";standardButtons: StandardButton.Ok; text:" '+cleanmessage+'"}';
|
||||
var messageObject=Qt.createQmlObject(messageString,rootwindow,"messageOutput");
|
||||
}
|
||||
|
||||
|
|
|
@ -40,35 +40,66 @@ function getFriendsTimeline(login,database,contacts,rootwindow,callback){// retr
|
|||
var result = tx.executeSql('SELECT status_id from news WHERE username="'+login.username+'" ORDER BY status_id DESC LIMIT 1'); // check for last news id
|
||||
try{parameter="&since_id="+result.rows.item(0).status_id;}catch(e){};})
|
||||
var newContacts=[];
|
||||
//print(JSON.stringify("Contacts "+contacts));
|
||||
Helperjs.friendicaRequest(login,"/api/statuses/friends_timeline"+parameter, rootwindow,function (obj){
|
||||
var news=JSON.parse(obj);
|
||||
for (var i=0;i<news.length;i++){
|
||||
if(contacts.indexOf(news[i].user.id)==-1 && !(inArray(newContacts,"id",news[i].user.id))){
|
||||
news[i].user.isFriend=0;
|
||||
newContacts.push(news[i].user);
|
||||
}
|
||||
if (news[i].friendica_activities.like.length>0){
|
||||
print("Like Contact"+JSON.stringify(news[i].friendica_activities.like));
|
||||
for (var j=0;j<news[i].friendica_activities.like.length;j++){
|
||||
if(contacts.indexOf(news[i].friendica_activities.like[j].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activities.like[j].id))){
|
||||
news[i].friendica_activities.like[j].isFriend=0;
|
||||
newContacts.push(news[i].friendica_activities.like[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (news[i].friendica_activities.dislike.length>0){
|
||||
print("DisLike Contact"+JSON.stringify(news[i].friendica_activities.dislike));
|
||||
for (var k=0;j<news[k].friendica_activities.dislike.length;k++){
|
||||
if(contacts.indexOf(news[i].friendica_activities.dislike[k].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activties.dislike[k].id))){
|
||||
news[i].friendica_activities.dislike[k].isFriend=0;
|
||||
newContacts.push(news[i].friendica_activities.dislike[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var newContacts=findNewContacts(news,contacts);
|
||||
// for (var i=0;i<news.length;i++){
|
||||
// if(contacts.indexOf(news[i].user.id)==-1 && !(inArray(newContacts,"id",news[i].user.id))){
|
||||
// news[i].user.isFriend=0;
|
||||
// newContacts.push(news[i].user);
|
||||
// }
|
||||
// if (news[i].friendica_activities.like.length>0){
|
||||
// // print("Like Contact"+JSON.stringify(news[i].friendica_activities.like));
|
||||
// for (var j=0;j<news[i].friendica_activities.like.length;j++){
|
||||
// if(contacts.indexOf(news[i].friendica_activities.like[j].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activities.like[j].id))){
|
||||
// news[i].friendica_activities.like[j].isFriend=0;
|
||||
// newContacts.push(news[i].friendica_activities.like[j]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (news[i].friendica_activities.dislike.length>0){
|
||||
// //print("DisLike Contact"+JSON.stringify(news[i].friendica_activities.dislike));
|
||||
// for (var k=0;j<news[k].friendica_activities.dislike.length;k++){
|
||||
// if(contacts.indexOf(news[i].friendica_activities.dislike[k].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activties.dislike[k].id))){
|
||||
// news[i].friendica_activities.dislike[k].isFriend=0;
|
||||
// newContacts.push(news[i].friendica_activities.dislike[k]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
callback(news,newContacts)
|
||||
})}
|
||||
|
||||
function findNewContacts(news,contacts){
|
||||
var newContacts=[];
|
||||
for (var i=0;i<news.length;i++){
|
||||
if(contacts.indexOf(news[i].user.id)==-1 && !(inArray(newContacts,"id",news[i].user.id))){
|
||||
news[i].user.isFriend=0;
|
||||
newContacts.push(news[i].user);
|
||||
}
|
||||
if (news[i].friendica_activities.like.length>0){
|
||||
// print("Like Contact"+JSON.stringify(news[i].friendica_activities.like));
|
||||
for (var j=0;j<news[i].friendica_activities.like.length;j++){
|
||||
if(contacts.indexOf(news[i].friendica_activities.like[j].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activities.like[j].id))){
|
||||
news[i].friendica_activities.like[j].isFriend=0;
|
||||
newContacts.push(news[i].friendica_activities.like[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (news[i].friendica_activities.dislike.length>0){
|
||||
//print("DisLike Contact"+JSON.stringify(news[i].friendica_activities.dislike));
|
||||
for (var k=0;j<news[k].friendica_activities.dislike.length;k++){
|
||||
if(contacts.indexOf(news[i].friendica_activities.dislike[k].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activties.dislike[k].id))){
|
||||
news[i].friendica_activities.dislike[k].isFriend=0;
|
||||
newContacts.push(news[i].friendica_activities.dislike[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return newContacts
|
||||
}
|
||||
|
||||
function storeNews(login,database,news,rootwindow,callback){
|
||||
// save news after contacts download, call next function
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
|
@ -80,14 +111,14 @@ function storeNews(login,database,news,rootwindow,callback){
|
|||
var attendyesarray=[]; for (var user in news[i].friendica_activities.attendyes){attendyesarray.push(parseInt(news[i].friendica_activities.attendyes[user].id))}
|
||||
var attendnoarray=[]; for (var user in news[i].friendica_activities.attendno){attendnoarray.push(parseInt(news[i].friendica_activities.attendno[user].id))}
|
||||
var attendmaybearray=[]; for (var user in news[i].friendica_activities.attendmaybe){attendmaybearray.push(parseInt(news[i].friendica_activities.attendmaybe[user].id))}
|
||||
|
||||
var friendica_activities=[likearray,dislikearray,attendyesarray,attendnoarray,attendmaybearray]
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('SELECT * from news where status_id = "'+news[i].id+'"'); // check for news id
|
||||
if(result.rows.length === 1) {// use update
|
||||
print(news[i].id +' exists, update it')
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=0, text="'+Qt.btoa(news[i].text)+'", created_at="'+Date.parse(cleanDate(news[i].created_at))+'", in_reply_to_status_id="'+news[i].in_reply_to_status_id+'", source="'+news[i].source+'", status_id="'+news[i].id+'", in_reply_to_user_id="'+news[i].in_reply_to_user_id+'", geo="'+news[i].geo+'", favorited="'+news[i].favorited+'", uid="'+news[i].user.id+'", statusnet_html="'+Qt.btoa(news[i].status_html)+'", statusnet_conversation_id="'+news[i].statusnet_conversation_id+'",like="'+JSON.stringify(likearray)+'", dislike="'+JSON.stringify(dislikearray)+'", attendyes="'+JSON.stringify(attendyesarray)+'",attendno="'+JSON.stringify(attendnoarray)+'",attendmaybe="'+JSON.stringify(attendmaybearray)+'" where status_id="'+news[i].status_id+'"');
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=0, text="'+Qt.btoa(news[i].text)+'", created_at="'+Date.parse(cleanDate(news[i].created_at))+'", in_reply_to_status_id="'+news[i].in_reply_to_status_id+'", source="'+news[i].source+'", status_id="'+news[i].id+'", in_reply_to_user_id="'+news[i].in_reply_to_user_id+'", geo="'+news[i].geo+'", favorited="'+news[i].favorited+'", uid="'+news[i].user.id+'", statusnet_html="'+Qt.btoa(news[i].status_html)+'", statusnet_conversation_id="'+news[i].statusnet_conversation_id+'",friendica_activities="'+JSON.stringify(friendica_activities)+'" where status_id="'+news[i].status_id+'"');
|
||||
} else {// use insert
|
||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,in_reply_to_status_id,source,status_id,in_reply_to_user_id,geo,favorited,uid,statusnet_html,statusnet_conversation_id,like,dislike,attendyes,attendno,attendmaybe) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,0,Qt.btoa(news[i].text),Date.parse(cleanDate(news[i].created_at)), news[i].in_reply_to_status_id, news[i].source, news[i].id,news[i].in_reply_to_user_id,news[i].geo,news[i].favorited, news[i].user.id,Qt.btoa(news[i].statusnet_html),news[i].statusnet_conversation_id, JSON.stringify(likearray),JSON.stringify(dislikearray),JSON.stringify(attendyesarray),JSON.stringify(attendnoarray),JSON.stringify(attendmaybearray)])}})
|
||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,in_reply_to_status_id,source,status_id,in_reply_to_user_id,geo,favorited,uid,statusnet_html,statusnet_conversation_id,friendica_activities,friendica_activities_self) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,0,Qt.btoa(news[i].text),Date.parse(cleanDate(news[i].created_at)), news[i].in_reply_to_status_id, news[i].source, news[i].id,news[i].in_reply_to_user_id,news[i].geo,news[i].favorited, news[i].user.id,Qt.btoa(news[i].statusnet_html),news[i].statusnet_conversation_id, JSON.stringify(friendica_activities),"[]"])}})
|
||||
}
|
||||
getDirectMessage(login,database,rootwindow,callback)
|
||||
}
|
||||
|
@ -102,9 +133,9 @@ function getDirectMessage(login,database,rootwindow,callback){
|
|||
var result = tx.executeSql('SELECT * from news where status_id = "'+messages[i].id+'"'); // check for news id
|
||||
if(result.rows.length === 1) {// use update
|
||||
print(messages[i].id +' exists, update it')
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=1, text="'+Qt.btoa(messages[i].text)+'", created_at="'+Date.parse(cleanDate(messages[i].created_at))+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].sender.id+'", statusnet_html="'+Qt.btoa(messages[i].text)+'" where status_id="'+messages[i].status_id+'"');
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=1, text="'+Qt.btoa(messages[i].text)+'", created_at="'+Date.parse(messages[i].created_at)+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].sender.id+'", statusnet_html="'+Qt.btoa(messages[i].text)+'" where status_id="'+messages[i].status_id+'"');
|
||||
} else {// use insert
|
||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id,uid,statusnet_html) VALUES (?,?,?,?,?,?,?,?)', [login.username,1,Qt.btoa(messages[i].text),Date.parse(cleanDate(messages[i].created_at)), "Friendica", messages[i].id, messages[i].sender.id,Qt.btoa(messages[i].text)])}
|
||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id,uid,statusnet_html) VALUES (?,?,?,?,?,?,?,?)', [login.username,1,Qt.btoa(messages[i].text),Date.parse(messages[i].created_at), "Friendica", messages[i].id, messages[i].sender.id,Qt.btoa(messages[i].text)])}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
@ -121,15 +152,25 @@ function getNotifications(login,database,rootwindow,callback){
|
|||
var result = tx.executeSql('SELECT * from news where status_id = "'+messages[i].id+'"'); // check for news id
|
||||
if(result.rows.length === 1) {// use update
|
||||
print(messages[i].id +' exists, update it')
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=2, text="'+Qt.btoa(messages[i].msg_html)+'", created_at="'+messages[i].timestamp+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].uid+'", statusnet_html="'+Qt.btoa(messages[i].msg_html)+'", statusnet_conversation_id="'+messages[i].parent+'" where status_id="'+messages[i].id+'"');
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=2, text="'+Qt.btoa(messages[i].msg_html)+'", created_at="'+Date.parse(messages[i].date)+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].uid+'", statusnet_html="'+Qt.btoa(messages[i].msg_html)+'", statusnet_conversation_id="'+messages[i].parent+'" where status_id="'+messages[i].id+'"');
|
||||
} else {// use insert
|
||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id, uid,statusnet_html,statusnet_conversation_id) VALUES (?,?,?,?,?,?,?,?,?)', [login.username,2,Qt.btoa(messages[i].msg_html),messages[i].timestamp,"Friendica", messages[i].id, messages[i].uid,Qt.btoa(messages[i].msg_html),messages[i].parent])}
|
||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id, uid,statusnet_html,statusnet_conversation_id) VALUES (?,?,?,?,?,?,?,?,?)', [login.username,2,Qt.btoa(messages[i].msg_html),Date.parse(messages[i].date),"Friendica", messages[i].id, messages[i].uid,Qt.btoa(messages[i].msg_html),messages[i].parent])}
|
||||
});
|
||||
}
|
||||
})
|
||||
newsfromdb(database,login.username,callback)
|
||||
}
|
||||
|
||||
function getActivitiesUserData(database,username,useridArray){
|
||||
var helpArray=[];
|
||||
for (var i=0;i<useridArray.length;i++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
helpArray.push(userdata[0]);
|
||||
},"id",useridArray[i]);
|
||||
}
|
||||
return helpArray
|
||||
}
|
||||
|
||||
function newsfromdb(database,username,callback,contact,stop_time){
|
||||
// return news before stop_time (used by More button), in brackets of 20 entries, or by specified contact
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
|
@ -139,6 +180,7 @@ db.transaction( function(tx) {
|
|||
stop="<="+rs.rows.item(0).created_at}catch(e){stop="<99999999999999"}}
|
||||
else{var stop="<"+stop_time}
|
||||
var contactfilter="";if(contact){contactfilter=" AND uid='"+contact+"'"}
|
||||
print('select * from news WHERE username="'+username+'" AND created_at'+stop+contactfilter+' ORDER BY created_at DESC LIMIT 20');
|
||||
var newsrs=tx.executeSql('select * from news WHERE username="'+username+'" AND created_at'+stop+contactfilter+' ORDER BY created_at DESC LIMIT 20');
|
||||
var newsArray=[];
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
|
@ -152,57 +194,45 @@ db.transaction( function(tx) {
|
|||
},"id",newsArray[i].in_reply_to_user_id);
|
||||
}
|
||||
if (newsArray[i].messagetype==0){
|
||||
//userdata for likes
|
||||
var likeArray=JSON.parse(newsArray[i].like);
|
||||
var likeHelper=[];
|
||||
for (var j=0;j<likeArray.length;j++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
likeHelper[j]=userdata[0];
|
||||
},"id",likeArray[j]);
|
||||
}
|
||||
newsArray[i].like=likeHelper;
|
||||
//userdata for dislikes
|
||||
var dislikeArray=JSON.parse(newsArray[i].dislike);
|
||||
var dislikeHelper=[];
|
||||
for (var k=0;k<dislikeArray.length;k++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
dislikeHelper[j]=userdata[0];
|
||||
},"id",dislikeArray[k]);
|
||||
}
|
||||
newsArray[i].dislike=dislikeHelper;
|
||||
//userdata for attendyes
|
||||
var attendyesArray=JSON.parse(newsArray[i].attendyes);
|
||||
var attendyesHelper=[];
|
||||
for (var l=0;l<attendyesArray.length;l++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
attendyesHelper[j]=userdata[0];
|
||||
},"id",attendyesArray[l]);
|
||||
}
|
||||
newsArray[i].attendyes=attendyesHelper;
|
||||
//userdata for attendno
|
||||
var attendnoArray=JSON.parse(newsArray[i].attendno);
|
||||
var attendnoHelper=[];
|
||||
for (var m=0;m<attendnoArray.length;m++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
attendnoHelper[j]=userdata[0];
|
||||
},"id",attendnoArray[m]);
|
||||
}
|
||||
newsArray[i].attendno=attendnoHelper;
|
||||
|
||||
//userdata for attendmaybe
|
||||
var attendmaybeArray=JSON.parse(newsArray[i].attendmaybe);
|
||||
var attendmaybeHelper=[];
|
||||
for (var n=0;n<attendmaybeArray.length;n++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
attendmaybeHelper[j]=userdata[0];
|
||||
},"id",attendmaybeArray[l]);
|
||||
}
|
||||
newsArray[i].attendmaybe=attendmaybeHelper;
|
||||
for(var j=0;j<newsArray[i].friendica_activities.length;j++)
|
||||
{var friendicaArray=JSON.parse(newsArray[i].friendica_activities);
|
||||
// print("Array: "+friendicaArray[1]);
|
||||
newsArray[i].like=getActivitiesUserData(database,username,friendicaArray[0]);
|
||||
newsArray[i].dislike=getActivitiesUserData(database,username,friendicaArray[1]);
|
||||
newsArray[i].attendyes=getActivitiesUserData(database,username,friendicaArray[2]);
|
||||
newsArray[i].attendno=getActivitiesUserData(database,username,friendicaArray[3]);
|
||||
newsArray[i].attendmaybe=getActivitiesUserData(database,username,friendicaArray[4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
callback(newsArray)});
|
||||
}
|
||||
|
||||
function fetchUsersForNews(database,username,news){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
news.user=userdata[0];
|
||||
//print("Fetch user"+JSON.stringify(news.user));
|
||||
},"id",news.uid);
|
||||
if(news.in_reply_to_user_id){
|
||||
Helperjs.readData(database,"contacts",username,function(replytodata){
|
||||
news.reply_user=replytodata[0];
|
||||
//print("Fetch reply to"+JSON.stringify(news.reply_user));
|
||||
},"id",news.in_reply_to_user_id);
|
||||
}
|
||||
if (news.messagetype==0){
|
||||
for(var j=0;j<news.friendica_activities.length;j++)
|
||||
{var friendicaArray=JSON.parse(news.friendica_activities);
|
||||
// print("Array: "+friendicaArray[1]);
|
||||
news.like=getActivitiesUserData(database,username,friendicaArray[0]);
|
||||
news.dislike=getActivitiesUserData(database,username,friendicaArray[1]);
|
||||
news.attendyes=getActivitiesUserData(database,username,friendicaArray[2]);
|
||||
news.attendno=getActivitiesUserData(database,username,friendicaArray[3]);
|
||||
news.attendmaybe=getActivitiesUserData(database,username,friendicaArray[4]);
|
||||
}
|
||||
}
|
||||
return news
|
||||
}
|
||||
|
||||
function deleteNews(login,database,newsid,rootwindow,callback){
|
||||
Helperjs.friendicaPostRequest(login,"/api/statuses/destroy?id="+newsid, rootwindow,function (obj){
|
||||
print("Delete "+obj);
|
||||
|
@ -228,73 +258,105 @@ function favorite(login,favorite,newsid,rootwindow){
|
|||
})}
|
||||
}
|
||||
|
||||
function likerequest(login,database,toggle,verb,newsid,rootwindow){
|
||||
function likerequest(login,database,verb,newsid,rootwindow){
|
||||
Helperjs.friendicaPostRequest(login,"/api/friendica/activity/"+verb+"?id="+newsid, rootwindow,function (obj){
|
||||
print("likereturn "+obj);
|
||||
if (obj=='"ok"'){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {var result = tx.executeSql('UPDATE news SET '+verb+'d ='+toggle+' where status_id ='+newsid);
|
||||
})}})
|
||||
db.transaction( function(tx) {
|
||||
var currentActivities_rs=tx.executeSql('select friendica_activities_self from news WHERE username="'+login.username+'" AND status_id='+newsid) ;
|
||||
var currentActivities=JSON.parse(currentActivities_rs.rows.item(0).friendica_activities_self);
|
||||
//print("currentActivities "+JSON.stringify(currentActivities));
|
||||
if ((verb=="like")&&(currentActivities.indexOf(1)==-1)){ currentActivities.push(1);
|
||||
currentActivities.splice(currentActivities.indexOf(2),1)
|
||||
}
|
||||
if ((verb=="dislike")&&(currentActivities.indexOf(2)==-1)){ currentActivities.push(2);
|
||||
currentActivities.splice(currentActivities.indexOf(1),1)
|
||||
}
|
||||
if (verb=="unlike"){ try{currentActivities.splice(currentActivities.indexOf(1),1)}catch(e){}}
|
||||
if (verb=="undislike"){ try{currentActivities.splice(currentActivities.indexOf(2),1)}catch(e){}}
|
||||
var result = tx.executeSql('UPDATE news SET friendica_activities_self ="'+JSON.stringify(currentActivities)+'" where username="'+login.username+'" AND status_id ='+newsid);
|
||||
})}
|
||||
else{print("likerequest"+obj)}})
|
||||
}
|
||||
|
||||
function like(login,database,toggle,verb,newsid,rootwindow){
|
||||
if(verb=="like"&& toggle==1){
|
||||
likerequest(login,database,1,"like",newsid,rootwindow);
|
||||
likerequest(login,database,0,"undislike",newsid,rootwindow);}
|
||||
if(verb=="dislike"&& toggle==1){
|
||||
likerequest(login,database,1,"dislike",newsid,rootwindow);
|
||||
likerequest(login,database,0,"unlike",newsid,rootwindow);}
|
||||
if(toggle==0){
|
||||
likerequest(login,database,0,"un"+verb,newsid,rootwindow);}
|
||||
if(verb=="like"&& toggle==1){likerequest(login,database,"like",newsid,rootwindow);
|
||||
}
|
||||
if(verb=="dislike"&& toggle==1){likerequest(login,database,"dislike",newsid,rootwindow);
|
||||
}
|
||||
if(toggle==0){
|
||||
likerequest(login,database,"un"+verb,newsid,rootwindow);}
|
||||
}
|
||||
|
||||
function attend(login,database,attend,newsid,rootwindow,callback){
|
||||
Helperjs.friendicaPostRequest(login,"/api/friendica/activity/attend"+attend+"?id="+newsid, rootwindow,function (obj){
|
||||
var attendReturn=JSON.parse(obj);
|
||||
// print("attend: "+obj);
|
||||
//if (attendReturn=="OK")
|
||||
{
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {var result = tx.executeSql('UPDATE news SET attend="+attend+" where status_id ='+newsid);
|
||||
callback();
|
||||
Helperjs.friendicaPostRequest(login,"/api/friendica/activity/attend"+attend+"?id="+newsid, rootwindow,function (obj){
|
||||
var attendReturn=JSON.parse(obj);
|
||||
// print("attend: "+obj);
|
||||
if (attendReturn=="OK")
|
||||
{var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var currentActivities_rs=tx.executeSql('select friendica_activities_self from news WHERE username="'+login.username+'" AND status_id='+newsid) ;
|
||||
var currentActivities=JSON.parse(currentActivities_rs.rows.item(0));
|
||||
print("currentActivities "+JSON.stringify(currentActivities));
|
||||
if ((attend=="attendyes")&&(currentActivities.indexOf(3)==-1)){
|
||||
currentActivities.push(3);
|
||||
currentActivities.splice(currentActivities.indexOf(4),1)
|
||||
currentActivities.splice(currentActivities.indexOf(5),1)
|
||||
}
|
||||
if ((attend=="attendno")&&(currentActivities.indexOf(4)==-1)){
|
||||
currentActivities.push(4);
|
||||
currentActivities.splice(currentActivities.indexOf(3),1)
|
||||
currentActivities.splice(currentActivities.indexOf(5),1)
|
||||
}
|
||||
if ((attend=="attendmaybe")&&(currentActivities.indexOf(5)==-1)){
|
||||
currentActivities.push(5);
|
||||
currentActivities.splice(currentActivities.indexOf(3),1)
|
||||
currentActivities.splice(currentActivities.indexOf(4),1)
|
||||
}
|
||||
var result = tx.executeSql('UPDATE news SET friendica_activities_self ="'+JSON.stringify(currentActivities)+'" where username="'+login.username+'" AND status_id ='+newsid);
|
||||
callback();
|
||||
})}})}
|
||||
|
||||
function requestConversation(login,database,newsid,rootwindow,callback){
|
||||
function requestConversation(login,database,newsid,contacts,rootwindow,callback){
|
||||
Helperjs.friendicaRequest(login,"/api/conversation/show?id="+newsid,rootwindow, function (obj){
|
||||
print(obj+JSON.stringify(obj));
|
||||
var news=JSON.parse(obj);
|
||||
for (var i=0;i<news.length;i++){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
print('store news data for ' + news[i].id);
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('SELECT * from news where status_id = "'+news[i].id+'"'); // check for news id
|
||||
if(result.rows.length === 1) {// use update
|
||||
print(news[i].id +' exists, update it')
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=0, text="'+Qt.btoa(news[i].text)+'", truncated="'+news[i].truncated+'", created_at="'+Date.parse(cleanDate(news[i].created_at))+'", in_reply_to_status_id="'+news[i].in_reply_to_status_id+'", source="'+news[i].source+'", status_id="'+news[i].id+'", in_reply_to_user_id="'+news[i].in_reply_to_user_id+'", geo="'+news[i].geo+'", favorited="'+news[i].favorited+'", uid="'+news[i].user.id+'", statusnet_html="'+Qt.btoa(news[i].status_html)+'", statusnet_conversation_id="'+news[i].statusnet_conversation_id+'", attachments="'+news[i].attachments+'" where status_id="'+news[i].status_id+'"');
|
||||
} else {// use insert
|
||||
result = tx.executeSql('INSERT INTO news VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,0,Qt.btoa(news[i].text),news[i].truncated,Date.parse(cleanDate(news[i].created_at)), news[i].in_reply_to_status_id, news[i].source, news[i].id,news[i].in_reply_to_user_id,news[i].geo,news[i].favorited, news[i].user.id,Qt.btoa(news[i].statusnet_html),news[i].statusnet_conversation_id, news[i].attachments,0,0,0]);
|
||||
}});
|
||||
if(news[i].user.following!=true){
|
||||
updateContactInDB(login,database,rootwindow,news[i].user)}
|
||||
}
|
||||
callback();
|
||||
}
|
||||
);}
|
||||
var newContacts=findNewContacts(news,contacts);
|
||||
// storeNews(login,database,news,rootwindow,callback)
|
||||
callback(news,newContacts)
|
||||
})}
|
||||
|
||||
function conversationfromdb(database,user,conversationId,callback){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
print('select * from news WHERE statusnet_conversation_id='+conversationId+' ORDER BY status_id DESC');
|
||||
var newsrs=tx.executeSql('select * from news WHERE statusnet_conversation_id='+conversationId+' ORDER BY status_id DESC');
|
||||
var newsArray=[];
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
newsArray.push(newsrs.rows.item(i))
|
||||
Helperjs.readData(database,"contacts",function(userdata){
|
||||
newsArray[i].user=userdata[0];
|
||||
},"id",newsArray[i].uid);
|
||||
}
|
||||
var newsArray=[];
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
newsArray.push(newsrs.rows.item(i));
|
||||
newsArray[i]=fetchUsersForNews(database,user,newsArray[i]);
|
||||
callback(newsArray);
|
||||
});}
|
||||
}})}
|
||||
|
||||
function requestFavorites(login,database,rootwindow,callback){
|
||||
Helperjs.friendicaRequest(login,"/api/favorites",rootwindow, function (obj){
|
||||
//print(obj+JSON.stringify(obj));
|
||||
var news=JSON.parse(obj);
|
||||
// storeNews(login,database,news,rootwindow,callback)
|
||||
callback(news)
|
||||
})}
|
||||
|
||||
function favoritesfromdb(database,user,callback){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
print('select * from news WHERE username="'+user+'" AND favorited=1 ORDER BY status_id DESC');
|
||||
var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND favorited=1 ORDER BY status_id DESC');
|
||||
var newsArray=[];
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
newsArray.push(newsrs.rows.item(i));
|
||||
newsArray[i]=fetchUsersForNews(database,user,newsArray[i]);
|
||||
callback(newsArray);
|
||||
}})}
|
||||
|
||||
|
||||
function inArray(list, prop, val) {
|
||||
if (list.length > 0 ) {
|
||||
|
|
|
@ -1,35 +1,50 @@
|
|||
WorkerScript.onMessage = function(msg) {
|
||||
if(msg.appendnews!==true){ msg.model.clear()};
|
||||
|
||||
for (var j=0;j<msg.news.length;j++){
|
||||
if (msg.news[j]) {
|
||||
var newsitemobject=msg.news[j];
|
||||
var likeText="";var dislikeText="";var attendyesText="";var attendnoText="";var attendmaybeText="";
|
||||
if (newsitemobject.messagetype==0){
|
||||
if (msg.news[j].like.length>0){
|
||||
if (msg.news[j].like.length==1){likeText= Qt.atob(msg.news[j].like[0].name)+" "+ qsTr("likes this.")}
|
||||
else {likeText= msg.news[j].like.length+" "+ qsTr("like this.")}
|
||||
if (msg.news[j]) {
|
||||
var newsitemobject=msg.news[j];
|
||||
//print("Newsitem"+JSON.stringify(newsitemobject));
|
||||
if (newsitemobject.messagetype==2){
|
||||
newsitemobject.user={};
|
||||
newsitemobject.user.profile_image="qrc:/images/defaultcontact.jpg";
|
||||
newsitemobject.user.profile_image_url="qrc:/images/defaultcontact.jpg";
|
||||
newsitemobject.user.name="";
|
||||
}
|
||||
var likeText="";var dislikeText="";var attendyesText="";var attendnoText="";var attendmaybeText=""; var self={};
|
||||
if (newsitemobject.messagetype==0){
|
||||
if (newsitemobject.like.length>0){
|
||||
if (newsitemobject.like.length==1){likeText= Qt.atob(newsitemobject.like[0].name)+" "+ qsTr("likes this.")}
|
||||
else {likeText= newsitemobject.like.length+" "+ qsTr("like this.")}
|
||||
}
|
||||
if (msg.news[j].dislike.length>0){
|
||||
if (msg.news[j].dislike.length==1){dislikeText= QT.atob(msg.news[j].dislike[0].name)+" "+ qsTr("doesn't like this.")}
|
||||
else {dislikeText= msg.news[j].dislike.length+" "+ qsTr("don't like this.")}
|
||||
if (newsitemobject.dislike.length>0){
|
||||
if (newsitemobject.dislike.length==1){dislikeText= QT.atob(newsitemobject.dislike[0].name)+" "+ qsTr("doesn't like this.")}
|
||||
else {dislikeText= newsitemobject.dislike.length+" "+ qsTr("don't like this.")}
|
||||
}
|
||||
if (msg.news[j].attendyes.length>0){
|
||||
if (msg.news[j].attendyes.length==1){attendyesText= Qt.atob(msg.news[j].attendyes[0].name)+" "+ qsTr("will attend.")}
|
||||
else {attendyesText= msg.news[j].attendyes.length+" "+ qsTr("persons will attend.")}
|
||||
if (newsitemobject.attendyes.length>0){
|
||||
if (newsitemobject.attendyes.length==1){attendyesText= Qt.atob(newsitemobject.attendyes[0].name)+" "+ qsTr("will attend.")}
|
||||
else {attendyesText= newsitemobject.attendyes.length+" "+ qsTr("persons will attend.")}
|
||||
}
|
||||
if (msg.news[j].attendno.length>0){
|
||||
if (msg.news[j].attendno.length==1){attendnoText= Qt.atob(msg.news[j].attendno[0].name)+" "+ qsTr("will not attend.")}
|
||||
else {attendnoText= msg.news[j].attendno.length+" "+ qsTr("persons will not attend.")}
|
||||
if (newsitemobject.attendno.length>0){
|
||||
if (newsitemobject.attendno.length==1){attendnoText= Qt.atob(newsitemobject.attendno[0].name)+" "+ qsTr("will not attend.")}
|
||||
else {attendnoText= newsitemobject.attendno.length+" "+ qsTr("persons will not attend.")}
|
||||
}
|
||||
if (msg.news[j].attendmaybe.length>0){
|
||||
if (msg.news[j].attendmaybe.length==1){attendmaybeText= Qt.atob(msg.news[j].attendmaybe[0].name)+" "+ qsTr("may attend.")}
|
||||
else {attendmaybeText= msg.news[j].attendmaybe.length+" "+ qsTr("persons may attend.")}
|
||||
if (newsitemobject.attendmaybe.length>0){
|
||||
if (newsitemobject.attendmaybe.length==1){attendmaybeText= Qt.atob(newsitemobject.attendmaybe[0].name)+" "+ qsTr("may attend.")}
|
||||
else {attendmaybeText= newsitemobject.attendmaybe.length+" "+ qsTr("persons may attend.")}
|
||||
}
|
||||
var friendica_activities_self=JSON.parse(newsitemobject.friendica_activities_self);
|
||||
if (friendica_activities_self.indexOf(3)!=-1){self.attending=qsTr("yes")}
|
||||
if (friendica_activities_self.indexOf(4)!=-1){self.attending=qsTr("no")}
|
||||
if (friendica_activities_self.indexOf(5)!=-1){self.attending=qsTr("maybe")}
|
||||
if (friendica_activities_self.indexOf(1)!=-1){self.liked=1}
|
||||
if (friendica_activities_self.indexOf(2)!=-1){self.disliked=1}
|
||||
}
|
||||
var friendica_activities={likeText:likeText,dislikeText:dislikeText,attendyesText:attendyesText,attendnoText:attendnoText,attendmaybeText:attendmaybeText}
|
||||
var seconds=(msg.currentTime-newsitemobject.created_at)/1000;
|
||||
var timestring="";
|
||||
if (seconds<60) {timestring=seconds+" "+qsTr("seconds") +" "+qsTr("ago");}
|
||||
var friendica_activities={likeText:likeText,dislikeText:dislikeText,attendyesText:attendyesText,attendnoText:attendnoText,attendmaybeText:attendmaybeText,self:self}
|
||||
//print(JSON.stringify(friendica_activities) ) ;
|
||||
var seconds=(msg.currentTime-newsitemobject.created_at)/1000;
|
||||
var timestring="";
|
||||
if (seconds<60) {timestring=seconds+" "+qsTr("seconds") +" "+qsTr("ago");}
|
||||
else if (seconds<90){timestring=Math.round(seconds/60)+" "+qsTr("minute") +" "+qsTr("ago");}
|
||||
else if (seconds<3600){timestring=Math.round(seconds/60)+" "+qsTr("minutes") +" "+qsTr("ago");}
|
||||
else if (seconds<5400){timestring=Math.round(seconds/3600)+" "+qsTr("hour") +" "+qsTr("ago");}
|
||||
|
@ -40,7 +55,7 @@ WorkerScript.onMessage = function(msg) {
|
|||
else if (seconds<69984000){timestring=Math.round(seconds/3888000)+" "+qsTr("months") +" "+qsTr("ago");}
|
||||
else {timestring=Math.round(seconds/69984000)+" "+qsTr("years") +" "+qsTr("ago");}
|
||||
var data=({"newsitemobject": newsitemobject,"dateDiff":timestring,"friendica_activities":friendica_activities})}
|
||||
// print("News:"+j+msg.news.length+JSON.stringify(data));
|
||||
//print("News:"+j+msg.news.length+JSON.stringify(data));
|
||||
msg.model.append(data);}
|
||||
if (j==msg.news.length){
|
||||
msg.model.sync()
|
||||
|
|
|
@ -24,13 +24,13 @@ function requestList(login,database,rootwindow,callback) {
|
|||
|
||||
function dataRequest(login,photoID,database,rootwindow) {
|
||||
// check if image exist and call download function
|
||||
Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photoID, rootwindow, function (obj){
|
||||
try{ if(obj==""){currentImageNo=currentImageNo+1}else{
|
||||
var image = JSON.parse(obj);
|
||||
Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photoID, rootwindow, function (image){
|
||||
try{ if(image==""){currentImageNo=currentImageNo+1}else{
|
||||
var obj = JSON.parse(image);
|
||||
print('storeData() for ' + JSON.stringify(obj));
|
||||
try{sprite.destroy();}catch(e){}
|
||||
if (obj["link"]["0"]){var source=obj["link"]["0"]} else {var source=obj["link"]["4"]}//source for profile picture or original size
|
||||
print("Source"+obj["link"]["0"]+source)
|
||||
// try{sprite.destroy();}catch(e){}
|
||||
// if (obj["link"]["0"]){var source=obj["link"]["0"]} else {var source=obj["link"]["4"]}//source for profile picture or original size
|
||||
// print("Source"+source);
|
||||
obj["source"]=source;
|
||||
var filename=obj.filename;
|
||||
if (filename==""){// check if file as any filename
|
||||
|
@ -45,7 +45,7 @@ function dataRequest(login,photoID,database,rootwindow) {
|
|||
}
|
||||
print("obj.Filename: "+obj["filename"]+" filename: "+filename)
|
||||
}
|
||||
saveImage(obj,login.imagestore,function(obj,sprite){
|
||||
saveImage(obj,login.imagestore+'albums/'+obj.album,function(obj,sprite){
|
||||
//sprite.destroy(500);
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
|
@ -53,9 +53,9 @@ function dataRequest(login,photoID,database,rootwindow) {
|
|||
var result = tx.executeSql('SELECT * from imageData where id = "'+obj["id"]+'"');
|
||||
if(result.rows.length === 1) {// use update
|
||||
print(obj["id"] +' exists, update it')
|
||||
result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+obj.id+'", created="'+obj.created+'", edited="'+obj.edited+'", profile="'+obj.profile+'", link="'+obj.source+'", filename="'+obj.filename+'",title="'+obj.title+'", desc="'+obj.desc+'", type="'+obj.type+'", width="'+obj.width+'", height="'+obj.height+'", album="'+obj.album+'", location="file://'+login.imagestore+'" where id="'+obj["id"]+'"');
|
||||
result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+obj.id+'", created="'+obj.created+'", edited="'+obj.edited+'", profile="'+obj.profile+'", link="'+obj["link"]["4"]+'", filename="'+obj.filename+'",title="'+obj.title+'", desc="'+obj.desc+'", type="'+obj.type+'", width="'+obj.width+'", height="'+obj.height+'", album="'+obj.album+'", location="file://'+login.imagestore+'albums/'+obj.album+'/" where id="'+obj["id"]+'"');
|
||||
} else {// use insert print('... does not exists, create it')
|
||||
result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,obj.id,obj.created,obj.edited, obj.title, obj.desc, obj.album, obj.filename, obj.type, obj.height, obj.width,obj. profile,obj.source,'file://'+login.imagestore]);
|
||||
result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,obj.id,obj.created,obj.edited, obj.title, obj.desc, obj.album, obj.filename, obj.type, obj.height, obj.width,obj. profile,obj["link"]["4"],'file://'+login.imagestore+'albums/'+obj.album+"/"]);
|
||||
print("Inserted");}
|
||||
})})}}
|
||||
catch (e){print("Data retrieval failure! "+ e+obj);}
|
||||
|
@ -63,18 +63,17 @@ function dataRequest(login,photoID,database,rootwindow) {
|
|||
|
||||
function saveImage(obj,storagedirectory,callback) {
|
||||
// create image component from base64 code and save it
|
||||
print("Storing "+storagedirectory+obj.filename+obj.width+"x"+obj.height);
|
||||
print("Storing "+storagedirectory+"/"+obj.filename+obj.width+"x"+obj.height);
|
||||
var maxSize=Math.max(fotostab.width,fotostab.height);
|
||||
var helpwidth=(obj.width<maxSize)?obj.width:maxSize;
|
||||
var helpheight=(obj.height<maxSize)?obj.height:maxSize;
|
||||
|
||||
if (obj.width>obj.height){ //landscape
|
||||
helpheight=helpwidth*obj.height/obj.width
|
||||
} else { //portrait
|
||||
helpwidth=helpheight*obj.width/obj.height
|
||||
}
|
||||
var component=Qt.createComponent("qrc:/qml/PhotoPlaceholder.qml");
|
||||
var sprite = component.createObject(fotostab, {"x":0,"y":0,"imageName":storagedirectory+obj.filename ,"width":helpwidth,"height":helpheight,"source": obj.source,"downloadtype":"picture"});
|
||||
var sprite = component.createObject(fotostab, {"x":0,"y":0,"imageName":storagedirectory+"/"+obj.filename ,"width":helpwidth,"height":helpheight,"source": obj["link"]["4"],"downloadtype":"picture"});
|
||||
callback(obj,sprite)
|
||||
}
|
||||
|
||||
|
@ -141,8 +140,8 @@ function initDatabase(database) { // initialize the database object
|
|||
print('... create table')
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS imageData(username TEXT,id INT, created TEXT,edited TEXT, title TEXT, desc TEXT, album TEXT,filename TEXT, type TEXT, height INT, width INT, profile INT, link TEXT,location TEXT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS config(server TEXT, username TEXT, password TEXT, imagestore TEXT, maxnews INT, timerInterval INT, newsViewType TEXT,isActive INT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS news(username TEXT, messagetype INT, text TEXT, created_at INT, in_reply_to_status_id INT, source TEXT, status_id INT, in_reply_to_user_id INT, geo TEXT,favorited TEXT, uid INT, statusnet_html TEXT, statusnet_conversation_id TEXT,like TEXT, dislike TEXT, attendyes TEXT,attendno TEXT, attendmaybe TEXT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS contacts(username TEXT, id INT, name TEXT, screen_name TEXT, location TEXT,description TEXT, profile_image BLOB, url TEXT, protected TEXT, followers_count INT, friends_count INT, created_at TEXT, favourites_count TEXT, utc_offset TEXT, time_zone TEXT, statuses_count INT, following TEXT, verified TEXT, statusnet_blocking TEXT, notifications TEXT, statusnet_profile_url TEXT, cid INT, network TEXT, isFriend INT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS news(username TEXT, messagetype INT, text TEXT, created_at INT, in_reply_to_status_id INT, source TEXT, status_id INT, in_reply_to_user_id INT, geo TEXT,favorited TEXT, uid INT, statusnet_html TEXT, statusnet_conversation_id TEXT,friendica_activities TEXT, friendica_activities_self TEXT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS contacts(username TEXT, id INT, name TEXT, screen_name TEXT, location TEXT,profile_image_url TEXT, description TEXT, profile_image BLOB, url TEXT, protected TEXT, followers_count INT, friends_count INT, created_at INT, favourites_count TEXT, utc_offset TEXT, time_zone TEXT, statuses_count INT, following TEXT, verified TEXT, statusnet_blocking TEXT, notifications TEXT, statusnet_profile_url TEXT, cid INT, network TEXT, isFriend INT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS groups(username TEXT, groupname TEXT, gid INT, members TEXT)');
|
||||
})}
|
||||
|
||||
|
|
0
v0.002/Develop/source-android/qml/BlueButton.qml
Normal file
0
v0.002/Develop/source-android/qml/BlueButton.qml
Normal file
|
@ -187,7 +187,8 @@ onCurrentIndexChanged:{
|
|||
if (errormessage=="") {
|
||||
filesystem.Directory=userconfig.imagestore;
|
||||
filesystem.makeDir("contacts");
|
||||
Service.storeConfig(db,userconfig);
|
||||
filesystem.makeDir("albums");
|
||||
Service.storeConfig(db,userconfig);
|
||||
Service.readConfig(db,function(userconfig){Service.getServerConfig(userconfig,configBackground, function(obj){
|
||||
var serverString=obj;
|
||||
var serverconfigObject=Qt.createQmlObject(serverString,configBackground,"serverconfigOutput");
|
||||
|
@ -236,13 +237,14 @@ onCurrentIndexChanged:{
|
|||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
try{Helperjs.readData(db,"config",root.login.username,function(users){
|
||||
try{print("get users");
|
||||
Helperjs.readData(db,"config","",function(users){
|
||||
users.sort(function(obj1, obj2) {
|
||||
return obj1.isActive - obj2.isActive;
|
||||
});
|
||||
for (var i=0; i<users.length;i++){
|
||||
if (users[i]) {usermodel.append({text:users[i].username});};
|
||||
};})}
|
||||
}})}
|
||||
catch (e){print(e)}
|
||||
}
|
||||
}
|
||||
|
|
137
v0.002/Develop/source-android/qml/ContactComponent.qml
Normal file
137
v0.002/Develop/source-android/qml/ContactComponent.qml
Normal file
|
@ -0,0 +1,137 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.3
|
||||
|
||||
Item {
|
||||
id: contactComponent
|
||||
property var createdAtDate: new Date(contact.created_at)
|
||||
property var linkUrl: contact.network!=="dfrn"?contact.url:contact.url.replace("profile","dfrn_request")
|
||||
Rectangle {
|
||||
id: wrapper
|
||||
width: 16*mm
|
||||
height: 15*mm
|
||||
border.color: "grey"
|
||||
color:"white"
|
||||
Image {
|
||||
id: photoImage
|
||||
x:1
|
||||
y:1
|
||||
width: 10*mm
|
||||
height:10*mm
|
||||
source:(contact.isFriend==1)? "file://"+contact.profile_image :contact.profile_image_url
|
||||
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
|
||||
}
|
||||
|
||||
Label {
|
||||
id: namelabel
|
||||
x: 1
|
||||
width: wrapper.width-4
|
||||
height: 3*mm
|
||||
text: contact.screen_name
|
||||
elide:Text.ElideRight
|
||||
anchors.topMargin: 0
|
||||
anchors.left: photoImage.left
|
||||
color: "#303030"
|
||||
font.pixelSize: 3*mm
|
||||
anchors.top: photoImage.bottom
|
||||
}
|
||||
Button{
|
||||
id:infobutton
|
||||
width: 5*mm
|
||||
height: 5*mm
|
||||
text:"?"
|
||||
anchors.left: photoImage.right
|
||||
anchors.leftMargin: 3
|
||||
anchors.topMargin: 3
|
||||
anchors.top: parent.top
|
||||
onClicked:{
|
||||
//print("State: "+ friendComponent.state);
|
||||
contactComponent.state="large"}
|
||||
}
|
||||
Rectangle{
|
||||
id: detailsrectangle
|
||||
anchors.top: namelabel.bottom
|
||||
anchors.topMargin: 2*mm
|
||||
opacity: 0
|
||||
|
||||
Flickable{
|
||||
id:namelabelflickable
|
||||
width: root.width-10*mm
|
||||
height:friendsTabView.height-55*mm
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
flickableDirection:Flickable.VerticalFlick
|
||||
contentWidth:width
|
||||
contentHeight: namelabeltext.height
|
||||
clip:true
|
||||
Text{
|
||||
id:namelabeltext
|
||||
//anchors.top: parent.top
|
||||
width: namelabelflickable.width
|
||||
height: implicitHeight
|
||||
font.pixelSize: 3*mm
|
||||
textFormat:Text.RichText
|
||||
wrapMode: Text.Wrap
|
||||
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(contact.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+contact.location+"<br> <b>"+qsTr("Posts")+":</b> "+contact.statuses_count+
|
||||
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ linkUrl+"'>"+linkUrl+"</a><br> <b>"+
|
||||
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
|
||||
onLinkActivated: {
|
||||
Qt.openUrlExternally(link)}
|
||||
}
|
||||
}
|
||||
|
||||
Row{
|
||||
anchors.top: namelabelflickable.bottom
|
||||
anchors.topMargin: 2*mm
|
||||
spacing:4
|
||||
|
||||
Button{
|
||||
id:photobutton
|
||||
text:"Photos"
|
||||
visible:contact.location=="Friendica"? 1:0
|
||||
onClicked:{contactComponent.state="";
|
||||
root.currentIndex=2;
|
||||
fotostab.active=true;
|
||||
root.fotoSignal(contact) ;
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
id:messagebutton
|
||||
text:"Messages"
|
||||
onClicked:{contactComponent.state="";
|
||||
root.currentIndex=0;
|
||||
newstab.active=true;
|
||||
root.messageSignal(contact.id) ;
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
id:dmbutton
|
||||
visible: contact.following=="true"?true:false
|
||||
text: "DM"
|
||||
onClicked:{contactComponent.state="";
|
||||
root.currentIndex=0;
|
||||
newstab.active=true;
|
||||
root.directmessageSignal(contact.screen_name);
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
id: closeButton
|
||||
text: "close"
|
||||
onClicked:{contactComponent.state=""}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
states: [
|
||||
State {
|
||||
name: "large"
|
||||
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(contact.name)+" (@"+contact.screen_name+")"}
|
||||
PropertyChanges { target: contactComponent; z: 2 }
|
||||
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-20*mm}
|
||||
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
|
||||
PropertyChanges { target:contactComponent.GridView.view;contentY:contactComponent.y;contentX:contactComponent.x;interactive:false}
|
||||
PropertyChanges { target: detailsrectangle; opacity:1 }
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import "qrc:/js/service.js" as Service
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
|
@ -17,17 +18,35 @@ Rectangle {
|
|||
tabPosition: Qt.TopEdge
|
||||
x:mm
|
||||
y:mm
|
||||
width: root.width-5*mm
|
||||
width: root.width-2*mm
|
||||
height: root.height-10*mm
|
||||
currentIndex: 0
|
||||
signal friendsSignal(var username)
|
||||
|
||||
signal contactsSignal(var username)
|
||||
signal groupsSignal(var username)
|
||||
onCurrentIndexChanged:{
|
||||
if (currentIndex==0){friendsSignal(root.login.username)}
|
||||
if (currentIndex==0){root.friendsSignal(root.login.username)}
|
||||
else if (currentIndex==1){contactsSignal(root.login.username)}
|
||||
else if (currentIndex==2){groupsSignal(root.login.username)}
|
||||
}
|
||||
style: TabViewStyle {
|
||||
frameOverlap: 1
|
||||
tab: Rectangle {
|
||||
color: "white"
|
||||
//border.color: "light grey"
|
||||
implicitWidth: root.width/3-2*mm
|
||||
implicitHeight: 4*mm
|
||||
Text { id: text
|
||||
anchors.centerIn: parent
|
||||
text: styleData.title
|
||||
color: "dark grey"
|
||||
font.pixelSize:2.5*mm
|
||||
font.bold: styleData.selected
|
||||
}
|
||||
}
|
||||
frame: Rectangle { color: "light grey" }
|
||||
tabsAlignment:Qt.AlignHCenter
|
||||
}
|
||||
|
||||
Tab{
|
||||
title: qsTr("Friends")
|
||||
|
@ -35,15 +54,16 @@ Rectangle {
|
|||
id: friendsGridTab
|
||||
function showFriends(username){
|
||||
try {friendsModel.clear()} catch(e){print(e)};
|
||||
Helperjs.readData(db,"contacts",username,function(friends){
|
||||
for (var i=0;i<friends.length;i++){
|
||||
friendsModel.append({"friend":friends[i]});
|
||||
Helperjs.readData(db,"contacts",username,function(friendsobject){
|
||||
for (var i=0;i<friendsobject.length;i++){
|
||||
friendsModel.append({"contact":friendsobject[i]});
|
||||
}},"isFriend",1)
|
||||
}
|
||||
Button {
|
||||
id: updateFriendsButton
|
||||
text: qsTr("Update")
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: mm
|
||||
anchors.right: parent.right
|
||||
onClicked: {
|
||||
try {friendsModel.clear()} catch(e){print(e)};
|
||||
|
@ -67,7 +87,7 @@ Rectangle {
|
|||
GridView {
|
||||
id: friendsView
|
||||
x:mm
|
||||
y:updateFriendsButton.height+mm
|
||||
y:updateFriendsButton.height+2*mm
|
||||
width:friendsGridTab.width-2*mm
|
||||
height:friendsGridTab.height-updateFriendsButton.height-2*mm
|
||||
clip: true
|
||||
|
@ -77,7 +97,7 @@ Rectangle {
|
|||
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
|
||||
}
|
||||
model: friendsModel
|
||||
delegate: FriendComponent { }
|
||||
delegate: ContactComponent { }
|
||||
}
|
||||
|
||||
ListModel{id:friendsModel}
|
||||
|
@ -85,7 +105,7 @@ Rectangle {
|
|||
|
||||
|
||||
Component.onCompleted: {
|
||||
friendsTabView.friendsSignal.connect(showFriends);
|
||||
root.friendsSignal.connect(showFriends);
|
||||
showFriends(root.login.username)
|
||||
}
|
||||
}
|
||||
|
@ -98,16 +118,16 @@ Rectangle {
|
|||
id: contactsGridTab
|
||||
function showContacts(username){
|
||||
try {contactsModel.clear()} catch(e){print(e)};
|
||||
Helperjs.readData(db, "contacts",root.login.username,function(friendsobject){
|
||||
for (var j=0;j<friendsobject.length;j++){
|
||||
contactsModel.append({"friend":friendsobject[j]});
|
||||
Helperjs.readData(db, "contacts",root.login.username,function(contactsobject){
|
||||
for (var j=0;j<contactsobject.length;j++){
|
||||
contactsModel.append({"contact":contactsobject[j]});
|
||||
}
|
||||
},"isFriend",0)}
|
||||
|
||||
GridView {
|
||||
id: contactsView
|
||||
x:mm
|
||||
y:mm
|
||||
y:2*mm
|
||||
width:contactsGridTab.width-2*mm
|
||||
height:contactsGridTab.height-2*mm
|
||||
clip: true
|
||||
|
@ -117,7 +137,7 @@ Rectangle {
|
|||
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
|
||||
}
|
||||
model: contactsModel
|
||||
delegate: FriendComponent { }
|
||||
delegate: ContactComponent { }
|
||||
}
|
||||
|
||||
ListModel{id: contactsModel}
|
||||
|
@ -132,7 +152,6 @@ Rectangle {
|
|||
id: groupsGridTab
|
||||
function showGroups(username){
|
||||
try {groupsModel.clear()} catch(e){print(e)};
|
||||
print("showGroups"+username);
|
||||
Helperjs.readData(db, "groups",root.login.username,function(groupsobject){
|
||||
for (var j=0;j<groupsobject.length;j++){
|
||||
groupsModel.append({"group":groupsobject[j]});
|
||||
|
@ -141,6 +160,7 @@ Rectangle {
|
|||
id: updateGroupsButton
|
||||
text: qsTr("Update")
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: mm
|
||||
anchors.right: parent.right
|
||||
onClicked: {
|
||||
print("Update groups");
|
||||
|
@ -150,7 +170,7 @@ Rectangle {
|
|||
GridView {
|
||||
id: groupsView
|
||||
x:mm
|
||||
y:updateGroupsButton.height+mm
|
||||
y:updateGroupsButton.height+2*mm
|
||||
width:groupsGridTab.width-2*mm
|
||||
height:groupsGridTab.height-updateGroupsButton.height-2*mm
|
||||
clip: true
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.3
|
||||
import "qrc:/js/service.js" as Service
|
||||
import "qrc:/js/layout.js" as Layoutjs
|
||||
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
Item {
|
||||
id: groupComponent
|
||||
|
||||
Rectangle {
|
||||
id: wrapper
|
||||
width: 16*mm
|
||||
|
@ -13,6 +10,14 @@ import "qrc:/js/layout.js" as Layoutjs
|
|||
border.color: "grey"
|
||||
color:"white"
|
||||
|
||||
Image {
|
||||
id: photoImage
|
||||
x:1
|
||||
y:1
|
||||
width: 10*mm
|
||||
height:10*mm
|
||||
source:"qrc:/images/defaultcontact.jpg"
|
||||
}
|
||||
Label {
|
||||
id: namelabel
|
||||
x: 1
|
||||
|
@ -22,127 +27,92 @@ import "qrc:/js/layout.js" as Layoutjs
|
|||
|
||||
color: "#303030"
|
||||
font.pixelSize: 3*mm
|
||||
anchors.centerIn:parent
|
||||
anchors.top: photoImage.bottom
|
||||
}
|
||||
Button{
|
||||
id:infobutton
|
||||
width: 5*mm
|
||||
height: 5*mm
|
||||
text:"?"
|
||||
anchors.top: namelabel.bottom;anchors.topMargin: 3
|
||||
anchors.left: photoImage.right
|
||||
anchors.leftMargin: 3
|
||||
anchors.topMargin: 3
|
||||
anchors.top: parent.top
|
||||
onClicked:{
|
||||
print("State: "+ groupComponent.state+groupView.contentY);
|
||||
Helperjs.readField("members",root.db,"groups",root.login.username,function(groups){
|
||||
try {groupModel.clear()}catch (e){print(e)}
|
||||
var groupmembers=JSON.parse(groups);
|
||||
for (var user in groupmembers){
|
||||
Helperjs.readData(root.db,"contacts",root.login.username,function(userdata){
|
||||
groupModel.append({"groupmember":userdata[0]});
|
||||
},"id",groupmembers[user])}
|
||||
},"groupname",group.groupname);
|
||||
groupComponent.state="large"}
|
||||
}
|
||||
|
||||
|
||||
Rectangle{
|
||||
id: detailsrectangle
|
||||
anchors.top: infobutton.bottom
|
||||
anchors.top: namelabel.bottom
|
||||
anchors.topMargin: 2*mm
|
||||
opacity: 0
|
||||
|
||||
Component { id:footerComponent
|
||||
Rectangle{
|
||||
border.color: "#EEEEEE"
|
||||
border.width: 1
|
||||
width:parent.width
|
||||
height:6*mm
|
||||
Text{
|
||||
font.pixelSize: 3*mm
|
||||
anchors.centerIn: parent
|
||||
text:qsTr("+")
|
||||
}
|
||||
MouseArea{anchors.fill:parent
|
||||
onClicked:{var contactitems="";
|
||||
readData(db,"contacts",root.login.username, function(contacts){for (var i=0;i<contacts.length;i++){
|
||||
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"'; onTriggered: groupModel.append(' @"+contacts[i]+"')}"
|
||||
}},"isFriend",0)
|
||||
var menuString="import QtQuick.Controls 1.4; Menu {"+contactitems+"}";
|
||||
print("menustring: "+menuString);
|
||||
var contactlistObject=Qt.createQmlObject(menuString,messageSend,"contactmenuOutput");
|
||||
contactlistObject.popup();
|
||||
Newsjs.addToGroup
|
||||
}}}}
|
||||
|
||||
Component { id:groupMember
|
||||
Component { id:groupMember
|
||||
Rectangle{
|
||||
border.color: "#EEEEEE"
|
||||
border.width: 1
|
||||
width:parent.width
|
||||
height:6*mm
|
||||
Image {
|
||||
id: memberImage
|
||||
x:1
|
||||
y:1
|
||||
width: 5*mm
|
||||
height:5*mm
|
||||
source:(groupmember.isFriend==1)? "file://"+groupmember.profile_image :groupmember.profile_image_url
|
||||
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
|
||||
}
|
||||
Text{
|
||||
font.pixelSize: 3*mm
|
||||
anchors.left: parent.left
|
||||
text:groupmember.screen_name
|
||||
anchors.left: memberImage.right
|
||||
anchors.margins: 1*mm
|
||||
text:Qt.atob(groupmember.name)
|
||||
}
|
||||
}}
|
||||
|
||||
ListView{
|
||||
id:namelabeltext
|
||||
anchors.top: parent.top
|
||||
ListView{
|
||||
id: groupListView
|
||||
x:1
|
||||
//anchors.top: parent.top
|
||||
width: root.width-10*mm
|
||||
height:wrapper.height-20*mm
|
||||
height:groupsView.height -28*mm
|
||||
clip: true
|
||||
spacing: 0
|
||||
footer: footerComponent
|
||||
spacing: 2
|
||||
model: groupModel
|
||||
delegate: groupMember
|
||||
}
|
||||
|
||||
ListModel{id: groupModel}
|
||||
|
||||
}
|
||||
|
||||
Row{
|
||||
anchors.top: namelabeltext.bottom
|
||||
anchors.topMargin: 2*mm
|
||||
spacing:4
|
||||
|
||||
Button{
|
||||
id:photobutton
|
||||
text:"Photos"
|
||||
visible:friend.location=="Friendica"? 1:0
|
||||
onClicked:{root.currentIndex=2;
|
||||
fotostab.active=true;
|
||||
root.fotoSignal(friend) ;
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
id:messagebutton
|
||||
text:"Messages"
|
||||
onClicked:{root.currentIndex=0;
|
||||
newstab.active=true;
|
||||
root.messageSignal(friend.id) ;
|
||||
}
|
||||
}
|
||||
|
||||
Button{id:dmbutton
|
||||
visible: friend.following=="true"?true:false
|
||||
text: "DM"
|
||||
onClicked:{root.currentIndex=0;
|
||||
newstab.active=true;
|
||||
root.directmessageSignal(friend.screen_name);
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
id: closeButton
|
||||
text: "close"
|
||||
onClicked:{friendComponent.state=""}
|
||||
}
|
||||
}
|
||||
Button{
|
||||
id: closeButton
|
||||
anchors.top: groupListView.bottom
|
||||
x:1
|
||||
text: "close"
|
||||
onClicked:{groupComponent.state=""}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "large"
|
||||
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsView.width; text:Qt.atob(friend.name)+" (@"+friend.screen_name+")"}
|
||||
PropertyChanges { target: friendComponent; z: 2 }
|
||||
PropertyChanges { target: wrapper; width:friendsView.width;height:friendsView.height -2*mm-1}
|
||||
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
|
||||
PropertyChanges { target:friendComponent.GridView.view ;contentY:friendComponent.y;contentX:friendComponent.x;interactive:false}
|
||||
PropertyChanges { target: detailsrectangle; opacity:1 }
|
||||
}
|
||||
name: "large"
|
||||
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:groupsView.width}
|
||||
PropertyChanges { target: groupComponent; z: 2 }
|
||||
PropertyChanges { target: wrapper; width:groupsView.width;height:groupsView.height -2*mm-1}
|
||||
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
|
||||
PropertyChanges { target:groupComponent.GridView.view ;contentY:groupComponent.y;contentX:groupComponent.x;interactive:false}
|
||||
PropertyChanges { target: detailsrectangle; opacity:1 }
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ Rectangle{
|
|||
Text{id:infoBoxText
|
||||
textFormat: Text.RichText
|
||||
wrapMode: Text.Wrap
|
||||
text: "<b>Friendiqa v0.001 </b><br>Licensed under GPL 3<br> "+
|
||||
text: "<b>Friendiqa v0.002 </b><br>Licensed under GPL 3<br> "+
|
||||
"Sourcecode: <a href='https://github.com/LubuWest/Friendiqa'>https://github.com/LubuWest/Friendica</a><br>"+
|
||||
"C++ code by <a href='https://kirgroup.com/profile/fabrixxm'>Fabio</a><br>"+
|
||||
"QML and Javascript code by <a href='https://freunde.ma-nic.de/profile/marco'>Marco</a>"
|
||||
|
|
|
@ -5,18 +5,22 @@ import QtQml 2.2
|
|||
import QtQuick.Controls 1.3
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.LocalStorage 2.0
|
||||
//import "../qml"
|
||||
import "qrc:/js/service.js" as Service
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
import "qrc:/js/service.js" as Servicejs
|
||||
|
||||
Item{
|
||||
id:messageSend
|
||||
property var login
|
||||
property string parentId: ""
|
||||
property string reply_to_user:""
|
||||
property string attachImageURL: "";
|
||||
property int directmessage: 0;
|
||||
property var contacts: []
|
||||
// title: parentId !== "" ? qsTr("Reply to "+reply_to_user) : qsTr("New post")
|
||||
property var login
|
||||
property string parentId: ""
|
||||
property string reply_to_user:""
|
||||
property string attachImageURL: "";
|
||||
property int directmessage: 0;
|
||||
property var contacts: []
|
||||
property var groups: []
|
||||
property string contact_allow:""
|
||||
property string contact_deny:""
|
||||
property string group_allow:""
|
||||
property string group_deny:""
|
||||
|
||||
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
|
||||
xhr.url= login.server + "/api/statuses/update.xml";
|
||||
|
@ -46,7 +50,7 @@ Item{
|
|||
Column {
|
||||
id:messageColumn
|
||||
spacing: 2
|
||||
|
||||
width: parent.width
|
||||
TextField {
|
||||
id: titleField
|
||||
width: parent.width
|
||||
|
@ -59,8 +63,13 @@ Item{
|
|||
width: parent.width
|
||||
height: 30*mm
|
||||
wrapMode: TextEdit.Wrap
|
||||
textFormat: TextEdit.RichText
|
||||
}
|
||||
CheckBox{
|
||||
|
||||
Row{
|
||||
|
||||
spacing: 2
|
||||
CheckBox{
|
||||
id:dmCheckbox
|
||||
text:"DM"
|
||||
enabled: false
|
||||
|
@ -70,18 +79,59 @@ CheckBox{
|
|||
else if(dmCheckbox.checkedState==Qt.Unchecked){directmessage=0}
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
text:qsTr("Url")
|
||||
onClicked: {
|
||||
if(bodyField.selectedText==""){Helperjs.showMessage("Error","No text selected",messageSend)}
|
||||
else{urlTextEdit.text="";
|
||||
urlRectangle.visible=true}}
|
||||
}
|
||||
Rectangle{
|
||||
id:urlRectangle
|
||||
height:parent.height
|
||||
width:37*mm
|
||||
visible:false
|
||||
TextField{
|
||||
id:urlTextEdit
|
||||
width:30*mm
|
||||
height:parent.height
|
||||
}
|
||||
Button{
|
||||
anchors.left:urlTextEdit.right
|
||||
anchors.leftMargin:mm
|
||||
text:qsTr("\u2713")
|
||||
onClicked: {
|
||||
var start = bodyField.selectionStart;
|
||||
var end = bodyField.selectionEnd;
|
||||
var text = bodyField.getText(start,end);
|
||||
text = "<a href='"+urlTextEdit.text+"'>" + text + "</a>";
|
||||
bodyField.remove(start,end);
|
||||
bodyField.insert(start,text);
|
||||
urlRectangle.visible=false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Row{
|
||||
spacing:2
|
||||
Button {
|
||||
id: cancelButton
|
||||
text: qsTr("Cancel")
|
||||
onClicked: {newsStack.pop()}
|
||||
}
|
||||
|
||||
Button{
|
||||
text:qsTr("Permissions")
|
||||
onClicked: {
|
||||
var component = Qt.createComponent("qrc:/qml/PermissionDialog.qml");
|
||||
var sprite = component.createObject(messageColumn);
|
||||
if (sprite == null) { // Error Handling
|
||||
console.log("Error creating object"); }
|
||||
}}
|
||||
Button {
|
||||
id: attachButton
|
||||
text: qsTr("Attach")
|
||||
onClicked: {imageAttachmentDialog.open()}
|
||||
onClicked: {
|
||||
try{imageAttachment.visible=false;
|
||||
imageAttachment.opacity=0;imageAttachment.destroy()}catch(e){}
|
||||
imageAttachmentDialog.open()}
|
||||
}
|
||||
Button{
|
||||
id:contactButton
|
||||
|
@ -90,43 +140,49 @@ CheckBox{
|
|||
onClicked:{
|
||||
var contactitems="";
|
||||
for (var i=0;i<contacts.length;i++){
|
||||
contactitems=contactitems+"MenuItem{text:'"+contacts[i]+"'; onTriggered: bodyField.append(' @"+contacts[i]+"')}"
|
||||
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"'; onTriggered: bodyField.append(' @"+contacts[i].screen_name+"')}"
|
||||
}
|
||||
var menuString="import QtQuick.Controls 1.4; Menu {"+contactitems+"}";
|
||||
// print(menuString);
|
||||
var contactlistObject=Qt.createQmlObject(menuString,messageSend,"contactmenuOutput")
|
||||
contactlistObject.popup() }
|
||||
}
|
||||
|
||||
Button {
|
||||
id: sendButton
|
||||
text: qsTr("Send")
|
||||
onClicked: {
|
||||
print("login: "+login.server+login.username);
|
||||
if (directmessage==0){
|
||||
statusUpdate(titleField.text,bodyField.text,messageSend.parentId,attachImageURL.toString());}
|
||||
else {dmUpdate( titleField.text,bodyField.text,"",messageSend.reply_to_user) }
|
||||
newsStack.pop()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Row{
|
||||
spacing:2
|
||||
Button {
|
||||
id: cancelButton
|
||||
text: qsTr("Cancel")
|
||||
onClicked: {newsStack.pop()}
|
||||
}
|
||||
Button {
|
||||
id: sendButton
|
||||
text: qsTr("Send")
|
||||
onClicked: {
|
||||
//print("login: "+login.server+login.username);
|
||||
var title=titleField.text.replace("\"","\'");
|
||||
var body=bodyField.getText(0,bodyField.length);
|
||||
if (directmessage==0){
|
||||
statusUpdate(title,body,messageSend.parentId,attachImageURL.toString())}
|
||||
else {dmUpdate( title,body,"",messageSend.reply_to_user) }
|
||||
newsStack.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: imageAttachmentDialog
|
||||
title: "Please choose a picture"
|
||||
folder: shortcuts.pictures
|
||||
selectFolder: false
|
||||
onAccepted: {
|
||||
attachImageURL=imageAttachmentDialog.fileUrl;
|
||||
var imageAttachementObject=Qt.createQmlObject('import QtQuick 2.0; Image {source:"'+attachImageURL.toString()+'"; width: 30*mm; height: 30*mm;fillMode: Image.PreserveAspectFit}',messageColumn,"attachedImage");
|
||||
console.log("You chose: " + attachImageURL)
|
||||
id: imageAttachmentDialog
|
||||
title: "Please choose a picture"
|
||||
folder: shortcuts.pictures
|
||||
selectFolder: false
|
||||
onAccepted: {
|
||||
attachImageURL=imageAttachmentDialog.fileUrl;
|
||||
var imageAttachmentObject=Qt.createQmlObject('import QtQuick 2.0; Image {id:imageAttachment;source:"'+attachImageURL.toString()+'"; width: 15*mm; height: 15*mm;fillMode: Image.PreserveAspectFit}',messageColumn,"attachedImage");
|
||||
//console.log("You chose: " + attachImageURL)
|
||||
|
||||
}
|
||||
onRejected: {
|
||||
console.log("Canceled")
|
||||
//console.log("Canceled")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ Item {
|
|||
}
|
||||
|
||||
function onDirectMessage(friend){
|
||||
print(root.login.server);
|
||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
|
||||
}
|
||||
|
||||
|
@ -51,13 +52,43 @@ Item {
|
|||
width:root.width-2*mm
|
||||
height:root.height-8*mm
|
||||
|
||||
ComboBox{
|
||||
y:mm
|
||||
width: 8*mm
|
||||
model: ListModel{
|
||||
id: cbModel
|
||||
ListElement{text: qsTr("News")}
|
||||
ListElement{text: qsTr("Favorites")}
|
||||
}
|
||||
onCurrentIndexChanged:{
|
||||
if (currentIndex==0){newsModel.clear();
|
||||
Newsjs.newsfromdb(root.db,root.login.username, function(dbnews){
|
||||
showNews(dbnews)
|
||||
})}
|
||||
else if (currentIndex==1){
|
||||
newsBusy.running=true;
|
||||
Newsjs.requestFavorites(root.login,db,root,function(news){
|
||||
JSON.stringify("Favorites: "+news);
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
Newsjs.favoritesfromdb(db,root.login.username,function(newsarray){
|
||||
JSON.stringify("FavoritesArray: "+newsarray);showNews(newsarray)
|
||||
|
||||
});
|
||||
}
|
||||
)})
|
||||
}
|
||||
}}
|
||||
|
||||
Button {
|
||||
id: newMessageButton
|
||||
text: qsTr("+")
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
onClicked: {
|
||||
Helperjs.readField("screen_name",root.db,"contacts",root.login.username,function(friends){
|
||||
var groups=[];
|
||||
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
|
||||
groups=groupobject});
|
||||
Helperjs.readData(root.db,"contacts",root.login.username,function(friends){
|
||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"contacts": friends,"login":root.login}})
|
||||
},"isFriend",1);
|
||||
}
|
||||
|
@ -150,6 +181,6 @@ Item {
|
|||
showNews(dbnews)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,13 @@ import QtQuick.LocalStorage 2.0
|
|||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
import "qrc:/js/layout.js" as Layoutjs
|
||||
|
||||
|
||||
Item {
|
||||
id: newsitem
|
||||
width: newsView.width
|
||||
height:Math.max((itemMessage.height+createdAtLabel.height+friendicaActivities.height+4*mm),profileImage.height+user_name.height+mm)
|
||||
height:Math.max((itemMessage.height+topFlow.height+friendicaActivities.height+4*mm),profileImage.height+user_name.height+mm)
|
||||
|
||||
// property var friendica_activities
|
||||
property string conversation_id: ""
|
||||
property string attending: ""
|
||||
onAttendingChanged: {attendLabel.visible=true;
|
||||
|
@ -23,7 +21,7 @@ Item {
|
|||
Rectangle{
|
||||
width:newsitem.width
|
||||
height:newsitem.height-1
|
||||
color: (newsitemobject.directmessage)?"#ffe6e6" : "white"
|
||||
color: (newsitemobject.messagetype==1)?"#ffe6e6" : "white"
|
||||
|
||||
Column {
|
||||
id: authorcolumn
|
||||
|
@ -31,7 +29,7 @@ Item {
|
|||
|
||||
Image {
|
||||
id:profileImage
|
||||
source: "file://"+newsitemobject.user.profile_image
|
||||
source:(newsitemobject.user.isFriend==1)? "file://"+newsitemobject.user.profile_image : newsitemobject.user.profile_image_url
|
||||
x:1
|
||||
width: 7*mm
|
||||
height: 7*mm
|
||||
|
@ -53,10 +51,13 @@ Item {
|
|||
}
|
||||
Column {
|
||||
id:newscolumn
|
||||
width: newsitem.width-8*mm
|
||||
anchors.left: authorcolumn.right
|
||||
|
||||
Row{
|
||||
spacing: 5*mm
|
||||
Flow{
|
||||
id:topFlow
|
||||
spacing: 2*mm
|
||||
width:parent.width
|
||||
Label {
|
||||
color: "grey"
|
||||
text: if (newsitemobject.messagetype==0){qsTr("Source: ")+newsitemobject.source
|
||||
|
@ -66,9 +67,9 @@ Item {
|
|||
Label {
|
||||
id:createdAtLabel
|
||||
color: "grey"
|
||||
height:3.5*mm
|
||||
font.pixelSize: 1.5*mm
|
||||
horizontalAlignment: Label.AlignRight
|
||||
height:3.5*mm
|
||||
font.pixelSize: 1.5*mm
|
||||
horizontalAlignment: Label.AlignRight
|
||||
text: dateDiff
|
||||
}
|
||||
CheckBox {
|
||||
|
@ -104,8 +105,53 @@ Item {
|
|||
{Newsjs.favorite(login,false,newsitemobject.status_id,root)}
|
||||
}
|
||||
}
|
||||
Rectangle{
|
||||
width: 4*mm
|
||||
height: 3*mm
|
||||
Text{
|
||||
id:newsmenusymbol
|
||||
color: "grey"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: 2*mm
|
||||
font.bold: true
|
||||
text: "\u22EE"
|
||||
}
|
||||
MouseArea{
|
||||
anchors.fill:parent
|
||||
onClicked: {newsmenu.popup()}}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
width: 4*mm
|
||||
height: 3*mm
|
||||
Text{
|
||||
id:conversationsymbol
|
||||
color: "grey"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: 2*mm
|
||||
text: "\u21C4"
|
||||
}
|
||||
MouseArea{
|
||||
anchors.fill:parent
|
||||
onClicked: {
|
||||
newsBusy.running=true;
|
||||
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
|
||||
for (var i=0;i<newContacts.length;i++){
|
||||
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
||||
}
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
var currentTime= new Date();
|
||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||
newsModel.clear();
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
||||
newsWorker.sendMessage(msg);
|
||||
newsBusy.running=false
|
||||
});
|
||||
}
|
||||
)})
|
||||
}}
|
||||
}}
|
||||
|
||||
Text {
|
||||
color: "#404040"
|
||||
|
@ -116,10 +162,10 @@ Item {
|
|||
width: newsitem.width-8*mm-2
|
||||
height: implicitHeight
|
||||
wrapMode: Text.Wrap
|
||||
onLinkActivated:{ print("link "+link);
|
||||
Qt.openUrlExternally(link)}
|
||||
onLinkActivated:{
|
||||
Qt.openUrlExternally(link)}
|
||||
}
|
||||
Row{id: friendicaActivities
|
||||
Row{id:friendicaActivities
|
||||
spacing:mm
|
||||
Label{color: "grey"
|
||||
font.pixelSize: 1.5*mm
|
||||
|
@ -141,13 +187,13 @@ Item {
|
|||
font.pixelSize: 1.5*mm
|
||||
text: friendica_activities.attendmaybeText
|
||||
}
|
||||
}
|
||||
Row {
|
||||
}
|
||||
Row {
|
||||
CheckBox{id:likeCheckbox
|
||||
height:3*mm
|
||||
width:8*mm
|
||||
checked:(newsitemobject.liked==1)?true:false
|
||||
style: CheckBoxStyle {
|
||||
checked:(friendica_activities.self.liked)?true:false
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
implicitWidth: 7*mm
|
||||
implicitHeight: 3*mm
|
||||
|
@ -170,11 +216,11 @@ Row {
|
|||
else{Newsjs.like(root.login,root.db,0,"like",newsitemobject.status_id,root)}}
|
||||
}
|
||||
CheckBox{id: dislikeCheckbox
|
||||
height:3*mm
|
||||
width:8*mm
|
||||
checked: (newsitemobject.disliked==1)?true:false
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
height:3*mm
|
||||
width:8*mm
|
||||
checked: (friendica_activities.self.disliked)?true:false
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
implicitWidth: 7*mm
|
||||
implicitHeight:3*mm
|
||||
color:"white"
|
||||
|
@ -211,7 +257,7 @@ Row {
|
|||
height:3.5*mm
|
||||
font.pixelSize: 1.5*mm
|
||||
horizontalAlignment: Label.AlignRight
|
||||
text: qsTr("attending: ")+ qsTr(attending)
|
||||
text: (friendica_activities.self.attending)?qsTr("attending: ")+ qsTr(attending):""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -221,10 +267,10 @@ Row {
|
|||
MenuItem {
|
||||
text: qsTr("Reply")
|
||||
onTriggered: {
|
||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_id}});
|
||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_id,"login":root.login}});
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
MenuItem {
|
||||
text: qsTr("DM")
|
||||
onTriggered: {
|
||||
root.directmessageSignal(newsitemobject.user.screen_name);
|
||||
|
@ -241,16 +287,20 @@ MenuItem {
|
|||
MenuItem {
|
||||
text: qsTr("Conversation")
|
||||
onTriggered: {
|
||||
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root,function(){
|
||||
var currentTime= new Date();
|
||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
|
||||
for (var i=0;i<newContacts.length;i++){
|
||||
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
||||
}
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
var currentTime= new Date();
|
||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||
newsModel.clear();
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
||||
newsWorker.sendMessage(msg);
|
||||
});
|
||||
}
|
||||
)}
|
||||
}
|
||||
)})
|
||||
}}
|
||||
|
||||
Menu{
|
||||
title: qsTr("Attending")
|
||||
|
@ -275,8 +325,8 @@ Menu{
|
|||
MenuItem {
|
||||
text: qsTr("Delete")
|
||||
onTriggered: {
|
||||
Newsjs.deleteNews(root.login,db,newsitemobject.status_id,root,function(reply){
|
||||
print(JSON.stringify(reply));
|
||||
Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,root,function(reply){
|
||||
print("Deleted "+reply);
|
||||
newsModel.remove(index);
|
||||
})
|
||||
}
|
||||
|
|
126
v0.002/Develop/source-android/qml/PermissionDialog.qml
Normal file
126
v0.002/Develop/source-android/qml/PermissionDialog.qml
Normal file
|
@ -0,0 +1,126 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQml.Models 2.1
|
||||
import "qrc:/js/service.js" as Service
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
|
||||
Rectangle{
|
||||
id:permissionDialog
|
||||
width: 80*mm
|
||||
height:root.height/3
|
||||
|
||||
Text{
|
||||
x:0.5*mm
|
||||
y:0.5*mm
|
||||
text: "Contacts"
|
||||
}
|
||||
ListView {
|
||||
id: contactView
|
||||
x:0.5*mm
|
||||
y:5.5*mm
|
||||
width: 39*mm
|
||||
height:permissionDialog.height-14*mm
|
||||
clip: true
|
||||
spacing: 0
|
||||
model: contactModel
|
||||
delegate: contactItem
|
||||
}
|
||||
|
||||
ListModel{id: contactModel}
|
||||
Component{
|
||||
id:contactItem
|
||||
|
||||
Rectangle{
|
||||
id:contactitemRect
|
||||
width:contactView.width
|
||||
height: 5*mm
|
||||
property string contactstatus:""
|
||||
color: "light blue"
|
||||
border.color:"grey"
|
||||
Text{
|
||||
color:"grey"
|
||||
text:contact.screen_name
|
||||
}
|
||||
onContactstatusChanged:
|
||||
{ if(contactstatus=="positive"){contactsitemRect.color="green"} else if (contactstatus=="negative"){contactsitemRect.color= "red"} else{contactsitemRect.color= "white"}}
|
||||
MouseArea{
|
||||
anchors.fill: parent}
|
||||
}
|
||||
}
|
||||
Text{
|
||||
x:20*mm
|
||||
y:0.5*mm
|
||||
text: "Groups"
|
||||
}
|
||||
ListView {
|
||||
id: groupView
|
||||
x:20*mm
|
||||
y:5.5*mm
|
||||
width: 19*mm
|
||||
height:permissionDialog-8*mm
|
||||
clip: true
|
||||
spacing: 0
|
||||
model: groupModel
|
||||
delegate: groupItem
|
||||
}
|
||||
|
||||
ListModel{id: groupModel}
|
||||
Component{
|
||||
id:groupItem
|
||||
|
||||
Rectangle{
|
||||
id:groupitemRect
|
||||
width:groupView.width
|
||||
height: 5*mm
|
||||
property string groupstatus:""
|
||||
color: "white"
|
||||
border.color:"grey"
|
||||
Text{
|
||||
color:"grey"
|
||||
text:group.groupname
|
||||
}
|
||||
onGroupstatusChanged:
|
||||
{ if(groupstatus=="positive"){groupitemRect.color="green"} else if (groupstatus=="negative"){groupitemRect.color= "red"} else{groupitemRect.color= "white"}}
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
onClicked:{
|
||||
if(groupModel.get(index).groupstatus=="neutral"){
|
||||
groupModel.setProperty(index,"groupstatus","positive")}
|
||||
else if (groupModel.get(index).groupstatus=="positive"){
|
||||
groupModel.setProperty(index,"groupstatus","negative")}
|
||||
else{groupModel.setProperty(index,"groupstatus","neutral")}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
anchors.horizontalCenter: parent.hoizontalCenter
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin:1
|
||||
text:qsTr("Done")
|
||||
onClicked:{var group_allow=[];
|
||||
for (var i=0;i<groupModel.count;i++)
|
||||
{if (groupModel.get(i).groupstatus=="positive"){
|
||||
group_allow.append(groupModel.get(i).groupname)
|
||||
}
|
||||
}
|
||||
print("groups"+JSON.stringify(group_allow))
|
||||
permissionDialog.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted:{
|
||||
print("permissiondialog completed");
|
||||
Helperjs.readData(db,"contacts",login.username,function(contacts){
|
||||
for (var name in contacts){
|
||||
print("contact: "+JSON.stringify(contacts[name]));
|
||||
contactModel.append({"contact":contacts[name]})
|
||||
}},"isFriend",1);
|
||||
|
||||
Helperjs.readData(db,"groups",login.username,function(owngroups){
|
||||
for (var number in owngroups){
|
||||
groupModel.append({"group":owngroup[number]})
|
||||
}});
|
||||
}
|
||||
}
|
|
@ -18,17 +18,42 @@ Rectangle {
|
|||
// photoWorker.sendMessage(msg);
|
||||
//}
|
||||
onNewImagesChanged:{
|
||||
Helperjs.readField("album",root.db,"imageData",root.login.username,function(albums){
|
||||
//print("albums"+JSON.stringify(albums)+JSON.stringify(newImages[currentImageNo]));
|
||||
if(albums.indexOf(newImages[currentImageNo].album)==-1){
|
||||
filesystem.Directory=root.login.imagestore+"/albums";
|
||||
filesystem.makeDir(newImages[currentImageNo].album);}
|
||||
});
|
||||
if(newImages.length>0){
|
||||
print("Current image number"+currentImageNo)
|
||||
Service.dataRequest(root.login,newImages[currentImageNo].id,root.db,fotorectangle);
|
||||
newImagesProgress.visible=true //download first image
|
||||
}}
|
||||
|
||||
onCurrentImageNoChanged:{
|
||||
if(currentImageNo<newImages.length){Service.dataRequest(root.login,newImages[currentImageNo].id,root.db,fotorectangle)};
|
||||
if(currentImageNo==newImages.length){newImagesProgress.visible=false;showOwnFotos();
|
||||
newImages=[];currentImageNo=0}
|
||||
// download next image if photoplaceholder is finished saving
|
||||
// download next image if photoplaceholder is finished saving
|
||||
}
|
||||
|
||||
function showOwnFotos(){
|
||||
try {photogroupModel.clear()}catch (e){print(e)}
|
||||
Helperjs.readField("album",root.db, "imageData",root.login.username,function(albums){
|
||||
if (albums[0]) {
|
||||
var msg = { 'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture': false};
|
||||
photoWorker.sendMessage(msg);
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
function onFriendsFotos(friend){print("Friend "+friend.url);
|
||||
try {photogroupModel.clear()}catch (e){print(e)}
|
||||
Service.requestFriendsAlbumPictures(friend,fotostab,function(albums){
|
||||
var msg = {'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture':true};
|
||||
photoWorker.sendMessage(msg);
|
||||
})
|
||||
}
|
||||
|
||||
ProgressBar{
|
||||
id: newImagesProgress
|
||||
|
@ -118,23 +143,5 @@ Button {
|
|||
ListView {anchors.fill: parent; model: visualphotoModel.parts.fullscreen; interactive: false }
|
||||
WorkerScript{id: photoWorker;source: "qrc:/js/photoworker.js"}
|
||||
|
||||
function showOwnFotos(){
|
||||
try {photogroupModel.clear()}catch (e){print(e)}
|
||||
Helperjs.readField("album",root.db, "imageData",root.login.username,function(albums){
|
||||
if (albums[0]) {
|
||||
var msg = { 'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture': false};
|
||||
photoWorker.sendMessage(msg);
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
function onFriendsFotos(friend){print("Friend "+friend.url);
|
||||
try {photogroupModel.clear()}catch (e){print(e)}
|
||||
Service.requestFriendsAlbumPictures(friend,fotostab,function(albums){
|
||||
var msg = {'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture':true};
|
||||
photoWorker.sendMessage(msg);
|
||||
})
|
||||
}
|
||||
|
||||
Component.onCompleted: { root.fotoSignal.connect(onFriendsFotos);}
|
||||
Component.onCompleted: { root.fotoSignal.connect(onFriendsFotos);}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import QtQuick.LocalStorage 2.0
|
|||
import QtQuick.Window 2.0
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
import QtQml.Models 2.1
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
|
@ -16,7 +17,7 @@ TabView{
|
|||
id:root
|
||||
tabPosition: Qt.BottomEdge
|
||||
width: Screen.desktopAvailableWidth
|
||||
height: Screen.desktopAvailableHeight
|
||||
height: Screen.desktopAvailableHeight
|
||||
|
||||
property var db: ["Photos", "1.0", "Stores Friendica data", 100000000]
|
||||
property var login: Service.readActiveConfig(db)
|
||||
|
@ -26,7 +27,7 @@ TabView{
|
|||
signal fotoSignal(var friend)
|
||||
signal directmessageSignal(var friend)
|
||||
signal newsSignal(var news)
|
||||
|
||||
signal friendsSignal(var username)
|
||||
|
||||
currentIndex: (login=="")? 3:0
|
||||
|
||||
|
@ -39,11 +40,11 @@ TabView{
|
|||
newsSignal(dbnews)
|
||||
})}
|
||||
onNewContactsChanged:{if(newContacts.length>0){// download first contact image and update db
|
||||
print("newcontact"+JSON.stringify(newContacts[0]));
|
||||
// print("newcontact"+JSON.stringify(newContacts));
|
||||
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
||||
}
|
||||
onCurrentContactChanged:{// download next contact image after photoplaceholder is finished saving and update db
|
||||
print("Current contact"+JSON.stringify(newContacts[currentContact]));
|
||||
//print("Current contact"+JSON.stringify(newContacts[currentContact]));
|
||||
if(currentContact<newContacts.length){
|
||||
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
||||
else if(currentContact==newContacts.length){//newImagesProgress.visible=false;
|
||||
|
@ -66,25 +67,56 @@ TabView{
|
|||
}
|
||||
|
||||
function updateContactInDB(login,database,isFriend,contact){// for newstab and friendstab
|
||||
try{var imagename=login.imagestore+"contacts/"+contact.screen_name+".jpg";
|
||||
var component=Qt.createComponent("qrc:/qml/PhotoPlaceholder.qml");
|
||||
print("imageName "+imagename+" source "+ contact.profile_image_url)
|
||||
var sprite = component.createObject(root, {"fillMode": "Image.PreserveAspectFit","x":root.width,"y":50,"imageName":imagename,"source": contact.profile_image_url,"downloadtype":"contact"});} catch(e){print("Fehler beim Profilbild"+e)}
|
||||
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+".jpg";
|
||||
if (isFriend==1){
|
||||
xhr.setUrl(Qt.resolvedUrl(contact.profile_image_url));
|
||||
xhr.setFilename(imagename);
|
||||
xhr.download();
|
||||
}
|
||||
var db=LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
var result;
|
||||
db.transaction( function(tx) {
|
||||
result = tx.executeSql('SELECT * from contacts where id = '+contact.id); // check for news id
|
||||
if(result.rows.length === 1) {// use update
|
||||
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'",description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Newsjs.cleanDate(contact.created_at)+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where id='+contact.id);
|
||||
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'", profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Date.parse(Newsjs.cleanDate(contact.created_at))+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where id='+contact.id);
|
||||
} else {// use insert
|
||||
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,Qt.btoa(contact.description),imagename,contact.url,contact.protected,contact.followers_count, contact.friends_count,Newsjs.cleanDate(contact.created_at),contact.favorites_count,contact.utc_offset,contact.time_zone,contact.statuses_count,contact.following,contact.verfied,contact.statusnet_blocking,contact.notifications,contact.statusnet_profile_url,contact.cid,contact.network,isFriend]);}
|
||||
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,contact.profile_image_url, Qt.btoa(contact.description),imagename,contact.url,contact.protected,contact.followers_count, contact.friends_count,Date.parse(Newsjs.cleanDate(contact.created_at)),contact.favorites_count,contact.utc_offset,contact.time_zone,contact.statuses_count,contact.following,contact.verfied,contact.statusnet_blocking,contact.notifications,contact.statusnet_profile_url,contact.cid,contact.network,isFriend]);}
|
||||
});
|
||||
if (isFriend!=1){root.currentContact=root.currentContact+1}
|
||||
}
|
||||
|
||||
Connections{
|
||||
target:xhr
|
||||
onDownloaded:{root.currentContact=root.currentContact+1}
|
||||
}
|
||||
Connections{
|
||||
target:xhr
|
||||
onError:{print("Error"+data)}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
if (login==""){Service.initDatabase(db)}
|
||||
Helperjs.readField("id",db,"contacts",login.username,function(contacts){contactlist=contacts},"isFriend",1)
|
||||
}
|
||||
|
||||
|
||||
style: TabViewStyle {
|
||||
frameOverlap: 1
|
||||
tab: Rectangle {
|
||||
color: styleData.selected?"white":"light blue"
|
||||
border.color: "light grey"
|
||||
implicitWidth: root.width/4-2*mm
|
||||
implicitHeight: 4*mm
|
||||
Text { id: text
|
||||
anchors.centerIn: parent
|
||||
text: styleData.title
|
||||
color: "black"
|
||||
font.pixelSize:3*mm
|
||||
font.bold: styleData.selected
|
||||
}
|
||||
}
|
||||
frame: Rectangle { color: "light grey" }
|
||||
tabsAlignment:Qt.AlignHCenter
|
||||
}
|
||||
Tab{
|
||||
title: qsTr("News")
|
||||
id: newstab
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<file>js/layout.js</file>
|
||||
<file>js/photoworker.js</file>
|
||||
<file>js/service.js</file>
|
||||
<file>qml/FriendComponent.qml</file>
|
||||
<file>qml/MessageSend.qml</file>
|
||||
<file>qml/Newsitem.qml</file>
|
||||
<file>qml/PhotoComponent.qml</file>
|
||||
|
@ -20,5 +19,7 @@
|
|||
<file>images/defaultcontact.jpg</file>
|
||||
<file>qml/InfoBox.qml</file>
|
||||
<file>qml/GroupComponent.qml</file>
|
||||
<file>qml/ContactComponent.qml</file>
|
||||
<file>qml/PermissionDialog.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
|
|||
view.rootContext()->setContextProperty("xhr", xhr);
|
||||
FILESYSTEM* filesystem = FILESYSTEM::instance();
|
||||
view.rootContext()->setContextProperty("filesystem", filesystem);
|
||||
view.setSource(QUrl("qrc:/qml/friendiqa.qml"));
|
||||
view.setSource(QUrl("qrc:/qml/friendiqa.qml"));
|
||||
view.show();
|
||||
view.connect(view.rootContext()->engine(), SIGNAL(quit()), &app, SLOT(quit()));
|
||||
return app.exec();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "xhr.h"
|
||||
#include "xhr.h"
|
||||
|
||||
#include <QHttpPart>
|
||||
#include <QTextCodec>
|
||||
|
@ -14,7 +14,7 @@ XHR *XHR::instance()
|
|||
|
||||
XHR::XHR(QObject *parent) : QObject(parent)
|
||||
{
|
||||
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
||||
// request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
||||
}
|
||||
|
||||
void XHR::setUrl(QString url)
|
||||
|
@ -32,6 +32,15 @@ void XHR::setLogin(QString login)
|
|||
emit loginChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void XHR::setFilename(QString filename)
|
||||
{
|
||||
if (filename!=m_filename) {
|
||||
m_filename = filename;
|
||||
emit filenameChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString XHR::url() const
|
||||
{
|
||||
return m_url;
|
||||
|
@ -42,6 +51,11 @@ QString XHR::login() const
|
|||
return m_login;
|
||||
}
|
||||
|
||||
QString XHR::filename() const
|
||||
{
|
||||
return m_filename;
|
||||
}
|
||||
|
||||
void XHR::setParam(QString name, QString value)
|
||||
{
|
||||
params.insert(name, value);
|
||||
|
@ -58,6 +72,21 @@ void XHR::clearParams()
|
|||
params.clear();
|
||||
}
|
||||
|
||||
void XHR::download()
|
||||
{
|
||||
QUrl requrl(m_url);
|
||||
// qDebug() << "start download of " << requrl;
|
||||
request.setUrl(requrl);
|
||||
reply = manager.get(request);
|
||||
// qDebug() << "reply " << reply->header(QNetworkRequest::LocationHeader)<<reply->header(QNetworkRequest::LastModifiedHeader);
|
||||
// qDebug() << "request " << request.url();
|
||||
// qDebug() << "error " << reply->error();
|
||||
// reply->ignoreSslErrors();
|
||||
connect(reply, &QNetworkReply::readyRead,this, &XHR::onRequestFinished);
|
||||
connect(reply, &QNetworkReply::sslErrors, this, &XHR::onSSLError);
|
||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
||||
void XHR::get()
|
||||
{
|
||||
QUrlQuery query;
|
||||
|
@ -82,7 +111,7 @@ void XHR::get()
|
|||
connect(reply, &QNetworkReply::finished, this, &XHR::onReplySuccess);
|
||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
|
||||
connect(reply, &QNetworkReply::readyRead, this, &XHR::onReadyRead);
|
||||
|
||||
connect(reply, &QNetworkReply::sslErrors, this, &XHR::onSSLError);
|
||||
}
|
||||
|
||||
void XHR::post()
|
||||
|
@ -145,6 +174,22 @@ void XHR::onReplySuccess()
|
|||
reply->deleteLater();
|
||||
}
|
||||
|
||||
void XHR::onRequestFinished()
|
||||
{
|
||||
// Save the file here
|
||||
QByteArray b = reply->readAll();
|
||||
QImage image = QImage::fromData(b);
|
||||
if (image.isNull()){qDebug() << "Image empty"<<m_url;}
|
||||
QFile file(m_filename);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
image.save(&file, "JPG");
|
||||
b.clear();
|
||||
file.close();
|
||||
// qDebug() << m_url << "File downloaded "<<file.fileName();
|
||||
emit this->downloaded();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
void XHR::onReadyRead()
|
||||
{
|
||||
qDebug() << ".";
|
||||
|
|
|
@ -11,35 +11,43 @@ class XHR : public QObject
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged)
|
||||
Q_PROPERTY(QString login READ login WRITE setLogin NOTIFY loginChanged)
|
||||
|
||||
Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged)
|
||||
public:
|
||||
static XHR *instance();
|
||||
|
||||
explicit XHR(QObject *parent = 0);
|
||||
|
||||
void setUrl(QString url);
|
||||
// void setLogin(QString login);
|
||||
|
||||
// void setLogin(QString login);
|
||||
|
||||
QString url() const;
|
||||
QString login() const;
|
||||
QString filename() const;
|
||||
|
||||
signals:
|
||||
void urlChanged();
|
||||
void loginChanged();
|
||||
void filenameChanged();
|
||||
void downloaded();
|
||||
void success(QString data);
|
||||
void error(QString data, int code);
|
||||
|
||||
public slots:
|
||||
void setUrl(QString url);
|
||||
void setLogin(QString login);
|
||||
void setFilename(QString filename);
|
||||
void setParam(QString name, QString value);
|
||||
void setImageFileParam(QString name, QString url);
|
||||
void clearParams();
|
||||
void post();
|
||||
void get();
|
||||
void download();
|
||||
|
||||
private slots:
|
||||
void onReplyError(QNetworkReply::NetworkError code);
|
||||
void onReplySuccess();
|
||||
void onRequestFinished();
|
||||
//void onFileWritten();
|
||||
void onReadyRead();
|
||||
void onSSLError(const QList<QSslError> &errors);
|
||||
|
||||
|
@ -47,6 +55,7 @@ private:
|
|||
QByteArray buffer;
|
||||
QString m_url;
|
||||
QString m_login;
|
||||
QString m_filename;
|
||||
QHash<QString, QString> params;
|
||||
QHash<QString, QString> files;
|
||||
|
||||
|
|
|
@ -4,18 +4,19 @@
|
|||
function friendicaRequest(login,api,rootwindow,callback) {
|
||||
var xhrequest= new XMLHttpRequest();
|
||||
xhrequest.onreadystatechange = function() {
|
||||
if (xhrequest.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
||||
} else if(xhrequest.readyState === XMLHttpRequest.DONE) {
|
||||
// if (xhrequest.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
||||
// } else
|
||||
if(xhrequest.readyState === XMLHttpRequest.DONE) {
|
||||
try{ if (xhrequest.responseText!=""){
|
||||
callback(xhrequest.responseText)
|
||||
}else{
|
||||
showMessage("Error",api+" NO RESPONSE",rootwindow)
|
||||
callback(xhrequest.responseText)
|
||||
}else{
|
||||
showMessage("Error",api+" NO RESPONSE",rootwindow);
|
||||
callback(xhrequest.responseText)
|
||||
}
|
||||
}
|
||||
catch (e){
|
||||
showMessage("Error", api+" "+e,rootwindow)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
xhrequest.open("GET", login.server+api,true,login.username,Qt.atob(login.password));
|
||||
|
@ -65,12 +66,15 @@ function readData(database,table,username,callback,filter,filtervalue) { // read
|
|||
if (filter){
|
||||
var where = " AND "+ filter +" = '" + filtervalue+"'";
|
||||
} else { var where="";}
|
||||
if (username){
|
||||
var user = ' where username= "'+ username +'"';
|
||||
} else { var user='';}
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
if(!db) { return; }
|
||||
db.transaction( function(tx) {
|
||||
// print('select * from '+table'+where username= "'+username+'"'+'where);
|
||||
//print('select * from '+table+user+where);
|
||||
var rsArray=[];
|
||||
var rs = tx.executeSql('select * from '+table+' where username= "'+username+'"'+where);
|
||||
var rs = tx.executeSql('select * from '+table+user+where);
|
||||
for(var i = 0; i < rs.rows.length; i++) {
|
||||
rsArray.push(rs.rows.item(i))
|
||||
}
|
||||
|
@ -85,19 +89,20 @@ var where = " AND "+ filter +" = '" + filtervalue+"'";
|
|||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
if(!db) { return; }
|
||||
db.transaction( function(tx) {
|
||||
// print('... read from database ' + field)
|
||||
var rsArray=[];
|
||||
print('select DISTINCT '+field+' from '+table+' WHERE username="'+username+'"'+where+' ORDER BY '+field+' ASC');
|
||||
var rs = tx.executeSql('select DISTINCT '+field+' from '+table+' WHERE username="'+username+'"'+where+' ORDER BY '+field+' ASC');
|
||||
for(var i = 0; i < rs.rows.length; i++) {
|
||||
rsArray.push(rs.rows.item(i)[field])
|
||||
}
|
||||
callback(rsArray);
|
||||
//print('... read from database ' + field)
|
||||
var rsArray=[];
|
||||
//print('select DISTINCT '+field+' from '+table+' WHERE username="'+username+'"'+where+' ORDER BY '+field+' ASC');
|
||||
var rs = tx.executeSql('select DISTINCT '+field+' from '+table+' WHERE username="'+username+'"'+where+' ORDER BY '+field+' ASC');
|
||||
for(var i = 0; i < rs.rows.length; i++) {
|
||||
rsArray.push(rs.rows.item(i)[field])
|
||||
}
|
||||
callback(rsArray);
|
||||
});
|
||||
}
|
||||
|
||||
function showMessage(header,message,rootwindow){
|
||||
var messageString='import QtQuick 2.0; import QtQuick.Dialogs 1.2; MessageDialog{ visible: true; title:"'+header+'";standardButtons: StandardButton.Ok; text:" '+message+'"}';
|
||||
var cleanmessage=message.replace(/"/g,"-");
|
||||
var messageString='import QtQuick 2.0; import QtQuick.Dialogs 1.2; MessageDialog{ visible: true; title:"'+header+'";standardButtons: StandardButton.Ok; text:" '+cleanmessage+'"}';
|
||||
var messageObject=Qt.createQmlObject(messageString,rootwindow,"messageOutput");
|
||||
}
|
||||
|
||||
|
|
|
@ -40,35 +40,66 @@ function getFriendsTimeline(login,database,contacts,rootwindow,callback){// retr
|
|||
var result = tx.executeSql('SELECT status_id from news WHERE username="'+login.username+'" ORDER BY status_id DESC LIMIT 1'); // check for last news id
|
||||
try{parameter="&since_id="+result.rows.item(0).status_id;}catch(e){};})
|
||||
var newContacts=[];
|
||||
//print(JSON.stringify("Contacts "+contacts));
|
||||
Helperjs.friendicaRequest(login,"/api/statuses/friends_timeline"+parameter, rootwindow,function (obj){
|
||||
var news=JSON.parse(obj);
|
||||
for (var i=0;i<news.length;i++){
|
||||
if(contacts.indexOf(news[i].user.id)==-1 && !(inArray(newContacts,"id",news[i].user.id))){
|
||||
news[i].user.isFriend=0;
|
||||
newContacts.push(news[i].user);
|
||||
}
|
||||
if (news[i].friendica_activities.like.length>0){
|
||||
print("Like Contact"+JSON.stringify(news[i].friendica_activities.like));
|
||||
for (var j=0;j<news[i].friendica_activities.like.length;j++){
|
||||
if(contacts.indexOf(news[i].friendica_activities.like[j].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activities.like[j].id))){
|
||||
news[i].friendica_activities.like[j].isFriend=0;
|
||||
newContacts.push(news[i].friendica_activities.like[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (news[i].friendica_activities.dislike.length>0){
|
||||
print("DisLike Contact"+JSON.stringify(news[i].friendica_activities.dislike));
|
||||
for (var k=0;j<news[k].friendica_activities.dislike.length;k++){
|
||||
if(contacts.indexOf(news[i].friendica_activities.dislike[k].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activties.dislike[k].id))){
|
||||
news[i].friendica_activities.dislike[k].isFriend=0;
|
||||
newContacts.push(news[i].friendica_activities.dislike[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var newContacts=findNewContacts(news,contacts);
|
||||
// for (var i=0;i<news.length;i++){
|
||||
// if(contacts.indexOf(news[i].user.id)==-1 && !(inArray(newContacts,"id",news[i].user.id))){
|
||||
// news[i].user.isFriend=0;
|
||||
// newContacts.push(news[i].user);
|
||||
// }
|
||||
// if (news[i].friendica_activities.like.length>0){
|
||||
// // print("Like Contact"+JSON.stringify(news[i].friendica_activities.like));
|
||||
// for (var j=0;j<news[i].friendica_activities.like.length;j++){
|
||||
// if(contacts.indexOf(news[i].friendica_activities.like[j].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activities.like[j].id))){
|
||||
// news[i].friendica_activities.like[j].isFriend=0;
|
||||
// newContacts.push(news[i].friendica_activities.like[j]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (news[i].friendica_activities.dislike.length>0){
|
||||
// //print("DisLike Contact"+JSON.stringify(news[i].friendica_activities.dislike));
|
||||
// for (var k=0;j<news[k].friendica_activities.dislike.length;k++){
|
||||
// if(contacts.indexOf(news[i].friendica_activities.dislike[k].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activties.dislike[k].id))){
|
||||
// news[i].friendica_activities.dislike[k].isFriend=0;
|
||||
// newContacts.push(news[i].friendica_activities.dislike[k]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
callback(news,newContacts)
|
||||
})}
|
||||
|
||||
function findNewContacts(news,contacts){
|
||||
var newContacts=[];
|
||||
for (var i=0;i<news.length;i++){
|
||||
if(contacts.indexOf(news[i].user.id)==-1 && !(inArray(newContacts,"id",news[i].user.id))){
|
||||
news[i].user.isFriend=0;
|
||||
newContacts.push(news[i].user);
|
||||
}
|
||||
if (news[i].friendica_activities.like.length>0){
|
||||
// print("Like Contact"+JSON.stringify(news[i].friendica_activities.like));
|
||||
for (var j=0;j<news[i].friendica_activities.like.length;j++){
|
||||
if(contacts.indexOf(news[i].friendica_activities.like[j].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activities.like[j].id))){
|
||||
news[i].friendica_activities.like[j].isFriend=0;
|
||||
newContacts.push(news[i].friendica_activities.like[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (news[i].friendica_activities.dislike.length>0){
|
||||
//print("DisLike Contact"+JSON.stringify(news[i].friendica_activities.dislike));
|
||||
for (var k=0;j<news[k].friendica_activities.dislike.length;k++){
|
||||
if(contacts.indexOf(news[i].friendica_activities.dislike[k].id)==-1 && !(inArray(newContacts,"id",news[i].friendica_activties.dislike[k].id))){
|
||||
news[i].friendica_activities.dislike[k].isFriend=0;
|
||||
newContacts.push(news[i].friendica_activities.dislike[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return newContacts
|
||||
}
|
||||
|
||||
function storeNews(login,database,news,rootwindow,callback){
|
||||
// save news after contacts download, call next function
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
|
@ -80,14 +111,14 @@ function storeNews(login,database,news,rootwindow,callback){
|
|||
var attendyesarray=[]; for (var user in news[i].friendica_activities.attendyes){attendyesarray.push(parseInt(news[i].friendica_activities.attendyes[user].id))}
|
||||
var attendnoarray=[]; for (var user in news[i].friendica_activities.attendno){attendnoarray.push(parseInt(news[i].friendica_activities.attendno[user].id))}
|
||||
var attendmaybearray=[]; for (var user in news[i].friendica_activities.attendmaybe){attendmaybearray.push(parseInt(news[i].friendica_activities.attendmaybe[user].id))}
|
||||
|
||||
var friendica_activities=[likearray,dislikearray,attendyesarray,attendnoarray,attendmaybearray]
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('SELECT * from news where status_id = "'+news[i].id+'"'); // check for news id
|
||||
if(result.rows.length === 1) {// use update
|
||||
print(news[i].id +' exists, update it')
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=0, text="'+Qt.btoa(news[i].text)+'", created_at="'+Date.parse(cleanDate(news[i].created_at))+'", in_reply_to_status_id="'+news[i].in_reply_to_status_id+'", source="'+news[i].source+'", status_id="'+news[i].id+'", in_reply_to_user_id="'+news[i].in_reply_to_user_id+'", geo="'+news[i].geo+'", favorited="'+news[i].favorited+'", uid="'+news[i].user.id+'", statusnet_html="'+Qt.btoa(news[i].status_html)+'", statusnet_conversation_id="'+news[i].statusnet_conversation_id+'",like="'+JSON.stringify(likearray)+'", dislike="'+JSON.stringify(dislikearray)+'", attendyes="'+JSON.stringify(attendyesarray)+'",attendno="'+JSON.stringify(attendnoarray)+'",attendmaybe="'+JSON.stringify(attendmaybearray)+'" where status_id="'+news[i].status_id+'"');
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=0, text="'+Qt.btoa(news[i].text)+'", created_at="'+Date.parse(cleanDate(news[i].created_at))+'", in_reply_to_status_id="'+news[i].in_reply_to_status_id+'", source="'+news[i].source+'", status_id="'+news[i].id+'", in_reply_to_user_id="'+news[i].in_reply_to_user_id+'", geo="'+news[i].geo+'", favorited="'+news[i].favorited+'", uid="'+news[i].user.id+'", statusnet_html="'+Qt.btoa(news[i].status_html)+'", statusnet_conversation_id="'+news[i].statusnet_conversation_id+'",friendica_activities="'+JSON.stringify(friendica_activities)+'" where status_id="'+news[i].status_id+'"');
|
||||
} else {// use insert
|
||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,in_reply_to_status_id,source,status_id,in_reply_to_user_id,geo,favorited,uid,statusnet_html,statusnet_conversation_id,like,dislike,attendyes,attendno,attendmaybe) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,0,Qt.btoa(news[i].text),Date.parse(cleanDate(news[i].created_at)), news[i].in_reply_to_status_id, news[i].source, news[i].id,news[i].in_reply_to_user_id,news[i].geo,news[i].favorited, news[i].user.id,Qt.btoa(news[i].statusnet_html),news[i].statusnet_conversation_id, JSON.stringify(likearray),JSON.stringify(dislikearray),JSON.stringify(attendyesarray),JSON.stringify(attendnoarray),JSON.stringify(attendmaybearray)])}})
|
||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,in_reply_to_status_id,source,status_id,in_reply_to_user_id,geo,favorited,uid,statusnet_html,statusnet_conversation_id,friendica_activities,friendica_activities_self) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,0,Qt.btoa(news[i].text),Date.parse(cleanDate(news[i].created_at)), news[i].in_reply_to_status_id, news[i].source, news[i].id,news[i].in_reply_to_user_id,news[i].geo,news[i].favorited, news[i].user.id,Qt.btoa(news[i].statusnet_html),news[i].statusnet_conversation_id, JSON.stringify(friendica_activities),"[]"])}})
|
||||
}
|
||||
getDirectMessage(login,database,rootwindow,callback)
|
||||
}
|
||||
|
@ -102,9 +133,9 @@ function getDirectMessage(login,database,rootwindow,callback){
|
|||
var result = tx.executeSql('SELECT * from news where status_id = "'+messages[i].id+'"'); // check for news id
|
||||
if(result.rows.length === 1) {// use update
|
||||
print(messages[i].id +' exists, update it')
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=1, text="'+Qt.btoa(messages[i].text)+'", created_at="'+Date.parse(cleanDate(messages[i].created_at))+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].sender.id+'", statusnet_html="'+Qt.btoa(messages[i].text)+'" where status_id="'+messages[i].status_id+'"');
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=1, text="'+Qt.btoa(messages[i].text)+'", created_at="'+Date.parse(messages[i].created_at)+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].sender.id+'", statusnet_html="'+Qt.btoa(messages[i].text)+'" where status_id="'+messages[i].status_id+'"');
|
||||
} else {// use insert
|
||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id,uid,statusnet_html) VALUES (?,?,?,?,?,?,?,?)', [login.username,1,Qt.btoa(messages[i].text),Date.parse(cleanDate(messages[i].created_at)), "Friendica", messages[i].id, messages[i].sender.id,Qt.btoa(messages[i].text)])}
|
||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id,uid,statusnet_html) VALUES (?,?,?,?,?,?,?,?)', [login.username,1,Qt.btoa(messages[i].text),Date.parse(messages[i].created_at), "Friendica", messages[i].id, messages[i].sender.id,Qt.btoa(messages[i].text)])}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
@ -121,15 +152,25 @@ function getNotifications(login,database,rootwindow,callback){
|
|||
var result = tx.executeSql('SELECT * from news where status_id = "'+messages[i].id+'"'); // check for news id
|
||||
if(result.rows.length === 1) {// use update
|
||||
print(messages[i].id +' exists, update it')
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=2, text="'+Qt.btoa(messages[i].msg_html)+'", created_at="'+messages[i].timestamp+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].uid+'", statusnet_html="'+Qt.btoa(messages[i].msg_html)+'", statusnet_conversation_id="'+messages[i].parent+'" where status_id="'+messages[i].id+'"');
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=2, text="'+Qt.btoa(messages[i].msg_html)+'", created_at="'+Date.parse(messages[i].date)+'", source="Friendica", status_id="'+messages[i].id+'", uid="'+messages[i].uid+'", statusnet_html="'+Qt.btoa(messages[i].msg_html)+'", statusnet_conversation_id="'+messages[i].parent+'" where status_id="'+messages[i].id+'"');
|
||||
} else {// use insert
|
||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id, uid,statusnet_html,statusnet_conversation_id) VALUES (?,?,?,?,?,?,?,?,?)', [login.username,2,Qt.btoa(messages[i].msg_html),messages[i].timestamp,"Friendica", messages[i].id, messages[i].uid,Qt.btoa(messages[i].msg_html),messages[i].parent])}
|
||||
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,source,status_id, uid,statusnet_html,statusnet_conversation_id) VALUES (?,?,?,?,?,?,?,?,?)', [login.username,2,Qt.btoa(messages[i].msg_html),Date.parse(messages[i].date),"Friendica", messages[i].id, messages[i].uid,Qt.btoa(messages[i].msg_html),messages[i].parent])}
|
||||
});
|
||||
}
|
||||
})
|
||||
newsfromdb(database,login.username,callback)
|
||||
}
|
||||
|
||||
function getActivitiesUserData(database,username,useridArray){
|
||||
var helpArray=[];
|
||||
for (var i=0;i<useridArray.length;i++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
helpArray.push(userdata[0]);
|
||||
},"id",useridArray[i]);
|
||||
}
|
||||
return helpArray
|
||||
}
|
||||
|
||||
function newsfromdb(database,username,callback,contact,stop_time){
|
||||
// return news before stop_time (used by More button), in brackets of 20 entries, or by specified contact
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
|
@ -139,6 +180,7 @@ db.transaction( function(tx) {
|
|||
stop="<="+rs.rows.item(0).created_at}catch(e){stop="<99999999999999"}}
|
||||
else{var stop="<"+stop_time}
|
||||
var contactfilter="";if(contact){contactfilter=" AND uid='"+contact+"'"}
|
||||
print('select * from news WHERE username="'+username+'" AND created_at'+stop+contactfilter+' ORDER BY created_at DESC LIMIT 20');
|
||||
var newsrs=tx.executeSql('select * from news WHERE username="'+username+'" AND created_at'+stop+contactfilter+' ORDER BY created_at DESC LIMIT 20');
|
||||
var newsArray=[];
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
|
@ -152,57 +194,45 @@ db.transaction( function(tx) {
|
|||
},"id",newsArray[i].in_reply_to_user_id);
|
||||
}
|
||||
if (newsArray[i].messagetype==0){
|
||||
//userdata for likes
|
||||
var likeArray=JSON.parse(newsArray[i].like);
|
||||
var likeHelper=[];
|
||||
for (var j=0;j<likeArray.length;j++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
likeHelper[j]=userdata[0];
|
||||
},"id",likeArray[j]);
|
||||
}
|
||||
newsArray[i].like=likeHelper;
|
||||
//userdata for dislikes
|
||||
var dislikeArray=JSON.parse(newsArray[i].dislike);
|
||||
var dislikeHelper=[];
|
||||
for (var k=0;k<dislikeArray.length;k++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
dislikeHelper[j]=userdata[0];
|
||||
},"id",dislikeArray[k]);
|
||||
}
|
||||
newsArray[i].dislike=dislikeHelper;
|
||||
//userdata for attendyes
|
||||
var attendyesArray=JSON.parse(newsArray[i].attendyes);
|
||||
var attendyesHelper=[];
|
||||
for (var l=0;l<attendyesArray.length;l++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
attendyesHelper[j]=userdata[0];
|
||||
},"id",attendyesArray[l]);
|
||||
}
|
||||
newsArray[i].attendyes=attendyesHelper;
|
||||
//userdata for attendno
|
||||
var attendnoArray=JSON.parse(newsArray[i].attendno);
|
||||
var attendnoHelper=[];
|
||||
for (var m=0;m<attendnoArray.length;m++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
attendnoHelper[j]=userdata[0];
|
||||
},"id",attendnoArray[m]);
|
||||
}
|
||||
newsArray[i].attendno=attendnoHelper;
|
||||
|
||||
//userdata for attendmaybe
|
||||
var attendmaybeArray=JSON.parse(newsArray[i].attendmaybe);
|
||||
var attendmaybeHelper=[];
|
||||
for (var n=0;n<attendmaybeArray.length;n++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
attendmaybeHelper[j]=userdata[0];
|
||||
},"id",attendmaybeArray[l]);
|
||||
}
|
||||
newsArray[i].attendmaybe=attendmaybeHelper;
|
||||
for(var j=0;j<newsArray[i].friendica_activities.length;j++)
|
||||
{var friendicaArray=JSON.parse(newsArray[i].friendica_activities);
|
||||
// print("Array: "+friendicaArray[1]);
|
||||
newsArray[i].like=getActivitiesUserData(database,username,friendicaArray[0]);
|
||||
newsArray[i].dislike=getActivitiesUserData(database,username,friendicaArray[1]);
|
||||
newsArray[i].attendyes=getActivitiesUserData(database,username,friendicaArray[2]);
|
||||
newsArray[i].attendno=getActivitiesUserData(database,username,friendicaArray[3]);
|
||||
newsArray[i].attendmaybe=getActivitiesUserData(database,username,friendicaArray[4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
callback(newsArray)});
|
||||
}
|
||||
|
||||
function fetchUsersForNews(database,username,news){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
news.user=userdata[0];
|
||||
//print("Fetch user"+JSON.stringify(news.user));
|
||||
},"id",news.uid);
|
||||
if(news.in_reply_to_user_id){
|
||||
Helperjs.readData(database,"contacts",username,function(replytodata){
|
||||
news.reply_user=replytodata[0];
|
||||
//print("Fetch reply to"+JSON.stringify(news.reply_user));
|
||||
},"id",news.in_reply_to_user_id);
|
||||
}
|
||||
if (news.messagetype==0){
|
||||
for(var j=0;j<news.friendica_activities.length;j++)
|
||||
{var friendicaArray=JSON.parse(news.friendica_activities);
|
||||
// print("Array: "+friendicaArray[1]);
|
||||
news.like=getActivitiesUserData(database,username,friendicaArray[0]);
|
||||
news.dislike=getActivitiesUserData(database,username,friendicaArray[1]);
|
||||
news.attendyes=getActivitiesUserData(database,username,friendicaArray[2]);
|
||||
news.attendno=getActivitiesUserData(database,username,friendicaArray[3]);
|
||||
news.attendmaybe=getActivitiesUserData(database,username,friendicaArray[4]);
|
||||
}
|
||||
}
|
||||
return news
|
||||
}
|
||||
|
||||
function deleteNews(login,database,newsid,rootwindow,callback){
|
||||
Helperjs.friendicaPostRequest(login,"/api/statuses/destroy?id="+newsid, rootwindow,function (obj){
|
||||
print("Delete "+obj);
|
||||
|
@ -228,73 +258,105 @@ function favorite(login,favorite,newsid,rootwindow){
|
|||
})}
|
||||
}
|
||||
|
||||
function likerequest(login,database,toggle,verb,newsid,rootwindow){
|
||||
function likerequest(login,database,verb,newsid,rootwindow){
|
||||
Helperjs.friendicaPostRequest(login,"/api/friendica/activity/"+verb+"?id="+newsid, rootwindow,function (obj){
|
||||
print("likereturn "+obj);
|
||||
if (obj=='"ok"'){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {var result = tx.executeSql('UPDATE news SET '+verb+'d ='+toggle+' where status_id ='+newsid);
|
||||
})}})
|
||||
db.transaction( function(tx) {
|
||||
var currentActivities_rs=tx.executeSql('select friendica_activities_self from news WHERE username="'+login.username+'" AND status_id='+newsid) ;
|
||||
var currentActivities=JSON.parse(currentActivities_rs.rows.item(0).friendica_activities_self);
|
||||
//print("currentActivities "+JSON.stringify(currentActivities));
|
||||
if ((verb=="like")&&(currentActivities.indexOf(1)==-1)){ currentActivities.push(1);
|
||||
currentActivities.splice(currentActivities.indexOf(2),1)
|
||||
}
|
||||
if ((verb=="dislike")&&(currentActivities.indexOf(2)==-1)){ currentActivities.push(2);
|
||||
currentActivities.splice(currentActivities.indexOf(1),1)
|
||||
}
|
||||
if (verb=="unlike"){ try{currentActivities.splice(currentActivities.indexOf(1),1)}catch(e){}}
|
||||
if (verb=="undislike"){ try{currentActivities.splice(currentActivities.indexOf(2),1)}catch(e){}}
|
||||
var result = tx.executeSql('UPDATE news SET friendica_activities_self ="'+JSON.stringify(currentActivities)+'" where username="'+login.username+'" AND status_id ='+newsid);
|
||||
})}
|
||||
else{print("likerequest"+obj)}})
|
||||
}
|
||||
|
||||
function like(login,database,toggle,verb,newsid,rootwindow){
|
||||
if(verb=="like"&& toggle==1){
|
||||
likerequest(login,database,1,"like",newsid,rootwindow);
|
||||
likerequest(login,database,0,"undislike",newsid,rootwindow);}
|
||||
if(verb=="dislike"&& toggle==1){
|
||||
likerequest(login,database,1,"dislike",newsid,rootwindow);
|
||||
likerequest(login,database,0,"unlike",newsid,rootwindow);}
|
||||
if(toggle==0){
|
||||
likerequest(login,database,0,"un"+verb,newsid,rootwindow);}
|
||||
if(verb=="like"&& toggle==1){likerequest(login,database,"like",newsid,rootwindow);
|
||||
}
|
||||
if(verb=="dislike"&& toggle==1){likerequest(login,database,"dislike",newsid,rootwindow);
|
||||
}
|
||||
if(toggle==0){
|
||||
likerequest(login,database,"un"+verb,newsid,rootwindow);}
|
||||
}
|
||||
|
||||
function attend(login,database,attend,newsid,rootwindow,callback){
|
||||
Helperjs.friendicaPostRequest(login,"/api/friendica/activity/attend"+attend+"?id="+newsid, rootwindow,function (obj){
|
||||
var attendReturn=JSON.parse(obj);
|
||||
// print("attend: "+obj);
|
||||
//if (attendReturn=="OK")
|
||||
{
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {var result = tx.executeSql('UPDATE news SET attend="+attend+" where status_id ='+newsid);
|
||||
callback();
|
||||
Helperjs.friendicaPostRequest(login,"/api/friendica/activity/attend"+attend+"?id="+newsid, rootwindow,function (obj){
|
||||
var attendReturn=JSON.parse(obj);
|
||||
// print("attend: "+obj);
|
||||
if (attendReturn=="OK")
|
||||
{var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var currentActivities_rs=tx.executeSql('select friendica_activities_self from news WHERE username="'+login.username+'" AND status_id='+newsid) ;
|
||||
var currentActivities=JSON.parse(currentActivities_rs.rows.item(0));
|
||||
print("currentActivities "+JSON.stringify(currentActivities));
|
||||
if ((attend=="attendyes")&&(currentActivities.indexOf(3)==-1)){
|
||||
currentActivities.push(3);
|
||||
currentActivities.splice(currentActivities.indexOf(4),1)
|
||||
currentActivities.splice(currentActivities.indexOf(5),1)
|
||||
}
|
||||
if ((attend=="attendno")&&(currentActivities.indexOf(4)==-1)){
|
||||
currentActivities.push(4);
|
||||
currentActivities.splice(currentActivities.indexOf(3),1)
|
||||
currentActivities.splice(currentActivities.indexOf(5),1)
|
||||
}
|
||||
if ((attend=="attendmaybe")&&(currentActivities.indexOf(5)==-1)){
|
||||
currentActivities.push(5);
|
||||
currentActivities.splice(currentActivities.indexOf(3),1)
|
||||
currentActivities.splice(currentActivities.indexOf(4),1)
|
||||
}
|
||||
var result = tx.executeSql('UPDATE news SET friendica_activities_self ="'+JSON.stringify(currentActivities)+'" where username="'+login.username+'" AND status_id ='+newsid);
|
||||
callback();
|
||||
})}})}
|
||||
|
||||
function requestConversation(login,database,newsid,rootwindow,callback){
|
||||
function requestConversation(login,database,newsid,contacts,rootwindow,callback){
|
||||
Helperjs.friendicaRequest(login,"/api/conversation/show?id="+newsid,rootwindow, function (obj){
|
||||
print(obj+JSON.stringify(obj));
|
||||
var news=JSON.parse(obj);
|
||||
for (var i=0;i<news.length;i++){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
print('store news data for ' + news[i].id);
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('SELECT * from news where status_id = "'+news[i].id+'"'); // check for news id
|
||||
if(result.rows.length === 1) {// use update
|
||||
print(news[i].id +' exists, update it')
|
||||
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype=0, text="'+Qt.btoa(news[i].text)+'", truncated="'+news[i].truncated+'", created_at="'+Date.parse(cleanDate(news[i].created_at))+'", in_reply_to_status_id="'+news[i].in_reply_to_status_id+'", source="'+news[i].source+'", status_id="'+news[i].id+'", in_reply_to_user_id="'+news[i].in_reply_to_user_id+'", geo="'+news[i].geo+'", favorited="'+news[i].favorited+'", uid="'+news[i].user.id+'", statusnet_html="'+Qt.btoa(news[i].status_html)+'", statusnet_conversation_id="'+news[i].statusnet_conversation_id+'", attachments="'+news[i].attachments+'" where status_id="'+news[i].status_id+'"');
|
||||
} else {// use insert
|
||||
result = tx.executeSql('INSERT INTO news VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,0,Qt.btoa(news[i].text),news[i].truncated,Date.parse(cleanDate(news[i].created_at)), news[i].in_reply_to_status_id, news[i].source, news[i].id,news[i].in_reply_to_user_id,news[i].geo,news[i].favorited, news[i].user.id,Qt.btoa(news[i].statusnet_html),news[i].statusnet_conversation_id, news[i].attachments,0,0,0]);
|
||||
}});
|
||||
if(news[i].user.following!=true){
|
||||
updateContactInDB(login,database,rootwindow,news[i].user)}
|
||||
}
|
||||
callback();
|
||||
}
|
||||
);}
|
||||
var newContacts=findNewContacts(news,contacts);
|
||||
// storeNews(login,database,news,rootwindow,callback)
|
||||
callback(news,newContacts)
|
||||
})}
|
||||
|
||||
function conversationfromdb(database,user,conversationId,callback){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
print('select * from news WHERE statusnet_conversation_id='+conversationId+' ORDER BY status_id DESC');
|
||||
var newsrs=tx.executeSql('select * from news WHERE statusnet_conversation_id='+conversationId+' ORDER BY status_id DESC');
|
||||
var newsArray=[];
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
newsArray.push(newsrs.rows.item(i))
|
||||
Helperjs.readData(database,"contacts",function(userdata){
|
||||
newsArray[i].user=userdata[0];
|
||||
},"id",newsArray[i].uid);
|
||||
}
|
||||
var newsArray=[];
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
newsArray.push(newsrs.rows.item(i));
|
||||
newsArray[i]=fetchUsersForNews(database,user,newsArray[i]);
|
||||
callback(newsArray);
|
||||
});}
|
||||
}})}
|
||||
|
||||
function requestFavorites(login,database,rootwindow,callback){
|
||||
Helperjs.friendicaRequest(login,"/api/favorites",rootwindow, function (obj){
|
||||
//print(obj+JSON.stringify(obj));
|
||||
var news=JSON.parse(obj);
|
||||
// storeNews(login,database,news,rootwindow,callback)
|
||||
callback(news)
|
||||
})}
|
||||
|
||||
function favoritesfromdb(database,user,callback){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
print('select * from news WHERE username="'+user+'" AND favorited=1 ORDER BY status_id DESC');
|
||||
var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND favorited=1 ORDER BY status_id DESC');
|
||||
var newsArray=[];
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
newsArray.push(newsrs.rows.item(i));
|
||||
newsArray[i]=fetchUsersForNews(database,user,newsArray[i]);
|
||||
callback(newsArray);
|
||||
}})}
|
||||
|
||||
|
||||
function inArray(list, prop, val) {
|
||||
if (list.length > 0 ) {
|
||||
|
|
|
@ -1,35 +1,50 @@
|
|||
WorkerScript.onMessage = function(msg) {
|
||||
if(msg.appendnews!==true){ msg.model.clear()};
|
||||
|
||||
for (var j=0;j<msg.news.length;j++){
|
||||
if (msg.news[j]) {
|
||||
var newsitemobject=msg.news[j];
|
||||
var likeText="";var dislikeText="";var attendyesText="";var attendnoText="";var attendmaybeText="";
|
||||
if (newsitemobject.messagetype==0){
|
||||
if (msg.news[j].like.length>0){
|
||||
if (msg.news[j].like.length==1){likeText= Qt.atob(msg.news[j].like[0].name)+" "+ qsTr("likes this.")}
|
||||
else {likeText= msg.news[j].like.length+" "+ qsTr("like this.")}
|
||||
if (msg.news[j]) {
|
||||
var newsitemobject=msg.news[j];
|
||||
//print("Newsitem"+JSON.stringify(newsitemobject));
|
||||
if (newsitemobject.messagetype==2){
|
||||
newsitemobject.user={};
|
||||
newsitemobject.user.profile_image="qrc:/images/defaultcontact.jpg";
|
||||
newsitemobject.user.profile_image_url="qrc:/images/defaultcontact.jpg";
|
||||
newsitemobject.user.name="";
|
||||
}
|
||||
var likeText="";var dislikeText="";var attendyesText="";var attendnoText="";var attendmaybeText=""; var self={};
|
||||
if (newsitemobject.messagetype==0){
|
||||
if (newsitemobject.like.length>0){
|
||||
if (newsitemobject.like.length==1){likeText= Qt.atob(newsitemobject.like[0].name)+" "+ qsTr("likes this.")}
|
||||
else {likeText= newsitemobject.like.length+" "+ qsTr("like this.")}
|
||||
}
|
||||
if (msg.news[j].dislike.length>0){
|
||||
if (msg.news[j].dislike.length==1){dislikeText= QT.atob(msg.news[j].dislike[0].name)+" "+ qsTr("doesn't like this.")}
|
||||
else {dislikeText= msg.news[j].dislike.length+" "+ qsTr("don't like this.")}
|
||||
if (newsitemobject.dislike.length>0){
|
||||
if (newsitemobject.dislike.length==1){dislikeText= QT.atob(newsitemobject.dislike[0].name)+" "+ qsTr("doesn't like this.")}
|
||||
else {dislikeText= newsitemobject.dislike.length+" "+ qsTr("don't like this.")}
|
||||
}
|
||||
if (msg.news[j].attendyes.length>0){
|
||||
if (msg.news[j].attendyes.length==1){attendyesText= Qt.atob(msg.news[j].attendyes[0].name)+" "+ qsTr("will attend.")}
|
||||
else {attendyesText= msg.news[j].attendyes.length+" "+ qsTr("persons will attend.")}
|
||||
if (newsitemobject.attendyes.length>0){
|
||||
if (newsitemobject.attendyes.length==1){attendyesText= Qt.atob(newsitemobject.attendyes[0].name)+" "+ qsTr("will attend.")}
|
||||
else {attendyesText= newsitemobject.attendyes.length+" "+ qsTr("persons will attend.")}
|
||||
}
|
||||
if (msg.news[j].attendno.length>0){
|
||||
if (msg.news[j].attendno.length==1){attendnoText= Qt.atob(msg.news[j].attendno[0].name)+" "+ qsTr("will not attend.")}
|
||||
else {attendnoText= msg.news[j].attendno.length+" "+ qsTr("persons will not attend.")}
|
||||
if (newsitemobject.attendno.length>0){
|
||||
if (newsitemobject.attendno.length==1){attendnoText= Qt.atob(newsitemobject.attendno[0].name)+" "+ qsTr("will not attend.")}
|
||||
else {attendnoText= newsitemobject.attendno.length+" "+ qsTr("persons will not attend.")}
|
||||
}
|
||||
if (msg.news[j].attendmaybe.length>0){
|
||||
if (msg.news[j].attendmaybe.length==1){attendmaybeText= Qt.atob(msg.news[j].attendmaybe[0].name)+" "+ qsTr("may attend.")}
|
||||
else {attendmaybeText= msg.news[j].attendmaybe.length+" "+ qsTr("persons may attend.")}
|
||||
if (newsitemobject.attendmaybe.length>0){
|
||||
if (newsitemobject.attendmaybe.length==1){attendmaybeText= Qt.atob(newsitemobject.attendmaybe[0].name)+" "+ qsTr("may attend.")}
|
||||
else {attendmaybeText= newsitemobject.attendmaybe.length+" "+ qsTr("persons may attend.")}
|
||||
}
|
||||
var friendica_activities_self=JSON.parse(newsitemobject.friendica_activities_self);
|
||||
if (friendica_activities_self.indexOf(3)!=-1){self.attending=qsTr("yes")}
|
||||
if (friendica_activities_self.indexOf(4)!=-1){self.attending=qsTr("no")}
|
||||
if (friendica_activities_self.indexOf(5)!=-1){self.attending=qsTr("maybe")}
|
||||
if (friendica_activities_self.indexOf(1)!=-1){self.liked=1}
|
||||
if (friendica_activities_self.indexOf(2)!=-1){self.disliked=1}
|
||||
}
|
||||
var friendica_activities={likeText:likeText,dislikeText:dislikeText,attendyesText:attendyesText,attendnoText:attendnoText,attendmaybeText:attendmaybeText}
|
||||
var seconds=(msg.currentTime-newsitemobject.created_at)/1000;
|
||||
var timestring="";
|
||||
if (seconds<60) {timestring=seconds+" "+qsTr("seconds") +" "+qsTr("ago");}
|
||||
var friendica_activities={likeText:likeText,dislikeText:dislikeText,attendyesText:attendyesText,attendnoText:attendnoText,attendmaybeText:attendmaybeText,self:self}
|
||||
//print(JSON.stringify(friendica_activities) ) ;
|
||||
var seconds=(msg.currentTime-newsitemobject.created_at)/1000;
|
||||
var timestring="";
|
||||
if (seconds<60) {timestring=seconds+" "+qsTr("seconds") +" "+qsTr("ago");}
|
||||
else if (seconds<90){timestring=Math.round(seconds/60)+" "+qsTr("minute") +" "+qsTr("ago");}
|
||||
else if (seconds<3600){timestring=Math.round(seconds/60)+" "+qsTr("minutes") +" "+qsTr("ago");}
|
||||
else if (seconds<5400){timestring=Math.round(seconds/3600)+" "+qsTr("hour") +" "+qsTr("ago");}
|
||||
|
@ -40,7 +55,7 @@ WorkerScript.onMessage = function(msg) {
|
|||
else if (seconds<69984000){timestring=Math.round(seconds/3888000)+" "+qsTr("months") +" "+qsTr("ago");}
|
||||
else {timestring=Math.round(seconds/69984000)+" "+qsTr("years") +" "+qsTr("ago");}
|
||||
var data=({"newsitemobject": newsitemobject,"dateDiff":timestring,"friendica_activities":friendica_activities})}
|
||||
// print("News:"+j+msg.news.length+JSON.stringify(data));
|
||||
//print("News:"+j+msg.news.length+JSON.stringify(data));
|
||||
msg.model.append(data);}
|
||||
if (j==msg.news.length){
|
||||
msg.model.sync()
|
||||
|
|
|
@ -24,13 +24,13 @@ function requestList(login,database,rootwindow,callback) {
|
|||
|
||||
function dataRequest(login,photoID,database,rootwindow) {
|
||||
// check if image exist and call download function
|
||||
Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photoID, rootwindow, function (obj){
|
||||
try{ if(obj==""){currentImageNo=currentImageNo+1}else{
|
||||
var image = JSON.parse(obj);
|
||||
Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photoID, rootwindow, function (image){
|
||||
try{ if(image==""){currentImageNo=currentImageNo+1}else{
|
||||
var obj = JSON.parse(image);
|
||||
print('storeData() for ' + JSON.stringify(obj));
|
||||
try{sprite.destroy();}catch(e){}
|
||||
if (obj["link"]["0"]){var source=obj["link"]["0"]} else {var source=obj["link"]["4"]}//source for profile picture or original size
|
||||
print("Source"+obj["link"]["0"]+source)
|
||||
// try{sprite.destroy();}catch(e){}
|
||||
// if (obj["link"]["0"]){var source=obj["link"]["0"]} else {var source=obj["link"]["4"]}//source for profile picture or original size
|
||||
// print("Source"+source);
|
||||
obj["source"]=source;
|
||||
var filename=obj.filename;
|
||||
if (filename==""){// check if file as any filename
|
||||
|
@ -45,7 +45,7 @@ function dataRequest(login,photoID,database,rootwindow) {
|
|||
}
|
||||
print("obj.Filename: "+obj["filename"]+" filename: "+filename)
|
||||
}
|
||||
saveImage(obj,login.imagestore,function(obj,sprite){
|
||||
saveImage(obj,login.imagestore+'albums/'+obj.album,function(obj,sprite){
|
||||
//sprite.destroy(500);
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
|
@ -53,9 +53,9 @@ function dataRequest(login,photoID,database,rootwindow) {
|
|||
var result = tx.executeSql('SELECT * from imageData where id = "'+obj["id"]+'"');
|
||||
if(result.rows.length === 1) {// use update
|
||||
print(obj["id"] +' exists, update it')
|
||||
result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+obj.id+'", created="'+obj.created+'", edited="'+obj.edited+'", profile="'+obj.profile+'", link="'+obj.source+'", filename="'+obj.filename+'",title="'+obj.title+'", desc="'+obj.desc+'", type="'+obj.type+'", width="'+obj.width+'", height="'+obj.height+'", album="'+obj.album+'", location="file://'+login.imagestore+'" where id="'+obj["id"]+'"');
|
||||
result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+obj.id+'", created="'+obj.created+'", edited="'+obj.edited+'", profile="'+obj.profile+'", link="'+obj["link"]["4"]+'", filename="'+obj.filename+'",title="'+obj.title+'", desc="'+obj.desc+'", type="'+obj.type+'", width="'+obj.width+'", height="'+obj.height+'", album="'+obj.album+'", location="file://'+login.imagestore+'albums/'+obj.album+'/" where id="'+obj["id"]+'"');
|
||||
} else {// use insert print('... does not exists, create it')
|
||||
result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,obj.id,obj.created,obj.edited, obj.title, obj.desc, obj.album, obj.filename, obj.type, obj.height, obj.width,obj. profile,obj.source,'file://'+login.imagestore]);
|
||||
result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,obj.id,obj.created,obj.edited, obj.title, obj.desc, obj.album, obj.filename, obj.type, obj.height, obj.width,obj. profile,obj["link"]["4"],'file://'+login.imagestore+'albums/'+obj.album+"/"]);
|
||||
print("Inserted");}
|
||||
})})}}
|
||||
catch (e){print("Data retrieval failure! "+ e+obj);}
|
||||
|
@ -63,18 +63,17 @@ function dataRequest(login,photoID,database,rootwindow) {
|
|||
|
||||
function saveImage(obj,storagedirectory,callback) {
|
||||
// create image component from base64 code and save it
|
||||
print("Storing "+storagedirectory+obj.filename+obj.width+"x"+obj.height);
|
||||
print("Storing "+storagedirectory+"/"+obj.filename+obj.width+"x"+obj.height);
|
||||
var maxSize=Math.max(fotostab.width,fotostab.height);
|
||||
var helpwidth=(obj.width<maxSize)?obj.width:maxSize;
|
||||
var helpheight=(obj.height<maxSize)?obj.height:maxSize;
|
||||
|
||||
if (obj.width>obj.height){ //landscape
|
||||
helpheight=helpwidth*obj.height/obj.width
|
||||
} else { //portrait
|
||||
helpwidth=helpheight*obj.width/obj.height
|
||||
}
|
||||
var component=Qt.createComponent("qrc:/qml/PhotoPlaceholder.qml");
|
||||
var sprite = component.createObject(fotostab, {"x":0,"y":0,"imageName":storagedirectory+obj.filename ,"width":helpwidth,"height":helpheight,"source": obj.source,"downloadtype":"picture"});
|
||||
var sprite = component.createObject(fotostab, {"x":0,"y":0,"imageName":storagedirectory+"/"+obj.filename ,"width":helpwidth,"height":helpheight,"source": obj["link"]["4"],"downloadtype":"picture"});
|
||||
callback(obj,sprite)
|
||||
}
|
||||
|
||||
|
@ -141,8 +140,8 @@ function initDatabase(database) { // initialize the database object
|
|||
print('... create table')
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS imageData(username TEXT,id INT, created TEXT,edited TEXT, title TEXT, desc TEXT, album TEXT,filename TEXT, type TEXT, height INT, width INT, profile INT, link TEXT,location TEXT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS config(server TEXT, username TEXT, password TEXT, imagestore TEXT, maxnews INT, timerInterval INT, newsViewType TEXT,isActive INT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS news(username TEXT, messagetype INT, text TEXT, created_at INT, in_reply_to_status_id INT, source TEXT, status_id INT, in_reply_to_user_id INT, geo TEXT,favorited TEXT, uid INT, statusnet_html TEXT, statusnet_conversation_id TEXT,like TEXT, dislike TEXT, attendyes TEXT,attendno TEXT, attendmaybe TEXT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS contacts(username TEXT, id INT, name TEXT, screen_name TEXT, location TEXT,description TEXT, profile_image BLOB, url TEXT, protected TEXT, followers_count INT, friends_count INT, created_at TEXT, favourites_count TEXT, utc_offset TEXT, time_zone TEXT, statuses_count INT, following TEXT, verified TEXT, statusnet_blocking TEXT, notifications TEXT, statusnet_profile_url TEXT, cid INT, network TEXT, isFriend INT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS news(username TEXT, messagetype INT, text TEXT, created_at INT, in_reply_to_status_id INT, source TEXT, status_id INT, in_reply_to_user_id INT, geo TEXT,favorited TEXT, uid INT, statusnet_html TEXT, statusnet_conversation_id TEXT,friendica_activities TEXT, friendica_activities_self TEXT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS contacts(username TEXT, id INT, name TEXT, screen_name TEXT, location TEXT,profile_image_url TEXT, description TEXT, profile_image BLOB, url TEXT, protected TEXT, followers_count INT, friends_count INT, created_at INT, favourites_count TEXT, utc_offset TEXT, time_zone TEXT, statuses_count INT, following TEXT, verified TEXT, statusnet_blocking TEXT, notifications TEXT, statusnet_profile_url TEXT, cid INT, network TEXT, isFriend INT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS groups(username TEXT, groupname TEXT, gid INT, members TEXT)');
|
||||
})}
|
||||
|
||||
|
|
0
v0.002/Develop/source-linux/qml/BlueButton.qml
Normal file
0
v0.002/Develop/source-linux/qml/BlueButton.qml
Normal file
|
@ -187,7 +187,8 @@ onCurrentIndexChanged:{
|
|||
if (errormessage=="") {
|
||||
filesystem.Directory=userconfig.imagestore;
|
||||
filesystem.makeDir("contacts");
|
||||
Service.storeConfig(db,userconfig);
|
||||
filesystem.makeDir("albums");
|
||||
Service.storeConfig(db,userconfig);
|
||||
Service.readConfig(db,function(userconfig){Service.getServerConfig(userconfig,configBackground, function(obj){
|
||||
var serverString=obj;
|
||||
var serverconfigObject=Qt.createQmlObject(serverString,configBackground,"serverconfigOutput");
|
||||
|
@ -236,13 +237,14 @@ onCurrentIndexChanged:{
|
|||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
try{Helperjs.readData(db,"config",root.login.username,function(users){
|
||||
try{print("get users");
|
||||
Helperjs.readData(db,"config","",function(users){
|
||||
users.sort(function(obj1, obj2) {
|
||||
return obj1.isActive - obj2.isActive;
|
||||
});
|
||||
for (var i=0; i<users.length;i++){
|
||||
if (users[i]) {usermodel.append({text:users[i].username});};
|
||||
};})}
|
||||
}})}
|
||||
catch (e){print(e)}
|
||||
}
|
||||
}
|
||||
|
|
137
v0.002/Develop/source-linux/qml/ContactComponent.qml
Normal file
137
v0.002/Develop/source-linux/qml/ContactComponent.qml
Normal file
|
@ -0,0 +1,137 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.3
|
||||
|
||||
Item {
|
||||
id: contactComponent
|
||||
property var createdAtDate: new Date(contact.created_at)
|
||||
property var linkUrl: contact.network!=="dfrn"?contact.url:contact.url.replace("profile","dfrn_request")
|
||||
Rectangle {
|
||||
id: wrapper
|
||||
width: 16*mm
|
||||
height: 15*mm
|
||||
border.color: "grey"
|
||||
color:"white"
|
||||
Image {
|
||||
id: photoImage
|
||||
x:1
|
||||
y:1
|
||||
width: 10*mm
|
||||
height:10*mm
|
||||
source:(contact.isFriend==1)? "file://"+contact.profile_image :contact.profile_image_url
|
||||
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
|
||||
}
|
||||
|
||||
Label {
|
||||
id: namelabel
|
||||
x: 1
|
||||
width: wrapper.width-4
|
||||
height: 3*mm
|
||||
text: contact.screen_name
|
||||
elide:Text.ElideRight
|
||||
anchors.topMargin: 0
|
||||
anchors.left: photoImage.left
|
||||
color: "#303030"
|
||||
font.pixelSize: 3*mm
|
||||
anchors.top: photoImage.bottom
|
||||
}
|
||||
Button{
|
||||
id:infobutton
|
||||
width: 5*mm
|
||||
height: 5*mm
|
||||
text:"?"
|
||||
anchors.left: photoImage.right
|
||||
anchors.leftMargin: 3
|
||||
anchors.topMargin: 3
|
||||
anchors.top: parent.top
|
||||
onClicked:{
|
||||
//print("State: "+ friendComponent.state);
|
||||
contactComponent.state="large"}
|
||||
}
|
||||
Rectangle{
|
||||
id: detailsrectangle
|
||||
anchors.top: namelabel.bottom
|
||||
anchors.topMargin: 2*mm
|
||||
opacity: 0
|
||||
|
||||
Flickable{
|
||||
id:namelabelflickable
|
||||
width: root.width-10*mm
|
||||
height:friendsTabView.height-55*mm
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
flickableDirection:Flickable.VerticalFlick
|
||||
contentWidth:width
|
||||
contentHeight: namelabeltext.height
|
||||
clip:true
|
||||
Text{
|
||||
id:namelabeltext
|
||||
//anchors.top: parent.top
|
||||
width: namelabelflickable.width
|
||||
height: implicitHeight
|
||||
font.pixelSize: 3*mm
|
||||
textFormat:Text.RichText
|
||||
wrapMode: Text.Wrap
|
||||
text:"<b>"+qsTr("Description")+": </b> "+Qt.atob(contact.description)+"<br> <b>"+qsTr("Server Type")+":</b> "+contact.location+"<br> <b>"+qsTr("Posts")+":</b> "+contact.statuses_count+
|
||||
"<br> <b>"+qsTr("URL")+":</b> <a href='"+ linkUrl+"'>"+linkUrl+"</a><br> <b>"+
|
||||
qsTr("Created at")+":</b> "+createdAtDate.toLocaleString(Qt.locale())
|
||||
onLinkActivated: {
|
||||
Qt.openUrlExternally(link)}
|
||||
}
|
||||
}
|
||||
|
||||
Row{
|
||||
anchors.top: namelabelflickable.bottom
|
||||
anchors.topMargin: 2*mm
|
||||
spacing:4
|
||||
|
||||
Button{
|
||||
id:photobutton
|
||||
text:"Photos"
|
||||
visible:contact.location=="Friendica"? 1:0
|
||||
onClicked:{contactComponent.state="";
|
||||
root.currentIndex=2;
|
||||
fotostab.active=true;
|
||||
root.fotoSignal(contact) ;
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
id:messagebutton
|
||||
text:"Messages"
|
||||
onClicked:{contactComponent.state="";
|
||||
root.currentIndex=0;
|
||||
newstab.active=true;
|
||||
root.messageSignal(contact.id) ;
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
id:dmbutton
|
||||
visible: contact.following=="true"?true:false
|
||||
text: "DM"
|
||||
onClicked:{contactComponent.state="";
|
||||
root.currentIndex=0;
|
||||
newstab.active=true;
|
||||
root.directmessageSignal(contact.screen_name);
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
id: closeButton
|
||||
text: "close"
|
||||
onClicked:{contactComponent.state=""}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
states: [
|
||||
State {
|
||||
name: "large"
|
||||
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsTabView.width-4*mm; text:Qt.atob(contact.name)+" (@"+contact.screen_name+")"}
|
||||
PropertyChanges { target: contactComponent; z: 2 }
|
||||
PropertyChanges { target: wrapper; width:friendsTabView.width-3*mm;height:friendsTabView.height-20*mm}
|
||||
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
|
||||
PropertyChanges { target:contactComponent.GridView.view;contentY:contactComponent.y;contentX:contactComponent.x;interactive:false}
|
||||
PropertyChanges { target: detailsrectangle; opacity:1 }
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import "qrc:/js/service.js" as Service
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
|
@ -17,17 +18,35 @@ Rectangle {
|
|||
tabPosition: Qt.TopEdge
|
||||
x:mm
|
||||
y:mm
|
||||
width: root.width-5*mm
|
||||
width: root.width-2*mm
|
||||
height: root.height-10*mm
|
||||
currentIndex: 0
|
||||
signal friendsSignal(var username)
|
||||
|
||||
signal contactsSignal(var username)
|
||||
signal groupsSignal(var username)
|
||||
onCurrentIndexChanged:{
|
||||
if (currentIndex==0){friendsSignal(root.login.username)}
|
||||
if (currentIndex==0){root.friendsSignal(root.login.username)}
|
||||
else if (currentIndex==1){contactsSignal(root.login.username)}
|
||||
else if (currentIndex==2){groupsSignal(root.login.username)}
|
||||
}
|
||||
style: TabViewStyle {
|
||||
frameOverlap: 1
|
||||
tab: Rectangle {
|
||||
color: "white"
|
||||
//border.color: "light grey"
|
||||
implicitWidth: root.width/3-2*mm
|
||||
implicitHeight: 4*mm
|
||||
Text { id: text
|
||||
anchors.centerIn: parent
|
||||
text: styleData.title
|
||||
color: "dark grey"
|
||||
font.pixelSize:2.5*mm
|
||||
font.bold: styleData.selected
|
||||
}
|
||||
}
|
||||
frame: Rectangle { color: "light grey" }
|
||||
tabsAlignment:Qt.AlignHCenter
|
||||
}
|
||||
|
||||
Tab{
|
||||
title: qsTr("Friends")
|
||||
|
@ -35,15 +54,16 @@ Rectangle {
|
|||
id: friendsGridTab
|
||||
function showFriends(username){
|
||||
try {friendsModel.clear()} catch(e){print(e)};
|
||||
Helperjs.readData(db,"contacts",username,function(friends){
|
||||
for (var i=0;i<friends.length;i++){
|
||||
friendsModel.append({"friend":friends[i]});
|
||||
Helperjs.readData(db,"contacts",username,function(friendsobject){
|
||||
for (var i=0;i<friendsobject.length;i++){
|
||||
friendsModel.append({"contact":friendsobject[i]});
|
||||
}},"isFriend",1)
|
||||
}
|
||||
Button {
|
||||
id: updateFriendsButton
|
||||
text: qsTr("Update")
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: mm
|
||||
anchors.right: parent.right
|
||||
onClicked: {
|
||||
try {friendsModel.clear()} catch(e){print(e)};
|
||||
|
@ -67,7 +87,7 @@ Rectangle {
|
|||
GridView {
|
||||
id: friendsView
|
||||
x:mm
|
||||
y:updateFriendsButton.height+mm
|
||||
y:updateFriendsButton.height+2*mm
|
||||
width:friendsGridTab.width-2*mm
|
||||
height:friendsGridTab.height-updateFriendsButton.height-2*mm
|
||||
clip: true
|
||||
|
@ -77,7 +97,7 @@ Rectangle {
|
|||
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
|
||||
}
|
||||
model: friendsModel
|
||||
delegate: FriendComponent { }
|
||||
delegate: ContactComponent { }
|
||||
}
|
||||
|
||||
ListModel{id:friendsModel}
|
||||
|
@ -85,7 +105,7 @@ Rectangle {
|
|||
|
||||
|
||||
Component.onCompleted: {
|
||||
friendsTabView.friendsSignal.connect(showFriends);
|
||||
root.friendsSignal.connect(showFriends);
|
||||
showFriends(root.login.username)
|
||||
}
|
||||
}
|
||||
|
@ -98,16 +118,16 @@ Rectangle {
|
|||
id: contactsGridTab
|
||||
function showContacts(username){
|
||||
try {contactsModel.clear()} catch(e){print(e)};
|
||||
Helperjs.readData(db, "contacts",root.login.username,function(friendsobject){
|
||||
for (var j=0;j<friendsobject.length;j++){
|
||||
contactsModel.append({"friend":friendsobject[j]});
|
||||
Helperjs.readData(db, "contacts",root.login.username,function(contactsobject){
|
||||
for (var j=0;j<contactsobject.length;j++){
|
||||
contactsModel.append({"contact":contactsobject[j]});
|
||||
}
|
||||
},"isFriend",0)}
|
||||
|
||||
GridView {
|
||||
id: contactsView
|
||||
x:mm
|
||||
y:mm
|
||||
y:2*mm
|
||||
width:contactsGridTab.width-2*mm
|
||||
height:contactsGridTab.height-2*mm
|
||||
clip: true
|
||||
|
@ -117,7 +137,7 @@ Rectangle {
|
|||
NumberAnimation { properties: "x,y"; from: 300; duration: 1000 }
|
||||
}
|
||||
model: contactsModel
|
||||
delegate: FriendComponent { }
|
||||
delegate: ContactComponent { }
|
||||
}
|
||||
|
||||
ListModel{id: contactsModel}
|
||||
|
@ -132,7 +152,6 @@ Rectangle {
|
|||
id: groupsGridTab
|
||||
function showGroups(username){
|
||||
try {groupsModel.clear()} catch(e){print(e)};
|
||||
print("showGroups"+username);
|
||||
Helperjs.readData(db, "groups",root.login.username,function(groupsobject){
|
||||
for (var j=0;j<groupsobject.length;j++){
|
||||
groupsModel.append({"group":groupsobject[j]});
|
||||
|
@ -141,6 +160,7 @@ Rectangle {
|
|||
id: updateGroupsButton
|
||||
text: qsTr("Update")
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: mm
|
||||
anchors.right: parent.right
|
||||
onClicked: {
|
||||
print("Update groups");
|
||||
|
@ -150,7 +170,7 @@ Rectangle {
|
|||
GridView {
|
||||
id: groupsView
|
||||
x:mm
|
||||
y:updateGroupsButton.height+mm
|
||||
y:updateGroupsButton.height+2*mm
|
||||
width:groupsGridTab.width-2*mm
|
||||
height:groupsGridTab.height-updateGroupsButton.height-2*mm
|
||||
clip: true
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.3
|
||||
import "qrc:/js/service.js" as Service
|
||||
import "qrc:/js/layout.js" as Layoutjs
|
||||
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
Item {
|
||||
id: groupComponent
|
||||
|
||||
Rectangle {
|
||||
id: wrapper
|
||||
width: 16*mm
|
||||
|
@ -13,6 +10,14 @@ import "qrc:/js/layout.js" as Layoutjs
|
|||
border.color: "grey"
|
||||
color:"white"
|
||||
|
||||
Image {
|
||||
id: photoImage
|
||||
x:1
|
||||
y:1
|
||||
width: 10*mm
|
||||
height:10*mm
|
||||
source:"qrc:/images/defaultcontact.jpg"
|
||||
}
|
||||
Label {
|
||||
id: namelabel
|
||||
x: 1
|
||||
|
@ -22,127 +27,92 @@ import "qrc:/js/layout.js" as Layoutjs
|
|||
|
||||
color: "#303030"
|
||||
font.pixelSize: 3*mm
|
||||
anchors.centerIn:parent
|
||||
anchors.top: photoImage.bottom
|
||||
}
|
||||
Button{
|
||||
id:infobutton
|
||||
width: 5*mm
|
||||
height: 5*mm
|
||||
text:"?"
|
||||
anchors.top: namelabel.bottom;anchors.topMargin: 3
|
||||
anchors.left: photoImage.right
|
||||
anchors.leftMargin: 3
|
||||
anchors.topMargin: 3
|
||||
anchors.top: parent.top
|
||||
onClicked:{
|
||||
print("State: "+ groupComponent.state+groupView.contentY);
|
||||
Helperjs.readField("members",root.db,"groups",root.login.username,function(groups){
|
||||
try {groupModel.clear()}catch (e){print(e)}
|
||||
var groupmembers=JSON.parse(groups);
|
||||
for (var user in groupmembers){
|
||||
Helperjs.readData(root.db,"contacts",root.login.username,function(userdata){
|
||||
groupModel.append({"groupmember":userdata[0]});
|
||||
},"id",groupmembers[user])}
|
||||
},"groupname",group.groupname);
|
||||
groupComponent.state="large"}
|
||||
}
|
||||
|
||||
|
||||
Rectangle{
|
||||
id: detailsrectangle
|
||||
anchors.top: infobutton.bottom
|
||||
anchors.top: namelabel.bottom
|
||||
anchors.topMargin: 2*mm
|
||||
opacity: 0
|
||||
|
||||
Component { id:footerComponent
|
||||
Rectangle{
|
||||
border.color: "#EEEEEE"
|
||||
border.width: 1
|
||||
width:parent.width
|
||||
height:6*mm
|
||||
Text{
|
||||
font.pixelSize: 3*mm
|
||||
anchors.centerIn: parent
|
||||
text:qsTr("+")
|
||||
}
|
||||
MouseArea{anchors.fill:parent
|
||||
onClicked:{var contactitems="";
|
||||
readData(db,"contacts",root.login.username, function(contacts){for (var i=0;i<contacts.length;i++){
|
||||
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"'; onTriggered: groupModel.append(' @"+contacts[i]+"')}"
|
||||
}},"isFriend",0)
|
||||
var menuString="import QtQuick.Controls 1.4; Menu {"+contactitems+"}";
|
||||
print("menustring: "+menuString);
|
||||
var contactlistObject=Qt.createQmlObject(menuString,messageSend,"contactmenuOutput");
|
||||
contactlistObject.popup();
|
||||
Newsjs.addToGroup
|
||||
}}}}
|
||||
|
||||
Component { id:groupMember
|
||||
Component { id:groupMember
|
||||
Rectangle{
|
||||
border.color: "#EEEEEE"
|
||||
border.width: 1
|
||||
width:parent.width
|
||||
height:6*mm
|
||||
Image {
|
||||
id: memberImage
|
||||
x:1
|
||||
y:1
|
||||
width: 5*mm
|
||||
height:5*mm
|
||||
source:(groupmember.isFriend==1)? "file://"+groupmember.profile_image :groupmember.profile_image_url
|
||||
onStatusChanged: if (photoImage.status == Image.Error) {source="qrc:/images/defaultcontact.jpg"}
|
||||
}
|
||||
Text{
|
||||
font.pixelSize: 3*mm
|
||||
anchors.left: parent.left
|
||||
text:groupmember.screen_name
|
||||
anchors.left: memberImage.right
|
||||
anchors.margins: 1*mm
|
||||
text:Qt.atob(groupmember.name)
|
||||
}
|
||||
}}
|
||||
|
||||
ListView{
|
||||
id:namelabeltext
|
||||
anchors.top: parent.top
|
||||
ListView{
|
||||
id: groupListView
|
||||
x:1
|
||||
//anchors.top: parent.top
|
||||
width: root.width-10*mm
|
||||
height:wrapper.height-20*mm
|
||||
height:groupsView.height -28*mm
|
||||
clip: true
|
||||
spacing: 0
|
||||
footer: footerComponent
|
||||
spacing: 2
|
||||
model: groupModel
|
||||
delegate: groupMember
|
||||
}
|
||||
|
||||
ListModel{id: groupModel}
|
||||
|
||||
}
|
||||
|
||||
Row{
|
||||
anchors.top: namelabeltext.bottom
|
||||
anchors.topMargin: 2*mm
|
||||
spacing:4
|
||||
|
||||
Button{
|
||||
id:photobutton
|
||||
text:"Photos"
|
||||
visible:friend.location=="Friendica"? 1:0
|
||||
onClicked:{root.currentIndex=2;
|
||||
fotostab.active=true;
|
||||
root.fotoSignal(friend) ;
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
id:messagebutton
|
||||
text:"Messages"
|
||||
onClicked:{root.currentIndex=0;
|
||||
newstab.active=true;
|
||||
root.messageSignal(friend.id) ;
|
||||
}
|
||||
}
|
||||
|
||||
Button{id:dmbutton
|
||||
visible: friend.following=="true"?true:false
|
||||
text: "DM"
|
||||
onClicked:{root.currentIndex=0;
|
||||
newstab.active=true;
|
||||
root.directmessageSignal(friend.screen_name);
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
id: closeButton
|
||||
text: "close"
|
||||
onClicked:{friendComponent.state=""}
|
||||
}
|
||||
}
|
||||
Button{
|
||||
id: closeButton
|
||||
anchors.top: groupListView.bottom
|
||||
x:1
|
||||
text: "close"
|
||||
onClicked:{groupComponent.state=""}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "large"
|
||||
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:friendsView.width; text:Qt.atob(friend.name)+" (@"+friend.screen_name+")"}
|
||||
PropertyChanges { target: friendComponent; z: 2 }
|
||||
PropertyChanges { target: wrapper; width:friendsView.width;height:friendsView.height -2*mm-1}
|
||||
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
|
||||
PropertyChanges { target:friendComponent.GridView.view ;contentY:friendComponent.y;contentX:friendComponent.x;interactive:false}
|
||||
PropertyChanges { target: detailsrectangle; opacity:1 }
|
||||
}
|
||||
name: "large"
|
||||
PropertyChanges { target: namelabel; font.pixelSize: 4*mm; width:groupsView.width}
|
||||
PropertyChanges { target: groupComponent; z: 2 }
|
||||
PropertyChanges { target: wrapper; width:groupsView.width;height:groupsView.height -2*mm-1}
|
||||
PropertyChanges { target: photoImage; width:15*mm;height:15*mm }
|
||||
PropertyChanges { target:groupComponent.GridView.view ;contentY:groupComponent.y;contentX:groupComponent.x;interactive:false}
|
||||
PropertyChanges { target: detailsrectangle; opacity:1 }
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ Rectangle{
|
|||
Text{id:infoBoxText
|
||||
textFormat: Text.RichText
|
||||
wrapMode: Text.Wrap
|
||||
text: "<b>Friendiqa v0.001 </b><br>Licensed under GPL 3<br> "+
|
||||
text: "<b>Friendiqa v0.002 </b><br>Licensed under GPL 3<br> "+
|
||||
"Sourcecode: <a href='https://github.com/LubuWest/Friendiqa'>https://github.com/LubuWest/Friendica</a><br>"+
|
||||
"C++ code by <a href='https://kirgroup.com/profile/fabrixxm'>Fabio</a><br>"+
|
||||
"QML and Javascript code by <a href='https://freunde.ma-nic.de/profile/marco'>Marco</a>"
|
||||
|
|
|
@ -5,18 +5,22 @@ import QtQml 2.2
|
|||
import QtQuick.Controls 1.3
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.LocalStorage 2.0
|
||||
//import "../qml"
|
||||
import "qrc:/js/service.js" as Service
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
import "qrc:/js/service.js" as Servicejs
|
||||
|
||||
Item{
|
||||
id:messageSend
|
||||
property var login
|
||||
property string parentId: ""
|
||||
property string reply_to_user:""
|
||||
property string attachImageURL: "";
|
||||
property int directmessage: 0;
|
||||
property var contacts: []
|
||||
// title: parentId !== "" ? qsTr("Reply to "+reply_to_user) : qsTr("New post")
|
||||
property var login
|
||||
property string parentId: ""
|
||||
property string reply_to_user:""
|
||||
property string attachImageURL: "";
|
||||
property int directmessage: 0;
|
||||
property var contacts: []
|
||||
property var groups: []
|
||||
property string contact_allow:""
|
||||
property string contact_deny:""
|
||||
property string group_allow:""
|
||||
property string group_deny:""
|
||||
|
||||
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
|
||||
xhr.url= login.server + "/api/statuses/update.xml";
|
||||
|
@ -46,7 +50,7 @@ Item{
|
|||
Column {
|
||||
id:messageColumn
|
||||
spacing: 2
|
||||
|
||||
width: parent.width
|
||||
TextField {
|
||||
id: titleField
|
||||
width: parent.width
|
||||
|
@ -59,8 +63,13 @@ Item{
|
|||
width: parent.width
|
||||
height: 30*mm
|
||||
wrapMode: TextEdit.Wrap
|
||||
textFormat: TextEdit.RichText
|
||||
}
|
||||
CheckBox{
|
||||
|
||||
Row{
|
||||
|
||||
spacing: 2
|
||||
CheckBox{
|
||||
id:dmCheckbox
|
||||
text:"DM"
|
||||
enabled: false
|
||||
|
@ -70,18 +79,59 @@ CheckBox{
|
|||
else if(dmCheckbox.checkedState==Qt.Unchecked){directmessage=0}
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
text:qsTr("Url")
|
||||
onClicked: {
|
||||
if(bodyField.selectedText==""){Helperjs.showMessage("Error","No text selected",messageSend)}
|
||||
else{urlTextEdit.text="";
|
||||
urlRectangle.visible=true}}
|
||||
}
|
||||
Rectangle{
|
||||
id:urlRectangle
|
||||
height:parent.height
|
||||
width:37*mm
|
||||
visible:false
|
||||
TextField{
|
||||
id:urlTextEdit
|
||||
width:30*mm
|
||||
height:parent.height
|
||||
}
|
||||
Button{
|
||||
anchors.left:urlTextEdit.right
|
||||
anchors.leftMargin:mm
|
||||
text:qsTr("\u2713")
|
||||
onClicked: {
|
||||
var start = bodyField.selectionStart;
|
||||
var end = bodyField.selectionEnd;
|
||||
var text = bodyField.getText(start,end);
|
||||
text = "<a href='"+urlTextEdit.text+"'>" + text + "</a>";
|
||||
bodyField.remove(start,end);
|
||||
bodyField.insert(start,text);
|
||||
urlRectangle.visible=false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Row{
|
||||
spacing:2
|
||||
Button {
|
||||
id: cancelButton
|
||||
text: qsTr("Cancel")
|
||||
onClicked: {newsStack.pop()}
|
||||
}
|
||||
|
||||
Button{
|
||||
text:qsTr("Permissions")
|
||||
onClicked: {
|
||||
var component = Qt.createComponent("qrc:/qml/PermissionDialog.qml");
|
||||
var sprite = component.createObject(messageColumn);
|
||||
if (sprite == null) { // Error Handling
|
||||
console.log("Error creating object"); }
|
||||
}}
|
||||
Button {
|
||||
id: attachButton
|
||||
text: qsTr("Attach")
|
||||
onClicked: {imageAttachmentDialog.open()}
|
||||
onClicked: {
|
||||
try{imageAttachment.visible=false;
|
||||
imageAttachment.opacity=0;imageAttachment.destroy()}catch(e){}
|
||||
imageAttachmentDialog.open()}
|
||||
}
|
||||
Button{
|
||||
id:contactButton
|
||||
|
@ -90,43 +140,49 @@ CheckBox{
|
|||
onClicked:{
|
||||
var contactitems="";
|
||||
for (var i=0;i<contacts.length;i++){
|
||||
contactitems=contactitems+"MenuItem{text:'"+contacts[i]+"'; onTriggered: bodyField.append(' @"+contacts[i]+"')}"
|
||||
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"'; onTriggered: bodyField.append(' @"+contacts[i].screen_name+"')}"
|
||||
}
|
||||
var menuString="import QtQuick.Controls 1.4; Menu {"+contactitems+"}";
|
||||
// print(menuString);
|
||||
var contactlistObject=Qt.createQmlObject(menuString,messageSend,"contactmenuOutput")
|
||||
contactlistObject.popup() }
|
||||
}
|
||||
|
||||
Button {
|
||||
id: sendButton
|
||||
text: qsTr("Send")
|
||||
onClicked: {
|
||||
print("login: "+login.server+login.username);
|
||||
if (directmessage==0){
|
||||
statusUpdate(titleField.text,bodyField.text,messageSend.parentId,attachImageURL.toString());}
|
||||
else {dmUpdate( titleField.text,bodyField.text,"",messageSend.reply_to_user) }
|
||||
newsStack.pop()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Row{
|
||||
spacing:2
|
||||
Button {
|
||||
id: cancelButton
|
||||
text: qsTr("Cancel")
|
||||
onClicked: {newsStack.pop()}
|
||||
}
|
||||
Button {
|
||||
id: sendButton
|
||||
text: qsTr("Send")
|
||||
onClicked: {
|
||||
//print("login: "+login.server+login.username);
|
||||
var title=titleField.text.replace("\"","\'");
|
||||
var body=bodyField.getText(0,bodyField.length);
|
||||
if (directmessage==0){
|
||||
statusUpdate(title,body,messageSend.parentId,attachImageURL.toString())}
|
||||
else {dmUpdate( title,body,"",messageSend.reply_to_user) }
|
||||
newsStack.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: imageAttachmentDialog
|
||||
title: "Please choose a picture"
|
||||
folder: shortcuts.pictures
|
||||
selectFolder: false
|
||||
onAccepted: {
|
||||
attachImageURL=imageAttachmentDialog.fileUrl;
|
||||
var imageAttachementObject=Qt.createQmlObject('import QtQuick 2.0; Image {source:"'+attachImageURL.toString()+'"; width: 30*mm; height: 30*mm;fillMode: Image.PreserveAspectFit}',messageColumn,"attachedImage");
|
||||
console.log("You chose: " + attachImageURL)
|
||||
id: imageAttachmentDialog
|
||||
title: "Please choose a picture"
|
||||
folder: shortcuts.pictures
|
||||
selectFolder: false
|
||||
onAccepted: {
|
||||
attachImageURL=imageAttachmentDialog.fileUrl;
|
||||
var imageAttachmentObject=Qt.createQmlObject('import QtQuick 2.0; Image {id:imageAttachment;source:"'+attachImageURL.toString()+'"; width: 15*mm; height: 15*mm;fillMode: Image.PreserveAspectFit}',messageColumn,"attachedImage");
|
||||
//console.log("You chose: " + attachImageURL)
|
||||
|
||||
}
|
||||
onRejected: {
|
||||
console.log("Canceled")
|
||||
//console.log("Canceled")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ Item {
|
|||
}
|
||||
|
||||
function onDirectMessage(friend){
|
||||
print(root.login.server);
|
||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": friend,"directmessage":1,"login":root.login}});
|
||||
}
|
||||
|
||||
|
@ -51,13 +52,43 @@ Item {
|
|||
width:root.width-2*mm
|
||||
height:root.height-8*mm
|
||||
|
||||
ComboBox{
|
||||
y:mm
|
||||
width: 8*mm
|
||||
model: ListModel{
|
||||
id: cbModel
|
||||
ListElement{text: qsTr("News")}
|
||||
ListElement{text: qsTr("Favorites")}
|
||||
}
|
||||
onCurrentIndexChanged:{
|
||||
if (currentIndex==0){newsModel.clear();
|
||||
Newsjs.newsfromdb(root.db,root.login.username, function(dbnews){
|
||||
showNews(dbnews)
|
||||
})}
|
||||
else if (currentIndex==1){
|
||||
newsBusy.running=true;
|
||||
Newsjs.requestFavorites(root.login,db,root,function(news){
|
||||
JSON.stringify("Favorites: "+news);
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
Newsjs.favoritesfromdb(db,root.login.username,function(newsarray){
|
||||
JSON.stringify("FavoritesArray: "+newsarray);showNews(newsarray)
|
||||
|
||||
});
|
||||
}
|
||||
)})
|
||||
}
|
||||
}}
|
||||
|
||||
Button {
|
||||
id: newMessageButton
|
||||
text: qsTr("+")
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
onClicked: {
|
||||
Helperjs.readField("screen_name",root.db,"contacts",root.login.username,function(friends){
|
||||
var groups=[];
|
||||
Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
|
||||
groups=groupobject});
|
||||
Helperjs.readData(root.db,"contacts",root.login.username,function(friends){
|
||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"contacts": friends,"login":root.login}})
|
||||
},"isFriend",1);
|
||||
}
|
||||
|
@ -150,6 +181,6 @@ Item {
|
|||
showNews(dbnews)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,13 @@ import QtQuick.LocalStorage 2.0
|
|||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
import "qrc:/js/layout.js" as Layoutjs
|
||||
|
||||
|
||||
Item {
|
||||
id: newsitem
|
||||
width: newsView.width
|
||||
height:Math.max((itemMessage.height+createdAtLabel.height+friendicaActivities.height+4*mm),profileImage.height+user_name.height+mm)
|
||||
height:Math.max((itemMessage.height+topFlow.height+friendicaActivities.height+4*mm),profileImage.height+user_name.height+mm)
|
||||
|
||||
// property var friendica_activities
|
||||
property string conversation_id: ""
|
||||
property string attending: ""
|
||||
onAttendingChanged: {attendLabel.visible=true;
|
||||
|
@ -23,7 +21,7 @@ Item {
|
|||
Rectangle{
|
||||
width:newsitem.width
|
||||
height:newsitem.height-1
|
||||
color: (newsitemobject.directmessage)?"#ffe6e6" : "white"
|
||||
color: (newsitemobject.messagetype==1)?"#ffe6e6" : "white"
|
||||
|
||||
Column {
|
||||
id: authorcolumn
|
||||
|
@ -31,7 +29,7 @@ Item {
|
|||
|
||||
Image {
|
||||
id:profileImage
|
||||
source: "file://"+newsitemobject.user.profile_image
|
||||
source:(newsitemobject.user.isFriend==1)? "file://"+newsitemobject.user.profile_image : newsitemobject.user.profile_image_url
|
||||
x:1
|
||||
width: 7*mm
|
||||
height: 7*mm
|
||||
|
@ -53,10 +51,13 @@ Item {
|
|||
}
|
||||
Column {
|
||||
id:newscolumn
|
||||
width: newsitem.width-8*mm
|
||||
anchors.left: authorcolumn.right
|
||||
|
||||
Row{
|
||||
spacing: 5*mm
|
||||
Flow{
|
||||
id:topFlow
|
||||
spacing: 2*mm
|
||||
width:parent.width
|
||||
Label {
|
||||
color: "grey"
|
||||
text: if (newsitemobject.messagetype==0){qsTr("Source: ")+newsitemobject.source
|
||||
|
@ -66,9 +67,9 @@ Item {
|
|||
Label {
|
||||
id:createdAtLabel
|
||||
color: "grey"
|
||||
height:3.5*mm
|
||||
font.pixelSize: 1.5*mm
|
||||
horizontalAlignment: Label.AlignRight
|
||||
height:3.5*mm
|
||||
font.pixelSize: 1.5*mm
|
||||
horizontalAlignment: Label.AlignRight
|
||||
text: dateDiff
|
||||
}
|
||||
CheckBox {
|
||||
|
@ -104,8 +105,53 @@ Item {
|
|||
{Newsjs.favorite(login,false,newsitemobject.status_id,root)}
|
||||
}
|
||||
}
|
||||
Rectangle{
|
||||
width: 4*mm
|
||||
height: 3*mm
|
||||
Text{
|
||||
id:newsmenusymbol
|
||||
color: "grey"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: 2*mm
|
||||
font.bold: true
|
||||
text: "\u22EE"
|
||||
}
|
||||
MouseArea{
|
||||
anchors.fill:parent
|
||||
onClicked: {newsmenu.popup()}}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
width: 4*mm
|
||||
height: 3*mm
|
||||
Text{
|
||||
id:conversationsymbol
|
||||
color: "grey"
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: 2*mm
|
||||
text: "\u21C4"
|
||||
}
|
||||
MouseArea{
|
||||
anchors.fill:parent
|
||||
onClicked: {
|
||||
newsBusy.running=true;
|
||||
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
|
||||
for (var i=0;i<newContacts.length;i++){
|
||||
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
||||
}
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
var currentTime= new Date();
|
||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||
newsModel.clear();
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
||||
newsWorker.sendMessage(msg);
|
||||
newsBusy.running=false
|
||||
});
|
||||
}
|
||||
)})
|
||||
}}
|
||||
}}
|
||||
|
||||
Text {
|
||||
color: "#404040"
|
||||
|
@ -116,10 +162,10 @@ Item {
|
|||
width: newsitem.width-8*mm-2
|
||||
height: implicitHeight
|
||||
wrapMode: Text.Wrap
|
||||
onLinkActivated:{ print("link "+link);
|
||||
Qt.openUrlExternally(link)}
|
||||
onLinkActivated:{
|
||||
Qt.openUrlExternally(link)}
|
||||
}
|
||||
Row{id: friendicaActivities
|
||||
Row{id:friendicaActivities
|
||||
spacing:mm
|
||||
Label{color: "grey"
|
||||
font.pixelSize: 1.5*mm
|
||||
|
@ -141,13 +187,13 @@ Item {
|
|||
font.pixelSize: 1.5*mm
|
||||
text: friendica_activities.attendmaybeText
|
||||
}
|
||||
}
|
||||
Row {
|
||||
}
|
||||
Row {
|
||||
CheckBox{id:likeCheckbox
|
||||
height:3*mm
|
||||
width:8*mm
|
||||
checked:(newsitemobject.liked==1)?true:false
|
||||
style: CheckBoxStyle {
|
||||
checked:(friendica_activities.self.liked)?true:false
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
implicitWidth: 7*mm
|
||||
implicitHeight: 3*mm
|
||||
|
@ -170,11 +216,11 @@ Row {
|
|||
else{Newsjs.like(root.login,root.db,0,"like",newsitemobject.status_id,root)}}
|
||||
}
|
||||
CheckBox{id: dislikeCheckbox
|
||||
height:3*mm
|
||||
width:8*mm
|
||||
checked: (newsitemobject.disliked==1)?true:false
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
height:3*mm
|
||||
width:8*mm
|
||||
checked: (friendica_activities.self.disliked)?true:false
|
||||
style: CheckBoxStyle {
|
||||
background: Rectangle {
|
||||
implicitWidth: 7*mm
|
||||
implicitHeight:3*mm
|
||||
color:"white"
|
||||
|
@ -211,7 +257,7 @@ Row {
|
|||
height:3.5*mm
|
||||
font.pixelSize: 1.5*mm
|
||||
horizontalAlignment: Label.AlignRight
|
||||
text: qsTr("attending: ")+ qsTr(attending)
|
||||
text: (friendica_activities.self.attending)?qsTr("attending: ")+ qsTr(attending):""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -221,10 +267,10 @@ Row {
|
|||
MenuItem {
|
||||
text: qsTr("Reply")
|
||||
onTriggered: {
|
||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_id}});
|
||||
newsStack.push({item:"qrc:/qml/MessageSend.qml",properties:{"reply_to_user": newsitemobject.user.screen_name,"parentId":newsitemobject.status_id,"login":root.login}});
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
MenuItem {
|
||||
text: qsTr("DM")
|
||||
onTriggered: {
|
||||
root.directmessageSignal(newsitemobject.user.screen_name);
|
||||
|
@ -241,16 +287,20 @@ MenuItem {
|
|||
MenuItem {
|
||||
text: qsTr("Conversation")
|
||||
onTriggered: {
|
||||
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root,function(){
|
||||
var currentTime= new Date();
|
||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||
Newsjs.requestConversation(root.login,db,newsitemobject.status_id,root.contactlist,root,function(news,newContacts){
|
||||
for (var i=0;i<newContacts.length;i++){
|
||||
root.updateContactInDB(root.login,root.db,0,newContacts[i])
|
||||
}
|
||||
Newsjs.storeNews(root.login,root.db,news,root,function(){
|
||||
var currentTime= new Date();
|
||||
Newsjs.conversationfromdb(db,root.login.username,newsitemobject.statusnet_conversation_id, function(newsarray){
|
||||
newsModel.clear();
|
||||
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsarray,'latestmessage':0};
|
||||
newsWorker.sendMessage(msg);
|
||||
});
|
||||
}
|
||||
)}
|
||||
}
|
||||
)})
|
||||
}}
|
||||
|
||||
Menu{
|
||||
title: qsTr("Attending")
|
||||
|
@ -275,8 +325,8 @@ Menu{
|
|||
MenuItem {
|
||||
text: qsTr("Delete")
|
||||
onTriggered: {
|
||||
Newsjs.deleteNews(root.login,db,newsitemobject.status_id,root,function(reply){
|
||||
print(JSON.stringify(reply));
|
||||
Newsjs.deleteNews(root.login,root.db,newsitemobject.status_id,root,function(reply){
|
||||
print("Deleted "+reply);
|
||||
newsModel.remove(index);
|
||||
})
|
||||
}
|
||||
|
|
126
v0.002/Develop/source-linux/qml/PermissionDialog.qml
Normal file
126
v0.002/Develop/source-linux/qml/PermissionDialog.qml
Normal file
|
@ -0,0 +1,126 @@
|
|||
import QtQuick 2.0
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQml.Models 2.1
|
||||
import "qrc:/js/service.js" as Service
|
||||
import "qrc:/js/helper.js" as Helperjs
|
||||
|
||||
Rectangle{
|
||||
id:permissionDialog
|
||||
width: 80*mm
|
||||
height:root.height/3
|
||||
|
||||
Text{
|
||||
x:0.5*mm
|
||||
y:0.5*mm
|
||||
text: "Contacts"
|
||||
}
|
||||
ListView {
|
||||
id: contactView
|
||||
x:0.5*mm
|
||||
y:5.5*mm
|
||||
width: 39*mm
|
||||
height:permissionDialog.height-14*mm
|
||||
clip: true
|
||||
spacing: 0
|
||||
model: contactModel
|
||||
delegate: contactItem
|
||||
}
|
||||
|
||||
ListModel{id: contactModel}
|
||||
Component{
|
||||
id:contactItem
|
||||
|
||||
Rectangle{
|
||||
id:contactitemRect
|
||||
width:contactView.width
|
||||
height: 5*mm
|
||||
property string contactstatus:""
|
||||
color: "light blue"
|
||||
border.color:"grey"
|
||||
Text{
|
||||
color:"grey"
|
||||
text:contact.screen_name
|
||||
}
|
||||
onContactstatusChanged:
|
||||
{ if(contactstatus=="positive"){contactsitemRect.color="green"} else if (contactstatus=="negative"){contactsitemRect.color= "red"} else{contactsitemRect.color= "white"}}
|
||||
MouseArea{
|
||||
anchors.fill: parent}
|
||||
}
|
||||
}
|
||||
Text{
|
||||
x:20*mm
|
||||
y:0.5*mm
|
||||
text: "Groups"
|
||||
}
|
||||
ListView {
|
||||
id: groupView
|
||||
x:20*mm
|
||||
y:5.5*mm
|
||||
width: 19*mm
|
||||
height:permissionDialog-8*mm
|
||||
clip: true
|
||||
spacing: 0
|
||||
model: groupModel
|
||||
delegate: groupItem
|
||||
}
|
||||
|
||||
ListModel{id: groupModel}
|
||||
Component{
|
||||
id:groupItem
|
||||
|
||||
Rectangle{
|
||||
id:groupitemRect
|
||||
width:groupView.width
|
||||
height: 5*mm
|
||||
property string groupstatus:""
|
||||
color: "white"
|
||||
border.color:"grey"
|
||||
Text{
|
||||
color:"grey"
|
||||
text:group.groupname
|
||||
}
|
||||
onGroupstatusChanged:
|
||||
{ if(groupstatus=="positive"){groupitemRect.color="green"} else if (groupstatus=="negative"){groupitemRect.color= "red"} else{groupitemRect.color= "white"}}
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
onClicked:{
|
||||
if(groupModel.get(index).groupstatus=="neutral"){
|
||||
groupModel.setProperty(index,"groupstatus","positive")}
|
||||
else if (groupModel.get(index).groupstatus=="positive"){
|
||||
groupModel.setProperty(index,"groupstatus","negative")}
|
||||
else{groupModel.setProperty(index,"groupstatus","neutral")}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
Button{
|
||||
anchors.horizontalCenter: parent.hoizontalCenter
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin:1
|
||||
text:qsTr("Done")
|
||||
onClicked:{var group_allow=[];
|
||||
for (var i=0;i<groupModel.count;i++)
|
||||
{if (groupModel.get(i).groupstatus=="positive"){
|
||||
group_allow.append(groupModel.get(i).groupname)
|
||||
}
|
||||
}
|
||||
print("groups"+JSON.stringify(group_allow))
|
||||
permissionDialog.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted:{
|
||||
print("permissiondialog completed");
|
||||
Helperjs.readData(db,"contacts",login.username,function(contacts){
|
||||
for (var name in contacts){
|
||||
print("contact: "+JSON.stringify(contacts[name]));
|
||||
contactModel.append({"contact":contacts[name]})
|
||||
}},"isFriend",1);
|
||||
|
||||
Helperjs.readData(db,"groups",login.username,function(owngroups){
|
||||
for (var number in owngroups){
|
||||
groupModel.append({"group":owngroup[number]})
|
||||
}});
|
||||
}
|
||||
}
|
|
@ -18,17 +18,42 @@ Rectangle {
|
|||
// photoWorker.sendMessage(msg);
|
||||
//}
|
||||
onNewImagesChanged:{
|
||||
Helperjs.readField("album",root.db,"imageData",root.login.username,function(albums){
|
||||
//print("albums"+JSON.stringify(albums)+JSON.stringify(newImages[currentImageNo]));
|
||||
if(albums.indexOf(newImages[currentImageNo].album)==-1){
|
||||
filesystem.Directory=root.login.imagestore+"/albums";
|
||||
filesystem.makeDir(newImages[currentImageNo].album);}
|
||||
});
|
||||
if(newImages.length>0){
|
||||
print("Current image number"+currentImageNo)
|
||||
Service.dataRequest(root.login,newImages[currentImageNo].id,root.db,fotorectangle);
|
||||
newImagesProgress.visible=true //download first image
|
||||
}}
|
||||
|
||||
onCurrentImageNoChanged:{
|
||||
if(currentImageNo<newImages.length){Service.dataRequest(root.login,newImages[currentImageNo].id,root.db,fotorectangle)};
|
||||
if(currentImageNo==newImages.length){newImagesProgress.visible=false;showOwnFotos();
|
||||
newImages=[];currentImageNo=0}
|
||||
// download next image if photoplaceholder is finished saving
|
||||
// download next image if photoplaceholder is finished saving
|
||||
}
|
||||
|
||||
function showOwnFotos(){
|
||||
try {photogroupModel.clear()}catch (e){print(e)}
|
||||
Helperjs.readField("album",root.db, "imageData",root.login.username,function(albums){
|
||||
if (albums[0]) {
|
||||
var msg = { 'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture': false};
|
||||
photoWorker.sendMessage(msg);
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
function onFriendsFotos(friend){print("Friend "+friend.url);
|
||||
try {photogroupModel.clear()}catch (e){print(e)}
|
||||
Service.requestFriendsAlbumPictures(friend,fotostab,function(albums){
|
||||
var msg = {'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture':true};
|
||||
photoWorker.sendMessage(msg);
|
||||
})
|
||||
}
|
||||
|
||||
ProgressBar{
|
||||
id: newImagesProgress
|
||||
|
@ -118,23 +143,5 @@ Button {
|
|||
ListView {anchors.fill: parent; model: visualphotoModel.parts.fullscreen; interactive: false }
|
||||
WorkerScript{id: photoWorker;source: "qrc:/js/photoworker.js"}
|
||||
|
||||
function showOwnFotos(){
|
||||
try {photogroupModel.clear()}catch (e){print(e)}
|
||||
Helperjs.readField("album",root.db, "imageData",root.login.username,function(albums){
|
||||
if (albums[0]) {
|
||||
var msg = { 'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture': false};
|
||||
photoWorker.sendMessage(msg);
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
function onFriendsFotos(friend){print("Friend "+friend.url);
|
||||
try {photogroupModel.clear()}catch (e){print(e)}
|
||||
Service.requestFriendsAlbumPictures(friend,fotostab,function(albums){
|
||||
var msg = {'model': photogroupModel,'albums':albums,'firstalbum':0,'foreignPicture':true};
|
||||
photoWorker.sendMessage(msg);
|
||||
})
|
||||
}
|
||||
|
||||
Component.onCompleted: { root.fotoSignal.connect(onFriendsFotos);}
|
||||
Component.onCompleted: { root.fotoSignal.connect(onFriendsFotos);}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import QtQuick.LocalStorage 2.0
|
|||
import QtQuick.Window 2.0
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
import QtQml.Models 2.1
|
||||
import "qrc:/js/news.js" as Newsjs
|
||||
|
@ -26,7 +27,7 @@ TabView{
|
|||
signal fotoSignal(var friend)
|
||||
signal directmessageSignal(var friend)
|
||||
signal newsSignal(var news)
|
||||
|
||||
signal friendsSignal(var username)
|
||||
|
||||
currentIndex: (login=="")? 3:0
|
||||
|
||||
|
@ -39,11 +40,11 @@ TabView{
|
|||
newsSignal(dbnews)
|
||||
})}
|
||||
onNewContactsChanged:{if(newContacts.length>0){// download first contact image and update db
|
||||
print("newcontact"+JSON.stringify(newContacts[0]));
|
||||
// print("newcontact"+JSON.stringify(newContacts));
|
||||
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
||||
}
|
||||
onCurrentContactChanged:{// download next contact image after photoplaceholder is finished saving and update db
|
||||
print("Current contact"+JSON.stringify(newContacts[currentContact]));
|
||||
//print("Current contact"+JSON.stringify(newContacts[currentContact]));
|
||||
if(currentContact<newContacts.length){
|
||||
updateContactInDB(login,db,newContacts[currentContact].isFriend,newContacts[currentContact])}
|
||||
else if(currentContact==newContacts.length){//newImagesProgress.visible=false;
|
||||
|
@ -66,25 +67,56 @@ TabView{
|
|||
}
|
||||
|
||||
function updateContactInDB(login,database,isFriend,contact){// for newstab and friendstab
|
||||
try{var imagename=login.imagestore+"contacts/"+contact.screen_name+".jpg";
|
||||
var component=Qt.createComponent("qrc:/qml/PhotoPlaceholder.qml");
|
||||
print("imageName "+imagename+" source "+ contact.profile_image_url)
|
||||
var sprite = component.createObject(root, {"fillMode": "Image.PreserveAspectFit","x":root.width,"y":50,"imageName":imagename,"source": contact.profile_image_url,"downloadtype":"contact"});} catch(e){print("Fehler beim Profilbild"+e)}
|
||||
var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+".jpg";
|
||||
if (isFriend==1){
|
||||
xhr.setUrl(Qt.resolvedUrl(contact.profile_image_url));
|
||||
xhr.setFilename(imagename);
|
||||
xhr.download();
|
||||
}
|
||||
var db=LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
var result;
|
||||
db.transaction( function(tx) {
|
||||
result = tx.executeSql('SELECT * from contacts where id = '+contact.id); // check for news id
|
||||
if(result.rows.length === 1) {// use update
|
||||
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'",description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Newsjs.cleanDate(contact.created_at)+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where id='+contact.id);
|
||||
result = tx.executeSql('UPDATE contacts SET username="'+login.username+'", id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'", profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", url="'+contact.url+'" , protected="'+contact.protected+'", followers_count='+contact.followers_count+', friends_count='+contact.friends_count+', created_at="'+ Date.parse(Newsjs.cleanDate(contact.created_at))+'", favourites_count="'+contact.favorites_count+'", utc_offset="'+contact.utc_offset+'", time_zone="'+contact.time_zone+'", statuses_count='+contact.statuses_count+', following="'+contact.following+'", verified ="'+contact.verified+'", statusnet_blocking="'+contact.statusnet_blocking+'", notifications="'+contact.notifictions+'", statusnet_profile_url="'+contact.statusnet_profile_url+'", cid='+contact.cid+', network="'+contact.network+'", isFriend='+isFriend+' where id='+contact.id);
|
||||
} else {// use insert
|
||||
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,Qt.btoa(contact.description),imagename,contact.url,contact.protected,contact.followers_count, contact.friends_count,Newsjs.cleanDate(contact.created_at),contact.favorites_count,contact.utc_offset,contact.time_zone,contact.statuses_count,contact.following,contact.verfied,contact.statusnet_blocking,contact.notifications,contact.statusnet_profile_url,contact.cid,contact.network,isFriend]);}
|
||||
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,contact.profile_image_url, Qt.btoa(contact.description),imagename,contact.url,contact.protected,contact.followers_count, contact.friends_count,Date.parse(Newsjs.cleanDate(contact.created_at)),contact.favorites_count,contact.utc_offset,contact.time_zone,contact.statuses_count,contact.following,contact.verfied,contact.statusnet_blocking,contact.notifications,contact.statusnet_profile_url,contact.cid,contact.network,isFriend]);}
|
||||
});
|
||||
if (isFriend!=1){root.currentContact=root.currentContact+1}
|
||||
}
|
||||
|
||||
Connections{
|
||||
target:xhr
|
||||
onDownloaded:{root.currentContact=root.currentContact+1}
|
||||
}
|
||||
Connections{
|
||||
target:xhr
|
||||
onError:{print("Error"+data)}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
if (login==""){Service.initDatabase(db)}
|
||||
Helperjs.readField("id",db,"contacts",login.username,function(contacts){contactlist=contacts},"isFriend",1)
|
||||
}
|
||||
|
||||
|
||||
style: TabViewStyle {
|
||||
frameOverlap: 1
|
||||
tab: Rectangle {
|
||||
color: styleData.selected?"white":"light blue"
|
||||
border.color: "light grey"
|
||||
implicitWidth: root.width/4-2*mm
|
||||
implicitHeight: 4*mm
|
||||
Text { id: text
|
||||
anchors.centerIn: parent
|
||||
text: styleData.title
|
||||
color: "black"
|
||||
font.pixelSize:3*mm
|
||||
font.bold: styleData.selected
|
||||
}
|
||||
}
|
||||
frame: Rectangle { color: "light grey" }
|
||||
tabsAlignment:Qt.AlignHCenter
|
||||
}
|
||||
Tab{
|
||||
title: qsTr("News")
|
||||
id: newstab
|
||||
|
|
Loading…
Reference in a new issue