Commit 5d311a6d authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Fix save to gallery behavior

Also start implementing user chat actions objects parsing
parent aedc397e
......@@ -38,7 +38,8 @@ SOURCES += \
$$PWD/src/QtTdLibFile.cpp \
$$PWD/src/QtTdLibMessage.cpp \
$$PWD/src/QtTdLibUser.cpp \
$$PWD/src/TextFormatter.cpp
$$PWD/src/TextFormatter.cpp \
src/QtTdLibChatAction.cpp
HEADERS += \
$$PWD/src/QtTdLibJsonWrapper.h \
......@@ -52,7 +53,8 @@ HEADERS += \
$$PWD/src/QtTdLibFile.h \
$$PWD/src/QtTdLibMessage.h \
$$PWD/src/QtTdLibUser.h \
$$PWD/src/TextFormatter.h
$$PWD/src/TextFormatter.h \
src/QtTdLibChatAction.h
RESOURCES += \
$$PWD/qml.qrc \
......
......@@ -6,6 +6,7 @@ QtTdLibChat::QtTdLibChat (const qint64 id, QObject * parent)
: QtTdLibAbstractInt53IdObject { QtTdLibObjectType::CHAT, id, parent }
, m_isCurrentChat { false }
, m_firstUnreadMessageItem { Q_NULLPTR }
, m_chatActions { new QQmlObjectListModel<QtTdLibChatAction> { this, { }, "userId" } }
{
QtTdLibCollection::allChats.insert (id, this);
static const QString ICON { "/usr/share/icons/hicolor/128x128/apps/harbour-telegrame.png" };
......
......@@ -10,6 +10,7 @@
#include "QtTdLibCommon.h"
#include "QtTdLibFile.h"
#include "QtTdLibMessage.h"
#include "QtTdLibChatAction.h"
class QtTdLibChatMemberStatus : public QtTdLibAbstractObject {
Q_OBJECT
......@@ -262,6 +263,8 @@ class QtTdLibChat : public QtTdLibAbstractInt53IdObject, public FactoryInt53Id<Q
QML_READONLY_PTR_PROPERTY (firstUnreadMessageItem, QtTdLibMessage)
QML_OBJMODEL_PROPERTY (chatActions, QtTdLibChatAction)
public:
explicit QtTdLibChat (const qint64 id = 0, QObject * parent = Q_NULLPTR);
virtual ~QtTdLibChat (void);
......
#include "QtTdLibChatAction.h"
QtTdLibChatAction::QtTdLibChatAction (const QtTdLibObjectType::Type typeOf, QObject * parent)
: QtTdLibAbstractObject { typeOf, parent }
{ }
QtTdLibChatAction * QtTdLibChatAction::createAbstract (const QJsonObject & json, QObject * parent) {
switch (QtTdLibEnums::objectTypeEnumFromJson (json)) {
case QtTdLibObjectType::CHAT_ACTION_CANCEL: return QtTdLibChatActionCancel::create (json, parent);
case QtTdLibObjectType::CHAT_ACTION_CHOOSING_CONTACT: return QtTdLibChatActionChoosingContact::create (json, parent);
case QtTdLibObjectType::CHAT_ACTION_CHOOSING_LOCATION: return QtTdLibChatActionChoosingLocation::create (json, parent);
case QtTdLibObjectType::CHAT_ACTION_RECORDING_VIDEO: return QtTdLibChatActionRecordingVideo::create (json, parent);
case QtTdLibObjectType::CHAT_ACTION_RECORDING_VIDEO_NOTE: return QtTdLibChatActionRecordingVideoNote::create (json, parent);
case QtTdLibObjectType::CHAT_ACTION_RECORDING_VOICE_NOTE: return QtTdLibChatActionRecordingVoiceNote::create (json, parent);
case QtTdLibObjectType::CHAT_ACTION_START_PLAYING_GAME: return QtTdLibChatActionStartPlayingGame::create (json, parent);
case QtTdLibObjectType::CHAT_ACTION_TYPING: return QtTdLibChatActionTyping::create (json, parent);
case QtTdLibObjectType::CHAT_ACTION_UPLOADING_DOCUMENT: return QtTdLibChatActionUploadingDocument::create (json, parent);
case QtTdLibObjectType::CHAT_ACTION_UPLOADING_PHOTO: return QtTdLibChatActionUploadingPhoto::create (json, parent);
case QtTdLibObjectType::CHAT_ACTION_UPLOADING_VIDEO: return QtTdLibChatActionUploadingVideo::create (json, parent);
case QtTdLibObjectType::CHAT_ACTION_UPLOADING_VIDEO_NOTE: return QtTdLibChatActionUploadingVideoNote::create (json, parent);
case QtTdLibObjectType::CHAT_ACTION_UPLOADING_VOICE_NOTE: return QtTdLibChatActionUploadingVoiceNote::create (json, parent);
default: return Q_NULLPTR;
}
}
QtTdLibChatActionCancel::QtTdLibChatActionCancel (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_CANCEL, parent }
{ }
QtTdLibChatActionChoosingContact::QtTdLibChatActionChoosingContact (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_CHOOSING_CONTACT, parent }
{ }
QtTdLibChatActionChoosingLocation::QtTdLibChatActionChoosingLocation (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_CHOOSING_LOCATION, parent }
{ }
QtTdLibChatActionRecordingVideo::QtTdLibChatActionRecordingVideo (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_RECORDING_VIDEO, parent }
{ }
QtTdLibChatActionRecordingVideoNote::QtTdLibChatActionRecordingVideoNote (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_RECORDING_VIDEO_NOTE, parent }
{ }
QtTdLibChatActionRecordingVoiceNote::QtTdLibChatActionRecordingVoiceNote (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_RECORDING_VOICE_NOTE, parent }
{ }
QtTdLibChatActionStartPlayingGame::QtTdLibChatActionStartPlayingGame (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_START_PLAYING_GAME, parent }
{ }
QtTdLibChatActionTyping::QtTdLibChatActionTyping (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_TYPING, parent }
{ }
QtTdLibChatActionUploadingDocument::QtTdLibChatActionUploadingDocument (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_UPLOADING_DOCUMENT, parent }
{ }
void QtTdLibChatActionUploadingDocument::updateFromJson (const QJsonObject & json) {
set_progress_withJSON (json ["progress"]);
}
QtTdLibChatActionUploadingPhoto::QtTdLibChatActionUploadingPhoto (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_UPLOADING_PHOTO, parent }
{ }
void QtTdLibChatActionUploadingPhoto::updateFromJson (const QJsonObject & json) {
set_progress_withJSON (json ["progress"]);
}
QtTdLibChatActionUploadingVideo::QtTdLibChatActionUploadingVideo (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_UPLOADING_VIDEO, parent }
{ }
void QtTdLibChatActionUploadingVideo::updateFromJson (const QJsonObject & json) {
set_progress_withJSON (json ["progress"]);
}
QtTdLibChatActionUploadingVideoNote::QtTdLibChatActionUploadingVideoNote (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_UPLOADING_VIDEO_NOTE, parent }
{ }
void QtTdLibChatActionUploadingVideoNote::updateFromJson (const QJsonObject & json) {
set_progress_withJSON (json ["progress"]);
}
QtTdLibChatActionUploadingVoiceNote::QtTdLibChatActionUploadingVoiceNote (QObject * parent)
: QtTdLibChatAction { QtTdLibObjectType::CHAT_ACTION_UPLOADING_VOICE_NOTE, parent }
{ }
void QtTdLibChatActionUploadingVoiceNote::updateFromJson (const QJsonObject & json) {
set_progress_withJSON (json ["progress"]);
}
#ifndef QTTDLIBCHATACTION_H
#define QTTDLIBCHATACTION_H
#include "QtTdLibCommon.h"
class QtTdLibChatAction : public QtTdLibAbstractObject {
Q_OBJECT
/// custom
Q_TDLIB_PROPERTY_ID32 (userId)
public:
explicit QtTdLibChatAction (const QtTdLibObjectType::Type typeOf = QtTdLibObjectType::INVALID, QObject * parent = Q_NULLPTR);
static QtTdLibChatAction * createAbstract (const QJsonObject & json, QObject * parent = Q_NULLPTR);
};
class QtTdLibChatActionCancel : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionCancel> {
Q_OBJECT
public:
explicit QtTdLibChatActionCancel (QObject * parent = Q_NULLPTR);
};
class QtTdLibChatActionChoosingContact : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionChoosingContact> {
Q_OBJECT
public:
explicit QtTdLibChatActionChoosingContact (QObject * parent = Q_NULLPTR);
};
class QtTdLibChatActionChoosingLocation : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionChoosingLocation> {
Q_OBJECT
public:
explicit QtTdLibChatActionChoosingLocation (QObject * parent = Q_NULLPTR);
};
class QtTdLibChatActionRecordingVideo : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionRecordingVideo> {
Q_OBJECT
public:
explicit QtTdLibChatActionRecordingVideo (QObject * parent = Q_NULLPTR);
};
class QtTdLibChatActionRecordingVideoNote : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionRecordingVideoNote> {
Q_OBJECT
public:
explicit QtTdLibChatActionRecordingVideoNote (QObject * parent = Q_NULLPTR);
};
class QtTdLibChatActionRecordingVoiceNote : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionRecordingVoiceNote> {
Q_OBJECT
public:
explicit QtTdLibChatActionRecordingVoiceNote (QObject * parent = Q_NULLPTR);
};
class QtTdLibChatActionStartPlayingGame : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionStartPlayingGame> {
Q_OBJECT
public:
explicit QtTdLibChatActionStartPlayingGame (QObject * parent = Q_NULLPTR);
};
class QtTdLibChatActionTyping : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionTyping> {
Q_OBJECT
public:
explicit QtTdLibChatActionTyping (QObject * parent = Q_NULLPTR);
};
class QtTdLibChatActionUploadingDocument : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionUploadingDocument> {
Q_OBJECT
Q_TDLIB_PROPERTY_INT32 (progress)
public:
explicit QtTdLibChatActionUploadingDocument (QObject * parent = Q_NULLPTR);
void updateFromJson (const QJsonObject & json) Q_DECL_FINAL;
};
class QtTdLibChatActionUploadingPhoto : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionUploadingPhoto> {
Q_OBJECT
Q_TDLIB_PROPERTY_INT32 (progress)
public:
explicit QtTdLibChatActionUploadingPhoto (QObject * parent = Q_NULLPTR);
void updateFromJson (const QJsonObject & json) Q_DECL_FINAL;
};
class QtTdLibChatActionUploadingVideo : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionUploadingVideo> {
Q_OBJECT
Q_TDLIB_PROPERTY_INT32 (progress)
public:
explicit QtTdLibChatActionUploadingVideo (QObject * parent = Q_NULLPTR);
void updateFromJson (const QJsonObject & json) Q_DECL_FINAL;
};
class QtTdLibChatActionUploadingVideoNote : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionUploadingVideoNote> {
Q_OBJECT
Q_TDLIB_PROPERTY_INT32 (progress)
public:
explicit QtTdLibChatActionUploadingVideoNote (QObject * parent = Q_NULLPTR);
void updateFromJson (const QJsonObject & json) Q_DECL_FINAL;
};
class QtTdLibChatActionUploadingVoiceNote : public QtTdLibChatAction, public FactoryNoId<QtTdLibChatActionUploadingVoiceNote> {
Q_OBJECT
Q_TDLIB_PROPERTY_INT32 (progress)
public:
explicit QtTdLibChatActionUploadingVoiceNote (QObject * parent = Q_NULLPTR);
void updateFromJson (const QJsonObject & json) Q_DECL_FINAL;
};
#endif // QTTDLIBCHATACTION_H
......@@ -28,6 +28,19 @@ QtTdLibObjectType::Type QtTdLibEnums::objectTypeEnumFromString (const QString &
{ "callDiscardReasonHungUp", QtTdLibObjectType::CALL_DISCARD_REASON_HUNG_UP },
{ "callDiscardReasonMissed", QtTdLibObjectType::CALL_DISCARD_REASON_MISSED },
{ "chat", QtTdLibObjectType::CHAT },
{ "chatActionCancel", QtTdLibObjectType::CHAT_ACTION_CANCEL },
{ "chatActionChoosingContact", QtTdLibObjectType::CHAT_ACTION_CHOOSING_CONTACT },
{ "chatActionChoosingLocation", QtTdLibObjectType::CHAT_ACTION_CHOOSING_LOCATION },
{ "chatActionRecordingVideo", QtTdLibObjectType::CHAT_ACTION_RECORDING_VIDEO },
{ "chatActionRecordingVideoNote", QtTdLibObjectType::CHAT_ACTION_RECORDING_VIDEO_NOTE },
{ "chatActionRecordingVoiceNote", QtTdLibObjectType::CHAT_ACTION_RECORDING_VOICE_NOTE },
{ "chatActionStartPlayingGame", QtTdLibObjectType::CHAT_ACTION_START_PLAYING_GAME },
{ "chatActionTyping", QtTdLibObjectType::CHAT_ACTION_TYPING },
{ "chatActionUploadingDocument", QtTdLibObjectType::CHAT_ACTION_UPLOADING_DOCUMENT },
{ "chatActionUploadingPhoto", QtTdLibObjectType::CHAT_ACTION_UPLOADING_PHOTO },
{ "chatActionUploadingVideo", QtTdLibObjectType::CHAT_ACTION_UPLOADING_VIDEO },
{ "chatActionUploadingVideoNote", QtTdLibObjectType::CHAT_ACTION_UPLOADING_VIDEO_NOTE },
{ "chatActionUploadingVoiceNote", QtTdLibObjectType::CHAT_ACTION_UPLOADING_VOICE_NOTE },
{ "chatNotificationSettings", QtTdLibObjectType::CHAT_NOTIFICATION_SETTINGS },
{ "chatPhoto", QtTdLibObjectType::CHAT_PHOTO },
{ "chatMember", QtTdLibObjectType::CHAT_MEMBER },
......@@ -68,7 +81,7 @@ QtTdLibObjectType::Type QtTdLibEnums::objectTypeEnumFromString (const QString &
{ "messageChatUpgradeFrom", QtTdLibObjectType::MESSAGE_CHAT_UPGRADE_FROM },
{ "messageChatUpgradeTo", QtTdLibObjectType::MESSAGE_CHAT_UPGRADE_TO },
{ "messageContactRegistered", QtTdLibObjectType::MESSAGE_CONTACT_REGISTERED },
{ "messagePinMessage", QtTdLibObjectType::MESSAGE_PIN_MESSAGE },
{ "messagePinMessage", QtTdLibObjectType::MESSAGE_PIN_MESSAGE },
{ "messageDocument", QtTdLibObjectType::MESSAGE_DOCUMENT },
{ "messagePhoto", QtTdLibObjectType::MESSAGE_PHOTO },
{ "messages", QtTdLibObjectType::MESSAGES },
......@@ -120,7 +133,7 @@ QtTdLibObjectType::Type QtTdLibEnums::objectTypeEnumFromString (const QString &
{ "updateInstalledStickerSets", QtTdLibObjectType::UPDATE_INSTALLED_STICKER_SETS },
{ "updateMessageContent", QtTdLibObjectType::UPDATE_MESSAGE_CONTENT },
{ "updateMessageEdited", QtTdLibObjectType::UPDATE_MESSAGE_EDITED },
{ "updateMessageSendSucceeded", QtTdLibObjectType::UPDATE_MESSAGE_SEND_SUCCEEDED },
{ "updateMessageSendSucceeded", QtTdLibObjectType::UPDATE_MESSAGE_SEND_SUCCEEDED },
{ "updateNewChat", QtTdLibObjectType::UPDATE_NEW_CHAT },
{ "updateNewMessage", QtTdLibObjectType::UPDATE_NEW_MESSAGE },
{ "updateNotificationSettings", QtTdLibObjectType::UPDATE_NOTIFICATION_SETTINGS },
......@@ -128,6 +141,7 @@ QtTdLibObjectType::Type QtTdLibEnums::objectTypeEnumFromString (const QString &
{ "updateSupergroupFullInfo", QtTdLibObjectType::UPDATE_SUPERGROUP_FULL_INFO },
{ "updateUnreadMessageCount", QtTdLibObjectType::UPDATE_UNREAD_MESSAGE_COUNT },
{ "updateUser", QtTdLibObjectType::UPDATE_USER },
{ "updateUserChatAction", QtTdLibObjectType::UPDATE_USER_CHAT_ACTION },
{ "updateUserStatus", QtTdLibObjectType::UPDATE_USER_STATUS },
{ "user", QtTdLibObjectType::USER },
{ "users", QtTdLibObjectType::USERS },
......
......@@ -31,6 +31,19 @@ QML_ENUM_CLASS (QtTdLibObjectType,
CALL_DISCARD_REASON_HUNG_UP,
CALL_DISCARD_REASON_MISSED,
CHAT,
CHAT_ACTION_CANCEL,
CHAT_ACTION_CHOOSING_CONTACT,
CHAT_ACTION_CHOOSING_LOCATION,
CHAT_ACTION_RECORDING_VIDEO,
CHAT_ACTION_RECORDING_VIDEO_NOTE,
CHAT_ACTION_RECORDING_VOICE_NOTE,
CHAT_ACTION_START_PLAYING_GAME,
CHAT_ACTION_TYPING,
CHAT_ACTION_UPLOADING_DOCUMENT,
CHAT_ACTION_UPLOADING_PHOTO,
CHAT_ACTION_UPLOADING_VIDEO,
CHAT_ACTION_UPLOADING_VIDEO_NOTE,
CHAT_ACTION_UPLOADING_VOICE_NOTE,
CHAT_NOTIFICATION_SETTINGS,
CHAT_PHOTO,
CHAT_MEMBER,
......@@ -131,6 +144,7 @@ QML_ENUM_CLASS (QtTdLibObjectType,
UPDATE_SUPERGROUP_FULL_INFO,
UPDATE_UNREAD_MESSAGE_COUNT,
UPDATE_USER,
UPDATE_USER_CHAT_ACTION,
UPDATE_USER_STATUS,
USER,
USERS,
......
......@@ -622,41 +622,56 @@ static const QString DIR_VIDEOS { QStringLiteral ("/home/nemo/Videos/Telegram
static const QString DIR_DOWNLOADS { QStringLiteral ("/home/nemo/Downloads/Telegrame") };
void QtTdLibGlobal::savePhotoToGallery (QtTdLibFile * fileItem) {
if (fileItem != Q_NULLPTR) {
if (fileItem != Q_NULLPTR &&
fileItem->get_remote () != Q_NULLPTR &&
fileItem->get_local () != Q_NULLPTR &&
fileItem->get_local ()->get_isDownloadingCompleted ()) {
QDir ().mkpath (DIR_PHOTOS);
QFileInfo info { fileItem->get_local ()->get_path () };
QFile::copy (info.absoluteFilePath (), (DIR_PHOTOS % '/' % info.fileName ()));
const QFileInfo info { fileItem->get_local ()->get_path () };
QFile::copy (info.absoluteFilePath (), (DIR_PHOTOS % '/' % fileItem->get_remote ()->get_id () % '.' % info.suffix ()));
}
}
bool QtTdLibGlobal::isPhotoSavedToGallery (QtTdLibFile * fileItem) const {
bool ret { false };
if (fileItem != Q_NULLPTR) {
QFileInfo info { fileItem->get_local ()->get_path () };
ret = QFile::exists (DIR_PHOTOS % '/' % info.fileName ());
if (fileItem != Q_NULLPTR &&
fileItem->get_remote () != Q_NULLPTR &&
fileItem->get_local () != Q_NULLPTR &&
fileItem->get_local ()->get_isDownloadingCompleted ()) {
const QFileInfo info { fileItem->get_local ()->get_path () };
ret = QFile::exists (DIR_PHOTOS % '/' % fileItem->get_remote ()->get_id () % '.' % info.suffix ());
}
return ret;
}
void QtTdLibGlobal::saveVideoToGallery (QtTdLibFile * fileItem) {
if (fileItem != Q_NULLPTR) {
if (fileItem != Q_NULLPTR &&
fileItem->get_remote () != Q_NULLPTR &&
fileItem->get_local () != Q_NULLPTR &&
fileItem->get_local ()->get_isDownloadingCompleted ()) {
QDir ().mkpath (DIR_VIDEOS);
QFileInfo info { fileItem->get_local ()->get_path () };
QFile::copy (info.absoluteFilePath (), (DIR_VIDEOS % '/' % info.fileName ()));
const QFileInfo info { fileItem->get_local ()->get_path () };
QFile::copy (info.absoluteFilePath (), (DIR_VIDEOS % '/' % fileItem->get_remote ()->get_id () % '.' % info.suffix ()));
}
}
bool QtTdLibGlobal::isVideoSavedToGallery (QtTdLibFile * fileItem) const {
bool ret { false };
if (fileItem != Q_NULLPTR) {
QFileInfo info { fileItem->get_local ()->get_path () };
ret = QFile::exists (DIR_VIDEOS % '/' % info.fileName ());
if (fileItem != Q_NULLPTR &&
fileItem->get_remote () != Q_NULLPTR &&
fileItem->get_local () != Q_NULLPTR &&
fileItem->get_local ()->get_isDownloadingCompleted ()) {
const QFileInfo info { fileItem->get_local ()->get_path () };
ret = QFile::exists (DIR_VIDEOS % '/' % fileItem->get_remote ()->get_id () % '.' % info.suffix ());
}
return ret;
}
void QtTdLibGlobal::downloadDocument (QtTdLibDocument * documentItem) {
if (documentItem != Q_NULLPTR) {
if (documentItem != Q_NULLPTR &&
documentItem->get_document () != Q_NULLPTR &&
documentItem->get_document ()->get_local () != Q_NULLPTR &&
documentItem->get_document ()->get_local ()->get_isDownloadingCompleted ()) {
QDir ().mkpath (DIR_DOWNLOADS);
QFile::copy (documentItem->get_document ()->get_local ()->get_path (), (DIR_DOWNLOADS % '/' % documentItem->get_fileName ()));
}
......@@ -1348,6 +1363,25 @@ void QtTdLibGlobal::onFrame (const QJsonObject & json) {
}
break;
}
case QtTdLibObjectType::UPDATE_USER_CHAT_ACTION: {
const qint64 chatId { QtTdLibId53Helper::fromJsonToCpp (json ["chat_id"]) };
if (QtTdLibChat * chatItem = { getChatItemById (chatId) }) {
const qint32 userId { QtTdLibId32Helper::fromJsonToCpp (json ["user_id"]) };
const QJsonObject chatActionJson { json ["action"].toObject () };
const QtTdLibObjectType::Type typeOfChatAction { QtTdLibEnums::objectTypeEnumFromJson (chatActionJson) };
if (QtTdLibChatAction * chatActionItem = { chatItem->get_chatActions ()->getByUid (QString::number (userId)) }) {
chatItem->get_chatActions ()->remove (chatActionItem);
}
if (typeOfChatAction != QtTdLibObjectType::INVALID &&
typeOfChatAction != QtTdLibObjectType::CHAT_ACTION_CANCEL) {
if (QtTdLibChatAction * chatAction = { QtTdLibChatAction::createAbstract (chatActionJson) }) {
chatAction->set_userId (userId);
chatItem->get_chatActions ()->append (chatAction);
}
}
}
break;
}
case QtTdLibObjectType::STICKER_SETS: {
const QJsonArray setsJson = json ["sets"].toArray ();
for (const QJsonValue & tmp : setsJson) {
......
......@@ -55,6 +55,20 @@ int main (int argc, char * argv []) {
qmlRegisterType<QtTdLibCallDiscardReasonHungUp> ("harbour.Telegrame", 1, 0, "TD_CallDiscardReasonHungUp");
qmlRegisterType<QtTdLibCallDiscardReasonMissed> ("harbour.Telegrame", 1, 0, "TD_CallDiscardReasonMissed");
qmlRegisterType<QtTdLibChat> ("harbour.Telegrame", 1, 0, "TD_Chat");
qmlRegisterType<QtTdLibChatAction> ("harbour.Telegrame", 1, 0, "TD_ChatAction");
qmlRegisterType<QtTdLibChatActionCancel> ("harbour.Telegrame", 1, 0, "TD_ChatActionCancel");
qmlRegisterType<QtTdLibChatActionChoosingContact> ("harbour.Telegrame", 1, 0, "TD_ChatActionChoosingContact");
qmlRegisterType<QtTdLibChatActionChoosingLocation> ("harbour.Telegrame", 1, 0, "TD_ChatActionChoosingLocation");
qmlRegisterType<QtTdLibChatActionRecordingVideo> ("harbour.Telegrame", 1, 0, "TD_ChatActionRecordingVideo");
qmlRegisterType<QtTdLibChatActionRecordingVideoNote> ("harbour.Telegrame", 1, 0, "TD_ChatActionRecordingVideoNote");
qmlRegisterType<QtTdLibChatActionRecordingVoiceNote> ("harbour.Telegrame", 1, 0, "TD_ChatActionRecordingVoiceNote");
qmlRegisterType<QtTdLibChatActionStartPlayingGame> ("harbour.Telegrame", 1, 0, "TD_ChatActionStartPlayingGame");
qmlRegisterType<QtTdLibChatActionTyping> ("harbour.Telegrame", 1, 0, "TD_ChatActionTyping");
qmlRegisterType<QtTdLibChatActionUploadingDocument> ("harbour.Telegrame", 1, 0, "TD_ChatActionUploadingDocument");
qmlRegisterType<QtTdLibChatActionUploadingPhoto> ("harbour.Telegrame", 1, 0, "TD_ChatActionUploadingPhoto");
qmlRegisterType<QtTdLibChatActionUploadingVideo> ("harbour.Telegrame", 1, 0, "TD_ChatActionUploadingVideo");
qmlRegisterType<QtTdLibChatActionUploadingVideoNote> ("harbour.Telegrame", 1, 0, "TD_ChatActionUploadingVideoNote");
qmlRegisterType<QtTdLibChatActionUploadingVoiceNote> ("harbour.Telegrame", 1, 0, "TD_ChatActionUploadingVoiceNote");
qmlRegisterType<QtTdLibChatNotificationSettings> ("harbour.Telegrame", 1, 0, "TD_ChatNotificationSettings");
qmlRegisterType<QtTdLibChatPhoto> ("harbour.Telegrame", 1, 0, "TD_ChatPhoto");
qmlRegisterType<QtTdLibChatType> ("harbour.Telegrame", 1, 0, "TD_ChatType");
......@@ -136,8 +150,8 @@ 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");
QGuiApplication * app { SailfishApp::application (argc, argv) };
app->setApplicationName ("harbour-telegrame");
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) }) {
......@@ -148,5 +162,5 @@ int main (int argc, char * argv []) {
QQuickView * view { SailfishApp::createView () };
view->setSource (QUrl { "qrc:///qml/harbour-telegrame.qml" });
view->show ();
return app->exec ();
return QGuiApplication::exec ();
}
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