Skip to content

Commit

Permalink
Fixing the repository and moving keys to separate class
Browse files Browse the repository at this point in the history
  • Loading branch information
mronkko committed Dec 23, 2012
1 parent 10203fe commit d00c992
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 112 deletions.
2 changes: 1 addition & 1 deletion ZotPad beta-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.2.2434</string>
<string>1.2.2436</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSRequiresIPhoneOS</key>
Expand Down
2 changes: 2 additions & 0 deletions ZotPad.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2668,6 +2668,7 @@
A7F5ABE516450223005DC63C /* ZPTagOwner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZPTagOwner.h; sourceTree = "<group>"; };
A7F6225B1686F3550038E27B /* Beta-release-notes.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = "Beta-release-notes.txt"; sourceTree = "<group>"; };
A7F6225C1686F3550038E27B /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
A7F6225D16871AC80038E27B /* configure.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = configure.sh; sourceTree = "<group>"; };
A7FC2ECB15AE12B400CF4A5B /* link_zotero_mac_unix.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = link_zotero_mac_unix.sh; sourceTree = "<group>"; };
A7FC2ECE15AE1AEE00CF4A5B /* link_zotero_windows.vbs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = link_zotero_windows.vbs; sourceTree = "<group>"; };
A7FC2ED115AE1B1A00CF4A5B /* Dropbox_instructions.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Dropbox_instructions.txt; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3469,6 +3470,7 @@
A7200DC514718DBF004347C9 = {
isa = PBXGroup;
children = (
A7F6225D16871AC80038E27B /* configure.sh */,
A7F6225B1686F3550038E27B /* Beta-release-notes.txt */,
A7F6225C1686F3550038E27B /* README.md */,
A7200DDA14718DC0004347C9 /* ZotPad */,
Expand Down
31 changes: 10 additions & 21 deletions ZotPad/ZPAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import "ZPFileChannel_Dropbox.h"
#import "ZPAuthenticationDialog.h"
#import "TestFlight.h"
#import "ZPSecrets.h"

//Setting up the logger
#import "DDTTYLogger.h"
Expand Down Expand Up @@ -82,18 +83,20 @@ - (BOOL)application:(UIApplication *)application
self.fileLogger.rollingFrequency = 60 * 60 *24; // 24 hour rolling
self.fileLogger.logFileManager.maximumNumberOfLogFiles = 7; // one week of logs


#ifdef ZPDEBUG


//We know that this is deprecated, so suppress warnings
if(TESTFLIGHT_KEY != nil){
//We know that this is deprecated, so suppress warnings
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[TestFlight setDeviceIdentifier:[[UIDevice currentDevice] uniqueIdentifier]];
[TestFlight setDeviceIdentifier:[[UIDevice currentDevice] uniqueIdentifier]];
#pragma clang diagnostic pop


[TestFlight takeOff:@"5e753f234f33fc2bddf4437600037fbf_NjcyMjEyMDEyLTA0LTA5IDE0OjUyOjU0LjE4MDQwMg"];


[TestFlight takeOff:@"5e753f234f33fc2bddf4437600037fbf_NjcyMjEyMDEyLTA0LTA5IDE0OjUyOjU0LjE4MDQwMg"];
}

//Perform a memory warning every 2 seconds
//[NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)2 target:[UIApplication sharedApplication] selector:@selector(_performMemoryWarning) userInfo:NULL repeats:YES];

Expand All @@ -106,7 +109,7 @@ - (BOOL)application:(UIApplication *)application


#else
if([ZPPreferences reportErrors]) [TestFlight takeOff:@"5e753f234f33fc2bddf4437600037fbf_NjcyMjEyMDEyLTA0LTA5IDE0OjUyOjU0LjE4MDQwMg"];
if([ZPPreferences reportErrors] && TESTFLIGHT_KEY != nil) [TestFlight takeOff:@"5e753f234f33fc2bddf4437600037fbf_NjcyMjEyMDEyLTA0LTA5IDE0OjUyOjU0LjE4MDQwMg"];
self.fileLogger.logFormatter = [[ZPFileLogFormatter alloc] initWithLevel:LOG_LEVEL_INFO];

#endif
Expand All @@ -115,20 +118,6 @@ - (BOOL)application:(UIApplication *)application

DDLogVerbose(@"Verbose logging is enabled");

//Manual override for userID and Key. Useful for running the code in debugger with other people's credentials.

/*
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"" forKey:@"userID"];
[defaults setObject:@"" forKey:@"OAuthKey"];
*/
//Uncomment these to always reset the app after launch
/*
[ZPDatabase resetDatabase];
[[ZPCacheController instance] performSelectorInBackground:@selector(purgeAllAttachmentFilesFromCache) withObject:NULL];
*/



[ZPPreferences checkAndProcessApplicationResetPreferences];

Expand Down
1 change: 0 additions & 1 deletion ZotPad/ZPAttachmentFileInteractionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#import <MobileCoreServices/MobileCoreServices.h>
#import <QuartzCore/QuartzCore.h>
#import "ZPItemDetailViewController.h"
#import "ZPItemLookup.h"


@interface ZPAttachmentFileInteractionController(){
Expand Down
14 changes: 7 additions & 7 deletions ZotPad/ZPAuthenticationDialog.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@

#import "ZPCore.h"


#import "ZPAuthenticationDialog.h"

#import "OAToken.h"

#import "DSActivityView.h"
#import "ZPCacheController.h"

#import "ZPSecrets.h"

@implementation ZPAuthenticationDialog

Expand Down Expand Up @@ -145,9 +142,12 @@ -(void) processVerifier:(NSString*)verifier{
}

- (void) makeOAuthRequest:(OAToken *) token {
//TODO: move these to secrets
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:@"4cb573ead72e5d84eab4"
secret:@"605a2a699d22dc4cce7f"];

//Check that the keys are installed and crash if not
if(ZOTERO_KEY == nil || ZOTERO_SECRET == nil) [NSException raise:@"Missing credentials exception" format:@"Authentication key or secret for Zotero is missing. Please see the file ZotPad/Secrets.h for details"];

OAConsumer *consumer = [[OAConsumer alloc] initWithKey:ZOTERO_KEY
secret:ZOTERO_SECRET];

NSURL *url;

Expand Down
36 changes: 13 additions & 23 deletions ZotPad/ZPFileChannel_DropBox.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,18 @@
#import "DBSession+iOS.h"

#import "ZPLocalization.h"
#import "ZPSecrets.h"



//Zipping and base64 encoding
#import "ZipArchive.h"


// https://www.dropbox.com/account#applications


const NSInteger ZPFILECHANNEL_DROPBOX_UPLOAD = 1;
const NSInteger ZPFILECHANNEL_DROPBOX_DOWNLOAD = 2;

#ifdef BETA

static NSString* const DROPBOX_KEY_FULL_ACCESS = @"w1nps3e4js2va7z";
static NSString* const DROPBOX_SECRET_FULL_ACCESS = @"vvk17pjqx0ngjs3";

static NSString* const DROPBOX_KEY = @"or7xa2bxhzit1ws";
static NSString* const DROPBOX_SECRET = @"6azju842azhs5oz";

#else

#import "ZPSecrets.h"

static const NSString* DROPBOX_KEY_FULL_ACCESS = @"6tpvh0msumv6plh";
static const NSString* DROPBOX_KEY = @"nn6res38igpo4ec";

#endif

@interface ZPDBSession : DBSession {
BOOL _ZPisLinking;
}
Expand Down Expand Up @@ -98,23 +80,31 @@ @implementation ZPFileChannel_Dropbox

+(void) linkDroboxIfNeeded{
if([ZPPreferences useDropbox]){

if([ZPDBSession sharedSession]==NULL){
DDLogInfo(@"Starting Dropbox");

if([ZPPreferences dropboxHasFullControl]){

if(DROPBOX_KEY_FULL_ACCESS == nil || DROPBOX_SECRET_FULL_ACCESS == nil) [NSException raise:@"Missing credentials exception" format:@"Authentication key or secret for Dropbox (full access) is missing. Please see the file ZotPad/Secrets.h for details"];


ZPDBSession* dbSession =
[[ZPDBSession alloc]
initWithAppKey:DROPBOX_KEY_FULL_ACCESS
appSecret:DROPBOX_SECRET_FULL_ACCESS
initWithAppKey:(NSString*)DROPBOX_KEY_FULL_ACCESS
appSecret:(NSString*)DROPBOX_SECRET_FULL_ACCESS
root:kDBRootDropbox];
[ZPDBSession setSharedSession:dbSession];

}
else{

if(DROPBOX_KEY == nil || DROPBOX_SECRET == nil) [NSException raise:@"Missing credentials exception" format:@"Authentication key or secret for Dropbox is missing. Please see the file ZotPad/Secrets.h for details"];

ZPDBSession* dbSession =
[[ZPDBSession alloc]
initWithAppKey:DROPBOX_KEY
appSecret:DROPBOX_SECRET
initWithAppKey:(NSString*)DROPBOX_KEY
appSecret:(NSString*)DROPBOX_SECRET
root:kDBRootAppFolder];
[ZPDBSession setSharedSession:dbSession];
}
Expand Down
86 changes: 42 additions & 44 deletions ZotPad/ZPLogViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#import "UserVoice.h"
#import "UVSession.h"
#import "UVClientConfig.h"
#import "ZPSecrets.h"

@interface ZPLogViewController (){
MFMailComposeViewController *mailController;
Expand Down Expand Up @@ -72,56 +73,53 @@ -(IBAction)showManual:(id)sender{
[self presentModalViewController:ql animated:YES];
}

#if 0

-(IBAction)knowledgeBase:(id)sender{
[[[UIAlertView alloc] initWithTitle:@"Not implemented"
message:@"Feedback and knowledge base are not available in beta builds."
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil]show];
}

#else

#import "ZPSecrets.h"

-(IBAction)contactSupport:(id)sender{
UVConfig *config = [UVConfig configWithSite:@"zotpad.uservoice.com"
andKey:USERVOICE_API_KEY
andSecret:USERVOICE_SECRET];

if(USERVOICE_API_KEY == nil || USERVOICE_SECRET == nil){
[[[UIAlertView alloc] initWithTitle:@"Not implemented"
message:@"Feedback and knowledge base are not available in this build because UserVoice key or secret is missing."
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil]show];

NSString* technicalInfo = [NSString stringWithFormat:@"\n\n --- Technical info ---\n\n%@ %@ (build %@)\n%@ (iOS %@)\nuserID: %@\nAPI key: %@\n\n --- Application log ----\n\n%@",
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"],
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"],
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"],
[[UIDevice currentDevice] model],
[[UIDevice currentDevice] systemVersion],
[ZPPreferences userID],
[ZPPreferences OAuthKey],
logView.text];

//Do we want to include a database dump
if([ZPPreferences includeDatabaseWithSupportRequest]){
//Read the database file and append it as base64 encoded string
technicalInfo = [technicalInfo stringByAppendingFormat:@"\n\n --- Database file ---\n\n%@",[ZPDatabase base64encodedDBfile]];
}
if([ZPPreferences includeFileListWithSupportRequest]){
technicalInfo = [technicalInfo stringByAppendingString:@"\n\n --- Files in documents folder ---\n\n"];
else{
UVConfig *config = [UVConfig configWithSite:@"zotpad.uservoice.com"
andKey:(NSString*)USERVOICE_API_KEY
andSecret:(NSString*)USERVOICE_SECRET];


NSString* documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:NULL];
technicalInfo = [technicalInfo stringByAppendingString:[directoryContent componentsJoinedByString:@"\n"]];
NSString* technicalInfo = [NSString stringWithFormat:@"\n\n --- Technical info ---\n\n%@ %@ (build %@)\n%@ (iOS %@)\nuserID: %@\nAPI key: %@\n\n --- Application log ----\n\n%@",
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"],
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"],
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"],
[[UIDevice currentDevice] model],
[[UIDevice currentDevice] systemVersion],
[ZPPreferences userID],
[ZPPreferences OAuthKey],
logView.text];

//Do we want to include a database dump
if([ZPPreferences includeDatabaseWithSupportRequest]){
//Read the database file and append it as base64 encoded string
technicalInfo = [technicalInfo stringByAppendingFormat:@"\n\n --- Database file ---\n\n%@",[ZPDatabase base64encodedDBfile]];
}
if([ZPPreferences includeFileListWithSupportRequest]){
technicalInfo = [technicalInfo stringByAppendingString:@"\n\n --- Files in documents folder ---\n\n"];

NSString* documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:NULL];
technicalInfo = [technicalInfo stringByAppendingString:[directoryContent componentsJoinedByString:@"\n"]];
}

//Do we want to include a file list


config.customFields = [NSDictionary dictionaryWithObject:technicalInfo
forKey:@"Technical Information"];

[UserVoice presentUserVoiceInterfaceForParentViewController:self andConfig:config];
}

//Do we want to include a file list


config.customFields = [NSDictionary dictionaryWithObject:technicalInfo
forKey:@"Technical Information"];

[UserVoice presentUserVoiceInterfaceForParentViewController:self andConfig:config];
}

#endif
Expand Down
25 changes: 11 additions & 14 deletions ZotPad/ZPSecrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// This file contains the secrets and keys that ZotPad uses to authenticate
// with third party web services. The public GitHub repository contains the
// secrets and keys used in the ZotPad beta app. If you want to
// Zotero secret and key used in the ZotPad beta app. If you want to
// compile a production version of the app, you need to obtain a separate key.
// (Or you can copy the beta key as the production key)
//
Expand All @@ -28,28 +28,25 @@ static const NSString* DROPBOX_SECRET = @"6azju842azhs5oz";
static const NSString* DROPBOX_KEY_FULL_ACCESS = @"w1nps3e4js2va7z";
static const NSString* DROPBOX_SECRET_FULL_ACCESS = @"vvk17pjqx0ngjs3";

static const NSString* USERVOICE_API_KEY = nil;
static const NSString* USERVOICE_SECRET = nil;
static const NSString* USERVOICE_API_KEY = @"7Dxx3D5IB1fvrc3X42KBTg";
static const NSString* USERVOICE_SECRET = @"hfThpmD59PwAtNf1aT9aK5RjrUZnvqg15aENZQxav8";

static const NSString* TESTFLIGHT_KEY = nil;
static const NSString* TESTFLIGHT_KEY = @"5e753f234f33fc2bddf4437600037fbf_NjcyMjEyMDEyLTA0LTA5IDE0OjUyOjU0LjE4MDQwMg";

#else

// Production keys

static const NSString* ZOTERO_KEY = nil;
static const NSString* ZOTERO_SECRET = nil;
static const NSString* ZOTERO_KEY = @"d990ba1fdc4bb901f45f";
static const NSString* ZOTERO_SECRET = @"df0f6917d08325d99dee";

static const NSString* DROPBOX_KEY = nil;
static const NSString* DROPBOX_SECRET = nil;
static const NSString* DROPBOX_KEY = @"nn6res38igpo4ec";
static const NSString* DROPBOX_SECRET = @"w2aehbumzcus6vk";

static const NSString* DROPBOX_KEY_FULL_ACCESS = nil;
static const NSString* DROPBOX_SECRET_FULL_ACCESS = nil;
static const NSString* DROPBOX_KEY_FULL_ACCESS = @"6tpvh0msumv6plh";
static const NSString* DROPBOX_SECRET_FULL_ACCESS = @"mueanvefj1wo1e2";

static const NSString* USERVOICE_API_KEY = nil;
static const NSString* USERVOICE_SECRET = nil;

static const NSString* TESTFLIGHT_KEY = nil;
static const NSString* TESTFLIGHT_KEY = @"5e753f234f33fc2bddf4437600037fbf_NjcyMjEyMDEyLTA0LTA5IDE0OjUyOjU0LjE4MDQwMg";

#endif

Expand Down
3 changes: 2 additions & 1 deletion configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
#

git submodule init
git submodule update


git submodule foreach git pull

0 comments on commit d00c992

Please sign in to comment.