コード例 #1
0
ファイル: entity.cpp プロジェクト: KDE/telepathy-logger-qt
EntityPtr Entity::create(const Tp::ContactPtr & contact, EntityType type)
{
#if 0
    // TODO how to go from Tp::ContactPtr to TpContact ?
    //TplEntity *entity = tpl_entity_new_from_tp_contact(0, (TplEntityType) type);
    return EntityPtr::wrap(entity, false);
#else
    QString id = contact->id();
    QString alias = contact->alias();
    QString avatarToken = contact->avatarToken();
    return Entity::create(id.toUtf8(), type, alias.toUtf8(), avatarToken.toUtf8());
#endif
}
コード例 #2
0
ファイル: Contact.cpp プロジェクト: A-K/naali
    Contact::Contact(Tp::ContactPtr tp_contact): tp_contact_(tp_contact)
    {
        if (tp_contact.isNull())
            return;
        id_ = tp_contact->id();
        name_ = tp_contact->alias();
        QString avatar = tp_contact->avatarToken();  // todo: use this information

        connect(tp_contact_.data(),
                SIGNAL( simplePresenceChanged(const QString &, uint, const QString &) ),
                SLOT( OnSimplePresenceChanged(const QString &, uint, const QString &) ));
        connect(tp_contact_.data(),
                SIGNAL( subscriptionStateChanged(Tp::Contact::PresenceState) ),
                SLOT( OnContactChanged() ));
        connect(tp_contact_.data(),
                SIGNAL( publishStateChanged(Tp::Contact::PresenceState) ),
                SLOT( OnContactChanged() ));
        connect(tp_contact_.data(),
                SIGNAL( blockStatusChanged(bool) ),
                SLOT( OnContactChanged()) );
    }
コード例 #3
0
TpSessionChannel::TpSessionChannel(Tp::ConnectionPtr conn, const Tp::ContactPtr &contact)
{
    QDEBUG_FUNCTION_BEGIN
    QVariantMap request;
    qDebug() << "TpSessionChannel::TpSessionChannel" << "contact.id() " << contact->id();

    request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType"),
                   TELEPATHY_INTERFACE_CHANNEL_TYPE_TEXT);
    request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType"),
                   (uint) Tp::HandleTypeContact);
    request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandle"),
                   contact->handle()[0]);

    connect(conn->ensureChannel(request),
            SIGNAL(finished(Tp::PendingOperation*)),
            SLOT(onChannelCreated(Tp::PendingOperation*)));

    peerContact = contact;

    QDEBUG_FUNCTION_END
}
コード例 #4
0
void InviteContactDialog::onOkClicked()
{
    // don't do anytghing if no contact has been selected
    if (!m_contactGridWidget->hasSelection()) {
        return;
    }

    Tp::ContactPtr contact = m_contactGridWidget->selectedContact();

    if (contact.isNull() || m_channel.isNull() || m_account.isNull()) {
        return;
    }

    //if can invite do so, otherwise make a new channel with the new contacts
    if (m_channel->canInviteContacts()) {
        m_channel->inviteContacts(QList<Tp::ContactPtr>() << contact);
    }
    else {
        QList<Tp::ContactPtr> contacts;
        contacts << contact;
        m_account->createConferenceTextChat(QList<Tp::ChannelPtr>() << m_channel, contacts);
    }
}
void ContactWrapper::setContact(const Tp::ContactPtr& newContact)
{
    kDebug() << "setting new contact to: " << newContact->id();

    // disconnect signals
    undoContactConnects();
    m_contact = newContact;

    // establish new signals
    setupContactConnects();

    // tell QML we have a new contact
    emit(newContactSet());
}
コード例 #6
0
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);
}