Commit bb263f49 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Integration TDLIB 1.4 throught custom "lite" submodule (pregenerated)

parent 70123947
[submodule "libQtQmlTricks"]
path = libQtQmlTricks
url = http://gitlab.unique-conception.org/qt-qml-tricks/ui-elements-ng.git
path = libQtQmlTricks
url = http://gitlab.unique-conception.org/qt-qml-tricks/ui-elements-ng.git
[submodule "RegionFlags"]
path = RegionFlags
url = https://github.com/behdad/region-flags.git
path = RegionFlags
url = https://github.com/behdad/region-flags.git
[submodule "TDLIB-lite"]
path = TDLIB-lite
url = ../../qt-libraries/tdlib-lite.git
Subproject commit 852861a4e4d80e4010bba0639955b86b5d709b09
include ($$PWD/libQtQmlTricks/libQtQmlTricks-3.0.pri)
include ($$PWD/TDLIB-lite/libTD.pri)
TARGET = harbour-telegrame
TEMPLATE = app
CONFIG += c++11
QT += core network gui qml quick multimedia dbus
MOC_DIR = _moc
......@@ -15,8 +14,27 @@ RCC_DIR = _rcc
CONFIG += link_pkgconfig
QMAKE_CXXFLAGS -= -g
QMAKE_CXXFLAGS_DEBUG -= -g
QMAKE_CXXFLAGS_RELEASE -= -g
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -g
QMAKE_CFLAGS -= -g
QMAKE_CFLAGS_DEBUG -= -g
QMAKE_CFLAGS_RELEASE -= -g
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO -= -g
QMAKE_CXXFLAGS += -g0
QMAKE_CXXFLAGS_DEBUG += -g0
QMAKE_CXXFLAGS_RELEASE += -g0
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += -g0
QMAKE_CFLAGS += -g0
QMAKE_CFLAGS_DEBUG += -g0
QMAKE_CFLAGS_RELEASE += -g0
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -g0
PKGCONFIG += sailfishapp
PKGCONFIG += tdlibjson
PKGCONFIG += nemonotifications-qt5
PKGCONFIG += mlite5
......
......@@ -13,22 +13,20 @@ Name: harbour-telegrame
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: A native Telegram client for Sailfish OS
Version: 0.9
Release: 18
Version: 0.10
Release: 19
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.3
BuildRequires: pkgconfig(sailfishapp) >= 1.0.2
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Qml)
BuildRequires: pkgconfig(Qt5Quick)
BuildRequires: pkgconfig(Qt5Multimedia)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(tdlibjson)
BuildRequires: pkgconfig(nemonotifications-qt5)
BuildRequires: desktop-file-utils
......
Name: harbour-telegrame
Summary: A native Telegram client for Sailfish OS
Version: 0.9
Release: 18
Version: 0.10
Release: 19
Group: Qt/Qt
URL: http://gitlab.unique-conception.org/sailfish-app/telegra-me
......@@ -24,12 +24,10 @@ PkgConfigBR:
- Qt5Quick
- Qt5Multimedia
- openssl
- tdlibjson
- nemonotifications-qt5
Requires:
- sailfishsilica-qt5 >= 0.10.9
- tdlibjson >= 1.3
Files:
- '%{_bindir}'
......
......@@ -98,7 +98,8 @@ QtTdLibGlobal::QtTdLibGlobal (QObject * parent)
m_audioRecorder->setEncodingSettings (audioEncoderSettings);
m_audioRecorder->setContainerFormat ("wav"); // "ogg"
connect (m_audioRecorder, &QAudioRecorder::durationChanged, [this] (void) {
if (m_audioRecorder->status () == QMediaRecorder::RecordingStatus || m_audioRecorder->status () == QMediaRecorder::FinalizingStatus) {
if (m_audioRecorder->status () == QMediaRecorder::RecordingStatus ||
m_audioRecorder->status () == QMediaRecorder::FinalizingStatus) {
set_recordingDuration (int (m_audioRecorder->duration ()));
}
});
......@@ -415,8 +416,8 @@ void QtTdLibGlobal::loadSingleMessageRef (QtTdLibChat * chatItem, const qint64 m
void QtTdLibGlobal::loadInitialMessage (QtTdLibChat * chatItem, const qint64 messageId) {
if (chatItem != Q_NULLPTR) {
if (messageId != 0) {
if (messageId < chatItem->get_oldestFetchedMessageId () || messageId > chatItem->get_newestFetchedMessageId ()) {
chatItem->messagesModel.clear (); // NOTE : need to clean current model
if (messageId < chatItem->get_oldestFetchedMessageId () || messageId > chatItem->get_newestFetchedMessageId ()) { // NOTE : need to clean current model
chatItem->messagesModel.clear ();
chatItem->set_oldestFetchedMessageId (0); // NOTE : reset lower boundary
chatItem->set_newestFetchedMessageId (0); // NOTE : reset upper boundary
chatItem->set_hasReachedFirst (false); // NOTE : reset start flag
......@@ -428,19 +429,19 @@ void QtTdLibGlobal::loadInitialMessage (QtTdLibChat * chatItem, const qint64 mes
loadOlderMessages (chatItem); // NOTE : load older messages
loadNewerMessages (chatItem); // NOTE : load newer messages
}
else {
send (QJsonObject { // NOTE : need to get message from TDLIB call
{ "@type", "getChatHistory" },
{ "chat_id", chatItem->get_id_asJSON () },
{ "from_message_id", QtTdLibId53Helper::fromCppToJson (messageId) },
{ "offset", -1 }, // must be negative to fetch newer messages
{ "limit", 2 }, // must be higher than -offset
{ "only_local", false }, // allow to request on network not only database
{ "@extra", QJsonObject {
{ "chat_id", chatItem->get_id_asJSON () },
{ "load_mode", LOAD_INIT },
}
}
else { // NOTE : need to get message from TDLIB call
send (QJsonObject {
{ "@type", "getChatHistory" },
{ "chat_id", chatItem->get_id_asJSON () },
{ "from_message_id", QtTdLibId53Helper::fromCppToJson (messageId) },
{ "offset", -1 }, // must be negative to fetch newer messages
{ "limit", 2 }, // must be higher than -offset
{ "only_local", false }, // allow to request on network not only database
{ "@extra", QJsonObject {
{ "chat_id", chatItem->get_id_asJSON () },
{ "load_mode", LOAD_INIT },
}
}
});
}
}
......
......@@ -4,17 +4,50 @@
#include <QStringBuilder>
#include <QJsonDocument>
#include <QJsonArray>
#include <QDebug>
#include <td/telegram/td_json_client.h>
#include <td/telegram/td_log.h>
#include "td/telegram/td_json_client.h"
QtTdLibJsonWrapper::QtTdLibJsonWrapper (const bool debug, QObject * parent)
: QThread { parent }
, m_debug { debug }
, m_tdJsonClientHandle { td_json_client_create () }
{
td_set_log_verbosity_level (m_debug ? 2 : 1);
exec (QJsonObject {
{ "@type", "setLogStream" },
{ "log_stream", QJsonObject {
{ "@type", "logStreamDefault" },
}
},
});
exec (QJsonObject {
{ "@type", "setLogVerbosityLevel" },
{ "new_verbosity_level", (m_debug ? 2 : 0) },
});
const QJsonObject json = exec (QJsonObject {
{ "@type", "getLogTags" },
});
const QJsonArray list = json.value ("tags").toArray ();
for (const QJsonValue & tmp : list) {
const QString tag { tmp.toString () };
int level { 0 };
if (tag == QStringLiteral ("td_init")) {
level = (m_debug ? 2 : 0);
}
else if (tag == QStringLiteral ("td_requests")) {
level = (m_debug ? 2 : 0);
}
else if (tag == QStringLiteral ("notifications")) {
level = (m_debug ? 2 : 0);
}
else { }
exec (QJsonObject {
{ "@type", "setLogTagVerbosityLevel" },
{ "tag", tag },
{ "new_verbosity_level", level },
});
}
}
QtTdLibJsonWrapper::~QtTdLibJsonWrapper (void) {
......
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