From e461e5e3c4e6104d4eb744b07e24abba6f3a1db8 Mon Sep 17 00:00:00 2001 From: str4d Date: Wed, 16 Jul 2014 01:45:14 +0000 Subject: [PATCH] Use the I2P Android client library The build script looks for the client library in Maven Central. It is possible to use a local .aar by placing it in a folder "aars" in the base folder, and uncommenting the flatDir{} section in the base build.gradle. --- app/build.gradle | 1 + .../android/router/service/IRouterState.aidl | 33 ------------------- .../router/service/IRouterStateCallback.aidl | 13 -------- .../i2p/bote/android/service/BoteService.java | 15 +++++---- botejars/build.gradle | 3 -- botejars/build.xml | 14 +------- build.gradle | 3 ++ 7 files changed, 13 insertions(+), 69 deletions(-) delete mode 100644 app/src/main/aidl/net/i2p/android/router/service/IRouterState.aidl delete mode 100644 app/src/main/aidl/net/i2p/android/router/service/IRouterStateCallback.aidl diff --git a/app/build.gradle b/app/build.gradle index 3d7d822..b6cbeaa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,6 +24,7 @@ android { } dependencies { + compile 'net.i2p.android:client:0.1@aar' compile project(':botejars') compile fileTree(dir: 'libs', include: '*.jar') compile 'com.android.support:support-v4:19.1.0' diff --git a/app/src/main/aidl/net/i2p/android/router/service/IRouterState.aidl b/app/src/main/aidl/net/i2p/android/router/service/IRouterState.aidl deleted file mode 100644 index 1a087bc..0000000 --- a/app/src/main/aidl/net/i2p/android/router/service/IRouterState.aidl +++ /dev/null @@ -1,33 +0,0 @@ -package net.i2p.android.router.service; - -import net.i2p.android.router.service.IRouterStateCallback; - -/** - * An interface for determining the state of the I2P RouterService. - */ -interface IRouterState { - - /** - * This allows I2P to inform on state changes. - */ - void registerCallback(IRouterStateCallback cb); - - /** - * Remove registered callback interface. - */ - void unregisterCallback(IRouterStateCallback cb); - - /** - * Determines whether the RouterService has been started. If it hasn't, no - * state changes will ever occur from this RouterService instance, and the - * client should unbind and inform the user that the I2P router is not - * running (and optionally send a net.i2p.android.router.START_I2P Intent). - */ - boolean isStarted(); - - /** - * Get the state of the I2P router - **/ - String getState(); - -} diff --git a/app/src/main/aidl/net/i2p/android/router/service/IRouterStateCallback.aidl b/app/src/main/aidl/net/i2p/android/router/service/IRouterStateCallback.aidl deleted file mode 100644 index a5ee84c..0000000 --- a/app/src/main/aidl/net/i2p/android/router/service/IRouterStateCallback.aidl +++ /dev/null @@ -1,13 +0,0 @@ -package net.i2p.android.router.service; - -/** - * Callback interface used to send synchronous notifications of the current - * RouterService state back to registered clients. Note that this is a - * one-way interface so the server does not block waiting for the client. - */ -oneway interface IRouterStateCallback { - /** - * Called when the state of the I2P router changes - */ - void stateChanged(String newState); -} diff --git a/app/src/main/java/i2p/bote/android/service/BoteService.java b/app/src/main/java/i2p/bote/android/service/BoteService.java index c99057a..9f8b344 100644 --- a/app/src/main/java/i2p/bote/android/service/BoteService.java +++ b/app/src/main/java/i2p/bote/android/service/BoteService.java @@ -8,6 +8,7 @@ import javax.mail.MessagingException; import net.i2p.android.router.service.IRouterState; import net.i2p.android.router.service.IRouterStateCallback; +import net.i2p.android.router.service.State; import net.i2p.router.Router; import net.i2p.router.RouterContext; import net.i2p.router.RouterLaunch; @@ -146,8 +147,8 @@ public class BoteService extends Service implements NetworkStatusListener, NewEm mStateService = IRouterState.Stub.asInterface(service); try { mStateService.registerCallback(mStatusListener); - String state = mStateService.getState(); - if ("ACTIVE".equals(state)) + final int state = mStateService.getState(); + if (state == State.ACTIVE) I2PBote.getInstance().connectNow(); } catch (RemoteException e) { // TODO Auto-generated catch block @@ -164,11 +165,11 @@ public class BoteService extends Service implements NetworkStatusListener, NewEm private final IRouterStateCallback.Stub mStatusListener = new IRouterStateCallback.Stub() { - public void stateChanged(String newState) throws RemoteException { - if ("STOPPING".equals(newState) || - "MANUAL_STOPPING".equals(newState) || - "MANUAL_QUITTING".equals(newState) || - "NETWORK_STOPPING".equals(newState)) + public void stateChanged(int newState) throws RemoteException { + if (newState == State.STOPPING || + newState == State.MANUAL_STOPPING || + newState == State.MANUAL_QUITTING || + newState == State.NETWORK_STOPPING) stopSelf(); } }; diff --git a/botejars/build.gradle b/botejars/build.gradle index 6855de4..7fa72eb 100644 --- a/botejars/build.gradle +++ b/botejars/build.gradle @@ -8,10 +8,7 @@ task buildJars(type: Exec) { // TODO an empty botejars.jar is added to the classpath artifacts { - 'default' file: file('libs/i2p.jar'), builtBy: buildJars 'default' file: file('libs/router.jar'), builtBy: buildJars - 'default' file: file('libs/mstreaming.jar'), builtBy: buildJars - 'default' file: file('libs/streaming.jar'), builtBy: buildJars 'default' file: file('libs/bcprov-ecc-jdk16-146.jar'), builtBy: buildJars 'default' file: file('libs/flexi-gmss-1.7p1.jar'), builtBy: buildJars 'default' file: file('libs/lzma-9.20.jar'), builtBy: buildJars diff --git a/botejars/build.xml b/botejars/build.xml index 5facff4..ba28680 100644 --- a/botejars/build.xml +++ b/botejars/build.xml @@ -69,21 +69,9 @@ - - - - - - - - - - - - - + diff --git a/build.gradle b/build.gradle index 76a4eef..660c6e4 100644 --- a/build.gradle +++ b/build.gradle @@ -10,6 +10,9 @@ buildscript { allprojects { repositories { +// flatDir { +// dirs file("${project.rootDir}/aars") +// } mavenCentral() } } \ No newline at end of file