コード例 #1
0
	virtual	VError HandleRequest( IHTTPResponse* inResponse)
			{
				if (inResponse == NULL)
					return VE_INVALID_PARAMETER;

				VError err = VE_OK;
				bool done = false;

				// First, extract the relative path from the url
				VString path = inResponse->GetRequest().GetURLPath();
				VRegexMatcher *matcher = VRegexMatcher::Create( fPattern, &err);
				if ((matcher != NULL) && (err == VE_OK))
				{
					bool match = matcher->Find( path, 1, false, &err);
					if (match && (err == VE_OK))
					{
						// Remove the pattern from the path
						path.Remove( matcher->GetGroupStart(0), matcher->GetGroupLength(0));

						// Check whether a namespace is specified
						VString lNamespaceKey( L"namespace=");
						VString lNamespace = inResponse->GetRequest().GetURLQuery();
						if (lNamespace.BeginsWith( lNamespaceKey))
							lNamespace.Remove( 1, lNamespaceKey.GetLength());
						else
							lNamespace.Clear();

						// Now, we have a relative  module path
						VString proxy;
						err = fService->GetProxy( proxy, path, lNamespace, &inResponse->GetRequest(), inResponse);
						if (err == VE_OK)
						{
							VString contentType( L"application/javascript");
							err = SetHTTPResponseString( inResponse, proxy, &contentType);
							done = true;
						}
					}
				}
				ReleaseRefCountable( &matcher);

				if (!done)
					err = inResponse->ReplyWithStatusCode( HTTP_NOT_FOUND);

				return err;
			}
コード例 #2
0
VError VFolder::GetRelativeURL(VFolder* inBaseFolder, VString& outURL, bool inEncoded)
{
	VString folderURL;
	VError err = GetURL(outURL, inEncoded);
	if (inBaseFolder != NULL)
	{
		inBaseFolder->GetURL(folderURL, inEncoded);
		if (outURL.BeginsWith(folderURL))
		{
			outURL.Remove(1, folderURL.GetLength());
		}

	}
	return err;
}
コード例 #3
0
void VHTMLSyntax::SwapComment( ICodeEditorDocument* inDocument, VString& ioString, bool inComment )
{
	if ( inComment )
	{
		ioString.Insert( CVSTR( "<!--" ), 1 );
		ioString += CVSTR( "-->" );
	}
	else
	{
		if ( ioString.BeginsWith( CVSTR( "<!--" ) ) )
			ioString.Remove( 1, 4 );

		if ( ioString.EndsWith( CVSTR( "-->" ) ) )
			ioString.Truncate( ioString.GetLength() - 3 );
	}
}
コード例 #4
0
VError VArchiveUnStream::ProceedCatalog()
{
	VError result = VE_OK;
	VStr8 dotSlash("./");
	VStr8 slash("/");
	VStr8 extra("::");
	VStr8 folderSep(XBOX::FOLDER_SEPARATOR);

	if ( fStream->GetLong() == 'FPBK' )
	{
		VString filePath;
		VString fileExtra;
		VString storedPath;
		uLONG kind = 0;
		uLONG creator = 0;
		sLONG8 dataFileSize = 0;
		sLONG8 resFileSize = 0;
		uBYTE version = fStream->GetByte();
		uLONG8 fileCount = fStream->GetLong8();
		fTotalByteCount = 0;


		if ( fStream->GetLong() == 'LIST' )
		{
			for ( uLONG i = 0; i < fileCount && result == VE_OK; i++ )
			{
				if ( fStream->GetLong() == 'file' )
				{
					result = filePath.ReadFromStream(fStream);
					if ( result == VE_OK )
					{
						VIndex index = filePath.Find(extra);
						fileExtra = filePath;
						fileExtra.Remove(1,index+1);
						filePath.Remove(index,filePath.GetLength()-index+1);
						storedPath = filePath;
						if ( filePath.Find( dotSlash ) > 0 )
						{
							// some archives have bogous file paths such as ./Z:/folder
							filePath.Exchange( (UniChar) ':', (UniChar) '_');
							filePath.Replace(fDestinationFolder.GetPath(),1,2);
						}
						filePath.Exchange(slash ,folderSep, 1, 255);
					
						dataFileSize = fStream->GetLong8();
						fTotalByteCount += dataFileSize;
						resFileSize = fStream->GetLong8();
						fTotalByteCount += resFileSize;

						kind = fStream->GetLong();
						creator = fStream->GetLong();

						VFile *file = new VFile(filePath);
						fFileCatalog.push_back(new VArchiveCatalog(file,dataFileSize,resFileSize,storedPath,fileExtra,kind,creator));
						ReleaseRefCountable( &file);
					}
				}
				else
					result = VE_STREAM_BAD_SIGNATURE;
			}
		}
		else
			result = VE_STREAM_BAD_SIGNATURE;
	}
	return result;
}
コード例 #5
0
XBOX::VError VRPCService::GetProxy( XBOX::VString& outProxy, const XBOX::VString& inModulePath, const XBOX::VString& inNamespace, const IHTTPRequest* inRequest, IHTTPResponse* inResponse)
{
	VError err = VE_OK;

	outProxy.Clear();

	if (fApplication != NULL)
	{
		VRIAContext *riaContext = fApplication->RetainNewContext( err);
		if (err == VE_OK)
		{
			VRPCCatalog *catalog = fApplication->RetainRPCCatalog( riaContext, &err, inRequest, inResponse);
			if (err == VE_OK)
			{
				if (catalog != NULL)
				{
					MapOfRPCSchema schemas;

					err = catalog->RetainSchemasByModule( inModulePath, schemas);
					if (err == VE_OK)
					{
						// Build the proxy
						VFile *bodyFile = NULL, *templateFile = NULL;
						VFilePath path;

						VRIAServerApplication::Get()->GetWAFrameworkFolderPath( path);
						path.ToSubFolder( L"Core").ToSubFolder( L"Runtime").ToSubFolder( L"rpcService");
						path.SetFileName( L"proxy-body.js", true);

						bodyFile = new VFile( path);
						if (bodyFile == NULL)
							err = vThrowError( VE_MEMORY_FULL);
						
						if (err == VE_OK)
						{
							path.SetFileName( L"proxy-template.js", true);
							templateFile = new VFile( path);
							if (templateFile == NULL)
								err = vThrowError( VE_MEMORY_FULL);
						}
						
						if (err == VE_OK && bodyFile->Exists() && templateFile->Exists())
						{
							VString templateString;
							VFileStream bodyStream( bodyFile);
							VFileStream templateStream( templateFile);
							
							err = bodyStream.OpenReading();
							if (err == VE_OK)
								templateStream.OpenReading();
							if (err == VE_OK)
								err = bodyStream.GetText( outProxy);
							if (err == VE_OK)
							{
								VValueBag bag;
								bag.SetString( L"rpc-pattern", fPatternForMethods);
								bag.SetString( L"publishInGlobalNamespace", (fPublishInClientGlobalNamespace) ? L"true" : L"false");
								outProxy.Format( &bag);
							}
							if (err == VE_OK)
								err = templateStream.GetText( templateString);
							if (err == VE_OK)
							{
								if (templateString.BeginsWith( L"/*"))
								{
									// sc 28/08/2014, remove the copyright
									VIndex end = templateString.Find( L"*/");
									if (end > 0)
									{
										templateString.Remove( 1, end + 1);
									}
								}

								for (MapOfRPCSchema::const_iterator iter = schemas.begin() ; iter != schemas.end() ; ++iter)
								{
									VValueBag bag;
									bag.SetString( L"function-name", iter->first.GetMethodName());
									bag.SetString( L"namespace", inNamespace);
									bag.SetString( L"modulePath", inModulePath);
									VString proxy( templateString);
									proxy.Format( &bag);
									outProxy.AppendString( proxy);
								}
							}

							bodyStream.CloseReading();
							templateStream.CloseReading();
						}
						else
						{
							err = vThrowError( VE_FILE_NOT_FOUND);
						}

						QuickReleaseRefCountable( bodyFile);
						QuickReleaseRefCountable( templateFile);
					}
				}
				else
				{
					err = vThrowError( VE_RIA_RPC_CATALOG_NOT_FOUND);
				}
			}
		}
		ReleaseRefCountable( &riaContext);
	}

	return err;	
}