OAuth and bugfixes

This commit is contained in:
LubuWest 2023-05-24 21:40:26 +02:00
commit d43c18bb76
65 changed files with 1681 additions and 1494 deletions

View file

@ -34,7 +34,6 @@ WorkerScript.onMessage = function(msg) {
if (msg.albums[j]) {
var albumobject=msg.albums[j];
var data=({"albumobject": albumobject,"foreignPicture": msg.foreignPicture})}
// print("Albums:"+j+msg.albums.length+JSON.stringify(data));
msg.model.append(data);}
if (j==msg.albums.length){
msg.model.sync()

View file

@ -41,7 +41,6 @@ function friendicaRequest(login,api,rootwindow,callback) {
callback(xhrequest.responseText)
}else{print("xhrequest.status "+xhrequest.status)
callback(xhrequest.responseText)
//showMessage("Error","API:\n" +login.server+api+"\n NO RESPONSE"+xhrequest.statusText,rootwindow);
}
}
catch (e){
@ -49,30 +48,39 @@ function friendicaRequest(login,api,rootwindow,callback) {
}
}
}
xhrequest.open("GET", login.server+api,true,login.username,Qt.atob(login.password));
if (login.password==""){
xhrequest.open("GET", login.server+api,true);
xhrequest.setRequestHeader("Authorization","Bearer "+login.token);
}
else{
xhrequest.open("GET", login.server+api,true,login.username,Qt.atob(login.password));
}
xhrequest.send();
}
function friendicaPostRequest(login,api,data,method,rootwindow,callback) {
var xhrequest= new XMLHttpRequest();
xhrequest.onreadystatechange = function() {
//print(api+JSON.stringify(login)+Qt.atob(login.password));
if (xhrequest.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
} else if(xhrequest.readyState === XMLHttpRequest.DONE) {
try{ if (xhrequest.responseText!=""){//print (xhrequest.responseText)
callback(xhrequest.responseText)
}else{//print("API:\n" +api+" NO RESPONSE");
//showMessage("Error","API:\n" +api+" NO RESPONSE",rootwindow)
}else{
callback(xhrequest.responseText)
}
}
catch (e){
print("API:\n" + api+" "+e+"\n Return:"+xhrequest.responseText);
//showMessage("Error", "API:\n" + api+" "+e+"\n Return:"+xhrequest.responseText,rootwindow)
}
}
}
xhrequest.open(method, login.server+api,true,login.username,Qt.atob(login.password));
if (login.password==""){
xhrequest.open(method, login.server+api,true);
xhrequest.setRequestHeader("Authorization","Bearer "+login.token);
}
else{
xhrequest.open(method, login.server+api,true,login.username,Qt.atob(login.password));
}
xhrequest.send(data);
}
@ -86,32 +94,6 @@ function getCount(database,login,table,field,countvalue){
return count
}
function friendicaWebRequest(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","API:\n" +url+" "+e+"\n Return: "+xhrequest.responseText, rootwindow)}
}
}
xhrequest.open("GET", url,true);
xhrequest.send();
}
function friendicaXmlRequest(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.responseXML)}
catch (e){showMessage("Error","API:\n" +url+" "+e+"\n Return: "+xhrequest.responseText, rootwindow)}
}
}
xhrequest.open("GET", url);
xhrequest.responseType ="document";
xhrequest.send();
}
function friendicaRemoteAuthRequest(login,url,c_url,rootwindow,callback) {
var xhrequest = new XMLHttpRequest();
@ -142,7 +124,6 @@ function readData(database,table,username,callback,filter,filtervalue, sort) { /
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
if(!db) { return; }
db.transaction( function(tx) {
//print('select * from '+table+user+where+sortparam);
var rsArray=[];
var rs = tx.executeSql('select * from '+table+user+where+sortparam);
for(var i = 0; i < rs.rows.length; i++) {
@ -161,7 +142,6 @@ var where = " AND "+ filter +" = '" + filtervalue+"'";
db.transaction( function(tx) {
//print('... read from database ' + field)
var rsArray=[];
//print('select DISTINCT '+field+' from '+table+' WHERE username="'+username+'"'+where+' ORDER BY '+field+' ASC');
var rs = tx.executeSql('select DISTINCT '+field+' from '+table+' WHERE username="'+username+'"'+where+' ORDER BY '+field+' ASC');
for(var i = 0; i < rs.rows.length; i++) {
rsArray.push(rs.rows.item(i)[field])

View file

@ -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)
})
}

View file

@ -1,76 +0,0 @@
// This file is part of Friendiqa
// https://git.friendi.ca/lubuwest/Friendiqa
// Copyright (C) 2020 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);
});
}
function displayFriends(obj){
for (var i=0; i<obj.length; i++){
//print(obj[i]);
if (obj[i]) {friendsModel.append({"friendName": obj[i]});
};
}}
function ensureVisibility(c,f)
{
if (f.contentX >= c.x)
f.contentX = c.x;
else if (f.contentX+f.width <= c.x+c.width)
f.contentX = c.x+c.width-f.width;
if (f.contentY >= c.y)
f.contentY = c.y;
else if (f.contentY+f.height <= c.y+c.height)
f.contentY = c.y+c.height-f.height;
}
function createObject(objectQml,qmlParameters,parentitem,callback) {
var component = Qt.createComponent(objectQml);
if (component.status === Component.Ready || component.status === Component.Error)
finishCreation(component,qmlParameters,parentitem,callback);
else
component.statusChanged.connect(finishCreation(qmlParameters));
}
function finishCreation(component,qmlParameters,parentitem,callback) {
if (component.status === Component.Ready) {
var createdObject = component.createObject(parentitem, qmlParameters);
if (createdObject === null)
print("Error creating image"); }
else if (component.status === Component.Error)
print("Error loading component:"+component.errorString());
else {print("created")}
//callback(createdObject);
}

View file

@ -279,7 +279,6 @@ function storeNews(login,database,news,rootwindow){
db.transaction( function(tx) {
var result = tx.executeSql('SELECT * from news where username="'+login.username+'" AND status_id = "'+news[i].id+'" AND messagetype='+news[i].messagetype); // check for news id
if(result.rows.length === 1) {// use update
//print(news[i].id +' news exists, update it'+'UPDATE news SET username="'+login.username+'", messagetype=0, text="'+Qt.btoa(news[i].text)+'", created_at="'+Date.parse(cleanDate(news[i].created_at))+'", in_reply_to_status_id="'+news[i].in_reply_to_status_id+'", source="'+news[i].source+'", status_id="'+news[i].id+'", in_reply_to_user_id="'+news[i].in_reply_to_user_id+'", geo="'+news[i].geo+'", favorited="'+news[i].favorited+'", uid="'+news[i].user.id+'", statusnet_html="'+Qt.btoa(news[i].status_html)+'", statusnet_conversation_id="'+news[i].statusnet_conversation_id+'",friendica_activities="'+Qt.btoa(JSON.stringify(friendica_activities))+'",attachments="'+attachments+'",friendica_owner="'+news[i].friendica_owner.url+'" where username="'+login.username+'" AND status_id="'+news[i].status_id+'" AND messagetype=0')
result = tx.executeSql('UPDATE news SET username="'+login.username+'", messagetype='+news[i].messagetype+', text="'+Qt.btoa(news[i].text)+'", created_at="'+news[i].created_at+'", in_reply_to_status_id="'+news[i].in_reply_to_status_id+'", source="'+news[i].source+'", status_id="'+news[i].id+'", in_reply_to_user_id="'+news[i].in_reply_to_user_id+'", geo="'+news[i].geo+'", favorited="'+news[i].favorited+'", uid="'+news[i].user.id+'", statusnet_html="'+Qt.btoa(news[i].statusnet_html)+'", statusnet_conversation_id="'+news[i].statusnet_conversation_id+'",friendica_activities="'+Qt.btoa(JSON.stringify(friendica_activities))+'",attachments="'+attachments+'",friendica_owner="'+news[i].friendica_author.url+'" where username="'+login.username+'" AND status_id="'+news[i].status_id+'" AND messagetype=0');
} else {// use insert
result = tx.executeSql('INSERT INTO news (username,messagetype,text,created_at,in_reply_to_status_id,source,status_id,in_reply_to_user_id,geo,favorited,uid,statusnet_html,statusnet_conversation_id,friendica_activities,friendica_activities_self,attachments,friendica_owner) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,news[i].messagetype,Qt.btoa(news[i].text),news[i].created_at, news[i].in_reply_to_status_id, news[i].source, news[i].id,news[i].in_reply_to_user_id,news[i].geo,news[i].favorited, news[i].user.id,Qt.btoa(news[i].statusnet_html),news[i].statusnet_conversation_id, Qt.btoa(JSON.stringify(friendica_activities)),"[]",attachments,news[i].friendica_author.url])}})
@ -308,7 +307,6 @@ function newsfromdb(database,login,messagetype,callback,contact,stop_time){
else{var stop="<"+stop_time}
var contactfilter="";if(contact){contactfilter=" AND (uid='"+contact+"' OR friendica_owner='"+contact+"')"}
if (messagetype=="0"){messagetype="0,5"}
//print('select * from news WHERE username="'+login.username+'" AND messagetype IN ( '+messagetype+' ) AND created_at'+stop+contactfilter+' ORDER BY created_at DESC LIMIT 20');
var newsrs=tx.executeSql('select * from news WHERE username="'+login.username+'" AND messagetype IN ( '+messagetype+' ) AND created_at'+stop+contactfilter+' ORDER BY created_at DESC LIMIT 20');
var newsArray=[];
var allcontacts=getAllContacts(database,login.username);
@ -326,7 +324,7 @@ function newsfromdb(database,login,messagetype,callback,contact,stop_time){
}
function fetchUsersForNews(database,username,news,allcontacts){//print("fetchusers "+JSON.stringify(news))
function fetchUsersForNews(database,username,news,allcontacts){//print("fetchusers "+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);
@ -382,7 +380,6 @@ function likerequest(login,database,verb,newsid,rootwindow){
db.transaction( function(tx) {
var currentActivities_rs=tx.executeSql('select friendica_activities_self from news WHERE username="'+login.username+'" AND status_id='+newsid) ;
var currentActivities=JSON.parse(currentActivities_rs.rows.item(0).friendica_activities_self);
//print(verb+"currentActivities "+JSON.stringify(currentActivities));
if ((verb=="like")&&(currentActivities.indexOf(1)==-1)){ currentActivities.push(1);
if (currentActivities.indexOf(2)!=-1){currentActivities.splice(currentActivities.indexOf(2),1)}
}
@ -391,7 +388,6 @@ function likerequest(login,database,verb,newsid,rootwindow){
}
if (verb=="unlike"){ if (currentActivities.indexOf(1)!=-1){currentActivities.splice(currentActivities.indexOf(1),1)}}
if (verb=="undislike"){ if (currentActivities.indexOf(2)!=-1){currentActivities.splice(currentActivities.indexOf(2),1)}}
//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{}})
@ -408,7 +404,6 @@ function like(login,database,toggle,verb,newsid,rootwindow){
function attend(login,database,attend,newsid,rootwindow,callback){
Helperjs.friendicaPostRequest(login,"/api/friendica/activity/attend"+attend+"?id="+newsid, "","POST",rootwindow,function (obj){
//print("attend: "+attend+obj);
if (obj=='"ok"')
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
db.transaction( function(tx) {
@ -418,7 +413,6 @@ function attend(login,database,attend,newsid,rootwindow,callback){
currentActivities.push(3);
if (currentActivities.indexOf(4)!=-1){currentActivities.splice(currentActivities.indexOf(4),1)}
if (currentActivities.indexOf(5)!=-1){currentActivities.splice(currentActivities.indexOf(5),1)}
//print(JSON.stringify(currentActivities));
}
if ((attend=="no")&&(currentActivities.indexOf(4)==-1)){
currentActivities.push(4);
@ -443,26 +437,8 @@ function requestConversation(login,database,newsid,contacts,rootwindow,callback)
callback(news,newContacts)
})}
//function conversationfromdb(database,user,conversationId,callback){
// var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
// db.transaction( function(tx) {
// var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id="'+conversationId+'" ORDER BY created_at ASC');
// var newsArray=[];
// var allcontacts=getAllContacts(database,user);
// for(var i = 0; i < newsrs.rows.length; i++) {
// newsArray.push(newsrs.rows.item(i));
// newsArray[i].statusnet_html=Qt.atob(newsArray[i].statusnet_html);
// newsArray[i].text=Qt.atob(newsArray[i].text);
// newsArray[i].id=newsArray[i].status_id;
// newsArray[i]=fetchUsersForNews(database,user,newsArray[i],allcontacts);
// if (helpernews.attachments!="" && newsArray[i].attachments!==null){newsArray[i].attachments=JSON.parse(Qt.atob(newsArray[i].attachments))};
// }
// callback(newsArray)})
//}
function requestFavorites(login,database,contacts,rootwindow,callback){
Helperjs.friendicaRequest(login,"/api/favorites",rootwindow, function (obj){
//print(obj+JSON.stringify(obj));
var news=JSON.parse(obj);
var newContacts=findNewContacts(news,contacts);
// storeNews(login,database,news,rootwindow,callback)
@ -494,7 +470,6 @@ function chatsfromdb(database,login,messagetype,currentconversations,callback,st
for(var j = 0; j< conversations.length; j++) {
var newsrs=tx.executeSql('select * from news WHERE username="'+login.username+'" AND statusnet_conversation_id="'+conversations[j] +'" AND messagetype="'+messagetype+'" ORDER BY created_at ASC');
//print(JSON.stringify(newsrs.rows.item(0))+JSON.stringify(newsrs.rows.item(1)))
var helpernews=newsrs.rows.item(0);
helpernews=cleanhelpernews(database,login.username,helpernews,allcontacts)
helpernews.currentconversation=[];
@ -532,17 +507,18 @@ function allchatsfromdb(database,user,callback){
for(var j = 0; j< conversationIds.length; j++) {
var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id="'+conversationIds[j] +'" ORDER BY created_at ASC');
var helpernews=newsrs.rows.item(0);
var helpernews=cleanhelpernews(database,user,helpernews,allcontacts)
helpernews.currentconversation=[];
for (var h = 0;h<newsrs.rows.length;h++){
var helpernews2=newsrs.rows.item(h);
if(helpernews.id!=helpernews2.status_id){
helpernews2.newscount=0;
helpernews2=cleanhelpernews(database,user,helpernews2,allcontacts)
helpernews.currentconversation.push(helpernews2)
if (helpernews){
var helpernews=cleanhelpernews(database,user,helpernews,allcontacts)
helpernews.currentconversation=[];
for (var h = 0;h<newsrs.rows.length;h++){
var helpernews2=newsrs.rows.item(h);
if(helpernews.id!=helpernews2.status_id){
helpernews2.newscount=0;
helpernews2=cleanhelpernews(database,user,helpernews2,allcontacts)
helpernews.currentconversation.push(helpernews2)
}
}
}
newsArray.push(helpernews);
countArray.push(newsrs.rows.length)
}
@ -557,16 +533,10 @@ function allchatsfromdb(database,user,callback){
function oldchatfromdb(database,user,conversationId,lastpost,allcontacts,callback){
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
db.transaction( function(tx) {
// var newsArray=[];
// var countArray=[];
//var allcontacts=getAllContacts(database,user);
var newsrs=tx.executeSql('select * from news WHERE username="'+user+'" AND statusnet_conversation_id="'+conversationId +'" AND status_id<'+lastpost+' ORDER BY created_at ASC');
let conversation=[];
var helpernews={currentconversation:conversation}
if(newsrs.rows.length>0){
//helpernews=newsrs.rows.item(0);
//helpernews=cleanhelpernews(database,user,helpernews,allcontacts)
//helpernews.currentconversation=[];
for (var h = 0;h<newsrs.rows.length;h++){
var helpernews2=newsrs.rows.item(h);
if(helpernews.id!=helpernews2.status_id){
@ -579,8 +549,6 @@ function oldchatfromdb(database,user,conversationId,lastpost,allcontacts,callbac
}
var newscount=newsrs.rows.length;
callback(helpernews,newscount);
// var conversationobject={news:helpernews,newscount:newscount};
// return conversationobject;
})
}
@ -595,7 +563,6 @@ function cleanhelpernews(database,user,helpernews,allcontacts){
return helpernews
}
function getAllContacts(database,user){
var allcontacts=[];
Helperjs.readData(database,"contacts",user,function(obj){

View file

@ -32,14 +32,14 @@
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}
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]) {
// print("album"+msg.albums[j].name);
if(msg.foreignPicture){
var albumname=msg.albums[j].name.trim();var albumlink=msg.albums[j].link
}else{
var albumname=msg.albums[j].toString();var albumlink=""}
var albumname=msg.albums[j].name;var albumlink=""
}
msg.model.append({"albumlink":albumlink,"foreignPicture":msg.foreignPicture,"albumname":albumname,"friend":contact});
msg.model.sync()
};

View file

@ -62,27 +62,6 @@ function cleanPermissions(oldperms){
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++){
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 result = tx.executeSql('SELECT * from events where username="'+login.username+'" AND id = '+events[i].id); // check for news id
if(result.rows.length === 1) {// use update
result = tx.executeSql('UPDATE events SET username="'+login.username+'", start="'+Date.parse(events[i].start)+'", end="'+Date.parse(events[i].end)+'", allday="'+Number(events[i].allday)+'", title="'+events[i].title+'", j="'+events[i].j+'", d="'+events[i].d+ '", isFirst="'+Number(events[i].isFirst)+'", uid="'+events[i].item.uid+'", cid="'+events[i].item.cid+'", uri="'+events[i].item.uri+'", created="'+ Date.parse(events[i].item.created)+'", edited="'+ Date.parse(events[i].item.edited)+'", desc="'+events[i].item.desc+'", location="'+events[i].item.location+'", type="'+events[i].item.type+'", nofinish="'+events[i].item.nofinish+'", adjust ="'+events[i].item.adjust+'", ignore="'+events[i].item.ignore+'", permissions="'+ JSON.stringify(permissions)+'", guid="'+events[i].item.guid+'", itemid="'+events[i].item.itemid+ '", plink="'+events[i].item.plink+ '", authorName="'+events[i].item["author-name"]+ '", authorAvatar="'+events[i].item["author-avatar"]+ '", authorLink="'+events[i].item["author-link"]+ '", html="'+Qt.btoa(events[i].html)+'" where username="'+login.username+'" AND id='+events[i].id);
} else {// use insert
result = tx.executeSql('INSERT INTO events (username,id,start,end,allday,title,j,d,isFirst,uid,cid,uri,created,edited,desc,location,type,nofinish,adjust,ignore,permissions,guid,itemid,plink,authorName,authorAvatar,authorLink,html) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username, events[i].id, Date.parse(events[i].start), Date.parse(events[i].end), events[i].allday, events[i].title, events[i].j, events[i].d, events[i].isFirst, events[i].item.uid, events[i].item.cid, events[i].item.uri, Date.parse(events[i].item.created), Date.parse(events[i].item.edited), events[i].item.desc, events[i].item.location, events[i].item.type, events[i].item.nofinish, events[i].item.adjust, events[i].item.ignore, JSON.stringify(permissions), events[i].item.guid, events[i].item.itemid, events[i].item.plink, events[i].item["author-name"], events[i].item["author-avatar"], events[i].item["author-link"], Qt.btoa(events[i].html)])}
callback()
}
})})}
function newscount(database, callback){
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
db.transaction( function(tx) {
@ -115,84 +94,6 @@ function eventsfromdb(database, username,callback){
callback(eventArray,dayArray)});
}
function requestFriendsEvents(login,friend,rootwindow,callback){
// get calendar JSON object of contact without user and password
Helperjs.friendicaWebRequest(friend.replace("profile","cal")+"/json",rootwindow,function(calhtml){
//print(calhtml);
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 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]);
var permissions=JSON.stringify(obj)
@ -207,34 +108,14 @@ function storeConfig(database,obj) { // stores config to DB
//print(JSON.stringify(obj));
var result = tx.executeSql('SELECT * from config WHERE username="'+obj.username+'"');
if(result.rows.length === 1) {// use update
var result2 = tx.executeSql('UPDATE config SET server="'+obj.server+'",password="'+obj.password+'", imagestore="'+obj.imagestore+'", maxnews="'+obj.accountId+'", timerInterval=0, newsViewType="'+obj.newsViewType+'", isActive=0 WHERE username="'+obj.username +'"');
var result2 = tx.executeSql('UPDATE config SET server="'+obj.server+'",password="'+obj.password+'", imagestore="'+obj.imagestore+'", maxnews="'+obj.accountId+'", timerInterval=0, newsViewType="'+obj.newsViewType+'", isActive=0, APIVersion="'+Qt.btoa(obj.token)+'", addons="'+obj.client + '" WHERE username="'+obj.username +'"');
var result3 = tx.executeSql('UPDATE config SET isActive=1 WHERE username !="'+obj.username +'"');
} else {// use insert print('... does not exists, create it')
var result2 = tx.executeSql('INSERT INTO config VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)', [obj.server, obj.username, obj.password, obj.imagestore, obj.accountId, 0,obj.newsViewType,0,"[[],[],[],[]]",0,"","",""]);
var result2 = tx.executeSql('INSERT INTO config VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)', [obj.server, obj.username, obj.password, obj.imagestore, obj.accountId, 0,obj.newsViewType,0,"[[],[],[],[]]",0,Qt.btoa(obj.token),"",obj.client]);
var result3 = tx.executeSql('UPDATE config SET isActive=1 WHERE username !="'+obj.username +'"');
}
})}
function showServerConfig(url,rootwindow,callback){
Helperjs.friendicaWebRequest(url+"/api/statusnet/config",rootwindow, function (obj){
var serverconfig = JSON.parse(obj);
var serverConfigString="import QtQuick 2.0; import QtQuick.Dialogs 1.2; MessageDialog{ visible: true; title:'Server';standardButtons: StandardButton.Ok;text: 'Name: "+serverconfig.site.name+"\nLanguage: "+serverconfig.site.language+
"\nEmail: "+serverconfig.site.email+"\nTimezone: "+serverconfig.site.timezone+"\nClosed: "+serverconfig.site.closed+
"\nText limit: "+serverconfig.site.textlimit+"\nShort Url length: "+serverconfig.site.shorturllength+
"\nFriendica version: "+serverconfig.site.friendica.FRIENDICA_VERSION+"\nDFRN version: "+serverconfig.site.friendica.DFRN_PROTOCOL_VERSION +
"\nDB Update version: "+serverconfig.site.friendica.DB_UPDATE_VERSION+"'}";
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){
@ -256,41 +137,15 @@ function requestProfile(login,database,rootwindow,callback){
});
}
function getServerConfig(database,login,rootwindow,callback){
// check server with given credentials
try {Helperjs.friendicaRequest(login,"/api/statusnet/config",rootwindow, function (obj){
var serverconfig = JSON.parse(obj);
var serverconfigString="import QtQuick 2.0; import QtQuick.Dialogs 1.2; MessageDialog{ visible: true; title:'Server';standardButtons: StandardButton.Ok;text: 'SUCCESS! \nName: "+serverconfig.site.name+"\nLanguage: "+serverconfig.site.language+
"\nEmail: "+serverconfig.site.email+"\nTimezone: "+serverconfig.site.timezone+"\nClosed: "+serverconfig.site.closed+
"\nText limit: "+serverconfig.site.textlimit+"\nShort Url length: "+serverconfig.site.shorturllength+
"\nFriendica version: "+serverconfig.site.friendica.FRIENDICA_VERSION+"\nDFRN version: "+serverconfig.site.friendica.DFRN_PROTOCOL_VERSION +
"\nDB Update version: "+serverconfig.site.friendica.DB_UPDATE_VERSION+"'}";
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
db.transaction( function(tx) {
var result = tx.executeSql('UPDATE config SET APIVersion="'+ serverconfig.site.friendica.FRIENDICA_VERSION+'" WHERE username="'+login.username +'"')})
callback(serverconfigString);
})}
catch (e){callback (e);
}}
function readConfig(database,callback,filter,filtervalue) { // reads config
if (filter){var where = " WHERE "+ filter +" = '" + filtervalue+"'"} else { var where=""}
//print("readConfig");
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3],initDatabase(database));
db.transaction( function(tx) {
var tables = tx.executeSql("SELECT * FROM sqlite_master WHERE type='table'");
if (tables.rows.length==0){print("no database");callback("")} else {
var rs = tx.executeSql('select * from config'+where);
var rsArray=[];
if (rs.rows.length>0){
for(var i = 0; i < rs.rows.length; i++) {
rsArray.push(rs.rows.item(i))
}
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,accountId:rsArray[0].maxnews,permissions:JSON.parse(rsArray[0].permissions),maxContactAge:rsArray[0].maxContactAge,APIVersion:rsArray[0].APIVersion,addons:rsArray[0].addons};
if (rsObject.newsViewType!="" && rsObject.newsViewType!=null &&!typeof(rsObject.newsViewType)=='undefined'){updateNewsviewtype(database,rsObject.newsViewType)}
} else {var rsObject=""}
updatenews.setDatabase();
let rsArray=updatenews.getAccounts(filter,filtervalue);
let rsObject=rsArray[0];
callback(rsObject)}}
)
}
@ -300,14 +155,8 @@ function readAllLogins(database,callback) { // reads config
db.transaction( function(tx) {
var tables = tx.executeSql("SELECT * FROM sqlite_master WHERE type='table'");
if (tables.rows.length==0){print("no database");callback("")} else {
var rs = tx.executeSql('select * from config');
var rsArray=[];
if (rs.rows.length>0){
for(var i = 0; i < rs.rows.length; i++) {
rsArray.push(rs.rows.item(i));
rsArray[i].permissions=JSON.parse(rsArray[i].permissions)
}
}
updatenews.setDatabase();
var rsArray=updatenews.getAccounts();
}
callback(rsArray)}
)
@ -326,7 +175,6 @@ function setDefaultOptions(database){
})
}
function readGlobaloptions(database,callback){
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
var go=({});
@ -368,7 +216,7 @@ function deleteConfig(database,userobj,callback) { // delete user data from DB
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+"'");
var rs6 = tx.executeSql("delete from events WHERE username='"+ userobj.username+"'");
callback();
})
}
@ -379,11 +227,9 @@ function updateNewsviewtype(database, newsViewtype){
db.transaction( function(tx) {
var rs1 = tx.executeSql('INSERT INTO globaloptions (k,v) VALUES (?,?)', ["newsViewType",newsViewtype])
var rs2 = tx.executeSql('UPDATE config SET newsViewType=""');
//Helperjs.showMessage(qsTr("Changelog"),qsTr("Setting view type of news has moved from account page to config page."),root)
})
}
function cleanNews(database,callback){
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
db.transaction( function(tx) {
@ -448,7 +294,7 @@ function updateContactInDB(login,database,isFriend,contact){// for newstab and f
});
}
function processNews(api,data){//print("processnews "+ " api "+ api + " data "+data);
function processNews(api,data){
try{var newslist=JSON.parse(data)} catch(e){print("processnews "+e+ " api "+ api + " data "+data);newsBusy.running=false;};
if (api=="/api/users/show"){
var usermessages=[];
@ -618,7 +464,6 @@ function processNews(api,data){//print("processnews "+ " api "+ api + " data "+d
}
}
function cleanUser(user){
user.created_at=Date.parse(Newsjs.cleanDate(user.created_at));
var imagehelper1=user.profile_image_url.split("?");
@ -628,78 +473,11 @@ function cleanUser(user){
return user
}
function updateView(viewtype){//print("lastnews "+lastnews);
function updateView(viewtype,lastnews=0){
//messageSend.state="";
//newsBusy.running=true;
//downloadNotice.text="xhr start "+Date.now()
switch(viewtype){
case "Conversations":
Newsjs.getLastNews(login,db,function(lastnews){
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/statuses/friends_timeline");
xhr.clearParams();
xhr.setParam("since_id",lastnews);
xhr.setParam("count",50)});
break;
case "Timeline":
var lastnews=Newsjs.getLastNews(login,db,function(lastnews){
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/statuses/friends_timeline");
xhr.clearParams();
xhr.setParam("since_id",lastnews);
xhr.setParam("count",50)
});
break;
case "Search":
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/search");
break;
case "Notifications":
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/friendica/notification");
xhr.clearParams();
break;
case "Direct Messages":
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/direct_messages/all");
xhr.clearParams();
break;
case "Public Timeline":
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/statuses/public_timeline");
xhr.clearParams();
break;
case "Favorites":
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/favorites");
xhr.clearParams();
break;
case "Replies":
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/statuses/replies");
xhr.clearParams();
break;
default:
Newsjs.getLastNews(login,db,function(lastnews){
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setApi("/api/statuses/friends_timeline");
xhr.clearParams();
xhr.setParam("since_id",lastnews);
xhr.setParam("count",50)
newstab.newstabstatus="Conversations";
});
}
xhr.get();
if (viewtype==="Conversations"){Newsjs.allchatsfromdb(db,login.username,function(temp){
newsStack.allchats=temp
})}
@ -707,6 +485,44 @@ function updateView(viewtype){//print("lastnews "+lastnews);
//alarm.setAlarm(root.globaloptions.syncinterval);
setBackgroundsync()
}
xhr.setAccount(login);
switch(viewtype){
case "Conversations":
xhr.setApi("/api/statuses/friends_timeline");
xhr.setParam("since_id",lastnews);
xhr.setParam("count",50);
break;
case "Timeline":
xhr.setApi("/api/statuses/friends_timeline");
xhr.setParam("since_id",lastnews);
xhr.setParam("count",50)
break;
case "Search":
xhr.setApi("/api/search");
break;
case "Notifications":
xhr.setApi("/api/friendica/notification");
break;
case "Direct Messages":
xhr.setApi("/api/direct_messages/all");
break;
case "Public Timeline":
xhr.setApi("/api/statuses/public_timeline");
break;
case "Favorites":
xhr.setApi("/api/favorites");
break;
case "Replies":
xhr.setApi("/api/statuses/replies");
break;
default:
xhr.setApi("/api/statuses/friends_timeline");
xhr.setParam("since_id",lastnews);
xhr.setParam("count",50)
newstab.newstabstatus="Conversations";
}
xhr.get();
}
function showGroups(){
@ -732,10 +548,8 @@ function setBackgroundsync(){
function getGroupnews(list){
newstab.newstabstatus="Group news";
newsBusy.running=true;
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
xhr.setAccount(login);
xhr.setApi("/api/lists/statuses");
xhr.clearParams();
xhr.setParam("list_id",list)
xhr.get();
}

View file

@ -82,12 +82,23 @@ var html=[//Smileys
'\ud83d\ude4E',
'\ud83d\ude4F',
'\ud83e\udd2F',
'\uD83E\uDD17',
'\uD83E\uDD14',
'\uD83E\uDD73',
'\uD83E\uDD21',
'\uD83D\uDC4D',
'\uD83D\uDC94',
'\u2764\uFE0F',
'\uD83D\uDCA9',
'\uD83D\uDC2D',
'\uD83D\uDC2E',
'\uD83D\uDC31',
'\uD83D\uDCAF',
'\uD83C\uDF82',
'\uD83C\uDF89',
'\uD83C\uDF81',
'\uD83C\uDF08',
'\uD83D\uDC80',
'\u2639',
'\u263B',
//Weather

View file

@ -1,47 +0,0 @@
<html>
<head>
<title>-1</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
</head>
<body bgcolor="black" marginwidth="0" marginheight="0">
<div id="player"></div>
<script>
function getVideoId() {
return window.location.href.slice(window.location.href.indexOf('?') + 1);
}
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
console.log("Videoid: "+getVideoId());
player = new YT.Player('player', {
playerVars: { 'html5': 1, 'iv_load_policy': 3, 'autoplay': 1 },
frameborder: '0',
height: '100%',
width: '100%',
videoId: getVideoId(),
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(event) {
document.title = 0;
event.target.playVideo();
}
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING) {
document.title = 1;
} else if (event.data == YT.PlayerState.ENDED || event.data == YT.PlayerState.PAUSED) {
document.title = 2;
}
}
</script>
</body>
</html>