Exemplo n.º 1
0
void
ProjectGiraffeTab1::updateItems()
{
#if kDebugUseDummyItems
	AppLog("Creating dummy items");
	User *dummyUser = new User();
	dummyUser->setUsername(L"Username");
	for (int i = 0; i < 10; i++) {
		Graffiti *graffiti = new Graffiti();
		graffiti->setUser(dummyUser);
		graffiti->setText(L"dummy string");
		_items->Add(graffiti);
	}

#else

#if kDebugUseHttpConnection

	double latitude = ProjectGiraffeMainForm::currentLatitude;
	double longitude = ProjectGiraffeMainForm::currentLongitude;
	HttpConnection *connection = HttpConnection::graffitiNearbyGetConnection(this,latitude,longitude);
	connection->begin();

#else
	// Kick off http request for items based on location.
	// Populate item source array
	HttpSession* pHttpSession = null;
	HttpTransaction* pHttpTransaction = null;
	String* pProxyAddr = null;
	String hostAddr = L"http://ec2-54-243-69-6.compute-1.amazonaws.com/";
	String uri = L"http://ec2-54-243-69-6.compute-1.amazonaws.com/";

	AppLog("Starting the HTTP Session");
	pHttpSession = new HttpSession();

	// HttpSession construction.
	pHttpSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, pProxyAddr, hostAddr, null);

	// Open a new HttpTransaction.
	pHttpTransaction = pHttpSession->OpenTransactionN();

	// Add a listener.
	pHttpTransaction->AddHttpTransactionListener(*this);

	// Get an HTTP request.
	HttpRequest* pHttpRequest = pHttpTransaction->GetRequest();

	// Set the HTTP method and URI:
	pHttpRequest->SetMethod(NET_HTTP_METHOD_GET);
	pHttpRequest->SetUri(uri);

	// Submit the request:
	pHttpTransaction->Submit();
#endif

#endif
}
Exemplo n.º 2
0
String IRailConnection::getTrip(String &from, String &to,TrainsResultsForm *pTrainsResultsForm) {
	this->pTrainsResultsForm = pTrainsResultsForm;
	result r = E_SUCCESS;
	String* pProxyAddr = null;
	String hostAddr = L"http://api.irail.be";
	String hostAddr2(L"http://api.irail.be/connections/?to=");
	hostAddr2.Append(to);
	hostAddr2.Append(L"&from=");
	hostAddr2.Append(from);
	HttpSession* pSession = null;
	HttpTransaction* pTransaction = null;

	pSession = new HttpSession();
	r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, pProxyAddr ,hostAddr,null);
	if (IsFailed(r))
	{
		AppLog("Construct Session failed. (%s)\n", GetErrorMessage(r));
	}
	pTransaction = pSession->OpenTransactionN();
	if (null == pTransaction)
	{
		AppLog("Construct Session failed. \n");
	}
	r = pTransaction->AddHttpTransactionListener(*this);
	if (IsFailed(r))
	{
		AppLog("AddHttpTransactionListener Session failed.\n");
	}
	HttpRequest* pRequest = pTransaction->GetRequest();
	if(pRequest == null)
	{
		AppLog("GetRequest failed. \n");
	}

	r = pRequest->SetUri(hostAddr2);
	if(IsFailed(r))
	{
		AppLog("SetUri failed. (%s)\n", GetErrorMessage(r));
	}

	r = pRequest->SetMethod(NET_HTTP_METHOD_GET);
	if(IsFailed(r))
	{
		AppLog("SetMethod failed. (%s)\n", GetErrorMessage(r));
	}
	r = pTransaction->Submit();
	if(IsFailed(r))
	{
		AppLog("Submit failed. (%s)\n", GetErrorMessage(r));
	}
	return hostAddr;
}
Exemplo n.º 3
0
void
Network::IsReachable(const String& hostAddr) {
	String* pProxyAddr = null;
	//String hostAddr = L"http://localhost:port";
	AppLogDebug("Trying to reach...%S", hostAddr.GetPointer());
	__pHttpSession = new HttpSession();
	__pHttpSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, pProxyAddr, hostAddr, null);
	HttpTransaction* pHttpTransaction = __pHttpSession->OpenTransactionN();
	pHttpTransaction->AddHttpTransactionListener(*this);
	HttpRequest* pHttpRequest = pHttpTransaction->GetRequest();
	pHttpRequest->SetMethod(NET_HTTP_METHOD_GET);
	pHttpRequest->SetUri(hostAddr);
	pHttpTransaction->Submit();
}
Exemplo n.º 4
0
result Chatting::RequestHttpPost(void) {
	result r = E_SUCCESS;
	HttpSession* pSession = null;
	HttpTransaction* pTransaction = null;
	HttpRequest* pRequest = null;
	HttpMultipartEntity* pMultipartEntity = null;
	String hostAddr(HTTP_CLIENT_HOST_ADDRESS);

	// Creates an HTTP session.
	pSession = new HttpSession();
	r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null);

	pTransaction = pSession->OpenTransactionN();
	r = pTransaction->AddHttpTransactionListener(*this);
	//  r = pTransaction->SetHttpProgressListener(*this);

	pRequest = pTransaction->GetRequest();
	pRequest->SetMethod(NET_HTTP_METHOD_POST);
	r = pRequest->SetUri(HTTP_CLIENT_REQUEST_URI);

	pMultipartEntity = new HttpMultipartEntity();
	r = pMultipartEntity->Construct();

	String me = __pEditField->GetText();

	Tizen::Text::Encoding* pEnc = Tizen::Text::Encoding::GetEncodingN(L"UTF-8");

	pMultipartEntity->AddStringPart(L"message", me, L"text/plain", L"UTF-8",
			*pEnc);
	r = pMultipartEntity->AddStringPart(L"friendIdRegId", resultRegId);

	r = pRequest->SetEntity(*pMultipartEntity);
	r = pTransaction->Submit();

	return r;
}