Telegram Connection Manager — GSoC 2014 task overview


My name is Alexandr Akulich and this year I’m accepted for GSoC 2014 to work on Qt-based Telegram Connection Manager for KDE Telepathy.
In this post I’ll tell you about my goals and let you know, what is already done.

Creation of Qt-based Telegram CM for KDE Telepathy is a task, that requires work throughout the entire stack, so I split task into three smaller and easier to handle.
Only small high-level part will depend on KDE, while most of that stack is shared between several operation systems and desktop environments, so it will work for Jolla, Empathy, Ubuntu’s IM client and any other software, powered by Telepathy.

On lower level, I decide to develop some core library, named libTelegramQt. This library will transparently do all low-level tasks (establish connection to Telegram server, handle data centers, do all cryptographic and RPC stuff) and provide convenient API for messaging, files transferring, contact-list operations and other actions.

On medium level, I have to implement connection manager itself. This sub-task is complicated due to lack of TelepathyQt Service bindings operability and documentation. For our luck, there is a branch with all needed stuff. With big support from my fantastic, excellent and irreplaceable mentor, David Edmundson, this branch is going to be tested and merged into master.

On high level, there will be plugin for KDE Telepathy, which will provide Telegram accounts setup. This task have need some trick, because Telegram requires confirmation code to be obtaining via SMS. My plan is to provide DBus method (like “send auth code to <phone number>”) in Connection Manager and to invoke it from KDE Control Module.

What is done by now:
Implemented supporting app to generate enum with Telegram Schema constants.
Implemented authorization key creation. It means, that library is able to talk with server in Diffie-Hellman encrypted session to get it’s secret numbers to turn on primary AES encryption. (passed all this stuff)
As next step, implemented package’s AES encryption/decryption with control sums checking. To test that thing, implemented Data Centers configuration obtaining, but that config is not used yet.

To be able to rely on quality of the library and to simplify refactor and porting to new platforms, I implemented automatic tests, which already saved me few hours of manual testing.
As means to test the library in real action, I created small application that connects to the server, passes authentication and gets the DC Config.

Telegram Qt TestApp

My next steps are to implement DC configuration usage, send acknowledgment packages and, finally, to send request for SMS with confirmation code.

Thank you for reading and stay tuned to know about Telegram Connection Manager progress.

Links: telegram-qt repository

Tagged with: , , , ,
Posted in Uncategorized
28 comments on “Telegram Connection Manager — GSoC 2014 task overview
  1. Aleix Pol says:

    Looking forward to it, keep rocking! 🙂

  2. bartotten says:

    Please notice that there is an app for android that can send notifications to KDE. Maybe you can receive the verification code too. Would be awesome integration 😉

    • Kaffeine says:

      Yeah! That was my secret plan 🙂
      In my opinion, integration is one of the key features of KDE Telepathy. I’ll do my best in that direction.

  3. afiestas says:

    Wow! this is really awesome!

  4. […] of Code de este año, y su proyecto trata de lo comentado, integrar Telegram en KDE Telepathy. En su blog da más datos sobre lo que ya está hecho y sobre lo que queda por hacer. Y queda. Pero está bien […]

  5. […] La info más extendida en el blog oficial de la aplicación: Telegram […]

  6. […] más información os remito al blog del estudiante donde se pone a nuestra disposición los planes de Alexandr y el repositorio de […]

  7. Follower says:

    Good Job! Continue Please!

  8. murlidhar says:

    is it not being developed anymore? hopefully the development hasn’t stopped. very eager to try it out 🙂

  9. Kaffeine says:

    It’s almost not developed since end of the August.
    Right now telegram-qt library and telepathy-morse are capable to get contact list and to send and receive chat messages. There is proper delivery-reports and typing status. TelegramQt also support avatars, user registration and some kind of group chat (it’s able to create chat and to send/receive messages, but can’t show list of active chats).
    Both repositories are now moved to KDE Playground, so latest versions available at and
    Both compatible with Qt4 and Qt5.

    I have little to no time for this project, but I didn’t lost my interest, so I will come back as soon as possible.

    Next thing to be done is offline messages receiving. Actually, I implemented it, but accidentally lost that code. Now it’s in WIP state with 70% done.

  10. Yehiel says:

    Thanks for the update. could not build it using qt4, it requires qt5…

    • Kaffeine says:

      Did you specify build type with “-DUSE_QT4=true” cmake option? Both Qt4 and Qt5 works (for me) with both TelegramQt and Telepathy-Morse projects. Even more, it’s possible to install both versions of TelegramQt without files collision.

  11. Alberto says:

    Thanks for all the work! I have a small problem though. I compiled telegram-qt and telepathy-morse, and surely I get a new option ‘telegram’ in the telepathy account manager. I insert my phone number under ‘Account’ but when I confirm “connecting” appears briefly and then nothing happens. Am I doing something wrong? Thanks again!

    • Kaffeine says:

      Did you installed morse? Telepathy tries to run connection manager, but it needs to know application location. You can try to manually run telepathy-morse before telegram usage. By the way, what is your distro and DE? I have ebuilds for Gentoo, but no packages for other distributions.

      • Alberto says:

        Yes, when I create the account a new process ‘telepathy-morse’ appears, so I think it is instanned correctly. My distribution is Kubuntu (KDE 4.13)

      • Alberto says:

        If it’s useful, I tried running telepathy-morse from the command line and creating the account. Here’s the output:

        $ ./telepathy-morse
        MorseProtocol::MorseProtocol(const QDBusConnection&, const QString&)
        tp-qt 0.9.5 DEBUG: Interface “org.freedesktop.Telepathy.Protocol.Interface.Addressing” plugged
        tp-qt 0.9.5 DEBUG: Interface “org.freedesktop.Telepathy.Protocol.Interface.Presence” plugged
        tp-qt 0.9.5 DEBUG: Protocol “telegram” added to CM
        tp-qt 0.9.5 DEBUG: Registering protocol “telegram” at path “/org/freedesktop/Telepathy/ConnectionManager/morse/telegram” for CM “/org/freedesktop/Telepathy/ConnectionManager/morse” at bus name “org.freedesktop.Telepathy.ConnectionManager.morse”
        tp-qt 0.9.5 DEBUG: Registered object “/org/freedesktop/Telepathy/ConnectionManager/morse/telegram” at bus name “org.freedesktop.Telepathy.ConnectionManager.morse”
        tp-qt 0.9.5 DEBUG: Registering CM “/org/freedesktop/Telepathy/ConnectionManager/morse” at bus name “org.freedesktop.Telepathy.ConnectionManager.morse”
        tp-qt 0.9.5 DEBUG: Registered object “/org/freedesktop/Telepathy/ConnectionManager/morse” at bus name “org.freedesktop.Telepathy.ConnectionManager.morse”
        Tp::BaseConnectionPtr MorseProtocol::createConnection(const QVariantMap&, Tp::DBusError*) QMap((“account”, QVariant(QString, “+39xxxxxxxxxx”) ) )
        Object::connect: No such signal Tp::BaseConnection::Adaptee::selfContactChanged(uint, const QString&) in /build/buildd/telepathy-qt-0.9.5+dfsg/obj-x86_64-linux-gnu/TelepathyQt/_gen/svc-connection.cpp:17
        MorseConnection::MorseConnection(const QDBusConnection&, const QString&, const QString&, const QVariantMap&)
        tp-qt 0.9.5 DEBUG: Interface “org.freedesktop.Telepathy.Connection.Interface.Contacts” plugged
        tp-qt 0.9.5 DEBUG: Interface “org.freedesktop.Telepathy.Connection.Interface.SimplePresence” plugged
        tp-qt 0.9.5 DEBUG: Interface “org.freedesktop.Telepathy.Connection.Interface.ContactList” plugged
        tp-qt 0.9.5 DEBUG: Interface “org.freedesktop.Telepathy.Connection.Interface.Aliasing” plugged
        tp-qt 0.9.5 DEBUG: Interface “org.freedesktop.Telepathy.Connection.Interface.Requests” plugged
        uint MorseConnection::addContact(const QString&)
        uint MorseConnection::addContacts(const QStringList&) (“+39xxxxxxxxxx”)
        void MorseConnection::updateContactsState(const QStringList&)
        void MorseConnection::setSubscriptionState(const QStringList&, const QList&, uint)
        tp-qt 0.9.5 DEBUG: cmName: “morse” escapedProtocolName: “telegram” name: “connection_2363680”
        tp-qt 0.9.5 DEBUG: busName: “org.freedesktop.Telepathy.Connection.morse.telegram.connection_2363680” objectName: “/org/freedesktop/Telepathy/Connection/morse/telegram/connection_2363680”
        tp-qt 0.9.5 DEBUG: Connection: registering interfaces at Tp::DBusObject(0x2362810)
        Object::connect: No such signal Tp::BaseConnectionContactListInterface::Adaptee::contactsChanged(const Tp::ContactSubscriptionMap&, const Tp::UIntList&) in /build/buildd/telepathy-qt-0.9.5+dfsg/obj-x86_64-linux-gnu/TelepathyQt/_gen/svc-connection.cpp:959
        tp-qt 0.9.5 DEBUG: Registered object “/org/freedesktop/Telepathy/Connection/morse/telegram/connection_2363680” at bus name “org.freedesktop.Telepathy.Connection.morse.telegram.connection_2363680”
        tp-qt 0.9.5 DEBUG: BaseConnection::status = 2 MorseConnection(0x2363680)
        uint MorseConnection::setPresence(const QString&, const QString&, Tp::DBusError*) “available”
        tp-qt 0.9.5 DEBUG: BaseConnectionRequestsInterface::requestableChannelClasses
        tp-qt 0.9.5 DEBUG: BaseConnection::setStatus 1 1 MorseConnection(0x2363680)
        New active dc: 0
        tp-qt 0.9.5 DEBUG: BaseConnection::status = 1 MorseConnection(0x2363680)
        tp-qt 0.9.5 DEBUG: BaseConnectionRequestsInterface::requestableChannelClasses
        tp-qt 0.9.5 DEBUG: BaseConnection::status = 1 MorseConnection(0x2363680)
        tp-qt 0.9.5 DEBUG: BaseConnectionRequestsInterface::requestableChannelClasses
        tp-qt 0.9.5 DEBUG: BaseConnection::status = 1 MorseConnection(0x2363680)
        tp-qt 0.9.5 DEBUG: BaseConnectionRequestsInterface::requestableChannelClasses
        NAS: 1
        NAS: 2
        NAS: 3
        NAS: 4
        New active dc: 0

        After this nothing more happens, and the ui remains on “connecting”

      • Kaffeine says:

        Oh, you’re right. I wiped data, recreated account and now It doesn’t work for me too. It’s regression. I’ll fix it ASAP (today).

  12. Kaffeine says:

    Today I took a time to work on Telegram.
    I fixed number of bugs:
    1) Regression that leads to impossibility of authentication with confirmation code.
    2) Regression with contacts onliness.
    3) Fixed several memory-cleanup issues. Implemented missed destructors, etc.
    Implemented several important (or not) things:
    1) Implemented skipping of read offline messages (so now you’ll receive only unread messages).
    2) Implemented fall-back for auth with invalid session data. (Session data may be invalid due to bug (e.g. after bug #1) or because of auth.resetAuthorizations call).
    3) Mostly implemented phone-numbers masking for debug messages. (Now output will looks like 55xxxxxxxx).

    Big thanks to Alberto for poking me. 🙂

  13. Yajo says:

    One doubt: if the core library depends on Qt, wouldn’t that be a problem for GTK desktops to use it? Shouldn’t the Qt dependencies be only for the GUI layer?

    • Kaffeine says:

      There is absolutely no technical troubles on use TelepathyMorse on any desktop environment, as all interations between telepathy clients and services occurs via DBus interfaces.
      Nowadays most of telepathy connection managers uses GNOME GLib library and that is not a problem for “Qt desktops”.
      TelegramQt library depends only on QtCore and QtNetwork modules. TelepathyMorse directly depends on QtCore, QtDBus and have inherited dependencies on QtXml (because of DBus) and QtNetwork.
      So, there is no any kind of dependency on any of those “Widgets”, “QML” or other GUI-related things.

  14. TemeV says:


    Great work with this.

    Only problem I’ve had so far (in addition to all the missing features) is that it requests the code everytime I go online. I managed to fix it by adding
    if (newState == CTelegramConnection::AuthStateSignedIn) {
    to the end of the method CTelegramDispatcher::whenConnectionAuthChanged. I’m not sure if this is the right way, but at least it seems to be working.

  15. Steven Haigh says:

    I’m wondering what the status of this is – and how it can be submitted into something that can actually be distributed. It would seem to be a waste of time to have this bitrot away….

    • Kaffeine says:

      Sadly, I have no time to fix a release-blocker issue, but the release is definitely “almost here”. May be next week, may be next month. Definitely (99%) this summer.

      Did you read another post with a status update? (

      Since then, I implemented basic group chat support. It works well with KDE Telepathy, but somewhy it doesn’t work with Empathy and this is the issue. I didn’t find anything noticeable in DBus logs and drowned in Empathy code.

      By the way, I released TelepathyQt-0.9.6 with all required stuff, so now Telepathy-Morse doesn’t depend on custom TelepathyQt build. I think, I have to ask Empathy developers for help.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: