예제 #1
0
void MorseConnection::doConnect(Tp::DBusError *error)
{
    Q_UNUSED(error);

    CAppInformation appInfo;
    appInfo.setAppId(14617);
    appInfo.setAppHash(QLatin1String("e17ac360fd072f83d5d08db45ce9a121"));
    appInfo.setAppVersion(QLatin1String("0.1"));
    appInfo.setDeviceInfo(QLatin1String("pc"));
    appInfo.setOsInfo(QLatin1String("GNU/Linux"));
    appInfo.setLanguageCode(QLatin1String("en"));

    m_authReconnectionsCount = 0;
    m_core = new CTelegramCore(0);
    m_core->setPingInterval(m_keepaliveInterval * 1000);
    m_core->setAppInformation(&appInfo);
    m_core->setMessageReceivingFilterFlags(TelegramNamespace::MessageFlagOut|TelegramNamespace::MessageFlagRead);
    m_core->setAcceptableMessageTypes(TelegramNamespace::MessageTypeText);

    setStatus(Tp::ConnectionStatusConnecting, Tp::ConnectionStatusReasonNoneSpecified);

    connect(m_core, SIGNAL(connectionStateChanged(TelegramNamespace::ConnectionState)),
            this, SLOT(whenConnectionStateChanged(TelegramNamespace::ConnectionState)));
    connect(m_core, SIGNAL(authorizationErrorReceived()),
            this, SLOT(whenAuthErrorReceived()));
    connect(m_core, SIGNAL(phoneCodeRequired()),
            this, SLOT(whenPhoneCodeRequired()));
    connect(m_core, SIGNAL(authSignErrorReceived(TelegramNamespace::AuthSignError,QString)),
            this, SLOT(whenAuthSignErrorReceived(TelegramNamespace::AuthSignError,QString)));
    connect(m_core, SIGNAL(avatarReceived(QString,QByteArray,QString,QString)),
            this, SLOT(whenAvatarReceived(QString,QByteArray,QString,QString)));
    connect(m_core, SIGNAL(contactListChanged()),
            this, SLOT(whenContactListChanged()));
    connect(m_core, SIGNAL(messageReceived(QString,QString,TelegramNamespace::MessageType,quint32,quint32,quint32)),
            this, SLOT(whenMessageReceived(QString,QString,TelegramNamespace::MessageType,quint32,quint32,quint32)));
    connect(m_core, SIGNAL(chatMessageReceived(quint32,QString,QString,TelegramNamespace::MessageType,quint32,quint32,quint32)),
            this, SLOT(whenChatMessageReceived(quint32,QString,QString,TelegramNamespace::MessageType,quint32,quint32,quint32)));
    connect(m_core, SIGNAL(chatChanged(quint32)),
            this, SLOT(whenChatChanged(quint32)));
    connect(m_core, SIGNAL(contactStatusChanged(QString,TelegramNamespace::ContactStatus)),
            this, SLOT(updateContactPresence(QString)));

    const QByteArray sessionData = getSessionData(m_selfPhone);

    if (sessionData.isEmpty()) {
        qDebug() << "init connection...";
        m_core->initConnection(QLatin1String("149.154.175.50"), 443);
    } else {
        qDebug() << "restore connection...";
        m_core->restoreConnection(sessionData);
    }
}
예제 #2
0
void ContactModel::addBot(MAGNORMOBOT *bot)
{
	if (conduits.contains(bot)) {
		qWarning("ContactModel is already tracking %p\n", bot);
		return;
	}
	connect(bot, SIGNAL(contactPresenceUpdated(QString)), SLOT(updateContactPresence(QString)));
    connect(bot, SIGNAL(contactAdded(QString)), SLOT(addContact(QString)));
    connect(bot, SIGNAL(contactUpdated(QString)), SLOT(updateContact(QString)));
    connect(bot, SIGNAL(contactRemoved(QString)), SLOT(removeContact(QString)));
	connect(bot, SIGNAL(contactListReceived()), SLOT(receiveContactList()));
	connect(bot, SIGNAL(disconnected()), SLOT(botDisconnected()), Qt::QueuedConnection);
	connect(bot, SIGNAL(destroyed()), SLOT(botDestroyed()));
    refreshContacts(bot);
}