Permalink
Browse files

Initial commit, hooray!

  • Loading branch information...
minddog
minddog committed Feb 17, 2011
0 parents commit e21e5622b900bedff33a022ca859e51fc2ac223e
Showing with 30,289 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +740 −0 Classes/FolderListController.xib
  3. +912 −0 Classes/MessageDetailController.xib
  4. +663 −0 Classes/MessageListController.xib
  5. +33 −0 Classes/NSData+Base64.h
  6. +298 −0 Classes/NSData+Base64.m
  7. +142 −0 Classes/NSExtensions.h
  8. +311 −0 Classes/NSExtensions.m
  9. +103 −0 Classes/NSURLExtensions.h
  10. +216 −0 Classes/NSURLExtensions.m
  11. +41 −0 Classes/SFHFKeychainUtils.h
  12. +434 −0 Classes/SFHFKeychainUtils.m
  13. +635 −0 Classes/TextEntryController.xib
  14. +70 −0 Classes/UIExtensions.h
  15. +142 −0 Classes/UIExtensions.m
  16. +41 −0 Classes/UIViewPositioningExtension.h
  17. +129 −0 Classes/UIViewPositioningExtension.m
  18. +35 −0 Classes/VBXActivityLabel.h
  19. +86 −0 Classes/VBXActivityLabel.m
  20. +51 −0 Classes/VBXAnnotation.h
  21. +79 −0 Classes/VBXAnnotation.m
  22. +50 −0 Classes/VBXAppDelegate.h
  23. +512 −0 Classes/VBXAppDelegate.m
  24. +40 −0 Classes/VBXAppURL.h
  25. +166 −0 Classes/VBXAppURL.m
  26. +49 −0 Classes/VBXAudioControl.h
  27. +182 −0 Classes/VBXAudioControl.m
  28. +82 −0 Classes/VBXAudioPlaybackController.h
  29. +330 −0 Classes/VBXAudioPlaybackController.m
  30. +32 −0 Classes/VBXButtonCell.h
  31. +58 −0 Classes/VBXButtonCell.m
  32. +44 −0 Classes/VBXCache.h
  33. +349 −0 Classes/VBXCache.m
  34. +34 −0 Classes/VBXCallerIdController.h
  35. +118 −0 Classes/VBXCallerIdController.m
  36. +34 −0 Classes/VBXCellDataSource.h
  37. +57 −0 Classes/VBXCellDataSource.m
  38. +47 −0 Classes/VBXConfigAccessor.h
  39. +91 −0 Classes/VBXConfigAccessor.m
  40. +78 −0 Classes/VBXConfiguration.h
  41. +304 −0 Classes/VBXConfiguration.m
  42. +34 −0 Classes/VBXDataSource.h
  43. +130 −0 Classes/VBXDataSource.m
  44. +61 −0 Classes/VBXDialerAccessor.h
  45. +127 −0 Classes/VBXDialerAccessor.m
  46. +60 −0 Classes/VBXDialerController.h
  47. +969 −0 Classes/VBXDialerController.m
  48. +30 −0 Classes/VBXDimOverlay.h
  49. +72 −0 Classes/VBXDimOverlay.m
  50. +48 −0 Classes/VBXFolderDetail.h
  51. +58 −0 Classes/VBXFolderDetail.m
  52. +32 −0 Classes/VBXFolderList.h
  53. +42 −0 Classes/VBXFolderList.m
  54. +50 −0 Classes/VBXFolderListAccessor.h
  55. +67 −0 Classes/VBXFolderListAccessor.m
  56. +44 −0 Classes/VBXFolderListCell.h
  57. +240 −0 Classes/VBXFolderListCell.m
  58. +58 −0 Classes/VBXFolderListController.h
  59. +293 −0 Classes/VBXFolderListController.m
  60. +42 −0 Classes/VBXFolderSummary.h
  61. +52 −0 Classes/VBXFolderSummary.m
  62. +37 −0 Classes/VBXFooterTextCell.h
  63. +106 −0 Classes/VBXFooterTextCell.m
  64. +146 −0 Classes/VBXGlobal.h
  65. +794 −0 Classes/VBXGlobal.m
  66. +34 −0 Classes/VBXLicenseController.h
  67. +66 −0 Classes/VBXLicenseController.m
  68. +37 −0 Classes/VBXLoadMoreCell.h
  69. +114 −0 Classes/VBXLoadMoreCell.m
  70. +43 −0 Classes/VBXLoginController.h
  71. +265 −0 Classes/VBXLoginController.m
  72. +37 −0 Classes/VBXMaskedImageView.h
  73. +113 −0 Classes/VBXMaskedImageView.m
  74. +65 −0 Classes/VBXMessageAttribute.h
  75. +109 −0 Classes/VBXMessageAttribute.m
  76. +49 −0 Classes/VBXMessageAttributeAccessor.h
  77. +69 −0 Classes/VBXMessageAttributeAccessor.m
  78. +36 −0 Classes/VBXMessageAttributeController.h
  79. +127 −0 Classes/VBXMessageAttributeController.m
  80. +72 −0 Classes/VBXMessageDetail.h
  81. +135 −0 Classes/VBXMessageDetail.m
  82. +75 −0 Classes/VBXMessageDetailAccessor.h
  83. +154 −0 Classes/VBXMessageDetailAccessor.m
  84. +96 −0 Classes/VBXMessageDetailController.h
  85. +1,079 −0 Classes/VBXMessageDetailController.m
  86. +65 −0 Classes/VBXMessageListAccessor.h
  87. +139 −0 Classes/VBXMessageListAccessor.m
  88. +60 −0 Classes/VBXMessageListCell.h
  89. +301 −0 Classes/VBXMessageListCell.m
  90. +70 −0 Classes/VBXMessageListController.h
  91. +573 −0 Classes/VBXMessageListController.m
  92. +59 −0 Classes/VBXMessageSummary.h
  93. +80 −0 Classes/VBXMessageSummary.m
  94. +54 −0 Classes/VBXNavigationController.h
  95. +148 −0 Classes/VBXNavigationController.m
  96. +93 −0 Classes/VBXObjectBuilder.h
  97. +337 −0 Classes/VBXObjectBuilder.m
  98. +36 −0 Classes/VBXOutgoingPhone.h
  99. +47 −0 Classes/VBXOutgoingPhone.m
  100. +36 −0 Classes/VBXPerfTimer.h
  101. +51 −0 Classes/VBXPerfTimer.m
  102. +57 −0 Classes/VBXResourceLoader.h
  103. +172 −0 Classes/VBXResourceLoader.m
  104. +45 −0 Classes/VBXResourceRequest.h
  105. +110 −0 Classes/VBXResourceRequest.m
  106. +40 −0 Classes/VBXResult.h
  107. +52 −0 Classes/VBXResult.m
  108. +40 −0 Classes/VBXSectionedDataSource.h
  109. +124 −0 Classes/VBXSectionedDataSource.m
  110. +52 −0 Classes/VBXSecurityAlertController.h
  111. +135 −0 Classes/VBXSecurityAlertController.m
  112. +51 −0 Classes/VBXSendTextController.h
  113. +645 −0 Classes/VBXSendTextController.m
  114. +53 −0 Classes/VBXSessionExpiredController.h
  115. +185 −0 Classes/VBXSessionExpiredController.m
  116. +44 −0 Classes/VBXSetNumberController.h
  117. +161 −0 Classes/VBXSetNumberController.m
  118. +48 −0 Classes/VBXSetServerController.h
  119. +355 −0 Classes/VBXSetServerController.m
  120. +49 −0 Classes/VBXSettingsController.h
  121. +207 −0 Classes/VBXSettingsController.m
  122. +38 −0 Classes/VBXStatefulTableViewController.h
  123. +75 −0 Classes/VBXStatefulTableViewController.m
  124. +49 −0 Classes/VBXStringPartLabel.h
  125. +162 −0 Classes/VBXStringPartLabel.m
  126. +47 −0 Classes/VBXSublist.h
  127. +106 −0 Classes/VBXSublist.m
  128. +36 −0 Classes/VBXTableStatusView.h
  129. +109 −0 Classes/VBXTableStatusView.m
  130. +28 −0 Classes/VBXTableView.h
  131. +59 −0 Classes/VBXTableView.m
  132. +27 −0 Classes/VBXTableViewCell.h
  133. +46 −0 Classes/VBXTableViewCell.m
  134. +38 −0 Classes/VBXTableViewController.h
  135. +119 −0 Classes/VBXTableViewController.m
  136. +46 −0 Classes/VBXTextEntryController.h
  137. +110 −0 Classes/VBXTextEntryController.m
  138. +38 −0 Classes/VBXTextFieldCell.h
  139. +118 −0 Classes/VBXTextFieldCell.m
  140. +35 −0 Classes/VBXTicketStatus.h
  141. +66 −0 Classes/VBXTicketStatus.m
  142. +59 −0 Classes/VBXTrustHelper.h
  143. +188 −0 Classes/VBXTrustHelper.m
  144. +70 −0 Classes/VBXURLLoader.h
  145. +251 −0 Classes/VBXURLLoader.m
  146. +41 −0 Classes/VBXUser.h
  147. +64 −0 Classes/VBXUser.m
  148. +37 −0 Classes/VBXViewCell.h
  149. +76 −0 Classes/VBXViewCell.m
  150. +46 −0 Classes/VBXViewController.h
  151. +184 −0 Classes/VBXViewController.m
  152. BIN Default.png
  153. +8 −0 Entitlements.plist
  154. BIN Icon-settings.png
  155. BIN Icon.png
  156. +452 −0 LICENSE
  157. +30 −0 NSDictionary+merge.h
  158. +53 −0 NSDictionary+merge.m
  159. +45 −0 OpenVBX-Info.plist
  160. +1,384 −0 OpenVBX.xcodeproj/project.pbxproj
  161. +29 −0 OpenVBX_Prefix.pch
  162. +2 −0 PCRE/README
  163. +311 −0 PCRE/include/pcre.h
  164. +1,805 −0 PCRE/include/pcre_internal.h
  165. +172 −0 PCRE/include/pcre_scanner.h
  166. +177 −0 PCRE/include/pcre_stringpiece.h
  167. +710 −0 PCRE/include/pcrecpp.h
  168. +71 −0 PCRE/include/pcrecpp_internal.h
  169. +174 −0 PCRE/include/pcrecpparg.h
  170. +145 −0 PCRE/include/pcreposix.h
  171. BIN PCRE/lib/libpcre.a
  172. BIN PCRE/lib/libpcrecpp.a
  173. BIN PCRE/lib/libpcreposix.a
  174. +233 −0 PCRE/objpcre.h
  175. +565 −0 PCRE/objpcre.m
  176. +47 −0 README.md
  177. BIN Raw/Default.psd
  178. BIN Raw/barbutton.psd
  179. BIN Raw/dialer.psd
  180. BIN Raw/dropdown.psd
  181. BIN Raw/iphone-backspace-button.psd
  182. BIN Raw/mailish-button.psd
  183. BIN Resources/barbutton.png
  184. +519 −0 Resources/default-config.json
  185. BIN Resources/delivery-phone-icon-big.png
  186. BIN Resources/delivery-phone-icon.png
  187. BIN Resources/delivery-sms-icon-big.png
  188. BIN Resources/delivery-sms-icon.png
  189. BIN Resources/dialer-accessory-key-bg.png
  190. BIN Resources/dialer-backspace-icon-mask.png
  191. BIN Resources/dialer-call-bg.png
  192. BIN Resources/dialer-callerid-bg.png
  193. BIN Resources/dialer-contacts-icon-mask.png
  194. BIN Resources/dialer-number-middle-bg.png
  195. BIN Resources/dialer-number-side-bg.png
  196. BIN Resources/dialer-numberarea-bg.png
  197. BIN Resources/dropdown-highlighted.png
  198. BIN Resources/dropdown-normal.png
  199. BIN Resources/folder-icon-mask.png
  200. BIN Resources/gear.png
  201. BIN Resources/gray-play-button.png
  202. BIN Resources/inbox-icon-mask.png
  203. BIN Resources/iphone-call-icon.png
  204. BIN Resources/iphone-white-arrow.png
  205. BIN Resources/openvbx-logo.png
  206. BIN Resources/pause-button.png
  207. BIN Resources/pause-symbol.png
  208. BIN Resources/play-button.png
  209. BIN Resources/play-symbol.png
  210. BIN Resources/plus-icon.png
  211. BIN Resources/security-alert-background.png
  212. BIN Resources/shadow.png
  213. BIN Resources/stop-symbol.png
  214. BIN Resources/tableview-grouped-background.png
  215. BIN Resources/text-button-highlighted.png
  216. BIN Resources/text-button.png
  217. +27 −0 Settings.bundle/Root.plist
  218. BIN Settings.bundle/en.lproj/Root.strings
  219. +282 −0 TrustTest.m
  220. +20 −0 UnitTests-Info.plist
  221. +189 −0 UnitTests/SublistTest.m
  222. +39 −0 VBXError.h
  223. +28 −0 VBXError.m
  224. +37 −0 VBXUserDefaultsKeys.h
  225. +37 −0 VBXUserDefaultsKeys.m
  226. +52 −0 VBXVersion.h
  227. +92 −0 VBXVersion.m
  228. +118 −0 YAJL/NSObject+YAJL.h
  229. +33 −0 YAJL/YAJL.h
  230. +98 −0 YAJL/YAJLDocument.h
  231. +104 −0 YAJL/YAJLGen.h
  232. +129 −0 YAJL/YAJLParser.h
  233. BIN YAJL/libYAJLIPhone.a
  234. +85 −0 YAJL/yajl_common.h
  235. +159 −0 YAJL/yajl_gen.h
  236. +193 −0 YAJL/yajl_parse.h
  237. +19 −0 bump_version.sh
  238. +138 −0 hideous-config.json
  239. BIN icon-57.png
  240. +120 −0 license.html
  241. +28 −0 main.m
@@ -0,0 +1,3 @@
+OpenVBX.xcodeproj/*.mode1v3
+OpenVBX.xcodeproj/*.pbxuser
+build

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,33 @@
+//
+// NSData+Base64.h
+// base64
+//
+// Created by Matt Gallagher on 2009/06/03.
+// Copyright 2009 Matt Gallagher. All rights reserved.
+//
+// Permission is given to use this source code file, free of charge, in any
+// project, commercial or otherwise, entirely at your risk, with the condition
+// that any redistribution (in part or whole) of source code must retain
+// this copyright and permission notice. Attribution in compiled projects is
+// appreciated but not required.
+//
+
+#import <Foundation/Foundation.h>
+
+void *NewBase64Decode(
+ const char *inputBuffer,
+ size_t length,
+ size_t *outputLength);
+
+char *NewBase64Encode(
+ const void *inputBuffer,
+ size_t length,
+ bool separateLines,
+ size_t *outputLength);
+
+@interface NSData (Base64)
+
++ (NSData *)dataFromBase64String:(NSString *)aString;
+- (NSString *)base64EncodedString;
+
+@end
@@ -0,0 +1,298 @@
+//
+// NSData+Base64.m
+// base64
+//
+// Created by Matt Gallagher on 2009/06/03.
+// Copyright 2009 Matt Gallagher. All rights reserved.
+//
+// Permission is given to use this source code file, free of charge, in any
+// project, commercial or otherwise, entirely at your risk, with the condition
+// that any redistribution (in part or whole) of source code must retain
+// this copyright and permission notice. Attribution in compiled projects is
+// appreciated but not required.
+//
+
+#import "NSData+Base64.h"
+
+//
+// Mapping from 6 bit pattern to ASCII character.
+//
+static unsigned char base64EncodeLookup[65] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+//
+// Definition for "masked-out" areas of the base64DecodeLookup mapping
+//
+#define xx 65
+
+//
+// Mapping from ASCII character to 6 bit pattern.
+//
+static unsigned char base64DecodeLookup[256] =
+{
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 62, xx, xx, xx, 63,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, xx, xx, xx, xx, xx, xx,
+ xx, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, xx, xx, xx, xx, xx,
+ xx, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, xx, xx, xx, xx, xx,
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
+ xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
+};
+
+//
+// Fundamental sizes of the binary and base64 encode/decode units in bytes
+//
+#define BINARY_UNIT_SIZE 3
+#define BASE64_UNIT_SIZE 4
+
+//
+// NewBase64Decode
+//
+// Decodes the base64 ASCII string in the inputBuffer to a newly malloced
+// output buffer.
+//
+// inputBuffer - the source ASCII string for the decode
+// length - the length of the string or -1 (to specify strlen should be used)
+// outputLength - if not-NULL, on output will contain the decoded length
+//
+// returns the decoded buffer. Must be free'd by caller. Length is given by
+// outputLength.
+//
+void *NewBase64Decode(
+ const char *inputBuffer,
+ size_t length,
+ size_t *outputLength)
+{
+ if (length == -1)
+ {
+ length = strlen(inputBuffer);
+ }
+
+ size_t outputBufferSize = (length / BASE64_UNIT_SIZE) * BINARY_UNIT_SIZE;
+ unsigned char *outputBuffer = (unsigned char *)malloc(outputBufferSize);
+
+ size_t i = 0;
+ size_t j = 0;
+ while (i < length)
+ {
+ //
+ // Accumulate 4 valid characters (ignore everything else)
+ //
+ unsigned char accumulated[BASE64_UNIT_SIZE];
+ size_t accumulateIndex = 0;
+ while (i < length)
+ {
+ unsigned char decode = base64DecodeLookup[inputBuffer[i++]];
+ if (decode != xx)
+ {
+ accumulated[accumulateIndex] = decode;
+ accumulateIndex++;
+
+ if (accumulateIndex == BASE64_UNIT_SIZE)
+ {
+ break;
+ }
+ }
+ }
+
+ //
+ // Store the 6 bits from each of the 4 characters as 3 bytes
+ //
+ outputBuffer[j] = (accumulated[0] << 2) | (accumulated[1] >> 4);
+ outputBuffer[j + 1] = (accumulated[1] << 4) | (accumulated[2] >> 2);
+ outputBuffer[j + 2] = (accumulated[2] << 6) | accumulated[3];
+ j += accumulateIndex - 1;
+ }
+
+ if (outputLength)
+ {
+ *outputLength = j;
+ }
+ return outputBuffer;
+}
+
+//
+// NewBase64Decode
+//
+// Encodes the arbitrary data in the inputBuffer as base64 into a newly malloced
+// output buffer.
+//
+// inputBuffer - the source data for the encode
+// length - the length of the input in bytes
+// separateLines - if zero, no CR/LF characters will be added. Otherwise
+// a CR/LF pair will be added every 64 encoded chars.
+// outputLength - if not-NULL, on output will contain the encoded length
+// (not including terminating 0 char)
+//
+// returns the encoded buffer. Must be free'd by caller. Length is given by
+// outputLength.
+//
+char *NewBase64Encode(
+ const void *buffer,
+ size_t length,
+ bool separateLines,
+ size_t *outputLength)
+{
+ const unsigned char *inputBuffer = (const unsigned char *)buffer;
+
+ #define MAX_NUM_PADDING_CHARS 2
+ #define OUTPUT_LINE_LENGTH 64
+ #define INPUT_LINE_LENGTH ((OUTPUT_LINE_LENGTH / BASE64_UNIT_SIZE) * BINARY_UNIT_SIZE)
+ #define CR_LF_SIZE 2
+
+ //
+ // Byte accurate calculation of final buffer size
+ //
+ size_t outputBufferSize =
+ ((length / BINARY_UNIT_SIZE)
+ + ((length % BINARY_UNIT_SIZE) ? 1 : 0))
+ * BASE64_UNIT_SIZE;
+ if (separateLines)
+ {
+ outputBufferSize +=
+ (outputBufferSize / OUTPUT_LINE_LENGTH) * CR_LF_SIZE;
+ }
+
+ //
+ // Include space for a terminating zero
+ //
+ outputBufferSize += 1;
+
+ //
+ // Allocate the output buffer
+ //
+ char *outputBuffer = (char *)malloc(outputBufferSize);
+ if (!outputBuffer)
+ {
+ return NULL;
+ }
+
+ size_t i = 0;
+ size_t j = 0;
+ const size_t lineLength = separateLines ? INPUT_LINE_LENGTH : length;
+ size_t lineEnd = lineLength;
+
+ while (true)
+ {
+ if (lineEnd > length)
+ {
+ lineEnd = length;
+ }
+
+ for (; i + BINARY_UNIT_SIZE - 1 < lineEnd; i += BINARY_UNIT_SIZE)
+ {
+ //
+ // Inner loop: turn 48 bytes into 64 base64 characters
+ //
+ outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2];
+ outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i] & 0x03) << 4)
+ | ((inputBuffer[i + 1] & 0xF0) >> 4)];
+ outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i + 1] & 0x0F) << 2)
+ | ((inputBuffer[i + 2] & 0xC0) >> 6)];
+ outputBuffer[j++] = base64EncodeLookup[inputBuffer[i + 2] & 0x3F];
+ }
+
+ if (lineEnd == length)
+ {
+ break;
+ }
+
+ //
+ // Add the newline
+ //
+ outputBuffer[j++] = '\r';
+ outputBuffer[j++] = '\n';
+ lineEnd += lineLength;
+ }
+
+ if (i + 1 < length)
+ {
+ //
+ // Handle the single '=' case
+ //
+ outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2];
+ outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i] & 0x03) << 4)
+ | ((inputBuffer[i + 1] & 0xF0) >> 4)];
+ outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i + 1] & 0x0F) << 2];
+ outputBuffer[j++] = '=';
+ }
+ else if (i < length)
+ {
+ //
+ // Handle the double '=' case
+ //
+ outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2];
+ outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0x03) << 4];
+ outputBuffer[j++] = '=';
+ outputBuffer[j++] = '=';
+ }
+ outputBuffer[j] = 0;
+
+ //
+ // Set the output length and return the buffer
+ //
+ if (outputLength)
+ {
+ *outputLength = j;
+ }
+ return outputBuffer;
+}
+
+@implementation NSData (Base64)
+
+//
+// dataFromBase64String:
+//
+// Creates an NSData object containing the base64 decoded representation of
+// the base64 string 'aString'
+//
+// Parameters:
+// aString - the base64 string to decode
+//
+// returns the autoreleased NSData representation of the base64 string
+//
++ (NSData *)dataFromBase64String:(NSString *)aString
+{
+ NSData *data = [aString dataUsingEncoding:NSASCIIStringEncoding];
+ size_t outputLength;
+ void *outputBuffer = NewBase64Decode([data bytes], [data length], &outputLength);
+ NSData *result = [NSData dataWithBytes:outputBuffer length:outputLength];
+ free(outputBuffer);
+ return result;
+}
+
+//
+// base64EncodedString
+//
+// Creates an NSString object that contains the base 64 encoding of the
+// receiver's data. Lines are broken at 64 characters long.
+//
+// returns an autoreleased NSString being the base 64 representation of the
+// receiver.
+//
+- (NSString *)base64EncodedString
+{
+ size_t outputLength;
+ char *outputBuffer =
+ NewBase64Encode([self bytes], [self length], true, &outputLength);
+
+ NSString *result =
+ [[[NSString alloc]
+ initWithBytes:outputBuffer
+ length:outputLength
+ encoding:NSASCIIStringEncoding]
+ autorelease];
+ free(outputBuffer);
+ return result;
+}
+
+@end
Oops, something went wrong.

0 comments on commit e21e562

Please sign in to comment.