Пример #1
0
void AccountNotificationService::notifyConnectionError(const Account &account, const QString &errorServer, const QString &errorMessage)
{
	if (account.property(QStringLiteral("notify:ignore-connection-errors"), false).toBool())
		return;

	auto lastConnectionError = account.property(QStringLiteral("notify:last-connection-error"), QDateTime{}).toDateTime();
	if (lastConnectionError.isValid() && lastConnectionError.addSecs(60) > QDateTime::currentDateTime())
		return;

	account.addProperty(QStringLiteral("notify:last-connection-error"), QDateTime::currentDateTime(), CustomProperties::NonStorable);

	auto data = QVariantMap{};
	data.insert(QStringLiteral("account"), qVariantFromValue(account));
	data.insert(QStringLiteral("error-server"), errorServer);
	data.insert(QStringLiteral("error-message"), errorMessage);

	auto notification = Notification{};
	notification.type = m_connectionErrorEvent.name();
	notification.title = tr("Connection error");
	notification.text = normalizeHtml(plainToHtml(tr("Connection error on account: %1 (%2)").arg(account.id(), account.accountIdentity().name())));
	notification.data = std::move(data);
	notification.details = normalizeHtml(plainToHtml(errorDetails(errorServer, errorMessage)));
	notification.callbacks.append(QStringLiteral("connection-ignore-errors"));

	m_notificationService->notify(notification);
}
Пример #2
0
void OtrNotifier::notifyCreatePrivateKeyFinished(const Account &account, bool ok)
{
    notify(
        CreatePrivateKeyFinishedNotifyTopic, account,
        ok ? normalizeHtml(HtmlString{tr("%1: private key created, you can start a private conversation now")}.arg(
                 plainToHtml(account.id())))
           : normalizeHtml(HtmlString{tr("%1: private key creation failed")}.arg(plainToHtml(account.id()))));
}
Пример #3
0
void OtrNotifier::notifyCreatePrivateKeyStarted(const Account &account)
{
    notify(
        CreatePrivateKeyStartedNotifyTopic, account,
        normalizeHtml(
            HtmlString{tr("%1: creating private key, it can took a few minutes")}.arg(plainToHtml(account.id()))));
}
Пример #4
0
void CenzorNotificationService::notifyCenzored(const Chat &chat)
{
	auto data = QVariantMap{};
	data.insert(QStringLiteral("account"), qVariantFromValue(chat.chatAccount()));
	data.insert(QStringLiteral("chat"), qVariantFromValue(chat));

	auto notification = Notification{};
	notification.type = m_cenzoredEvent.name();
	notification.icon = KaduIcon{"kadu_icons/blocking"};
	notification.title = (tr("Cenzor"));
	notification.text = normalizeHtml(HtmlString{tr("Message was cenzored")});
	notification.details = normalizeHtml(HtmlString{tr("Your interlocutor used obscene word and became admonished")});
	notification.callbacks.append("chat-open");
	notification.callbacks.append("ignore");

	m_notificationService->notify(notification);

}
Пример #5
0
void FacebookChatService::unreadMessageReceived(const QFacebookDownloadUnreadMessageResult &result)
{
    if (m_receivedMessages.find(result.messageId) != std::end(m_receivedMessages))
        return;

    m_receivedMessages.insert(std::make_pair(result.messageId, QDateTime::currentDateTime()));

    auto contact = m_contactManager->byId(account(), QString::number(result.senderUid), ActionCreateAndAdd);
    auto chat = ChatTypeContact::findChat(m_chatManager, m_chatStorage, contact, ActionCreateAndAdd);
    auto message = m_messageStorage->create();
    message.setMessageChat(chat);
    message.setType(MessageType::MessageTypeReceived);
    message.setMessageSender(contact);
    message.setSendDate(result.timestamp);
    message.setReceiveDate(QDateTime::currentDateTime());
    message.setContent(normalizeHtml(plainToHtml(result.text)));

    emit messageReceived(message);
}
Пример #6
0
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);
}
Пример #7
0
void OtrNotifier::notifyStillSecure(const Contact &contact)
{
    notify(
        contact,
        normalizeHtml(HtmlString{tr("%1: conversation is still private")}.arg(plainToHtml(contact.display(true)))));
}
Пример #8
0
void OtrNotifier::notifyGoneInsecure(const Contact &contact)
{
    notify(
        contact,
        normalizeHtml(HtmlString{tr("%1: private conversation stopped")}.arg(plainToHtml(contact.display(true)))));
}
Пример #9
0
void OtrNotifier::notifyPeerEndedSession(const Contact &contact)
{
    notify(
        contact, normalizeHtml(HtmlString{tr("%1: peer ended private conversation; you should do the same")}.arg(
                     plainToHtml(contact.display(true)))));
}
Пример #10
0
void OtrNotifier::notifyTryingToRefreshSession(const Contact &contact)
{
    notify(
        contact, normalizeHtml(HtmlString{tr("%1: trying to refresh private conversation")}.arg(
                     plainToHtml(contact.display(true)))));
}