Skip to content

Commit

Permalink
Se han parcheado las comunicaciones para que envien los metadatos "re…
Browse files Browse the repository at this point in the history
…leaseDate" y "dateLimit" en forma de String para evitar las excepciones en el nodo servidor. Además, se añadio la instrucción para que los procesos de salvar y recuperar se ejecuten en hilos distintos a la activity.
  • Loading branch information
luislorenzom committed Jun 25, 2016
1 parent 435163f commit 8cfdef1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ repositories {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files('libs/NautilusMessage.jar')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'net.tomp2p:tomp2p-android:5.0-Beta5'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile files('libs/NautilusMessage.jar')
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void onClick(View v) {
final ProgressDialog progress = ProgressDialog.show(FileNavigator.this, "Retrieving file",
"Conneting with the servers, wait a minute", true);

new Thread(new Runnable() {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
ClientConnection clientConnection = new ClientConnection(FileNavigator.this);
Expand All @@ -194,6 +194,8 @@ public void run() {
}
});

t.start();

} else {
Toast.makeText(getApplicationContext(), "Can't get the keys from this file", Toast.LENGTH_SHORT).show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
publicKey = null;
}

final ProgressDialog progress = ProgressDialog.show(PrepareFileToSend.this, "Retrieving file",
final ProgressDialog progress = ProgressDialog.show(PrepareFileToSend.this, "Saving file",
"Conneting with the servers, wait a minute", true);

new Thread(new Runnable() {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
// Send the petition to clientConnection
Expand All @@ -231,6 +231,10 @@ public void run() {
});
}
});

t.start();


}
return super.onOptionsItemSelected(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ private int startClient(String ipAddress, NautilusMessage msgObject) {
}

// --------------------------------------------------------------
if (msgObject.getType() == 1) {
if (msgObject.getType() == 3) {
// Send and logic to process msg type one
FutureDirect future = client.sendDirect(peerA).object(msg).start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
Expand Down Expand Up @@ -96,8 +97,20 @@ public List<NautilusMessage> prepareFileToSend(String filePath, int downloadLimi
keysList.add(nKey);

// Generate a message
NautilusMessage msg = new NautilusMessage(1, hash, readContentIntoByteArray(encryptFile),
downloadLimit, dateLimit, releaseDate);
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String dateLimitString = null;
String releaseDateString = null;

if (dateLimit != null) {
dateLimitString = sdf.format(dateLimit.getTime());
}

if (releaseDate != null) {
releaseDateString = sdf.format(releaseDate.getTime());
}

NautilusMessage msg = new NautilusMessage(dateLimitString, releaseDateString, 3, hash,
readContentIntoByteArray(encryptFile), downloadLimit);

// Add the new message to the messageList
msgs.add(msg);
Expand Down

0 comments on commit 8cfdef1

Please sign in to comment.