├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── CONTRIBUTORS ├── README.md ├── TelegramQt.pro ├── depecher.astylerc ├── depecher ├── .gitignore ├── ModelTest.cpp ├── ModelTest.hpp ├── TODO.txt ├── dbus │ ├── ChatShareAdaptor.cpp │ ├── ChatShareAdaptor.hpp │ ├── DBusShareAdaptor.cpp │ ├── DBusShareAdaptor.hpp │ ├── DBusShareAdaptorWrapper.cpp │ ├── DBusShareAdaptorWrapper.hpp │ ├── DepecherAdaptor.cpp │ ├── DepecherAdaptor.hpp │ ├── depecher-dbus-access.conf │ ├── org.blacksailer.depecher.service │ ├── org.blacksailer.depecher.share.xml │ ├── org.blacksailer.depecher.xml │ └── sailfish_access.c ├── depecher.desktop ├── depecher.pro ├── events │ ├── depecher_im.ini │ ├── depecher_im_exists.ini │ └── depecher_im_fg.ini ├── icons │ ├── 108x108 │ │ └── depecher.png │ ├── 128x128 │ │ └── depecher.png │ ├── 256x256 │ │ └── depecher.png │ ├── 86x86 │ │ └── depecher.png │ ├── depecher_3.png │ └── depecher_icon.svg ├── notificationcategories │ ├── x-depecher.im.conf │ └── x-depecher.im.fg.conf ├── qml │ ├── Background.qml │ ├── ShareUI.qml │ ├── app.qml │ ├── assets │ │ ├── background │ │ │ └── dark.jpg │ │ └── icons │ │ │ ├── check.svg │ │ │ ├── depecher.png │ │ │ ├── en_sailfish.jpg │ │ │ ├── git.svg │ │ │ ├── it_sailfish.jpg │ │ │ ├── lock_slide.svg │ │ │ ├── lock_slide_40x80.png │ │ │ ├── lock_slide_80x40.png │ │ │ ├── paypal.svg │ │ │ ├── rocket.svg │ │ │ └── ru_sailfish.jpg │ ├── cover │ │ └── CoverPage.qml │ ├── js │ │ ├── countries.js │ │ ├── mimetypes.js │ │ └── utils.js │ └── pages │ │ ├── AboutPage.qml │ │ ├── AuthorizeDialog.qml │ │ ├── ChannelInfoPage.qml │ │ ├── ContactsPage.qml │ │ ├── DialogsPage.qml │ │ ├── FilterMessagesPage.qml │ │ ├── GroupInfoPage.qml │ │ ├── MessagingPage.qml │ │ ├── PicturePage.qml │ │ ├── SelectChatDialog.qml │ │ ├── SettingsPage.qml │ │ ├── UserPage.qml │ │ ├── VideoPage.qml │ │ ├── components │ │ ├── ChatItem.qml │ │ ├── ChatItemShare.qml │ │ ├── MenuComponent.qml │ │ ├── NotificationPanel.qml │ │ ├── PreviewStickerSetDialog.qml │ │ ├── authorization │ │ │ ├── AreYouSureDialog.qml │ │ │ ├── EncryptionKeyDialog.qml │ │ │ └── SignInDialog.qml │ │ └── settings │ │ │ ├── AppearancePage.qml │ │ │ ├── BehaviorPage.qml │ │ │ ├── ProxyDialog.qml │ │ │ ├── ProxyPage.qml │ │ │ └── proxypage.qrc │ │ └── items │ │ ├── AttachComponent.qml │ │ ├── AttachSticker.qml │ │ ├── CircleImage.qml │ │ ├── MessageItem.qml │ │ ├── ShareComponent.qml │ │ ├── StickerPreviewComponent.qml │ │ ├── VoiceButton.qml │ │ ├── WritingItem.qml │ │ ├── delegates │ │ ├── AnimationDelegate.qml │ │ ├── AudioDelegate.qml │ │ ├── ChatCreatedDelegate.qml │ │ ├── ContactDelegate.qml │ │ ├── DocumentDelegate.qml │ │ ├── ImageDelegate.qml │ │ ├── JoinByLinkDelegate.qml │ │ ├── JoinedDelegate.qml │ │ ├── NewMessageDelegate.qml │ │ ├── RichTextItem.qml │ │ ├── StickerDelegate.qml │ │ ├── TextDelegate.qml │ │ ├── TopMarginDelegate.qml │ │ ├── VideoDelegate.qml │ │ ├── VideoNoteDelegate.qml │ │ ├── VoiceNoteDelegate.qml │ │ └── utils.js │ │ └── filter_delegates │ │ ├── AudioView.qml │ │ ├── DocumentView.qml │ │ ├── LinkView.qml │ │ ├── PhotoView.qml │ │ ├── SharedContent.qml │ │ ├── VideoView.qml │ │ └── VoiceView.qml ├── qrc_resource.cpp ├── resource.qrc ├── rpm │ ├── depecher.changes.in │ ├── depecher.spec │ └── depecher.yaml ├── settings │ ├── DepecherAppSettings.qml │ └── depecher.json ├── src │ ├── DBusAdaptor.cpp │ ├── DBusAdaptor.hpp │ ├── FileWorker.cpp │ ├── FileWorker.hpp │ ├── Settings.cpp │ ├── Settings.hpp │ ├── components │ │ ├── AudioRecorder.cpp │ │ └── AudioRecorder.hpp │ ├── fileGeneratedHandlers │ │ ├── CopyFileConversion.cpp │ │ ├── CopyFileConversion.hpp │ │ ├── FileGeneratedHandler.cpp │ │ ├── FileGeneratedHandler.hpp │ │ ├── FileGeneratedInterface.hpp │ │ ├── FileLoaderFromHTTP │ │ ├── PhotoCompressor │ │ ├── VideoCompressor │ │ ├── copyFromOutsideCache │ │ ├── inputFileGeneratedHandlerFactory │ │ └── voiceToOgg │ ├── main.cpp │ └── singletons │ │ ├── DNSTXTLookup.cpp │ │ ├── DNSTXTLookup.hpp │ │ ├── PageAppStarter.cpp │ │ └── PageAppStarter.hpp ├── systemd │ └── org.blacksailer.depecher.service └── translations │ ├── depecher-de.ts │ ├── depecher-es.ts │ ├── depecher-fi.ts │ ├── depecher-hu.ts │ ├── depecher-it.ts │ ├── depecher-sv.ts │ ├── depecher-zh_CN.ts │ └── depecher.ts ├── icons ├── icons.pro └── svgs │ └── icon-m-depecher.svg ├── rpm ├── sharechat ├── ChatShareModel.cpp ├── ChatShareModel.hpp ├── ShareChatPlugin.cpp ├── ShareChatPlugin.hpp ├── qmldir └── sharechat.pro ├── shareui ├── DepecherMediaTransfer.cpp ├── DepecherMediaTransfer.hpp ├── DepecherPluginInfo.cpp ├── DepecherPluginInfo.hpp ├── DepecherTransferIface.cpp ├── DepecherTransferIface.hpp └── shareui.pro ├── tdlibjson_wrapper ├── .gitignore ├── api_secret.pri.example ├── tdlibQt │ ├── FileWriter.cpp │ ├── FileWriter.hpp │ ├── ListenObject.cpp │ ├── ListenObject.hpp │ ├── ListenScheduler.cpp │ ├── ListenScheduler.hpp │ ├── NotificationManager.cpp │ ├── NotificationManager.hpp │ ├── ParseObject.cpp │ ├── ParseObject.hpp │ ├── TdlibJsonWrapper.cpp │ ├── TdlibJsonWrapper.hpp │ ├── TelegramProfileProvider.cpp │ ├── TelegramProfileProvider.hpp │ ├── include │ │ ├── AppApiInfo.hpp.in │ │ ├── AuthenticationHandler.cpp │ │ ├── AuthenticationHandler.hpp │ │ ├── FileGeneratedInterface.hpp │ │ └── TdlibNamespace.hpp │ ├── infoProviders │ │ ├── BasicGroupInfoProvider.cpp │ │ ├── BasicGroupInfoProvider.hpp │ │ ├── ChannelInfoProvider.cpp │ │ ├── ChannelInfoProvider.hpp │ │ ├── InfoProvider.cpp │ │ ├── InfoProvider.hpp │ │ ├── UserInfoProvider.cpp │ │ ├── UserInfoProvider.hpp │ │ ├── UsernameResolver.cpp │ │ └── UsernameResolver.hpp │ ├── items │ │ ├── AboutMeDAO.cpp │ │ ├── AboutMeDAO.hpp │ │ ├── ProxyDAO.cpp │ │ ├── ProxyDAO.hpp │ │ ├── TdApi.cpp │ │ ├── TdApi.hpp │ │ ├── TdLibDependencies.hpp │ │ └── td_api.h │ └── models │ │ ├── ChatMembersModel.cpp │ │ ├── ChatMembersModel.hpp │ │ ├── ChatsModel.cpp │ │ ├── ChatsModel.hpp │ │ ├── ContactsModel.cpp │ │ ├── ContactsModel.hpp │ │ ├── FilterContactsModel.cpp │ │ ├── FilterContactsModel.hpp │ │ ├── MessagingModel.cpp │ │ ├── MessagingModel.hpp │ │ ├── SearchChatMessagesModel.cpp │ │ ├── SearchChatMessagesModel.hpp │ │ ├── SearchChatsModel.cpp │ │ ├── SearchChatsModel.hpp │ │ ├── StickerModel.cpp │ │ ├── StickerModel.hpp │ │ └── singletons │ │ ├── UsersModel.cpp │ │ └── UsersModel.hpp └── tdlibjson_wrapper.pro └── webp-plugin ├── .qmake.conf ├── libwebp.pri ├── libwebp ├── AUTHORS ├── COPYING ├── ChangeLog ├── NEWS ├── PATENTS ├── README └── src │ ├── dec │ ├── alpha.c │ ├── alphai.h │ ├── buffer.c │ ├── decode_vp8.h │ ├── frame.c │ ├── idec.c │ ├── io.c │ ├── quant.c │ ├── tree.c │ ├── vp8.c │ ├── vp8i.h │ ├── vp8l.c │ ├── vp8li.h │ ├── webp.c │ └── webpi.h │ ├── demux │ └── demux.c │ ├── dsp │ ├── alpha_processing.c │ ├── alpha_processing_sse2.c │ ├── cpu.c │ ├── dec.c │ ├── dec_clip_tables.c │ ├── dec_mips32.c │ ├── dec_neon.c │ ├── dec_sse2.c │ ├── dsp.h │ ├── enc.c │ ├── enc_avx2.c │ ├── enc_mips32.c │ ├── enc_neon.c │ ├── enc_sse2.c │ ├── lossless.c │ ├── lossless.h │ ├── lossless_mips32.c │ ├── lossless_neon.c │ ├── lossless_sse2.c │ ├── neon.h │ ├── upsampling.c │ ├── upsampling_neon.c │ ├── upsampling_sse2.c │ ├── yuv.c │ ├── yuv.h │ ├── yuv_mips32.c │ ├── yuv_sse2.c │ └── yuv_tables_sse2.h │ ├── enc │ ├── alpha.c │ ├── analysis.c │ ├── backward_references.c │ ├── backward_references.h │ ├── config.c │ ├── cost.c │ ├── cost.h │ ├── filter.c │ ├── frame.c │ ├── histogram.c │ ├── histogram.h │ ├── iterator.c │ ├── picture.c │ ├── picture_csp.c │ ├── picture_psnr.c │ ├── picture_rescale.c │ ├── picture_tools.c │ ├── quant.c │ ├── syntax.c │ ├── token.c │ ├── tree.c │ ├── vp8enci.h │ ├── vp8l.c │ ├── vp8li.h │ └── webpenc.c │ ├── mux │ ├── muxedit.c │ ├── muxi.h │ ├── muxinternal.c │ └── muxread.c │ ├── utils │ ├── bit_reader.c │ ├── bit_reader.h │ ├── bit_reader_inl.h │ ├── bit_writer.c │ ├── bit_writer.h │ ├── color_cache.c │ ├── color_cache.h │ ├── endian_inl.h │ ├── filters.c │ ├── filters.h │ ├── huffman.c │ ├── huffman.h │ ├── huffman_encode.c │ ├── huffman_encode.h │ ├── quant_levels.c │ ├── quant_levels.h │ ├── quant_levels_dec.c │ ├── quant_levels_dec.h │ ├── random.c │ ├── random.h │ ├── rescaler.c │ ├── rescaler.h │ ├── thread.c │ ├── thread.h │ ├── utils.c │ └── utils.h │ └── webp │ ├── config.h │ ├── decode.h │ ├── demux.h │ ├── encode.h │ ├── format_constants.h │ ├── mux.h │ ├── mux_types.h │ └── types.h ├── main.cpp ├── qwebphandler.cpp ├── qwebphandler_p.h ├── webp.json └── webp.pro /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | 8 | 9 | ## Environment 10 | 17 | 18 | * Depecher version: 19 | * SailfishOS version: 20 | * SailfishOS device: 21 | 22 | 23 | ## Steps to reproduce 24 | 25 | 34 | 35 | 1. 36 | 2. 37 | 3. 38 | 39 | 40 | 41 | ## Expected behavior 42 | 43 | 46 | 47 | ## Actual behavior 48 | 49 | 52 | 53 | ## Attachment 54 | 55 | 58 | 59 | 62 | 63 | 66 | 67 | 68 | 77 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | json/* 2 | tdlibjson_wrapper/.vscode 3 | tdlibjson_wrapper/api_secret.pri 4 | json.tar 5 | *.mdj 6 | *.user 7 | *.cmd 8 | *.sh 9 | supplement/ -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Thanks to following contributors: 2 | 3 | @a-andreyev 4 | @Ruditimmermans 5 | @DylanVanAssche 6 | @foolsbazar 7 | 8 | Translators: 9 | @eson57 - swedish 10 | @0312birdzhang - simple chinese 11 | @1Zgp - hungarian 12 | @frzifus - german 13 | @armenfdezb - spanish * 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Telegram app for Sailfish OS 2 | 3 | Depecher - telegram client for Sailfish OS based on [tdlib library](https://github.com/blacksailer/td/tree/cmake) 4 | 5 | 6 | Features: 7 | 8 | Depecher - Another Telegram client for Sailfish OS based on tdlib. 9 | 10 | Features: 11 | - Send/View/Delete messages 12 | - View photos 13 | - View stickers 14 | - Uploading/Downloading photos/docs 15 | - Receive notifications 16 | - 2FA authorization enabled 17 | 18 | 19 | 20 | #### Want to contribute? 21 | 22 | - Review code! 23 | - Create issue for missing features! 24 | - Do something really cool! 25 | 26 | To build this app required: 27 | 28 | 1. tdlibjson tdlibjson-devel [rpm](https://openrepos.net/content/blacksailer/tdlibjson) package installed 29 | 2. APP_ID and APP_HASH changed in tdlibjson_wrapper.pro 30 | 31 | 32 | -------------------------------------------------------------------------------- /TelegramQt.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = webp \ 3 | icons \ 4 | lib \ 5 | shareui \ 6 | sharechat \ 7 | app 8 | # where to find the sub projects - give the folders 9 | lib.subdir = tdlibjson_wrapper 10 | app.subdir = depecher 11 | webp.file = webp-plugin/webp.pro 12 | lib.makefile = MyMakefile 13 | # what subproject depends on others 14 | app.depends = lib 15 | 16 | # build the project sequentially as listed in SUBDIRS ! 17 | CONFIG += ordered 18 | 19 | -------------------------------------------------------------------------------- /depecher.astylerc: -------------------------------------------------------------------------------- 1 | style=kr 2 | attach-namespaces 3 | indent=spaces=4 4 | pad-oper 5 | unpad-paren 6 | pad-header 7 | align-pointer=name 8 | keep-one-line-blocks -------------------------------------------------------------------------------- /depecher/.gitignore: -------------------------------------------------------------------------------- 1 | *.user 2 | *.qm -------------------------------------------------------------------------------- /depecher/ModelTest.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MODELTEST_HPP 2 | #define MODELTEST_HPP 3 | 4 | 5 | /**************************************************************************** 6 | ** 7 | ** Copyright (C) 2016 The Qt Company Ltd. 8 | ** Contact: https://www.qt.io/licensing/ 9 | ** 10 | ** This file is part of Qt Creator. 11 | ** 12 | ** Commercial License Usage 13 | ** Licensees holding valid commercial Qt licenses may use this file in 14 | ** accordance with the commercial license agreement provided with the 15 | ** Software or, alternatively, in accordance with the terms contained in 16 | ** a written agreement between you and The Qt Company. For licensing terms 17 | ** and conditions see https://www.qt.io/terms-conditions. For further 18 | ** information use the contact form at https://www.qt.io/contact-us. 19 | ** 20 | ** GNU General Public License Usage 21 | ** Alternatively, this file may be used under the terms of the GNU 22 | ** General Public License version 3 as published by the Free Software 23 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 24 | ** included in the packaging of this file. Please review the following 25 | ** information to ensure the GNU General Public License requirements will 26 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #pragma once 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | class ModelTest : public QObject 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | ModelTest(QAbstractItemModel *model, QObject *parent = 0); 42 | 43 | private Q_SLOTS: 44 | void nonDestructiveBasicTest(); 45 | void rowCount(); 46 | void columnCount(); 47 | void hasIndex(); 48 | void index(); 49 | void parent(); 50 | void data(); 51 | 52 | public Q_SLOTS: 53 | void runAllTests(); 54 | protected Q_SLOTS: 55 | void layoutAboutToBeChanged(); 56 | void layoutChanged(); 57 | void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end); 58 | void rowsInserted(const QModelIndex &parent, int start, int end); 59 | void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); 60 | void rowsRemoved(const QModelIndex &parent, int start, int end); 61 | 62 | private: 63 | void checkChildren(const QModelIndex &parent, int currentDepth = 0); 64 | 65 | QAbstractItemModel *model; 66 | 67 | struct Changing { 68 | QModelIndex parent; 69 | int oldSize; 70 | QVariant last; 71 | QVariant next; 72 | }; 73 | QStack insert; 74 | QStack remove; 75 | 76 | bool fetchingMore; 77 | 78 | QList changing; 79 | }; 80 | 81 | 82 | #endif // MODELTEST_HPP 83 | -------------------------------------------------------------------------------- /depecher/TODO.txt: -------------------------------------------------------------------------------- 1 | https://github.com/sailfishos/sailfish-secrets -------------------------------------------------------------------------------- /depecher/dbus/ChatShareAdaptor.cpp: -------------------------------------------------------------------------------- 1 | #include "ChatShareAdaptor.hpp" 2 | #include "tdlibQt/TdlibJsonWrapper.hpp" 3 | #include "tdlibQt/ParseObject.hpp" 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static const QString c_dbusObjectPath = QStringLiteral("/org/blacksailer/depecher/share"); 10 | static const QString c_dbusInterface = QStringLiteral("org.blacksailer.depecher.share"); 11 | static const QString c_extraName = QStringLiteral("dbus"); 12 | 13 | ChatShareAdaptor::ChatShareAdaptor(QObject *parent) : QObject(parent) 14 | { 15 | m_dbusServer = new QDBusServer("unix:abstract=depecher-dbus", this); 16 | connect(m_dbusServer, &QDBusServer::newConnection, 17 | [this](const QDBusConnection & dbus) { 18 | m_dbusConnection = new QDBusConnection(dbus); 19 | m_dbusConnection->registerObject(c_dbusObjectPath, c_dbusInterface, this, QDBusConnection::RegisterOption::ExportAllSlots); 20 | }); 21 | m_tdlibJson = tdlibQt::TdlibJsonWrapper::instance(); 22 | 23 | connect(m_tdlibJson, &tdlibQt::TdlibJsonWrapper::chatReceived, 24 | this, &ChatShareAdaptor::addChatItem); 25 | connect(m_tdlibJson, &tdlibQt::TdlibJsonWrapper::chatsReceived, 26 | [this](const QJsonObject & chatsObject) { 27 | if (chatsObject.keys().contains("@extra")) { 28 | if (chatsObject["@extra"].toString() == c_extraName) { 29 | foreach (auto item, chatsObject["chat_ids"].toArray()) { 30 | switch (item.type()) { 31 | case QJsonValue::Double: 32 | m_chatIds.append((qint64)item.toDouble()); 33 | break; 34 | case QJsonValue::String: 35 | m_chatIds.append((qint64)item.toString().toLongLong()); 36 | break; 37 | default: 38 | break; 39 | } 40 | } 41 | } 42 | foreach (qint64 item, m_chatIds) { 43 | m_tdlibJson->getChat(item, c_extraName); 44 | } 45 | } 46 | 47 | }); 48 | 49 | } 50 | void ChatShareAdaptor::addChatItem(const QJsonObject &chatObject) 51 | { 52 | 53 | if (chatObject.keys().contains("@extra")) { 54 | if (chatObject["@extra"].toString() == c_extraName) { 55 | m_chats.append(chatObject.toVariantMap()); 56 | if (m_chats.size() == m_chatIds.size()) 57 | sendChatList(); 58 | } 59 | } 60 | } 61 | void ChatShareAdaptor::sendChatList() 62 | { 63 | QDBusMessage reply = m_delayedList.last().reply; 64 | reply << m_chats; 65 | m_dbusConnection->send(reply); 66 | m_delayedList.removeLast(); 67 | m_chatIds.clear(); 68 | m_chats.clear(); 69 | } 70 | 71 | QDBusVariant ChatShareAdaptor::getChatList(const qint64 lastChatId, const qint64 order, const QDBusMessage &message) 72 | { 73 | m_delayedList.append(RequestData()); 74 | message.setDelayedReply(true); 75 | m_delayedList.last().reply = message.createReply(); 76 | m_tdlibJson->getChats(lastChatId, 77 | order, 78 | 5, 79 | c_extraName); 80 | 81 | return QDBusVariant(QVariant()); 82 | } 83 | 84 | ChatShareAdaptor::~ChatShareAdaptor() 85 | { 86 | delete m_dbusConnection; 87 | } 88 | -------------------------------------------------------------------------------- /depecher/dbus/ChatShareAdaptor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHATSHAREADAPTOR_HPP 2 | #define CHATSHAREADAPTOR_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | class QDBusServer; 8 | class QDBusConnection; 9 | namespace tdlibQt { 10 | class TdlibJsonWrapper; 11 | } 12 | class ChatShareAdaptor : public QObject 13 | { 14 | Q_OBJECT 15 | struct RequestData { 16 | QVariant chatList; 17 | QDBusMessage reply; 18 | }; 19 | QDBusConnection *m_dbusConnection; 20 | tdlibQt::TdlibJsonWrapper *m_tdlibJson; 21 | 22 | QDBusServer *m_dbusServer; 23 | QList m_delayedList; 24 | 25 | QList m_chatIds; 26 | QList m_chats; 27 | public: 28 | explicit ChatShareAdaptor(QObject *parent = nullptr); 29 | ~ChatShareAdaptor(); 30 | void sendChatList(); 31 | 32 | signals: 33 | 34 | private slots: 35 | void addChatItem(const QJsonObject &chatObject); 36 | 37 | public slots: 38 | QDBusVariant getChatList(const qint64 lastChatId, const qint64 order, const QDBusMessage &message); 39 | 40 | }; 41 | 42 | #endif // CHATSHAREADAPTOR_HPP 43 | -------------------------------------------------------------------------------- /depecher/dbus/DBusShareAdaptor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QDBUSSHAREADAPTOR_HPP 2 | #define QDBUSSHAREADAPTOR_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include "tdlibQt/items/TdApi.hpp" 8 | namespace tdlibQt { 9 | class TdlibJsonWrapper; 10 | } 11 | class DBusShareAdaptor : public QObject 12 | { 13 | Q_OBJECT 14 | 15 | QMap> m_files; 16 | QMap m_fileIdToGenerationIdMap; 17 | QMap m_filesPending; 18 | QMap> m_generationIdPathMap; 19 | tdlibQt::TdlibJsonWrapper *m_tdlibJson; 20 | 21 | inline void sendPhoto(const QList &chat_ids, const QString &filepath); 22 | inline void sendDocument(const QList &chat_ids, const QString &filepath); 23 | inline void sendText(const QList &chat_ids, const QString &data); 24 | inline void sendVCard(const QList &chat_ids, const QString &data); 25 | static QString decode(const QByteArray &input); 26 | public: 27 | explicit DBusShareAdaptor(QObject *parent = nullptr); 28 | ~DBusShareAdaptor(); 29 | signals: 30 | void uploadFailed(const QString &chat_id, const QString &message_id); 31 | void uploadFinished(const QString &chat_id, const QString &message_id, const QString &remote_url); 32 | void uploadProgress(const QString &chat_id, const QString &message_id, int percent); 33 | void uploadStarted(const QString &chat_id, const QString &message_id, const QString &local_url); 34 | public slots: 35 | void sendMedia(const QList &chat_ids, const QString &filepath, const QString &mimeType); 36 | private slots: 37 | void updateFileReceived(const QJsonObject &updateFileObject); 38 | void fileGenerationStarted(const QJsonObject &updateFileGenerationStartObject); 39 | void fileGenerationStoped(const QJsonObject &updateFileGenerationStopObject); 40 | }; 41 | 42 | 43 | #endif // QDBUSSHAREADAPTOR_HPP 44 | -------------------------------------------------------------------------------- /depecher/dbus/DBusShareAdaptorWrapper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.8 3 | * Command line was: qdbusxml2cpp -a DBusShareAdaptorWrapper.hpp:DBusShareAdaptorWrapper.cpp -c DBusShareAdaptorWrapper C:\Users\cheiv\Documents\Projects\SailfishOS\fromBigTower\depecher\depecher\dbus\org.blacksailer.depecher.share.xml 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. 6 | * 7 | * This is an auto-generated file. 8 | * Do not edit! All changes made to it will be lost. 9 | */ 10 | 11 | #include "DBusShareAdaptorWrapper.hpp" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "sailfish_access.c" 20 | #include 21 | /* 22 | * Implementation of adaptor class DBusShareAdaptorWrapper 23 | */ 24 | 25 | DBusShareAdaptorWrapper::DBusShareAdaptorWrapper(QObject *parent) 26 | : QDBusAbstractAdaptor(parent) 27 | { 28 | // constructor 29 | setAutoRelaySignals(true); 30 | } 31 | 32 | DBusShareAdaptorWrapper::~DBusShareAdaptorWrapper() 33 | { 34 | if (m_policyInitialized) { 35 | da_peer_flush(CONNMAN_BUS, NULL); 36 | if (active_policy) { 37 | g_ptr_array_free(active_policy, TRUE); 38 | active_policy = NULL; 39 | } 40 | } 41 | 42 | } 43 | 44 | void DBusShareAdaptorWrapper::initPolicy() 45 | { 46 | active_policy = g_ptr_array_new_with_free_func 47 | (sailfish_access_policy_free); 48 | 49 | sailfish_access_load_config(); 50 | m_policyInitialized = true; 51 | 52 | 53 | } 54 | 55 | 56 | void DBusShareAdaptorWrapper::sendMedia(const QList &chat_ids, const QString &filepath, const QString &mimeType, const QDBusMessage &message) 57 | { 58 | if (sailfish_access_policy_check(message.service().toLatin1().constData(), 59 | SEND_MEDIA, 0) == AUTH_DENY) { 60 | QDBusConnection::sessionBus().send(message.createErrorReply(QDBusError::AccessDenied, "Policy error")); 61 | return; 62 | 63 | } 64 | // handle method call org.blacksailer.depecher.share.sendMedia 65 | QMetaObject::invokeMethod(parent(), "sendMedia", 66 | Q_ARG(QList, chat_ids), 67 | Q_ARG(QString, filepath), 68 | Q_ARG(QString, mimeType) 69 | ); 70 | } 71 | 72 | 73 | -------------------------------------------------------------------------------- /depecher/dbus/DBusShareAdaptorWrapper.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.8 3 | * Command line was: qdbusxml2cpp -a file.hpp:file.cpp -c DBusShareAdaptorWrapper C:\Users\cheiv\Documents\Projects\SailfishOS\fromBigTower\depecher\depecher\dbus\org.blacksailer.depecher.share.xml 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #ifndef FILE_HPP_H 13 | #define FILE_HPP_H 14 | 15 | #include 16 | #include 17 | QT_BEGIN_NAMESPACE 18 | class QByteArray; 19 | template class QList; 20 | template class QMap; 21 | class QString; 22 | class QStringList; 23 | class QVariant; 24 | QT_END_NAMESPACE 25 | 26 | /* 27 | * Adaptor class for interface org.blacksailer.depecher.share 28 | */ 29 | class DBusShareAdaptorWrapper: public QDBusAbstractAdaptor 30 | { 31 | Q_OBJECT 32 | Q_CLASSINFO("D-Bus Interface", "org.blacksailer.depecher.share") 33 | Q_CLASSINFO("D-Bus Introspection", "" 34 | " \n" 35 | " \n" 36 | " \n" 37 | " \n" 38 | " \n" 39 | " \n" 40 | " \n" 41 | " \n" 42 | " \n" 43 | " \n" 44 | " \n" 45 | " \n" 46 | " \n" 47 | " \n" 48 | " \n" 49 | " \n" 50 | " \n" 51 | " \n" 52 | " \n" 53 | " \n" 54 | " \n" 55 | " \n" 56 | " \n" 57 | " \n" 58 | " \n" 59 | " \n" 60 | " \n" 61 | " \n" 62 | "") 63 | bool m_policyInitialized = false; 64 | public: 65 | DBusShareAdaptorWrapper(QObject *parent); 66 | virtual ~DBusShareAdaptorWrapper(); 67 | void initPolicy(); 68 | public Q_SLOTS: // METHODS 69 | Q_NOREPLY void sendMedia(const QList &chat_ids, const QString &filepath, const QString &mimeType, const QDBusMessage &message); 70 | Q_SIGNALS: // SIGNALS 71 | void uploadFailed(const QString &chat_id, const QString &message_id); 72 | void uploadFinished(const QString &chat_id, const QString &message_id, const QString &remote_url); 73 | void uploadProgress(const QString &chat_id, const QString &message_id, int percent); 74 | void uploadStarted(const QString &chat_id, const QString &message_id, const QString &local_url); 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /depecher/dbus/DepecherAdaptor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.8 3 | * Command line was: qdbusxml2cpp Projects\SailfishOS\depecher\depecher\dbus\harbour-depecher.xml -a DepecherAdaptor 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. 6 | * 7 | * This is an auto-generated file. 8 | * Do not edit! All changes made to it will be lost. 9 | */ 10 | 11 | #include "DepecherAdaptor.hpp" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | /* 21 | * Implementation of adaptor class DepecherAdaptor 22 | */ 23 | 24 | DepecherAdaptor::DepecherAdaptor(QObject *parent) 25 | : QDBusAbstractAdaptor(parent) 26 | { 27 | // constructor 28 | setAutoRelaySignals(true); 29 | } 30 | 31 | DepecherAdaptor::~DepecherAdaptor() 32 | { 33 | // destructor 34 | } 35 | 36 | void DepecherAdaptor::showApp(const QStringList &item) 37 | { 38 | // handle method call org.blacksailer.depecher.showApp 39 | QMetaObject::invokeMethod(parent(), "showApp", Q_ARG(QStringList, item)); 40 | } 41 | 42 | void DepecherAdaptor::openConversation(qlonglong chatId) 43 | { 44 | // handle method call org.blacksailer.depecher.openConversation 45 | QMetaObject::invokeMethod(parent(), "openConversation", Q_ARG(qlonglong, chatId)); 46 | } 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /depecher/dbus/DepecherAdaptor.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.8 3 | * Command line was: qdbusxml2cpp C:\Users\cheiv\Documents\Projects\SailfishOS\depecher\depecher\dbus\harbour-depecher.xml -a test 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #ifndef TEST_H 13 | #define TEST_H 14 | 15 | #include 16 | #include 17 | QT_BEGIN_NAMESPACE 18 | class QByteArray; 19 | template class QList; 20 | template class QMap; 21 | class QString; 22 | class QStringList; 23 | class QVariant; 24 | QT_END_NAMESPACE 25 | 26 | /* 27 | * Adaptor class for interface org.blacksailer.depecher 28 | */ 29 | class DepecherAdaptor: public QDBusAbstractAdaptor 30 | { 31 | Q_OBJECT 32 | Q_CLASSINFO("D-Bus Interface", "org.blacksailer.depecher") 33 | Q_CLASSINFO("D-Bus Introspection", "" 34 | " \n" 35 | " \n" 36 | " \n" 37 | " \n" 38 | " \n" 39 | " \n" 40 | " \n" 41 | " \n" 42 | " \n" 43 | " \n" 44 | "") 45 | public: 46 | DepecherAdaptor(QObject *parent); 47 | virtual ~DepecherAdaptor(); 48 | 49 | public: // PROPERTIES 50 | public Q_SLOTS: // METHODS 51 | Q_NOREPLY void showApp(const QStringList &item); 52 | Q_NOREPLY void openConversation(qlonglong chatId); 53 | Q_SIGNALS: // SIGNALS 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /depecher/dbus/depecher-dbus-access.conf: -------------------------------------------------------------------------------- 1 | # If configuration is missing, default access rules are used. 2 | # One line is one rule and syntax is as follows. 3 | # 4 | # = ; = ; ... 5 | # 6 | # Where: 7 | # - is the method to apply the rule to (or * for all) 8 | # - is the policy version, usually 1 9 | # - is the user or group the rule applies to (or * for all) 10 | # - is allow or deny 11 | # 12 | # More specific rules take precedence over more general rules 13 | 14 | [Common] 15 | DefaultAccess = 1; * = allow; group(privileged) = allow 16 | 17 | [org.blacksailer.depecher.share] 18 | * = 1; * = allow; group(privileged) = allow 19 | getChatList = 1; * = deny; group(privileged) = allow 20 | -------------------------------------------------------------------------------- /depecher/dbus/org.blacksailer.depecher.service: -------------------------------------------------------------------------------- 1 | [D-BUS Service] 2 | Name=org.blacksailer.depecher 3 | User=nemo 4 | SystemdService=org.blacksailer.depecher.service 5 | 6 | #https://jdebp.eu/Softwares/nosh/avoid-dbus-bus-activation.html 7 | Exec=/bin/false 8 | -------------------------------------------------------------------------------- /depecher/dbus/org.blacksailer.depecher.share.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /depecher/dbus/org.blacksailer.depecher.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /depecher/depecher.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | X-Nemo-Application-Type=silica-qt5 4 | Comment=Telegram client 5 | Icon=depecher 6 | Name=Depecher 7 | #https://git.merproject.org/mer-core/libcontentaction/blob/master/src/doc.h 8 | Exec=/usr/bin/invoker -s --type=silica-qt5 /usr/bin/depecher 9 | X-Maemo-Service=org.blacksailer.depecher 10 | X-Maemo-Object-Path=/org/blacksailer/depecher 11 | X-Maemo-Method=org.blacksailer.depecher.showApp 12 | X-Maemo-Fixed-Args=Start 13 | -------------------------------------------------------------------------------- /depecher/events/depecher_im.ini: -------------------------------------------------------------------------------- 1 | [depecher_im => play.mode=short] 2 | sound.profile = im_fg.alert.tone@general => sound.filename 3 | sound.stream.event.id = event-in-call 4 | sound.stream.module-stream-restore.id = x-ringtone-volume 5 | sound.enabled.profile = im_fg.alert.enabled => sound.enabled 6 | haptic.type = event 7 | haptic.effect = message 8 | 9 | [depecher_im => play.mode=*,context@call_state.mode=active] 10 | sound.profile = im_fg.alert.tone@general => sound.filename 11 | sound.stream.event.id = event-in-call 12 | sound.stream.module-stream-restore.id = sink-input-by-media-role:indicator-tone 13 | haptic.type = event 14 | haptic.effect = message 15 | 16 | [depecher_im => play.mode=foreground] 17 | sound.profile = im_fg.alert.tone => sound.filename 18 | sound.profile.fallback = im_fg.alert.tone@fallback => sound.filename 19 | sound.stream.event.id = message-new-email 20 | sound.stream.module-stream-restore.id = x-ringtone-volume 21 | sound.enabled.profile = im_fg.alert.enabled => sound.enabled 22 | haptic.type = event 23 | haptic.effect = message 24 | 25 | [depecher_im] 26 | haptic.type = event 27 | haptic.effect = message 28 | mce.led_pattern = PatternCommunicationIM 29 | 30 | -------------------------------------------------------------------------------- /depecher/events/depecher_im_exists.ini: -------------------------------------------------------------------------------- 1 | # Email exists indication 2 | [depecher_im_exists] 3 | mce.led_pattern = PatternCommunicationIM 4 | sound.profile = im.alert.tone => sound.filename 5 | sound.profile.fallback = im.alert.tone@fallback => sound.filename 6 | sound.stream.event.id = message-new-email 7 | sound.stream.module-stream-restore.id = x-ringtone-volume 8 | sound.stream.media.role = notification 9 | sound.stream.droid.device.additional-route = AUDIO_DEVICE_OUT_SPEAKER 10 | sound.enabled.profile = im.alert.enabled => sound.enabled 11 | haptic.type = short 12 | #https://git.merproject.org/jpetrell/ngfd/blob/master/src/plugins/devicelock/plugin.c 13 | #https://git.merproject.org/mer-core/nemo-qml-plugin-devicelock/blob/master/src/nemo-devicelock/devicelock.h#L40 14 | [depecher_im_exists => play.mode=*,context@device_lock.state=manager_lockout] 15 | 16 | [depecher_im_exists => play.mode=*,context@call_state.mode=active] 17 | mce.led_pattern = PatternCommunicationIM 18 | -------------------------------------------------------------------------------- /depecher/events/depecher_im_fg.ini: -------------------------------------------------------------------------------- 1 | [depecher_im_fg] 2 | #Vibration settings 3 | #https://git.merproject.org/mer-core/ngfd/blob/master/src/include/ngf/haptic.h 4 | #"touch","short","strong","long","notice","message","attention","alarm","ringtone" 5 | sound.profile = im_fg.alert.tone => sound.filename 6 | sound.profile.fallback = im_fg.alert.tone@fallback => sound.filename 7 | sound.stream.event.id = message-new-email 8 | sound.stream.module-stream-restore.id = x-meego-ringing-volume 9 | sound.enabled.profile = im_fg.alert.enabled => sound.enabled 10 | haptic.type = event 11 | haptic.effect = short 12 | mce.led_pattern = PatternCommunicationIM 13 | -------------------------------------------------------------------------------- /depecher/icons/108x108/depecher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/icons/108x108/depecher.png -------------------------------------------------------------------------------- /depecher/icons/128x128/depecher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/icons/128x128/depecher.png -------------------------------------------------------------------------------- /depecher/icons/256x256/depecher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/icons/256x256/depecher.png -------------------------------------------------------------------------------- /depecher/icons/86x86/depecher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/icons/86x86/depecher.png -------------------------------------------------------------------------------- /depecher/icons/depecher_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/icons/depecher_3.png -------------------------------------------------------------------------------- /depecher/notificationcategories/x-depecher.im.conf: -------------------------------------------------------------------------------- 1 | #https://git.merproject.org/mer-core/lipstick/blob/master/doc/src/notifications.dox 2 | x-nemo-icon=icon-lock-chat 3 | urgency=1 4 | x-nemo-feedback=depecher_im,depecher_im_exists 5 | #https://git.merproject.org/mer-core/lipstick/blob/master/doc/src/notifications.dox#L34 6 | x-nemo-priority=110 7 | x-nemo-display-on=true 8 | 9 | 10 | -------------------------------------------------------------------------------- /depecher/notificationcategories/x-depecher.im.fg.conf: -------------------------------------------------------------------------------- 1 | #https://git.merproject.org/mer-core/lipstick/blob/master/doc/src/notifications.dox 2 | x-nemo-feedback=depecher_im_fg 3 | x-nemo-led-disabled-without-body-and-summary=false 4 | x-nemo-max-content-lines=2 5 | -------------------------------------------------------------------------------- /depecher/qml/Background.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.1 2 | import QtQuick.Window 2.1 as QtQuick 3 | import Sailfish.Silica 1.0 4 | import Sailfish.Silica.private 1.0 5 | import Nemo.Configuration 1.0 6 | 7 | Wallpaper { 8 | id: wallpaper 9 | property string settingsUiPath: "/apps/depecher/ui" 10 | ConfigurationValue { 11 | id:nightMode 12 | key:settingsUiPath + "/nightMode" 13 | defaultValue: false 14 | } 15 | Connections { 16 | target: nightMode 17 | onValueChanged: { 18 | if(nightMode.value) 19 | wallpaper.source = "qrc:/qml/assets/background/dark.jpg" 20 | else 21 | wallpaper.source = "" 22 | } 23 | } 24 | anchors.fill: parent 25 | rotation: parent.rotation 26 | state: rotation 27 | 28 | states: [ 29 | State { 30 | name: "0" 31 | PropertyChanges { 32 | target: wallpaper 33 | windowRotation: 0 34 | } 35 | }, 36 | State { 37 | name: "180" 38 | PropertyChanges { 39 | target: wallpaper 40 | windowRotation: 180 41 | } 42 | }, 43 | State { 44 | name: "270" 45 | PropertyChanges { 46 | target: wallpaper 47 | windowRotation: 270 48 | } 49 | }, 50 | State { 51 | name: "90" 52 | PropertyChanges { 53 | target: wallpaper 54 | windowRotation: 90 55 | width: page.height 56 | height: page.width 57 | } 58 | } 59 | ] 60 | Component.onCompleted: { 61 | if(nightMode.value) 62 | wallpaper.source = "qrc:/qml/assets/background/dark.jpg" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /depecher/qml/ShareUI.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import Sailfish.TransferEngine 1.0 4 | import Nemo.DBus 2.0 5 | import "pages/components" 6 | import "org/blacksailer/depecher/sharechat" 1.0 7 | import "js/mimetypes.js" as Mime 8 | ShareDialog { 9 | id: root 10 | allowedOrientations: Orientation.Portrait 11 | 12 | property int viewWidth: root.isPortrait ? Screen.width : Screen.width / 2 13 | property var chat_ids: [] 14 | 15 | property string filepath: source 16 | 17 | canAccept: listModel.count !== 0 18 | property bool searchEnabled: false 19 | onAccepted: { 20 | if (source == '' && content && 'type' in content) 21 | { 22 | shareItem.mimeType = content.type 23 | if(content.type === 'text/x-url') { 24 | shareItem.notificationsEnabled = false 25 | shareItem.userData = {"recipients":chat_ids.join(','), "name":content.linkTitle, 26 | "data":content.status } 27 | } else 28 | shareItem.userData = {"recipients":chat_ids.join(','), 29 | "name":content.name, 30 | "data":content.data} 31 | } 32 | else 33 | shareItem.userData = {"recipients":chat_ids.join(',')} 34 | 35 | shareItem.start() 36 | } 37 | 38 | ShareChatModel { 39 | id:model 40 | } 41 | SilicaListView { 42 | id:listModel 43 | anchors.fill: parent 44 | model: model 45 | PullDownMenu { 46 | MenuItem { 47 | text: qsTr("Reset") 48 | onClicked: model.reset() 49 | } 50 | } 51 | header: PageHeader { 52 | title: chat_ids.length == 0 ? qsTr("Choose chat") : qsTr("%1 selected").arg(chat_ids.length) 53 | } 54 | 55 | delegate: ChatItemShare { 56 | id: chatDelegate 57 | ListView.onAdd: AddAnimation { 58 | target: chatDelegate 59 | } 60 | 61 | ListView.onRemove: RemoveAnimation { 62 | target: chatDelegate 63 | } 64 | 65 | onClicked: { 66 | var contains = false 67 | for( var i = 0; i < chat_ids.length; i++) 68 | if ( chat_ids[i] === id) 69 | contains = true 70 | if(!contains) 71 | { 72 | chat_ids.push(id) 73 | highlighted = true 74 | } 75 | else { 76 | for( var i = 0; i < chat_ids.length; i++){ 77 | if ( chat_ids[i] === id) { 78 | highlighted = false 79 | chat_ids.splice(i, 1); 80 | } 81 | } 82 | } 83 | } 84 | } 85 | } 86 | ViewPlaceholder { 87 | enabled:listModel.count === 0 88 | text: qsTr("Ensure that depecher is running") 89 | hintText: qsTr("Do not close until media is transfered") 90 | } 91 | SailfishShare { 92 | id: shareItem 93 | source: root.filepath 94 | metadataStripped: true 95 | serviceId: root.methodId 96 | userData: {"description": "Depecher"} 97 | mimeType: Mime.getMimeType(filepath) 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /depecher/qml/assets/background/dark.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/qml/assets/background/dark.jpg -------------------------------------------------------------------------------- /depecher/qml/assets/icons/check.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 63 | 69 | 70 | 75 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /depecher/qml/assets/icons/depecher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/qml/assets/icons/depecher.png -------------------------------------------------------------------------------- /depecher/qml/assets/icons/en_sailfish.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/qml/assets/icons/en_sailfish.jpg -------------------------------------------------------------------------------- /depecher/qml/assets/icons/git.svg: -------------------------------------------------------------------------------- 1 | Artboard 1 -------------------------------------------------------------------------------- /depecher/qml/assets/icons/it_sailfish.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/qml/assets/icons/it_sailfish.jpg -------------------------------------------------------------------------------- /depecher/qml/assets/icons/lock_slide_40x80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/qml/assets/icons/lock_slide_40x80.png -------------------------------------------------------------------------------- /depecher/qml/assets/icons/lock_slide_80x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/qml/assets/icons/lock_slide_80x40.png -------------------------------------------------------------------------------- /depecher/qml/assets/icons/paypal.svg: -------------------------------------------------------------------------------- 1 | icon-depecher -------------------------------------------------------------------------------- /depecher/qml/assets/icons/rocket.svg: -------------------------------------------------------------------------------- 1 | icon-depecher -------------------------------------------------------------------------------- /depecher/qml/assets/icons/ru_sailfish.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/qml/assets/icons/ru_sailfish.jpg -------------------------------------------------------------------------------- /depecher/qml/cover/CoverPage.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import TelegramModels 1.0 4 | import QtMultimedia 5.6 5 | import "../js/utils.js" as Utils 6 | CoverBackground { 7 | Connections { 8 | target: c_telegramWrapper 9 | onConnectionStateChanged:{ 10 | status.text = Utils.setState(connectionState) 11 | } 12 | } 13 | Column{ 14 | width:parent.width 15 | anchors.centerIn: parent 16 | Item{ 17 | width:label.width+counter.width 18 | height: counter.height 19 | anchors.horizontalCenter: parent.horizontalCenter 20 | 21 | Label { 22 | id: counter 23 | width:paintedWidth 24 | text:c_telegramWrapper.totalUnreadCount 25 | color: Theme.primaryColor 26 | font.pixelSize: Theme.fontSizeExtraLarge*3/2 27 | // Rectangle { 28 | // color:"red" 29 | // anchors.fill: parent 30 | // } 31 | } 32 | Label { 33 | id:captionUnread 34 | width:label.width 35 | anchors.left: counter.right 36 | anchors.leftMargin: Theme.paddingSmall 37 | anchors.top: counter.top 38 | anchors.topMargin: Theme.paddingMedium 39 | text:qsTr("Unread messages") 40 | wrapMode: Text.WordWrap 41 | font.pixelSize: Theme.fontSizeExtraSmall 42 | color: Theme.secondaryColor 43 | } 44 | } 45 | Label { 46 | id: label 47 | text: qsTr("Depecher") 48 | color: Theme.secondaryColor 49 | anchors.horizontalCenter: parent.horizontalCenter 50 | } 51 | Label { 52 | id:status 53 | width:parent.width 54 | color: Theme.highlightColor 55 | text: Utils.setState(c_telegramWrapper.connectionState) 56 | horizontalAlignment: Text.AlignHCenter 57 | wrapMode: Text.WordWrap 58 | anchors.horizontalCenter: parent.horizontalCenter 59 | } 60 | 61 | } 62 | CoverActionList { 63 | id: coverAction 64 | enabled: rootWindow.__depecher_audio.hasAudio 65 | CoverAction { 66 | iconSource: rootWindow.__depecher_audio.playbackState === Audio.PlayingState ? "image://theme/icon-cover-pause" 67 | : "image://theme/icon-cover-play" 68 | onTriggered:rootWindow.__depecher_audio.playbackState === Audio.PlayingState ? 69 | rootWindow.__depecher_audio.pause() 70 | : rootWindow.__depecher_audio.play() 71 | } 72 | } 73 | 74 | } 75 | 76 | -------------------------------------------------------------------------------- /depecher/qml/js/utils.js: -------------------------------------------------------------------------------- 1 | function setState(state) { 2 | switch(state){ 3 | case 0: 4 | return qsTr("Waiting for network") 5 | case 1: 6 | return qsTr("Connecting") 7 | case 2: 8 | return qsTr("Connecting to proxy") 9 | case 3: 10 | return qsTr("Updating...") 11 | case 4: 12 | return qsTr("Ready") 13 | default: 14 | return qsTr("Uknown") 15 | } 16 | 17 | } 18 | function setAuthState(state) { 19 | /* 20 | AuthorizationStateWaitTdlibParameters, 21 | AuthorizationStateWaitEncryptionKey, 22 | AuthorizationStateWaitPhoneNumber, 23 | AuthorizationStateWaitCode, 24 | AuthorizationStateWaitPassword, 25 | AuthorizationStateLoggingOut, 26 | AuthorizationStateClosing, 27 | AuthorizationStateClosed, 28 | AuthorizationStateReady 29 | 30 | */ 31 | switch(state){ 32 | case 0: 33 | return qsTr("Waiting for network") 34 | case 1: 35 | return qsTr("Wait lib parameters") 36 | case 2: 37 | return qsTr("Wait encryption key") 38 | case 3: 39 | return qsTr("Wait phone number") 40 | case 4: 41 | return qsTr("Wait code") 42 | case 5: 43 | return qsTr("Wait password") 44 | case 6: 45 | return qsTr("Wait logging out") 46 | case 7: 47 | return qsTr("Wait closing") 48 | case 8: 49 | return qsTr("Wait closed") 50 | case 8: 51 | return qsTr("Ready") 52 | default: 53 | return qsTr("Uknown") 54 | } 55 | } 56 | function getWidth() { 57 | switch(page.orientation) { 58 | case Orientation.Portrait: 59 | case Orientation.PortraitInverted: 60 | return Screen.width 61 | case Orientation.Landscape: 62 | case Orientation.LandscapeInverted: 63 | return Screen.height 64 | 65 | } 66 | } 67 | function getHeight() { 68 | switch(page.orientation) { 69 | case Orientation.Portrait: 70 | case Orientation.PortraitInverted: 71 | return Screen.height 72 | case Orientation.Landscape: 73 | case Orientation.LandscapeInverted: 74 | return Screen.width 75 | 76 | } 77 | } 78 | 79 | function formatDate(dateByUnix, shouldShowAsToday) { 80 | var date = new Date(dateByUnix * 1000) 81 | var dateMidnight = new Date(date.getTime()) 82 | dateMidnight.setHours(0, 0, 0, 0) 83 | var dateMidnightByUnix = dateMidnight.getTime() 84 | var dateYear = date.getFullYear() 85 | var currentMidnight = new Date() 86 | currentMidnight.setHours(0, 0, 0, 0) 87 | var currentMidnightByUnix = currentMidnight.getTime() 88 | var currentYear = currentMidnight.getFullYear() 89 | if (dateMidnightByUnix === currentMidnightByUnix) 90 | return shouldShowAsToday ? 91 | qsTr("Today") : 92 | Format.formatDate(date, Formatter.TimeValue) 93 | else if (dateYear === currentYear) 94 | return Format.formatDate(date, Formatter.DateMediumWithoutYear) 95 | else 96 | return Format.formatDate(date, Formatter.DateMedium) 97 | } 98 | -------------------------------------------------------------------------------- /depecher/qml/pages/DialogsPage.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import tdlibQtEnums 1.0 4 | import TelegramModels 1.0 5 | import "items" 6 | import "components" 7 | 8 | Page { 9 | id: page 10 | allowedOrientations: Orientation.All 11 | 12 | property string titleHeader:Qt.application.version 13 | //for search in pageStack 14 | property bool __chat_page: true 15 | property string _opened_chat_id: "" 16 | Connections { 17 | target: c_telegramWrapper 18 | onErrorReceivedMap: { 19 | if(errorObject["code"] === 401) 20 | pageStack.replace(Qt.resolvedUrl("AuthorizeDialog.qml"),{},PageStackAction.Immediate) 21 | } 22 | } 23 | onStatusChanged: { 24 | if (status == PageStatus.Active) 25 | if(c_telegramWrapper.authorizationState == TdlibState.AuthorizationStateWaitPhoneNumber) 26 | pageStack.replace(Qt.resolvedUrl("AuthorizeDialog.qml"),{},PageStackAction.Immediate) 27 | 28 | } 29 | SilicaListView { 30 | anchors.fill: parent 31 | model: ChatsModel { 32 | id:chatsModel 33 | } 34 | 35 | header: PageHeader { 36 | title: titleHeader 37 | } 38 | 39 | 40 | PullDownMenu { 41 | 42 | MenuItem { 43 | text:qsTr("Reset dialogs") 44 | onClicked: chatsModel.reset() 45 | } 46 | MenuItem { 47 | text:qsTr("Settings") 48 | onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml")) 49 | } 50 | MenuItem { 51 | text:qsTr("Contacts") 52 | onClicked: pageStack.push(Qt.resolvedUrl("ContactsPage.qml")) 53 | } 54 | } 55 | 56 | delegate: ChatItem { 57 | id: chatDelegate 58 | 59 | menu: ContextMenu { 60 | MenuItem { 61 | text: mute_for > 0 ? qsTr("Unmute") : qsTr("Mute") 62 | onClicked: chatsModel.changeNotificationSettings(id,!(mute_for > 0)) 63 | } 64 | MenuItem { 65 | text: is_marked_unread ? qsTr("Mark as read") : qsTr("Mark as unread") 66 | onClicked: chatsModel.markAsUnread(id,!is_marked_unread) 67 | } 68 | } 69 | 70 | ListView.onAdd: AddAnimation { 71 | target: chatDelegate 72 | } 73 | 74 | ListView.onRemove: RemoveAnimation { 75 | target: chatDelegate 76 | } 77 | 78 | onClicked:{ 79 | var page = pageStack.find(function (page) { 80 | return page.__messaging_page !== undefined 81 | }); 82 | if(_opened_chat_id !== id) 83 | { 84 | _opened_chat_id = id 85 | if(is_marked_unread) 86 | chatsModel.markAsUnread(id,false) 87 | pageStack.pushAttached("MessagingPage.qml",{chatId:id}) 88 | } 89 | pageStack.navigateForward() 90 | } 91 | } 92 | } 93 | 94 | } 95 | 96 | 97 | -------------------------------------------------------------------------------- /depecher/qml/pages/FilterMessagesPage.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import TelegramModels 1.0 4 | import tdlibQtEnums 1.0 5 | import "../js/utils.js" as Utils 6 | import QtMultimedia 5.6 7 | import "items/filter_delegates" 8 | Page { 9 | id:page 10 | property alias chatId: itemsModel.peerId 11 | property alias filter: itemsModel.filter 12 | property alias totalCount: itemsModel.totalCount 13 | SearchChatMessagesModel { 14 | id: itemsModel 15 | } 16 | 17 | Loader { 18 | id:loader 19 | anchors.fill: parent 20 | function onDownloadDocument(index) { 21 | itemsModel.downloadDocument(index) 22 | } 23 | onLoaded: { 24 | loader.item.downloadDocument.connect(onDownloadDocument) 25 | } 26 | source: {} 27 | Component.onCompleted: { 28 | switch(filter) { 29 | case TdlibState.Photo: 30 | setSource("items/filter_delegates/PhotoView.qml",{model:itemsModel,currentFilter:filter}) 31 | break 32 | case TdlibState.Video: 33 | setSource("items/filter_delegates/VideoView.qml",{model:itemsModel,currentFilter:filter}) 34 | break 35 | case TdlibState.Audio: 36 | setSource("items/filter_delegates/AudioView.qml",{model:itemsModel,currentFilter:filter}) 37 | break 38 | case TdlibState.Document: 39 | setSource("items/filter_delegates/DocumentView.qml",{model:itemsModel,currentFilter:filter}) 40 | break 41 | case TdlibState.Url: 42 | setSource("items/filter_delegates/LinkView.qml",{model:itemsModel,currentFilter:filter}) 43 | break 44 | case TdlibState.VoiceNote: 45 | setSource("items/filter_delegates/VoiceView.qml",{model:itemsModel,currentFilter:filter}) 46 | break 47 | 48 | } 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /depecher/qml/pages/SelectChatDialog.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import tdlibQtEnums 1.0 4 | import TelegramModels 1.0 5 | import "items" 6 | import "components" 7 | 8 | Dialog { 9 | id: page 10 | property string selected_chat_id: "" 11 | property string from_chat_id: "" 12 | property var messages: [] 13 | allowedOrientations: Orientation.All 14 | onAccepted: { 15 | var page = pageStack.find(function (page) { 16 | return page.__chat_page !== undefined; 17 | }); 18 | if(page) 19 | page._opened_chat_id = "" 20 | pageStack.replaceAbove(page,Qt.resolvedUrl("MessagingPage.qml"),{"chatId":selected_chat_id, 21 | "forwardMessages":{ 22 | "selected_chat_id":selected_chat_id, 23 | "from_chat_id":from_chat_id, 24 | "messages":messages 25 | }}) 26 | } 27 | canAccept: selected_chat_id !== "" 28 | ChatsModel{ 29 | id:chatsModel 30 | } 31 | SilicaListView { 32 | anchors.fill: parent 33 | model:chatsModel 34 | header: DialogHeader { 35 | acceptText: qsTr("Select chat") 36 | } 37 | 38 | delegate: ChatItem { 39 | id: chatDelegate 40 | highlighted: id === selected_chat_id 41 | 42 | ListView.onAdd: AddAnimation { 43 | target: chatDelegate 44 | } 45 | 46 | ListView.onRemove: RemoveAnimation { 47 | target: chatDelegate 48 | } 49 | 50 | onClicked: { 51 | selected_chat_id = id 52 | } 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /depecher/qml/pages/VideoPage.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Gallery 1.0 3 | import Sailfish.Media 1.0 4 | import QtMultimedia 5.6 5 | import Sailfish.Silica 1.0 6 | Page { 7 | id:root 8 | property alias source: mediaPlayer.source 9 | property url thumbnail 10 | property alias mimeType: videoPoster.mimeType 11 | 12 | property bool autoPlay: false 13 | orientation: Orientation.All 14 | VideoPoster { 15 | id:videoPoster 16 | source: root.thumbnail ? root.thumbnail : root.source 17 | playing: mediaPlayer.playing 18 | loaded: mediaPlayer.loaded 19 | busy: false//!mediaPlayer.hasVideo && mediaPlayer.hasError 20 | onTogglePlay: mediaPlayer.togglePlay() 21 | contentWidth: root.width 22 | contentHeight: root.height 23 | anchors.centerIn: parent 24 | overlayMode: mediaPlayer.playbackState == MediaPlayer.StoppedState 25 | 26 | 27 | } 28 | VideoOutput { 29 | property alias player: mediaPlayer 30 | visible: player.playbackState != MediaPlayer.StoppedState 31 | anchors.fill: parent 32 | source: GalleryMediaPlayer { 33 | id: mediaPlayer 34 | active: true 35 | autoPlay: root.autoPlay 36 | source: active ? currentItem.source : "" 37 | onPlayingChanged: { 38 | if (playing) { 39 | // go fullscreen for playback if triggered via Play icon. 40 | overlay.hideControls() 41 | } 42 | } 43 | } 44 | MouseArea { 45 | anchors.fill: parent 46 | onClicked: { 47 | if(overlay.open) 48 | overlay.hideControls() 49 | else 50 | overlay.showControls() 51 | } 52 | } 53 | 54 | } 55 | MediaPlayerControlsPanel { 56 | id:overlay 57 | z:100 58 | duration: mediaPlayer.duration / 1000 59 | position: mediaPlayer.position / 1000 60 | playing: true 61 | showMenu: false 62 | Component.onCompleted: showControls() 63 | onSliderReleased: { 64 | mediaPlayer.seek(value * 1000) 65 | } 66 | onPreviousClicked: mediaPlayer.seek(0) 67 | 68 | onPlayPauseClicked: mediaPlayer.togglePlay() 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /depecher/qml/pages/components/authorization/AreYouSureDialog.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import tdlibQtEnums 1.0 4 | import "../../../js/utils.js" as Utils 5 | Dialog { 6 | id:areYouSureDialog 7 | property string fullPhoneNumber: "" 8 | property string connectionStatus: Utils.setState(c_telegramWrapper.connectionState) 9 | acceptDestination: Qt.resolvedUrl("SignInDialog.qml") 10 | acceptDestinationAction: PageStackAction.Replace 11 | canAccept: c_telegramWrapper.connectionState === TdlibState.ConnectionStateReady 12 | onAcceptPendingChanged: { 13 | if (acceptPending) { 14 | c_telegramWrapper.setPhoneNumber(fullPhoneNumber); 15 | } 16 | } 17 | Connections { 18 | target: c_telegramWrapper 19 | onConnectionStateChanged:{ 20 | connectionStatus = Utils.setState(connectionState) 21 | } 22 | } 23 | 24 | Column{ 25 | width: parent.width-2*x 26 | x:Theme.horizontalPageMargin 27 | spacing:Theme.paddingLarge 28 | PageHeader{} 29 | Label{ 30 | width: parent.width 31 | horizontalAlignment: Text.AlignHCenter 32 | visible: connectionStatus != "Ready" 33 | wrapMode: Text.WordWrap 34 | font.pixelSize: Theme.fontSizeExtraSmall 35 | text:qsTr("To continue connection to Telegram is needed") 36 | color:"red" 37 | } 38 | Label{ 39 | width: parent.width 40 | horizontalAlignment: Text.AlignHCenter 41 | 42 | wrapMode: Text.WordWrap 43 | font.pixelSize: Theme.fontSizeSmall 44 | color: Theme.secondaryColor 45 | text: qsTr("Connection status: ")+ connectionStatus 46 | } 47 | 48 | Label{ 49 | width: parent.width 50 | horizontalAlignment: Text.AlignHCenter 51 | text:qsTr("Is phone correct?") 52 | color:Theme.primaryColor 53 | 54 | } 55 | Label{ 56 | text:fullPhoneNumber 57 | horizontalAlignment: Text.AlignHCenter 58 | width: parent.width 59 | color:Theme.secondaryColor 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /depecher/qml/pages/components/authorization/EncryptionKeyDialog.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | Item { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /depecher/qml/pages/components/settings/BehaviorPage.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import Nemo.Configuration 1.0 4 | import TelegramModels 1.0 5 | import tdlibQtEnums 1.0 6 | import "../../items" 7 | Page { 8 | id:root 9 | property string settingsBehaviorPath: "/apps/depecher/behavior" 10 | ConfigurationValue { 11 | id:sendByEnter 12 | key:settingsBehaviorPath +"/sendByEnter" 13 | defaultValue: false 14 | } 15 | Column{ 16 | id:column 17 | width: parent.width 18 | PageHeader{ 19 | title:qsTr("Behavior") 20 | } 21 | TextSwitch { 22 | width: parent.width -2*x 23 | x:Theme.horizontalPageMargin 24 | checked: sendByEnter.value 25 | automaticCheck: false 26 | text: qsTr("Send message by enter") 27 | onClicked: { 28 | sendByEnter.value = !checked 29 | sendByEnter.sync() 30 | } 31 | 32 | } 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /depecher/qml/pages/components/settings/proxypage.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/CircleImage.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import QtGraphicalEffects 1.0 4 | 5 | Image { 6 | id:avata 7 | property alias source:avata.source 8 | property alias fallbackText:fallbacktext.text 9 | property alias fallbackItemVisible: fallbackitem.visible 10 | width:parent.height-5 11 | height: width 12 | 13 | layer.enabled:true 14 | layer.effect: OpacityMask { 15 | maskSource: Item { 16 | width: avata.width 17 | height: avata.height 18 | Rectangle { 19 | anchors.centerIn: parent 20 | width: avata.width 21 | height: avata.height 22 | radius: Math.min(width, height) 23 | } 24 | } 25 | } 26 | 27 | Rectangle { 28 | id: fallbackitem 29 | anchors.fill: parent 30 | color: Theme.highlightBackgroundColor 31 | radius: width * 0.5 32 | Label { 33 | id: fallbacktext 34 | font { bold: true; pixelSize: Theme.fontSizeLarge } 35 | anchors.centerIn: parent 36 | color: Theme.primaryColor 37 | } 38 | } 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/StickerPreviewComponent.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | 4 | Item { 5 | property alias source: img.source 6 | property alias emoji: emojiLabel.text 7 | width: parent.width 8 | height: emojiLabel.height + img.height + 2*Theme.paddingMedium 9 | 10 | Label{ 11 | id:emojiLabel 12 | anchors.horizontalCenter: parent.horizontalCenter 13 | anchors.topMargin: Theme.paddingMedium 14 | font.pixelSize: Theme.fontSizeHuge 15 | } 16 | Image { 17 | id: img 18 | anchors.horizontalCenter: parent.horizontalCenter 19 | anchors.top: emojiLabel.bottom 20 | anchors.topMargin: Theme.paddingMedium 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/delegates/ChatCreatedDelegate.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import TelegramModels 1.0 4 | import tdlibQtEnums 1.0 5 | import QtMultimedia 5.6 6 | import Nemo.Configuration 1.0 7 | import Nemo.DBus 2.0 8 | import QtQml.Models 2.3 9 | import depecherUtils 1.0 10 | 11 | 12 | Item { 13 | width: messageListItem.width 14 | height: Theme.itemSizeSmall 15 | x:Theme.horizontalPageMargin/2 16 | 17 | Rectangle { 18 | width: chatCreatedLabel.width + 4*Theme.paddingLarge 19 | height: chatCreatedLabel.height + 1*Theme.paddingLarge 20 | anchors.centerIn: parent 21 | radius: 90 22 | gradient: Gradient { 23 | GradientStop { position: 0.0; color: Theme.rgba(Theme.highlightBackgroundColor, 0.10) } 24 | GradientStop { position: 1.0; color: Theme.rgba(Theme.highlightBackgroundColor, 0.30) } 25 | } 26 | Label { 27 | id: chatCreatedLabel 28 | anchors.centerIn: parent 29 | text: qsTr("%1 created the group %2").arg(author).arg(content) 30 | font.pixelSize: Theme.fontSizeTiny 31 | font.bold: true 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/delegates/ContactDelegate.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import TelegramModels 1.0 4 | import tdlibQtEnums 1.0 5 | import QtMultimedia 5.6 6 | import Nemo.Configuration 1.0 7 | import Nemo.DBus 2.0 8 | import QtQml.Models 2.3 9 | import depecherUtils 1.0 10 | 11 | BackgroundItem { 12 | property int maxWidth: messageListItem.width *2/3 - Theme.horizontalPageMargin * 2 13 | width: maxWidth 14 | height: Theme.itemSizeMedium 15 | DBusInterface { 16 | id: manager 17 | 18 | bus: DBus.SessionBus 19 | service: "com.jolla.contacts.ui" 20 | path: "/com/jolla/contacts/ui" 21 | iface: "com.jolla.contacts.ui" 22 | } 23 | 24 | Column{ 25 | width: parent.width 26 | Label { 27 | text: content["first_name"] + " " + content["last_name"] 28 | } 29 | Label { 30 | font.pixelSize: Theme.fontSizeSmall 31 | text: content["phone_number"] 32 | } 33 | FileWorker { 34 | id:fileWorker 35 | } 36 | } 37 | onClicked: { 38 | var path = fileWorker.openContact(content["first_name"],content["last_name"], 39 | content["phone_number"],content["user_id"]) 40 | manager.typedCall( "importContactFile",[{"type":"s","value":"file://"+path}], 41 | function(){ 42 | console.log("Import fine!") 43 | }, 44 | function() { 45 | console.log("Importing error") 46 | } 47 | ) 48 | 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/delegates/JoinByLinkDelegate.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import TelegramModels 1.0 4 | import tdlibQtEnums 1.0 5 | import QtMultimedia 5.6 6 | import Nemo.Configuration 1.0 7 | import Nemo.DBus 2.0 8 | import QtQml.Models 2.3 9 | import depecherUtils 1.0 10 | 11 | Item { 12 | width: messageListItem.width 13 | height: Theme.itemSizeSmall 14 | x:Theme.horizontalPageMargin/2 15 | Rectangle { 16 | width: joinByLinkLabel.width + 4*Theme.paddingLarge 17 | height: joinByLinkLabel.height + 1*Theme.paddingLarge 18 | anchors.centerIn: parent 19 | 20 | radius: 90 21 | gradient: Gradient { 22 | GradientStop { position: 0.0; color: Theme.rgba(Theme.highlightBackgroundColor, 0.10) } 23 | GradientStop { position: 1.0; color: Theme.rgba(Theme.highlightBackgroundColor, 0.30) } 24 | } 25 | 26 | Label { 27 | id: joinByLinkLabel 28 | anchors.centerIn: parent 29 | text: qsTr("%1 joined by invite link").arg(author) 30 | font.pixelSize: Theme.fontSizeTiny 31 | font.bold: true 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/delegates/JoinedDelegate.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import TelegramModels 1.0 4 | import tdlibQtEnums 1.0 5 | import QtMultimedia 5.6 6 | import Nemo.Configuration 1.0 7 | import Nemo.DBus 2.0 8 | import QtQml.Models 2.3 9 | import depecherUtils 1.0 10 | 11 | Item { 12 | width: messageListItem.width 13 | height: Theme.itemSizeSmall 14 | x:Theme.horizontalPageMargin/2 15 | 16 | Rectangle { 17 | width: joinedLabel.width + 4*Theme.paddingLarge 18 | height: joinedLabel.height + 1*Theme.paddingLarge 19 | anchors.centerIn: parent 20 | radius: 90 21 | gradient: Gradient { 22 | GradientStop { position: 0.0; color: Theme.rgba(Theme.highlightBackgroundColor, 0.10) } 23 | GradientStop { position: 1.0; color: Theme.rgba(Theme.highlightBackgroundColor, 0.30) } 24 | } 25 | 26 | Label { 27 | id: joinedLabel 28 | anchors.centerIn: parent 29 | text: qsTr("%1 joined Telegram!").arg(author) 30 | font.pixelSize: Theme.fontSizeTiny 31 | font.bold: true 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/delegates/NewMessageDelegate.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import TelegramModels 1.0 4 | import tdlibQtEnums 1.0 5 | import QtMultimedia 5.6 6 | import Nemo.Configuration 1.0 7 | import Nemo.DBus 2.0 8 | import QtQml.Models 2.3 9 | import depecherUtils 1.0 10 | 11 | Item { 12 | width: messageListItem.width 13 | height: Theme.itemSizeSmall 14 | x:Theme.horizontalPageMargin/2 15 | 16 | Rectangle { 17 | width: newMessagesLabel.width + 4*Theme.paddingLarge 18 | height: newMessagesLabel.height + 1*Theme.paddingLarge 19 | anchors.centerIn: parent 20 | radius: 90 21 | gradient: Gradient { 22 | GradientStop { position: 0.0; color: Theme.rgba(Theme.highlightBackgroundColor, 0.10) } 23 | GradientStop { position: 1.0; color: Theme.rgba(Theme.highlightBackgroundColor, 0.30) } 24 | } 25 | 26 | Label { 27 | id: newMessagesLabel 28 | anchors.centerIn: parent 29 | text: qsTr("New messages") 30 | font.pixelSize: Theme.fontSizeTiny 31 | font.bold: true 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/delegates/RichTextItem.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.6 2 | import Sailfish.Silica 1.0 3 | Label { 4 | property string content 5 | textFormat: Text.RichText 6 | text: "" + 7 | content 8 | color: pressed ? Theme.secondaryColor : Theme.primaryColor 9 | linkColor: pressed ? Theme.secondaryHighlightColor : Theme.highlightColor 10 | onLinkActivated: { 11 | if(link.substring(0,4) == "user") 12 | pageStack.push(Qt.resolvedUrl("../../UserPage.qml"),{username:link.substring(6)}) 13 | else if(link.substring(0,7) == "id_user") 14 | pageStack.push(Qt.resolvedUrl("../../UserPage.qml"),{user_id:parseInt(link.substring(8))}) 15 | else 16 | Qt.openUrlExternally(link) 17 | } 18 | font.pixelSize: Theme.fontSizeSmall 19 | wrapMode: Text.WrapAtWordBoundaryOrAnywhere 20 | } 21 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/delegates/StickerDelegate.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import TelegramModels 1.0 4 | import tdlibQtEnums 1.0 5 | import QtMultimedia 5.6 6 | import Nemo.Configuration 1.0 7 | import Nemo.DBus 2.0 8 | import QtQml.Models 2.3 9 | import depecherUtils 1.0 10 | 11 | Image { 12 | id:stickerImage 13 | asynchronous: true 14 | anchors.fill: parent 15 | fillMode: Image.PreserveAspectFit 16 | source: content ? "image://depecherDb/" + content : "" 17 | MouseArea { 18 | anchors.fill: parent 19 | onClicked: pageStack.push(Qt.resolvedUrl("../../components/PreviewStickerSetDialog.qml"),{set_id:sticker_set_id}) 20 | } 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/delegates/TextDelegate.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import TelegramModels 1.0 4 | import tdlibQtEnums 1.0 5 | import QtMultimedia 5.6 6 | import Nemo.Configuration 1.0 7 | import Nemo.DBus 2.0 8 | import QtQml.Models 2.3 9 | import depecherUtils 1.0 10 | import "utils.js" as JsUtils 11 | 12 | 13 | Column { 14 | id:textColumn 15 | 16 | width: textItem.width 17 | 18 | 19 | ConfigurationValue { 20 | id: fullSizeInChannels 21 | key:"/apps/depecher/ui/message/fullSizeInChannels" 22 | defaultValue: false 23 | } 24 | states: [ 25 | State { 26 | name: "fullSizeWithMarginCorrection" 27 | when: fullSizeInChannels.value && messagingModel.chatType["is_channel"] 28 | PropertyChanges { 29 | target: textItem 30 | width: JsUtils.getWidth() - 2 * textColumn.x 31 | } 32 | PropertyChanges { 33 | target: textColumn 34 | x: Theme.paddingMedium 35 | width: JsUtils.getWidth() 36 | } 37 | } 38 | ] 39 | 40 | 41 | RichTextItem { 42 | id: textItem 43 | width: messageListItem.width * 2 / 3 - Theme.horizontalPageMargin * 2 44 | content: rich_text 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/delegates/TopMarginDelegate.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | Item { 4 | width:messageListItem.width 5 | height: Theme.itemSizeExtraLarge - 49 6 | } 7 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/delegates/utils.js: -------------------------------------------------------------------------------- 1 | function getWidth() { 2 | switch(page.orientation) { 3 | case Orientation.Portrait: 4 | case Orientation.PortraitInverted: 5 | return Screen.width 6 | case Orientation.Landscape: 7 | case Orientation.LandscapeInverted: 8 | return Screen.height 9 | 10 | } 11 | } 12 | function getHeight() { 13 | switch(page.orientation) { 14 | case Orientation.Portrait: 15 | case Orientation.PortraitInverted: 16 | return Screen.height 17 | case Orientation.Landscape: 18 | case Orientation.LandscapeInverted: 19 | return Screen.width 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/filter_delegates/DocumentView.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import TelegramModels 1.0 4 | import tdlibQtEnums 1.0 5 | import "../../../js/utils.js" as Utils 6 | import QtMultimedia 5.6 7 | Page { 8 | id:page 9 | property alias chatId: itemsModel.peerId 10 | property alias filter: itemsModel.filter 11 | property alias totalCount: itemsModel.totalCount 12 | SearchChatMessagesModel { 13 | id: itemsModel 14 | Component.onCompleted: console.log(filter) 15 | } 16 | SilicaListView { 17 | id:list 18 | property var currentFilter 19 | model:itemsModel 20 | header: PageHeader { 21 | title: qsTr("Documents") 22 | } 23 | anchors.fill: parent 24 | delegate: BackgroundItem { 25 | width: parent.width 26 | height: Theme.itemSizeMedium 27 | enabled: file_downloading_completed && !file_is_uploading 28 | onClicked: Qt.openUrlExternally("file://"+content) 29 | 30 | Row { 31 | id: documentRowWrapper 32 | width: parent.width 33 | spacing: Theme.paddingMedium 34 | height: parent.height 35 | 36 | Image { 37 | id: image 38 | fillMode: Image.PreserveAspectFit 39 | source: "image://theme/icon-m-file-document" 40 | anchors.verticalCenter: parent.verticalCenter 41 | 42 | ProgressCircle { 43 | id: progress 44 | anchors.fill: parent 45 | visible: file_is_uploading || file_is_downloading 46 | value : file_is_uploading ? file_uploaded_size / file_downloaded_size : 47 | file_downloaded_size / file_uploaded_size 48 | } 49 | 50 | Image { 51 | id: downloadIcon 52 | visible: !file_downloading_completed || progress.visible 53 | source: progress.visible ? "image://theme/icon-s-clear-opaque-cross" 54 | : "image://theme/icon-s-update" 55 | anchors.centerIn: parent 56 | } 57 | 58 | MouseArea { 59 | enabled: downloadIcon.visible 60 | anchors.fill: parent 61 | onClicked: { 62 | if(file_is_downloading) 63 | itemsModel.cancelDownload(index) 64 | else 65 | itemsModel.downloadDocument(index) 66 | } 67 | } 68 | 69 | } 70 | 71 | Column { 72 | width: parent.width - image.width - parent.spacing 73 | spacing: Theme.paddingSmall 74 | anchors.verticalCenter: image.verticalCenter 75 | 76 | Label { 77 | width: parent.width 78 | elide: Text.ElideMiddle 79 | color: pressed ? Theme.secondaryColor : Theme.primaryColor 80 | font.pixelSize: Theme.fontSizeSmall 81 | text: document_name 82 | } 83 | 84 | Label { 85 | 86 | color: pressed ? Theme.primaryColor : Theme.secondaryColor 87 | font.pixelSize: Theme.fontSizeTiny 88 | text: Format.formatFileSize(file_downloaded_size) + "/" 89 | + Format.formatFileSize(file_uploaded_size) 90 | } 91 | } 92 | } 93 | } 94 | 95 | } 96 | 97 | 98 | } 99 | 100 | 101 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/filter_delegates/LinkView.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import TelegramModels 1.0 4 | import tdlibQtEnums 1.0 5 | import "../../../js/utils.js" as Utils 6 | import QtMultimedia 5.6 7 | import "../delegates" 8 | Page { 9 | id:page 10 | property alias chatId: itemsModel.peerId 11 | property alias filter: itemsModel.filter 12 | property alias totalCount: itemsModel.totalCount 13 | SearchChatMessagesModel { 14 | id: itemsModel 15 | } 16 | SilicaListView { 17 | id:list 18 | header: PageHeader { 19 | title: qsTr("Links") 20 | 21 | } 22 | model:itemsModel 23 | anchors.fill: parent 24 | delegate: Column { 25 | width:Utils.getWidth() - 2 * x 26 | x: Theme.horizontalPageMargin 27 | Label { 28 | width:parent.width 29 | maximumLineCount: 3 30 | font.pixelSize: Theme.fontSizeSmall 31 | wrapMode: Text.WrapAtWordBoundaryOrAnywhere 32 | textFormat: Text.PlainText 33 | truncationMode: TruncationMode.Fade 34 | text:content 35 | } 36 | Label { 37 | width:parent.width 38 | textFormat: Text.RichText 39 | text: "" + 40 | links 41 | color: pressed ? Theme.secondaryColor : Theme.primaryColor 42 | linkColor: pressed ? Theme.secondaryHighlightColor : Theme.highlightColor 43 | onLinkActivated: { 44 | Qt.openUrlExternally(link) 45 | } 46 | font.pixelSize: Theme.fontSizeSmall 47 | wrapMode: Text.WrapAtWordBoundaryOrAnywhere 48 | } 49 | } 50 | } 51 | } 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /depecher/qml/pages/items/filter_delegates/PhotoView.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | import Sailfish.Silica 1.0 3 | import TelegramModels 1.0 4 | import tdlibQtEnums 1.0 5 | import "../../../js/utils.js" as Utils 6 | import QtMultimedia 5.6 7 | Page { 8 | id:page 9 | property alias chatId: itemsModel.peerId 10 | property alias filter: itemsModel.filter 11 | property alias totalCount: itemsModel.totalCount 12 | SearchChatMessagesModel { 13 | id: itemsModel 14 | } 15 | SilicaGridView { 16 | id:grid 17 | property var currentFilter 18 | property Item expandItem 19 | header: PageHeader { 20 | title: qsTr("Images") 21 | } 22 | anchors.fill: parent 23 | property real cellSize: Math.floor(width / columnCount) 24 | property int columnCount: Math.floor(width / Theme.itemSizeHuge) 25 | cellHeight: cellSize 26 | cellWidth: cellSize 27 | 28 | model: itemsModel 29 | 30 | delegate: BackgroundItem { 31 | id:thumbnail 32 | 33 | width: grid.cellSize 34 | height:isExpanded ? grid.contextMenu.height + grid.cellHeight : grid.cellHeight 35 | property bool isExpanded: grid.expandItem === thumbnail 36 | Item { 37 | id:wrapper 38 | width:grid.cellSize 39 | height:width 40 | Image { 41 | source: content 42 | fillMode: Image.PreserveAspectCrop 43 | anchors.fill: parent 44 | } 45 | } 46 | 47 | onClicked: { 48 | pageStack.push("../../PicturePage.qml",{imagePath:content}) 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /depecher/resource.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | qml/assets/icons/git.svg 4 | qml/assets/icons/paypal.svg 5 | qml/assets/icons/rocket.svg 6 | qml/assets/icons/check.svg 7 | qml/assets/icons/en_sailfish.jpg 8 | qml/assets/icons/ru_sailfish.jpg 9 | qml/assets/background/dark.jpg 10 | qml/assets/icons/lock_slide_40x80.png 11 | qml/assets/icons/lock_slide_80x40.png 12 | qml/assets/icons/it_sailfish.jpg 13 | 14 | 15 | -------------------------------------------------------------------------------- /depecher/rpm/depecher.yaml: -------------------------------------------------------------------------------- 1 | Name: depecher 2 | Summary: Telegram client for Sailfish OS 3 | Version: 0.7.3 4 | Release: 1 5 | # The contents of the Group field should be one of the groups listed here: 6 | # http://gitorious.org/meego-developer-tools/spectacle/blobs/master/data/GROUPS 7 | Group: Applications/Communications 8 | URL: https://github.com/blacksailer/depecher 9 | License: LICENSE 10 | # This must be generated before uploading a package to a remote build service. 11 | # Usually this line does not need to be modified. 12 | Sources: 13 | - '%{name}-%{version}.tar.bz2' 14 | Description: | 15 | Another Telegram client for Sailfish OS built on top of tdlib 16 | Configure: none 17 | # The qtc5 builder inserts macros to allow QtCreator to have fine 18 | # control over qmake/make execution 19 | Builder: qtc5 20 | 21 | # This section specifies build dependencies that are resolved using pkgconfig. 22 | # This is the preferred way of specifying build dependencies for your package. 23 | PkgConfigBR: 24 | - sailfishapp >= 1.0.2 25 | - Qt5Core 26 | - Qt5Qml 27 | - Qt5Quick 28 | - openssl 29 | - tdlibjson 30 | - nemonotifications-qt5 31 | - vorbisfile 32 | - libdbusaccess 33 | 34 | # Build dependencies without a pkgconfig setup can be listed here 35 | PkgBR: 36 | - sailfish-svg2png >= 0.1.5 37 | 38 | # Runtime dependencies which are not automatically detected 39 | Requires: 40 | - sailfishsilica-qt5 >= 0.10.9 41 | - tdlibjson >= 1.3.1 42 | - libvorbis 43 | - libdbusaccess 44 | 45 | # All installed files 46 | Files: 47 | - '%{_bindir}' 48 | - '%{_datadir}/%{name}' 49 | - '%{_datadir}/applications/%{name}.desktop' 50 | - '%{_datadir}/icons/hicolor/*/apps/%{name}.png' 51 | - '%{_datadir}/lipstick/notificationcategories/*.conf' 52 | - '%{_datadir}/ngfd/events.d/*.ini' 53 | - '%exclude %{_libdir}/cmake/*' 54 | - '%exclude %{_libdir}/debug/*' 55 | - '%{_datadir}/dbus-1/services/org.blacksailer.depecher.service' 56 | - '%{_datadir}/dbus-1/interfaces/org.blacksailer.depecher.xml' 57 | - '%{_datadir}/jolla-settings/entries/%{name}.json' 58 | - '%{_libdir}/systemd/user/org.blacksailer.depecher.service' 59 | - '%{_libdir}/nemo-transferengine/plugins/*' 60 | - '%{_sysconfdir}/%{name}/depecher-dbus-access.conf' 61 | - '%{_datadir}/themes/%{theme}/meegotouch/z1.0/icons/*.png' 62 | - '%{_datadir}/themes/%{theme}/meegotouch/z1.25/icons/*.png' 63 | - '%{_datadir}/themes/%{theme}/meegotouch/z1.5/icons/*.png' 64 | - '%{_datadir}/themes/%{theme}/meegotouch/z1.5-large/icons/*.png' 65 | - '%{_datadir}/themes/%{theme}/meegotouch/z1.75/icons/*.png' 66 | - '%{_datadir}/themes/%{theme}/meegotouch/z2.0/icons/*.png' 67 | 68 | # For more information about yaml and what's supported in Sailfish OS 69 | # build system, please see https://wiki.merproject.org/wiki/Spectacle 70 | -------------------------------------------------------------------------------- /depecher/settings/depecher.json: -------------------------------------------------------------------------------- 1 | { 2 | "translation_catalog" : "depecher", 3 | "entries": [ 4 | { 5 | "path": "applications/depecher.desktop", 6 | "title": "Depecher", 7 | "type": "page", 8 | "icon": "depecher", 9 | "params": { 10 | "source": "/usr/share/depecher/settings/DepecherAppSettings.qml" 11 | } 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /depecher/src/DBusAdaptor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DBUSADAPTOR_HPP 2 | #define DBUSADAPTOR_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include "dbus/DepecherAdaptor.hpp" 8 | class PageAppStarter; 9 | namespace tdlibQt { 10 | class TdlibJsonWrapper; 11 | } 12 | 13 | 14 | class DBusAdaptor : public QObject 15 | { 16 | Q_OBJECT 17 | QGuiApplication *app = nullptr; 18 | QQuickView *view = nullptr; 19 | PageAppStarter *pagesStarter; 20 | tdlibQt::TdlibJsonWrapper *tdlibJson; 21 | public: 22 | explicit DBusAdaptor(QGuiApplication *parent = nullptr); 23 | ~DBusAdaptor(); 24 | static bool isRegistered(); 25 | static bool raiseApp(); 26 | public slots: 27 | void showApp(const QStringList &cmd); 28 | void openConversation(const qlonglong &chatId); 29 | private slots: 30 | void onViewDestroyed(); 31 | void onViewClosing(QQuickCloseEvent *v); 32 | }; 33 | 34 | #endif // DBUSADAPTOR_HPP 35 | -------------------------------------------------------------------------------- /depecher/src/FileWorker.cpp: -------------------------------------------------------------------------------- 1 | #include "FileWorker.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | FileWorker::FileWorker(QObject *parent) : QObject(parent), 9 | m_PicturesPath(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + "/Depecher") 10 | { 11 | QDir pictureDir; 12 | pictureDir.mkpath(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + "/Depecher"); 13 | } 14 | 15 | bool FileWorker::savePictureToGallery(const QString &sourcePath) 16 | { 17 | QUrl a(sourcePath); 18 | return QFile::copy(a.toLocalFile(), 19 | m_PicturesPath + "/" + 20 | a.fileName()); 21 | } 22 | 23 | QString FileWorker::openContact(const QString &firstName, const QString &lastName, const QString &phoneNumber, const int userId) 24 | { 25 | QString path = QStandardPaths::writableLocation(QStandardPaths::TempLocation); 26 | QFile file(path + "/contact.vcf"); 27 | QString vcfData = "BEGIN:VCARD \n" 28 | "VERSION:2.1 \n" 29 | "FN;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:%1 %2 \n" 30 | "N;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:%2;%1 \n" 31 | "TEL;HOME;VOICE;ISDN:%3 \n" 32 | "END:VCARD"; 33 | vcfData = vcfData.arg(firstName, lastName, phoneNumber); 34 | if (file.open(QIODevice::WriteOnly)) { 35 | file.write(vcfData.toUtf8()); 36 | file.close(); 37 | return path + "/contact.vcf"; 38 | } else 39 | return ""; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /depecher/src/FileWorker.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILEWORKER_HPP 2 | #define FILEWORKER_HPP 3 | 4 | #include 5 | 6 | class FileWorker : public QObject 7 | { 8 | Q_OBJECT 9 | QString m_PicturesPath; 10 | public: 11 | explicit FileWorker(QObject *parent = 0); 12 | 13 | signals: 14 | 15 | public slots: 16 | bool savePictureToGallery(const QString &sourcePath); 17 | QString openContact(const QString &firstName, const QString &lastName, const QString &phoneNumber, const int userId); 18 | }; 19 | 20 | #endif // FILEWORKER_HPP 21 | -------------------------------------------------------------------------------- /depecher/src/Settings.cpp: -------------------------------------------------------------------------------- 1 | #include "Settings.hpp" 2 | 3 | Settings::Settings() 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /depecher/src/Settings.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SETTINGS_HPP 2 | #define SETTINGS_HPP 3 | 4 | 5 | class Settings 6 | { 7 | public: 8 | Settings(); 9 | }; 10 | 11 | #endif // SETTINGS_HPP -------------------------------------------------------------------------------- /depecher/src/components/AudioRecorder.hpp: -------------------------------------------------------------------------------- 1 | #ifndef AUDIORECORDER_H 2 | #define AUDIORECORDER_H 3 | 4 | #include 5 | #include 6 | 7 | class QTemporaryFile; 8 | 9 | class AudioRecorder : public QAudioRecorder 10 | { 11 | Q_OBJECT 12 | Q_PROPERTY(QString location READ location NOTIFY locationChanged) 13 | Q_PROPERTY(bool autoRemove READ autoRemove WRITE setAutoRemove NOTIFY autoRemoveChanged) 14 | Q_PROPERTY(AudioRecorder::AudioCodec codec READ codec WRITE setCodec NOTIFY codecChanged) 15 | Q_PROPERTY(bool recording READ recording NOTIFY recordingChanged) 16 | 17 | public: 18 | explicit AudioRecorder(QObject *parent = nullptr); 19 | ~AudioRecorder(); 20 | enum AudioCodec 21 | { 22 | Vorbis, 23 | Speex, 24 | PCM, 25 | FLAC 26 | }; 27 | Q_ENUM(AudioCodec) 28 | Q_ENUM(QMediaRecorder::State) 29 | 30 | QString location() const; 31 | AudioRecorder::AudioCodec codec() const; 32 | 33 | bool autoRemove() const; 34 | 35 | bool recording() const; 36 | 37 | private: 38 | struct CodecSetting 39 | { 40 | QString codec; 41 | QString extension; 42 | QString container; 43 | }; 44 | static const QString defaultStoragePath; 45 | QHash codecSettingsMap; 46 | QString m_location; 47 | void setLocation(const QString &location); 48 | 49 | AudioRecorder::AudioCodec m_codec; 50 | QTemporaryFile *m_file; 51 | 52 | 53 | 54 | 55 | bool m_autoRemove = false; 56 | 57 | bool m_recording; 58 | 59 | public slots: 60 | void setCodec(AudioRecorder::AudioCodec codec); 61 | void startRecording(); 62 | void stopRecording(); 63 | void deleteRecording(); 64 | void setAutoRemove(bool autoRemove); 65 | QString getWaveform(); 66 | 67 | signals: 68 | 69 | void locationChanged(QString location); 70 | void codecChanged(AudioRecorder::AudioCodec codec); 71 | 72 | void autoRemoveChanged(bool autoRemove); 73 | void recordingChanged(bool recording); 74 | }; 75 | 76 | #endif // AUDIORECORDER_H 77 | -------------------------------------------------------------------------------- /depecher/src/fileGeneratedHandlers/CopyFileConversion.hpp: -------------------------------------------------------------------------------- 1 | #ifndef COPYFILECONVERSION_HPP 2 | #define COPYFILECONVERSION_HPP 3 | 4 | #include "FileGeneratedInterface.hpp" 5 | 6 | class CopyFileConversion : public FileGeneratedInterface 7 | { 8 | Q_OBJECT 9 | qint64 m_expectedSize = 0; 10 | qint64 m_generatedSize = 0; 11 | 12 | public: 13 | CopyFileConversion(QObject *parent, const qint64 &generationId, 14 | const QString &originalPath, 15 | const QString &destinationPath, 16 | const QString &conversion); 17 | 18 | // FileGeneratedInterface interface 19 | public slots: 20 | void startGeneration() Q_DECL_OVERRIDE; 21 | void stop(const QString &error); 22 | void stopGeneration() Q_DECL_OVERRIDE; 23 | void finishGeneration() Q_DECL_OVERRIDE; 24 | }; 25 | 26 | 27 | class Worker : public QObject { 28 | Q_OBJECT 29 | 30 | const QString m_originalPath; 31 | const QString m_destinationPath; 32 | bool m_stopCopy = false; 33 | public: 34 | Worker(const QString &src,const QString &dst); 35 | public slots: 36 | void process(); 37 | void stop(); 38 | signals: 39 | void finished(); 40 | void aborted(); 41 | void copied(qint64 bytes); 42 | void error(const QString &err); 43 | 44 | private: 45 | // add your variables here 46 | }; 47 | #endif // COPYFILECONVERSION_HPP 48 | -------------------------------------------------------------------------------- /depecher/src/fileGeneratedHandlers/FileGeneratedHandler.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILEGENERATEDHANDLER_HPP 2 | #define FILEGENERATEDHANDLER_HPP 3 | 4 | #include 5 | #include 6 | class FileGeneratedInterface; 7 | namespace tdlibQt { 8 | class TdlibJsonWrapper; 9 | } 10 | class FileGeneratedHandler : public QObject 11 | { 12 | Q_OBJECT 13 | 14 | QHash m_conversionMap; 15 | tdlibQt::TdlibJsonWrapper *m_tdlibJson; 16 | 17 | public: 18 | explicit FileGeneratedHandler(QObject *parent = nullptr); 19 | 20 | signals: 21 | 22 | private slots: 23 | void initGeneration(const QJsonObject &updateFileGenerationStartObject); 24 | void stopGeneration(const QJsonObject &updateFileGenerationStopObject); 25 | void updateGeneration(qint64 generation_id,int expected_size,int local_prefix_size); 26 | void finishGeneration(const qint64 generation_id,const int code, const QString &message); 27 | }; 28 | 29 | #endif // FILEGENERATEDHANDLER_HPP 30 | -------------------------------------------------------------------------------- /depecher/src/fileGeneratedHandlers/FileGeneratedInterface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILEGENERATEDINTERFACE_HPP 2 | #define FILEGENERATEDINTERFACE_HPP 3 | #include 4 | #include 5 | class FileGeneratedInterface : public QObject { 6 | Q_OBJECT 7 | protected: 8 | const qint64 m_generationId; 9 | const QString m_originalPath; 10 | const QString m_destinationPath; 11 | const QString m_conversion; 12 | public: 13 | FileGeneratedInterface(QObject *parent, const qint64 &generationId, 14 | const QString &originalPath, 15 | const QString &destinationPath, 16 | const QString &conversion): QObject(parent), 17 | m_generationId(generationId), 18 | m_originalPath(originalPath), 19 | m_destinationPath(destinationPath), 20 | m_conversion(conversion) { 21 | 22 | } 23 | 24 | 25 | signals: 26 | void generationProgressUpdated(const qint64 generation_id,const qint64 expected_size, const qint64 local_prefix_size); 27 | void generationStopped(const qint64 generation_id, const int code, const QString &message); 28 | void generationFinished(const qint64 generation_id); 29 | public slots: 30 | virtual void startGeneration() = 0; 31 | virtual void stopGeneration() = 0; 32 | virtual void finishGeneration() = 0; 33 | 34 | }; 35 | #endif // FILEGENERATEDINTERFACE_HPP 36 | -------------------------------------------------------------------------------- /depecher/src/fileGeneratedHandlers/FileLoaderFromHTTP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/src/fileGeneratedHandlers/FileLoaderFromHTTP -------------------------------------------------------------------------------- /depecher/src/fileGeneratedHandlers/PhotoCompressor: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/src/fileGeneratedHandlers/PhotoCompressor -------------------------------------------------------------------------------- /depecher/src/fileGeneratedHandlers/VideoCompressor: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/src/fileGeneratedHandlers/VideoCompressor -------------------------------------------------------------------------------- /depecher/src/fileGeneratedHandlers/copyFromOutsideCache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/src/fileGeneratedHandlers/copyFromOutsideCache -------------------------------------------------------------------------------- /depecher/src/fileGeneratedHandlers/inputFileGeneratedHandlerFactory: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/src/fileGeneratedHandlers/inputFileGeneratedHandlerFactory -------------------------------------------------------------------------------- /depecher/src/fileGeneratedHandlers/voiceToOgg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blacksailer/depecher/7bda0ad4b5600b8f7150036ae400e67debfd75db/depecher/src/fileGeneratedHandlers/voiceToOgg -------------------------------------------------------------------------------- /depecher/src/main.cpp: -------------------------------------------------------------------------------- 1 | #ifdef QT_QML_DEBUG 2 | #include 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "tdlibQt/TdlibJsonWrapper.hpp" 10 | #include "tdlibQt/NotificationManager.hpp" 11 | #include "tdlibQt/models/singletons/UsersModel.hpp" 12 | #include "DBusAdaptor.hpp" 13 | #include "dbus/DBusShareAdaptor.hpp" 14 | #include "dbus/ChatShareAdaptor.hpp" 15 | #include "src/fileGeneratedHandlers/FileGeneratedHandler.hpp" 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | QGuiApplication *app = SailfishApp::application(argc, argv); 20 | MGConfItem quitOnCloseUi("/apps/depecher/tdlib/quit_on_close_ui"); 21 | 22 | if (DBusAdaptor::isRegistered()) { 23 | if (DBusAdaptor::raiseApp()) { 24 | return 0; 25 | } else { 26 | return 1; 27 | } 28 | } 29 | 30 | QScopedPointer dbusWatcher(new DBusAdaptor(app)); 31 | QScopedPointer dbusShareWatcher(new DBusShareAdaptor(app)); 32 | QScopedPointer dbusChatShareWatcher(new ChatShareAdaptor(app)); 33 | app->addLibraryPath(QString("%1/../share/%2/lib").arg(qApp->applicationDirPath(), 34 | qApp->applicationName())); 35 | app->setApplicationVersion(APP_VERSION); 36 | 37 | 38 | QTranslator translator; 39 | 40 | QString locale = QLocale::system().name(); 41 | //locale="de"; // for testing purposes only 42 | if (!translator.load("depecher-" + locale, SailfishApp::pathTo("translations").toLocalFile())) { 43 | qDebug() << "Couldn't load translation for locale " + locale + " from " + 44 | SailfishApp::pathTo("translations").toLocalFile(); 45 | } 46 | app->installTranslator(&translator); 47 | 48 | 49 | //Need to create at first launch. Bad design maybe, should change 50 | auto tdlib = tdlibQt::TdlibJsonWrapper::instance(); 51 | auto NotificationManager = tdlibQt::NotificationManager::instance(); 52 | auto usersmodel = tdlibQt::UsersModel::instance(); 53 | tdlib->startListen(); 54 | //used in authenticationhandler too. 55 | // tdlib->setEncryptionKey(); 56 | FileGeneratedHandler generationHandler(app); 57 | 58 | if (quitOnCloseUi.value(false).toBool()) { 59 | app->setQuitOnLastWindowClosed(true); 60 | DBusAdaptor::raiseApp(); 61 | } else { 62 | app->setQuitOnLastWindowClosed(false); 63 | QObject::connect(app, &QGuiApplication::aboutToQuit, 64 | NotificationManager, &tdlibQt::NotificationManager::removeAll); 65 | } 66 | 67 | return app->exec(); 68 | } 69 | -------------------------------------------------------------------------------- /depecher/src/singletons/DNSTXTLookup.cpp: -------------------------------------------------------------------------------- 1 | #include "DNSTXTLookup.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | static const QString DNS_SERVER = QStringLiteral("sfosfc.toxip.net"); 9 | 10 | //Do not work in emulator 11 | DNSTXTLookup::DNSTXTLookup(QObject *parent) : QObject(parent), 12 | dns(new QDnsLookup(this)) 13 | { 14 | connect(dns, &QDnsLookup::finished, 15 | this, &DNSTXTLookup::handleLookup); 16 | 17 | dns->setType(QDnsLookup::TXT); 18 | dns->setName(DNS_SERVER); 19 | } 20 | 21 | DNSTXTLookup::~DNSTXTLookup() 22 | { 23 | dns->deleteLater(); 24 | } 25 | 26 | void DNSTXTLookup::lookupServer() 27 | { 28 | dns->lookup(); 29 | } 30 | 31 | void DNSTXTLookup::handleLookup() 32 | { 33 | 34 | // Handle the results. 35 | const auto records = dns->textRecords(); 36 | for (const QDnsTextRecord &record : records) { 37 | { 38 | setInviteLink(record.values().last()); 39 | } 40 | } 41 | // Check the lookup succeeded. 42 | if (dns->error() != QDnsLookup::NoError) { 43 | qWarning("DNS lookup failed"); 44 | qDebug() << dns->error() << dns->errorString(); 45 | return; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /depecher/src/singletons/DNSTXTLookup.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DNSTXTLOOKUP_HPP 2 | #define DNSTXTLOOKUP_HPP 3 | 4 | #include 5 | #include 6 | 7 | class QQmlEngine; 8 | class QJSEngine; 9 | class DNSTXTLookup : public QObject 10 | { 11 | Q_OBJECT 12 | 13 | Q_PROPERTY(QString inviteLink READ inviteLink WRITE setInviteLink NOTIFY inviteLinkChanged) 14 | 15 | QDnsLookup *dns; 16 | QString m_inviteLink; 17 | 18 | public: 19 | explicit DNSTXTLookup(QObject *parent = nullptr); 20 | ~DNSTXTLookup(); 21 | 22 | QString inviteLink() const 23 | { 24 | return m_inviteLink; 25 | } 26 | static QObject *qmlInstance(QQmlEngine *engine, QJSEngine *scriptEngine) 27 | { 28 | Q_UNUSED(engine); 29 | Q_UNUSED(scriptEngine); 30 | 31 | return new DNSTXTLookup; 32 | } 33 | public slots: 34 | void setInviteLink(const QString &inviteLink) 35 | { 36 | if (m_inviteLink == inviteLink) 37 | return; 38 | 39 | m_inviteLink = inviteLink; 40 | emit inviteLinkChanged(m_inviteLink); 41 | } 42 | void lookupServer(); 43 | signals: 44 | 45 | void inviteLinkChanged(const QString &inviteLink); 46 | 47 | private slots: 48 | void handleLookup(); 49 | }; 50 | 51 | #endif // DNSTXTLOOKUP_HPP 52 | -------------------------------------------------------------------------------- /depecher/src/singletons/PageAppStarter.cpp: -------------------------------------------------------------------------------- 1 | #include "PageAppStarter.hpp" 2 | 3 | PageAppStarter::PageAppStarter(QObject *parent) : QObject(parent) 4 | { 5 | 6 | } 7 | void PageAppStarter::addPage(QVariant chatId) 8 | { 9 | QVariantMap NewPage; 10 | NewPage["pageParam"] = QString::number(chatId.toLongLong()); 11 | m_pages.append(NewPage); 12 | } 13 | 14 | QVariantList PageAppStarter::getPages() 15 | { 16 | QVariantList result; 17 | while (m_pages.size() > 0) 18 | result.append(m_pages.dequeue()); 19 | 20 | return result; 21 | } 22 | -------------------------------------------------------------------------------- /depecher/src/singletons/PageAppStarter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PAGEAPPSTARTER_HPP 2 | #define PAGEAPPSTARTER_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | class PageAppStarter : public QObject 8 | { 9 | Q_OBJECT 10 | QQueue m_pages; 11 | 12 | public: 13 | explicit PageAppStarter(QObject *parent = nullptr); 14 | void addPage(QVariant chatId); 15 | signals: 16 | 17 | public slots: 18 | QVariantList getPages(); 19 | 20 | }; 21 | 22 | #endif // PAGEAPPSTARTER_HPP 23 | -------------------------------------------------------------------------------- /depecher/systemd/org.blacksailer.depecher.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=native application for Telegram based on tdlib 3 | Requires=lipstick.service dbus.service 4 | After=lipstick.service dbus.service 5 | 6 | [Service] 7 | Type=dbus 8 | BusName=org.blacksailer.depecher 9 | ExecStart=/usr/bin/depecher 10 | 11 | [Install] 12 | WantedBy=post-user-session.target 13 | -------------------------------------------------------------------------------- /icons/icons.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = aux 2 | # Configures svg to png 3 | THEMENAME=sailfish-default 4 | CONFIG += sailfish-svg2png 5 | -------------------------------------------------------------------------------- /rpm: -------------------------------------------------------------------------------- 1 | depecher/rpm -------------------------------------------------------------------------------- /sharechat/ChatShareModel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHATSHAREPROXYMODEL_HPP 2 | #define CHATSHAREPROXYMODEL_HPP 3 | 4 | #include 5 | #include "../tdlibjson_wrapper/tdlibQt/items/TdApi.hpp" 6 | class QDBusInterface; 7 | class QDBusPendingCallWatcher; 8 | class ChatShareModel : public QAbstractListModel 9 | { 10 | Q_OBJECT 11 | Q_PROPERTY(QVariant answer READ answer WRITE setAnswer NOTIFY answerChanged) 12 | 13 | QAbstractListModel *m_model; 14 | QDBusInterface *m_remoteAppIface; 15 | QList> m_chats; 16 | bool m_fetchPending = false; 17 | enum Roles { 18 | ID, 19 | TYPE, 20 | TITLE, 21 | DATE, 22 | PHOTO, 23 | MUTE_FOR, 24 | CHAT_ACTION, 25 | LAST_MESSAGE, 26 | LAST_MESSAGE_ID, 27 | LAST_MESSAGE_AUTHOR, 28 | LAST_MESSAGE_INBOX_ID, 29 | LAST_MESSAGE_OUTBOX_ID, 30 | ORDER, 31 | IS_PINNED, 32 | IS_SPONSORED, 33 | IS_MARKED_UNREAD, 34 | UNREAD_COUNT, 35 | UNREAD_MENTION_COUNT, 36 | NOTIFICATION_SETTINGS, 37 | REPLY_MARKUP_MESSAGE_ID, 38 | DRAFT_MESSAGE, 39 | CLIENT_DATA, 40 | SENDING_STATE 41 | }; 42 | 43 | public: 44 | ChatShareModel(QObject *parent = 0); 45 | ~ChatShareModel(); 46 | QVariant answer() const; 47 | public slots: 48 | void setAnswer(QVariant answer); 49 | void addItems(QDBusPendingCallWatcher *call); 50 | void reset(); 51 | signals: 52 | void answerChanged(QVariant answer); 53 | private: 54 | QVariant m_answer; 55 | QVariantMap parseDBusArgument(QMap value); 56 | // QAbstractItemModel interface 57 | QVariantList parseDBusArgumentArray(QVariantList srcArray); 58 | public: 59 | int rowCount(const QModelIndex &parent) const override; 60 | QVariant data(const QModelIndex &index, int role) const override; 61 | QHash roleNames() const override; 62 | void fetchMore(const QModelIndex &parent) override; 63 | bool canFetchMore(const QModelIndex &parent) const override; 64 | }; 65 | 66 | #endif // CHATSHAREPROXYMODEL_HPP 67 | -------------------------------------------------------------------------------- /sharechat/ShareChatPlugin.cpp: -------------------------------------------------------------------------------- 1 | #include "tdlibQt/include/TdlibNamespace.hpp" 2 | #include "ShareChatPlugin.hpp" 3 | #include "ChatShareModel.hpp" 4 | #include 5 | void ShareChatPlugin::registerTypes(const char *uri) 6 | { 7 | // @uri org.blacksailer.depecher.sharechat 8 | qmlRegisterUncreatableType(uri, 1, 0, "TdlibState", 9 | "Error class uncreatable"); 10 | qmlRegisterType(uri, 1, 0, "ShareChatModel"); 11 | } 12 | -------------------------------------------------------------------------------- /sharechat/ShareChatPlugin.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SHARECHATPLUGIN_HPP 2 | #define SHARECHATPLUGIN_HPP 3 | 4 | #include 5 | 6 | class ShareChatPlugin : public QQmlExtensionPlugin 7 | { 8 | Q_OBJECT 9 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") 10 | 11 | public: 12 | void registerTypes(const char *uri); 13 | 14 | }; 15 | 16 | #endif // SHARECHATPLUGIN_HPP 17 | -------------------------------------------------------------------------------- /sharechat/qmldir: -------------------------------------------------------------------------------- 1 | module .usr.share.depecher.qml.org.blacksailer.depecher.sharechat 2 | plugin sharechat 3 | -------------------------------------------------------------------------------- /sharechat/sharechat.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | QT += quick core dbus 3 | CONFIG += qt plugin link_pkgconfig 4 | 5 | PKGCONFIG += tdlibjson 6 | 7 | LIBS += -L$$OUT_PWD/../tdlibjson_wrapper -ltdlibjson_wrapper 8 | 9 | TARGET = $$qtLibraryTarget(sharechat) 10 | target.path = /usr/share/depecher/qml/org/blacksailer/depecher/sharechat 11 | 12 | qmldir.files = qmldir 13 | qmldir.path = /usr/share/depecher/qml/org/blacksailer/depecher/sharechat 14 | 15 | INSTALLS += target qmldir 16 | 17 | INCLUDEPATH = $$PWD/../tdlibjson_wrapper 18 | 19 | HEADERS += \ 20 | ShareChatPlugin.hpp \ 21 | ChatShareModel.hpp 22 | 23 | SOURCES += \ 24 | ShareChatPlugin.cpp \ 25 | ChatShareModel.cpp 26 | 27 | DISTFILES += \ 28 | qmldir 29 | -------------------------------------------------------------------------------- /shareui/DepecherMediaTransfer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DEPECHERMEDIATRANSFER_HPP 2 | #define DEPECHERMEDIATRANSFER_HPP 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #define SERVER_INTERFACE "org.blacksailer.depecher.share" 12 | #define SERVER_SERVICE "org.blacksailer.depecher" 13 | #define SERVER_PATH "/org/blacksailer/depecher/share" 14 | class DepecherMediaTransfer : public MediaTransferInterface 15 | { 16 | Q_OBJECT 17 | public: 18 | explicit DepecherMediaTransfer(QObject *parent = nullptr); 19 | bool cancelEnabled() const; 20 | QString displayName() const; 21 | bool restartEnabled() const; 22 | QUrl serviceIcon() const; 23 | 24 | private: 25 | QDBusInterface *_iface; 26 | QString _mediaName; 27 | QStringList m_generationIds; 28 | 29 | private slots: 30 | void uploadMediaProgress(const QString &jid, const QString &msgId, int percent); 31 | void uploadMediaFinished(const QString &jid, const QString &msgId, const QString &remoteUrl); 32 | void uploadMediaStarted(const QString &jid, const QString &msgId, const QString &localUrl); 33 | void uploadMediaFailed(const QString &jid, const QString &msgId); 34 | 35 | public slots: 36 | void cancel(); 37 | void start(); 38 | 39 | }; 40 | 41 | #endif // DEPECHERMEDIATRANSFER_HPP 42 | -------------------------------------------------------------------------------- /shareui/DepecherPluginInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "DepecherPluginInfo.hpp" 2 | 3 | DepecherPluginInfo::DepecherPluginInfo() : m_ready(false) 4 | { 5 | 6 | } 7 | 8 | QList DepecherPluginInfo::info() const 9 | { 10 | return m_infoList; 11 | } 12 | 13 | void DepecherPluginInfo::query() 14 | { 15 | TransferMethodInfo info; 16 | 17 | QStringList capabilities; 18 | capabilities << QLatin1String("application/*") 19 | << QLatin1String("image/*") 20 | << QLatin1String("audio/*") 21 | << QLatin1String("video/*") 22 | << QLatin1String("text/plain") 23 | << QLatin1String("text/x-url") 24 | << QLatin1String("text/vcard"); 25 | 26 | info.displayName = QLatin1String("Depecher"); 27 | info.methodId = QLatin1String("DepecherSharePlugin"); 28 | info.accountIcon = QLatin1String("image://theme/icon-m-depecher"); 29 | info.shareUIPath = QLatin1String("/usr/share/depecher/qml/ShareUI.qml"); 30 | info.capabilitities = capabilities; 31 | m_infoList.clear(); 32 | m_infoList << info; 33 | 34 | m_ready = true; 35 | Q_EMIT infoReady(); 36 | } 37 | 38 | bool DepecherPluginInfo::ready() const 39 | { 40 | return m_ready; 41 | } 42 | -------------------------------------------------------------------------------- /shareui/DepecherPluginInfo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DEPECHERPLUGININFO_HPP 2 | #define DEPECHERPLUGININFO_HPP 3 | #include 4 | #include 5 | 6 | class DepecherPluginInfo: public TransferPluginInfo 7 | { 8 | Q_OBJECT 9 | public: 10 | DepecherPluginInfo(); 11 | QList info() const; 12 | void query(); 13 | bool ready() const; 14 | 15 | private: 16 | QList m_infoList; 17 | bool m_ready; 18 | 19 | }; 20 | 21 | #endif // DEPECHERPLUGININFO_HPP 22 | -------------------------------------------------------------------------------- /shareui/DepecherTransferIface.cpp: -------------------------------------------------------------------------------- 1 | #include "DepecherTransferIface.hpp" 2 | #include "DepecherPluginInfo.hpp" 3 | #include "DepecherMediaTransfer.hpp" 4 | DepecherTransferIface::DepecherTransferIface() 5 | { 6 | 7 | } 8 | 9 | QString DepecherTransferIface::pluginId() const 10 | { 11 | return QLatin1String("DepecherSharePlugin"); 12 | } 13 | bool DepecherTransferIface::enabled() const 14 | { 15 | return true; 16 | } 17 | 18 | TransferPluginInfo *DepecherTransferIface::infoObject() 19 | { 20 | return new DepecherPluginInfo; 21 | } 22 | 23 | MediaTransferInterface *DepecherTransferIface::transferObject() 24 | { 25 | return new DepecherMediaTransfer; 26 | } 27 | -------------------------------------------------------------------------------- /shareui/DepecherTransferIface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DEPECHERTRANSFERIFACE_HPP 2 | #define DEPECHERTRANSFERIFACE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | class DepecherTransferIface : public QObject, public TransferPluginInterface 11 | { 12 | Q_OBJECT 13 | Q_PLUGIN_METADATA(IID "org.blacksailer.depecher.transfer.plugin") 14 | Q_INTERFACES(TransferPluginInterface) 15 | public: 16 | DepecherTransferIface(); 17 | QString pluginId() const; 18 | bool enabled() const; 19 | TransferPluginInfo *infoObject(); 20 | MediaTransferInterface *transferObject(); 21 | }; 22 | 23 | #endif // DEPECHERTRANSFERIFACE_HPP 24 | -------------------------------------------------------------------------------- /shareui/shareui.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | 3 | TARGET = $$qtLibraryTarget(depechershareplugin) 4 | target.path = /usr/lib/nemo-transferengine/plugins 5 | 6 | QT += dbus 7 | CONFIG += plugin link_pkgconfig 8 | PKGCONFIG += nemotransferengine-qt5 9 | 10 | INSTALLS += target 11 | 12 | HEADERS += \ 13 | DepecherPluginInfo.hpp \ 14 | DepecherMediaTransfer.hpp \ 15 | DepecherTransferIface.hpp 16 | 17 | SOURCES += \ 18 | DepecherPluginInfo.cpp \ 19 | DepecherMediaTransfer.cpp \ 20 | DepecherTransferIface.cpp 21 | 22 | DISTFILES += 23 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | tdlibQt/include/AppApiInfo.hpp 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/api_secret.pri.example: -------------------------------------------------------------------------------- 1 | APPID = 31231231 #To build you have to create file with app_id, or replace with your app_id 2 | APP_HASH = asdaslkjsv2312edkl123 #To build you have to create file app_hash, or replace with your app_hash 3 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/FileWriter.cpp: -------------------------------------------------------------------------------- 1 | #include "FileWriter.hpp" 2 | #include 3 | #include 4 | #include 5 | FileWriter::FileWriter(QObject *parent) : QObject(parent) 6 | { 7 | 8 | } 9 | 10 | void FileWriter::writeJson(const QJsonDocument &doc) 11 | { 12 | QString typeJson = doc.object()["@type"].toString(); 13 | QDir parentDataDir; 14 | parentDataDir.mkpath(dirPath); 15 | parentDataDir.setPath(dirPath); 16 | parentDataDir.mkdir(typeJson); 17 | if (!typeCounter.contains(typeJson)) 18 | typeCounter[typeJson] = 0; 19 | int fileCount = typeCounter[typeJson]; 20 | QFile jsonFile(parentDataDir.absolutePath() + "/" 21 | + typeJson + "/" 22 | + QString::number(fileCount) 23 | + ".json"); 24 | 25 | if (jsonFile.open(QFile::WriteOnly)) { 26 | jsonFile.write(doc.toJson()); 27 | typeCounter[typeJson] = fileCount + 1; 28 | jsonFile.close(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/FileWriter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILEWRITER_HPP 2 | #define FILEWRITER_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | class FileWriter : public QObject 9 | { 10 | Q_OBJECT 11 | QString dirPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) 12 | + "/depecherJson"; 13 | QMap typeCounter; 14 | public: 15 | explicit FileWriter(QObject *parent = 0); 16 | void writeJson(const QJsonDocument &doc); 17 | signals: 18 | 19 | public slots: 20 | }; 21 | 22 | #endif // FILEWRITER_HPP 23 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/ListenObject.cpp: -------------------------------------------------------------------------------- 1 | #include "ListenObject.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | namespace tdlibQt { 7 | ListenObject::ListenObject(void *client_, QWaitCondition *condition, 8 | QObject *parent) : QObject(parent), 9 | client(client_), 10 | onActive(condition) 11 | { 12 | timer = new QTimer(this); 13 | timer->setInterval(30 * 1000); 14 | qRegisterMetaType("Qt::ApplicationState"); 15 | connect(qApp, &QGuiApplication::applicationStateChanged, 16 | this, &ListenObject::onApplicationStateChanged); 17 | connect(timer, &QTimer::timeout, this, &ListenObject::setIsActiveTrue); 18 | } 19 | 20 | void ListenObject::onApplicationStateChanged(Qt::ApplicationState state) 21 | { 22 | switch (state) { 23 | case Qt::ApplicationActive: 24 | timer->stop(); 25 | setIsActiveTrue(); 26 | break; 27 | default: 28 | break; 29 | } 30 | } 31 | 32 | void ListenObject::setIsActiveTrue() 33 | { 34 | isActive = true; 35 | } 36 | 37 | void ListenObject::listen() 38 | { 39 | forever { 40 | // mutex.lock(); 41 | // onActive->wait(&mutex); 42 | if (isActive) { 43 | try { 44 | //Throws std::logic_error for some reason. 45 | std::string str = td_json_client_receive(client, 10); 46 | 47 | if (!str.empty()) { 48 | QByteArray result = QByteArray::fromStdString(str); 49 | emit resultReady(result); 50 | } 51 | } catch (std::logic_error err) { 52 | #ifdef QT_DEBUG 53 | qDebug() << "Logic error caught"; 54 | #endif 55 | if (qApp->applicationState() != Qt::ApplicationActive) { 56 | setIsActiveTrue(); 57 | timer->start(); 58 | } 59 | } 60 | } 61 | // mutex.unlock(); 62 | } 63 | } 64 | }//namespace tdlibQt 65 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/ListenObject.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LISTENOBJECT_HPP 2 | #define LISTENOBJECT_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | class QWaitCondition; 9 | 10 | namespace tdlibQt { 11 | 12 | 13 | class ListenObject : public QObject 14 | { 15 | Q_OBJECT 16 | void *client; 17 | QWaitCondition *onActive; 18 | QMutex mutex; 19 | QTimer *timer; 20 | bool isActive = true; 21 | 22 | public: 23 | explicit ListenObject(void *client_ = nullptr, QWaitCondition *condition = nullptr, 24 | QObject *parent = 0); 25 | 26 | signals: 27 | void resultReady(const QByteArray &s); 28 | 29 | private slots: 30 | void onApplicationStateChanged(Qt::ApplicationState state); 31 | void setIsActiveTrue(); 32 | public slots: 33 | void listen(); 34 | 35 | }; 36 | }//namespace tdlibQt 37 | #endif // LISTENOBJECT_HPP 38 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/ListenScheduler.cpp: -------------------------------------------------------------------------------- 1 | #include "ListenScheduler.hpp" 2 | #include 3 | #include 4 | namespace tdlibQt { 5 | void ListenScheduler::beginForever() 6 | { 7 | forever { 8 | if (appIsActive) 9 | wakeUpListener(); 10 | } 11 | } 12 | 13 | ListenScheduler::ListenScheduler(QObject *parent) : QObject(parent) 14 | { 15 | connect(qApp, &QGuiApplication::applicationStateChanged, 16 | this, &ListenScheduler::onApplicationStateChanged); 17 | 18 | timer.setInterval(TIMEOUT_INTERVAL); 19 | connect(&timer, &QTimer::timeout, this, &ListenScheduler::wakeUpListener); 20 | } 21 | 22 | QWaitCondition *ListenScheduler::getCondition() 23 | { 24 | return &stateAndTimeCondition; 25 | } 26 | 27 | void ListenScheduler::wakeUpListener() 28 | { 29 | stateAndTimeCondition.wakeOne(); 30 | } 31 | 32 | void ListenScheduler::onApplicationStateChanged(Qt::ApplicationState state) 33 | { 34 | beginForever(); 35 | switch (state) { 36 | case Qt::ApplicationActive: 37 | appIsActive = true; 38 | if (timer.isActive()) 39 | timer.stop(); 40 | break; 41 | default: 42 | appIsActive = false; 43 | if (!timer.isActive()) { 44 | qDebug() << "sleeping for 30 seconds"; 45 | timer.start(); 46 | } 47 | break; 48 | } 49 | } 50 | 51 | } //namespace tdlibQt 52 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/ListenScheduler.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LISTENSCHEDULER_HPP 2 | #define LISTENSCHEDULER_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | namespace tdlibQt { 8 | class ListenScheduler : public QObject 9 | { 10 | Q_OBJECT 11 | QWaitCondition stateAndTimeCondition; 12 | QTimer timer; 13 | const int TIMEOUT_INTERVAL = 30 * 1000; 14 | bool appIsActive = false; 15 | public: 16 | explicit ListenScheduler(QObject *parent = 0); 17 | QWaitCondition *getCondition(); 18 | signals: 19 | 20 | private slots: 21 | void wakeUpListener(); 22 | public slots: 23 | void onApplicationStateChanged(Qt::ApplicationState state); 24 | void beginForever(); 25 | 26 | }; 27 | 28 | } //namespace tdlibQt 29 | 30 | #endif // LISTENSCHEDULER_HPP 31 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/NotificationManager.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NOTIFICATIONMANAGER_HPP 2 | #define NOTIFICATIONMANAGER_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "../tdlibjson_wrapper/tdlibQt/include/TdlibNamespace.hpp" 9 | #include 10 | namespace tdlibQt { 11 | class TdlibJsonWrapper; 12 | class notificationGroup; 13 | class NotificationManager : public QObject 14 | { 15 | Q_OBJECT 16 | 17 | TdlibJsonWrapper *m_client; 18 | static const int m_expireTimeout = 60 * 60 * 1000; 19 | QMap> m_chatIdsToPublish; 20 | QMap> m_chatIdsPublished; 21 | bool isAtFirstLoaded = true; 22 | Enums::ConnectionState m_connectionState = Enums::ConnectionState::ConnectionStateConnecting; 23 | QTimer m_PublishTimer; 24 | 25 | 26 | 27 | explicit NotificationManager(QObject *parent = 0); 28 | void processNotificationGroup(QSharedPointer &group); 29 | public: 30 | qint64 currentViewableChatId = 0; //Setted by MessageModel 31 | static NotificationManager *instance(); 32 | NotificationManager(NotificationManager const &) = delete; 33 | void operator=(NotificationManager const &) = delete; 34 | void removeNotification(qint64 chatId); 35 | 36 | signals: 37 | 38 | private slots: 39 | void getUpdateChatOutbox(const QJsonObject &chatReadOutbox); 40 | void gotNewMessage(const QJsonObject &updateNewMessage); 41 | void gotNotificationGroup(const QJsonObject &updateNotificationGroupObject); 42 | void gotActiveNotification(const QJsonObject &updateActiveNotificationObject); 43 | void publishNotifications(); 44 | 45 | public slots: 46 | void notifySummary(const qint64 timestamp, const QString &summary, const QString &body, 47 | const qint64 chatId, const qint64 unreadCount = 0); 48 | void notifyPreview(const qint64 timestamp, const QString &summary, const QString &body, 49 | const qint64 chatId, const qint64 unreadCount = 0); 50 | void onViewMessages(const qint64 peerId); 51 | void removeAll(); 52 | 53 | }; 54 | }// tdlibQt 55 | 56 | #endif // NOTIFICATIONMANAGER_HPP 57 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/TelegramProfileProvider.cpp: -------------------------------------------------------------------------------- 1 | #include "TelegramProfileProvider.hpp" 2 | #include 3 | #include 4 | namespace tdlibQt { 5 | TelegramProfileProvider::TelegramProfileProvider() : QQuickImageProvider( 6 | QQuickImageProvider::Image) 7 | { 8 | 9 | } 10 | 11 | QImage TelegramProfileProvider::requestImage(const QString &id, QSize *size, 12 | const QSize &requestedSize) 13 | { 14 | QString rsrcid = id; 15 | //https://github.com/tdlib/td/issues/264 16 | if (rsrcid.right(9) == ".jpg.webp") { 17 | QImageReader imgReader(rsrcid.left(rsrcid.length() - 1 - 4), "webp"); 18 | QImage result = imgReader.read(); 19 | if (imgReader.error() == QImageReader::InvalidDataError || imgReader.error() == QImageReader::DeviceError) { 20 | imgReader.setFormat("jpg"); 21 | result = imgReader.read(); 22 | } 23 | *size = result.size(); 24 | return result; 25 | } else { 26 | QImageReader imgReader(rsrcid); 27 | QImage result = imgReader.read(); 28 | 29 | // if (requestedSize.isValid()) { 30 | // result = image.scaled(requestedSize, Qt::KeepAspectRatio); 31 | // } else { 32 | // result = image; 33 | // } 34 | *size = result.size(); 35 | return result; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/TelegramProfileProvider.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TELEGRAMPROFILEPROVIDER_HPP 2 | #define TELEGRAMPROFILEPROVIDER_HPP 3 | 4 | #include 5 | namespace tdlibQt { 6 | class TelegramProfileProvider : public QQuickImageProvider 7 | { 8 | public: 9 | explicit TelegramProfileProvider(); 10 | // QQuickImageProvider interface 11 | QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize); 12 | }; 13 | } 14 | 15 | #endif // TELEGRAMPROFILEPROVIDER_HPP 16 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/include/AppApiInfo.hpp.in: -------------------------------------------------------------------------------- 1 | #ifndef APPAPIINFO_HPP 2 | #define APPAPIINFO_HPP 3 | #include 4 | 5 | namespace tdlibQt { 6 | static const QString appid = QStringLiteral(\"$$APPID\"); 7 | static const QString apphash = QStringLiteral(\"$$APP_HASH\"); 8 | } //namespace tdlibQt 9 | #endif // APPAPIINFO_HPP 10 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/include/AuthenticationHandler.hpp: -------------------------------------------------------------------------------- 1 | #ifndef AUTHENTICATIONHANDLER_HPP 2 | #define AUTHENTICATIONHANDLER_HPP 3 | 4 | #include 5 | #include 6 | #include "../items/TdApi.hpp" 7 | #include "../include/TdlibNamespace.hpp" 8 | namespace tdlibQt { 9 | 10 | class TdlibJsonWrapper; 11 | class AuthenticationHandler : public QObject 12 | { 13 | Q_OBJECT 14 | QSharedPointer m_authorizationState; 15 | Q_PROPERTY(tdlibQt::Enums::AuthorizationState currentAuthorizationState READ authorizationState 16 | WRITE 17 | setCurrentAuthorizationState 18 | NOTIFY authorizationStateChanged) 19 | Q_PROPERTY(QString getType READ getType NOTIFY getTypeChanged) 20 | Q_PROPERTY(QString getHint READ getHint NOTIFY getHintChanged) 21 | Q_PROPERTY(QString emailPattern READ emailPattern NOTIFY emailPatternChanged) 22 | Q_PROPERTY(bool hasRecoveryEmail READ hasRecoveryEmail NOTIFY hasRecoveryEmailChanged) 23 | Q_PROPERTY(bool isUserRegistered READ getIsUserRegistered NOTIFY isUserRegisteredChanged) 24 | Q_PROPERTY(QVariantMap error READ error NOTIFY errorChanged) 25 | Q_PROPERTY(QVariantMap ok READ ok NOTIFY okChanged) 26 | 27 | tdlibQt::Enums::AuthorizationState m_currentAuthorizationState; 28 | TdlibJsonWrapper *m_client; 29 | 30 | bool isUserRegistered() const; 31 | QString getCurrentCodeType() const; 32 | 33 | 34 | QVariantMap m_error; 35 | 36 | QVariantMap m_ok; 37 | 38 | public: 39 | explicit AuthenticationHandler(QObject *parent = nullptr); 40 | tdlibQt::Enums::AuthorizationState authorizationState() const; 41 | 42 | QString getType() const; 43 | 44 | bool getIsUserRegistered() const; 45 | 46 | QString getHint() const; 47 | 48 | QString emailPattern() const; 49 | 50 | bool hasRecoveryEmail() const; 51 | 52 | QVariantMap error() const 53 | { 54 | return m_error; 55 | } 56 | 57 | QVariantMap ok() const 58 | { 59 | return m_ok; 60 | } 61 | 62 | public slots: 63 | 64 | void setCurrentAuthorizationState(tdlibQt::Enums::AuthorizationState currentAuthorizationState); 65 | void recoverPassword(); 66 | void sendRecoveryCode(const QString &code); 67 | void setEncryptionKey(const QString &passwd = "abcd"); 68 | void checkPassword(const QString &password); 69 | signals: 70 | void authorizationStateChanged(tdlibQt::Enums::AuthorizationState currentAuthorizationState); 71 | 72 | void getTypeChanged(QString getType); 73 | 74 | void isUserRegisteredChanged(bool isUserRegistered); 75 | 76 | void getHintChanged(QString getHint); 77 | 78 | void emailPatternChanged(QString emailPattern); 79 | 80 | void hasRecoveryEmailChanged(bool hasRecoveryEmail); 81 | 82 | void errorChanged(QVariantMap error); 83 | 84 | void okChanged(QVariantMap ok); 85 | 86 | private slots: 87 | void setAuthorizationState(const QSharedPointer &authorizationState); 88 | void setError(const QJsonObject &errorObject); 89 | void setOk(const QJsonObject &okObject); 90 | }; 91 | } //namespace tdlibQt 92 | #endif // AUTHENTICATIONHANDLER_HPP 93 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/include/FileGeneratedInterface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILEGENERATEDINTERFACE_HPP 2 | #define FILEGENERATEDINTERFACE_HPP 3 | #include 4 | #include 5 | namespace tdlibQt { 6 | 7 | class FileGeneratedInterface: public QObject { 8 | Q_OBJECT 9 | 10 | qint64 m_generationId; 11 | QString m_originalPath; 12 | QString m_destinationPath; 13 | QString m_conversion; 14 | signals: 15 | void generationProgressUpdated(qint64 generation_id,int expected_size,int local_prefix_size); 16 | void generationStopped(); 17 | void generationFinished(); 18 | private slots: 19 | virtual void startGeneration(const QJsonObject &updateFileGenerationStartObject); 20 | virtual void updateGenerationProgress(); 21 | virtual void stopGeneration(); 22 | virtual void finishGeneration(); 23 | 24 | }; 25 | } //namespace tdlibQt 26 | #endif // FILEGENERATEDINTERFACE_HPP 27 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/include/TdlibNamespace.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TDLIBNAMESPACE_HPP 2 | #define TDLIBNAMESPACE_HPP 3 | #include 4 | namespace tdlibQt { 5 | 6 | class Enums: public QObject 7 | { 8 | public: 9 | enum class AuthorizationState { 10 | AuthorizationStateWaitTdlibParameters, 11 | AuthorizationStateWaitEncryptionKey, 12 | AuthorizationStateWaitPhoneNumber, 13 | AuthorizationStateWaitCode, 14 | AuthorizationStateWaitPassword, 15 | AuthorizationStateLoggingOut, 16 | AuthorizationStateClosing, 17 | AuthorizationStateClosed, 18 | AuthorizationStateReady 19 | }; 20 | enum class ConnectionState { 21 | ConnectionStateWaitingForNetwork, 22 | ConnectionStateConnecting, 23 | ConnectionStateConnectingToProxy, 24 | ConnectionStateUpdating, 25 | ConnectionStateReady 26 | }; 27 | enum class ChatType { 28 | BasicGroup, 29 | Private, 30 | Secret, 31 | Supergroup, 32 | Channel 33 | }; 34 | 35 | enum class FileType { 36 | Photo, 37 | Video, 38 | Document, 39 | Animation, 40 | Sticker 41 | }; 42 | enum class MessageState { 43 | Sending_Failed, 44 | Sending_Pending, 45 | Sending_Not_Read, 46 | Sending_Read 47 | }; 48 | enum SearchFilter { 49 | Empty = 5, 50 | Animation, 51 | Audio, 52 | Document, 53 | Photo, 54 | Video, 55 | VoiceNote, 56 | PhotoAndVideo, 57 | Url, 58 | ChatPhoto, 59 | Call, 60 | MissedCall, 61 | VideoNote, 62 | VoiceAndVideoNote, 63 | UnreadMention, 64 | Mention 65 | }; 66 | Q_ENUM(SearchFilter) 67 | Q_ENUM(MessageState) 68 | Q_ENUM(FileType) 69 | Q_ENUM(AuthorizationState) 70 | Q_ENUM(ConnectionState) 71 | Q_ENUM(ChatType) 72 | 73 | Q_OBJECT 74 | 75 | }; 76 | } 77 | Q_DECLARE_METATYPE(tdlibQt::Enums::AuthorizationState) 78 | Q_DECLARE_METATYPE(tdlibQt::Enums::ConnectionState) 79 | Q_DECLARE_METATYPE(tdlibQt::Enums::ChatType) 80 | Q_DECLARE_METATYPE(tdlibQt::Enums::MessageState) 81 | Q_DECLARE_METATYPE(tdlibQt::Enums::SearchFilter) 82 | 83 | Q_DECLARE_METATYPE(Qt::ApplicationState) 84 | 85 | #endif // TDLIBNAMESPACE_HPP 86 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/infoProviders/BasicGroupInfoProvider.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BASICGROUPINFOPROVIDER_HPP 2 | #define BASICGROUPINFOPROVIDER_HPP 3 | 4 | #include 5 | #include "InfoProvider.hpp" 6 | #include 7 | #include "tdlibQt/items/TdApi.hpp" 8 | 9 | namespace tdlibQt { 10 | class ChatMembersModel; 11 | class BasicGroupInfoProvider : public InfoProvider 12 | { 13 | Q_OBJECT 14 | Q_PROPERTY(int groupId READ groupId WRITE setGroupId NOTIFY groupIdChanged) 15 | Q_PROPERTY(QString inviteLink READ inviteLink NOTIFY inviteLinkChanged) 16 | Q_PROPERTY(QString name READ name NOTIFY nameChanged) 17 | Q_PROPERTY(int members READ members NOTIFY membersChanged) 18 | Q_PROPERTY(ChatMembersModel *membersModel READ membersModel NOTIFY membersModelChanged) 19 | QSharedPointer m_group; 20 | QSharedPointer m_info; 21 | 22 | void emitInfo(); 23 | void emitGroup(); 24 | void emitAll(); 25 | 26 | int m_groupId = 0; 27 | 28 | 29 | ChatMembersModel *m_membersModel = nullptr; 30 | 31 | public: 32 | explicit BasicGroupInfoProvider(QObject *parent = nullptr); 33 | 34 | int groupId() const 35 | { 36 | return m_groupId; 37 | } 38 | 39 | QString inviteLink() const; 40 | 41 | QString name() const; 42 | 43 | int members() const; 44 | 45 | ChatMembersModel *membersModel() const; 46 | 47 | public slots: 48 | void setGroupId(int groupId); 49 | 50 | signals: 51 | 52 | void groupIdChanged(int groupId); 53 | 54 | void inviteLinkChanged(); 55 | 56 | void nameChanged(); 57 | 58 | void membersChanged(); 59 | void membersModelChanged(); 60 | private slots: 61 | void basicGroupFullInfoReceived(const QJsonObject &obj); 62 | void updateBasicGroupReceived(const QJsonObject &obj); 63 | void basicGroupReceived(const QJsonObject &obj); 64 | 65 | void onChatIdChanged(const qint64 &chatId); 66 | 67 | }; 68 | }//namespace tdlibQt 69 | 70 | #endif // BASICGROUPINFOPROVIDER_HPP 71 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/infoProviders/UserInfoProvider.hpp: -------------------------------------------------------------------------------- 1 | #ifndef USERINFOPROVIDER_HPP 2 | #define USERINFOPROVIDER_HPP 3 | 4 | #include 5 | #include 6 | #include "InfoProvider.hpp" 7 | #include "tdlibQt/items/TdApi.hpp" 8 | namespace tdlibQt { 9 | class TdlibJsonWrapper; 10 | class UserInfoProvider : public InfoProvider 11 | { 12 | Q_OBJECT 13 | Q_PROPERTY(int userId READ userId WRITE setUserId NOTIFY userIdChanged) 14 | Q_PROPERTY(QString firstName READ firstName NOTIFY firstNameChanged) 15 | Q_PROPERTY(QString lastName READ lastName NOTIFY lastNameChanged) 16 | Q_PROPERTY(QString status READ status NOTIFY statusChanged) 17 | Q_PROPERTY(QString username READ username NOTIFY usernameChanged) 18 | Q_PROPERTY(QString bio READ bio NOTIFY bioChanged) 19 | Q_PROPERTY(QString phoneNumber READ phoneNumber NOTIFY phoneNumberChanged) 20 | Q_PROPERTY(linkState incomingLink READ incomingLink NOTIFY incomingLinkChanged) 21 | Q_PROPERTY(linkState outgoingLink READ outgoingLink NOTIFY outcomingLinkChanged) 22 | Q_PROPERTY(int groupCount READ groupCount WRITE setGroupCount NOTIFY groupCountChanged) 23 | 24 | public: 25 | enum class linkState { 26 | NONE, 27 | KNOWS_PHONE_NUMBER, 28 | IS_CONTACT 29 | }; 30 | Q_ENUM(linkState) 31 | private: 32 | 33 | QSharedPointer m_userInfo; 34 | QSharedPointer m_userFullInfo; 35 | int m_userId = 0; 36 | 37 | linkState m_incomingLink; 38 | 39 | linkState m_outcomingLink; 40 | 41 | void emitAll(); 42 | 43 | int m_groupCount = 0; 44 | 45 | QString m_bio; 46 | 47 | public: 48 | explicit UserInfoProvider(QObject *parent = nullptr); 49 | int userId() const; 50 | 51 | QString firstName() const; 52 | 53 | QString lastName() const; 54 | 55 | QString avatar() const override; 56 | 57 | QString username() const; 58 | 59 | QString bio() const 60 | { 61 | return m_bio; 62 | } 63 | 64 | QString status() const; 65 | 66 | linkState incomingLink() const; 67 | 68 | linkState outgoingLink() const; 69 | 70 | 71 | QString phoneNumber() const; 72 | 73 | int groupCount() const 74 | { 75 | return m_groupCount; 76 | } 77 | 78 | signals: 79 | void userIdChanged(int userId); 80 | 81 | void firstNameChanged(); 82 | 83 | void lastNameChanged(); 84 | 85 | 86 | void statusChanged(); 87 | 88 | void incomingLinkChanged(); 89 | 90 | void outcomingLinkChanged(); 91 | 92 | void phoneNumberChanged(); 93 | 94 | void usernameChanged(); 95 | 96 | void bioChanged(); 97 | 98 | void groupCountChanged(int groupCount); 99 | void chatIdReceived(const QString &chatId); 100 | private slots: 101 | void updateUserReceived(const QJsonObject &userObject); 102 | void userFullInfoReceived(const QJsonObject &userFullInfoObject); 103 | void errorReceived(const QJsonObject &errorObject); 104 | void setGroupCount(int groupCount); 105 | void setBio(const QString &bio); 106 | void processFile(const QJsonObject &fileObject); 107 | void onChatReceived(const QJsonObject &userObject); 108 | public slots: 109 | void setUserId(int userId); 110 | QString getChatId(); 111 | }; 112 | } // namespace tdlibQt 113 | Q_DECLARE_METATYPE(tdlibQt::UserInfoProvider::linkState) 114 | #endif // USERINFOPROVIDER_HPP 115 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/infoProviders/UsernameResolver.cpp: -------------------------------------------------------------------------------- 1 | #include "UsernameResolver.hpp" 2 | #include "tdlibQt/TdlibJsonWrapper.hpp" 3 | #include "tdlibQt/ParseObject.hpp" 4 | namespace tdlibQt { 5 | static const QString c_extra = QLatin1String("UsernameResolver"); 6 | 7 | UsernameResolver::UsernameResolver(QObject *parent) : QObject(parent) 8 | { 9 | m_tdlibJson = TdlibJsonWrapper::instance(); 10 | connect(m_tdlibJson, &TdlibJsonWrapper::chatReceived, 11 | this, &UsernameResolver::chatReceived); 12 | connect(m_tdlibJson, &TdlibJsonWrapper::errorReceived, 13 | this, &UsernameResolver::errorReceived); 14 | } 15 | 16 | void UsernameResolver::setResolvedId(double resolvedId) 17 | { 18 | qWarning("Floating point comparison needs context sanity check"); 19 | if (qFuzzyCompare(m_resolvedId, resolvedId)) 20 | return; 21 | 22 | m_resolvedId = resolvedId; 23 | emit resolvedIdChanged(m_resolvedId); 24 | } 25 | 26 | void UsernameResolver::setResolvedChatId(double resolvedChatId) 27 | { 28 | qWarning("Floating point comparison needs context sanity check"); 29 | if (qFuzzyCompare(m_resolvedChatId, resolvedChatId)) 30 | return; 31 | 32 | m_resolvedChatId = resolvedChatId; 33 | emit resolvedChatIdChanged(m_resolvedChatId); 34 | } 35 | 36 | void UsernameResolver::setUsername(QString username) 37 | { 38 | if (m_username == username) 39 | return; 40 | 41 | m_username = username; 42 | m_tdlibJson->searchPublicChat(m_username, c_extra); 43 | emit usernameChanged(m_username); 44 | } 45 | void UsernameResolver::chatReceived(const QJsonObject &chatObject) 46 | { 47 | if (chatObject["@extra"].toString() == c_extra) { 48 | auto chat = ParseObject::parseChat(chatObject); 49 | setResolvedChatId(chat->id_); 50 | switch (chat->type_->get_id()) { 51 | case chatTypePrivate::ID: 52 | setResolvedId(static_cast(chat->type_.data())->user_id_); 53 | setChatType(tdlibQt::Enums::ChatType::Private); 54 | break; 55 | case chatTypeBasicGroup::ID: 56 | setResolvedId(static_cast(chat->type_.data())->basic_group_id_); 57 | setChatType(tdlibQt::Enums::ChatType::BasicGroup); 58 | break; 59 | case chatTypeSupergroup::ID: 60 | setResolvedId(static_cast(chat->type_.data())->supergroup_id_); 61 | if (static_cast(chat->type_.data())->is_channel_) 62 | setChatType(tdlibQt::Enums::ChatType::Channel); 63 | else 64 | setChatType(tdlibQt::Enums::ChatType::Supergroup); 65 | break; 66 | case chatTypeSecret::ID: 67 | setResolvedId(static_cast(chat->type_.data())->secret_chat_id_); 68 | setChatType(tdlibQt::Enums::ChatType::Secret); 69 | default: 70 | break; 71 | } 72 | } 73 | } 74 | void UsernameResolver::errorReceived(const QJsonObject &errorObject) 75 | { 76 | if (errorObject["@extra"].toString() == c_extra) { 77 | if (errorObject["code"].toInt() == 400) 78 | setError(tr("Username %1 not found").arg(username())); 79 | else 80 | setError(errorObject["message"].toString()); 81 | } 82 | } 83 | } // namespace tdlibQt 84 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/infoProviders/UsernameResolver.hpp: -------------------------------------------------------------------------------- 1 | #ifndef USERNAMERESOLVER_HPP 2 | #define USERNAMERESOLVER_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | namespace tdlibQt { 8 | class TdlibJsonWrapper; 9 | class UsernameResolver : public QObject 10 | { 11 | Q_OBJECT 12 | Q_PROPERTY(QString error READ error WRITE setError NOTIFY errorChanged) 13 | Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged) 14 | Q_PROPERTY(double resolvedId READ resolvedId WRITE setResolvedId NOTIFY resolvedIdChanged) 15 | Q_PROPERTY(double resolvedChatId READ resolvedChatId WRITE setResolvedChatId NOTIFY resolvedChatIdChanged) 16 | Q_PROPERTY(tdlibQt::Enums::ChatType chatType READ chatType WRITE setChatType NOTIFY chatTypeChanged) 17 | tdlibQt::Enums::ChatType m_chatType; 18 | 19 | TdlibJsonWrapper *m_tdlibJson; 20 | QString m_username = ""; 21 | 22 | double m_resolvedId = 0; 23 | 24 | double m_resolvedChatId = 0; 25 | 26 | QString m_error = ""; 27 | 28 | public: 29 | explicit UsernameResolver(QObject *parent = nullptr); 30 | 31 | tdlibQt::Enums::ChatType chatType() const 32 | { 33 | return m_chatType; 34 | } 35 | 36 | QString username() const 37 | { 38 | return m_username; 39 | } 40 | 41 | double resolvedId() const 42 | { 43 | return m_resolvedId; 44 | } 45 | 46 | double resolvedChatId() const 47 | { 48 | return m_resolvedChatId; 49 | } 50 | 51 | QString error() const 52 | { 53 | return m_error; 54 | } 55 | 56 | signals: 57 | 58 | void chatTypeChanged(tdlibQt::Enums::ChatType chatType); 59 | 60 | void usernameChanged(QString username); 61 | 62 | void resolvedIdChanged(double resolvedId); 63 | 64 | void resolvedChatIdChanged(double resolvedChatId); 65 | void errorChanged(QString error); 66 | 67 | private slots: 68 | void setResolvedId(double resolvedId); 69 | void setResolvedChatId(double resolvedChatId); 70 | 71 | public slots: 72 | void setChatType(tdlibQt::Enums::ChatType chatType) 73 | { 74 | if (m_chatType == chatType) 75 | return; 76 | 77 | m_chatType = chatType; 78 | emit chatTypeChanged(m_chatType); 79 | } 80 | void setUsername(QString username); 81 | void chatReceived(const QJsonObject &chatObject); 82 | 83 | void setError(QString error) 84 | { 85 | if (m_error == error) 86 | return; 87 | 88 | m_error = error; 89 | emit errorChanged(m_error); 90 | } 91 | protected slots: 92 | void errorReceived(const QJsonObject &errorObject); 93 | }; 94 | } // namespace tdlibQt 95 | #endif // USERNAMERESOLVER_HPP 96 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/items/AboutMeDAO.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ABOUTMEDAO_HPP 2 | #define ABOUTMEDAO_HPP 3 | 4 | #include 5 | namespace tdlibQt { 6 | class TdlibJsonWrapper; 7 | class AboutMeDAO : public QObject 8 | { 9 | Q_OBJECT 10 | Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged) 11 | Q_PROPERTY(bool disableGetMe READ disableGetMe WRITE setDisableGetMe NOTIFY disableGetMeChanged) 12 | Q_PROPERTY(QString firstName READ firstName WRITE setFirstName NOTIFY firstNameChanged) 13 | Q_PROPERTY(QString lastName READ lastName WRITE setLastName NOTIFY lastNameChanged) 14 | Q_PROPERTY(QString fullName READ fullName WRITE setFullName NOTIFY fullNameChanged) 15 | Q_PROPERTY(QString phoneNumber READ phoneNumber WRITE setPhoneNumber NOTIFY phoneNumberChanged) 16 | Q_PROPERTY(QString photoPath READ photoPath WRITE setPhotoPath NOTIFY photoPathChanged) 17 | TdlibJsonWrapper *m_client; 18 | int m_profilePhotoId = 0; 19 | QString m_firstName; 20 | 21 | QString m_lastName; 22 | 23 | QString m_fullName; 24 | 25 | QString m_phoneNumber; 26 | 27 | QString m_photoPath; 28 | 29 | QString m_id; 30 | 31 | QString m_last_message_inbox_id; 32 | 33 | QString m_last_message_id; 34 | 35 | bool m_disableGetMe; 36 | 37 | public: 38 | explicit AboutMeDAO(QObject *parent = 0); 39 | 40 | QString firstName() const; 41 | 42 | QString lastName() const; 43 | 44 | QString fullName() const; 45 | 46 | QString phoneNumber() const; 47 | 48 | QString photoPath() const; 49 | 50 | QString id() const; 51 | 52 | bool disableGetMe() const; 53 | 54 | signals: 55 | 56 | void firstNameChanged(QString firstName); 57 | 58 | void lastNameChanged(QString lastName); 59 | 60 | void fullNameChanged(QString fullName); 61 | 62 | void phoneNumberChanged(QString phoneNumber); 63 | 64 | void photoPathChanged(QString photoPath); 65 | 66 | void idChanged(QString id); 67 | 68 | void disableGetMeChanged(bool disableGetMe); 69 | 70 | public slots: 71 | void setInfo(const QJsonObject &meObject); 72 | void setFirstName(QString firstName); 73 | void setLastName(QString lastName); 74 | void setFullName(QString fullName); 75 | void setPhoneNumber(QString phoneNumber); 76 | void setPhotoPath(QString photoPath); 77 | void setId(QString id); 78 | 79 | void setDisableGetMe(bool disableGetMe); 80 | }; 81 | } //namespace tdlibQt 82 | 83 | #endif // ABOUTMEDAO_HPP 84 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/models/ChatMembersModel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHATMEMBERSMODEL_HPP 2 | #define CHATMEMBERSMODEL_HPP 3 | 4 | #include 5 | #include "tdlibQt/items/TdApi.hpp" 6 | namespace tdlibQt { 7 | class TdlibJsonWrapper; 8 | class ChatMembersModel : public QAbstractListModel 9 | { 10 | Q_OBJECT 11 | Q_PROPERTY(bool supergroupMode READ supergroupMode WRITE setSupergroupMode NOTIFY supergroupModeChanged) 12 | bool m_supergroupMode = false; 13 | 14 | public: 15 | explicit ChatMembersModel(QObject *parent = nullptr); 16 | ChatMembersModel(QObject *parent = nullptr, bool mode = false); 17 | TdlibJsonWrapper *m_tdlibJson; 18 | QMap avatarPhotoMap; 19 | std::vector> m_members; 20 | enum DataRoles { 21 | USER_ID, 22 | AVATAR, 23 | NAME, 24 | STATUS, 25 | ONLINE_STATUS 26 | }; 27 | enum MemberStatus { 28 | Administrator, 29 | Restricted, 30 | Banned, 31 | Creator, 32 | Left, 33 | Member 34 | }; 35 | void setMembers(const std::vector > &members); 36 | Q_ENUM(MemberStatus) 37 | signals: 38 | 39 | void supergroupModeChanged(bool supergroupMode); 40 | void downloadAvatar(const int fileId, const int rowIndex, const int priority) const; 41 | private slots: 42 | void processFile(const QJsonObject &fileObject); 43 | void getFile(const int fileId, const int rowIndex, const int priority); 44 | void userStatusReceived(const QJsonObject &userStatusObject); 45 | public slots: 46 | 47 | // QAbstractItemModel interface 48 | void setSupergroupMode(bool supergroupMode); 49 | 50 | public: 51 | int rowCount(const QModelIndex &parent) const override; 52 | QVariant data(const QModelIndex &index, int role) const override; 53 | QHash roleNames() const override; 54 | bool supergroupMode() const; 55 | }; 56 | } // namespace tdlibQt 57 | 58 | #endif // CHATMEMBERSMODEL_HPP 59 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/models/ChatsModel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CHATSMODEL_HPP 2 | #define CHATSMODEL_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include "tdlibQt/items/TdApi.hpp" 8 | #include "tdlibQt/include/TdlibNamespace.hpp" 9 | 10 | namespace tdlibQt { 11 | class TdlibJsonWrapper; 12 | class ChatsModel : public QAbstractListModel 13 | { 14 | Q_OBJECT 15 | Q_PROPERTY(int totalUnreadCount READ totalUnreadCount NOTIFY 16 | totalUnreadCountChanged) 17 | QList> m_chats; 18 | QList m_chatIds; 19 | QMap> chatActionMap; 20 | QVector chatActionIndices; 21 | QTimer chatActionTimer; 22 | enum Roles { 23 | ID, 24 | TYPE, 25 | TITLE, 26 | DATE, 27 | PHOTO, 28 | MUTE_FOR, 29 | CHAT_ACTION, 30 | LAST_MESSAGE, 31 | LAST_MESSAGE_ID, 32 | LAST_MESSAGE_AUTHOR, 33 | LAST_MESSAGE_INBOX_ID, 34 | LAST_MESSAGE_OUTBOX_ID, 35 | ORDER, 36 | IS_PINNED, 37 | IS_SPONSORED, 38 | IS_MARKED_UNREAD, 39 | UNREAD_COUNT, 40 | UNREAD_MENTION_COUNT, 41 | NOTIFICATION_SETTINGS, 42 | REPLY_MARKUP_MESSAGE_ID, 43 | DRAFT_MESSAGE, 44 | CLIENT_DATA, 45 | SENDING_STATE 46 | }; 47 | TdlibJsonWrapper *tdlibJson; 48 | void changeChatOrderOrAdd(qint64 chatId, qint64 order); 49 | const int indexByOrder(const qint64 order); 50 | bool isContains(const QSharedPointer &chat); 51 | bool fetchPending = false; 52 | void addItem(const QSharedPointer &chatItem); 53 | public: 54 | explicit ChatsModel(QObject *parent = 0); 55 | 56 | // QAbstractItemModel interface 57 | int rowCount(const QModelIndex &parent) const override; 58 | QVariant data(const QModelIndex &index, int role) const override; 59 | // bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild); 60 | void fetchMore(const QModelIndex &parent) override; 61 | QHash roleNames() const override; 62 | bool canFetchMore(const QModelIndex &parent) const override; 63 | int getIndex(const qint64 chatId); 64 | 65 | int totalUnreadCount() const; 66 | 67 | private slots: 68 | void chatActionCleanUp(); 69 | void addChat(const QJsonObject &chatObject); 70 | void addChats(const QJsonObject &chatsObject); 71 | void updateChatPhoto(const QJsonObject &chatObject); 72 | void updateChatOrder(const QJsonObject &chatOrderObject); 73 | void updateChatLastMessage(const QJsonObject &chatLastMessageObject); 74 | void updateChatReadInbox(const QJsonObject &chatReadInboxObject); 75 | void updateChatReadOutbox(const QJsonObject &chatReadOutboxObject); 76 | 77 | void updateChatAction(const QJsonObject &chatActionObject); 78 | void sortByOrder(); 79 | void updateChatMentionCount(const QJsonObject &chatMentionCountObject); 80 | void updateMentionRead(const QJsonObject &messageMentionReadObject); 81 | void updateNotificationSettings(const QJsonObject &updateNotificationSettingsObject); 82 | void updateChatIsMarkedAsUnread(const QJsonObject &updateChatIsMarkedAsUnreadObject); 83 | void onAuthorizationStateChanged(const Enums::AuthorizationState state); 84 | 85 | signals: 86 | 87 | void totalUnreadCountChanged(int totalUnreadCount); 88 | 89 | public slots: 90 | void changeNotificationSettings(const QString &chatId, bool mute); 91 | void markAsUnread(const QString &chatId, bool unread); 92 | void reset(); 93 | }; 94 | } // namespace tdlibQt 95 | #endif // CHATSMODEL_HPP 96 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/models/ContactsModel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CONTACTSMODEL_HPP 2 | #define CONTACTSMODEL_HPP 3 | 4 | #include 5 | #include 6 | #include "tdlibQt/items/TdApi.hpp" 7 | namespace tdlibQt { 8 | 9 | class TdlibJsonWrapper; 10 | 11 | class ContactsModel : public QAbstractListModel 12 | { 13 | Q_OBJECT 14 | 15 | QList> m_contacts; 16 | QList m_contactsIds; 17 | TdlibJsonWrapper *m_clientJson; 18 | QTimer m_statusTimer; 19 | 20 | public: 21 | ContactsModel(QObject *parent = 0); 22 | enum class Status { 23 | userStatusEmpty, 24 | userStatusOnline,//int expires_; 25 | userStatusOffline,//int was_online_; 26 | userStatusRecently, 27 | userStatusLastWeek, 28 | userStatusLastMonth 29 | }; 30 | enum DataTypes { 31 | USER_ID, 32 | FIRST_NAME, 33 | LAST_NAME, 34 | USER_NAME, 35 | PHONE_NUMBER, 36 | STATUS, 37 | PHOTO, 38 | IS_VERIFIED 39 | }; 40 | // QAbstractItemModel interface 41 | void appendContact(const QSharedPointer &usr); 42 | public: 43 | int rowCount(const QModelIndex &parent) const override; 44 | QVariant data(const QModelIndex &index, int role) const override; 45 | QHash roleNames() const override; 46 | signals: 47 | void chatIdReceived(QString chatId); 48 | private slots: 49 | void onChatReceived(const QJsonObject &obj); 50 | public slots: 51 | void parseContact(const QJsonObject &userObject); 52 | void addContactIds(const QJsonObject &usersObject); 53 | void updateContactPhoto(const QJsonObject &fileObject); 54 | void updateStatus(const QJsonObject &statusObject); 55 | QString getChatId(const int userId); 56 | }; 57 | 58 | 59 | } // namespace tdlibQt 60 | 61 | Q_DECLARE_METATYPE(tdlibQt::ContactsModel::Status) 62 | #endif // CONTACTSMODEL_HPP 63 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/models/FilterContactsModel.cpp: -------------------------------------------------------------------------------- 1 | #include "FilterContactsModel.hpp" 2 | namespace tdlibQt { 3 | FilterContactsModel::FilterContactsModel(QObject *parent) : QSortFilterProxyModel(parent) 4 | { 5 | } 6 | 7 | QAbstractItemModel *FilterContactsModel::source() const 8 | { 9 | return m_source; 10 | } 11 | 12 | 13 | void FilterContactsModel::setSource(QAbstractItemModel *source) 14 | { 15 | if (m_source == source) 16 | return; 17 | 18 | m_source = source; 19 | setSourceModel(m_source); 20 | 21 | emit sourceChanged(m_source); 22 | } 23 | 24 | void FilterContactsModel::sortModel(Qt::SortOrder order) 25 | { 26 | this->sort(0, order); 27 | } 28 | 29 | bool FilterContactsModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const 30 | { 31 | if (m_source) { 32 | QModelIndex index = sourceModel()->index(source_row, 0, source_parent); 33 | 34 | return (sourceModel()->data(index, 1).toString().contains(filterRegExp()) 35 | || sourceModel()->data(index, 2).toString().contains(filterRegExp()) 36 | || sourceModel()->data(index, 3).toString().contains(filterRegExp())); 37 | } 38 | return true; 39 | } 40 | } // tdlibQt 41 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/models/FilterContactsModel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILTERCONTACTSMODEL_HPP 2 | #define FILTERCONTACTSMODEL_HPP 3 | 4 | #include 5 | namespace tdlibQt { 6 | 7 | class FilterContactsModel : public QSortFilterProxyModel 8 | { 9 | Q_OBJECT 10 | Q_PROPERTY(QAbstractItemModel *source READ source WRITE setSource NOTIFY sourceChanged) 11 | QAbstractItemModel *m_source; 12 | 13 | public: 14 | FilterContactsModel(QObject *parent = 0); 15 | 16 | // QSortFilterProxyModel interface 17 | QAbstractItemModel *source() const; 18 | 19 | public slots: 20 | void setSource(QAbstractItemModel *source); 21 | void sortModel(Qt::SortOrder order); 22 | signals: 23 | void sourceChanged(QAbstractItemModel *source); 24 | 25 | protected: 26 | bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; 27 | }; 28 | } // tdlibQt 29 | #endif // FILTERCONTACTSMODEL_HPP 30 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/models/SearchChatsModel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SEACHCHATSMODEL_H 2 | #define SEACHCHATSMODEL_H 3 | 4 | #include 5 | #include 6 | #include "tdlibQt/items/TdApi.hpp" 7 | 8 | namespace tdlibQt { 9 | 10 | class TdlibJsonWrapper; 11 | class chat; 12 | class SearchChatsModel : public QAbstractItemModel 13 | { 14 | Q_OBJECT 15 | QList> m_localResult; 16 | QList> m_globalResult; 17 | QSharedPointer rootLocal; 18 | QSharedPointer rootGlobal; 19 | 20 | public: 21 | explicit SearchChatsModel(QObject *parent = nullptr); 22 | TdlibJsonWrapper *m_clientJson; 23 | enum Roles { 24 | ID, 25 | TYPE, 26 | TITLE, 27 | DATE, 28 | PHOTO 29 | }; 30 | QVariant dataLocal(const QModelIndex &index, int role) const; 31 | QVariant dataGlobal(const QModelIndex &index, int role) const; 32 | signals: 33 | 34 | private slots: 35 | 36 | void addChat(const QJsonObject &chatObject); 37 | void updateChatPhoto(const QJsonObject &updateFileObject); 38 | 39 | public slots: 40 | void searchChats(const QString &query); 41 | 42 | 43 | // QAbstractItemModel interface 44 | public: 45 | QModelIndex index(int row, int column, const QModelIndex &parent) const override; 46 | QModelIndex parent(const QModelIndex &child) const override; 47 | int rowCount(const QModelIndex &parent) const override; 48 | int columnCount(const QModelIndex &parent) const override; 49 | QVariant data(const QModelIndex &index, int role) const override; 50 | QHash roleNames() const override; 51 | }; 52 | } //namespace tdlibQt 53 | 54 | #endif // SEACHCHATSMODEL_H 55 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibQt/models/singletons/UsersModel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef USERSMODEL_HPP 2 | #define USERSMODEL_HPP 3 | 4 | #include 5 | #include "tdlibQt/items/TdApi.hpp" 6 | 7 | namespace tdlibQt { 8 | class TdlibJsonWrapper; 9 | class UsersModel : public QObject 10 | { 11 | Q_OBJECT 12 | TdlibJsonWrapper *m_tdlibJson; 13 | QMap> m_chats; 14 | QMap> m_supergroups; 15 | QMap> m_groups; 16 | QMap> m_users; 17 | UsersModel(QObject *parent = 0); 18 | public: 19 | static UsersModel *instance(); 20 | UsersModel(UsersModel const &) = delete; 21 | void operator=(UsersModel const &) = delete; 22 | 23 | int getChatMuteFor(const qint64 chatId); 24 | QString getChatTitle(const qint64 chatId); 25 | qint64 getLastMessageInbox(const qint64 chatId); 26 | qint64 getLastMessageOutbox(const qint64 chatId); 27 | qint64 getLastMessageId(const qint64 chatId); 28 | QVariantMap getChatType(const qint64 chatId); 29 | QString getUserFirstName(const int userId); 30 | QString getUserFullName(const int userId); 31 | void setSmallAvatar(qint64 id, QSharedPointer small); 32 | QSharedPointer getUserPhoto(const int userId); 33 | QSharedPointer getGroupStatus(int group_id); 34 | QSharedPointer getUser(const int userId); 35 | QSharedPointer getGroup(const int groupId); 36 | 37 | QSharedPointer getSupergroup(const int supergroupId); 38 | QSharedPointer getChat(const qint64 chatId); 39 | QSharedPointer getUserStatus(const int userId); 40 | static QString getUserStatusAsString(const QSharedPointer &userStatus); 41 | 42 | signals: 43 | void userStatusChanged(const int userId); 44 | private slots: 45 | void updateChatLastMessage(const QJsonObject &chatLastMessageObject); 46 | void updateChatReadInbox(const QJsonObject &chatReadInboxObject); 47 | void updateChatReadOutbox(const QJsonObject &chatReadOutboxObject); 48 | void updateUserStatus(const QJsonObject &updateUserStatusObject); 49 | void getUpdateNewChat(const QJsonObject &updateNewChatObject); 50 | void getUpdateUser(const QJsonObject &updateNewUserObject); 51 | void parseUser(const QJsonObject &userObject); 52 | 53 | void getUpdateNewSupergroup(const QJsonObject &updateNewSupergroupObject); 54 | void getUpdateGroup(const QJsonObject &updateGroupObject); 55 | }; 56 | } //tdlibQt 57 | 58 | #endif // USERSMODEL_HPP 59 | -------------------------------------------------------------------------------- /tdlibjson_wrapper/tdlibjson_wrapper.pro: -------------------------------------------------------------------------------- 1 | APPID = $$fromfile(api_secret.pri,APPID)#To build you have to create file api_secret.pri with app_id, or replace with your app_id 2 | APP_HASH = $$fromfile(api_secret.pri,APP_HASH)#To build you have to create file api_secret.pri app_hash, or replace with your app_hash 3 | 4 | 5 | VERSION = 0.7.3 6 | DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\" 7 | 8 | TEMPLATE = lib 9 | TARGET = tdlibjson_wrapper 10 | CONFIG += staticlib 11 | QT += dbus quick 12 | 13 | CONFIG += c++11 link_pkgconfig 14 | PKGCONFIG += tdlibjson 15 | PKGCONFIG += mlite5 16 | 17 | CONFIG (debug, debug|release) { 18 | OBJECTS_DIR = build/debug 19 | } else { 20 | OBJECTS_DIR = build/release 21 | } 22 | MOC_DIR = build/mocs 23 | 24 | HEADERS += \ 25 | tdlibQt/TdlibJsonWrapper.hpp \ 26 | tdlibQt/ListenObject.hpp \ 27 | tdlibQt/ParseObject.hpp \ 28 | tdlibQt/infoProviders/BasicGroupInfoProvider.hpp \ 29 | tdlibQt/infoProviders/ChannelInfoProvider.hpp \ 30 | tdlibQt/infoProviders/InfoProvider.hpp \ 31 | tdlibQt/infoProviders/UserInfoProvider.hpp \ 32 | tdlibQt/infoProviders/UsernameResolver.hpp \ 33 | tdlibQt/items/TdApi.hpp \ 34 | tdlibQt/items/TdLibDependencies.hpp \ 35 | tdlibQt/include/TdlibNamespace.hpp \ 36 | tdlibQt/models/ChatMembersModel.hpp \ 37 | tdlibQt/models/ChatsModel.hpp \ 38 | tdlibQt/TelegramProfileProvider.hpp \ 39 | tdlibQt/models/MessagingModel.hpp \ 40 | tdlibQt/FileWriter.hpp \ 41 | tdlibQt/ListenScheduler.hpp \ 42 | tdlibQt/include/AppApiInfo.hpp \ 43 | tdlibQt/include/AuthenticationHandler.hpp \ 44 | tdlibQt/items/ProxyDAO.hpp \ 45 | tdlibQt/items/AboutMeDAO.hpp \ 46 | tdlibQt/models/SearchChatMessagesModel.hpp \ 47 | tdlibQt/models/singletons/UsersModel.hpp \ 48 | tdlibQt/models/StickerModel.hpp \ 49 | tdlibQt/NotificationManager.hpp \ 50 | tdlibQt/models/SearchChatsModel.hpp \ 51 | tdlibQt/models/ContactsModel.hpp \ 52 | tdlibQt/models/FilterContactsModel.hpp 53 | 54 | SOURCES += \ 55 | tdlibQt/TdlibJsonWrapper.cpp \ 56 | tdlibQt/ListenObject.cpp \ 57 | tdlibQt/ParseObject.cpp \ 58 | tdlibQt/infoProviders/BasicGroupInfoProvider.cpp \ 59 | tdlibQt/infoProviders/ChannelInfoProvider.cpp \ 60 | tdlibQt/infoProviders/InfoProvider.cpp \ 61 | tdlibQt/infoProviders/UserInfoProvider.cpp \ 62 | tdlibQt/infoProviders/UsernameResolver.cpp \ 63 | tdlibQt/items/TdApi.cpp \ 64 | tdlibQt/models/ChatMembersModel.cpp \ 65 | tdlibQt/models/ChatsModel.cpp \ 66 | tdlibQt/TelegramProfileProvider.cpp \ 67 | tdlibQt/models/MessagingModel.cpp \ 68 | tdlibQt/FileWriter.cpp \ 69 | tdlibQt/ListenScheduler.cpp \ 70 | tdlibQt/include/AuthenticationHandler.cpp \ 71 | tdlibQt/items/ProxyDAO.cpp \ 72 | tdlibQt/items/AboutMeDAO.cpp \ 73 | tdlibQt/models/SearchChatMessagesModel.cpp \ 74 | tdlibQt/models/singletons/UsersModel.cpp \ 75 | tdlibQt/models/StickerModel.cpp \ 76 | tdlibQt/NotificationManager.cpp \ 77 | tdlibQt/models/SearchChatsModel.cpp \ 78 | tdlibQt/models/ContactsModel.cpp \ 79 | tdlibQt/models/FilterContactsModel.cpp 80 | 81 | info_file.input = $$PWD/tdlibQt/include/AppApiInfo.hpp.in 82 | info_file.output = $$PWD/tdlibQt/include/AppApiInfo.hpp 83 | 84 | QMAKE_SUBSTITUTES += info_file 85 | 86 | OTHER_FILES += \ 87 | tdlibQt/include/AppApiInfo.hpp.in 88 | 89 | DISTFILES += \ 90 | api_secret.pri \ 91 | api_secret.pri 92 | -------------------------------------------------------------------------------- /webp-plugin/.qmake.conf: -------------------------------------------------------------------------------- 1 | load(qt_build_config) 2 | 3 | MODULE_VERSION = 5.2.0 4 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/AUTHORS: -------------------------------------------------------------------------------- 1 | Contributors: 2 | - Charles Munger (clm at google dot com) 3 | - Christian Duvivier (cduvivier at google dot com) 4 | - Djordje Pesut (djordje dot pesut at imgtec dot com) 5 | - James Zern (jzern at google dot com) 6 | - Jan Engelhardt (jengelh at medozas dot de) 7 | - Johann (johann dot koenig at duck dot com) 8 | - Jovan Zelincevic (jovan dot zelincevic at imgtec dot com) 9 | - Jyrki Alakuijala (jyrki at google dot com) 10 | - levytamar82 (tamar dot levy at intel dot com) 11 | - Lou Quillio (louquillio at google dot com) 12 | - Mans Rullgard (mans at mansr dot com) 13 | - Martin Olsson (mnemo at minimum dot se) 14 | - Mikołaj Zalewski (mikolajz at google dot com) 15 | - Noel Chromium (noel at chromium dot org) 16 | - Pascal Massimino (pascal dot massimino at gmail dot com) 17 | - Paweł Hajdan, Jr (phajdan dot jr at chromium dot org) 18 | - Pierre Joye (pierre dot php at gmail dot com) 19 | - Sam Clegg (sbc at chromium dot org) 20 | - Scott LaVarnway (slavarnway at google dot com) 21 | - Scott Talbot (s at chikachow dot org) 22 | - Slobodan Prijic (slobodan dot prijic at imgtec dot com) 23 | - Somnath Banerjee (somnath dot banerjee at gmail dot com) 24 | - Timothy Gu (timothygu99 at gmail dot com) 25 | - Urvang Joshi (urvang at google dot com) 26 | - Vikas Arora (vikasa at google dot com) 27 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Google Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of Google nor the names of its contributors may 16 | be used to endorse or promote products derived from this software 17 | without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | ------------------------------------ 3 | 4 | "These implementations" means the copyrightable works that implement the WebM 5 | codecs distributed by Google as part of the WebM Project. 6 | 7 | Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge, 8 | royalty-free, irrevocable (except as stated in this section) patent license to 9 | make, have made, use, offer to sell, sell, import, transfer, and otherwise 10 | run, modify and propagate the contents of these implementations of WebM, where 11 | such license applies only to those patent claims, both currently owned by 12 | Google and acquired in the future, licensable by Google that are necessarily 13 | infringed by these implementations of WebM. This grant does not include claims 14 | that would be infringed only as a consequence of further modification of these 15 | implementations. If you or your agent or exclusive licensee institute or order 16 | or agree to the institution of patent litigation or any other patent 17 | enforcement activity against any entity (including a cross-claim or 18 | counterclaim in a lawsuit) alleging that any of these implementations of WebM 19 | or any code incorporated within any of these implementations of WebM 20 | constitute direct or contributory patent infringement, or inducement of 21 | patent infringement, then any patent rights granted to you under this License 22 | for these implementations of WebM shall terminate as of the date such 23 | litigation is filed. 24 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/dec/alphai.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Alpha decoder: internal header. 11 | // 12 | // Author: Urvang (urvang@google.com) 13 | 14 | #ifndef WEBP_DEC_ALPHAI_H_ 15 | #define WEBP_DEC_ALPHAI_H_ 16 | 17 | #include "./webpi.h" 18 | #include "../utils/filters.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | struct VP8LDecoder; // Defined in dec/vp8li.h. 25 | 26 | typedef struct ALPHDecoder ALPHDecoder; 27 | struct ALPHDecoder { 28 | int width_; 29 | int height_; 30 | int method_; 31 | WEBP_FILTER_TYPE filter_; 32 | int pre_processing_; 33 | struct VP8LDecoder* vp8l_dec_; 34 | VP8Io io_; 35 | int use_8b_decode; // Although alpha channel requires only 1 byte per 36 | // pixel, sometimes VP8LDecoder may need to allocate 37 | // 4 bytes per pixel internally during decode. 38 | }; 39 | 40 | //------------------------------------------------------------------------------ 41 | // internal functions. Not public. 42 | 43 | // Allocates a new alpha decoder instance. 44 | ALPHDecoder* ALPHNew(void); 45 | 46 | // Clears and deallocates an alpha decoder instance. 47 | void ALPHDelete(ALPHDecoder* const dec); 48 | 49 | //------------------------------------------------------------------------------ 50 | 51 | #ifdef __cplusplus 52 | } // extern "C" 53 | #endif 54 | 55 | #endif /* WEBP_DEC_ALPHAI_H_ */ 56 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/dsp/alpha_processing_sse2.c: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Utilities for processing transparent channel. 11 | // 12 | // Author: Skal (pascal.massimino@gmail.com) 13 | 14 | #include "./dsp.h" 15 | 16 | #if defined(WEBP_USE_SSE2) 17 | #include 18 | 19 | //------------------------------------------------------------------------------ 20 | 21 | static int ExtractAlpha(const uint8_t* argb, int argb_stride, 22 | int width, int height, 23 | uint8_t* alpha, int alpha_stride) { 24 | // alpha_and stores an 'and' operation of all the alpha[] values. The final 25 | // value is not 0xff if any of the alpha[] is not equal to 0xff. 26 | uint32_t alpha_and = 0xff; 27 | int i, j; 28 | const __m128i a_mask = _mm_set1_epi32(0xffu); // to preserve alpha 29 | const __m128i all_0xff = _mm_set_epi32(0, 0, ~0u, ~0u); 30 | __m128i all_alphas = all_0xff; 31 | 32 | // We must be able to access 3 extra bytes after the last written byte 33 | // 'src[4 * width - 4]', because we don't know if alpha is the first or the 34 | // last byte of the quadruplet. 35 | const int limit = (width - 1) & ~7; 36 | 37 | for (j = 0; j < height; ++j) { 38 | const __m128i* src = (const __m128i*)argb; 39 | for (i = 0; i < limit; i += 8) { 40 | // load 32 argb bytes 41 | const __m128i a0 = _mm_loadu_si128(src + 0); 42 | const __m128i a1 = _mm_loadu_si128(src + 1); 43 | const __m128i b0 = _mm_and_si128(a0, a_mask); 44 | const __m128i b1 = _mm_and_si128(a1, a_mask); 45 | const __m128i c0 = _mm_packs_epi32(b0, b1); 46 | const __m128i d0 = _mm_packus_epi16(c0, c0); 47 | // store 48 | _mm_storel_epi64((__m128i*)&alpha[i], d0); 49 | // accumulate eight alpha 'and' in parallel 50 | all_alphas = _mm_and_si128(all_alphas, d0); 51 | src += 2; 52 | } 53 | for (; i < width; ++i) { 54 | const uint32_t alpha_value = argb[4 * i]; 55 | alpha[i] = alpha_value; 56 | alpha_and &= alpha_value; 57 | } 58 | argb += argb_stride; 59 | alpha += alpha_stride; 60 | } 61 | // Combine the eight alpha 'and' into a 8-bit mask. 62 | alpha_and &= _mm_movemask_epi8(_mm_cmpeq_epi8(all_alphas, all_0xff)); 63 | return (alpha_and == 0xff); 64 | } 65 | 66 | #endif // WEBP_USE_SSE2 67 | 68 | //------------------------------------------------------------------------------ 69 | // Init function 70 | 71 | extern void WebPInitAlphaProcessingSSE2(void); 72 | 73 | void WebPInitAlphaProcessingSSE2(void) { 74 | #if defined(WEBP_USE_SSE2) 75 | WebPExtractAlpha = ExtractAlpha; 76 | #endif 77 | } 78 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/dsp/enc_avx2.c: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // AVX2 version of speed-critical encoding functions. 11 | 12 | #include "./dsp.h" 13 | 14 | #if defined(WEBP_USE_AVX2) 15 | 16 | #endif // WEBP_USE_AVX2 17 | 18 | //------------------------------------------------------------------------------ 19 | // Entry point 20 | 21 | extern void VP8EncDspInitAVX2(void); 22 | 23 | void VP8EncDspInitAVX2(void) { 24 | } 25 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/dsp/neon.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // NEON common code. 11 | 12 | #ifndef WEBP_DSP_NEON_H_ 13 | #define WEBP_DSP_NEON_H_ 14 | 15 | #include 16 | 17 | #include "./dsp.h" 18 | 19 | // Right now, some intrinsics functions seem slower, so we disable them 20 | // everywhere except aarch64 where the inline assembly is incompatible. 21 | #if defined(__aarch64__) 22 | #define USE_INTRINSICS // use intrinsics when possible 23 | #endif 24 | 25 | #define INIT_VECTOR2(v, a, b) do { \ 26 | v.val[0] = a; \ 27 | v.val[1] = b; \ 28 | } while (0) 29 | 30 | #define INIT_VECTOR3(v, a, b, c) do { \ 31 | v.val[0] = a; \ 32 | v.val[1] = b; \ 33 | v.val[2] = c; \ 34 | } while (0) 35 | 36 | #define INIT_VECTOR4(v, a, b, c, d) do { \ 37 | v.val[0] = a; \ 38 | v.val[1] = b; \ 39 | v.val[2] = c; \ 40 | v.val[3] = d; \ 41 | } while (0) 42 | 43 | // if using intrinsics, this flag avoids some functions that make gcc-4.6.3 44 | // crash ("internal compiler error: in immed_double_const, at emit-rtl."). 45 | // (probably similar to gcc.gnu.org/bugzilla/show_bug.cgi?id=48183) 46 | #if !(LOCAL_GCC_PREREQ(4,8) || defined(__aarch64__)) 47 | #define WORK_AROUND_GCC 48 | #endif 49 | 50 | static WEBP_INLINE int32x4x4_t Transpose4x4(const int32x4x4_t rows) { 51 | uint64x2x2_t row01, row23; 52 | 53 | row01.val[0] = vreinterpretq_u64_s32(rows.val[0]); 54 | row01.val[1] = vreinterpretq_u64_s32(rows.val[1]); 55 | row23.val[0] = vreinterpretq_u64_s32(rows.val[2]); 56 | row23.val[1] = vreinterpretq_u64_s32(rows.val[3]); 57 | // Transpose 64-bit values (there's no vswp equivalent) 58 | { 59 | const uint64x1_t row0h = vget_high_u64(row01.val[0]); 60 | const uint64x1_t row2l = vget_low_u64(row23.val[0]); 61 | const uint64x1_t row1h = vget_high_u64(row01.val[1]); 62 | const uint64x1_t row3l = vget_low_u64(row23.val[1]); 63 | row01.val[0] = vcombine_u64(vget_low_u64(row01.val[0]), row2l); 64 | row23.val[0] = vcombine_u64(row0h, vget_high_u64(row23.val[0])); 65 | row01.val[1] = vcombine_u64(vget_low_u64(row01.val[1]), row3l); 66 | row23.val[1] = vcombine_u64(row1h, vget_high_u64(row23.val[1])); 67 | } 68 | { 69 | const int32x4x2_t out01 = vtrnq_s32(vreinterpretq_s32_u64(row01.val[0]), 70 | vreinterpretq_s32_u64(row01.val[1])); 71 | const int32x4x2_t out23 = vtrnq_s32(vreinterpretq_s32_u64(row23.val[0]), 72 | vreinterpretq_s32_u64(row23.val[1])); 73 | int32x4x4_t out; 74 | out.val[0] = out01.val[0]; 75 | out.val[1] = out01.val[1]; 76 | out.val[2] = out23.val[0]; 77 | out.val[3] = out23.val[1]; 78 | return out; 79 | } 80 | } 81 | 82 | #endif // WEBP_DSP_NEON_H_ 83 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/enc/cost.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Cost tables for level and modes. 11 | // 12 | // Author: Skal (pascal.massimino@gmail.com) 13 | 14 | #ifndef WEBP_ENC_COST_H_ 15 | #define WEBP_ENC_COST_H_ 16 | 17 | #include 18 | #include 19 | #include "./vp8enci.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | // On-the-fly info about the current set of residuals. Handy to avoid 26 | // passing zillions of params. 27 | typedef struct { 28 | int first; 29 | int last; 30 | const int16_t* coeffs; 31 | 32 | int coeff_type; 33 | ProbaArray* prob; 34 | StatsArray* stats; 35 | CostArray* cost; 36 | } VP8Residual; 37 | 38 | void VP8InitResidual(int first, int coeff_type, 39 | VP8Encoder* const enc, VP8Residual* const res); 40 | 41 | typedef void (*VP8SetResidualCoeffsFunc)(const int16_t* const coeffs, 42 | VP8Residual* const res); 43 | extern VP8SetResidualCoeffsFunc VP8SetResidualCoeffs; 44 | 45 | void VP8SetResidualCoeffsInit(void); // must be called first 46 | 47 | int VP8RecordCoeffs(int ctx, const VP8Residual* const res); 48 | 49 | // approximate cost per level: 50 | extern const uint16_t VP8LevelFixedCosts[MAX_LEVEL + 1]; 51 | extern const uint16_t VP8EntropyCost[256]; // 8bit fixed-point log(p) 52 | 53 | // Cost of coding one event with probability 'proba'. 54 | static WEBP_INLINE int VP8BitCost(int bit, uint8_t proba) { 55 | return !bit ? VP8EntropyCost[proba] : VP8EntropyCost[255 - proba]; 56 | } 57 | 58 | // Cost calculation function. 59 | typedef int (*VP8GetResidualCostFunc)(int ctx0, const VP8Residual* const res); 60 | extern VP8GetResidualCostFunc VP8GetResidualCost; 61 | 62 | void VP8GetResidualCostInit(void); // must be called first 63 | 64 | // Level cost calculations 65 | extern const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2]; 66 | void VP8CalculateLevelCosts(VP8Proba* const proba); 67 | static WEBP_INLINE int VP8LevelCost(const uint16_t* const table, int level) { 68 | return VP8LevelFixedCosts[level] 69 | + table[(level > MAX_VARIABLE_LEVEL) ? MAX_VARIABLE_LEVEL : level]; 70 | } 71 | 72 | // Mode costs 73 | extern const uint16_t VP8FixedCostsUV[4]; 74 | extern const uint16_t VP8FixedCostsI16[4]; 75 | extern const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES]; 76 | 77 | //------------------------------------------------------------------------------ 78 | 79 | #ifdef __cplusplus 80 | } // extern "C" 81 | #endif 82 | 83 | #endif /* WEBP_ENC_COST_H_ */ 84 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/enc/vp8li.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Lossless encoder: internal header. 11 | // 12 | // Author: Vikas Arora (vikaas.arora@gmail.com) 13 | 14 | #ifndef WEBP_ENC_VP8LI_H_ 15 | #define WEBP_ENC_VP8LI_H_ 16 | 17 | #include "./backward_references.h" 18 | #include "./histogram.h" 19 | #include "../utils/bit_writer.h" 20 | #include "../webp/encode.h" 21 | #include "../webp/format_constants.h" 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef struct { 28 | const WebPConfig* config_; // user configuration and parameters 29 | const WebPPicture* pic_; // input picture. 30 | 31 | uint32_t* argb_; // Transformed argb image data. 32 | uint32_t* argb_scratch_; // Scratch memory for argb rows 33 | // (used for prediction). 34 | uint32_t* transform_data_; // Scratch memory for transform data. 35 | int current_width_; // Corresponds to packed image width. 36 | 37 | // Encoding parameters derived from quality parameter. 38 | int histo_bits_; 39 | int transform_bits_; 40 | int cache_bits_; // If equal to 0, don't use color cache. 41 | 42 | // Encoding parameters derived from image characteristics. 43 | int use_cross_color_; 44 | int use_subtract_green_; 45 | int use_predict_; 46 | int use_palette_; 47 | int palette_size_; 48 | uint32_t palette_[MAX_PALETTE_SIZE]; 49 | 50 | // Some 'scratch' (potentially large) objects. 51 | struct VP8LBackwardRefs refs_[2]; // Backward Refs array corresponding to 52 | // LZ77 & RLE coding. 53 | VP8LHashChain hash_chain_; // HashChain data for constructing 54 | // backward references. 55 | } VP8LEncoder; 56 | 57 | //------------------------------------------------------------------------------ 58 | // internal functions. Not public. 59 | 60 | // Encodes the picture. 61 | // Returns 0 if config or picture is NULL or picture doesn't have valid argb 62 | // input. 63 | int VP8LEncodeImage(const WebPConfig* const config, 64 | const WebPPicture* const picture); 65 | 66 | // Encodes the main image stream using the supplied bit writer. 67 | WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, 68 | const WebPPicture* const picture, 69 | VP8LBitWriter* const bw); 70 | 71 | //------------------------------------------------------------------------------ 72 | 73 | #ifdef __cplusplus 74 | } // extern "C" 75 | #endif 76 | 77 | #endif /* WEBP_ENC_VP8LI_H_ */ 78 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/utils/color_cache.c: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Color Cache for WebP Lossless 11 | // 12 | // Author: Jyrki Alakuijala (jyrki@google.com) 13 | 14 | #include 15 | #include 16 | #include "./color_cache.h" 17 | #include "../utils/utils.h" 18 | 19 | //------------------------------------------------------------------------------ 20 | // VP8LColorCache. 21 | 22 | int VP8LColorCacheInit(VP8LColorCache* const cc, int hash_bits) { 23 | const int hash_size = 1 << hash_bits; 24 | assert(cc != NULL); 25 | assert(hash_bits > 0); 26 | cc->colors_ = (uint32_t*)WebPSafeCalloc((uint64_t)hash_size, 27 | sizeof(*cc->colors_)); 28 | if (cc->colors_ == NULL) return 0; 29 | cc->hash_shift_ = 32 - hash_bits; 30 | return 1; 31 | } 32 | 33 | void VP8LColorCacheClear(VP8LColorCache* const cc) { 34 | if (cc != NULL) { 35 | WebPSafeFree(cc->colors_); 36 | cc->colors_ = NULL; 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/utils/color_cache.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Color Cache for WebP Lossless 11 | // 12 | // Authors: Jyrki Alakuijala (jyrki@google.com) 13 | // Urvang Joshi (urvang@google.com) 14 | 15 | #ifndef WEBP_UTILS_COLOR_CACHE_H_ 16 | #define WEBP_UTILS_COLOR_CACHE_H_ 17 | 18 | #include "../webp/types.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | // Main color cache struct. 25 | typedef struct { 26 | uint32_t *colors_; // color entries 27 | int hash_shift_; // Hash shift: 32 - hash_bits. 28 | } VP8LColorCache; 29 | 30 | static const uint32_t kHashMul = 0x1e35a7bd; 31 | 32 | static WEBP_INLINE uint32_t VP8LColorCacheLookup( 33 | const VP8LColorCache* const cc, uint32_t key) { 34 | assert(key <= (~0U >> cc->hash_shift_)); 35 | return cc->colors_[key]; 36 | } 37 | 38 | static WEBP_INLINE void VP8LColorCacheInsert(const VP8LColorCache* const cc, 39 | uint32_t argb) { 40 | const uint32_t key = (kHashMul * argb) >> cc->hash_shift_; 41 | cc->colors_[key] = argb; 42 | } 43 | 44 | static WEBP_INLINE int VP8LColorCacheGetIndex(const VP8LColorCache* const cc, 45 | uint32_t argb) { 46 | return (kHashMul * argb) >> cc->hash_shift_; 47 | } 48 | 49 | static WEBP_INLINE int VP8LColorCacheContains(const VP8LColorCache* const cc, 50 | uint32_t argb) { 51 | const uint32_t key = (kHashMul * argb) >> cc->hash_shift_; 52 | return cc->colors_[key] == argb; 53 | } 54 | 55 | //------------------------------------------------------------------------------ 56 | 57 | // Initializes the color cache with 'hash_bits' bits for the keys. 58 | // Returns false in case of memory error. 59 | int VP8LColorCacheInit(VP8LColorCache* const color_cache, int hash_bits); 60 | 61 | // Delete the memory associated to color cache. 62 | void VP8LColorCacheClear(VP8LColorCache* const color_cache); 63 | 64 | //------------------------------------------------------------------------------ 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif // WEBP_UTILS_COLOR_CACHE_H_ 71 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/utils/endian_inl.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Endian related functions. 11 | 12 | #ifndef WEBP_UTILS_ENDIAN_INL_H_ 13 | #define WEBP_UTILS_ENDIAN_INL_H_ 14 | 15 | #ifdef HAVE_CONFIG_H 16 | #include "../webp/config.h" 17 | #endif 18 | 19 | #include "../dsp/dsp.h" 20 | #include "../webp/types.h" 21 | 22 | // some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__) 23 | #if !defined(WORDS_BIGENDIAN) && \ 24 | (defined(__BIG_ENDIAN__) || defined(_M_PPC) || \ 25 | (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))) 26 | #define WORDS_BIGENDIAN 27 | #endif 28 | 29 | #if defined(WORDS_BIGENDIAN) 30 | #define HToLE32 BSwap32 31 | #define HToLE16 BSwap16 32 | #else 33 | #define HToLE32(x) (x) 34 | #define HToLE16(x) (x) 35 | #endif 36 | 37 | #if !defined(HAVE_CONFIG_H) 38 | #if LOCAL_GCC_PREREQ(4,8) || __has_builtin(__builtin_bswap16) 39 | #define HAVE_BUILTIN_BSWAP16 40 | #endif 41 | #if LOCAL_GCC_PREREQ(4,3) || __has_builtin(__builtin_bswap32) 42 | #define HAVE_BUILTIN_BSWAP32 43 | #endif 44 | #if LOCAL_GCC_PREREQ(4,3) || __has_builtin(__builtin_bswap64) 45 | #define HAVE_BUILTIN_BSWAP64 46 | #endif 47 | #endif // !HAVE_CONFIG_H 48 | 49 | static WEBP_INLINE uint16_t BSwap16(uint16_t x) { 50 | #if defined(HAVE_BUILTIN_BSWAP16) 51 | return __builtin_bswap16(x); 52 | #elif defined(_MSC_VER) 53 | return _byteswap_ushort(x); 54 | #else 55 | // gcc will recognize a 'rorw $8, ...' here: 56 | return (x >> 8) | ((x & 0xff) << 8); 57 | #endif // HAVE_BUILTIN_BSWAP16 58 | } 59 | 60 | static WEBP_INLINE uint32_t BSwap32(uint32_t x) { 61 | #if defined(WEBP_USE_MIPS32_R2) 62 | uint32_t ret; 63 | __asm__ volatile ( 64 | "wsbh %[ret], %[x] \n\t" 65 | "rotr %[ret], %[ret], 16 \n\t" 66 | : [ret]"=r"(ret) 67 | : [x]"r"(x) 68 | ); 69 | return ret; 70 | #elif defined(HAVE_BUILTIN_BSWAP32) 71 | return __builtin_bswap32(x); 72 | #elif defined(__i386__) || defined(__x86_64__) 73 | uint32_t swapped_bytes; 74 | __asm__ volatile("bswap %0" : "=r"(swapped_bytes) : "0"(x)); 75 | return swapped_bytes; 76 | #elif defined(_MSC_VER) 77 | return (uint32_t)_byteswap_ulong(x); 78 | #else 79 | return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24); 80 | #endif // HAVE_BUILTIN_BSWAP32 81 | } 82 | 83 | static WEBP_INLINE uint64_t BSwap64(uint64_t x) { 84 | #if defined(HAVE_BUILTIN_BSWAP64) 85 | return __builtin_bswap64(x); 86 | #elif defined(__x86_64__) 87 | uint64_t swapped_bytes; 88 | __asm__ volatile("bswapq %0" : "=r"(swapped_bytes) : "0"(x)); 89 | return swapped_bytes; 90 | #elif defined(_MSC_VER) 91 | return (uint64_t)_byteswap_uint64(x); 92 | #else // generic code for swapping 64-bit values (suggested by bdb@) 93 | x = ((x & 0xffffffff00000000ull) >> 32) | ((x & 0x00000000ffffffffull) << 32); 94 | x = ((x & 0xffff0000ffff0000ull) >> 16) | ((x & 0x0000ffff0000ffffull) << 16); 95 | x = ((x & 0xff00ff00ff00ff00ull) >> 8) | ((x & 0x00ff00ff00ff00ffull) << 8); 96 | return x; 97 | #endif // HAVE_BUILTIN_BSWAP64 98 | } 99 | 100 | #endif // WEBP_UTILS_ENDIAN_INL_H_ 101 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/utils/filters.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Spatial prediction using various filters 11 | // 12 | // Author: Urvang (urvang@google.com) 13 | 14 | #ifndef WEBP_UTILS_FILTERS_H_ 15 | #define WEBP_UTILS_FILTERS_H_ 16 | 17 | #include "../webp/types.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | // Filters. 24 | typedef enum { 25 | WEBP_FILTER_NONE = 0, 26 | WEBP_FILTER_HORIZONTAL, 27 | WEBP_FILTER_VERTICAL, 28 | WEBP_FILTER_GRADIENT, 29 | WEBP_FILTER_LAST = WEBP_FILTER_GRADIENT + 1, // end marker 30 | WEBP_FILTER_BEST, 31 | WEBP_FILTER_FAST 32 | } WEBP_FILTER_TYPE; 33 | 34 | typedef void (*WebPFilterFunc)(const uint8_t* in, int width, int height, 35 | int stride, uint8_t* out); 36 | typedef void (*WebPUnfilterFunc)(int width, int height, int stride, 37 | int row, int num_rows, uint8_t* data); 38 | 39 | // Filter the given data using the given predictor. 40 | // 'in' corresponds to a 2-dimensional pixel array of size (stride * height) 41 | // in raster order. 42 | // 'stride' is number of bytes per scan line (with possible padding). 43 | // 'out' should be pre-allocated. 44 | extern const WebPFilterFunc WebPFilters[WEBP_FILTER_LAST]; 45 | 46 | // In-place reconstruct the original data from the given filtered data. 47 | // The reconstruction will be done for 'num_rows' rows starting from 'row' 48 | // (assuming rows upto 'row - 1' are already reconstructed). 49 | extern const WebPUnfilterFunc WebPUnfilters[WEBP_FILTER_LAST]; 50 | 51 | // Fast estimate of a potentially good filter. 52 | WEBP_FILTER_TYPE EstimateBestFilter(const uint8_t* data, 53 | int width, int height, int stride); 54 | 55 | #ifdef __cplusplus 56 | } // extern "C" 57 | #endif 58 | 59 | #endif /* WEBP_UTILS_FILTERS_H_ */ 60 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/utils/huffman_encode.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Author: Jyrki Alakuijala (jyrki@google.com) 11 | // 12 | // Entropy encoding (Huffman) for webp lossless 13 | 14 | #ifndef WEBP_UTILS_HUFFMAN_ENCODE_H_ 15 | #define WEBP_UTILS_HUFFMAN_ENCODE_H_ 16 | 17 | #include "../webp/types.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | // Struct for holding the tree header in coded form. 24 | typedef struct { 25 | uint8_t code; // value (0..15) or escape code (16,17,18) 26 | uint8_t extra_bits; // extra bits for escape codes 27 | } HuffmanTreeToken; 28 | 29 | // Struct to represent the tree codes (depth and bits array). 30 | typedef struct { 31 | int num_symbols; // Number of symbols. 32 | uint8_t* code_lengths; // Code lengths of the symbols. 33 | uint16_t* codes; // Symbol Codes. 34 | } HuffmanTreeCode; 35 | 36 | // Struct to represent the Huffman tree. 37 | // TODO(vikasa): Add comment for the fields of the Struct. 38 | typedef struct { 39 | uint32_t total_count_; 40 | int value_; 41 | int pool_index_left_; // Index for the left sub-tree. 42 | int pool_index_right_; // Index for the right sub-tree. 43 | } HuffmanTree; 44 | 45 | // Turn the Huffman tree into a token sequence. 46 | // Returns the number of tokens used. 47 | int VP8LCreateCompressedHuffmanTree(const HuffmanTreeCode* const tree, 48 | HuffmanTreeToken* tokens, int max_tokens); 49 | 50 | // Create an optimized tree, and tokenize it. 51 | // 'buf_rle' and 'huff_tree' are pre-allocated and the 'tree' is the constructed 52 | // huffman code tree. 53 | void VP8LCreateHuffmanTree(uint32_t* const histogram, int tree_depth_limit, 54 | uint8_t* const buf_rle, HuffmanTree* const huff_tree, 55 | HuffmanTreeCode* const tree); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif // WEBP_UTILS_HUFFMAN_ENCODE_H_ 62 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/utils/quant_levels.h: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Alpha plane quantization utility 11 | // 12 | // Author: Vikas Arora (vikasa@google.com) 13 | 14 | #ifndef WEBP_UTILS_QUANT_LEVELS_H_ 15 | #define WEBP_UTILS_QUANT_LEVELS_H_ 16 | 17 | #include 18 | 19 | #include "../webp/types.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | // Replace the input 'data' of size 'width'x'height' with 'num-levels' 26 | // quantized values. If not NULL, 'sse' will contain the sum of squared error. 27 | // Valid range for 'num_levels' is [2, 256]. 28 | // Returns false in case of error (data is NULL, or parameters are invalid). 29 | int QuantizeLevels(uint8_t* const data, int width, int height, int num_levels, 30 | uint64_t* const sse); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif 35 | 36 | #endif /* WEBP_UTILS_QUANT_LEVELS_H_ */ 37 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/utils/quant_levels_dec.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Alpha plane de-quantization utility 11 | // 12 | // Author: Vikas Arora (vikasa@google.com) 13 | 14 | #ifndef WEBP_UTILS_QUANT_LEVELS_DEC_H_ 15 | #define WEBP_UTILS_QUANT_LEVELS_DEC_H_ 16 | 17 | #include "../webp/types.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | // Apply post-processing to input 'data' of size 'width'x'height' assuming that 24 | // the source was quantized to a reduced number of levels. 25 | // Strength is in [0..100] and controls the amount of dithering applied. 26 | // Returns false in case of error (data is NULL, invalid parameters, 27 | // malloc failure, ...). 28 | int WebPDequantizeLevels(uint8_t* const data, int width, int height, 29 | int strength); 30 | 31 | #ifdef __cplusplus 32 | } // extern "C" 33 | #endif 34 | 35 | #endif /* WEBP_UTILS_QUANT_LEVELS_DEC_H_ */ 36 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/utils/random.c: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Pseudo-random utilities 11 | // 12 | // Author: Skal (pascal.massimino@gmail.com) 13 | 14 | #include 15 | #include "./random.h" 16 | 17 | //------------------------------------------------------------------------------ 18 | 19 | // 31b-range values 20 | static const uint32_t kRandomTable[VP8_RANDOM_TABLE_SIZE] = { 21 | 0x0de15230, 0x03b31886, 0x775faccb, 0x1c88626a, 0x68385c55, 0x14b3b828, 22 | 0x4a85fef8, 0x49ddb84b, 0x64fcf397, 0x5c550289, 0x4a290000, 0x0d7ec1da, 23 | 0x5940b7ab, 0x5492577d, 0x4e19ca72, 0x38d38c69, 0x0c01ee65, 0x32a1755f, 24 | 0x5437f652, 0x5abb2c32, 0x0faa57b1, 0x73f533e7, 0x685feeda, 0x7563cce2, 25 | 0x6e990e83, 0x4730a7ed, 0x4fc0d9c6, 0x496b153c, 0x4f1403fa, 0x541afb0c, 26 | 0x73990b32, 0x26d7cb1c, 0x6fcc3706, 0x2cbb77d8, 0x75762f2a, 0x6425ccdd, 27 | 0x24b35461, 0x0a7d8715, 0x220414a8, 0x141ebf67, 0x56b41583, 0x73e502e3, 28 | 0x44cab16f, 0x28264d42, 0x73baaefb, 0x0a50ebed, 0x1d6ab6fb, 0x0d3ad40b, 29 | 0x35db3b68, 0x2b081e83, 0x77ce6b95, 0x5181e5f0, 0x78853bbc, 0x009f9494, 30 | 0x27e5ed3c 31 | }; 32 | 33 | void VP8InitRandom(VP8Random* const rg, float dithering) { 34 | memcpy(rg->tab_, kRandomTable, sizeof(rg->tab_)); 35 | rg->index1_ = 0; 36 | rg->index2_ = 31; 37 | rg->amp_ = (dithering < 0.0) ? 0 38 | : (dithering > 1.0) ? (1 << VP8_RANDOM_DITHER_FIX) 39 | : (uint32_t)((1 << VP8_RANDOM_DITHER_FIX) * dithering); 40 | } 41 | 42 | //------------------------------------------------------------------------------ 43 | 44 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/utils/random.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Pseudo-random utilities 11 | // 12 | // Author: Skal (pascal.massimino@gmail.com) 13 | 14 | #ifndef WEBP_UTILS_RANDOM_H_ 15 | #define WEBP_UTILS_RANDOM_H_ 16 | 17 | #include 18 | #include "../webp/types.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define VP8_RANDOM_DITHER_FIX 8 // fixed-point precision for dithering 25 | #define VP8_RANDOM_TABLE_SIZE 55 26 | 27 | typedef struct { 28 | int index1_, index2_; 29 | uint32_t tab_[VP8_RANDOM_TABLE_SIZE]; 30 | int amp_; 31 | } VP8Random; 32 | 33 | // Initializes random generator with an amplitude 'dithering' in range [0..1]. 34 | void VP8InitRandom(VP8Random* const rg, float dithering); 35 | 36 | // Returns a centered pseudo-random number with 'num_bits' amplitude. 37 | // (uses D.Knuth's Difference-based random generator). 38 | // 'amp' is in VP8_RANDOM_DITHER_FIX fixed-point precision. 39 | static WEBP_INLINE int VP8RandomBits2(VP8Random* const rg, int num_bits, 40 | int amp) { 41 | int diff; 42 | assert(num_bits + VP8_RANDOM_DITHER_FIX <= 31); 43 | diff = rg->tab_[rg->index1_] - rg->tab_[rg->index2_]; 44 | if (diff < 0) diff += (1u << 31); 45 | rg->tab_[rg->index1_] = diff; 46 | if (++rg->index1_ == VP8_RANDOM_TABLE_SIZE) rg->index1_ = 0; 47 | if (++rg->index2_ == VP8_RANDOM_TABLE_SIZE) rg->index2_ = 0; 48 | // sign-extend, 0-center 49 | diff = (int)((uint32_t)diff << 1) >> (32 - num_bits); 50 | diff = (diff * amp) >> VP8_RANDOM_DITHER_FIX; // restrict range 51 | diff += 1 << (num_bits - 1); // shift back to 0.5-center 52 | return diff; 53 | } 54 | 55 | static WEBP_INLINE int VP8RandomBits(VP8Random* const rg, int num_bits) { 56 | return VP8RandomBits2(rg, num_bits, rg->amp_); 57 | } 58 | 59 | #ifdef __cplusplus 60 | } // extern "C" 61 | #endif 62 | 63 | #endif /* WEBP_UTILS_RANDOM_H_ */ 64 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/webp/mux_types.h: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Data-types common to the mux and demux libraries. 11 | // 12 | // Author: Urvang (urvang@google.com) 13 | 14 | #ifndef WEBP_WEBP_MUX_TYPES_H_ 15 | #define WEBP_WEBP_MUX_TYPES_H_ 16 | 17 | #include // free() 18 | #include // memset() 19 | #include "./types.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | // Note: forward declaring enumerations is not allowed in (strict) C and C++, 26 | // the types are left here for reference. 27 | // typedef enum WebPFeatureFlags WebPFeatureFlags; 28 | // typedef enum WebPMuxAnimDispose WebPMuxAnimDispose; 29 | // typedef enum WebPMuxAnimBlend WebPMuxAnimBlend; 30 | typedef struct WebPData WebPData; 31 | 32 | // VP8X Feature Flags. 33 | typedef enum WebPFeatureFlags { 34 | FRAGMENTS_FLAG = 0x00000001, 35 | ANIMATION_FLAG = 0x00000002, 36 | XMP_FLAG = 0x00000004, 37 | EXIF_FLAG = 0x00000008, 38 | ALPHA_FLAG = 0x00000010, 39 | ICCP_FLAG = 0x00000020 40 | } WebPFeatureFlags; 41 | 42 | // Dispose method (animation only). Indicates how the area used by the current 43 | // frame is to be treated before rendering the next frame on the canvas. 44 | typedef enum WebPMuxAnimDispose { 45 | WEBP_MUX_DISPOSE_NONE, // Do not dispose. 46 | WEBP_MUX_DISPOSE_BACKGROUND // Dispose to background color. 47 | } WebPMuxAnimDispose; 48 | 49 | // Blend operation (animation only). Indicates how transparent pixels of the 50 | // current frame are blended with those of the previous canvas. 51 | typedef enum WebPMuxAnimBlend { 52 | WEBP_MUX_BLEND, // Blend. 53 | WEBP_MUX_NO_BLEND // Do not blend. 54 | } WebPMuxAnimBlend; 55 | 56 | // Data type used to describe 'raw' data, e.g., chunk data 57 | // (ICC profile, metadata) and WebP compressed image data. 58 | struct WebPData { 59 | const uint8_t* bytes; 60 | size_t size; 61 | }; 62 | 63 | // Initializes the contents of the 'webp_data' object with default values. 64 | static WEBP_INLINE void WebPDataInit(WebPData* webp_data) { 65 | if (webp_data != NULL) { 66 | memset(webp_data, 0, sizeof(*webp_data)); 67 | } 68 | } 69 | 70 | // Clears the contents of the 'webp_data' object by calling free(). Does not 71 | // deallocate the object itself. 72 | static WEBP_INLINE void WebPDataClear(WebPData* webp_data) { 73 | if (webp_data != NULL) { 74 | free((void*)webp_data->bytes); 75 | WebPDataInit(webp_data); 76 | } 77 | } 78 | 79 | // Allocates necessary storage for 'dst' and copies the contents of 'src'. 80 | // Returns true on success. 81 | static WEBP_INLINE int WebPDataCopy(const WebPData* src, WebPData* dst) { 82 | if (src == NULL || dst == NULL) return 0; 83 | WebPDataInit(dst); 84 | if (src->bytes != NULL && src->size != 0) { 85 | dst->bytes = (uint8_t*)malloc(src->size); 86 | if (dst->bytes == NULL) return 0; 87 | memcpy((void*)dst->bytes, src->bytes, src->size); 88 | dst->size = src->size; 89 | } 90 | return 1; 91 | } 92 | 93 | #ifdef __cplusplus 94 | } // extern "C" 95 | #endif 96 | 97 | #endif /* WEBP_WEBP_MUX_TYPES_H_ */ 98 | -------------------------------------------------------------------------------- /webp-plugin/libwebp/src/webp/types.h: -------------------------------------------------------------------------------- 1 | // Copyright 2010 Google Inc. All Rights Reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license 4 | // that can be found in the COPYING file in the root of the source 5 | // tree. An additional intellectual property rights grant can be found 6 | // in the file PATENTS. All contributing project authors may 7 | // be found in the AUTHORS file in the root of the source tree. 8 | // ----------------------------------------------------------------------------- 9 | // 10 | // Common types 11 | // 12 | // Author: Skal (pascal.massimino@gmail.com) 13 | 14 | #ifndef WEBP_WEBP_TYPES_H_ 15 | #define WEBP_WEBP_TYPES_H_ 16 | 17 | #include // for size_t 18 | 19 | #ifndef _MSC_VER 20 | #include 21 | #if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \ 22 | (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) 23 | #define WEBP_INLINE inline 24 | #else 25 | #define WEBP_INLINE 26 | #endif 27 | #else 28 | typedef signed char int8_t; 29 | typedef unsigned char uint8_t; 30 | typedef signed short int16_t; 31 | typedef unsigned short uint16_t; 32 | typedef signed int int32_t; 33 | typedef unsigned int uint32_t; 34 | typedef unsigned long long int uint64_t; 35 | typedef long long int int64_t; 36 | #define WEBP_INLINE __forceinline 37 | #endif /* _MSC_VER */ 38 | 39 | #ifndef WEBP_EXTERN 40 | // This explicitly marks library functions and allows for changing the 41 | // signature for e.g., Windows DLL builds. 42 | #define WEBP_EXTERN(type) extern type 43 | #endif /* WEBP_EXTERN */ 44 | 45 | // Macro to check ABI compatibility (same major revision number) 46 | #define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8)) 47 | 48 | #endif /* WEBP_WEBP_TYPES_H_ */ 49 | -------------------------------------------------------------------------------- /webp-plugin/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2015 The Qt Company Ltd. 4 | ** Contact: http://www.qt.io/licensing/ 5 | ** 6 | ** This file is part of the WebP plugins in the Qt ImageFormats module. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL21$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and The Qt Company. For licensing terms 14 | ** and conditions see http://www.qt.io/terms-conditions. For further 15 | ** information use the contact form at http://www.qt.io/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 or version 3 as published by the Free 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the 22 | ** following information to ensure the GNU Lesser General Public License 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 25 | ** 26 | ** As a special exception, The Qt Company gives you certain additional 27 | ** rights. These rights are described in The Qt Company LGPL Exception 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 29 | ** 30 | ** $QT_END_LICENSE$ 31 | ** 32 | ****************************************************************************/ 33 | 34 | #include 35 | #include 36 | 37 | #ifndef QT_NO_IMAGEFORMATPLUGIN 38 | 39 | #ifdef QT_NO_IMAGEFORMAT_WEBP 40 | #undef QT_NO_IMAGEFORMAT_WEBP 41 | #endif 42 | #include "qwebphandler_p.h" 43 | 44 | #include 45 | #include 46 | 47 | QT_BEGIN_NAMESPACE 48 | 49 | class QWebpPlugin : public QImageIOPlugin 50 | { 51 | Q_OBJECT 52 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "webp.json") 53 | 54 | public: 55 | Capabilities capabilities(QIODevice *device, const QByteArray &format) const; 56 | QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const; 57 | }; 58 | 59 | QWebpPlugin::Capabilities QWebpPlugin::capabilities(QIODevice *device, const QByteArray &format) const 60 | { 61 | if (format == "webp") 62 | return Capabilities(CanRead | CanWrite); 63 | 64 | if (!format.isEmpty()) 65 | return 0; 66 | if (!device->isOpen()) 67 | return 0; 68 | 69 | Capabilities cap; 70 | if (device->isReadable() && QWebpHandler::canRead(device)) 71 | cap |= CanRead; 72 | if (device->isWritable()) 73 | cap |= CanWrite; 74 | 75 | return cap; 76 | } 77 | 78 | QImageIOHandler *QWebpPlugin::create(QIODevice *device, const QByteArray &format) const 79 | { 80 | QImageIOHandler *handler = new QWebpHandler; 81 | handler->setDevice(device); 82 | handler->setFormat(format); 83 | return handler; 84 | } 85 | 86 | QT_END_NAMESPACE 87 | 88 | #include "main.moc" 89 | 90 | #endif // !QT_NO_IMAGEFORMATPLUGIN 91 | -------------------------------------------------------------------------------- /webp-plugin/qwebphandler_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2015 The Qt Company Ltd. 4 | ** Contact: http://www.qt.io/licensing/ 5 | ** 6 | ** This file is part of the WebP plugins in the Qt ImageFormats module. 7 | ** 8 | ** $QT_BEGIN_LICENSE:LGPL21$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and The Qt Company. For licensing terms 14 | ** and conditions see http://www.qt.io/terms-conditions. For further 15 | ** information use the contact form at http://www.qt.io/contact-us. 16 | ** 17 | ** GNU Lesser General Public License Usage 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser 19 | ** General Public License version 2.1 or version 3 as published by the Free 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the 22 | ** following information to ensure the GNU Lesser General Public License 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 25 | ** 26 | ** As a special exception, The Qt Company gives you certain additional 27 | ** rights. These rights are described in The Qt Company LGPL Exception 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 29 | ** 30 | ** $QT_END_LICENSE$ 31 | ** 32 | ****************************************************************************/ 33 | 34 | #ifndef QWEBPHANDLER_P_H 35 | #define QWEBPHANDLER_P_H 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #include "webp/decode.h" 42 | 43 | class QWebpHandler : public QImageIOHandler 44 | { 45 | public: 46 | QWebpHandler(); 47 | ~QWebpHandler() {} 48 | 49 | public: 50 | QByteArray name() const; 51 | 52 | bool canRead() const; 53 | bool read(QImage *image); 54 | 55 | static bool canRead(QIODevice *device); 56 | 57 | bool write(const QImage &image); 58 | QVariant option(ImageOption option) const; 59 | void setOption(ImageOption option, const QVariant &value); 60 | bool supportsOption(ImageOption option) const; 61 | 62 | private: 63 | bool ensureScanned() const; 64 | 65 | private: 66 | enum ScanState { 67 | ScanError = -1, 68 | ScanNotScanned = 0, 69 | ScanSuccess = 1, 70 | }; 71 | 72 | bool m_lossless; 73 | int m_quality; 74 | mutable ScanState m_scanState; 75 | WebPBitstreamFeatures m_features; 76 | }; 77 | 78 | #endif // WEBPHANDLER_H 79 | -------------------------------------------------------------------------------- /webp-plugin/webp.json: -------------------------------------------------------------------------------- 1 | { 2 | "Keys": [ "webp" ], 3 | "MimeTypes": [ "image/webp" ] 4 | } 5 | -------------------------------------------------------------------------------- /webp-plugin/webp.pro: -------------------------------------------------------------------------------- 1 | TARGET = qwebp 2 | 3 | PLUGIN_TYPE = imageformats 4 | PLUGIN_CLASS_NAME = QWebpPlugin 5 | load(qt_plugin) 6 | 7 | CONFIG -= import_plugins 8 | HEADERS += qwebphandler_p.h 9 | SOURCES += main.cpp qwebphandler.cpp 10 | OTHER_FILES += webp.json 11 | 12 | config_libwebp { 13 | unix|win32-g++*: LIBS += -lwebp 14 | else:win32: LIBS += libwebp.lib 15 | } else { 16 | include($$PWD/libwebp.pri) 17 | } 18 | 19 | INSTALLS = # None 20 | --------------------------------------------------------------------------------