updatenews error bugfix

This commit is contained in:
LubuWest 2023-05-31 20:47:17 +02:00
parent d43c18bb76
commit 59fe1ea0df
16 changed files with 117 additions and 105 deletions

View file

@ -103,9 +103,7 @@ Currently supported:
* Maximum news (deleted after use of Quit button)
* Sync home timeline, replies, DM, Events, friend requests; Notify yes/no
* Hide #nsfw
* OAuth
* OAuth2 as authorization method
# Other
@ -120,7 +118,7 @@ ToDo
# Translations
* German, Spanish, Italian, Hungarian, dutch
* German, Spanish, Italian, Hungarian, Dutch
* To contribute translations: <https://translate.codeberg.org/projects/friendiqa/friendiqa/>
# Install

View file

@ -2,14 +2,6 @@
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.6.8" android:versionCode="34" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- %%INSERT_PERMISSIONS -->
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
<!-- %%INSERT_FEATURES android:requestLegacyExternalStorage="true" -->
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<application android:hardwareAccelerated="true"
@ -96,7 +88,7 @@
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
-->
<meta-data android:name="android.app.extract_android_style" android:value="default"/>
<meta-data android:name="android.app.extract_android_style" android:value="minimal"/>
<!-- extract android style -->
</activity>
@ -138,4 +130,7 @@
</application>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

View file

@ -1 +1 @@
/home/pankraz/ownCloud/clientsync/Friendiqa/v0.6/source-linux/common/oauth.cpp
../../source-linux/common/oauth.cpp

View file

@ -1 +1 @@
/home/pankraz/ownCloud/clientsync/Friendiqa/v0.6/source-linux/common/oauth.h
../../source-linux/common/oauth.h

View file

@ -13,7 +13,7 @@
TEMPLATE = app
TARGET = friendiqa
CONFIG += release
QT += core core-private qml quick gui widgets sql androidextras network networkauth #webengine webview
QT += core core-private qml quick gui widgets sql androidextras network networkauth
include(androidnative.pri/androidnative.pri)
@ -88,8 +88,6 @@ DISTFILES += \
android/src/FriendiqaActivity.java \
android/src/FriendiqaService.java
ANDROID_EXTRA_LIBS = /home/pankraz/android-sdk/android_openssl/latest/arm/libcrypto_1_1.so /home/pankraz/android-sdk/android_openssl/latest/arm/libssl_1_1.so /home/pankraz/android-sdk/android_openssl/latest/arm64/libcrypto_1_1.so /home/pankraz/android-sdk/android_openssl/latest/arm64/libssl_1_1.so /home/pankraz/android-sdk/android_openssl/latest/x86/libcrypto_1_1.so /home/pankraz/android-sdk/android_openssl/latest/x86/libssl_1_1.so /home/pankraz/android-sdk/android_openssl/latest/x86_64/libcrypto_1_1.so /home/pankraz/android-sdk/android_openssl/latest/x86_64/libssl_1_1.so /home/pankraz/android-sdk/android_openssl/latest/arm/libcrypto_1_1.so /home/pankraz/android-sdk/android_openssl/latest/arm/libssl_1_1.so /home/pankraz/android-sdk/android_openssl/latest/arm64/libcrypto_1_1.so /home/pankraz/android-sdk/android_openssl/latest/arm64/libssl_1_1.so /home/pankraz/android-sdk/android_openssl/latest/x86/libcrypto_1_1.so /home/pankraz/android-sdk/android_openssl/latest/x86/libssl_1_1.so /home/pankraz/android-sdk/android_openssl/latest/x86_64/libcrypto_1_1.so /home/pankraz/android-sdk/android_openssl/latest/x86_64/libssl_1_1.so
#ANDROID_ABIS = arm64-v8a
#android: include(/home/pankraz/git/android_openssl/openssl.pri)
android: include(/home/pankraz/android-sdk/android_openssl/openssl.pri)

View file

@ -1,6 +1,6 @@
// This file is part of Friendiqa
// https://github.com/lubuwest/Friendiqa
// Copyright (C) 2020 Marco R. <thomasschmidt45@gmx.net>
// Copyright (C) 2023 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

View file

@ -161,6 +161,7 @@ void UPDATENEWS::login()
QJsonObject currentAccount =acc[usernameindex].toObject();
xhr.setAccount(currentAccount.toVariantMap());
username = currentAccount["username"].toString();
m_url=currentAccount["server"].toString();
}
}
@ -206,7 +207,7 @@ void UPDATENEWS::timeline()
{
m_api="/api/statuses/friends_timeline";
xhr.clearParams();
//xhr.setUrl(m_url);
xhr.setUrl(m_url);
xhr.setApi(m_api);
QSqlQuery query("SELECT status_id FROM news WHERE messagetype=0 AND username='"+ username +"' ORDER BY status_id DESC LIMIT 1",m_db);
if (query.isActive() && query.isSelect()){
@ -226,6 +227,7 @@ void UPDATENEWS::replies()
{
m_api="/api/statuses/replies";
xhr.clearParams();
xhr.setUrl(m_url);
xhr.setApi(m_api);
QSqlQuery query("SELECT status_id FROM news WHERE messagetype=3 AND username='"+ username +"' ORDER BY status_id DESC LIMIT 1",m_db);
if (query.isActive() && query.isSelect()){
@ -245,6 +247,7 @@ void UPDATENEWS::directmessages()
{
m_api="/api/direct_messages/all";
xhr.clearParams();
xhr.setUrl(m_url);
xhr.setApi(m_api);
QSqlQuery query("SELECT status_id FROM news WHERE messagetype=1 AND username='"+ username +"' ORDER BY status_id DESC LIMIT 1",m_db);
if (query.isActive() && query.isSelect()){
@ -263,6 +266,7 @@ void UPDATENEWS::notifications()
{
m_api="/api/friendica/notification";
xhr.clearParams();
xhr.setUrl(m_url);
xhr.setApi(m_api);
xhr.get();
QObject::connect(&xhr,SIGNAL(success(QByteArray,QString)),this,SLOT(store(QByteArray,QString)));
@ -273,6 +277,7 @@ void UPDATENEWS::notifications()
void UPDATENEWS::events()
{ m_api="/api/friendica/events";
xhr.clearParams();
xhr.setUrl(m_url);
xhr.setApi(m_api);
QSqlQuery query("SELECT id FROM events WHERE username='"+ username +"' ORDER BY id DESC LIMIT 1",m_db);
if (query.isActive() && query.isSelect()){
@ -291,6 +296,7 @@ void UPDATENEWS::events()
void UPDATENEWS::friendrequests()
{ m_api="/api/v1/follow_requests";
xhr.clearParams();
xhr.setUrl(m_url);
xhr.setApi(m_api);
xhr.get();
QObject::disconnect(&xhr,SIGNAL(success(QByteArray,QString)),this,SLOT(store(QByteArray,QString)));
@ -300,7 +306,6 @@ void UPDATENEWS::friendrequests()
}
void UPDATENEWS::store(QByteArray serverreply,QString apiname)
{ if (apiname!=m_api || xhr.downloadtype()!=""){} else {
QJsonDocument news;
@ -430,6 +435,7 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
}
}
QList<QJsonValue> newcontacts=findNewContacts(news);
emit this->success(m_api);
if (newcontacts.size()>0){
updateContacts(newcontacts);
startImagedownload("contactlist");
@ -442,7 +448,7 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
}
}
else {
qDebug()<< m_api << "Friendiqa updatenews error " << serverreply <<username ;
qDebug()<< m_api <<username << "Friendiqa updatenews error " << serverreply ;
//emit this->error(m_api,QTextCodec::codecForName("utf-8")->toUnicode(serverreply));
emit this->error(m_api,QString(serverreply));
if(m_syncAll){
@ -454,8 +460,6 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
}
void UPDATENEWS::updateImageLocation(QString downloadtype,QString imageurl, QString filename, int index){
if (downloadtype=="contactlist"){
QSqlQuery testquery("SELECT profile_image FROM contacts WHERE profile_image_url ='"+imageurl+ "' AND username = '" +username+"'",m_db);
@ -812,7 +816,7 @@ void UPDATENEWS::storeEvents(QByteArray serverreply,QString apiname)
}
}
if(notifylist.contains("notify_Events")){
QSqlQuery eventnotifyquery("SELECT start,title FROM events WHERE (start BETWEEN " + QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch()) + " AND "+QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch()+(m_updateInterval*60*1000))+") AND username='"+ username +"'",m_db);
QSqlQuery eventnotifyquery("SELECT start,title FROM events WHERE (start BETWEEN " + QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch()) + " AND "+QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch()+(m_updateInterval*119*1000))+") AND username='"+ username +"'",m_db);
while (eventnotifyquery.next()) {
alarm.notify("Event: "+ QDateTime::fromMSecsSinceEpoch(eventnotifyquery.value(0).toLongLong()).toString("dd.MM.yyyy hh:mm"),eventnotifyquery.value(1).toString(),1);
}

View file

@ -75,6 +75,7 @@ public slots:
private:
QString m_api;
QString m_url;
QString username;
bool m_syncAll;
int syncindex;

View file

@ -363,7 +363,10 @@ void XHR::onRequestFinished()
{
// Save the file here
//qDebug() << "buffer " << buffer;
if (buffer.isNull()){qDebug() << "File empty"<<m_url; buffer.clear(); emit this->error(m_downloadtype,m_url,m_api,1);}
if (buffer.isNull()){qDebug() << "File empty"<<m_url;
buffer.clear();
emit this->error(m_downloadtype,m_url,m_api,1);
}
else if (m_downloadtype=="picturelist") {
QJsonDocument jsonResponse = QJsonDocument::fromJson(buffer);
QJsonObject jsonObject = jsonResponse.object();
@ -391,7 +394,6 @@ void XHR::onRequestFinished()
jsonObject["data"]="";
jsonObject["filename"]=helpfile+filesuffix;
emit this->downloadedjson(m_downloadtype,m_url,m_filename,dlindex,jsonObject);
if(downloadtype()=="picturelist"){dlindex=dlindex+1;XHR::getlist();}
}
else {
QFile file(m_filename);
@ -400,10 +402,11 @@ void XHR::onRequestFinished()
buffer.clear();
file.close();
emit this->downloaded(m_downloadtype,m_url,m_filename,dlindex);
if(downloadtype()=="contactlist" || downloadtype()=="friendrequests"){dlindex=dlindex+1;XHR::getlist();}
//reply->deleteLater();
}
if(downloadtype()=="contactlist" || downloadtype()=="friendrequests" || downloadtype()=="picturelist"){
dlindex=dlindex+1;XHR::getlist();
}
}
void XHR::onReadyRead()

View file

@ -43,11 +43,9 @@ Dialog {
standardButtons: Dialog.Yes | Dialog.No
modal: true
onAccepted: {
// username.visible=true;
// password.visible=true;
username.visible=true;
ruleButton.visible=false;
// confirmation.visible=true
accountPage.state="oauth"
confirmationOAuth.visible=true
}
onRejected: {close()}
ScrollView{

View file

@ -67,10 +67,13 @@ Page{
else{
if (users.length==0){Service.setDefaultOptions(db);}
if (userconfig.APIVersion!=""){userconfig.password=""}
if (imagestoredir==""){imagestoredir=filesystem.homePath+"/"+credentials.username+"/";
userconfig.imagestore=imagestoredir}
if(userconfig.imagestore == filesystem.homePath+"/"+username.text+"/")
{filesystem.makePath(filesystem.homePath+"/"+username.text);}
if (imagestoredir==""){
imagestoredir=filesystem.homePath+"/"+credentials.username+"/";
userconfig.imagestore=imagestoredir
}
if(userconfig.imagestore == filesystem.homePath+"/"+credentials.username+"/")
{filesystem.makePath(filesystem.homePath+"/"+credentials.username);}
print("imagestoredir "+imagestoredir)
filesystem.Directory=imagestoredir;
filesystem.makeDir("contacts");
filesystem.makeDir("albums");
@ -373,7 +376,7 @@ Page{
rulestext=rulestext+rulesarray[rule].text+"\n"
}
var component = Qt.createComponent("qrc:/qml/configqml/AcceptRules.qml");
var rulesdialog = component.createObject(root,{"rules": rulestext});
var rulesdialog = component.createObject(accountPage,{"rules": rulestext});
rulesdialog.open();
}
else if(api=="/api/statusnet/config"){
@ -385,7 +388,7 @@ Page{
catch(e){print(e)}
}
else if (api=="/api/v1/apps"){
else if (api=="/api/v1/apps"){print("/api/v1/apps text "+text)
let app=JSON.parse(text);
accountPage.appdata=app;
oauth2.setClientId(app.client_id);
@ -537,23 +540,23 @@ Page{
states: [
State {
name: "new_oauth"
PropertyChanges { target: username; visible: false }
PropertyChanges { target: password; visible: false}
PropertyChanges { target: ruleButton; visible: true}
PropertyChanges {target: username; visible: false }
PropertyChanges {target: password; visible: false}
PropertyChanges {target: ruleButton; visible: true}
},
State {
name:"oauth"
PropertyChanges {target: username; visible: true}
PropertyChanges { target: password; visible: false}
PropertyChanges {target: password; visible: false}
PropertyChanges {target: confirmationOAuth; visible: true}
PropertyChanges {target: setDefault; visible: true}
PropertyChanges { target: confirmation; visible: false}
PropertyChanges {target: confirmation; visible: false}
},
State{
name:"password"
PropertyChanges { target: username; visible: true }
PropertyChanges { target: password; visible: true}
PropertyChanges { target: confirmation; visible: true}
PropertyChanges {target: username; visible: true }
PropertyChanges {target: password; visible: true}
PropertyChanges {target: confirmation; visible: true}
PropertyChanges {target: confirmationOAuth; visible: false}
}
]
@ -565,6 +568,10 @@ Page{
})
accountPage.users=storedUsers;
Service.readConfig(db,function(obj){
if (obj==null){
accountPage.state="new_oauth"
}
else{
userButton.text=obj.username;
servername.text=obj.server;
serverModel.insert(0,{text:obj.server})
@ -577,6 +584,8 @@ Page{
if(obj.password!=""){accountPage.state="password"}
else if (obj.token!=""){accountPage.state="oauth"}
else {accountPage.state="new_oauth"}
}
},"isActive",0)
})}
catch (e){//print("onCompleted" +users.count +e)

View file

@ -80,7 +80,7 @@ ApplicationWindow{
color: Material.backgroundColor
function onLoginChanged(login){
if(login==""){rootstackView.push("qrc:/qml/configqml/AccountPage.qml")}
if(login=="" || login==null){rootstackView.push("qrc:/qml/configqml/AccountPage.qml")}
else{
// if (login.newsViewType!="" || login.newsViewType!=null){
// newstab.newstabstatus=login.newsViewType;}

View file

@ -39,7 +39,6 @@ Item {
width: parent.width
Label{
y:0.5*root.fontFactor*osSettings.bigFontSize
width:parent.width
height: 1.5*osSettings.bigFontSize*root.fontFactor
@ -47,11 +46,6 @@ Item {
font.pointSize: osSettings.bigFontSize
text: account.username
}
// Label{
// text:login.hasOwnProperty("server")?"@"+login.server:""
// font.pixelSize: 5*mm
// width: parent.width
// }
Label{
y:2*root.fontFactor*osSettings.bigFontSize
@ -64,6 +58,7 @@ Item {
login=account;
if(!wideScreen){leftDrawerAndroid.close()}
// newstypeSignal("refresh")
newsBusy.running=true;
updatenews.setDatabase();
updatenews.login();
updatenews.startsync();

View file

@ -124,7 +124,7 @@ Rectangle{
messageSend.reply_to_user=newsitemobject.user.screen_name;
messageSend.parentId=newsitemobject.id
} else {
messageSend.state="";
messageSend.state=null;
messageSend.reply_to_user="";
messageSend.parentId="";
bodyField.text="";

View file

@ -38,7 +38,6 @@ import "qrc:/js/service.js" as Service
Rectangle{
id: newsStack
//anchors.fill: parent
width: parent.width
height: parent.height
color: Material.backgroundColor
@ -47,17 +46,6 @@ Rectangle{
property int lastnewsid:0
property string newstabstatus: ""
BusyIndicator{
id: newsBusy
anchors.horizontalCenter: parent.horizontalCenter
anchors.top:parent.top
anchors.topMargin: mm
width: 2*root.fontFactor*osSettings.bigFontSize
height: 2*root.fontFactor*osSettings.bigFontSize
z:2
running: false
}
function newstypeHandling(newstype){
try{newsBusy.running=true}catch(e){print(e)};
root.replySignal("");
@ -215,14 +203,37 @@ Rectangle{
xhr.get()
}
}
function loadDBNews(){
var messagetype=0;
switch(newsSwipeview.stacktype){
case "Home":messagetype=0;break;
case "DirectMessages": messagetype=1;break;
case "Notifications":messagetype=2;break;
case "Replies":messagetype=3;break;
default:messagetype=0;
}
if((newstabstatus=="Conversations")&&(newsSwipeview.stacktype=="Home")){
Newsjs.chatsfromdb(db,login,messagetype,[],function(dbnews,lastid){
lastnewsid=lastid;
showNews(dbnews);
})
}
else{
Newsjs.newsfromdb(db,login,messagetype,function(dbnews,lastid){
lastnewsid=lastid;
showNews(dbnews)
})
}
}
Connections{
target:xhr
function onError(data,url,api,code){
//if (data !="contactlist"){Helperjs.showMessage(qsTr("Network Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root);}
newsBusy.running=false;
}
function onSuccess(data,api){
// downloadNotice.text=downloadNotice.text+ "\n xhr finished "+Date.now();
const newsApiArray=["/api/statuses/friends_timeline",
"/api/direct_messages/all",
"/api/direct_messages/conversation",
@ -244,6 +255,16 @@ Rectangle{
}
}
}
Connections{
target:updatenews
function onError(api,data){print("updatnews error "+api);
newsBusy.running=false;
}
function onSuccess(api){
loadDBNews();
newsBusy.running=false;
}
}
Timer {id:replytimer; interval: 1000; running: false; repeat: false
onTriggered: {
@ -440,30 +461,8 @@ Rectangle{
root.searchSignal.connect(search);
try{newsModel.clear()} catch(e){}
swipeIndicator.visible=true;
//newsSwipeview.height=rootstack.height
//newsSwipeview.y=5*mm;
//rootStackItem.state=""
root.globaloptions.hasOwnProperty("newsViewType")?newstab.newstabstatus=root.globaloptions.newsViewType:newstab.newstabstatus="Conversations";
newstabstatus=newstab.newstabstatus;
var messagetype=0;
switch(newsSwipeview.stacktype){
case "Home":messagetype=0;break;
case "DirectMessages": messagetype=1;break;
case "Notifications":messagetype=2;break;
case "Replies":messagetype=3;break;
default:messagetype=0;
}
if((newstabstatus=="Conversations")&&(newsSwipeview.stacktype=="Home")){
Newsjs.chatsfromdb(db,login,messagetype,[],function(dbnews,lastid){
lastnewsid=lastid;
showNews(dbnews);
})
}
else{
Newsjs.newsfromdb(db,login,messagetype,function(dbnews,lastid){
lastnewsid=lastid;
showNews(dbnews)
})}
loadDBNews()
}
}

View file

@ -192,6 +192,7 @@ Rectangle{
//onLoaded: newsSwipeview.stacktype="Notifications"
}
}
PageIndicator {
id: swipeIndicator
z:5
@ -203,5 +204,16 @@ Rectangle{
anchors.horizontalCenter: parent.horizontalCenter
}
BusyIndicator{
id: newsBusy
anchors.horizontalCenter: newsSwipeview.horizontalCenter
anchors.top:parent.top
anchors.topMargin: mm
width: 2*root.fontFactor*osSettings.bigFontSize
height: 2*root.fontFactor*osSettings.bigFontSize
z:2
running: false
}
Component.onCompleted: {root.directmessageSignal.connect(newsSwipeview.onDirectMessage)}
}