Beispiel #1
0
void Utils::rtrim(wstring& s, const wchar_t c)
{
    while (!s.empty() && s.back() == c)
    {
        s.pop_back();
    }
}
Beispiel #2
0
wstring Helpers::EscapeCommandLineArg(const wstring& str)
{
	wstring result(L"\"");
	result += str;
	if( str.back() == L'\\' )
		result += L"\\";
	result += L"\"";

	return result;
}
void ConnectedShortcut::reconnect(const wstring& settingsArgs)
{
	if (!isConnected())
		return;

	wstring largs = CommandLineParser::joinArguments(getLArgs());
	if (!settingsArgs.empty() && settingsArgs.back() != L' ')
		largs.insert(largs.begin(), L' ');

	m_pLink->SetArguments((settingsArgs + largs).data());
}
Beispiel #4
0
 bool JstrChecker::IS_STRING(const wstring &str, wstring &strvl) {
     if (str.front() != JsonSymbol::STRING_BOUND || str.back() != JsonSymbol::STRING_BOUND) return false;
     strvl = L"";
     for (size_t i = 1; i < str.size() - 1; i++) {
         if (str[i] == JsonSymbol::ESCAPE_SYM) {
             if (i == str.size() - 2) return false;
             strvl.push_back(ESCAPE(str[i + 1]));
             i++;
         } else if (str[i] == JsonSymbol::STRING_BOUND) {
             return false;
         } else {
             strvl.push_back(str[i]);
         }
     }
     return true;
 }
void ConnectedShortcut::connect(const wstring& settingsArgs)
{
	if (isConnected())
		return;
	
	wstring args = getArguments();
	wstring target = CommandLineParser::escapeArgument(getPath());
	wstring description = SHORT_APP_NAME L" + " + getDescription();
	wstring workingDirectory = getWorkingDirectory();

	if (!args.empty())
		target.push_back(L' ');
	if (!settingsArgs.empty() && settingsArgs.back() != L' ')
		target.insert(target.begin(), L' ');

	// SetPath seems to change the working directory, too.
	// We want to keep the original directory, however.
	m_pLink->SetPath(getSelfPath().data());
	m_pLink->SetArguments((settingsArgs + target + args).data());
	m_pLink->SetDescription(description.data());
	m_pLink->SetWorkingDirectory(workingDirectory.data());

	m_isConnectedCachedResult = true;
}
void ChkFolderPath(wstring& strPath)
{
	if( strPath.empty() == false && strPath.back() == L'\\' ){
		strPath.pop_back();
	}
}
Beispiel #7
0
static BOOL ExpandMacro(wstring var, PLUGIN_RESERVE_INFO* info, EPG_EVENT_INFO* epgInfo, wstring& convert)
{
	//�֐���ς�
	vector<wstring> funcStack;
	while( !var.empty() && var.back() == L')' ){
		size_t n = var.find(L'(');
		if( n == wstring::npos ){
			return FALSE;
		}
		funcStack.push_back(var.substr(0, n));
		var = var.substr(n + 1, var.size() - 1 - (n + 1));
	}

	wstring strSDW28;
	SYSTEMTIME t28TimeS;
	if( 0 <= info->startTime.wHour && info->startTime.wHour < 4 ){
		GetSumTime(info->startTime, -24*60*60, &t28TimeS);
		GetDayOfWeekString2(t28TimeS, strSDW28);
		t28TimeS.wHour+=24;
	}else{
		t28TimeS = info->startTime;
		GetDayOfWeekString2(t28TimeS, strSDW28);
	}

	SYSTEMTIME tEnd;
	GetI64Time(info->startTime, info->durationSec, NULL, NULL, &tEnd);

	wstring strEDW28;
	SYSTEMTIME t28TimeE;
	if( 0 <= tEnd.wHour && tEnd.wHour < 4 ){
		GetSumTime(tEnd, -24*60*60, &t28TimeE);
		GetDayOfWeekString2(t28TimeE, strEDW28);
		t28TimeE.wHour+=24;
	}else{
		t28TimeE = tEnd;
		GetDayOfWeekString2(t28TimeE, strEDW28);
	}

	wstring ret;
	if( var == L"Title" )	ret = info->eventName;
	else if( var == L"SDYYYY" )	Format(ret, L"%04d", info->startTime.wYear);
	else if( var == L"SDYY" )	Format(ret, L"%02d", info->startTime.wYear%100);
	else if( var == L"SDMM" )	Format(ret, L"%02d", info->startTime.wMonth);
	else if( var == L"SDM" )	Format(ret, L"%d", info->startTime.wMonth);
	else if( var == L"SDDD" )	Format(ret, L"%02d", info->startTime.wDay);
	else if( var == L"SDD" )	Format(ret, L"%d", info->startTime.wDay);
	else if( var == L"SDW" )	GetDayOfWeekString2(info->startTime, ret);
	else if( var == L"STHH" )	Format(ret, L"%02d", info->startTime.wHour);
	else if( var == L"STH" )	Format(ret, L"%d", info->startTime.wHour);
	else if( var == L"STMM" )	Format(ret, L"%02d", info->startTime.wMinute);
	else if( var == L"STM" )	Format(ret, L"%d", info->startTime.wMinute);
	else if( var == L"STSS" )	Format(ret, L"%02d", info->startTime.wSecond);
	else if( var == L"STS" )	Format(ret, L"%d", info->startTime.wSecond);
	else if( var == L"EDYYYY" )	Format(ret, L"%04d", tEnd.wYear);
	else if( var == L"EDYY" )	Format(ret, L"%02d", tEnd.wYear%100);
	else if( var == L"EDMM" )	Format(ret, L"%02d", tEnd.wMonth);
	else if( var == L"EDM" )	Format(ret, L"%d", tEnd.wMonth);
	else if( var == L"EDDD" )	Format(ret, L"%02d", tEnd.wDay);
	else if( var == L"EDD" )	Format(ret, L"%d", tEnd.wDay);
	else if( var == L"EDW" )	GetDayOfWeekString2(tEnd, ret);
	else if( var == L"ETHH" )	Format(ret, L"%02d", tEnd.wHour);
	else if( var == L"ETH" )	Format(ret, L"%d", tEnd.wHour);
	else if( var == L"ETMM" )	Format(ret, L"%02d", tEnd.wMinute);
	else if( var == L"ETM" )	Format(ret, L"%d", tEnd.wMinute);
	else if( var == L"ETSS" )	Format(ret, L"%02d", tEnd.wSecond);
	else if( var == L"ETS" )	Format(ret, L"%d", tEnd.wSecond);
	else if( var == L"ONID10" )	Format(ret, L"%d", info->ONID);
	else if( var == L"TSID10" )	Format(ret, L"%d", info->TSID);
	else if( var == L"SID10" )	Format(ret, L"%d", info->SID);
	else if( var == L"EID10" )	Format(ret, L"%d", info->EventID);
	else if( var == L"ONID16" )	Format(ret, L"%04X", info->ONID);
	else if( var == L"TSID16" )	Format(ret, L"%04X", info->TSID);
	else if( var == L"SID16" )	Format(ret, L"%04X", info->SID);
	else if( var == L"EID16" )	Format(ret, L"%04X", info->EventID);
	else if( var == L"ServiceName" )	ret = info->serviceName;
	else if( var == L"SDYYYY28" )	Format(ret, L"%04d", t28TimeS.wYear);
	else if( var == L"SDYY28" )	Format(ret, L"%02d", t28TimeS.wYear%100);
	else if( var == L"SDMM28" )	Format(ret, L"%02d", t28TimeS.wMonth);
	else if( var == L"SDM28" )	Format(ret, L"%d", t28TimeS.wMonth);
	else if( var == L"SDDD28" )	Format(ret, L"%02d", t28TimeS.wDay);
	else if( var == L"SDD28" )	Format(ret, L"%d", t28TimeS.wDay);
	else if( var == L"SDW28" )	ret = strSDW28;
	else if( var == L"STHH28" )	Format(ret, L"%02d", t28TimeS.wHour);
	else if( var == L"STH28" )	Format(ret, L"%d", t28TimeS.wHour);
	else if( var == L"EDYYYY28" )	Format(ret, L"%04d", t28TimeE.wYear);
	else if( var == L"EDYY28" )	Format(ret, L"%02d", t28TimeE.wYear%100);
	else if( var == L"EDMM28" )	Format(ret, L"%02d", t28TimeE.wMonth);
	else if( var == L"EDM28" )	Format(ret, L"%d", t28TimeE.wMonth);
	else if( var == L"EDDD28" )	Format(ret, L"%02d", t28TimeE.wDay);
	else if( var == L"EDD28" )	Format(ret, L"%d", t28TimeE.wDay);
	else if( var == L"EDW28" )	ret = strEDW28;
	else if( var == L"ETHH28" )	Format(ret, L"%02d", t28TimeE.wHour);
	else if( var == L"ETH28" )	Format(ret, L"%d", t28TimeE.wHour);
	else if( var == L"DUHH" )	Format(ret, L"%02d", info->durationSec/(60*60));
	else if( var == L"DUH" )	Format(ret, L"%d", info->durationSec/(60*60));
	else if( var == L"DUMM" )	Format(ret, L"%02d", (info->durationSec%(60*60))/60);
	else if( var == L"DUM" )	Format(ret, L"%d", (info->durationSec%(60*60))/60);
	else if( var == L"DUSS" )	Format(ret, L"%02d", info->durationSec%60);
	else if( var == L"DUS" )	Format(ret, L"%d", info->durationSec%60);
	else if( var == L"Title2" ){
		ret = info->eventName;
		while( ret.find(L"[") != wstring::npos && ret.find(L"]") != wstring::npos ){
			wstring strSep1;
			wstring strSep2;
			Separate(ret, L"[", ret, strSep1);
			Separate(strSep1, L"]", strSep2, strSep1);
			ret += strSep1;
		}
	}else if( var == L"Genre" ){
		if( epgInfo != NULL && epgInfo->contentInfo != NULL && epgInfo->contentInfo->listSize > 0 ){
			GetGenreName(epgInfo->contentInfo->nibbleList[0].content_nibble_level_1, 0xFF, ret);
		}
	}else if( var == L"Genre2" ){
		if( epgInfo != NULL && epgInfo->contentInfo != NULL && epgInfo->contentInfo->listSize > 0 ){
			GetGenreName(epgInfo->contentInfo->nibbleList[0].content_nibble_level_1, epgInfo->contentInfo->nibbleList[0].content_nibble_level_2, ret);
		}
	}else if( var == L"SubTitle" ){
		if( epgInfo != NULL && epgInfo->shortInfo != NULL ){
			ret = epgInfo->shortInfo->text_char;
		}
	}else if( var == L"SubTitle2" ){
		if( epgInfo != NULL && epgInfo->shortInfo != NULL ){
			wstring strSubTitle2 = epgInfo->shortInfo->text_char;
			strSubTitle2 = strSubTitle2.substr(0, strSubTitle2.find(L"\r\n"));
			LPCWSTR startsWith[] = { L"#����", L"0123456789�O�P�Q�R�S�T�U�V�W�X", NULL };
			for( size_t j, i = 0; i < strSubTitle2.size(); i++ ){
				for( j = 0; startsWith[i][j] && startsWith[i][j] != strSubTitle2[i]; j++ );
				if( startsWith[i][j] == L'\0' ){
					break;
				}
				if( startsWith[i+1] == NULL ){
					ret = strSubTitle2;
					break;
				}
			}
		}
	}else{
		return FALSE;
	}

	//�֐���K�p
	while( !funcStack.empty() ){
		wstring func = funcStack.back();
		funcStack.pop_back();
		for( size_t i = 0; i < func.size(); i++ ){
			//���l�����Q��(&�����R�[�h;)��W�J
			if( func[i] == L'&' ){
				wchar_t* p;
				wchar_t c = (wchar_t)wcstol(&func.c_str()[i + 1], &p, 10);
				func.replace(i, p - func.c_str() - i + (*p ? 1 : 0), 1, c);
			}
		}
		if( func == L"HtoZ" ){
			funcStack.push_back(L"Tr�_ !\"#&36;%&38;'&40;)*+,-./:;<=>?@[\\]^_`{|}~�_�@�I�h���������f�i�j���{�C�|�D�^�F�G�������H���m���n�O�Q�e�o�b�p�P�_");
			funcStack.push_back(L"HtoZ<alnum>");
		}else if( func == L"ZtoH" ){
			funcStack.push_back(L"Tr�_�@�I�h���������f�i�j���{�C�|�D�^�F�G�������H���m���n�O�Q�e�o�b�p�P�_ !\"#&36;%&38;'&40;)*+,-./:;<=>?@[\\]^_`{|}~�_");
			funcStack.push_back(L"ZtoH<alnum>");
		}else if( func == L"HtoZ<alnum>" ){
			funcStack.push_back(L"Tr/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/�O�P�Q�R�S�T�U�V�W�X�`�a�b�c�d�e�f�g�h�i�j�k�l�m�n�o�p�q�r�s�t�u�v�w�x�y����������������������������������������������������/");
		}else if( func == L"ZtoH<alnum>" ){
			funcStack.push_back(L"Tr/�O�P�Q�R�S�T�U�V�W�X�`�a�b�c�d�e�f�g�h�i�j�k�l�m�n�o�p�q�r�s�t�u�v�w�x�y����������������������������������������������������/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/");
		}else if( func.compare(0, 2, L"Tr") == 0 && func.size() >= 3 ){
			//�����u��(Tr/�u���������X�g/�u����/)
			size_t n = func.find(func[2], 3);
			if( n == wstring::npos ){
				return FALSE;
			}
			if( func.find(func[2], n + 1) != 4 + (n - 3) * 2 ){
				return FALSE;
			}
			wstring cmp(func, 3, n - 3);
			for( wstring::iterator itr = ret.begin(); itr != ret.end(); itr++ ){
				size_t m = cmp.find(*itr);
				if( m != wstring::npos ){
					*itr = func[n + 1 + m];
				}
			}
		}else if( func.compare(0, 2, L"Rm") == 0 && func.size() >= 3 ){
			//�����폜(Rm/�폜�������X�g/)
			size_t n = func.find(func[2], 3);
			if( n == wstring::npos ){
				return FALSE;
			}
			wstring cmp(func, 3, n - 3);
			for( wstring::iterator itr = ret.begin(); itr != ret.end(); ){
				if( cmp.find(*itr) != wstring::npos ){
					itr = ret.erase(itr);
				}else{
					itr++;
				}
			}
		}else if( func.compare(0, 2, L"Head") && func.size() >= 5 ){
			//���؂�(Head������)
			ret = ret.substr(0, wcstol(&func.c_str()[4], NULL, 10));
		}else{
			return FALSE;
		}
	}

	convert += ret;

	return TRUE;
}