void
DatabaseCorrelation::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("DatabaseCorrelation");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("name")) != 0)
        SetName(node->AsString());
    if((node = searchNode->GetNode("numStates")) != 0)
        SetNumStates(node->AsInt());
    if((node = searchNode->GetNode("method")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 5)
                SetMethod(CorrelationMethod(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            CorrelationMethod value;
            if(CorrelationMethod_FromString(node->AsString(), value))
                SetMethod(value);
        }
    }
    if((node = searchNode->GetNode("databaseNames")) != 0)
        SetDatabaseNames(node->AsStringVector());
    if((node = searchNode->GetNode("databaseNStates")) != 0)
        SetDatabaseNStates(node->AsIntVector());
    if((node = searchNode->GetNode("databaseTimes")) != 0)
        SetDatabaseTimes(node->AsDoubleVector());
    if((node = searchNode->GetNode("databaseCycles")) != 0)
        SetDatabaseCycles(node->AsIntVector());
    if((node = searchNode->GetNode("indices")) != 0)
        SetIndices(node->AsIntVector());
    if((node = searchNode->GetNode("condensedTimes")) != 0)
        SetCondensedTimes(node->AsDoubleVector());
    if((node = searchNode->GetNode("condensedCycles")) != 0)
        SetCondensedCycles(node->AsIntVector());
}
HTTPServerResponse::HTTPServerResponse(Poco::Net::HTTPServerResponse &response)
    : StaticBoundObject("Network.HTTPServerResponse")
    , response(response)
{
    SetMethod("setStatus",&HTTPServerResponse::SetStatus);
    SetMethod("setReason",&HTTPServerResponse::SetReason);
    SetMethod("setStatusAndReason",&HTTPServerResponse::SetStatusAndReason);
    SetMethod("setContentType",&HTTPServerResponse::SetContentType);
    SetMethod("setContentLength",&HTTPServerResponse::SetContentLength);
    SetMethod("addCookie",&HTTPServerResponse::AddCookie);
    SetMethod("setHeader",&HTTPServerResponse::SetHeader);
    SetMethod("write",&HTTPServerResponse::Write);
    SetMethod("enableAsync",&HTTPServerResponse::EnableAsync);
}
예제 #3
0
LSP::GotoDefinitionRequest::GotoDefinitionRequest(const wxFileName& filename, size_t line, size_t column)
    : m_filename(filename)
    , m_line(line)
    , m_column(column)
{
    SetMethod("textDocument/definition");
    m_params.reset(new TextDocumentPositionParams());
    m_params->As<TextDocumentPositionParams>()->SetTextDocument(TextDocumentIdentifier(filename));
    m_params->As<TextDocumentPositionParams>()->SetPosition(Position(line, column));
}
예제 #4
0
void Ide::SetupDefaultMethod()
{
	if(IsNull(method)) {
		SetMethod(GetDefaultMethod());
		if(IsNull(method)) {
			FindFile ff(ConfigFile("*.bm"));
			if(!ff)
				return;
			SetMethod(GetFileTitle(ff.GetName()));
		}
		VectorMap<String, String> map = GetMethodVars(method);
		debug.linkmode = atoi(map.Get("DEBUG_LINKMODE", "0"));
		debug.def.debug = atoi(map.Get("DEBUG_INFO", "0"));
		debug.def.blitz = MapFlag(map, "DEBUG_BLITZ");
		release.linkmode = atoi(map.Get("RELEASE_LINKMODE", "0"));
		release.def.debug <<= 0;
		release.def.blitz = MapFlag(map, "RELEASE_BLITZ");
	}
}
	HttpServerRequest::HttpServerRequest(Host *host, SharedKMethod callback, Poco::Net::HTTPServerRequest &request) :
		host(host),callback(callback),request(request)
	{
		SetMethod("getMethod",&HttpServerRequest::GetMethod);
		SetMethod("getVersion",&HttpServerRequest::GetVersion);
		SetMethod("getURI",&HttpServerRequest::GetURI);
		SetMethod("getContentType",&HttpServerRequest::GetContentType);
		SetMethod("getContentLength",&HttpServerRequest::GetContentLength);
		SetMethod("getHeader",&HttpServerRequest::GetHeader);
		SetMethod("hasHeader",&HttpServerRequest::HasHeader);
		SetMethod("read",&HttpServerRequest::Read);
	}
예제 #6
0
void CLightManager::Setup (int nLevel)
{
SetMethod ();
if (!gameStates.app.bNostalgia) {
	lightManager.AddGeometryLights ();
	ComputeNearestLights (nLevel);
	lightmapManager.Setup (nLevel);
	}
GatherStaticLights (nLevel);
}
예제 #7
0
void Ide::SelectMethod()
{
	SetMethod(methodlist.GetKey());
	int q = recent_buildmode.Find(~method);
	if(q >= 0) {
		StringStream ss(recent_buildmode[q]);
		SerializeOutputMode(ss);
	}
	SyncBuildMode();
	SetHdependDirs();
}
예제 #8
0
 RubyEvaluator::RubyEvaluator() :
     StaticBoundObject("Ruby.Evaluator")
 {
     /**
      * @notiapi(method=True,name=Ruby.canEvaluate,since=0.7)
      * @notiarg[String, mimeType] Code mime type
      * @notiresult[bool] whether or not the mimetype is understood by Ruby
      */
     SetMethod("canEvaluate", &RubyEvaluator::CanEvaluate);
     
     /**
      * @notiapi(method=Ruby,name=Ruby.evaluate,since=0.2) Evaluates a string as Ruby code
      * @notiarg[String, mimeType] Code mime type (normally "text/ruby")
      * @notiarg[String, name] name of the script source
      * @notiarg[String, code] Ruby script code
      * @notiarg[Object, scope] global variable scope
      * @notiresult[Any] result of the evaluation
      */
     SetMethod("evaluate", &RubyEvaluator::Evaluate);
 }
예제 #9
0
 TCPSocket::TCPSocket(std::string& host, int port) :
     KEventObject("Network.TCPSocket"),
     address(host, port),
     socket(address.family()),
     state(CLOSED),
     reader(*this, &TCPSocket::ReadThread),
     writer(*this, &TCPSocket::WriteThread)
 {
     SetMethod("connect", &TCPSocket::_Connect);
     SetMethod("setTimeout", &TCPSocket::_SetTimeout);
     SetMethod("close", &TCPSocket::_Close);
     SetMethod("isClosed", &TCPSocket::_IsClosed);
     SetMethod("write", &TCPSocket::_Write);
     SetMethod("onRead", &TCPSocket::_OnRead);
     SetMethod("onReadComplete", &TCPSocket::_OnReadComplete);
     SetMethod("onError", &TCPSocket::_OnError);
     SetMethod("onTimeout", &TCPSocket::_OnTimeout);
 }
예제 #10
0
Notification::Notification() : KAccessorObject("Notification"),
	timeout(-1)
{
	SetMethod("setTitle", &Notification::_SetTitle);
	SetMethod("setMessage", &Notification::_SetMessage);
	SetMethod("setIcon", &Notification::_SetIcon);
	SetMethod("setTimeout", &Notification::_SetTimeout);
	SetMethod("setDelay", &Notification::_SetTimeout);
	SetMethod("setCallback", &Notification::_SetCallback);
	SetMethod("show", &Notification::_Show);
	SetMethod("hide", &Notification::_Hide);

	SetBool("nativeNotifications", Notification::InitializeImpl());
	this->CreateImpl();
}
	HTTPServerBinding::HTTPServerBinding(Host* host) :
		StaticBoundObject("HTTPServer"),
		host(host),global(host->GetGlobalObject()),
		callback(NULL),socket(NULL),connection(NULL)
	{
		/**
		 * @tiapi(method=True,name=Network.HTTPServer.bind,since=0.3) bind this server to a port on a specific interface
		 * @tiarg(for=Network.HTTPServer.bind,name=port,type=Number) port to bind on
		 * @tiarg(for=Network.HTTPServer.bind,name=address,type=String,optional=True) address to bind to
		 * @tiarg(for=Network.HTTPServer.bind,name=callback,type=Method) callback for server logic (in seperate thread)
		 */
		SetMethod("bind",&HTTPServerBinding::Bind);
		
		/**
		 * @tiapi(method=True,name=Network.HTTPServer.close,since=0.3) close this server
		 */
		SetMethod("close",&HTTPServerBinding::Close);
		
		/**
		 * @tiapi(method=True,name=Network.HTTPServer.isClosed,since=0.3) check to see if this server socket is closed
		 * @tiresult(for=Network.HTTPServer.isClosed,type=Boolean) return whether or not this server socket is closed
		 */
		SetMethod("isClosed",&HTTPServerBinding::IsClosed);
	}
예제 #12
0
void HttpGetSocket::OnConnect()
{
	SetMethod( "GET" );
	AddResponseHeader( "Accept", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1");
	AddResponseHeader( "Accept-Language", "en-us,en;q=0.5");
	AddResponseHeader( "Accept-Encoding", "gzip,deflate");
	AddResponseHeader( "Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
	AddResponseHeader( "User-agent", MyUseragent() );

	if (GetUrlPort() != 80 && GetUrlPort() != 443)
		AddResponseHeader( "Host", GetUrlHost() + ":" + Utility::l2string(GetUrlPort()) );
	else
		AddResponseHeader( "Host", GetUrlHost() );
	SendRequest();
}
예제 #13
0
void HttpPostSocket::OnConnect()
{
	if (m_bMultipart)
	{
		DoMultipartPost();
	}
	else
	{
		std::string body;

		// only fields, no files, add urlencoding
		for (std::map<std::string,std::list<std::string> >::iterator it = m_fields.begin(); it != m_fields.end(); it++)
		{
			std::string name = (*it).first;
			std::list<std::string>& ref = (*it).second;
			if (body.size())
			{
				body += '&';
			}
			body += name + "=";
			bool first = true;
			for (std::list<std::string>::iterator it = ref.begin(); it != ref.end(); it++)
			{
				std::string value = *it;
				if (!first)
				{
					body += "%0d%0a"; // CRLF
				}
				body += Utility::rfc1738_encode(value);
				first = false;
			}
		}

		// build header, send body
		SetMethod("POST");
		SetHttpVersion( "HTTP/1.1" );
		AddResponseHeader( "Host", m_host ); // oops - this is actually a request header that we're adding..
		AddResponseHeader( "User-agent", MyUseragent());
		AddResponseHeader( "Accept", "text/html, text/plain, */*;q=0.01" );
		AddResponseHeader( "Connection", "close" );
		AddResponseHeader( "Content-type", "application/x-www-form-urlencoded" );
		AddResponseHeader( "Content-length", Utility::l2string((long)body.size()) );
		SendRequest();

		// send body
		Send( body );
	}
}
예제 #14
0
bool CWebView::LoadURL ( const SString& strURL, bool bFilterEnabled, const SString& strPostData, bool bURLEncoded )
{
    if ( !m_pWebView )
        return false;

    CefURLParts urlParts;
    if ( !CefParseURL ( strURL, urlParts ) )
        return false; // Invalid URL

    // Are we allowed to browse this website?
    if ( bFilterEnabled && g_pCore->GetWebCore ()->GetURLState ( UTF16ToMbUTF8 ( urlParts.host.str ), true ) != eURLState::WEBPAGE_ALLOWED )
        return false;

    // Load it!
    auto pFrame = m_pWebView->GetMainFrame ();
    if ( strPostData.empty () )
    {
        pFrame->LoadURL ( strURL );
    }
    else
    {
        // Load URL first, see https://bitbucket.org/chromiumembedded/cef/issue/579
        pFrame->LoadURL ( "about:blank" );

        // Perform HTTP POST
        auto request = CefRequest::Create ();
        auto postData = CefPostData::Create ();
        auto postDataElement = CefPostDataElement::Create ();
        postDataElement->SetToBytes ( strPostData.size (), strPostData.c_str () );
        postData->AddElement ( postDataElement );

        if ( bURLEncoded )
        {
            CefRequest::HeaderMap headerMap;
            headerMap.insert ( std::make_pair ( "Content-Type", "application/x-www-form-urlencoded" ) );
            headerMap.insert ( std::make_pair ( "Content-Length", std::to_string ( strPostData.size () ) ) );
            //headerMap.insert ( std::make_pair ( "Connection", "close" ) );
            request->SetHeaderMap ( headerMap );
        }

        request->SetURL ( strURL );
        request->SetMethod ( "POST" );
        request->SetPostData ( postData );
        pFrame->LoadRequest ( request );
    }
   
    return true;
}
예제 #15
0
파일: dynlight.cpp 프로젝트: paud/d2x-xl
void CLightManager::Setup (int nLevel)
{
SetMethod ();
if (!gameStates.app.bNostalgia) {
	lightManager.AddGeometryLights ();
	ComputeNearestLights (nLevel);
	if (gameStates.render.bPerPixelLighting) {
		lightmapManager.Create (nLevel);
		if (lightmapManager.HaveLightmaps ())
			meshBuilder.RebuildLightmapTexCoord ();	//rebuild to create proper lightmap texture coordinates
		else
			gameOpts->render.bUseLightmaps = 0;
		}
	}
GatherStaticLights (nLevel);
}
예제 #16
0
/* static */
void V8Runtime::bootstrap(Local<Context> context)
{
	Isolate* isolate = context->GetIsolate();
	EventEmitter::initTemplate(context);

	Local<Object> global = Object::New(isolate);
	krollGlobalObject.Reset(isolate, global);
	Local<Array> mc = Array::New(isolate);
	moduleContexts.Reset(isolate, mc);

	KrollBindings::initFunctions(global, context);

	SetMethod(isolate, global, "log", krollLog);
	// Move this into the EventEmitter::initTemplate call?
	Local<FunctionTemplate> eect = Local<FunctionTemplate>::New(isolate, EventEmitter::constructorTemplate);
	global->Set(NEW_SYMBOL(isolate, "EventEmitter"), eect->GetFunction());

	global->Set(NEW_SYMBOL(isolate, "runtime"), STRING_NEW(isolate, "v8"));
	global->Set(NEW_SYMBOL(isolate, "DBG"), v8::Boolean::New(isolate, V8Runtime::DBG));
	global->Set(NEW_SYMBOL(isolate, "moduleContexts"), mc);

	LOG_TIMER(TAG, "Executing kroll.js");

	TryCatch tryCatch(isolate);
	Local<Value> result = V8Util::executeString(isolate, KrollBindings::getMainSource(isolate), STRING_NEW(isolate, "ti:/kroll.js"));

	if (tryCatch.HasCaught()) {
		V8Util::reportException(isolate, tryCatch, true);
	}
	if (!result->IsFunction()) {
		LOGF(TAG, "kroll.js result is not a function");
		V8Util::reportException(isolate, tryCatch, true);
	}

	Local<Function> mainFunction = result.As<Function>();
	Local<Value> args[] = { global };
	mainFunction->Call(context, context->Global(), 1, args);

	if (tryCatch.HasCaught()) {
		V8Util::reportException(isolate, tryCatch, true);
		LOGE(TAG, "Caught exception while bootstrapping Kroll");
	}
}
예제 #17
0
void HttpPutSocket::OnConnect()
{
	SetMethod( "PUT" );
	SetHttpVersion( "HTTP/1.1" );
	AddResponseHeader( "Host", m_host );
	AddResponseHeader( "Content-type", m_content_type );
	AddResponseHeader( "Content-length", Utility::l2string(m_content_length) );
	SendRequest();

	FILE *fil = fopen(m_filename.c_str(), "rb");
	if (fil)
	{
		size_t n;
		char buf[2000];
		while ((n = fread(buf, 1, 2000, fil)) > 0)
		{
			SendBuf(buf, n);
		}
		fclose(fil);
	}
}
예제 #18
0
void HttpPutSocket::OnConnect()
{
	SetMethod( "PUT" );
	SetHttpVersion( "HTTP/1.1" );
	AddResponseHeader( "Host", GetUrlHost() );
	AddResponseHeader( "Content-type", m_content_type );
	AddResponseHeader( "Content-length", Utility::l2string(m_content_length) );
	AddResponseHeader( "User-agent", MyUseragent() );
	SendRequest();

	std::auto_ptr<IFile> fil = std::auto_ptr<IFile>(new File);
	if (fil -> fopen(m_filename, "rb"))
	{
		size_t n;
		char buf[32768];
		while ((n = fil -> fread(buf, 1, 32768)) > 0)
		{
			SendBuf(buf, n);
		}
		fil -> fclose();
	}
}
예제 #19
0
CODESolver::CODESolver(CTimeStateBlock*pIC, double dTime_, double dTimeMax_, int MaxIters, ODE_Methods Method_, ODE_SSC_Type StepSizeControl_) :
  rIC(*pIC),
  m_MagEps(TBF_DynSys, "ODESolve:MagEPS", 1.0e-4,1.0e-6, 100, TBF_UseAbs|TBF_UseRel)
  {
  pODEBase=NULL;

  rIC.m_TimeIncMn=rIC.m_TimeInc;
  rIC.m_TimeIncMnRqd=rIC.m_TimeInc;
  dTimeWrk=rIC.m_TimeInc;
  Time_Stop=0.0;
  m_nGoodIters=0;
  m_nBadIters=0;
  m_nIters4Step=0;
  SetMethod(Method_);
  SetStepSizeControl(StepSizeControl_);
  rIC.m_TimeIncMx=dTimeMax_;
  rIC.m_TimeIncMxRqd=dTimeMax_;
  m_nMaxIters=MaxIters;
  SafetyScale=1.0;

//  m_Mag_Eps_R=dNAN;
//  m_Mag_Eps_A=dNAN;

  SetMagConvergence(1.0e-4,1.0e-6);

  GrowLimit=0.5;
  Grow=1.1;

  OKShrinkLimit=0.8;
  OKShrink=0.95;

  BADShrink=0.8;

  dEstMaxDT=0.0;
  fStepTooLarge=False;

  };
예제 #20
0
파일: ctest4.cpp 프로젝트: Barush/IMS
int main(int argc, char *argv[])
{
  SetOutput("ctest4.dat");
  _Print("# Test \n");
  if(argc>1)
  {
    double d = atof(argv[1]);
    if(d==0) return 3;
    ACCURACY = d;
  }

  Print("# SetAccuracy(%g) \n", ACCURACY);

//DebugON();

//  _Print("# implicitn¡ metoda (RKE) \n");
  Init(0,ENDTIME);                // inicializace experimentu
  SetAccuracy(ACCURACY);          // rel chyba
//  SetMethod(SIMLIB_ABM4Step); 
//  SetMethod(SIMLIB_RK45Step); 
//  SetMethod(SIMLIB_EulerStep); 
//  SetMethod(SIMLIB_RK23Step); 
//  SetMethod(SIMLIB_FWStep); 
  Run();                          // simulace

return 0;

  _Print("\n# Eulerova metoda \n");

  Init(0,ENDTIME);                // inicializace experimentu
  SetAccuracy(ACCURACY);       
  SetMethod(SIMLIB_EulerStep);
  Run();                          // simulace

  return 0;
}
예제 #21
0
파일: Http.cpp 프로젝트: deadalnix/CSFML
void sfHttpRequest_SetMethod(sfHttpRequest* httpRequest, sfHttpMethod method)
{
    CSFML_CALL(httpRequest, SetMethod(static_cast<sf::Http::Request::Method>(method)));
}
예제 #22
0
status_t
BHttpRequest::_ProtocolLoop()
{
	// Initialize the request redirection loop
	int8 maxRedirs = fOptMaxRedirs;
	bool newRequest;

	do {
		newRequest = false;

		// Result reset
		fHeaders.Clear();
		_ResultHeaders().Clear();

		BString host = fUrl.Host();
		int port = fSSL ? 443 : 80;

		if (fUrl.HasPort())
			port = fUrl.Port();

		if (fContext->UseProxy()) {
			host = fContext->GetProxyHost();
			port = fContext->GetProxyPort();
		}

		status_t result = fInputBuffer.InitCheck();
		if (result != B_OK)
			return result;

		if (!_ResolveHostName(host, port)) {
			_EmitDebug(B_URL_PROTOCOL_DEBUG_ERROR,
				"Unable to resolve hostname (%s), aborting.",
					fUrl.Host().String());
			return B_SERVER_NOT_FOUND;
		}

		status_t requestStatus = _MakeRequest();
		if (requestStatus != B_OK)
			return requestStatus;

		// Prepare the referer for the next request if needed
		if (fOptAutoReferer)
			fOptReferer = fUrl.UrlString();

		switch (StatusCodeClass(fResult.StatusCode())) {
			case B_HTTP_STATUS_CLASS_INFORMATIONAL:
				// Header 100:continue should have been
				// handled in the _MakeRequest read loop
				break;

			case B_HTTP_STATUS_CLASS_SUCCESS:
				break;

			case B_HTTP_STATUS_CLASS_REDIRECTION:
			{
				// Redirection has been explicitly disabled
				if (!fOptFollowLocation)
					break;

				int code = fResult.StatusCode();
				if (code == B_HTTP_STATUS_MOVED_PERMANENTLY
					|| code == B_HTTP_STATUS_FOUND
					|| code == B_HTTP_STATUS_SEE_OTHER
					|| code == B_HTTP_STATUS_TEMPORARY_REDIRECT) {
					BString locationUrl = fHeaders["Location"];

					fUrl = BUrl(fUrl, locationUrl);

					// 302 and 303 redirections also convert POST requests to GET
					// (and remove the posted form data)
					if ((code == B_HTTP_STATUS_FOUND
						|| code == B_HTTP_STATUS_SEE_OTHER)
						&& fRequestMethod == B_HTTP_POST) {
						SetMethod(B_HTTP_GET);
						delete fOptPostFields;
						fOptPostFields = NULL;
						delete fOptInputData;
						fOptInputData = NULL;
						fOptInputDataSize = 0;
					}

					if (--maxRedirs > 0) {
						newRequest = true;

						// Redirections may need a switch from http to https.
						if (fUrl.Protocol() == "https")
							fSSL = true;
						else if (fUrl.Protocol() == "http")
							fSSL = false;

						_EmitDebug(B_URL_PROTOCOL_DEBUG_TEXT,
							"Following: %s\n",
							fUrl.UrlString().String());
					}
				}
				break;
			}

			case B_HTTP_STATUS_CLASS_CLIENT_ERROR:
				if (fResult.StatusCode() == B_HTTP_STATUS_UNAUTHORIZED) {
					BHttpAuthentication* authentication
						= &fContext->GetAuthentication(fUrl);
					status_t status = B_OK;

					if (authentication->Method() == B_HTTP_AUTHENTICATION_NONE) {
						// There is no authentication context for this
						// url yet, so let's create one.
						BHttpAuthentication newAuth;
						newAuth.Initialize(fHeaders["WWW-Authenticate"]);
						fContext->AddAuthentication(fUrl, newAuth);

						// Get the copy of the authentication we just added.
						// That copy is owned by the BUrlContext and won't be
						// deleted (unlike the temporary object above)
						authentication = &fContext->GetAuthentication(fUrl);
					}

					newRequest = false;
					if (fOptUsername.Length() > 0 && status == B_OK) {
						// If we received an username and password, add them
						// to the request. This will either change the
						// credentials for an existing request, or set them
						// for a new one we created just above.
						//
						// If this request handles HTTP redirections, it will
						// also automatically retry connecting and send the
						// login information.
						authentication->SetUserName(fOptUsername);
						authentication->SetPassword(fOptPassword);
						newRequest = true;
					}
				}
				break;

			case B_HTTP_STATUS_CLASS_SERVER_ERROR:
				break;

			default:
			case B_HTTP_STATUS_CLASS_INVALID:
				break;
		}
	} while (newRequest);

	_EmitDebug(B_URL_PROTOCOL_DEBUG_TEXT,
		"%ld headers and %ld bytes of data remaining",
		fHeaders.CountHeaders(), fInputBuffer.Size());

	if (fResult.StatusCode() == 404)
		return B_RESOURCE_NOT_FOUND;

	return B_OK;
}
예제 #23
0
Properties::Properties(const std::string& filePath) :
    StaticBoundObject("App.Properties"),
    logger(Logger::Get("App.Properties")),
    filePath(filePath)
{
    if (!filePath.empty())
    {
        Poco::File file(filePath);
        if (!file.exists()) 
            file.createFile();

        config = new TitaniumPropertyFileConfiguration(filePath);
    }
    else
    {
        config = new TitaniumPropertyFileConfiguration();
    }

    SetMethod("getBool", &Properties::GetBool);
    SetMethod("getDouble", &Properties::GetDouble);
    SetMethod("getInt", &Properties::GetInt);
    SetMethod("getString", &Properties::GetString);
    SetMethod("getList", &Properties::GetList);
    SetMethod("setBool", &Properties::SetBool);
    SetMethod("setDouble", &Properties::SetDouble);
    SetMethod("setInt", &Properties::SetInt);
    SetMethod("setString", &Properties::SetString);
    SetMethod("setList", &Properties::SetList);
    SetMethod("hasProperty", &Properties::HasProperty);
    SetMethod("removeProperty", &Properties::RemoveProperty);
    SetMethod("listProperties", &Properties::ListProperties);
    SetMethod("saveTo", &Properties::SaveTo);
}
예제 #24
0
 HttpServerRequest::HttpServerRequest(Poco::Net::HTTPServerRequest& request) :
         StaticBoundObject("Network.HttpServerRequest"),
         request(request)
 {
     /**
      * @tiapi(method=True,name=Network.HTTPServerRequest.getMethod,since=0.3) get the HTTP method of this request
      * @tiresult(for=Network.HTTPServerRequest.getMethod,type=String) the http method of this request, i.e. "GET", "POST"
      */
     SetMethod("getMethod",&HttpServerRequest::GetMethod);
     
     /**
      * @tiapi(method=True,name=Network.HTTPServerRequest.getVersion,since=0.3) get the HTTP version of this request
      * @tiresult(for=Network.HTTPServerRequest.getVersion,type=String) the http version of this request, i.e. "1.1"
      */
     SetMethod("getVersion",&HttpServerRequest::GetVersion);
     
     /**
      * @tiapi(method=True,name=Network.HTTPServerRequest.getURI,since=0.3) get the URI of this request
      * @tiresult(for=Network.HTTPServerRequest.getURI,type=String) the URI of this request, i.e. "/path/index.html"
      */
     SetMethod("getURI",&HttpServerRequest::GetURI);
     
     /**
      * @tiapi(method=True,name=Network.HTTPServerRequest.getContentType,since=0.3) get the content type of this request
      * @tiresult(for=Network.HTTPServerRequest.getContentType,type=String) the content type of this request, i.e. "text/plain"
      */
     SetMethod("getContentType",&HttpServerRequest::GetContentType);
     
     /**
      * @tiapi(method=True,name=Network.HTTPServerRequest.getContentLength,since=0.3) the content length of this request
      * @tiresult(for=Network.HTTPServerRequest.getContentLength,type=Number) the content length of this request, i.e 100
      */
     SetMethod("getContentLength",&HttpServerRequest::GetContentLength);
     
     /**
      * @tiapi(method=True,name=Network.HTTPServerRequest.getHeader,since=0.3) get an HTTP header value from this request
      * @tiarg(for=Network.HTTPServerRequest.getHeader,type=String,name=header) the header of the request
      * @tiresult(for=Network.HTTPServerRequest.getHeader,type=String) the value of the passed in HTTP header or null
      */
     SetMethod("getHeader",&HttpServerRequest::GetHeader);
     
     /**
      * @tiapi(method=True,name=Network.HTTPServerRequest.hasHeader,since=0.3) check to see if this request has an HTTP header
      * @tiarg(for=Network.HTTPServerRequest.hasHeader,type=String,name=header) the header of the request to check
      * @tiresult(for=Network.HTTPServerRequest.hasHeader,type=Boolean) whether or not this request has the passed in HTTP header
      */
     SetMethod("hasHeader",&HttpServerRequest::HasHeader);
     
     /**
      * @tiapi(method=True,name=Network.HTTPServerRequest.getHeaders,since=0.7) get an HTTP header value from this request
      * @tiarg(for=Network.HTTPServerRequest.getHeader,type=String,name=header) the header of the request
      * @tiresult(for=Network.HTTPServerRequest.getHeader,type=String) the value of the passed in HTTP header or null
      */
     SetMethod("getHeaders", &HttpServerRequest::GetHeaders);
 
     /**
      * @tiapi(method=True,name=Network.HTTPServerRequest.read,since=0.3) read content from this request
      * @tiarg(for=Network.HTTPServerRequest.read,type=Number,optional=True,name=length) the number of bytes to read (default 8096)
      * @tiresult(for=Network.HTTPServerRequest.read,type=String) the data read from this request
      */
     SetMethod("read",&HttpServerRequest::Read);
 }
	void PropertiesBinding::Init()
	{
		/**
		 * @tiapi(method=True,name=App.Properties.getBool,since=0.2) Returns a property value as boolean
		 * @tiarg[String, name] The name of the property to return
		 * @tiarg[Boolean, default] The value to return if this property is not set
		 * @tiresult[Boolean] The value of the property with the given name
		 */
		SetMethod("getBool", &PropertiesBinding::GetBool);
		/**
		 * @tiapi(method=True,name=App.Properties.getDouble,since=0.2) Returns a property value as double
		 * @tiarg[String, name] The name of the property to return
		 * @tiarg[Number, default] The value to return if this property is not set
		 * @tiresult[Number] The value of the property with the given name
		 */
		SetMethod("getDouble", &PropertiesBinding::GetDouble);
		/**
		 * @tiapi(method=True,name=App.Properties.getInt,since=0.2) Returns a property value as integer
		 * @tiarg[String, name] The name of the property to return
		 * @tiarg[Number, default] The value to return if this property is not set
		 * @tiresult[Number] The value of the property with the given name
		 */
		SetMethod("getInt", &PropertiesBinding::GetInt);
		/**
		 * @tiapi(method=True,name=App.Properties.getString,since=0.2) Returns a property value as string
		 * @tiarg[String, name] The name of the property to return
		 * @tiarg[String, default] The value to return if this property is not set
		 * @tiresult[String] The value of the property with the given name
		 */
		SetMethod("getString", &PropertiesBinding::GetString);
		/**
		 * @tiapi(method=True,name=App.Properties.getList,since=0.2) Returns a property value as a list
		 * @tiarg[list, name] The name of the property to return
		 * @tiarg[list, default] The value to return if this property is not set
		 * @tiresult[list] The value of the property with the given name
		 */
		SetMethod("getList", &PropertiesBinding::GetList);
		/**
		 * @tiapi(method=True,name=App.Properties.setBool,since=0.2) Sets a boolean property value
		 * @tiarg(for=App.Properties.setBool,name=name,type=String) the property name
		 * @tiarg(for=App.Properties.setBool,name=value,type=Boolean) the value
		 */
		SetMethod("setBool", &PropertiesBinding::SetBool);
		/**
		 * @tiapi(method=True,name=App.Properties.setDouble,since=0.2) Sets a double property value
		 * @tiarg(for=App.Properties.setDouble,name=name,type=String) the property name
		 * @tiarg(for=App.Properties.setDouble,name=value,type=Number) the value
		 */
		SetMethod("setDouble", &PropertiesBinding::SetDouble);
		/**
		 * @tiapi(method=True,name=App.Properties.setInt,since=0.2) Sets an integer property value
		 * @tiarg(for=App.Properties.setInt,name=name,type=String) the property name
		 * @tiarg(for=App.Properties.setInt,name=value,type=Number) the value
		 */
		SetMethod("setInt", &PropertiesBinding::SetInt);
		/**
		 * @tiapi(method=True,name=App.Properties.setString,since=0.2) Sets a string property value
		 * @tiarg(for=App.Properties.setString,name=name,type=String) the property name
		 * @tiarg(for=App.Properties.setString,name=value,type=String) the value
		 */
		SetMethod("setString", &PropertiesBinding::SetString);
		/**
		 * @tiapi(method=True,name=App.Properties.setList,since=0.2) Sets a list property value
		 * @tiarg(for=App.Properties.setList,name=name,type=String) the property name
		 * @tiarg(for=App.Properties.setList,name=value,type=Array<String>) the value
		 */
		SetMethod("setList", &PropertiesBinding::SetList);
		/**
		 * @tiapi(method=True,name=App.Properties.hasProperty,since=0.2) Checks whether a property exists
		 * @tiarg(for=App.Properties.hasProperty,name=name,type=String) the property name
		 * @tiresult(for=App.Properties.hasProperty,type=Boolean) returns true if the property exists
		 */
		SetMethod("hasProperty", &PropertiesBinding::HasProperty);
		/**
		 * @tiapi(method=True,name=App.Properties.listProperties,since=0.2) Returns a list of property values
		 * @tiresult(for=App.Properties.listProperties,type=Array<String>) returns a list of property values
		 */
		SetMethod("listProperties", &PropertiesBinding::ListProperties);
		/**
		 * @tiapi(method=True,name=App.Properties.saveTo,since=0.2) save this properties object to a file
		 * @tiarg(for=App.Properties.saveTo,name=filename,type=String) the filename
		 */
		SetMethod("saveTo", &PropertiesBinding::SaveTo);
	
	}
예제 #26
0
void HttpPostSocket::DoMultipartPost()
{
	long length = 0; // calculate content_length of our post body
	std::string tmp;

	// fields
	{
		for (std::map<std::string,std::list<std::string> >::iterator it = m_fields.begin(); it != m_fields.end(); it++)
		{
			std::string name = (*it).first;
			std::list<std::string>& ref = (*it).second;
			tmp = "--" + m_boundary + "\r\n"
				"content-disposition: form-data; name=\"" + name + "\"\r\n"
				"\r\n";
			for (std::list<std::string>::iterator it = ref.begin(); it != ref.end(); it++)
			{
				std::string value = *it;
				tmp += value + "\r\n";
			}
			length += (long)tmp.size();
		}
	}

	// files
	{
		for (std::map<std::string,std::string>::iterator it = m_files.begin(); it != m_files.end(); it++)
		{
			std::string name = (*it).first;
			std::string filename = (*it).second;
			long content_length = m_content_length[filename];
			std::string content_type = m_content_type[filename];
			tmp = "--" + m_boundary + "\r\n"
				"content-disposition: form-data; name=\"" + name + "\"; filename=\"" + filename + "\"\r\n"
				"content-type: " + content_type + "\r\n"
				"\r\n";
			length += (long)tmp.size();
			length += content_length;
			length += 2; // crlf after file
		}
	}

	// end
	tmp = "--" + m_boundary + "--\r\n";
	length += (long)tmp.size();

	// build header, send body
	SetMethod("POST");
	SetHttpVersion( "HTTP/1.1" );
	AddResponseHeader( "Host", m_host ); // oops - this is actually a request header that we're adding..
	AddResponseHeader( "User-agent", MyUseragent());
	AddResponseHeader( "Accept", "text/html, text/plain, */*;q=0.01" );
	AddResponseHeader( "Connection", "close" );
	AddResponseHeader( "Content-type", "multipart/form-data; boundary=" + m_boundary );
	AddResponseHeader( "Content-length", Utility::l2string(length) );

	SendRequest();

	// send fields
	{
		for (std::map<std::string,std::list<std::string> >::iterator it = m_fields.begin(); it != m_fields.end(); it++)
		{
			std::string name = (*it).first;
			std::list<std::string>& ref = (*it).second;
			tmp = "--" + m_boundary + "\r\n"
				"content-disposition: form-data; name=\"" + name + "\"\r\n"
				"\r\n";
			for (std::list<std::string>::iterator it = ref.begin(); it != ref.end(); it++)
			{
				std::string value = *it;
				tmp += value + "\r\n";
			}
			Send( tmp );
		}
	}

	// send files
	{
		for (std::map<std::string,std::string>::iterator it = m_files.begin(); it != m_files.end(); it++)
		{
			std::string name = (*it).first;
			std::string filename = (*it).second;
			std::string content_type = m_content_type[filename];
			tmp = "--" + m_boundary + "\r\n"
				"content-disposition: form-data; name=\"" + name + "\"; filename=\"" + filename + "\"\r\n"
				"content-type: " + content_type + "\r\n"
				"\r\n";
			Send( tmp );
			{
				FILE *fil = fopen(filename.c_str(),"rb");
				if (fil)
				{
					char slask[2000];
					size_t n;
					while ((n = fread(slask, 1, 2000, fil)) > 0)
					{
						SendBuf(slask, n);
					}
					fclose(fil);
				}
			}
			Send("\r\n");
		}
	}

	// end of send
	Send("--" + m_boundary + "--\r\n");
}
예제 #27
0
	Process::Process() :
		KEventMethod("Process.Process"),
		stdoutPipe(new Pipe()),
		stderrPipe(new Pipe()),
		stdinPipe(new Pipe()),
		environment(GetCurrentEnvironment()),
		pid(-1),
		exitCode(Value::Null),
		onRead(0),
		onExit(0),
		exitMonitorAdapter(new RunnableAdapter<Process>(
			*this, &Process::ExitMonitorAsync)),
		running(false)
	{
		/**
		 * @tiapi(method=True,name=Process.Process.getPID,since=0.5)
		 * @tiresult[Number] The PID of this process
		 */
		SetMethod("getPID", &Process::_GetPID);
		
		/**
		 * @tiapi(method=True,name=Process.Process.getExitCode,since=0.5)
		 * @tiresult[Number] The exit code of this process. If the process is still running, this will return -1
		 */
		SetMethod("getExitCode", &Process::_GetExitCode);
		
		/**
		 * @tiapi(method=True,name=Process.Process.getArguments,since=0.5)
		 * @tiresult[Array<String>] The list of arguments this process was created with
		 */
		SetMethod("getArguments", &Process::_GetArguments);
		
		/**
		 * @tiapi(method=True,name=Process.Process.getEnvironment,since=0.5)
		 * @tiarg[String, key] an environment key
		 * @tiresult[String|Object] Either the string value of the given key or the entire environment object
		 */
		SetMethod("getEnvironment", &Process::_GetEnvironment);
		
		/**
		 * @tiapi(method=True,name=Process.Process.setEnvironment,since=0.5) Set an environment variable for this process
		 * @tiarg[String, key] an environment key
		 * @tiarg[String, value] the value
		 */
		SetMethod("setEnvironment", &Process::_SetEnvironment);
		
		/**
		 * @tiapi(method=True,name=Process.Process.cloneEnvironment,since=0.5)
		 * @tiresult[Object, environment] A clone of this process' environment
		 */
		SetMethod("cloneEnvironment", &Process::_CloneEnvironment);
		
		/**
		 * @tiapi(method=True,name=Process.Process.launch,since=0.5)
		 * @tiapi Launch this process asynchronously (not waiting for it's exit)
		 */
		SetMethod("launch", &Process::_Launch);
		
		/**
		 * @tiapi(method=True,name=Process.Process.terminate,since=0.5)
		 * @tiapi Terminate this process (SIGTERM in Unix, TerminateProcess in Windows)
		 */
		SetMethod("terminate", &Process::_Terminate);
		
		/**
		 * @tiapi(method=True,name=Process.Process.kill,since=0.5)
		 * @tiapi Kill this process (SIGINT in Unix, TerminateProcess in Windows)
		 */
		SetMethod("kill", &Process::_Kill);
		
		/**
		 * @tiapi(method=True,name=Process.Process.sendSignal,since=0.5)
		 * @tiapi Send a signal (e.g. Process.SIGHUP) to this Process
		 * @tiapi NOTE: this method does nothing in Windows
		 * @tiarg[Number|String, signal] The name of the signal to send.
		 */
		SetMethod("sendSignal", &Process::_SendSignal);
		
		/**
		 * @tiapi(method=True,name=Process.Process.setOnRead,since=0.5)
		 * @tiapi Set an onRead event handler for this process stdout and stderr
		 * @tiarg[Function, onRead] a handler that is passed an event, with a "data" Bytes full of data read from the pipe
		 */
		SetMethod("setOnRead", &Process::_SetOnRead);
		
		/**
		 * @tiapi(method=True,name=Process.Process.setOnExit,since=0.5)
		 * @tiapi Set an onExit event handler for this process
		 * @tiarg[Function, onExit] a function
		 */
		SetMethod("setOnExit", &Process::_SetOnExit);
		
		/**
		 * @tiapi(method=True,name=Process.Process.getStdin,since=0.5)
		 * @tiresult[Process.Pipe] the standard input pipe for this process
		 */
		SetMethod("getStdin", &Process::_GetStdin);
		
		/**
		 * @tiapi(method=True,name=Process.Process.getStdout,since=0.5)
		 * @tiresult[Process.Pipe] the standard output pipe for this process
		 */
		SetMethod("getStdout", &Process::_GetStdout);
		
		/**
		 * @tiapi(method=True,name=Process.Process.getStderr,since=0.5)
		 * @tiresult[Process.Pipe] the standard error pipe for this process
		 */
		SetMethod("getStderr", &Process::_GetStderr);
		
		/**
		 * @tiapi(method=True,name=Process.Process.isRunning,since=0.5)
		 * @tiresult[Boolean] whether or not this process is actively running
		 */
		SetMethod("isRunning", &Process::_IsRunning);
		
		/**
		 * @tiapi(method=True,name=Process.Process.toString,since=0.5)
		 * @tiresult[String] the arguments of this process as a string
		 */
		SetMethod("toString", &Process::_ToString);
	}