OAuth and bugfixes
This commit is contained in:
parent
e58a1f69dc
commit
d43c18bb76
65 changed files with 1681 additions and 1494 deletions
|
@ -55,7 +55,7 @@ function dataRequest(login,photo,database,xhr,rootwindow) {
|
|||
Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photo.id, rootwindow, function (image){
|
||||
if(image=="" || typeof(image)=="undefined"){currentimageno=currentimageno+1}else{
|
||||
|
||||
try{print("image "+ image)
|
||||
try{
|
||||
var obj = JSON.parse(image);
|
||||
if (obj.hasOwnProperty('status')){
|
||||
var helpfilename=photo.filename.substring(0,photo.filename.lastIndexOf("."));
|
||||
|
@ -69,7 +69,8 @@ function dataRequest(login,photo,database,xhr,rootwindow) {
|
|||
else{photo.filename=helpfilename+filesuffix}
|
||||
var link="";
|
||||
xhr.setUrl(Qt.resolvedUrl(photo.thumb));
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
if(login.password!=""){xhr.setLogin(login.username+":"+Qt.atob(login.password));}
|
||||
else{xhr.setToken(login.token)}
|
||||
xhr.setFilename(login.imagestore+'albums/'+photo.album+"/"+photo["filename"]);
|
||||
xhr.setDownloadtype("picture");
|
||||
xhr.download();
|
||||
|
@ -95,7 +96,8 @@ function dataRequest(login,photo,database,xhr,rootwindow) {
|
|||
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));
|
||||
if(login.password!=""){xhr.setLogin(login.username+":"+Qt.atob(login.password));}
|
||||
else{xhr.setToken(login.token)}
|
||||
xhr.setFilename(login.imagestore+'albums/'+obj.album+"/"+obj["filename"]);
|
||||
xhr.setDownloadtype("picture");
|
||||
xhr.download();
|
||||
|
@ -120,7 +122,8 @@ function dataRequest(login,photo,database,xhr,rootwindow) {
|
|||
else{photo.filename=helpfilename+filesuffix}
|
||||
var link="";
|
||||
xhr.setUrl(Qt.resolvedUrl(photo.thumb));
|
||||
xhr.setLogin(login.username+":"+Qt.atob(login.password));
|
||||
if(login.password!=""){xhr.setLogin(login.username+":"+Qt.atob(login.password));}
|
||||
else{xhr.setToken(login.token)}
|
||||
xhr.setFilename(login.imagestore+'albums/'+photo.album+"/"+photo["filename"]);
|
||||
xhr.setDownloadtype("picture");
|
||||
xhr.download();
|
||||
|
@ -154,7 +157,6 @@ function deleteImage(database,login,type,location,filesystem,rootwindow,callback
|
|||
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+'"')
|
||||
|
@ -211,47 +213,13 @@ function deleteContacts(database,user,callback) { // does nothing useful at the
|
|||
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){//print("newRequestFriendsAlbumPictures");
|
||||
// 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){
|
||||
try {var obj=JSON.parse(photohtml);//print ("Photohtml: "+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)
|
||||
getAlbumFromHtml(photohtml,false,rootwindow,callback)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getAlbumFromHtml(photohtml,remoteAuthBool,rootwindow,callback){
|
||||
//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}//print(albumlink+" "+albumname);
|
||||
var album={'link':albumlink,'name':albumname}
|
||||
photoarray.push(album);
|
||||
}
|
||||
callback(photoarray,remoteAuthBool)
|
||||
|
@ -269,13 +237,6 @@ function newRequestFriendsPictures(login,link,friend,remoteAuthBool,remoteauth,r
|
|||
callback(photoarray)
|
||||
})
|
||||
})}
|
||||
else{
|
||||
Helperjs.friendicaWebRequest(link,rootwindow,function(photohtml){
|
||||
getPictureFromHtml(photohtml,remoteAuthBool,function(photoarray){
|
||||
callback(photoarray)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function getPictureFromHtml(photohtml,remoteAuthBool,callback){
|
||||
|
@ -290,10 +251,6 @@ function getPictureFromHtml(photohtml,remoteAuthBool,callback){
|
|||
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);
|
||||
|
@ -305,41 +262,8 @@ function getPictureFromHtml(photohtml,remoteAuthBool,callback){
|
|||
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)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue