void WaMetascanEventHandler::responseStatusCheck( WaJson& json_response, void* p_enclosure )
{
	TStatus* p_status = ( TStatus* )p_enclosure;

	if ( !json_response.isType( WAAPI_JSON_OBJECT ) )
	{
		printf( "[response status check] - json wrong format\n" );
		UResult scan_result( WA_METASCAN_ERROR_INVALID_JSON );
		p_status->p_result->couple = scan_result.couple;
	}
	else
	{
		WaMetascanEventHandler::_processStatusResponse( json_response, p_status );
	}
	delete p_status;
}
void WaMetascanEventHandler::_processStatusResponse( WaJson& json_response, TStatus* p_status )
{
	WaJson  result_json;
	int     percentage;
	UResult scan_result( WA_METASCAN_ERROR_INVALID_JSON );

	if ( ( WAAPI_SUCCESS( json_response.get( L"scan_results", result_json ) )  &&
		( WAAPI_SUCCESS( result_json.get( L"progress_percentage", percentage ) ) ) ) )
	{
		if ( percentage < 100 )
		{
			// Just for file
			printf( " - Progress: %d\n", percentage );
			TStatus* p_new_status = new TStatus( *p_status );			

			TDataContext* p_context = new TDataContext( p_status->s_root,
														p_status->s_resource,
														true,                       // GET
														"",                         // Nothing set in message body
														( void* )p_new_status,      // Current enclosure
														&( WaMetascanEventHandler::responseStatusCheck ),
														NULL, NULL );
			WaMetascanDataSender::signal( p_context );
		}
		else
		{
			// For both file and hash
			wa_int n_engine = 0;
			wa_int i_status = WA_METASCAN_ERROR_INVALID_JSON;

			result_json.get( L"scan_all_result_i", i_status );
			result_json.get( L"total_avs", n_engine );
			scan_result.detail.n_engine = ( char )n_engine;
			scan_result.detail.scan_status = ( char )i_status;

			p_status->p_result->couple = scan_result.couple;
		}
	}
	else
	{
		p_status->p_result->couple = scan_result.couple;
	}
}
Exemplo n.º 3
0
void ui_screen(struct p2p *p)
{

	system("clear");
	printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
	printf("****************************************************************************************************\n");
	printf("*                                      P2P UI TEST v0.5                                            *\n");
	printf("****************************************************************************************************\n");
	printf("* Enable: %-89s*\n", naming_enable(p->enable));
	printf("* Intent: %2d                                                                                       *\n", p->intent);
	printf("* Status: %-89s*\n", naming_status(p->status));
	printf("* Role: %-91s*\n", naming_role(p->role));
	printf("* WPS method: %-85s*\n", naming_wpsinfo(p->wps_info));
	printf("* PIN code: %08d                                                                               *\n", p->pin);
	
	printf("* Device name: %-84s*\n", p->dev_name);
	printf("* Peer device address: %-76s*\n", p->peer_devaddr);
	printf("* Peer interface address: %-73s*\n", p->peer_ifaddr);
	
	printf("*                                                                                                  *\n");
	printf("* e) Wi-Fi Direct Enable/Disable                                                                   *\n");
	printf("* i) Intent ( The degree to be Group Owner/SoftAP )                                                *\n");
	printf("* a) Scan Wi-Fi Direct devices                                                                     *\n");
	printf("* m) Peer device address you want to test                                                          *\n");
	printf("* p) Provision discovery                                                                           *\n");
	printf("* c) Input PIN codes                                                                               *\n");
	printf("* w) WPS method                                                                                    *\n");
	printf("* n) Group owner negotiation                                                                       *\n");
	printf("* x) Start wpa_supplicant/hostapd                                                                  *\n");
	printf("* h) Set operation channel                        | t) Set SoftAP ssid                             *\n");
	printf("* r) Get Current P2P Role                         | s) Get Current P2P Status                      *\n");
	printf("* d) Set device name                              | l) Set Listen channel                          *\n");
	printf("* f) Reflash Current State                        | q) Quit                                        *\n");
	printf("****************************************************************************************************\n");
	
	
	if(p->p2p_get==0)
	{
		printf("*                                                                                                  *\n");
	}	
	else if(p->p2p_get==1)
	{
		printf("*%-98s*\n", p->print_line);
	}
	
	printf("****************************************************************************************************\n");
	
	if( ( p->show_scan_result == 1 ) && ( p->have_p2p_dev == 1 ) )
	//if( (p->have_p2p_dev == 1) && (p->enable >= P2P_ROLE_DEVICE) && ( p->wpsing == 0 ) && (p->status >= P2P_STATE_LISTEN && p->status <= P2P_STATE_FIND_PHASE_SEARCH) )
	{
			scan_result(p);
	}
	else
	{
		int i=0;
		for(i = 0; i < SCAN_POOL_NO + 1; i++ )
			printf("*                                                                                                  *\n");
	}	
	
	printf("****************************************************************************************************\n");

	p->show_scan_result = 0;
}