void statusWidget::presenceMenuTriggered() { QString icon = "green"; QAction* action = qobject_cast<QAction*>(sender()); if(action == actionAvailable) { emit presenceTypeChanged(QXmppPresence::Available); icon = "green"; } else if(action == actionBusy) { emit presenceStatusTypeChanged(QXmppPresence::DND); icon = "red"; } else if(action == actionAway) { emit presenceStatusTypeChanged(QXmppPresence::Away); icon = "orange"; } #if 0 else if(action == actionInvisible) { emit presenceStatusTypeChanged(QXmppPresence::Invisible); icon = "gray"; } #endif else if(action == actionSign_out) { emit presenceTypeChanged(QXmppPresence::Unavailable); icon = "gray"; } label->setPixmap(QPixmap(":/icons/resource/"+icon+".png")); }
Xmpp_client::Xmpp_client(QString a_login, QString a_password, int a_xmpp_client_port, QObject *parent) : m_login(a_login), m_password(a_password), m_xmpp_client_port(a_xmpp_client_port), QXmppClient(parent) { bool check; Q_UNUSED(check); m_capabilitiesCache = new capabilitiesCache(this); m_vCardCache = new vCardCache(this); qDebug() << "Xmpp_client::Xmpp_client !!!"; QXmppLogger::getLogger()->setLoggingType(QXmppLogger::SignalLogging); transfer_manager = new QXmppTransferManager; this->addExtension (transfer_manager); // uncomment one of the following if you only want to use a specific transfer method: // //transfer_manager->setSupportedMethods(QXmppTransferJob::InBandMethod); // manager->setSupportedMethods(QXmppTransferJob::SocksMethod); transfer_manager->setProxy("proxy.nodecast.net"); transfer_manager->setSupportedMethods(QXmppTransferJob::InBandMethod); muc_manager = new QXmppMucManager; this->addExtension(muc_manager); check = connect(&this->rosterManager(), SIGNAL(rosterReceived()), this, SLOT(rosterReceived())); Q_ASSERT(check); check = connect(&this->rosterManager(), SIGNAL(itemChanged(QString)), this, SLOT(rosterChanged(QString))); Q_ASSERT(check); check = connect(&this->rosterManager(), SIGNAL(presenceChanged(QString,QString)), this, SLOT(presenceChanged(QString,QString))); Q_ASSERT(check); check = connect(this, SIGNAL(messageReceived(const QXmppMessage&)), SLOT(messageReceived(const QXmppMessage&))); Q_ASSERT(check); Q_UNUSED(check); check = connect(this, SIGNAL(presenceReceived(const QXmppPresence&)), SLOT(presenceReceived(const QXmppPresence&))); check = connect(this, SIGNAL(connected()), SLOT(updateStatusWidget())); Q_ASSERT(check); // check = connect(&m_xmppClient, SIGNAL(connected()), SLOT(addAccountToCache())); // Q_ASSERT(check); check = connect(this, SIGNAL(connected()), SLOT(connectedToServer())); Q_ASSERT(check); check = connect(this, SIGNAL(disconnected()), SLOT(disconnectedToServer())); Q_ASSERT(check); check = connect(this, SIGNAL(error(QXmppClient::Error)), SLOT(connectedError())); Q_ASSERT(check); check = connect(transfer_manager, SIGNAL(fileReceived(QXmppTransferJob*)), SLOT(file_received(QXmppTransferJob*))); Q_ASSERT(check); check = connect(transfer_manager, SIGNAL(jobFinished(QXmppTransferJob*)), SLOT(job_finished(QXmppTransferJob*))); Q_ASSERT(check); check = connect(&this->vCardManager(), SIGNAL(vCardReceived(QXmppVCardIq)), m_vCardCache, SLOT(vCardReceived(QXmppVCardIq))); Q_ASSERT(check); check = connect(m_vCardCache, SIGNAL(vCardReadyToUse(QString)), SLOT(updateVCard(QString))); Q_ASSERT(check); check = connect(QXmppLogger::getLogger(), SIGNAL(message(QXmppLogger::MessageType,QString)), &m_consoleDlg, SLOT(message(QXmppLogger::MessageType,QString))); Q_ASSERT(check); //this->logger()->setLoggingType(QXmppLogger::StdoutLogging); //this->logger()->setLoggingType(QXmppLogger::FileLogging); m_rosterItemSortFilterModel = new rosterItemSortFilterProxyModel(this); m_rosterItemModel = new rosterItemModel(this); roster = new Ui::Roster; roster_widget= new QWidget; roster->setupUi(roster_widget); layoutRoster = new QVBoxLayout; layoutRoster->addWidget(&m_statusWidget); layoutRoster->addWidget(roster_widget); m_stacked_tab_chat = new QStackedWidget; vRosterSplitter = new QSplitter(Qt::Horizontal); groupBoxContact = new QGroupBox; groupBoxContact->setLayout(layoutRoster); vRosterSplitter->addWidget(groupBoxContact); vRosterSplitter->addWidget(m_stacked_tab_chat); check = connect(roster->lineEdit_filter, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); Q_ASSERT(check); m_rosterItemSortFilterModel->setSourceModel(m_rosterItemModel); roster->listView->setModel(m_rosterItemSortFilterModel); m_rosterItemSortFilterModel->sort(0); connect(roster->listView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(rosterItemSelectionChanged(QItemSelection))); rosterItemDelegate *delegate = new rosterItemDelegate(); roster->listView->setItemDelegate(delegate); roster->verticalLayout->insertWidget(0, &m_statusWidget); check = connect(&m_statusWidget, SIGNAL(statusTextChanged(QString)), SLOT(statusTextChanged(QString))); Q_ASSERT(check); check = connect(&m_statusWidget, SIGNAL(presenceTypeChanged(QXmppPresence::Type)), SLOT(presenceTypeChanged(QXmppPresence::Type))); Q_ASSERT(check); check = connect(&m_statusWidget, SIGNAL(presenceStatusTypeChanged(QXmppPresence::AvailableStatusType)), SLOT(presenceStatusTypeChanged(QXmppPresence::AvailableStatusType))); Q_ASSERT(check); check = connect(&m_statusWidget, SIGNAL(avatarChanged(QImage)), SLOT(avatarChanged(QImage))); Q_ASSERT(check); check = connect(roster->listView, SIGNAL(showProfile(QString)), this, SLOT(showProfile(QString))); Q_ASSERT(check); check = connect(roster->listView, SIGNAL(removeContact(QString)), this, SLOT(action_removeContact(QString))); Q_ASSERT(check); check = connect(roster->pushButton_addContact, SIGNAL(clicked()), SLOT(action_addContact())); Q_ASSERT(check); this->configuration().setPort(m_xmpp_client_port); this->configuration().setJid(m_login); this->configuration().setPassword(m_password); this->configuration().setResource("nodecast"); this->configuration().setStreamSecurityMode(QXmppConfiguration::StreamSecurityMode::TLSRequired); this->connectToServer(this->configuration()); }