Пример #1
0
/**
 * Refresh information for the given contact.
 *
 * Once the information is retrieved infoFieldsChanged() will be emitted.
 *
 * This method requires Contact::FeatureInfo to be ready.
 *
 * \return A PendingOperation, which will emit PendingOperation::finished
 *         when the call has finished.
 * \sa infoFieldsChanged()
 */
PendingOperation *Contact::refreshInfo()
{
    ConnectionPtr conn = manager()->connection();
    if (!mPriv->requestedFeatures.contains(FeatureInfo)) {
        warning() << "Contact::refreshInfo() used on" << this
            << "for which FeatureInfo hasn't been requested - failing";
        return new PendingFailure(TP_QT_ERROR_NOT_AVAILABLE,
                QLatin1String("FeatureInfo needs to be ready in order to "
                    "use this method"),
                ContactPtr(this));
    }

    return manager()->refreshContactInfo(QList<ContactPtr>() << ContactPtr(this));
}
ContactPtr StandardContactList::contact(int id) const
{
    QMap<int, ContactPtr>::const_iterator it = m_contacts.find(id);
    if(it == m_contacts.end())
        return ContactPtr();
    return it.value();
}
Пример #3
0
/**
 * Start a request to retrieve the avatar for this contact.
 *
 * Force the request of the avatar data. This method returns directly, emitting
 * avatarTokenChanged() and avatarDataChanged() signals once the token and data are
 * fetched from the server.
 *
 * This is only useful if the avatar token is unknown; see isAvatarTokenKnown().
 * It happens in the case of offline XMPP contacts, because the server does not
 * send the token for them and an explicit request of the avatar data is needed.
 *
 * This method requires Contact::FeatureAvatarData to be ready.
 *
 * \sa avatarData(), avatarDataChanged(), avatarToken(), avatarTokenChanged()
 */
void Contact::requestAvatarData()
{
    if (!mPriv->requestedFeatures.contains(FeatureAvatarData)) {
        warning() << "Contact::requestAvatarData() used on" << this
            << "for which FeatureAvatarData hasn't been requested - returning \"\"";
        return;
    }

    return manager()->requestContactAvatars(QList<ContactPtr>() << ContactPtr(this));
}
Пример #4
0
bool
History::Contact::populate_menu (Ekiga::MenuBuilder &builder)
{
  
  boost::shared_ptr<Ekiga::ContactCore> ccore = contact_core.lock ();
  if (ccore)
    return ccore->populate_contact_menu (ContactPtr (this, null_deleter ()),
					 uri, builder);
  else
    return false;
}
Пример #5
0
KAB::Book::Book (Ekiga::ContactCore &_core): core(_core)
{
    KABC::AddressBook *kab = KABC::StdAddressBook::self ();

    kab->load (); // FIXME: turn async!

    for (KABC::AddressBook::Iterator iter = kab->begin ();
            iter != kab->end ();
            iter++) {

        add_contact (ContactPtr (new Contact (core, &(*iter))));
    }
}
Пример #6
0
/**
 * Return the current client types of the given contact.
 *
 * If necessary, this method will make a request to the server for up-to-date
 * information and wait for a reply. Therefore, this method is more appropriate
 * for use in a "Contact Information..." dialog; it can be used to show progress
 * information (while waiting for the method to return), and can distinguish
 * between various error conditions.
 *
 * This method requires FeatureClientTypes to be ready.
 *
 * \return A list of the client types advertised by this contact.
 * \sa clientTypes(), clientTypesChanged()
 */
PendingStringList *Contact::requestClientTypes()
{
    if (!mPriv->requestedFeatures.contains(FeatureClientTypes)) {
        warning() << "Contact::requestClientTypes() used on" << this
            << "for which FeatureClientTypes hasn't been requested - the operation will fail";
    }

    Client::ConnectionInterfaceClientTypesInterface *clientTypesInterface =
        manager()->connection()->interface<Client::ConnectionInterfaceClientTypesInterface>();

    return new PendingStringList(
            clientTypesInterface->RequestClientTypes(mPriv->handle.at(0)),
            ContactPtr(this));
}
Пример #7
0
void Contact::Private::updateAvatarData()
{
    /* If token is NULL, it means that CM doesn't know the token. In that case we
     * have to request the avatar data to get the token. This happens with XMPP
     * for offline contacts. We don't want to bypass the avatar cache, so we won't
     * update avatar. */
    if (avatarToken.isNull()) {
        return;
    }

    /* If token is empty (""), it means the contact has no avatar. */
    if (avatarToken.isEmpty()) {
        debug() << "Contact" << parent->id() << "has no avatar";
        avatarData = AvatarData();
        emit parent->avatarDataChanged(avatarData);
        return;
    }

    parent->manager()->requestContactAvatars(QList<ContactPtr>() << ContactPtr(parent));
}
Пример #8
0
ContactPtr JSONToContact(const QByteArray& jsonData)
{
    QJsonDocument document = QJsonDocument::fromJson(jsonData);
    const QVariantMap data = document.toVariant().toMap();
    const QVariantMap entry = data.value(QStringLiteral("entry")).toMap();
    const QVariantList categories = entry.value(QStringLiteral("category")).toList();

    bool isContact = false;
    Q_FOREACH(const QVariant &c, categories) {
        const QVariantMap category = c.toMap();

        if (category.value(QStringLiteral("term")).toString() == QLatin1String("http://schemas.google.com/contact/2008#contact")) {
            isContact = true;
            break;
        }
    }
    if (!isContact) {
        return ContactPtr();
    }

    return Private::JSONToContact(entry).staticCast<Contact>();
}
Пример #9
0
bool
OPENLDAP::Contact::populate_menu (Ekiga::MenuBuilder &builder)
{
  boost::shared_ptr<Ekiga::ContactCore> contact_core = core.get<Ekiga::ContactCore> ("contact-core");
  /* FIXME: add here the specific actions we want to allow
   * (before or after the uri-specific actions)
   */

  Ekiga::TemporaryMenuBuilder tmp_builder;

  bool result = false;
  for (std::map<std::string, std::string>::const_iterator iter
	 = uris.begin ();
       iter != uris.end ();
       iter++) {
    if (contact_core->populate_contact_menu (ContactPtr(this, null_deleter ()),
					     iter->second, tmp_builder)) {
      builder.add_ghost ("", iter->first);
      tmp_builder.populate_menu (builder);
      result = true;
    }
  }
  return result;
}
Пример #10
0
/**
 * Start a request that this contact allow the local user to subscribe to their presence (i.e. that
 * this contact's subscribe attribute becomes Contact::PresenceStateYes)
 *
 * This method requires Connection::FeatureRoster to be ready.
 *
 * \return A PendingOperation which will emit PendingOperation::finished
 *         when the request has been made.
 * \sa subscriptionState(), removePresenceSubscription()
 */
PendingOperation *Contact::requestPresenceSubscription(const QString &message)
{
    return manager()->requestPresenceSubscription(QList<ContactPtr>() << ContactPtr(this), message);
}
/**
 * Can be used by subclasses to override the Contact subclass constructed by the factory.
 *
 * The default implementation constructs Tp::Contact objects.
 *
 * \param manager The contact manager this contact belongs.
 * \param handle The contact handle.
 * \param features The desired contact features.
 * \param attributes The desired contact attributes.
 * \return A pointer to the constructed contact.
 */
ContactPtr ContactFactory::construct(Tp::ContactManager *manager, const ReferencedHandles &handle,
        const Features &features, const QVariantMap &attributes) const
{
    ContactPtr contact = ContactPtr(new Contact(manager, handle, features, attributes));
    return contact;
}
ContactPtr StandardContactList::createContact(int id)
{
    return ContactPtr(new Contact(id));
}
Пример #13
0
/**
 * Attempt to remove the contact from the user-defined contact list
 * group named \a group.
 *
 * This method requires Connection::FeatureRosterGroups to be ready.
 *
 * \param group The group name.
 * \return A PendingOperation which will emit PendingOperation::finished
 *         when an attempt has been made to to remote the contact to the user-defined contact
 *         list group.
 * \sa groups(), addToGroup()
 */
PendingOperation *Contact::removeFromGroup(const QString &group)
{
    return manager()->removeContactsFromGroup(group, QList<ContactPtr>() << ContactPtr(this));
}
/**
 * Return the contact through which the request was made.
 *
 * \return A pointer to the Contact object.
 */
ContactPtr PendingContactInfo::contact() const
{
    return ContactPtr(qobject_cast<Contact*>((Contact*) _object().data()));
}
Пример #15
0
/**
 * Attempt to add the contact to the user-defined contact list
 * group named \a group.
 *
 * This method requires Connection::FeatureRosterGroups to be ready.
 *
 * \param group The group name.
 * \return A PendingOperation which will emit PendingOperation::finished
 *         when an attempt has been made to to add the contact to the user-defined contact
 *         list group.
 * \sa groups(), removeFromGroup()
 */
PendingOperation *Contact::addToGroup(const QString &group)
{
    return manager()->addContactsToGroup(group, QList<ContactPtr>() << ContactPtr(this));
}
Пример #16
0
/**
 * Unblock this contact.
 *
 * This method requires Connection::FeatureRoster to be ready.
 *
 * \return A PendingOperation which will emit PendingOperation::finished
 *         when an attempt has been made to take the requested action.
 * \sa block(), blockAndReportAbuse()
 */
PendingOperation *Contact::unblock()
{
    return manager()->unblockContacts(QList<ContactPtr>() << ContactPtr(this));
}
Пример #17
0
/**
 * Block this contact and additionally report abusive behaviour
 * to the server.
 *
 * If reporting abusive behaviour is not supported by the protocol,
 * this method has the same effect as block().
 *
 * This method requires Connection::FeatureRoster to be ready.
 *
 * \return A PendingOperation which will emit PendingOperation::finished
 *         when an attempt has been made to take the requested action.
 * \sa ContactManager::canReportAbuse(), block(), unblock()
 */
PendingOperation *Contact::blockAndReportAbuse()
{
    return manager()->blockContactsAndReportAbuse(QList<ContactPtr>() << ContactPtr(this));
}
Пример #18
0
/**
 * Start a request for the local user to stop sending presence to this contact.
 *
 * This method requires Connection::FeatureRoster to be ready.
 *
 * \return A PendingOperation which will emit PendingOperation::finished
 *         when the request has been made.
 * \sa publishState(), authorizePresencePublication()
 */
PendingOperation *Contact::removePresencePublication(const QString &message)
{
    return manager()->removePresencePublication(QList<ContactPtr>() << ContactPtr(this), message);
}
Пример #19
0
/**
 * Start a request to retrieve the information for this contact.
 *
 * This method is useful for UIs that don't care about notification of changes
 * in the contact information but want to show the contact information
 * (e.g. right-click on a contact and show the contact info).
 *
 * \return A PendingContactInfo, which will emit PendingContactInfo::finished
 *         when the information has been retrieved or an error occurred.
 */
PendingContactInfo *Contact::requestInfo()
{
    return new PendingContactInfo(ContactPtr(this));
}