void ConnectionsModel::onAccountManagerReady(Tp::PendingOperation* ) { InfTubeConnectionRetriever r; const ChannelList channels = r.retrieveChannels(); if ( channels.size() > 0 ){ beginInsertRows(QModelIndex(), 0, channels.size() - 1); m_connections = channels; endInsertRows(); } kDebug() << "channels:" << m_connections; foreach ( const QVariantMap& channelData, m_connections ) { kDebug() << "constructing tube for channel" << channelData; kDebug() << "accounts:" << m_accountManager->allAccounts(); foreach ( const Tp::AccountPtr account, m_accountManager->allAccounts() ) { kDebug() << account->objectPath(); } Tp::AccountPtr account = m_accountManager->accountForPath(channelData["accountPath"].toString()); Tp::StreamTubeChannelPtr channel = Tp::StreamTubeChannel::create(account->connection(), channelData["channelIdentifier"].toString(), QVariantMap()); m_channels << channel; connect(channel->becomeReady(Tp::Features() << Tp::StreamTubeChannel::FeatureCore), SIGNAL(finished(Tp::PendingOperation*)), SLOT(onChannelReady(Tp::PendingOperation*))); }
ContactInfoDialog::ContactInfoDialog(const Tp::AccountPtr &account, const Tp::ContactPtr &contact, QWidget *parent) : QDialog(parent) , d(new Private(this)) { #if 0 // Editing contacts is not yet supported in TpQt /* Whether contact is the user himself */ d->editable = (contact == account->connection()->selfContact()); #endif d->editable = false; d->account = account; d->contact = KTp::ContactPtr::qObjectCast(contact); d->buttonBox = new QDialogButtonBox(this); if (d->editable) { d->buttonBox->setStandardButtons(QDialogButtonBox::Save | QDialogButtonBox::Close); } else { d->buttonBox->setStandardButtons(QDialogButtonBox::Close); } connect(d->buttonBox, &QDialogButtonBox::clicked, this, &ContactInfoDialog::slotButtonClicked); setMaximumSize(sizeHint()); QVBoxLayout *layout = new QVBoxLayout(this); layout->setSpacing(30); /* Title - presence icon, alias, id */ KTitleWidget *titleWidget = new KTitleWidget(this); KTp::Presence presence(contact->presence()); titleWidget->setPixmap(presence.icon().pixmap(32, 32), KTitleWidget::ImageLeft); titleWidget->setText(contact->alias()); titleWidget->setComment(contact->id()); layout->addWidget(titleWidget); /* 1st column: avatar; 2nd column: details */ d->columnsLayout = new QHBoxLayout(); d->columnsLayout->setSpacing(30); layout->addLayout(d->columnsLayout); /* Make sure the contact has all neccessary features ready */ Tp::PendingContacts *op = contact->manager()->upgradeContacts( QList<Tp::ContactPtr>() << contact, Tp::Features() << Tp::Contact::FeatureAvatarData << Tp::Contact::FeatureInfo); connect(op, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onContactUpgraded(Tp::PendingOperation*))); /* State Info - there is no point showing this information when it's about ourselves */ if (!d->editable) { d->stateLayout = new QFormLayout(); d->stateLayout->setSpacing(10); layout->addLayout(d->stateLayout); // Fetch roster feature, if it is supported, but not loaded Tp::ConnectionPtr conn = contact->manager()->connection(); if(!conn->actualFeatures().contains(Tp::Connection::FeatureRoster) && !conn->missingFeatures().contains(Tp::Connection::FeatureRoster)) { Tp::PendingReady *pr = conn->becomeReady(Tp::Features() << Tp::Connection::FeatureRoster); connect(pr, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onFeatureRosterReady(Tp::PendingOperation*))); } else { d->loadStateRows(); } } layout->addWidget(d->buttonBox); }