├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── database ├── database.sql ├── database.sqlite ├── profiles.sqlite └── userdata.sqlite ├── debian ├── changelog ├── compat ├── control ├── copyright ├── rules └── source │ └── format ├── demos ├── Search │ ├── SearchList.qml │ ├── main.qml │ └── user.png ├── SimpleClient │ ├── DialogList.qml │ ├── MainForm.qml │ ├── MessageFrame.qml │ ├── main.qml │ └── user.png ├── StickerManager │ ├── StickerList.qml │ └── main.qml ├── StickerViewer │ ├── StickerList.qml │ └── main.qml └── share │ ├── LoginForm.qml │ └── tg-server.pub ├── documents ├── abstractenginelistmodel.md ├── abstractlistmodel.md ├── app.md ├── authenticate.md ├── authstore.md ├── cache.md ├── dialoglistmodel.md ├── downloadhandler.md ├── engine.md ├── enums.md ├── host.md ├── image.md ├── makeHtml.sh ├── medialistmodel.md ├── memberslistmodel.md ├── messagefetcher.md ├── messagelistmodel.md ├── messagesearchmodel.md ├── messagesfilter.md ├── notificationhandler.md ├── peerdetails.md ├── profilemanagermodel.md ├── sendmessageaction.md ├── sharedpointer.md ├── start.md ├── status.md ├── statustyping.md ├── stickerscategoriesmodel.md ├── stickersmodel.md ├── topmessagesmodel.md └── tqobject.md ├── files └── tg-server.pub ├── objects ├── ThemeItem.vco ├── templates │ ├── class.template │ ├── equals.template │ ├── file.template │ └── initialize.template ├── types.h └── types.sco ├── old ├── backgroundmanager.cpp ├── backgroundmanager.h ├── chatparticipantlist.cpp ├── chatparticipantlist.h ├── database.cpp ├── database.h ├── databaseabstractencryptor.cpp ├── databaseabstractencryptor.h ├── databasecore.cpp ├── databasecore.h ├── dialogfilesmodel.cpp ├── dialogfilesmodel.h ├── documentattributelist.cpp ├── documentattributelist.h ├── mp3converterengine.cpp ├── mp3converterengine.h ├── newsletterdialog.cpp ├── newsletterdialog.h ├── photosizelist.cpp ├── photosizelist.h ├── profilesmodel.cpp ├── profilesmodel.h ├── tagfiltermodel.cpp ├── tagfiltermodel.h ├── telegramchatparticipantsmodel.cpp ├── telegramchatparticipantsmodel.h ├── telegramcontactsfiltermodel.cpp ├── telegramcontactsfiltermodel.h ├── telegramcontactsmodel.cpp ├── telegramcontactsmodel.h ├── telegramdetailedcontactsmodel.cpp ├── telegramdetailedcontactsmodel.h ├── telegramdialogsmodel.cpp ├── telegramdialogsmodel.h ├── telegramfilehandler.cpp ├── telegramfilehandler.h ├── telegrammessagesmodel.cpp ├── telegrammessagesmodel.h ├── telegramqml.cpp ├── telegramqml.h ├── telegramsearchmodel.cpp ├── telegramsearchmodel.h ├── telegramuploadsmodel.cpp ├── telegramuploadsmodel.h ├── telegramwallpapersmodel.cpp ├── telegramwallpapersmodel.h ├── tgabstractlistmodel.cpp ├── tgabstractlistmodel.h ├── userdata.cpp ├── userdata.h ├── usernamefiltermodel.cpp └── usernamefiltermodel.h ├── plugins.qmltypes ├── private ├── telegramdownloadhandler.cpp ├── telegramdownloadhandler.h ├── telegramfilelocation.cpp ├── telegramfilelocation.h ├── telegramthumbnailer.cpp ├── telegramthumbnailer.h ├── telegramthumbnailercore.cpp ├── telegramthumbnailercore.h ├── telegramuploadhandler.cpp ├── telegramuploadhandler.h └── tqmlmessageobject.h ├── qmake └── headerinstall.pri ├── qmldir ├── telegramabstractenginelistmodel.cpp ├── telegramabstractenginelistmodel.h ├── telegramabstractlistmodel.cpp ├── telegramabstractlistmodel.h ├── telegramapp.cpp ├── telegramapp.h ├── telegramauthenticate.cpp ├── telegramauthenticate.h ├── telegramauthstore.cpp ├── telegramauthstore.h ├── telegramcache.cpp ├── telegramcache.h ├── telegramdialoglistmodel.cpp ├── telegramdialoglistmodel.h ├── telegramengine.cpp ├── telegramengine.h ├── telegramenums.cpp ├── telegramenums.h ├── telegramhost.cpp ├── telegramhost.h ├── telegramimageelement.cpp ├── telegramimageelement.h ├── telegrammedialistmodel.cpp ├── telegrammedialistmodel.h ├── telegrammemberslistmodel.cpp ├── telegrammemberslistmodel.h ├── telegrammessagefetcher.cpp ├── telegrammessagefetcher.h ├── telegrammessagelistmodel.cpp ├── telegrammessagelistmodel.h ├── telegrammessagesearchmodel.cpp ├── telegrammessagesearchmodel.h ├── telegramnotificationhandler.cpp ├── telegramnotificationhandler.h ├── telegrampeerdetails.cpp ├── telegrampeerdetails.h ├── telegramprofilemanagermodel.cpp ├── telegramprofilemanagermodel.h ├── telegramqml.pri ├── telegramqml.pro ├── telegramqml_global.h ├── telegramqml_macros.h ├── telegramqml_plugin.cpp ├── telegramqml_plugin.h ├── telegramqmlinitializer.cpp ├── telegramqmlinitializer.h ├── telegramqmlsharedpointer.cpp ├── telegramqmlsharedpointer.h ├── telegramshareddatamanager.cpp ├── telegramshareddatamanager.h ├── telegramsharedpointer.cpp ├── telegramsharedpointer.h ├── telegramstatus.cpp ├── telegramstatus.h ├── telegramstatustyping.cpp ├── telegramstatustyping.h ├── telegramstickerscategoriesmodel.cpp ├── telegramstickerscategoriesmodel.h ├── telegramstickersmodel.cpp ├── telegramstickersmodel.h ├── telegramtesttools.cpp ├── telegramtesttools.h ├── telegramtools.cpp ├── telegramtools.h ├── telegramtopmessagesmodel.cpp ├── telegramtopmessagesmodel.h ├── tqbaseobject.cpp ├── tqbaseobject.h ├── tqmldocumentexporter.cpp ├── tqmldocumentexporter.h ├── tqmlresource.qrc ├── tqobject.cpp └── tqobject.h /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | 3 | *.slo 4 | *.lo 5 | *.o 6 | *.a 7 | *.la 8 | *.lai 9 | *.so 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | 15 | /.qmake.cache 16 | /.qmake.stash 17 | *.pro.user 18 | *.pro.user.* 19 | *.qbs.user 20 | *.qbs.user.* 21 | *.moc 22 | moc_*.cpp 23 | qrc_*.cpp 24 | ui_*.h 25 | Makefile* 26 | *-build-* 27 | 28 | # QtCreator 29 | 30 | *.autosave 31 | 32 | #QtCtreator Qml 33 | *.qmlproject.user 34 | *.qmlproject.user.* 35 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aseman-Land/TelegramQML/761f109bbd1de4d4c928330a5f3918a84c18b33e/.gitmodules -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TelegramQML 2 | Telegram API tools for QtQML and Qml, based on Cutegram-Core and libqtelegram. 3 | It's free and released under the GPLv3 license. 4 | 5 | ### [Developer Documents](documents/start.md) 6 | 7 | ### How to Compile 8 | #### Install dependencies 9 | 10 | Install gcc, g++, openssl, git, Qt5Core, Qt5DBus, Qt5Gui, Qt5Multimedia, Qt5MultimediaQuick_p, Qt5Network, Qt5PrintSupport, Qt5Qml, Qt5Quick, Qt5Sql, Qt5Svg, and Qt5Widgets. 11 | on Ubuntu: 12 | 13 | sudo apt-get install g++ gcc git qtbase5-dev libqt5sql5-sqlite libqt5multimediaquick-p5 libqt5multimedia5-plugins libqt5multimedia5 libqt5qml5 libqt5qml-graphicaleffects libqt5qml-quickcontrols qtdeclarative5-dev libqt5quick5 libthumbnailer-qt-dev libthumbnailer-qt1.0:armhf thumbnailer-service:armhf 14 | 15 | Note: You may have to add this ppa first: 16 | 17 | https://launchpad.net/~ci-train-ppa-service/+archive/ubuntu/stable-phone-overlay 18 | 19 | on Fedora (tested on Fedora 20): 20 | 21 | yum install qt5-qtbase qt5-qtbase-devel qt5-qtdeclarative qt5-qtquick1 qt5-qtquick1-devel kde-plasma-applicationname kde-plasma-nm qt5-qtdeclarative-devel qt5-qtdeclarative-static qt5-qtgraphicaleffects qt5-qtquickcontrols openssl-devel libappindicator-devel 22 | 23 | For other distributions search for the corresponding packages. 24 | 25 | #### Available qmake keywords 26 | 27 | There are some available keywords, you can use it as qmake flags on build step on each project: 28 | 29 | OPENSSL_LIB_DIR 30 | OPENSSL_INCLUDE_PATH 31 | LIBQTELEGRAM_LIB_DIR 32 | LIBQTELEGRAM_INCLUDE_PATH 33 | TELEGRAMQML_LIB_DIR 34 | TELEGRAMQML_INCLUDE_PATH 35 | 36 | #### Get libqtelegram 37 | 38 | First, you should build and install libqtelegram. 39 | 40 | git clone https://github.com/Aseman-Land/libqtelegram-aseman-edition.git 41 | 42 | And: 43 | 44 | cd libqtelegram-aseman-edition 45 | mkdir build && cd build 46 | qmake -r PREFIX=/usr CONFIG+=typeobjects .. 47 | 48 | And then start building: 49 | 50 | make 51 | sudo make install 52 | 53 | #### Get source code from git repository 54 | 55 | Get cutegram codes using this command: 56 | 57 | git clone https://github.com/Aseman-Land/TelegramQML.git 58 | 59 | #### Start building 60 | 61 | Switch to source directory 62 | 63 | cd TelegramQML 64 | 65 | ##### Ubuntu 66 | 67 | First, Please create build directory. 68 | 69 | mkdir build && cd build 70 | 71 | To build TelegramQml in the plugin mode run: 72 | 73 | qmake -r .. 74 | 75 | and to build in the library mode run: 76 | 77 | qmake -r .. PREFIX=/usr BUILD_MODE+=lib 78 | 79 | To make use of thumbnailer on the Ubuntu phone (which does not ship with ffmpeg), add the following to the qmake commands above: 80 | 81 | LIBS+=-lthumbnailer DEFINES+=UBUNTU_PHONE 82 | 83 | Then start build process: 84 | 85 | make 86 | make install 87 | 88 | You can use command below after building to clean build directory on the each step. 89 | 90 | make clean 91 | -------------------------------------------------------------------------------- /database/database.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aseman-Land/TelegramQML/761f109bbd1de4d4c928330a5f3918a84c18b33e/database/database.sqlite -------------------------------------------------------------------------------- /database/profiles.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aseman-Land/TelegramQML/761f109bbd1de4d4c928330a5f3918a84c18b33e/database/profiles.sqlite -------------------------------------------------------------------------------- /database/userdata.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aseman-Land/TelegramQML/761f109bbd1de4d4c928330a5f3918a84c18b33e/database/userdata.sqlite -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | telegramqml (2.0.0-1aseman-xenial) xenial; urgency=medium 2 | 3 | * Complitely rewritten using last libqtelegram-ae API (API53) 4 | 5 | -- Aseman Team Sun, 3 Jul 2016 12:00:00 +0330 6 | 7 | telegramqml (0.9.1-3aseman-wily) wily; urgency=medium 8 | 9 | * Add error handler 10 | * Many other improvements and bugfixes 11 | 12 | -- Aseman Team Tue, 12 Jan 2016 12:00:00 +0330 13 | 14 | telegramqml (0.9.1-3aseman-trusty) trusty; urgency=medium 15 | 16 | * Add error handler 17 | * Many other improvements and bugfixes 18 | 19 | -- Aseman Team Tue, 12 Jan 2016 12:00:00 +0330 20 | 21 | telegramqml (0.9.0-3aseman-vivid) vivid; urgency=medium 22 | 23 | * API 29 support 24 | * All messages stored encrypted on the database now 25 | * Custom authentication file 26 | * Add new demos on TelegramQml repository for developers 27 | * Many other improvements and bugfixes 28 | 29 | -- Aseman Team Mon, 5 Oct 2015 10:30:00 +0330 30 | 31 | telegramqml (0.9.0-3aseman-trusty) trusty; urgency=medium 32 | 33 | * API 29 support 34 | * All messages stored encrypted on the database now 35 | * Custom authentication file 36 | * Add new demos on TelegramQml repository for developers 37 | * Many other improvements and bugfixes 38 | 39 | -- Aseman Team Mon, 5 Oct 2015 10:30:00 +0330 40 | 41 | telegramqml (0.8.0-1aseman-vivid) vivid; urgency=medium 42 | 43 | * First Release 44 | 45 | -- Aseman Team Wed, 8 Jul 2015 10:30:00 +0330 46 | 47 | telegramqml (0.8.0-1aseman-utopic) utopic; urgency=medium 48 | 49 | * First Release 50 | 51 | -- Aseman Team Wed, 8 Jul 2015 10:30:00 +0330 52 | 53 | telegramqml (0.8.0-1aseman-trusty) trusty; urgency=medium 54 | 55 | * First Release 56 | 57 | -- Aseman Team Wed, 8 Jul 2015 10:30:00 +0330 58 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: telegramqml 2 | Section: libs 3 | Priority: optional 4 | Maintainer: Aseman Team 5 | Build-Depends: 6 | debhelper (>= 8.0.0), 7 | g++ (>= 4:4.7), 8 | gcc (>= 4:4.7), 9 | qtbase5-dev (>= 5.2.0), 10 | libqt5sql5-sqlite (>= 5.2.0), 11 | libqt5multimediaquick-p5 (>= 5.2.0), 12 | libqt5multimedia5-plugins (>= 5.2.0), 13 | libqt5multimedia5 (>= 5.2.0), 14 | qtchooser, 15 | qt5-qmake, 16 | qt5-default, 17 | libqt5qml5 (>= 5.2.0), 18 | libqt5qml-graphicaleffects (>= 5.2.0) | qml-module-qtgraphicaleffects, 19 | qtdeclarative5-controls-plugin (>= 5.2.0) | qml-module-qtquick-controls, 20 | qtdeclarative5-dev (>= 5.2.0), 21 | libqt5quick5 (>= 5.2.0), 22 | qtmultimedia5-dev (>= 5.2.0), 23 | libqt5webkit5-dev (>= 5.1.0), 24 | libappindicator-dev, 25 | libssl-dev, 26 | libqtelegram-ae-dev 27 | Standards-Version: 3.9.5 28 | Homepage: http://aseman.co/telegramqml 29 | Vcs-Git: https://github.com/Aseman-Land/TelegramQML 30 | 31 | Package: telegramqml 32 | Section: libs 33 | Architecture: any 34 | Depends: ${shlibs:Depends}, ${misc:Depends}, 35 | qtdeclarative5-controls-plugin (>= 5.2.0) | qml-module-qtquick-controls, 36 | qtdeclarative5-dialogs-plugin (>= 5.2.0) | qml-module-qtquick-dialogs, 37 | qtdeclarative5-qtquick2-plugin (>= 5.2.0) | qml-module-qtquick2, 38 | qtdeclarative5-window-plugin (>= 5.2.0) | qml-module-qtquick-window2, 39 | qtdeclarative5-qtmultimedia-plugin (>= 5.2.0) | qml-module-qtmultimedia, 40 | qtdeclarative5-qtsensors-plugin (>= 5.2.0) | qml-module-qtsensors, 41 | libqt5qml-graphicaleffects (>= 5.2.0) | qml-module-qtgraphicaleffects, 42 | libqt5multimedia5 (>= 5.2.0), 43 | libqt5multimedia5-plugins (>= 5.2.0), 44 | libqt5multimediaquick-p5 (>= 5.2.0), 45 | libqt5sql5-sqlite (>= 5.2.0), 46 | qt5-image-formats-plugins 47 | Description: Telegram API tools for QtQML and Qml, 48 | based on Cutegram-Core and libqtelegram. 49 | It's free and released under the GPLv3 license. 50 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: telegramqml 3 | Source: aseman.co/telegramqml 4 | 5 | Files: * 6 | Copyright: 2015 Aseman Team 7 | License: GPL-3.0+ 8 | 9 | Files: debian/* 10 | Copyright: 2015 Aseman Team 11 | License: GPL-3.0+ 12 | 13 | License: GPL-3.0+ 14 | This program is free software: you can redistribute it and/or modify 15 | it under the terms of the GNU General Public License as published by 16 | the Free Software Foundation, either version 3 of the License, or 17 | (at your option) any later version. 18 | . 19 | This package is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License for more details. 23 | . 24 | You should have received a copy of the GNU General Public License 25 | along with this program. If not, see . 26 | . 27 | On Debian systems, the complete text of the GNU General 28 | Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". 29 | 30 | # Please also look if there are files or directories which have a 31 | # different copyright/license attached and list them here. 32 | # Please avoid to pick license terms that are more restrictive than the 33 | # packaged work, as it may make Debian's contributions unacceptable upstream. 34 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | # Uncomment this to turn on verbose mode. 5 | #export DH_VERBOSE=1 6 | 7 | %: 8 | dh $@ 9 | 10 | override_dh_auto_configure: 11 | dh_auto_configure -- 12 | 13 | override_dh_install: 14 | dh_install 15 | 16 | override_dh_clean: 17 | dh_clean 18 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /demos/Search/SearchList.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | import QtQuick.Controls 1.3 3 | import QtQuick.Window 2.2 4 | import TelegramQml 1.0 5 | import "../share" 6 | 7 | Item { 8 | width: 640 9 | height: 480 10 | 11 | property alias telegram: smodel.telegram 12 | 13 | SearchModel { 14 | id: smodel 15 | } 16 | 17 | TextField { 18 | id: keyword_txt 19 | width: parent.width 20 | placeholderText: qsTr("Search Keyword") 21 | onAccepted: smodel.keyword = text 22 | } 23 | 24 | ScrollView { 25 | width: parent.width 26 | anchors.top: keyword_txt.bottom 27 | anchors.bottom: parent.bottom 28 | 29 | ListView { 30 | id: listView 31 | anchors.fill: parent 32 | model: smodel 33 | delegate: dialog_component 34 | } 35 | } 36 | 37 | Component { 38 | id: dialog_component 39 | Rectangle { 40 | id: item 41 | width: listView.width 42 | height: 50 43 | 44 | property Message message: model.item 45 | property User user: telegram.user(message.fromId) 46 | 47 | property Peer toPeer: message.toId 48 | property User toUser: telegram.user(toPeer.userId) 49 | property Chat toChat: telegram.chat(toPeer.chatId) 50 | 51 | FileHandler { 52 | id: handler 53 | target: item.user 54 | telegram: smodel.telegram 55 | defaultThumbnail: "user.png" 56 | } 57 | 58 | Row { 59 | anchors.fill: parent 60 | anchors.margins: 4 61 | spacing: 10 62 | 63 | Image { 64 | height: parent.height 65 | width: height 66 | sourceSize: Qt.size(width, height) 67 | source: handler.thumbPath 68 | } 69 | 70 | Column { 71 | anchors.verticalCenter: parent.verticalCenter 72 | 73 | Text { 74 | text: { 75 | var from = (item.user.firstName + " " + item.user.lastName).trim() 76 | var to = item.toPeer.chatId? item.toChat.title : 77 | item.toUser.firstName + 78 | " " + item.toUser.lastName 79 | to = to.trim() 80 | return ("from: %1 to: %2").arg(from).arg(to) 81 | } 82 | } 83 | Text { 84 | text: item.message.message 85 | wrapMode: Text.WrapAtWordBoundaryOrAnywhere 86 | elide: Text.ElideRight 87 | maximumLineCount: 1 88 | } 89 | } 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /demos/Search/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | import QtQuick.Controls 1.3 3 | import QtQuick.Window 2.2 4 | import TelegramQml 1.0 5 | import "../share" 6 | 7 | ApplicationWindow { 8 | title: qsTr("TgQml Demo: StickerManager") 9 | width: 640 10 | height: 480 11 | visible: true 12 | 13 | Telegram { 14 | id: tg 15 | defaultHostAddress: "149.154.167.50" 16 | defaultHostDcId: 2 17 | defaultHostPort: 443 18 | appId: 13682 19 | appHash: "de37bcf00f4688de900510f4f87384bb" 20 | configPath: tg.homePath + "/.config/TelegramQml/examples" 21 | publicKeyFile: "../share/tg-server.pub" 22 | Component.onCompleted: setLogLevel(Telegram.LogLevelUseful) 23 | } 24 | 25 | LoginForm { 26 | id: login 27 | anchors.fill: parent 28 | telegram: tg 29 | visible: !tg.authLoggedIn 30 | } 31 | 32 | SearchList { 33 | anchors.fill: parent 34 | telegram: tg 35 | visible: tg.authLoggedIn 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /demos/Search/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aseman-Land/TelegramQML/761f109bbd1de4d4c928330a5f3918a84c18b33e/demos/Search/user.png -------------------------------------------------------------------------------- /demos/SimpleClient/DialogList.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Controls 1.3 3 | import TelegramQml 1.0 4 | 5 | Item { 6 | id: dialogList 7 | width: 250 8 | 9 | property Telegram telegram 10 | property Dialog currentDialog: telegram.nullDialog 11 | 12 | ScrollView { 13 | anchors.fill: parent 14 | 15 | ListView { 16 | id: listView 17 | anchors.fill: parent 18 | model: DialogsModel { 19 | telegram: dialogList.telegram 20 | } 21 | delegate: dialog_component 22 | } 23 | } 24 | 25 | Component { 26 | id: dialog_component 27 | Rectangle { 28 | id: item 29 | width: listView.width 30 | height: 50 31 | color: currentDialog==dialog? "#330d80ec" : "#00000000" 32 | 33 | property Dialog dialog: model.item 34 | property User user: telegram.user(dialog.peer.userId) 35 | property Chat chat: telegram.chat(dialog.peer.chatId) 36 | 37 | FileHandler { 38 | id: handler 39 | target: item.dialog 40 | telegram: dialogList.telegram 41 | defaultThumbnail: "user.png" 42 | } 43 | 44 | Row { 45 | anchors.fill: parent 46 | anchors.margins: 4 47 | spacing: 10 48 | 49 | Image { 50 | height: parent.height 51 | width: height 52 | sourceSize: Qt.size(width, height) 53 | source: handler.thumbPath 54 | } 55 | 56 | Text { 57 | anchors.verticalCenter: parent.verticalCenter 58 | text: item.dialog.peer.chatId? item.chat.title 59 | : item.user.firstName + " " + item.user.lastName 60 | } 61 | } 62 | 63 | MouseArea { 64 | anchors.fill: parent 65 | onClicked: currentDialog = item.dialog 66 | } 67 | } 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /demos/SimpleClient/MainForm.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | import QtQuick.Controls 1.3 3 | import TelegramQml 1.0 4 | 5 | Item { 6 | id: mainForm 7 | width: 640 8 | height: 480 9 | 10 | property Telegram telegram 11 | 12 | DialogList { 13 | id: dialogList 14 | height: parent.height 15 | telegram: mainForm.telegram 16 | } 17 | 18 | MessageFrame { 19 | width: parent.width - dialogList.width 20 | height: parent.height 21 | anchors.right: parent.right 22 | telegram: mainForm.telegram 23 | dialog: dialogList.currentDialog 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /demos/SimpleClient/MessageFrame.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Controls 1.3 3 | import TelegramQml 1.0 4 | 5 | Rectangle { 6 | id: msgFrame 7 | width: 100 8 | height: 62 9 | 10 | property Telegram telegram 11 | property Dialog dialog: telegram.nullDialog 12 | 13 | ScrollView { 14 | width: parent.width 15 | anchors.top: parent.top 16 | anchors.bottom: send_row.top 17 | 18 | ListView { 19 | id: listv 20 | anchors.fill: parent 21 | verticalLayoutDirection: ListView.BottomToTop 22 | model: MessagesModel { 23 | telegram: msgFrame.telegram 24 | dialog: msgFrame.dialog 25 | } 26 | delegate: Item { 27 | id: item 28 | width: listv.width 29 | height: row.height + 10 30 | 31 | property Message message: model.item 32 | property Dialog dialog: telegram.dialog(message.fromId) 33 | 34 | Rectangle { 35 | width: parent.width; height: 1 36 | color: "#dddddd" 37 | } 38 | 39 | Row { 40 | id: row 41 | width: parent.width - 10 42 | anchors.centerIn: parent 43 | layoutDirection: item.message.out? Qt.RightToLeft : Qt.LeftToRight 44 | spacing: 10 45 | 46 | Image { 47 | anchors.verticalCenter: parent.verticalCenter 48 | height: 36; width: height 49 | sourceSize: Qt.size(width, height) 50 | source: handler.thumbPath 51 | } 52 | 53 | Text { 54 | width: parent.width - 60 55 | text: item.message.message 56 | wrapMode: Text.WrapAtWordBoundaryOrAnywhere 57 | anchors.verticalCenter: parent.verticalCenter 58 | } 59 | } 60 | 61 | FileHandler { 62 | id: handler 63 | target: item.dialog 64 | telegram: msgFrame.telegram 65 | defaultThumbnail: "user.png" 66 | } 67 | } 68 | } 69 | } 70 | 71 | Row { 72 | id: send_row 73 | width: parent.width 74 | anchors.bottom: parent.bottom 75 | 76 | TextField { 77 | id: msg 78 | width: parent.width - send_btn.width 79 | anchors.verticalCenter: parent.verticalCenter 80 | onAccepted: send_btn.clicked() 81 | } 82 | 83 | Button { 84 | id: send_btn 85 | anchors.verticalCenter: parent.verticalCenter 86 | text: qsTr("SEND") 87 | onClicked: { 88 | var dialogId = dialog.peer.chatId 89 | if(!dialogId) 90 | dialogId = dialog.peer.userId 91 | 92 | telegram.sendMessage(dialogId, msg.text) 93 | msg.text = "" 94 | } 95 | } 96 | } 97 | } 98 | 99 | -------------------------------------------------------------------------------- /demos/SimpleClient/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | import QtQuick.Controls 1.3 3 | import QtQuick.Window 2.2 4 | import TelegramQml 1.0 5 | import "../share" 6 | 7 | ApplicationWindow { 8 | title: qsTr("TgQml Demo: SimpleClient") 9 | width: 640 10 | height: 480 11 | visible: true 12 | 13 | Telegram { 14 | id: tg 15 | defaultHostAddress: "149.154.167.50" 16 | defaultHostDcId: 2 17 | defaultHostPort: 443 18 | appId: 13682 19 | appHash: "de37bcf00f4688de900510f4f87384bb" 20 | configPath: tg.homePath + "/.config/TelegramQml/examples" 21 | publicKeyFile: "../share/tg-server.pub" 22 | Component.onCompleted: setLogLevel(Telegram.LogLevelUseful) 23 | } 24 | 25 | MainForm { 26 | anchors.fill: parent 27 | telegram: tg 28 | visible: tg.authLoggedIn 29 | } 30 | 31 | LoginForm { 32 | id: login 33 | anchors.fill: parent 34 | telegram: tg 35 | visible: !tg.authLoggedIn 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /demos/SimpleClient/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aseman-Land/TelegramQML/761f109bbd1de4d4c928330a5f3918a84c18b33e/demos/SimpleClient/user.png -------------------------------------------------------------------------------- /demos/StickerManager/StickerList.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Controls 1.3 3 | import TelegramQml 1.0 4 | 5 | Item { 6 | id: stickerlist 7 | 8 | property Telegram telegram 9 | property alias currentStickerSet: sticker_model.currentStickerSet 10 | 11 | StickersModel { 12 | id: sticker_model 13 | telegram: stickerlist.telegram 14 | } 15 | 16 | ListView { 17 | id: catList 18 | height: parent.height 19 | width: 200 20 | model: sticker_model.installedStickerSets 21 | delegate: sticker_cat_component 22 | } 23 | 24 | ScrollView { 25 | height: parent.height 26 | anchors.left: catList.right 27 | anchors.right: parent.right 28 | 29 | GridView { 30 | anchors.fill: parent 31 | model: sticker_model 32 | delegate: sticker_item_component 33 | cellWidth: 100 34 | cellHeight: 100 35 | } 36 | } 37 | 38 | 39 | 40 | Component { 41 | id: sticker_cat_component 42 | Rectangle { 43 | id: catItem 44 | width: 200 45 | height: 26 46 | color: currentStickerSet==setId? "#330d80ec" : "#00000000" 47 | 48 | property string setId: sticker_model.installedStickerSets[index] 49 | property StickerSet stickerSet: sticker_model.stickerSetItem(setId) 50 | property Document document: sticker_model.stickerSetThumbnailDocument(setId) 51 | 52 | Row { 53 | anchors.fill: parent 54 | anchors.margins: 4 55 | spacing: 10 56 | 57 | Image { 58 | anchors.verticalCenter: parent.verticalCenter 59 | height: parent.height 60 | width: height 61 | sourceSize: Qt.size(width, height) 62 | source: handler.downloaded? handler.filePath : handler.thumbPath 63 | } 64 | 65 | Text { 66 | text: catItem.stickerSet.title 67 | } 68 | } 69 | 70 | FileHandler { 71 | id: handler 72 | target: catItem.document 73 | telegram: stickerlist.telegram 74 | Component.onCompleted: download() 75 | } 76 | 77 | MouseArea { 78 | id: marea 79 | anchors.fill: parent 80 | onClicked: currentStickerSet = catItem.setId 81 | } 82 | } 83 | } 84 | 85 | Component { 86 | id: sticker_item_component 87 | Item { 88 | id: item 89 | width: 100 90 | height: 100 91 | 92 | property Document document: model.document 93 | 94 | FileHandler { 95 | id: handler 96 | target: item.document 97 | telegram: stickerlist.telegram 98 | Component.onCompleted: download() 99 | } 100 | 101 | Image { 102 | anchors.fill: parent 103 | anchors.margins: 4 104 | height: parent.height 105 | width: height 106 | fillMode: Image.PreserveAspectFit 107 | sourceSize: Qt.size(width, height) 108 | source: handler.downloaded? handler.filePath : handler.thumbPath 109 | } 110 | } 111 | } 112 | } 113 | 114 | -------------------------------------------------------------------------------- /demos/StickerManager/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | import QtQuick.Controls 1.3 3 | import QtQuick.Window 2.2 4 | import TelegramQml 1.0 5 | import "../share" 6 | 7 | ApplicationWindow { 8 | title: qsTr("TgQml Demo: StickerManager") 9 | width: 640 10 | height: 480 11 | visible: true 12 | 13 | Telegram { 14 | id: tg 15 | defaultHostAddress: "149.154.167.50" 16 | defaultHostDcId: 2 17 | defaultHostPort: 443 18 | appId: 13682 19 | appHash: "de37bcf00f4688de900510f4f87384bb" 20 | configPath: tg.homePath + "/.config/TelegramQml/examples" 21 | publicKeyFile: "../share/tg-server.pub" 22 | Component.onCompleted: setLogLevel(Telegram.LogLevelUseful) 23 | } 24 | 25 | LoginForm { 26 | id: login 27 | anchors.fill: parent 28 | telegram: tg 29 | visible: !tg.authLoggedIn 30 | } 31 | 32 | StickerList { 33 | anchors.fill: parent 34 | visible: tg.authLoggedIn 35 | telegram: tg 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /demos/StickerViewer/StickerList.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Controls 1.3 3 | import TelegramQml 1.0 4 | 5 | Item { 6 | id: stickerlist 7 | 8 | property Telegram telegram 9 | 10 | StickersModel { 11 | id: sticker_model 12 | telegram: stickerlist.telegram 13 | } 14 | 15 | TextField { 16 | id: input 17 | width: parent.width 18 | placeholderText: qsTr("Sticker short name") 19 | onAccepted: sticker_model.currentStickerSet = text 20 | } 21 | 22 | TextInput { 23 | id: sticker_title 24 | anchors.top: input.bottom 25 | x: 10 26 | readOnly: true 27 | selectByMouse: true 28 | font.pointSize: 12 29 | text: sticker_model.stickerSetItem(sticker_model.currentStickerSet).title 30 | } 31 | 32 | ScrollView { 33 | width: parent.width 34 | height: parent.height 35 | anchors.top: sticker_title.bottom 36 | anchors.bottom: parent.bottom 37 | 38 | GridView { 39 | anchors.fill: parent 40 | model: sticker_model 41 | delegate: sticker_item_component 42 | cellWidth: 100 43 | cellHeight: 100 44 | } 45 | } 46 | 47 | Component { 48 | id: sticker_item_component 49 | Item { 50 | id: item 51 | width: 100 52 | height: 100 53 | 54 | property Document document: model.document 55 | 56 | FileHandler { 57 | id: handler 58 | target: item.document 59 | telegram: stickerlist.telegram 60 | Component.onCompleted: download() 61 | } 62 | 63 | Image { 64 | anchors.fill: parent 65 | anchors.margins: 4 66 | height: parent.height 67 | width: height 68 | fillMode: Image.PreserveAspectFit 69 | sourceSize: Qt.size(width, height) 70 | source: handler.downloaded? handler.filePath : handler.thumbPath 71 | } 72 | 73 | MouseArea { 74 | anchors.fill: parent 75 | onClicked: Qt.openUrlExternally(handler.thumbPath) 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /demos/StickerViewer/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.4 2 | import QtQuick.Controls 1.3 3 | import QtQuick.Window 2.2 4 | import TelegramQml 1.0 5 | import "../share" 6 | 7 | ApplicationWindow { 8 | title: qsTr("TgQml Demo: StickerManager") 9 | width: 640 10 | height: 480 11 | visible: true 12 | 13 | Telegram { 14 | id: tg 15 | defaultHostAddress: "149.154.167.50" 16 | defaultHostDcId: 2 17 | defaultHostPort: 443 18 | appId: 13682 19 | appHash: "de37bcf00f4688de900510f4f87384bb" 20 | configPath: tg.homePath + "/.config/TelegramQml/examples" 21 | publicKeyFile: "../share/tg-server.pub" 22 | Component.onCompleted: setLogLevel(Telegram.LogLevelUseful) 23 | } 24 | 25 | LoginForm { 26 | id: login 27 | anchors.fill: parent 28 | telegram: tg 29 | visible: !tg.authLoggedIn 30 | } 31 | 32 | StickerList { 33 | anchors.fill: parent 34 | visible: tg.authLoggedIn 35 | telegram: tg 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /demos/share/LoginForm.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import QtQuick.Controls 1.3 3 | import TelegramQml 1.0 4 | 5 | Rectangle { 6 | width: 100 7 | height: 62 8 | color: myPalette.window 9 | 10 | property Telegram telegram 11 | 12 | SystemPalette { id: myPalette; colorGroup: SystemPalette.Active } 13 | 14 | Column { 15 | anchors.centerIn: parent 16 | spacing: 4 17 | visible: telegram.phoneNumber.length == 0 18 | 19 | Text { 20 | anchors.horizontalCenter: parent.horizontalCenter 21 | font.pointSize: 20 22 | color: "#333333" 23 | text: qsTr("Enter Your Phone") 24 | } 25 | 26 | TextField { 27 | id: phone 28 | width: 300 29 | validator: RegExpValidator{regExp: /\+(?!0)\d*/} 30 | placeholderText: qsTr("ex: +123456789") 31 | onAccepted: login_btn.clicked() 32 | } 33 | 34 | Button { 35 | id: login_btn 36 | text: qsTr("Login") 37 | width: 300 38 | onClicked: telegram.phoneNumber = phone.text 39 | } 40 | } 41 | 42 | BusyIndicator { 43 | anchors.centerIn: parent 44 | running: telegram.phoneNumber.length != 0 && 45 | !telegram.authNeeded && 46 | !telegram.authLoggedIn 47 | } 48 | 49 | Column { 50 | anchors.centerIn: parent 51 | spacing: 4 52 | visible: telegram.phoneNumber.length != 0 && 53 | telegram.authNeeded 54 | 55 | Text { 56 | anchors.horizontalCenter: parent.horizontalCenter 57 | font.pointSize: 20 58 | color: "#333333" 59 | text: qsTr("Enter Code") 60 | } 61 | 62 | TextField { 63 | id: code 64 | width: 300 65 | } 66 | 67 | Button { 68 | text: qsTr("Send Code") 69 | width: 300 70 | onClicked: telegram.authSignIn(code.text) 71 | } 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /demos/share/tg-server.pub: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PUBLIC KEY----- 2 | MIIBCgKCAQEAwVACPi9w23mF3tBkdZz+zwrzKOaaQdr01vAbU4E1pvkfj4sqDsm6 3 | lyDONS789sVoD/xCS9Y0hkkC3gtL1tSfTlgCMOOul9lcixlEKzwKENj1Yz/s7daS 4 | an9tqw3bfUV/nqgbhGX81v/+7RFAEd+RwFnK7a+XYl9sluzHRyVVaTTveB2GazTw 5 | Efzk2DWgkBluml8OREmvfraX3bkHZJTKX4EQSjBbbdJ2ZXIsRrYOXfaA+xayEGB+ 6 | 8hdlLmAjbCVfaigxX0CDqWeR1yFL9kwd9P0NsZRPsmoqVwMbMu7mStFai6aIhc3n 7 | Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB 8 | -----END RSA PUBLIC KEY----- 9 | 10 | -------------------------------------------------------------------------------- /documents/abstractenginelistmodel.md: -------------------------------------------------------------------------------- 1 | # AbstractEngineListModel 2 | 3 | * [Component details](#component-details) 4 | * [Normal Properties](#normal-properties) 5 | * [Methods](#methods) 6 | * [Roles](#roles) 7 | 8 | 9 | ### Component details: 10 | 11 | |Detail|Value| 12 | |------|-----| 13 | |Import|TelegramQml 2.0| 14 | |Component|AbstractEngineListModel| 15 | |C++ class|TelegramAbstractEngineListModel| 16 | |Inherits|[AbstractListModel](abstractlistmodel.md)| 17 | |Model|Yes| 18 | 19 | 20 | 21 | ### Normal Properties 22 | 23 | * engine: [Engine](engine.md) 24 | 25 | 26 | ### Methods 27 | 28 | * void startTimer(int ms, Callback callback) 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /documents/abstractlistmodel.md: -------------------------------------------------------------------------------- 1 | # AbstractListModel 2 | 3 | * [Component details](#component-details) 4 | * [Normal Properties](#normal-properties) 5 | * [Methods](#methods) 6 | * [Roles](#roles) 7 | 8 | 9 | ### Component details: 10 | 11 | |Detail|Value| 12 | |------|-----| 13 | |Import|TelegramQml 2.0| 14 | |Component|AbstractListModel| 15 | |C++ class|TelegramAbstractListModel| 16 | |Inherits|QAbstractListModel| 17 | |Model|Yes| 18 | 19 | 20 | 21 | ### Normal Properties 22 | 23 | * count: int (readOnly) 24 | * isEmpty: boolean (readOnly) 25 | * errorText: string (readOnly) 26 | * errorCode: int (readOnly) 27 | * items: [QQmlListProperty](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/qqmllistproperty.md) (readOnly) 28 | 29 | 30 | ### Methods 31 | 32 | * variant get(int index, int role) 33 | * variant get(int index, string roleName) 34 | * map get(int index) 35 | * int indexOf(int role, variant value) 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /documents/app.md: -------------------------------------------------------------------------------- 1 | # App 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | 7 | 8 | ### Component details: 9 | 10 | |Detail|Value| 11 | |------|-----| 12 | |Import|TelegramQml 2.0| 13 | |Component|App| 14 | |C++ class|TelegramApp| 15 | |Inherits|object| 16 | |Model|No| 17 | 18 | 19 | ### Required Properties 20 | 21 | * appId: int 22 | * appHash: string 23 | 24 | 25 | ### Normal Properties 26 | 27 | * isValid: boolean (readOnly) 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /documents/authenticate.md: -------------------------------------------------------------------------------- 1 | # Authenticate 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Enumerator](#enumerator) 7 | * [Methods](#methods) 8 | * [Signals](#signals) 9 | 10 | 11 | ### Component details: 12 | 13 | |Detail|Value| 14 | |------|-----| 15 | |Import|TelegramQml 2.0| 16 | |Component|Authenticate| 17 | |C++ class|TelegramAuthenticate| 18 | |Inherits|[Tq](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/tq.md)| 19 | |Model|No| 20 | 21 | 22 | ### Required Properties 23 | 24 | * engine: [Engine](engine.md) 25 | 26 | 27 | ### Normal Properties 28 | 29 | * state: int (readOnly) 30 | * callTimeout: int (readOnly) 31 | * remainingTime: int (readOnly) 32 | 33 | 34 | ### Methods 35 | 36 | * void signUp(string firstName, string lastName) 37 | * void signIn(string code) 38 | * void checkPassword(string password) 39 | 40 | 41 | ### Signals 42 | 43 | * void authLoggedIn() 44 | 45 | 46 | ### Enumerator 47 | 48 | 49 | ##### AuthState 50 | 51 | |Key|Value| 52 | |---|-----| 53 | |AuthUnknown|0| 54 | |AuthCheckingPhone|1| 55 | |AuthCheckingPhoneError|2| 56 | |AuthSignUpNeeded|3| 57 | |AuthCodeRequesting|4| 58 | |AuthCodeRequestingError|5| 59 | |AuthCodeRequested|6| 60 | |AuthPasswordRequested|7| 61 | |AuthLoggingIn|8| 62 | |AuthLoggingInError|9| 63 | |AuthLoggedIn|10| 64 | 65 | -------------------------------------------------------------------------------- /documents/authstore.md: -------------------------------------------------------------------------------- 1 | # AuthStore 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | 7 | 8 | ### Component details: 9 | 10 | |Detail|Value| 11 | |------|-----| 12 | |Import|TelegramQml 2.0| 13 | |Component|AuthStore| 14 | |C++ class|TelegramAuthStore| 15 | |Inherits|object| 16 | |Model|No| 17 | 18 | 19 | ### Required Properties 20 | 21 | * writeMethod: function(){[code]} 22 | * readMethod: function(){[code]} 23 | 24 | 25 | ### Normal Properties 26 | 27 | * isValid: boolean (readOnly) 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /documents/cache.md: -------------------------------------------------------------------------------- 1 | # Cache 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Signals](#signals) 7 | 8 | 9 | ### Component details: 10 | 11 | |Detail|Value| 12 | |------|-----| 13 | |Import|TelegramQml 2.0| 14 | |Component|Cache| 15 | |C++ class|TelegramCache| 16 | |Inherits|[Tq](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/tq.md)| 17 | |Model|No| 18 | 19 | 20 | ### Required Properties 21 | 22 | * path: string 23 | 24 | 25 | ### Normal Properties 26 | 27 | * encryptMethod: function(){[code]} 28 | * decryptMethod: function(){[code]} 29 | * engine: [Engine](engine.md) (readOnly) 30 | * pts: int (readOnly) 31 | * updating: boolean (readOnly) 32 | * isValid: boolean (readOnly) 33 | * cacheMessages: boolean 34 | 35 | 36 | 37 | ### Signals 38 | 39 | * void qtsChanged() 40 | 41 | 42 | -------------------------------------------------------------------------------- /documents/downloadhandler.md: -------------------------------------------------------------------------------- 1 | # DownloadHandler 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Methods](#methods) 7 | * [Signals](#signals) 8 | 9 | 10 | ### Component details: 11 | 12 | |Detail|Value| 13 | |------|-----| 14 | |Import|TelegramQml 2.0| 15 | |Component|DownloadHandler| 16 | |C++ class|TelegramDownloadHandler| 17 | |Inherits|[Tq](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/tq.md)| 18 | |Model|No| 19 | 20 | 21 | ### Required Properties 22 | 23 | * source: [TypeQObject](typeqobject.md) 24 | 25 | 26 | ### Normal Properties 27 | 28 | * target: [FileLocation](filelocation.md) (readOnly) 29 | * targetType: int (readOnly) 30 | * size: int (readOnly) 31 | * downloadedSize: int (readOnly) 32 | * downloadTotal: int (readOnly) 33 | * downloading: boolean (readOnly) 34 | * destination: string (readOnly) 35 | * thumbnail: string (readOnly) 36 | * imageSize: size (readOnly) 37 | * thumbnailSize: size (readOnly) 38 | 39 | 40 | ### Methods 41 | 42 | * boolean download() 43 | * boolean check() 44 | * void stop() 45 | 46 | 47 | ### Signals 48 | 49 | * void engineChanged() 50 | 51 | 52 | -------------------------------------------------------------------------------- /documents/engine.md: -------------------------------------------------------------------------------- 1 | # Engine 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Enumerator](#enumerator) 7 | * [Methods](#methods) 8 | * [Signals](#signals) 9 | 10 | 11 | ### Component details: 12 | 13 | |Detail|Value| 14 | |------|-----| 15 | |Import|TelegramQml 2.0| 16 | |Component|Engine| 17 | |C++ class|TelegramEngine| 18 | |Inherits|[Tq](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/tq.md)| 19 | |Model|No| 20 | 21 | 22 | ### Required Properties 23 | 24 | * phoneNumber: string 25 | * configDirectory: string 26 | * app: [App](app.md) 27 | * host: [Host](host.md) 28 | 29 | 30 | ### Normal Properties 31 | 32 | * cache: [Cache](cache.md) 33 | * authStore: [AuthStore](authstore.md) 34 | * profileManager: [ProfileManagerModel](profilemanagermodel.md) 35 | * our: [UserFull](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/userfull.md) (readOnly) 36 | * timeout: int 37 | * state: int (readOnly) 38 | * logLevel: int 39 | * tempPath: string 40 | * telegramObject: [](.md) (readOnly) 41 | 42 | 43 | ### Methods 44 | 45 | * void logout() 46 | 47 | 48 | ### Signals 49 | 50 | * void authLoggedIn() 51 | * void authNeeded() 52 | * void authLoggedOut() 53 | 54 | 55 | ### Enumerator 56 | 57 | 58 | ##### AuthState 59 | 60 | |Key|Value| 61 | |---|-----| 62 | |AuthUnknown|0| 63 | |AuthInitializing|1| 64 | |AuthNeeded|2| 65 | |AuthFetchingOurDetails|3| 66 | |AuthLoggedIn|4| 67 | 68 | ##### LogLevel 69 | 70 | |Key|Value| 71 | |---|-----| 72 | |LogLevelClean|0| 73 | |LogLevelUseful|1| 74 | |LogLevelFull|2| 75 | 76 | -------------------------------------------------------------------------------- /documents/enums.md: -------------------------------------------------------------------------------- 1 | # Enums 2 | 3 | * [Component details](#component-details) 4 | * [Enumerator](#enumerator) 5 | 6 | 7 | ### Component details: 8 | 9 | |Detail|Value| 10 | |------|-----| 11 | |Import|TelegramQml 2.0| 12 | |Component|Enums| 13 | |C++ class|TelegramEnums| 14 | |Inherits|object| 15 | |Model|No| 16 | 17 | 18 | 19 | 20 | 21 | 22 | ### Enumerator 23 | 24 | 25 | ##### SendFileType 26 | 27 | |Key|Value| 28 | |---|-----| 29 | |SendFileTypeAutoDetect|0| 30 | |SendFileTypeDocument|1| 31 | |SendFileTypeSticker|2| 32 | |SendFileTypeAnimated|3| 33 | |SendFileTypeVideo|4| 34 | |SendFileTypePhoto|5| 35 | |SendFileTypeAudio|6| 36 | 37 | ##### MessageType 38 | 39 | |Key|Value| 40 | |---|-----| 41 | |TypeTextMessage|0| 42 | |TypeDocumentMessage|1| 43 | |TypeVideoMessage|2| 44 | |TypeAudioMessage|3| 45 | |TypeVenueMessage|4| 46 | |TypeWebPageMessage|5| 47 | |TypeGeoMessage|6| 48 | |TypeContactMessage|7| 49 | |TypeActionMessage|8| 50 | |TypePhotoMessage|9| 51 | |TypeStickerMessage|10| 52 | |TypeAnimatedMessage|11| 53 | |TypeUnsupportedMessage|12| 54 | 55 | -------------------------------------------------------------------------------- /documents/host.md: -------------------------------------------------------------------------------- 1 | # Host 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | 7 | 8 | ### Component details: 9 | 10 | |Detail|Value| 11 | |------|-----| 12 | |Import|TelegramQml 2.0| 13 | |Component|Host| 14 | |C++ class|TelegramHost| 15 | |Inherits|object| 16 | |Model|No| 17 | 18 | 19 | ### Required Properties 20 | 21 | * hostAddress: string 22 | * hostPort: int 23 | * hostDcId: int 24 | * publicKey: url 25 | 26 | 27 | ### Normal Properties 28 | 29 | * isValid: boolean (readOnly) 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /documents/image.md: -------------------------------------------------------------------------------- 1 | # Image 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Methods](#methods) 7 | 8 | 9 | ### Component details: 10 | 11 | |Detail|Value| 12 | |------|-----| 13 | |Import|TelegramQml 2.0| 14 | |Component|Image| 15 | |C++ class|TelegramImageElement| 16 | |Inherits|Item| 17 | |Model|No| 18 | 19 | 20 | ### Required Properties 21 | 22 | * source: [TypeQObject](typeqobject.md) 23 | * engine: [Engine](engine.md) 24 | 25 | 26 | ### Normal Properties 27 | 28 | * qtQuickVersion: string 29 | * fileSize: int (readOnly) 30 | * downloadedSize: int (readOnly) 31 | * downloading: boolean (readOnly) 32 | * downloaded: boolean (readOnly) 33 | * thumbnailDownloaded: boolean (readOnly) 34 | * destination: url (readOnly) 35 | * thumbnail: url (readOnly) 36 | * currentImage: url (readOnly) 37 | * imageSize: size (readOnly) 38 | * errorText: string (readOnly) 39 | * errorCode: int (readOnly) 40 | * asynchronous: boolean 41 | * autoTransform: boolean 42 | * cache: boolean 43 | * fillMode: int 44 | * horizontalAlignment: int 45 | * mipmap: boolean 46 | * mirror: boolean 47 | * paintedHeight: real (readOnly) 48 | * paintedWidth: real (readOnly) 49 | * smooth: boolean 50 | * sourceSize: size 51 | * verticalAlignment: int 52 | 53 | 54 | ### Methods 55 | 56 | * boolean download() 57 | * boolean check() 58 | * void stop() 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /documents/makeHtml.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | FILELIST=`find . -name "*.md"` 4 | DEST_PATH="html" 5 | 6 | mkdir $DEST_PATH 7 | for MDFILE in $FILELIST 8 | do 9 | DEST_FILE=`basename $MDFILE .md` 10 | DEST_DIR=`dirname $MDFILE` 11 | 12 | DIRECTORY="$DEST_PATH/$DEST_DIR/" 13 | if [ ! -d "$DIRECTORY" ]; then 14 | mkdir "$DIRECTORY" 15 | fi 16 | 17 | DST="$DIRECTORY/$DEST_FILE.html" 18 | SRC="$DEST_DIR/$DEST_FILE.md" 19 | 20 | grip --export "$SRC" "$DST" 21 | sed -i 's/.md">/.html">/g' "$DST" 22 | done 23 | -------------------------------------------------------------------------------- /documents/medialistmodel.md: -------------------------------------------------------------------------------- 1 | # MediaListModel 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Roles](#roles) 6 | 7 | 8 | ### Component details: 9 | 10 | |Detail|Value| 11 | |------|-----| 12 | |Import|TelegramQml 2.0| 13 | |Component|MediaListModel| 14 | |C++ class|TelegramMediaListModel| 15 | |Inherits|[MessageSearchModel](messagesearchmodel.md)| 16 | |Model|Yes| 17 | 18 | 19 | ### Required Properties 20 | 21 | * engine: [Engine](engine.md) 22 | * messageFilter: int 23 | 24 | 25 | 26 | 27 | 28 | 29 | ### Roles 30 | 31 | * model.item 32 | * model.mediaItem 33 | * model.serviceItem 34 | * model.markupItem 35 | * model.entityList 36 | * model.fromUserItem 37 | * model.toUserItem 38 | * model.toChatItem 39 | * model.toPeerItem 40 | * model.message 41 | * model.dateTime 42 | * model.date 43 | * model.unread 44 | * model.sent 45 | * model.out 46 | * model.replyMsgId 47 | * model.replyMessage 48 | * model.replyPeer 49 | * model.forwardFromPeer 50 | * model.forwardDate 51 | * model.messageType 52 | * model.replyType 53 | * model.fileName 54 | * model.fileMimeType 55 | * model.fileTitle 56 | * model.filePerformer 57 | * model.fileDuration 58 | * model.fileIsVoice 59 | * model.fileSize 60 | * model.downloadable 61 | * model.uploading 62 | * model.downloading 63 | * model.transfaring 64 | * model.transfared 65 | * model.transfaredSize 66 | * model.totalSize 67 | * model.filePath 68 | * model.thumbPath 69 | -------------------------------------------------------------------------------- /documents/memberslistmodel.md: -------------------------------------------------------------------------------- 1 | # MembersListModel 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Enumerator](#enumerator) 7 | * [Roles](#roles) 8 | 9 | 10 | ### Component details: 11 | 12 | |Detail|Value| 13 | |------|-----| 14 | |Import|TelegramQml 2.0| 15 | |Component|MembersListModel| 16 | |C++ class|TelegramMembersListModel| 17 | |Inherits|[AbstractEngineListModel](abstractenginelistmodel.md)| 18 | |Model|Yes| 19 | 20 | 21 | ### Required Properties 22 | 23 | * engine: [Engine](engine.md) 24 | * currentPeer: [InputPeer](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputpeer.md) 25 | 26 | 27 | ### Normal Properties 28 | 29 | * filter: int 30 | * refreshing: boolean (readOnly) 31 | * dateConvertorMethod: function(){[code]} 32 | 33 | 34 | 35 | 36 | ### Enumerator 37 | 38 | 39 | ##### DataRoles 40 | 41 | |Key|Value| 42 | |---|-----| 43 | |RoleDate|256| 44 | |RoleInviter|257| 45 | |RoleUser|258| 46 | |RoleKickedBy|259| 47 | |RoleType|260| 48 | |RolePeer|261| 49 | |RoleStatus|262| 50 | 51 | ##### Types 52 | 53 | |Key|Value| 54 | |---|-----| 55 | |TypeNormal|0| 56 | |TypeSelf|1| 57 | |TypeAdmin|2| 58 | |TypeModerator|3| 59 | |TypeEditor|4| 60 | |TypeKicked|5| 61 | |TypeCreator|6| 62 | |TypeUnknown|7| 63 | 64 | 65 | ### Roles 66 | 67 | * model.date 68 | * model.inviter 69 | * model.user 70 | * model.kickedBy 71 | * model.type 72 | * model.peer 73 | * model.status 74 | -------------------------------------------------------------------------------- /documents/messagefetcher.md: -------------------------------------------------------------------------------- 1 | # MessageFetcher 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | 7 | 8 | ### Component details: 9 | 10 | |Detail|Value| 11 | |------|-----| 12 | |Import|TelegramQml 2.0| 13 | |Component|MessageFetcher| 14 | |C++ class|TelegramMessageFetcher| 15 | |Inherits|[Tq](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/tq.md)| 16 | |Model|No| 17 | 18 | 19 | ### Required Properties 20 | 21 | * engine: [Engine](engine.md) 22 | * messageId: int 23 | * inputPeer: [InputPeer](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputpeer.md) 24 | 25 | 26 | ### Normal Properties 27 | 28 | * result: [TQmlMessage](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/tqmlmessage.md) (readOnly) 29 | * fromUser: [User](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/user.md) (readOnly) 30 | * mediaType: int (readOnly) 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /documents/messagesearchmodel.md: -------------------------------------------------------------------------------- 1 | # MessageSearchModel 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Methods](#methods) 7 | * [Roles](#roles) 8 | 9 | 10 | ### Component details: 11 | 12 | |Detail|Value| 13 | |------|-----| 14 | |Import|TelegramQml 2.0| 15 | |Component|MessageSearchModel| 16 | |C++ class|TelegramMessageSearchModel| 17 | |Inherits|[MessageListModel](messagelistmodel.md)| 18 | |Model|Yes| 19 | 20 | 21 | ### Required Properties 22 | 23 | * engine: [Engine](engine.md) 24 | * currentPeer: [InputPeer](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputpeer.md) 25 | * keyword: string 26 | * currentPeer: [InputPeer](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputpeer.md) 27 | 28 | 29 | ### Normal Properties 30 | 31 | * messageFilter: int 32 | * minimumDate: QDateTime 33 | * maximumDate: QDateTime 34 | 35 | 36 | ### Methods 37 | 38 | * void loadBack() 39 | 40 | 41 | 42 | 43 | ### Roles 44 | 45 | * model.item 46 | * model.mediaItem 47 | * model.serviceItem 48 | * model.markupItem 49 | * model.entityList 50 | * model.fromUserItem 51 | * model.toUserItem 52 | * model.toChatItem 53 | * model.toPeerItem 54 | * model.message 55 | * model.dateTime 56 | * model.date 57 | * model.unread 58 | * model.sent 59 | * model.out 60 | * model.replyMsgId 61 | * model.replyMessage 62 | * model.replyPeer 63 | * model.forwardFromPeer 64 | * model.forwardDate 65 | * model.messageType 66 | * model.replyType 67 | * model.fileName 68 | * model.fileMimeType 69 | * model.fileTitle 70 | * model.filePerformer 71 | * model.fileDuration 72 | * model.fileIsVoice 73 | * model.fileSize 74 | * model.downloadable 75 | * model.uploading 76 | * model.downloading 77 | * model.transfaring 78 | * model.transfared 79 | * model.transfaredSize 80 | * model.totalSize 81 | * model.filePath 82 | * model.thumbPath 83 | -------------------------------------------------------------------------------- /documents/messagesfilter.md: -------------------------------------------------------------------------------- 1 | # MessagesFilter 2 | 3 | * [Component details](#component-details) 4 | * [Normal Properties](#normal-properties) 5 | * [Enumerator](#enumerator) 6 | 7 | 8 | ### Component details: 9 | 10 | |Detail|Value| 11 | |------|-----| 12 | |Import|TelegramQml 2.0| 13 | |Component|MessagesFilter| 14 | |C++ class|MessagesFilterObject| 15 | |Inherits|[TypeQObject](typeqobject.md)| 16 | |Model|No| 17 | 18 | 19 | 20 | ### Normal Properties 21 | 22 | * flags: int 23 | * missed: boolean 24 | * core: MessagesFilter 25 | * classType: uint 26 | 27 | 28 | 29 | 30 | ### Enumerator 31 | 32 | 33 | ##### MessagesFilterClassType 34 | 35 | |Key|Value| 36 | |---|-----| 37 | |TypeInputMessagesFilterEmpty|0| 38 | |TypeInputMessagesFilterPhotos|1| 39 | |TypeInputMessagesFilterVideo|2| 40 | |TypeInputMessagesFilterPhotoVideo|3| 41 | |TypeInputMessagesFilterPhotoVideoDocuments|4| 42 | |TypeInputMessagesFilterDocument|5| 43 | |TypeInputMessagesFilterUrl|6| 44 | |TypeInputMessagesFilterGif|7| 45 | |TypeInputMessagesFilterVoice|8| 46 | |TypeInputMessagesFilterMusic|9| 47 | |TypeInputMessagesFilterChatPhotos|10| 48 | |TypeInputMessagesFilterPhoneCalls|11| 49 | |TypeInputMessagesFilterRoundVoice|12| 50 | |TypeInputMessagesFilterRoundVideo|13| 51 | 52 | -------------------------------------------------------------------------------- /documents/notificationhandler.md: -------------------------------------------------------------------------------- 1 | # NotificationHandler 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Signals](#signals) 7 | 8 | 9 | ### Component details: 10 | 11 | |Detail|Value| 12 | |------|-----| 13 | |Import|TelegramQml 2.0| 14 | |Component|NotificationHandler| 15 | |C++ class|TelegramNotificationHandler| 16 | |Inherits|[Tq](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/tq.md)| 17 | |Model|No| 18 | 19 | 20 | ### Required Properties 21 | 22 | * engine: [Engine](engine.md) 23 | 24 | 25 | ### Normal Properties 26 | 27 | * unreadCount: int (readOnly) 28 | * globalUnreadCount: int (readOnly) 29 | 30 | 31 | 32 | ### Signals 33 | 34 | * void newMessage(string title, string message, string peerKey) 35 | 36 | 37 | -------------------------------------------------------------------------------- /documents/peerdetails.md: -------------------------------------------------------------------------------- 1 | # PeerDetails 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Methods](#methods) 7 | 8 | 9 | ### Component details: 10 | 11 | |Detail|Value| 12 | |------|-----| 13 | |Import|TelegramQml 2.0| 14 | |Component|PeerDetails| 15 | |C++ class|TelegramPeerDetails| 16 | |Inherits|[Tq](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/tq.md)| 17 | |Model|No| 18 | 19 | 20 | ### Required Properties 21 | 22 | * peer: [InputPeer](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputpeer.md) 23 | * engine: [Engine](engine.md) 24 | 25 | 26 | ### Normal Properties 27 | 28 | * dateConvertorMethod: function(){[code]} 29 | * isChat: boolean (readOnly) 30 | * isUser: boolean (readOnly) 31 | * isChannel: boolean (readOnly) 32 | * key: string (readOnly) 33 | * displayName: string (readOnly) 34 | * participantsCount: int (readOnly) 35 | * statusText: string (readOnly) 36 | * phoneNumber: string (readOnly) 37 | * username: string 38 | * mute: boolean 39 | * blocked: boolean 40 | * joined: boolean 41 | * refreshing: boolean (readOnly) 42 | * editable: boolean (readOnly) 43 | * userFull: [UserFull](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/userfull.md) (readOnly) 44 | * chatFull: [ChatFull](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/chatfull.md) (readOnly) 45 | * chatUsers: list<variant> (readOnly) 46 | 47 | 48 | ### Methods 49 | 50 | * void renameChat(string title, function(){[code]} callback) 51 | * void renameChat(string title) 52 | * void renameUser(string firstName, string lastName, function(){[code]} callback) 53 | * void renameUser(string firstName, string lastName) 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /documents/profilemanagermodel.md: -------------------------------------------------------------------------------- 1 | # ProfileManagerModel 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Enumerator](#enumerator) 7 | * [Methods](#methods) 8 | * [Roles](#roles) 9 | 10 | 11 | ### Component details: 12 | 13 | |Detail|Value| 14 | |------|-----| 15 | |Import|TelegramQml 2.0| 16 | |Component|ProfileManagerModel| 17 | |C++ class|TelegramProfileManagerModel| 18 | |Inherits|[AbstractListModel](abstractlistmodel.md)| 19 | |Model|Yes| 20 | 21 | 22 | ### Required Properties 23 | 24 | * source: string 25 | * engineDelegate: Component 26 | 27 | 28 | ### Normal Properties 29 | 30 | * initializing: boolean (readOnly) 31 | 32 | 33 | ### Methods 34 | 35 | * void addNew() 36 | * int add(string phoneNumber, boolean mute, [Engine](engine.md) engine) 37 | * boolean remove(string phoneNumber) 38 | 39 | 40 | 41 | ### Enumerator 42 | 43 | 44 | ##### DataRole 45 | 46 | |Key|Value| 47 | |---|-----| 48 | |DataPhoneNumber|256| 49 | |DataMute|257| 50 | |DataEngine|258| 51 | 52 | ##### AddResult 53 | 54 | |Key|Value| 55 | |---|-----| 56 | |AddResultSucessfully|0| 57 | |AddResultExists|1| 58 | |AddResultInvalidPhone|2| 59 | |AddResultDatabaseError|3| 60 | 61 | 62 | ### Roles 63 | 64 | * model.phoneNumber 65 | * model.mute 66 | * model.engine 67 | -------------------------------------------------------------------------------- /documents/sendmessageaction.md: -------------------------------------------------------------------------------- 1 | # SendMessageAction 2 | 3 | * [Component details](#component-details) 4 | * [Normal Properties](#normal-properties) 5 | * [Enumerator](#enumerator) 6 | 7 | 8 | ### Component details: 9 | 10 | |Detail|Value| 11 | |------|-----| 12 | |Import|TelegramQml 2.0| 13 | |Component|SendMessageAction| 14 | |C++ class|SendMessageActionObject| 15 | |Inherits|[TypeQObject](typeqobject.md)| 16 | |Model|No| 17 | 18 | 19 | 20 | ### Normal Properties 21 | 22 | * progress: int 23 | * core: SendMessageAction 24 | * classType: uint 25 | 26 | 27 | 28 | 29 | ### Enumerator 30 | 31 | 32 | ##### SendMessageActionClassType 33 | 34 | |Key|Value| 35 | |---|-----| 36 | |TypeSendMessageTypingAction|0| 37 | |TypeSendMessageCancelAction|1| 38 | |TypeSendMessageRecordVideoAction|2| 39 | |TypeSendMessageUploadVideoAction|3| 40 | |TypeSendMessageRecordAudioAction|4| 41 | |TypeSendMessageUploadAudioAction|5| 42 | |TypeSendMessageUploadPhotoAction|6| 43 | |TypeSendMessageUploadDocumentAction|7| 44 | |TypeSendMessageGeoLocationAction|8| 45 | |TypeSendMessageChooseContactAction|9| 46 | |TypeSendMessageGamePlayAction|10| 47 | |TypeSendMessageRecordRoundAction|11| 48 | |TypeSendMessageUploadRoundAction|12| 49 | |TypeSendMessageTypingActionSecret17|13| 50 | |TypeSendMessageCancelActionSecret17|14| 51 | |TypeSendMessageRecordVideoActionSecret17|15| 52 | |TypeSendMessageUploadVideoActionSecret17|16| 53 | |TypeSendMessageRecordAudioActionSecret17|17| 54 | |TypeSendMessageUploadAudioActionSecret17|18| 55 | |TypeSendMessageUploadPhotoActionSecret17|19| 56 | |TypeSendMessageUploadDocumentActionSecret17|20| 57 | |TypeSendMessageGeoLocationActionSecret17|21| 58 | |TypeSendMessageChooseContactActionSecret17|22| 59 | 60 | -------------------------------------------------------------------------------- /documents/sharedpointer.md: -------------------------------------------------------------------------------- 1 | # SharedPointer 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Methods](#methods) 6 | 7 | 8 | ### Component details: 9 | 10 | |Detail|Value| 11 | |------|-----| 12 | |Import|TelegramQml 2.0| 13 | |Component|SharedPointer| 14 | |C++ class|TelegramQmlSharedPointer| 15 | |Inherits|object| 16 | |Model|No| 17 | 18 | 19 | ### Required Properties 20 | 21 | * object: object 22 | 23 | 24 | 25 | ### Methods 26 | 27 | * void clean() 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /documents/start.md: -------------------------------------------------------------------------------- 1 | # TelegramQml Documents 2 | 3 | ### How to import: 4 | 5 | ```c++ 6 | import TelegramQml 2.0 7 | ``` 8 | 9 | or 10 | 11 | ```c++ 12 | import TelegramQml 2.0 as Telegram 13 | ``` 14 | 15 | ### Backward Compatible: 16 | 17 | Backward compatible components will added soon. But we suggest to user our new components and tools. 18 | 19 | ### Types 20 | 21 | Here are all components of the TelegramQml: 22 | 23 | 24 | ##### Login and Auth 25 | 26 | * [Engine](engine.md) 27 | * [App](app.md) 28 | * [Host](host.md) 29 | * [Cache](cache.md) 30 | * [AuthStore](authstore.md) 31 | * [Authenticate](authenticate.md) 32 | 33 | ##### Models 34 | 35 | * [DialogListModel](dialoglistmodel.md) 36 | * [MessageListModel](messagelistmodel.md) 37 | * [MessageSearchModel](messagesearchmodel.md) 38 | * [MediaListModel](medialistmodel.md) 39 | * [TopMessagesModel](topmessagesmodel.md) 40 | * [StickersCategoriesModel](stickerscategoriesmodel.md) 41 | * [StickersModel](stickersmodel.md) 42 | * [MembersListModel](memberslistmodel.md) 43 | * [ProfileManagerModel](profilemanagermodel.md) 44 | 45 | ##### File handler 46 | 47 | * [Image](image.md) 48 | * [DownloadHandler](downloadhandler.md) 49 | 50 | ##### Other 51 | 52 | * [MessageFetcher](messagefetcher.md) 53 | * [PeerDetails](peerdetails.md) 54 | * [NotificationHandler](notificationhandler.md) 55 | * [Status](status.md) 56 | * [StatusTyping](statustyping.md) 57 | * [MessagesFilter](messagesfilter.md) 58 | * [SendMessageAction](sendmessageaction.md) 59 | 60 | ##### Base 61 | 62 | * [TqObject](tqobject.md) 63 | * [AbstractListModel](abstractlistmodel.md) 64 | * [AbstractEngineListModel](abstractenginelistmodel.md) 65 | * [SharedPointer](sharedpointer.md) 66 | * [Enums](enums.md) 67 | -------------------------------------------------------------------------------- /documents/status.md: -------------------------------------------------------------------------------- 1 | # Status 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Methods](#methods) 7 | 8 | 9 | ### Component details: 10 | 11 | |Detail|Value| 12 | |------|-----| 13 | |Import|TelegramQml 2.0| 14 | |Component|Status| 15 | |C++ class|TelegramStatus| 16 | |Inherits|[Tq](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/tq.md)| 17 | |Model|No| 18 | 19 | 20 | ### Required Properties 21 | 22 | * engine: [Engine](engine.md) 23 | 24 | 25 | ### Normal Properties 26 | 27 | * online: boolean 28 | * typing: [StatusTyping](statustyping.md) 29 | 30 | 31 | ### Methods 32 | 33 | * void requestStatus(boolean online) 34 | * void requestTyping([InputPeer](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputpeer.md) peer, [SendMessageAction](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/sendmessageaction.md) action) 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /documents/statustyping.md: -------------------------------------------------------------------------------- 1 | # StatusTyping 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Signals](#signals) 7 | 8 | 9 | ### Component details: 10 | 11 | |Detail|Value| 12 | |------|-----| 13 | |Import|TelegramQml 2.0| 14 | |Component|StatusTyping| 15 | |C++ class|TelegramStatusTyping| 16 | |Inherits|object| 17 | |Model|No| 18 | 19 | 20 | ### Required Properties 21 | 22 | * peer: [InputPeer](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputpeer.md) 23 | 24 | 25 | ### Normal Properties 26 | 27 | * action: [SendMessageAction](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/sendmessageaction.md) 28 | 29 | 30 | 31 | ### Signals 32 | 33 | * void changed() 34 | 35 | 36 | -------------------------------------------------------------------------------- /documents/stickerscategoriesmodel.md: -------------------------------------------------------------------------------- 1 | # StickersCategoriesModel 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Roles](#roles) 7 | 8 | 9 | ### Component details: 10 | 11 | |Detail|Value| 12 | |------|-----| 13 | |Import|TelegramQml 2.0| 14 | |Component|StickersCategoriesModel| 15 | |C++ class|TelegramStickersCategoriesModel| 16 | |Inherits|[AbstractEngineListModel](abstractenginelistmodel.md)| 17 | |Model|Yes| 18 | 19 | 20 | ### Required Properties 21 | 22 | * engine: [Engine](engine.md) 23 | 24 | 25 | ### Normal Properties 26 | 27 | * refreshing: boolean (readOnly) 28 | 29 | 30 | 31 | 32 | 33 | ### Roles 34 | 35 | * model.message 36 | * model.installed 37 | * model.disabled 38 | * model.archived 39 | * model.official 40 | * model.title 41 | * model.shortName 42 | * model.count 43 | * model.hash 44 | * model.inputItem 45 | * model.documentItems 46 | -------------------------------------------------------------------------------- /documents/stickersmodel.md: -------------------------------------------------------------------------------- 1 | # StickersModel 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Enumerator](#enumerator) 7 | * [Methods](#methods) 8 | * [Roles](#roles) 9 | 10 | 11 | ### Component details: 12 | 13 | |Detail|Value| 14 | |------|-----| 15 | |Import|TelegramQml 2.0| 16 | |Component|StickersModel| 17 | |C++ class|TelegramStickersModel| 18 | |Inherits|[AbstractEngineListModel](abstractenginelistmodel.md)| 19 | |Model|Yes| 20 | 21 | 22 | ### Required Properties 23 | 24 | * engine: [Engine](engine.md) 25 | * documents: list<variant> 26 | 27 | 28 | ### Normal Properties 29 | 30 | * refreshing: boolean (readOnly) 31 | * shortName: string 32 | * stickerSet: [InputStickerSet](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputstickerset.md) 33 | 34 | 35 | ### Methods 36 | 37 | * void showRecents() 38 | * void addToRecents([Document](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/document.md) doc) 39 | 40 | 41 | 42 | ### Enumerator 43 | 44 | 45 | ##### DialogsRoles 46 | 47 | |Key|Value| 48 | |---|-----| 49 | |RoleDocument|256| 50 | |RoleAlt|257| 51 | 52 | 53 | ### Roles 54 | 55 | * model.document 56 | * model.alt 57 | -------------------------------------------------------------------------------- /documents/topmessagesmodel.md: -------------------------------------------------------------------------------- 1 | # TopMessagesModel 2 | 3 | * [Component details](#component-details) 4 | * [Required Properties](#required-properties) 5 | * [Normal Properties](#normal-properties) 6 | * [Enumerator](#enumerator) 7 | * [Methods](#methods) 8 | * [Roles](#roles) 9 | 10 | 11 | ### Component details: 12 | 13 | |Detail|Value| 14 | |------|-----| 15 | |Import|TelegramQml 2.0| 16 | |Component|TopMessagesModel| 17 | |C++ class|TelegramTopMessagesModel| 18 | |Inherits|[MessageListModel](messagelistmodel.md)| 19 | |Model|Yes| 20 | 21 | 22 | ### Required Properties 23 | 24 | * engine: [Engine](engine.md) 25 | * currentPeer: [InputPeer](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/inputpeer.md) 26 | 27 | 28 | ### Normal Properties 29 | 30 | * dialogsLimit: int 31 | * visibleType: int 32 | 33 | 34 | ### Methods 35 | 36 | * void recheck() 37 | 38 | 39 | 40 | ### Enumerator 41 | 42 | 43 | ##### VisibleTypes 44 | 45 | |Key|Value| 46 | |---|-----| 47 | |VisibleTypeNone|0| 48 | |VisibleTypeChannel|1| 49 | |VisibleTypeChat|2| 50 | |VisibleTypeUser|4| 51 | |VisibleTypeMegaGroup|8| 52 | |VisibleTypeAll|15| 53 | 54 | 55 | ### Roles 56 | 57 | * model.item 58 | * model.mediaItem 59 | * model.serviceItem 60 | * model.markupItem 61 | * model.entityList 62 | * model.fromUserItem 63 | * model.toUserItem 64 | * model.toChatItem 65 | * model.toPeerItem 66 | * model.message 67 | * model.dateTime 68 | * model.date 69 | * model.unread 70 | * model.sent 71 | * model.out 72 | * model.replyMsgId 73 | * model.replyMessage 74 | * model.replyPeer 75 | * model.forwardFromPeer 76 | * model.forwardDate 77 | * model.messageType 78 | * model.replyType 79 | * model.fileName 80 | * model.fileMimeType 81 | * model.fileTitle 82 | * model.filePerformer 83 | * model.fileDuration 84 | * model.fileIsVoice 85 | * model.fileSize 86 | * model.downloadable 87 | * model.uploading 88 | * model.downloading 89 | * model.transfaring 90 | * model.transfared 91 | * model.transfaredSize 92 | * model.totalSize 93 | * model.filePath 94 | * model.thumbPath 95 | -------------------------------------------------------------------------------- /documents/tqobject.md: -------------------------------------------------------------------------------- 1 | # TqObject 2 | 3 | * [Component details](#component-details) 4 | * [Normal Properties](#normal-properties) 5 | 6 | 7 | ### Component details: 8 | 9 | |Detail|Value| 10 | |------|-----| 11 | |Import|TelegramQml 2.0| 12 | |Component|TqObject| 13 | |C++ class|TqObject| 14 | |Inherits|object| 15 | |Model|No| 16 | 17 | 18 | 19 | ### Normal Properties 20 | 21 | * errorText: string (readOnly) 22 | * errorCode: int (readOnly) 23 | * items: [QQmlListProperty](https://github.com/Aseman-Land/libqtelegram-aseman-edition/blob/API51/telegram/documents/types/qqmllistproperty.md) (readOnly) 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /files/tg-server.pub: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PUBLIC KEY----- 2 | MIIBCgKCAQEAwVACPi9w23mF3tBkdZz+zwrzKOaaQdr01vAbU4E1pvkfj4sqDsm6 3 | lyDONS789sVoD/xCS9Y0hkkC3gtL1tSfTlgCMOOul9lcixlEKzwKENj1Yz/s7daS 4 | an9tqw3bfUV/nqgbhGX81v/+7RFAEd+RwFnK7a+XYl9sluzHRyVVaTTveB2GazTw 5 | Efzk2DWgkBluml8OREmvfraX3bkHZJTKX4EQSjBbbdJ2ZXIsRrYOXfaA+xayEGB+ 6 | 8hdlLmAjbCVfaigxX0CDqWeR1yFL9kwd9P0NsZRPsmoqVwMbMu7mStFai6aIhc3n 7 | Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB 8 | -----END RSA PUBLIC KEY----- 9 | 10 | -------------------------------------------------------------------------------- /objects/ThemeItem.vco: -------------------------------------------------------------------------------- 1 | #TelegramThemeObject 2 | 3 | include "asemantools/asemanquickobject.h"; 4 | include ; 5 | include ; 6 | include ; 7 | 8 | object ThemeItem { 9 | QString themeName rw; 10 | QString author rw; 11 | QString copyright rw; 12 | QString homePage rw; 13 | 14 | QColor masterColor rw; 15 | bool visualEffects rw = true; 16 | 17 | QColor dialogListBackground rw; 18 | QColor dialogListFontColor rw; 19 | QColor dialogListShadowColor rw; 20 | QFont dialogListFont rw; 21 | qreal dialogListWidth rw = 275; 22 | bool dialogListLightIcon rw = false; 23 | QColor dialogListScrollColor rw; 24 | qreal dialogListScrollWidth rw = 6; 25 | qreal dialogListShadowWidth rw = 5; 26 | QColor dialogListDateColor rw; 27 | QFont dialogListDateFont rw; 28 | QColor dialogListMessageColor rw; 29 | QFont dialogListMessageFont rw; 30 | QColor dialogPointerColor rw; 31 | qreal dialogPointerHeight rw = 16; 32 | QColor dialogListHighlightColor rw; 33 | QColor dialogListHighlightTextColor rw; 34 | QColor dialogListHighlightDateColor rw; 35 | QColor dialogListHighlightMessageColor rw; 36 | 37 | QColor searchBarColor rw; 38 | QColor searchBarFocusedColor rw; 39 | QColor searchBarTextColor rw; 40 | QColor searchBarPlaceholderColor rw; 41 | QFont searchBarFont rw; 42 | 43 | QColor sendFrameColor rw; 44 | QColor sendFrameShadowColor rw; 45 | qreal sendFrameShadowSize rw; 46 | bool sendFrameLightIcon rw = false; 47 | QColor sendFrameFontColor rw; 48 | QColor sendFrameFontHighlightColor rw; 49 | QFont sendFrameFont rw; 50 | qreal sendFrameHeight rw = 40; 51 | 52 | QColor messageIncomingColor rw; 53 | QColor messageIncomingFontColor rw; 54 | QColor messageIncomingNameColor rw; 55 | QColor messageIncomingDateColor rw; 56 | bool messageIncomingLightIcon rw = false; 57 | QColor messageOutgoingColor rw; 58 | QColor messageOutgoingFontColor rw; 59 | QColor messageOutgoingNameColor rw; 60 | QColor messageOutgoingDateColor rw; 61 | bool messageOutgoingLightIcon rw = false; 62 | QColor messageMediaColor rw; 63 | QColor messageMediaNameColor rw; 64 | QColor messageMediaDateColor rw; 65 | bool messageMediaLightIcon rw = false; 66 | qreal messageRadius rw = 5; 67 | bool messageShadow rw = true; 68 | qreal messageShadowSize rw = 2; 69 | QColor messageShadowColor rw; 70 | qreal messagePointerHeight rw = 15; 71 | 72 | QColor headerColor rw; 73 | QColor headerTitleColor rw; 74 | QFont headerTitleFont rw; 75 | QColor headerDateColor rw; 76 | QFont headerDateFont rw; 77 | bool headerLightIcon rw = false; 78 | QColor headerSecretColor rw; 79 | QColor headerSecretTitleColor rw; 80 | QFont headerSecretTitleFont rw; 81 | QColor headerSecretDateColor rw; 82 | QFont headerSecretDateFont rw; 83 | bool headerSecretLightIcon rw = false; 84 | qreal headerHeight rw = 50; 85 | 86 | QColor panelColor rw; 87 | bool panelLightIcon rw = true; 88 | qreal panelPointerHeight rw = 12; 89 | QColor panelTooltipBackground rw; 90 | QColor panelTooltipTextColor rw; 91 | QColor panelShadowColor rw; 92 | qreal panelShadowWidth rw = 5; 93 | 94 | QColor sidebarColor rw; 95 | QColor sidebarFontColor rw; 96 | QFont sidebarFont rw; 97 | QColor sidebarPhoneBackground rw; 98 | QColor sidebarPhoneColor rw; 99 | QFont sidebarPhoneFont rw; 100 | } 101 | -------------------------------------------------------------------------------- /objects/templates/class.template: -------------------------------------------------------------------------------- 1 | class %nameObject : public QObject 2 | { 3 | Q_OBJECT 4 | %properties 5 | public: 6 | %nameObject(const %name & another, QObject *parent = 0) : QObject(parent){ 7 | (void)another; 8 | %presets 9 | } 10 | %nameObject(QObject *parent = 0) : QObject(parent){} 11 | ~%nameObject(){} 12 | 13 | %body 14 | 15 | void operator= ( const %name & another) { 16 | %equals 17 | } 18 | 19 | signals: 20 | void changed(); 21 | %notifies 22 | private: 23 | %variables 24 | }; 25 | 26 | Q_DECLARE_METATYPE(%nameObject*) 27 | 28 | %next -------------------------------------------------------------------------------- /objects/templates/equals.template: -------------------------------------------------------------------------------- 1 | %pointerflag_%name = another.%name(); 2 | emit %nameChanged(); 3 | %equals -------------------------------------------------------------------------------- /objects/templates/file.template: -------------------------------------------------------------------------------- 1 | %includes 2 | %classes 3 | 4 | static bool initialize() { 5 | %intializes 6 | qmlRegisterType("CutegramTypes", 1, 0, "PhotoSizeList"); 7 | qRegisterMetaType("PhotoSizeList*"); 8 | 9 | qmlRegisterType("CutegramTypes", 1, 0, "ChatParticipantList"); 10 | qRegisterMetaType("ChatParticipantList*"); 11 | 12 | return true; 13 | } 14 | static bool initialized = false; 15 | -------------------------------------------------------------------------------- /objects/templates/initialize.template: -------------------------------------------------------------------------------- 1 | qmlRegisterType<%nameObject>("CutegramTypes", 1, 0, "%name"); 2 | qRegisterMetaType<%nameObject*>("%nameObject*"); 3 | 4 | %intializes -------------------------------------------------------------------------------- /old/backgroundmanager.cpp: -------------------------------------------------------------------------------- 1 | #include "backgroundmanager.h" 2 | #include "objects/types.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class BackgroundManagerPrivate 11 | { 12 | public: 13 | QUrl directory; 14 | QPointer dialog; 15 | QUrl background; 16 | }; 17 | 18 | BackgroundManager::BackgroundManager(QObject *parent) : 19 | QObject(parent) 20 | { 21 | p = new BackgroundManagerPrivate; 22 | } 23 | 24 | void BackgroundManager::setDirectory(const QUrl &path) 25 | { 26 | if(p->directory == path) 27 | return; 28 | 29 | p->directory = path; 30 | 31 | QDir().mkpath(p->directory.toLocalFile()); 32 | Q_EMIT directoryChanged(); 33 | 34 | refresh(); 35 | } 36 | 37 | QUrl BackgroundManager::directory() const 38 | { 39 | return p->directory; 40 | } 41 | 42 | void BackgroundManager::setDialog(DialogObject *dialog) 43 | { 44 | if(p->dialog == dialog) 45 | return; 46 | 47 | p->dialog = dialog; 48 | Q_EMIT dialogChanged(); 49 | 50 | refresh(); 51 | } 52 | 53 | DialogObject *BackgroundManager::dialog() const 54 | { 55 | return p->dialog; 56 | } 57 | 58 | QUrl BackgroundManager::background() const 59 | { 60 | return p->background; 61 | } 62 | 63 | qint64 BackgroundManager::dialogId() 64 | { 65 | if(!p->dialog || p->directory.isEmpty()) 66 | return 0; 67 | 68 | qint64 dId = p->dialog->peer()->chatId()? p->dialog->peer()->chatId() : 69 | p->dialog->peer()->userId(); 70 | if(!dId) 71 | return 0; 72 | 73 | return dId; 74 | } 75 | 76 | void BackgroundManager::setBackground(const QString &filePath) 77 | { 78 | const qint64 dId = dialogId(); 79 | if(!dId) 80 | { 81 | p->background = QUrl(); 82 | Q_EMIT backgroundChanged(); 83 | return; 84 | } 85 | 86 | const QString dIdStr = QString::number(dId); 87 | const QStringList &files = QDir(p->directory.toLocalFile()).entryList(QDir::Files); 88 | Q_FOREACH(const QString &f, files) 89 | { 90 | const QString path = p->directory.toLocalFile() + "/" + f; 91 | QFileInfo info(path); 92 | if(info.baseName() != dIdStr) 93 | continue; 94 | 95 | QFile::remove(path); 96 | } 97 | 98 | if(!filePath.isEmpty()) 99 | { 100 | QFileInfo inf(filePath); 101 | QFile::copy(filePath, p->directory.toLocalFile() + "/" + dIdStr + "." + inf.suffix()); 102 | } 103 | 104 | refresh(); 105 | } 106 | 107 | void BackgroundManager::refresh() 108 | { 109 | const qint64 dId = dialogId(); 110 | if(!dId) 111 | { 112 | p->background = QUrl(); 113 | Q_EMIT backgroundChanged(); 114 | return; 115 | } 116 | 117 | QString filePath; 118 | const QString dIdStr = QString::number(dId); 119 | const QStringList &files = QDir(p->directory.toLocalFile()).entryList(QDir::Files); 120 | Q_FOREACH(const QString &f, files) 121 | { 122 | const QString path = p->directory.toLocalFile() + "/" + f; 123 | QFileInfo info(path); 124 | if(info.baseName() != dIdStr) 125 | continue; 126 | 127 | filePath = path; 128 | break; 129 | } 130 | 131 | p->background = filePath.isEmpty()? QUrl() : QUrl::fromLocalFile(filePath); 132 | Q_EMIT backgroundChanged(); 133 | } 134 | 135 | BackgroundManager::~BackgroundManager() 136 | { 137 | delete p; 138 | } 139 | 140 | -------------------------------------------------------------------------------- /old/backgroundmanager.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKGROUNDMANAGER_H 2 | #define BACKGROUNDMANAGER_H 3 | 4 | #include "telegramqml_global.h" 5 | 6 | #include 7 | #include 8 | 9 | class DialogObject; 10 | class BackgroundManagerPrivate; 11 | class TELEGRAMQMLSHARED_EXPORT BackgroundManager : public QObject 12 | { 13 | Q_OBJECT 14 | Q_PROPERTY(QUrl directory READ directory WRITE setDirectory NOTIFY directoryChanged) 15 | Q_PROPERTY(DialogObject* dialog READ dialog WRITE setDialog NOTIFY dialogChanged) 16 | Q_PROPERTY(QUrl background READ background NOTIFY backgroundChanged) 17 | 18 | public: 19 | BackgroundManager(QObject *parent = 0); 20 | ~BackgroundManager(); 21 | 22 | void setDirectory(const QUrl &path); 23 | QUrl directory() const; 24 | 25 | void setDialog(DialogObject *dialog); 26 | DialogObject *dialog() const; 27 | 28 | QUrl background() const; 29 | qint64 dialogId(); 30 | 31 | public Q_SLOTS: 32 | void setBackground(const QString &filePath); 33 | 34 | Q_SIGNALS: 35 | void directoryChanged(); 36 | void dialogChanged(); 37 | void backgroundChanged(); 38 | 39 | private: 40 | void refresh(); 41 | 42 | private: 43 | BackgroundManagerPrivate *p; 44 | }; 45 | 46 | #endif // BACKGROUNDMANAGER_H 47 | -------------------------------------------------------------------------------- /old/chatparticipantlist.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 Aseman 3 | http://aseman.co 4 | 5 | This project is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This project is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "chatparticipantlist.h" 20 | #include "objects/types.h" 21 | 22 | 23 | 24 | class ChatParticipantListPrivate 25 | { 26 | public: 27 | QList list; 28 | }; 29 | 30 | ChatParticipantList::ChatParticipantList(QObject *parent) : 31 | QObject(parent) 32 | { 33 | p = new ChatParticipantListPrivate; 34 | } 35 | 36 | ChatParticipantList::ChatParticipantList(const QList &another, QObject *parent) : 37 | QObject(parent) 38 | { 39 | p = new ChatParticipantListPrivate; 40 | operator =(another); 41 | } 42 | 43 | void ChatParticipantList::operator =(const QList &another) 44 | { 45 | Q_FOREACH( ChatParticipantObject *obj, p->list ) 46 | obj->deleteLater(); 47 | 48 | p->list.clear(); 49 | 50 | Q_FOREACH( const ChatParticipant & size, another ) 51 | { 52 | ChatParticipantObject *obj = new ChatParticipantObject(size, this); 53 | p->list << obj; 54 | } 55 | 56 | Q_EMIT firstChanged(); 57 | Q_EMIT lastChanged(); 58 | Q_EMIT countChanged(); 59 | } 60 | 61 | QList ChatParticipantList::userIds() const 62 | { 63 | QList results; 64 | Q_FOREACH( ChatParticipantObject *obj, p->list ) 65 | results << obj->userId(); 66 | 67 | return results; 68 | } 69 | 70 | ChatParticipantObject *ChatParticipantList::first() const 71 | { 72 | if( p->list.isEmpty() ) 73 | return 0; 74 | 75 | return p->list.first(); 76 | } 77 | 78 | ChatParticipantObject *ChatParticipantList::last() const 79 | { 80 | if( p->list.isEmpty() ) 81 | return 0; 82 | 83 | return p->list.last(); 84 | } 85 | 86 | int ChatParticipantList::count() const 87 | { 88 | return p->list.count(); 89 | } 90 | 91 | ChatParticipantObject *ChatParticipantList::at(int idx) 92 | { 93 | return p->list.at(idx); 94 | } 95 | 96 | ChatParticipantList::~ChatParticipantList() 97 | { 98 | delete p; 99 | } 100 | -------------------------------------------------------------------------------- /old/chatparticipantlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 Aseman 3 | http://aseman.co 4 | 5 | This project is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This project is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef CHATPARTICIPANTLIST_H 20 | #define CHATPARTICIPANTLIST_H 21 | 22 | #include "telegramqml_global.h" 23 | 24 | #include 25 | 26 | class ChatParticipant; 27 | class ChatParticipantObject; 28 | class ChatParticipantListPrivate; 29 | class TELEGRAMQMLSHARED_EXPORT ChatParticipantList : public QObject 30 | { 31 | Q_OBJECT 32 | Q_PROPERTY(int count READ count NOTIFY countChanged) 33 | public: 34 | ChatParticipantList(QObject *parent = 0); 35 | ChatParticipantList(const QList & another, QObject *parent = 0); 36 | ~ChatParticipantList(); 37 | 38 | void operator =( const QList & another ); 39 | QList userIds() const; 40 | 41 | ChatParticipantObject *first() const; 42 | ChatParticipantObject *last() const; 43 | 44 | int count() const; 45 | 46 | public Q_SLOTS: 47 | ChatParticipantObject *at( int idx ); 48 | 49 | Q_SIGNALS: 50 | void firstChanged(); 51 | void lastChanged(); 52 | void countChanged(); 53 | 54 | private: 55 | ChatParticipantListPrivate *p; 56 | }; 57 | 58 | Q_DECLARE_METATYPE(ChatParticipantList*) 59 | 60 | #endif // CHATPARTICIPANTLIST_H 61 | -------------------------------------------------------------------------------- /old/database.h: -------------------------------------------------------------------------------- 1 | #ifndef DATABASE_H 2 | #define DATABASE_H 3 | 4 | #include 5 | 6 | #include "telegramqml_global.h" 7 | #include "databaseabstractencryptor.h" 8 | 9 | class Peer; 10 | class Message; 11 | class User; 12 | class Dialog; 13 | class Contact; 14 | class Chat; 15 | class DbUser; 16 | class DbDialog; 17 | class DbMessage; 18 | class DbContact; 19 | class DbChat; 20 | class DatabasePrivate; 21 | class TELEGRAMQMLSHARED_EXPORT Database : public QObject 22 | { 23 | Q_OBJECT 24 | Q_PROPERTY(QString phoneNumber READ phoneNumber WRITE setPhoneNumber NOTIFY phoneNumberChanged) 25 | Q_PROPERTY(QString configPath READ configPath WRITE setConfigPath NOTIFY configPathChanged) 26 | 27 | public: 28 | Database(QObject *parent = 0); 29 | ~Database(); 30 | 31 | void setPhoneNumber(const QString &phoneNumber); 32 | QString phoneNumber() const; 33 | 34 | void setConfigPath(const QString &path); 35 | QString configPath() const; 36 | 37 | void setEncrypter(DatabaseAbstractEncryptor *encrypter); 38 | DatabaseAbstractEncryptor *encrypter() const; 39 | 40 | public Q_SLOTS: 41 | void insertUser(const User &user); 42 | void insertChat(const Chat &chat); 43 | void insertDialog(const Dialog &dialog, bool encrypted); 44 | void insertContact(const Contact &contact); 45 | void insertMessage(const Message &message, bool encrypted); 46 | void insertMediaEncryptedKeys(qint64 mediaId, const QByteArray &key, const QByteArray &iv); 47 | 48 | void updateUnreadCount(qint64 chatId, int unreadCount); 49 | 50 | void readFullDialogs(); 51 | void readMessages(const Peer &peer, int offset, int limit); 52 | void markMessagesAsRead(const QList& messages); 53 | void markMessagesAsReadFromMaxDate(qint32 chatId, qint32 maxDate); 54 | 55 | void deleteMessage(qint64 msgId); 56 | void deleteDialog(qint64 dlgId); 57 | void deleteHistory(qint64 dlgId); 58 | 59 | void blockUser(qint64 userId); 60 | void unblockUser(qint64 userId); 61 | 62 | Q_SIGNALS: 63 | void userFounded(const User &user); 64 | void chatFounded(const Chat &chat); 65 | void dialogFounded(const Dialog &dialog, bool encrypted); 66 | void contactFounded(const Contact &contact); 67 | void messageFounded(const Message &message); 68 | void mediaKeyFounded(qint64 mediaId, const QByteArray &key, const QByteArray &iv); 69 | void phoneNumberChanged(); 70 | void configPathChanged(); 71 | 72 | private Q_SLOTS: 73 | void userFounded_slt(const DbUser &user); 74 | void chatFounded_slt(const DbChat &chat); 75 | void dialogFounded_slt(const DbDialog &dialog, bool encrypted); 76 | void messageFounded_slt(const DbMessage &message); 77 | void contactFounded_slt(const DbContact &contact); 78 | 79 | private: 80 | void refresh(); 81 | 82 | private: 83 | DatabasePrivate *p; 84 | }; 85 | 86 | #endif // DATABASE_H 87 | -------------------------------------------------------------------------------- /old/databaseabstractencryptor.cpp: -------------------------------------------------------------------------------- 1 | #include "databaseabstractencryptor.h" 2 | 3 | DatabaseAbstractEncryptor::DatabaseAbstractEncryptor() 4 | { 5 | qRegisterMetaType("DatabaseAbstractEncryptor*"); 6 | } 7 | 8 | DatabaseAbstractEncryptor::~DatabaseAbstractEncryptor() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /old/databaseabstractencryptor.h: -------------------------------------------------------------------------------- 1 | #ifndef DATABASEABSTRACTENCRYPTOR_H 2 | #define DATABASEABSTRACTENCRYPTOR_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "telegramqml_global.h" 10 | 11 | class TELEGRAMQMLSHARED_EXPORT DatabaseAbstractEncryptor 12 | { 13 | public: 14 | DatabaseAbstractEncryptor(); 15 | virtual ~DatabaseAbstractEncryptor(); 16 | 17 | virtual QVariant encrypt(const QString &text, bool encryptedMessage) = 0; // Thread safe function 18 | virtual QString decrypt(const QVariant &data) = 0; // Thread safe function 19 | }; 20 | 21 | Q_DECLARE_METATYPE(DatabaseAbstractEncryptor*) 22 | 23 | #endif // DATABASEABSTRACTENCRYPTOR_H 24 | -------------------------------------------------------------------------------- /old/dialogfilesmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef DIALOGFILESMODEL_H 2 | #define DIALOGFILESMODEL_H 3 | 4 | #include "telegramqml_global.h" 5 | #include "tgabstractlistmodel.h" 6 | 7 | class DialogObject; 8 | class TelegramQml; 9 | class DialogFilesModelPrivate; 10 | class TELEGRAMQMLSHARED_EXPORT DialogFilesModel : public TgAbstractListModel 11 | { 12 | Q_OBJECT 13 | Q_ENUMS(FileRoles) 14 | 15 | Q_PROPERTY(TelegramQml* telegram READ telegram WRITE setTelegram NOTIFY telegramChanged) 16 | Q_PROPERTY(DialogObject* dialog READ dialog WRITE setDialog NOTIFY dialogChanged) 17 | Q_PROPERTY(int count READ count NOTIFY countChanged) 18 | 19 | public: 20 | enum FileRoles { 21 | NameRole = Qt::UserRole, 22 | PathRole, 23 | ThumbnailRole, 24 | SuffixRole 25 | }; 26 | 27 | DialogFilesModel(QObject *parent = 0); 28 | ~DialogFilesModel(); 29 | 30 | TelegramQml *telegram() const; 31 | void setTelegram(TelegramQml *tg ); 32 | 33 | DialogObject *dialog() const; 34 | void setDialog( DialogObject *dlg ); 35 | 36 | QString id( const QModelIndex &index ) const; 37 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 38 | 39 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 40 | 41 | QHash roleNames() const; 42 | 43 | int count() const; 44 | 45 | public Q_SLOTS: 46 | void refresh(); 47 | 48 | Q_SIGNALS: 49 | void telegramChanged(); 50 | void countChanged(); 51 | void dialogChanged(); 52 | 53 | private: 54 | QString dirPath() const; 55 | 56 | private: 57 | DialogFilesModelPrivate *p; 58 | }; 59 | 60 | #endif // DIALOGFILESMODEL_H 61 | -------------------------------------------------------------------------------- /old/documentattributelist.cpp: -------------------------------------------------------------------------------- 1 | #include "documentattributelist.h" 2 | #include "objects/types.h" 3 | 4 | class DocumentAttributeListPrivate 5 | { 6 | public: 7 | QList list; 8 | }; 9 | 10 | DocumentAttributeList::DocumentAttributeList(QObject *parent) : 11 | QObject(parent) 12 | { 13 | p = new DocumentAttributeListPrivate; 14 | } 15 | 16 | DocumentAttributeList::DocumentAttributeList(const QList & another, QObject *parent) : 17 | QObject(parent) 18 | { 19 | p = new DocumentAttributeListPrivate; 20 | operator =(another); 21 | } 22 | 23 | void DocumentAttributeList::operator =(const QList &another) 24 | { 25 | while(!p->list.isEmpty()) 26 | p->list.takeFirst()->deleteLater(); 27 | 28 | Q_FOREACH( const DocumentAttribute & size, another ) 29 | { 30 | DocumentAttributeObject *obj = new DocumentAttributeObject(size, this); 31 | p->list << obj; 32 | } 33 | 34 | Q_EMIT firstChanged(); 35 | Q_EMIT lastChanged(); 36 | Q_EMIT countChanged(); 37 | } 38 | 39 | DocumentAttributeObject *DocumentAttributeList::first() const 40 | { 41 | if( p->list.isEmpty() ) 42 | return 0; 43 | 44 | return p->list.first(); 45 | } 46 | 47 | DocumentAttributeObject *DocumentAttributeList::last() const 48 | { 49 | if( p->list.isEmpty() ) 50 | return 0; 51 | 52 | return p->list.last(); 53 | } 54 | 55 | int DocumentAttributeList::count() const 56 | { 57 | return p->list.count(); 58 | } 59 | 60 | DocumentAttributeObject *DocumentAttributeList::at(int idx) 61 | { 62 | return p->list.at(idx); 63 | } 64 | 65 | DocumentAttributeList::~DocumentAttributeList() 66 | { 67 | delete p; 68 | } 69 | -------------------------------------------------------------------------------- /old/documentattributelist.h: -------------------------------------------------------------------------------- 1 | #ifndef DOCUMENTATTRIBUTELIST_H 2 | #define DOCUMENTATTRIBUTELIST_H 3 | 4 | #include 5 | 6 | #include "telegramqml_global.h" 7 | 8 | class DocumentAttribute; 9 | class DocumentAttributeObject; 10 | class DocumentAttributeListPrivate; 11 | class TELEGRAMQMLSHARED_EXPORT DocumentAttributeList : public QObject 12 | { 13 | Q_OBJECT 14 | 15 | Q_PROPERTY(DocumentAttributeObject* first READ first NOTIFY firstChanged) 16 | Q_PROPERTY(DocumentAttributeObject* last READ last NOTIFY lastChanged) 17 | Q_PROPERTY(int count READ count NOTIFY countChanged) 18 | 19 | public: 20 | DocumentAttributeList(QObject *parent = 0); 21 | DocumentAttributeList(const QList & another, QObject *parent = 0); 22 | ~DocumentAttributeList(); 23 | 24 | void operator =( const QList & another ); 25 | 26 | DocumentAttributeObject *first() const; 27 | DocumentAttributeObject *last() const; 28 | 29 | int count() const; 30 | 31 | public Q_SLOTS: 32 | DocumentAttributeObject *at( int idx ); 33 | 34 | Q_SIGNALS: 35 | void firstChanged(); 36 | void lastChanged(); 37 | void countChanged(); 38 | 39 | private: 40 | DocumentAttributeListPrivate *p; 41 | }; 42 | 43 | Q_DECLARE_METATYPE(DocumentAttributeList*) 44 | 45 | #endif // DOCUMENTATTRIBUTELIST_H 46 | -------------------------------------------------------------------------------- /old/mp3converterengine.cpp: -------------------------------------------------------------------------------- 1 | #include "mp3converterengine.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class MP3ConverterEnginePrivate 9 | { 10 | public: 11 | QPointer process; 12 | QString source; 13 | QString destination; 14 | }; 15 | 16 | MP3ConverterEngine::MP3ConverterEngine(QObject *parent) : 17 | QObject(parent) 18 | { 19 | p = new MP3ConverterEnginePrivate; 20 | p->process = 0; 21 | } 22 | 23 | void MP3ConverterEngine::setSource(const QString &source) 24 | { 25 | if(p->source == source) 26 | return; 27 | 28 | p->source = source; 29 | Q_EMIT sourceChanged(); 30 | } 31 | 32 | QString MP3ConverterEngine::source() const 33 | { 34 | return p->source; 35 | } 36 | 37 | void MP3ConverterEngine::setDestination(const QString &destination) 38 | { 39 | if(p->destination == destination) 40 | return; 41 | 42 | p->destination = destination; 43 | Q_EMIT destinationChanged(); 44 | } 45 | 46 | QString MP3ConverterEngine::destination() const 47 | { 48 | return p->destination; 49 | } 50 | 51 | bool MP3ConverterEngine::running() const 52 | { 53 | return p->process; 54 | } 55 | 56 | void MP3ConverterEngine::start() 57 | { 58 | if(p->process) 59 | return; 60 | 61 | QStringList args; 62 | args << "-i"; 63 | args << p->source; 64 | args << "-acodec"; 65 | args << "libmp3lame"; 66 | args << "-ac"; 67 | args << "2"; 68 | args << "-ab"; 69 | args << "64k"; 70 | args << "-ar"; 71 | args << "44100"; 72 | args << p->destination; 73 | 74 | QString ffmpegPath; 75 | #ifdef Q_OS_WIN 76 | ffmpegPath = QCoreApplication::applicationDirPath() + "/ffmpeg.exe"; 77 | #else 78 | #ifdef Q_OS_MAC 79 | ffmpegPath = QCoreApplication::applicationDirPath() + "/ffmpeg"; 80 | #else 81 | if(QFileInfo::exists("/usr/bin/avconv")) 82 | ffmpegPath = "/usr/bin/avconv"; 83 | else 84 | ffmpegPath = "ffmpeg"; 85 | #endif 86 | #endif 87 | 88 | p->process = new QProcess(this); 89 | 90 | connect(p->process, SIGNAL(error(QProcess::ProcessError)), SIGNAL(error())); 91 | connect(p->process, SIGNAL(finished(int)), SLOT(finished_prv())); 92 | 93 | p->process->start(ffmpegPath, args); 94 | Q_EMIT runningChanged(); 95 | } 96 | 97 | void MP3ConverterEngine::finished_prv() 98 | { 99 | p->process->deleteLater(); 100 | p->process = 0; 101 | 102 | Q_EMIT finished(); 103 | Q_EMIT runningChanged(); 104 | } 105 | 106 | MP3ConverterEngine::~MP3ConverterEngine() 107 | { 108 | delete p; 109 | } 110 | 111 | -------------------------------------------------------------------------------- /old/mp3converterengine.h: -------------------------------------------------------------------------------- 1 | #ifndef MP3CONVERTERENGINE_H 2 | #define MP3CONVERTERENGINE_H 3 | 4 | #include 5 | 6 | #include "telegramqml_global.h" 7 | 8 | class MP3ConverterEnginePrivate; 9 | class TELEGRAMQMLSHARED_EXPORT MP3ConverterEngine : public QObject 10 | { 11 | Q_OBJECT 12 | Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged) 13 | Q_PROPERTY(QString destination READ destination WRITE setDestination NOTIFY destinationChanged) 14 | Q_PROPERTY(bool running READ running NOTIFY runningChanged) 15 | 16 | public: 17 | MP3ConverterEngine(QObject *parent = 0); 18 | ~MP3ConverterEngine(); 19 | 20 | void setSource(const QString &source); 21 | QString source() const; 22 | 23 | void setDestination(const QString &destination); 24 | QString destination() const; 25 | 26 | bool running() const; 27 | 28 | public Q_SLOTS: 29 | void start(); 30 | 31 | Q_SIGNALS: 32 | void sourceChanged(); 33 | void destinationChanged(); 34 | void finished(); 35 | void error(); 36 | void runningChanged(); 37 | 38 | private Q_SLOTS: 39 | void finished_prv(); 40 | 41 | private: 42 | MP3ConverterEnginePrivate *p; 43 | }; 44 | 45 | #endif // MP3CONVERTERENGINE_H 46 | -------------------------------------------------------------------------------- /old/newsletterdialog.cpp: -------------------------------------------------------------------------------- 1 | #define CUTEGRAM_DIALOG_ID INT_MAX-100 2 | 3 | #include "newsletterdialog.h" 4 | 5 | qint32 NewsLetterDialog::cutegramId() 6 | { 7 | return CUTEGRAM_DIALOG_ID; 8 | } 9 | -------------------------------------------------------------------------------- /old/newsletterdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef NEWSLETTERDIALOG_H 2 | #define NEWSLETTERDIALOG_H 3 | 4 | #include "telegramqml_global.h" 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | class Dialog; 11 | class User; 12 | class Message; 13 | class TELEGRAMQMLSHARED_EXPORT NewsLetterDialog : public QObject 14 | { 15 | Q_OBJECT 16 | public Q_SLOTS: 17 | virtual Dialog dialog() const = 0; 18 | virtual User user() const = 0; 19 | 20 | virtual void check() = 0; 21 | static qint32 cutegramId(); 22 | 23 | Q_SIGNALS: 24 | void incomingMessage(const Message &msg, const Dialog &dialog); 25 | }; 26 | 27 | #endif // NEWSLETTERDIALOG_H 28 | -------------------------------------------------------------------------------- /old/photosizelist.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 Aseman 3 | http://aseman.co 4 | 5 | This project is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This project is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "photosizelist.h" 20 | #include "objects/types.h" 21 | 22 | class PhotoSizeListPrivate 23 | { 24 | public: 25 | QList list; 26 | }; 27 | 28 | PhotoSizeList::PhotoSizeList(QObject *parent) : 29 | QObject(parent) 30 | { 31 | p = new PhotoSizeListPrivate; 32 | } 33 | 34 | PhotoSizeList::PhotoSizeList(const QList & another, QObject *parent) : 35 | QObject(parent) 36 | { 37 | p = new PhotoSizeListPrivate; 38 | operator =(another); 39 | } 40 | 41 | void PhotoSizeList::operator =(const QList &another) 42 | { 43 | Q_FOREACH( const PhotoSize & size, another ) 44 | { 45 | bool containt = false; 46 | for( int i=0; ilist.count(); i++ ) 47 | { 48 | PhotoSizeObject *tmp = p->list.at(i); 49 | if( tmp->location()->localId() != size.location().localId() || 50 | tmp->location()->dcId() != size.location().dcId() || 51 | tmp->location()->volumeId() != size.location().volumeId() || 52 | tmp->location()->secret() != size.location().secret() ) 53 | continue; 54 | 55 | containt = true; 56 | break; 57 | } 58 | if( containt ) 59 | continue; 60 | 61 | PhotoSizeObject *obj = new PhotoSizeObject(size, this); 62 | p->list << obj; 63 | } 64 | 65 | Q_EMIT firstChanged(); 66 | Q_EMIT lastChanged(); 67 | Q_EMIT countChanged(); 68 | } 69 | 70 | PhotoSizeObject *PhotoSizeList::first() const 71 | { 72 | if( p->list.isEmpty() ) 73 | return 0; 74 | 75 | return p->list.first(); 76 | } 77 | 78 | PhotoSizeObject *PhotoSizeList::last() const 79 | { 80 | if( p->list.isEmpty() ) 81 | return 0; 82 | 83 | return p->list.last(); 84 | } 85 | 86 | int PhotoSizeList::count() const 87 | { 88 | return p->list.count(); 89 | } 90 | 91 | PhotoSizeObject *PhotoSizeList::at(int idx) 92 | { 93 | return p->list.at(idx); 94 | } 95 | 96 | PhotoSizeList::~PhotoSizeList() 97 | { 98 | delete p; 99 | } 100 | -------------------------------------------------------------------------------- /old/photosizelist.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 Aseman 3 | http://aseman.co 4 | 5 | This project is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This project is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef PHOTOSIZELIST_H 20 | #define PHOTOSIZELIST_H 21 | 22 | #include 23 | 24 | #include "telegramqml_global.h" 25 | 26 | class PhotoSize; 27 | class PhotoSizeObject; 28 | class PhotoSizeListPrivate; 29 | class TELEGRAMQMLSHARED_EXPORT PhotoSizeList : public QObject 30 | { 31 | Q_OBJECT 32 | 33 | Q_PROPERTY(PhotoSizeObject* first READ first NOTIFY firstChanged) 34 | Q_PROPERTY(PhotoSizeObject* last READ last NOTIFY lastChanged) 35 | Q_PROPERTY(int count READ count NOTIFY countChanged) 36 | 37 | public: 38 | PhotoSizeList(QObject *parent = 0); 39 | PhotoSizeList(const QList & another, QObject *parent = 0); 40 | ~PhotoSizeList(); 41 | 42 | void operator =( const QList & another ); 43 | 44 | PhotoSizeObject *first() const; 45 | PhotoSizeObject *last() const; 46 | 47 | int count() const; 48 | 49 | public Q_SLOTS: 50 | PhotoSizeObject *at( int idx ); 51 | 52 | Q_SIGNALS: 53 | void firstChanged(); 54 | void lastChanged(); 55 | void countChanged(); 56 | 57 | private: 58 | PhotoSizeListPrivate *p; 59 | }; 60 | 61 | Q_DECLARE_METATYPE(PhotoSizeList*) 62 | 63 | #endif // PHOTOSIZELIST_H 64 | -------------------------------------------------------------------------------- /old/tagfiltermodel.h: -------------------------------------------------------------------------------- 1 | #ifndef TAGFILTERMODEL_H 2 | #define TAGFILTERMODEL_H 3 | 4 | #include "telegramqml_global.h" 5 | #include "tgabstractlistmodel.h" 6 | 7 | class UserData; 8 | class TagFilterModelPrivate; 9 | class TELEGRAMQMLSHARED_EXPORT TagFilterModel : public TgAbstractListModel 10 | { 11 | Q_OBJECT 12 | Q_ENUMS(TagFilterRoles) 13 | 14 | Q_PROPERTY(UserData* userData READ userData WRITE setUserData NOTIFY userDataChanged) 15 | Q_PROPERTY(QString keyword READ keyword WRITE setKeyword NOTIFY keywordChanged) 16 | Q_PROPERTY(int count READ count NOTIFY countChanged) 17 | 18 | public: 19 | enum TagFilterRoles { 20 | TagRole = Qt::UserRole 21 | }; 22 | 23 | TagFilterModel(QObject *parent = 0); 24 | ~TagFilterModel(); 25 | 26 | void setUserData(UserData *userData); 27 | UserData *userData() const; 28 | 29 | QString id( const QModelIndex &index ) const; 30 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 31 | 32 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 33 | 34 | QHash roleNames() const; 35 | 36 | int count() const; 37 | 38 | void setKeyword(const QString &keyword); 39 | QString keyword() const; 40 | 41 | public Q_SLOTS: 42 | void refresh(); 43 | QString get(int idx); 44 | 45 | Q_SIGNALS: 46 | void userDataChanged(); 47 | void countChanged(); 48 | void keywordChanged(); 49 | 50 | private: 51 | void listChanged(); 52 | 53 | private: 54 | TagFilterModelPrivate *p; 55 | }; 56 | 57 | #endif // TAGFILTERMODEL_H 58 | -------------------------------------------------------------------------------- /old/telegramchatparticipantsmodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 Aseman 3 | http://aseman.co 4 | 5 | This project is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This project is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TELEGRAMCHATPARTICIPANTSMODEL_H 20 | #define TELEGRAMCHATPARTICIPANTSMODEL_H 21 | 22 | #include "telegramqml_global.h" 23 | #include "tgabstractlistmodel.h" 24 | 25 | class TelegramQml; 26 | class DialogObject; 27 | class TelegramChatParticipantsModelPrivate; 28 | class TELEGRAMQMLSHARED_EXPORT TelegramChatParticipantsModel : public TgAbstractListModel 29 | { 30 | Q_OBJECT 31 | Q_ENUMS(DialogsRoles) 32 | 33 | Q_PROPERTY(TelegramQml* telegram READ telegram WRITE setTelegram NOTIFY telegramChanged) 34 | Q_PROPERTY(DialogObject* dialog READ dialog WRITE setDialog NOTIFY dialogChanged) 35 | Q_PROPERTY(int count READ count NOTIFY countChanged) 36 | Q_PROPERTY(bool refreshing READ refreshing NOTIFY refreshingChanged) 37 | 38 | public: 39 | enum DialogsRoles { 40 | ItemRole = Qt::UserRole 41 | }; 42 | 43 | public: 44 | TelegramChatParticipantsModel(QObject *parent = 0); 45 | ~TelegramChatParticipantsModel(); 46 | 47 | TelegramQml *telegram() const; 48 | void setTelegram(TelegramQml *tg ); 49 | 50 | DialogObject *dialog() const; 51 | void setDialog( DialogObject *dlg ); 52 | 53 | qint64 id( const QModelIndex &index ) const; 54 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 55 | 56 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 57 | 58 | QHash roleNames() const; 59 | 60 | int count() const; 61 | bool refreshing() const; 62 | 63 | public Q_SLOTS: 64 | void refresh(); 65 | 66 | Q_SIGNALS: 67 | void telegramChanged(); 68 | void dialogChanged(); 69 | void countChanged(); 70 | void refreshingChanged(); 71 | 72 | private Q_SLOTS: 73 | void chatFullsChanged(); 74 | 75 | private: 76 | TelegramChatParticipantsModelPrivate *p; 77 | }; 78 | 79 | #endif // TELEGRAMCHATPARTICIPANTSMODEL_H 80 | -------------------------------------------------------------------------------- /old/telegramcontactsfiltermodel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Canonical 3 | 4 | This project is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This project is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | 19 | #include 20 | 21 | #include "telegramdetailedcontactsmodel.h" 22 | #include "telegramcontactsfiltermodel.h" 23 | 24 | TelegramContactsFilterModel::TelegramContactsFilterModel(QObject *parent) : 25 | QSortFilterProxyModel(parent), mOwnId(0), mSearchTerm("") 26 | { 27 | } 28 | 29 | TelegramContactsFilterModel::~TelegramContactsFilterModel() 30 | { 31 | } 32 | 33 | bool TelegramContactsFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { 34 | QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); 35 | 36 | QString fullName = sourceModel()->data(index, TelegramDetailedContactsModel::FullNameRole).toString(); 37 | qint32 id = sourceModel()->data(index, TelegramDetailedContactsModel::IdRole).toInt(); 38 | 39 | bool notSelf = (id != mOwnId); 40 | return notSelf && (fullName.contains(filterRegExp())); 41 | } 42 | 43 | QString TelegramContactsFilterModel::searchTerm() const 44 | { 45 | return mSearchTerm; 46 | } 47 | 48 | void TelegramContactsFilterModel::setSearchTerm(const QString &searchTerm) 49 | { 50 | if (mSearchTerm != searchTerm) { 51 | mSearchTerm = searchTerm; 52 | 53 | QString pattern = QString("\\b%1").arg(searchTerm); 54 | setFilterKeyColumn(0); 55 | setFilterRegExp(QRegExp(pattern, Qt::CaseInsensitive)); 56 | 57 | Q_EMIT searchTermChanged(); 58 | } 59 | } 60 | 61 | QVariant TelegramContactsFilterModel::get(int rowIndex) const { 62 | QVariantMap data; 63 | QModelIndex sourceIndex = mapToSource(index(rowIndex, 0)); 64 | if (sourceIndex.isValid()) { 65 | QAbstractItemModel *source = sourceModel(); 66 | QHash roles = source->roleNames(); 67 | Q_FOREACH(int role, roles.keys()) { 68 | data.insert(roles[role], source->data(sourceIndex, role)); 69 | } 70 | } 71 | return data; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /old/telegramcontactsfiltermodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Canonical 3 | 4 | This project is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This project is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | 19 | #ifndef TELEGRAMCONTACTSFILTERMODEL_H 20 | #define TELEGRAMCONTACTSFILTERMODEL_H 21 | 22 | #include 23 | 24 | #include "telegramqml_global.h" 25 | 26 | class TELEGRAMQMLSHARED_EXPORT TelegramContactsFilterModel : public QSortFilterProxyModel 27 | { 28 | Q_OBJECT 29 | 30 | Q_PROPERTY(int count READ rowCount NOTIFY countChanged) 31 | Q_PROPERTY(QString searchTerm READ searchTerm WRITE setSearchTerm NOTIFY searchTermChanged) 32 | 33 | public: 34 | TelegramContactsFilterModel(QObject *parent = 0); 35 | ~TelegramContactsFilterModel(); 36 | 37 | bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; 38 | 39 | Q_INVOKABLE QVariant get(int rowIndex) const; 40 | 41 | QString searchTerm() const; 42 | void setSearchTerm(const QString &searchTerm); 43 | 44 | Q_SIGNALS: 45 | void searchTermChanged(); 46 | void countChanged(); 47 | 48 | private: 49 | qint64 mOwnId; 50 | QString mSearchTerm; 51 | }; 52 | 53 | #endif // TELEGRAMCONTACTSFILTERMODEL_H 54 | -------------------------------------------------------------------------------- /old/telegramcontactsmodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 Aseman 3 | http://aseman.co 4 | 5 | This project is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This project is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TELEGRAMCONTACTSMODEL_H 20 | #define TELEGRAMCONTACTSMODEL_H 21 | 22 | #include "telegramqml_global.h" 23 | #include "tgabstractlistmodel.h" 24 | 25 | class TelegramQml; 26 | class TelegramContactsModelPrivate; 27 | class TELEGRAMQMLSHARED_EXPORT TelegramContactsModel : public TgAbstractListModel 28 | { 29 | Q_OBJECT 30 | Q_ENUMS(ContactsRoles) 31 | 32 | Q_PROPERTY(TelegramQml* telegram READ telegram WRITE setTelegram NOTIFY telegramChanged) 33 | Q_PROPERTY(int count READ count NOTIFY countChanged) 34 | Q_PROPERTY(bool initializing READ initializing NOTIFY initializingChanged) 35 | 36 | public: 37 | enum ContactsRoles { 38 | ItemRole = Qt::UserRole 39 | }; 40 | 41 | TelegramContactsModel(QObject *parent = 0); 42 | ~TelegramContactsModel(); 43 | 44 | TelegramQml *telegram() const; 45 | void setTelegram(TelegramQml *tg ); 46 | 47 | qint64 id( const QModelIndex &index ) const; 48 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 49 | 50 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 51 | 52 | QHash roleNames() const; 53 | 54 | int count() const; 55 | bool initializing() const; 56 | 57 | public Q_SLOTS: 58 | void refresh(); 59 | 60 | Q_SIGNALS: 61 | void telegramChanged(); 62 | void countChanged(); 63 | void initializingChanged(); 64 | 65 | private Q_SLOTS: 66 | void recheck(); 67 | void contactsChanged(); 68 | 69 | private: 70 | TelegramContactsModelPrivate *p; 71 | }; 72 | 73 | #endif // TELEGRAMCONTACTSMODEL_H 74 | -------------------------------------------------------------------------------- /old/telegramdetailedcontactsmodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 Aseman, 2015 Canonical 3 | http://aseman.co 4 | 5 | This project is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This project is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TELEGRAMDETAILEDCONTACTSMODEL_H 20 | #define TELEGRAMDETAILEDCONTACTSMODEL_H 21 | 22 | #include "telegramqml_global.h" 23 | #include "tgabstractlistmodel.h" 24 | 25 | class TelegramQml; 26 | class TelegramDetailedContactsModelPrivate; 27 | class TELEGRAMQMLSHARED_EXPORT TelegramDetailedContactsModel : public TgAbstractListModel 28 | { 29 | Q_OBJECT 30 | Q_ENUMS(DetailedContactsRoles) 31 | 32 | Q_PROPERTY(TelegramQml* telegram READ telegram WRITE setTelegram NOTIFY telegramChanged) 33 | Q_PROPERTY(int count READ count NOTIFY countChanged) 34 | Q_PROPERTY(bool initializing READ initializing NOTIFY initializingChanged) 35 | 36 | public: 37 | enum DetailedContactsRoles { 38 | ItemRole = Qt::UserRole, 39 | IdRole, 40 | AccessHashRole, 41 | PhoneRole, 42 | FirstNameRole, 43 | LastNameRole, 44 | FullNameRole, 45 | UsernameRole, 46 | PhotoRole, 47 | StatusRole 48 | }; 49 | 50 | TelegramDetailedContactsModel(QObject *parent = 0); 51 | ~TelegramDetailedContactsModel(); 52 | 53 | TelegramQml *telegram() const; 54 | void setTelegram(TelegramQml *tg ); 55 | 56 | qint64 id( const QModelIndex &index ) const; 57 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 58 | 59 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 60 | 61 | QHash roleNames() const; 62 | 63 | int count() const; 64 | bool initializing() const; 65 | 66 | public Q_SLOTS: 67 | void refresh(); 68 | 69 | Q_SIGNALS: 70 | void telegramChanged(); 71 | void countChanged(); 72 | void initializingChanged(); 73 | 74 | private Q_SLOTS: 75 | void recheck(); 76 | void contactsChanged(); 77 | 78 | private: 79 | TelegramDetailedContactsModelPrivate *p; 80 | }; 81 | 82 | #endif // TELEGRAMDETAILEDCONTACTSMODEL_H 83 | -------------------------------------------------------------------------------- /old/telegramdialogsmodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 Aseman 3 | http://aseman.co 4 | 5 | This project is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This project is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TELEGRAMDIALOGSMODEL_H 20 | #define TELEGRAMDIALOGSMODEL_H 21 | 22 | #include "telegramqml_global.h" 23 | #include "tgabstractlistmodel.h" 24 | 25 | class DialogObject; 26 | class TelegramQml; 27 | class TelegramDialogsModelPrivate; 28 | class TELEGRAMQMLSHARED_EXPORT TelegramDialogsModel : public TgAbstractListModel 29 | { 30 | Q_OBJECT 31 | Q_ENUMS(DialogsRoles) 32 | 33 | Q_PROPERTY(TelegramQml* telegram READ telegram WRITE setTelegram NOTIFY telegramChanged) 34 | Q_PROPERTY(int count READ count NOTIFY countChanged) 35 | Q_PROPERTY(bool initializing READ initializing NOTIFY initializingChanged) 36 | Q_PROPERTY(bool stopUpdating READ stopUpdating WRITE setStopUpdating NOTIFY stopUpdatingChanged) 37 | 38 | public: 39 | enum DialogsRoles { 40 | ItemRole = Qt::UserRole, 41 | SectionRole 42 | }; 43 | 44 | TelegramDialogsModel(QObject *parent = 0); 45 | ~TelegramDialogsModel(); 46 | 47 | TelegramQml *telegram() const; 48 | void setTelegram(TelegramQml *tg ); 49 | 50 | bool stopUpdating() const; 51 | void setStopUpdating(bool stt); 52 | 53 | qint64 id( const QModelIndex &index ) const; 54 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 55 | 56 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 57 | 58 | QHash roleNames() const; 59 | 60 | int count() const; 61 | bool initializing() const; 62 | 63 | Q_INVOKABLE int indexOf(DialogObject *dialog); 64 | Q_INVOKABLE DialogObject *at(int row); 65 | 66 | public Q_SLOTS: 67 | void refreshDatabase(); 68 | void recheck(); 69 | 70 | Q_SIGNALS: 71 | void telegramChanged(); 72 | void countChanged(); 73 | void initializingChanged(); 74 | void stopUpdatingChanged(); 75 | 76 | private Q_SLOTS: 77 | void dialogsChanged(bool cachedData); 78 | void dialogsChanged_priv(); 79 | void userDataChanged(); 80 | 81 | QList fixDialogs(QList dialogs ); 82 | 83 | protected: 84 | void timerEvent(QTimerEvent *e); 85 | 86 | private: 87 | TelegramDialogsModelPrivate *p; 88 | }; 89 | 90 | #endif // TELEGRAMDIALOGSMODEL_H 91 | -------------------------------------------------------------------------------- /old/telegramsearchmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMSEARCHMODEL_H 2 | #define TELEGRAMSEARCHMODEL_H 3 | 4 | #include "telegramqml_global.h" 5 | #include "tgabstractlistmodel.h" 6 | 7 | class MessageObject; 8 | class TelegramQml; 9 | class TelegramSearchModelPrivate; 10 | class TELEGRAMQMLSHARED_EXPORT TelegramSearchModel : public TgAbstractListModel 11 | { 12 | Q_OBJECT 13 | Q_ENUMS(SearchsRoles) 14 | 15 | Q_PROPERTY(TelegramQml* telegram READ telegram WRITE setTelegram NOTIFY telegramChanged) 16 | Q_PROPERTY(int count READ count NOTIFY countChanged) 17 | Q_PROPERTY(bool initializing READ initializing NOTIFY initializingChanged) 18 | Q_PROPERTY(QString keyword READ keyword WRITE setKeyword NOTIFY keywordChanged) 19 | 20 | public: 21 | enum SearchsRoles { 22 | ItemRole = Qt::UserRole 23 | }; 24 | 25 | TelegramSearchModel(QObject *parent = 0); 26 | ~TelegramSearchModel(); 27 | 28 | TelegramQml *telegram() const; 29 | void setTelegram(TelegramQml *tgo ); 30 | 31 | void setKeyword(const QString &kw); 32 | QString keyword() const; 33 | 34 | qint64 id( const QModelIndex &index ) const; 35 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 36 | 37 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 38 | 39 | QHash roleNames() const; 40 | 41 | int count() const; 42 | bool initializing() const; 43 | 44 | QList messages() const; 45 | 46 | public Q_SLOTS: 47 | void refresh(); 48 | 49 | Q_SIGNALS: 50 | void telegramChanged(); 51 | void countChanged(); 52 | void initializingChanged(); 53 | void keywordChanged(); 54 | 55 | private Q_SLOTS: 56 | void searchDone(const QList &messages); 57 | 58 | protected: 59 | void timerEvent(QTimerEvent *e); 60 | 61 | private: 62 | TelegramSearchModelPrivate *p; 63 | }; 64 | 65 | #endif // TELEGRAMSEARCHMODEL_H 66 | -------------------------------------------------------------------------------- /old/telegramuploadsmodel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 Aseman 3 | http://aseman.co 4 | 5 | This project is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This project is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #include "telegramuploadsmodel.h" 20 | #include "telegramqml.h" 21 | #include "objects/types.h" 22 | 23 | #include 24 | #include 25 | 26 | class TelegramUploadsModelPrivate 27 | { 28 | public: 29 | QPointer telegram; 30 | QList uploads; 31 | }; 32 | 33 | TelegramUploadsModel::TelegramUploadsModel(QObject *parent) : 34 | TgAbstractListModel(parent) 35 | { 36 | p = new TelegramUploadsModelPrivate; 37 | p->telegram = 0; 38 | } 39 | 40 | TelegramQml *TelegramUploadsModel::telegram() const 41 | { 42 | return p->telegram; 43 | } 44 | 45 | void TelegramUploadsModel::setTelegram(TelegramQml *tgo) 46 | { 47 | TelegramQml *tg = static_cast(tgo); 48 | if( p->telegram == tg ) 49 | return; 50 | 51 | p->telegram = tg; 52 | Q_EMIT telegramChanged(); 53 | if( !p->telegram ) 54 | return; 55 | 56 | connect( p->telegram, SIGNAL(uploadsChanged()), SLOT(uploadsChanged()) ); 57 | } 58 | 59 | qint64 TelegramUploadsModel::id(const QModelIndex &index) const 60 | { 61 | int row = index.row(); 62 | return p->uploads.at(row); 63 | } 64 | 65 | int TelegramUploadsModel::rowCount(const QModelIndex &parent) const 66 | { 67 | Q_UNUSED(parent) 68 | return p->uploads.count(); 69 | } 70 | 71 | QVariant TelegramUploadsModel::data(const QModelIndex &index, int role) const 72 | { 73 | QVariant res; 74 | const qint64 key = id(index); 75 | switch( role ) 76 | { 77 | case ItemRole: 78 | res = QVariant::fromValue(p->telegram->upload(key)); 79 | break; 80 | } 81 | 82 | return res; 83 | } 84 | 85 | QHash TelegramUploadsModel::roleNames() const 86 | { 87 | static QHash *res = 0; 88 | if( res ) 89 | return *res; 90 | 91 | res = new QHash(); 92 | res->insert( ItemRole, "item"); 93 | return *res; 94 | } 95 | 96 | int TelegramUploadsModel::count() const 97 | { 98 | return p->uploads.count(); 99 | } 100 | 101 | void TelegramUploadsModel::uploadsChanged() 102 | { 103 | const QList & uploads = p->telegram->uploads(); 104 | 105 | beginResetModel(); 106 | p->uploads.clear(); 107 | endResetModel(); 108 | 109 | for( int i=0 ; iuploads.contains(dId) ) 113 | continue; 114 | 115 | beginInsertRows(QModelIndex(), i, i ); 116 | p->uploads.insert( i, dId ); 117 | endInsertRows(); 118 | } 119 | } 120 | 121 | TelegramUploadsModel::~TelegramUploadsModel() 122 | { 123 | delete p; 124 | } 125 | -------------------------------------------------------------------------------- /old/telegramuploadsmodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 Aseman 3 | http://aseman.co 4 | 5 | This project is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This project is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TELEGRAMUPLOADSMODEL_H 20 | #define TELEGRAMUPLOADSMODEL_H 21 | 22 | #include "telegramqml_global.h" 23 | #include "tgabstractlistmodel.h" 24 | 25 | class TelegramQml; 26 | class TelegramUploadsModelPrivate; 27 | class TELEGRAMQMLSHARED_EXPORT TelegramUploadsModel : public TgAbstractListModel 28 | { 29 | Q_OBJECT 30 | Q_ENUMS(UploadsRoles) 31 | 32 | Q_PROPERTY(TelegramQml* telegram READ telegram WRITE setTelegram NOTIFY telegramChanged) 33 | Q_PROPERTY(int count READ count NOTIFY countChanged) 34 | 35 | public: 36 | enum UploadsRoles { 37 | ItemRole = Qt::UserRole 38 | }; 39 | 40 | TelegramUploadsModel(QObject *parent = 0); 41 | ~TelegramUploadsModel(); 42 | 43 | TelegramQml *telegram() const; 44 | void setTelegram(TelegramQml *tg ); 45 | 46 | qint64 id( const QModelIndex &index ) const; 47 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 48 | 49 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 50 | 51 | QHash roleNames() const; 52 | 53 | int count() const; 54 | 55 | Q_SIGNALS: 56 | void telegramChanged(); 57 | void countChanged(); 58 | 59 | private Q_SLOTS: 60 | void uploadsChanged(); 61 | 62 | private: 63 | TelegramUploadsModelPrivate *p; 64 | }; 65 | 66 | #endif // TELEGRAMUPLOADSMODEL_H 67 | -------------------------------------------------------------------------------- /old/telegramwallpapersmodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2014 Aseman 3 | http://aseman.co 4 | 5 | This project is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This project is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | */ 18 | 19 | #ifndef TELEGRAMWALLPAPERSMODEL_H 20 | #define TELEGRAMWALLPAPERSMODEL_H 21 | 22 | #include "telegramqml_global.h" 23 | #include "tgabstractlistmodel.h" 24 | 25 | class TelegramQml; 26 | class TelegramWallpapersModelPrivate; 27 | class TELEGRAMQMLSHARED_EXPORT TelegramWallpapersModel : public TgAbstractListModel 28 | { 29 | Q_OBJECT 30 | Q_ENUMS(WallpapersRoles) 31 | 32 | Q_PROPERTY(TelegramQml* telegram READ telegram WRITE setTelegram NOTIFY telegramChanged) 33 | Q_PROPERTY(int count READ count NOTIFY countChanged) 34 | Q_PROPERTY(bool initializing READ initializing NOTIFY initializingChanged) 35 | 36 | public: 37 | enum WallpapersRoles { 38 | ItemRole = Qt::UserRole 39 | }; 40 | 41 | TelegramWallpapersModel(QObject *parent = 0); 42 | ~TelegramWallpapersModel(); 43 | 44 | TelegramQml *telegram() const; 45 | void setTelegram(TelegramQml *tg ); 46 | 47 | qint64 id( const QModelIndex &index ) const; 48 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 49 | 50 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 51 | 52 | QHash roleNames() const; 53 | 54 | int count() const; 55 | bool initializing() const; 56 | 57 | Q_SIGNALS: 58 | void telegramChanged(); 59 | void countChanged(); 60 | void initializingChanged(); 61 | 62 | private Q_SLOTS: 63 | void recheck(); 64 | void wallpapersChanged(); 65 | 66 | protected: 67 | TelegramWallpapersModelPrivate *p; 68 | }; 69 | 70 | #endif // TELEGRAMWALLPAPERSMODEL_H 71 | -------------------------------------------------------------------------------- /old/tgabstractlistmodel.cpp: -------------------------------------------------------------------------------- 1 | #include "tgabstractlistmodel.h" 2 | 3 | #include 4 | 5 | TgAbstractListModel::TgAbstractListModel(QObject *parent) : 6 | QAbstractListModel(parent) 7 | { 8 | } 9 | 10 | QStringList TgAbstractListModel::roles() const 11 | { 12 | QStringList result; 13 | const QHash &roles = roleNames(); 14 | QHashIterator i(roles); 15 | while(i.hasNext()) 16 | { 17 | i.next(); 18 | result << i.value(); 19 | } 20 | 21 | qSort(result.begin(), result.end()); 22 | return result; 23 | } 24 | 25 | QVariant TgAbstractListModel::get(int row, int role) const 26 | { 27 | if(row >= rowCount()) 28 | return QVariant(); 29 | 30 | const QModelIndex &idx = index(row,0); 31 | return data(idx , role); 32 | } 33 | 34 | QVariantMap TgAbstractListModel::get(int index) const 35 | { 36 | if(index >= rowCount()) 37 | return QVariantMap(); 38 | 39 | QVariantMap result; 40 | const QHash &roles = roleNames(); 41 | QHashIterator i(roles); 42 | while(i.hasNext()) 43 | { 44 | i.next(); 45 | result[i.value()] = get(index, i.key()); 46 | } 47 | 48 | return result; 49 | } 50 | 51 | TgAbstractListModel::~TgAbstractListModel() 52 | { 53 | } 54 | 55 | -------------------------------------------------------------------------------- /old/tgabstractlistmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef TGABSTRACTLISTMODEL_H 2 | #define TGABSTRACTLISTMODEL_H 3 | 4 | #include 5 | #include 6 | 7 | #include "telegramqml_global.h" 8 | 9 | class TELEGRAMQMLSHARED_EXPORT TgAbstractListModel : public QAbstractListModel 10 | { 11 | Q_OBJECT 12 | public: 13 | TgAbstractListModel(QObject *parent = 0); 14 | virtual ~TgAbstractListModel(); 15 | 16 | Q_INVOKABLE QStringList roles() const; 17 | 18 | public Q_SLOTS: 19 | QVariant get(int index, int role) const; 20 | QVariantMap get(int index) const; 21 | }; 22 | 23 | #endif // TGABSTRACTLISTMODEL_H 24 | -------------------------------------------------------------------------------- /old/usernamefiltermodel.h: -------------------------------------------------------------------------------- 1 | #ifndef USERNAMEFILTERMODEL_H 2 | #define USERNAMEFILTERMODEL_H 3 | 4 | #include "telegramqml_global.h" 5 | #include "tgabstractlistmodel.h" 6 | 7 | class DialogObject; 8 | class TelegramQml; 9 | class UserNameFilterModelPrivate; 10 | class TELEGRAMQMLSHARED_EXPORT UserNameFilterModel : public TgAbstractListModel 11 | { 12 | Q_OBJECT 13 | Q_ENUMS(FilterRoles) 14 | 15 | Q_PROPERTY(TelegramQml* telegram READ telegram WRITE setTelegram NOTIFY telegramChanged) 16 | Q_PROPERTY(DialogObject* dialog READ dialog WRITE setDialog NOTIFY dialogChanged) 17 | Q_PROPERTY(QString keyword READ keyword WRITE setKeyword NOTIFY keywordChanged) 18 | Q_PROPERTY(int count READ count NOTIFY countChanged) 19 | 20 | public: 21 | enum FilterRoles { 22 | UserIdRole = Qt::UserRole 23 | }; 24 | 25 | UserNameFilterModel(QObject *parent = 0); 26 | ~UserNameFilterModel(); 27 | 28 | TelegramQml *telegram() const; 29 | void setTelegram(TelegramQml *tg ); 30 | 31 | DialogObject *dialog() const; 32 | void setDialog(DialogObject *dialog); 33 | 34 | qint64 id( const QModelIndex &index ) const; 35 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 36 | 37 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 38 | 39 | QHash roleNames() const; 40 | 41 | int count() const; 42 | 43 | void setKeyword(const QString &keyword); 44 | QString keyword() const; 45 | 46 | public Q_SLOTS: 47 | void refresh(); 48 | qint64 get(int idx); 49 | 50 | Q_SIGNALS: 51 | void telegramChanged(); 52 | void countChanged(); 53 | void keywordChanged(); 54 | void dialogChanged(); 55 | 56 | private Q_SLOTS: 57 | void listChanged(); 58 | 59 | private: 60 | UserNameFilterModelPrivate *p; 61 | }; 62 | 63 | #endif // USERNAMEFILTERMODEL_H 64 | -------------------------------------------------------------------------------- /private/telegramthumbnailer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Canonical 3 | 4 | This project is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This project is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "telegramthumbnailer.h" 26 | 27 | TelegramThumbnailer::TelegramThumbnailer(QObject *parent) : QObject(parent) 28 | { 29 | core = new TelegramThumbnailerCore(); 30 | thread = new QThread(this); 31 | thread->start(); 32 | 33 | core->moveToThread(thread); 34 | 35 | connect(core, &TelegramThumbnailerCore::thumbnailCreated, this, &TelegramThumbnailer::thumbnailCreated, Qt::QueuedConnection); 36 | } 37 | 38 | TelegramThumbnailer::~TelegramThumbnailer() 39 | { 40 | thread->quit(); 41 | thread->wait(); 42 | 43 | thread->deleteLater(); 44 | thread = 0; 45 | 46 | core->deleteLater(); 47 | core = 0; 48 | } 49 | 50 | QString TelegramThumbnailer::getThumbFilename(const QString &filePath) const { 51 | QByteArray bytes(filePath.toStdString().c_str()); 52 | QString filename = QString(QCryptographicHash::hash(bytes, QCryptographicHash::Md5).toHex()); 53 | return filename.append(".jpg"); 54 | } 55 | 56 | QString TelegramThumbnailer::getThumbPath(const QString &thumbnailDirPath, const QString &filePath) const { 57 | QString filename = getThumbFilename(filePath); 58 | QDir temp(thumbnailDirPath); 59 | QString thumbPath = temp.filePath(filename); 60 | return thumbPath; 61 | } 62 | 63 | bool TelegramThumbnailer::hasThumbnail(const QString &thumbnailDirPath, const QString &filePath) const { 64 | QString thumbPath = getThumbPath(thumbnailDirPath, filePath); 65 | return hasThumbnail(thumbPath); 66 | } 67 | 68 | bool TelegramThumbnailer::hasThumbnail(const QString &thumbPath) const { 69 | QFile thumbnail(thumbPath); 70 | return thumbnail.exists(); 71 | } 72 | 73 | void TelegramThumbnailer::createThumbnail(const QString &source, const QString &dest, TelegramThumbnailer_Callback callback) { 74 | requests.insert(source, callback); 75 | 76 | QMetaObject::invokeMethod(core, "createThumbnail", Qt::QueuedConnection, 77 | Q_ARG(QString,source), Q_ARG(QString,dest)); 78 | } 79 | 80 | void TelegramThumbnailer::thumbnailCreated(QString path) { 81 | TelegramThumbnailer_Callback callback = requests.take(path); 82 | if (callback) { 83 | callback(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /private/telegramthumbnailer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Canonical 3 | 4 | This project is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This project is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "telegramthumbnailercore.h" 28 | #include "telegramqml_global.h" 29 | 30 | typedef std::function TelegramThumbnailer_Callback; 31 | 32 | class TELEGRAMQMLSHARED_EXPORT TelegramThumbnailer : public QObject 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | TelegramThumbnailer(QObject *parent = 0); 38 | virtual ~TelegramThumbnailer(); 39 | 40 | QString getThumbFilename(const QString &filePath) const; 41 | QString getThumbPath(const QString &thumbnailDirPath, const QString &filePath) const; 42 | bool hasThumbnail(const QString &thumbnailDirPath, const QString &filePath) const; 43 | bool hasThumbnail(const QString &thumbPath) const; 44 | void createThumbnail(const QString &source, const QString &dest, TelegramThumbnailer_Callback callback); 45 | 46 | private Q_SLOTS: 47 | void thumbnailCreated(QString path); 48 | 49 | private: 50 | QHash requests; 51 | 52 | QThread *thread; 53 | TelegramThumbnailerCore *core; 54 | }; 55 | -------------------------------------------------------------------------------- /private/telegramthumbnailercore.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 Canonical 3 | 4 | This project is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This project is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include "telegramqml_global.h" 22 | 23 | class TELEGRAMQMLSHARED_EXPORT TelegramThumbnailerCore : public QObject 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | TelegramThumbnailerCore(QObject *parent = 0); 29 | virtual ~TelegramThumbnailerCore(); 30 | 31 | public Q_SLOTS: 32 | void createThumbnail(QString source, QString dest); 33 | 34 | protected: 35 | bool createVideoThumbnail(const QString &source, const QString &dest); 36 | bool createAudioThumbnail(const QString &source, const QString &dest); 37 | 38 | private: 39 | void removeFiles(const QString &dir); 40 | 41 | Q_SIGNALS: 42 | void thumbnailCreated(QString path); 43 | }; 44 | -------------------------------------------------------------------------------- /private/tqmlmessageobject.h: -------------------------------------------------------------------------------- 1 | #ifndef TQMLMESSAGEOBJECT_H 2 | #define TQMLMESSAGEOBJECT_H 3 | 4 | #include 5 | #include 6 | 7 | class TQmlMessageObject : public MessageObject 8 | { 9 | Q_OBJECT 10 | Q_PROPERTY(SecretChatMessageObject* secretChatMessage READ secretChatMessage WRITE setSecretChatMessage NOTIFY secretChatMessageChanged) 11 | 12 | public: 13 | TQmlMessageObject(const Message &core, QObject *parent = 0) : MessageObject(core, parent), m_secretChatMessage(0) {} 14 | TQmlMessageObject(QObject *parent = 0) : MessageObject(parent), m_secretChatMessage(0) {} 15 | virtual ~TQmlMessageObject() { if(m_secretChatMessage) delete m_secretChatMessage; } 16 | 17 | SecretChatMessageObject *secretChatMessage() const { return m_secretChatMessage; } 18 | void setSecretChatMessage(SecretChatMessageObject *secretChatMessage) { 19 | if(m_secretChatMessage == secretChatMessage) return; 20 | if(m_secretChatMessage) delete m_secretChatMessage; 21 | m_secretChatMessage = secretChatMessage; 22 | if(m_secretChatMessage) { 23 | m_secretChatMessage->setParent(this); 24 | } 25 | Q_EMIT secretChatMessageChanged(); 26 | } 27 | 28 | TQmlMessageObject &operator =(const Message &b) { 29 | MessageObject::operator =(b); 30 | return *this; 31 | } 32 | 33 | bool operator ==(const Message &b) const { 34 | return MessageObject::operator ==(b); 35 | } 36 | 37 | Q_SIGNALS: 38 | void secretChatMessageChanged(); 39 | 40 | private: 41 | SecretChatMessageObject *m_secretChatMessage; 42 | }; 43 | 44 | #endif // TQMLMESSAGEOBJECT_H 45 | -------------------------------------------------------------------------------- /qmake/headerinstall.pri: -------------------------------------------------------------------------------- 1 | 2 | basePath = $${dirname(PWD)} 3 | for(header, INSTALL_HEADERS) { 4 | relPath = $${relative_path($$header, $$basePath)} 5 | path = $${INSTALL_PREFIX}/$${dirname(relPath)} 6 | eval(headers_$${path}.files += $$relPath) 7 | eval(headers_$${path}.path = $$path) 8 | eval(INSTALLS *= headers_$${path}) 9 | } 10 | -------------------------------------------------------------------------------- /qmldir: -------------------------------------------------------------------------------- 1 | module TelegramQml 2 | plugin telegramqml 3 | classname TelegramQmlPlugin 4 | typeinfo plugins.qmltypes 5 | 6 | -------------------------------------------------------------------------------- /telegramabstractenginelistmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMABSTRACTENGINELISTMODEL_H 2 | #define TELEGRAMABSTRACTENGINELISTMODEL_H 3 | 4 | #include "telegramengine.h" 5 | #include "telegramqml_global.h" 6 | #include "telegramabstractlistmodel.h" 7 | #include "telegramtools.h" 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | class UpdatesType; 16 | class Peer; 17 | class User; 18 | class Update; 19 | class Chat; 20 | class UpdatesState; 21 | class UpdatesDifference; 22 | class UpdatesChannelDifference; 23 | class MessageFwdHeader; 24 | class Message; 25 | class SecretChatMessage; 26 | class TELEGRAMQMLSHARED_EXPORT TelegramAbstractEngineListModel : public TelegramAbstractListModel 27 | { 28 | Q_OBJECT 29 | Q_PROPERTY(TelegramEngine* engine READ engine WRITE setEngine NOTIFY engineChanged) 30 | 31 | public: 32 | TelegramAbstractEngineListModel(QObject *parent = 0); 33 | virtual ~TelegramAbstractEngineListModel(); 34 | 35 | typedef std::function Callback; 36 | 37 | TelegramEngine *engine() const { return mEngine; } 38 | void setEngine(TelegramEngine *engine); 39 | 40 | static QStringList requiredProperties() { 41 | return QStringList(); 42 | } 43 | 44 | Telegram *telegram() const { 45 | return mTelegram; 46 | } 47 | 48 | public Q_SLOTS: 49 | void startTimer(int ms, Callback callback); 50 | 51 | Q_SIGNALS: 52 | void engineChanged(); 53 | 54 | protected: 55 | virtual void refresh() = 0; 56 | virtual void clean() = 0; 57 | QPointer mEngine; 58 | 59 | virtual void onUpdatesGetDifferenceAnswer(qint64 id, const QList &messages, const QList &secretChatMessages, const QList &otherUpdates, const QList &chats, const QList &users, const UpdatesState &state, bool isIntermediateState); 60 | virtual void onUpdatesGetStateAnswer(qint64 msgId, const UpdatesState &result); 61 | virtual void onUpdatesGetChannelDifferenceAnswer(qint64 msgId, const UpdatesChannelDifference &result); 62 | virtual void onUpdateSecretChatMessage(const SecretChatMessage &secretChatMessage, qint32 qts); 63 | virtual void onUpdates(const UpdatesType &update); 64 | 65 | virtual void timerEvent(QTimerEvent *e); 66 | 67 | virtual void connectTelegram(); 68 | 69 | private: 70 | QString mErrorText; 71 | qint32 mErrorCode; 72 | QPointer mTelegram; 73 | QHash mTimers; 74 | }; 75 | 76 | #endif // TELEGRAMABSTRACTENGINELISTMODEL_H 77 | -------------------------------------------------------------------------------- /telegramabstractlistmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMABSTRACTLISTMODEL_H 2 | #define TELEGRAMABSTRACTLISTMODEL_H 3 | 4 | #include "telegramqml_global.h" 5 | #include "telegramtools.h" 6 | #include "tqbaseobject.h" 7 | 8 | #include 9 | #include 10 | 11 | class TELEGRAMQMLSHARED_EXPORT TelegramAbstractListModel : public QAbstractListModel, public TqBaseObject 12 | { 13 | Q_OBJECT 14 | Q_PROPERTY(int count READ count NOTIFY countChanged) 15 | Q_PROPERTY(bool isEmpty READ isEmpty NOTIFY isEmptyChanged) 16 | Q_PROPERTY(QString errorText READ errorText NOTIFY errorChanged) 17 | Q_PROPERTY(qint32 errorCode READ errorCode NOTIFY errorChanged) 18 | Q_PROPERTY(QQmlListProperty items READ items NOTIFY itemsChanged) 19 | Q_CLASSINFO("DefaultProperty", "items") 20 | 21 | public: 22 | TelegramAbstractListModel(QObject *parent = 0); 23 | virtual ~TelegramAbstractListModel(); 24 | 25 | Q_INVOKABLE QStringList roles() const; 26 | 27 | int rowCount(const QModelIndex &) const { return count(); } 28 | virtual int count() const = 0; 29 | bool isEmpty() const { return count() == 0; } 30 | 31 | QString errorText() const { return mErrorText; } 32 | qint32 errorCode() const { return mErrorCode; } 33 | 34 | QQmlListProperty items(); 35 | static QStringList requiredProperties() { 36 | return QStringList(); 37 | } 38 | 39 | public Q_SLOTS: 40 | QVariant get(int index, int role) const; 41 | QVariant get(int index, const QString &roleName) const; 42 | QVariantMap get(int index) const; 43 | int indexOf(int role, const QVariant &value); 44 | 45 | Q_SIGNALS: 46 | void countChanged(); 47 | void errorChanged(); 48 | void itemsChanged(); 49 | void isEmptyChanged(); 50 | 51 | protected: 52 | void setError(const QString &errorText, qint32 errorCode) { 53 | mErrorText = TelegramTools::convertErrorToText(errorText); 54 | mErrorCode = errorCode; 55 | Q_EMIT errorChanged(); 56 | } 57 | 58 | private: 59 | static void append(QQmlListProperty *p, QObject *v); 60 | static int count(QQmlListProperty *p); 61 | static QObject *at(QQmlListProperty *p, int idx); 62 | static void clear(QQmlListProperty *p); 63 | 64 | protected: 65 | QList _items; 66 | 67 | private: 68 | QString mErrorText; 69 | qint32 mErrorCode; 70 | int _cacheCount; 71 | }; 72 | 73 | #endif // TELEGRAMABSTRACTLISTMODEL_H 74 | -------------------------------------------------------------------------------- /telegramapp.cpp: -------------------------------------------------------------------------------- 1 | #include "telegramapp.h" 2 | 3 | class TelegramAppPrivate 4 | { 5 | public: 6 | qint32 appId; 7 | QString appHash; 8 | bool valid; 9 | }; 10 | 11 | TelegramApp::TelegramApp(QObject *parent) : 12 | QObject(parent) 13 | { 14 | p = new TelegramAppPrivate; 15 | p->valid = false; 16 | p->appId = 0; 17 | } 18 | 19 | void TelegramApp::setAppId(const qint32 &appId) 20 | { 21 | if(p->appId == appId) 22 | return; 23 | 24 | p->appId = appId; 25 | Q_EMIT appIdChanged(); 26 | refreshValid(); 27 | } 28 | 29 | qint32 TelegramApp::appId() const 30 | { 31 | return p->appId; 32 | } 33 | 34 | void TelegramApp::setAppHash(const QString &appHash) 35 | { 36 | if(p->appHash == appHash) 37 | return; 38 | 39 | p->appHash = appHash; 40 | Q_EMIT appHashChanged(); 41 | refreshValid(); 42 | } 43 | 44 | QString TelegramApp::appHash() const 45 | { 46 | return p->appHash; 47 | } 48 | 49 | bool TelegramApp::isValid() const 50 | { 51 | return p->appId && !p->appHash.isEmpty(); 52 | } 53 | 54 | QStringList TelegramApp::requiredProperties() 55 | { 56 | return QStringList() << FUNCTION_NAME(appHash) << FUNCTION_NAME(appId); 57 | } 58 | 59 | void TelegramApp::refreshValid() 60 | { 61 | const bool valid = isValid(); 62 | if(valid == p->valid) 63 | return; 64 | 65 | p->valid = valid; 66 | Q_EMIT isValidChanged(); 67 | } 68 | 69 | TelegramApp::~TelegramApp() 70 | { 71 | p->appHash.clear(); 72 | refreshValid(); 73 | delete p; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /telegramapp.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMAPP_H 2 | #define TELEGRAMAPP_H 3 | 4 | #include 5 | 6 | #include "telegramqml_macros.h" 7 | #include "telegramqml_global.h" 8 | #include "tqbaseobject.h" 9 | 10 | /*! 11 | * Define and Keep a Telegram App details 12 | * to use in the Telegram.Engine component. 13 | */ 14 | class TelegramAppPrivate; 15 | class TELEGRAMQMLSHARED_EXPORT TelegramApp : public QObject, public TqBaseObject 16 | { 17 | Q_OBJECT 18 | Q_PROPERTY(qint32 appId READ appId WRITE setAppId NOTIFY appIdChanged) 19 | Q_PROPERTY(QString appHash READ appHash WRITE setAppHash NOTIFY appHashChanged) 20 | Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged) 21 | 22 | public: 23 | TelegramApp(QObject *parent = 0); 24 | virtual ~TelegramApp(); 25 | 26 | void setAppId(const qint32 &appId); 27 | qint32 appId() const; 28 | 29 | void setAppHash(const QString &appHash); 30 | QString appHash() const; 31 | 32 | virtual bool isValid() const; 33 | static QStringList requiredProperties(); 34 | 35 | Q_SIGNALS: 36 | void appIdChanged(); 37 | void appHashChanged(); 38 | void isValidChanged(); 39 | 40 | protected: 41 | void refreshValid(); 42 | 43 | private: 44 | TelegramAppPrivate *p; 45 | }; 46 | 47 | #endif // TELEGRAMAPP_H 48 | -------------------------------------------------------------------------------- /telegramauthenticate.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMAUTHENTICATE_H 2 | #define TELEGRAMAUTHENTICATE_H 3 | 4 | #include 5 | 6 | #include "telegramqml_macros.h" 7 | #include "tqobject.h" 8 | 9 | class TelegramEngine; 10 | class TelegramAuthenticatePrivate; 11 | class TELEGRAMQMLSHARED_EXPORT TelegramAuthenticate : public TqObject 12 | { 13 | Q_OBJECT 14 | Q_ENUMS(AuthState) 15 | Q_PROPERTY(TelegramEngine* engine READ engine WRITE setEngine NOTIFY engineChanged) 16 | Q_PROPERTY(int state READ state NOTIFY stateChanged) 17 | Q_PROPERTY(int callTimeout READ callTimeout NOTIFY callTimeoutChanged) 18 | Q_PROPERTY(int remainingTime READ remainingTime NOTIFY remainingTimeChanged) 19 | 20 | public: 21 | enum AuthState { 22 | AuthUnknown = 0, 23 | AuthCheckingPhone = 1, 24 | AuthCheckingPhoneError = 2, 25 | AuthSignUpNeeded = 3, 26 | AuthCodeRequesting = 4, 27 | AuthCodeRequestingError = 5, 28 | AuthCodeRequested = 6, 29 | AuthPasswordRequested = 7, 30 | AuthLoggingIn = 8, 31 | AuthLoggingInError = 9, 32 | AuthLoggedIn = 10 33 | }; 34 | 35 | TelegramAuthenticate(QObject *parent = 0); 36 | virtual ~TelegramAuthenticate(); 37 | 38 | TelegramEngine *engine() const; 39 | void setEngine(TelegramEngine *engine); 40 | 41 | int state() const; 42 | int callTimeout() const; 43 | int remainingTime() const; 44 | 45 | static QStringList requiredProperties(); 46 | 47 | public Q_SLOTS: 48 | void signUp(const QString &firstName, const QString &lastName); 49 | void signIn(const QString &code); 50 | void checkPassword(const QString &password); 51 | 52 | Q_SIGNALS: 53 | void engineChanged(); 54 | void stateChanged(); 55 | void callTimeoutChanged(); 56 | void remainingTimeChanged(); 57 | void authLoggedIn(); 58 | 59 | protected: 60 | virtual void refresh(); 61 | virtual void clean(); 62 | void startRemainingTimer(int time); 63 | 64 | private: 65 | void requestCode(); 66 | void switchState(int state); 67 | 68 | private: 69 | TelegramAuthenticatePrivate *p; 70 | }; 71 | 72 | #endif // TELEGRAMAUTHENTICATE_H 73 | -------------------------------------------------------------------------------- /telegramauthstore.cpp: -------------------------------------------------------------------------------- 1 | #include "telegramauthstore.h" 2 | 3 | class TelegramAuthStorePrivate 4 | { 5 | public: 6 | QJSValue writeMethod; 7 | QJSValue readMethod; 8 | }; 9 | 10 | TelegramAuthStore::TelegramAuthStore(QObject *parent) : 11 | QObject(parent) 12 | { 13 | p = new TelegramAuthStorePrivate; 14 | } 15 | 16 | void TelegramAuthStore::setWriteMethod(const QJSValue &method) 17 | { 18 | if(p->writeMethod.isNull() && method.isNull()) 19 | return; 20 | 21 | p->writeMethod = method; 22 | Q_EMIT writeMethodChanged(); 23 | Q_EMIT isValidChanged(); 24 | } 25 | 26 | QJSValue TelegramAuthStore::writeMethod() const 27 | { 28 | return p->writeMethod; 29 | } 30 | 31 | void TelegramAuthStore::setReadMethod(const QJSValue &method) 32 | { 33 | if(p->readMethod.isNull() && method.isNull()) 34 | return; 35 | 36 | p->readMethod = method; 37 | Q_EMIT readMethodChanged(); 38 | Q_EMIT isValidChanged(); 39 | } 40 | 41 | QJSValue TelegramAuthStore::readMethod() const 42 | { 43 | return p->readMethod; 44 | } 45 | 46 | bool TelegramAuthStore::isValid() const 47 | { 48 | return !p->readMethod.isNull() && !p->writeMethod.isNull() && 49 | p->readMethod.isCallable() && p->writeMethod.isCallable(); 50 | } 51 | 52 | QStringList TelegramAuthStore::requiredProperties() 53 | { 54 | return QStringList() << FUNCTION_NAME(readMethod) 55 | << FUNCTION_NAME(writeMethod); 56 | } 57 | 58 | TelegramAuthStore::~TelegramAuthStore() 59 | { 60 | delete p; 61 | } 62 | -------------------------------------------------------------------------------- /telegramauthstore.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMAUTHSTORE_H 2 | #define TELEGRAMAUTHSTORE_H 3 | 4 | #include 5 | #include 6 | 7 | #include "telegramqml_macros.h" 8 | #include "telegramqml_global.h" 9 | #include "tqbaseobject.h" 10 | 11 | class TelegramAuthStorePrivate; 12 | class TelegramAuthStore : public QObject, public TqBaseObject 13 | { 14 | Q_OBJECT 15 | Q_PROPERTY(QJSValue writeMethod READ writeMethod WRITE setWriteMethod NOTIFY writeMethodChanged) 16 | Q_PROPERTY(QJSValue readMethod READ readMethod WRITE setReadMethod NOTIFY readMethodChanged) 17 | Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged) 18 | 19 | public: 20 | TelegramAuthStore(QObject *parent = 0); 21 | virtual ~TelegramAuthStore(); 22 | 23 | void setWriteMethod(const QJSValue &method); 24 | QJSValue writeMethod() const; 25 | 26 | void setReadMethod(const QJSValue &method); 27 | QJSValue readMethod() const; 28 | 29 | bool isValid() const; 30 | static QStringList requiredProperties(); 31 | 32 | Q_SIGNALS: 33 | void writeMethodChanged(); 34 | void readMethodChanged(); 35 | void isValidChanged(); 36 | 37 | private: 38 | TelegramAuthStorePrivate *p; 39 | }; 40 | 41 | #endif // TELEGRAMAUTHSTORE_H 42 | -------------------------------------------------------------------------------- /telegramenums.cpp: -------------------------------------------------------------------------------- 1 | #include "telegramenums.h" 2 | 3 | TelegramEnums::TelegramEnums(QObject *parent) : 4 | QObject(parent) 5 | { 6 | 7 | } 8 | 9 | TelegramEnums::~TelegramEnums() 10 | { 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /telegramenums.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMENUMS_H 2 | #define TELEGRAMENUMS_H 3 | 4 | #include "tqbaseobject.h" 5 | 6 | #include 7 | 8 | class TelegramEnums : public QObject, public TqBaseObject 9 | { 10 | Q_OBJECT 11 | Q_ENUMS(SendFileType) 12 | Q_ENUMS(MessageType) 13 | 14 | public: 15 | enum SendFileType { 16 | SendFileTypeAutoDetect, 17 | SendFileTypeDocument, 18 | SendFileTypeSticker, 19 | SendFileTypeAnimated, 20 | SendFileTypeVideo, 21 | SendFileTypePhoto, 22 | SendFileTypeAudio 23 | }; 24 | 25 | enum MessageType { 26 | TypeTextMessage, 27 | TypeDocumentMessage, 28 | TypeVideoMessage, 29 | TypeAudioMessage, 30 | TypeVenueMessage, 31 | TypeWebPageMessage, 32 | TypeGeoMessage, 33 | TypeContactMessage, 34 | TypeActionMessage, 35 | TypePhotoMessage, 36 | TypeStickerMessage, 37 | TypeAnimatedMessage, 38 | TypeUnsupportedMessage 39 | }; 40 | 41 | TelegramEnums(QObject *parent = 0); 42 | virtual ~TelegramEnums(); 43 | 44 | static QStringList requiredProperties() { 45 | return QStringList(); 46 | } 47 | }; 48 | 49 | #endif // TELEGRAMENUMS_H 50 | -------------------------------------------------------------------------------- /telegramhost.cpp: -------------------------------------------------------------------------------- 1 | #include "telegramhost.h" 2 | 3 | #include 4 | 5 | class TelegramHostPrivate 6 | { 7 | public: 8 | QString hostAddress; 9 | qint32 hostPort; 10 | qint32 hostDcId; 11 | QUrl publicKey; 12 | bool valid; 13 | }; 14 | 15 | TelegramHost::TelegramHost(QObject *parent) : 16 | QObject(parent) 17 | { 18 | p = new TelegramHostPrivate; 19 | p->hostPort = 0; 20 | p->hostDcId = 0; 21 | p->valid = false; 22 | p->publicKey = QUrl("qrc:/files/tg-server.pub"); 23 | } 24 | 25 | QString TelegramHost::hostAddress() const 26 | { 27 | return p->hostAddress; 28 | } 29 | 30 | void TelegramHost::setHostAddress(const QString &hostAddress) 31 | { 32 | if(p->hostAddress == hostAddress) 33 | return; 34 | 35 | p->hostAddress = hostAddress; 36 | Q_EMIT hostAddressChanged(); 37 | refreshValid(); 38 | } 39 | 40 | qint32 TelegramHost::hostPort() const 41 | { 42 | return p->hostPort; 43 | } 44 | 45 | void TelegramHost::setHostPort(qint32 hostPort) 46 | { 47 | if(p->hostPort == hostPort) 48 | return; 49 | 50 | p->hostPort = hostPort; 51 | Q_EMIT hostPortChanged(); 52 | refreshValid(); 53 | } 54 | 55 | qint32 TelegramHost::hostDcId() const 56 | { 57 | return p->hostDcId; 58 | } 59 | 60 | void TelegramHost::setHostDcId(qint32 hostDcId) 61 | { 62 | if(p->hostDcId == hostDcId) 63 | return; 64 | 65 | p->hostDcId = hostDcId; 66 | Q_EMIT hostDcIdChanged(); 67 | refreshValid(); 68 | } 69 | 70 | QUrl TelegramHost::publicKey() const 71 | { 72 | return p->publicKey; 73 | } 74 | 75 | void TelegramHost::setPublicKey(const QUrl &publicKey) 76 | { 77 | if(p->publicKey == publicKey) 78 | return; 79 | 80 | p->publicKey = publicKey; 81 | if(p->publicKey.isValid() && !p->publicKey.isLocalFile()) 82 | qDebug() << "Error: The public key is not a local file."; 83 | 84 | Q_EMIT publicKeyChanged(); 85 | refreshValid(); 86 | } 87 | 88 | bool TelegramHost::isValid() const 89 | { 90 | return p->hostDcId && p->hostPort && 91 | !p->hostAddress.isEmpty() && 92 | p->publicKey.isValid(); 93 | } 94 | 95 | QStringList TelegramHost::requiredProperties() 96 | { 97 | return QStringList() << FUNCTION_NAME(hostDcId) 98 | << FUNCTION_NAME(hostPort) 99 | << FUNCTION_NAME(hostAddress) 100 | << FUNCTION_NAME(publicKey); 101 | } 102 | 103 | void TelegramHost::refreshValid() 104 | { 105 | const bool valid = isValid(); 106 | if(valid == p->valid) 107 | return; 108 | 109 | p->valid = valid; 110 | Q_EMIT isValidChanged(); 111 | } 112 | 113 | TelegramHost::~TelegramHost() 114 | { 115 | p->hostAddress.clear(); 116 | refreshValid(); 117 | delete p; 118 | } 119 | 120 | -------------------------------------------------------------------------------- /telegramhost.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMHOST_H 2 | #define TELEGRAMHOST_H 3 | 4 | #include 5 | #include 6 | 7 | #include "telegramqml_macros.h" 8 | #include "telegramqml_global.h" 9 | #include "tqbaseobject.h" 10 | 11 | /*! 12 | * Define and Keep Telegram's default host details 13 | * to use in the Telegram.Engine component. 14 | */ 15 | class TelegramHostPrivate; 16 | class TELEGRAMQMLSHARED_EXPORT TelegramHost : public QObject, public TqBaseObject 17 | { 18 | Q_OBJECT 19 | Q_PROPERTY(QString hostAddress READ hostAddress WRITE setHostAddress NOTIFY hostAddressChanged) 20 | Q_PROPERTY(qint32 hostPort READ hostPort WRITE setHostPort NOTIFY hostPortChanged) 21 | Q_PROPERTY(qint32 hostDcId READ hostDcId WRITE setHostDcId NOTIFY hostDcIdChanged) 22 | Q_PROPERTY(QUrl publicKey READ publicKey WRITE setPublicKey NOTIFY publicKeyChanged) 23 | Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged) 24 | 25 | public: 26 | TelegramHost(QObject *parent = 0); 27 | virtual ~TelegramHost(); 28 | 29 | QString hostAddress() const; 30 | void setHostAddress(const QString &hostAddress); 31 | 32 | qint32 hostPort() const; 33 | void setHostPort(qint32 hostPort); 34 | 35 | qint32 hostDcId() const; 36 | void setHostDcId(qint32 hostDcId); 37 | 38 | QUrl publicKey() const; 39 | void setPublicKey(const QUrl &publicKey); 40 | 41 | virtual bool isValid() const; 42 | static QStringList requiredProperties(); 43 | 44 | Q_SIGNALS: 45 | void hostAddressChanged(); 46 | void hostPortChanged(); 47 | void hostDcIdChanged(); 48 | void publicKeyChanged(); 49 | void isValidChanged(); 50 | 51 | protected: 52 | void refreshValid(); 53 | 54 | private: 55 | TelegramHostPrivate *p; 56 | }; 57 | 58 | #endif // TELEGRAMHOST_H 59 | -------------------------------------------------------------------------------- /telegrammedialistmodel.cpp: -------------------------------------------------------------------------------- 1 | #include "telegrammedialistmodel.h" 2 | 3 | class TelegramMediaListModelPrivate 4 | { 5 | public: 6 | }; 7 | 8 | TelegramMediaListModel::TelegramMediaListModel(QObject *parent) : 9 | TelegramMessageSearchModel(parent) 10 | { 11 | p = new TelegramMediaListModelPrivate; 12 | } 13 | 14 | QStringList TelegramMediaListModel::requiredProperties() 15 | { 16 | return QStringList() << FUNCTION_NAME(engine) 17 | << FUNCTION_NAME(messageFilter); 18 | } 19 | 20 | TelegramMediaListModel::~TelegramMediaListModel() 21 | { 22 | delete p; 23 | } 24 | -------------------------------------------------------------------------------- /telegrammedialistmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMMEDIALISTMODEL_H 2 | #define TELEGRAMMEDIALISTMODEL_H 3 | 4 | #include "telegrammessagesearchmodel.h" 5 | 6 | class TelegramMediaListModelPrivate; 7 | class TELEGRAMQMLSHARED_EXPORT TelegramMediaListModel : public TelegramMessageSearchModel 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | TelegramMediaListModel(QObject *parent = 0); 13 | virtual ~TelegramMediaListModel(); 14 | 15 | static QStringList requiredProperties(); 16 | 17 | private: 18 | TelegramMediaListModelPrivate *p; 19 | }; 20 | 21 | #endif // TELEGRAMMEDIALISTMODEL_H 22 | -------------------------------------------------------------------------------- /telegrammemberslistmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMMEMBERSLISTMODEL_H 2 | #define TELEGRAMMEMBERSLISTMODEL_H 3 | 4 | #include "telegramabstractenginelistmodel.h" 5 | 6 | class InputPeerObject; 7 | class TelegramMembersListModelPrivate; 8 | class TELEGRAMQMLSHARED_EXPORT TelegramMembersListModel : public TelegramAbstractEngineListModel 9 | { 10 | Q_OBJECT 11 | Q_ENUMS(Types) 12 | Q_ENUMS(DataRoles) 13 | Q_PROPERTY(InputPeerObject* currentPeer READ currentPeer WRITE setCurrentPeer NOTIFY currentPeerChanged) 14 | Q_PROPERTY(qint32 filter READ filter WRITE setFilter NOTIFY filterChanged) 15 | Q_PROPERTY(bool refreshing READ refreshing NOTIFY refreshingChanged) 16 | Q_PROPERTY(QJSValue dateConvertorMethod READ dateConvertorMethod WRITE setDateConvertorMethod NOTIFY dateConvertorMethodChanged) 17 | 18 | public: 19 | enum DataRoles { 20 | RoleDate = Qt::UserRole, 21 | RoleInviter, 22 | RoleUser, 23 | RoleKickedBy, 24 | RoleType, 25 | RolePeer, 26 | RoleStatus 27 | }; 28 | 29 | enum Types { 30 | TypeNormal, 31 | TypeSelf, 32 | TypeAdmin, 33 | TypeModerator, 34 | TypeEditor, 35 | TypeKicked, 36 | TypeCreator, 37 | TypeUnknown 38 | }; 39 | 40 | TelegramMembersListModel(QObject *parent = 0); 41 | virtual ~TelegramMembersListModel(); 42 | 43 | void setCurrentPeer(InputPeerObject *peer); 44 | InputPeerObject *currentPeer() const; 45 | 46 | void setFilter(qint32 filter); 47 | qint32 filter() const; 48 | 49 | void setRefreshing(bool refreshing); 50 | bool refreshing() const; 51 | 52 | QJSValue dateConvertorMethod() const; 53 | void setDateConvertorMethod(const QJSValue &method); 54 | 55 | class TelegramChatsMemebrsListModelItem id(const QModelIndex &index) const; 56 | int count() const; 57 | 58 | QVariant data(const QModelIndex &index, int role) const; 59 | 60 | QHash roleNames() const; 61 | static QStringList requiredProperties(); 62 | 63 | Q_SIGNALS: 64 | void currentPeerChanged(); 65 | void filterChanged(); 66 | void refreshingChanged(); 67 | void dateConvertorMethodChanged(); 68 | 69 | public Q_SLOTS: 70 | 71 | private: 72 | void refresh(); 73 | void clean(); 74 | 75 | void changed(const QList &list); 76 | 77 | protected: 78 | QString convertDate(const QDateTime &td) const; 79 | 80 | private: 81 | TelegramMembersListModelPrivate *p; 82 | }; 83 | 84 | #endif // TELEGRAMMEMBERSLISTMODEL_H 85 | -------------------------------------------------------------------------------- /telegrammessagefetcher.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMMESSAGEFETCHER_H 2 | #define TELEGRAMMESSAGEFETCHER_H 3 | 4 | #include "tqobject.h" 5 | #include "telegramengine.h" 6 | 7 | class UserObject; 8 | class TQmlMessageObject; 9 | class InputPeerObject; 10 | class TelegramMessageFetcherPrivate; 11 | class TelegramMessageFetcher : public TqObject 12 | { 13 | Q_OBJECT 14 | Q_PROPERTY(TelegramEngine* engine READ engine WRITE setEngine NOTIFY engineChanged) 15 | Q_PROPERTY(qint32 messageId READ messageId WRITE setMessageId NOTIFY messageIdChanged) 16 | Q_PROPERTY(InputPeerObject* inputPeer READ inputPeer WRITE setInputPeer NOTIFY inputPeerChanged) 17 | Q_PROPERTY(TQmlMessageObject* result READ result NOTIFY resultChanged) 18 | Q_PROPERTY(UserObject* fromUser READ fromUser NOTIFY fromUserChanged) 19 | Q_PROPERTY(int mediaType READ mediaType NOTIFY mediaTypeChanged) 20 | 21 | 22 | public: 23 | TelegramMessageFetcher(QObject *parent = 0); 24 | virtual ~TelegramMessageFetcher(); 25 | 26 | void setEngine(TelegramEngine *engine); 27 | TelegramEngine *engine() const; 28 | 29 | void setInputPeer(InputPeerObject *inputPeer); 30 | InputPeerObject *inputPeer() const; 31 | 32 | void setMessageId(qint32 msgId); 33 | qint32 messageId() const; 34 | 35 | TQmlMessageObject *result() const; 36 | UserObject *fromUser() const; 37 | int mediaType() const; 38 | 39 | static QStringList requiredProperties(); 40 | 41 | Q_SIGNALS: 42 | void engineChanged(); 43 | void inputPeerChanged(); 44 | void messageIdChanged(); 45 | void resultChanged(); 46 | void fromUserChanged(); 47 | void mediaTypeChanged(); 48 | 49 | public Q_SLOTS: 50 | 51 | protected: 52 | void refresh(); 53 | void clean(); 54 | 55 | private: 56 | TelegramMessageFetcherPrivate *p; 57 | }; 58 | 59 | #endif // TELEGRAMMESSAGEFETCHER_H 60 | -------------------------------------------------------------------------------- /telegrammessagesearchmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMMESSAGESEARCHMODEL_H 2 | #define TELEGRAMMESSAGESEARCHMODEL_H 3 | 4 | #include "telegrammessagelistmodel.h" 5 | 6 | #include 7 | 8 | class TelegramMessageSearchModelPrivate; 9 | class TELEGRAMQMLSHARED_EXPORT TelegramMessageSearchModel : public TelegramMessageListModel 10 | { 11 | Q_OBJECT 12 | Q_PROPERTY(QString keyword READ keyword WRITE setKeyword NOTIFY keywordChanged) 13 | Q_PROPERTY(InputPeerObject* currentPeer READ currentPeer WRITE setCurrentPeer NOTIFY currentPeerChanged) 14 | Q_PROPERTY(int messageFilter READ messageFilter WRITE setMessageFilter NOTIFY messageFilterChanged) 15 | Q_PROPERTY(QDateTime minimumDate READ minimumDate WRITE setMinimumDate NOTIFY minimumDateChanged) 16 | Q_PROPERTY(QDateTime maximumDate READ maximumDate WRITE setMaximumDate NOTIFY maximumDateChanged) 17 | 18 | public: 19 | TelegramMessageSearchModel(QObject *parent = 0); 20 | virtual ~TelegramMessageSearchModel(); 21 | 22 | void setCurrentPeer(InputPeerObject *peer); 23 | InputPeerObject *currentPeer() const; 24 | 25 | void setKeyword(const QString &keyword); 26 | QString keyword() const; 27 | 28 | /*! From MessagesFilterObject class */ 29 | void setMessageFilter(int filter); 30 | int messageFilter() const; 31 | 32 | void setMinimumDate(const QDateTime &minDate); 33 | QDateTime minimumDate() const; 34 | 35 | void setMaximumDate(const QDateTime &maxDate); 36 | QDateTime maximumDate() const; 37 | 38 | static QStringList requiredProperties(); 39 | 40 | Q_SIGNALS: 41 | void keywordChanged(); 42 | void messageFilterChanged(); 43 | void minimumDateChanged(); 44 | void maximumDateChanged(); 45 | void currentPeerChanged(); 46 | 47 | public Q_SLOTS: 48 | void loadBack(); 49 | 50 | protected: 51 | virtual void refresh(); 52 | void getFromServer(bool more = false); 53 | 54 | private: 55 | TelegramMessageSearchModelPrivate *p; 56 | }; 57 | 58 | #endif // TELEGRAMMESSAGESEARCHMODEL_H 59 | -------------------------------------------------------------------------------- /telegramnotificationhandler.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMNOTIFICATIONHANDLER_H 2 | #define TELEGRAMNOTIFICATIONHANDLER_H 3 | 4 | #include "tqobject.h" 5 | #include "telegramqml_global.h" 6 | 7 | class UpdatesType; 8 | class Peer; 9 | class User; 10 | class Update; 11 | class Chat; 12 | class MessageFwdHeader; 13 | class TelegramEngine; 14 | class TelegramNotificationHandlerPrivate; 15 | class TELEGRAMQMLSHARED_EXPORT TelegramNotificationHandler : public TqObject 16 | { 17 | Q_OBJECT 18 | Q_PROPERTY(TelegramEngine* engine READ engine WRITE setEngine NOTIFY engineChanged) 19 | Q_PROPERTY(int unreadCount READ unreadCount NOTIFY unreadCountChanged) 20 | Q_PROPERTY(int globalUnreadCount READ globalUnreadCount NOTIFY globalUnreadCountChanged) 21 | 22 | public: 23 | TelegramNotificationHandler(QObject *parent = 0); 24 | virtual ~TelegramNotificationHandler(); 25 | 26 | void setEngine(TelegramEngine *engine); 27 | TelegramEngine *engine() const; 28 | 29 | int unreadCount() const; 30 | int globalUnreadCount() const; 31 | 32 | static QStringList requiredProperties(); 33 | 34 | Q_SIGNALS: 35 | void engineChanged(); 36 | void unreadCountChanged(); 37 | void globalUnreadCountChanged(); 38 | void newMessage(const QString &title, const QString &message, const QString &peerKey); 39 | 40 | public Q_SLOTS: 41 | 42 | protected: 43 | virtual void onUpdates(const UpdatesType &update); 44 | virtual void refreshUnreads(); 45 | 46 | void insertUpdate(const Update &update); 47 | void refresh(); 48 | 49 | private: 50 | TelegramNotificationHandlerPrivate *p; 51 | }; 52 | 53 | #endif // TELEGRAMNOTIFICATIONHANDLER_H 54 | -------------------------------------------------------------------------------- /telegramprofilemanagermodel.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMPROFILEMANAGERMODEL_H 2 | #define TELEGRAMPROFILEMANAGERMODEL_H 3 | 4 | #include "telegramabstractlistmodel.h" 5 | #include "telegramqml_global.h" 6 | 7 | #include 8 | #include 9 | 10 | class TelegramEngine; 11 | class TelegramProfileManagerModelPrivate; 12 | class TELEGRAMQMLSHARED_EXPORT TelegramProfileManagerModel : public TelegramAbstractListModel 13 | { 14 | Q_OBJECT 15 | Q_ENUMS(DataRole) 16 | Q_ENUMS(AddResult) 17 | Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged) 18 | Q_PROPERTY(QQmlComponent* engineDelegate READ engineDelegate WRITE setEngineDelegate NOTIFY engineDelegateChanged) 19 | Q_PROPERTY(bool initializing READ initializing NOTIFY initializingChanged) 20 | 21 | public: 22 | enum DataRole { 23 | DataPhoneNumber = Qt::UserRole, 24 | DataMute, 25 | DataEngine 26 | }; 27 | 28 | enum AddResult { 29 | AddResultSucessfully, 30 | AddResultExists, 31 | AddResultInvalidPhone, 32 | AddResultDatabaseError 33 | }; 34 | 35 | TelegramProfileManagerModel(QObject *parent = 0); 36 | virtual ~TelegramProfileManagerModel(); 37 | 38 | class TelegramProfileManagerModelItem id(const QModelIndex &index) const; 39 | int count() const; 40 | QVariant data(const QModelIndex &index, int role) const; 41 | 42 | QHash roleNames() const; 43 | 44 | void setSource(const QString &source); 45 | QString source() const; 46 | 47 | void setEngineDelegate(QQmlComponent *component); 48 | QQmlComponent *engineDelegate() const; 49 | 50 | bool initializing() const; 51 | static QStringList requiredProperties(); 52 | 53 | public Q_SLOTS: 54 | void addNew(); 55 | int add(const QString &phoneNumber, bool mute, TelegramEngine *engine); 56 | bool remove(const QString &phoneNumber); 57 | 58 | Q_SIGNALS: 59 | void sourceChanged(); 60 | void engineDelegateChanged(); 61 | void initializingChanged(); 62 | 63 | private: 64 | void changed(const QList &list); 65 | void init(); 66 | void initTables(); 67 | void initBuffer(); 68 | 69 | protected: 70 | void itemsChanged_slt(); 71 | void setInitializing(bool initializing); 72 | 73 | private: 74 | TelegramProfileManagerModelPrivate *p; 75 | }; 76 | 77 | #endif // TELEGRAMPROFILEMANAGERMODEL_H 78 | -------------------------------------------------------------------------------- /telegramqml.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | TARGET = telegramqml 3 | DEFINES += TELEGRAMQML_LIBRARY 4 | DEFINES += TELEGRAMQML_QML_PLUGIN ASEMAN_STATIC_BUILD 5 | CONFIG += qt no_keywords c++11 6 | 7 | uri = TelegramQml 8 | 9 | win32 { 10 | QT += winextras 11 | } else { 12 | macx { 13 | QT += macextras 14 | } 15 | } 16 | 17 | include(telegramqml.pri) 18 | 19 | linux { 20 | contains(QT_ARCH, x86_64) { 21 | LIB_PATH = x86_64-linux-gnu 22 | } else:contains(QT_ARCH, arm) { 23 | LIB_PATH = arm-linux-gnueabihf 24 | } else { 25 | LIB_PATH = i386-linux-gnu 26 | } 27 | contains(DEFINES, UBUNTU_PHONE) { 28 | CONFIG += link_pkgconfig 29 | PKGCONFIG += libthumbnailer-qt 30 | } 31 | } 32 | 33 | contains(BUILD_MODE,lib) { 34 | isEmpty(PREFIX) { 35 | isEmpty(INSTALL_HEADERS_PREFIX): INSTALL_HEADERS_PREFIX = $$[QT_INSTALL_HEADERS] 36 | isEmpty(INSTALL_LIBS_PREFIX): INSTALL_LIBS_PREFIX = $$[QT_INSTALL_LIBS] 37 | } else { 38 | isEmpty(INSTALL_HEADERS_PREFIX): INSTALL_HEADERS_PREFIX = $$PREFIX/include 39 | isEmpty(INSTALL_LIBS_PREFIX): INSTALL_LIBS_PREFIX = $$PREFIX/lib/$$LIB_PATH 40 | } 41 | 42 | DEFINES += BUILD_MODE_LIB 43 | 44 | !contains(CONFIG, no_install) { 45 | INSTALL_PREFIX = $$INSTALL_HEADERS_PREFIX/telegramqml 46 | INSTALL_HEADERS = $$HEADERS 47 | include(qmake/headerinstall.pri) 48 | 49 | target = $$TARGET 50 | target.path = $$INSTALL_LIBS_PREFIX 51 | 52 | INSTALLS += target 53 | } 54 | } else { 55 | CONFIG += plugin 56 | DEFINES += BUILD_MODE_PLUGIN 57 | 58 | DESTDIR = TelegramQml 59 | TARGET = $$qtLibraryTarget($$TARGET) 60 | DISTFILES = qmldir \ 61 | plugins.qmltypes 62 | 63 | !equals(_PRO_FILE_PWD_, $$OUT_PWD) { 64 | copy_qmldir.target = $$OUT_PWD/$$DESTDIR/qmldir 65 | copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir 66 | copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\" 67 | 68 | copy_qmltypes.target = $$OUT_PWD/$$DESTDIR/plugins.qmltypes 69 | copy_qmltypes.depends = $$_PRO_FILE_PWD_/plugins.qmltypes 70 | copy_qmltypes.commands = $(COPY_FILE) \"$$replace(copy_qmltypes.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmltypes.target, /, $$QMAKE_DIR_SEP)\" 71 | 72 | QMAKE_EXTRA_TARGETS += copy_qmldir copy_qmltypes 73 | PRE_TARGETDEPS += $$copy_qmldir.target $$copy_qmltypes.target 74 | } 75 | 76 | qmldir.files = qmldir plugins.qmltypes 77 | 78 | unix { 79 | !contains(CONFIG, no_install) { 80 | installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) 81 | qmldir.path = $$installPath 82 | target.path = $$installPath 83 | INSTALLS += target qmldir 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /telegramqml_global.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMQML_GLOBAL 2 | #define TELEGRAMQML_GLOBAL 3 | 4 | #include 5 | 6 | #ifdef TELEGRAMQML_EMBEDED_MODE 7 | #define TELEGRAMQMLSHARED_EXPORT 8 | #else 9 | #if defined(TELEGRAMQML_LIBRARY) 10 | # define TELEGRAMQMLSHARED_EXPORT Q_DECL_EXPORT 11 | #else 12 | # define TELEGRAMQMLSHARED_EXPORT Q_DECL_IMPORT 13 | #endif 14 | #endif 15 | 16 | #endif // TELEGRAMQML_GLOBAL 17 | 18 | -------------------------------------------------------------------------------- /telegramqml_macros.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMQML_MACROS 2 | #define TELEGRAMQML_MACROS 3 | 4 | #include 5 | 6 | #define SECRETCHAT_CLASS_TYPE 0x74697f 7 | 8 | #endif // TELEGRAMQML_MACROS 9 | 10 | -------------------------------------------------------------------------------- /telegramqml_plugin.cpp: -------------------------------------------------------------------------------- 1 | #include "telegramqml_plugin.h" 2 | #include "telegramqmlinitializer.h" 3 | 4 | #include 5 | 6 | void TelegramQmlPlugin::registerTypes(const char *uri) 7 | { 8 | // @uri com.mycompany.qmlcomponents 9 | TelegramQmlInitializer::init(uri); 10 | } 11 | -------------------------------------------------------------------------------- /telegramqml_plugin.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMQML_PLUGIN_H 2 | #define TELEGRAMQML_PLUGIN_H 3 | 4 | #include 5 | 6 | class TelegramQmlPlugin : public QQmlExtensionPlugin 7 | { 8 | Q_OBJECT 9 | Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) 10 | 11 | public: 12 | void registerTypes(const char *uri); 13 | }; 14 | 15 | #endif // TELEGRAMQML_PLUGIN_H 16 | 17 | -------------------------------------------------------------------------------- /telegramqmlinitializer.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMQMLINITIALIZER_H 2 | #define TELEGRAMQMLINITIALIZER_H 3 | 4 | #include "telegramqml_global.h" 5 | 6 | #include 7 | 8 | class QQmlEngine; 9 | class QJSEngine; 10 | class QObject; 11 | class TELEGRAMQMLSHARED_EXPORT TelegramQmlInitializer 12 | { 13 | public: 14 | #ifdef ASEMAN_STATIC_BUILD 15 | static bool registerTypes(); 16 | #endif 17 | 18 | static void init(const char *uri, bool exportMode = false); 19 | 20 | template 21 | static int registerType(const char *uri, int versionMajor, int versionMinor, const char *typeName, bool exportMode); 22 | 23 | template 24 | static int registerModel(const char *uri, int versionMajor, int versionMinor, const char *typeName, bool exportMode); 25 | 26 | template 27 | static int registerSingletonType(const char *uri, int versionMajor, int versionMinor, const char *typeName, 28 | QObject *(*callback)(QQmlEngine *, QJSEngine *), bool exportMode); 29 | 30 | template 31 | static int registerUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason, bool exportMode); 32 | 33 | static void exportDocuments(const QString &destination); 34 | 35 | private: 36 | static void initializeTypes(const char *uri); 37 | 38 | protected: 39 | template 40 | static QString exportItem(const QString &module, int major, int minor, const QString &component, bool store = true); 41 | template 42 | static QString exportModel(const QString &module, int major, int minor, const QString &component); 43 | 44 | static QString fixType(const QString &type); 45 | 46 | private: 47 | #ifdef ASEMAN_STATIC_BUILD 48 | static bool static_types_registered; 49 | #endif 50 | }; 51 | 52 | #endif // TELEGRAMQMLINITIALIZER_H 53 | -------------------------------------------------------------------------------- /telegramqmlsharedpointer.cpp: -------------------------------------------------------------------------------- 1 | #include "telegramqmlsharedpointer.h" 2 | #include "tqbaseobject.h" 3 | 4 | TelegramQmlSharedPointer::TelegramQmlSharedPointer(QObject *parent) : 5 | QObject(parent) 6 | { 7 | 8 | } 9 | 10 | void TelegramQmlSharedPointer::setObject(QObject *object) 11 | { 12 | if(object == mObject) 13 | return; 14 | 15 | if(mObject) disconnect(mObject.data(), &QObject::destroyed, this, &TelegramQmlSharedPointer::clean); 16 | mObject = object; 17 | if(mObject) connect(mObject.data(), &QObject::destroyed, this, &TelegramQmlSharedPointer::clean); 18 | 19 | Q_EMIT objectChanged(); 20 | } 21 | 22 | QObject *TelegramQmlSharedPointer::object() const 23 | { 24 | return mObject; 25 | } 26 | 27 | QStringList TelegramQmlSharedPointer::requiredProperties() 28 | { 29 | return QStringList() << FUNCTION_NAME(object); 30 | } 31 | 32 | void TelegramQmlSharedPointer::clean() 33 | { 34 | mObject = 0; 35 | } 36 | 37 | TelegramQmlSharedPointer::~TelegramQmlSharedPointer() 38 | { 39 | 40 | } 41 | -------------------------------------------------------------------------------- /telegramqmlsharedpointer.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMQMLSHAREDPOINTER_H 2 | #define TELEGRAMQMLSHAREDPOINTER_H 3 | 4 | #include 5 | 6 | #include "telegramsharedpointer.h" 7 | 8 | class TelegramQmlSharedPointer : public QObject 9 | { 10 | Q_OBJECT 11 | Q_PROPERTY(QObject* object READ object WRITE setObject NOTIFY objectChanged) 12 | 13 | public: 14 | TelegramQmlSharedPointer(QObject *parent = 0); 15 | virtual ~TelegramQmlSharedPointer(); 16 | 17 | void setObject(QObject *object); 18 | QObject *object() const; 19 | 20 | static QStringList requiredProperties(); 21 | 22 | public Q_SLOTS: 23 | void clean(); 24 | 25 | Q_SIGNALS: 26 | void objectChanged(); 27 | 28 | private: 29 | TelegramSharedPointer mObject; 30 | }; 31 | 32 | #endif // TELEGRAMQMLSHAREDPOINTER_H 33 | -------------------------------------------------------------------------------- /telegramshareddatamanager.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMSHAREDDATAMANAGER_H 2 | #define TELEGRAMSHAREDDATAMANAGER_H 3 | 4 | #include 5 | #include 6 | 7 | #include "telegramsharedpointer.h" 8 | #include "private/telegramfilelocation.h" 9 | #include "telegramqml_global.h" 10 | 11 | #include 12 | #include 13 | 14 | class TelegramSharedDataManagerPrivate; 15 | class TELEGRAMQMLSHARED_EXPORT TelegramSharedDataManager : public QObject 16 | { 17 | Q_OBJECT 18 | public: 19 | TelegramSharedDataManager(QObject *parent = 0); 20 | virtual ~TelegramSharedDataManager(); 21 | 22 | TelegramSharedPointer insertDialog(const Dialog &dialog, QByteArray *key = 0); 23 | TelegramSharedPointer insertMessage(const Message &message, QByteArray *key = 0x0); 24 | TelegramSharedPointer insertChat(const Chat &chat, QByteArray *key = 0); 25 | TelegramSharedPointer insertUser(const User &user, QByteArray *key = 0); 26 | TelegramSharedPointer insertInputPeer(const InputPeer &peer, QByteArray *key = 0); 27 | TelegramSharedPointer insertUserFull(const UserFull &user, QByteArray *key = 0); 28 | TelegramSharedPointer insertChatFull(const ChatFull &user, QByteArray *key = 0); 29 | TelegramSharedPointer insertStickerSet(const StickerSet &stickerSet, QByteArray *key = 0); 30 | TelegramSharedPointer insertDocument(const Document &document, QByteArray *key = 0); 31 | 32 | TelegramSharedPointer getDialog(const QByteArray &byte); 33 | TelegramSharedPointer getMessage(const QByteArray &byte); 34 | TelegramSharedPointer getChat(const QByteArray &byte); 35 | TelegramSharedPointer getUser(const QByteArray &byte); 36 | TelegramSharedPointer getUserFull(const QByteArray &byte); 37 | TelegramSharedPointer getChatFull(const QByteArray &byte); 38 | TelegramSharedPointer getStickerSet(const QByteArray &byte); 39 | TelegramSharedPointer getDocument(const QByteArray &byte); 40 | 41 | QList dialogs(); 42 | QList messages(); 43 | QList chats(); 44 | QList users(); 45 | 46 | private: 47 | TelegramSharedDataManagerPrivate *p; 48 | }; 49 | 50 | #endif // TELEGRAMSHAREDDATAMANAGER_H 51 | -------------------------------------------------------------------------------- /telegramsharedpointer.cpp: -------------------------------------------------------------------------------- 1 | #include "telegramsharedpointer.h" 2 | 3 | #include 4 | #include 5 | 6 | #ifndef DISABLE_SHARED_POINTER 7 | QHash > tg_share_pointer_data; 8 | 9 | void tg_share_pointer_append(void *dis, void *ptr) 10 | { 11 | tg_share_pointer_data[ptr].insert(dis); 12 | } 13 | 14 | bool tg_share_pointer_remove(void *dis, void *ptr) 15 | { 16 | tg_share_pointer_data[ptr].remove(dis); 17 | if(tg_share_pointer_data[ptr].isEmpty()) 18 | { 19 | tg_share_pointer_data.remove(ptr); 20 | return true; 21 | } 22 | else 23 | return false; 24 | } 25 | 26 | bool tg_share_pointer_contains(void *ptr) 27 | { 28 | return tg_share_pointer_data.contains(ptr); 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /telegramsharedpointer.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMSHAREDPOINTER_H 2 | #define TELEGRAMSHAREDPOINTER_H 3 | 4 | #include "telegramqml_global.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class TelegramTypeQObject; 12 | 13 | void TELEGRAMQMLSHARED_EXPORT tg_share_pointer_append(void *dis, void *ptr); 14 | bool TELEGRAMQMLSHARED_EXPORT tg_share_pointer_remove(void *dis, void *ptr); 15 | bool TELEGRAMQMLSHARED_EXPORT tg_share_pointer_contains(void *ptr); 16 | 17 | #ifdef DISABLE_SHARED_POINTER 18 | template 19 | using TelegramSharedPointer = T*; 20 | #else 21 | template 22 | class TELEGRAMQMLSHARED_EXPORT TelegramSharedPointer 23 | { 24 | public: 25 | TelegramSharedPointer(T *ptr = 0): value(0) { operator =(ptr); } 26 | TelegramSharedPointer(const TelegramSharedPointer &b): value(0) { operator =(b.value); } 27 | virtual ~TelegramSharedPointer() { operator =(0); } 28 | 29 | static bool contains(void *ptr) { return tg_share_pointer_contains(ptr); } 30 | inline T *data() const { return value; } 31 | inline bool isNull() const { return !data(); } 32 | inline bool operator !() const { return isNull(); } 33 | inline T &operator*() const { return *data(); } 34 | inline T *operator->() const { return data(); } 35 | inline operator T*() const { return data(); } 36 | inline bool operator!=(T *b) { return !operator==(b); } 37 | inline bool operator==(T *b) { return value == b; } 38 | inline bool operator!=(const TelegramSharedPointer &b) { return !operator==(b); } 39 | inline bool operator==(const TelegramSharedPointer &b) { return value == b.value; } 40 | inline void operator=(const TelegramSharedPointer &b) { operator=(b.value); } 41 | inline void operator=(T *b) { 42 | if(b == value) return; 43 | if(b) tg_share_pointer_append(this, b); 44 | if(value && tg_share_pointer_remove(this, value)) 45 | delete value; 46 | value = b; 47 | } 48 | 49 | private: 50 | T *value; 51 | }; 52 | #endif 53 | 54 | inline bool operator==(const TelegramSharedPointer &e1, const TelegramSharedPointer &e2) 55 | { 56 | return e1.data() == e2.data(); 57 | } 58 | 59 | inline uint qHash(const TelegramSharedPointer &key, uint seed) 60 | { 61 | return qHash(static_cast(key.data()), seed); 62 | } 63 | 64 | #endif // TELEGRAMSHAREDPOINTER_H 65 | -------------------------------------------------------------------------------- /telegramstatus.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMSTATUS_H 2 | #define TELEGRAMSTATUS_H 3 | 4 | #include "telegramengine.h" 5 | #include "tqobject.h" 6 | 7 | class SendMessageActionObject; 8 | class InputPeerObject; 9 | class TelegramStatusTyping; 10 | class TelegramStatusPrivate; 11 | class TELEGRAMQMLSHARED_EXPORT TelegramStatus : public TqObject 12 | { 13 | Q_OBJECT 14 | Q_PROPERTY(TelegramEngine* engine READ engine WRITE setEngine NOTIFY engineChanged) 15 | Q_PROPERTY(bool online READ online WRITE setOnline NOTIFY onlineChanged) 16 | Q_PROPERTY(TelegramStatusTyping* typing READ typing WRITE setTyping NOTIFY typingChanged) 17 | 18 | public: 19 | TelegramStatus(QObject *parent = 0); 20 | virtual ~TelegramStatus(); 21 | 22 | void setEngine(TelegramEngine *engine); 23 | TelegramEngine *engine() const; 24 | 25 | void setOnline(bool online); 26 | bool online() const; 27 | 28 | void setTyping(TelegramStatusTyping *typing); 29 | TelegramStatusTyping *typing() const; 30 | 31 | static QStringList requiredProperties(); 32 | 33 | Q_SIGNALS: 34 | void engineChanged(); 35 | void onlineChanged(); 36 | void typingChanged(); 37 | 38 | public Q_SLOTS: 39 | void requestStatus(bool online); 40 | void requestTyping(InputPeerObject *peer, SendMessageActionObject *action); 41 | 42 | protected: 43 | void refresh(); 44 | void timerEvent(QTimerEvent *e); 45 | 46 | private: 47 | TelegramStatusPrivate *p; 48 | }; 49 | 50 | #endif // TELEGRAMSTATUS_H 51 | -------------------------------------------------------------------------------- /telegramstatustyping.cpp: -------------------------------------------------------------------------------- 1 | #include "telegramstatustyping.h" 2 | #include "telegramsharedpointer.h" 3 | #include "tqbaseobject.h" 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | class TelegramStatusTypingPrivate 11 | { 12 | public: 13 | TelegramSharedPointer peer; 14 | QPointer action; 15 | }; 16 | 17 | TelegramStatusTyping::TelegramStatusTyping(QObject *parent) : 18 | QObject(parent) 19 | { 20 | p = new TelegramStatusTypingPrivate; 21 | setAction(new SendMessageActionObject(this)); 22 | p->action->setClassType(SendMessageActionObject::TypeSendMessageTypingAction); 23 | 24 | connect(this, &TelegramStatusTyping::actionChanged, this, &TelegramStatusTyping::changed); 25 | } 26 | 27 | void TelegramStatusTyping::setPeer(InputPeerObject *peer) 28 | { 29 | if(p->peer == peer) 30 | return; 31 | 32 | p->peer = peer; 33 | Q_EMIT peerChanged(); 34 | Q_EMIT changed(); 35 | } 36 | 37 | InputPeerObject *TelegramStatusTyping::peer() const 38 | { 39 | return p->peer; 40 | } 41 | 42 | void TelegramStatusTyping::setAction(SendMessageActionObject *action) 43 | { 44 | if(p->action == action) 45 | return; 46 | 47 | if(p->action) 48 | disconnect(p->action.data(), &SendMessageActionObject::coreChanged, this, &TelegramStatusTyping::actionChanged); 49 | p->action = action; 50 | if(p->action) 51 | connect(p->action.data(), &SendMessageActionObject::coreChanged, this, &TelegramStatusTyping::actionChanged); 52 | 53 | Q_EMIT actionChanged(); 54 | } 55 | 56 | SendMessageActionObject *TelegramStatusTyping::action() 57 | { 58 | return p->action; 59 | } 60 | 61 | QStringList TelegramStatusTyping::requiredProperties() 62 | { 63 | return QStringList() << FUNCTION_NAME(peer); 64 | } 65 | 66 | TelegramStatusTyping::~TelegramStatusTyping() 67 | { 68 | delete p; 69 | } 70 | 71 | -------------------------------------------------------------------------------- /telegramstatustyping.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMSTATUSTYPING_H 2 | #define TELEGRAMSTATUSTYPING_H 3 | 4 | #include 5 | 6 | #include "telegramqml_global.h" 7 | 8 | class SendMessageActionObject; 9 | class InputPeerObject; 10 | class TelegramStatusTypingPrivate; 11 | class TELEGRAMQMLSHARED_EXPORT TelegramStatusTyping : public QObject 12 | { 13 | Q_OBJECT 14 | Q_PROPERTY(InputPeerObject* peer READ peer WRITE setPeer NOTIFY peerChanged) 15 | Q_PROPERTY(SendMessageActionObject* action READ action WRITE setAction NOTIFY actionChanged) 16 | 17 | public: 18 | TelegramStatusTyping(QObject *parent = 0); 19 | virtual ~TelegramStatusTyping(); 20 | 21 | void setPeer(InputPeerObject *peer); 22 | InputPeerObject *peer() const; 23 | 24 | void setAction(SendMessageActionObject *action); 25 | SendMessageActionObject *action(); 26 | 27 | static QStringList requiredProperties(); 28 | 29 | Q_SIGNALS: 30 | void peerChanged(); 31 | void actionChanged(); 32 | void changed(); 33 | 34 | public Q_SLOTS: 35 | 36 | private: 37 | TelegramStatusTypingPrivate *p; 38 | }; 39 | 40 | #endif // TELEGRAMSTATUSTYPING_H 41 | -------------------------------------------------------------------------------- /telegramstickerscategoriesmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMSTICKERSCATEGORIESMODEL_H 2 | #define TELEGRAMSTICKERSCATEGORIESMODEL_H 3 | 4 | #include "telegramqml_macros.h" 5 | #include "telegramqml_global.h" 6 | #include "telegramabstractenginelistmodel.h" 7 | 8 | class TelegramStickersCategoriesItem; 9 | class TelegramStickersCategoriesModelPrivate; 10 | class TelegramStickersCategoriesModel : public TelegramAbstractEngineListModel 11 | { 12 | Q_OBJECT 13 | Q_PROPERTY(bool refreshing READ refreshing NOTIFY refreshingChanged) 14 | Q_ENUMS(DataRoles) 15 | 16 | public: 17 | enum DataRoles { 18 | RoleStickerSetItem = Qt::UserRole, 19 | RoleInstalled, 20 | RoleDisabled, 21 | RoleArchived, 22 | RoleOfficial, 23 | RoleTitle, 24 | RoleShortName, 25 | RoleCount, 26 | RoleHash, 27 | RoleInputItem, 28 | RoleDocumentItems 29 | }; 30 | 31 | TelegramStickersCategoriesModel(QObject *parent = 0); 32 | virtual ~TelegramStickersCategoriesModel(); 33 | 34 | bool refreshing() const; 35 | 36 | QByteArray id(const QModelIndex &index) const; 37 | int count() const; 38 | QVariant data(const QModelIndex &index, int role) const; 39 | 40 | QHash roleNames() const; 41 | static QStringList requiredProperties(); 42 | 43 | Q_SIGNALS: 44 | void refreshingChanged(); 45 | 46 | public Q_SLOTS: 47 | 48 | protected: 49 | void refresh(); 50 | void clean(); 51 | void getStickersFromServer(); 52 | 53 | void setRefreshing(bool refreshing); 54 | 55 | private: 56 | void changed(const QList &order, const QHash &items); 57 | 58 | private: 59 | TelegramStickersCategoriesModelPrivate *p; 60 | }; 61 | 62 | #endif // TELEGRAMSTICKERSCATEGORIESMODEL_H 63 | -------------------------------------------------------------------------------- /telegramstickersmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMSTICKERSMODEL_H 2 | #define TELEGRAMSTICKERSMODEL_H 3 | 4 | #include 5 | 6 | #include "telegramqml_macros.h" 7 | #include "telegramqml_global.h" 8 | #include "telegramabstractenginelistmodel.h" 9 | 10 | class TelegramStickersItem; 11 | class DocumentObject; 12 | class InputStickerSetObject; 13 | class TelegramEngine; 14 | class TelegramStickersModelPrivate; 15 | class TELEGRAMQMLSHARED_EXPORT TelegramStickersModel : public TelegramAbstractEngineListModel 16 | { 17 | Q_OBJECT 18 | Q_ENUMS(DialogsRoles) 19 | Q_PROPERTY(bool refreshing READ refreshing NOTIFY refreshingChanged) 20 | Q_PROPERTY(QString shortName READ shortName WRITE setShortName NOTIFY shortNameChanged) 21 | Q_PROPERTY(InputStickerSetObject* stickerSet READ stickerSet WRITE setStickerSet NOTIFY stickerSetChanged) 22 | Q_PROPERTY(QVariantList documents READ documents WRITE setDocuments NOTIFY documentsChanged) 23 | 24 | public: 25 | enum DialogsRoles { 26 | RoleDocument = Qt::UserRole, 27 | RoleAlt 28 | }; 29 | 30 | TelegramStickersModel(QObject *parent = 0); 31 | virtual ~TelegramStickersModel(); 32 | 33 | QString shortName() const; 34 | void setShortName(const QString &shortName); 35 | 36 | void setStickerSet(InputStickerSetObject *stickerSet); 37 | InputStickerSetObject *stickerSet() const; 38 | 39 | void setDocuments(const QVariantList &list); 40 | QVariantList documents() const; 41 | 42 | QByteArray id( const QModelIndex &index ) const; 43 | int count() const; 44 | 45 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 46 | 47 | QHash roleNames() const; 48 | 49 | bool refreshing() const; 50 | static QStringList requiredProperties(); 51 | 52 | public Q_SLOTS: 53 | void showRecents(); 54 | void addToRecents(DocumentObject *doc); 55 | 56 | Q_SIGNALS: 57 | void engineChanged(); 58 | void refreshingChanged(); 59 | void stickerSetChanged(); 60 | void shortNameChanged(); 61 | void documentsChanged(); 62 | 63 | protected: 64 | void refresh(); 65 | void clean(); 66 | void getFromServer(); 67 | void changed(const QList &list, const QHash &items); 68 | 69 | private: 70 | TelegramStickersModelPrivate *p; 71 | }; 72 | 73 | #endif // TELEGRAMSTICKERSMODEL_H 74 | -------------------------------------------------------------------------------- /telegramtesttools.cpp: -------------------------------------------------------------------------------- 1 | #include "telegramtesttools.h" 2 | 3 | #include 4 | 5 | class TelegramTestToolsPrivate 6 | { 7 | public: 8 | }; 9 | 10 | TelegramTestTools::TelegramTestTools(QObject *parent) : 11 | QObject(parent) 12 | { 13 | p = new TelegramTestToolsPrivate; 14 | } 15 | 16 | void TelegramTestTools::connectDestroy(QObject *obj, const QJSValue &callback) 17 | { 18 | qDebug() << "added" << obj; 19 | connect(obj, &QObject::destroyed, this, [this, callback, obj](){ 20 | QJSValue jsCallback = callback; 21 | qDebug() << "destroyed" << obj; 22 | jsCallback.call(); 23 | }); 24 | } 25 | 26 | TelegramTestTools::~TelegramTestTools() 27 | { 28 | delete p; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /telegramtesttools.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMTESTTOOLS_H 2 | #define TELEGRAMTESTTOOLS_H 3 | 4 | #include 5 | #include 6 | 7 | class TelegramTestToolsPrivate; 8 | class TelegramTestTools : public QObject 9 | { 10 | Q_OBJECT 11 | public: 12 | TelegramTestTools(QObject *parent = 0); 13 | virtual ~TelegramTestTools(); 14 | 15 | public Q_SLOTS: 16 | void connectDestroy(QObject *obj, const QJSValue &callback); 17 | 18 | Q_SIGNALS: 19 | 20 | private: 21 | TelegramTestToolsPrivate *p; 22 | }; 23 | 24 | #endif // TELEGRAMTESTTOOLS_H 25 | -------------------------------------------------------------------------------- /telegramtools.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMTOOLS_H 2 | #define TELEGRAMTOOLS_H 3 | 4 | #include "telegramqml_global.h" 5 | #include "telegramenums.h" 6 | #include "private/tqmlmessageobject.h" 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | class UserObject; 14 | class TQmlMessageObject; 15 | class TelegramTypeQObject; 16 | class TELEGRAMQMLSHARED_EXPORT TelegramTools 17 | { 18 | public: 19 | static QByteArray identifier(const Peer &peer); 20 | static QByteArray identifier(qint32 peerType, qint32 peerId); 21 | static QByteArray identifier(const InputPeer &peer); 22 | static QByteArray identifier(const Dialog &dialog); 23 | static QByteArray identifier(const Dialog &dialog, qint32 messageId); 24 | static QByteArray identifier(const Peer &peer, qint32 messageId); 25 | static QByteArray identifier(const Message &message); 26 | static QByteArray identifier(const Chat &chat); 27 | static QByteArray identifier(const User &user); 28 | static QByteArray identifier(const UserFull &user); 29 | static QByteArray identifier(const ChatFull &chat); 30 | static QByteArray identifier(const StickerSet &stickerSet); 31 | static QByteArray identifier(const Document &document); 32 | static QByteArray identifier(class SecretChat *secretChat); 33 | 34 | static class InputPeer chatInputPeer(const Chat &chat); 35 | static class InputPeer userInputPeer(const User &user); 36 | static class InputPeer peerInputPeer(const Peer &peer, qint64 accessHash); 37 | static class InputPeer secretChatInputPeer(class SecretChat *secretChat); 38 | static class SecretChat *inputPeerSecretChat(const InputPeer &inputPeer, class TelegramEngine *engine); 39 | 40 | static class Peer chatPeer(const Chat &chat); 41 | static class Peer userPeer(const User &user); 42 | static class Peer dialogPeer(const Dialog &dialog); 43 | static class Peer messagePeer(const Message &message); 44 | static class Peer messagePeer(const SecretChatMessage &message); 45 | static class Peer inputPeerPeer(const InputPeer &inputPeer); 46 | static class InputMedia mediaInputMedia(const MessageMedia &media); 47 | 48 | static Message secretMessageMessage(const SecretChatMessage &smsg, class TelegramEngine *engine); 49 | static MessageMedia decryptedMediaMessageMedia(const DecryptedMessageMedia &dmedia, const EncryptedFile &efile = EncryptedFile::typeEncryptedFileEmpty); 50 | static MessageAction decryptedActionMessageAction(const DecryptedMessageAction &daction); 51 | 52 | static qint64 generateRandomId(); 53 | static QString convertErrorToText(const QString &error); 54 | 55 | static TelegramEnums::MessageType messageType(TQmlMessageObject *msg); 56 | static TelegramTypeQObject *objectRoot(TelegramTypeQObject *object); 57 | static void analizeUpdatesType(const UpdatesType &updates, class TelegramEngine *engine, std::function callback, const Message &sentMsg = Message::null); 58 | 59 | static QString userStatus(UserObject *user, std::function dateConversationMethod); 60 | }; 61 | 62 | #endif // TELEGRAMTOOLS_H 63 | -------------------------------------------------------------------------------- /telegramtopmessagesmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMTOPMESSAGESMODEL_H 2 | #define TELEGRAMTOPMESSAGESMODEL_H 3 | 4 | #include "telegrammessagelistmodel.h" 5 | 6 | class TelegramTopMessagesModelPrivate; 7 | class TELEGRAMQMLSHARED_EXPORT TelegramTopMessagesModel : public TelegramMessageListModel 8 | { 9 | Q_OBJECT 10 | Q_ENUMS(VisibleTypes) 11 | Q_PROPERTY(int dialogsLimit READ dialogsLimit WRITE setDialogsLimit NOTIFY dialogsLimitChanged) 12 | Q_PROPERTY(int visibleType READ visibleType WRITE setVisibleType NOTIFY visibleTypeChanged) 13 | 14 | public: 15 | enum VisibleTypes { 16 | VisibleTypeNone = 0, 17 | VisibleTypeChannel = 1, 18 | VisibleTypeChat = 2, 19 | VisibleTypeUser = 4, 20 | VisibleTypeMegaGroup = 8, 21 | VisibleTypeAll = VisibleTypeChannel | VisibleTypeChat | VisibleTypeUser | VisibleTypeMegaGroup 22 | }; 23 | 24 | TelegramTopMessagesModel(QObject *parent = 0); 25 | virtual ~TelegramTopMessagesModel(); 26 | 27 | void setDialogsLimit(int dialogsLimit); 28 | int dialogsLimit() const; 29 | 30 | void setVisibleType(int visibleType); 31 | int visibleType() const; 32 | 33 | Q_SIGNALS: 34 | void dialogsLimitChanged(); 35 | void visibleTypeChanged(); 36 | 37 | public Q_SLOTS: 38 | void recheck(); 39 | 40 | protected: 41 | virtual void refresh(); 42 | void loadDialogs(const QList &peers, const QList &dialogs); 43 | 44 | private: 45 | void loadDialogs_prv(QList peers, QList dialogs); 46 | 47 | private: 48 | TelegramTopMessagesModelPrivate *p; 49 | }; 50 | 51 | #endif // TELEGRAMTOPMESSAGESMODEL_H 52 | -------------------------------------------------------------------------------- /tqbaseobject.cpp: -------------------------------------------------------------------------------- 1 | #include "tqbaseobject.h" 2 | 3 | -------------------------------------------------------------------------------- /tqbaseobject.h: -------------------------------------------------------------------------------- 1 | #ifndef TQBASEOBJECT_H 2 | #define TQBASEOBJECT_H 3 | 4 | #include 5 | #include 6 | 7 | #define FUNCTION_NAME(FNC) #FNC 8 | 9 | class TqBaseObject 10 | { 11 | public: 12 | TqBaseObject(){} 13 | virtual ~TqBaseObject(){} 14 | }; 15 | 16 | #endif // TQBASEOBJECT_H 17 | -------------------------------------------------------------------------------- /tqmldocumentexporter.cpp: -------------------------------------------------------------------------------- 1 | #include "tqmldocumentexporter.h" 2 | #include "telegramqmlinitializer.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | class MessagesFilterObj : public MessagesFilterObject 12 | { 13 | public: 14 | static QStringList requiredProperties() { 15 | return QStringList(); 16 | } 17 | }; 18 | 19 | class TqmlDocumentExporterPrivate 20 | { 21 | public: 22 | QString destination; 23 | QStringList indexCache; 24 | }; 25 | 26 | TqmlDocumentExporter::TqmlDocumentExporter(QObject *parent) : 27 | QObject(parent) 28 | { 29 | p = new TqmlDocumentExporterPrivate; 30 | } 31 | 32 | TqmlDocumentExporter::~TqmlDocumentExporter() 33 | { 34 | delete p; 35 | } 36 | 37 | void TqmlDocumentExporter::setDestination(const QString &destination) 38 | { 39 | if(p->destination == destination) 40 | return; 41 | 42 | p->destination = destination; 43 | Q_EMIT destinationChanged(); 44 | } 45 | 46 | QString TqmlDocumentExporter::destination() const 47 | { 48 | return p->destination; 49 | } 50 | 51 | void TqmlDocumentExporter::exportDocuments() 52 | { 53 | TelegramQmlInitializer::exportDocuments(p->destination); 54 | } 55 | -------------------------------------------------------------------------------- /tqmldocumentexporter.h: -------------------------------------------------------------------------------- 1 | #ifndef TQMLDOCUMENTEXPORTER_H 2 | #define TQMLDOCUMENTEXPORTER_H 3 | 4 | #include 5 | 6 | class TqmlDocumentExporterPrivate; 7 | class TqmlDocumentExporter : public QObject 8 | { 9 | Q_OBJECT 10 | Q_PROPERTY(QString destination READ destination WRITE setDestination NOTIFY destinationChanged) 11 | 12 | public: 13 | TqmlDocumentExporter(QObject *parent = 0); 14 | virtual ~TqmlDocumentExporter(); 15 | 16 | void setDestination(const QString &destination); 17 | QString destination() const; 18 | 19 | Q_SIGNALS: 20 | void destinationChanged(); 21 | 22 | public Q_SLOTS: 23 | void exportDocuments(); 24 | 25 | private: 26 | TqmlDocumentExporterPrivate *p; 27 | }; 28 | 29 | #endif // TQMLDOCUMENTEXPORTER_H 30 | -------------------------------------------------------------------------------- /tqmlresource.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | database/profiles.sqlite 4 | database/userdata.sqlite 5 | database/database.sqlite 6 | files/tg-server.pub 7 | 8 | 9 | -------------------------------------------------------------------------------- /tqobject.cpp: -------------------------------------------------------------------------------- 1 | #include "tqobject.h" 2 | 3 | #include 4 | 5 | QSet tq_object_instances; 6 | 7 | TqObject::TqObject(QObject *parent) : 8 | QObject(parent), 9 | mErrorCode(0) 10 | { 11 | tq_object_instances.insert(this); 12 | } 13 | 14 | QQmlListProperty TqObject::items() 15 | { 16 | return QQmlListProperty(this, &_items, QQmlListProperty::AppendFunction(append), 17 | QQmlListProperty::CountFunction(count), 18 | QQmlListProperty::AtFunction(at), 19 | QQmlListProperty::ClearFunction(clear) ); 20 | } 21 | 22 | void TqObject::append(QQmlListProperty *p, QObject *v) 23 | { 24 | TqObject *aobj = static_cast(p->object); 25 | aobj->_items.append(v); 26 | Q_EMIT aobj->itemsChanged(); 27 | } 28 | 29 | int TqObject::count(QQmlListProperty *p) 30 | { 31 | TqObject *aobj = static_cast(p->object); 32 | return aobj->_items.count(); 33 | } 34 | 35 | QObject *TqObject::at(QQmlListProperty *p, int idx) 36 | { 37 | TqObject *aobj = static_cast(p->object); 38 | return aobj->_items.at(idx); 39 | } 40 | 41 | void TqObject::clear(QQmlListProperty *p) 42 | { 43 | TqObject *aobj = static_cast(p->object); 44 | aobj->_items.clear(); 45 | Q_EMIT aobj->itemsChanged(); 46 | } 47 | 48 | bool TqObject::isValid(TqObject *obj) 49 | { 50 | return tq_object_instances.contains(obj); 51 | } 52 | 53 | TqObject::~TqObject() 54 | { 55 | tq_object_instances.remove(this); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /tqobject.h: -------------------------------------------------------------------------------- 1 | #ifndef TQOBJECT_H 2 | #define TQOBJECT_H 3 | 4 | #include 5 | #include 6 | 7 | #include "telegramtools.h" 8 | #include "telegramqml_global.h" 9 | #include "tqbaseobject.h" 10 | 11 | #define tqobject_cast(OBJECT) static_cast(OBJECT) 12 | 13 | class TELEGRAMQMLSHARED_EXPORT TqObject : public QObject, public TqBaseObject 14 | { 15 | Q_OBJECT 16 | Q_PROPERTY(QString errorText READ errorText NOTIFY errorChanged) 17 | Q_PROPERTY(qint32 errorCode READ errorCode NOTIFY errorChanged) 18 | Q_PROPERTY(QQmlListProperty items READ items NOTIFY itemsChanged) 19 | Q_CLASSINFO("DefaultProperty", "items") 20 | 21 | public: 22 | Q_INVOKABLE explicit TqObject(QObject *parent = 0); 23 | virtual ~TqObject(); 24 | 25 | static bool isValid(TqObject *obj); 26 | 27 | QString errorText() const { return mErrorText; } 28 | qint32 errorCode() const { return mErrorCode; } 29 | 30 | QQmlListProperty items(); 31 | static QStringList requiredProperties() { 32 | return QStringList(); 33 | } 34 | 35 | Q_SIGNALS: 36 | void errorChanged(); 37 | void itemsChanged(); 38 | 39 | protected: 40 | void setError(const QString &errorText, qint32 errorCode) { 41 | mErrorText = TelegramTools::convertErrorToText(errorText); 42 | mErrorCode = errorCode; 43 | Q_EMIT errorChanged(); 44 | } 45 | 46 | private: 47 | static void append(QQmlListProperty *p, QObject *v); 48 | static int count(QQmlListProperty *p); 49 | static QObject *at(QQmlListProperty *p, int idx); 50 | static void clear(QQmlListProperty *p); 51 | 52 | protected: 53 | QList _items; 54 | 55 | private: 56 | QString mErrorText; 57 | qint32 mErrorCode; 58 | }; 59 | 60 | #endif // TQOBJECT_H 61 | --------------------------------------------------------------------------------