Example #1
0
void GaduEditAccountWidget::dataChanged()
{
	ConfigurationValueState widgetsState = stateNotifier()->state();

	auto accountData = GaduAccountData{account()};

	if (account().accountIdentity() == Identities->currentIdentity()
		&& account().id() == AccountId->text()
		&& account().rememberPassword() == RememberPassword->isChecked()
		&& account().password() == AccountPassword->text()
		&& account().privateStatus() == ShowStatusToEveryone->isChecked()
		&& account().useDefaultProxy() == ProxyCombo->isDefaultProxySelected()
		&& account().proxy() == ProxyCombo->currentProxy()
		&& accountData.receiveImagesDuringInvisibility() == ReceiveImagesDuringInvisibility->isChecked()

		&& accountData.chatImageSizeWarning() == ChatImageSizeWarning->isChecked()

		&& m_configuration->deprecatedApi()->readBoolEntry("Network", "isDefServers", true) == useDefaultServers->isChecked()
		&& m_configuration->deprecatedApi()->readEntry("Network", "Server") == ipAddresses->text()
		&& accountData.sendTypingNotification() == SendTypingNotification->isChecked()
		&& accountData.receiveSpam() != ReceiveSpam->isChecked()
		&& !gpiw->isModified())
	{
		simpleStateNotifier()->setState(StateNotChanged);
		return;
	}

	bool sameIdExists = m_accountManager->byId(account().protocolName(), AccountId->text())
			&& m_accountManager->byId(account().protocolName(), AccountId->text()) != account();

	if (AccountId->text().isEmpty() || sameIdExists || StateChangedDataInvalid == widgetsState)
		simpleStateNotifier()->setState(StateChangedDataInvalid);
	else
		simpleStateNotifier()->setState(StateChangedDataValid);
}
void JabberChatStateService::sendState(const Contact &contact, ChatState state)
{
	if (!m_client || !m_client->isConnected())
		return;

	if (!contact || contact.currentStatus().isDisconnected())
		return;

	auto receivedChatState = static_cast<QXmppMessage::State>(contact.property("jabber:received-chat-state", QXmppMessage::State::None).toInt());
	if (receivedChatState == QXmppMessage::State::None || receivedChatState == QXmppMessage::State::Gone)
		return;

	auto jabberAccountDetails = dynamic_cast<JabberAccountDetails *>(account().details());
	if (!jabberAccountDetails || !jabberAccountDetails->sendTypingNotification())
		return;

	auto xmppState = stateToXmppState(state);
	if (!jabberAccountDetails->sendGoneNotification() && (xmppState == QXmppMessage::State::Gone || xmppState == QXmppMessage::State::Inactive))
		xmppState = QXmppMessage::State::Paused;

	auto sentChatState = static_cast<QXmppMessage::State>(contact.property("jabber:sent-chat-state", QXmppMessage::State::None).toInt());
	// invalid transition
	if (sentChatState == QXmppMessage::State::None && (xmppState != QXmppMessage::State::Active && xmppState != QXmppMessage::State::Composing && xmppState != QXmppMessage::State::Gone))
		return;

	// don't send if it is the same as last sent state
	if (xmppState == sentChatState || xmppState == QXmppMessage::State::None)
		return;

	auto jid = m_resourceService->bestContactJid(contact);

	auto xmppMessage = QXmppMessage{};
	xmppMessage.setFrom(m_client.data()->clientPresence().id());
	xmppMessage.setStamp(QDateTime::currentDateTime());
	xmppMessage.setTo(jid.full());
	xmppMessage.setType(QXmppMessage::Chat);

	if (xmppState == QXmppMessage::State::Inactive && sentChatState == QXmppMessage::State::Composing)
	{
		// send intermediate state first
		xmppMessage.setState(QXmppMessage::State::Paused);
		m_client->sendPacket(xmppMessage);
	}

	if (xmppState == QXmppMessage::State::Composing && sentChatState == QXmppMessage::State::Inactive)
	{
		// send intermediate state first
		xmppMessage.setState(QXmppMessage::State::Active);
		m_client->sendPacket(xmppMessage);
	}

	xmppMessage.setState(xmppState);
	m_client->sendPacket(xmppMessage);

	// Save last state
	// if (sentChatState != QXmppMessage::State::Gone || xmppState == QXmppMessage::State::Active) I don't know why we have this condition
	contact.addProperty("jabber:sent-chat-state", static_cast<int>(xmppState), CustomProperties::NonStorable);
}
Example #3
0
void GaduProtocol::configureServices()
{
    auto accountData = GaduAccountData{account()};

    CurrentChatStateService->setSendTypingNotifications(accountData.sendTypingNotification());

    switch (statusTypeManager()->statusTypeData(status().type()).typeGroup())
    {
    case StatusTypeGroup::Offline:
        CurrentChatImageService->setReceiveImages(false);
        break;
    case StatusTypeGroup::Invisible:
        CurrentChatImageService->setReceiveImages(accountData.receiveImagesDuringInvisibility());
        break;
    default:
        CurrentChatImageService->setReceiveImages(true);
        break;
    }
}
Example #4
0
void GaduEditAccountWidget::loadAccountData()
{
	Identities->setCurrentIdentity(account().accountIdentity());
	AccountId->setText(account().id());
	RememberPassword->setChecked(account().rememberPassword());
	AccountPassword->setText(account().password());
	ShowStatusToEveryone->setChecked(account().privateStatus());
	if (account().useDefaultProxy())
		ProxyCombo->selectDefaultProxy();
	else
		ProxyCombo->setCurrentProxy(account().proxy());

	auto accountData = GaduAccountData{account()};
	ReceiveImagesDuringInvisibility->setChecked(accountData.receiveImagesDuringInvisibility());;
	ChatImageSizeWarning->setChecked(accountData.chatImageSizeWarning());
	SendTypingNotification->setChecked(accountData.sendTypingNotification());
	ReceiveSpam->setChecked(!accountData.receiveSpam());

	useDefaultServers->setChecked(m_configuration->deprecatedApi()->readBoolEntry("Network", "isDefServers", true));
	ipAddresses->setText(m_configuration->deprecatedApi()->readEntry("Network", "Server"));

	simpleStateNotifier()->setState(StateNotChanged);
}