2013-05-18 Mark Holland <mark@mark-holland.me.uk>
* src/pandroid/agent/PandroidAgentListener.java: Changed xml header to UTF-8 encoding. * src/pandroid/agent/PandroidAgentTentacle.java: Changed data String to byte array. * Pandroid Agent v3.0_UTF8.apk: Added apk that sends xml in utf-8 encoding. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
d4e7b1f795
commit
9d718116aa
|
@ -1,3 +1,14 @@
|
|||
2013-05-18 Mark Holland <mark@mark-holland.me.uk>
|
||||
|
||||
* src/pandroid/agent/PandroidAgentListener.java: Changed xml
|
||||
header to UTF-8 encoding.
|
||||
|
||||
* src/pandroid/agent/PandroidAgentTentacle.java: Changed data
|
||||
String to byte array.
|
||||
|
||||
* Pandroid Agent v3.0_UTF8.apk: Added apk that sends xml in
|
||||
utf-8 encoding.
|
||||
|
||||
2013-05-16 Mark Holland <mark@mark-holland.me.uk>
|
||||
|
||||
* src/pandroid/agent/PandroidAgentListener.java: Fixed
|
||||
|
|
|
@ -363,7 +363,7 @@ public class PandroidAgentListener extends Service {
|
|||
private String buildXML(){
|
||||
String buffer = "";
|
||||
String gpsData = "";
|
||||
buffer += "<?xml version='1.0' encoding='iso-8859-1'?>\n";
|
||||
buffer += "<?xml version='1.0' encoding='UTF-8'?>\n";
|
||||
|
||||
String latitude = getSharedData("PANDROID_DATA", "latitude", "181", "float");
|
||||
String longitude = getSharedData("PANDROID_DATA", "longitude", "181", "float");
|
||||
|
|
|
@ -14,17 +14,12 @@
|
|||
|
||||
package pandroid.agent;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.*;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
class tentacle_client {
|
||||
|
||||
|
@ -35,7 +30,7 @@ class tentacle_client {
|
|||
String send = null;
|
||||
String serverResponse = null;
|
||||
String address = "127.0.0.1";
|
||||
String data = "";
|
||||
byte[] data = null;
|
||||
String parameter = "";
|
||||
String filePath = null;
|
||||
boolean verbose = false;
|
||||
|
@ -80,7 +75,7 @@ class tentacle_client {
|
|||
socketCliente.connect(new InetSocketAddress(address, port), 2000);
|
||||
|
||||
} catch (UnknownHostException e) {
|
||||
getError("Host don't exists");
|
||||
getError("Host doesn't exist");
|
||||
return -1;
|
||||
} catch (IOException e) {
|
||||
getError("Could not connect: The host is down");
|
||||
|
@ -104,26 +99,24 @@ class tentacle_client {
|
|||
getError("Could not get Buffered reader");
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
file = new File(filePath);
|
||||
FileReader fr = new FileReader (file);
|
||||
BufferedReader br = new BufferedReader(fr);
|
||||
|
||||
getInfo("Reading the file '" + file.getName() + "' content...\n", verbose);
|
||||
// Reading the file
|
||||
String line;
|
||||
while((line=br.readLine())!=null)
|
||||
data += line + '\n';
|
||||
|
||||
br.close();
|
||||
int size = (int) file.length();
|
||||
data = new byte[size];
|
||||
try {
|
||||
BufferedInputStream buf = new BufferedInputStream(new FileInputStream(file));
|
||||
buf.read(data, 0, data.length);
|
||||
buf.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
getError("File not found");
|
||||
} catch (IOException e) {
|
||||
getError("Could not get the file");
|
||||
getError("Could not read from file");
|
||||
}
|
||||
|
||||
getInfo("*** Start of transference ***\n",verbose);
|
||||
// Send the file name and length
|
||||
try {
|
||||
send = "SEND <" + file.getName() + "> SIZE " + Integer.toString(data.length()) + '\n';
|
||||
send = "SEND <" + file.getName() + "> SIZE " + Integer.toString(data.length) + '\n';
|
||||
getInfo("Client -> Server: " + send, verbose);
|
||||
serverOutput.writeBytes(send);
|
||||
} catch (IOException e) {
|
||||
|
@ -139,7 +132,7 @@ class tentacle_client {
|
|||
if (serverResponse != null && serverResponse.equals("SEND OK")) {
|
||||
try {
|
||||
getInfo("Client -> Server: [file data]\n", verbose);
|
||||
serverOutput.writeBytes(data);
|
||||
serverOutput.write(data);
|
||||
|
||||
} catch (IOException e) {
|
||||
getError("Could not write on server");
|
||||
|
|
Loading…
Reference in New Issue