version v0.6
This commit is contained in:
parent
bdc28e632e
commit
8482bde3ed
86 changed files with 7064 additions and 3208 deletions
|
@ -61,11 +61,11 @@ UPDATENEWS::UPDATENEWS(QObject *parent) : QObject(parent)
|
|||
|
||||
void UPDATENEWS::setUrl(QString url)
|
||||
{
|
||||
if (url!=m_url) {
|
||||
m_url = url;
|
||||
xhr.setUrl(url);
|
||||
emit urlChanged(m_url);
|
||||
}
|
||||
if (url!=m_url) {
|
||||
m_url = url;
|
||||
xhr.setUrl(url);
|
||||
emit urlChanged(m_url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,10 +77,10 @@ void UPDATENEWS::setDatabase()
|
|||
m_db.setDatabaseName(QUrl("file://"+db_url+".sqlite").toLocalFile());
|
||||
//qDebug() << db_url;
|
||||
|
||||
if (!m_db.open())
|
||||
{
|
||||
qDebug() << "Error: connection with database fail " << m_db.lastError();
|
||||
}
|
||||
if (!m_db.open())
|
||||
{
|
||||
qDebug() << "Error: connection with database fail " << m_db.lastError();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,23 +89,23 @@ void UPDATENEWS::login()
|
|||
QSqlQuery query("SELECT * FROM config WHERE isActive=0",m_db);
|
||||
while (query.next())
|
||||
{
|
||||
username = query.value(1).toString();
|
||||
QByteArray bpassword=query.value(2).toByteArray();
|
||||
QString password=QByteArray::fromBase64(bpassword);
|
||||
m_login=username+":"+password ;
|
||||
xhr.setLogin(m_login);
|
||||
m_url=query.value(0).toString();
|
||||
xhr.setUrl(m_url);
|
||||
m_imagedir=query.value(3).toString();
|
||||
xhr.setImagedir(m_imagedir);
|
||||
QString isActive=query.value(7).toString();
|
||||
username = query.value(1).toString();
|
||||
QByteArray bpassword=query.value(2).toByteArray();
|
||||
QString password=QByteArray::fromBase64(bpassword);
|
||||
m_login=username+":"+password ;
|
||||
xhr.setLogin(m_login);
|
||||
m_url=query.value(0).toString();
|
||||
xhr.setUrl(m_url);
|
||||
m_imagedir=query.value(3).toString();
|
||||
xhr.setImagedir(m_imagedir);
|
||||
QString isActive=query.value(7).toString();
|
||||
}
|
||||
//m_updateInterval=query.value(5).toInt();
|
||||
//m_updateInterval=query.value(5).toInt();
|
||||
|
||||
|
||||
QSqlQuery syncquery("SELECT * FROM globaloptions",m_db);
|
||||
// QSqlQuery delquery("DELETE FROM globaloptions WHERE k='sync_interval'",m_db);
|
||||
// delquery.exec();
|
||||
// QSqlQuery delquery("DELETE FROM globaloptions WHERE k='sync_interval'",m_db);
|
||||
// delquery.exec();
|
||||
m_updateInterval=0;
|
||||
syncindex=0;
|
||||
synclist.clear();
|
||||
|
@ -136,33 +136,35 @@ void UPDATENEWS::login()
|
|||
|
||||
void UPDATENEWS::startsync()
|
||||
{ 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()){
|
||||
if (synclist[syncindex]=="sync_Timeline"){
|
||||
timeline();
|
||||
} else if (synclist[syncindex]=="sync_Replies") {
|
||||
replies();
|
||||
} else if (synclist[syncindex]=="sync_DirectMessages") {
|
||||
directmessages();
|
||||
} else if (synclist[syncindex]=="sync_Notifications") {
|
||||
notifications();
|
||||
} else if (synclist[syncindex]=="sync_Events") {
|
||||
events();
|
||||
}
|
||||
} else if (syncindex==synclist.length()) {
|
||||
m_api="";
|
||||
if(m_updateInterval!=0){
|
||||
syncindex=0;
|
||||
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;
|
||||
}
|
||||
}
|
||||
//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()){
|
||||
if (synclist[syncindex]=="sync_Timeline"){
|
||||
timeline();
|
||||
} else if (synclist[syncindex]=="sync_Replies") {
|
||||
replies();
|
||||
} else if (synclist[syncindex]=="sync_DirectMessages") {
|
||||
directmessages();
|
||||
} else if (synclist[syncindex]=="sync_Notifications") {
|
||||
notifications();
|
||||
} else if (synclist[syncindex]=="sync_FriendRequests") {
|
||||
friendrequests();
|
||||
}else if (synclist[syncindex]=="sync_Events") {
|
||||
events();
|
||||
}
|
||||
} else if (syncindex==synclist.length()) {
|
||||
m_api="";
|
||||
if(m_updateInterval!=0){
|
||||
syncindex=0;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -237,10 +239,8 @@ void UPDATENEWS::notifications()
|
|||
QObject::connect(&xhr, SIGNAL(downloaded(QString, QString, QString, int)), this, SLOT(updateImageLocation(QString,QString, QString, int)));
|
||||
}
|
||||
|
||||
|
||||
void UPDATENEWS::events()
|
||||
{
|
||||
m_api="/api/friendica/events";
|
||||
{ m_api="/api/friendica/events";
|
||||
xhr.clearParams();
|
||||
xhr.setUrl(m_url);
|
||||
xhr.setApi(m_api);
|
||||
|
@ -258,11 +258,24 @@ void UPDATENEWS::events()
|
|||
QObject::connect(&xhr,SIGNAL(error(QString,QString,QString,int)),this,SLOT(showError(QString,QString,QString,int)));
|
||||
}
|
||||
|
||||
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)));
|
||||
QObject::connect(&xhr,SIGNAL(success(QByteArray,QString)),this,SLOT(storeFriendrequests(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;
|
||||
//qDebug()<<apiname << serverreply;
|
||||
//qDebug()<<apiname;
|
||||
QJsonParseError jsonerror;
|
||||
news=QJsonDocument::fromJson(serverreply,&jsonerror);
|
||||
if (news.isArray()){
|
||||
|
@ -274,7 +287,9 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
|
|||
if (testquery.first()) {continue;}
|
||||
}
|
||||
QSqlQuery query(m_db);
|
||||
query.prepare("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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
query.prepare("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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
query.bindValue(0,username);
|
||||
query.bindValue(1,"0");
|
||||
query.bindValue(2, newsitem["text"].toString().toUtf8().toBase64());
|
||||
|
@ -292,7 +307,9 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
|
|||
QString friendicaHtml="<b>" + newsitem["friendica_title"].toString() +"</b><br><br>"+newsitem["friendica_html"].toString();
|
||||
query.bindValue(11, friendicaHtml.toUtf8().toBase64());}
|
||||
else{query.bindValue(11, newsitem["friendica_html"].toString().toUtf8().toBase64());}
|
||||
query.bindValue(12, newsitem["statusnet_conversation_id"].toInt());
|
||||
if (newsitem["statusnet_conversation_id"].isDouble()){
|
||||
query.bindValue(12, newsitem["statusnet_conversation_id"].toInt());
|
||||
}else{query.bindValue(12, newsitem["statusnet_conversation_id"].toString());}
|
||||
QJsonArray likeArray;QJsonArray dislikeArray;QJsonArray attendyesArray;QJsonArray attendnoArray;QJsonArray attendmaybeArray;
|
||||
if (newsitem.toObject().contains("friendica_activities")){
|
||||
for (int a=0; a < newsitem["friendica_activities"]["like"].toArray().count();a++){
|
||||
|
@ -310,7 +327,7 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
|
|||
for (int e = 0; e < newsitem["friendica_activities"]["attendmaybe"].toArray().count();e++){
|
||||
attendmaybeArray.append(newsitem["friendica_activities"]["attendmaybe"][e]["url"].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
QJsonArray friendica_activities; friendica_activities={likeArray,dislikeArray,attendyesArray,attendnoArray,attendmaybeArray};
|
||||
QJsonDocument activities; activities.setArray(friendica_activities);
|
||||
query.bindValue(13,activities.toJson(QJsonDocument::Compact).toBase64());
|
||||
|
@ -326,7 +343,7 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
|
|||
query.bindValue(16, newsitem["friendica_author"]["url"]);
|
||||
}else {
|
||||
query.bindValue(16, newsitem["user"]["url"]);
|
||||
}
|
||||
}
|
||||
|
||||
if (apiname=="/api/statuses/replies"){
|
||||
query.bindValue(1,"3");
|
||||
|
@ -382,7 +399,7 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
|
|||
QList<QJsonValue> newcontacts=findNewContacts(news);
|
||||
if (newcontacts.size()>0){
|
||||
updateContacts(newcontacts);
|
||||
startImagedownload();
|
||||
startImagedownload("contactlist");
|
||||
|
||||
} else {
|
||||
if(m_updateInterval!=0){
|
||||
|
@ -404,6 +421,7 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
|
|||
|
||||
|
||||
void UPDATENEWS::updateImageLocation(QString downloadtype,QString imageurl, QString filename, int index){
|
||||
//qDebug()<< "update Imagelocation " << downloadtype << " " << imageurl << " " << filename;
|
||||
if (downloadtype=="contactlist"){
|
||||
QSqlQuery testquery("SELECT profile_image FROM contacts WHERE profile_image_url ='"+imageurl+ "' AND username = '" +username+"'",m_db);
|
||||
testquery.first();
|
||||
|
@ -413,6 +431,22 @@ void UPDATENEWS::updateImageLocation(QString downloadtype,QString imageurl, QStr
|
|||
newcontactnames.clear();
|
||||
newcontactimagelinks.clear();
|
||||
if(m_updateInterval!=0){
|
||||
qDebug()<< "contactdownload finished!";
|
||||
syncindex+=1;
|
||||
startsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (downloadtype=="friendrequests"){
|
||||
QSqlQuery testquery("SELECT avatar_static FROM friendshiprequests WHERE avatar ='"+imageurl+ "' AND username = '" +username+"'",m_db);
|
||||
testquery.first();
|
||||
QSqlQuery query("UPDATE friendshiprequests SET avatar_static='"+ filename +"' WHERE avatar ='"+imageurl+ "' AND username = '" +username+"'",m_db);
|
||||
if(!(query.exec())) {qDebug()<< "update friendrequests Imagelocation " << query.lastError();}
|
||||
if (index==(newcontactnames.length()-1)){
|
||||
newcontactnames.clear();
|
||||
newcontactimagelinks.clear();
|
||||
if(m_updateInterval!=0){
|
||||
qDebug()<< "friendrequests finished!";
|
||||
syncindex+=1;
|
||||
startsync();
|
||||
}
|
||||
|
@ -421,6 +455,7 @@ void UPDATENEWS::updateImageLocation(QString downloadtype,QString imageurl, QStr
|
|||
}
|
||||
|
||||
QJsonObject UPDATENEWS::findNotificationContact(QString contacturl){
|
||||
//qDebug()<< "findNotificationContact "<<contacturl;
|
||||
QSqlQuery query("SELECT id,url FROM contacts WHERE url='"+contacturl+"' AND username='"+ username+"'",m_db);
|
||||
query.first();
|
||||
QJsonObject contact{
|
||||
|
@ -442,7 +477,7 @@ QList <QJsonValue> UPDATENEWS::findNewContacts(QJsonDocument news){
|
|||
//main contacts
|
||||
if (news[i].toObject().contains("sender") ){
|
||||
if(imageurls.contains(news[i]["sender"]["profile_image_url"].toString().section('?',0,0)) || newcontactimagelinks.contains(news[i]["sender"]["profile_image_url"].toString().section('?',0,0))){
|
||||
}
|
||||
}
|
||||
else{
|
||||
newcontacts.append(news[i]["sender"]);
|
||||
newcontactimagelinks.append(news[i]["sender"]["profile_image_url"].toString().section('?',0,0));
|
||||
|
@ -462,7 +497,7 @@ QList <QJsonValue> UPDATENEWS::findNewContacts(QJsonDocument news){
|
|||
if (news[i].toObject().contains("friendica_activities") ){
|
||||
for (int a=0; a < news[i]["friendica_activities"]["like"].toArray().count();a++){
|
||||
if(imageurls.contains(news[i]["friendica_activities"]["like"][a]["profile_image_url"].toString().section('?',0,0)) || newcontactimagelinks.contains(news[i]["friendica_activities"]["like"][a]["profile_image_url"].toString().section('?',0,0))){
|
||||
}
|
||||
}
|
||||
else{
|
||||
newcontacts.append(news[i]["friendica_activities"]["like"][a]);
|
||||
newcontactimagelinks.append(news[i]["friendica_activities"]["like"][a]["profile_image_url"].toString().section('?',0,0));
|
||||
|
@ -471,7 +506,7 @@ QList <QJsonValue> UPDATENEWS::findNewContacts(QJsonDocument news){
|
|||
}
|
||||
for (int b=0; b < news[i]["friendica_activities"]["dislike"].toArray().count();b++){
|
||||
if(imageurls.contains(news[i]["friendica_activities"]["dislike"][b]["profile_image_url"].toString().section('?',0,0)) || newcontactimagelinks.contains(news[i]["friendica_activities"]["dislike"][b]["profile_image_url"].toString().section('?',0,0))){
|
||||
}
|
||||
}
|
||||
else{
|
||||
newcontacts.append(news[i]["friendica_activities"]["dislike"][b]);
|
||||
newcontactimagelinks.append(news[i]["friendica_activities"]["dislike"][b]["profile_image_url"].toString().section('?',0,0));
|
||||
|
@ -482,13 +517,13 @@ QList <QJsonValue> UPDATENEWS::findNewContacts(QJsonDocument news){
|
|||
//owner contacts
|
||||
if (news[i].toObject().contains("friendica_author") ){
|
||||
if(imageurls.contains(news[i]["friendica_author"]["profile_image_url"].toString().section('?',0,0)) || newcontactimagelinks.contains(news[i]["friendica_owner"]["profile_image_url"].toString().section('?',0,0))){
|
||||
}
|
||||
}
|
||||
else{
|
||||
newcontacts.append(news[i]["friendica_author"]);
|
||||
newcontactimagelinks.append(news[i]["friendica_author"]["profile_image_url"].toString().section('?',0,0));
|
||||
newcontactnames.append(news[i]["friendica_author"]["screen_name"].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return newcontacts;
|
||||
}
|
||||
|
@ -585,9 +620,110 @@ void UPDATENEWS::updateContacts(QList<QJsonValue> contacts){
|
|||
}
|
||||
}
|
||||
|
||||
void UPDATENEWS::storeFriendrequests(QByteArray serverreply,QString apiname)
|
||||
{ if (apiname!=m_api || xhr.downloadtype()!=""){} else {
|
||||
QJsonDocument friendrequests;
|
||||
QJsonParseError jsonerror;
|
||||
friendrequests=QJsonDocument::fromJson(serverreply,&jsonerror);
|
||||
if (friendrequests.isArray()){
|
||||
|
||||
QSqlQuery imagequery("SELECT avatar FROM friendshiprequests",m_db);
|
||||
QList<QString> imageurls;
|
||||
while (imagequery.next()){
|
||||
imageurls.append(imagequery.value(0).toString());
|
||||
}
|
||||
|
||||
for (int i=0; i < friendrequests.array().count();i++){
|
||||
QJsonValue friendrequestitem=friendrequests[i];
|
||||
try{
|
||||
QSqlQuery testquery("SELECT url FROM friendshiprequests WHERE username='"+ username +"' AND url='" + friendrequestitem["url"].toString() +"'",m_db);
|
||||
QSqlQuery query(m_db);
|
||||
if (testquery.first()){
|
||||
query.prepare("UPDATE friendshiprequests SET id=?, usernamef=?, acct=?, display_name=?,locked=?,"
|
||||
"bot=?, discoverable=?, groupf=?, created_at=?,"
|
||||
"note=?, avatar=?, header=?, header_static=?, followers_count=?,"
|
||||
"following_count=?, statuses_count=?, last_status_at=?, emojis=?, fields=? "
|
||||
" WHERE username='"+ username +"' AND url='" + friendrequestitem["url"].toString() +"'");
|
||||
|
||||
query.bindValue(0, friendrequestitem["id"].toInt());
|
||||
query.bindValue(1, friendrequestitem["username"]);
|
||||
query.bindValue(2, friendrequestitem["acct"]);
|
||||
query.bindValue(3, friendrequestitem["display_name"].toString().toUtf8().toBase64());
|
||||
query.bindValue(4, friendrequestitem["locked"].toBool());
|
||||
query.bindValue(5, friendrequestitem["bot"].toBool());
|
||||
query.bindValue(6, friendrequestitem["discoverable"].toBool());
|
||||
query.bindValue(7, friendrequestitem["group"].toBool());
|
||||
query.bindValue(8, QDateTime::fromString(friendrequestitem["created_at"].toString(),Qt::ISODate).toMSecsSinceEpoch() );
|
||||
query.bindValue(9, friendrequestitem["note"].toString().toUtf8().toBase64());
|
||||
query.bindValue(10, friendrequestitem["avatar"]);
|
||||
query.bindValue(11, friendrequestitem["header"]);
|
||||
query.bindValue(12, friendrequestitem["header_static"]);
|
||||
query.bindValue(13, friendrequestitem["followers_count"].toInt());
|
||||
query.bindValue(14, friendrequestitem["following_count"].toInt());
|
||||
query.bindValue(15, friendrequestitem["statuses_count"].toInt());
|
||||
query.bindValue(16, QDateTime::fromString(friendrequestitem["last_status_at"].toString(),Qt::ISODate).toMSecsSinceEpoch() );
|
||||
query.bindValue(17, friendrequestitem["emojis"].toString().toUtf8().toBase64());
|
||||
query.bindValue(18, friendrequestitem["fields"].toString().toUtf8().toBase64());
|
||||
}
|
||||
else{
|
||||
|
||||
query.prepare("INSERT INTO friendshiprequests (username, id, usernamef, acct, display_name, locked,"
|
||||
" created_at, followers_count, following_count, statuses_count, note, url, avatar, avatar_static, "
|
||||
"header, header_static, emojis, moved, fields, bot, groupf, discoverable, last_status_at) "
|
||||
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
query.bindValue(0, username);
|
||||
query.bindValue(1, friendrequestitem["id"].toInt());
|
||||
query.bindValue(2, friendrequestitem["username"].toString());
|
||||
query.bindValue(3, friendrequestitem["acct"].toString());
|
||||
query.bindValue(4, friendrequestitem["display_name"].toString().toUtf8().toBase64());
|
||||
query.bindValue(5, friendrequestitem["locked"].toBool());
|
||||
query.bindValue(6, QDateTime::fromString(friendrequestitem["created_at"].toString(),Qt::ISODate).toMSecsSinceEpoch());
|
||||
query.bindValue(7, friendrequestitem["followers_count"].toInt());
|
||||
query.bindValue(8, friendrequestitem["following_count"].toInt());
|
||||
query.bindValue(9, friendrequestitem["statuses_count"].toInt());
|
||||
query.bindValue(10, friendrequestitem["note"].toString().toUtf8().toBase64());
|
||||
query.bindValue(11, friendrequestitem["url"].toString());
|
||||
query.bindValue(12, friendrequestitem["avatar"].toString());
|
||||
query.bindValue(13, "");
|
||||
query.bindValue(14, friendrequestitem["header"].toString());
|
||||
query.bindValue(15, friendrequestitem["header_static"].toString());
|
||||
query.bindValue(16, friendrequestitem["emojis"].toString().toUtf8().toBase64());
|
||||
query.bindValue(17, "false");
|
||||
query.bindValue(18, friendrequestitem["fields"].toString().toUtf8().toBase64());
|
||||
query.bindValue(19, friendrequestitem["bot"].toBool());
|
||||
query.bindValue(20, friendrequestitem["group"].toBool());
|
||||
query.bindValue(21, friendrequestitem["discoverable"].toBool());
|
||||
query.bindValue(22, QDateTime::fromString(friendrequestitem["last_status_at"].toString(),Qt::ISODate).toMSecsSinceEpoch());
|
||||
|
||||
if(notifylist.contains("notify_FriendRequests")){
|
||||
alarm.notify("Friend Request: "+ friendrequestitem["acct"].toString(),friendrequestitem["note"].toString(),0);
|
||||
}
|
||||
|
||||
}
|
||||
if(!(query.exec())) {qDebug()<< "friendrequestitem error " << query.lastError() << " " << query.lastQuery();}
|
||||
} catch(...){
|
||||
qDebug() << "Friendiqasync Error inserting friendrequestitem" << friendrequestitem["acct"] << " " ;
|
||||
}
|
||||
|
||||
if(imageurls.contains(friendrequestitem["avatar"].toString() )){
|
||||
}
|
||||
else{
|
||||
newcontactimagelinks.append(friendrequestitem["avatar"].toString());
|
||||
newcontactnames.append(friendrequestitem["username"].toString());
|
||||
}
|
||||
|
||||
}
|
||||
if (newcontactimagelinks.length()>0){
|
||||
qDebug() << "start Friendrequests imagedownload";
|
||||
startImagedownload("friendrequests");
|
||||
}
|
||||
}
|
||||
}
|
||||
QObject::disconnect(&xhr,SIGNAL(success(QByteArray,QString)),this,SLOT(storeFriendrequests(QByteArray,QString)));
|
||||
}
|
||||
|
||||
void UPDATENEWS::storeEvents(QByteArray serverreply,QString apiname)
|
||||
{ if (apiname!=m_api || xhr.downloadtype()!=""){} else {
|
||||
{ if (apiname!=m_api || xhr.downloadtype()!=""){} else {
|
||||
QJsonDocument events;
|
||||
QJsonParseError jsonerror;
|
||||
events=QJsonDocument::fromJson(serverreply,&jsonerror);
|
||||
|
@ -616,18 +752,18 @@ void UPDATENEWS::storeEvents(QByteArray serverreply,QString apiname)
|
|||
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"];
|
||||
}
|
||||
} catch(...){
|
||||
qDebug() << "Friendiqasync Error event" << eventitem["name"];
|
||||
}
|
||||
}
|
||||
emit this->success(m_api);
|
||||
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);
|
||||
}
|
||||
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;
|
||||
|
@ -641,9 +777,9 @@ QString UPDATENEWS::url() const
|
|||
return m_url;
|
||||
}
|
||||
|
||||
void UPDATENEWS::startImagedownload()
|
||||
void UPDATENEWS::startImagedownload(QString downloadtype)
|
||||
{
|
||||
xhr.setDownloadtype("contactlist");
|
||||
xhr.setDownloadtype(downloadtype );
|
||||
xhr.setFilelist(newcontactimagelinks);
|
||||
xhr.setContactlist(newcontactnames);
|
||||
xhr.setImagedir(m_imagedir);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue