Browse Source

new version with hashtags

master
LubuWest 10 months ago
parent
commit
56bdb80ea0
  1. 6
      CHANGELOG.md
  2. 1
      README.md
  3. 13
      source-android/android/AndroidManifest.xml
  4. 69
      source-android/android/build.gradle.backup
  5. 3
      source-android/android/gradle.properties
  6. 17
      source-android/androidnative.pri/java/src/androidnative/AndroidNativeActivity.java
  7. 22
      source-android/androidnative.pri/java/src/androidnative/ImagePicker.java
  8. 115
      source-android/common/filesystemandroid.cpp
  9. 4
      source-android/common/friendiqa.cpp
  10. 7
      source-android/friendiqa.pro
  11. 1
      source-linux/application.qrc
  12. 73
      source-linux/common/alarmlinux (conflicted copy 2019-06-23 133538).cpp
  13. 24
      source-linux/common/filesystem.cpp
  14. 3
      source-linux/common/filesystem.h
  15. 97
      source-linux/common/friendiqa (conflicted copy 2019-06-24 214903).cpp
  16. 16
      source-linux/common/updatenews.cpp
  17. 121
      source-linux/common/uploadableimage (conflicted copy 2017-12-15 232034).cpp
  18. 71
      source-linux/common/uploadableimage (conflicted copy 2017-12-15 232034).h
  19. 369
      source-linux/common/xhr (conflicted copy 2019-06-24 214813).cpp
  20. 18
      source-linux/common/xhr.cpp
  21. 8
      source-linux/common/xhr.h
  22. 8
      source-linux/js/image.js
  23. 111
      source-linux/js/news.js
  24. 1
      source-linux/js/newsworker.js
  25. 48
      source-linux/js/service.js
  26. 1
      source-linux/qml/calendarqml/CalendarDay.qml
  27. 2
      source-linux/qml/calendarqml/CalendarTab.qml
  28. 2
      source-linux/qml/calendarqml/EventList.qml
  29. 172
      source-linux/qml/configqml/AccountPage.qml
  30. 2
      source-linux/qml/configqml/InfoBox.qml
  31. 45
      source-linux/qml/contactqml/ContactDetailsComponent.qml
  32. 40
      source-linux/qml/contactqml/FriendsTab.qml
  33. 3
      source-linux/qml/contactqml/GroupComponent.qml
  34. 13
      source-linux/qml/contactqml/ProfileComponent.qml
  35. 56
      source-linux/qml/friendiqa.qml
  36. 1
      source-linux/qml/genericqml/ContactComponent.qml
  37. 22
      source-linux/qml/genericqml/Search.qml
  38. 2
      source-linux/qml/newsqml/ContactPage.qml
  39. 105
      source-linux/qml/newsqml/Conversation.qml
  40. 218
      source-linux/qml/newsqml/MessageSend.qml
  41. 12
      source-linux/qml/newsqml/NewsStack.qml
  42. 16
      source-linux/qml/newsqml/NewsVideo.qml
  43. 7
      source-linux/qml/newsqml/NewsVideoLarge.qml
  44. 5
      source-linux/qml/newsqml/NewsYplayer.qml
  45. 270
      source-linux/qml/newsqml/Newsitem.qml
  46. 21
      source-linux/qml/newsqml/SmileyDialog.qml
  47. 6
      source-linux/qml/photoqml/PhotoTab.qml

6
CHANGELOG.md

@ -1,3 +1,9 @@
## v0.5.4 ##
* More Simplification of account page (images are stored in the private app directory, no permission required)
* Image attachment for Android 10 repaired
* Hashtags are saved after message is sent and can be used in later messages
* Bugfixes
## v0.5.3 ##
* Implementation of new events API (incl. sync and notification) for Friendica version >= 20.03
* Indentation to see replied to newsitem for conversation view

1
README.md

@ -36,6 +36,7 @@ Currently supported:
* Update fetches new posts (up to last 50) since last in local DB
* More shows older posts from local DB
* Create new Message with images or direct messages, Contact/Group access rights (can be stored), smileys
* Hashtags are saved after message is sent and can be used in later messages
* Send image from Android gallery
* Send text or urls from other apps to Friendiqa
* Native Android image dialog

13
source-android/android/AndroidManifest.xml

@ -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.3" android:versionCode="21" android:installLocation="auto">
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.5.4" android:versionCode="22" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
@ -12,8 +12,15 @@
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<application android:hardwareAccelerated="false" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Friendiqa" android:extractNativeLibs="true" android:icon="@drawable/friendiqa" android:theme="@android:style/Theme.Holo.Light" android:logo="@drawable/friendiqa">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="androidnative.friendiqa.FriendiqaActivity" android:label="Friendiqa" android:screenOrientation="unspecified" android:launchMode="singleTask" android:taskAffinity="">
<application android:hardwareAccelerated="false"
android:name="org.qtproject.qt5.android.bindings.QtApplication"
android:label="Friendiqa"
android:extractNativeLibs="true"
android:requestLegacyExternalStorage="true"
android:icon="@drawable/friendiqa"
android:theme="@android:style/Theme.Holo.Light"
android:logo="@drawable/friendiqa">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="androidnative.friendiqa.FriendiqaActivity" android:label="Friendiqa" android:screenOrientation="unspecified" android:launchMode="singleInstance" android:taskAffinity="">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

69
source-android/android/build.gradle.backup

@ -0,0 +1,69 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
//apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:25.3.1'
}
dependencies {
compile 'com.android.support:support-compat:25.3.1'
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion androidBuildToolsVersion
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
}
apply from: "androidnative.gradle"
setAndroidNativePath("/../androidnative.pri");

3
source-android/android/gradle.properties

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

17
source-android/androidnative.pri/java/src/androidnative/AndroidNativeActivity.java

@ -4,6 +4,7 @@ import android.util.Log;
import android.app.Activity;
import android.os.*;
import java.util.Map;
import java.util.HashMap;
import android.content.pm.PackageManager;
import android.content.Context;
import android.Manifest.permission;
@ -18,7 +19,7 @@ import androidx.core.content.ContextCompat;
*/
public class AndroidNativeActivity extends org.qtproject.qt5.android.bindings.QtActivity {
public static final int MY_PERMISSIONS_REQUEST_WRITE_STORAGE = 0x245285a8;
public static final int MY_PERMISSIONS_REQUEST_READ_STORAGE = 0x245285a8;
@Override
@ -30,16 +31,16 @@ public class AndroidNativeActivity extends org.qtproject.qt5.android.bindings.Qt
protected void onResume() {
super.onResume();
if (ContextCompat.checkSelfPermission(this,android.Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED) {
//if (ContextCompat.checkSelfPermission(this,android.Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
ActivityCompat.requestPermissions(this,new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE},MY_PERMISSIONS_REQUEST_WRITE_STORAGE);
// ActivityCompat.requestPermissions(this,new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE},MY_PERMISSIONS_REQUEST_WRITE_STORAGE);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
} else {
//} else {
System.loadLibrary("friendiqa_arm64-v8a");
if((getIntent().getFlags() == (Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY)) || (getIntent().getFlags() == Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) || (getIntent().getFlags() == Intent.FLAG_ACTIVITY_NEW_TASK) || (getIntent().getFlags() == Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) || (getIntent().getFlags() == (Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED))) {
@ -68,7 +69,7 @@ public class AndroidNativeActivity extends org.qtproject.qt5.android.bindings.Qt
} else {
SystemDispatcher.onActivityResume();
}}
}
//}
}
@ -76,10 +77,12 @@ public class AndroidNativeActivity extends org.qtproject.qt5.android.bindings.Qt
@Override public void onRequestPermissionsResult(int requestCode,String permissions[], int[] grantResults) {
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_WRITE_STORAGE: {
case MY_PERMISSIONS_REQUEST_READ_STORAGE: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
SystemDispatcher.onActivityResume();
Map message = new HashMap();
message.put("multiple",false);
SystemDispatcher.dispatch("androidnative.ImagePicker.pickImage",message);
} else {
}
return;

22
source-android/androidnative.pri/java/src/androidnative/ImagePicker.java

@ -1,6 +1,7 @@
package androidnative;
import org.qtproject.qt5.android.QtNative;
import android.content.Intent;
import android.content.Context;
import android.util.Log;
import android.app.Activity;
import java.util.Map;
@ -17,12 +18,20 @@ import android.content.ClipData;
import java.util.List;
import java.util.ArrayList;
import android.content.pm.PackageManager;
import android.content.Context;
import android.Manifest.permission;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
public class ImagePicker {
// Random
public static final int PICK_IMAGE_ACTION = 0x245285a3;
public static final int TAKE_PHOTO_ACTION = 0x29fe8748;
public static final int MY_PERMISSIONS_REQUEST_READ_STORAGE = 0x245285a8;
public static final String PICK_IMAGE_MESSAGE = "androidnative.ImagePicker.pickImage";
public static final String TAKE_PHOTO_MESSAGE = "androidnative.ImagePicker.takePhoto";
public static final String CHOSEN_MESSAGE = "androidnative.ImagePicker.chosen";
@ -47,8 +56,15 @@ public class ImagePicker {
}
static void pickImage(Map message) {
Context context;
context = QtNative.activity().getApplicationContext();
Activity activity = org.qtproject.qt5.android.QtNative.activity();
if (ContextCompat.checkSelfPermission(context,android.Manifest.permission.READ_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
ActivityCompat.requestPermissions(activity,new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE},MY_PERMISSIONS_REQUEST_READ_STORAGE);
} else {
Boolean multiple = false;
Activity activity = org.qtproject.qt5.android.QtNative.activity();
//Activity activity = org.qtproject.qt5.android.QtNative.activity();
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
@ -63,7 +79,7 @@ public class ImagePicker {
// >= API 18
activity.startActivityForResult(intent, PICK_IMAGE_ACTION);
}
}}
static void takePhoto(Map message) {
if (message.containsKey("broadcast")) {

115
source-android/common/filesystemandroid.cpp

@ -0,0 +1,115 @@
// This file is part of Friendiqa
// https://github.com/lubuwest/Friendiqa
// Copyright (C) 2020 Marco R. <thomasschmidt45@gmx.net>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// In addition, as a special exception, the copyright holders give
// permission to link the code of portions of this program with the
// OpenSSL library under certain conditions as described in each
// individual source file, and distribute linked combinations including
// the two.
//
// You must obey the GNU General Public License in all respects for all
// of the code used other than OpenSSL. If you modify file(s) with this
// exception, you may extend this exception to your version of the
// file(s), but you are not obligated to do so. If you do not wish to do
// so, delete this exception statement from your version. If you delete
// this exception statement from all source files in the program, then
// also delete it here.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "filesystem.h"
#include <QtAndroidExtras>
FILESYSTEM *FILESYSTEM::instance()
{
static FILESYSTEM filesystem;
return &filesystem;
}
FILESYSTEM::FILESYSTEM(QObject *parent) : QObject(parent){}
void FILESYSTEM::setDirectory(QString Directory)
{
if (Directory!=m_Directory) {
m_Directory = Directory;
emit directoryChanged();
}
}
QString FILESYSTEM::Directory() const
{
return m_Directory;
}
QString FILESYSTEM::homePath() const
{
QAndroidJniObject activity =QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative","activity", "()Landroid/app/Activity;");
QAndroidJniObject dir = activity.callObjectMethod("getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;", NULL);
QString homeDir=dir.toString();
return homeDir;
}
bool FILESYSTEM::fileexist(QString name)
{ return QFile::exists(name);
}
void FILESYSTEM::makeDir(QString name)
{
QDir dir(m_Directory);
if (dir.mkdir(name)){
emit success(name);
}
else {
emit error(name,1);
}
}
void FILESYSTEM::makePath(QString name)
{
QDir dir(m_Directory);
if (dir.mkpath(name)){
emit success(name);
}
else {
emit error(name,1);}
}
void FILESYSTEM::rmDir()
{
QDir dir(m_Directory);
if (dir.removeRecursively()){
emit success(m_Directory);
}
else {emit error(m_Directory,1);}
}
void FILESYSTEM::rmFile(QString name)
{
QDir dir(m_Directory);
if(dir.remove(name)){
emit success(name);
}
else {emit error(name,1);}
}
QFileInfoList FILESYSTEM::fileList()
{
QDir dir(m_Directory);
QStringList filters;
filters << "*.png" <<"*.PNG" << "*.jpg" << "*.JPG" << "*.JPEG";
dir.setNameFilters(filters);
dir.setSorting(QDir::Time | QDir::Reversed);
return dir.entryInfoList();
}

4
source-android/common/friendiqa.cpp

@ -38,9 +38,6 @@
#include "filesystem.h"
#include "remoteauthasyncimageprovider.h"
#include "AndroidNative/systemdispatcher.h"
//#include "AndroidNative/environment.h"
//#include "AndroidNative/debug.h"
//#include "AndroidNative/mediascannerconnection.h"
#ifdef Q_OS_ANDROID
@ -87,7 +84,6 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) {
UPDATENEWS* updatenews = UPDATENEWS::instance();
view.rootContext()->setContextProperty("updatenews", updatenews);
view.setSource(QUrl("qrc:/qml/friendiqa.qml"));
//QtWebEngine::initialize();
view.show();
view.connect(view.rootContext()->engine(), SIGNAL(quit()), &app, SLOT(quit()));

7
source-android/friendiqa.pro

@ -18,9 +18,9 @@ QT += qml quick gui widgets androidextras sql webview #webengine
include(androidnative.pri/androidnative.pri)
SOURCES += common/friendiqa.cpp \
common/uploadableimage.cpp \
common/uploadableimage.cpp \
common/xhr.cpp \
common/filesystem.cpp \
common/filesystemandroid.cpp \
common/remoteauthasyncimageprovider.cpp \
common/updatenews.cpp \
common/alarmandroid.cpp
@ -84,3 +84,6 @@ DISTFILES += \
android/src/FriendiqaService.java
ANDROID_EXTRA_LIBS = $$PWD/android/arm/libcrypto_1_1.so $$PWD/android/arm/libssl_1_1.so $$PWD/android/arm64/libcrypto_1_1.so $$PWD/android/arm64/libssl_1_1.so
ANDROID_ABIS = arm64-v8a
android: include(/home/pankraz/git/android_openssl/openssl.pri)

1
source-linux/application.qrc

@ -237,5 +237,6 @@
<file>common/xhr.cpp</file>
<file>common/xhr.h</file>
<file>qml/newsqml/MoreComments.qml</file>
<file>common/filesystemandroid.cpp</file>
</qresource>
</RCC>

73
source-linux/common/alarmlinux (conflicted copy 2019-06-23 133538).cpp

@ -0,0 +1,73 @@
// This file is part of Friendiqa
// https://git.friendi.ca/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/>.
//#include <QtAndroidExtras/QAndroidJniObject>
//#include <QtAndroidExtras/QAndroidJniEnvironment>
#include "alarm.h"
#include <QtCore/QDebug>
#include <QtDBus/QtDBus>
//#include "AndroidNative/systemdispatcher.h"
ALARM *ALARM::instance()
{
static ALARM alarm;
return &alarm;
}
ALARM::ALARM(QObject *parent) : QObject(parent){}
void ALARM::setAlarm(int interval)
{
qDebug() << interval;
QVariantMap message;
message["value"] = interval;
// AndroidNative::SystemDispatcher::instance()->loadClass("androidnative.Util");
// AndroidNative::SystemDispatcher::instance()->dispatch("androidnative.Util.setSchedule", message);
//AndroidNative::SystemDispatcher::instance()->dispatch("androidnative.Util.stopService", message);
}
void ALARM::notify(QString title, QString text, int id)
{
qDebug() << title << text;
QVariantMap message;
message["title"] = title;
message["message"] = text;
QDBusConnection bus = QDBusConnection::sessionBus();
QDBusInterface dbus_iface("org.freedesktop.Notifications", "/org/freedesktop/Notifications",
"org.freedesktop.Notifications", bus);
QString appname="Friendiqa";
uint v=12321;
if (dbus_iface.isValid()){
dbus_iface.call("Notify",appname,v,"",title,text,"","",5000);
}
// AndroidNative::SystemDispatcher::instance()->dispatch("Notifier.notify", message);
}

24
source-linux/common/filesystem.cpp

@ -30,6 +30,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "filesystem.h"
#include <QDebug>
FILESYSTEM *FILESYSTEM::instance()
{
@ -54,8 +55,9 @@ QString FILESYSTEM::Directory() const
QString FILESYSTEM::homePath() const
{
QDir dir(m_Directory);
QString homeDir=dir.homePath();
//QDir dir(m_Directory);
//
QString homeDir=QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);;
//qDebug(homeDir);
return homeDir;
}
@ -81,9 +83,25 @@ void FILESYSTEM::makeDir(QString name)
{
QDir dir(m_Directory);
if (dir.mkdir(name)){
qDebug() << "makedir success" <<name;
emit success(name);
}
else {emit error(name,1);}
else {
qDebug() << "makedir error" <<name;
emit error(name,1);
}
}
void FILESYSTEM::makePath(QString name)
{
QDir dir(m_Directory);
if (dir.mkpath(name)){
qDebug() << "makepath success" <<name;
emit success(name);
}
else {
qDebug() << "makepath error" <<name;
emit error(name,1);}
}
void FILESYSTEM::rmDir()

3
source-linux/common/filesystem.h

@ -34,6 +34,8 @@
#include <QDir>
#include <QObject>
#include <QStandardPaths>
//#include <QtAndroidExtras>
//#include <QAndroidActivityResultReceiver>
@ -67,6 +69,7 @@ signals:
public slots:
bool fileexist(QString name);
void makeDir(QString name);
void makePath(QString name);
void rmDir();
void rmFile(QString name);
//void searchImage();

97
source-linux/common/friendiqa (conflicted copy 2019-06-24 214903).cpp

@ -0,0 +1,97 @@
// 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/>.
#include <QApplication>
#include <QtQml/QQmlEngine>
//#include <QAndroidService>
//#include <QtAndroid>
#include <QtQuick>
#include "xhr.h"
#include "updatenews.h"
#include "filesystem.h"
#include "remoteauthasyncimageprovider.h"
//#include "alarm.h"
//#include "AndroidNative/systemdispatcher.h"
//#include "AndroidNative/environment.h"
//#include "AndroidNative/debug.h"
//#include "AndroidNative/mediascannerconnection.h"
#ifdef Q_OS_ANDROID
#include <QtAndroidExtras/QAndroidJniObject>
#include <QtAndroidExtras/QAndroidJniEnvironment>
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
Q_UNUSED(vm);
qDebug("NativeInterface::JNI_OnLoad()"); // It must call this function within JNI_OnLoad to enable System Dispatcher
AndroidNative::SystemDispatcher::registerNatives();
return JNI_VERSION_1_6;
}
#endif
int main(int argc, char *argv[]) {
//qDebug()<< "argv Friendiqa"<< argv[0] <<" argv2" <<argv[1];
if (qstrcmp(argv[1],"-service")==0){
//qDebug()<<"FriendiqaMain Service";
//QAndroidService app(argc, argv);
UPDATENEWS* updatenews= UPDATENEWS::instance();
updatenews->setDatabase();
updatenews->login();
updatenews->startsync();
//app.connect (updatenews,SIGNAL(quitapp()),&app,SLOT(quit()));
//QtAndroid::androidService().callMethod<void>("stopSelf");
//return app.exec();
}
else{
QApplication app(argc, argv);
QQuickView view;
QTranslator qtTranslator;
qtTranslator.load("friendiqa-" + QLocale::system().name(),":/translations");
app.installTranslator(&qtTranslator);
RemoteAuthAsyncImageProvider *imageProvider = new RemoteAuthAsyncImageProvider;
view.engine()->addImageProvider("remoteauthimage",imageProvider);
view.rootContext()->setContextProperty("remoteauth", imageProvider);
XHR* xhr = XHR::instance();
view.rootContext()->setContextProperty("xhr", xhr);
FILESYSTEM* filesystem = FILESYSTEM::instance();
view.rootContext()->setContextProperty("filesystem", filesystem);
ALARM* alarm = ALARM::instance();
view.rootContext()->setContextProperty("alarm", alarm);
UPDATENEWS* updatenews = UPDATENEWS::instance();
view.rootContext()->setContextProperty("updatenews", updatenews);
view.setSource(QUrl("qrc:/qml/friendiqa.qml"));
view.show();
view.connect(view.rootContext()->engine(), SIGNAL(quit()), &app, SLOT(quit()));
return app.exec();
}
}

16
source-linux/common/updatenews.cpp

@ -45,7 +45,6 @@
#include <QSqlDatabase>
#include <QSqlError>
#include <QDateTime>
//#include "AndroidNative/systemdispatcher.h"
@ -110,7 +109,6 @@ void UPDATENEWS::login()
m_updateInterval=0;
syncindex=0;
synclist.clear();
//QSqlQuery syncquery("SELECT * FROM globaloptions WHERE k like 'sync_%' AND v=1",m_db);
while (syncquery.next()){
if (syncquery.value(0).toString()=="syncinterval"){
m_updateInterval=syncquery.value(1).toInt();
@ -129,9 +127,7 @@ void UPDATENEWS::login()
if (synctimequery.next()){
QSqlQuery synctimequery2("UPDATE globaloptions SET v='"+QString::number(QDateTime::currentSecsSinceEpoch()) + "' WHERE k = 'lastsync'",m_db);
if(!(synctimequery2.exec())) {qDebug()<<" synctimequery2 " << 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 " << synctimequery3.lastError();}
}
@ -260,7 +256,6 @@ void UPDATENEWS::events()
QObject::disconnect(&xhr,SIGNAL(success(QByteArray,QString)),this,SLOT(store(QByteArray,QString)));
QObject::connect(&xhr,SIGNAL(success(QByteArray,QString)),this,SLOT(storeEvents(QByteArray,QString)));
QObject::connect(&xhr,SIGNAL(error(QString,QString,QString,int)),this,SLOT(showError(QString,QString,QString,int)));
//QObject::connect(&xhr, SIGNAL(downloaded(QString, QString, QString, int)), this, SLOT(updateImageLocation(QString,QString, QString, int)));
}
@ -293,7 +288,10 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
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());
if (newsitem["friendica_title"]!="") {
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());
QJsonArray likeArray;QJsonArray dislikeArray;QJsonArray attendyesArray;QJsonArray attendnoArray;QJsonArray attendmaybeArray;
if (newsitem.toObject().contains("friendica_activities")){
@ -382,7 +380,6 @@ void UPDATENEWS::store(QByteArray serverreply,QString apiname)
}
}
QList<QJsonValue> newcontacts=findNewContacts(news);
//qDebug()<< "new contacts count " << newcontacts.size();
if (newcontacts.size()>0){
updateContacts(newcontacts);
startImagedownload();
@ -410,7 +407,6 @@ void UPDATENEWS::updateImageLocation(QString downloadtype,QString imageurl, QStr
if (downloadtype=="contactlist"){
QSqlQuery testquery("SELECT profile_image FROM contacts WHERE profile_image_url ='"+imageurl+ "' AND username = '" +username+"'",m_db);
testquery.first();
//qDebug()<< "update imageurl for " <<imageurl << " from " <<testquery.value(0).toString() <<" to "<< filename <<" index " << index << " newcontactnames.length " <<newcontactnames.length();
QSqlQuery query("UPDATE contacts SET profile_image='"+ filename +"' WHERE profile_image_url ='"+imageurl+ "' AND username = '" +username+"'",m_db);
if(!(query.exec())) {qDebug()<< "updateImagelocation " << query.lastError();}
if (index==(newcontactnames.length()-1)){
@ -441,7 +437,6 @@ QList <QJsonValue> UPDATENEWS::findNewContacts(QJsonDocument news){
imageurls.append(query.value(0).toString());
}
QList<QJsonValue> newcontacts;
//qDebug()<<"updatenews findcontacts news count "<<news.array().count();
for (int i=0; i<news.array().count();i++){
//main contacts
@ -505,7 +500,6 @@ void UPDATENEWS::updateContacts(QList<QJsonValue> contacts){
QJsonValue contact=contacts[i];
QSqlQuery query(m_db);
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=?,"
@ -595,7 +589,6 @@ void UPDATENEWS::updateContacts(QList<QJsonValue> contacts){
void UPDATENEWS::storeEvents(QByteArray serverreply,QString apiname)
{ if (apiname!=m_api || xhr.downloadtype()!=""){} else {
QJsonDocument events;
//qDebug()<<apiname << serverreply;
QJsonParseError jsonerror;
events=QJsonDocument::fromJson(serverreply,&jsonerror);
if (events.isArray()){
@ -650,7 +643,6 @@ QString UPDATENEWS::url() const
void UPDATENEWS::startImagedownload()
{
//qDebug() << "start image download";
xhr.setDownloadtype("contactlist");
xhr.setFilelist(newcontactimagelinks);
xhr.setContactlist(newcontactnames);

121
source-linux/common/uploadableimage (conflicted copy 2017-12-15 232034).cpp

@ -0,0 +1,121 @@
// 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/>.
#include "uploadableimage.h"
#include <QBuffer>
#include <QDebug>
#include <QFileInfo>
#include <QUrl>
void UploadableImage::setSource(const QString &a) {
if (a != m_source) {
m_source = a;
//m_base64 = "";
m_mimetype = "";
m_filename = "";
qDebug() << "UploadableImage::setSource : " << m_source;
if (m_source=="") {
emit sourceChanged();
//emit base64Changed();
emit mimetypeChanged();
emit filenameChanged();
return;
}
QImage fullimage = QImage(QUrl(m_source).toLocalFile());
if (fullimage.width() > 800 || fullimage.height() > 800) {
if (fullimage.width() > fullimage.height()) {
m_image = fullimage.scaledToWidth(800);
} else {
m_image = fullimage.scaledToHeight(800);
}
} else {
m_image = fullimage;
}
qDebug() << "UploadableImage::setSource : " << m_image.width() << "x" << m_image.height();
emit sourceChanged();
QFileInfo fi(m_source);
m_filename = fi.fileName();
emit filenameChanged();
QString filetype = fi.suffix().toUpper();
if (filetype!="PNG" && filetype!="JPG") {
filetype = "JPG";
}
qDebug() << "UploadableImage::setSource : " << "Saving as " << filetype;
m_mimetype = "image/"+filetype.toLower();
emit mimetypeChanged();
/*
QByteArray byteArray;
QBuffer buffer(&byteArray);
m_image.save(&buffer, filetype.toLatin1().constData());
QString b64 = QString::fromLatin1(byteArray.toBase64().data());
for(int k=0; k<b64.length(); k+=76) {
m_base64 += b64.mid(k,76) + "\n";
}
m_base64 = m_base64.trimmed();
emit base64Changed();
*/
}
}
QString UploadableImage::source() const {
return m_source;
}
//QString UploadableImage::base64() const {
// return m_base64;
//}
QString UploadableImage::filename() const {
return m_filename;
}
QString UploadableImage::mimetype() const {
return m_mimetype;
}
QByteArray UploadableImage::bytes() {
QByteArray byteArray;
QBuffer buffer(&byteArray);
m_image.save(&buffer, "PNG");
return byteArray;
}

71
source-linux/common/uploadableimage (conflicted copy 2017-12-15 232034).h

@ -0,0 +1,71 @@
// 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/>.
#ifndef UPLOADABLEIMAGE_H
#define UPLOADABLEIMAGE_H
#include <QObject>
#include <QQuickItem>
#include <QImage>
class UploadableImage : public QObject
{
Q_OBJECT
Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
//Q_PROPERTY(QString base64 READ base64 NOTIFY base64Changed)
Q_PROPERTY(QString filename READ filename NOTIFY filenameChanged)
Q_PROPERTY(QString mimetype READ mimetype NOTIFY mimetypeChanged)
Q_PROPERTY(QByteArray bytes READ bytes)
public:
void setSource(const QString &a);
QString source() const;
//QString base64() const;
QString filename() const;
QString mimetype() const;
QByteArray bytes();
signals:
void sourceChanged();
//void base64Changed();
void filenameChanged();
void mimetypeChanged();
private:
QString m_source;
QImage m_image;
//QString m_base64;
QString m_filename;
QString m_mimetype;
};
#endif // UPLOADABLEIMAGE_H

369
source-linux/common/xhr (conflicted copy 2019-06-24 214813).cpp

@ -0,0 +1,369 @@
// 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/>.
#include "xhr.h"
#include <QHttpPart>
#include <QTextCodec>
#include <QUrlQuery>
#include <QList>
#include <QDataStream>
#include <QJsonDocument>
#include <QJsonObject>
#include "uploadableimage.h"
XHR *XHR::instance()
{
static XHR xhr;
return &xhr;
}
XHR::XHR(QObject *parent) : QObject(parent)
{
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
}
void XHR::setUrl(QString url)
{
if (url!=m_url) {
m_url = url;
emit urlChanged();
}
}
void XHR::setApi(QString api)
{
if (api!=m_api) {
m_api = api;
emit apiChanged();
}
}
void XHR::setLogin(QString login)
{
if (login!=m_login) {
m_login = login;
emit loginChanged();
}
}
void XHR::setFilename(QString filename)
{
if (filename!=m_filename) {
m_filename = filename;
emit filenameChanged();
}
}
void XHR::setContactlist(QList<QString> contactlist)
{
if (contactlist!=m_contactlist) {
m_contactlist = contactlist;
emit contactlistChanged();
}
}
void XHR::setFilelist(QList<QString> filelist)
{
if (filelist!=m_filelist) {
m_filelist = filelist;
emit filelistChanged();
}
}
void XHR::setImagedir(QString imagedir)
{
if (imagedir!=m_imagedir) {
m_imagedir = imagedir;
emit imagedirChanged();
}
}
void XHR::setDownloadtype(QString downloadtype)
{
if (downloadtype!=m_downloadtype) {
m_downloadtype = downloadtype;
emit downloadtypeChanged();
}
}
QString XHR::url() const
{
return m_url;
}
QString XHR::api() const
{
return m_api;
}
QString XHR::login() const
{
return m_login;
}
QString XHR::filename() const
{
return m_filename;
}
QList<QString> XHR::contactlist() const
{
return m_contactlist;
}
QList<QString> XHR::filelist() const
{
return m_filelist;
}
QString XHR::imagedir() const
{
return m_imagedir;
}
QString XHR::downloadtype() const
{
return m_downloadtype;
}
QString XHR::networktype()
{
return nc.bearerTypeFamily() + nc.bearerTypeName();
}
void XHR::setParam(QString name, QString value)
{
params.insert(name, value);
}
void XHR::setImageFileParam(QString name, QString url)
{
files.insert(name, url);
}
void XHR::clearParams()
{
files.clear();
params.clear();
}
void XHR::download()
{
QUrl requrl(m_url);
if(m_downloadtype=="picturelist"){
QByteArray loginData = m_login.toLocal8Bit().toBase64();
QString headerData = "Basic " + loginData;
request.setRawHeader("Authorization", headerData.toLocal8Bit());
}
request.setUrl(requrl);
reply = manager.get(request);
reply->ignoreSslErrors();
connect(reply, &QNetworkReply::readyRead,this, &XHR::onReadyRead);
//connect(reply,SIGNAL(downloadProgress(qint64,qint64)), this,SLOT(updateDownloadProgress(qint64,qint64)));
connect(reply, &QNetworkReply::finished,this, &XHR::onRequestFinished);
connect(reply, &QNetworkReply::sslErrors, this, &XHR::onSSLError);
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
}
void XHR::get()
{
QUrlQuery query;
QHashIterator<QString, QString> i(params);
while(i.hasNext()) {
i.next();
query.addQueryItem(i.key(), i.value());
//qDebug()<<i.key() << " value "<< i.value();
}
QUrl requrl(m_url+m_api);
//qDebug() << "API "<< requrl<<m_api;
requrl.setQuery(query);
QByteArray loginData = m_login.toLocal8Bit().toBase64();
QString headerData = "Basic " + loginData;
request.setRawHeader("Authorization", headerData.toLocal8Bit());
request.setUrl(requrl);
reply = manager.get(request);
connect(reply, &QNetworkReply::finished, this, &XHR::onReplySuccess);
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
connect(reply, &QNetworkReply::readyRead, this, &XHR::onReadyRead);
connect(reply, &QNetworkReply::sslErrors, this, &XHR::onSSLError);
}
void XHR::getlist()
{
if(dlindex < m_filelist.size()) {
QString cleanfilename;
if (m_downloadtype=="contactlist"){cleanfilename = m_contactlist.at(dlindex)+"-"+ m_filelist.at(dlindex).section('/',-1).section('?',0,0);
XHR::setFilename(imagedir()+"contacts/"+cleanfilename);
XHR::setUrl(m_filelist.at(dlindex));}
else {
XHR::setUrl(m_filelist.at(dlindex));}
XHR::download();
} else {dlindex=0;m_downloadtype="";m_contactlist.clear();m_filelist.clear();}
}
void XHR::post()
{
//qDebug() << "start post to " << m_url;
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
QHashIterator<QString, QString> iparams(params);
while(iparams.hasNext()) {
iparams.next();
//qDebug() << "\t add param " << iparams.key() << " : " << iparams.value();
QHttpPart textPart;
textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"" + iparams.key() + "\""));
textPart.setBody(iparams.value().toUtf8());
multiPart->append(textPart);
}
UploadableImage uimg;
QHashIterator<QString, QString> ifiles(files);
while(ifiles.hasNext()) {
ifiles.next();
uimg.setSource(ifiles.value());
//qDebug() << "\t image: " << uimg.mimetype() << ", " << ifiles.key();
QHttpPart imagePart;
imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(uimg.mimetype()));
imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"" + ifiles.key() + "\"; filename=\""+uimg.filename()+"\""));
imagePart.setBody(uimg.bytes());
multiPart->append(imagePart);
}
QByteArray loginData = m_login.toLocal8Bit().toBase64();
QString headerData = "Basic " + loginData;
request.setRawHeader(QByteArray("Authorization"), headerData.toLocal8Bit());
request.setUrl(m_url+m_api);
reply = manager.post(request, multiPart);
qDebug() << "\t request sent";
connect(reply, &QNetworkReply::finished, this, &XHR::onReplySuccess);
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onReplyError(QNetworkReply::NetworkError)));
connect(reply, &QNetworkReply::readyRead, this, &XHR::onReadyRead);
connect(reply, &QNetworkReply::sslErrors, this, &XHR::onSSLError);
qDebug() << "\t reply signals connected";
}
void XHR::onReplyError(QNetworkReply::NetworkError code)
{
qDebug() << code;
emit this->error( bufferToString(), m_url,m_api, (int) code);
buffer.clear();
reply->deleteLater();
}
void XHR::onReplySuccess()
{
qDebug() << "!";
emit this->success(buffer, m_api);
buffer.clear();
// reply->deleteLater();
}
void XHR::onRequestFinished()
{
qDebug()<<"download requestFinished ";
// Save the file here
if (buffer.isNull()){qDebug() << "File empty"<<m_url; buffer.clear(); emit this->error(m_downloadtype,m_url,m_api,1);}
else if (m_downloadtype=="picturelist") {
QJsonDocument jsonResponse = QJsonDocument::fromJson(buffer);
QJsonObject jsonObject = jsonResponse.object();
int arraystart=buffer.indexOf('{"data":"')+8;
int arraylength=buffer.indexOf('"',9)-arraystart;
QByteArray b64=buffer.mid(arraystart,arraylength);
QString helpfilename=jsonObject["filename"].toString();
QString helpfile=helpfilename.left(helpfilename.lastIndexOf("."));
QString filesuffix="";
if (jsonObject["type"].toString()=="image/jpeg"){filesuffix=".jpg";}
else if (jsonObject["type"].toString()=="image/png"){filesuffix=".png";}
else {filesuffix="";}
if (helpfilename==""){// check if file has any filename
helpfile=jsonObject["id"].toString();
setFilename(imagedir()+"albums/"+jsonObject["album"].toString()+"/"+jsonObject["id"].toString()+filesuffix);
}
else{setFilename(imagedir()+"albums/"+jsonObject["album"].toString()+"/"+helpfile+filesuffix);}
//qDebug()<<"Filename "<<m_filename;
QFile file(m_filename);
file.open(QIODevice::WriteOnly);
file.write(QByteArray::fromBase64(b64));
buffer.clear();
b64.clear();
file.close();
jsonObject["data"]="";
jsonObject["filename"]=helpfile+filesuffix;
emit this->downloadedjson(m_downloadtype,m_url,m_filename,dlindex,jsonObject);
if(downloadtype()=="picturelist"){dlindex=dlindex+1;XHR::getlist();}
}
else {
QFile file(m_filename);
file.open(QIODevice::WriteOnly);
file.write(buffer);
buffer.clear();
file.close();
emit this->downloaded(m_downloadtype,m_url,m_filename,dlindex);
if(downloadtype()=="contactlist"){dlindex=dlindex+1;XHR::getlist();}
//reply->deleteLater();
}
}
void XHR::onReadyRead()
{
qDebug() << ".";
buffer += reply->readAll();
}
//void XHR::updateDownloadProgress(qint64 bytesRead, qint64 totalBytes)
//{
// qDebug() << "Bytes: " << bytesRead<<" / "<<totalBytes;
//}
void XHR::onSSLError(const QList<QSslError> &errors)
{
qDebug() << "XHR::onSSLError :" ;
QListIterator<QSslError> ierrs(errors);
while(ierrs.hasNext()) {
qDebug() << "\t" << ierrs.next().errorString();
}
}
QString XHR::bufferToString()
{
return QTextCodec::codecForName("utf-8")->toUnicode(buffer);
}

18
source-linux/common/xhr.cpp

@ -154,11 +154,6 @@ QString XHR::downloadtype() const
return m_downloadtype;
}
QString XHR::networktype()
{
return nc.bearerTypeFamily() + nc.bearerTypeName();
}
void XHR::setParam(QString name, QString value)
{
params.insert(name, value);
@ -261,19 +256,6 @@ void XHR::post()
imagePart.setBody(uimg.bytes());
multiPart->append(imagePart);
}
// QHashIterator<QString, QString> ifiles(files);
// while(ifiles.hasNext()) {
// ifiles.next();
// uimg.setSource(ifiles.value());
// //qDebug() << "\t image: " << uimg.mimetype() << ", " << ifiles.key();
// QHttpPart imagePart;
// imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(uimg.mimetype()));
// imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"" + ifiles.key() + "\"; filename=\""+uimg.filename()+"\""));
// imagePart.setBody(uimg.bytes());
// multiPart->append(imagePart);
// }
QByteArray loginData = m_login.toLocal8Bit().toBase64();
QString headerData = "Basic " + loginData;

8
source-linux/common/xhr.h

@ -49,7 +49,7 @@ class XHR : public QObject
Q_PROPERTY(QList<QString> contactlist READ contactlist WRITE setContactlist NOTIFY contactlistChanged)
Q_PROPERTY(QList<QString> filelist READ filelist WRITE setFilelist NOTIFY filelistChanged)
Q_PROPERTY(QString downloadtype READ downloadtype WRITE setDownloadtype NOTIFY downloadtypeChanged)
Q_PROPERTY(QString networktype READ networktype() NOTIFY networktypeChanged)
//Q_PROPERTY(QString networktype READ networktype() NOTIFY networktypeChanged)
public:
@ -65,7 +65,7 @@ public:
QList<QString> filelist() const;
QString imagedir() const;
QString downloadtype() const;
QString networktype();
// QString networktype();
signals:
void urlChanged();
@ -116,7 +116,7 @@ private:
QString m_login;
QString m_filename;
QString m_downloadtype;
QString m_networktype;
// QString m_networktype;
QHash<QString, QString> params;
QHash<QString, QString> files;
QList<QString> m_filelist;
@ -127,7 +127,7 @@ private:
QNetworkAccessManager manager;
QNetworkRequest request;
QNetworkReply *reply;
QNetworkConfiguration nc;
//QNetworkConfiguration nc;
QString bufferToString();
};

8
source-linux/js/image.js

@ -172,11 +172,11 @@ function deleteContacts(database,user,callback) { // does nothing useful at the
// })
//}
function newRequestFriendsAlbumPictures(login,friend,rootwindow,callback){print("newRequestFriendsAlbumPictures");
function newRequestFriendsAlbumPictures(login,friend,rootwindow,callback){//print("newRequestFriendsAlbumPictures");
// screenscraping of albums page of contact with remoteAuth
//commented out for broken remoteauth
//Helperjs.friendicaRemoteAuthRequest(login,friend.url.replace("profile","photos"),friend.url,rootwindow,function(photohtml){
Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){
Helperjs.friendicaRemoteAuthRequest(login,friend.url.replace("profile","photos"),friend.url,rootwindow,function(photohtml){
//Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){
try {var obj=JSON.parse(photohtml);print ("Photohtml: "+photohtml)
if (obj.hasOwnProperty('status')){
Helperjs.friendicaWebRequest(friend.url.replace("profile","photos"),rootwindow,function(photohtml){
@ -190,7 +190,7 @@ function newRequestFriendsAlbumPictures(login,friend,rootwindow,callback){print(
}
function getAlbumFromHtml(photohtml,remoteAuthBool,rootwindow,callback){
print(photohtml);
//print(photohtml);
var photoarray=[];
var arr = photohtml.split("sidebar-photos-albums-li");
for (var i=2;i<arr.length;i++){

111
source-linux/js/news.js

@ -86,6 +86,37 @@ function listFriends(login,database,callback,filter){
});
}
function listHashtags(login,database,callback){
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
db.transaction( function(tx) {
var result = tx.executeSql('SELECT * from hashtags WHERE username="'+login.username+'" ORDER BY date DESC LIMIT 50');
// check for frie