Browse Source

v0.5.2

tags/v0.5.2
LubuWest 2 months ago
parent
commit
c1bdcbf963
48 changed files with 1323 additions and 1219 deletions
  1. +6
    -0
      CHANGELOG.md
  2. +3
    -2
      source-android/android/AndroidManifest.xml
  3. +12
    -6
      source-android/android/build.gradle
  4. +3
    -3
      source-android/android/gradle.properties
  5. +1
    -1
      source-android/android/gradle/wrapper/gradle-wrapper.properties
  6. +0
    -0
      source-android/android/gradlew
  7. +4
    -2
      source-android/androidnative.pri/java/src/androidnative/AndroidNativeActivity.java
  8. +51
    -5
      source-android/androidnative.pri/java/src/androidnative/AndroidNativeService.java
  9. +78
    -47
      source-android/androidnative.pri/java/src/androidnative/Util.java
  10. +6
    -0
      source-android/friendiqa.pro
  11. +1
    -1
      source-android/images
  12. +1
    -1
      source-android/js
  13. +1
    -1
      source-android/qml/calendarqml
  14. +1
    -1
      source-android/qml/configqml
  15. +1
    -1
      source-android/qml/contactqml
  16. +12
    -10
      source-android/qml/friendiqa.qml
  17. +1
    -1
      source-android/qml/genericqml
  18. +1
    -1
      source-android/qml/newsqml
  19. +1
    -1
      source-android/qml/photoqml
  20. +1
    -0
      source-android/translations
  21. +2
    -1
      source-linux/application.qrc
  22. +204
    -178
      source-linux/common/updatenews.cpp
  23. +1
    -0
      source-linux/common/xhr.cpp
  24. +4
    -0
      source-linux/friendiqa.pro
  25. +13
    -1
      source-linux/js/news.js
  26. +149
    -132
      source-linux/js/newsworker.js
  27. +26
    -35
      source-linux/js/service.js
  28. +2
    -0
      source-linux/qml/configqml/AccountPage.qml
  29. +3
    -4
      source-linux/qml/configqml/InfoBox.qml
  30. +1
    -2
      source-linux/qml/configqml/SyncConfig.qml
  31. +14
    -8
      source-linux/qml/friendiqa.qml
  32. +3
    -3
      source-linux/qml/genericqml/IntentReceiver.qml
  33. +2
    -1
      source-linux/qml/genericqml/MButton.qml
  34. +10
    -8
      source-linux/qml/newsqml/Conversation.qml
  35. +1
    -2
      source-linux/qml/newsqml/MessageSend.qml
  36. +63
    -0
      source-linux/qml/newsqml/MoreComments.qml
  37. +1
    -1
      source-linux/qml/newsqml/NewsImage.qml
  38. +19
    -196
      source-linux/qml/newsqml/NewsStack.qml
  39. +8
    -6
      source-linux/qml/newsqml/NewsVideo.qml
  40. +2
    -1
      source-linux/qml/newsqml/NewsVideoLarge.qml
  41. +4
    -1
      source-linux/qml/newsqml/NewsYplayer.qml
  42. +251
    -227
      source-linux/qml/newsqml/Newsitem.qml
  43. BIN
      source-linux/translations/friendiqa-de.qm
  44. +109
    -100
      source-linux/translations/friendiqa-de.ts
  45. BIN
      source-linux/translations/friendiqa-es.qm
  46. +117
    -108
      source-linux/translations/friendiqa-es.ts
  47. BIN
      source-linux/translations/friendiqa-it.qm
  48. +129
    -120
      source-linux/translations/friendiqa-it.ts

+ 6
- 0
CHANGELOG.md View File

@@ -1,3 +1,9 @@
## v0.5.2 ##
* Redesign of news item
* Background sync for Android >8.0
* Bugfixes


## v0.5.1 ##
* Videos open in full screen
* Youtube videos open in app


+ 3
- 2
source-android/android/AndroidManifest.xml View File

@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.5.1" android:versionCode="14" android:installLocation="auto">
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.5.2" android:versionCode="17" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:vmSafeMode="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Friendiqa" android:icon="@drawable/friendiqa" android:logo="@drawable/friendiqa" android:theme="@android:style/Theme.Holo.Light">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="androidnative.friendiqa.FriendiqaActivity" android:label="Friendiqa" android:screenOrientation="unspecified" android:launchMode="singleTask" android:taskAffinity="">
<intent-filter>
@@ -88,7 +88,8 @@
</application>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>

<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- 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 -->


+ 12
- 6
source-android/android/build.gradle View File

@@ -1,15 +1,17 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:3.5.2'
}
}

allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
@@ -25,12 +27,16 @@ dependencies {

//apply plugin: 'android-library'

dependencies {
compile 'com.android.support:support-v4:25.4.0'
}
//dependencies {
// compile 'com.android.support:support-v4:25.4.0'
//}

//dependencies {
// compile 'com.android.support:support-compat:25.4.0'
//}

dependencies {
compile 'com.android.support:support-compat:25.4.0'
compile 'androidx.appcompat:appcompat:1.1.0'
}

android {


+ 3
- 3
source-android/android/gradle.properties View File

@@ -1,4 +1,4 @@
androidBuildToolsVersion=25.0.3
androidCompileSdkVersion=27
buildDir=.build
qt5AndroidDir=/home/pankraz/Qt/5.11.1/android_armv7/src/android/java
android.useAndroidX=true
android.enableJetifier=true
android.enforceUniquePackageName=false

+ 1
- 1
source-android/android/gradle/wrapper/gradle-wrapper.properties View File

@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip

+ 0
- 0
source-android/android/gradlew View File


+ 4
- 2
source-android/androidnative.pri/java/src/androidnative/AndroidNativeActivity.java View File

@@ -7,8 +7,10 @@ import java.util.Map;
import android.content.pm.PackageManager;
import android.content.Context;
import android.Manifest.permission;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
//import android.support.v4.app.ActivityCompat;
//import android.support.v4.content.ContextCompat;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

/** An alternative Activity class for Qt applicaiton.



+ 51
- 5
source-android/androidnative.pri/java/src/androidnative/AndroidNativeService.java View File

@@ -1,23 +1,69 @@
package androidnative;
import android.os.Build;
import android.content.Context;
import android.content.Intent;
import android.app.PendingIntent;
import android.content.Context;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.util.Log;
import android.app.Notification.Builder;
import android.app.Notification;
import android.app.job.JobScheduler;
import org.qtproject.qt5.android.bindings.QtService;
import org.qtproject.qt5.android.QtNative;
import org.qtproject.friendiqa.R;
import androidnative.friendiqa.FriendiqaActivity;
public class AndroidNativeService extends QtService
{
private static String TAG = "AndroidNative";
public void startQtService(Context ctx) {
Log.d(TAG,"Friendiqa QtService");
ctx.startService(new Intent(ctx, AndroidNativeService.class));
Log.d(TAG, "QtActivity active "+String.valueOf(QtNative.activity()!=null));
if (QtNative.activity()==null){
//Log.d(TAG,"Friendiqasync Stop existing QtService");
ctx.stopService(new Intent(ctx, AndroidNativeService.class));

}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//Log.d(TAG,"Friendiqasync startForegroundService");
ctx.startForegroundService(new Intent(ctx, AndroidNativeService.class));
} else {
ctx.startService(new Intent(ctx, AndroidNativeService.class));
}
}
public static void stopQtService(Context ctx) {
Log.d(TAG,"Friendiqa QtServiceStop");

//Log.d(TAG,"Friendiqasync QtServiceStop");
ctx.stopService(new Intent(ctx, AndroidNativeService.class));
}
@Override
public void onCreate()
{
Context context;
context = this.getApplicationContext();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

Intent intent = new Intent(context,FriendiqaActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
String CHANNEL_ID = "channel_02";
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
"Sync Channel",
NotificationManager.IMPORTANCE_DEFAULT);
channel.setSound(null,null);
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel);
//Log.d(TAG,"Friendiqa onCreate Notification");
Notification notification = new Notification.Builder(context,CHANNEL_ID)
.setSmallIcon(R.drawable.friendiqanotification)
.setContentTitle("Friendiqa")
.setContentText("Background Sync")
.setContentIntent(pendingIntent).build();
startForeground(1, notification);}
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.cancel(1);
super.onCreate();
}
}

+ 78
- 47
source-android/androidnative.pri/java/src/androidnative/Util.java View File

@@ -11,8 +11,10 @@ import android.content.ComponentName;
import android.app.job.JobScheduler;
import android.app.job.JobInfo;
import android.app.PendingIntent;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import org.qtproject.qt5.android.QtNative;
import androidnative.friendiqa.FriendiqaService;
import androidnative.friendiqa.FriendiqaStopService;
@@ -120,32 +122,46 @@ public class Util {
final String textTitle = (String) message.get("title");
final String textContent = (String) message.get("message");
final int notificationId = (int) message.get("id");
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.friendiqanotification)
.setContentIntent(pendingIntent)
.setContentTitle(textTitle)
.setContentText(textContent)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(textContent))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true);

NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(notificationId, builder.build());
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
final String CHANNEL_ID = "channel_01";
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
"Channel for Friendiqa News",
NotificationManagerCompat.IMPORTANCE_LOW);
notificationManager.createNotificationChannel(channel);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context,CHANNEL_ID)
.setSmallIcon(R.drawable.friendiqanotification)
.setContentIntent(pendingIntent)
.setContentTitle(textTitle)
.setContentText(textContent)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(textContent))
.setAutoCancel(true);
notificationManager.notify(notificationId, builder.build());
} else {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.friendiqanotification)
.setContentIntent(pendingIntent)
.setContentTitle(textTitle)
.setContentText(textContent)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(textContent))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true);
notificationManager.notify(notificationId, builder.build());
}
}

static void setSchedule(Map message) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return;
}
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
return;
}
//Log.d(TAG,"Friendiqa schedule Androidnative service");
final Integer value = (Integer) message.get("value");
//final Activity activity = QtNative.activity();
//final Service service = QtNative.service();
//final int JOB_ID = 1;
final int ONE_MIN = 60 * 1000;
Context context;
@@ -155,34 +171,49 @@ public class Util {
} else {
context = QtNative.activity().getApplicationContext();
}
ComponentName component = new ComponentName(context, FriendiqaService.class);
JobInfo.Builder builder = new JobInfo.Builder(2, component)
// schedule it to run any time between 1 - 5 minutes
.setMinimumLatency(value * ONE_MIN)
.setOverrideDeadline((value + 5)*ONE_MIN)
//.setPeriodic(value * ONE_MIN)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.schedule(builder.build());
if (QtNative.service() != null){
//Log.d(TAG,"Schedule Stopping Friendiqa Androidnative service");
ComponentName componentStopper = new ComponentName(context, FriendiqaStopService.class);
JobInfo.Builder stopbuilder = new JobInfo.Builder(1, componentStopper)
.setMinimumLatency(50)
.setOverrideDeadline(100);
if (value==0){
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.cancelAll();
//Log.d(TAG,"Friendiqasync deleting Androidnative jobscheduler");
} else {
//Log.d(TAG,"Friendiqasync schedule Androidnative jobscheduler");
ComponentName component = new ComponentName(context, FriendiqaService.class);
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
//Log.d(TAG,"Jobinfolist size " + String.valueOf(jobScheduler.getAllPendingJobs().size()));
if (jobScheduler.getAllPendingJobs().size()==0){
JobInfo.Builder builder = new JobInfo.Builder(2, component)
.setPeriodic(value * ONE_MIN)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setPersisted(true)
.setPrefetch(true);
//Log.d(TAG,"Friendiqa schedule Androidnative sync schedule"+ (value * ONE_MIN));
jobScheduler.schedule(builder.build());
} else {
for ( JobInfo jobInfo : jobScheduler.getAllPendingJobs() ) {
//Log.d(TAG,"Jobinfo current interval " + String.valueOf(jobInfo.getIntervalMillis ()));
if (jobInfo.getIntervalMillis ()!=(value * ONE_MIN)){
JobInfo.Builder builder = new JobInfo.Builder(2, component)
.setPeriodic(value * ONE_MIN)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setPersisted(true)
.setPrefetch(true);
//Log.d(TAG,"Friendiqa schedule Androidnative sync schedule"+ (value * ONE_MIN));
jobScheduler.schedule(builder.build());
}
}
}
//Log.d(TAG,"Active service " + String.valueOf(QtNative.service()!=null));
if (QtNative.service() != null){
//Log.d(TAG,"Schedule Stopping Friendiqa Androidnative service");
ComponentName componentStopper = new ComponentName(context, FriendiqaStopService.class);
JobInfo.Builder stopbuilder = new JobInfo.Builder(1, componentStopper)
.setMinimumLatency(50)
.setOverrideDeadline(100);
JobScheduler jobStopScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobStopScheduler.schedule(stopbuilder.build());
//AndroidNativeService.stopQtService(context);
JobScheduler jobStopScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobStopScheduler.schedule(stopbuilder.build());
}
}
//context.stopService(new Intent(context, AndroidNativeService.class));
}

/**static void stopService(Map message){
this.stopService(new Intent(this, AndroidNativeService.class));
}
**/
}

+ 6
- 0
source-android/friendiqa.pro View File

@@ -77,3 +77,9 @@ contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
$$PWD/android/libcrypto_1_1.so \
$$PWD/android/libssl_1_1.so
}

contains(ANDROID_TARGET_ARCH,arm64-v8a) {
ANDROID_EXTRA_LIBS = \
/home/pankraz/ownCloud/clientsync/Friendiqa/v0.5.2/source-android/../../../../../git/android_openssl/arm64/libcrypto_1_1.so \
$$PWD/../../../../../git/android_openssl/arm64/libssl_1_1.so
}

+ 1
- 1
source-android/images View File

@@ -1 +1 @@
./../source-linux/images/
../source-linux/images

+ 1
- 1
source-android/js View File

@@ -1 +1 @@
./../source-linux/js/
../source-linux/js

+ 1
- 1
source-android/qml/calendarqml View File

@@ -1 +1 @@
./../../source-linux/qml/calendarqml/
../../source-linux/qml/calendarqml

+ 1
- 1
source-android/qml/configqml View File

@@ -1 +1 @@
./../../source-linux/qml/configqml/
../../source-linux/qml/configqml

+ 1
- 1
source-android/qml/contactqml View File

@@ -1 +1 @@
./../../source-linux/qml/contactqml/
../../source-linux/qml/contactqml

+ 12
- 10
source-android/qml/friendiqa.qml View File

@@ -31,14 +31,14 @@

import QtQuick 2.5
import QtQuick.LocalStorage 2.0
import QtQuick.Window 2.13
import QtQuick.Window 2.0
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.11
import "qrc:/js/news.js" as Newsjs
import "qrc:/js/service.js" as Service

StackView{

StackView{
id:root
property QtObject osSettings: {var tmp=Qt.createComponent("qrc:/qml/configqml/OSSettingsAndroid.qml");return tmp.createObject(root)}
width: osSettings.appWidth
@@ -107,7 +107,6 @@ StackView{

Keys.onReleased: {
if (event.key === osSettings.backKey) {

if (rootstack.currentIndex==0){
newstab.active=true;
if (newstab.newstabstatus!=login.newsViewType){
@@ -120,6 +119,7 @@ StackView{
newsSignal(dbnews)
})}
}

else if (newstab.conversation.length>0){newstab.conversation=[]}
else if (root.depth>1){root.pop()}
else{Service.cleanNews(root.db,function(){
@@ -161,10 +161,10 @@ StackView{
anchors.fill: parent
onClicked:{
leftDrawer.close();
newstypeSignal("refresh")
// updatenews.setDatabase();
// updatenews.login();
// updatenews.startsync();
// newstypeSignal("refresh")
updatenews.setDatabase();
updatenews.login();
updatenews.startsync();
}
}
}
@@ -308,6 +308,8 @@ StackView{

Item{
id:rootStackItem
width:parent.width
height: parent.height
//anchors.fill:parent
states: State {
name: "fullscreen";
@@ -389,10 +391,10 @@ StackView{
}

}

Component.onCompleted: {
forceActiveFocus();
Component.onCompleted: {
forceActiveFocus();
Service.readGlobaloptions(db,function(go){globaloptions=go})
//print(xhr.networktype());
if(osSettings.osType=="Android"){
var component = Qt.createComponent("qrc:/qml/genericqml/IntentReceiver.qml");
var IntentReceiverQml = component.createObject(root);


+ 1
- 1
source-android/qml/genericqml View File

@@ -1 +1 @@
./../../source-linux/qml/genericqml/
../../source-linux/qml/genericqml

+ 1
- 1
source-android/qml/newsqml View File

@@ -1 +1 @@
./../../source-linux/qml/newsqml/
../../source-linux/qml/newsqml

+ 1
- 1
source-android/qml/photoqml View File

@@ -1 +1 @@
./../../source-linux/qml/photoqml/
../../source-linux/qml/photoqml

+ 1
- 0
source-android/translations View File

@@ -0,0 +1 @@
../source-linux/translations

+ 2
- 1
source-linux/application.qrc View File

@@ -228,7 +228,7 @@
<file>images/smileys/adult/finger.gif</file>
<file>images/smileys/adult/sperm.gif</file>
<file>images/smileys/adult/tits.gif</file>
<file>images/addImage.png</file>
<file>images/addImage.png</file>
<file>common/filesystem.cpp</file>
<file>common/filesystem.h</file>
<file>common/friendiqa.cpp</file>
@@ -236,5 +236,6 @@
<file>common/uploadableimage.h</file>
<file>common/xhr.cpp</file>
<file>common/xhr.h</file>
<file>qml/newsqml/MoreComments.qml</file>
</qresource>
</RCC>

+ 204
- 178
source-linux/common/updatenews.cpp View File

@@ -123,13 +123,19 @@ void UPDATENEWS::login()
notifylist.append(syncquery.value(0).toString());
//qDebug() << " notify " << syncquery.value(0).toString() << " " <<syncquery.value(1).toString();
}

}
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 ";
} else {
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();}
}
// QSqlQuery notifyquery("SELECT * FROM globaloptions WHERE k like 'notify_%' AND v=1",m_db);
//qDebug() << "size " << notifyquery.size();
// while (notifyquery.next()){
// notifylist.append(syncquery.value(0).toString());
// qDebug() << " notify " << syncquery.value(0).toString();
//}

}

void UPDATENEWS::startsync()
@@ -242,107 +248,112 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
if (news.isArray()){
for (int i=0; i < news.array().count();i++){
QJsonValue newsitem=news[i];
if (apiname=="/api/friendica/notifications"){
QSqlQuery testquery("SELECT status_id FROM news WHERE status_id=" + QString::number(newsitem["id"].toInt()) + " AND messagetype=2 AND username='"+ username +"'",m_db);
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.bindValue(0,username);
query.bindValue(1,"0");
query.bindValue(2, newsitem["text"].toString().toUtf8().toBase64());
QString sourcedate=newsitem["created_at"].toString();
QString formateddate=sourcedate.mid(0,3)+", "+sourcedate.mid(8,3)+sourcedate.mid(4,3)+sourcedate.mid(25,5)+sourcedate.mid(10,15);
query.bindValue(3,QDateTime::fromString(formateddate,Qt::RFC2822Date).toMSecsSinceEpoch() );
if(newsitem["in_reply_to_status_id"]!=QJsonValue::Null){query.bindValue(4, newsitem["in_reply_to_status_id"].toInt());}
query.bindValue(5,newsitem["source"]);
query.bindValue(6,newsitem["id"].toInt());
if(newsitem["in_reply_to_user_id"]!=QJsonValue::Null){ query.bindValue(7,newsitem["in_reply_to_user_id"].toInt());}
query.bindValue(8,newsitem["geo"]);
query.bindValue( 9, newsitem["favorited"].toInt());
query.bindValue(10, newsitem["user"]["id"].toInt());
query.bindValue(11, newsitem["statusnet_html"].toString().toUtf8().toBase64());
query.bindValue(12, newsitem["statusnet_conversation_id"].toInt());
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++){
likeArray.append(newsitem["friendica_activities"]["like"][a]["url"].toString());
try{
if (apiname=="/api/friendica/notifications"){
QSqlQuery testquery("SELECT status_id FROM news WHERE status_id=" + QString::number(newsitem["id"].toInt()) + " AND messagetype=2 AND username='"+ username +"'",m_db);
if (testquery.first()) {continue;}
}
for (int b=0; b < newsitem["friendica_activities"]["dislike"].toArray().count();b++){
dislikeArray.append(newsitem["friendica_activities"]["dislike"][b]["url"].toString());
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.bindValue(0,username);
query.bindValue(1,"0");
query.bindValue(2, newsitem["text"].toString().toUtf8().toBase64());
QString sourcedate=newsitem["created_at"].toString();
QString formateddate=sourcedate.mid(0,3)+", "+sourcedate.mid(8,3)+sourcedate.mid(4,3)+sourcedate.mid(25,5)+sourcedate.mid(10,15);
query.bindValue(3,QDateTime::fromString(formateddate,Qt::RFC2822Date).toMSecsSinceEpoch() );
if(newsitem["in_reply_to_status_id"]!=QJsonValue::Null){query.bindValue(4, newsitem["in_reply_to_status_id"].toInt());}
query.bindValue(5,newsitem["source"]);
query.bindValue(6,newsitem["id"].toInt());
if(newsitem["in_reply_to_user_id"]!=QJsonValue::Null){ query.bindValue(7,newsitem["in_reply_to_user_id"].toInt());}
query.bindValue(8,newsitem["geo"]);
query.bindValue( 9, newsitem["favorited"].toInt());
query.bindValue(10, newsitem["user"]["id"].toInt());
query.bindValue(11, newsitem["statusnet_html"].toString().toUtf8().toBase64());
query.bindValue(12, newsitem["statusnet_conversation_id"].toInt());
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++){
likeArray.append(newsitem["friendica_activities"]["like"][a]["url"].toString());
}
for (int b=0; b < newsitem["friendica_activities"]["dislike"].toArray().count();b++){
dislikeArray.append(newsitem["friendica_activities"]["dislike"][b]["url"].toString());
}
for (int c=0; c < newsitem["friendica_activities"]["attendyes"].toArray().count();c++){
attendyesArray.append(newsitem["friendica_activities"]["attendyes"][c]["url"].toString());
}
for (int d=0; d < newsitem["friendica_activities"]["attendno"].toArray().count();d++){
attendnoArray.append(newsitem["friendica_activities"]["attendno"][d]["url"].toString());
}
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());
query.bindValue(14,"[]");

if (newsitem["attachments"]!=QJsonValue::Undefined){
query.bindValue(15, QJsonDocument(newsitem["attachments"].toArray()).toJson(QJsonDocument::Compact).toBase64());
}else {
query.bindValue(15, "");
}
for (int c=0; c < newsitem["friendica_activities"]["attendyes"].toArray().count();c++){
attendyesArray.append(newsitem["friendica_activities"]["attendyes"][c]["url"].toString());

if (newsitem["friendica_author"]!=QJsonValue::Undefined){
query.bindValue(16, newsitem["friendica_author"]["url"]);
}else {
query.bindValue(16, newsitem["user"]["url"]);
}

if (apiname=="/api/statuses/replies"){
query.bindValue(1,"3");
}
for (int d=0; d < newsitem["friendica_activities"]["attendno"].toArray().count();d++){
attendnoArray.append(newsitem["friendica_activities"]["attendno"][d]["url"].toString());
if (apiname == "/api/direct_messages/all"){
query.bindValue(1,"1");
query.bindValue(5,"Friendica");
if(newsitem["recipient"]["id"]!=QJsonValue::Null){ query.bindValue(7,newsitem["recipient"]["id"].toInt());}
query.bindValue(10, newsitem["sender_id"].toInt());
query.bindValue(11, newsitem["text"].toString().toUtf8().toBase64());
if(newsitem["friendica_parent_uri"]!=QJsonValue::Null){ query.bindValue(12,newsitem["friendica_parent_uri"]);}
query.bindValue(16, newsitem["sender"]["url"]);
}
for (int e = 0; e < newsitem["friendica_activities"]["attendmaybe"].toArray().count();e++){
attendmaybeArray.append(newsitem["friendica_activities"]["attendmaybe"][e]["url"].toString());
if (apiname == "/api/friendica/notifications"){
query.bindValue(1,"2");
query.bindValue(3,QDateTime::fromString(newsitem["date"].toString(),"yyyy-MM-dd hh:mm:ss").toMSecsSinceEpoch());
query.bindValue(5,"Friendica");
QJsonObject cleancontact= findNotificationContact(newsitem["url"].toString());
query.bindValue(10, cleancontact["id"].toInt());
query.bindValue(11, newsitem["msg_html"].toString().toUtf8().toBase64());
if(newsitem["parent"]!=QJsonValue::Null){ query.bindValue(12,newsitem["parent"]);}
query.bindValue(16, newsitem["url"]);
}
}
QJsonArray friendica_activities; friendica_activities={likeArray,dislikeArray,attendyesArray,attendnoArray,attendmaybeArray};
QJsonDocument activities; activities.setArray(friendica_activities);
query.bindValue(13,activities.toJson(QJsonDocument::Compact).toBase64());
query.bindValue(14,"[]");

if (newsitem["attachments"]!=QJsonValue::Undefined){
query.bindValue(15, QJsonDocument(newsitem["attachments"].toArray()).toJson(QJsonDocument::Compact).toBase64());
}else {
query.bindValue(15, "");
}

if (newsitem["friendica_author"]!=QJsonValue::Undefined){
query.bindValue(16, newsitem["friendica_author"]["url"]);
}else {
query.bindValue(16, newsitem["user"]["url"]);
}

if (apiname=="/api/statuses/replies"){
query.bindValue(1,"3");
}
if (apiname == "/api/direct_messages/all"){
query.bindValue(1,"1");
query.bindValue(5,"Friendica");
if(newsitem["recipient"]["id"]!=QJsonValue::Null){ query.bindValue(7,newsitem["recipient"]["id"].toInt());}
query.bindValue(10, newsitem["sender_id"].toInt());
query.bindValue(11, newsitem["text"].toString().toUtf8().toBase64());
if(newsitem["friendica_parent_uri"]!=QJsonValue::Null){ query.bindValue(12,newsitem["friendica_parent_uri"]);}
query.bindValue(16, newsitem["sender"]["url"]);
}
if (apiname == "/api/friendica/notifications"){
query.bindValue(1,"2");
query.bindValue(3,QDateTime::fromString(newsitem["date"].toString(),"yyyy-MM-dd hh:mm:ss").toMSecsSinceEpoch());
query.bindValue(5,"Friendica");
QJsonObject cleancontact= findNotificationContact(newsitem["url"].toString());
query.bindValue(10, cleancontact["id"].toInt());
query.bindValue(11, newsitem["msg_html"].toString().toUtf8().toBase64());
if(newsitem["parent"]!=QJsonValue::Null){ query.bindValue(12,newsitem["parent"]);}
query.bindValue(16, newsitem["url"]);
}

if(!(query.exec())) {qDebug()<<query.lastError();}
if(!(query.exec())) {qDebug()<<query.lastError();}

// notifications
if (apiname=="/api/statuses/friends_timeline"){
if(notifylist.contains("notify_Timeline")){
alarm.notify("Home: "+ newsitem["user"]["name"].toString(),newsitem["text"].toString(),0);
// notifications
if (apiname=="/api/statuses/friends_timeline"){
if(notifylist.contains("notify_Timeline")){
alarm.notify("Home: "+ newsitem["user"]["name"].toString(),newsitem["text"].toString(),0);
}
}
}
if (apiname=="/api/statuses/replies"){
if(notifylist.contains("notify_Replies")){
alarm.notify("Replies: "+newsitem["user"]["name"].toString(),newsitem["text"].toString(),1);
if (apiname=="/api/statuses/replies"){
if(notifylist.contains("notify_Replies")){
alarm.notify("Replies: "+newsitem["user"]["name"].toString(),newsitem["text"].toString(),1);
}
}
}
if (apiname=="/api/direct_messages/all"){
if(notifylist.contains("notify_DirectMessages")){
alarm.notify("DirectMessage: "+newsitem["sender"]["name"].toString(),newsitem["text"].toString(),2);
if (apiname=="/api/direct_messages/all"){
if(notifylist.contains("notify_DirectMessages")){
alarm.notify("DirectMessage: "+newsitem["sender"]["name"].toString(),newsitem["text"].toString(),2);
}
}
}
if (apiname=="/api/friendica/notifications"){
if(notifylist.contains("notify_Notifications")){
alarm.notify("Notification: "+newsitem["name"].toString(),newsitem["text"].toString(),3);
if (apiname=="/api/friendica/notifications"){
if(notifylist.contains("notify_Notifications")){
alarm.notify("Notification: "+newsitem["name"].toString(),newsitem["text"].toString(),3);
}
}
}catch(...){
qDebug() << "Friendiqasync Error inserting news" << newsitem["text"].toString() << " " << newsitem.toString();

}
}
QList<QJsonValue> newcontacts=findNewContacts(news);
@@ -409,12 +420,23 @@ QList <QJsonValue> UPDATENEWS::findNewContacts(QJsonDocument news){

for (int i=0; i<news.array().count();i++){
//main contacts
if(imageurls.contains(news[i]["user"]["profile_image_url"].toString().section('?',0,0)) || newcontactimagelinks.contains(news[i]["user"]["profile_image_url"].toString().section('?',0,0))){
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));
newcontactnames.append(news[i]["sender"]["screen_name"].toString());
}
}
if (news[i].toObject().contains("user") ){
if(imageurls.contains(news[i]["user"]["profile_image_url"].toString().section('?',0,0)) || newcontactimagelinks.contains(news[i]["user"]["profile_image_url"].toString().section('?',0,0))){
}
else{
newcontacts.append(news[i]["user"]);
newcontactimagelinks.append(news[i]["user"]["profile_image_url"].toString().section('?',0,0));
newcontactnames.append(news[i]["user"]["screen_name"].toString());
}
else{
newcontacts.append(news[i]["user"]);
newcontactimagelinks.append(news[i]["user"]["profile_image_url"].toString().section('?',0,0));
newcontactnames.append(news[i]["user"]["screen_name"].toString());
}
//like/dislike contacts
if (news[i].toObject().contains("friendica_activities") ){
@@ -457,86 +479,90 @@ void UPDATENEWS::updateContacts(QList<QJsonValue> contacts){
for (int i=0; i < contacts.count();i++){
QJsonValue contact=contacts[i];
QSqlQuery query(m_db);
//qDebug() << "updatecontact " << contact["screen_name"];
QSqlQuery testquery("SELECT url FROM contacts WHERE username='"+ username +"' AND url='" + contact["url"].toString() +"'",m_db);
if (testquery.first()){
query.prepare("UPDATE contacts SET id=?, name=?, screen_name=?, location=?,imageAge=?,"
"profile_image_url=?, description=?, protected=?, followers_count=?,"
"friends_count=?, created_at=?, favourites_count=?, utc_offset=?, time_zone=?, statuses_count=?,"
"following=?, verified=?, statusnet_blocking=?, notifications=?, statusnet_profile_url=?, cid=?, network=?, timestamp=? "
" WHERE username='"+ username +"' AND url='" + contact["url"].toString() +"'");
query.bindValue(0, contact["id"].toInt());
query.bindValue(1, contact["name"].toString().toUtf8().toBase64());
query.bindValue(2, contact["screen_name"]);
query.bindValue(3, contact["location"]);
query.bindValue(4, currentTime);
query.bindValue(5, contact["profile_image_url"].toString().section('?',0,0));
if(contact["description"].isNull() ){query.bindValue(6,"");}else{query.bindValue(6, contact["description"].toString().toUtf8().toBase64());}
query.bindValue(7,contact["protected"].toBool());
query.bindValue(8,contact["followers_count"].toInt());
query.bindValue(9,contact["friends_count"].toInt());
QString sourcedate=contact["created_at"].toString();
QString formateddate=sourcedate.mid(0,3)+", "+sourcedate.mid(8,3)+sourcedate.mid(4,3)+sourcedate.mid(25,5)+sourcedate.mid(10,15);
query.bindValue(10,QDateTime::fromString(formateddate,Qt::RFC2822Date).toMSecsSinceEpoch() );
query.bindValue(11,contact["favorites_count"].toInt());
query.bindValue(12,contact["utc_offset"].toInt());
query.bindValue(13,contact["time_zone"].toString());
query.bindValue(14,contact["statuses_count"].toInt());
query.bindValue(15,contact["following"].toBool());
query.bindValue(16,contact["verfied"].toBool());
query.bindValue(17,contact["statusnet_blocking"].toBool());
query.bindValue(18,contact["notifications"].toBool());
query.bindValue(19,contact["statusnet_profile_url"]);
query.bindValue(20,contact["cid"].toInt());
query.bindValue(21,contact["network"]);
qint64 timestamp=0;
QString timestamphelper=contact["profile_image_url"].toString();
try {timestamp=timestamphelper.mid(timestamphelper.indexOf("?ts")+4,timestamphelper.length()).toUInt();} catch(...){}
query.bindValue(22,timestamp);
}
try{
//qDebug() << "updatecontact " << contact["screen_name"];
QSqlQuery testquery("SELECT url FROM contacts WHERE username='"+ username +"' AND url='" + contact["url"].toString() +"'",m_db);
if (testquery.first()){
query.prepare("UPDATE contacts SET id=?, name=?, screen_name=?, location=?,imageAge=?,"
"profile_image_url=?, description=?, protected=?, followers_count=?,"
"friends_count=?, created_at=?, favourites_count=?, utc_offset=?, time_zone=?, statuses_count=?,"
"following=?, verified=?, statusnet_blocking=?, notifications=?, statusnet_profile_url=?, cid=?, network=?, timestamp=? "
" WHERE username='"+ username +"' AND url='" + contact["url"].toString() +"'");
query.bindValue(0, contact["id"].toInt());
query.bindValue(1, contact["name"].toString().toUtf8().toBase64());
query.bindValue(2, contact["screen_name"]);
query.bindValue(3, contact["location"]);
query.bindValue(4, currentTime);
query.bindValue(5, contact["profile_image_url"].toString().section('?',0,0));
if(contact["description"].isNull() ){query.bindValue(6,"");}else{query.bindValue(6, contact["description"].toString().toUtf8().toBase64());}
query.bindValue(7,contact["protected"].toBool());
query.bindValue(8,contact["followers_count"].toInt());
query.bindValue(9,contact["friends_count"].toInt());
QString sourcedate=contact["created_at"].toString();
QString formateddate=sourcedate.mid(0,3)+", "+sourcedate.mid(8,3)+sourcedate.mid(4,3)+sourcedate.mid(25,5)+sourcedate.mid(10,15);
query.bindValue(10,QDateTime::fromString(formateddate,Qt::RFC2822Date).toMSecsSinceEpoch() );
query.bindValue(11,contact["favorites_count"].toInt());
query.bindValue(12,contact["utc_offset"].toInt());
query.bindValue(13,contact["time_zone"].toString());
query.bindValue(14,contact["statuses_count"].toInt());
query.bindValue(15,contact["following"].toBool());
query.bindValue(16,contact["verfied"].toBool());
query.bindValue(17,contact["statusnet_blocking"].toBool());
query.bindValue(18,contact["notifications"].toBool());
query.bindValue(19,contact["statusnet_profile_url"]);
query.bindValue(20,contact["cid"].toInt());
query.bindValue(21,contact["network"]);
qint64 timestamp=0;
QString timestamphelper=contact["profile_image_url"].toString();
try {timestamp=timestamphelper.mid(timestamphelper.indexOf("?ts")+4,timestamphelper.length()).toUInt();} catch(...){}
query.bindValue(22,timestamp);
}

else{
query.prepare("INSERT INTO contacts (username, id, name, screen_name, location,imageAge,"
"profile_image_url, description, profile_image, url, protected, followers_count,"
"friends_count, created_at, favourites_count, utc_offset, time_zone, statuses_count,"
"following, verified, statusnet_blocking, notifications, statusnet_profile_url, cid, network, isFriend, timestamp)"
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");

else{
query.prepare("INSERT INTO contacts (username, id, name, screen_name, location,imageAge,"
"profile_image_url, description, profile_image, url, protected, followers_count,"
"friends_count, created_at, favourites_count, utc_offset, time_zone, statuses_count,"
"following, verified, statusnet_blocking, notifications, statusnet_profile_url, cid, network, isFriend, timestamp)"
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");

query.bindValue(0,username);
query.bindValue(1, contact["id"].toInt());
query.bindValue(2, contact["name"].toString().toUtf8().toBase64());
query.bindValue(3, contact["screen_name"]);
query.bindValue(4, contact["location"]);
query.bindValue(5, currentTime);
query.bindValue(6, contact["profile_image_url"].toString().section('?',0,0));
if(contact["description"].isNull() ){query.bindValue(7,"");}else{query.bindValue(7, contact["description"].toString().toUtf8().toBase64());}
query.bindValue(8,"none");
query.bindValue(9, contact["url"].toString());
query.bindValue(10,contact["protected"].toBool());
query.bindValue(11,contact["followers_count"].toInt());
query.bindValue(12,contact["friends_count"].toInt());
QString sourcedate=contact["created_at"].toString();
QString formateddate=sourcedate.mid(0,3)+", "+sourcedate.mid(8,3)+sourcedate.mid(4,3)+sourcedate.mid(25,5)+sourcedate.mid(10,15);
query.bindValue(13,QDateTime::fromString(formateddate,Qt::RFC2822Date).toMSecsSinceEpoch() );
query.bindValue(14,contact["favorites_count"].toInt());
query.bindValue(15,contact["utc_offset"].toInt());
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(20,contact["statusnet_blocking"].toBool());
query.bindValue(21,contact["notifications"].toBool());
query.bindValue(22,contact["statusnet_profile_url"]);
query.bindValue(23,contact["cid"].toInt());
query.bindValue(24,contact["network"]);
query.bindValue(25, 0);
qint64 timestamp=0;
QString timestamphelper=contact["profile_image_url"].toString();
try {timestamp=timestamphelper.mid(timestamphelper.indexOf("?ts")+4,timestamphelper.length()).toUInt();} catch(...){}
query.bindValue(26,timestamp);
query.bindValue(0,username);
query.bindValue(1, contact["id"].toInt());
query.bindValue(2, contact["name"].toString().toUtf8().toBase64());
query.bindValue(3, contact["screen_name"]);
query.bindValue(4, contact["location"]);
query.bindValue(5, currentTime);
query.bindValue(6, contact["profile_image_url"].toString().section('?',0,0));
if(contact["description"].isNull() ){query.bindValue(7,"");}else{query.bindValue(7, contact["description"].toString().toUtf8().toBase64());}
query.bindValue(8,"none");
query.bindValue(9, contact["url"].toString());
query.bindValue(10,contact["protected"].toBool());
query.bindValue(11,contact["followers_count"].toInt());
query.bindValue(12,contact["friends_count"].toInt());
QString sourcedate=contact["created_at"].toString();
QString formateddate=sourcedate.mid(0,3)+", "+sourcedate.mid(8,3)+sourcedate.mid(4,3)+sourcedate.mid(25,5)+sourcedate.mid(10,15);
query.bindValue(13,QDateTime::fromString(formateddate,Qt::RFC2822Date).toMSecsSinceEpoch() );
query.bindValue(14,contact["favorites_count"].toInt());
query.bindValue(15,contact["utc_offset"].toInt());
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(20,contact["statusnet_blocking"].toBool());
query.bindValue(21,contact["notifications"].toBool());
query.bindValue(22,contact["statusnet_profile_url"]);
query.bindValue(23,contact["cid"].toInt());
query.bindValue(24,contact["network"]);
query.bindValue(25, 0);
qint64 timestamp=0;
QString timestamphelper=contact["profile_image_url"].toString();
try {timestamp=timestamphelper.mid(timestamphelper.indexOf("?ts")+4,timestamphelper.length()).toUInt();} catch(...){}
query.bindValue(26,timestamp);

}
query.exec() ;
} catch(...){
qDebug() << "Friendiqasync Error inserting contact" << contact["screen_name"] << " " << contact.toString();
}
query.exec() ;
}
}



+ 1
- 0
source-linux/common/xhr.cpp View File

@@ -295,6 +295,7 @@ void XHR::onReplyError(QNetworkReply::NetworkError code)
emit this->error( bufferToString(), m_url,m_api, (int) code);
buffer.clear();
reply->deleteLater();
if((downloadtype()=="contactlist")||(downloadtype()=="picturelist")){dlindex=dlindex+1;XHR::getlist();}
}

void XHR::onReplySuccess()


+ 4
- 0
source-linux/friendiqa.pro View File

@@ -47,6 +47,7 @@ HEADERS += \
DISTFILES += \
qml/calendarqml/*.qml \
qml/newsqml/Lastcomment.qml \
qml/newsqml/NewsVideoLarge.qml \
translations/*.ts \
translations/*.qm \
@@ -58,3 +59,6 @@ DISTFILES += \
js/*.js \
qml/newsqml/NewsStack.qml \
qml/configqml/SyncComponent.qml

target.path=/usr/bin/friendiqa
INSTALLS+=target

+ 13
- 1
source-linux/js/news.js View File

@@ -187,7 +187,7 @@ function storeNews(login,database,news,rootwindow){
// save news after contacts download, call next function
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
for (var i=0;i<news.length;i++){
print('store news data for ' + 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);
//print('store news data for ' + 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);
//var ausdruck=news[i];
var likearray=[];var dislikearray=[];var attendyesarray=[];var attendnoarray=[];var attendmaybearray=[];
if(news[i].hasOwnProperty('friendica_activities')){
@@ -480,6 +480,7 @@ function chatsfromdb(database,login,messagetype,callback,stop_time){

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.newscount=newsrs.rows.length;
helpernews=fetchUsersForNews(database,login.username,helpernews,allcontacts);
@@ -487,6 +488,17 @@ function chatsfromdb(database,login,messagetype,callback,stop_time){
helpernews.text=Qt.atob(helpernews.text);
helpernews.id=helpernews.status_id;
if (helpernews.attachments!="" && helpernews.attachments!==null){helpernews.attachments=JSON.parse(Qt.atob(helpernews.attachments))};
helpernews.currentconversation=[];
for (var h = 0;h<newsrs.rows.length;h++){
var helpernews2=newsrs.rows.item(h);
helpernews2.newscount=0;
helpernews2=fetchUsersForNews(database,login.username,helpernews2,allcontacts);
helpernews2.statusnet_html=Qt.atob(helpernews2.statusnet_html);
helpernews2.text=Qt.atob(helpernews2.text);//print(h+" "+helpernews2.text)
helpernews2.id=helpernews2.status_id;
if (helpernews2.attachments!="" && helpernews2.attachments!==null){helpernews2.attachments=JSON.parse(Qt.atob(helpernews2.attachments))};
helpernews.currentconversation.push(helpernews2)
}
newsArray.push(helpernews);
}
callback(newsArray,lastid);


+ 149
- 132
source-linux/js/newsworker.js View File

@@ -34,126 +34,108 @@ function findend (text, startpos) {
return (indexOf >= 0) ? (indexOf + (startpos || 0)) : text.length;
}


WorkerScript.onMessage = function(msg) {
if(msg.deleteId!==undefined)
{msg.model.remove(msg.deleteId);
msg.model.sync()
}
else{
if(msg.method=="refresh"){msg.model.clear()};
msg.model.sync()
for (var j=0;j<msg.news.length;j++){
if (msg.news[j]) {
var newsitemobject=msg.news[j];
//print("Newsitem"+JSON.stringify(newsitemobject.friendica_owner+" userid: "+newsitemobject.user.id));
// if (newsitemobject.messagetype==2){
// newsitemobject.user={};
// newsitemobject.user.profile_image="";
// newsitemobject.user.profile_image_url="";
// newsitemobject.user.name="";
// }
var forumname="";
try{if (newsitemobject.messagetype==0&&newsitemobject.hasOwnProperty('friendica_author')&&
((newsitemobject.friendica_author.url)!=(newsitemobject.user.url))&&((newsitemobject.friendica_author.url)!=null)){
//print(" Friendica Author "+JSON.stringify(newsitemobject));
forumname=" via "+newsitemobject.user.name;
newsitemobject.user=newsitemobject.friendica_author;
}}catch(e){print("forum name "+e)}
var likeText="";var dislikeText="";var attendyesText="";var attendnoText="";var attendmaybeText=""; var self={};
try{if (newsitemobject.messagetype==0&&newsitemobject.hasOwnProperty('friendica_activities')){
if (newsitemobject.friendica_activities.like.length>0){
if (newsitemobject.friendica_activities.like.length==1){likeText= newsitemobject.friendica_activities.like[0].name+" "+ qsTr("likes this.")}
else {likeText= newsitemobject.friendica_activities.like.length+" "+ qsTr("like this.")}
}
if (newsitemobject.friendica_activities.dislike.length>0){
if (newsitemobject.friendica_activities.dislike.length==1){dislikeText= newsitemobject.friendica_activities.dislike[0].name+" "+ qsTr("doesn't like this.")}
else {dislikeText= newsitemobject.friendica_activities.dislike.length+" "+ qsTr("don't like this.")}
}
if (newsitemobject.friendica_activities.attendyes.length>0){
if (newsitemobject.friendica_activities.attendyes.length==1){attendyesText=newsitemobject.friendica_activities.attendyes[0].name+" "+ qsTr("will attend.")}
else {attendyesText= newsitemobject.friendica_activities.attendyes.length+" "+ qsTr("persons will attend.")}
}
if (newsitemobject.friendica_activities.attendno.length>0){
if (newsitemobject.friendica_activities.attendno.length==1){attendnoText= newsitemobject.friendica_activities.attendno[0].name+" "+ qsTr("will not attend.")}
else {attendnoText= newsitemobject.friendica_activities.attendno.length+" "+ qsTr("persons will not attend.")}
}
if (newsitemobject.friendica_activities.attendmaybe.length>0){
if (newsitemobject.friendica_activities.attendmaybe.length==1){attendmaybeText= newsitemobject.friendica_activities.attendmaybe[0].name+" "+ qsTr("may attend.")}
else {attendmaybeText= newsitemobject.friendica_activities.attendmaybe.length+" "+ qsTr("persons may attend.")}
}
//var friendica_activities_self=JSON.parse(newsitemobject.friendica_activities_self);
if (newsitemobject.hasOwnProperty("friendica_activities_self")){
if (newsitemobject.friendica_activities_self.indexOf(3)!=-1){self.attending=qsTr("yes")}
if (newsitemobject.friendica_activities_self.indexOf(4)!=-1){self.attending=qsTr("no")}
if (newsitemobject.friendica_activities_self.indexOf(5)!=-1){self.attending=qsTr("maybe")}
if (newsitemobject.friendica_activities_self.indexOf(1)!=-1){self.liked=1}
if (newsitemobject.friendica_activities_self.indexOf(2)!=-1){self.disliked=1}
}}} catch(e){print("Activities "+e+ " "+JSON.stringify(newsitemobject.friendica_activities))}
var friendica_activities={likeText:likeText,dislikeText:dislikeText,attendyesText:attendyesText,attendnoText:attendnoText,attendmaybeText:attendmaybeText,self:self}
var attachmentList=[];
var videoformats=["mp4", "avi", "webm","ogg","mp3"]
try{if(newsitemobject.attachments){
var attachArray=newsitemobject.attachments;
for (var image in attachArray){
var attachhelper={mimetype:attachArray[image].mimetype}
var attachhelperstring=Qt.btoa(attachArray[image].url)
var helperstringposition=newsitemobject.statusnet_html.indexOf(attachhelperstring);
if (helperstringposition>-1){attachhelper.url=newsitemobject.statusnet_html.substring(newsitemobject.statusnet_html.lastIndexOf("http",helperstringposition),helperstringposition+attachhelperstring.length);
if (attachArray[image].mimetype=="image/jpeg"){attachhelper.url=attachhelper.url+".jpg"}
else if (attachArray[image].mimetype=="image/gif"){attachhelper.url=attachhelper.url+".gif"}
else if (attachArray[image].mimetype=="image/png"){attachhelper.url=attachhelper.url+".png"}
}
else {attachhelper.url=attachArray[image].url}
attachmentList.push(attachhelper)
//print("Attachhelper "+attachhelper.url)
newsitemobject.statusnet_html=newsitemobject.statusnet_html.replace(attachhelper.url,"")
newsitemobject.statusnet_html=newsitemobject.statusnet_html.replace(attachhelper.url.substring(0,attachhelper.url.length-4)+".jpeg","")
newsitemobject.statusnet_html=newsitemobject.statusnet_html.replace(attachhelper.url.substring(0,attachhelper.url.length-4),"")
function beautify(newsitemobject,msg){
var forumname="";
try{if (newsitemobject.messagetype==0&&newsitemobject.hasOwnProperty('friendica_author')&&
((newsitemobject.friendica_author.url)!=(newsitemobject.user.url))&&((newsitemobject.friendica_author.url)!=null)){
//print(" Friendica Author "+JSON.stringify(newsitemobject));
forumname=" via "+newsitemobject.user.name;
newsitemobject.user=newsitemobject.friendica_author;
}}catch(e){print("forum name "+e)}
var likeText="";var dislikeText="";var attendyesText="";var attendnoText="";var attendmaybeText=""; var self={};
try{if (newsitemobject.messagetype==0&&newsitemobject.hasOwnProperty('friendica_activities')){
if (newsitemobject.friendica_activities.like.length>0){
if (newsitemobject.friendica_activities.like.length==1){likeText= newsitemobject.friendica_activities.like[0].name+" "+ qsTr("likes this.")}
else {likeText= newsitemobject.friendica_activities.like.length+" "+ qsTr("like this.")}
}
if (newsitemobject.friendica_activities.dislike.length>0){
if (newsitemobject.friendica_activities.dislike.length==1){dislikeText= newsitemobject.friendica_activities.dislike[0].name+" "+ qsTr("doesn't like this.")}
else {dislikeText= newsitemobject.friendica_activities.dislike.length+" "+ qsTr("don't like this.")}
}
if (newsitemobject.friendica_activities.attendyes.length>0){
if (newsitemobject.friendica_activities.attendyes.length==1){attendyesText=newsitemobject.friendica_activities.attendyes[0].name+" "+ qsTr("will attend.")}
else {attendyesText= newsitemobject.friendica_activities.attendyes.length+" "+ qsTr("persons will attend.")}
}
if (newsitemobject.friendica_activities.attendno.length>0){
if (newsitemobject.friendica_activities.attendno.length==1){attendnoText= newsitemobject.friendica_activities.attendno[0].name+" "+ qsTr("will not attend.")}
else {attendnoText= newsitemobject.friendica_activities.attendno.length+" "+ qsTr("persons will not attend.")}
}
if (newsitemobject.friendica_activities.attendmaybe.length>0){
if (newsitemobject.friendica_activities.attendmaybe.length==1){attendmaybeText= newsitemobject.friendica_activities.attendmaybe[0].name+" "+ qsTr("may attend.")}
else {attendmaybeText= newsitemobject.friendica_activities.attendmaybe.length+" "+ qsTr("persons may attend.")}
}
//var friendica_activities_self=JSON.parse(newsitemobject.friendica_activities_self);
if (newsitemobject.hasOwnProperty("friendica_activities_self")){
if (newsitemobject.friendica_activities_self.indexOf(3)!=-1){self.attending=qsTr("yes")}
if (newsitemobject.friendica_activities_self.indexOf(4)!=-1){self.attending=qsTr("no")}
if (newsitemobject.friendica_activities_self.indexOf(5)!=-1){self.attending=qsTr("maybe")}
if (newsitemobject.friendica_activities_self.indexOf(1)!=-1){self.liked=1}
if (newsitemobject.friendica_activities_self.indexOf(2)!=-1){self.disliked=1}
}}} catch(e){print("Activities "+e+ " "+JSON.stringify(newsitemobject.friendica_activities))}
var friendica_activities={likeText:likeText,dislikeText:dislikeText,attendyesText:attendyesText,attendnoText:attendnoText,attendmaybeText:attendmaybeText,self:self}
var attachmentList=[];
var videoformats=["mp4", "avi", "webm","ogg","mp3"]
try{if(newsitemobject.attachments){
var attachArray=newsitemobject.attachments;
for (var image in attachArray){
var attachhelper={mimetype:attachArray[image].mimetype}
var attachhelperstring=Qt.btoa(attachArray[image].url)
var helperstringposition=newsitemobject.statusnet_html.indexOf(attachhelperstring);
if (helperstringposition>-1){attachhelper.url=newsitemobject.statusnet_html.substring(newsitemobject.statusnet_html.lastIndexOf("http",helperstringposition),helperstringposition+attachhelperstring.length);
if (attachArray[image].mimetype=="image/jpeg"){attachhelper.url=attachhelper.url+".jpg"}
else if (attachArray[image].mimetype=="image/gif"){attachhelper.url=attachhelper.url+".gif"}
else if (attachArray[image].mimetype=="image/png"){attachhelper.url=attachhelper.url+".png"}
}
}
}catch(e){print("attachment "+e)}
for (var format in videoformats){
if (newsitemobject.text.indexOf("."+videoformats[format])>-1){
var videohelper={mimetype:"video/"+videoformats[format]}
var videotext=newsitemobject.text;
while (videotext.indexOf("."+videoformats[format])>-1){
var videohelperstringposition=videotext.indexOf("."+videoformats[format]);
videohelper.url=videotext.substring(videotext.lastIndexOf("http",videohelperstringposition),videohelperstringposition+4);
videotext=videotext.substring(videohelperstringposition+4,videotext.length)
if ((attachmentList.length==0) || (attachmentList[attachmentList.length-1].url!=videohelper.url)){attachmentList.push(videohelper)}
}
}
else {attachhelper.url=attachArray[image].url}
attachmentList.push(attachhelper)
//print("Attachhelper "+attachhelper.url)
newsitemobject.statusnet_html=newsitemobject.statusnet_html.replace(attachhelper.url,"")
newsitemobject.statusnet_html=newsitemobject.statusnet_html.replace(attachhelper.url.substring(0,attachhelper.url.length-4)+".jpeg","")
newsitemobject.statusnet_html=newsitemobject.statusnet_html.replace(attachhelper.url.substring(0,attachhelper.url.length-4),"")
}
if (newsitemobject.text.indexOf("/videos/watch/")>-1){
var ptvideohelper={mimetype:"video/mp4"}
var ptvideotext=newsitemobject.text;
while (ptvideotext.indexOf("/videos/watch/")>-1){
var ptvideohelperstringposition=ptvideotext.indexOf("/videos/watch/");
var ptposend=findend(ptvideotext,ptvideohelperstringposition);
if(ptposend==-1){ptposend=ptvideotext.length};
ptvideohelper.url=ptvideotext.substring(ptvideotext.lastIndexOf("http",ptvideohelperstringposition),ptposend)+"-480.mp4";
ptvideohelper.url=ptvideohelper.url.replace("/videos/watch","/static/webseed");
ptvideotext=ptvideotext.substring(ptposend,ptvideotext.length)
if ((attachmentList.length==0) || (attachmentList[attachmentList.length-1].url!=ptvideohelper.url)){attachmentList.push(ptvideohelper)}
}
}catch(e){print("attachment "+e)}
for (var format in videoformats){
if (newsitemobject.text.indexOf("."+videoformats[format])>-1){
var videohelper={mimetype:"video/"+videoformats[format]}
var videotext=newsitemobject.text;
while (videotext.indexOf("."+videoformats[format])>-1){
var videohelperstringposition=videotext.indexOf("."+videoformats[format]);
videohelper.url=videotext.substring(videotext.lastIndexOf("http",videohelperstringposition),videohelperstringposition+4);
videotext=videotext.substring(videohelperstringposition+4,videotext.length)
if ((attachmentList.length==0) || (attachmentList[attachmentList.length-1].url!=videohelper.url)){attachmentList.push(videohelper)}
}
}
if (newsitemobject.text.indexOf("youtube.com/watch?v")>-1){
//print("message "+msg.options.showWebsiteForLinks);
//if (msg.options.showYoutube!="false"){
}
if (newsitemobject.text.indexOf("/videos/watch/")>-1){
var ptvideohelper={mimetype:"video/mp4"}
var ptvideotext=newsitemobject.text;
while (ptvideotext.indexOf("/videos/watch/")>-1){
var ptvideohelperstringposition=ptvideotext.indexOf("/videos/watch/");
var ptposend=findend(ptvideotext,ptvideohelperstringposition);
if(ptposend==-1){ptposend=ptvideotext.length};
ptvideohelper.url=ptvideotext.substring(ptvideotext.lastIndexOf("http",ptvideohelperstringposition),ptposend)+"-480.mp4";
ptvideohelper.url=ptvideohelper.url.replace("/videos/watch","/static/webseed");
ptvideotext=ptvideotext.substring(ptposend,ptvideotext.length)
if ((attachmentList.length==0) || (attachmentList[attachmentList.length-1].url!=ptvideohelper.url)){attachmentList.push(ptvideohelper)}
}
}
if (newsitemobject.text.indexOf("youtube.com/watch?v")>-1){
//print("message "+msg.options.showWebsiteForLinks);
//if (msg.options.showYoutube!="false"){

var yttext=newsitemobject.text;
while (yttext.indexOf("youtube.com/watch?v")>-1){
var ythelperstringposition=yttext.indexOf("watch?v=");
var ytposend=findend(yttext,ythelperstringposition);
var ythelper={mimetype:"video/youtube"}
ythelper.url=yttext.substring(ythelperstringposition+8,ytposend);
yttext=yttext.substring(ytposend,yttext.length);
if ((attachmentList.length==0) || (attachmentList[attachmentList.length-1].url!=ythelper.url)){attachmentList.push(ythelper)}
}
//}
}

var yttext=newsitemobject.text;
while (yttext.indexOf("youtube.com/watch?v")>-1){
var ythelperstringposition=yttext.indexOf("watch?v=");
var ytposend=findend(yttext,ythelperstringposition);
var ythelper={mimetype:"video/youtube"}
ythelper.url=yttext.substring(ythelperstringposition+8,ytposend);
yttext=yttext.substring(ytposend,yttext.length);
if ((attachmentList.length==0) || (attachmentList[attachmentList.length-1].url!=ythelper.url)){attachmentList.push(ythelper)}
}
//}
}
// if (newsitemobject.text.indexOf(".html")>-1){
// //print("message "+msg.options.showWebsiteForLinks);
// if (msg.options.showWebsiteForLinks!="false"){
@@ -169,27 +151,62 @@ else{
// }
// }

newsitemobject.attachmentList=attachmentList;
newsitemobject.attachmentList=attachmentList;

if ((msg.options.hasOwnProperty("hide_nsfw"))&&(msg.options.hide_nsfw==1)&&(newsitemobject.text.indexOf("#nsfw")>-1)){
newsitemobject.nsfw=true
} else{newsitemobject.nsfw=false}

if ((msg.options.hasOwnProperty("hide_nsfw"))&&(msg.options.hide_nsfw==1)&&(newsitemobject.text.indexOf("#nsfw")>-1)){
newsitemobject.nsfw=true
} else{newsitemobject.nsfw=false}
var seconds=(msg.currentTime-newsitemobject.created_at)/1000;
var timestring="";
if (seconds<60) {timestring=seconds+" "+qsTr("seconds") +" "+qsTr("ago");}
else if (seconds<90){timestring=Math.round(seconds/60)+" "+qsTr("minute") +" "+qsTr("ago");}
else if (seconds<3600){timestring=Math.round(seconds/60)+" "+qsTr("minutes") +" "+qsTr("ago");}
else if (seconds<5400){timestring=Math.round(seconds/3600)+" "+qsTr("hour") +" "+qsTr("ago");}
else if (seconds<86400){timestring=Math.round(seconds/3600)+" "+qsTr("hours") +" "+qsTr("ago");}
else if (seconds<129600){timestring=Math.round(seconds/86400)+" "+qsTr("day") +" "+qsTr("ago");}
else if (seconds<3888000){timestring=Math.round(seconds/86400)+" "+qsTr("days") +" "+qsTr("ago");}
else if (seconds<5832000){timestring=Math.round(seconds/3888000)+" "+qsTr("month") +" "+qsTr("ago");}
else if (seconds<69984000){timestring=Math.round(seconds/3888000)+" "+qsTr("months") +" "+qsTr("ago");}
else {timestring=Math.round(seconds/46656000)+" "+qsTr("years") +" "+qsTr("ago");}

newsitemobject.dateDiff=timestring;
newsitemobject.friendica_activities_view=friendica_activities;
newsitemobject.forumname=forumname;
return newsitemobject;
}

var seconds=(msg.currentTime-newsitemobject.created_at)/1000;
var timestring="";
if (seconds<60) {timestring=seconds+" "+qsTr("seconds") +" "+qsTr("ago");}
else if (seconds<90){timestring=Math.round(seconds/60)+" "+qsTr("minute") +" "+qsTr("ago");}
else if (seconds<3600){timestring=Math.round(seconds/60)+" "+qsTr("minutes") +" "+qsTr("ago");}
else if (seconds<5400){timestring=Math.round(seconds/3600)+" "+qsTr("hour") +" "+qsTr("ago");}
else if (seconds<86400){timestring=Math.round(seconds/3600)+" "+qsTr("hours") +" "+qsTr("ago");}
else if (seconds<129600){timestring=Math.round(seconds/86400)+" "+qsTr("day") +" "+qsTr("ago");}
else if (seconds<3888000){timestring=Math.round(seconds/86400)+" "+qsTr("days") +" "+qsTr("ago");}
else if (seconds<5832000){timestring=Math.round(seconds/3888000)+" "+qsTr("month") +" "+qsTr("ago");}
else if (seconds<69984000){timestring=Math.round(seconds/3888000)+" "+qsTr("months") +" "+qsTr("ago");}
else {timestring=Math.round(seconds/46656000)+" "+qsTr("years") +" "+qsTr("ago");}

var data=({"newsitemobject": newsitemobject,"dateDiff":timestring,"friendica_activities":friendica_activities,"forumname":forumname})}

WorkerScript.onMessage = function(msg) {
if(msg.deleteId!==undefined)
{msg.model.remove(msg.deleteId);
msg.model.sync()
}
else{
if(msg.method=="refresh"){msg.model.clear()};
msg.model.sync()
for (var j=0;j<msg.news.length;j++){
if (msg.news[j]) {
var newsitemobject=msg.news[j];
//print("Newsitem"+JSON.stringify(newsitemobject.friendica_owner+" userid: "+newsitemobject.user.id));
// if (newsitemobject.messagetype==2){
// newsitemobject.user={};
// newsitemobject.user.profile_image="";
// newsitemobject.user.profile_image_url="";
// newsitemobject.user.name="";
// }

//var data=({"newsitemobject": newsitemobject,"dateDiff":timestring,"friendica_activities":friendica_activities,"forumname":forumname})}
//print("News:"+j+msg.news.length+JSON.stringify(data));
newsitemobject=beautify(newsitemobject,msg);
if (newsitemobject.hasOwnProperty("currentconversation")&&(newsitemobject.currentconversation.length>1)){
newsitemobject.lastcomment=beautify(newsitemobject.currentconversation[newsitemobject.currentconversation.length-1],msg);
//print("Currentconversation" + newsitemobject.currentconversation.length+JSON.stringify(newsitemobject.lastcomment))
}

var data=({"newsitemobject": newsitemobject})
}
if(msg.method=="append") {
msg.model.insert(j, data)}
else{


+ 26
- 35
source-linux/js/service.js View File

@@ -288,7 +288,7 @@ function readConfig(database,callback,filter,filtervalue) { // reads config
}

function readActiveConfig(database){
var obj;
var obj="";
readConfig(database,function(config){obj=config},"isActive", 0);
return obj;
}
@@ -341,12 +341,15 @@ function cleanNews(database,callback){
var maxnewsrs = tx.executeSql("SELECT v FROM globaloptions WHERE k='max_news'");
var maxnews=1000; if(maxnewsrs.rows.length>0){ maxnews=maxnewsrs.rows.item(0).v};
for (var i=0; i<6;i++){
if (i!=0){maxnews=maxnews/5}
if (i!=0){var maxnewsa=maxnews/5}else{maxnewsa=maxnews}
var newscountrs = tx.executeSql('SELECT COUNT(*) from news WHERE messagetype='+i);
var newscount = newscountrs.rows.item(0)["COUNT(*)"];//print("newscount "+newscount)
if (newscount>maxnews){
var lastvalidtimers= tx.executeSql('SELECT DISTINCT created_at FROM news WHERE messagetype='+i+' ORDER BY created_at ASC LIMIT ' +(newscount-maxnews));
var lastvalidtime=lastvalidtimers.rows.item(newscount-maxnews-1).created_at;
var newscount = 0;
if (newscountrs.rows.length>0){newscount=newscountrs.rows.item(0)["COUNT(*)"]};//print(i+"newscount "+newscount)
if (newscount>maxnewsa){
var lastvalidtimers= tx.executeSql('SELECT DISTINCT created_at FROM news WHERE messagetype='+i+' ORDER BY created_at ASC LIMIT ' +(newscount-maxnewsa));
// print('SELECT DISTINCT created_at FROM news WHERE messagetype='+i+' ORDER BY created_at ASC LIMIT ' +(newscount-maxnewsa))
// print(JSON.stringify(lastvalidtimers.rows.item(newscount-maxnewsa-1)))
var lastvalidtime=lastvalidtimers.rows.item(newscount-maxnewsa-1).created_at;
var deleters = tx.executeSql('DELETE from news WHERE messagetype='+i+' AND created_at<='+lastvalidtime)}
}
callback()
@@ -387,7 +390,8 @@ function updateContactInDB(login,database,isFriend,contact){// for newstab and f
}

function processNews(api,data){
//print(api + data);
//print("processNews "+api + data);

try{var newslist=JSON.parse(data)} catch(e){newsBusy.running=false;};
if (data==""){}
else if (typeof(newslist)=='undefined'){
@@ -397,34 +401,6 @@ function processNews(api,data){
Helperjs.showMessage(qsTr("JSON status Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root)
}
else if (!(Array.isArray(newslist))){
// print("processNews not array"+newslist+JSON.stringify(newslist));
// if(newslist.hasOwnProperty('id')){
// newslist.created_at=Date.parse(Newsjs.cleanDate(newslist.created_at));
// newslist.messagetype=5;
// newslist.friendica_author=cleanUser(newslist.friendica_author);
// newslist.user=cleanUser(newslist.user);
// if(newslist.in_reply_to_user_id){newslist.reply_user=Newsjs.objFromArray(allcontacts,"id",newslist.in_reply_to_user_id)}
// var dummynewslist=[newslist];
// Newsjs.storeNews(login,db,dummynewslist,root);
// 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((login.newsViewType=="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)
// })}

// }
replytimer.restart()
}
else {
@@ -624,6 +600,10 @@ function updateView(viewtype){
if (viewtype==="Conversations"){Newsjs.allchatsfromdb(db,login.username,function(temp){
newsStack.allchats=temp
})}
if ((osSettings.osType=="Android") && root.globaloptions.hasOwnProperty("syncinterval") && root.globaloptions.syncinterval !=null && root.globaloptions.syncinterval !=0){
//alarm.setAlarm(root.globaloptions.syncinterval);
setBackgroundsync()
}
}

function showGroups(){
@@ -638,6 +618,17 @@ function showGroups(){
})
}

function setBackgroundsync(){
Helperjs.readData(db,"globaloptions","",function(lastsync){
//print("Lastsync "+(parseFloat(lastsync[0]["v"])+120) + " Date "+Date.now()/1000 + " "+((parseFloat(lastsync[0]["v"])+120)<(Date.now()/1000)))
if((lastsync.length>0)&&((parseFloat(lastsync[0]["v"])+120)<(Date.now()/1000))){
alarm.setAlarm(root.globaloptions.syncinterval);

}

},"k","lastsync")
}

function getGroupnews(list){
newstab.newstabstatus="Group news";
newsBusy.running=true;


+ 2
- 0
source-linux/qml/configqml/AccountPage.qml View File

@@ -335,6 +335,8 @@ Page{
//reset values
root.login=userconfig;
root.news=[];
rootstack.currentIndex=0;
root.newstypeSignal("refresh");
},"isActive",0);

//Service.requestProfile(userconfig,db,root,function(nc){root.newContacts=nc});


+ 3
- 4
source-linux/qml/configqml/InfoBox.qml View File

@@ -43,12 +43,11 @@ Rectangle{
textFormat: Text.RichText
width: root.width-mm
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
text: "<b>Friendiqa v0.5 </b><br>Licensed under GPL 3 with the exception of OpenSSL <br> "+
"Profile <a href='https://freunde.ma-nic.de/profile/friendiqa'>https://freunde.ma-nic.de/profile/friendiqa</a><br>"+
text: "<b>Friendiqa v0.5.2 </b><br>Licensed under GPL 3 with the exception of OpenSSL <br> "+
"Website <a href='https://friendiqa.ma-nic.de'>https://friendiqa.ma-nic.de</a><br>"+
"Sourcecode: <a href='https://git.friendi.ca/LubuWest/Friendiqa'>https://git.friendi.ca/LubuWest/Friendiqa</a><br>"+
"Privacy Policy: <a href='https://git.friendi.ca/lubuwest/Friendiqa/src/branch/master/PrivacyPolicy.md'>http://git.friendi.ca/lubuwest/Friendiqa/src/branch/master/PrivacyPolicy.md</a><br>"+
"Most of C++ code by <a href='https://kirgroup.com/profile/fabrixxm'>Fabio</a><br>"+
"QML and Javascript code by <a href='https://freunde.ma-nic.de/profile/marco'>Marco</a><br>"+
"Code by <a href='https://freunde.ma-nic.de/profile/pankraz'>Marco</a><br>"+
"Qt Framework <a href='https://www.qt.io'>www.qt.io</a><br>"+
"Icons by <a href='http://fontawesome.io'>FontAwesome</a><br>"+
"Folder Icon by <a href='https://github.com/KDE/breeze-icons'>KDE Breeze Icons</a><br>"+


+ 1
- 2
source-linux/qml/configqml/SyncConfig.qml View File

@@ -62,10 +62,9 @@ Rectangle{
selectByMouse: true
onTextChanged: {
Service.updateglobaloptions(root.db,"syncinterval",text);
if(osSettings.osType=="Android" && text !=0){
if(osSettings.osType=="Android"){
alarm.setAlarm(text);
} else if(osSettings.osType=="Linux" && text !=0){

}
}
}


+ 14
- 8
source-linux/qml/friendiqa.qml View File

@@ -105,10 +105,11 @@ StackView{

FontLoader{id: fontAwesome; source: "qrc:/images/fontawesome-webfont.ttf"}

Keys.onReleased: {
Keys.onReleased: {print("Backkey"+newstab.conversation.length+" "+root.depth)
if (event.key === osSettings.backKey) {
if (currentIndex==0){
if (rootstack.currentIndex==0){
newstab.active=true;
print(newstab.newstabstatus)
if (newstab.newstabstatus!=login.newsViewType){
newstab.newstabstatus=login.newsViewType;
if(login.newsViewType=="Timeline"){Newsjs.newsfromdb(db,login.username,0,function(dbnews){
@@ -118,7 +119,9 @@ StackView{
Newsjs.chatsfromdb(db,login.username,function(dbnews){
newsSignal(dbnews)
})}
print(newstab.conversation.length);
}

else if (newstab.conversation.length>0){newstab.conversation=[]}
else if (root.depth>1){root.pop()}
else{Service.cleanNews(root.db,function(){
@@ -126,8 +129,8 @@ StackView{
Qt.quit()})
})}
}
else if (currentIndex==2){fotoSignal("backButton")}
else {currentIndex=0}
else if (rootstack.currentIndex==2){fotoSignal("backButton")}
else {rootstack.currentIndex=0}
event.accepted = true
}}

@@ -160,10 +163,10 @@ StackView{
anchors.fill: parent
onClicked:{
leftDrawer.close();
newstypeSignal("refresh")
// updatenews.setDatabase();
// updatenews.login();
// updatenews.startsync();
// newstypeSignal("refresh")
updatenews.setDatabase();
updatenews.login();
updatenews.startsync();
}
}
}
@@ -307,6 +310,8 @@ StackView{

Item{
id:rootStackItem
width:parent.width
height: parent.height
//anchors.fill:parent
states: State {
name: "fullscreen";
@@ -389,6 +394,7 @@ StackView{

}
Component.onCompleted: {
forceActiveFocus();
Service.readGlobaloptions(db,function(go){globaloptions=go})
//print(xhr.networktype());
if(osSettings.osType=="Android"){


+ 3
- 3
source-linux/qml/genericqml/IntentReceiver.qml View File

@@ -38,9 +38,9 @@ Item {

Component.onCompleted: {
SystemDispatcher.setInitialized();
if (root.globaloptions.hasOwnProperty("syncinterval") && root.globaloptions.syncinterval !=null && root.globaloptions.syncinterval !=0){
alarm.setAlarm(root.globaloptions.syncinterval);
}
// if (root.globaloptions.hasOwnProperty("syncinterval") && root.globaloptions.syncinterval !=null && root.globaloptions.syncinterval !=0){
// alarm.setAlarm(root.globaloptions.syncinterval);
// }
}
}


+ 2
- 1
source-linux/qml/genericqml/MButton.qml View File

@@ -28,7 +28,7 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import QtQuick 2.6
import QtQuick.Controls 2.4
Button{
id: mButton
@@ -36,4 +36,5 @@ Button{
height: 6*mm
//color: Material.grey
font.pixelSize: 3*mm
background: Rectangle{color:"#F8F8F8"}
}

+ 10
- 8
source-linux/qml/newsqml/Conversation.qml View File

@@ -40,7 +40,7 @@ Rectangle {
id:conversationList
// width:root.width-5*mm
// height:root.height-12*mm
//property var news
property var news:[]
// y:1
// z:2
color: "white"
@@ -83,7 +83,7 @@ Rectangle {
} else { conversationBusy.running=false;
conversationModel.clear();
var currentTime= new Date();
var msg = {'currentTime': currentTime, 'model': conversationModel,'news':newstab.conversation, 'options':globaloptions};
var msg = {'currentTime': currentTime, 'model': conversationModel,'news':newstab.conversation, 'method':'refresh', 'options':globaloptions};
conversationWorker.sendMessage(msg)
//conversationsymbol.color="grey"
}
@@ -176,15 +176,17 @@ Rectangle {
text: "\uf057"
onClicked: {
//newsView.positionViewAtIndex(newsStack.conversationIndex,ListView.Beginning);
newsStack.pop()
newstab.conversation=[];
//newsStack.pop()
//conversationList.destroy();
//conversationsymbol.color="grey"
}
}

// Component.onCompleted: {
// if (news){var currentTime= new Date();
// var msg = {'currentTime': currentTime, 'model': conversationModel,'news':news};
// conversationWorker.sendMessage(msg)}
// }
Component.onCompleted: {
if (news.length>0){var currentTime= new Date();
var msg = {'currentTime': currentTime, 'model': conversationModel,'news':news,'appendnews':true, 'options':globaloptions};
conversationWorker.sendMessage(msg)}
}
}

+ 1
- 2
source-linux/qml/newsqml/MessageSend.qml View File

@@ -148,7 +148,7 @@ Rectangle{
reply_to_user=newsitemobject.user.screen_name;
parentId=newsitemobject.id
} else {
messageSend.state=""
messageSend.state="";
reply_to_user="";
parentId="";
bodyField.text="";
@@ -482,7 +482,6 @@ Rectangle{
SmileyDialog{id:smileyDialog;x:mm;visible: false}
}
Component.onCompleted:{
//
//parentId=conversationModel.get(conversationModel.count-1).newsitemobject.id
//if(attachImageURLs.length>0){attachImage(attachImageURLs[0])}
newsStack.replySignal.connect(setParent);


+ 63
- 0
source-linux/qml/newsqml/MoreComments.qml View File

@@ -0,0 +1,63 @@
// This file is part of Friendiqa
// https://github.com/lubuwest/Friendiqa
// Copyright (C) 2017 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/>.

import QtQuick 2.0
Rectangle{
id: moreComments
width: parent.width
height: 5*mm
color:"white"
property int comments:0
// border.color:"grey"
// border.width:1
signal clicked
state:""

Text{
id:mainText
color: "grey"
anchors.right: parent.right
anchors.margins: mm
width: contentWidth
height: contentHeight
font.family:fontAwesome.name
//font.pixelSize: 3*mm
text: qsTr("Show all comments")+" (" +comments + ")" //"\uf0dc"
}
MouseArea{
id:buttonArea
anchors.fill:parent
onClicked: {
pushConversation();
}
}
}


+ 1
- 1
source-linux/qml/newsqml/NewsImage.qml View File

@@ -31,7 +31,7 @@

import QtQuick 2.9
AnimatedImage {id:gif;
width:newscolumn.width;
width:toprow.width;
property string mimetype:""
fillMode: Image.PreserveAspectFit;
onStatusChanged: playing = (status == AnimatedImage.Ready);


+ 19
- 196
source-linux/qml/newsqml/NewsStack.qml View File

@@ -121,9 +121,7 @@ StackView{


function showNews(newsToShow){
try{
if (newsStack.depth>1){newsStack.pop()}
}catch(e){}
try{if (newsStack.depth>1){newsStack.pop()}}catch(e){}
newsBusy.running=false;
var currentTime= new Date();
// downloadNotice.text=downloadNotice.text + "\n shownews start "+ Date.now();
@@ -192,7 +190,8 @@ StackView{
}
onSuccess:{
// downloadNotice.text=downloadNotice.text+ "\n xhr finished "+Date.now();
Service.processNews(api,data);
Service.processNews(api,data)
replySignal("")
}
}

@@ -224,179 +223,8 @@ StackView{
id:newslistRectangle
y:1
color: "white"
//anchors.fill:parent

// Button{
// id:newstabstatusButton
// anchors.top: parent.top
// anchors.topMargin: 0.5*mm
// height: 8*mm
// text: qsTr(newstab.newstabstatus)
// visible: newsStack.parent.stacktype=="standard"
// onClicked: {print(newsStack.parent.stacktype);
// newstabmenu.popup(2*mm,6*mm)
// }

// Menu{id:newstabmenu
// width: 40*mm

// delegate:MenuItem{
// contentItem: Text{
// font.pixelSize: 3.5*mm
// text:parent.text
// }
// background: Rectangle {
// implicitWidth: 40*mm; implicitHeight: 5*mm
// color: "#ffffff"
// border.color: "grey"
// }
// }
// Action {
// text: qsTr("Timeline")
// onTriggered: {
// }
// Action {
// text: qsTr("Conversations")
// onTriggered:{
// //newsModel.clear();
// newstab.newstabstatus="Conversations";
// Newsjs.chatsfromdb(db,root.login,function(news){showNews(news)})
// }
// }
// Action {
// text: qsTr("Favorites")
// onTriggered:{
// newsStack.updateMethodNews="refresh";
// newstab.newstabstatus="Favorites";
// Service.updateView("Favorites")
// }
// }
// Action {
// text: qsTr("Replies")
// onTriggered:{
// newsStack.updateMethodNews="refresh";
// newstab.newstabstatus="Replies";
// Service.updateView("Replies")
// }
// }
// Action {
// text: qsTr("Public timeline")
// onTriggered:{
// newsStack.updateMethodNews="refresh";
// newstab.newstabstatus="Public Timeline";
// Service.updateView("Public Timeline")
// }
// }
//// Action {
//// text: qsTr("Direct Messages")
//// onTriggered:{
//// newsStack.updateMethodNews="refresh";
//// newstab.newstabstatus="Direct Messages";
//// Service.updateView("Direct Messages")
//// }
//// }
//// Action {
//// text: qsTr("Notifications")
//// onTriggered:{
//// newsStack.updateMethodNews="refresh";
//// newstab.newstabstatus="Notifications";
//// Service.updateView("Notifications")
//// }
//// }
// Action {

// text: qsTr("Group news")
// onTriggered:
// {
// newsStack.updateMethodNews="refresh";
// Service.showGroups();
// }
// }
// Action {

// text: qsTr("Settings")
// onTriggered:
// {
// leftDrawer.open()
// }
// }
// Action {
// text: qsTr("Quit")
// onTriggered:{
// Service.cleanNews(root.db,function(){
// Service.cleanContacts(root.login,root.db,function(){
// Qt.quit()})
// })
// }
// }
// }
// }

// Row{
// spacing: mm
// anchors.top: parent.top
// anchors.topMargin: 0.5*mm
// anchors.right: parent.right

// Button {
// id: searchButton
// height: 8*mm
// text: "\uf002"
// visible: newsStack.parent.stacktype=="standard"
// onClicked: {
// newsView.anchors.topMargin=18*mm;
// var component = Qt.createComponent("qrc:/qml/genericqml/Search.qml");
// var searchItem = component.createObject(newsStack,{y:8*mm,width:root.width,height: 8*mm});
// }
// }

// Button {
// id: newMessageButton
// text: "\uf040"
// height: 8*mm
// onClicked: {
// var groups=[];
// Helperjs.readData(root.db,"groups",root.login.username,function(groupobject){
// groups=groupobject
// });
// newstab.newstabstatus="SendMessage";
// Helperjs.readData(root.db,"contacts",root.login.username,function(friends){
// newsStack.push("qrc:/qml/newsqml/MessageSend.qml",{"contacts": friends,"login":root.login})
// },"isFriend",1);
// }
// }
// BlueButton {
// id: quitButton
// text: "\uf08b"
// onClicked: {Service.cleanNews(root.db,function(){
// Service.cleanContacts(root.login,root.db,function(){
// Qt.quit() })
// })}
// }
// Button {
// id: update
// height: 8*mm
// text: "\uf021"
// onClicked: {
// if (newstab.newstabstatus=="Timeline"){
// newsStack.updateMethodNews="append"
// } else {newsStack.updateMethodNews="refresh"}
// //root.contactLoadType="news";
// if (newsStack.parent.stacktype=="standard"){
// Service.updateView(newstab.newstabstatus)
// }
// else if (newsStack.parent.stacktype=="directmessage"){
// Service.updateView("Direct Messages")
// }
// else if (newsStack.parent.stacktype=="notifications"){
// Service.updateView("Notifications")
// }
// }
// }

// }
Component { id:footerComponent
Rectangle{
border.color: "#EEEEEE"
@@ -411,21 +239,26 @@ StackView{
MouseArea{
anchors.fill:parent
onClicked:{
getOldNews();
if (newsModel.count==0){
if (newsSwipeview.stacktype=="Home"){
Service.updateView(newstab.newstabstatus)
}
else if (newsSwipeview.stacktype=="DirectMessages"){
Service.updateView("Direct Messages")
}
else if (newsSwipeview.stacktype=="Notifications"){
Service.updateView("Notifications")
}
else if (newsSwipeview.stacktype=="Replies"){
Service.updateView("Replies")
}