コード例 #1
0
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
	Measure* measure = (Measure*)data;
	measure->rm = rm;
	
	//初始化 PlayerName
	LPCWSTR str = RmReadString(rm, L"PlayerName", L"");

	if (!_wcsicmp(L"KwMusic", str))
	{
		measure->name = PLAYER_KUWO;
		measure->player = KwMusic::Create();
	}
	else if (!_wcsicmp(L"KgMusic", str))
	{
		measure->name = PLAYER_KUGOU;
		measure->player = KgMusic::Create();
	}
	else if (!_wcsicmp(L"QQMusic", str))
	{
		measure->name = PLAYER_QQ;
		measure->player = QQMusic::Create();
	}
	else if (!_wcsicmp(L"BaiduMusic", str))
	{
		measure->name = PLAYER_BAIDU;
		measure->player = BaiduMusic::Create();
	}
	else
	{

		measure->name = PLAYER_KUWO;
		measure->player = KwMusic::Create();

		wstring error = L"MusicPlayer.dll: Invalid PlayerName=";
		error += str;
		error += L" in [";
		error += RmGetMeasureName(rm);
		error += L"]";
		RmLog(LOG_WARNING, error.c_str());
	}



	//初始化 PlayerType
	str = RmReadString(rm, L"PlayerType", L"");

	if (_wcsicmp(L"TITLE", str) == 0)
	{
		measure->type = MEASURE_TITLE;
	}
	else if (_wcsicmp(L"ARTIST", str) == 0)
	{
		measure->type = MEASURE_ARTIST;
	}
	else if (_wcsicmp(L"TRACK", str) == 0)
	{
		measure->type = MEASURE_TRACK;
	}
	else if (_wcsicmp(L"PLAYERPATH", str) == 0)
	{
		measure->type = MEASURE_PLAYERPATH;
		measure->playerpath = RmReadString(rm, L"PlayerPath", L"");
	}
	else if (_wcsicmp(L"STATUS", str) == 0)
	{
		measure->type = MEASURE_STATUS;
	}
	else if (_wcsicmp(L"COVER", str) == 0)
	{
		measure->type = MEASURE_COVER;
		switch (measure->name)
		{
		case PLAYER_KUGOU:
		case PLAYER_QQ:
			measure->player->m_RequireCover = true;
		}
	}
	else
	{
		std::wstring error = L"MusicPlayer.dll: Invalid PlayerType=";
		error += str;
		error += L" in [";
		error += RmGetMeasureName(rm);
		error += L"]";
		RmLog(LOG_WARNING, error.c_str());
	}

	measure->trackChangeAction = RmReadString(rm, L"TrackChangeAction", L"");

}
コード例 #2
0
ファイル: WebParser.cpp プロジェクト: ksujaym/rainmeter
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
	MeasureData* measure = (MeasureData*)data;

	EnterCriticalSection(&g_CriticalSection);

	/* Read our own settings from the ini-file */

	std::wstring url = RmReadString(rm, L"Url", L"", FALSE);

	std::wstring::size_type start = 0;
	while ((start = url.find(L"[&", start)) != std::wstring::npos)
	{
		std::wstring::size_type si = start + 1;
		std::wstring::size_type end = url.find(L']', si);
		if (end == std::wstring::npos) break;

		std::wstring var = L"[";
		var.append(url, si + 1, end - si);

		const WCHAR* result = RmReplaceVariables(rm, var.c_str());
		const size_t resultLength = wcslen(result);
		url.replace(start, end - start + 1, result, resultLength);
		start += resultLength;
	}

	measure->url = url;

	measure->regExp = RmReadString(rm, L"RegExp", L"");
	measure->finishAction = RmReadString(rm, L"FinishAction", L"", FALSE);
	measure->onRegExpErrAction = RmReadString(rm, L"OnRegExpErrorAction", L"", FALSE);
	measure->onConnectErrAction = RmReadString(rm, L"OnConnectErrorAction", L"", FALSE);
	measure->onDownloadErrAction = RmReadString(rm, L"OnDownloadErrorAction", L"", FALSE);
	measure->errorString = RmReadString(rm, L"ErrorString", L"");

	int index = RmReadInt(rm, L"StringIndex", 0);
	measure->stringIndex = index < 0 ? 0 : index;

	index = RmReadInt(rm, L"StringIndex2", 0);
	measure->stringIndex2 = index < 0 ? 0 : index;

	measure->decodeCharacterReference = RmReadInt(rm, L"DecodeCharacterReference", 0);
	measure->updateRate = RmReadInt(rm, L"UpdateRate", 600);
	measure->forceReload = 0!=RmReadInt(rm, L"ForceReload", 0);
	measure->codepage = RmReadInt(rm, L"CodePage", 0);
	if (measure->codepage == 0)
	{
		measure->codepage = CP_UTF8;
	}

	measure->download = 0!=RmReadInt(rm, L"Download", 0);
	if (measure->download)
	{
		measure->downloadFolder = RmPathToAbsolute(rm, L"DownloadFile\\");
		measure->downloadFile = RmReadString(rm, L"DownloadFile", L"");
	}
	else
	{
		measure->downloadFile.clear();
	}

	measure->debug = RmReadInt(rm, L"Debug", 0);
	if (measure->debug == 2)
	{
		measure->debugFileLocation = RmReadPath(rm, L"Debug2File", L"WebParserDump.txt");
		RmLog(rm, LOG_DEBUG, measure->debugFileLocation.c_str());
	}

	LeaveCriticalSection(&g_CriticalSection);
}
コード例 #3
0
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
	Measure* measure = (Measure*)data;

	// Data is stored in two structs: Measure and ParentMeasure. ParentMeasure is created for measures
	// with PlayerName=someplayer. Measure is created for all measures and points to ParentMeasure as
	// referenced in PlayerName=[section].

	// Read settings from the ini-file
	void* skin = RmGetSkin(rm);
	LPCWSTR str = RmReadString(rm, L"PlayerName", L"", FALSE);
	if (str[0] == L'[')
	{
		if (measure->parent)
		{
			// Don't let a measure measure change its parent
		}
		else
		{
			// PlayerName starts with [ so use referenced section
			++str;
			size_t len = wcslen(str);
			if (len > 0 && str[len - 1] == L']')
			{
				--len;

				std::vector<ParentMeasure*>::iterator iter = g_ParentMeasures.begin();
				for ( ; iter != g_ParentMeasures.end(); ++iter)
				{
					if (skin == (*iter)->skin &&
						_wcsnicmp(str, (*iter)->ownerName, len) == 0)
					{
						// Use same ParentMeasure as referenced section
						measure->parent = (*iter);
						++measure->parent->measureCount;

						break;
					}
				}

				if (!measure->parent)
				{
					// The referenced section doesn't exist
					std::wstring error = L"NowPlaying.dll: Invalid PlayerName=";
					error.append(str - 1, len + 2);
					error += L" in [";
					error += RmGetMeasureName(rm);
					error += L"]";
					RmLog(LOG_WARNING, error.c_str());
					return;
				}
			}
		}
	}
	else
	{
		// ParentMeasure is created when PlayerName is an actual player (and not a reference)
		ParentMeasure* parent = measure->parent;
		Player* oldPlayer = nullptr;
		if (parent)
		{
			if (parent->data != data)
			{
				// Don't let a measure-only measure become a parent measure
				return;
			}

			oldPlayer = parent->player;
		}
		else
		{
			parent = new ParentMeasure;
			g_ParentMeasures.push_back(parent);
			parent->data = data;
			parent->skin = skin;
			parent->ownerName = RmGetMeasureName(rm);
			measure->parent = parent;
		}

		if (_wcsicmp(L"AIMP", str) == 0)
		{
			parent->player = PlayerAIMP::Create();
		}
		else if (_wcsicmp(L"CAD", str) == 0)
		{
			parent->player = PlayerCAD::Create();
		}
		else if (_wcsicmp(L"foobar2000", str) == 0)
		{
			HWND fooWindow = FindWindow(L"foo_rainmeter_class", nullptr);
			if (fooWindow)
			{
				const WCHAR* error = L"Your foobar2000 plugin is out of date.\n\nDo you want to update the plugin now?";
				if (MessageBox(nullptr, error, L"Rainmeter", MB_YESNO | MB_ICONINFORMATION | MB_TOPMOST) == IDYES)
				{
					ShellExecute(nullptr, L"open", L"http://github.com/poiru/foo-cad#readme", nullptr, nullptr, SW_SHOWNORMAL);
				}
			}

			parent->player = PlayerCAD::Create();
		}
		else if (_wcsicmp(L"iTunes", str) == 0)
		{
			parent->player = PlayerITunes::Create();
		}
		else if (_wcsicmp(L"MediaMonkey", str) == 0)
		{
			parent->player = PlayerWinamp::Create(WA_MEDIAMONKEY);
		}
		else if (_wcsicmp(L"Spotify", str) == 0)
		{
			parent->player = PlayerSpotify::Create();
		}
		else if (_wcsicmp(L"WinAmp", str) == 0)
		{
			parent->player = PlayerWinamp::Create(WA_WINAMP);
		}
		else if (_wcsicmp(L"WMP", str) == 0)
		{
			parent->player = PlayerWMP::Create();
		}
		else
		{
			// Default to WLM
			parent->player = PlayerWLM::Create();

			if (_wcsicmp(L"WLM", str) != 0)
			{
				std::wstring error = L"NowPlaying.dll: Invalid PlayerName=";
				error += str;
				error += L" in [";
				error += parent->ownerName;
				error += L"]";
				RmLog(LOG_ERROR, error.c_str());
			}
		}

		parent->player->AddInstance();
		parent->playerPath = RmReadString(rm, L"PlayerPath", L"");
		parent->trackChangeAction = RmReadString(rm, L"TrackChangeAction", L"", FALSE);
		parent->disableLeadingZero = RmReadInt(rm, L"DisableLeadingZero", 0) != 0;

		if (oldPlayer)
		{
			parent->player->SetMeasures(oldPlayer->GetMeasures());

			// Remove instance here so that player doesn't have to reinitialize if PlayerName was
			// not changed.
			oldPlayer->RemoveInstance();
		}
	}

	str = RmReadString(rm, L"PlayerType", L"");
	if (_wcsicmp(L"ARTIST", str) == 0)
	{
		measure->type = MEASURE_ARTIST;
	}
	else if (_wcsicmp(L"TITLE", str) == 0)
	{
		measure->type = MEASURE_TITLE;
	}
	else if (_wcsicmp(L"ALBUM", str) == 0)
	{
		measure->type = MEASURE_ALBUM;
	}
	else if (_wcsicmp(L"COVER", str) == 0)
	{
		measure->type = MEASURE_COVER;
	}
	else if (_wcsicmp(L"DURATION", str) == 0)
	{
		measure->type = MEASURE_DURATION;
	}
	else if (_wcsicmp(L"POSITION", str) == 0)
	{
		measure->type = MEASURE_POSITION;
	}
	else if (_wcsicmp(L"PROGRESS", str) == 0)
	{
		measure->type = MEASURE_PROGRESS;
		*maxValue = 100.0;
	}
	else if (_wcsicmp(L"RATING", str) == 0)
	{
		measure->type = MEASURE_RATING;
		*maxValue = 5.0;
	}
	else if (_wcsicmp(L"STATE", str) == 0)
	{
		measure->type = MEASURE_STATE;
	}
	else if (_wcsicmp(L"STATUS", str) == 0)
	{
		measure->type = MEASURE_STATUS;
	}
	else if (_wcsicmp(L"VOLUME", str) == 0)
	{
		measure->type = MEASURE_VOLUME;
		*maxValue = 100.0;
	}
	else if (_wcsicmp(L"SHUFFLE", str) == 0)
	{
		measure->type = MEASURE_SHUFFLE;
	}
	else if (_wcsicmp(L"REPEAT", str) == 0)
	{
		measure->type = MEASURE_REPEAT;
	}
	else if (_wcsicmp(L"LYRICS", str) == 0)
	{
		RmLog(LOG_WARNING, L"NowPlaying.dll: Using undocumented PlayerType=LYRICS!");
		measure->type = MEASURE_LYRICS;
	}
	else if (_wcsicmp(L"FILE", str) == 0)
	{
		measure->type = MEASURE_FILE;
	}
	else if (_wcsicmp(L"NUMBER", str) == 0)
	{
		measure->type = MEASURE_NUMBER;
	}
	else if (_wcsicmp(L"YEAR", str) == 0)
	{
		measure->type = MEASURE_YEAR;
	}
	else
	{
		std::wstring error = L"NowPlaying.dll: Invalid PlayerType=";
		error += str;
		error += L" in [";
		error += RmGetMeasureName(rm);
		error += L"]";
		RmLog(LOG_WARNING, error.c_str());
	}

	measure->parent->player->AddMeasure(measure->type);
}
コード例 #4
0
ファイル: SysInfo.cpp プロジェクト: JamesAC/rainmeter
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
	MeasureData* measure = (MeasureData*)data;

	int defaultData = -1;

	LPCTSTR type = RmReadString(rm, L"SysInfoType", L"");
	if (_wcsicmp(L"COMPUTER_NAME", type) == 0)
	{
		measure->type = MEASURE_COMPUTER_NAME;
	}
	else if (_wcsicmp(L"USER_NAME", type) == 0)
	{
		measure->type = MEASURE_USER_NAME;
	}
	else if (_wcsicmp(L"WORK_AREA", type) == 0)
	{
		measure->type = MEASURE_WORK_AREA;
	}
	else if (_wcsicmp(L"SCREEN_SIZE", type) == 0)
	{
		measure->type = MEASURE_SCREEN_SIZE;
	}
	else if (_wcsicmp(L"RAS_STATUS", type) == 0)
	{
		measure->type = MEASURE_RAS_STATUS;
	}
	else if (_wcsicmp(L"OS_VERSION", type) == 0)
	{
		measure->type = MEASURE_OS_VERSION;
	}
	else if (_wcsicmp(L"OS_BITS", type) == 0)
	{
		measure->type = MEASURE_OS_BITS;
	}
	else if (_wcsicmp(L"ADAPTER_DESCRIPTION", type) == 0)
	{
		defaultData = 0;
		measure->type = MEASURE_ADAPTER_DESCRIPTION;
	}
	else if (_wcsicmp(L"NET_MASK", type) == 0)
	{
		defaultData = 0;
		measure->type = MEASURE_NET_MASK;
	}
	else if (_wcsicmp(L"IP_ADDRESS", type) == 0)
	{
		defaultData = 0;
		measure->type = MEASURE_IP_ADDRESS;
	}
	else if (_wcsicmp(L"GATEWAY_ADDRESS", type) == 0)
	{
		defaultData = 0;
		measure->type = MEASURE_GATEWAY_ADDRESS;
	}
	else if (_wcsicmp(L"HOST_NAME", type) == 0)
	{
		measure->type = MEASURE_HOST_NAME;
	}
	else if (_wcsicmp(L"DOMAIN_NAME", type) == 0)
	{
		measure->type = MEASURE_DOMAIN_NAME;
	}
	else if (_wcsicmp(L"DNS_SERVER", type) == 0)
	{
		measure->type = MEASURE_DNS_SERVER;
	}
	else if (_wcsicmp(L"WORK_AREA_TOP", type) == 0)
	{
		measure->type = MEASURE_WORK_AREA_TOP;
	}
	else if (_wcsicmp(L"WORK_AREA_LEFT", type) == 0)
	{
		measure->type = MEASURE_WORK_AREA_LEFT;
	}
	else if (_wcsicmp(L"WORK_AREA_WIDTH", type) == 0)
	{
		measure->type = MEASURE_WORK_AREA_WIDTH;
	}
	else if (_wcsicmp(L"WORK_AREA_HEIGHT", type) == 0)
	{
		measure->type = MEASURE_WORK_AREA_HEIGHT;
	}
	else if (_wcsicmp(L"SCREEN_WIDTH", type) == 0)
	{
		measure->type = MEASURE_SCREEN_WIDTH;
	}
	else if (_wcsicmp(L"SCREEN_HEIGHT", type) == 0)
	{
		measure->type = MEASURE_SCREEN_HEIGHT;
	}
	else if (_wcsicmp(L"NUM_MONITORS", type) == 0)
	{
		measure->type = MEASURE_NUM_MONITORS;
	}
	else if (_wcsicmp(L"VIRTUAL_SCREEN_TOP", type) == 0)
	{
		measure->type = MEASURE_VIRTUAL_SCREEN_TOP;
	}
	else if (_wcsicmp(L"VIRTUAL_SCREEN_LEFT", type) == 0)
	{
		measure->type = MEASURE_VIRTUAL_SCREEN_LEFT;
	}
	else if (_wcsicmp(L"VIRTUAL_SCREEN_WIDTH", type) == 0)
	{
		measure->type = MEASURE_VIRTUAL_SCREEN_WIDTH;
	}
	else if (_wcsicmp(L"VIRTUAL_SCREEN_HEIGHT", type) == 0)
	{
		measure->type = MEASURE_VIRTUAL_SCREEN_HEIGHT;
	}
	else
	{
		WCHAR buffer[256];
		_snwprintf_s(buffer, _TRUNCATE, L"SysInfo.dll: SysInfoType=%s is not valid in [%s]", type, RmGetMeasureName(rm));
		RmLog(LOG_ERROR, buffer);
	}

	measure->data = RmReadInt(rm, L"SysInfoData", defaultData);
}