Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Classes/DropboxAPIKeys.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// DropboxAPIKeys.h
// MyKeePass
//
// Created by Jose Ramon Roca on 08/05/11.
// Copyright 2011 -. All rights reserved.
//

#define DROPBOX_CONSUMER_KEY "<YOUR CONSUMER KEY>"
#define DROPBOX_CONSUMER_SECRET "<YOUR CONSUMER SECRET>"
31 changes: 22 additions & 9 deletions Classes/MyKeePassAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,38 @@
// MyKeePassAppDelegate.h
// MyKeePass
//
// Created by Qiang Yu on 12/4/09.
// Copyright __MyCompanyName__ 2009. All rights reserved.
// Created by Qiang Yu on 3/3/10.
// Copyright Qiang Yu 2010. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MainViewController.h"
#import "DatabaseWrapper.h"
#import "KdbViewController.h"
#import "PasswordViewController.h"
#import "FileManager.h"

@interface MyKeePassAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
MainViewController * _mainViewController;
DatabaseWrapper * _databaseWrapper;
FileManager * _fileManager;

MainViewController * _mainView;
KdbViewController * _kdbView;

UIViewController * _currentViewController;

UIWindow *window;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet MainViewController * _mainViewController;
@property(nonatomic, retain) DatabaseWrapper * _databaseWrapper;
@property (nonatomic, readonly) FileManager * _fileManager;
@property (nonatomic, retain) MainViewController * _mainView;
@property (nonatomic, retain) KdbViewController * _kdbView;
@property (nonatomic, retain) UIViewController * _currentViewController;

-(void)switchViews;
+(MyKeePassAppDelegate *)delegate;
+(UIWindow *)getWindow;

-(void)showKdb;
-(void)showMainView;
-(BOOL)isEditable;
@end

114 changes: 83 additions & 31 deletions Classes/MyKeePassAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,115 @@
// MyKeePassAppDelegate.m
// MyKeePass
//
// Created by Qiang Yu on 12/4/09.
// Copyright __MyCompanyName__ 2009. All rights reserved.
// Created by Qiang Yu on 3/3/10.
// Copyright Qiang Yu 2010. All rights reserved.
//

#import <QuartzCore/QuartzCore.h>
#import "MyKeePassAppDelegate.h"
#import "DropboxSDK.h"
#import "DropboxAPIKeys.h"

@implementation MyKeePassAppDelegate

@synthesize window;
@synthesize _mainViewController;
@synthesize _databaseWrapper;

-(id)init{
if(self==[super init]){
self._databaseWrapper = [[DatabaseWrapper alloc]init];
}
return self;
}
@synthesize _fileManager;
@synthesize _kdbView;
@synthesize _mainView;
@synthesize _currentViewController;

- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:_mainViewController.view];
// Override point for customization after application launch
DBSession* dbSession = [[[DBSession alloc]
initWithConsumerKey:@DROPBOX_CONSUMER_KEY
consumerSecret:@DROPBOX_CONSUMER_SECRET]
autorelease];
[DBSession setSharedSession:dbSession];

//initialize the file manager
_fileManager = [[FileManager alloc]init];

//initialize the main view
_mainView = [[MainViewController alloc]init];

self._currentViewController = _mainView;

[window addSubview:_mainView.view];
[window makeKeyAndVisible];
}


- (void)dealloc {
[_mainView release];
[_kdbView release];
[window release];
[_mainViewController release];
[_databaseWrapper release];
[_fileManager release];
[_currentViewController release];
[super dealloc];
}


-(void)switchViews{
[_mainViewController switchViews];
-(void)showKdb{
if(![_currentViewController isKindOfClass:[KdbViewController class]]){
[_currentViewController.view removeFromSuperview];
id<KdbReader> kdbReader = _fileManager._kdbReader;

if(!_kdbView){
_kdbView = [[KdbViewController alloc]initWithGroup:[[kdbReader getKdbTree] getRoot]];
}

self._currentViewController = _kdbView;

[window addSubview:_currentViewController.view];

CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionFade];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[window layer] addAnimation:animation forKey:@"SwitchToKdbView"];
}
}

- (void)applicationWillResignActive:(UIApplication *)application{
//clean views e.g. dismiss modal views such as TableTextFieldEditViewController
[_mainViewController cleanViews];
[_databaseWrapper saveDatabase];
_databaseWrapper._database = nil;
-(void)showMainView{
if(![_currentViewController isKindOfClass:[MainViewController class]]){
[_currentViewController.view removeFromSuperview];
_fileManager._kdbReader = nil;
self._kdbView = nil;

if(!_mainView)
_mainView = [[MainViewController alloc]init];

self._currentViewController = _mainView;

[window addSubview:_currentViewController.view];

CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionFade];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[window layer] addAnimation:animation forKey:@"SwitchToMainView"];
}
}

- (void)applicationDidBecomeActive:(UIApplication *)application{
///
//switch the view to fileview whenever the application becomes active
///
if(!_mainViewController._fileViewController.view.superview){
[self switchViews];
if([_currentViewController isKindOfClass:[KdbViewController class]]){
[_currentViewController.view removeFromSuperview];

PasswordViewController * lockWindow = [[PasswordViewController alloc] initWithFileName:_fileManager._filename remote:NO];
lockWindow._isReopen = YES;

self._currentViewController = lockWindow;
[window addSubview:lockWindow.view];
[lockWindow release];
}
}

- (void)applicationWillTerminate:(UIApplication *)application{
[_databaseWrapper saveDatabase];
-(BOOL)isEditable{
return _fileManager._editable;
}

+(MyKeePassAppDelegate *)delegate{
return (MyKeePassAppDelegate *)[[UIApplication sharedApplication] delegate];
}

+(UIWindow *)getWindow{
return ((MyKeePassAppDelegate *)[[UIApplication sharedApplication] delegate]).window;
}
@end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions Classes/ThirdParty/DropboxSDK/DBAccountInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// DBAccountInfo.h
// DropboxSDK
//
// Created by Brian Smith on 5/3/10.
// Copyright 2010 Dropbox, Inc. All rights reserved.
//


#import "DBQuota.h"

@interface DBAccountInfo : NSObject <NSCoding> {
NSString* country;
NSString* displayName;
DBQuota* quota;
NSString* userId;
NSString* referralLink;
}

- (id)initWithDictionary:(NSDictionary*)dict;

@property (nonatomic, readonly) NSString* country;
@property (nonatomic, readonly) NSString* displayName;
@property (nonatomic, readonly) DBQuota* quota;
@property (nonatomic, readonly) NSString* userId;
@property (nonatomic, readonly) NSString* referralLink;

@end
61 changes: 61 additions & 0 deletions Classes/ThirdParty/DropboxSDK/DBAccountInfo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// DBAccountInfo.m
// DropboxSDK
//
// Created by Brian Smith on 5/3/10.
// Copyright 2010 Dropbox, Inc. All rights reserved.
//

#import "DBAccountInfo.h"


@implementation DBAccountInfo

- (id)initWithDictionary:(NSDictionary*)dict {
if ((self = [super init])) {
country = [[dict objectForKey:@"country"] retain];
displayName = [[dict objectForKey:@"display_name"] retain];
quota = [[DBQuota alloc] initWithDictionary:[dict objectForKey:@"quota_info"]];
userId = [[[dict objectForKey:@"uid"] stringValue] retain];
referralLink = [[dict objectForKey:@"referral_link"] retain];
}
return self;
}

- (void)dealloc {
[country release];
[displayName release];
[quota release];
[userId release];
[referralLink release];
[super dealloc];
}

@synthesize country;
@synthesize displayName;
@synthesize quota;
@synthesize userId;
@synthesize referralLink;


#pragma mark NSCoding methods

- (void)encodeWithCoder:(NSCoder*)coder {
[coder encodeObject:country forKey:@"country"];
[coder encodeObject:displayName forKey:@"displayName"];
[coder encodeObject:quota forKey:@"quota"];
[coder encodeObject:userId forKey:@"userId"];
[coder encodeObject:referralLink forKey:@"referralLink"];
}

- (id)initWithCoder:(NSCoder*)coder {
self = [super init];
country = [[coder decodeObjectForKey:@"country"] retain];
displayName = [[coder decodeObjectForKey:@"displayName"] retain];
quota = [[coder decodeObjectForKey:@"quota"] retain];
userId = [[coder decodeObjectForKey:@"userId"] retain];
referralLink = [[coder decodeObjectForKey:@"referralLink"] retain];
return self;
}

@end
36 changes: 36 additions & 0 deletions Classes/ThirdParty/DropboxSDK/DBCreateAccountController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// DBCreateAccountController.h
// DropboxSDK
//
// Created by Brian Smith on 5/20/10.
// Copyright 2010 Dropbox, Inc. All rights reserved.
//


@class DBLoadingView;
@class DBLoginController;
@class DBRestClient;

@interface DBCreateAccountController : UIViewController {
BOOL hasCreatedAccount;
DBLoginController* loginController;
DBRestClient* restClient;

UITableView* tableView;
UIView* headerView;
UITableViewCell* firstNameCell;
UITextField* firstNameField;
UITableViewCell* lastNameCell;
UITextField* lastNameField;
UITableViewCell* emailCell;
UITextField* emailField;
UITableViewCell* passwordCell;
UITextField* passwordField;
UIView* footerView;
UIActivityIndicatorView* activityIndicator;
DBLoadingView* loadingView;
}

@property (nonatomic, assign) DBLoginController* loginController;

@end
Loading