Permalink
Browse files

upgrading iphone pigeon to phonegap 0.8.0

  • Loading branch information...
1 parent 15f7609 commit fec6f48a305ce1e6dfd5b463a4a1cd5f743deaec alunny committed Nov 3, 2009
Showing with 12,627 additions and 1,943 deletions.
  1. +3 −1 .gitignore
  2. +4 −0 iphone/.gitignore
  3. +21 −0 iphone/Classes/Bonjour.h
  4. +37 −0 iphone/Classes/Bonjour.m
  5. +53 −0 iphone/Classes/Camera.h
  6. +133 −0 iphone/Classes/Camera.m
  7. +15 −0 iphone/Classes/Categories.h
  8. +48 −0 iphone/Classes/Categories.m
  9. +68 −9 iphone/Classes/Contacts.h
  10. +344 −50 iphone/Classes/Contacts.m
  11. +18 −0 iphone/Classes/DebugConsole.h
  12. +23 −0 iphone/Classes/DebugConsole.m
  13. +4 −2 iphone/Classes/Device.h
  14. +19 −31 iphone/Classes/Device.m
  15. +3 −4 iphone/Classes/Image.h
  16. +4 −1 iphone/Classes/Image.m
  17. +30 −0 iphone/Classes/InvokedUrlCommand.h
  18. +90 −0 iphone/Classes/InvokedUrlCommand.m
  19. +50 −0 iphone/Classes/JSON/JSON.h
  20. +68 −0 iphone/Classes/JSON/NSObject+SBJSON.h
  21. +53 −0 iphone/Classes/JSON/NSObject+SBJSON.m
  22. +58 −0 iphone/Classes/JSON/NSString+SBJSON.h
  23. +55 −0 iphone/Classes/JSON/NSString+SBJSON.m
  24. +75 −0 iphone/Classes/JSON/SBJSON.h
  25. +212 −0 iphone/Classes/JSON/SBJSON.m
  26. +86 −0 iphone/Classes/JSON/SBJsonBase.h
  27. +78 −0 iphone/Classes/JSON/SBJsonBase.m
  28. +87 −0 iphone/Classes/JSON/SBJsonParser.h
  29. +475 −0 iphone/Classes/JSON/SBJsonParser.m
  30. +129 −0 iphone/Classes/JSON/SBJsonWriter.h
  31. +228 −0 iphone/Classes/JSON/SBJsonWriter.m
  32. +29 −0 iphone/Classes/LoadingView.h
  33. +218 −0 iphone/Classes/LoadingView.m
  34. +28 −13 iphone/Classes/Location.h
  35. +147 −54 iphone/Classes/Location.m
  36. +17 −0 iphone/Classes/Map.h
  37. +18 −0 iphone/Classes/Map.m
  38. +39 −0 iphone/Classes/Movie.h
  39. +146 −0 iphone/Classes/Movie.m
  40. +31 −0 iphone/Classes/NSData+Base64.h
  41. +298 −0 iphone/Classes/NSData+Base64.m
  42. +23 −0 iphone/Classes/Network.h
  43. +64 −0 iphone/Classes/Network.m
  44. +26 −0 iphone/Classes/Notification.h
  45. +109 −0 iphone/Classes/Notification.m
  46. +25 −0 iphone/Classes/OCABMutableMultiValue.h
  47. +68 −0 iphone/Classes/OCABMutableMultiValue.m
  48. +35 −0 iphone/Classes/OCABRecord.h
  49. +123 −0 iphone/Classes/OCABRecord.m
  50. +17 −0 iphone/Classes/OCCFObject.h
  51. +68 −0 iphone/Classes/OCCFObject.m
  52. +27 −0 iphone/Classes/PhoneGapCommand.h
  53. +49 −0 iphone/Classes/PhoneGapCommand.m
  54. +21 −18 iphone/Classes/PhoneGapDelegate.h
  55. +303 −371 iphone/Classes/PhoneGapDelegate.m
  56. +5 −1 iphone/Classes/PhoneGapViewController.h
  57. +26 −11 iphone/Classes/PhoneGapViewController.m
  58. +122 −0 iphone/Classes/Reachability.h
  59. +585 −0 iphone/Classes/Reachability.m
  60. +21 −4 iphone/Classes/Sound.h
  61. +75 −14 iphone/Classes/Sound.m
  62. +49 −0 iphone/Classes/UIControls.h
  63. +442 −0 iphone/Classes/UIControls.m
  64. +1 −1 iphone/Info.plist
  65. +12 −2 iphone/MainWindow.xib
  66. +35 −0 iphone/PhoneGap.plist
  67. +6 −1 iphone/PhoneGap_Prefix.pch
  68. +92 −97 iphone/Pigeon.xcodeproj/andrewlunny.mode1v3
  69. +128 −560 iphone/Pigeon.xcodeproj/andrewlunny.pbxuser
  70. +303 −56 iphone/Pigeon.xcodeproj/project.pbxproj
  71. +3 −0 iphone/README.md
  72. +1 −0 iphone/VERSION
  73. BIN iphone/beep.wav
  74. +8 −0 iphone/build-phonegap.sh
  75. +1 −1 iphone/build/Debug-iphonesimulator/Pigeon.app.dSYM/Contents/Info.plist
  76. BIN iphone/build/Debug-iphonesimulator/Pigeon.app/Info.plist
  77. BIN iphone/build/Debug-iphonesimulator/Pigeon.app/MainWindow.nib
  78. BIN iphone/build/Debug-iphonesimulator/Pigeon.app/beep.wav
  79. +1,282 −638 iphone/build/Debug-iphonesimulator/Pigeon.app/www/script/phonegap.js
  80. BIN iphone/build/Pigeon.build/Debug-iphonesimulator/PhoneGap.build/Objects-normal/i386/Contacts.o
  81. BIN iphone/build/Pigeon.build/Debug-iphonesimulator/PhoneGap.build/Objects-normal/i386/Device.o
  82. BIN iphone/build/Pigeon.build/Debug-iphonesimulator/PhoneGap.build/Objects-normal/i386/Image.o
  83. BIN iphone/build/Pigeon.build/Debug-iphonesimulator/PhoneGap.build/Objects-normal/i386/Location.o
  84. BIN ...ne/build/Pigeon.build/Debug-iphonesimulator/PhoneGap.build/Objects-normal/i386/PhoneGapDelegate.o
  85. BIN ...ld/Pigeon.build/Debug-iphonesimulator/PhoneGap.build/Objects-normal/i386/PhoneGapViewController.o
  86. +24 −2 ...e/build/Pigeon.build/Debug-iphonesimulator/PhoneGap.build/Objects-normal/i386/Pigeon.LinkFileList
  87. BIN iphone/build/Pigeon.build/Debug-iphonesimulator/PhoneGap.build/Objects-normal/i386/Sound.o
  88. BIN iphone/build/Pigeon.build/Debug-iphonesimulator/PhoneGap.build/Objects-normal/i386/main.o
  89. BIN iphone/build/Pigeon.build/Debug-iphonesimulator/PhoneGap.build/Pigeon-project-headers.hmap
  90. BIN iphone/build/Pigeon.build/Debug-iphonesimulator/PhoneGap.build/Pigeon.hmap
  91. BIN iphone/build/Pigeon.build/Pigeon.pbxindex/categories.pbxbtree
  92. BIN iphone/build/Pigeon.build/Pigeon.pbxindex/cdecls.pbxbtree
  93. BIN iphone/build/Pigeon.build/Pigeon.pbxindex/decls.pbxbtree
  94. BIN iphone/build/Pigeon.build/Pigeon.pbxindex/files.pbxbtree
  95. BIN iphone/build/Pigeon.build/Pigeon.pbxindex/imports.pbxbtree
  96. BIN iphone/build/Pigeon.build/Pigeon.pbxindex/pbxindex.header
  97. BIN iphone/build/Pigeon.build/Pigeon.pbxindex/protocols.pbxbtree
  98. BIN iphone/build/Pigeon.build/Pigeon.pbxindex/refs.pbxbtree
  99. BIN iphone/build/Pigeon.build/Pigeon.pbxindex/strings.pbxstrings/control
  100. BIN iphone/build/Pigeon.build/Pigeon.pbxindex/strings.pbxstrings/strings
  101. BIN iphone/build/Pigeon.build/Pigeon.pbxindex/subclasses.pbxbtree
  102. BIN iphone/build/Pigeon.build/Pigeon.pbxindex/symbols0.pbxsymbols
  103. +1,541 −0 iphone/doxygen.cfg
  104. +0 −1 iphone/main.m
  105. BIN iphone/www/assets/bar.png
  106. BIN iphone/www/assets/button.png
  107. BIN iphone/www/assets/header.png
  108. BIN iphone/www/assets/login_button.png
  109. BIN iphone/www/assets/tweet_background.png
  110. BIN iphone/www/assets/tweet_button.png
  111. +92 −0 iphone/www/index.html
  112. +166 −0 iphone/www/master.css
  113. +1,309 −0 iphone/www/script/phonegap.js
  114. +213 −0 iphone/www/script/pigeon.js
  115. +87 −0 iphone/www/script/sql.js
  116. +1 −0 iphone/www/script/xui-min.js
  117. BIN symbian/www/Icon.png
  118. +18 −0 symbian/www/Info.plist
  119. +45 −0 symbian/www/assets/master.css
  120. BIN symbian/www/assets/nitobi-avatar.png
  121. +34 −0 symbian/www/index.html
  122. +96 −0 symbian/www/js/controller.js
  123. +1,304 −0 symbian/www/js/phonegap.js
View
@@ -1 +1,3 @@
-build/*
+build/*
+tmp/
+tmp/*
View
@@ -0,0 +1,4 @@
+build/*
+*.pbxuser
+*.perspectivev3
+*.mode1v3
@@ -0,0 +1,21 @@
+//
+// Bonjour.h
+// PhoneGap
+//
+// Created by Brant Vasilieff on 3/1/09.
+// Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+#import "PhoneGapCommand.h"
+
+@interface Bonjour : PhoneGapCommand
+{
+ NSString* __identifier;
+}
+
+- (void)start:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
+- (void)stop:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
+
+@end
@@ -0,0 +1,37 @@
+//
+// Bonjour.m
+// PhoneGap
+//
+// Created by Brant Vasilieff on 3/1/09.
+// Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+#import "Bonjour.h"
+
+
+@implementation Bonjour
+
+- (void)start:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
+{
+}
+
+- (void)stop:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
+{
+}
+
+- (id)init
+{
+ if (self = [super init])
+ {
+ __identifier = nil;
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [__identifier release];
+ [super dealloc];
+}
+
+@end
@@ -0,0 +1,53 @@
+/*
+ * Camera.h
+ *
+ * Created by Nitobi on 12/12/08.
+ * Copyright 2008 Nitobi. All rights reserved.
+ *
+ */
+
+#import <Foundation/Foundation.h>
+#import "PhoneGapCommand.h"
+
+@interface CameraPicker : UIImagePickerController
+{
+ NSString* successCallback;
+ NSString* errorCallback;
+ NSInteger quality;
+}
+
+@property NSInteger quality;
+@property (retain) NSString* successCallback;
+@property (retain) NSString* errorCallback;
+
+- (void) dealloc;
+
+@end
+
+@interface Camera : PhoneGapCommand<UIImagePickerControllerDelegate, UINavigationControllerDelegate>
+{
+ CameraPicker* pickerController;
+}
+
+/*
+ * getPicture
+ *
+ * arguments:
+ * 1: this is the javascript function that will be called with the results, the first parameter passed to the
+ * javascript function is the picture as a Base64 encoded string
+ * 2: this is the javascript function to be called if there was an error
+ * options:
+ * quality: integer between 1 and 100
+ */
+- (void) getPicture:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
+- (void) postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url;
+
+- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo;
+- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker;
+
+- (void) dealloc;
+
+@end
+
+
+
@@ -0,0 +1,133 @@
+//
+// Camera.m
+// PhoneGap
+//
+// Created by Shazron Abdullah on 15/07/09.
+// Copyright 2009 Nitobi. All rights reserved.
+//
+
+#import "Camera.h"
+#import "NSData+Base64.h"
+#import "Categories.h"
+
+@implementation Camera
+
+- (void) getPicture:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
+{
+ NSUInteger argc = [arguments count];
+ NSString* successCallback = nil, *errorCallback = nil;
+
+ if (argc > 0) successCallback = [arguments objectAtIndex:0];
+ if (argc > 1) errorCallback = [arguments objectAtIndex:1];
+
+ if (argc < 1) {
+ NSLog(@"Camera.getPicture: Missing 1st parameter.");
+ return;
+ }
+
+ bool hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
+ if (!hasCamera) {
+ NSLog(@"Camera.getPicture: Camera not available.");
+ return;
+ }
+
+ if (pickerController == nil) {
+ pickerController = [[CameraPicker alloc] init];
+ pickerController.delegate = self;
+ pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
+ pickerController.successCallback = successCallback;
+ pickerController.errorCallback = errorCallback;
+ pickerController.quality = [options integerValueForKey:@"quality" defaultValue:100 withRange:NSMakeRange(0, 100)];
+ }
+
+ [[super appViewController] presentModalViewController:pickerController animated:YES];
+}
+
+- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo
+{
+ CameraPicker* cameraPicker = (CameraPicker*)picker;
+ CGFloat quality = (double)cameraPicker.quality / 100.0;
+ NSData* data = UIImageJPEGRepresentation(image, quality);
+
+ [picker dismissModalViewControllerAnimated:YES];
+
+ if (cameraPicker.successCallback) {
+ NSString* jsString = [[NSString alloc] initWithFormat:@"%@(\"%@\");", cameraPicker.successCallback, [data base64EncodedString]];
+ [webView stringByEvaluatingJavaScriptFromString:jsString];
+ [jsString release];
+ }
+}
+
+- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker
+{
+ [picker dismissModalViewControllerAnimated:YES];
+}
+
+- (void) postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url
+{
+ NSString *boundary = @"----BOUNDARY_IS_I";
+
+ NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
+ [req setHTTPMethod:@"POST"];
+
+ NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
+ [req setValue:contentType forHTTPHeaderField:@"Content-type"];
+
+ NSData *imageData = UIImagePNGRepresentation(anImage);
+
+ // adding the body
+ NSMutableData *postBody = [NSMutableData data];
+
+ // first parameter an image
+ [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
+ [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upload\"; filename=\"%@\"\r\n", filename] dataUsingEncoding:NSUTF8StringEncoding]];
+ [postBody appendData:[@"Content-Type: image/png\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
+ [postBody appendData:imageData];
+
+// // second parameter information
+// [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
+// [postBody appendData:[@"Content-Disposition: form-data; name=\"some_other_name\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
+// [postBody appendData:[@"some_other_value" dataUsingEncoding:NSUTF8StringEncoding]];
+// [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r \n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
+
+ [req setHTTPBody:postBody];
+
+ NSURLResponse* response;
+ NSError* error;
+ [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
+
+// NSData* result = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
+// NSString * resultStr = [[[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding] autorelease];
+}
+
+- (void) dealloc
+{
+ if (pickerController) {
+ [pickerController release];
+ }
+
+ [super dealloc];
+}
+
+@end
+
+
+@implementation CameraPicker
+
+@synthesize quality;
+@synthesize successCallback;
+@synthesize errorCallback;
+
+- (void) dealloc
+{
+ if (successCallback) {
+ [successCallback release];
+ }
+ if (errorCallback) {
+ [errorCallback release];
+ }
+
+ [super dealloc];
+}
+
+@end
@@ -0,0 +1,15 @@
+//
+// Categories.h
+// PhoneGap
+//
+// Created by Shazron Abdullah on 26/05/09.
+// Copyright 2009 Nitobi Software. All rights reserved.
+//
+
+
+@interface NSMutableDictionary(NSDictionary_Extension)
+
+- (bool) existsValue:(NSString*)expectedValue forKey:(NSString*)key;
+- (NSUInteger) integerValueForKey:(NSString*)key defaultValue:(NSUInteger)defaultValue withRange:(NSRange)range;
+
+@end
@@ -0,0 +1,48 @@
+//
+// Categories.m
+// PhoneGap
+//
+// Created by Shazron Abdullah on 26/05/09.
+// Copyright 2009 Nitobi Software. All rights reserved.
+//
+
+#import "Categories.h"
+#import <math.h>
+
+@implementation NSMutableDictionary(NSDictionary_Extension)
+
+- (bool) existsValue:(NSString*)expectedValue forKey:(NSString*)key
+{
+ id val = [self valueForKey:key];
+ bool exists = false;
+ if (val != nil) {
+ exists = [(NSString*)val compare:expectedValue options:NSCaseInsensitiveSearch] == 0;
+ }
+
+ return exists;
+}
+
+- (NSUInteger) integerValueForKey:(NSString*)key defaultValue:(NSUInteger)defaultValue withRange:(NSRange)range
+{
+ NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
+ [numberFormatter setRoundingMode:NSNumberFormatterRoundCeiling];
+
+ NSUInteger value = defaultValue;
+
+ id val = [self valueForKey:key];
+ if (val != nil) {
+ NSNumber* number = [numberFormatter numberFromString:(NSString*)val];
+ value = [number unsignedIntValue];
+ }
+
+ [numberFormatter release];
+
+ // min, max checks
+ value = MAX(range.location, value);
+ value = MIN(range.length, value);
+
+ return value;
+}
+
+@end
+
Oops, something went wrong.

0 comments on commit fec6f48

Please sign in to comment.