mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
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
4f9ed4473b
commit
d4afafa13c
@ -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>
|
2013-05-16 Mark Holland <mark@mark-holland.me.uk>
|
||||||
|
|
||||||
* src/pandroid/agent/PandroidAgentListener.java: Fixed
|
* src/pandroid/agent/PandroidAgentListener.java: Fixed
|
||||||
|
@ -363,7 +363,7 @@ public class PandroidAgentListener extends Service {
|
|||||||
private String buildXML(){
|
private String buildXML(){
|
||||||
String buffer = "";
|
String buffer = "";
|
||||||
String gpsData = "";
|
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 latitude = getSharedData("PANDROID_DATA", "latitude", "181", "float");
|
||||||
String longitude = getSharedData("PANDROID_DATA", "longitude", "181", "float");
|
String longitude = getSharedData("PANDROID_DATA", "longitude", "181", "float");
|
||||||
|
@ -14,28 +14,23 @@
|
|||||||
|
|
||||||
package pandroid.agent;
|
package pandroid.agent;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.*;
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
class tentacle_client {
|
class tentacle_client {
|
||||||
|
|
||||||
// Return 0 when success, -1 when error
|
// Return 0 when success, -1 when error
|
||||||
public int tentacle_client(String args[]) {
|
public int tentacle_client(String args[]) {
|
||||||
|
|
||||||
int port = 41121;
|
int port = 41121;
|
||||||
String send = null;
|
String send = null;
|
||||||
String serverResponse = null;
|
String serverResponse = null;
|
||||||
String address = "127.0.0.1";
|
String address = "127.0.0.1";
|
||||||
String data = "";
|
byte[] data = null;
|
||||||
String parameter = "";
|
String parameter = "";
|
||||||
String filePath = null;
|
String filePath = null;
|
||||||
boolean verbose = false;
|
boolean verbose = false;
|
||||||
@ -62,7 +57,7 @@ class tentacle_client {
|
|||||||
// The solo params are checked otherwise
|
// The solo params are checked otherwise
|
||||||
if(parameter.equals("-v")) {
|
if(parameter.equals("-v")) {
|
||||||
verbose = true;
|
verbose = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,12 +75,12 @@ class tentacle_client {
|
|||||||
socketCliente.connect(new InetSocketAddress(address, port), 2000);
|
socketCliente.connect(new InetSocketAddress(address, port), 2000);
|
||||||
|
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
getError("Host don't exists");
|
getError("Host doesn't exist");
|
||||||
return -1;
|
return -1;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
getError("Could not connect: The host is down");
|
getError("Could not connect: The host is down");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DataOutputStream serverOutput = null;
|
DataOutputStream serverOutput = null;
|
||||||
@ -104,26 +99,24 @@ class tentacle_client {
|
|||||||
getError("Could not get Buffered reader");
|
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);
|
file = new File(filePath);
|
||||||
// Reading the file
|
int size = (int) file.length();
|
||||||
String line;
|
data = new byte[size];
|
||||||
while((line=br.readLine())!=null)
|
try {
|
||||||
data += line + '\n';
|
BufferedInputStream buf = new BufferedInputStream(new FileInputStream(file));
|
||||||
|
buf.read(data, 0, data.length);
|
||||||
br.close();
|
buf.close();
|
||||||
} catch (IOException e) {
|
} catch (FileNotFoundException e) {
|
||||||
getError("Could not get the file");
|
getError("File not found");
|
||||||
}
|
} catch (IOException e) {
|
||||||
|
getError("Could not read from file");
|
||||||
|
}
|
||||||
|
|
||||||
getInfo("*** Start of transference ***\n",verbose);
|
getInfo("*** Start of transference ***\n",verbose);
|
||||||
// Send the file name and length
|
// Send the file name and length
|
||||||
try {
|
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);
|
getInfo("Client -> Server: " + send, verbose);
|
||||||
serverOutput.writeBytes(send);
|
serverOutput.writeBytes(send);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -139,7 +132,7 @@ class tentacle_client {
|
|||||||
if (serverResponse != null && serverResponse.equals("SEND OK")) {
|
if (serverResponse != null && serverResponse.equals("SEND OK")) {
|
||||||
try {
|
try {
|
||||||
getInfo("Client -> Server: [file data]\n", verbose);
|
getInfo("Client -> Server: [file data]\n", verbose);
|
||||||
serverOutput.writeBytes(data);
|
serverOutput.write(data);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
getError("Could not write on server");
|
getError("Could not write on server");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user