Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change package and class names

renamed package to com.couchbase.android
renamed ICouchClient to ICouchbaseDelegate
renamed other instances of couch to Couchbase

Change-Id: I78079854c86839d1d0d48d1ec09de3c114e91fb8
Reviewed-on: http://review.couchbase.org/9240
Reviewed-by: Dale Harvey <daleharvey@arandomurl.com>
Tested-by: Dale Harvey <daleharvey@arandomurl.com>
  • Loading branch information...
commit b7a557910571690db44557ac28ff2ed3bf64b7d2 1 parent 869373a
@mschoch mschoch authored Dale Harvey committed
View
6 AndroidManifest.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.couchbase.libcouch"
+ package="com.couchbase.android"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
- <service android:name="com.couchbase.libcouch.CouchService" android:enabled="true" android:process=":remote">
+ <service android:name="com.couchbase.android.CouchbaseService" android:enabled="true" android:process=":remote">
<intent-filter>
- <action android:name="com.couchbase.libcouch.ICouchService"></action>
+ <action android:name="com.couchbase.android.ICouchService"></action>
</intent-filter>
</service>
View
4 script/couchbase-build.xml
@@ -124,7 +124,7 @@ all - Run all checks
<target name="check-manifest-service">
<condition property="service.couch.exists">
- <resourcecontains resource="${basedir}/AndroidManifest.xml" substring="com.couchbase.libcouch.CouchService"/>
+ <resourcecontains resource="${basedir}/AndroidManifest.xml" substring="com.couchbase.android.CouchbaseService"/>
</condition>
</target>
@@ -142,7 +142,7 @@ all - Run all checks
<target name="_init">
<!-- don't continue if it appears android.couchbase.dir is set incorrectly -->
- <available file="${android.couchbase.dir}/src/com/couchbase/libcouch/CouchbaseMobile.java"
+ <available file="${android.couchbase.dir}/src/com/couchbase/android/CouchbaseMobile.java"
property="android.couchbase.dir.valid"/>
<fail message="Property android.couchbase.dir does not appear to be set correctly." unless="android.couchbase.dir.valid"/>
</target>
View
2  script/couchbase-service.xsl
@@ -12,7 +12,7 @@ xmlns:android="http://schemas.android.com/apk/res/android">
<xsl:template match="application">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
- <service android:name="com.couchbase.libcouch.CouchService" android:enabled="true" android:exported="false"></service>
+ <service android:name="com.couchbase.android.CouchbaseService" android:enabled="true" android:exported="false"></service>
</xsl:copy>
</xsl:template>
View
20 ...om/couchbase/libcouch/CouchInstaller.java → ...couchbase/android/CouchbaseInstaller.java
@@ -1,4 +1,4 @@
-package com.couchbase.libcouch;
+package com.couchbase.android;
import java.io.BufferedReader;
import java.io.File;
@@ -20,13 +20,13 @@
import android.os.Message;
import android.util.Log;
-public class CouchInstaller {
+public class CouchbaseInstaller {
public static String indexFile() {
return CouchbaseMobile.dataPath() + "/installedfiles.index";
}
- public static void doInstall(String pkg, Handler handler, CouchService service)
+ public static void doInstall(String pkg, Handler handler, CouchbaseService service)
throws IOException {
if(!checkInstalled(pkg)) {
@@ -39,10 +39,10 @@ public static void doInstall(String pkg, Handler handler, CouchService service)
* of protecting ourselves from wiping the entire SD card with a typo.
*/
- File couchDir = new File(CouchbaseMobile.dataPath() + "/couchdb");
+ File couchbaseDir = new File(CouchbaseMobile.dataPath() + "/couchdb");
- if (couchDir.exists()) {
- deleteDirectory(couchDir);
+ if (couchbaseDir.exists()) {
+ deleteDirectory(couchbaseDir);
}
File erlangDir = new File(CouchbaseMobile.dataPath() + "/erlang");
@@ -55,14 +55,14 @@ public static void doInstall(String pkg, Handler handler, CouchService service)
}
Message done = Message.obtain();
- done.what = CouchService.COMPLETE;
+ done.what = CouchbaseService.COMPLETE;
handler.sendMessage(done);
}
/*
* This fetches a given package from amazon and tarbombs it to the filsystem
*/
- private static void installPackage(String pkg, Handler handler, CouchService service)
+ private static void installPackage(String pkg, Handler handler, CouchbaseService service)
throws IOException {
Log.v(CouchbaseMobile.TAG, "Installing " + pkg);
@@ -146,7 +146,7 @@ private static void installPackage(String pkg, Handler handler, CouchService ser
Message progress = new Message();
progress.arg1 = (int) ++filesUnpacked;
progress.arg2 = (int) filesInArchive;
- progress.what = CouchService.PROGRESS;
+ progress.what = CouchbaseService.PROGRESS;
handler.sendMessage(progress);
}
@@ -194,7 +194,7 @@ private static void installPackage(String pkg, Handler handler, CouchService ser
}
/*
- * Verifies that requested version of CouchDB is installed by checking for the presence of
+ * Verifies that requested version of Couchbase is installed by checking for the presence of
* the package files we write upon installation in the data directory of the app.
*/
public static boolean checkInstalled(String pkg) {
View
31 ...m/couchbase/libcouch/CouchbaseMobile.java → ...om/couchbase/android/CouchbaseMobile.java
@@ -1,4 +1,4 @@
-package com.couchbase.libcouch;
+package com.couchbase.android;
import java.io.File;
import java.io.FileNotFoundException;
@@ -8,6 +8,9 @@
import java.io.OutputStream;
import java.util.ArrayList;
+import com.couchbase.android.ICouchbaseDelegate;
+import com.couchbase.android.ICouchbaseService;
+
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -34,7 +37,7 @@
private static String releaseName;
/*
- * The default package name of couchdb binaries, applications are
+ * The default package name of Couchbase binaries, applications are
* recommended to use this default package name as it ensures this library
* was built to support these binaries
*/
@@ -45,8 +48,8 @@
*/
public static ArrayList<String> customIniFiles = new ArrayList<String>();
- private static ICouchService couchService;
- private static ICouchClient couchClient;
+ private static ICouchbaseService couchbaseService;
+ private static ICouchbaseDelegate couchbaseDelegate;
private static Context ctx;
/*
@@ -54,8 +57,8 @@
* that cannot be gotten automatically, so made this a class to
* store some context for later functions
*/
- public CouchbaseMobile(Context appCtx, ICouchClient client) {
- couchClient = client;
+ public CouchbaseMobile(Context appCtx, ICouchbaseDelegate delegate) {
+ couchbaseDelegate = delegate;
ctx = appCtx;
appNamespace = ctx.getPackageName();
}
@@ -78,18 +81,18 @@ public ServiceConnection startCouchbase() {
/*
* Start Couchbase, this starts Couchbase as an android service, the ServiceConnection
* returned allowed for futher communication (such as install progress / started
- * callbacks), check the ICouchClient.aidl and ICouchServer.aidl for the definition
+ * callbacks), check the ICouchbaseDelegate.aidl and ICouchbaseService.aidl for the definition
* of these callbacks
*/
public ServiceConnection startCouchbase(Context ctx, String release) {
releaseName = release;
- ctx.bindService(new Intent(ctx, CouchService.class), mConnection, Context.BIND_AUTO_CREATE);
+ ctx.bindService(new Intent(ctx, CouchbaseService.class), mConnection, Context.BIND_AUTO_CREATE);
return mConnection;
}
/*
* This will copy a database from the assets folder into the
- * couch database directory
+ * couchbase database directory
* NOTE: Databases that use snappy encoding will not currently
* be able to be opened
*/
@@ -101,7 +104,7 @@ public void installDatabase(String fileName) throws IOException {
/*
* Copy an .ini file from the assets folder into
* /data/data/com.your.app/user_data directory and
- * add it to the list of ini files for couch to load
+ * add it to the list of ini files for couchbase to load
*/
public void copyIniFile(String fileName) throws IOException {
File destination = new File(dataPath() + "/user_data/" + fileName);
@@ -133,14 +136,14 @@ private void copyIffNotExists(String name, File destination) throws IOException
}
/*
- * This holds the connection to the CouchDB Service
+ * This holds the connection to the Couchbase Service
*/
private final static ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, final IBinder service) {
try {
- couchService = ICouchService.Stub.asInterface(service);
- couchService.startCouchbase(couchClient, releaseName);
+ couchbaseService = ICouchbaseService.Stub.asInterface(service);
+ couchbaseService.startCouchbase(couchbaseDelegate, releaseName);
} catch (RemoteException e) {
e.printStackTrace();
}
@@ -148,7 +151,7 @@ public void onServiceConnected(ComponentName className, final IBinder service) {
@Override
public void onServiceDisconnected(ComponentName className) {
- couchService = null;
+ couchbaseService = null;
}
};
}
View
88 src/com/couchbase/libcouch/CouchService.java → ...m/couchbase/android/CouchbaseService.java
@@ -1,4 +1,4 @@
-package com.couchbase.libcouch;
+package com.couchbase.android;
import java.io.BufferedReader;
import java.io.FileDescriptor;
@@ -26,35 +26,37 @@
import android.os.RemoteException;
import android.util.Log;
+import com.couchbase.android.ICouchbaseDelegate;
+import com.couchbase.android.ICouchbaseService;
import com.google.ase.Exec;
-public class CouchService extends Service {
+public class CouchbaseService extends Service {
/*
- * Contants used to communnicate between the Couch Service
+ * Contants used to communnicate between the Couchbase Service
* and this thread
*/
public final static int ERROR = 0;
public final static int PROGRESS = 1;
public final static int COMPLETE = 2;
- public final static int COUCH_STARTED = 3;
+ public final static int COUCHBASE_STARTED = 3;
public final static int INSTALLING = 4;
- /* The url Couch has started on */
+ /* The url Couchbase has started on */
public URL url;
- /* Has Couch started */
- public boolean couchStarted = false;
+ /* Has Couchbase started */
+ public boolean couchbaseStarted = false;
- /* This is how we talk to the app that started Couch */
- private ICouchClient client;
+ /* This is how we talk to the app that started Couchbase */
+ private ICouchbaseDelegate couchbaseDelegate;
private Integer pid;
private PrintStream out;
private BufferedReader in;
/*
- * Couch runs in a seperate thread, have the communication run
+ * Couchbase runs in a seperate thread, have the communication run
* through our own handler so the app doesnt need to create a new
* handler to deal with touching the UI from a different thread
*/
@@ -68,19 +70,19 @@ public void handleMessage(Message msg) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String stacktrace = sw.toString();
- if (client != null) {
- client.exit(stacktrace);
+ if (couchbaseDelegate != null) {
+ couchbaseDelegate.exit(stacktrace);
}
break;
case PROGRESS:
- client.installing(msg.arg1, msg.arg2);
+ couchbaseDelegate.installing(msg.arg1, msg.arg2);
break;
case COMPLETE:
- startCouch();
+ startCouchbaseService();
break;
- case COUCH_STARTED:
+ case COUCHBASE_STARTED:
URL url = (URL) msg.obj;
- client.couchStarted(url.getHost(), url.getPort());
+ couchbaseDelegate.couchbaseStarted(url.getHost(), url.getPort());
break;
}
} catch (RemoteException e) {
@@ -94,10 +96,10 @@ public void handleMessage(Message msg) {
*/
@Override
public void onDestroy() {
- if (couchStarted) {
+ if (couchbaseStarted) {
stop();
}
- client = null;
+ couchbaseDelegate = null;
}
/*
@@ -105,24 +107,24 @@ public void onDestroy() {
*/
@Override
public IBinder onBind(Intent intent) {
- return new CouchServiceImpl();
+ return new CouchbaseServiceImpl();
}
/*
- * implements the callbacks that clients can call into the couchdb service
+ * implements the callbacks that clients can call into the couchbase service
*/
- public class CouchServiceImpl extends ICouchService.Stub {
+ public class CouchbaseServiceImpl extends ICouchbaseService.Stub {
@Override
- public void startCouchbase(ICouchClient cb, final String pkg) throws RemoteException {
- client = cb;
- if (!CouchInstaller.checkInstalled(pkg)) {
- installCouch(pkg);
+ public void startCouchbase(ICouchbaseDelegate cb, final String pkg) throws RemoteException {
+ couchbaseDelegate = cb;
+ if (!CouchbaseInstaller.checkInstalled(pkg)) {
+ installCouchbase(pkg);
} else {
- if (couchStarted == true) {
- couchStarted();
+ if (couchbaseStarted == true) {
+ couchbaseStarted();
} else {
- startCouch();
+ startCouchbaseService();
}
}
}
@@ -135,21 +137,21 @@ public void stopCouchbase() throws RemoteException {
}
};
- /* once couch has started we need to notify the waiting client */
- void couchStarted() throws RemoteException {
- client.couchStarted(url.getHost(), url.getPort());
+ /* once couchbase has started we need to notify the waiting client */
+ void couchbaseStarted() throws RemoteException {
+ couchbaseDelegate.couchbaseStarted(url.getHost(), url.getPort());
}
- /* Install Couch in a seperate thread */
- private void installCouch(final String pkg) {
- final CouchService service = this;
+ /* Install Couchbase in a seperate thread */
+ private void installCouchbase(final String pkg) {
+ final CouchbaseService service = this;
new Thread() {
@Override
public void run() {
try {
- CouchInstaller.doInstall(pkg, mHandler, service);
+ CouchbaseInstaller.doInstall(pkg, mHandler, service);
} catch (FileNotFoundException e) {
- Message.obtain(mHandler, CouchService.ERROR, e).sendToTarget();
+ Message.obtain(mHandler, CouchbaseService.ERROR, e).sendToTarget();
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
@@ -158,8 +160,8 @@ public void run() {
}.start();
}
- /* Start the couch process, run in a seperate thread */
- void startCouch() {
+ /* Start the couchbase process, run in a seperate thread */
+ void startCouchbaseService() {
String path = CouchbaseMobile.dataPath();
@@ -196,15 +198,15 @@ public void run() {
String line = in.readLine();
Log.v(CouchbaseMobile.TAG, line);
if (line.contains("has started on")) {
- couchStarted = true;
+ couchbaseStarted = true;
url = new URL(matchURLs(line).get(0));
- Message.obtain(mHandler, CouchService.COUCH_STARTED, url)
+ Message.obtain(mHandler, CouchbaseService.COUCHBASE_STARTED, url)
.sendToTarget();
}
}
} catch (Exception e) {
- Log.v(CouchbaseMobile.TAG, "CouchDB has stopped unexpectedly");
- Message.obtain(mHandler, CouchService.ERROR, e).sendToTarget();
+ Log.v(CouchbaseMobile.TAG, "Couchbase has stopped unexpectedly");
+ Message.obtain(mHandler, CouchbaseService.ERROR, e).sendToTarget();
}
}
}).start();
@@ -219,7 +221,7 @@ private void stop() {
} catch (IOException e) {
e.printStackTrace();
}
- couchStarted = false;
+ couchbaseStarted = false;
}
private ArrayList<String> matchURLs(String text) {
View
12 src/com/couchbase/android/ICouchbaseDelegate.aidl
@@ -0,0 +1,12 @@
+package com.couchbase.android;
+
+interface ICouchbaseDelegate
+{
+ /* Callback to notify when Couchbase has started */
+ void couchbaseStarted(String host, int port);
+
+ /* Callback for notifications on how the Couchbase install is progressing */
+ void installing(int completed, int total);
+
+ void exit(String error);
+}
View
13 src/com/couchbase/android/ICouchbaseService.aidl
@@ -0,0 +1,13 @@
+package com.couchbase.android;
+
+import com.couchbase.android.ICouchbaseDelegate;
+
+interface ICouchbaseService
+{
+ /* Starts couchbase, calls "couchbaseStarted" callback when
+ * complete
+ */
+ void startCouchbase(ICouchbaseDelegate callback, String pkg);
+
+ void stopCouchbase();
+}
View
12 src/com/couchbase/libcouch/ICouchClient.aidl
@@ -1,12 +0,0 @@
-package com.couchbase.libcouch;
-
-interface ICouchClient
-{
- /* Callback to notify when CouchDB has started */
- void couchStarted(String host, int port);
-
- /* Callback for notifications on how the CouchDB install is progressing */
- void installing(int completed, int total);
-
- void exit(String error);
-}
View
13 src/com/couchbase/libcouch/ICouchService.aidl
@@ -1,13 +0,0 @@
-package com.couchbase.libcouch;
-
-import com.couchbase.libcouch.ICouchClient;
-
-interface ICouchService
-{
- /* Starts couchDB, calls "couchStarted" callback when
- * complete
- */
- void startCouchbase(ICouchClient callback, String pkg);
-
- void stopCouchbase();
-}
Please sign in to comment.
Something went wrong with that request. Please try again.