예제 #1
0
void QXmppRosterManager::rosterIqReceived(const QXmppRosterIq& rosterIq)
{
    bool isInitial = (m_rosterReqId == rosterIq.id());

    switch(rosterIq.type())
    {
    case QXmppIq::Set:
        {
            // send result iq
            QXmppIq returnIq(QXmppIq::Result);
            returnIq.setId(rosterIq.id());
            m_stream->sendPacket(returnIq);

            // store updated entries and notify changes
            const QList<QXmppRosterIq::Item> items = rosterIq.items();
            for (int i = 0; i < items.count(); i++)
            {
                QString bareJid = items.at(i).bareJid();
                m_entries[bareJid] = items.at(i);
                emit rosterChanged(bareJid);
            }

            // when contact subscribes user...user sends 'subscribed' presence 
            // then after recieving following iq user requests contact for subscription
            
            // check the "from" is newly added in the roster...and remove this ask thing...and do this for all items
            QXmppRosterIq::Item item = items.at(0);
            if (!item.bareJid().isEmpty() &&
                item.subscriptionType() == QXmppRosterIq::Item::From &&
                item.subscriptionStatus().isEmpty())
            {
                QXmppPresence presence;
                presence.setTo(item.bareJid());
                presence.setType(QXmppPresence::Subscribe);
                m_stream->sendPacket(presence);
            }
        }
        break;
    case QXmppIq::Result:
        {
            QList<QXmppRosterIq::Item> items = rosterIq.items();
            for(int i = 0; i < items.count(); ++i)
            {
                QString bareJid = items.at(i).bareJid();
                m_entries[bareJid] = items.at(i);
                if (!isInitial)
                    emit rosterChanged(bareJid);
            }
            if (isInitial)
            {
                m_isRosterReceived = true;
                emit rosterReceived();
            }
            break;
        }
    default:
        break;
    }
}
예제 #2
0
GaduRosterService::GaduRosterService(GaduListHelper *gaduListHelper, const QVector<Contact> &contacts, Protocol *protocol) :
		RosterService{contacts, protocol},
		m_stateMachine{new GaduRosterStateMachine{this, protocol}},
		m_gaduListHelper{gaduListHelper}
{
	connect(this, SIGNAL(contactAdded(Contact)), this, SLOT(rosterChanged()));
	connect(this, SIGNAL(contactRemoved(Contact)), this, SLOT(rosterChanged()));
	connect(this, SIGNAL(contactUpdatedLocally(Contact)), this, SLOT(rosterChanged()));

	connect(m_stateMachine, SIGNAL(performGet()), SLOT(importContactList()));
	connect(m_stateMachine, SIGNAL(performPut()), SLOT(exportContactList()));
}
예제 #3
0
HomeStatControl::HomeStatControl(HockeyGame* game, bool phome, bool standAlone) : home(phome) {
    team = home ? game->getHomeTeam() : game->getAwayTeam();
    playerSelector.addItems( home ? game->getHomeTeam()->getGuiNames() :
                                    game->getAwayTeam()->getGuiNames());
    seasonLt.setText("Season Lower Third");
    gameLt.setText("Game Lower Third");
    seasonBar.setText("Season Stat Bar");
    gameBar.setText("Game Stat Bar");

    QHBoxLayout* myLayout = getFullLayout();

    connect(&seasonLt, SIGNAL(clicked()), this, SLOT(requestSeasonLt()));
    connect(this, SIGNAL(requestSeasonLt(int, bool)), game, SLOT(gatherSeasonStatsLt(int, bool)));

    connect(&gameLt, SIGNAL(clicked()), this, SLOT(requestGameLt()));
    connect(this, SIGNAL(requestGameLt(int, bool)), game, SLOT(gatherGameStatsLt(int, bool)));

    connect(&seasonBar, SIGNAL(clicked()), this, SLOT(requestSeasonSb()));
    connect(this, SIGNAL(requestSeasonSb(int, bool)), game, SLOT(gatherSeasonStatsSb(int, bool)));

    connect(&gameBar, SIGNAL(clicked()), this, SLOT(requestGameSb()));
    connect(this, SIGNAL(requestGameSb(int, bool)), game, SLOT(gatherGameStatsSb(int, bool)));
    if (standAlone) {
        connect(team, SIGNAL(rosterChanged()), this, SLOT(updateRoster()));
        setLayout(getFullLayout());
    }
}
예제 #4
0
void MyXmppClient::clearPresence() {
    qDebug() << "MyXmppClient::clearPresence() called";

    for( int j=0; j < cachedRoster->rowCount(); j++ ) {
        RosterItemModel *itemExists = (RosterItemModel*)cachedRoster->getElementByID(j);
        if (itemExists != 0) {
          itemExists->setPresence( this->getPicPresence( QXmppPresence::Unavailable ) );
        }
        itemExists = 0; delete itemExists;
    }
    emit rosterChanged();
}
예제 #5
0
void BuddyModel::setRoster(Vreen::Roster *roster)
{
    if (!m_roster.isNull())
        m_roster.data()->disconnect(this);
    m_roster = roster;

    setBuddies(roster->buddies());
    connect(roster, SIGNAL(buddyAdded(Vreen::Buddy*)), SLOT(addBuddy(Vreen::Buddy*)));
	connect(roster, SIGNAL(buddyRemoved(int)), SLOT(removeFriend(int)));
    connect(roster, SIGNAL(syncFinished(bool)), SLOT(onSyncFinished()));
    emit rosterChanged(roster);
}
예제 #6
0
파일: buddymodel.cpp 프로젝트: Astel/vreen
void BuddyModel::setRoster(Vreen::Roster *roster)
{
    if (!m_roster.isNull())
        m_roster.data()->disconnect(this);
    m_roster = roster;

    foreach (auto buddy, m_roster.data()->buddies())
        addFriend(buddy);

	connect(roster, SIGNAL(buddyAdded(Vreen::Buddy*)), SLOT(addFriend(Vreen::Buddy*)));
	connect(roster, SIGNAL(buddyRemoved(int)), SLOT(removeFriend(int)));
    emit rosterChanged(roster);
}
예제 #7
0
void GaduRosterService::prepareRoster()
{
	auto requiresSynchronization = false;
	for (auto &&contact : contacts())
		if (contact.rosterEntry())
		{
			if (contact.rosterEntry()->state() == RosterEntryState::Detached) // GG does not support detached contacts
				contact.rosterEntry()->setHasLocalChanges();
			else
				contact.rosterEntry()->fixupInitialState();
			requiresSynchronization |= contact.rosterEntry()->requiresSynchronization();
		}
	if (requiresSynchronization)
		rosterChanged();
}
예제 #8
0
StatPopUI::StatPopUI(HockeyGame *game, bool phome):
    HomeStatControl(game, phome, false)
{
    this->game=game;
    QVBoxLayout* myLayout = new QVBoxLayout();
    myLayout->addWidget(&seasonPreview);
    myLayout->addWidget(&gamePreview);
    myLayout->addLayout(getPopLayout());
    setLayout(myLayout);
    connect(&playerSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(updateGamePreview()));
    connect(&playerSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSeasonPreview()));
    HockeyTeam* team = home? game->getHomeTeam() : game->getAwayTeam();
    connect(team, SIGNAL(rosterChanged()), this, SLOT(updateRoster()));
    updateSeasonPreview();
    updateGamePreview();
}
예제 #9
0
void MyXmppClient::initPresence(const QString& bareJid, const QString& resource)
{
    int indxItem = -1;
    RosterItemModel *item = (RosterItemModel*)cachedRoster->find( bareJid, indxItem );

    if( item == 0 ) {
        return;
    }

    QXmppPresence xmppPresence = rosterManager->getPresence( bareJid, resource );
    QXmppPresence::Type statusJid = xmppPresence.type();

    QStringList _listResources = this->getResourcesByJid( bareJid );
    if( (_listResources.count() > 0) && (!_listResources.contains(resource)) )
    {
        qDebug() << bareJid << "/" << resource << " ****************[" <<_listResources<<"]" ;
        if( statusJid == QXmppPresence::Unavailable ) {
            return;
        }
    }

    item->setResource( resource );

    QString picStatus = this->getPicPresence( xmppPresence );
    item->setPresence( picStatus );

    QString txtStatus = this->getTextStatus( xmppPresence.statusText(), xmppPresence );
    item->setStatusText( txtStatus );

    RosterItemModel *itemExists = (RosterItemModel*)cachedRoster->find( bareJid, indxItem );

    if( itemExists != 0 ) {
        itemExists->copy( item );
        QString picStatusPrev = itemExists->presence();
        if( picStatusPrev != picStatus )
        {
            //emit presenceJidChanged( bareJid, txtStatus, picStatus );
            emit rosterChanged();
        }
    }
    item = 0; itemExists = 0;
    delete item; delete itemExists;

    emit contactStatusChanged(m_accountId,bareJid);
}
예제 #10
0
PastGamesUI::PastGamesUI(PastGamesGraphic *graphic, HockeyTeam *team, bool home, QWidget *parent) : QWidget(parent)
{
    showButton.setText("Show");
    QVBoxLayout* manager = new QVBoxLayout();
    manager->addWidget(&numToShow);
    manager->addWidget(&showButton);
    this->home=home;
    this->team = team;

    numToShow.setValue(std::min(2, team->getGameHistory().size()));
    numToShow.setMaximum(std::min(8, team->getGameHistory().size()));
    numToShow.setMinimum(1);
    connect(this, SIGNAL(show(bool,int)), graphic, SLOT(receiveData(bool,int)));
    connect(&showButton, SIGNAL(clicked()), this, SLOT(prepareToShow()));
    connect(team, SIGNAL(rosterChanged()), this, SLOT(updateUi()));
    //connect(&showButton, SIGNAL(clicked()), this, SLOT(close()));
    setLayout(manager);
}
예제 #11
0
void MyXmppClient::initRoster() {
    qDebug() << "MyXmppClient::initRoster() called";
    if (!rosterManager->isRosterReceived()) {
        qDebug() << "MyXmppClient::initRoster(): roster not available yet";
        return;
    }

    cachedRoster->cleanList();

    QStringList listBareJids = rosterManager->getRosterBareJids();

    for( int j=0; j < listBareJids.length(); j++ )
    {
        QString bareJid = listBareJids.at(j);

        cacheIM->addCacheJid( bareJid );

        QXmppRosterIq::Item itemRoster = rosterManager->getRosterEntry( bareJid );
        QString name = itemRoster.name();
        vCardData vCdata = cacheIM->getVCard( bareJid );

        if ( vCdata.isEmpty() && !disableAvatarCaching ) {
            qDebug() << "MyXmppClient::initRoster():" << bareJid << "has no VCard. Requesting.";
            vCardManager->requestVCard( bareJid );
        }
        RosterItemModel *itemExists = (RosterItemModel*)cachedRoster->find(bareJid);
        if (itemExists == 0) {
          RosterItemModel *itemModel = new RosterItemModel( );
          itemModel->setPresence( this->getPicPresence( QXmppPresence::Unavailable ) );
          itemModel->setContactName( name );
          itemModel->setJid( bareJid );
          itemModel->setAvatar(cacheIM->getAvatarCache(bareJid));
          cachedRoster->append(itemModel);
          itemModel = 0;
          delete itemModel;
        } else if (itemExists->name() != name) {
          itemExists->setContactName(name);
          emit contactRenamed(bareJid,name);
        }
        itemExists = 0; delete itemExists;
    }
    emit rosterChanged();
}
예제 #12
0
void Lvk::CA::XmppChatbot::connectSignals()
{
    connect(m_xmppClient, SIGNAL(messageReceived(const QXmppMessage&)),
            this, SLOT(onMessageReceived(const QXmppMessage&)));

    connect(m_xmppClient, SIGNAL(connected()),    SLOT(onConnected()));

    connect(&m_xmppClient->rosterManager(), SIGNAL(rosterReceived()), SLOT(onRosterReceived()));
    connect(&m_xmppClient->rosterManager(), SIGNAL(rosterChanged(QString)),
            SLOT(onRosterChanged(QString)));

    connect(&m_xmppClient->vCardManager(), SIGNAL(vCardReceived(const QXmppVCardIq&)),
            this, SLOT(onVCardReceived(const QXmppVCardIq&)));

    connect(m_xmppClient, SIGNAL(disconnected()), SLOT(onDisconnected()));

    connect(m_xmppClient, SIGNAL(error(QXmppClient::Error)),
            SLOT(emitLocalError(QXmppClient::Error)));

    connect(&m_netMgr, SIGNAL(onlineStateChanged(bool)), SLOT(onOnlineStateChanged(bool)));
}
예제 #13
0
파일: client.cpp 프로젝트: klpx/jam
Jam::Client::Client(QObject *parent) : QObject(parent)
{
    roster = new Jam::Roster;
    emit rosterChanged();
    setConnected(false);
}
예제 #14
0
/// \cond
bool QXmppRosterManager::handleStanza(const QDomElement &element)
{
    if (element.tagName() != "iq" || !QXmppRosterIq::isRosterIq(element))
        return false;

    // Security check: only server should send this iq
    // from() should be either empty or bareJid of the user
    const QString fromJid = element.attribute("from");
    if (!fromJid.isEmpty() && QXmppUtils::jidToBareJid(fromJid) != client()->configuration().jidBare())
        return false;

    QXmppRosterIq rosterIq;
    rosterIq.parse(element);

    bool isInitial = (d->rosterReqId == rosterIq.id());
    switch(rosterIq.type())
    {
    case QXmppIq::Set:
        {
            // send result iq
            QXmppIq returnIq(QXmppIq::Result);
            returnIq.setId(rosterIq.id());
            client()->sendPacket(returnIq);

            // store updated entries and notify changes
            const QList<QXmppRosterIq::Item> items = rosterIq.items();
            foreach (const QXmppRosterIq::Item &item, items) {
                const QString bareJid = item.bareJid();
                if (item.subscriptionType() == QXmppRosterIq::Item::Remove) {
                    if (d->entries.remove(bareJid)) {
                        // notify the user that the item was removed
                        emit itemRemoved(bareJid);
                    }
                } else {
                    const bool added = !d->entries.contains(bareJid);
                    d->entries.insert(bareJid, item);
                    if (added) {
                        // notify the user that the item was added
                        emit itemAdded(bareJid);
                    } else {
                        // notify the user that the item changed
                        emit itemChanged(bareJid);
                    }

                    // FIXME: remove legacy signal
                    emit rosterChanged(bareJid);
                }
            }
        }
        break;
    case QXmppIq::Result:
        {
            const QList<QXmppRosterIq::Item> items = rosterIq.items();
            foreach (const QXmppRosterIq::Item &item, items) {
                const QString bareJid = item.bareJid();
                d->entries.insert(bareJid, item);
                if (!isInitial)
                    emit rosterChanged(bareJid);
            }
            if (isInitial)
            {
                d->isRosterReceived = true;
                emit rosterReceived();
            }
            break;
        }
    default:
        break;
    }

    return true;
}
예제 #15
0
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());
}