예제 #1
0
	int push_remote_data(char* url, char* data, size_t data_size,char* contentType)
	{
		int retval = SYNC_PUSH_CHANGES_ERROR;
		char* szData = 0;
		char* cookie = 0;

		CHttpClient* gHttpClient = NULL;

		cookie = get_db_session(load_source_url());

		if (!cookie && !strstr(url, "clientcreate"))
			return SYNC_PUSH_CHANGES_ERROR;
		
		gHttpClient = CHttpClient::NewL();
		
		gHttpClient->SetCookie(cookie);
		
		gHttpClient->InvokeHttpMethodL(CHttpConstants::EPost,
				(const TUint8*) url, 
				strlen(url), 
				(const TUint8*) data,
				data_size, contentType);

		szData = gHttpClient->GetResponse();

		retval = szData ? SYNC_PUSH_CHANGES_OK : SYNC_PUSH_CHANGES_ERROR;

		if (szData)
			free(szData);

		delete gHttpClient;
		
		return retval;
	}
예제 #2
0
	char* fetch_remote_data(char* url)
		{
		char* cookie = 0;
		char* retval = 0;
		CHttpClient* gHttpClient = NULL;

		cookie = get_db_session(load_source_url());

		if (!cookie && !strstr(url, "clientcreate"))
			{
			return NULL;
			}

		gHttpClient = CHttpClient::NewL();

		gHttpClient->SetCookie(cookie);

		if (cookie)
			free(cookie);

		gHttpClient->InvokeHttpMethodL(CHttpConstants::EGet, (const TUint8*) url, strlen(url), NULL, 0, NULL);

		retval = gHttpClient->GetResponse();

		delete gHttpClient;
		
		return retval;
	}
예제 #3
0
	void makeLoginRequest(char* url, char* data)
	{
		char* session = NULL;
		CHttpClient* gHttpClient = CHttpClient::NewL();

		gHttpClient->InvokeHttpMethodL(CHttpConstants::EPost,
				(const TUint8*) url, 
				strlen(url), 
				(const TUint8*) data, 
				strlen(data), NULL);

		session = gHttpClient->GetCookie();

		if (session)
			set_db_session(load_source_url(), session);
		else
			delete_db_session(load_source_url());

		delete gHttpClient;
	}
예제 #4
0
void* notification_callback(void *parm) {
	notification_params_t* thread_params = (notification_params_t*) parm;
	
	if (thread_params) {
		// Create and install the active scheduler
	
		CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler;
		CleanupStack::PushL(activeScheduler);
		CActiveScheduler::Install(activeScheduler);

		CHttpClient* gHttpClient = CHttpClient::NewL();

		gHttpClient->InvokeHttpMethodL(CHttpConstants::EPost,
				(const TUint8*) thread_params->callback, strlen(
						thread_params->callback),
				(const TUint8*) thread_params->params, strlen(
						thread_params->params), NULL);

		delete gHttpClient;

		CleanupStack::PopAndDestroy(activeScheduler);
	}

	//clear parameters
	if (thread_params) {
		if (thread_params->callback)
			free( thread_params->callback );
		if (thread_params->params)
			free( thread_params->params );

		free(thread_params);
	}

	pthread_exit(NULL);
	return NULL;
}