v0.6.2 Bugfix: download and upload public images, comments in timeline

This commit is contained in:
LubuWest 2021-08-11 20:06:17 +02:00
parent baccd64303
commit d09a55bcd9
14 changed files with 200 additions and 145 deletions

View File

@ -2,7 +2,8 @@
## v0.6.2
* Follow and Unfollow contacts (Friendica 2021.07 required)
* Linux: App stays in systemtray after close, syncs in background
* bugfix for bulk image upload and download of public images
* bugfix for conversations in timeline
## v0.6.1
* Add requestLegacyExternalStorage in AndroidManifest for attachment permissions

View File

@ -69,8 +69,8 @@ ToDo:
# Images #
Currently supported:
* Download public and private own images to local directory
* Upload picture to album with descriptions(public), send from gallery
* Download public own images to local directory
* Upload public picture to album with descriptions, send from gallery
* Delete own pictures and albums on client and server
* Change name or album of existing picture
* Show albums in grid, show images in album in grid and fullscreen

View File

@ -45,14 +45,14 @@ ALARM::ALARM(QObject *parent) : QObject(parent){}
void ALARM::setAlarm(int interval)
{
qDebug() << interval;
//qDebug() << interval;
QVariantMap message;
message["value"] = interval;
}
void ALARM::notify(QString title, QString text, int id)
{
qDebug() << title << text;
//qDebug() << title << text;
// QVariantMap message;
// message["title"] = title;
// message["message"] = text;

View File

@ -83,7 +83,7 @@ void FILESYSTEM::makeDir(QString name)
{
QDir dir(m_Directory);
if (dir.mkdir(name)){
qDebug() << "makedir success" <<name;
//qDebug() << "makedir success" <<name;
emit success(name);
}
else {
@ -96,7 +96,7 @@ void FILESYSTEM::makePath(QString name)
{
QDir dir(m_Directory);
if (dir.mkpath(name)){
qDebug() << "makepath success" <<name;
//qDebug() << "makepath success" <<name;
emit success(name);
}
else {

View File

@ -42,7 +42,7 @@ void UploadableImage::setAngle(const int &b) {
if (b != m_angle) {
m_angle = b;
qDebug() << "UploadableImage::setAngle : " << m_angle;
//qDebug() << "UploadableImage::setAngle : " << m_angle;
if (m_angle==0) {
emit angleChanged();
return;
@ -57,7 +57,7 @@ void UploadableImage::setSource(const QString &a) {
m_mimetype = "";
m_filename = "";
qDebug() << "UploadableImage::setSource : " << m_source;
//qDebug() << "UploadableImage::setSource : " << m_source;
if (m_source=="") {
emit sourceChanged();
@ -83,7 +83,7 @@ void UploadableImage::setSource(const QString &a) {
} else {
m_image = fullimage;
}
qDebug() << "UploadableImage::setSource : " << m_image.width() << "x" << m_image.height();
//qDebug() << "UploadableImage::setSource : " << m_image.width() << "x" << m_image.height();
emit sourceChanged();
QFileInfo fi(m_source);
@ -95,7 +95,7 @@ void UploadableImage::setSource(const QString &a) {
if (filetype!="PNG" && filetype!="JPG") {
filetype = "JPG";
}
qDebug() << "UploadableImage::setSource : " << "Saving as " << filetype;
//qDebug() << "UploadableImage::setSource : " << "Saving as " << filetype;
m_mimetype = "image/"+filetype.toLower();
emit mimetypeChanged();

View File

@ -223,6 +223,7 @@ void XHR::getlist()
XHR::setUrl(m_filelist.at(dlindex));}
else {
XHR::setUrl(m_filelist.at(dlindex));}
qDebug() << "start download" << m_url;
XHR::download();
} else {dlindex=0;m_downloadtype="";m_contactlist.clear();m_filelist.clear();}
}

View File

@ -40,7 +40,8 @@ function friendicaRequest(login,api,rootwindow,callback) {
if (xhrequest.status==200){
callback(xhrequest.responseText)
}else{
showMessage("Error","API:\n" +login.server+api+"\n NO RESPONSE"+xhrequest.statusText,rootwindow);
callback(xhrequest.responseText)
//showMessage("Error","API:\n" +login.server+api+"\n NO RESPONSE"+xhrequest.statusText,rootwindow);
}
}
catch (e){
@ -60,7 +61,7 @@ function friendicaPostRequest(login,api,data,method,rootwindow,callback) {
} else if(xhrequest.readyState === XMLHttpRequest.DONE) {
try{ if (xhrequest.responseText!=""){
callback(xhrequest.responseText)
}else{print("API:\n" +api+" NO RESPONSE");
}else{//print("API:\n" +api+" NO RESPONSE");
showMessage("Error","API:\n" +api+" NO RESPONSE",rootwindow)
callback(xhrequest.responseText)
}

View File

@ -36,64 +36,95 @@
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;
//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)}
}
}
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);}
})}
callback(obj)
})}
else{callback(obj)}
})}
function dataRequest(login,photo,database,xhr,rootwindow) {
// check if image exist and call download function
Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photo.id, rootwindow, function (image){
if(image==""){currentimageno=currentimageno+1}else{
try{
var obj = JSON.parse(image);
if (obj.hasOwnProperty('status')){
var helpfilename=photo.filename.substring(0,photo.filename.lastIndexOf("."));
var filesuffix="";
if (photo.type=="image/jpeg"){filesuffix=".jpg"}
else if (photo.type=="image/png"){filesuffix=".png"}
else {filesuffix=""}
if (helpfilename==""){// check if file has any filename
photo.filename=photo["id"]+filesuffix;
}
else{photo.filename=helpfilename+filesuffix}
var link="";
xhr.setUrl(Qt.resolvedUrl(photo.thumb));
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setFilename(login.imagestore+'albums/'+photo.album+"/"+photo["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="'+photo.id+'", created="'+photo.created+'", edited="'+photo.edited+'", profile="0", link="'+photo["thumb"]+'", filename="'+photo.filename+'",title="", desc="'+photo.desc+'", type="'+photo.type+'", width="0", height="0", album="'+photo.album+'", location="file://'+login.imagestore+'albums/'+photo.album+'/" where id="'+photo["id"]+'"');
} else {// use insert print('... does not exists, create it')
result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,photo.id,photo.created,photo.edited,'', photo.desc, photo.album, photo.filename, photo.type, '', '',0,photo["thumb"],'file://'+login.imagestore+'albums/'+photo.album+"/"]);
}
})
}else{
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="'+link+'", 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,link,'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+"/"]);
}
})}
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]);
@ -107,26 +138,26 @@ function deleteImage(database,login,type,location,filesystem,rootwindow,callback
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)
//}
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+'"');
})
//}
})
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)
})
@ -136,13 +167,13 @@ function updateImage(database,login,type,filesystem,imageId,rootwindow,callback)
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
Helperjs.readData(database,"imageData",login.username,function(obj){
db.transaction( function(tx) {
if (type=='image'){
var deleters=tx.executeSql('DELETE FROM imageData WHERE location="'+obj[0].location+'" AND filename="'+obj[0].filename+'"');
filesystem.Directory=obj[0].location
filesystem.rmFile(obj[0].filename)
}
})
},"id",imageId);
if (type=='image'){
var deleters=tx.executeSql('DELETE FROM imageData WHERE location="'+obj[0].location+'" AND filename="'+obj[0].filename+'"');
filesystem.Directory=obj[0].location
filesystem.rmFile(obj[0].filename)
}
})
},"id",imageId);
callback()
}
@ -153,7 +184,7 @@ function deleteContacts(database,user,callback) { // does nothing useful at the
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)})
callback(result)})
}
//function requestFriendsAlbumPictures(login,friend,rootwindow,callback){
@ -173,10 +204,10 @@ function deleteContacts(database,user,callback) { // does nothing useful at the
//}
function newRequestFriendsAlbumPictures(login,friend,rootwindow,callback){//print("newRequestFriendsAlbumPictures");
// screenscraping of albums page of contact with remoteAuth
// screenscraping of albums page of contact with remoteAuth
//commented out for broken remoteauth
Helperjs.friendicaRemoteAuthRequest(login,friend.url.replace("profile","photos"),friend.url,rootwindow,function(photohtml){
//Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){
//Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){
try {var obj=JSON.parse(photohtml);//print ("Photohtml: "+photohtml)
if (obj.hasOwnProperty('status')){
Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){
@ -197,14 +228,14 @@ function getAlbumFromHtml(photohtml,remoteAuthBool,rootwindow,callback){
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);
photoarray.push(album);
}
callback(photoarray,remoteAuthBool)
}
function newRequestFriendsPictures(login,link,friend,remoteAuthBool,remoteauth,rootwindow,callback){
// screenscraping of pictures page for given album
// screenscraping of pictures page for given album
if (remoteAuthBool){
remoteauth.setUrl(login.server);
remoteauth.setLogin(login.username+":"+Qt.atob(login.password));
@ -225,20 +256,20 @@ function newRequestFriendsPictures(login,link,friend,remoteAuthBool,remoteauth,r
function getPictureFromHtml(photohtml,remoteAuthBool,callback){
var photoarray=[];
var basehtml=photohtml.substring(photohtml.indexOf('<base')+12,photohtml.indexOf('/>',photohtml.indexOf('<base'))-2);
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");}
// 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
// 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);
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);
@ -253,38 +284,38 @@ function getPictureFromHtml(photohtml,remoteAuthBool,callback){
//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);
photoarray.push(photo);
}
callback(photoarray)
}
function requestFriendsPictures(link,rootwindow,callback){
// screenscraping of pictures page for given album
// 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);
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");}
// 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>");}
// 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)
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)
})
}

View File

@ -145,7 +145,7 @@ else{
var newsitemobject=msg.news[j];
newsitemobject=beautify(newsitemobject,msg);
if (newsitemobject.hasOwnProperty("currentconversation")&&(newsitemobject.currentconversation.length>1)){
if (newsitemobject.hasOwnProperty("currentconversation")&&(newsitemobject.currentconversation.length>0)){
newsitemobject.lastcomment=beautify(newsitemobject.currentconversation[newsitemobject.currentconversation.length-1],msg);
newsitemobject.lastcomment.indent=1
//print("Currentconversation" + newsitemobject.currentconversation.length+JSON.stringify(newsitemobject.lastcomment))

View File

@ -291,7 +291,7 @@ function readConfig(database,callback,filter,filtervalue) { // reads config
}
var rsObject={server:rsArray[0].server,username:rsArray[0].username, password:rsArray[0].password,imagestore:rsArray[0].imagestore,isActive:rsArray[0].isActive, newsViewType:rsArray[0].newsViewType,permissions:JSON.parse(rsArray[0].permissions),maxContactAge:rsArray[0].maxContactAge,APIVersion:rsArray[0].APIVersion,addons:rsArray[0].addons};
if (rsObject.newsViewType!="" && rsObject.newsViewType!=null){updateNewsviewtype(database,rsObject.newsViewType)}
} else {print("config empty");var rsObject=""}
} else {var rsObject=""}
callback(rsObject)}}
)
}

View File

@ -29,9 +29,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import QtQuick 2.9
import QtQuick 2.15
AnimatedImage {id:gif;
width:toprow.width;
cache:false
smooth: false
//property string mimetype:""
fillMode: Image.PreserveAspectFit;
onStatusChanged: {playing = (status == AnimatedImage.Ready)}

View File

@ -173,7 +173,13 @@ Rectangle{
function getOldNews(){
var currentTime= new Date();
try{var lastnews_id=newsModel.get(newsModel.count-1).newsitemobject.created_at;} catch(e){var lastnews_id=99999999999999 }
var oldnewsitemobject=newsModel.get(newsModel.count-1).newsitemobject;
try{ if(oldnewsitemobject.hasOwnProperty("lastcomment")){
var lastnews_id=oldnewsitemobject.lastcomment.created_at;
}else{
var lastnews_id=oldnewsitemobject.created_at;
}
} catch(e){print(e);var lastnews_id=99999999999999 }
var messagetype=0;
switch(newsSwipeview.stacktype){
case "Home":messagetype=0;break;

View File

@ -53,7 +53,7 @@ Rectangle{
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.clearParams();
xhr.setParam("desc",imageUploadModel.get(inumber).description);
xhr.setParam("album", album.currentText);
if(album.editText!=""){xhr.setParam("album", album.editText)}else{xhr.setParam("album", album.currentText)};
//if (group_allow.length>0) {xhr.setParam("group_allow", Helperjs.cleanArray(group_allow))};
//if (group_deny.length>0) {xhr.setParam("group_deny", Helperjs.cleanArray(group_deny))};
//if (contact_allow.length>0) {xhr.setParam("contact_allow", Helperjs.cleanArray(contact_allow))};
@ -96,7 +96,7 @@ Rectangle{
}else{
Imagejs.requestList(login,db, true,root,function(obj){
fotorectangle.newimages=obj;
imageDialog.destroy()
photoStack.pop()
})
}} else{
@ -304,7 +304,7 @@ Rectangle{
text: imageId==""?qsTr("Upload"):qsTr("Change")
font.pointSize: osSettings.bigFontSize
onClicked:{
if(album.currentText==""){Helperjs.showMessage(qsTr("Error"),qsTr(" No album name given"), imageDialog)}
if(album.currentText==""&&album.editText==""){Helperjs.showMessage(qsTr("Error"),qsTr(" No album name given"), imageDialog)}
else if (imageId!=""){uploadBusy.running=true; updateImage()}
else{newimageProgress.visible=true;
if (imageUploadModel.count>0){

View File

@ -61,22 +61,28 @@ StackView{
if(albums.indexOf(fotorectangle.newimages[i].album)==-1){
filesystem.Directory=root.login.imagestore+"/albums";
filesystem.makeDir(fotorectangle.newimages[i].album)}
ownimagelist.push(root.login.server+"/api/friendica/photo?scale='0'&photo_id="+fotorectangle.newimages[i].id);
//ownimagelist.push(root.login.server+"/api/friendica/photo?scale='0'&photo_id="+fotorectangle.newimages[i].id);
}
Imagejs.dataRequest(login,fotorectangle.newimages[0],db,xhr,fotorectangle);
})
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setImagedir(login.imagestore);
xhr.setFilelist(ownimagelist);
xhr.setDownloadtype("picturelist");
xhr.getlist();
// xhr.setLogin(login.username+":"+Qt.atob(login.password));
// xhr.setImagedir(login.imagestore);
// xhr.setFilelist(ownimagelist);
// xhr.setDownloadtype("picturelist");
// xhr.getlist();
newImagesProgress.visible=true
}
}
onCurrentimagenoChanged:{
if(fotorectangle.currentimageno==fotorectangle.newimages.length){newImagesProgress.visible=false;showFotos(root.login,"");
fotorectangle.newimages=[];fotorectangle.currentimageno=0}
// download next image
if(fotorectangle.currentimageno==fotorectangle.newimages.length){
newImagesProgress.visible=false;showFotos(root.login,"");
fotorectangle.newimages=[];fotorectangle.currentimageno=0
}else{
// download next image
Imagejs.dataRequest(login,fotorectangle.newimages[currentimageno],db,xhr,fotorectangle)
}
}
Connections{
@ -90,10 +96,17 @@ StackView{
function onDownloaded(type,url,filename,i){
if(type=="picture"){fotorectangle.currentimageno=fotorectangle.currentimageno+1}
}
function onError(data,url,api,code){if(data=="picturelist"){
function onError(data,url,api,code){//print("Url "+url+" api " +api + " data "+data)
if(data=="picturelist"){
var requestid=url.substring(url.lastIndexOf("=")+1);
Imagejs.dataRequest(login,requestid,db,xhr,fotorectangle)
} else {fotorectangle.currentimageno=fotorectangle.currentimageno+1}
Imagejs.dataRequest(login,requestid,db,xhr,fotorectangle);
fotorectangle.currentimageno=fotorectangle.currentimageno+1
} else if (data=="picture"){
Helperjs.deleteData(root.db,"imageData",root.login.username,function(){
fotorectangle.currentimageno=fotorectangle.currentimageno+1
},"link",url)
}else{
fotorectangle.currentimageno=fotorectangle.currentimageno+1}
}
}
// Connections{