Skip to content

Commit

Permalink
Merge branch 'release/1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
pegli committed Aug 26, 2014
2 parents e3c750e + 495dde0 commit 1d22624
Show file tree
Hide file tree
Showing 171 changed files with 2,314 additions and 117 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ tmp
bin
build
*.zip
.DS_Store
.metadata
.*
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "mobile/ios/vendor/couchbase-lite-ios"]
path = mobile/ios/vendor/couchbase-lite-ios
url = https://github.com/couchbase/couchbase-lite-ios.git
branch = release/1.0.0
branch = release/1.0.2
2 changes: 2 additions & 0 deletions mobile/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ build
build.properties
dist
libs
example
documentation
1 change: 0 additions & 1 deletion mobile/android/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<import file="${titanium.platform}/../module/android/build.xml"/>

<target name="pre.dist">
<symlink link="." resource="../noarch/example" failonerror="no"/>
<symlink link="." resource="../noarch/documentation" failonerror="no"/>
</target>
</project>
1 change: 0 additions & 1 deletion mobile/android/example

This file was deleted.

17 changes: 17 additions & 0 deletions mobile/android/lib/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Couchbase, Inc. Community Edition License Agreement

IMPORTANT-READ CAREFULLY: BY CLICKING THE “I ACCEPT” BOX OR INSTALLING, DOWNLOADING OR OTHERWISE USING THIS SOFTWARE AND ANY ASSOCIATED DOCUMENTATION, YOU, ON BEHALF OF YOURSELF OR AS AN AUTHORIZED REPRESENTATIVE ON BEHALF OF AN ENTITY (“LICENSEE”) AGREE TO ALL THE TERMS OF THIS COMMUNITY EDITION LICENSE AGREEMENT (THE “AGREEMENT”) REGARDING YOUR USE OF THE SOFTWARE. YOU REPRESENT AND WARRANT THAT YOU HAVE FULL LEGAL AUTHORITY TO BIND THE LICENSEE TO THIS AGREEMENT. IF YOU DO NOT AGREE WITH ALL OF THESE TERMS, DO NOT SELECT THE “I ACCEPT” BOX AND DO NOT INSTALL, DOWNLOAD OR OTHERWISE USE THE SOFTWARE. THE EFFECTIVE DATE OF THIS AGREEMENT IS THE DATE ON WHICH YOU CLICK “I ACCEPT” OR OTHERWISE INSTALL, DOWNLOAD OR USE THE SOFTWARE.

1. License Grant. Couchbase Inc. hereby grants Licensee, free of charge, the non-exclusive right to use, copy, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to Licensee including the following copyright notice in all copies or substantial portions of the Software:

Couchbase ®
http://www.couchbase.com
Copyright 2011 Couchbase, Inc.

As used in this Agreement, “Software” means the object code version of the applicable elastic data management server software provided by Couchbase, Inc.

2. Restrictions. Licensee will not: (a) reverse engineer, disassemble, or decompile the Software (except to the extent such restrictions are prohibited by law);

3. Support. Couchbase, Inc. will provide Licensee with access to, and use of, the Couchbase, Inc. support forum available at the following URL: http://forums.Couchbase.org. Couchbase, Inc. may, at its discretion, modify, suspend or terminate support at any time.

4. Warranty Disclaimer and Limitation of Liability. THE SOFTWARE IS PROVIDED “AS IS,” WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL COUCHBASE INC. OR THE AUTHORS OR COPYRIGHT HOLDERS IN THE SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES (INCLUDING, WITHOUT LIMITATION, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES) OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added mobile/android/lib/webserver-2-3.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion mobile/android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 1.0.1
version: 1.1.0
apiversion: 2
description: TouchDB for Titanium
author: Paul Mietz Egli
Expand Down
8 changes: 8 additions & 0 deletions mobile/android/src/com/obscure/titouchdb/AttachmentProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import android.util.Log;

import com.couchbase.lite.Attachment;
import com.couchbase.lite.BlobStore;
import com.couchbase.lite.BlobStoreWriter;
import com.couchbase.lite.CouchbaseLiteException;

@Kroll.proxy(parentModule = TitouchdbModule.class)
Expand Down Expand Up @@ -65,6 +67,12 @@ public TiBlob getContent() {
public String getContentType() {
return attachment.getContentType();
}

@Kroll.getProperty(name = "contentURL")
public String getContentURL() {
BlobStore store = new BlobStore(attachment.getDocument().getDatabase().getAttachmentStorePath());
return "file:/" + store.pathForKey(BlobStore.keyForBlob(getContent().getBytes()));
}

@Kroll.getProperty(name = "document")
public DocumentProxy getDocument() {
Expand Down
23 changes: 23 additions & 0 deletions mobile/android/src/com/obscure/titouchdb/AuthenticatorProxy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.obscure.titouchdb;

import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.annotations.Kroll;

import com.couchbase.lite.auth.Authenticator;

@Kroll.proxy(parentModule = TitouchdbModule.class)
public class AuthenticatorProxy extends KrollProxy {

private static final String LCAT = "AuthenticatorProxy";

private Authenticator authenticator;

public AuthenticatorProxy(Authenticator authenticator) {
this.authenticator = authenticator;
}

public Authenticator getAuthenticator() {
return authenticator;
}

}
6 changes: 6 additions & 0 deletions mobile/android/src/com/obscure/titouchdb/DatabaseProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ public ReplicationProxy createPushReplication(String url) {
return result;
}

@Kroll.method
public QueryProxy createSlowQuery(KrollFunction map) {
lastError = null;
return new QueryProxy(this, database.slowQuery(new KrollMapper(map)));
}

@Kroll.method
public boolean deleteDatabase() {
lastError = null;
Expand Down
33 changes: 23 additions & 10 deletions mobile/android/src/com/obscure/titouchdb/ReplicationProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class ReplicationProxy extends KrollProxy implements ChangeListener {

private static final String LCAT = "ReplicationProxy";

private AuthenticatorProxy authenticatorProxy;

private DatabaseProxy databaseProxy;

private KrollDict lastError = null;
Expand All @@ -36,6 +38,20 @@ public ReplicationProxy(DatabaseProxy databaseProxy, Replication replicator) {
replicator.addChangeListener(this);
}

@Override
public void changed(ChangeEvent e) {
KrollDict params = new KrollDict();
params.put("source", this);
params.put("status", replicator.getStatus().ordinal());

fireEvent("change", params);
}

@Kroll.getProperty(name="authenticator")
public AuthenticatorProxy getAuthenticator() {
return authenticatorProxy;
}

@Kroll.getProperty(name = "changesCount")
public int getChangesCount() {
return replicator.getChangesCount();
Expand Down Expand Up @@ -113,6 +129,12 @@ public void restart() {
replicator.restart();
}

@Kroll.setProperty(name="authenticator")
public void setAuthenticator(AuthenticatorProxy authenticatorProxy) {
this.authenticatorProxy = authenticatorProxy;
replicator.setAuthenticator(authenticatorProxy != null ? authenticatorProxy.getAuthenticator() : null);
}

@Kroll.setProperty(name = "continuous")
public void setContinuous(boolean continuous) {
replicator.setContinuous(continuous);
Expand All @@ -124,7 +146,7 @@ public void setCreateTarget(boolean createTarget) {
}

@Kroll.method
public void setCredential(@Kroll.argument(optional=true) KrollDict credential) {
public void setCredential(@Kroll.argument(optional = true) KrollDict credential) {
if (credential == null) {
replicator.setAuthenticator(null);
}
Expand Down Expand Up @@ -167,13 +189,4 @@ public void stop() {
replicator.stop();
}

@Override
public void changed(ChangeEvent e) {
KrollDict params = new KrollDict();
params.put("source", this);
params.put("status", replicator.getStatus().ordinal());

fireEvent("status", params);
}

}
18 changes: 17 additions & 1 deletion mobile/android/src/com/obscure/titouchdb/TitouchdbModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.couchbase.lite.Query;
import com.couchbase.lite.SavedRevision;
import com.couchbase.lite.Status;
import com.couchbase.lite.auth.AuthenticatorFactory;

@Kroll.module(name = "Titouchdb", id = "com.obscure.titouchdb")
public class TitouchdbModule extends KrollModule {
Expand Down Expand Up @@ -116,11 +117,26 @@ public TitouchdbModule() {
Log.i(LCAT, this.toString() + " loaded");
}

@Kroll.method
public AuthenticatorProxy createBasicAuthenticator(String username, String password) {
return new AuthenticatorProxy(AuthenticatorFactory.createBasicAuthenticator(username, password));
}

@Kroll.method
public AuthenticatorProxy createFacebookAuthenticator(String token) {
return new AuthenticatorProxy(AuthenticatorFactory.createFacebookAuthenticator(token));
}

@Kroll.method
public AuthenticatorProxy createPersonaAuthenticator(String assertion, @Kroll.argument(optional=true) String email) {
return new AuthenticatorProxy(AuthenticatorFactory.createPersonaAuthenticator(assertion, email));
}

@Kroll.getProperty(name = "databaseManager")
public DatabaseManagerProxy getDatabaseManager() {
return this.databaseManagerProxy;
}

@Override
protected void initActivity(Activity activity) {
super.initActivity(activity);
Expand Down
2 changes: 2 additions & 0 deletions mobile/ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ bin
build
*.zip
example
documentation
.*
30 changes: 29 additions & 1 deletion mobile/ios/Classes/ComObscureTitouchdbModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#import "TiUtils.h"
#import "TiProxy+Errors.h"
#import "TDDatabaseManagerProxy.h"
#import "TDAuthenticatorProxy.h"

extern BOOL EnableLog(BOOL enable);

Expand All @@ -39,7 +40,7 @@ -(NSString*)moduleId {
-(void)startup {
[super startup];

EnableLog(YES);
[CBLManager enableLogging:nil];

NSLog(@"[INFO] %@ loaded", self);

Expand Down Expand Up @@ -122,6 +123,33 @@ - (id)stopListener:(id)args {
[self.listener stop];
}

#pragma mark -
#pragma mark CBLAuthenticator

- (id)createBasicAuthenticator:(id)args {
NSString * user;
NSString * pass;
ENSURE_ARG_AT_INDEX(user, args, 0, NSString)
ENSURE_ARG_AT_INDEX(pass, args, 1, NSString)

return [TDAuthenticatorProxy proxyWithAuthenticator:[CBLAuthenticator basicAuthenticatorWithName:user password:pass]];
}

- (id)createFacebookAuthenticator:(id)args {
NSString * token;
ENSURE_ARG_AT_INDEX(token, args, 0, NSString)

return [TDAuthenticatorProxy proxyWithAuthenticator:[CBLAuthenticator facebookAuthenticatorWithToken:token]];
}

- (id)createPersonaAuthenticator:(id)args {
NSString * assertion;
ENSURE_ARG_AT_INDEX(assertion, args, 0, NSString)

return [TDAuthenticatorProxy proxyWithAuthenticator:[CBLAuthenticator personaAuthenticatorWithAssertion:assertion]];
}


#pragma mark -
#pragma mark Constants

Expand Down
15 changes: 15 additions & 0 deletions mobile/ios/Classes/TDAuthenticatorProxy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// TDAuthenticatorProxy.h
// titouchdb
//
// Created by Paul Mietz Egli on 7/14/14.
//
//

#import "TiProxy.h"
#import "CBLAuthenticator.h"

@interface TDAuthenticatorProxy : TiProxy
@property (nonatomic, strong) id<CBLAuthenticator> authenticator;
+ (instancetype)proxyWithAuthenticator:(id<CBLAuthenticator>)authenticator;
@end
24 changes: 24 additions & 0 deletions mobile/ios/Classes/TDAuthenticatorProxy.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// TDAuthenticatorProxy.m
// titouchdb
//
// Created by Paul Mietz Egli on 7/14/14.
//
//

#import "TDAuthenticatorProxy.h"

@implementation TDAuthenticatorProxy

+ (instancetype)proxyWithAuthenticator:(id)authenticator {
return [[TDAuthenticatorProxy alloc] initWithAuthenticator:authenticator];
}

- (id)initWithAuthenticator:(id<CBLAuthenticator>)authenticator {
if (self = [super init]) {
self.authenticator = authenticator;
}
return self;
}

@end
9 changes: 9 additions & 0 deletions mobile/ios/Classes/TDDatabaseManagerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,13 @@ - (id)error {
return self.lastError ? [self errorDict:self.lastError] : nil;
}

/** specify whether the CouchbaseLite directory should be backed up or not */
- (void)setExcludedFromBackup:(id)value {
[self.databaseManager setExcludedFromBackup:[value boolValue]];
}

- (id)excludedFromBackup {
return NUMBOOL(self.databaseManager.excludedFromBackup);
}

@end
2 changes: 1 addition & 1 deletion mobile/ios/Classes/TDDatabaseProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ - (id)createAllDocumentsQuery:(id)args {
return [TDQueryProxy proxyWithDatabase:self query:query];
}

- (id)slowQueryWithMap:(id)args {
- (id)createSlowQuery:(id)args {
KrollCallback * callback;
ENSURE_ARG_AT_INDEX(callback, args, 0, KrollCallback);

Expand Down
15 changes: 15 additions & 0 deletions mobile/ios/Classes/TDQueryProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ - (id)initWithExecutionContext:(id<TiEvaluator>)context CBLQuery:(CBLQuery *)que
return self;
}

- (void)dealloc {
self.query = nil;
[super dealloc];
}

#pragma mark Properties

- (id)limit {
Expand Down Expand Up @@ -187,6 +192,11 @@ - (id)initWithQuery:(TDQueryProxy *) query queryEnumerator:(CBLQueryEnumerator *
return self;
}

- (void)dealloc {
self.enumerator = nil;
[super dealloc];
}

- (id)count {
return NUMLONG(self.enumerator.count);
}
Expand Down Expand Up @@ -238,6 +248,11 @@ - (id)initWithQueryEnumerator:(TDQueryEnumeratorProxy *)enumerator queryRow:(CBL
return self;
}

- (void)dealloc {
self.row = nil;
[super dealloc];
}

- (id)database {
return self.queryEnumerator.query.database;
}
Expand Down
Loading

0 comments on commit 1d22624

Please sign in to comment.