コード例 #1
0
	void SavePassword (const QString& password, const QString& key,
			const ICoreProxy_ptr& proxy)
	{
		const auto& plugins = proxy->GetPluginsManager ()->GetAllCastableTo<IPersistentStoragePlugin*> ();
		for (const auto plugin : plugins)
			if (const auto& storage = plugin->RequestStorage ())
				storage->Set (key.toUtf8 (), password);
	}
コード例 #2
0
ファイル: lastseen.cpp プロジェクト: ForNeVeR/leechcraft
	void Plugin::Init (ICoreProxy_ptr proxy)
	{
		Util::InstallTranslator ("azoth_lastseen");

		qRegisterMetaType<LastHash_t> ("LeechCraft::Azoth::LastSeen::LastHash_t");
		qRegisterMetaTypeStreamOperators<LastHash_t> ("LeechCraft::Azoth::LastSeen::LastHash_t");

		Storage_ = std::make_shared<OnDiskStorage> ();

		Migrate (proxy->GetPluginsManager ());
	}
コード例 #3
0
	QVariant GetPersistentData (const QByteArray& key,
			const ICoreProxy_ptr& proxy)
	{
		const auto& plugins = proxy->GetPluginsManager ()->
				GetAllCastableTo<IPersistentStoragePlugin*> ();
		for (const auto plug : plugins)
		{
			const auto& storage = plug->RequestStorage ();
			if (!storage)
				continue;

			const auto& value = storage->Get (key);
			if (!value.isNull ())
				return value;
		}
		return {};
	}
コード例 #4
0
ファイル: checker.cpp プロジェクト: DJm00n/leechcraft
	Checker::Checker (CheckModel *model,
			const QList<Media::ReleaseInfo::Type>& types,
			const ILMPProxy_ptr& lmpProxy,
			const ICoreProxy_ptr& coreProxy,
			QObject *parent)
	: QObject { parent }
	, Model_ { model }
	, Provider_ { coreProxy->GetPluginsManager ()->
				GetAllCastableTo<Media::IDiscographyProvider*> ().value (0) }
	, LmpProxy_ { lmpProxy }
	, Types_ { types }
	, Artists_ { Model_->GetSelectedArtists () }
	{
		if (!Provider_)
		{
			qWarning () << Q_FUNC_INFO
					<< "no providers :(";
			deleteLater ();
			return;
		}

		rotateQueue ();
	}
コード例 #5
0
ファイル: checkmodel.cpp プロジェクト: DJm00n/leechcraft
	CheckModel::CheckModel (const Collection::Artists_t& artists,
			const ICoreProxy_ptr& proxy, const ILMPProxy_ptr& lmpProxy, QObject *parent)
	: RoleNamesMixin<QStandardItemModel> { parent }
	, AllArtists_ { artists }
	, Proxy_ { lmpProxy }
	, DefaultAlbumIcon_ { GetIcon (proxy, "media-optical", AASize * 2) }
	, DefaultArtistIcon_ { GetIcon (proxy, "view-media-artist", ArtistSize * 2) }
	, AAProv_ { proxy->GetPluginsManager ()->
				GetAllCastableTo<Media::IAlbumArtProvider*> ().value (0) }
	, BioProv_ { proxy->GetPluginsManager ()->
				GetAllCastableTo<Media::IArtistBioFetcher*> ().value (0) }
	{
		QHash<int, QByteArray> roleNames;
		roleNames [Role::ArtistId] = "artistId";
		roleNames [Role::ArtistName] = "artistName";
		roleNames [Role::ScheduledToCheck] = "scheduled";
		roleNames [Role::IsChecked] = "isChecked";
		roleNames [Role::ArtistImage] = "artistImageUrl";
		roleNames [Role::Releases] = "releases";
		roleNames [Role::MissingCount] = "missingCount";
		roleNames [Role::PresentCount] = "presentCount";
		setRoleNames (roleNames);

		for (const auto& artist : artists)
		{
			if (artist.Name_.contains (" vs. ") ||
					artist.Name_.contains (" with ") ||
					artist.Albums_.isEmpty ())
				continue;

			auto item = new QStandardItem { artist.Name_ };
			item->setData (artist.ID_, Role::ArtistId);
			item->setData (artist.Name_, Role::ArtistName);
			item->setData (true, Role::ScheduledToCheck);
			item->setData (false, Role::IsChecked);
			item->setData (DefaultArtistIcon_, Role::ArtistImage);
			item->setData (0, Role::MissingCount);
			item->setData (artist.Albums_.size (), Role::PresentCount);

			const auto submodel = new ReleasesSubmodel { this };
			item->setData (QVariant::fromValue<QObject*> (submodel), Role::Releases);

			appendRow (item);

			Artist2Submodel_ [artist.ID_] = submodel;
			Artist2Item_ [artist.ID_] = item;

			Scheduled_ << artist.ID_;

			const auto proxy = BioProv_->RequestArtistBio (artist.Name_, false);
			new Util::OneTimeRunner
			{
				[this, artist, item, proxy] () -> void
				{
					if (!Artist2Item_.contains (artist.ID_))
						return;

					const auto& url = proxy->GetArtistBio ().BasicInfo_.LargeImage_;
					item->setData (url, Role::ArtistImage);
				},
				proxy->GetQObject (),
				{
					SIGNAL (ready ()),
					SIGNAL (error ())
				},
				this
			};
		}
	}