本文整理汇总了C++中Contact::contactAccount方法的典型用法代码示例。如果您正苦于以下问题:C++ Contact::contactAccount方法的具体用法?C++ Contact::contactAccount怎么用?C++ Contact::contactAccount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::contactAccount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant BuddyContactModel::data(const QModelIndex &index, int role) const
{
Contact data = contact(index);
if (data.isNull())
return QVariant();
switch (role)
{
case Qt::DisplayRole:
if (IncludeIdentityInDisplay)
return QString("%1 (%2)").arg(data.id()).arg(data.contactAccount().accountIdentity().name());
else
return data.id();
case Qt::DecorationRole:
return data.contactAccount().protocolHandler()
? data.contactAccount().protocolHandler()->icon().icon()
: QIcon();
case ContactRole:
return QVariant::fromValue<Contact>(data);
default:
return QVariant();
}
}
示例2: getStatusIconPath
static QString getStatusIconPath(BuddyOrContact buddyOrContact)
{
Buddy buddy = buddyOrContact.buddy();
Contact contact = buddyOrContact.contact();
if (buddy.isBlocked())
return webKitPath(IconsManager::instance()->iconPath("kadu_icons", "16x16", "blocked"));
if (contact.isBlocking())
return webKitPath(IconsManager::instance()->iconPath("kadu_icons", "16x16", "blocking"));
if (contact.contactAccount())
{
Protocol *protocol = contact.contactAccount().protocolHandler();
if (protocol)
{
StatusTypeManager* statustypemanager = StatusTypeManager::instance();
if (statustypemanager)
{
Status status = contact.currentStatus();
QString iconpath = statustypemanager->statusIconFullPath(protocol->statusPixmapPath(), status.type(), !status.description().isEmpty(), false);
if (!iconpath.isEmpty())
return webKitPath(iconpath);
}
}
}
return QString();
}
示例3: endSession
void OtrSessionService::endSession(const Contact &contact)
{
if (!AppOpsService || !OpDataFactory || !UserStateService)
return;
OtrOpData opData = OpDataFactory->opDataForContact(contact);
otrl_message_disconnect_all_instances(
UserStateService->userState(), AppOpsService->appOps(), &opData, qPrintable(contact.contactAccount().id()),
qPrintable(contact.contactAccount().protocolName()), qPrintable(contact.id()));
emit goneInsecure(contact);
}
示例4: data
QVariant ContactDataExtractor::data(const Contact &contact, int role, bool useBuddyData)
{
if (contact.isNull())
return QVariant();
switch (role)
{
case Qt::DisplayRole:
return useBuddyData
? contact.ownerBuddy().display()
: contact.id();
case Qt::DecorationRole:
{
if (contact.ownerBuddy().isBlocked())
return IconsManager::instance()->iconByPath("kadu_icons/blocked");
if (contact.isBlocking())
return IconsManager::instance()->iconByPath("kadu_icons/blocking");
// TODO generic icon
return !contact.contactAccount().isNull()
? contact.contactAccount().data()->statusIcon(contact.currentStatus())
: QIcon();
}
case BuddyRole:
return QVariant::fromValue(contact.ownerBuddy());
case ContactRole:
return QVariant::fromValue(contact);
case DescriptionRole:
{
BuddyKaduData *bkd = contact.ownerBuddy().data()->moduleStorableData<BuddyKaduData>("kadu", 0, true);
if (bkd && bkd->hideDescription())
return QVariant();
return contact.currentStatus().description();
}
case StatusRole:
return QVariant::fromValue(contact.currentStatus());
case AccountRole:
return QVariant::fromValue(contact.contactAccount());
case AvatarRole:
if (useBuddyData && !contact.ownerBuddy().buddyAvatar().isEmpty())
return QVariant::fromValue(contact.ownerBuddy().buddyAvatar().pixmap());
else
return QVariant::fromValue(contact.contactAvatar().pixmap());
case ItemTypeRole:
return ContactRole;
default:
return QVariant();
}
}
示例5: send
void GaduFileTransferHandler::send()
{
if (TypeSend != transfer().transferType()) // maybe assert here?
return;
if (SocketNotifiers || WaitingForSocketNotifiers) // already sending/receiving
return;
Contact contact = transfer().peer();
Account account = contact.contactAccount();
transfer().setRemoteFileName(QString());
if (account.isNull() || transfer().localFileName().isEmpty())
{
transfer().setTransferStatus(StatusNotConnected);
return; // TODO: notify
}
GaduProtocol *gaduProtocol = qobject_cast<GaduProtocol *>(account.protocolHandler());
if (!gaduProtocol || !gaduProtocol->gaduContactDetails(contact))
{
transfer().setTransferStatus(StatusNotConnected);
return;
}
// async call, will return in setFileTransferNotifiers
transfer().setTransferStatus(StatusWaitingForConnection);
WaitingForSocketNotifiers = true;
if (gaduProtocol->fileTransferService())
dynamic_cast<GaduFileTransferService *>(gaduProtocol->fileTransferService())->attachSendFileTransferSocket(this);
}
示例6: display
QString Buddy::display() const
{
if (isNull())
return QString();
QString result = data()->display().isEmpty()
? data()->nickName().isEmpty() ? data()->firstName() : data()->nickName()
: data()->display();
if (result.isEmpty())
{
if (!data()->contacts().isEmpty())
{
Contact contact = data()->contacts().at(0);
if (contact)
{
result = contact.id();
Account account = contact.contactAccount();
if (!account.accountIdentity().name().isEmpty())
result += QString(" (%1)").arg(account.accountIdentity().name());
}
}
}
return result;
}
示例7: accountSelectionChanged
void BuddyPersonalInfoConfigurationWidget::accountSelectionChanged(int index)
{
Contact c = ContactIdCombo->model()->index(index, 0).data(ContactRole).value<Contact>();
if (!c)
return;
if (InfoWidget)
{
InfoWidget->deleteLater();
InfoWidget->hide();
}
if (!c.contactAccount().protocolHandler())
return;
InfoWidget = c.contactAccount().protocolHandler()->protocolFactory()->newContactPersonalInfoWidget(c, this);
Layout->insertWidget(1, InfoWidget);
}
示例8: contactUpdated
void SqlContactsMapping::contactUpdated(const Contact &contact)
{
QMutexLocker locker(&Mutex);
int id = idByContact(contact, false);
// not all contacts are mapped
if (id <= 0)
return;
QSqlQuery query(Database);
query.prepare("UPDATE kadu_contacts SET account_id = :account_id, contact = :contact WHERE id = :id");
query.bindValue(":account_id", SqlAccountsMapping::idByAccount(contact.contactAccount()));
query.bindValue(":contact", contact.id());
query.bindValue(":id", id);
query.exec();
}
示例9: MyContact
GaduContactPersonalInfoWidget::GaduContactPersonalInfoWidget(const Contact &contact, QWidget *parent) :
QWidget(parent), MyContact(contact)
{
setAttribute(Qt::WA_DeleteOnClose);
createGui();
ContactPersonalInfoService *service = contact.contactAccount().protocolHandler()->contactPersonalInfoService();
if (!service)
{
reset();
return;
}
connect(service, SIGNAL(personalInfoAvailable(Buddy)), this, SLOT(personalInfoAvailable(Buddy)));
service->fetchPersonalInfo(contact);
}
示例10: startSession
void OtrSessionService::startSession(const Contact &contact)
{
if (!CurrentMessageManager || !PolicyService || !TrustLevelService)
return;
auto level = TrustLevelService->loadTrustLevelFromContact(contact);
auto account = contact.contactAccount();
auto otrPolicy = PolicyService->accountPolicy(account);
auto message = normalizeHtml(
HtmlString{QString::fromUtf8(otrl_proto_default_query_msg(qPrintable(account.id()), otrPolicy.toOtrPolicy()))});
if (level == OtrTrustLevelService::TrustLevelNotPrivate)
emit tryingToStartSession(contact);
else
emit tryingToRefreshSession(contact);
CurrentMessageManager->sendMessage(
ChatTypeContact::findChat(m_chatManager, m_chatStorage, contact, ActionCreateAndAdd), message, true);
}
示例11: idByContact
int SqlContactsMapping::idByContact(const Contact &contact, bool create)
{
QMutexLocker locker(&Mutex);
int id = contact.property("sql_history:id", 0).toInt();
if (!create || id > 0)
return id;
QSqlQuery query(Database);
query.prepare("INSERT INTO kadu_contacts (account_id, contact) VALUES (:account_id, :contact)");
query.bindValue(":account_id", SqlAccountsMapping::idByAccount(contact.contactAccount()));
query.bindValue(":contact", contact.id());
query.exec();
id = query.lastInsertId().toInt();
addMapping(id, contact);
return id;
}
示例12: MyContact
JabberContactPersonalInfoWidget::JabberContactPersonalInfoWidget(Contact &contact, QWidget *parent) :
QWidget(parent), MyContact(contact)
{
setAttribute(Qt::WA_DeleteOnClose);
createGui();
reset();
ContactPersonalInfoService *service = contact.contactAccount().protocolHandler()->contactPersonalInfoService();
if (!service)
return;
connect(service, SIGNAL(personalInfoAvailable(Buddy)), this, SLOT(personalInfoAvailable(Buddy)));
Buddy b = Buddy::create();
Contact c = Contact::create();
c.setId(contact.id());
c.setOwnerBuddy(b);
service->fetchPersonalInfo(c);
}
示例13: query
void SqlImport::importContactsToV4(QSqlDatabase &database)
{
QSqlQuery query(database);
QMap<int, Contact> contacts;
database.transaction();
query.prepare("SELECT id, uuid FROM kadu_contacts");
query.setForwardOnly(true);
query.exec();
while (query.next())
{
int id = query.value(0).toInt();
QString uuid = query.value(1).toString();
Contact contact = m_contactManager->byUuid(uuid);
if (contact && contact.contactAccount() && !contact.id().isEmpty())
contacts.insert(id, contact);
}
query.prepare("UPDATE kadu_contacts SET account_id = :account_id, contact = :contact WHERE id = :id");
query.setForwardOnly(false);
QList<int> ids = contacts.keys();
foreach (int id, ids)
{
Contact contact = contacts.value(id);
int accountId = SqlAccountsMapping::idByAccount(contact.contactAccount());
if (id > 0 && accountId > 0)
{
query.bindValue(":id", id);
query.bindValue(":account_id", accountId);
query.bindValue(":contact", contact.id());
query.exec();
contact.addProperty("sql_history:id", query.lastInsertId(), CustomProperties::NonStorable);
}
}
示例14: avatarId
AvatarId avatarId(const Contact &contact)
{
auto id = ContactGlobalId{contact.contactAccount(), {contact.id().toUtf8()}};
return avatarId(id);
}
示例15: parse
QString Parser::parse(const QString &s, BuddyOrContact buddyOrContact, const QObject * const object, bool escape)
{
Buddy buddy = buddyOrContact.buddy();
Contact contact = buddyOrContact.contact();
kdebugmf(KDEBUG_DUMP, "%s escape=%i\n", qPrintable(s), escape);
int index = 0, i, len = s.length();
QList<ParserToken> parseStack;
static QHash<QChar, bool> searchChars;
if (!searchChars.value('%', false))
{
searchChars['%'] = true;
searchChars['['] = true;
searchChars['{'] = true;
searchChars['\\'] = true;
searchChars['$'] = true;
searchChars['@'] = true;
searchChars['#'] = true;
searchChars['}'] = true;
searchChars[']'] = true;
}
bool allowExec = config_file.readBoolEntry("General", "AllowExecutingFromParser", false);
searchChars['`'] = allowExec;
searchChars['\''] = allowExec;
while (index < len)
{
ParserToken pe1, pe;
for(i = index; i < len; ++i)
if (searchChars.value(s.at(i), false))
break;
// this is the same, but code above is muuuuch faster
// i=s.find(QRegExp("%|`|\\{|\\[|'|\\}|\\]"), index);
if (i != index)
{
pe1.type = ParserToken::PT_STRING;
pe1.content = s.mid(index, i - index);
parseStack.push_back(pe1);
if (i == len)
break;
}
char c = s.at(i).toAscii();
if (c == '%')
{
++i;
if (i == len)
break;
pe.type = ParserToken::PT_STRING;
switch (s.at(i).toAscii())
{
case 's':
++i;
if (contact)
{
StatusType *type = StatusTypeManager::instance()->statusType(contact.currentStatus().type());
if (type)
pe.content = type->displayName();
}
break; // TODO: 't' removed
case 'q':
++i;
if (contact)
{
StatusContainer *container = contact.contactAccount().statusContainer();
if (container)
pe.content = container->statusIconPath(contact.currentStatus().type());
}
break;
case 'd':
++i;
if (contact)
pe.content = contact.currentStatus().description();
if (escape)
HtmlDocument::escapeText(pe.content);
if (config_file.readBoolEntry("Look", "ShowMultilineDesc"))
{
pe.content.replace('\n', QLatin1String("<br/>"));
pe.content.replace(QRegExp("\\s\\s"), QString(" "));
}
break;
case 'i':
++i;
if (contact)
pe.content = contact.address().toString();
break;
case 'v':
++i;
if (contact)
pe.content = contact.dnsName();
break;
//.........这里部分代码省略.........