Ejemplo n.º 1
0
int CSchemaCache::Load()
{
	WIN32_FIND_DATA pFind;
	CString strPath;
	HANDLE hSearch;
	int nCount;

	Clear();

	strPath.Format( _T("%s\\Schemas\\*.xsd"), (LPCTSTR)Settings.General.Path );
	hSearch = FindFirstFile( strPath, &pFind );
	if ( hSearch == INVALID_HANDLE_VALUE ) return 0;
	nCount = 0;

	do
	{
		strPath.Format( _T("%s\\Schemas\\%s"), (LPCTSTR)Settings.General.Path, pFind.cFileName );
		
		CSchema* pSchema = new CSchema();

		if ( pSchema->Load( strPath ) )
		{
			CString strURI( pSchema->m_sURI );
			CharLower( strURI.GetBuffer() );
			strURI.ReleaseBuffer();
			m_pURIs.SetAt( strURI, pSchema );
			
			CString strName( pSchema->m_sSingular );
			CharLower( strName.GetBuffer() );
			strName.ReleaseBuffer();
			m_pNames.SetAt( strName, pSchema );
		}
		else
		{
			delete pSchema;
		}
	}
	while ( FindNextFile( hSearch, &pFind ) );

	FindClose( hSearch );

	return nCount;
}
Ejemplo n.º 2
0
CED2KLink* CED2KLink::CreateLinkFromUrl(const TCHAR* uri)
{
	CString strURI(uri);
	int iPos = 0;
	CString strTok = GetNextString(strURI, _T("|"), iPos);
	if (strTok == _T("ed2k://"))
	{
		strTok = GetNextString(strURI, _T("|"), iPos);
		if (strTok == _T("file"))
		{
			CString strName = GetNextString(strURI, _T("|"), iPos);
			if (!strName.IsEmpty())
			{
				CString strSize = GetNextString(strURI, _T("|"), iPos);
				if (!strSize.IsEmpty())
				{
					CString strHash = GetNextString(strURI, _T("|"), iPos);
					if (!strHash.IsEmpty())
					{
						CStringArray astrEd2kParams;
						bool bEmuleExt = false;
						CString strEmuleExt;

						CString strLastTok;
						strTok = GetNextString(strURI, _T("|"), iPos);
						while (!strTok.IsEmpty())
						{
							strLastTok = strTok;
							if (strTok == _T("/"))
							{
								if (bEmuleExt)
									break;
								bEmuleExt = true;
							}
							else
							{
								if (bEmuleExt)
								{
									if (!strEmuleExt.IsEmpty())
										strEmuleExt += _T('|');
									strEmuleExt += strTok;
								}
								else
									astrEd2kParams.Add(strTok);
							}
							strTok = GetNextString(strURI, _T("|"), iPos);
						}

						if (strLastTok == _T("/"))
							return new CED2KFileLink(strName, strSize, strHash, astrEd2kParams, strEmuleExt.IsEmpty() ? (LPCTSTR)NULL : (LPCTSTR)strEmuleExt);
					}
				}
			}
		}
		else if (strTok == _T("serverlist"))
		{
			CString strURL = GetNextString(strURI, _T("|"), iPos);
			if (!strURL.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/"))
				return new CED2KServerListLink(strURL);
		}
		else if (strTok == _T("server"))
		{
			CString strServer = GetNextString(strURI, _T("|"), iPos);
			if (!strServer.IsEmpty())
			{
				CString strPort = GetNextString(strURI, _T("|"), iPos);
				if (!strPort.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/"))
					return new CED2KServerLink(strServer, strPort);
			}
		}
	}

	throw GetResString(IDS_ERR_NOSLLINK);
}
Ejemplo n.º 3
0
int CSchemaCache::Load()
{
#ifdef _DEBUG
	__int64 nStartTotal = GetMicroCount();
#endif

	Clear();

	CString strPath;
	strPath.Format( _T("%s\\Schemas\\*.xsd"), (LPCTSTR)Settings.General.Path );

	WIN32_FIND_DATA pFind = {};
	HANDLE hSearch = FindFirstFile( strPath, &pFind );
	if ( hSearch == INVALID_HANDLE_VALUE )
		return 0;

	int nCount = 0;
	do
	{
#ifdef _DEBUG
		__int64 nStart = GetMicroCount();
#endif
		strPath.Format( _T("%s\\Schemas\\%s"), (LPCTSTR)Settings.General.Path, pFind.cFileName );
		
		CSchema* pSchema = new CSchema();
		if ( pSchema && pSchema->Load( strPath ) )
		{
			CString strURI( pSchema->GetURI() );
			strURI.MakeLower();

			m_pURIs.SetAt( strURI, pSchema );
			
			CString strName( pSchema->m_sSingular );
			strName.MakeLower();

			m_pNames.SetAt( strName, pSchema );

			for ( POSITION pos = pSchema->GetFilterIterator(); pos; )
			{
				CString sType;
				BOOL bResult;
				pSchema->GetNextFilter( pos, sType, bResult );
				if ( bResult )
				{
					m_pTypeFilters.SetAt( sType, pSchema );
				}
			}

			++nCount;
		}
		else
		{
			delete pSchema;
			pSchema = NULL;
		}

#ifdef _DEBUG
		__int64 nEnd = GetMicroCount();
		TRACE( _T("Schema \"%s\" load time : %I64i ms : %s\n"), strPath,
			( nEnd - nStart ) / 1000, pSchema ? _T("SUCCESS") : _T("FAILED") );
#endif
	}
	while ( FindNextFile( hSearch, &pFind ) );

	FindClose( hSearch );

#ifdef _DEBUG
	__int64 nEndTotal = GetMicroCount();
	TRACE( _T("Schemas load time : %I64i ms. Found %d types.\n"),
		( nEndTotal - nStartTotal ) / 1000, m_pTypeFilters.GetCount() );
#endif

	return nCount;
}
Ejemplo n.º 4
0
CED2KLink* CED2KLink::CreateLinkFromUrl(const TCHAR* uri)
{
    CString strURI(uri);
    strURI.Trim(); // This function is used for various sources, trim the string again.
    int iPos = 0;
    CString strTok = GetNextString(strURI, _T("|"), iPos);
    if (strTok.CompareNoCase(_T("ed2k://")) == 0)
    {
        strTok = GetNextString(strURI, _T("|"), iPos);
        if (strTok == _T("file"))
        {
            CString strName = GetNextString(strURI, _T("|"), iPos);
            if (!strName.IsEmpty())
            {
                CString strSize = GetNextString(strURI, _T("|"), iPos);
                if (!strSize.IsEmpty())
                {
                    CString strHash = GetNextString(strURI, _T("|"), iPos);
                    if (!strHash.IsEmpty())
                    {
                        CStringArray astrEd2kParams;
                        bool bEmuleExt = false;
                        CString strEmuleExt;

                        CString strLastTok;
                        strTok = GetNextString(strURI, _T("|"), iPos);
                        while (!strTok.IsEmpty())
                        {
                            strLastTok = strTok;
                            if (strTok == _T("/"))
                            {
                                if (bEmuleExt)
                                    break;
                                bEmuleExt = true;
                            }
                            else
                            {
                                if (bEmuleExt)
                                {
                                    if (!strEmuleExt.IsEmpty())
                                        strEmuleExt += _T('|');
                                    strEmuleExt += strTok;
                                }
                                else
                                    astrEd2kParams.Add(strTok);
                            }
                            strTok = GetNextString(strURI, _T("|"), iPos);
                        }

                        if (strLastTok == _T("/"))
                            return new CED2KFileLink(strName, strSize, strHash, astrEd2kParams, strEmuleExt.IsEmpty() ? (LPCTSTR)NULL : (LPCTSTR)strEmuleExt);
                    }
                }
            }
        }
        else if (strTok == _T("serverlist"))
        {
            CString strURL = GetNextString(strURI, _T("|"), iPos);
            if (!strURL.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/"))
                return new CED2KServerListLink(strURL);
        }
        else if (strTok == _T("server"))
        {
            CString strServer = GetNextString(strURI, _T("|"), iPos);
            if (!strServer.IsEmpty())
            {
                CString strPort = GetNextString(strURI, _T("|"), iPos);
                if (!strPort.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/"))
                    return new CED2KServerLink(strServer, strPort);
            }
        }
        else if (strTok == _T("nodeslist"))
        {
            CString strURL = GetNextString(strURI, _T("|"), iPos);
            if (!strURL.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/"))
                return new CED2KNodesListLink(strURL);
        }
        else if (strTok == _T("search"))
        {
            CString strSearchTerm = GetNextString(strURI, _T("|"), iPos);
            // might be extended with more parameters in future versions
            if (!strSearchTerm.IsEmpty())
                return new CED2KSearchLink(strSearchTerm);
        }
        // MORPH START - Added by Commander, Friendlinks [emulEspaa] - added by zz_fly
        else if ( strTok == _T("friend") )
        {
            CString sNick = GetNextString(strURI, _T("|"), iPos);
            if ( !sNick.IsEmpty() )
            {
                CString sHash = GetNextString(strURI, _T("|"), iPos);
                if ( !sHash.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/"))
                    return new CED2KFriendLink(sNick, sHash);
            }
        }
        else if ( strTok == _T("friendlist") )
        {
            CString sURL = GetNextString(strURI, _T("|"), iPos);
            if ( !sURL.IsEmpty() && GetNextString(strURI, _T("|"), iPos) == _T("/") )
                return new CED2KFriendListLink(sURL);
        }
        // MORPH END - Added by Commander, Friendlinks [emulEspaa]
    }

    throw GetResString(IDS_ERR_NOSLLINK);
}
/*
bool SE_ColorEffectFrame::isAddress(const SE_StringID& content)
{
	std::string str = content.getStr();
	if(str.empty())
		return false;
	int c = str[0];
	if(c == '&')
		return true;
	else 
		return false;
}
*/
SE_StringID SE_ColorEffectFrame::getURL(const SE_StringID& uri)
{
	SE_URI strURI(uri.getStr());
	return strURI.getURL();
}