void NotificationsManager::NotifyWithReason (QObject *entryObj, const QString& msg,
			const char *func, const QString& eventType,
			const QString& patternLite, const QString& patternFull)
	{
		const auto entry = qobject_cast<ICLEntry*> (entryObj);
		if (!entry)
		{
			qWarning () << func
					<< entryObj
					<< "doesn't implement ICLEntry";
			return;
		}

		const auto& str = msg.isEmpty () ?
				patternLite
					.arg (entry->GetEntryName ())
					.arg (entry->GetHumanReadableID ()) :
				patternFull
					.arg (entry->GetEntryName ())
					.arg (entry->GetHumanReadableID ())
					.arg (msg);

		auto e = Util::MakeNotification ("Azoth", str, PInfo_);
		BuildNotification (e, entry, "Event");
		e.Additional_ ["org.LC.AdvNotifications.EventType"] = eventType;
		e.Additional_ ["org.LC.AdvNotifications.FullText"] = str;
		e.Additional_ ["org.LC.AdvNotifications.Count"] = 1;
		e.Additional_ ["org.LC.Plugins.Azoth.Msg"] = msg;

		EntityMgr_->HandleEntity (e);
	}
	MUCInviteDialog::MUCInviteDialog (IAccount *acc, ListType type, QWidget *parent)
	: QDialog (parent)
	, ManualMode_ (false)
	{
		Ui_.setupUi (this);
		Ui_.Invitee_->setInsertPolicy (QComboBox::NoInsert);

		ICLEntry::EntryType requestedType = ICLEntry::EntryType::Chat;
		switch (type)
		{
		case ListType::ListEntries:
			break;
		case ListType::ListMucs:
			requestedType = ICLEntry::EntryType::MUC;
			Ui_.InviteeLabel_->setText ("Conferences:");
			break;
		}

		for (auto entryObj : acc->GetCLEntries ())
		{
			const auto entry = qobject_cast<ICLEntry*> (entryObj);
			if (!entry ||
					entry->GetEntryType () != requestedType)
				continue;

			const QString& id = entry->GetHumanReadableID ();
			Ui_.Invitee_->addItem (QString ("%1 (%2)")
						.arg (entry->GetEntryName ())
						.arg (id),
					id);
		}
	}
	void MSNAccount::RemoveEntry (QObject *entryObj)
	{
		auto entry = qobject_cast<MSNBuddyEntry*> (entryObj);
		if (!entry)
		{
			qWarning () << Q_FUNC_INFO
					<< "invalid entry"
					<< entryObj;
			return;
		}

		const auto& id = ZheetUtil::ToStd (entry->GetContactID ());
		const auto& pass = ZheetUtil::ToStd (entry->GetHumanReadableID ());
		Conn_->delFromAddressBook (id, pass);
	}
Exemple #4
0
	void EntryBase::SetVCard (const QXmppVCardIq& vcard)
	{
		if (VCardDialog_)
			VCardDialog_->UpdateInfo (vcard);

		Account_->GetParentProtocol ()->GetVCardStorage ()->SetVCard (GetHumanReadableID (), vcard);

		emit vcardUpdated ();

		const auto& newPhotoHash = ComputeVCardPhotoHash (vcard);
		if (newPhotoHash != VCardPhotoHash_)
		{
			VCardPhotoHash_ = newPhotoHash;
			WriteDownPhotoHash ();
			emit avatarChanged (this);
		}
	}
Exemple #5
0
	QFuture<QImage> EntryBase::RefreshAvatar (Size)
	{
		const auto maybeVCard = Account_->GetParentProtocol ()->
				GetVCardStorage ()->GetVCard (GetHumanReadableID ());
		if (maybeVCard && VCardPhotoHash_ == ComputeVCardPhotoHash (*maybeVCard))
			return Util::MakeReadyFuture (QImage::fromData (maybeVCard->photo ()));

		QFutureInterface<QImage> iface;
		iface.reportStarted ();
		Account_->GetClientConnection ()->FetchVCard (GetJID (),
				[iface] (const QXmppVCardIq& iq) mutable
				{
					const auto& photo = iq.photo ();
					const auto image = photo.isEmpty () ?
							QImage {} :
							QImage::fromData (photo);
					iface.reportFinished (&image);
				});

		return iface.future ();
	}
Exemple #6
0
	QString Buddy::GetEntryID () const
	{
		return Account_->GetAccountID () + GetHumanReadableID ();
	}
	void ContactDropFilter::HandleContactsDropped (const QMimeData *data)
	{
		const auto thisEntry = GetEntry<ICLEntry> (EntryId_);
		const bool isMuc = thisEntry->GetEntryType () == ICLEntry::EntryType::MUC;

		auto entries = DndUtil::DecodeEntryObjs (data);
		entries.erase (std::remove_if (entries.begin (), entries.end (),
					[thisEntry] (QObject *entryObj)
					{
						return !CanEntryBeInvited (thisEntry,
								qobject_cast<ICLEntry*> (entryObj));
					}),
				entries.end ());

		if (entries.isEmpty ())
			return;

		QString text;
		if (entries.size () > 1)
			text = isMuc ?
					tr ("Enter reason to invite %n contact(s) to %1:", 0, entries.size ())
						.arg (thisEntry->GetEntryName ()) :
					tr ("Enter reason to invite %1 to %n conference(s):", 0, entries.size ())
						.arg (thisEntry->GetEntryName ());
		else
		{
			const auto muc = isMuc ?
					thisEntry :
					qobject_cast<ICLEntry*> (entries.first ());
			const auto entry = isMuc ?
					qobject_cast<ICLEntry*> (entries.first ()) :
					thisEntry;
			text = tr ("Enter reason to invite %1 to %2:")
					.arg (entry->GetEntryName ())
					.arg (muc->GetEntryName ());
		}

		bool ok = false;
		auto reason = QInputDialog::getText (nullptr,
				tr ("Invite to a MUC"),
				text,
				QLineEdit::Normal,
				{},
				&ok);
		if (!ok)
			return;

		if (isMuc)
		{
			const auto muc = qobject_cast<IMUCEntry*> (thisEntry->GetQObject ());

			for (const auto& entry : entries)
				muc->InviteToMUC (qobject_cast<ICLEntry*> (entry)->GetHumanReadableID (), reason);
		}
		else
		{
			const auto thisId = thisEntry->GetHumanReadableID ();

			for (const auto& mucEntryObj : entries)
			{
				const auto muc = qobject_cast<IMUCEntry*> (mucEntryObj);
				muc->InviteToMUC (thisId, reason);
			}
		}
	}
Exemple #8
0
	void EntryBase::WriteDownPhotoHash () const
	{
		const auto vcardStorage = Account_->GetParentProtocol ()->GetVCardStorage ();
		vcardStorage->SetVCardPhotoHash (GetHumanReadableID (), VCardPhotoHash_);
	}
Exemple #9
0
	QXmppVCardIq EntryBase::GetVCard () const
	{
		const auto storage = Account_->GetParentProtocol ()->GetVCardStorage ();
		return storage->GetVCard (GetHumanReadableID ()).get_value_or ({});
	}
Exemple #10
0
	void MRIMBuddy::DrawAttention (const QString& text, const QString&)
	{
		A_->GetConnection ()->SendAttention (GetHumanReadableID (), text);
	}
Exemple #11
0
	void MRIMBuddy::ShowInfo ()
	{
		A_->RequestInfo (GetHumanReadableID ());
	}
Exemple #12
0
	void MRIMBuddy::SetChatPartState (ChatPartState state, const QString&)
	{
		A_->SetTypingState (GetHumanReadableID (), state);
	}