Friendiqa v0.2
This commit is contained in:
parent
74fb551755
commit
a3be940192
123 changed files with 9156 additions and 2455 deletions
|
@ -1,3 +1,33 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations including
|
||||
// the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for all
|
||||
// of the code used other than OpenSSL. If you modify file(s) with this
|
||||
// exception, you may extend this exception to your version of the
|
||||
// file(s), but you are not obligated to do so. If you do not wish to do
|
||||
// so, delete this exception statement from your version. If you delete
|
||||
// this exception statement from all source files in the program, then
|
||||
// also delete it here.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
WorkerScript.onMessage = function(msg) {
|
||||
msg.model.clear();
|
||||
for (var j=0;j<msg.albums.length;j++){
|
||||
|
|
|
@ -1,3 +1,34 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations including
|
||||
// the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for all
|
||||
// of the code used other than OpenSSL. If you modify file(s) with this
|
||||
// exception, you may extend this exception to your version of the
|
||||
// file(s), but you are not obligated to do so. If you do not wish to do
|
||||
// so, delete this exception statement from your version. If you delete
|
||||
// this exception statement from all source files in the program, then
|
||||
// also delete it here.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
.pragma library
|
||||
.import QtQuick.LocalStorage 2.0 as Sql
|
||||
|
||||
|
@ -64,6 +95,20 @@ function friendicaWebRequest(url,rootwindow,callback) {
|
|||
xhrequest.send();
|
||||
}
|
||||
|
||||
function friendicaRemoteAuthRequest(login,url,c_url,rootwindow,callback) {
|
||||
var xhrequest = new XMLHttpRequest();
|
||||
xhrequest.onreadystatechange = function() {
|
||||
if (xhrequest.readyState === XMLHttpRequest.HEADERS_RECEIVED) {}
|
||||
else if(xhrequest.readyState === XMLHttpRequest.DONE) {
|
||||
try{callback(xhrequest.responseText)}
|
||||
catch (e){showMessage("Error",url+" "+e+"\n Return: "+xhrequest.responseText, rootwindow)}
|
||||
}
|
||||
}
|
||||
xhrequest.open("GET", login.server+"/api/friendica/remoteauth?c_url="+c_url+"&url="+url,true,login.username,Qt.atob(login.password));
|
||||
xhrequest.send();
|
||||
}
|
||||
|
||||
|
||||
function readData(database,table,username,callback,filter,filtervalue, sort) { // reads and applies data from DB
|
||||
if (filter){
|
||||
var where = " AND "+ filter +" = '" + filtervalue+"'";
|
||||
|
@ -107,7 +152,8 @@ var where = " AND "+ filter +" = '" + filtervalue+"'";
|
|||
}
|
||||
|
||||
function showMessage(header,message,rootwindow){//print("message: "+message);
|
||||
var cleanmessage=message.replace(/"/g,"-");
|
||||
var cleanmessage=message.replace(/"/g,"-"); //print(cleanmessage);
|
||||
if(cleanmessage.length>200){cleanmessage=cleanmessage.slice(0,200)+'...'}
|
||||
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");
|
||||
}
|
||||
|
|
272
source-android/js/image.js
Normal file
272
source-android/js/image.js
Normal file
|
@ -0,0 +1,272 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations including
|
||||
// the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for all
|
||||
// of the code used other than OpenSSL. If you modify file(s) with this
|
||||
// exception, you may extend this exception to your version of the
|
||||
// file(s), but you are not obligated to do so. If you do not wish to do
|
||||
// so, delete this exception statement from your version. If you delete
|
||||
// this exception statement from all source files in the program, then
|
||||
// also delete it here.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
.pragma library
|
||||
.import QtQuick.LocalStorage 2.0 as Sql
|
||||
.import "qrc:/js/helper.js" as Helperjs
|
||||
|
||||
function requestList(login,database,onlynew,rootwindow,callback) {
|
||||
//get list of own images and call download function
|
||||
Helperjs.friendicaRequest(login,"/api/friendica/photos/list", rootwindow,function (helperobject){
|
||||
//print("return"+helperobject);
|
||||
var obj=JSON.parse(helperobject);
|
||||
if (onlynew){Helperjs.readField("id",database,"imageData",login.username,function(AllStoredImages){
|
||||
if (AllStoredImages.length>0){
|
||||
for(var i=0;i< AllStoredImages.length;i++){
|
||||
var position=Helperjs.inArray(obj,"id",AllStoredImages[i]);
|
||||
if (position>-1){obj.splice(position,1)}
|
||||
}
|
||||
}
|
||||
callback(obj)
|
||||
})}
|
||||
else{callback(obj)}
|
||||
})}
|
||||
|
||||
function dataRequest(login,photoID,database,xhr,rootwindow) {
|
||||
// check if image exist and call download function
|
||||
Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photoID, rootwindow, function (image){
|
||||
try{ if(image==""){currentimageno=currentimageno+1}else{
|
||||
var obj = JSON.parse(image);
|
||||
var helpfilename=obj.filename.substring(0,obj.filename.lastIndexOf("."));
|
||||
var filesuffix="";
|
||||
if (obj.type=="image/jpeg"){filesuffix=".jpg"}
|
||||
else if (obj.type=="image/png"){filesuffix=".png"}
|
||||
else {filesuffix=""}
|
||||
if (helpfilename==""){// check if file has any filename
|
||||
obj.filename=obj["id"]+filesuffix;
|
||||
}
|
||||
else{obj.filename=helpfilename+filesuffix}
|
||||
var link="";
|
||||
if(obj["link"][0]){link=obj["link"][0]} else{link=obj["link"]["4"]}
|
||||
xhr.setUrl(Qt.resolvedUrl(link));
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
xhr.setFilename(login.imagestore+'albums/'+obj.album+"/"+obj["filename"]);
|
||||
xhr.setDownloadtype("picture");
|
||||
xhr.download();
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('SELECT * from imageData where id = "'+obj["id"]+'"');
|
||||
if(result.rows.length === 1) {// use update
|
||||
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["link"]["4"],'file://'+login.imagestore+'albums/'+obj.album+"/"]);
|
||||
}
|
||||
})}}
|
||||
catch (e){print("Data retrieval failure! "+ e+obj);}
|
||||
})}
|
||||
|
||||
function storeImagedata(login,database,imagedata,rootwindow) {
|
||||
// check if image exist and call download function
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('SELECT * from imageData where id = "'+imagedata["id"]+'"');
|
||||
if(result.rows.length === 1) {// use update
|
||||
result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+imagedata.id+'", created="'+imagedata.created+'", edited="'+imagedata.edited+'", profile="'+imagedata.profile+'", link="'+imagedata.link[0]+'", filename="'+imagedata.filename+'",title="'+imagedata.title+'", desc="'+imagedata.desc+'", type="'+imagedata.type+'", width="'+imagedata.width+'", height="'+imagedata.height+'", album="'+imagedata.album+'", location="file://'+login.imagestore+'albums/'+imagedata.album+'/" where id="'+imagedata["id"]+'"');
|
||||
} else {// use insert print('... does not exists, create it')
|
||||
result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,imagedata.id,imagedata.created,imagedata.edited, imagedata.title, imagedata.desc, imagedata.album, imagedata.filename, imagedata.type, imagedata.height, imagedata.width,imagedata. profile,imagedata.link[0],'file://'+login.imagestore+'albums/'+imagedata.album+"/"]);
|
||||
}
|
||||
})}
|
||||
|
||||
function deleteImage(database,login,type,location,filesystem,rootwindow,callback) { // delete image locally and on server
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
var rsfilename=location.substring(location.lastIndexOf("/")+1,location.length);
|
||||
var rslocation=location.substring(0,location.lastIndexOf("/")+1);
|
||||
//print(type+" Name "+ rsfilename+" Location: "+rslocation)
|
||||
db.transaction( function(tx) {
|
||||
if (type=='image'){
|
||||
var rs= tx.executeSql('SELECT * FROM imageData WHERE filename="'+rsfilename+'" AND location="'+rslocation+'"')
|
||||
var imageId=rs.rows.item(0).id;
|
||||
Helperjs.friendicaPostRequest(login,"/api/friendica/photo/delete?photo_id="+imageId,"","DELETE",rootwindow, function (obj){
|
||||
//var deletereturn = JSON.parse(obj); print(obj);
|
||||
//if (deletereturn.result=="deleted"){
|
||||
db.transaction( function(tx) {
|
||||
var deleters=tx.executeSql('DELETE FROM imageData WHERE location="'+rslocation+'" AND filename="'+rsfilename+'"'); });
|
||||
filesystem.Directory=rslocation.substring(7,rslocation.length-1);
|
||||
filesystem.rmFile(rsfilename)
|
||||
//}
|
||||
})
|
||||
}
|
||||
else{
|
||||
Helperjs.friendicaPostRequest(login,"/api/friendica/photoalbum/delete?album="+rsfilename,"","DELETE",rootwindow, function (obj){
|
||||
//var deletereturn = JSON.parse(obj);
|
||||
//if (deletereturn.result=="deleted"){
|
||||
db.transaction( function(tx) {
|
||||
var rs= tx.executeSql('SELECT DISTINCT location FROM imageData WHERE album="'+rsfilename+'" AND username="'+login.username+'"');
|
||||
var locationstring=rs.rows.item(0).location;
|
||||
filesystem.Directory=locationstring.substring(7,locationstring.length-1);
|
||||
filesystem.rmDir();
|
||||
var deleters=tx.executeSql('DELETE FROM imageData WHERE album="'+location+'"');
|
||||
})
|
||||
//}
|
||||
})
|
||||
}
|
||||
callback(location)
|
||||
})
|
||||
}
|
||||
|
||||
function deleteContacts(database,user,callback) { // does nothing useful at the moment
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
//print(' delete Image Data() for ' + field +"="+selection)
|
||||
db.transaction( function(tx) {
|
||||
result1= tx.executeSql('SELECT * FROM contacts a LEFT OUTER JOIN news b ON a.url==b.uid');
|
||||
result2= tx.executeSql('SELECT * FROM contacts a LEFT OUTER JOIN news b ON a.url==b.uid');
|
||||
callback(result)})
|
||||
}
|
||||
|
||||
//function requestFriendsAlbumPictures(login,friend,rootwindow,callback){
|
||||
//// screenscraping of albums page of contact without user and password
|
||||
// Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){
|
||||
// //print(photohtml);
|
||||
// var photoarray=[];
|
||||
// var arr = photohtml.split("sidebar-photos-albums-li");
|
||||
// for (var i=2;i<arr.length;i++){
|
||||
// var albumlink = arr[i].substring(arr[i].indexOf('http'),arr[i].indexOf('class')-2);
|
||||
// var albumname=arr[i].substring(arr[i].indexOf('/span')+6,arr[i].indexOf('</a>')-1);
|
||||
// var album={'link':albumlink,'name':albumname}
|
||||
// photoarray.push(album);
|
||||
// }
|
||||
// callback(photoarray)
|
||||
// })
|
||||
//}
|
||||
|
||||
function newRequestFriendsAlbumPictures(login,friend,rootwindow,callback){
|
||||
// screenscraping of albums page of contact with remoteAuth
|
||||
Helperjs.friendicaRemoteAuthRequest(login,friend.url.replace("profile","photos"),friend.url,rootwindow,function(photohtml){
|
||||
//print("Photohtml: "+photohtml);
|
||||
try {var obj=JSON.parse(photohtml);
|
||||
if (obj.hasOwnProperty('status')){
|
||||
Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){
|
||||
getAlbumFromHtml(photohtml,false,rootwindow,callback)})
|
||||
}}
|
||||
catch (e){
|
||||
getAlbumFromHtml(photohtml,true,rootwindow,callback)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getAlbumFromHtml(photohtml,remoteAuthBool,rootwindow,callback){
|
||||
var photoarray=[];
|
||||
var arr = photohtml.split("sidebar-photos-albums-li");
|
||||
for (var i=2;i<arr.length;i++){
|
||||
var albumlink = arr[i].substring(arr[i].indexOf('http'),arr[i].indexOf('class')-2);
|
||||
var albumname=arr[i].substring(arr[i].indexOf('/span')+6,arr[i].indexOf('</a>')-1);
|
||||
var album={'link':albumlink,'name':albumname}//print(albumlink+" "+albumname);
|
||||
photoarray.push(album);
|
||||
}
|
||||
callback(photoarray,remoteAuthBool)
|
||||
}
|
||||
|
||||
|
||||
function newRequestFriendsPictures(login,link,friend,remoteAuthBool,remoteauth,rootwindow,callback){
|
||||
// screenscraping of pictures page for given album
|
||||
if (remoteAuthBool){
|
||||
remoteauth.setUrl(login.server);
|
||||
remoteauth.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
remoteauth.setContacturl(friend.url);
|
||||
Helperjs.friendicaRemoteAuthRequest(login,link,friend.url,rootwindow,function(photohtml){
|
||||
getPictureFromHtml(photohtml,remoteAuthBool,function(photoarray){
|
||||
callback(photoarray)
|
||||
})
|
||||
})}
|
||||
else{
|
||||
Helperjs.friendicaWebRequest(link,rootwindow,function(photohtml){
|
||||
getPictureFromHtml(photohtml,remoteAuthBool,function(photoarray){
|
||||
callback(photoarray)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function getPictureFromHtml(photohtml,remoteAuthBool,callback){
|
||||
var photoarray=[];
|
||||
var basehtml=photohtml.substring(photohtml.indexOf('<base')+12,photohtml.indexOf('/>',photohtml.indexOf('<base'))-2);
|
||||
|
||||
// old theme
|
||||
if (photohtml.indexOf("photo-album-image-wrapper-end")>-1){ //theme 1
|
||||
var arr = photohtml.split("photo-album-image-wrapper-end");}
|
||||
|
||||
// other themes
|
||||
if (photohtml.indexOf("photo-album-wrapper")>-1){ //theme 2
|
||||
var photoarea=photohtml.substring(photohtml.indexOf("photo-album-wrapper"),photohtml.indexOf("photo-album-end"))
|
||||
var arr = photoarea.split("</a>");}
|
||||
//print("Url: "+login.server+ "Contacturl: "+friend.url)
|
||||
// remoteauth.setUrl(login.server);
|
||||
// remoteauth.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
// remoteauth.setContacturl(friend.url);
|
||||
for (var i=0;i<arr.length-1;i++){
|
||||
var photoname=arr[i].substring(arr[i].lastIndexOf('alt')+5,arr[i].lastIndexOf('title')-2);
|
||||
var thumblink=arr[i].substring(arr[i].lastIndexOf('<img')+10,arr[i].lastIndexOf('alt')-2);
|
||||
var imagetype=thumblink.substring(thumblink.lastIndexOf("."));
|
||||
var photolink=thumblink.substring(0,thumblink.length-imagetype.length-2)+"-0"+imagetype
|
||||
if(thumblink.substring(0,4)!=="http"){thumblink=basehtml+thumblink}
|
||||
if(photolink.substring(0,4)!=="http"){photolink=basehtml+photolink}
|
||||
if(remoteAuthBool){
|
||||
thumblink="image://remoteauthimage/"+thumblink;
|
||||
photolink="image://remoteauthimage/"+photolink;
|
||||
}
|
||||
//Helperjs.friendicaRemoteAuthRequest(login,thumblink,friend.url,rootwindow,function(thumbimage){thumbbase64=QT.btoa(thumbimage)});
|
||||
//thumblink="image://remoteauthimage/"+login.username+":"+Qt.atob(login.password)+"@"+login.server+"/api/friendica/remoteauth?c_url="+friend.url+"&url="+thumblink;
|
||||
var photo={'link':photolink,'name':photoname,'thumb':thumblink}
|
||||
photoarray.push(photo);
|
||||
}
|
||||
callback(photoarray)
|
||||
}
|
||||
|
||||
|
||||
function requestFriendsPictures(link,rootwindow,callback){
|
||||
// screenscraping of pictures page for given album
|
||||
Helperjs.friendicaWebRequest(link,rootwindow,function(photohtml){
|
||||
var photoarray=[];
|
||||
var basehtml=photohtml.substring(photohtml.indexOf('<base')+12,photohtml.indexOf('/>',photohtml.indexOf('<base'))-2);
|
||||
|
||||
// old theme
|
||||
if (photohtml.indexOf("photo-album-image-wrapper-end")>-1){ //theme 1
|
||||
var arr = photohtml.split("photo-album-image-wrapper-end");}
|
||||
|
||||
// other themes
|
||||
if (photohtml.indexOf("photo-album-wrapper")>-1){ //theme 2
|
||||
var photoarea=photohtml.substring(photohtml.indexOf("photo-album-wrapper"),photohtml.indexOf("photo-album-end"))
|
||||
var arr = photoarea.split("</a>");}
|
||||
|
||||
for (var i=0;i<arr.length-1;i++){
|
||||
var photoname=arr[i].substring(arr[i].lastIndexOf('alt')+5,arr[i].lastIndexOf('title')-2);
|
||||
var thumblink=arr[i].substring(arr[i].lastIndexOf('<img')+10,arr[i].lastIndexOf('alt')-2);
|
||||
var imagetype=thumblink.substring(thumblink.lastIndexOf("."));
|
||||
var photolink=thumblink.substring(0,thumblink.length-imagetype.length-2)+"-0"+imagetype
|
||||
if(thumblink.substring(0,4)!=="http"){thumblink=basehtml+thumblink}
|
||||
if(photolink.substring(0,4)!=="http"){photolink=basehtml+photolink}
|
||||
var photo={'link':photolink,'name':photoname,'thumb':thumblink}
|
||||
photoarray.push(photo);
|
||||
}
|
||||
callback(photoarray)
|
||||
})
|
||||
}
|
||||
|
|
@ -1,3 +1,34 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations including
|
||||
// the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for all
|
||||
// of the code used other than OpenSSL. If you modify file(s) with this
|
||||
// exception, you may extend this exception to your version of the
|
||||
// file(s), but you are not obligated to do so. If you do not wish to do
|
||||
// so, delete this exception statement from your version. If you delete
|
||||
// this exception statement from all source files in the program, then
|
||||
// also delete it here.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
function showFriends(db) {
|
||||
Service.readActiveConfig(db,function(login){
|
||||
Service.requestFriends(login.url,login.user,login.password,displayFriends);
|
||||
|
|
|
@ -1,3 +1,34 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations including
|
||||
// the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for all
|
||||
// of the code used other than OpenSSL. If you modify file(s) with this
|
||||
// exception, you may extend this exception to your version of the
|
||||
// file(s), but you are not obligated to do so. If you do not wish to do
|
||||
// so, delete this exception statement from your version. If you delete
|
||||
// this exception statement from all source files in the program, then
|
||||
// also delete it here.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
.pragma library
|
||||
.import QtQuick.LocalStorage 2.0 as Sql
|
||||
.import "qrc:/js/helper.js" as Helperjs
|
||||
|
@ -10,10 +41,14 @@ function requestFriends(login,database,rootwindow,callback){
|
|||
Helperjs.friendicaRequest(login,"/api/statuses/friends", rootwindow,function (obj){
|
||||
var friends=JSON.parse(obj);
|
||||
for (var i=0;i<friends.length;i++){ friends[i].isFriend=1}
|
||||
callback(friends)
|
||||
//try{requestProfile(login,friends,rootwindow,function(friends_profile){callback(friends_profile)})}
|
||||
//catch(e){
|
||||
callback(friends)//}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function requestGroups(login,database,rootwindow,callback){
|
||||
// retrieve, save and return groups. Other features currently not implemented
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
|
@ -32,7 +67,7 @@ function requestGroups(login,database,rootwindow,callback){
|
|||
function listFriends(login,database,callback){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('SELECT * from contacts WHERE username="'+login.username+'" AND isFriend=1'); // check for friends
|
||||
var result = tx.executeSql('SELECT * from contacts WHERE username="'+login.username+'" AND isFriend>0'); // check for friends
|
||||
var contactlist=[];
|
||||
for (var i=0;i<result.rows.length;i++){
|
||||
contactlist.push(result.rows.item(i))
|
||||
|
@ -61,7 +96,7 @@ function getFriendsTimeline(login,database,contacts,onlynew,rootwindow,callback)
|
|||
var result = tx.executeSql('SELECT status_id from news WHERE username="'+login.username+'" AND messagetype=0 ORDER BY status_id DESC LIMIT 1'); // check for last news id
|
||||
try{parameter=parameter+"&since_id="+result.rows.item(0).status_id;}catch(e){};})}
|
||||
var newContacts=[];
|
||||
Helperjs.friendicaRequest(login,"/api/statuses/friends_timeline"+parameter, rootwindow,function (obj){//print("newsjs "+JSON.stringify(contacts));
|
||||
Helperjs.friendicaRequest(login,"/api/statuses/friends_timeline"+parameter, rootwindow,function (obj){
|
||||
var news=JSON.parse(obj);
|
||||
var newContacts=findNewContacts(news,contacts);
|
||||
callback(news,newContacts)
|
||||
|
@ -166,8 +201,9 @@ function getDirectMessage(login,database,rootwindow,callback){
|
|||
});
|
||||
}
|
||||
})
|
||||
if(login.newsViewType=="Timeline"){newsfromdb(database,login.username,callback)}
|
||||
else{chatsfromdb(database,login.username,callback)}
|
||||
callback()
|
||||
// if(login.newsViewType=="Timeline"){newsfromdb(database,login.username,callback)}
|
||||
// else{chatsfromdb(database,login.username,callback)}
|
||||
}
|
||||
|
||||
function getNotifications(login,database,rootwindow,callback){
|
||||
|
@ -195,12 +231,14 @@ function getNotifications(login,database,rootwindow,callback){
|
|||
})
|
||||
})}
|
||||
|
||||
function getActivitiesUserData(database,username,userUrlArray){//print(JSON.stringify(userUrlArray));
|
||||
function getActivitiesUserData(database,username,allcontacts,userUrlArray){//print(JSON.stringify(userUrlArray));
|
||||
|
||||
var helpArray=[];
|
||||
for (var i=0;i<userUrlArray.length;i++){
|
||||
Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
helpArray.push(userdata[0]);
|
||||
},"url",userUrlArray[i]);
|
||||
helpArray.push(objFromArray(allcontacts,"url",userUrlArray[i]));
|
||||
// Helperjs.readData(database,"contacts",username,function(userdata){
|
||||
// helpArray.push(userdata[0]);
|
||||
// },"url",userUrlArray[i]);
|
||||
}
|
||||
return helpArray
|
||||
}
|
||||
|
@ -213,42 +251,47 @@ function newsfromdb(database,username,callback,contact,stop_time){
|
|||
try{var rs = tx.executeSql('select created_at from news WHERE username="'+username+'" ORDER BY created_at DESC LIMIT 1');
|
||||
stop="<="+rs.rows.item(0).created_at}catch(e){stop="<99999999999999"}}
|
||||
else{var stop="<"+stop_time}
|
||||
var contactfilter="";if(contact){contactfilter=" AND uid='"+contact+"'"}
|
||||
var contactfilter="";if(contact){contactfilter=" AND (uid='"+contact+"' OR friendica_owner='"+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=[];
|
||||
var allcontacts=[];
|
||||
Helperjs.readData(database,"contacts",username,function(obj){allcontacts=obj});
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
newsArray.push(newsrs.rows.item(i));
|
||||
newsArray[i]=fetchUsersForNews(database,username,newsArray[i])
|
||||
newsArray[i]=fetchUsersForNews(database,username,newsArray[i],allcontacts)
|
||||
}
|
||||
callback(newsArray)});
|
||||
}
|
||||
|
||||
function fetchUsersForNews(database,username,news){//print(JSON.stringify(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);
|
||||
}
|
||||
function fetchUsersForNews(database,username,news,allcontacts){//print(JSON.stringify(news))
|
||||
news.user=objFromArray(allcontacts,"id",news.uid);
|
||||
if(news.in_reply_to_user_id){news.reply_user=objFromArray(allcontacts,"id",news.in_reply_to_user_id)}
|
||||
news.friendica_owner_object=objFromArray(allcontacts,"url",news.friendica_owner);
|
||||
// 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(Qt.atob(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]);
|
||||
news.like=getActivitiesUserData(database,username,allcontacts,friendicaArray[0]);
|
||||
news.dislike=getActivitiesUserData(database,username,allcontacts,friendicaArray[1]);
|
||||
news.attendyes=getActivitiesUserData(database,username,allcontacts,friendicaArray[2]);
|
||||
news.attendno=getActivitiesUserData(database,username,allcontacts,friendicaArray[3]);
|
||||
news.attendmaybe=getActivitiesUserData(database,username,allcontacts,friendicaArray[4]);
|
||||
}
|
||||
Helperjs.readData(database,"contacts",username,function(friendica_owner_data){
|
||||
news.friendica_owner_object=friendica_owner_data[0];
|
||||
//print("Fetch friendica_owner"+JSON.stringify(news.friendica_owner));
|
||||
},"url",news.friendica_owner);
|
||||
// Helperjs.readData(database,"contacts",username,function(friendica_owner_data){
|
||||
// news.friendica_owner_object=friendica_owner_data[0];
|
||||
// //print("Fetch friendica_owner"+JSON.stringify(news.friendica_owner));
|
||||
// },"url",news.friendica_owner);
|
||||
}
|
||||
return news
|
||||
}
|
||||
|
@ -266,11 +309,13 @@ function deleteNews(login,database,newsid,messagetype,rootwindow,callback){
|
|||
})}
|
||||
|
||||
function retweetNews(login,database,newsid,rootwindow,callback){
|
||||
Helperjs.friendicaPostRequest(login,"/api/statuses/retweet?id="+newsid,"","POST", rootwindow,function (obj){
|
||||
Helperjs.friendicaPostRequest(login,"/api/statuses/retweet?id="+newsid,"","POST", rootwindow,function (obj){
|
||||
var answer=JSON.parse(obj);
|
||||
if(answer.status.error){Helperjs.showMessage("Repost",answer.status.code,rootwindow);}
|
||||
else{Helperjs.showMessage("Repost",obj,rootwindow)}
|
||||
})}
|
||||
if(answer.hasOwnProperty('status'))//('error' in answer.status)
|
||||
{Helperjs.showMessage("Repost",answer.status.code,rootwindow);}
|
||||
else{Helperjs.showMessage("Repost",answer.text,rootwindow)}
|
||||
})
|
||||
}
|
||||
|
||||
function favorite(login,favorite,newsid,rootwindow){
|
||||
// toggle favorites
|
||||
|
@ -299,7 +344,7 @@ function likerequest(login,database,verb,newsid,rootwindow){
|
|||
//print(JSON.stringify(currentActivities));
|
||||
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)}})
|
||||
else{}})
|
||||
}
|
||||
|
||||
function like(login,database,toggle,verb,newsid,rootwindow){
|
||||
|
@ -351,13 +396,16 @@ function requestConversation(login,database,newsid,contacts,rootwindow,callback)
|
|||
function conversationfromdb(database,user,conversationId,callback){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id="'+conversationId+'" ORDER BY created_at ASC');
|
||||
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);} )}
|
||||
var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id="'+conversationId+'" ORDER BY created_at ASC');
|
||||
var newsArray=[];
|
||||
var allcontacts=[];
|
||||
Helperjs.readData(database,"contacts",user,function(obj){allcontacts=obj});
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
newsArray.push(newsrs.rows.item(i));
|
||||
newsArray[i]=fetchUsersForNews(database,user,newsArray[i],allcontacts)
|
||||
}
|
||||
callback(newsArray)})
|
||||
}
|
||||
|
||||
function requestFavorites(login,database,contacts,rootwindow,callback){
|
||||
Helperjs.friendicaRequest(login,"/api/favorites",rootwindow, function (obj){
|
||||
|
@ -374,9 +422,11 @@ function favoritesfromdb(database,user,callback){
|
|||
//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=[];
|
||||
var allcontacts=[];
|
||||
Helperjs.readData(database,"contacts",user,function(obj){allcontacts=obj});
|
||||
for(var i = 0; i < newsrs.rows.length; i++) {
|
||||
newsArray.push(newsrs.rows.item(i));
|
||||
newsArray[i]=fetchUsersForNews(database,user,newsArray[i]);
|
||||
newsArray[i]=fetchUsersForNews(database,user,newsArray[i],allcontacts);
|
||||
callback(newsArray);
|
||||
}})}
|
||||
|
||||
|
@ -393,11 +443,13 @@ function chatsfromdb(database,user,callback,stop_time){
|
|||
conversations.push(conversationsrs.rows.item(i).statusnet_conversation_id);
|
||||
}
|
||||
var newsArray=[];
|
||||
var allcontacts=[];
|
||||
Helperjs.readData(database,"contacts",user,function(obj){allcontacts=obj});
|
||||
for(var j = 0; j< conversations.length; j++) {
|
||||
var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id="'+conversations[j] +'" ORDER BY created_at ASC');
|
||||
var helpernews=newsrs.rows.item(0);
|
||||
helpernews.newscount=newsrs.rows.length;
|
||||
helpernews=fetchUsersForNews(database,user,helpernews);
|
||||
helpernews=fetchUsersForNews(database,user,helpernews,allcontacts);
|
||||
//var chatArray=[];
|
||||
// for (var k=0;k<newsrs.rows.length;k++){
|
||||
// var helperchat=newsrs.rows.item(k);
|
||||
|
@ -419,7 +471,16 @@ function inArray(list, prop, val) {
|
|||
} return false;
|
||||
}
|
||||
|
||||
function cleanDate(date){
|
||||
var cleanedDate= date.slice(0,3)+", "+date.slice(8,11)+date.slice(4,7)+date.slice(25,30)+date.slice(10,25);
|
||||
return cleanedDate
|
||||
function objFromArray(list, prop, val) {
|
||||
if (list.length > 0 ) {
|
||||
for (var i in list) {if (list[i][prop] == val) {
|
||||
return list[i];
|
||||
}
|
||||
}
|
||||
} return false;
|
||||
}
|
||||
|
||||
function cleanDate(date){
|
||||
var cleanedDate= date.slice(0,3)+", "+date.slice(8,11)+date.slice(4,7)+date.slice(25,30)+date.slice(10,25);
|
||||
return cleanedDate
|
||||
}
|
||||
|
|
|
@ -1,3 +1,34 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations including
|
||||
// the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for all
|
||||
// of the code used other than OpenSSL. If you modify file(s) with this
|
||||
// exception, you may extend this exception to your version of the
|
||||
// file(s), but you are not obligated to do so. If you do not wish to do
|
||||
// so, delete this exception statement from your version. If you delete
|
||||
// this exception statement from all source files in the program, then
|
||||
// also delete it here.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
WorkerScript.onMessage = function(msg) {
|
||||
if(msg.deleteId!==undefined)
|
||||
{msg.model.remove(msg.deleteId);
|
||||
|
|
|
@ -1,5 +1,37 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations including
|
||||
// the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for all
|
||||
// of the code used other than OpenSSL. If you modify file(s) with this
|
||||
// exception, you may extend this exception to your version of the
|
||||
// file(s), but you are not obligated to do so. If you do not wish to do
|
||||
// so, delete this exception statement from your version. If you delete
|
||||
// this exception statement from all source files in the program, then
|
||||
// also delete it here.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
WorkerScript.onMessage = function(msg) {
|
||||
if (msg.firstalbum==0){msg.model.clear();}
|
||||
var contact={}; try{contact=msg.friend}catch(e){print(e)}
|
||||
var limit=0; if (msg.albums.length-msg.firstalbum<20){limit=msg.albums.length} else{limit=msg.firstalbum+20}
|
||||
for (var j=msg.firstalbum;j<limit;j++){
|
||||
if (msg.albums[msg.firstalbum]) {
|
||||
|
@ -8,7 +40,7 @@ WorkerScript.onMessage = function(msg) {
|
|||
var albumname=msg.albums[j].name.trim();var albumlink=msg.albums[j].link
|
||||
}else{
|
||||
var albumname=msg.albums[j].toString();var albumlink=""}
|
||||
msg.model.append({"albumlink":albumlink,"foreignPicture":msg.foreignPicture,"albumname":albumname});
|
||||
msg.model.append({"albumlink":albumlink,"foreignPicture":msg.foreignPicture,"albumname":albumname,"friend":contact});
|
||||
msg.model.sync()
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,150 +1,39 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations including
|
||||
// the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for all
|
||||
// of the code used other than OpenSSL. If you modify file(s) with this
|
||||
// exception, you may extend this exception to your version of the
|
||||
// file(s), but you are not obligated to do so. If you do not wish to do
|
||||
// so, delete this exception statement from your version. If you delete
|
||||
// this exception statement from all source files in the program, then
|
||||
// also delete it here.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//.pragma library
|
||||
.import QtQuick.LocalStorage 2.0 as Sql
|
||||
.import "qrc:/js/helper.js" as Helperjs
|
||||
.import "qrc:/js/news.js" as Newsjs
|
||||
|
||||
// IMAGE FUNCTIONS
|
||||
|
||||
function requestList(login,database,rootwindow,callback) {
|
||||
//get list of own images and call download function
|
||||
Helperjs.friendicaRequest(login,"/api/friendica/photos/list", rootwindow,function (helperobject){
|
||||
//print("return"+helperobject);
|
||||
var obj=JSON.parse(helperobject);
|
||||
Helperjs.readField("id",database,"imageData",login.username,function(AllStoredImages){
|
||||
if (AllStoredImages.length>0){
|
||||
for(var i=0;i< AllStoredImages.length;i++){
|
||||
var position=Helperjs.inArray(obj,"resourceID",AllStoredImages[i]);
|
||||
if (position>-1){obj.splice(position,1)}
|
||||
//obj.splice(obj.indexOf(AllStoredImages[i]),1);// list of objects instead of list!!!
|
||||
}}
|
||||
callback(obj)
|
||||
})
|
||||
})}
|
||||
|
||||
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 (image){
|
||||
try{ if(image==""){currentimageno=currentimageno+1}else{
|
||||
var obj = JSON.parse(image);
|
||||
var helpfilename=obj.filename.substring(0,obj.filename.lastIndexOf("."));
|
||||
var filesuffix="";
|
||||
if (obj.type=="image/jpeg"){filesuffix=".jpg"}
|
||||
else if (obj.type=="image/png"){filesuffix=".png"}
|
||||
else {filesuffix=""}
|
||||
if (helpfilename==""){// check if file has any filename
|
||||
obj.filename=obj["id"]+filesuffix;
|
||||
}
|
||||
else{obj.filename=helpfilename+filesuffix}
|
||||
var link="";
|
||||
if(obj["link"][0]){link=obj["link"][0]} else{link=obj["link"]["4"]}
|
||||
xhr.setUrl(Qt.resolvedUrl(link));
|
||||
xhr.setFilename(login.imagestore+'albums/'+obj.album+"/"+obj["filename"]);
|
||||
xhr.setDownloadtype("picture");
|
||||
xhr.download();
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('SELECT * from imageData where id = "'+obj["id"]+'"');
|
||||
if(result.rows.length === 1) {// use update
|
||||
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["link"]["4"],'file://'+login.imagestore+'albums/'+obj.album+"/"]);
|
||||
}
|
||||
})}}
|
||||
catch (e){print("Data retrieval failure! "+ e+obj);}
|
||||
})}
|
||||
|
||||
|
||||
function deleteImage(database,login,type,location,rootwindow,callback) { // delete image locally and on server
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
var rsfilename=location.substring(location.lastIndexOf("/")+1,location.length);
|
||||
var rslocation=location.substring(0,location.lastIndexOf("/")+1);
|
||||
//print(type+" Name "+ rsfilename+" Location: "+rslocation)
|
||||
db.transaction( function(tx) {
|
||||
if (type=='image'){
|
||||
var rs= tx.executeSql('SELECT * FROM imageData WHERE filename="'+rsfilename+'" AND location="'+rslocation+'"')
|
||||
var imageId=rs.rows.item(0).id;
|
||||
Helperjs.friendicaPostRequest(login,"/api/friendica/photo/delete?photo_id="+imageId,"","DELETE",rootwindow, function (obj){
|
||||
//var deletereturn = JSON.parse(obj); print(obj);
|
||||
//if (deletereturn.result=="deleted"){
|
||||
db.transaction( function(tx) {
|
||||
var deleters=tx.executeSql('DELETE FROM imageData WHERE location="'+rslocation+'" AND filename="'+rsfilename+'"'); });
|
||||
filesystem.Directory=rslocation.substring(7,rslocation.length-1);
|
||||
filesystem.rmFile(rsfilename)
|
||||
//}
|
||||
})
|
||||
}
|
||||
else{
|
||||
Helperjs.friendicaPostRequest(login,"/api/friendica/photoalbum/delete?album="+rsfilename,"","DELETE",rootwindow, function (obj){
|
||||
//var deletereturn = JSON.parse(obj);
|
||||
//if (deletereturn.result=="deleted"){
|
||||
db.transaction( function(tx) {
|
||||
var rs= tx.executeSql('SELECT DISTINCT location FROM imageData WHERE album="'+rsfilename+'" AND username="'+login.username+'"');
|
||||
var locationstring=rs.rows.item(0).location;
|
||||
filesystem.Directory=locationstring.substring(7,locationstring.length-1);
|
||||
filesystem.rmDir();
|
||||
var deleters=tx.executeSql('DELETE FROM imageData WHERE album="'+location+'"');
|
||||
})
|
||||
//}
|
||||
})
|
||||
}
|
||||
callback(location)
|
||||
})
|
||||
}
|
||||
|
||||
function deleteContacts(database,user,callback) { // does nothing useful at the moment
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
//print(' delete Image Data() for ' + field +"="+selection)
|
||||
db.transaction( function(tx) {
|
||||
result1= tx.executeSql('SELECT * FROM contacts a LEFT OUTER JOIN news b ON a.url==b.uid');
|
||||
result2= tx.executeSql('SELECT * FROM contacts a LEFT OUTER JOIN news b ON a.url==b.uid');
|
||||
callback(result)})
|
||||
}
|
||||
|
||||
function requestFriendsAlbumPictures(login,friend,rootwindow,callback){
|
||||
// screenscraping of albums page of contact without user and password
|
||||
Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){
|
||||
//print(photohtml);
|
||||
var photoarray=[];
|
||||
var arr = photohtml.split("sidebar-photos-albums-li");
|
||||
for (var i=2;i<arr.length;i++){
|
||||
var albumlink = arr[i].substring(arr[i].indexOf('http'),arr[i].indexOf('class')-2);
|
||||
var albumname=arr[i].substring(arr[i].indexOf('/span')+6,arr[i].indexOf('</a>')-1);
|
||||
var album={'link':albumlink,'name':albumname}
|
||||
photoarray.push(album);
|
||||
}
|
||||
callback(photoarray)
|
||||
})
|
||||
}
|
||||
|
||||
function requestFriendsPictures(link,rootwindow,callback){
|
||||
// screenscraping of pictures page for given album
|
||||
Helperjs.friendicaWebRequest(link,rootwindow,function(photohtml){
|
||||
var photoarray=[];
|
||||
var basehtml=photohtml.substring(photohtml.indexOf('<base')+12,photohtml.indexOf('/>',photohtml.indexOf('<base'))-2);
|
||||
|
||||
// old theme
|
||||
if (photohtml.indexOf("photo-album-image-wrapper-end")>-1){ //theme 1
|
||||
var arr = photohtml.split("photo-album-image-wrapper-end");}
|
||||
|
||||
// other themes
|
||||
if (photohtml.indexOf("photo-album-wrapper")>-1){ //theme 2
|
||||
var photoarea=photohtml.substring(photohtml.indexOf("photo-album-wrapper"),photohtml.indexOf("photo-album-end"))
|
||||
var arr = photoarea.split("</a>");}
|
||||
|
||||
for (var i=0;i<arr.length-1;i++){
|
||||
var photoname=arr[i].substring(arr[i].lastIndexOf('alt')+5,arr[i].lastIndexOf('title')-2);
|
||||
var thumblink=arr[i].substring(arr[i].lastIndexOf('<img')+10,arr[i].lastIndexOf('alt')-2);
|
||||
var imagetype=thumblink.substring(thumblink.lastIndexOf("."));
|
||||
var photolink=thumblink.substring(0,thumblink.length-imagetype.length-2)+"-0"+imagetype
|
||||
if(thumblink.substring(0,4)!=="http"){thumblink=basehtml+thumblink}
|
||||
if(photolink.substring(0,4)!=="http"){photolink=basehtml+photolink}
|
||||
var photo={'link':photolink,'name':photoname,'thumb':thumblink}
|
||||
photoarray.push(photo);
|
||||
}
|
||||
callback(photoarray)
|
||||
})
|
||||
}
|
||||
|
||||
// CONFIG FUNCTIONS
|
||||
|
||||
function initDatabase(database) { // initialize the database object
|
||||
|
@ -153,9 +42,10 @@ function initDatabase(database) { // initialize the database object
|
|||
db.transaction( function(tx) {
|
||||
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, permissions TEXT,maxContactAge INT,APIVersion TEXT,layout TEXT, addons TEXT)');
|
||||
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, attachments TEXT, friendica_owner 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, attachments TEXT, friendica_owner TEXT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS contacts(username TEXT, id INT, name TEXT, screen_name TEXT, location TEXT,imageAge INT, 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, timestamp INT)');
|
||||
tx.executeSql('CREATE INDEX IF NOT EXISTS contact_id ON contacts(id)');
|
||||
// tx.executeSql('CREATE INDEX IF NOT EXISTS contact_id ON contacts(id)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS profiles(username TEXT, id INT, profiledata TEXT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS groups(username TEXT, groupname TEXT, gid INT, members TEXT)');
|
||||
tx.executeSql('CREATE TABLE IF NOT EXISTS events(username TEXT, id INT, start INT, end INT, allday INT, title TEXT, j INT, d TEXT, isFirst INT, uid INT, cid INT, uri TEXT, created INT, edited INT, desc TEXT, location TEXT, type TEXT, nofinish TEXT, adjust INT, ignore INT, permissions TEXT, guid INT, itemid INT, plink TEXT, authorName TEXT, authorAvatar TEXT, authorLink TEXT, html TEXT)');
|
||||
})}
|
||||
|
@ -169,6 +59,7 @@ return (newpermArray)
|
|||
function getEvents(database,login,rootwindow,callback){
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
Helperjs.friendicaWebRequest(login.server+"/cal/"+login.username+"/json",rootwindow,function(obj){
|
||||
//Helperjs.friendicaRemoteAuthRequest(login,login.server+"/cal/"+login.username+"/json",login.server+"/profile/"+login.username,rootwindow,function(obj){
|
||||
var events = JSON.parse(obj);
|
||||
db.transaction( function(tx) {
|
||||
for (var i=0;i<events.length;i++){
|
||||
|
@ -244,6 +135,48 @@ function requestFriendsEvents(login,friend,rootwindow,callback){
|
|||
})
|
||||
}
|
||||
|
||||
function newRequestFriendsEvents(login,friend,rootwindow,callback){
|
||||
// get calendar JSON object of contact with remoteAuth or without user and password
|
||||
if(friend.isFriend==1){
|
||||
Helperjs.friendicaRemoteAuthRequest(login,friend.url.replace("profile","cal")+"/json",friend.url,rootwindow,function(calhtml){
|
||||
getEventsFromHtml(calhtml,rootwindow,callback)})
|
||||
}
|
||||
else{
|
||||
Helperjs.friendicaWebRequest(friend.url.replace("profile","cal")+"/json",rootwindow,function(calhtml){
|
||||
getEventsFromHtml(calhtml,rootwindow,callback)})
|
||||
}
|
||||
}
|
||||
|
||||
function getEventsFromHtml(calhtml,rootwindow,callback){
|
||||
var eventarray=[];var eventdays=[];
|
||||
var events=JSON.parse(calhtml);
|
||||
for (var i=0;i<events.length;i++){
|
||||
var permissions=[];
|
||||
permissions.push(cleanPermissions(events[i].item.allow_cid));
|
||||
permissions.push(cleanPermissions(events[i].item.allow_gid));
|
||||
permissions.push(cleanPermissions(events[i].item.deny_cid));
|
||||
permissions.push(cleanPermissions(events[i].item.deny_gid));
|
||||
|
||||
var event ={}
|
||||
event.start=Date.parse(events[i].start);event.end=Date.parse(events[i].end);
|
||||
event.allday=events[i].allday; event.title=events[i].title; event.j=events[i].j;
|
||||
event.d=events[i].d; event.isFirst=events[i].isFirst; event.uid=events[i].item.uid;
|
||||
event.cid=events[i].item.cid; event.uri=events[i].item.uri;
|
||||
event.created=Date.parse(events[i].item.created); event.edited=Date.parse(events[i].item.edited);
|
||||
event.desc=events[i].item.desc; event.location=events[i].item.location; event.type=events[i].item.type;
|
||||
event.nofinish=events[i].item.nofinish; event.adjust =events[i].item.adjust; event.ignore=events[i].item.ignore;
|
||||
event.permissions=JSON.stringify(permissions); event.guid=events[i].item.guid;
|
||||
event.itemid=events[i].item.itemid; event.plink=events[i].plink; event.authorName=events[i].item["author-name"];
|
||||
event.authorAvatar=events[i].item["author-avatar"]; event. authorLink=events[i].item["author-link"];
|
||||
event.html=Qt.btoa(events[i].html);
|
||||
eventarray.push(event);
|
||||
// var offsetTime = new Date().getTimezoneOffset() * 60 * 1000;print(new Date(event.start).toLocaleString()+"Zeitverschiebung:"+offsetTime)
|
||||
// var time = event.start - offsetTime;
|
||||
eventdays.push(Math.floor(event.start/(24*60*60*1000)))
|
||||
}
|
||||
//print(JSON.stringify(eventarray));
|
||||
callback(eventarray,eventdays)
|
||||
}
|
||||
|
||||
function savePermissions(database,obj) { // stores config to DB
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
|
@ -280,6 +213,36 @@ Helperjs.friendicaWebRequest(url+"/api/statusnet/config",rootwindow, function (o
|
|||
callback(serverConfigString)
|
||||
})}
|
||||
|
||||
function checkLogin(login,rootwindow,callback){
|
||||
// check server with given credentials
|
||||
try {Helperjs.friendicaRequest(login,"/api/account/verify_credentials",rootwindow, function (obj){
|
||||
var account = JSON.parse(obj);
|
||||
callback(account)
|
||||
})}
|
||||
catch(e){}
|
||||
}
|
||||
|
||||
function requestProfile(login,database,rootwindow,callback){
|
||||
// return profile data
|
||||
Helperjs.friendicaRequest(login,"/api/friendica/profile/show", rootwindow,function (obj){
|
||||
var profiledata=JSON.parse(obj);
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
for (var i=0;i<profiledata.profiles.length;i++){
|
||||
//print('store profile data for '+JSON.stringify(profiledata.profiles[i]));
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('SELECT * from profiles where username="'+login.username+'" AND id = '+profiledata.profiles[i].profile_id); // check for profile id
|
||||
if(result.rows.length === 1) {// use update
|
||||
result = tx.executeSql('UPDATE profiles SET profiledata="'+ Qt.btoa(JSON.stringify(profiledata.profiles[i]))+'" WHERE username="'+login.username+'" AND id='+parseInt(profiledata.profiles[i].profile_id));
|
||||
} else {// use insert
|
||||
result = tx.executeSql('INSERT INTO profiles (username,id,profiledata) VALUES (?,?,?)', [login.username,profiledata.profiles[i].profile_id,Qt.btoa(JSON.stringify(profiledata.profiles[i]))])}
|
||||
});
|
||||
}
|
||||
var profile=profiledata.friendica_owner;
|
||||
profile.isFriend=2;
|
||||
var profilearray=[];profilearray.push(profile);
|
||||
callback(profilearray)
|
||||
});
|
||||
}
|
||||
|
||||
function getServerConfig(database,login,rootwindow,callback){
|
||||
// check server with given credentials
|
||||
|
@ -295,14 +258,15 @@ try {Helperjs.friendicaRequest(login,"/api/statusnet/config",rootwindow, functio
|
|||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('UPDATE config SET APIVersion="'+ serverconfig.site.friendica.FRIENDICA_VERSION+'" WHERE username="'+login.username +'"')})
|
||||
|
||||
Helperjs.friendicaRequest(login,"/friendica/json",rootwindow, function (obj){
|
||||
var serverData = JSON.parse(obj);var serverAddons=JSON.stringify(serverData.plugins).replace(/"/g,"");
|
||||
db.transaction( function(tx) {
|
||||
var result = tx.executeSql('UPDATE config SET addons="'+ serverAddons+'" WHERE username="'+login.username +'"')})
|
||||
// Helperjs.friendicaRequest(login,"/friendica/json",rootwindow, function (obj){
|
||||
// var serverData = JSON.parse(obj);var serverAddons=JSON.stringify(serverData.plugins).replace(/"/g,"");
|
||||
// db.transaction( function(tx) {
|
||||
// var result = tx.executeSql('UPDATE config SET addons="'+ serverAddons+'" WHERE username="'+login.username +'"')})
|
||||
|
||||
callback(serverconfigString);
|
||||
})})}
|
||||
catch (e){callback (e);
|
||||
// })
|
||||
callback(serverconfigString);
|
||||
})}
|
||||
catch (e){callback (e);
|
||||
}}
|
||||
|
||||
function readConfig(database,callback,filter,filtervalue) { // reads config
|
||||
|
@ -334,8 +298,13 @@ function deleteConfig(database,userobj,callback) { // delete user data from DB
|
|||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
if(!db) { return; }
|
||||
db.transaction( function(tx) {
|
||||
var rs = tx.executeSql('delete from config'+where);
|
||||
callback(rs);
|
||||
var rs1 = tx.executeSql('delete from config'+where);
|
||||
var rs2 = tx.executeSql("delete from news WHERE username='"+ userobj.username+"'");
|
||||
var rs3 = tx.executeSql("delete from contacts WHERE username='"+ userobj.username+"'");
|
||||
var rs4 = tx.executeSql("delete from imageData WHERE username='"+ userobj.username+"'");
|
||||
var rs5 = tx.executeSql("delete from groups WHERE username='"+ userobj.username+"'");
|
||||
var rs5 = tx.executeSql("delete from events WHERE username='"+ userobj.username+"'");
|
||||
callback();
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -370,16 +339,22 @@ function cleanContacts(login,database,callback){
|
|||
}
|
||||
|
||||
function processNews(callback){
|
||||
// Newsjs.getCurrentContacts(login,db,function(contacts){
|
||||
// contactlist=contacts});
|
||||
|
||||
if (contactLoadType=="news"){
|
||||
if(root.news.length==0){}
|
||||
else{// show news
|
||||
Newsjs.storeNews(login,db,news,root,function(dbnews){
|
||||
root.newsSignal(dbnews);
|
||||
newstab.newstabstatus=login.newsViewType
|
||||
})}
|
||||
if(login.newsViewType=="Timeline"){
|
||||
Newsjs.newsfromdb(db,login.username,function(dbnews){
|
||||
root.newsSignal(dbnews);
|
||||
newstab.newstabstatus=login.newsViewType})
|
||||
}
|
||||
else{
|
||||
Newsjs.chatsfromdb(db,login.username,function(dbnews){
|
||||
root.newsSignal(dbnews);
|
||||
newstab.newstabstatus=login.newsViewType})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
else if (contactLoadType=="friends"){// show friends
|
||||
root.friendsSignal(login.username);
|
||||
|
@ -408,37 +383,18 @@ function processNews(callback){
|
|||
}
|
||||
|
||||
function updateContactInDB(login,database,isFriend,contact){// for newstab and friendstab
|
||||
// var suffix=contact.profile_image_url.substring(contact.profile_image_url.lastIndexOf("."), contact.profile_image_url.length);
|
||||
// var imagename=login.imagestore+"contacts/"+contact.screen_name.trim()+suffix;
|
||||
|
||||
var imagename="";
|
||||
contacttimer.restart();
|
||||
var currentTime=Date.now();
|
||||
var image_timestamp=0;
|
||||
if(contact.profile_image_url==""){root.currentContact=root.currentContact+1 }
|
||||
else{//print(JSON.stringify(contact))
|
||||
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
|
||||
db.transaction( function(tx) {
|
||||
var currentts=0;
|
||||
var currenttsrs= tx.executeSql('SELECT timestamp FROM contacts WHERE username="'+login.username+'" AND url="'+contact.url+'"');
|
||||
try{currentts=currenttsrs.rows.item(0).timestamp}catch(e){}
|
||||
|
||||
var imagename_helper=[];
|
||||
imagename_helper=contact.profile_image_url.split('?');//print("substring: "+JSON.stringify(imagename_helper)+imagename_helper[0].substring(imagename_helper[0].lastIndexOf("/")+1, imagename_helper[0].length))
|
||||
imagename=login.imagestore+"contacts/"+contact.screen_name+"-"+imagename_helper[0].substring(imagename_helper[0].lastIndexOf("/")+1, imagename_helper[0].length);
|
||||
try {parseInt(image_timestamp=imagename_helper[1].substring(imagename_helper[1].indexOf("ts=")+3,imagename_helper[1].length))} catch(e){};
|
||||
//print(contact.screen_name+" Timestamp"+image_timestamp+" "+ new Date(parseInt(image_timestamp)*1000));
|
||||
if ((image_timestamp>currentts) || (image_timestamp==0)){
|
||||
xhr.setUrl(Qt.resolvedUrl(contact.profile_image_url));
|
||||
xhr.setFilename(imagename);
|
||||
xhr.setDownloadtype("contact");
|
||||
xhr.download();
|
||||
}
|
||||
var result;
|
||||
result = tx.executeSql('SELECT * from contacts where username="'+login.username+'" AND url = "'+contact.url+'"'); // check for news url
|
||||
if(result.rows.length === 1) {// use update
|
||||
result = tx.executeSql('UPDATE contacts SET id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'",imageAge='+currentTime+', profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", profile_image="'+imagename+'", 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+', timestamp='+ image_timestamp+' where username="'+login.username+'" AND url="'+contact.url+'"');
|
||||
result = tx.executeSql('UPDATE contacts SET id='+contact.id+', name="'+Qt.btoa(contact.name)+'", screen_name="'+contact.screen_name+'", location="'+contact.location+'",imageAge='+currentTime+', profile_image_url="'+contact.profile_image_url+'", description="'+Qt.btoa(contact.description)+'", 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+', timestamp='+ currentTime+' where username="'+login.username+'" AND url="'+contact.url+'"');
|
||||
} else {// use insert
|
||||
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,currentTime,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,image_timestamp]);}
|
||||
result = tx.executeSql('INSERT INTO contacts VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,contact.id,Qt.btoa(contact.name),contact.screen_name,contact.location,currentTime,contact.profile_image_url, Qt.btoa(contact.description),"",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,image_timestamp]);}
|
||||
});
|
||||
}}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,34 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations including
|
||||
// the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for all
|
||||
// of the code used other than OpenSSL. If you modify file(s) with this
|
||||
// exception, you may extend this exception to your version of the
|
||||
// file(s), but you are not obligated to do so. If you do not wish to do
|
||||
// so, delete this exception statement from your version. If you delete
|
||||
// this exception statement from all source files in the program, then
|
||||
// also delete it here.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
var core=[
|
||||
{name:'<3',url:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue