Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commit

  • Loading branch information...
commit bd0e16831ca7e968b73ad3db916dd4ba9ab2ba46 1 parent da9d4ad
@ideashower ideashower authored
Showing with 21,104 additions and 0 deletions.
  1. +38 −0 Classes/Example/ExampleShareFile.h
  2. +82 −0 Classes/Example/ExampleShareFile.m
  3. +38 −0 Classes/Example/ExampleShareImage.h
  4. +83 −0 Classes/Example/ExampleShareImage.m
  5. +38 −0 Classes/Example/ExampleShareLink.h
  6. +78 −0 Classes/Example/ExampleShareLink.m
  7. +38 −0 Classes/Example/ExampleShareText.h
  8. +91 −0 Classes/Example/ExampleShareText.m
  9. +14 −0 Classes/Example/RootViewController.h
  10. +105 −0 Classes/Example/RootViewController.m
  11. +21 −0 Classes/Example/ShareKitAppDelegate.h
  12. +66 −0 Classes/Example/ShareKitAppDelegate.m
  13. BIN  Classes/Example/example.pdf
  14. BIN  Classes/Example/sanFran.jpg
  15. +35 −0 Classes/OAuth/Categories/NSMutableURLRequest+Parameters.h
  16. +97 −0 Classes/OAuth/Categories/NSMutableURLRequest+Parameters.m
  17. +34 −0 Classes/OAuth/Categories/NSString+URLEncoding.h
  18. +52 −0 Classes/OAuth/Categories/NSString+URLEncoding.m
  19. +34 −0 Classes/OAuth/Categories/NSURL+Base.h
  20. +38 −0 Classes/OAuth/Categories/NSURL+Base.m
  21. +230 −0 Classes/OAuth/Crytpo/Base64Transcoder.c
  22. +36 −0 Classes/OAuth/Crytpo/Base64Transcoder.h
  23. +86 −0 Classes/OAuth/Crytpo/hmac.c
  24. +31 −0 Classes/OAuth/Crytpo/hmac.h
  25. +169 −0 Classes/OAuth/Crytpo/sha1.c
  26. +12 −0 Classes/OAuth/Crytpo/sha1.h
  27. +45 −0 Classes/OAuth/OAAsynchronousDataFetcher.h
  28. +134 −0 Classes/OAuth/OAAsynchronousDataFetcher.m
  29. +40 −0 Classes/OAuth/OAConsumer.h
  30. +51 −0 Classes/OAuth/OAConsumer.m
  31. +45 −0 Classes/OAuth/OADataFetcher.h
  32. +65 −0 Classes/OAuth/OADataFetcher.m
  33. +32 −0 Classes/OAuth/OAHMAC_SHA1SignatureProvider.h
  34. +58 −0 Classes/OAuth/OAHMAC_SHA1SignatureProvider.m
  35. +68 −0 Classes/OAuth/OAMutableURLRequest.h
  36. +231 −0 Classes/OAuth/OAMutableURLRequest.m
  37. +31 −0 Classes/OAuth/OAPlaintextSignatureProvider.h
  38. +43 −0 Classes/OAuth/OAPlaintextSignatureProvider.m
  39. +53 −0 Classes/OAuth/OAProblem.h
  40. +165 −0 Classes/OAuth/OAProblem.m
  41. +45 −0 Classes/OAuth/OARequestParameter.h
  42. +70 −0 Classes/OAuth/OARequestParameter.m
  43. +47 −0 Classes/OAuth/OAServiceTicket.h
  44. +56 −0 Classes/OAuth/OAServiceTicket.m
  45. +34 −0 Classes/OAuth/OASignatureProviding.h
  46. +41 −0 Classes/OAuth/OAToken.h
  47. +105 −0 Classes/OAuth/OAToken.m
  48. +39 −0 Classes/OAuth/OAuthConsumer.h
  49. +89 −0 Classes/ShareKit/Core/Base Sharer Classes/SHKOAuthSharer.h
  50. +272 −0 Classes/ShareKit/Core/Base Sharer Classes/SHKOAuthSharer.m
  51. +172 −0 Classes/ShareKit/Core/Base Sharer Classes/SHKSharer.h
  52. +666 −0 Classes/ShareKit/Core/Base Sharer Classes/SHKSharer.m
  53. +38 −0 Classes/ShareKit/Core/Categories/UIWebView+SHK.h
  54. +37 −0 Classes/ShareKit/Core/Categories/UIWebView+SHK.m
  55. +41 −0 Classes/ShareKit/Core/Helpers/Keychain/SFHFKeychainUtils.h
  56. +434 −0 Classes/ShareKit/Core/Helpers/Keychain/SFHFKeychainUtils.m
  57. +35 −0 Classes/ShareKit/Core/Helpers/OAuth/Categories/NSMutableURLRequest+Parameters.h
  58. +97 −0 Classes/ShareKit/Core/Helpers/OAuth/Categories/NSMutableURLRequest+Parameters.m
  59. +34 −0 Classes/ShareKit/Core/Helpers/OAuth/Categories/NSString+URLEncoding.h
  60. +52 −0 Classes/ShareKit/Core/Helpers/OAuth/Categories/NSString+URLEncoding.m
  61. +34 −0 Classes/ShareKit/Core/Helpers/OAuth/Categories/NSURL+Base.h
  62. +38 −0 Classes/ShareKit/Core/Helpers/OAuth/Categories/NSURL+Base.m
  63. +230 −0 Classes/ShareKit/Core/Helpers/OAuth/Crytpo/Base64Transcoder.c
  64. +36 −0 Classes/ShareKit/Core/Helpers/OAuth/Crytpo/Base64Transcoder.h
  65. +86 −0 Classes/ShareKit/Core/Helpers/OAuth/Crytpo/hmac.c
  66. +31 −0 Classes/ShareKit/Core/Helpers/OAuth/Crytpo/hmac.h
  67. +169 −0 Classes/ShareKit/Core/Helpers/OAuth/Crytpo/sha1.c
  68. +12 −0 Classes/ShareKit/Core/Helpers/OAuth/Crytpo/sha1.h
  69. +45 −0 Classes/ShareKit/Core/Helpers/OAuth/OAAsynchronousDataFetcher.h
  70. +134 −0 Classes/ShareKit/Core/Helpers/OAuth/OAAsynchronousDataFetcher.m
  71. +40 −0 Classes/ShareKit/Core/Helpers/OAuth/OAConsumer.h
  72. +51 −0 Classes/ShareKit/Core/Helpers/OAuth/OAConsumer.m
  73. +45 −0 Classes/ShareKit/Core/Helpers/OAuth/OADataFetcher.h
  74. +65 −0 Classes/ShareKit/Core/Helpers/OAuth/OADataFetcher.m
  75. +32 −0 Classes/ShareKit/Core/Helpers/OAuth/OAHMAC_SHA1SignatureProvider.h
  76. +58 −0 Classes/ShareKit/Core/Helpers/OAuth/OAHMAC_SHA1SignatureProvider.m
  77. +68 −0 Classes/ShareKit/Core/Helpers/OAuth/OAMutableURLRequest.h
  78. +231 −0 Classes/ShareKit/Core/Helpers/OAuth/OAMutableURLRequest.m
  79. +31 −0 Classes/ShareKit/Core/Helpers/OAuth/OAPlaintextSignatureProvider.h
  80. +43 −0 Classes/ShareKit/Core/Helpers/OAuth/OAPlaintextSignatureProvider.m
  81. +53 −0 Classes/ShareKit/Core/Helpers/OAuth/OAProblem.h
  82. +165 −0 Classes/ShareKit/Core/Helpers/OAuth/OAProblem.m
  83. +45 −0 Classes/ShareKit/Core/Helpers/OAuth/OARequestParameter.h
  84. +70 −0 Classes/ShareKit/Core/Helpers/OAuth/OARequestParameter.m
  85. +47 −0 Classes/ShareKit/Core/Helpers/OAuth/OAServiceTicket.h
  86. +56 −0 Classes/ShareKit/Core/Helpers/OAuth/OAServiceTicket.m
  87. +34 −0 Classes/ShareKit/Core/Helpers/OAuth/OASignatureProviding.h
  88. +41 −0 Classes/ShareKit/Core/Helpers/OAuth/OAToken.h
  89. +105 −0 Classes/ShareKit/Core/Helpers/OAuth/OAToken.m
  90. +39 −0 Classes/ShareKit/Core/Helpers/OAuth/OAuthConsumer.h
  91. +74 −0 Classes/ShareKit/Core/Helpers/SHKRequest.h
  92. +148 −0 Classes/ShareKit/Core/Helpers/SHKRequest.m
  93. +120 −0 Classes/ShareKit/Core/SHK.h
  94. +460 −0 Classes/ShareKit/Core/SHK.m
  95. +86 −0 Classes/ShareKit/Core/SHKItem.h
  96. +183 −0 Classes/ShareKit/Core/SHKItem.m
  97. +56 −0 Classes/ShareKit/Core/SHKOfflineSharer.h
  98. +153 −0 Classes/ShareKit/Core/SHKOfflineSharer.m
  99. +21 −0 Classes/ShareKit/Core/SHKSharers.plist
  100. +35 −0 Classes/ShareKit/Customize UI/SHKCustomFormController.h
  101. +133 −0 Classes/ShareKit/Customize UI/SHKCustomFormController.m
  102. +36 −0 Classes/ShareKit/Customize UI/SHKCustomFormFieldCell.h
  103. +35 −0 Classes/ShareKit/Customize UI/SHKCustomFormFieldCell.m
  104. +40 −0 Classes/ShareKit/Customize UI/SHKCustomShareMenu.h
  105. +36 −0 Classes/ShareKit/Customize UI/SHKCustomShareMenu.m
  106. +45 −0 Classes/ShareKit/Customize UI/SHKCustomShareMenuCell.h
  107. +35 −0 Classes/ShareKit/Customize UI/SHKCustomShareMenuCell.m
  108. +88 −0 Classes/ShareKit/Reachability/Reachability.h
  109. +273 −0 Classes/ShareKit/Reachability/Reachability.m
  110. +36 −0 Classes/ShareKit/Sharers/Actions/Copy/SHKCopy.h
  111. +88 −0 Classes/ShareKit/Sharers/Actions/Copy/SHKCopy.m
  112. +46 −0 Classes/ShareKit/Sharers/Actions/Email/SHKMail.h
  113. +186 −0 Classes/ShareKit/Sharers/Actions/Email/SHKMail.m
  114. +36 −0 Classes/ShareKit/Sharers/Actions/Open in Safari/SHKSafari.h
  115. +79 −0 Classes/ShareKit/Sharers/Actions/Open in Safari/SHKSafari.m
  116. +41 −0 Classes/ShareKit/Sharers/Services/Delicious/SHKDelicious.h
  117. +193 −0 Classes/ShareKit/Sharers/Services/Delicious/SHKDelicious.m
  118. BIN  Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBConnect.bundle/images/close.png
  119. BIN  Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBConnect.bundle/images/fbicon.png
  120. BIN  Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBConnect.bundle/images/login.png
  121. BIN  Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBConnect.bundle/images/login2.png
  122. BIN  Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBConnect.bundle/images/login2_down.png
  123. BIN  Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBConnect.bundle/images/login_down.png
  124. BIN  Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBConnect.bundle/images/logout.png
  125. BIN  Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBConnect.bundle/images/logout_down.png
  126. +23 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBConnect.h
  127. +213 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBConnectGlobal.h
  128. +33 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBConnectGlobal.m
  129. +137 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBDialog.h
  130. +606 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBDialog.m
  131. +42 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBFeedDialog.h
  132. +85 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBFeedDialog.m
  133. +49 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBLoginButton.h
  134. +162 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBLoginButton.m
  135. +24 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBLoginDialog.h
  136. +129 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBLoginDialog.m
  137. +31 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBPermissionDialog.h
  138. +100 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBPermissionDialog.m
  139. +165 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBRequest.h
  140. +378 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBRequest.m
  141. +188 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBSession.h
  142. +286 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBSession.m
  143. +62 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBStreamDialog.h
  144. +77 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBStreamDialog.m
  145. +32 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBXMLHandler.h
  146. +152 −0 Classes/ShareKit/Sharers/Services/Facebook/FBConnect/FBXMLHandler.m
  147. +52 −0 Classes/ShareKit/Sharers/Services/Facebook/SHKFacebook.h
  148. +218 −0 Classes/ShareKit/Sharers/Services/Facebook/SHKFacebook.m
  149. +44 −0 Classes/ShareKit/Sharers/Services/Google Reader/SHKGoogleReader.h
  150. +301 −0 Classes/ShareKit/Sharers/Services/Google Reader/SHKGoogleReader.m
  151. +36 −0 Classes/ShareKit/Sharers/Services/Pinboard/SHKPinboard.h
  152. +173 −0 Classes/ShareKit/Sharers/Services/Pinboard/SHKPinboard.m
  153. +35 −0 Classes/ShareKit/Sharers/Services/Read It Later/SHKReadItLater.h
  154. +188 −0 Classes/ShareKit/Sharers/Services/Read It Later/SHKReadItLater.m
  155. +61 −0 Classes/ShareKit/Sharers/Services/Twitter/SHKTwitter.h
  156. +379 −0 Classes/ShareKit/Sharers/Services/Twitter/SHKTwitter.m
  157. +44 −0 Classes/ShareKit/Sharers/Services/Twitter/SHKTwitterForm.h
  158. +212 −0 Classes/ShareKit/Sharers/Services/Twitter/SHKTwitterForm.m
  159. +46 −0 Classes/ShareKit/UI/SHKActionSheet.h
  160. +102 −0 Classes/ShareKit/UI/SHKActionSheet.m
  161. +59 −0 Classes/ShareKit/UI/SHKActivityIndicator.h
  162. +277 −0 Classes/ShareKit/UI/SHKActivityIndicator.m
  163. +82 −0 Classes/ShareKit/UI/SHKFormController.h
  164. +288 −0 Classes/ShareKit/UI/SHKFormController.m
  165. +61 −0 Classes/ShareKit/UI/SHKFormFieldCell.h
  166. +156 −0 Classes/ShareKit/UI/SHKFormFieldCell.m
  167. +55 −0 Classes/ShareKit/UI/SHKFormFieldSettings.h
  168. +54 −0 Classes/ShareKit/UI/SHKFormFieldSettings.m
  169. +36 −0 Classes/ShareKit/UI/SHKNavController.h
  170. +38 −0 Classes/ShareKit/UI/SHKNavController.m
  171. +57 −0 Classes/ShareKit/UI/SHKOAuthView.h
  172. +158 −0 Classes/ShareKit/UI/SHKOAuthView.m
  173. +56 −0 Classes/ShareKit/UI/SHKShareMenu.h
  174. +325 −0 Classes/ShareKit/UI/SHKShareMenu.m
  175. +35 −0 Classes/ShareKit/UI/SHKViewControllerWrapper.h
  176. +38 −0 Classes/ShareKit/UI/SHKViewControllerWrapper.m
  177. +279 −0 MainWindow.xib
  178. +384 −0 RootViewController.xib
  179. +30 −0 ShareKit-Info.plist
  180. +1,469 −0 ShareKit.xcodeproj/nate.mode1v3
  181. +1,472 −0 ShareKit.xcodeproj/nate.pbxuser
  182. +892 −0 ShareKit.xcodeproj/project.pbxproj
  183. +14 −0 ShareKit_Prefix.pch
  184. +17 −0 main.m
View
38 Classes/Example/ExampleShareFile.h
@@ -0,0 +1,38 @@
+//
+// ExampleShareFile.h
+// ShareKit
+//
+// Created by Nathan Weiner on 6/29/10.
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface ExampleShareFile : UIViewController <UIWebViewDelegate>
+{
+ UIWebView *webView;
+}
+
+@property (nonatomic, retain) UIWebView *webView;
+
+@end
View
82 Classes/Example/ExampleShareFile.m
@@ -0,0 +1,82 @@
+//
+// ExampleShareFile.m
+// ShareKit
+//
+// Created by Nathan Weiner on 6/29/10.
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+#import "ExampleShareFile.h"
+#import "SHK.h"
+#import "SHKActionSheet.h"
+
+@implementation ExampleShareFile
+
+@synthesize webView;
+
+- (void)dealloc
+{
+ [webView release];
+ [super dealloc];
+}
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
+ {
+ self.toolbarItems = [NSArray arrayWithObjects:
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)] autorelease],
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
+ nil
+ ];
+ }
+
+ return self;
+}
+
+- (void)loadView
+{
+ self.webView = [[UIWebView alloc] initWithFrame:CGRectZero];
+ webView.delegate = self;
+ webView.scalesPageToFit = YES;
+ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"example.pdf"]]]];
+
+ self.view = webView;
+}
+
+- (void)share
+{
+ NSString *filePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"example.pdf"];
+ NSData *file = [NSData dataWithContentsOfFile:filePath];
+
+ SHKItem *item = [SHKItem file:file filename:@"Awesome.pdf" mimeType:@"application/pdf" title:@"My Awesome PDF"];
+ SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
+ [actionSheet showFromToolbar:self.navigationController.toolbar];
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return YES;
+}
+
+@end
View
38 Classes/Example/ExampleShareImage.h
@@ -0,0 +1,38 @@
+//
+// ExampleShareImage.h
+// ShareKit
+//
+// Created by Nathan Weiner on 6/18/10.
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface ExampleShareImage : UIViewController
+{
+ UIImageView *imageView;
+}
+
+@property (nonatomic, retain) UIImageView *imageView;
+
+@end
View
83 Classes/Example/ExampleShareImage.m
@@ -0,0 +1,83 @@
+ //
+// ExampleShareImage.m
+// ShareKit
+//
+// Created by Nathan Weiner on 6/18/10.
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+#import "ExampleShareImage.h"
+#import "SHKItem.h"
+#import "SHKActionSheet.h"
+
+@implementation ExampleShareImage
+
+@synthesize imageView;
+
+- (void)dealloc
+{
+ [imageView release];
+ [super dealloc];
+}
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
+ {
+ self.toolbarItems = [NSArray arrayWithObjects:
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)] autorelease],
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
+ nil
+ ];
+ }
+
+ return self;
+}
+
+- (void)loadView
+{
+ [super loadView];
+
+ self.imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sanFran.jpg"]];
+
+ imageView.frame = CGRectMake(0,0,self.view.bounds.size.width,self.view.bounds.size.height);
+
+ [self.view addSubview:imageView];
+
+ [imageView release];
+}
+
+- (void)share
+{
+ SHKItem *item = [SHKItem image:imageView.image title:@"San Francisco"];
+ SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
+
+ [actionSheet showFromToolbar:self.navigationController.toolbar];
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return YES;
+}
+
+@end
View
38 Classes/Example/ExampleShareLink.h
@@ -0,0 +1,38 @@
+//
+// ExampleShareLink.h
+// ShareKit
+//
+// Created by Nathan Weiner on 6/17/10.
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface ExampleShareLink : UIViewController <UIWebViewDelegate>
+{
+ UIWebView *webView;
+}
+
+@property (nonatomic, retain) UIWebView *webView;
+
+@end
View
78 Classes/Example/ExampleShareLink.m
@@ -0,0 +1,78 @@
+ //
+// ExampleShareLink.m
+// ShareKit
+//
+// Created by Nathan Weiner on 6/17/10.
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+#import "ExampleShareLink.h"
+#import "SHK.h"
+
+@implementation ExampleShareLink
+
+@synthesize webView;
+
+- (void)dealloc
+{
+ [webView release];
+ [super dealloc];
+}
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
+ {
+ self.toolbarItems = [NSArray arrayWithObjects:
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)] autorelease],
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
+ nil
+ ];
+ }
+
+ return self;
+}
+
+- (void)share
+{
+ SHKItem *item = [SHKItem URL:webView.request.URL title:[webView pageTitle]];
+ SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
+ [actionSheet showFromToolbar:self.navigationController.toolbar];
+}
+
+- (void)loadView
+{
+ self.webView = [[UIWebView alloc] initWithFrame:CGRectZero];
+ webView.delegate = self;
+ webView.scalesPageToFit = YES;
+ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://apple.com/"]]];
+
+ self.view = webView;
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return YES;
+}
+
+@end
View
38 Classes/Example/ExampleShareText.h
@@ -0,0 +1,38 @@
+//
+// ExampleShareText.h
+// ShareKit
+//
+// Created by Nathan Weiner on 6/18/10.
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface ExampleShareText : UIViewController
+{
+ UITextView *textView;
+}
+
+@property (nonatomic, retain) UITextView *textView;
+
+@end
View
91 Classes/Example/ExampleShareText.m
@@ -0,0 +1,91 @@
+ //
+// ExampleShareText.m
+// ShareKit
+//
+// Created by Nathan Weiner on 6/18/10.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#import "ExampleShareText.h"
+#import "SHKItem.h"
+#import "SHKActionSheet.h"
+
+@implementation ExampleShareText
+
+@synthesize textView;
+
+- (void)dealloc
+{
+ [textView release];
+ [super dealloc];
+}
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
+ {
+ self.toolbarItems = [NSArray arrayWithObjects:
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)] autorelease],
+ [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
+ nil
+ ];
+ }
+
+ return self;
+}
+
+- (void)loadView
+{
+ [super loadView];
+
+ self.textView = [[UITextView alloc] initWithFrame:CGRectMake(0,0,self.view.bounds.size.width,self.view.bounds.size.height)];
+ [self.view addSubview:textView];
+
+ textView.text = @"This is a chunk of text. If you highlight it, you'll be able to share the selection. If you tap the share button below, it will share all of it.";
+ textView.editable = NO;
+
+ [textView release];
+}
+
+- (void)share
+{
+ NSString *text;
+
+ if (textView.selectedRange.length > 0)
+ text = [textView.text substringWithRange:textView.selectedRange];
+
+ else
+ text = textView.text;
+
+
+ SHKItem *item = [SHKItem text:text];
+ SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
+
+ [actionSheet showFromToolbar:self.navigationController.toolbar];
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return YES;
+}
+
+
+@end
View
14 Classes/Example/RootViewController.h
@@ -0,0 +1,14 @@
+//
+// RootViewController.h
+// ShareKit
+//
+// Created by Nathan Weiner on 6/4/10.
+// Copyright Idea Shower, LLC 2010. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface RootViewController : UITableViewController {
+}
+
+@end
View
105 Classes/Example/RootViewController.m
@@ -0,0 +1,105 @@
+//
+// RootViewController.m
+// ShareKit
+//
+// Created by Nathan Weiner on 6/4/10.
+// Copyright Idea Shower, LLC 2010. All rights reserved.
+//
+
+#import "RootViewController.h"
+#import "ExampleShareLink.h"
+#import "ExampleShareImage.h"
+#import "ExampleShareText.h"
+#import "ExampleShareFile.h"
+#import "SHK.h"
+
+@implementation RootViewController
+
+#pragma mark -
+#pragma mark Table view data source
+
+
+// Customize the number of sections in the table view.
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+ return 1;
+}
+
+
+// Customize the number of rows in the table view.
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ return 4;
+}
+
+
+// Customize the appearance of table view cells.
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ static NSString *CellIdentifier = @"Cell";
+
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+ if (cell == nil) {
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+ }
+
+ switch (indexPath.row)
+ {
+ case 0:
+ cell.textLabel.text = @"Sharing a Link";
+ break;
+
+ case 1:
+ cell.textLabel.text = @"Sharing an Image";
+ break;
+
+ case 2:
+ cell.textLabel.text = @"Sharing Text";
+ break;
+
+ case 3:
+ cell.textLabel.text = @"Sharing a File";
+ break;
+
+ }
+
+ return cell;
+}
+
+
+#pragma mark -
+#pragma mark Table view delegate
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ switch (indexPath.row)
+ {
+ case 0:
+ [self.navigationController pushViewController:[[[ExampleShareLink alloc] initWithNibName:nil bundle:nil] autorelease] animated:YES];
+ break;
+
+ case 1:
+ [self.navigationController pushViewController:[[[ExampleShareImage alloc] initWithNibName:nil bundle:nil] autorelease] animated:YES];
+ break;
+
+ case 2:
+ [self.navigationController pushViewController:[[[ExampleShareText alloc] initWithNibName:nil bundle:nil] autorelease] animated:YES];
+ break;
+
+ case 3:
+ [self.navigationController pushViewController:[[[ExampleShareFile alloc] initWithNibName:nil bundle:nil] autorelease] animated:YES];
+ break;
+
+
+ }
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return YES;
+}
+
+
+
+
+@end
+
View
21 Classes/Example/ShareKitAppDelegate.h
@@ -0,0 +1,21 @@
+//
+// ShareKitAppDelegate.h
+// ShareKit
+//
+// Created by Nathan Weiner on 6/4/10.
+// Copyright Idea Shower, LLC 2010. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface ShareKitAppDelegate : NSObject <UIApplicationDelegate> {
+
+ UIWindow *window;
+ UINavigationController *navigationController;
+}
+
+@property (nonatomic, retain) IBOutlet UIWindow *window;
+@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
+
+@end
+
View
66 Classes/Example/ShareKitAppDelegate.m
@@ -0,0 +1,66 @@
+//
+// ShareKitAppDelegate.m
+// ShareKit
+//
+// Created by Nathan Weiner on 6/4/10.
+// Copyright Idea Shower, LLC 2010. All rights reserved.
+//
+
+#import "ShareKitAppDelegate.h"
+#import "RootViewController.h"
+
+#import "SHKReadItLater.h"
+#import "SHKFacebook.h"
+
+@implementation ShareKitAppDelegate
+
+@synthesize window;
+@synthesize navigationController;
+
+
+#pragma mark -
+#pragma mark Application lifecycle
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+ // Override point for customization after app launch
+
+ [window addSubview:[navigationController view]];
+ [window makeKeyAndVisible];
+
+ navigationController.topViewController.title = @"Examples";
+ [navigationController setToolbarHidden:NO];
+
+ [self performSelector:@selector(test) withObject:nil afterDelay:0.5];
+
+ return YES;
+}
+
+- (void)test
+{
+ [SHK flushOfflineQueue];
+ //[SHKFacebook shareURL:[NSURL URLWithString:@"http://ideashower.com"]];
+}
+
+- (void)test2
+{
+ [[SHKActivityIndicator currentIndicator] displayCompleted:@"Saved!"];
+}
+
+
+- (void)applicationWillTerminate:(UIApplication *)application {
+ // Save data if appropriate
+}
+
+
+#pragma mark -
+#pragma mark Memory management
+
+- (void)dealloc {
+ [navigationController release];
+ [window release];
+ [super dealloc];
+}
+
+
+@end
+
View
BIN  Classes/Example/example.pdf
Binary file not shown
View
BIN  Classes/Example/sanFran.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
35 Classes/OAuth/Categories/NSMutableURLRequest+Parameters.h
@@ -0,0 +1,35 @@
+//
+// NSMutableURLRequest+Parameters.h
+//
+// Created by Jon Crosby on 10/19/07.
+// Copyright 2007 Kaboomerang LLC. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+#import "OARequestParameter.h"
+#import "NSURL+Base.h"
+
+
+@interface NSMutableURLRequest (OAParameterAdditions)
+
+- (NSArray *)parameters;
+- (void)setParameters:(NSArray *)parameters;
+
+@end
View
97 Classes/OAuth/Categories/NSMutableURLRequest+Parameters.m
@@ -0,0 +1,97 @@
+//
+// NSMutableURLRequest+Parameters.m
+//
+// Created by Jon Crosby on 10/19/07.
+// Copyright 2007 Kaboomerang LLC. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+#import "NSMutableURLRequest+Parameters.h"
+
+
+@implementation NSMutableURLRequest (OAParameterAdditions)
+
+- (NSArray *)parameters
+{
+ NSString *encodedParameters;
+ BOOL shouldfree = NO;
+
+ if ([[self HTTPMethod] isEqualToString:@"GET"] || [[self HTTPMethod] isEqualToString:@"DELETE"])
+ encodedParameters = [[self URL] query];
+ else
+ {
+ // POST, PUT
+ shouldfree = YES;
+ encodedParameters = [[NSString alloc] initWithData:[self HTTPBody] encoding:NSASCIIStringEncoding];
+ }
+
+ if ((encodedParameters == nil) || ([encodedParameters isEqualToString:@""]))
+ {
+ if (shouldfree)
+ [encodedParameters release];
+
+ return nil;
+ }
+
+ NSArray *encodedParameterPairs = [encodedParameters componentsSeparatedByString:@"&"];
+ NSMutableArray *requestParameters = [[[NSMutableArray alloc] initWithCapacity:16] autorelease];
+
+ for (NSString *encodedPair in encodedParameterPairs)
+ {
+ NSArray *encodedPairElements = [encodedPair componentsSeparatedByString:@"="];
+ OARequestParameter *parameter = [OARequestParameter requestParameterWithName:[[encodedPairElements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
+ value:[[encodedPairElements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
+ [requestParameters addObject:parameter];
+ }
+
+ // Cleanup
+ if (shouldfree)
+ [encodedParameters release];
+
+ return requestParameters;
+}
+
+- (void)setParameters:(NSArray *)parameters
+{
+ NSMutableString *encodedParameterPairs = [NSMutableString stringWithCapacity:256];
+
+ int position = 1;
+ for (OARequestParameter *requestParameter in parameters)
+ {
+ [encodedParameterPairs appendString:[requestParameter URLEncodedNameValuePair]];
+ if (position < [parameters count])
+ [encodedParameterPairs appendString:@"&"];
+
+ position++;
+ }
+
+ if ([[self HTTPMethod] isEqualToString:@"GET"] || [[self HTTPMethod] isEqualToString:@"DELETE"])
+ [self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@", [[self URL] URLStringWithoutQuery], encodedParameterPairs]]];
+ else
+ {
+ // POST, PUT
+ NSData *postData = [encodedParameterPairs dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
+ [self setHTTPBody:postData];
+ [self setValue:[NSString stringWithFormat:@"%d", [postData length]] forHTTPHeaderField:@"Content-Length"];
+ [self setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
+ }
+}
+
+@end
View
34 Classes/OAuth/Categories/NSString+URLEncoding.h
@@ -0,0 +1,34 @@
+//
+// NSString+URLEncoding.h
+//
+// Created by Jon Crosby on 10/19/07.
+// Copyright 2007 Kaboomerang LLC. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+#import <Foundation/Foundation.h>
+
+
+@interface NSString (OAURLEncodingAdditions)
+
+- (NSString *)URLEncodedString;
+- (NSString *)URLDecodedString;
+
+@end
View
52 Classes/OAuth/Categories/NSString+URLEncoding.m
@@ -0,0 +1,52 @@
+//
+// NSString+URLEncoding.m
+//
+// Created by Jon Crosby on 10/19/07.
+// Copyright 2007 Kaboomerang LLC. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+#import "NSString+URLEncoding.h"
+
+
+@implementation NSString (OAURLEncodingAdditions)
+
+- (NSString *)URLEncodedString
+{
+ NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
+ (CFStringRef)self,
+ NULL,
+ CFSTR("!*'();:@&=+$,/?%#[]"),
+ kCFStringEncodingUTF8);
+ [result autorelease];
+ return result;
+}
+
+- (NSString*)URLDecodedString
+{
+ NSString *result = (NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
+ (CFStringRef)self,
+ CFSTR(""),
+ kCFStringEncodingUTF8);
+ [result autorelease];
+ return result;
+}
+
+@end
View
34 Classes/OAuth/Categories/NSURL+Base.h
@@ -0,0 +1,34 @@
+//
+// NSURL+Base.h
+// OAuthConsumer
+//
+// Created by Jon Crosby on 10/19/07.
+// Copyright 2007 Kaboomerang LLC. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+#import <Foundation/Foundation.h>
+
+
+@interface NSURL (OABaseAdditions)
+
+- (NSString *)URLStringWithoutQuery;
+
+@end
View
38 Classes/OAuth/Categories/NSURL+Base.m
@@ -0,0 +1,38 @@
+//
+// NSURL+Base.m
+// OAuthConsumer
+//
+// Created by Jon Crosby on 10/19/07.
+// Copyright 2007 Kaboomerang LLC. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+#import "NSURL+Base.h"
+
+
+@implementation NSURL (OABaseAdditions)
+
+- (NSString *)URLStringWithoutQuery
+{
+ NSArray *parts = [[self absoluteString] componentsSeparatedByString:@"?"];
+ return [parts objectAtIndex:0];
+}
+
+@end
View
230 Classes/OAuth/Crytpo/Base64Transcoder.c
@@ -0,0 +1,230 @@
+/*
+ * Base64Transcoder.c
+ * Base64Test
+ *
+ * Created by Jonathan Wight on Tue Mar 18 2003.
+ * Copyright (c) 2003 Toxic Software. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#include "Base64Transcoder.h"
+
+#include <math.h>
+#include <string.h>
+
+const u_int8_t kBase64EncodeTable[64] = {
+ /* 0 */ 'A', /* 1 */ 'B', /* 2 */ 'C', /* 3 */ 'D',
+ /* 4 */ 'E', /* 5 */ 'F', /* 6 */ 'G', /* 7 */ 'H',
+ /* 8 */ 'I', /* 9 */ 'J', /* 10 */ 'K', /* 11 */ 'L',
+ /* 12 */ 'M', /* 13 */ 'N', /* 14 */ 'O', /* 15 */ 'P',
+ /* 16 */ 'Q', /* 17 */ 'R', /* 18 */ 'S', /* 19 */ 'T',
+ /* 20 */ 'U', /* 21 */ 'V', /* 22 */ 'W', /* 23 */ 'X',
+ /* 24 */ 'Y', /* 25 */ 'Z', /* 26 */ 'a', /* 27 */ 'b',
+ /* 28 */ 'c', /* 29 */ 'd', /* 30 */ 'e', /* 31 */ 'f',
+ /* 32 */ 'g', /* 33 */ 'h', /* 34 */ 'i', /* 35 */ 'j',
+ /* 36 */ 'k', /* 37 */ 'l', /* 38 */ 'm', /* 39 */ 'n',
+ /* 40 */ 'o', /* 41 */ 'p', /* 42 */ 'q', /* 43 */ 'r',
+ /* 44 */ 's', /* 45 */ 't', /* 46 */ 'u', /* 47 */ 'v',
+ /* 48 */ 'w', /* 49 */ 'x', /* 50 */ 'y', /* 51 */ 'z',
+ /* 52 */ '0', /* 53 */ '1', /* 54 */ '2', /* 55 */ '3',
+ /* 56 */ '4', /* 57 */ '5', /* 58 */ '6', /* 59 */ '7',
+ /* 60 */ '8', /* 61 */ '9', /* 62 */ '+', /* 63 */ '/'
+};
+
+/*
+-1 = Base64 end of data marker.
+-2 = White space (tabs, cr, lf, space)
+-3 = Noise (all non whitespace, non-base64 characters)
+-4 = Dangerous noise
+-5 = Illegal noise (null byte)
+*/
+
+const int8_t kBase64DecodeTable[128] = {
+ /* 0x00 */ -5, /* 0x01 */ -3, /* 0x02 */ -3, /* 0x03 */ -3,
+ /* 0x04 */ -3, /* 0x05 */ -3, /* 0x06 */ -3, /* 0x07 */ -3,
+ /* 0x08 */ -3, /* 0x09 */ -2, /* 0x0a */ -2, /* 0x0b */ -2,
+ /* 0x0c */ -2, /* 0x0d */ -2, /* 0x0e */ -3, /* 0x0f */ -3,
+ /* 0x10 */ -3, /* 0x11 */ -3, /* 0x12 */ -3, /* 0x13 */ -3,
+ /* 0x14 */ -3, /* 0x15 */ -3, /* 0x16 */ -3, /* 0x17 */ -3,
+ /* 0x18 */ -3, /* 0x19 */ -3, /* 0x1a */ -3, /* 0x1b */ -3,
+ /* 0x1c */ -3, /* 0x1d */ -3, /* 0x1e */ -3, /* 0x1f */ -3,
+ /* ' ' */ -2, /* '!' */ -3, /* '"' */ -3, /* '#' */ -3,
+ /* '$' */ -3, /* '%' */ -3, /* '&' */ -3, /* ''' */ -3,
+ /* '(' */ -3, /* ')' */ -3, /* '*' */ -3, /* '+' */ 62,
+ /* ',' */ -3, /* '-' */ -3, /* '.' */ -3, /* '/' */ 63,
+ /* '0' */ 52, /* '1' */ 53, /* '2' */ 54, /* '3' */ 55,
+ /* '4' */ 56, /* '5' */ 57, /* '6' */ 58, /* '7' */ 59,
+ /* '8' */ 60, /* '9' */ 61, /* ':' */ -3, /* ';' */ -3,
+ /* '<' */ -3, /* '=' */ -1, /* '>' */ -3, /* '?' */ -3,
+ /* '@' */ -3, /* 'A' */ 0, /* 'B' */ 1, /* 'C' */ 2,
+ /* 'D' */ 3, /* 'E' */ 4, /* 'F' */ 5, /* 'G' */ 6,
+ /* 'H' */ 7, /* 'I' */ 8, /* 'J' */ 9, /* 'K' */ 10,
+ /* 'L' */ 11, /* 'M' */ 12, /* 'N' */ 13, /* 'O' */ 14,
+ /* 'P' */ 15, /* 'Q' */ 16, /* 'R' */ 17, /* 'S' */ 18,
+ /* 'T' */ 19, /* 'U' */ 20, /* 'V' */ 21, /* 'W' */ 22,
+ /* 'X' */ 23, /* 'Y' */ 24, /* 'Z' */ 25, /* '[' */ -3,
+ /* '\' */ -3, /* ']' */ -3, /* '^' */ -3, /* '_' */ -3,
+ /* '`' */ -3, /* 'a' */ 26, /* 'b' */ 27, /* 'c' */ 28,
+ /* 'd' */ 29, /* 'e' */ 30, /* 'f' */ 31, /* 'g' */ 32,
+ /* 'h' */ 33, /* 'i' */ 34, /* 'j' */ 35, /* 'k' */ 36,
+ /* 'l' */ 37, /* 'm' */ 38, /* 'n' */ 39, /* 'o' */ 40,
+ /* 'p' */ 41, /* 'q' */ 42, /* 'r' */ 43, /* 's' */ 44,
+ /* 't' */ 45, /* 'u' */ 46, /* 'v' */ 47, /* 'w' */ 48,
+ /* 'x' */ 49, /* 'y' */ 50, /* 'z' */ 51, /* '{' */ -3,
+ /* '|' */ -3, /* '}' */ -3, /* '~' */ -3, /* 0x7f */ -3
+};
+
+const u_int8_t kBits_00000011 = 0x03;
+const u_int8_t kBits_00001111 = 0x0F;
+const u_int8_t kBits_00110000 = 0x30;
+const u_int8_t kBits_00111100 = 0x3C;
+const u_int8_t kBits_00111111 = 0x3F;
+const u_int8_t kBits_11000000 = 0xC0;
+const u_int8_t kBits_11110000 = 0xF0;
+const u_int8_t kBits_11111100 = 0xFC;
+
+size_t EstimateBas64EncodedDataSize(size_t inDataSize)
+{
+size_t theEncodedDataSize = (int)ceil(inDataSize / 3.0) * 4;
+theEncodedDataSize = theEncodedDataSize / 72 * 74 + theEncodedDataSize % 72;
+return(theEncodedDataSize);
+}
+
+size_t EstimateBas64DecodedDataSize(size_t inDataSize)
+{
+size_t theDecodedDataSize = (int)ceil(inDataSize / 4.0) * 3;
+//theDecodedDataSize = theDecodedDataSize / 72 * 74 + theDecodedDataSize % 72;
+return(theDecodedDataSize);
+}
+
+bool Base64EncodeData(const void *inInputData, size_t inInputDataSize, char *outOutputData, size_t *ioOutputDataSize)
+{
+size_t theEncodedDataSize = EstimateBas64EncodedDataSize(inInputDataSize);
+if (*ioOutputDataSize < theEncodedDataSize)
+ return(false);
+*ioOutputDataSize = theEncodedDataSize;
+const u_int8_t *theInPtr = (const u_int8_t *)inInputData;
+u_int32_t theInIndex = 0, theOutIndex = 0;
+for (; theInIndex < (inInputDataSize / 3) * 3; theInIndex += 3)
+ {
+ outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_11111100) >> 2];
+ outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_00000011) << 4 | (theInPtr[theInIndex + 1] & kBits_11110000) >> 4];
+ outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex + 1] & kBits_00001111) << 2 | (theInPtr[theInIndex + 2] & kBits_11000000) >> 6];
+ outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex + 2] & kBits_00111111) >> 0];
+ if (theOutIndex % 74 == 72)
+ {
+ outOutputData[theOutIndex++] = '\r';
+ outOutputData[theOutIndex++] = '\n';
+ }
+ }
+const size_t theRemainingBytes = inInputDataSize - theInIndex;
+if (theRemainingBytes == 1)
+ {
+ outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_11111100) >> 2];
+ outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_00000011) << 4 | (0 & kBits_11110000) >> 4];
+ outOutputData[theOutIndex++] = '=';
+ outOutputData[theOutIndex++] = '=';
+ if (theOutIndex % 74 == 72)
+ {
+ outOutputData[theOutIndex++] = '\r';
+ outOutputData[theOutIndex++] = '\n';
+ }
+ }
+else if (theRemainingBytes == 2)
+ {
+ outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_11111100) >> 2];
+ outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_00000011) << 4 | (theInPtr[theInIndex + 1] & kBits_11110000) >> 4];
+ outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex + 1] & kBits_00001111) << 2 | (0 & kBits_11000000) >> 6];
+ outOutputData[theOutIndex++] = '=';
+ if (theOutIndex % 74 == 72)
+ {
+ outOutputData[theOutIndex++] = '\r';
+ outOutputData[theOutIndex++] = '\n';
+ }
+ }
+return(true);
+}
+
+bool Base64DecodeData(const void *inInputData, size_t inInputDataSize, void *ioOutputData, size_t *ioOutputDataSize)
+{
+memset(ioOutputData, '.', *ioOutputDataSize);
+
+size_t theDecodedDataSize = EstimateBas64DecodedDataSize(inInputDataSize);
+if (*ioOutputDataSize < theDecodedDataSize)
+ return(false);
+*ioOutputDataSize = 0;
+const u_int8_t *theInPtr = (const u_int8_t *)inInputData;
+u_int8_t *theOutPtr = (u_int8_t *)ioOutputData;
+size_t theInIndex = 0, theOutIndex = 0;
+u_int8_t theOutputOctet;
+size_t theSequence = 0;
+for (; theInIndex < inInputDataSize; )
+ {
+ int8_t theSextet = 0;
+
+ int8_t theCurrentInputOctet = theInPtr[theInIndex];
+ theSextet = kBase64DecodeTable[theCurrentInputOctet];
+ if (theSextet == -1)
+ break;
+ while (theSextet == -2)
+ {
+ theCurrentInputOctet = theInPtr[++theInIndex];
+ theSextet = kBase64DecodeTable[theCurrentInputOctet];
+ }
+ while (theSextet == -3)
+ {
+ theCurrentInputOctet = theInPtr[++theInIndex];
+ theSextet = kBase64DecodeTable[theCurrentInputOctet];
+ }
+ if (theSequence == 0)
+ {
+ theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 2 & kBits_11111100;
+ }
+ else if (theSequence == 1)
+ {
+ theOutputOctet |= (theSextet >- 0 ? theSextet : 0) >> 4 & kBits_00000011;
+ theOutPtr[theOutIndex++] = theOutputOctet;
+ }
+ else if (theSequence == 2)
+ {
+ theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 4 & kBits_11110000;
+ }
+ else if (theSequence == 3)
+ {
+ theOutputOctet |= (theSextet >= 0 ? theSextet : 0) >> 2 & kBits_00001111;
+ theOutPtr[theOutIndex++] = theOutputOctet;
+ }
+ else if (theSequence == 4)
+ {
+ theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 6 & kBits_11000000;
+ }
+ else if (theSequence == 5)
+ {
+ theOutputOctet |= (theSextet >= 0 ? theSextet : 0) >> 0 & kBits_00111111;
+ theOutPtr[theOutIndex++] = theOutputOctet;
+ }
+ theSequence = (theSequence + 1) % 6;
+ if (theSequence != 2 && theSequence != 4)
+ theInIndex++;
+ }
+*ioOutputDataSize = theOutIndex;
+return(true);
+}
View
36 Classes/OAuth/Crytpo/Base64Transcoder.h
@@ -0,0 +1,36 @@
+/*
+ * Base64Transcoder.h
+ * Base64Test
+ *
+ * Created by Jonathan Wight on Tue Mar 18 2003.
+ * Copyright (c) 2003 Toxic Software. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdbool.h>
+
+extern size_t EstimateBas64EncodedDataSize(size_t inDataSize);
+extern size_t EstimateBas64DecodedDataSize(size_t inDataSize);
+
+extern bool Base64EncodeData(const void *inInputData, size_t inInputDataSize, char *outOutputData, size_t *ioOutputDataSize);
+extern bool Base64DecodeData(const void *inInputData, size_t inInputDataSize, void *ioOutputData, size_t *ioOutputDataSize);
+
View
86 Classes/OAuth/Crytpo/hmac.c
@@ -0,0 +1,86 @@
+//
+// hmac.c
+// OAuthConsumer
+//
+// Created by Jonathan Wight on 4/8/8.
+// Copyright 2008 Jonathan Wight. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+/*
+ * Implementation of HMAC-SHA1. Adapted from example at http://tools.ietf.org/html/rfc2104
+
+ */
+
+#include "sha1.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+void hmac_sha1(const unsigned char *inText, size_t inTextLength, unsigned char* inKey, size_t inKeyLength, unsigned char *outDigest)
+{
+const size_t B = 64;
+const size_t L = 20;
+
+SHA1_CTX theSHA1Context;
+unsigned char k_ipad[B + 1]; /* inner padding - key XORd with ipad */
+unsigned char k_opad[B + 1]; /* outer padding - key XORd with opad */
+
+/* if key is longer than 64 bytes reset it to key=SHA1 (key) */
+if (inKeyLength > B)
+ {
+ SHA1Init(&theSHA1Context);
+ SHA1Update(&theSHA1Context, inKey, inKeyLength);
+ SHA1Final(inKey, &theSHA1Context);
+ inKeyLength = L;
+ }
+
+/* start out by storing key in pads */
+memset(k_ipad, 0, sizeof k_ipad);
+memset(k_opad, 0, sizeof k_opad);
+memcpy(k_ipad, inKey, inKeyLength);
+memcpy(k_opad, inKey, inKeyLength);
+
+/* XOR key with ipad and opad values */
+int i;
+for (i = 0; i < B; i++)
+ {
+ k_ipad[i] ^= 0x36;
+ k_opad[i] ^= 0x5c;
+ }
+
+/*
+* perform inner SHA1
+*/
+SHA1Init(&theSHA1Context); /* init context for 1st pass */
+SHA1Update(&theSHA1Context, k_ipad, B); /* start with inner pad */
+SHA1Update(&theSHA1Context, (unsigned char *)inText, inTextLength); /* then text of datagram */
+SHA1Final((unsigned char *)outDigest, &theSHA1Context); /* finish up 1st pass */
+
+/*
+* perform outer SHA1
+*/
+SHA1Init(&theSHA1Context); /* init context for 2nd
+* pass */
+SHA1Update(&theSHA1Context, k_opad, B); /* start with outer pad */
+SHA1Update(&theSHA1Context, outDigest, L); /* then results of 1st
+* hash */
+SHA1Final(outDigest, &theSHA1Context); /* finish up 2nd pass */
+
+}
View
31 Classes/OAuth/Crytpo/hmac.h
@@ -0,0 +1,31 @@
+//
+// hmac.h
+// OAuthConsumer
+//
+// Created by Jonathan Wight on 4/8/8.
+// Copyright 2008 Jonathan Wight. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#ifndef HMAC_H
+#define HMAC_H 1
+
+extern void hmac_sha1(const unsigned char *inText, int inTextLength, unsigned char* inKey, const unsigned int inKeyLength, unsigned char *outDigest);
+
+#endif /* HMAC_H */
View
169 Classes/OAuth/Crytpo/sha1.c
@@ -0,0 +1,169 @@
+/*
+SHA-1 in C
+By Steve Reid <steve@edmweb.com>
+100% Public Domain
+
+Test Vectors (from FIPS PUB 180-1)
+"abc"
+ A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+A million repetitions of "a"
+ 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+*/
+
+/* #define LITTLE_ENDIAN * This should be #define'd if true. */
+#if __LITTLE_ENDIAN__
+#define LITTLE_ENDIAN
+#endif
+/* #define SHA1HANDSOFF * Copies data before messing with it. */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "sha1.h"
+
+void SHA1Transform(unsigned long state[5], unsigned char buffer[64]);
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/* blk0() and blk() perform the initial expand. */
+/* I got the idea of expanding during the round function from SSLeay */
+#ifdef LITTLE_ENDIAN
+#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+ |(rol(block->l[i],8)&0x00FF00FF))
+#else
+#define blk0(i) block->l[i]
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+ ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+
+/* Hash a single 512-bit block. This is the core of the algorithm. */
+
+void SHA1Transform(unsigned long state[5], unsigned char buffer[64])
+{
+unsigned long a, b, c, d, e;
+typedef union {
+ unsigned char c[64];
+ unsigned long l[16];
+} CHAR64LONG16;
+CHAR64LONG16* block;
+#ifdef SHA1HANDSOFF
+static unsigned char workspace[64];
+ block = (CHAR64LONG16*)workspace;
+ memcpy(block, buffer, 64);
+#else
+ block = (CHAR64LONG16*)buffer;
+#endif
+ /* Copy context->state[] to working vars */
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+ /* 4 rounds of 20 operations each. Loop unrolled. */
+ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+ R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+ R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+ R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+ /* Add the working vars back into context.state[] */
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+ /* Wipe variables */
+ a = b = c = d = e = 0;
+}
+
+
+/* SHA1Init - Initialize new context */
+
+void SHA1Init(SHA1_CTX* context)
+{
+ /* SHA1 initialization constants */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xEFCDAB89;
+ context->state[2] = 0x98BADCFE;
+ context->state[3] = 0x10325476;
+ context->state[4] = 0xC3D2E1F0;
+ context->count[0] = context->count[1] = 0;
+}
+
+
+/* Run your data through this. */
+
+void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len)
+{
+unsigned int i, j;
+
+ j = (context->count[0] >> 3) & 63;
+ if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++;
+ context->count[1] += (len >> 29);
+ if ((j + len) > 63) {
+ memcpy(&context->buffer[j], data, (i = 64-j));
+ SHA1Transform(context->state, context->buffer);
+ for ( ; i + 63 < len; i += 64) {
+ SHA1Transform(context->state, &data[i]);
+ }
+ j = 0;
+ }
+ else i = 0;
+ memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+
+/* Add padding and return the message digest. */
+
+void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
+{
+unsigned long i, j;
+unsigned char finalcount[8];
+
+ for (i = 0; i < 8; i++) {
+ finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
+ >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
+ }
+ SHA1Update(context, (unsigned char *)"\200", 1);
+ while ((context->count[0] & 504) != 448) {
+ SHA1Update(context, (unsigned char *)"\0", 1);
+ }
+ SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
+ for (i = 0; i < 20; i++) {
+ digest[i] = (unsigned char)
+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+ }
+ /* Wipe variables */
+ i = j = 0;
+ memset(context->buffer, 0, 64);
+ memset(context->state, 0, 20);
+ memset(context->count, 0, 8);
+ memset(&finalcount, 0, 8);
+#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */
+ SHA1Transform(context->state, context->buffer);
+#endif
+}
View
12 Classes/OAuth/Crytpo/sha1.h
@@ -0,0 +1,12 @@
+
+// From http://www.mirrors.wiretapped.net/security/cryptography/hashes/sha1/sha1.c
+
+typedef struct {
+ unsigned long state[5];
+ unsigned long count[2];
+ unsigned char buffer[64];
+} SHA1_CTX;
+
+extern void SHA1Init(SHA1_CTX* context);
+extern void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len);
+extern void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
View
45 Classes/OAuth/OAAsynchronousDataFetcher.h
@@ -0,0 +1,45 @@
+//
+// OAAsynchronousDataFetcher.h
+// OAuthConsumer
+//
+// Created by Zsombor Szabó on 12/3/08.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+
+#import "OAMutableURLRequest.h"
+
+@interface OAAsynchronousDataFetcher : NSObject {
+ OAMutableURLRequest *request;
+ NSHTTPURLResponse *response;
+ NSURLConnection *connection;
+ NSMutableData *responseData;
+ id delegate;
+ SEL didFinishSelector;
+ SEL didFailSelector;
+}
+
++ (id)asynchronousFetcherWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector;
+- (id)initWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector;
+
+- (void)start;
+- (void)cancel;
+
+@end
View
134 Classes/OAuth/OAAsynchronousDataFetcher.m
@@ -0,0 +1,134 @@
+//
+// OAAsynchronousDataFetcher.m
+// OAuthConsumer
+//
+// Created by Zsombor Szabó on 12/3/08.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "OAAsynchronousDataFetcher.h"
+
+#import "OAServiceTicket.h"
+
+@implementation OAAsynchronousDataFetcher
+
++ (id)asynchronousFetcherWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector
+{
+ return [[[OAAsynchronousDataFetcher alloc] initWithRequest:aRequest delegate:aDelegate didFinishSelector:finishSelector didFailSelector:failSelector] autorelease];
+}
+
+- (id)initWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector
+{
+ if (self = [super init])
+ {
+ request = [aRequest retain];
+ delegate = aDelegate;
+ didFinishSelector = finishSelector;
+ didFailSelector = failSelector;
+ }
+ return self;
+}
+
+- (void)start
+{
+ [request prepare];
+
+ if (connection)
+ [connection release];
+
+ connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
+
+ if (connection)
+ {
+ if (responseData)
+ [responseData release];
+ responseData = [[NSMutableData data] retain];
+ }
+ else
+ {
+ OAServiceTicket *ticket= [[OAServiceTicket alloc] initWithRequest:request
+ response:nil
+ didSucceed:NO];
+ [delegate performSelector:didFailSelector
+ withObject:ticket
+ withObject:nil];
+ [ticket release];
+ }
+}
+
+- (void)cancel
+{
+ if (connection)
+ {
+ [connection cancel];
+ [connection release];
+ connection = nil;
+ }
+}
+
+- (void)dealloc
+{
+ if (request) [request release];
+ if (connection) [connection release];
+ if (response) [response release];
+ if (responseData) [responseData release];
+ [super dealloc];
+}
+
+#pragma mark -
+#pragma mark NSURLConnection methods
+
+- (void)connection:(NSURLConnection *)aConnection didReceiveResponse:(NSURLResponse *)aResponse
+{
+ if (response)
+ [response release];
+ response = [aResponse retain];
+ [responseData setLength:0];
+}
+
+- (void)connection:(NSURLConnection *)aConnection didReceiveData:(NSData *)data
+{
+ [responseData appendData:data];
+}
+
+- (void)connection:(NSURLConnection *)aConnection didFailWithError:(NSError *)error
+{
+ OAServiceTicket *ticket= [[OAServiceTicket alloc] initWithRequest:request
+ response:response
+ didSucceed:NO];
+ [delegate performSelector:didFailSelector
+ withObject:ticket
+ withObject:error];
+
+ [ticket release];
+}
+
+- (void)connectionDidFinishLoading:(NSURLConnection *)aConnection
+{
+ OAServiceTicket *ticket = [[OAServiceTicket alloc] initWithRequest:request
+ response:response
+ didSucceed:[(NSHTTPURLResponse *)response statusCode] < 400];
+ [delegate performSelector:didFinishSelector
+ withObject:ticket
+ withObject:responseData];
+
+ [ticket release];
+}
+
+@end
View
40 Classes/OAuth/OAConsumer.h
@@ -0,0 +1,40 @@
+//
+// OAConsumer.h
+// OAuthConsumer
+//
+// Created by Jon Crosby on 10/19/07.
+// Copyright 2007 Kaboomerang LLC. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+#import <Foundation/Foundation.h>
+
+
+@interface OAConsumer : NSObject {
+@protected
+ NSString *key;
+ NSString *secret;
+}
+@property(retain) NSString *key;
+@property(retain) NSString *secret;
+
+- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret;
+
+@end
View
51 Classes/OAuth/OAConsumer.m
@@ -0,0 +1,51 @@
+//
+// OAConsumer.m
+// OAuthConsumer
+//
+// Created by Jon Crosby on 10/19/07.
+// Copyright 2007 Kaboomerang LLC. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "OAConsumer.h"
+
+
+@implementation OAConsumer
+@synthesize key, secret;
+
+#pragma mark init
+
+- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret
+{
+ if (self = [super init])
+ {
+ self.key = aKey;
+ self.secret = aSecret;
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [key release];
+ [secret release];
+ [super dealloc];
+}
+
+@end
View
45 Classes/OAuth/OADataFetcher.h
@@ -0,0 +1,45 @@
+//
+// OADataFetcher.h
+// OAuthConsumer
+//
+// Created by Jon Crosby on 11/5/07.
+// Copyright 2007 Kaboomerang LLC. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+#import "OAMutableURLRequest.h"
+#import "OAServiceTicket.h"
+
+
+@interface OADataFetcher : NSObject {
+@private
+ OAMutableURLRequest *request;
+ NSHTTPURLResponse *response;
+ NSURLConnection *connection;
+ NSError *error;
+ NSData *responseData;
+ id delegate;
+ SEL didFinishSelector;
+ SEL didFailSelector;
+}
+
+- (void)fetchDataWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector;
+
+@end
View
65 Classes/OAuth/OADataFetcher.m
@@ -0,0 +1,65 @@
+//
+// OADataFetcher.m
+// OAuthConsumer
+//
+// Created by Jon Crosby on 11/5/07.
+// Copyright 2007 Kaboomerang LLC. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+#import "OADataFetcher.h"
+
+
+@implementation OADataFetcher
+
+- (void)fetchDataWithRequest:(OAMutableURLRequest *)aRequest
+ delegate:(id)aDelegate
+ didFinishSelector:(SEL)finishSelector
+ didFailSelector:(SEL)failSelector
+{
+ request = aRequest;
+ delegate = aDelegate;
+ didFinishSelector = finishSelector;
+ didFailSelector = failSelector;
+
+ [request prepare];
+
+ responseData = [NSURLConnection sendSynchronousRequest:request
+ returningResponse:&response
+ error:&error];
+
+ if (response == nil || responseData == nil || error != nil) {
+ OAServiceTicket *ticket= [[OAServiceTicket alloc] initWithRequest:request
+ response:response
+ didSucceed:NO];
+ [delegate performSelector:didFailSelector
+ withObject:ticket
+ withObject:error];
+ } else {
+ OAServiceTicket *ticket = [[OAServiceTicket alloc] initWithRequest:request
+ response:response
+ didSucceed:[(NSHTTPURLResponse *)response statusCode] < 400];
+ [delegate performSelector:didFinishSelector
+ withObject:ticket
+ withObject:responseData];
+ }
+}
+
+@end
View
32 Classes/OAuth/OAHMAC_SHA1SignatureProvider.h
@@ -0,0 +1,32 @@
+//
+// OAHMAC_SHA1SignatureProvider.h
+// OAuthConsumer
+//
+// Created by Jon Crosby on 10/19/07.
+// Copyright 2007 Kaboomerang LLC. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+
+#import <Foundation/Foundation.h>
+#import "OASignatureProviding.h"
+
+
+@interface OAHMAC_SHA1SignatureProvider : NSObject <OASignatureProviding>
+@end
View
58 Classes/OAuth/OAHMAC_SHA1SignatureProvider.m
@@ -0,0 +1,58 @@
+//
+// OAHMAC_SHA1SignatureProvider.m
+// OAuthConsumer
+//
+// Created by Jon Crosby on 10/19/07.
+// Copyright 2007 Kaboomerang LLC. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE