Browse Source

Friendiqa v0.2

master v0.2
LubuWest 4 years ago
parent
commit
a3be940192
  1. 84
      CHANGELOG.md
  2. BIN
      Friendiqa_v0.2.apk
  3. 55
      README.md
  4. 2
      source-android/android/AndroidManifest.xml
  5. 10
      source-android/application.qrc
  6. 123
      source-android/common/filesystem.cpp
  7. 47
      source-android/common/filesystem.h
  8. 44
      source-android/common/friendiqa.cpp
  9. 56
      source-android/common/imageselectandroid.cpp
  10. 23
      source-android/common/imageselectandroid.h
  11. 348
      source-android/common/qasystemdispatcher.cpp
  12. 47
      source-android/common/qasystemdispatcher.h
  13. 22
      source-android/common/quickandroid.cpp
  14. 21
      source-android/common/quickandroid.h
  15. 123
      source-android/common/remoteauthasyncimageprovider.cpp
  16. 95
      source-android/common/remoteauthasyncimageprovider.h
  17. 31
      source-android/common/uploadableimage.cpp
  18. 31
      source-android/common/uploadableimage.h
  19. 157
      source-android/common/xhr.cpp
  20. 54
      source-android/common/xhr.h
  21. 4
      source-android/friendiqa.pro
  22. 30
      source-android/js/friendworker.js
  23. 48
      source-android/js/helper.js
  24. 272
      source-android/js/image.js
  25. 31
      source-android/js/layout.js
  26. 155
      source-android/js/news.js
  27. 31
      source-android/js/newsworker.js
  28. 34
      source-android/js/photoworker.js
  29. 318
      source-android/js/service.js
  30. 31
      source-android/js/smiley.js
  31. 31
      source-android/qml/calendarqml/CalendarDay.qml
  32. 59
      source-android/qml/calendarqml/CalendarTab.qml
  33. 34
      source-android/qml/calendarqml/EventList.qml
  34. 123
      source-android/qml/configqml/ConfigTab.qml
  35. 35
      source-android/qml/configqml/InfoBox.qml
  36. 34
      source-android/qml/configqml/OSSettingsAndroid.qml
  37. 34
      source-android/qml/configqml/OSSettingsLinux.qml
  38. 33
      source-android/qml/contactqml/ContactComponent.qml
  39. 41
      source-android/qml/contactqml/ContactDetailsComponent.qml
  40. 91
      source-android/qml/contactqml/ContactDetailsComponentOld.qml
  41. 31
      source-android/qml/contactqml/Contactlist.qml
  42. 106
      source-android/qml/contactqml/FriendsTab.qml
  43. 31
      source-android/qml/contactqml/GroupComponent.qml
  44. 277
      source-android/qml/contactqml/ProfileComponent.qml
  45. 103
      source-android/qml/friendiqa.qml
  46. 31
      source-android/qml/genericqml/BlueButton.qml
  47. 54
      source-android/qml/genericqml/ImagePickerLinux.qml
  48. 31
      source-android/qml/genericqml/PermissionDialog.qml
  49. 32
      source-android/qml/newsqml/Conversation.qml
  50. 31
      source-android/qml/newsqml/FriendicaActivities.qml
  51. 46
      source-android/qml/newsqml/MessageSend.qml
  52. 90
      source-android/qml/newsqml/NewsTab.qml
  53. 39
      source-android/qml/newsqml/Newsitem.qml
  54. 31
      source-android/qml/newsqml/PermissionDialog.qml
  55. 31
      source-android/qml/newsqml/SmileyDialog.qml
  56. 67
      source-android/qml/photoqml/ImageUploadDialog.qml
  57. 37
      source-android/qml/photoqml/PhotoComponent.qml
  58. 143
      source-android/qml/photoqml/PhotoTab.qml
  59. 38
      source-android/qml/photoqml/PhotogroupComponent.qml
  60. BIN
      source-android/translations/friendiqa-de.qm
  61. 487
      source-android/translations/friendiqa-de.ts
  62. BIN
      source-android/translations/friendiqa-es.qm
  63. 487
      source-android/translations/friendiqa-es.ts
  64. BIN
      source-android/translations/friendiqa-it.qm
  65. 785
      source-android/translations/friendiqa-it.ts
  66. 9
      source-linux/application.qrc
  67. 33
      source-linux/common/filesystem.cpp
  68. 41
      source-linux/common/filesystem.h
  69. 54
      source-linux/common/friendiqa.cpp
  70. 50
      source-linux/common/imagepickerandroid.cpp
  71. 23
      source-linux/common/imagepickerandroid.h
  72. 123
      source-linux/common/remoteauthasyncimageprovider.cpp
  73. 95
      source-linux/common/remoteauthasyncimageprovider.h
  74. 31
      source-linux/common/uploadableimage.cpp
  75. 31
      source-linux/common/uploadableimage.h
  76. 157
      source-linux/common/xhr.cpp
  77. 54
      source-linux/common/xhr.h
  78. 42
      source-linux/friendiqa.pro
  79. 30
      source-linux/js/friendworker.js
  80. 48
      source-linux/js/helper.js
  81. 272
      source-linux/js/image.js
  82. 31
      source-linux/js/layout.js
  83. 172
      source-linux/js/news.js
  84. 46
      source-linux/js/newsworker.js
  85. 34
      source-linux/js/photoworker.js
  86. 327
      source-linux/js/service.js
  87. 31
      source-linux/js/smiley.js
  88. 31
      source-linux/qml/calendarqml/CalendarDay.qml
  89. 69
      source-linux/qml/calendarqml/CalendarTab.qml
  90. 34
      source-linux/qml/calendarqml/EventList.qml
  91. 124
      source-linux/qml/configqml/ConfigTab.qml
  92. 42
      source-linux/qml/configqml/InfoBox.qml
  93. 34
      source-linux/qml/configqml/OSSettingsAndroid.qml
  94. 34
      source-linux/qml/configqml/OSSettingsLinux.qml
  95. 35
      source-linux/qml/contactqml/ContactComponent.qml
  96. 41
      source-linux/qml/contactqml/ContactDetailsComponent.qml
  97. 31
      source-linux/qml/contactqml/Contactlist.qml
  98. 128
      source-linux/qml/contactqml/FriendsTab.qml
  99. 148
      source-linux/qml/contactqml/GroupComponent.qml
  100. 277
      source-linux/qml/contactqml/ProfileComponent.qml

84
CHANGELOG.md

@ -1,29 +1,55 @@
## v0.1#
# News #
* Native Android image selector for new message
* Click on contacts shows contact details on news page
* Fix problem with news list after deletion of item
# Contacts #
* Clean contacts with no news
# Images #
* Upload pictures with description to album (permissions cannot be set due to API problems)
* Delete pictures or albums from client and server (long press on picture in overview)
* Fix problem when enlarging photo
# Translations #
* German, Spanish
## v0.1.1#
* FIX: Spanish translation
* FIX: Empty Newsview after deletion of first newsitem
## v0.1.2#
* FIX: Include openssl v1.0.2m for SSL connections in Android v7 and above
## v0.1##
# News #
* Native Android image selector for new message
* Click on contacts shows contact details on news page
* Fix problem with news list after deletion of item
# Contacts #
* Clean contacts with no news
# Images #
* Upload pictures with description to album (permissions cannot be set due to API problems)
* Delete pictures or albums from client and server (long press on picture in overview)
* Fix problem when enlarging photo
# Translations #
* German, Spanish
## v0.1.1##
* FIX: Spanish translation
* FIX: Empty Newsview after deletion of first newsitem
## v0.1.2#
* FIX: Include openssl v1.0.2m for SSL connections in Android v7 and above
## v0.2 ##
# News #
* Profile image download completely reworked, resulting in speed improvement
# Contacts #
* New profile tab, data of public and private profiles shown
* Change profile picture
* For friends image button shows private images thanks to new remoteAuth API (Friendica 3.6 server required) --> private holiday pictures have finally arrived!
* For friends calendar button shows private events thanks to new remoteAuth API (Friendica 3.6 server required)
* News button for forum accounts shows news published via that forum
# Images #
* Complete rework of image download, fixes bug with private images
* Download all or only new images
# Config #
* Check if nickname exist on server
* Check if password is correct
* Account deletion now also removes news, image data and events from local db
# Translations #
* Italian thanks to Davide de Prisco

BIN
Friendiqa_v0.2.apk

55
README.md

@ -20,7 +20,8 @@ QML based client for the Friendica Social Network.
Currently supported:
* Shows Posts from friends, favorited messages, Direct Messages and Notifications
* Open links in external browser
* Click on contact photo for contact details
*
Click on contact photo for contact details
* Click on like text for additional contact info
* Deletion, Reposting, Answering of Posts
* Liking, disliking, favoriting
@ -32,8 +33,7 @@ Currently supported:
ToDo:
* Move picture download into a background process
* Videos and other binary data as attachment (sending and receiving, currently not supported in API)
* Videos and other binary data as attachment (sending and receiving)
* More than one attachment (currently not supported in API)
* Rich text editing in Send Dialog
* Attachments for Direct messages (currently not supported in API)
@ -42,47 +42,54 @@ ToDo:
# Friends #
Currently supported:
* Tabs for friends, other contacts and groups
* Tabs for own profiles, friends, other contacts and groups
* Show profile(s) of user and change profile picture
* Grid of all known contacts with locally downloaded pictures
* Large friend item for addional information and functionality
* Large friend item for additional information and functionality
* Show news of contact from local database
* Send direct message, if contact is following
* Show public pictures of contact (screenscraping of contact's website, works only with certain theme)
* Show public and private (Friendica 3.6 required) pictures of contact (screenscraping of contact's website, works only with certain theme)
* Show public and private (Friendica 3.6 required) events of contact
* Show members of groups
* Open website of contact or connect page (for other contacts)
* Clean other contacts with no news
ToDo:
* More information for contact from description page, possibly private information for friends (currently not supported in API)
* More information for contact from description page, possibly private information for friends
(needs API change)
* Groups: create, change, delete
(needs API change)
# Images #
Currently supported:
* Download all own images to local directory
* Download public and private own images to local directory
* Upload picture to album with descriptions(public)
* Delete own pictures and albums on client and server
* Show albums in grid, show images in album in grid and fullscreen
* Upload pictures to albums with description
* Delete pictures on client and server
* Show albums and images of contacts
* Show public and private (Friendica 3.6 server required) albums and images of contacts
* Pinch to zoom, swipe to scroll
ToDo:
* Private images of friends
* Support for all themes of friends
* Change name or album of existing picture
* Upload private images
# Events #
* download own public events and show public events of Friendica contacts
* list view of events of selected date
* click on event to show details
* Download own public events
* Show public and private events of Friendica contacts (Friendica 3.6 server required)
* List view of events of selected date
* Click on event to show details
ToDo
* private events
* Show own private events (needs API)
* Create events (needs API)
# Config #
Currently supported:
* Multiple accounts
* Maximum news (surplus deleted after use of Quit button)
* Maximum news (deleted after use of Quit button)
* View mode for news (tree or timeline)
ToDo
@ -97,12 +104,14 @@ ToDo
# Translations #
* German, Spanish
* German, Spanish, Italian
# Install #
* F-Droid binary repository: [https://www.ma-nic.de/fdroid/repo](https://www.ma-nic.de/fdroid/repo)
* [Google Playstore](https://play.google.com/store/apps/details?id=org.qtproject.friendiqa)
* F-Droid binary repository: [https://www.ma-nic.de/fdroid/repo](https://www.ma-nic.de/fdroid/repo)
* [Google Playstore](https://play.google.com/store/apps/details?id=org.qtproject.friendiqa)
## License ##
Pubished under the [GPL v3](http://gplv3.fsf.org).
Pubished under the [GPL v3](http://gplv3.fsf.org) with the exception of the Openssl library, which is published under OpenSSL License.

2
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.1.2" android:versionCode="3" android:installLocation="auto">
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.2" android:versionCode="4" 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="singleTop">
<intent-filter>

10
source-android/application.qrc

@ -210,13 +210,13 @@
<file>translations/friendiqa-es.qm</file>
<file>translations/friendiqa-es.ts</file>
<file>qml/photoqml/ImageUploadDialog.qml</file>
<file>qml/genericqml/ImageDialog.qml</file>
<file>qml/genericqml/PermissionDialog.qml</file>
<file>images/addImage.png</file>
<file>common/imageselectandroid.h</file>
<file>common/imageselectandroid.cpp</file>
<file>qml/genericqml/ImagePicker.qml</file>
<file>common/quickandroid.h</file>
<file>common/quickandroid.cpp</file>
<file>qml/genericqml/ImagePickerLinux.qml</file>
<file>js/image.js</file>
<file>qml/contactqml/ProfileComponent.qml</file>
<file>translations/friendiqa-it.ts</file>
<file>translations/friendiqa-it.qm</file>
</qresource>
</RCC>

123
source-android/common/filesystem.cpp

@ -1,3 +1,34 @@
// 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 "filesystem.h"
FILESYSTEM *FILESYSTEM::instance()
@ -29,12 +60,12 @@ QString FILESYSTEM::homePath() const
return homeDir;
}
QString FILESYSTEM::cameraPath() const
{
QAndroidJniObject object = QAndroidJniObject::getStaticObjectField<jstring>("android.os.Environment", "DIRECTORY_DCIM");
QAndroidJniObject dcim =QAndroidJniObject::callStaticObjectMethod("android.os.Environment","getExternalStoragePublicDirectory", "(Ljava/lang/String;)Ljava/io/File;", object.object<jobject>());
return dcim.toString();
}
//QString FILESYSTEM::cameraPath() const
//{
//QAndroidJniObject object = QAndroidJniObject::getStaticObjectField<jstring>("android.os.Environment", "DIRECTORY_DCIM");
//QAndroidJniObject dcim =QAndroidJniObject::callStaticObjectMethod("android.os.Environment","getExternalStoragePublicDirectory", "(Ljava/lang/String;)Ljava/io/File;", object.object<jobject>());
// return dcim.toString();
//}
//bool FILESYSTEM::direxist(QString Directory) const
@ -83,46 +114,46 @@ QFileInfoList FILESYSTEM::fileList()
return dir.entryInfoList();
}
void FILESYSTEM::searchImage()
{
QAndroidJniObject ACTION_PICK = QAndroidJniObject::getStaticObjectField("android/content/Intent", "ACTION_PICK", "Ljava/lang/String;");
QAndroidJniObject EXTERNAL_CONTENT_URI = QAndroidJniObject::getStaticObjectField("android/provider/MediaStore$Images$Media", "EXTERNAL_CONTENT_URI", "Landroid/net/Uri;");
//void FILESYSTEM::searchImage()
//{
// QAndroidJniObject ACTION_PICK = QAndroidJniObject::getStaticObjectField("android/content/Intent", "ACTION_PICK", "Ljava/lang/String;");
// QAndroidJniObject EXTERNAL_CONTENT_URI = QAndroidJniObject::getStaticObjectField("android/provider/MediaStore$Images$Media", "EXTERNAL_CONTENT_URI", "Landroid/net/Uri;");
QAndroidJniObject intent=QAndroidJniObject("android/content/Intent", "(Ljava/lang/String;Landroid/net/Uri;)V", ACTION_PICK.object<jstring>(), EXTERNAL_CONTENT_URI.object<jobject>());
// QAndroidJniObject intent=QAndroidJniObject("android/content/Intent", "(Ljava/lang/String;Landroid/net/Uri;)V", ACTION_PICK.object<jstring>(), EXTERNAL_CONTENT_URI.object<jobject>());
if (ACTION_PICK.isValid() && intent.isValid())
{
intent.callObjectMethod("setType", "(Ljava/lang/String;)Landroid/content/Intent;", QAndroidJniObject::fromString("image/*").object<jstring>());
QtAndroid::startActivity(intent.object<jobject>(), 101,this);
qDebug() << "OK";
}
else
{
qDebug() << "ERRO";
}
}
// if (ACTION_PICK.isValid() && intent.isValid())
// {
// intent.callObjectMethod("setType", "(Ljava/lang/String;)Landroid/content/Intent;", QAndroidJniObject::fromString("image/*").object<jstring>());
// QtAndroid::startActivity(intent.object<jobject>(), 101,this);
// qDebug() << "OK";
// }
// else
// {
// qDebug() << "ERRO";
// }
//}
void FILESYSTEM::handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data)
{
jint RESULT_OK = QAndroidJniObject::getStaticField<jint>("android/app/Activity", "RESULT_OK");
if (receiverRequestCode == 101 && resultCode == RESULT_OK)
{
QAndroidJniObject uri = data.callObjectMethod("getData", "()Landroid/net/Uri;");
QAndroidJniObject dadosAndroid = QAndroidJniObject::getStaticObjectField("android/provider/MediaStore$MediaColumns", "DATA", "Ljava/lang/String;");
QAndroidJniEnvironment env;
jobjectArray projecao = (jobjectArray)env->NewObjectArray(1, env->FindClass("java/lang/String"), NULL);
jobject projacaoDadosAndroid = env->NewStringUTF(dadosAndroid.toString().toStdString().c_str());
env->SetObjectArrayElement(projecao, 0, projacaoDadosAndroid);
QAndroidJniObject contentResolver = QtAndroid::androidActivity().callObjectMethod("getContentResolver", "()Landroid/content/ContentResolver;");
QAndroidJniObject cursor = contentResolver.callObjectMethod("query", "(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;", uri.object<jobject>(), projecao, NULL, NULL, NULL);
jint columnIndex = cursor.callMethod<jint>("getColumnIndex", "(Ljava/lang/String;)I", dadosAndroid.object<jstring>());
cursor.callMethod<jboolean>("moveToFirst", "()Z");
QAndroidJniObject resultUri = cursor.callObjectMethod("getString", "(I)Ljava/lang/String;", columnIndex);
QString imageSelect = "file://" + resultUri.toString();
emit imageselected(imageSelect);
}
else
{
qDebug() << "Select error";
}
}
//void FILESYSTEM::handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data)
//{
// jint RESULT_OK = QAndroidJniObject::getStaticField<jint>("android/app/Activity", "RESULT_OK");
// if (receiverRequestCode == 101 && resultCode == RESULT_OK)
// {
// QAndroidJniObject uri = data.callObjectMethod("getData", "()Landroid/net/Uri;");
// QAndroidJniObject dadosAndroid = QAndroidJniObject::getStaticObjectField("android/provider/MediaStore$MediaColumns", "DATA", "Ljava/lang/String;");
// QAndroidJniEnvironment env;
// jobjectArray projecao = (jobjectArray)env->NewObjectArray(1, env->FindClass("java/lang/String"), NULL);
// jobject projacaoDadosAndroid = env->NewStringUTF(dadosAndroid.toString().toStdString().c_str());
// env->SetObjectArrayElement(projecao, 0, projacaoDadosAndroid);
// QAndroidJniObject contentResolver = QtAndroid::androidActivity().callObjectMethod("getContentResolver", "()Landroid/content/ContentResolver;");
// QAndroidJniObject cursor = contentResolver.callObjectMethod("query", "(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;", uri.object<jobject>(), projecao, NULL, NULL, NULL);
// jint columnIndex = cursor.callMethod<jint>("getColumnIndex", "(Ljava/lang/String;)I", dadosAndroid.object<jstring>());
// cursor.callMethod<jboolean>("moveToFirst", "()Z");
// QAndroidJniObject resultUri = cursor.callObjectMethod("getString", "(I)Ljava/lang/String;", columnIndex);
// QString imageSelect = "file://" + resultUri.toString();
// emit imageselected(imageSelect);
// }
// else
// {
// qDebug() << "Select error";
// }
//}

47
source-android/common/filesystem.h

@ -1,18 +1,49 @@
// 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 FILESYSTEM_H
#define FILESYSTEM_H
#include <QDir>
#include <QObject>
#include <QtAndroidExtras>
#include <QAndroidActivityResultReceiver>
//#include <QtAndroidExtras>
//#include <QAndroidActivityResultReceiver>
class FILESYSTEM : public QObject, public QAndroidActivityResultReceiver
class FILESYSTEM : public QObject//, public QAndroidActivityResultReceiver
{
Q_OBJECT
Q_PROPERTY(QString Directory READ Directory WRITE setDirectory NOTIFY directoryChanged)
//Q_PROPERTY(bool direxist READ direxist)
Q_PROPERTY(QString homePath READ homePath)
Q_PROPERTY(QString cameraPath READ cameraPath)
//Q_PROPERTY(QString cameraPath READ cameraPath)
public:
@ -23,11 +54,11 @@ public:
QFileInfoList fileList();
//bool direxist(QString Directory);
QString homePath() const;
QString cameraPath() const;
virtual void handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data);
//QString cameraPath() const;
// virtual void handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data);
signals:
void imageselected(QString);
//void imageselected(QString);
void directoryChanged();
//void fileListContent(QList data);
void success(QString data);
@ -37,7 +68,7 @@ public slots:
void makeDir(QString name);
void rmDir();
void rmFile(QString name);
void searchImage();
//void searchImage();
//void fileList();
private:

44
source-android/common/friendiqa.cpp

@ -1,15 +1,45 @@
// 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 <QtQuick>
#include "xhr.h"
#include "filesystem.h"
//#include "qadrawableprovider.h"
//#include "androidnative.pri/cpp/AndroidNative/systemdispatcher.h"
#include "remoteauthasyncimageprovider.h"
#include "AndroidNative/systemdispatcher.h"
#include "AndroidNative/environment.h"
#include "AndroidNative/debug.h"
//#include "AndroidNative/debug.h"
#include "AndroidNative/mediascannerconnection.h"
//#include "debugwrapper.h"
#ifdef Q_OS_ANDROID
#include <QtAndroidExtras/QAndroidJniObject>
@ -30,9 +60,9 @@ int main(int argc, char *argv[]) {
QTranslator qtTranslator;
qtTranslator.load("friendiqa-" + QLocale::system().name(),":/translations");
app.installTranslator(&qtTranslator);
// qmlRegisterType<QASystemDispatcher>("SystemDispatcher", 0, 1, "SystemDispatcher");
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();

56
source-android/common/imageselectandroid.cpp

@ -1,56 +0,0 @@
#include "imageselectandroid.h"
imageSelectAndroid::imageSelectAndroid()
{
}
imageSelectAndroid *imageSelectAndroid::instance()
{
static imageSelectAndroid imageselectandroid;
return &imageselectandroid;
}
void imageSelectAndroid::searchImage()
{
QAndroidJniObject ACTION_PICK = QAndroidJniObject::getStaticObjectField("android/content/Intent", "ACTION_PICK", "Ljava/lang/String;");
QAndroidJniObject EXTERNAL_CONTENT_URI = QAndroidJniObject::getStaticObjectField("android/provider/MediaStore$Images$Media", "EXTERNAL_CONTENT_URI", "Landroid/net/Uri;");
QAndroidJniObject intent=QAndroidJniObject("android/content/Intent", "(Ljava/lang/String;Landroid/net/Uri;)V", ACTION_PICK.object<jstring>(), EXTERNAL_CONTENT_URI.object<jobject>());
if (ACTION_PICK.isValid() && intent.isValid())
{
intent.callObjectMethod("setType", "(Ljava/lang/String;)Landroid/content/Intent;", QAndroidJniObject::fromString("image/*").object<jstring>());
QtAndroid::startActivity(intent.object<jobject>(), 101, this);
qDebug() << "OK";
}
else
{
qDebug() << "ERRO";
}
}
void imageSelectAndroid::handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data)
{ qDebug() << "done";
jint RESULT_OK = QAndroidJniObject::getStaticField<jint>("android/app/Activity", "RESULT_OK");
if (receiverRequestCode == 101 && resultCode == RESULT_OK)
{
qDebug() << "done";
QAndroidJniObject uri = data.callObjectMethod("getData", "()Landroid/net/Uri;");
QAndroidJniObject dadosAndroid = QAndroidJniObject::getStaticObjectField("android/provider/MediaStore$MediaColumns", "DATA", "Ljava/lang/String;");
QAndroidJniEnvironment env;
jobjectArray projecao = (jobjectArray)env->NewObjectArray(1, env->FindClass("java/lang/String"), NULL);
jobject projacaoDadosAndroid = env->NewStringUTF(dadosAndroid.toString().toStdString().c_str());
env->SetObjectArrayElement(projecao, 0, projacaoDadosAndroid);
QAndroidJniObject contentResolver = QtAndroid::androidActivity().callObjectMethod("getContentResolver", "()Landroid/content/ContentResolver;");
QAndroidJniObject cursor = contentResolver.callObjectMethod("query", "(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;", uri.object<jobject>(), projecao, NULL, NULL, NULL);
jint columnIndex = cursor.callMethod<jint>("getColumnIndex", "(Ljava/lang/String;)I", dadosAndroid.object<jstring>());
cursor.callMethod<jboolean>("moveToFirst", "()Z");
QAndroidJniObject resultUri = cursor.callObjectMethod("getString", "(I)Ljava/lang/String;", columnIndex);
QString imageSelect = "file://" + resultUri.toString();
emit imageselected(imageSelect);
}
else
{
qDebug() << "Select error";
}
}

23
source-android/common/imageselectandroid.h

@ -1,23 +0,0 @@
#ifndef IMAGEPICKANDROID_H
#define IMAGEPICKANDROID_H
#include <QObject>
#include <QtAndroidExtras>
#include <QDebug>
class imageSelectAndroid : public QObject, public QAndroidActivityResultReceiver
{
Q_OBJECT
public:
imageSelectAndroid();
static imageSelectAndroid *instance();
void searchImage();
virtual void handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject & data);
signals:
void imageselected(QString);
};
#endif // IMAGEPICKANDROID_H

348
source-android/common/qasystemdispatcher.cpp

@ -1,348 +0,0 @@
// Author: Ben Lau (https://github.com/benlau)
#include <QCoreApplication>
#include <QPointer>
#include <QtCore>
#include <QPair>
#include <QQueue>
#include "qasystemdispatcher.h"
static QPointer<QASystemDispatcher> m_instance;
QString QASystemDispatcher::ACTIVITY_RESUME_MESSAGE = "Activity.onResume";
QString QASystemDispatcher::ACTIVITY_RESULT_MESSAGE = "Activity.onActivityResult";
#ifdef Q_OS_ANDROID
#include <QAndroidJniObject>
#include <QAndroidJniEnvironment>
#define JCLASS_Name "quickandroid/SystemDispatcher"
#define DISPATCH_SIGNATURE "(Ljava/lang/String;Ljava/util/Map;)V"
#define EMIT_SIGNATURE "(Ljava/lang/String;Ljava/util/Map;)V"
static QVariantMap createVariantMap(jobject data);
static jobject createHashMap(const QVariantMap &data);
static QVariant convertToQVariant(QAndroidJniObject value) {
QVariant v;
if (!value.isValid()) {
return v;
}
QAndroidJniEnvironment env;
jclass jclass_of_string = env->FindClass("java/lang/String");
jclass jclass_of_integer = env->FindClass("java/lang/Integer");
jclass jclass_of_boolean = env->FindClass("java/lang/Boolean");
jclass jclass_of_list = env->FindClass("java/util/List");
jclass jclass_of_map = env->FindClass("java/util/Map");
if (env->IsInstanceOf(value.object<jobject>(),jclass_of_boolean)) {
v = QVariant::fromValue<bool>(value.callMethod<jboolean>("booleanValue","()Z"));
} else if (env->IsInstanceOf(value.object<jobject>(),jclass_of_integer)) {
v = value.callMethod<jint>("intValue","()I");
} else if (env->IsInstanceOf(value.object<jobject>(),jclass_of_string)) {
v = value.toString();
} else if (env->IsInstanceOf(value.object<jobject>(), jclass_of_map)) {
v = createVariantMap(value.object<jobject>());
} else if (env->IsInstanceOf(value.object<jobject>(),jclass_of_list)) {
QVariantList list;
int count = value.callMethod<jint>("size","()I");
for (int i = 0 ; i < count ; i++) {
QAndroidJniObject item = value.callObjectMethod("get","(I)Ljava/lang/Object;",i);
list.append(convertToQVariant(item));
}
v = list;
}
env->DeleteLocalRef(jclass_of_string);
env->DeleteLocalRef(jclass_of_integer);
env->DeleteLocalRef(jclass_of_boolean);
env->DeleteLocalRef(jclass_of_list);
env->DeleteLocalRef(jclass_of_map);
return v;
}
static QVariantMap createVariantMap(jobject data) {
QVariantMap res;
QAndroidJniEnvironment env;
/* Reference : https://community.oracle.com/thread/1549999 */
// Get the HashMap Class
jclass jclass_of_hashmap = (env)->GetObjectClass(data);
// Get link to Method "entrySet"
jmethodID entrySetMethod = (env)->GetMethodID(jclass_of_hashmap, "entrySet", "()Ljava/util/Set;");
// Invoke the "entrySet" method on the HashMap object
jobject jobject_of_entryset = env->CallObjectMethod(data, entrySetMethod);
// Get the Set Class
jclass jclass_of_set = (env)->FindClass("java/util/Set"); // Problem during compilation !!!!!
if (jclass_of_set == 0) {
qWarning() << "java/util/Set lookup failed\n";
return res;
}
// Get link to Method "iterator"
jmethodID iteratorMethod = env->GetMethodID(jclass_of_set, "iterator", "()Ljava/util/Iterator;");
// Invoke the "iterator" method on the jobject_of_entryset variable of type Set
jobject jobject_of_iterator = env->CallObjectMethod(jobject_of_entryset, iteratorMethod);
// Get the "Iterator" class
jclass jclass_of_iterator = (env)->FindClass("java/util/Iterator");
// Get link to Method "hasNext"
jmethodID hasNextMethod = env->GetMethodID(jclass_of_iterator, "hasNext", "()Z");
jmethodID nextMethod = env->GetMethodID(jclass_of_iterator, "next", "()Ljava/lang/Object;");
while (env->CallBooleanMethod(jobject_of_iterator, hasNextMethod) ) {
jobject jEntry = env->CallObjectMethod(jobject_of_iterator,nextMethod);
QAndroidJniObject entry = QAndroidJniObject(jEntry);
QAndroidJniObject key = entry.callObjectMethod("getKey","()Ljava/lang/Object;");
QAndroidJniObject value = entry.callObjectMethod("getValue","()Ljava/lang/Object;");
QString k = key.toString();
QVariant v = convertToQVariant(value);
env->DeleteLocalRef(jEntry);
if (v.isNull()) {
continue;
}
res[k] = v;
}
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionClear();
}
env->DeleteLocalRef(jclass_of_hashmap);
env->DeleteLocalRef(jobject_of_entryset);
env->DeleteLocalRef(jclass_of_set);
env->DeleteLocalRef(jobject_of_iterator);
env->DeleteLocalRef(jclass_of_iterator);
return res;
}
static jobject convertToJObject(QVariant v) {
jobject res = 0;
QAndroidJniEnvironment env;
if (v.type() == QVariant::String) {
QString str = v.toString();
res = env->NewStringUTF(str.toLocal8Bit().data());
} else if (v.type() == QVariant::Int) {
jclass integerClass = env->FindClass("java/lang/Integer");
jmethodID integerConstructor = env->GetMethodID(integerClass, "<init>", "(I)V");
res = env->NewObject(integerClass,integerConstructor,v.toInt());
env->DeleteLocalRef(integerClass);
} else if (v.type() == QVariant::Bool) {
jclass booleanClass = env->FindClass("java/lang/Boolean");
jmethodID booleanConstructor = env->GetMethodID(booleanClass,"<init>","(Z)V");
res = env->NewObject(booleanClass,booleanConstructor,v.toBool());
env->DeleteLocalRef(booleanClass);
} else if (v.type() == QVariant::Map) {
res = createHashMap(v.toMap());
} else if (v.type() == QVariant::List){
QVariantList list = v.value<QVariantList>();
jclass arrayListClass = env->FindClass("java/util/ArrayList");
jmethodID init = env->GetMethodID(arrayListClass, "<init>", "(I)V");
res = env->NewObject( arrayListClass, init, list.size());
jmethodID add = env->GetMethodID( arrayListClass, "add",
"(Ljava/lang/Object;)Z");
for (int i = 0 ; i < list.size() ; i++) {
jobject item = convertToJObject(list.at(i));
env->CallBooleanMethod(res,add, item);
env->DeleteLocalRef(item);
}
env->DeleteLocalRef(arrayListClass);
} else {
qWarning() << "QASystemDispatcher: Non-supported data type - " << v.type();
}
return res;
}
static jobject createHashMap(const QVariantMap &data) {
QAndroidJniEnvironment env;
jclass mapClass = env->FindClass("java/util/HashMap");
if (mapClass == NULL) {
qWarning() << "Failed to find class" << "java/util/HashMap";
return NULL;
}
jsize map_len = data.size();
jmethodID init = env->GetMethodID(mapClass, "<init>", "(I)V");
jobject hashMap = env->NewObject( mapClass, init, map_len);
jmethodID put = env->GetMethodID( mapClass, "put",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
QMapIterator<QString, QVariant> iter(data);
while (iter.hasNext()) {
iter.next();
QString key = iter.key();
jstring jkey = env->NewStringUTF(key.toLocal8Bit().data());
QVariant v = iter.value();
jobject item = convertToJObject(v);
if (item == 0) {
continue;
}
env->CallObjectMethod(hashMap,put,jkey,item);
env->DeleteLocalRef(item);
env->DeleteLocalRef(jkey);
}
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionClear();
}
env->DeleteLocalRef(mapClass);
return hashMap;
}
static void jniEmit(JNIEnv* env,jobject object,jstring name,jobject data) {
Q_UNUSED(object);
Q_UNUSED(env);
QAndroidJniObject tmp(name);
QString str = tmp.toString();
QVariantMap map;
if (data != 0) {
map = createVariantMap(data);
}
if (m_instance.isNull()) {
return;
}
QMetaObject::invokeMethod(m_instance.data(),"dispatched",Qt::AutoConnection,
Q_ARG(QString, str),
Q_ARG(QVariantMap,map));
}
#endif
QASystemDispatcher::QASystemDispatcher(QObject* parent) : QObject(parent)
{
}
QASystemDispatcher::~QASystemDispatcher()
{
}
QASystemDispatcher *QASystemDispatcher::instance()
{
if (!m_instance) {
QCoreApplication* app = QCoreApplication::instance();
m_instance = new QASystemDispatcher(app);
}
return m_instance;
}
void QASystemDispatcher::dispatch(QString type, QVariantMap message)
{
Q_UNUSED(type);
Q_UNUSED(message);
#ifdef Q_OS_ANDROID
QAndroidJniEnvironment env;
jstring jType = env->NewStringUTF(type.toLocal8Bit().data());
jobject jData = createHashMap(message);
QAndroidJniObject::callStaticMethod<void>(JCLASS_Name, "dispatch",
DISPATCH_SIGNATURE,
jType,jData);
env->DeleteLocalRef(jType);
env->DeleteLocalRef(jData);
#else
static bool dispatching = false;
static QQueue<QPair<QString,QVariantMap> > queue;
if (dispatching) {
queue.enqueue(QPair<QString,QVariantMap> (type,message) );
return;
}
dispatching = true;
emit dispatched(type,message);
qWarning() << "QASystemDispatcher: emitted"
while (queue.size() > 0) {
QPair<QString,QVariantMap> pair = queue.dequeue();
emit dispatched(pair.first,pair.second);
}
dispatching = false;
#endif
}
void QASystemDispatcher::loadClass(QString javaClassName)
{
QVariantMap message;
message["className"] = javaClassName;
dispatch("quickandroid.SystemDispatcher.loadClass",message);
}
void QASystemDispatcher::registerNatives()
{
#ifdef Q_OS_ANDROID
QAndroidJniEnvironment env;
jclass clazz = env->FindClass(JCLASS_Name);
if (!clazz)
{
qCritical() << QString("Can't find %1 class").arg(QString(JCLASS_Name));
return ;
}
JNINativeMethod methods[] =
{
{"jniEmit", EMIT_SIGNATURE, (void *)&jniEmit},
};
int numMethods = sizeof(methods) / sizeof(methods[0]);
if (env->RegisterNatives(clazz, methods, numMethods) < 0) {
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionClear();
qCritical() << "Exception occurred!!!";
return;
}
}
QAndroidJniObject::callStaticMethod<void>(JCLASS_Name, "init",
"()V");
#endif
}

47
source-android/common/qasystemdispatcher.h

@ -1,47 +0,0 @@
// Author: Ben Lau (https://github.com/benlau)
#pragma once
#include <QObject>
#include <QVariantMap>
/// QASystemDispatcher provides an simple messaging interface between C/C++/QML and Java code.
class QASystemDispatcher : public QObject
{
Q_OBJECT
public:
~QASystemDispatcher();
static QASystemDispatcher* instance();
/// Dispatch a message via Dispatcher
/** The message will be first passed to Java's SystemDispatcher and invoke
* registered listener. Once it is finished, it will emit the
* "dispatched" signal.
*
*/
Q_INVOKABLE void dispatch(QString type , QVariantMap message = QVariantMap());
/// Load a Java class
/** It will dispatch a message to Java and let it to load a Java class. That
* will force to run code in static block.
*
*/
Q_INVOKABLE void loadClass(QString javaClassName);
/// Register JNI native methods. This function must be called in JNI_OnLoad. Otherwise, the messenger will not be working
static void registerNatives();
/// The name of message that will be dispatched during Activity.onActivityResult.
static QString ACTIVITY_RESULT_MESSAGE;
/// The name of message that will be dispatched during Activity.onResume.
static QString ACTIVITY_RESUME_MESSAGE;
signals:
/// The signal is emitted when a message is dispatched.
void dispatched(QString type , QVariantMap message);
public:
explicit QASystemDispatcher(QObject* parent = 0);
};

22
source-android/common/quickandroid.cpp

@ -1,22 +0,0 @@
#include <QtQml>
#include <QVariantMap>
#include "quickandroid.h"
//#include "qadevice.h"
//#include "qamousesensor.h"
#ifdef Q_OS_ANDROID
#include <QAndroidJniEnvironment>
#include <QAndroidJniObject>
#endif
void QuickAndroid::registerTypes()
{
// "A" has been changed to a QML object. So now this function will do nothing.
// Keep here for compatible purpose only.
}
//qreal QuickAndroid::dp()
//{
// return QADevice::readDp();
//}

21
source-android/common/quickandroid.h

@ -1,21 +0,0 @@
#ifndef QUICKANDROID_H
#define QUICKANDROID_H
#include <QtGlobal>
/// Quick Android Context
class QuickAndroid
{
public:
static void registerTypes();
/// Obtain the detected "dp" value.
/** This function has been deprecated. Please use QADevice::dp()
@deprecated.
* @brief dp
* @return The detected "dp" value
*/
static qreal dp();
};
#endif // QUICKANDROID_H

123
source-android/common/remoteauthasyncimageprovider.cpp

@ -0,0 +1,123 @@
// 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 "remoteauthasyncimageprovider.h"
#include <QQuickAsyncImageProvider>
#include <QImage>
AsyncImageResponse::AsyncImageResponse(QNetworkRequest req, QSize reqSize)
{
m_reply = m_imageLoader.get(req);
m_requestedSize = reqSize;
connect(m_reply, &QNetworkReply::finished, this, &AsyncImageResponse::onResponseFinished);
}
void AsyncImageResponse::onResponseFinished()
{
QByteArray myImageData = m_reply->readAll();
m_resultImage = QImage::fromData(myImageData);
if (m_requestedSize.isValid())
{
m_resultImage = m_resultImage.scaled(m_requestedSize);
}
emit finished();
}
QQuickTextureFactory *AsyncImageResponse::textureFactory() const
{
return QQuickTextureFactory::textureFactoryForImage(m_resultImage);
}
RemoteAuthAsyncImageProvider::RemoteAuthAsyncImageProvider()
{
}
QQuickImageResponse* RemoteAuthAsyncImageProvider::requestImageResponse(const QString &id, const QSize &requestedSize)
{
QUrl iUrl=url()+"/api/friendica/remoteauth?c_url="+contacturl()+"&url="+id;
QByteArray loginData = m_login.toLocal8Bit().toBase64();
QString headerData = "Basic " + loginData;
QNetworkRequest request(iUrl);
request.setRawHeader("Authorization", headerData.toLocal8Bit());
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute,true);
request.setUrl(iUrl);
return new AsyncImageResponse(request, requestedSize);
}
void RemoteAuthAsyncImageProvider::setContacturl(QString contacturl)
{
if (contacturl!=m_contacturl) {
m_contacturl = contacturl;
emit contacturlChanged();
}
}
void RemoteAuthAsyncImageProvider::setUrl(QString url)
{
if (url!=m_url) {
m_url = url;
emit urlChanged();
}
}
void RemoteAuthAsyncImageProvider::setLogin(QString login)
{
if (login!=m_login) {
m_login = login;
emit loginChanged();
}
}
QString RemoteAuthAsyncImageProvider::contacturl() const
{
return m_contacturl;
}
QString RemoteAuthAsyncImageProvider::url() const
{
return m_url;
}
QString RemoteAuthAsyncImageProvider::login() const
{
return m_login;
}

95
source-android/common/remoteauthasyncimageprovider.h

@ -0,0 +1,95 @@
// 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 REMOTEAUTHIMAGEPROVIDER_H
#define REMOTEAUTHIMAGEPROVIDER_H
#include <QObject>
#include <QQuickAsyncImageProvider>
#include <QImage>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
class AsyncImageResponse : public QQuickImageResponse
{
Q_OBJECT
public:
explicit AsyncImageResponse(QNetworkRequest req, QSize requestedSize);
QQuickTextureFactory *textureFactory() const;
public slots:
void onResponseFinished();
protected:
QNetworkAccessManager m_imageLoader;
QNetworkReply* m_reply;
QSize m_requestedSize;
QImage m_resultImage;
int m_index;
QString m_id;
QImage m_image;
};
class RemoteAuthAsyncImageProvider : public QObject, public QQuickAsyncImageProvider
{
Q_OBJECT
Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged)
Q_PROPERTY(QString contacturl READ contacturl WRITE setContacturl NOTIFY contacturlChanged)
Q_PROPERTY(QString login READ login WRITE setLogin NOTIFY loginChanged)
public:
explicit RemoteAuthAsyncImageProvider();
QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override;
QString url() const;
QString contacturl() const;
QString login() const;
signals:
void contacturlChanged();
void urlChanged();
void loginChanged();
public slots:
void setContacturl(QString contacturl);
void setUrl(QString url);
void setLogin(QString login);
private:
QByteArray buffer;
QString m_url;
QString m_contacturl;
QString m_login;
QString bufferToString();
};
#endif // REMOTEAUTHIMAGEPROVIDER_H

31
source-android/common/uploadableimage.cpp

@ -1,3 +1,34 @@
// 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"

31
source-android/common/uploadableimage.h

@ -1,3 +1,34 @@
// 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

157
source-android/common/xhr.cpp

@ -1,12 +1,43 @@
#include "xhr.h"
// 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 <QNetworkCookieJar>
#include <QNetworkCookie>
#include <QList>
#include <QDataStream>
#include <QJsonDocument>
#include <QJsonObject>
#include "uploadableimage.h"
XHR *XHR::instance()
@ -44,6 +75,29 @@ void XHR::setFilename(QString filename)
}
}
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) {
@ -67,6 +121,21 @@ 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;
@ -91,9 +160,14 @@ void XHR::clearParams()
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();
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);
@ -117,9 +191,6 @@ void XHR::get()
QByteArray loginData = m_login.toLocal8Bit().toBase64();
QString headerData = "Basic " + loginData;
request.setRawHeader("Authorization", headerData.toLocal8Bit());
// QNetworkCookieJar* cJar = new QNetworkCookieJar;
// manager.setCookieJar(cJar);
request.setUrl(requrl);
reply = manager.get(request);
@ -129,6 +200,20 @@ void XHR::get()
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/