Permalink
Browse files

initial import into new repo to remove bulky binary artifacts. see pr…

  • Loading branch information...
0 parents commit 4004cb5ccf48eb9e10b454630eea87f91251602a @jchris jchris committed Mar 10, 2011
Showing 966 changed files with 20,869 additions and 0 deletions.
@@ -0,0 +1,6 @@
+.DS_Store
+*.swp
+*.pbxuser
+*.perspectivev3
+*.mode1v3
+build
@@ -0,0 +1,9 @@
+[submodule "Demo/Vendor/TouchJSON"]
+ path = Demo/Vendor/TouchJSON
+ url = https://github.com/TouchCode/TouchJSON.git
+[submodule "Demo/Vendor/TouchFoundation"]
+ path = Demo/Vendor/TouchFoundation
+ url = https://github.com/TouchCode/TouchFoundation.git
+[submodule "Demo/Vendor/trundle"]
+ path = Demo/Vendor/trundle
+ url = https://github.com/schwa/trundle.git
@@ -0,0 +1,43 @@
+//
+// DatabaseManager.h
+// Couchbase Mobile
+//
+// Created by Jan Lehnardt on 27/11/2010.
+// Copyright 2011 Couchbase, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Foundation/Foundation.h>
+#import "CCouchDBDocument.h"
+
+typedef void (^DatabaseManagerSuccessHandler)();
+typedef void (^DatabaseManagerErrorHandler)(id error);
+
+@class CCouchDBServer;
+@class CCouchDBDatabase;
+
+@interface DatabaseManager : NSObject {
+ CCouchDBServer *server;
+ CCouchDBDatabase *database;
+ NSMutableDictionary *connections;
+ id delegate;
+}
+
+@property(readonly)CCouchDBDatabase *database;
+@property(assign) id delegate;
+@property(assign) NSMutableDictionary *connections;
++(DatabaseManager *)sharedManager;
+-(void)syncFrom:(NSString *)from to:(NSString *)to onSuccess:(DatabaseManagerSuccessHandler)success onError:(DatabaseManagerErrorHandler) error;
+-(void)deleteDocument:(CCouchDBDocument *)inDocument;
+@end
@@ -0,0 +1,118 @@
+//
+// DocumentManager.m
+// Couchbase Mobile
+//
+// Created by Jan Lehnardt on 27/11/2010.
+// Copyright 2011 Couchbase, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import "DatabaseManager.h"
+#import "CCouchDBServer.h"
+#import "CCouchDBDatabase.h"
+#import "CURLOperation.h"
+
+#define DATABASE_NAME @"demo"
+
+static DatabaseManager *sharedManager;
+
+@implementation DatabaseManager
+
+@synthesize database;
+@synthesize delegate;
+@synthesize connections;
+
++(DatabaseManager *)sharedManager
+{
+ if(sharedManager == nil) {
+ sharedManager = [[DatabaseManager alloc] init];
+ }
+ return sharedManager;
+}
+
+-(id)init
+{
+ [super init];
+ server = [[CCouchDBServer alloc] init];
+ database = [[server databaseNamed:DATABASE_NAME] retain];
+ connections = [[NSMutableDictionary alloc] init];
+ return self;
+}
+
+
+-(void)doSyncFrom:(NSString *)from to:(NSString *)to onSuccess:(DatabaseManagerSuccessHandler)success onError:(DatabaseManagerErrorHandler) error
+{
+ NSURL *theUrl = [server.URL URLByAppendingPathComponent:@"_replicate"];
+ NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:theUrl];
+ theRequest.HTTPMethod = @"POST";
+ [theRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
+ NSString *body = [NSString stringWithFormat:@"{\"source\":\"%@\",\"target\":\"%@\"}", from, to];
+ [theRequest setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
+ NSDictionary *callbacks = [[NSDictionary dictionaryWithObjectsAndKeys:[success copy], @"success", [error copy], @"error", nil] retain];
+ NSURLConnection *connection = [[NSURLConnection connectionWithRequest:theRequest delegate:self] retain];
+ [connections setObject:callbacks forKey:[connection description]];
+}
+
+-(void)syncFrom:(NSString *)from to:(NSString *)to onSuccess:(DatabaseManagerSuccessHandler)success onError:(DatabaseManagerErrorHandler) error
+{
+ [self doSyncFrom:from to:to onSuccess:success onError:error];
+}
+
+- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
+{
+ NSLog(@"Sync Error: %@", error);
+ id callbacks = [connections objectForKey:[connection description]];
+ if(callbacks != nil) {
+ DatabaseManagerErrorHandler errorHandler = [callbacks valueForKey:@"error"];
+ if(errorHandler) {
+ errorHandler(error);
+ [errorHandler release];
+ }
+ }
+}
+
+-(void)connectionDidFinishLoading:(NSURLConnection *)connection
+{
+ id callbacks = [connections valueForKey:[connection description]];
+ if(callbacks != nil) {
+ DatabaseManagerSuccessHandler successHandler = [callbacks valueForKey:@"success"];
+ NSLog(@"got my success handler");
+ if(successHandler) {
+ successHandler();
+ [successHandler release];
+ }
+ }
+}
+
+-(void)deleteDocument:(CCouchDBDocument *)inDocument
+{
+ CouchDBSuccessHandler inSuccessHandler = ^(id inParameter) {
+ NSLog(@"Wooohooo! Deleted %@", inParameter);
+ };
+
+ CouchDBFailureHandler inFailureHandler = ^(NSError *error) {
+ NSLog(@"D'OH! No Delete %@", error);
+ };
+ CURLOperation *op = [self.database operationToDeleteDocument: inDocument
+ successHandler:inSuccessHandler
+ failureHandler:inFailureHandler];
+ [op start];
+}
+
+-(void)dealloc
+{
+ [server release];
+ [connections release];
+}
+@end
@@ -0,0 +1,34 @@
+//
+// DemoAppDelegate.h
+// Couchbase Mobile
+//
+// Created by Jan Lehnardt on 27/11/2010.
+// Copyright 2011 Couchbase, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+#import <UIKit/UIKit.h>
+#import "Couchbase.h"
+
+@interface DemoAppDelegate : NSObject <UIApplicationDelegate, CouchbaseDelegate> {
+
+ UIWindow *window;
+
+ UINavigationController *navigationController;
+}
+
+@property (nonatomic, retain) IBOutlet UIWindow *window;
+@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
+
+@end
+
@@ -0,0 +1,111 @@
+//
+// DemoAppDelegate.m
+// Couchbase Mobile
+//
+// Created by Jan Lehnardt on 27/11/2010.
+// Copyright 2011 Couchbase, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import "DemoAppDelegate.h"
+#import "RootViewController.h"
+
+
+@implementation DemoAppDelegate
+
+@synthesize window;
+@synthesize navigationController;
+
+-(void)couchbaseDidStart
+{
+ NSLog(@"CouchDB is Ready, go!");
+ // Tell RootViewController to stop spinning
+ [self.navigationController.visibleViewController couchbaseDidStart];
+}
+
+#pragma mark -
+#pragma mark Application lifecycle
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+
+ [Couchbase startCouchbase:self];
+
+ // Override point for customization after application launch.
+ // Add the navigation controller's view to the window and display.
+
+ [window addSubview:navigationController.view];
+ [window makeKeyAndVisible];
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application {
+ /*
+ Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+ */
+}
+
+
+- (void)applicationDidEnterBackground:(UIApplication *)application {
+ // CouchDB seems to get stuck when in background. exit() so we get relaunched freshly
+
+ exit(1);
+ /*
+ Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
+ */
+}
+
+
+- (void)applicationWillEnterForeground:(UIApplication *)application {
+ /*
+ Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
+ */
+}
+
+
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+ /*
+ Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+ */
+}
+
+
+- (void)applicationWillTerminate:(UIApplication *)application {
+ /*
+ Called when the application is about to terminate.
+ See also applicationDidEnterBackground:.
+ */
+}
+
+
+#pragma mark -
+#pragma mark Memory management
+
+- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
+ /*
+ Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
+ */
+}
+
+
+- (void)dealloc {
+ [navigationController release];
+ [window release];
+ [super dealloc];
+}
+
+
+@end
+
@@ -0,0 +1,31 @@
+//
+// NewItemViewController.h
+// Couchbase Mobile
+//
+// Created by Jan Lehnardt on 27/11/2010.
+// Copyright 2011 Couchbase, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface NewItemViewController : UIViewController {
+ UITextView *textView;
+ id delegate;
+}
+
+@property(nonatomic,retain)IBOutlet UITextView *textView;
+@property(assign) id delegate;
+@end
Oops, something went wrong.

0 comments on commit 4004cb5

Please sign in to comment.