void SipHandler::hookUpPlugin( SipPlugin* sip ) { QObject::connect( sip, SIGNAL( peerOnline( QString ) ), SLOT( onPeerOnline( QString ) ) ); QObject::connect( sip, SIGNAL( peerOffline( QString ) ), SLOT( onPeerOffline( QString ) ) ); QObject::connect( sip, SIGNAL( msgReceived( QString, QString ) ), SLOT( onMessage( QString, QString ) ) ); QObject::connect( sip, SIGNAL( sipInfoReceived( QString, SipInfo ) ), SLOT( onSipInfo( QString, SipInfo ) ) ); QObject::connect( sip, SIGNAL( softwareVersionReceived( QString, QString ) ), SLOT( onSoftwareVersion( QString, QString ) ) ); QObject::connect( sip, SIGNAL( avatarReceived( QString, QPixmap ) ), SLOT( onAvatarReceived( QString, QPixmap ) ) ); QObject::connect( sip, SIGNAL( avatarReceived( QPixmap ) ), SLOT( onAvatarReceived( QPixmap ) ) ); QObject::connect( sip->account(), SIGNAL( configurationChanged() ), sip, SLOT( configurationChanged() ) ); }
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); } }
void tlen::event(const QDomNode &n) { kdebugf(); QString nodeName=n.nodeName(); QDomElement element = n.toElement(); if(nodeName=="s" && element.hasAttribute("i")) { ping->start( 50000 ); sid = element.attribute("i"); if(tlenLogin()) state = tlen::Connected; else socket->close(); // TODO: Dont close connection and repeat login, after n times disconnect, signal } else if(nodeName=="iq") { if(element.hasAttribute( "type" ) && element.attribute("type") == "result") { // tcfg if(element.hasAttribute("id") && element.attribute("id")==sid) { tcfgRequest(); rosterRequest(); } if(element.hasAttribute("from") && element.attribute("from")=="tuba" && element.hasAttribute("id")){ // <iq from="tuba" type="result" to="jid" id="tr"> // <query xmlns="jabber:iq:register"> // <item></item></query></iq> if(element.attribute("id")=="tr") { QDomElement query = element.elementsByTagName("query").item(0).toElement(); //if (query.hasAttribute("xmlns") && element.attribute("xmlns")=="jabber:iq:register") emit pubdirReceived(query.childNodes()); return; } if(element.attribute("id")=="tw") { //if (query.hasAttribute("xmlns") && element.attribute("xmlns")=="jabber:iq:register") // TODO implement unsuccess if timeout emit pubdirUpdated(true); return; } } if(element.hasAttribute("id") && element.attribute("id")=="GetRoster") { emit clearRosterView(); } if(element.hasAttribute("from") && element.attribute("from") == "tcfg") { tcfgReceived(element); return; } if(n.hasChildNodes()) { QDomNodeList el=n.childNodes(); for(int i=0;i<el.count();++i) emit eventReceived(el.item(i)); } if(0) { emit tlenLoggedIn(); } } else if(element.hasAttribute("type") && element.attribute("type") == "set") { if(n.hasChildNodes()) { QDomNodeList el=n.childNodes(); for(int i=0;i<el.count();++i) emit eventReceived(el.item(i)); } } } else if(nodeName=="query") { QDomElement e=n.toElement(); QDomNodeList nl=n.childNodes(); for(int i=0;i<nl.count();++i) event(nl.item(i)); } else if(nodeName=="item") { QDomElement e=n.toElement(); QString jid=decode(e.attribute("jid")); QString subscription=e.attribute("subscription"); QString name=NULL, group=NULL; if(subscription=="remove") { emit removeItem(jid); return; } if(e.hasAttribute("ask")) subscription=e.attribute("ask"); if(e.hasAttribute("name")) name=e.attribute("name"); else name=jid; if( n.hasChildNodes() ) { QDomNodeList nl=n.childNodes(); for(int i=0;i<nl.count();++i) { group=nl.item(i).firstChild().toText().data(); } } if(group.isEmpty()) group=tr("Contacts"); group=decode(group.toUtf8()); name=decode(name.toUtf8()); emit itemReceived(jid, name, subscription, group); } else if(nodeName=="presence") { QDomElement e=n.toElement(); QString from=decode(e.attribute("from")); if(e.hasAttribute("type") && e.attribute("type")=="subscribe") { emit authorizationAsk(from); } else if( e.hasAttribute("type") && e.attribute("type")=="subscribed" ) return; else if(e.hasAttribute("type") && (e.attribute("type")=="unsubscribe" || e.attribute("type")=="unsubscribed")) return; else { QString status="none"; QString descr=""; if(e.hasAttribute("type")) status=e.attribute("type"); QDomNodeList l=n.childNodes(); for(int i=0; i<l.count(); ++i) { if(l.item(i).nodeName()=="show" && status=="none") status=l.item(i).firstChild().toText().data(); if(l.item(i).nodeName()=="status") descr=l.item(i).firstChild().toText().data(); if(l.item(i).nodeName()=="avatar") { // TODO store jid,type,md5 on list/qmultimap, check md5 - avatar changed QDomElement avatar = l.item(i).toElement().elementsByTagName("a").item(0).toElement(); if (avatar.hasAttribute("type") && avatar.hasAttribute("md5")) { emit avatarReceived(decode(from), avatar.attribute("type"), avatar.attribute("md5")); qDebug() << "Avatar " << from << "type:" <<avatar.attribute("type") << "md5:" << avatar.attribute("md5"); } } } descr=decode(descr.toUtf8()); emit presenceChanged(from,status,descr); } } else if(nodeName=="message") { QDomElement e=n.toElement(); if(e.hasAttribute("type") && e.attribute("type")=="chat") emit chatMsgReceived(n); } else if(nodeName=="m") { QDomElement e=n.toElement(); if(e.hasAttribute("tp")) { emit chatNotify(decode(e.attribute("f")), e.attribute("tp")); } } else if(nodeName=="n") { //<n f='Rainer+Wiesenfarth+%[email protected]%3E' s='Re%3A+qt+and+mysql,+odbc'/> - new mail } else if(nodeName=="avatar") { // search for token QDomElement e=n.toElement(); QDomNodeList l=n.childNodes(); for(int i=0; i<l.count(); ++i) if(l.item(i).nodeName()=="token") token=l.item(i).firstChild().toText().data(); } else if(nodeName=="f") { QDomElement e=n.toElement(); if(e.attribute("e")=="1") { //fileIncomingDialog *dlg=new fileIncomingDialog(n); //connect(dlg, SIGNAL(receive(QString,QString,bool)), this, SLOT(receiveFile(QString,QString,bool))); //dlg->show(); } else if(e.attribute("e")=="5") { //if( fileTransferDialog *dlg = fTransferMap.value( QString("%1-%2").arg( e.attribute("f") ).arg( e.attribute("i") ) ) ) // dlg->fileThread()->transferingAccepted(); } else if(e.attribute("e")=="6") { //fileTransferDialog *dlg=new fileTransferDialog( e.attribute("i").toInt(), e.attribute("f"), e.attribute("a"), (quint16)e.attribute("p").toInt(), TRUE); //fTransferMap.insert(QString("%1-%2").arg( e.attribute("f") ).arg( e.attribute("i") ), dlg); //dlg->show(); } else if(e.attribute("e")=="7") { //if( fileTransferDialog *dlg = fTransferMap.value( QString("%1-%2").arg( e.attribute("f") ).arg( e.attribute("i") ) ) ) // dlg->fileThread()->switchToSocketMode( e.attribute("a"), (quint16)e.attribute("p").toInt() ); } } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_contactsModel(new CContactsModel(this)), m_messagingModel(new CMessagingModel(this)), m_chatContactsModel(new CContactsModel(this)), m_chatMessagingModel(new CMessagingModel(this)), m_chatInfoModel(new CChatInfoModel(this)), m_activeChatId(0), m_chatCreationMode(false), m_core(new CTelegramCore(this)), m_registered(false), m_appState(AppStateNone) { ui->setupUi(this); ui->contactListTable->setModel(m_contactsModel); ui->messagingView->setModel(m_messagingModel); ui->groupChatContacts->setModel(m_chatContactsModel); ui->groupChatChatsList->setModel(m_chatInfoModel); ui->groupChatMessagingView->setModel(m_chatMessagingModel); QCompleter *comp = new QCompleter(m_contactsModel, this); ui->messagingContactPhone->setCompleter(comp); ui->groupChatContactPhone->setCompleter(comp); connect(ui->secretOpenFile, SIGNAL(clicked()), SLOT(loadSecretFromBrowsedFile())); // Telepathy Morse app info 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_core->setAppInformation(&appInfo); m_core->setAutoReconnection(true); connect(m_core, SIGNAL(connectionStateChanged(TelegramNamespace::ConnectionState)), SLOT(whenConnectionStateChanged(TelegramNamespace::ConnectionState))); connect(m_core, SIGNAL(phoneStatusReceived(QString,bool,bool)), SLOT(whenPhoneStatusReceived(QString,bool,bool))); connect(m_core, SIGNAL(phoneCodeRequired()), SLOT(whenPhoneCodeRequested())); connect(m_core, SIGNAL(authSignErrorReceived(TelegramNamespace::AuthSignError,QString)), SLOT(whenAuthSignErrorReceived(TelegramNamespace::AuthSignError,QString))); connect(m_core, SIGNAL(contactListChanged()), SLOT(whenContactListChanged())); connect(m_core, SIGNAL(contactProfileChanged(QString)), SLOT(whenContactProfileChanged(QString))); connect(m_core, SIGNAL(avatarReceived(QString,QByteArray,QString,QString)), SLOT(whenAvatarReceived(QString,QByteArray,QString))); connect(m_core, SIGNAL(messageMediaDataReceived(QString,quint32,QByteArray,QString,TelegramNamespace::MessageType,quint32,quint32)), SLOT(whenMessageMediaDataReceived(QString,quint32,QByteArray,QString,TelegramNamespace::MessageType,quint32,quint32))); connect(m_core, SIGNAL(messageReceived(TelegramNamespace::Message)), SLOT(whenMessageReceived(TelegramNamespace::Message))); connect(m_core, SIGNAL(contactChatTypingStatusChanged(quint32,QString,bool)), SLOT(whenContactChatTypingStatusChanged(quint32,QString,bool))); connect(m_core, SIGNAL(contactTypingStatusChanged(QString,bool)), SLOT(whenContactTypingStatusChanged(QString,bool))); connect(m_core, SIGNAL(contactStatusChanged(QString,TelegramNamespace::ContactStatus)), SLOT(whenContactStatusChanged(QString))); connect(m_core, SIGNAL(sentMessageStatusChanged(QString,quint64,TelegramNamespace::MessageDeliveryStatus)), m_messagingModel, SLOT(setMessageDeliveryStatus(QString,quint64,TelegramNamespace::MessageDeliveryStatus))); connect(m_core, SIGNAL(uploadingStatusUpdated(quint32,quint32,quint32)), SLOT(whenUploadingStatusUpdated(quint32,quint32,quint32))); connect(m_core, SIGNAL(chatAdded(quint32)), SLOT(whenChatAdded(quint32))); connect(m_core, SIGNAL(chatChanged(quint32)), SLOT(whenChatChanged(quint32))); ui->groupChatContacts->hideColumn(CContactsModel::Blocked); ui->mainSplitter->setSizes(QList<int>() << 0 << 100); ui->groupChatSplitter->setSizes(QList<int>() << 550 << 450 << 300); ui->groupChatChatsList->setColumnWidth(CChatInfoModel::Id, 30); ui->blockContact->hide(); ui->unblockContact->hide(); ui->groupChatLeaveChat->hide(); QFile helpFile(QLatin1String(":/USAGE")); helpFile.open(QIODevice::ReadOnly); ui->helpView->setPlainText(helpFile.readAll()); setAppState(AppStateNone); updateGroupChatAddContactButtonText(); connect(ui->groupChatContactPhone, SIGNAL(textChanged(QString)), SLOT(updateGroupChatAddContactButtonText())); #if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) connect(ui->messagingView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(whenCustomMenuRequested(QPoint))); #endif ui->groupChatAddContactForwardMessages->hide(); ui->messagingAttachButton->hide(); }