Commit cc91e51e authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Preliminary work to support TDLIB1.3 (still not fully leveraging it)

parent 5d311a6d
......@@ -39,7 +39,7 @@ SOURCES += \
$$PWD/src/QtTdLibMessage.cpp \
$$PWD/src/QtTdLibUser.cpp \
$$PWD/src/TextFormatter.cpp \
src/QtTdLibChatAction.cpp
$$PWD/src/QtTdLibChatAction.cpp
HEADERS += \
$$PWD/src/QtTdLibJsonWrapper.h \
......@@ -54,7 +54,7 @@ HEADERS += \
$$PWD/src/QtTdLibMessage.h \
$$PWD/src/QtTdLibUser.h \
$$PWD/src/TextFormatter.h \
src/QtTdLibChatAction.h
$$PWD/src/QtTdLibChatAction.h
RESOURCES += \
$$PWD/qml.qrc \
......
Subproject commit 1756d7c3239e3a66b8d8fea3f31d079f161d073c
Subproject commit c302d8888769372c1a0bc05faa22da9606f1abc4
......@@ -19,15 +19,6 @@ ApplicationWindow {
cover: compoPageCover;
initialPage: compoPageMain;
allowedOrientations: Orientation.All;
onActiveChanged: {
TD_Global.setUserOnlineState (active);
}
Component.onCompleted: {
TD_Global.setUserOnlineState (true);
}
Component.onDestruction: {
TD_Global.setUserOnlineState (false);
}
property string currentRecording : "";
property string currentDocument : "";
......
......@@ -14,14 +14,14 @@ Name: harbour-telegrame
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: A native Telegram client for Sailfish OS
Version: 0.9
Release: 17
Release: 18
Group: Qt/Qt
License: WTFPL
URL: http://gitlab.unique-conception.org/sailfish-app/telegra-me
Source0: %{name}-%{version}.tar.bz2
Source100: harbour-telegrame.yaml
Requires: sailfishsilica-qt5 >= 0.10.9
Requires: tdlibjson >= 1.2
Requires: tdlibjson >= 1.3
BuildRequires: pkgconfig(sailfishapp) >= 1.0.2
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Qml)
......@@ -29,6 +29,7 @@ BuildRequires: pkgconfig(Qt5Quick)
BuildRequires: pkgconfig(Qt5Multimedia)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(tdlibjson)
BuildRequires: pkgconfig(nemonotifications-qt5)
BuildRequires: desktop-file-utils
%description
......
Name: harbour-telegrame
Summary: A native Telegram client for Sailfish OS
Version: 0.9
Release: 17
Release: 18
Group: Qt/Qt
URL: http://gitlab.unique-conception.org/sailfish-app/telegra-me
......@@ -25,10 +25,11 @@ PkgConfigBR:
- Qt5Multimedia
- openssl
- tdlibjson
- nemonotifications-qt5
Requires:
- sailfishsilica-qt5 >= 0.10.9
- tdlibjson >= 1.2
- tdlibjson >= 1.3
Files:
- '%{_bindir}'
......
......@@ -103,11 +103,12 @@ QtTdLibGlobal::QtTdLibGlobal (QObject * parent)
set_recordingDuration (int (m_audioRecorder->duration ()));
}
});
connect (m_tdLibJsonWrapper, &QtTdLibJsonWrapper::recv, this, &QtTdLibGlobal::onFrame);
connect (m_tdLibJsonWrapper, &QtTdLibJsonWrapper::recv, this, &QtTdLibGlobal::onFrame, Qt::QueuedConnection);
m_tdLibJsonWrapper->start ();
}
QtTdLibGlobal::~QtTdLibGlobal (void) {
setUserOnlineState (false);
m_tdLibJsonWrapper->send (QJsonObject {
{ "@type", "close" }
});
......@@ -929,11 +930,11 @@ void QtTdLibGlobal::onFrame (const QJsonObject & json) {
{ "system_language_code", "en" },
{ "device_model", "Jolla Sailfish OS" },
{ "system_version", "3.x" },
{ "application_version", "0.9" },
{ "application_version", "0.9.xx" },
{ "enable_storage_optimizer", true },
{ "database_directory", QString (QDir::homePath () % "/.telegrame") },
{ "files_directory", QString (QDir::homePath () % "/.telegrame") },
//{ "ignore_file_names", false },
{ "ignore_file_names", false },
}
}
});
......@@ -947,6 +948,7 @@ void QtTdLibGlobal::onFrame (const QJsonObject & json) {
break;
}
case QtTdLibObjectType::AUTHORIZATION_STATE_READY: {
setUserOnlineState (true);
send (QJsonObject {
{ "@type", "getChats" },
{ "offset_order", "1000000" },
......@@ -961,9 +963,7 @@ void QtTdLibGlobal::onFrame (const QJsonObject & json) {
{ "@type", "getSavedAnimations" },
});
send (QJsonObject {
{ "@type", "searchContacts" },
{ "query", "" },
{ "limit", 1000 },
{ "@type", "getContacts" },
});
break;
}
......
......@@ -39,16 +39,17 @@ void QtTdLibJsonWrapper::run (void) {
}
QJsonObject QtTdLibJsonWrapper::exec (const QJsonObject & json) {
qWarning () << "EXEC" << json;
qWarning () << "EXEC [IN]" << json;
const QByteArray tmp { (QJsonDocument (json).toJson (QJsonDocument::Compact) % '\0') };
const QByteArray str { QByteArray (td_json_client_execute (m_tdJsonClientHandle, tmp.constData ())) };
const QJsonObject ret { QJsonDocument::fromJson (str).object () };
qWarning () << "RESULT" << ret;
qWarning () << "EXEC [OUT]" << ret;
return ret;
}
void QtTdLibJsonWrapper::send (const QJsonObject & json) {
qWarning () << "SEND" << json;
qWarning () << "SEND [IN]" << json;
const QByteArray tmp { (QJsonDocument (json).toJson (QJsonDocument::Compact) % '\0') };
td_json_client_send (m_tdJsonClientHandle, tmp.constData ());
qWarning () << "SEND [OUT]";
}
......@@ -24,6 +24,8 @@
#include "TextFormatter.h"
int main (int argc, char * argv []) {
SailfishApp::application (argc, argv);
QGuiApplication::setApplicationName (QStringLiteral ("harbour-telegrame"));
QtQmlTricks::registerComponents ();
qmlRegisterType<TextFormatter> ("harbour.Telegrame", 1, 0, "TextFormatter");
qmlRegisterType<QSortFilterProxyModel> ("harbour.Telegrame", 1, 0, "SortFilterProxyModel");
......@@ -150,8 +152,6 @@ int main (int argc, char * argv []) {
qmlRegisterUncreatableType<QtTdLibObjectType> ("harbour.Telegrame", 1, 0, "TD_ObjectType", "Enum class !");
qmlRegisterSingletonType<QtTdLibGlobal> ("harbour.Telegrame", 1, 0, "TD_Global", &QtTdLibGlobal::qmlSingletonFactory);
qmlRegisterSingletonType (QUrl { "qrc:///qml/components/Helpers.qml" }, "harbour.Telegrame", 1, 0, "Helpers");
SailfishApp::application (argc, argv);
QGuiApplication::setApplicationName ("harbour-telegrame");
const QList<QObject *> oldNoticationsList { Notification::notifications () };
for (QObject * tmp : oldNoticationsList) {
if (Notification * notification = { qobject_cast<Notification *> (tmp) }) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment