appjam 0.1.8.9 → 0.1.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.pbxproj +114 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.xcworkspace/xcuserdata/eiffel.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/AppDelegate.m.tt +13 -1
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MyLauncher/CustomBadge.h +52 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MyLauncher/CustomBadge.m +241 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MyLauncher/MyLauncherItem.h +58 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MyLauncher/MyLauncherItem.m +227 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MyLauncher/MyLauncherPageControl.h +37 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MyLauncher/MyLauncherPageControl.m +117 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MyLauncher/MyLauncherScrollView.h +23 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MyLauncher/MyLauncherScrollView.m +42 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MyLauncher/MyLauncherView.h +70 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MyLauncher/MyLauncherView.m +830 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MyLauncher/MyLauncherViewController.h +38 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/components/MyLauncher/MyLauncherViewController.m +302 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/AESCrypt-ObjC/AESCrypt.h +37 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/AESCrypt-ObjC/AESCrypt.m +50 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/AESCrypt-ObjC/NSData+Base64.h +17 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/AESCrypt-ObjC/NSData+Base64.m +110 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/AESCrypt-ObjC/NSData+CommonCrypto.h +112 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/AESCrypt-ObjC/NSData+CommonCrypto.m +546 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/AESCrypt-ObjC/NSString+Base64.h +15 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/AESCrypt-ObjC/NSString+Base64.m +82 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/DCIntrospect/DCCrossHairView.h +16 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/DCIntrospect/DCCrossHairView.m +43 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/DCIntrospect/DCFrameView.h +55 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/DCIntrospect/DCFrameView.m +234 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/DCIntrospect/DCIntrospect.h +155 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/DCIntrospect/DCIntrospect.m +1654 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/DCIntrospect/DCIntrospectSettings.h +56 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/DCIntrospect/DCStatusBarOverlay.h +34 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/DCIntrospect/DCStatusBarOverlay.m +107 -0
- data/lib/appjam/version.rb +1 -1
- metadata +32 -3
@@ -0,0 +1,38 @@
|
|
1
|
+
//
|
2
|
+
// MyLauncherViewController.h
|
3
|
+
// @rigoneri
|
4
|
+
//
|
5
|
+
// Copyright 2010 Rodrigo Neri
|
6
|
+
// Copyright 2011 David Jarrett
|
7
|
+
//
|
8
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
// you may not use this file except in compliance with the License.
|
10
|
+
// You may obtain a copy of the License at
|
11
|
+
//
|
12
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
//
|
14
|
+
// Unless required by applicable law or agreed to in writing, software
|
15
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
// See the License for the specific language governing permissions and
|
18
|
+
// limitations under the License.
|
19
|
+
//
|
20
|
+
|
21
|
+
#import <UIKit/UIKit.h>
|
22
|
+
#import "MyLauncherView.h"
|
23
|
+
#import "MyLauncherItem.h"
|
24
|
+
|
25
|
+
@interface MyLauncherViewController : UIViewController <MyLauncherViewDelegate, UINavigationControllerDelegate> {
|
26
|
+
}
|
27
|
+
|
28
|
+
@property (nonatomic, strong) UINavigationController *launcherNavigationController;
|
29
|
+
@property (nonatomic, strong) MyLauncherView *launcherView;
|
30
|
+
@property (nonatomic, strong) NSMutableDictionary *appControllers;
|
31
|
+
|
32
|
+
-(BOOL)hasSavedLauncherItems;
|
33
|
+
-(void)clearSavedLauncherItems;
|
34
|
+
|
35
|
+
-(void)launcherViewItemSelected:(MyLauncherItem*)item;
|
36
|
+
-(void)closeView;
|
37
|
+
|
38
|
+
@end
|
@@ -0,0 +1,302 @@
|
|
1
|
+
//
|
2
|
+
// MyLauncherViewController.m
|
3
|
+
// @rigoneri
|
4
|
+
//
|
5
|
+
// Copyright 2010 Rodrigo Neri
|
6
|
+
// Copyright 2011 David Jarrett
|
7
|
+
//
|
8
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
// you may not use this file except in compliance with the License.
|
10
|
+
// You may obtain a copy of the License at
|
11
|
+
//
|
12
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
//
|
14
|
+
// Unless required by applicable law or agreed to in writing, software
|
15
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
// See the License for the specific language governing permissions and
|
18
|
+
// limitations under the License.
|
19
|
+
//
|
20
|
+
|
21
|
+
#import "MyLauncherViewController.h"
|
22
|
+
|
23
|
+
@interface MyLauncherViewController ()
|
24
|
+
-(NSMutableArray *)savedLauncherItems;
|
25
|
+
-(NSArray*)retrieveFromUserDefaults:(NSString *)key;
|
26
|
+
-(void)saveToUserDefaults:(id)object key:(NSString *)key;
|
27
|
+
@property (nonatomic, strong) UIView *overlayView;
|
28
|
+
@property (nonatomic, strong) UIViewController *currentViewController;
|
29
|
+
@property (nonatomic, assign) CGRect statusBarFrame;
|
30
|
+
@end
|
31
|
+
|
32
|
+
@implementation MyLauncherViewController
|
33
|
+
|
34
|
+
@synthesize launcherNavigationController = _launcherNavigationController;
|
35
|
+
@synthesize launcherView = _launcherView;
|
36
|
+
@synthesize appControllers = _appControllers;
|
37
|
+
@synthesize overlayView = _overlayView;
|
38
|
+
@synthesize currentViewController = _currentViewController;
|
39
|
+
@synthesize statusBarFrame = _statusBarFrame;
|
40
|
+
|
41
|
+
#pragma mark - ViewController lifecycle
|
42
|
+
|
43
|
+
-(id)init {
|
44
|
+
if((self = [super init])) {
|
45
|
+
self.title = @"myLauncher";
|
46
|
+
}
|
47
|
+
return self;
|
48
|
+
}
|
49
|
+
|
50
|
+
-(void)loadView {
|
51
|
+
[super loadView];
|
52
|
+
|
53
|
+
[self setLauncherView:[[MyLauncherView alloc] initWithFrame:self.view.bounds]];
|
54
|
+
[self.launcherView setBackgroundColor:COLOR(234,237,250)];
|
55
|
+
[self.launcherView setDelegate:self];
|
56
|
+
self.view = self.launcherView;
|
57
|
+
|
58
|
+
[self.launcherView setPages:[self savedLauncherItems]];
|
59
|
+
[self.launcherView setNumberOfImmovableItems:[(NSNumber *)[self retrieveFromUserDefaults:@"myLauncherViewImmovable"] intValue]];
|
60
|
+
|
61
|
+
[self setAppControllers:[[NSMutableDictionary alloc] init]];
|
62
|
+
[self setStatusBarFrame:[[UIApplication sharedApplication] statusBarFrame]];
|
63
|
+
}
|
64
|
+
|
65
|
+
- (void)viewDidAppear:(BOOL)animated {
|
66
|
+
[self.launcherView viewDidAppear:animated];
|
67
|
+
}
|
68
|
+
|
69
|
+
- (void)viewWillLayoutSubviews {
|
70
|
+
if (!CGRectEqualToRect(self.statusBarFrame, [[UIApplication sharedApplication] statusBarFrame])) {
|
71
|
+
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
|
72
|
+
if (self.launcherNavigationController) {
|
73
|
+
CGRect navConFrame = self.launcherNavigationController.view.bounds;
|
74
|
+
[UIView animateWithDuration:0.3 animations:^{
|
75
|
+
CGRect navBarFrame = self.launcherNavigationController.navigationBar.frame;
|
76
|
+
[self.launcherNavigationController.navigationBar setFrame:CGRectMake(navBarFrame.origin.x, statusBarFrame.size.height, navBarFrame.size.width, navBarFrame.size.height)];
|
77
|
+
[self.launcherNavigationController.view setFrame:CGRectMake(navConFrame.origin.x, navConFrame.origin.y, navConFrame.size.width, navConFrame.size.height)];
|
78
|
+
} completion:^(BOOL finished){
|
79
|
+
[self.launcherNavigationController.view setNeedsLayout];
|
80
|
+
}];
|
81
|
+
}
|
82
|
+
[self setStatusBarFrame:statusBarFrame];
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
|
87
|
+
return YES;
|
88
|
+
}
|
89
|
+
|
90
|
+
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
|
91
|
+
[self.launcherView setCurrentOrientation:toInterfaceOrientation];
|
92
|
+
if (self.launcherNavigationController) {
|
93
|
+
[self.launcherNavigationController setNavigationBarHidden:YES];
|
94
|
+
[self.launcherNavigationController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
|
99
|
+
if(self.launcherNavigationController) {
|
100
|
+
[self.launcherNavigationController setNavigationBarHidden:NO];
|
101
|
+
[self.launcherNavigationController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
|
102
|
+
}
|
103
|
+
|
104
|
+
self.overlayView.frame = self.launcherView.frame;
|
105
|
+
[self.launcherView layoutLauncher];
|
106
|
+
}
|
107
|
+
|
108
|
+
- (void)didReceiveMemoryWarning {
|
109
|
+
[super didReceiveMemoryWarning];
|
110
|
+
}
|
111
|
+
|
112
|
+
- (void)viewDidUnload {
|
113
|
+
[super viewDidUnload];
|
114
|
+
}
|
115
|
+
|
116
|
+
#pragma mark - MyLauncherItem management
|
117
|
+
|
118
|
+
-(BOOL)hasSavedLauncherItems {
|
119
|
+
return ([self retrieveFromUserDefaults:@"myLauncherView"] != nil);
|
120
|
+
}
|
121
|
+
|
122
|
+
-(void)launcherViewItemSelected:(MyLauncherItem*)item {
|
123
|
+
if (![self appControllers] || [self launcherNavigationController]) {
|
124
|
+
return;
|
125
|
+
}
|
126
|
+
Class viewCtrClass = [[self appControllers] objectForKey:[item controllerStr]];
|
127
|
+
UIViewController *controller = [[viewCtrClass alloc] init];
|
128
|
+
|
129
|
+
[self setLauncherNavigationController:[[UINavigationController alloc] initWithRootViewController:controller]];
|
130
|
+
[[self.launcherNavigationController topViewController] setTitle:item.controllerTitle];
|
131
|
+
[self.launcherNavigationController setDelegate:self];
|
132
|
+
|
133
|
+
if(self.view.frame.size.width == 480)
|
134
|
+
self.launcherNavigationController.view.frame = CGRectMake(0, 0, 480, 320);
|
135
|
+
if(self.view.frame.size.width == 1024)
|
136
|
+
self.launcherNavigationController.view.frame = CGRectMake(0, 0, 1024, 768);
|
137
|
+
|
138
|
+
[controller.navigationItem setLeftBarButtonItem:
|
139
|
+
[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"launcher"]
|
140
|
+
style:UIBarButtonItemStyleBordered
|
141
|
+
target:self
|
142
|
+
action:@selector(closeView)]];
|
143
|
+
|
144
|
+
UIView *viewToLaunch = [[self.launcherNavigationController topViewController] view];
|
145
|
+
|
146
|
+
[self.parentViewController.view addSubview:[self.launcherNavigationController view]];
|
147
|
+
viewToLaunch.alpha = 0;
|
148
|
+
viewToLaunch.transform = CGAffineTransformMakeScale(0.00001, 0.00001);
|
149
|
+
|
150
|
+
if (!self.overlayView)
|
151
|
+
{
|
152
|
+
[self setOverlayView:[[UIView alloc] initWithFrame:self.launcherView.bounds]];
|
153
|
+
self.overlayView.backgroundColor = [UIColor blackColor];
|
154
|
+
self.overlayView.alpha = 0;
|
155
|
+
self.overlayView.autoresizesSubviews = YES;
|
156
|
+
self.overlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
|
157
|
+
[self.view addSubview:self.overlayView];
|
158
|
+
}
|
159
|
+
|
160
|
+
self.launcherView.frame = self.overlayView.bounds;
|
161
|
+
self.launcherView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
162
|
+
|
163
|
+
[UIView animateWithDuration:0.3
|
164
|
+
delay:0
|
165
|
+
options:UIViewAnimationOptionCurveEaseIn
|
166
|
+
animations:^{
|
167
|
+
viewToLaunch.alpha = 1.0;
|
168
|
+
viewToLaunch.transform = CGAffineTransformIdentity;
|
169
|
+
self.overlayView.alpha = 0.7;
|
170
|
+
}
|
171
|
+
completion:nil];
|
172
|
+
}
|
173
|
+
|
174
|
+
-(void)launcherViewDidBeginEditing:(id)sender {
|
175
|
+
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc]
|
176
|
+
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
|
177
|
+
target:self.launcherView action:@selector(endEditing)] animated:YES];
|
178
|
+
}
|
179
|
+
|
180
|
+
-(void)launcherViewDidEndEditing:(id)sender {
|
181
|
+
[self.navigationItem setRightBarButtonItem:nil];
|
182
|
+
}
|
183
|
+
|
184
|
+
- (void)closeView {
|
185
|
+
UIView *viewToClose = [[self.launcherNavigationController topViewController] view];
|
186
|
+
if (!viewToClose)
|
187
|
+
return;
|
188
|
+
|
189
|
+
viewToClose.transform = CGAffineTransformIdentity;
|
190
|
+
|
191
|
+
[UIView animateWithDuration:0.3
|
192
|
+
delay:0
|
193
|
+
options:UIViewAnimationOptionCurveEaseOut
|
194
|
+
animations:^{
|
195
|
+
viewToClose.alpha = 0;
|
196
|
+
viewToClose.transform = CGAffineTransformMakeScale(0.00001, 0.00001);
|
197
|
+
self.overlayView.alpha = 0;
|
198
|
+
}
|
199
|
+
completion:^(BOOL finished){
|
200
|
+
if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
|
201
|
+
[[self.launcherNavigationController topViewController] viewWillDisappear:NO];
|
202
|
+
}
|
203
|
+
[[self.launcherNavigationController view] removeFromSuperview];
|
204
|
+
if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
|
205
|
+
[[self.launcherNavigationController topViewController] viewDidDisappear:NO];
|
206
|
+
}
|
207
|
+
[self.launcherNavigationController setDelegate:nil];
|
208
|
+
[self setLauncherNavigationController:nil];
|
209
|
+
[self setCurrentViewController:nil];
|
210
|
+
[self.parentViewController viewWillAppear:NO];
|
211
|
+
[self.parentViewController viewDidAppear:NO];
|
212
|
+
}];
|
213
|
+
}
|
214
|
+
|
215
|
+
#pragma mark - UINavigationControllerDelegate
|
216
|
+
|
217
|
+
-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
218
|
+
if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
|
219
|
+
if (self.currentViewController) {
|
220
|
+
[self.currentViewController viewWillDisappear:animated];
|
221
|
+
}
|
222
|
+
[viewController viewWillAppear:animated];
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
227
|
+
if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
|
228
|
+
if (self.currentViewController) {
|
229
|
+
[self.currentViewController viewDidDisappear:animated];
|
230
|
+
}
|
231
|
+
[viewController viewDidAppear:animated];
|
232
|
+
}
|
233
|
+
[self setCurrentViewController:viewController];
|
234
|
+
}
|
235
|
+
|
236
|
+
#pragma mark - myLauncher caching
|
237
|
+
|
238
|
+
-(NSMutableArray *)savedLauncherItems {
|
239
|
+
NSArray *savedPages = (NSArray *)[self retrieveFromUserDefaults:@"myLauncherView"];
|
240
|
+
|
241
|
+
if(savedPages)
|
242
|
+
{
|
243
|
+
NSMutableArray *savedLauncherItems = [[NSMutableArray alloc] init];
|
244
|
+
|
245
|
+
for (NSArray *page in savedPages)
|
246
|
+
{
|
247
|
+
NSMutableArray *savedPage = [[NSMutableArray alloc] init];
|
248
|
+
for(NSDictionary *item in page)
|
249
|
+
{
|
250
|
+
NSNumber *version;
|
251
|
+
if ((version = [item objectForKey:@"myLauncherViewItemVersion"])) {
|
252
|
+
if ([version intValue] == 2) {
|
253
|
+
[savedPage addObject:[[MyLauncherItem alloc]
|
254
|
+
initWithTitle:[item objectForKey:@"title"]
|
255
|
+
iPhoneImage:[item objectForKey:@"image"]
|
256
|
+
iPadImage:[item objectForKey:@"iPadImage"]
|
257
|
+
target:[item objectForKey:@"controller"]
|
258
|
+
targetTitle:[item objectForKey:@"controllerTitle"]
|
259
|
+
deletable:[[item objectForKey:@"deletable"] boolValue]]];
|
260
|
+
}
|
261
|
+
} else {
|
262
|
+
[savedPage addObject:[[MyLauncherItem alloc]
|
263
|
+
initWithTitle:[item objectForKey:@"title"]
|
264
|
+
image:[item objectForKey:@"image"]
|
265
|
+
target:[item objectForKey:@"controller"]
|
266
|
+
deletable:[[item objectForKey:@"deletable"] boolValue]]];
|
267
|
+
}
|
268
|
+
}
|
269
|
+
|
270
|
+
[savedLauncherItems addObject:savedPage];
|
271
|
+
}
|
272
|
+
|
273
|
+
return savedLauncherItems;
|
274
|
+
}
|
275
|
+
|
276
|
+
return nil;
|
277
|
+
}
|
278
|
+
|
279
|
+
-(void)clearSavedLauncherItems {
|
280
|
+
[self saveToUserDefaults:nil key:@"myLauncherView"];
|
281
|
+
[self saveToUserDefaults:nil key:@"myLauncherViewImmovable"];
|
282
|
+
}
|
283
|
+
|
284
|
+
-(id)retrieveFromUserDefaults:(NSString *)key {
|
285
|
+
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
|
286
|
+
|
287
|
+
if (standardUserDefaults)
|
288
|
+
return [standardUserDefaults objectForKey:key];
|
289
|
+
return nil;
|
290
|
+
}
|
291
|
+
|
292
|
+
-(void)saveToUserDefaults:(id)object key:(NSString *)key {
|
293
|
+
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
|
294
|
+
|
295
|
+
if (standardUserDefaults)
|
296
|
+
{
|
297
|
+
[standardUserDefaults setObject:object forKey:key];
|
298
|
+
[standardUserDefaults synchronize];
|
299
|
+
}
|
300
|
+
}
|
301
|
+
|
302
|
+
@end
|
data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/AESCrypt-ObjC/AESCrypt.h
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
//
|
2
|
+
// AESCrypt.h
|
3
|
+
// Gurpartap Singh
|
4
|
+
//
|
5
|
+
// Created by Gurpartap Singh on 06/05/12.
|
6
|
+
// Copyright (c) 2012 Gurpartap Singh
|
7
|
+
//
|
8
|
+
// MIT License
|
9
|
+
//
|
10
|
+
// Permission is hereby granted, free of charge, to any person obtaining
|
11
|
+
// a copy of this software and associated documentation files (the
|
12
|
+
// "Software"), to deal in the Software without restriction, including
|
13
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
14
|
+
// distribute, sublicense, and/or sell copies of the Software, and to
|
15
|
+
// permit persons to whom the Software is furnished to do so, subject to
|
16
|
+
// the following conditions:
|
17
|
+
//
|
18
|
+
// The above copyright notice and this permission notice shall be
|
19
|
+
// included in all copies or substantial portions of the Software.
|
20
|
+
//
|
21
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
22
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
23
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
24
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
25
|
+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
26
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
27
|
+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
|
+
//
|
29
|
+
|
30
|
+
#import <Foundation/Foundation.h>
|
31
|
+
|
32
|
+
@interface AESCrypt : NSObject
|
33
|
+
|
34
|
+
+ (NSString *)encrypt:(NSString *)message password:(NSString *)password;
|
35
|
+
+ (NSString *)decrypt:(NSString *)base64EncodedString password:(NSString *)password;
|
36
|
+
|
37
|
+
@end
|
data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/AESCrypt-ObjC/AESCrypt.m
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
//
|
2
|
+
// AESCrypt.m
|
3
|
+
// Gurpartap Singh
|
4
|
+
//
|
5
|
+
// Created by Gurpartap Singh on 06/05/12.
|
6
|
+
// Copyright (c) 2012 Gurpartap Singh
|
7
|
+
//
|
8
|
+
// MIT License
|
9
|
+
//
|
10
|
+
// Permission is hereby granted, free of charge, to any person obtaining
|
11
|
+
// a copy of this software and associated documentation files (the
|
12
|
+
// "Software"), to deal in the Software without restriction, including
|
13
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
14
|
+
// distribute, sublicense, and/or sell copies of the Software, and to
|
15
|
+
// permit persons to whom the Software is furnished to do so, subject to
|
16
|
+
// the following conditions:
|
17
|
+
//
|
18
|
+
// The above copyright notice and this permission notice shall be
|
19
|
+
// included in all copies or substantial portions of the Software.
|
20
|
+
//
|
21
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
22
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
23
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
24
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
25
|
+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
26
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
27
|
+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
|
+
//
|
29
|
+
|
30
|
+
#import "AESCrypt.h"
|
31
|
+
|
32
|
+
#import "NSData+Base64.h"
|
33
|
+
#import "NSString+Base64.h"
|
34
|
+
#import "NSData+CommonCrypto.h"
|
35
|
+
|
36
|
+
@implementation AESCrypt
|
37
|
+
|
38
|
+
+ (NSString *)encrypt:(NSString *)message password:(NSString *)password {
|
39
|
+
NSData *encryptedData = [[message dataUsingEncoding:NSUTF8StringEncoding] AES256EncryptedDataUsingKey:[[password dataUsingEncoding:NSUTF8StringEncoding] SHA256Hash] error:nil];
|
40
|
+
NSString *base64EncodedString = [NSString base64StringFromData:encryptedData length:[encryptedData length]];
|
41
|
+
return base64EncodedString;
|
42
|
+
}
|
43
|
+
|
44
|
+
+ (NSString *)decrypt:(NSString *)base64EncodedString password:(NSString *)password {
|
45
|
+
NSData *encryptedData = [NSData base64DataFromString:base64EncodedString];
|
46
|
+
NSData *decryptedData = [encryptedData decryptedAES256DataUsingKey:[[password dataUsingEncoding:NSUTF8StringEncoding] SHA256Hash] error:nil];
|
47
|
+
return [[NSString alloc] initWithData:decryptedData encoding:NSUTF8StringEncoding];
|
48
|
+
}
|
49
|
+
|
50
|
+
@end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
//
|
2
|
+
// NSData+Base64.m
|
3
|
+
// Gurpartap Singh
|
4
|
+
//
|
5
|
+
// Created by Gurpartap Singh on 06/05/12.
|
6
|
+
// Copyright (c) 2012 Gurpartap Singh. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import <Foundation/Foundation.h>
|
10
|
+
|
11
|
+
@class NSString;
|
12
|
+
|
13
|
+
@interface NSData (Base64Additions)
|
14
|
+
|
15
|
+
+ (NSData *)base64DataFromString:(NSString *)string;
|
16
|
+
|
17
|
+
@end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
//
|
2
|
+
// NSData+Base64.h
|
3
|
+
// Gurpartap Singh
|
4
|
+
//
|
5
|
+
// Created by Gurpartap Singh on 06/05/12.
|
6
|
+
// Copyright (c) 2012 Gurpartap Singh. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "NSData+Base64.h"
|
10
|
+
|
11
|
+
@implementation NSData (Base64Additions)
|
12
|
+
|
13
|
+
+ (NSData *)base64DataFromString:(NSString *)string {
|
14
|
+
unsigned long ixtext, lentext;
|
15
|
+
unsigned char ch, inbuf[4], outbuf[3];
|
16
|
+
short i, ixinbuf;
|
17
|
+
Boolean flignore, flendtext = false;
|
18
|
+
const unsigned char *tempcstring;
|
19
|
+
NSMutableData *theData;
|
20
|
+
|
21
|
+
if (string == nil) {
|
22
|
+
return [NSData data];
|
23
|
+
}
|
24
|
+
|
25
|
+
ixtext = 0;
|
26
|
+
|
27
|
+
tempcstring = (const unsigned char *)[string UTF8String];
|
28
|
+
|
29
|
+
lentext = [string length];
|
30
|
+
|
31
|
+
theData = [NSMutableData dataWithCapacity: lentext];
|
32
|
+
|
33
|
+
ixinbuf = 0;
|
34
|
+
|
35
|
+
while (true) {
|
36
|
+
if (ixtext >= lentext) {
|
37
|
+
break;
|
38
|
+
}
|
39
|
+
|
40
|
+
ch = tempcstring [ixtext++];
|
41
|
+
|
42
|
+
flignore = false;
|
43
|
+
|
44
|
+
if ((ch >= 'A') && (ch <= 'Z')) {
|
45
|
+
ch = ch - 'A';
|
46
|
+
}
|
47
|
+
else if ((ch >= 'a') && (ch <= 'z')) {
|
48
|
+
ch = ch - 'a' + 26;
|
49
|
+
}
|
50
|
+
else if ((ch >= '0') && (ch <= '9')) {
|
51
|
+
ch = ch - '0' + 52;
|
52
|
+
}
|
53
|
+
else if (ch == '+') {
|
54
|
+
ch = 62;
|
55
|
+
}
|
56
|
+
else if (ch == '=') {
|
57
|
+
flendtext = true;
|
58
|
+
}
|
59
|
+
else if (ch == '/') {
|
60
|
+
ch = 63;
|
61
|
+
}
|
62
|
+
else {
|
63
|
+
flignore = true;
|
64
|
+
}
|
65
|
+
|
66
|
+
if (!flignore) {
|
67
|
+
short ctcharsinbuf = 3;
|
68
|
+
Boolean flbreak = false;
|
69
|
+
|
70
|
+
if (flendtext) {
|
71
|
+
if (ixinbuf == 0) {
|
72
|
+
break;
|
73
|
+
}
|
74
|
+
|
75
|
+
if ((ixinbuf == 1) || (ixinbuf == 2)) {
|
76
|
+
ctcharsinbuf = 1;
|
77
|
+
}
|
78
|
+
else {
|
79
|
+
ctcharsinbuf = 2;
|
80
|
+
}
|
81
|
+
|
82
|
+
ixinbuf = 3;
|
83
|
+
|
84
|
+
flbreak = true;
|
85
|
+
}
|
86
|
+
|
87
|
+
inbuf [ixinbuf++] = ch;
|
88
|
+
|
89
|
+
if (ixinbuf == 4) {
|
90
|
+
ixinbuf = 0;
|
91
|
+
|
92
|
+
outbuf[0] = (inbuf[0] << 2) | ((inbuf[1] & 0x30) >> 4);
|
93
|
+
outbuf[1] = ((inbuf[1] & 0x0F) << 4) | ((inbuf[2] & 0x3C) >> 2);
|
94
|
+
outbuf[2] = ((inbuf[2] & 0x03) << 6) | (inbuf[3] & 0x3F);
|
95
|
+
|
96
|
+
for (i = 0; i < ctcharsinbuf; i++) {
|
97
|
+
[theData appendBytes: &outbuf[i] length: 1];
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
if (flbreak) {
|
102
|
+
break;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
return theData;
|
108
|
+
}
|
109
|
+
|
110
|
+
@end
|