Example #1
0
// CTORS ////////////////////////////////////////////////////////////////////////////////
AnimationComponent::AnimationComponent(const std::string& jsonData)
	: time(0.0f)
	, currentFrame(0)
	, state (0)
{
	ParseJsonData(jsonData);
}
Example #2
0
void AnimationComponent::LoadFromJSON(const std::string& name)
{
	ParseJsonData( JsonStringFromFile( name.c_str() ) );
}
Example #3
0
bool CurlCore::VerifyUser(const string& sAuthUri, const string &sUserName, const string &sUserRepo, string &sTTL, string sCertificatePath)
{
	CURLcode res;
	string sUri = sAuthUri + "/" + sUserName;

	if(sUserRepo != "")
		sUri += "/"+sUserRepo+"/releases";

	//printf("Req URI: "<<sUri<<endl;
	if(m_pCurl)
	{
		curl_easy_setopt(m_pCurl, CURLOPT_URL, sUri.c_str());
		/* example.com is redirected, so we tell libcurl to follow redirection */ 
		curl_easy_setopt(m_pCurl, CURLOPT_FOLLOWLOCATION, 1L);

		// User-agent header 
		string sUserAgent = "CeasyCurl (sharma) v1.0";
		curl_easy_setopt(m_pCurl, CURLOPT_USERAGENT, sUserAgent.c_str());

		if(sCertificatePath == "")
		{
#ifdef ENABLE_HTTPS
			curl_easy_setopt(m_pCurl, CURLOPT_SSL_VERIFYPEER, 0L);
			curl_easy_setopt(m_pCurl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif
		}
		else
		{
			curl_easy_setopt(m_pCurl, CURLOPT_SSL_VERIFYPEER, 1);
			curl_easy_setopt(m_pCurl, CURLOPT_SSL_VERIFYHOST, 2);
			curl_easy_setopt(m_pCurl, CURLOPT_CAINFO, sCertificatePath.c_str());
		}		
	 	curl_easy_setopt(m_pCurl, CURLOPT_WRITEFUNCTION, WriteCallback);
		

		/* Perform the request, res will get the return code */ 
		res = curl_easy_perform(m_pCurl);
		//printf("Curl req performed"<<endl;
		char * url;
		long respcode=0;
		curl_easy_getinfo(m_pCurl, CURLINFO_RESPONSE_CODE, &respcode);
		
		/* Check for errors */ 
		if(res != CURLE_OK)
		  fprintf(stderr, "curl_easy_perform() failed: %s\n",
		          curl_easy_strerror(res));

		switch(respcode)
		{
			case 200:
			{
				// Parse the static string buffer readBuffer for username
				vector<string> sValues;
				printf("Your querry Succeeded :)\n");
				ParseJsonData(readBuffer, sValues);

				//for(int i=0;i<sValues.size();i++)
				{
					//printf("Response Values = %s\n", sValues[i].c_str());
				}
				readBuffer.clear();
				return true;
				break;	
			}
			case 401:
				printf("Un-Authorize\n");
				break;
			case 504:
				printf("Server Time-out\n");
				break;
			case 400:
				printf("Page not found\n");
				break;
			default:
			break;
		}
		readBuffer.clear();
 	}
	return false;
}