<commit_before>package se.z_app.stb.api.zenterio;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;

import se.z_app.stb.WebTVItem;
import se.z_app.stb.api.MonoDirectionalCmdInterface;
import se.z_app.stb.api.RemoteControl.Button;

public class RCCommand implements MonoDirectionalCmdInterface {
	
	private String iPAdress;
	
	/**
	 * Constructor that takes the IP adress of the STB as in argument.
	 * @param iP
	 */
	public RCCommand(String iP){
		iPAdress = iP.trim();
	}
	
	/**
	 * Sends a text string to the STB.
	 */
	public void sendText(String text) {
	    HttpClient httpclient = new DefaultHttpClient();
	    HttpPost httppost = new HttpPost("http://" + iPAdress + "/cgi-bin/writepipe_text");
   
	    try {
			httppost.setEntity(new StringEntity(text));
	        httpclient.execute(httppost);	 
	        
	    } catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    
		
	}

	/**
	 * Sends a button command to the STB.
	 */
	public void sendButton(Button button) {
	    HttpClient httpclient = new DefaultHttpClient();
	    HttpPost httppost = new HttpPost("http://" + iPAdress + "/cgi-bin/writepipe_key");
	    String text = buttonToString(button);
	
	    try {
			httppost.setEntity(new StringEntity(text));
	        httpclient.execute(httppost);	 
	        
	    } catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	
	public void launch(String url) {
		// TODO Auto-generated method stub
		
	}

	
	public void playWebTV(WebTVItem item) {
		// TODO Auto-generated method stub
		
	}


	public void queueWebTV(WebTVItem item) {
		// TODO Auto-generated method stub
		
	}

	public void facebookAuth(String accesstoken, String expires, String uid) {
		// TODO Auto-generated method stub
		
	}

	
	public void rawPost(String rawPostData, String uri) {
		// TODO Auto-generated method stub
		
	}

	
	public void rawGet(String uri) {
		// TODO Auto-generated method stub
		
	}
	
	private String buttonToString(Button button){
		String returnString = button.toString();
		if(returnString.substring(0, 0) != "P")
			returnString = "P"+returnString;
		returnString.toLowerCase();
		return returnString;
		
	}

	
}<commit_msg>Placed the network activity in a separate thread. Going to fix the sync. of the argument variables.<commit_after>package se.z_app.stb.api.zenterio;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;

import se.z_app.stb.WebTVItem;
import se.z_app.stb.api.MonoDirectionalCmdInterface;
import se.z_app.stb.api.RemoteControl.Button;

public class RCCommand implements MonoDirectionalCmdInterface {
	
	private String iPAdress;
	private String arg1;

	/**
	 * Constructor that takes the IP adress of the STB as in argument.
	 * @param iP
	 */
	public RCCommand(String iP){
		iPAdress = iP.trim();
	}
	
	/**
	 * Sends a text string to the STB. 
	 */
	public void sendText(String text) {
		arg1 = text;
	    new Thread(new Runnable() {
	    	

			
			@Override
			public void run() {
				   HttpClient httpclient = new DefaultHttpClient();
				   HttpPost httppost = new HttpPost("http://" + iPAdress + "/cgi-bin/writepipe_text");
			   
				   try {
						httppost.setEntity(new StringEntity(arg1));
				        httpclient.execute(httppost);	 
				        
				   } catch (UnsupportedEncodingException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
				   } catch (ClientProtocolException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
				   } catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
				   }
				
			}
		}).start();
	 	  	
	}

	/**
	 * Sends a button command to the STB.
	 */
	public void sendButton(Button button) {
		arg1 = buttonToString(button);
		new Thread(new Runnable() {
			
			@Override
			public void run() {
			    HttpClient httpclient = new DefaultHttpClient();
			    HttpPost httppost = new HttpPost("http://" + iPAdress + "/cgi-bin/writepipe_key");
			    System.out.println("http://" + iPAdress + "/cgi-bin/writepipe_key");
			    
			
			    try {
					httppost.setEntity(new StringEntity(arg1));
			        httpclient.execute(httppost);	 
			        System.out.println(arg1);
			        
			    } catch (UnsupportedEncodingException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (ClientProtocolException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
		}).start();

		
	}

	
	public void launch(String url) {
		arg1 = url;
	    new Thread(new Runnable() {
	    	
			
			@Override
			public void run() {
				   HttpClient httpclient = new DefaultHttpClient();
				   HttpPost httppost = new HttpPost("http://" + iPAdress + "/cgi-bin/launchurl");
			   
				   try {
						httppost.setEntity(new StringEntity(arg1));
				        httpclient.execute(httppost);	 
				        
				   } catch (UnsupportedEncodingException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
				   } catch (ClientProtocolException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
				   } catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
				   }
				
			}
		}).start();
		
	}

	
	public void playWebTV(WebTVItem item) {
		// TODO Auto-generated method stub
		
	}


	public void queueWebTV(WebTVItem item) {
		// TODO Auto-generated method stub
		
	}

	public void facebookAuth(String accesstoken, String expires, String uid) {
		// TODO Auto-generated method stub
		
	}


	public void rawPost(String rawPostData, String uri) {
		// TODO Auto-generated method stub
		
	}

	
	public void rawGet(String uri) {
		// TODO Auto-generated method stub
		
	}
	
	private String buttonToString(Button button){
		String returnString = button.toString();
		if(!returnString.startsWith("P"))
			returnString = "P"+returnString;
		returnString = returnString.toLowerCase();
		return returnString;
		
	}
	


	
}
{'fraction_non_alphanumeric': 0.10679196924391286, 'fraction_numerical': 0.0014238929232521715, 'mean_word_length': 2.86784140969163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1075142', 'n_tokens_mistral': 2530, 'n_tokens_neox': 2092, 'n_words': 521}