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

@ -50,11 +50,39 @@ function requestList(login,database,onlynew,rootwindow,callback) {
else{callback(obj)}
})}
function dataRequest(login,photoID,database,xhr,rootwindow) {
function dataRequest(login,photo,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{
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"}
@ -75,13 +103,16 @@ function dataRequest(login,photoID,database,xhr,rootwindow) {
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"]+'"');
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,obj["link"]["4"],'file://'+login.imagestore+'albums/'+obj.album+"/"]);
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);
}
}})
}
})}}
catch (e){print("Data retrieval failure! "+ e+obj);}
})}
function storeImagedata(login,database,imagedata,rootwindow) {
// check if image exist and call download function

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}
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{