v0.5.3 events and indentation
This commit is contained in:
parent
575c1b0e1e
commit
18c7255b91
103 changed files with 1601 additions and 1906 deletions
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://git.friendi.ca/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
// 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://git.friendi.ca/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
// 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
// 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
// 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
|
||||
|
|
|
@ -73,8 +73,10 @@ int main(int argc, char *argv[]) {
|
|||
//return app.exec();
|
||||
}
|
||||
else{
|
||||
QtWebEngine::initialize();
|
||||
QApplication app(argc, argv);
|
||||
QQuickView view;
|
||||
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
QTranslator qtTranslator;
|
||||
qtTranslator.load("friendiqa-" + QLocale::system().name(),":/translations");
|
||||
app.installTranslator(&qtTranslator);
|
||||
|
@ -89,7 +91,7 @@ int main(int argc, char *argv[]) {
|
|||
view.rootContext()->setContextProperty("alarm", alarm);
|
||||
UPDATENEWS* updatenews = UPDATENEWS::instance();
|
||||
view.rootContext()->setContextProperty("updatenews", updatenews);
|
||||
QtWebEngine::initialize();
|
||||
|
||||
view.setSource(QUrl("qrc:/qml/friendiqa.qml"));
|
||||
view.show();
|
||||
view.connect(view.rootContext()->engine(), SIGNAL(quit()), &app, SLOT(quit()));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
// 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
// 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://git.friendi.ca/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
// 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
|
||||
|
@ -128,18 +128,18 @@ void UPDATENEWS::login()
|
|||
QSqlQuery synctimequery("SELECT * FROM globaloptions WHERE k='lastsync'",m_db);
|
||||
if (synctimequery.next()){
|
||||
QSqlQuery synctimequery2("UPDATE globaloptions SET v='"+QString::number(QDateTime::currentSecsSinceEpoch()) + "' WHERE k = 'lastsync'",m_db);
|
||||
if(!(synctimequery2.exec())) {qDebug()<<synctimequery2.lastError();}
|
||||
qDebug() << " synctimequery ";
|
||||
if(!(synctimequery2.exec())) {qDebug()<<" synctimequery2 " << synctimequery2.lastError();}
|
||||
//qDebug() << " synctimequery ";
|
||||
} else {
|
||||
qDebug() << "INSERT INTO globaloptions(k,v) VALUES('lastsync','"+QString::number(QDateTime::currentSecsSinceEpoch()) + "'";
|
||||
//qDebug() << "INSERT INTO globaloptions(k,v) VALUES('lastsync','"+QString::number(QDateTime::currentSecsSinceEpoch()) + "'";
|
||||
QSqlQuery synctimequery3("INSERT INTO globaloptions(k,v) VALUES('lastsync','"+QString::number(QDateTime::currentSecsSinceEpoch()) + "')",m_db);
|
||||
if(!(synctimequery3.exec())) {qDebug()<<synctimequery3.lastError();}
|
||||
if(!(synctimequery3.exec())) {qDebug() << " synctimequery3 " << synctimequery3.lastError();}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void UPDATENEWS::startsync()
|
||||
{ //qDebug()<<"Friendiqa start syncing " <<synclist.length()<<" index "<<syncindex;
|
||||
{ qDebug()<<"Friendiqa start syncing "<<syncindex <<" of "<<synclist.length();
|
||||
QObject::connect(&xhr,SIGNAL(success(QByteArray,QString)),this,SLOT(store(QByteArray,QString)));
|
||||
QObject::connect(&xhr,SIGNAL(error(QString,QString,QString,int)),this,SLOT(showError(QString,QString,QString,int)));
|
||||
if (syncindex<synclist.length()){
|
||||
|
@ -151,6 +151,8 @@ void UPDATENEWS::startsync()
|
|||
directmessages();
|
||||
} else if (synclist[syncindex]=="sync_Notifications") {
|
||||
notifications();
|
||||
} else if (synclist[syncindex]=="sync_Events") {
|
||||
events();
|
||||
}
|
||||
} else if (syncindex==synclist.length()) {
|
||||
m_api="";
|
||||
|
@ -159,6 +161,7 @@ void UPDATENEWS::startsync()
|
|||
synclist.clear();
|
||||
m_db.close();
|
||||
m_db.removeDatabase(m_db.connectionName());
|
||||
QObject::disconnect(&xhr,SIGNAL(error(QString,QString,QString,int)),this,SLOT(showError(QString,QString,QString,int)));
|
||||
emit quitapp();
|
||||
alarm.setAlarm(m_updateInterval);
|
||||
m_updateInterval=0;
|
||||
|
@ -239,6 +242,28 @@ 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()){
|
||||
if (query.first()){
|
||||
QString lastid=query.value(0).toString();
|
||||
xhr.setParam("since_id",lastid);
|
||||
}
|
||||
}
|
||||
xhr.setParam("count","30");
|
||||
xhr.get();
|
||||
QObject::disconnect(&xhr,SIGNAL(success(QByteArray,QString)),this,SLOT(store(QByteArray,QString)));
|
||||
QObject::connect(&xhr,SIGNAL(success(QByteArray,QString)),this,SLOT(storeEvents(QByteArray,QString)));
|
||||
QObject::connect(&xhr,SIGNAL(error(QString,QString,QString,int)),this,SLOT(showError(QString,QString,QString,int)));
|
||||
//QObject::connect(&xhr, SIGNAL(downloaded(QString, QString, QString, int)), this, SLOT(updateImageLocation(QString,QString, QString, int)));
|
||||
}
|
||||
|
||||
|
||||
void UPDATENEWS::store(QByteArray serverreply,QString apiname)
|
||||
{ if (apiname!=m_api || xhr.downloadtype()!=""){} else {
|
||||
QJsonDocument news;
|
||||
|
@ -328,7 +353,7 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
|
|||
query.bindValue(16, newsitem["url"]);
|
||||
}
|
||||
|
||||
if(!(query.exec())) {qDebug()<<query.lastError();}
|
||||
if(!(query.exec())) {qDebug()<< "store news " << query.lastError();}
|
||||
|
||||
// notifications
|
||||
if (apiname=="/api/statuses/friends_timeline"){
|
||||
|
@ -352,7 +377,7 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
|
|||
}
|
||||
}
|
||||
}catch(...){
|
||||
qDebug() << "Friendiqasync Error inserting news" << newsitem["text"].toString() << " " << newsitem.toString();
|
||||
//qDebug() << "Friendiqasync Error inserting news" << newsitem["text"].toString() << " " << newsitem.toString();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -387,7 +412,7 @@ void UPDATENEWS::updateImageLocation(QString downloadtype,QString imageurl, QStr
|
|||
testquery.first();
|
||||
//qDebug()<< "update imageurl for " <<imageurl << " from " <<testquery.value(0).toString() <<" to "<< filename <<" index " << index << " newcontactnames.length " <<newcontactnames.length();
|
||||
QSqlQuery query("UPDATE contacts SET profile_image='"+ filename +"' WHERE profile_image_url ='"+imageurl+ "' AND username = '" +username+"'",m_db);
|
||||
query.exec();
|
||||
if(!(query.exec())) {qDebug()<< "updateImagelocation " << query.lastError();}
|
||||
if (index==(newcontactnames.length()-1)){
|
||||
newcontactnames.clear();
|
||||
newcontactimagelinks.clear();
|
||||
|
@ -546,7 +571,7 @@ void UPDATENEWS::updateContacts(QList<QJsonValue> contacts){
|
|||
query.bindValue(16,contact["time_zone"].toString());
|
||||
query.bindValue(17,contact["statuses_count"].toInt());
|
||||
query.bindValue(18,contact["following"].toBool());
|
||||
query.bindValue(19,contact["verfied"].toBool());
|
||||
query.bindValue(19,contact["verified"].toBool());
|
||||
query.bindValue(20,contact["statusnet_blocking"].toBool());
|
||||
query.bindValue(21,contact["notifications"].toBool());
|
||||
query.bindValue(22,contact["statusnet_profile_url"]);
|
||||
|
@ -559,13 +584,65 @@ void UPDATENEWS::updateContacts(QList<QJsonValue> contacts){
|
|||
query.bindValue(26,timestamp);
|
||||
|
||||
}
|
||||
query.exec() ;
|
||||
if(!(query.exec())) {qDebug()<< "updatecontacts " << query.lastError();}
|
||||
} catch(...){
|
||||
qDebug() << "Friendiqasync Error inserting contact" << contact["screen_name"] << " " << contact.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UPDATENEWS::storeEvents(QByteArray serverreply,QString apiname)
|
||||
{ if (apiname!=m_api || xhr.downloadtype()!=""){} else {
|
||||
QJsonDocument events;
|
||||
//qDebug()<<apiname << serverreply;
|
||||
QJsonParseError jsonerror;
|
||||
events=QJsonDocument::fromJson(serverreply,&jsonerror);
|
||||
if (events.isArray()){
|
||||
for (int i=0; i < events.array().count();i++){
|
||||
QJsonValue eventitem=events[i];
|
||||
try{
|
||||
QSqlQuery query(m_db);
|
||||
query.prepare("INSERT INTO events (username,id,cid,start,end,title,uri,desc,location,type,nofinish,adjust,ignore,permissions) " "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
query.bindValue(0,username);
|
||||
query.bindValue(1,eventitem["id"].toInt());
|
||||
query.bindValue(2,eventitem["cid"].toInt());
|
||||
QString sourcedateStart=eventitem["startTime"].toString();
|
||||
query.bindValue(3,QDateTime::fromString(sourcedateStart,Qt::ISODate).toMSecsSinceEpoch() );
|
||||
QString sourcedateEnd=eventitem["endTime"].toString();
|
||||
query.bindValue(4,QDateTime::fromString(sourcedateEnd,Qt::ISODate).toMSecsSinceEpoch() );
|
||||
query.bindValue(5,eventitem["name"].toString());
|
||||
query.bindValue(6,eventitem["uri"].toString());
|
||||
query.bindValue(7,eventitem["desc"].toString().toUtf8().toBase64());
|
||||
query.bindValue(8,eventitem["place"].toString());
|
||||
query.bindValue(9,eventitem["type"].toString());
|
||||
query.bindValue(10,eventitem["nofinsh"].toInt());
|
||||
query.bindValue(11,eventitem["adjust"].toInt());
|
||||
query.bindValue(12,eventitem["ignore"].toInt());
|
||||
QJsonArray permissions; permissions={eventitem["allow_cid"].toString().replace("<","[").replace(">","]"),eventitem["allow_gid"].toString().replace("<","[").replace(">","]"),eventitem["deny_cid"].toString().replace("<","[").replace(">","]"),eventitem["deny_gid"].toString().replace("<","[").replace(">","]")};
|
||||
QJsonDocument permissionDocument; permissionDocument.setArray(permissions);
|
||||
query.bindValue(13,permissionDocument.toJson(QJsonDocument::Compact));
|
||||
if(!(query.exec())) {qDebug()<< "store events " << query.lastError();}
|
||||
} catch(...){
|
||||
qDebug() << "Friendiqasync Error event" << eventitem["name"];
|
||||
}
|
||||
}
|
||||
emit this->success(m_api);
|
||||
}
|
||||
}
|
||||
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);
|
||||
while (eventnotifyquery.next()) {
|
||||
alarm.notify("Event: "+ QDateTime::fromMSecsSinceEpoch(eventnotifyquery.value(0).toLongLong()).toString("dd.MM.yyyy hh:mm"),eventnotifyquery.value(1).toString(),1);
|
||||
}
|
||||
}
|
||||
if(m_updateInterval!=0){
|
||||
syncindex+=1;
|
||||
startsync();
|
||||
}
|
||||
QObject::disconnect(&xhr,SIGNAL(success(QByteArray,QString)),this,SLOT(storeEvents(QByteArray,QString)));
|
||||
}
|
||||
|
||||
QString UPDATENEWS::url() const
|
||||
{
|
||||
return m_url;
|
||||
|
@ -583,7 +660,7 @@ void UPDATENEWS::startImagedownload()
|
|||
|
||||
void UPDATENEWS::showError(QString data, QString url,QString api, int code )
|
||||
{
|
||||
qDebug() << "showerror " << api << " data " << data;
|
||||
//qDebug() << "showerror " << api << " data " << data;
|
||||
emit this->error(api,data);
|
||||
if (api!=m_api || xhr.downloadtype()!=""){} else{
|
||||
if(m_updateInterval!=0){
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://git.friendi.ca/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
// 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
|
||||
|
@ -68,10 +68,12 @@ public slots:
|
|||
void startsync();
|
||||
void directmessages();
|
||||
void notifications();
|
||||
void events();
|
||||
//void startservice(QString type,QVariantMap map);
|
||||
void startImagedownload();
|
||||
void updateImageLocation(QString downloadtype,QString imageurl, QString filename, int index);
|
||||
void store(QByteArray serverreply,QString apiname);
|
||||
void storeEvents(QByteArray serverreply,QString apiname);
|
||||
void showError(QString data, QString url,QString api, int code);
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
// 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
// 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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
// 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
|
||||
|
@ -292,7 +292,7 @@ void XHR::post()
|
|||
void XHR::onReplyError(QNetworkReply::NetworkError code)
|
||||
{
|
||||
qDebug() << code;
|
||||
emit this->error( bufferToString(), m_url,m_api, (int) code);
|
||||
if(downloadtype()!="contactlist"){emit this->error( bufferToString(), m_url,m_api, (int) code);}
|
||||
buffer.clear();
|
||||
reply->deleteLater();
|
||||
if((downloadtype()=="contactlist")||(downloadtype()=="picturelist")){dlindex=dlindex+1;XHR::getlist();}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Friendiqa
|
||||
// https://github.com/lubuwest/Friendiqa
|
||||
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
|
||||
// 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue