Permalink
Browse files

master version

  • Loading branch information...
1 parent 10aad8d commit 147946291892c8cb6ffdcc9eb3a72961b988748a Jean Nawratil committed Jul 19, 2010
Showing with 11,769 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +18 −0 README.md
  3. +157 −0 UploadPostHelper.as
  4. +98 −0 com/adobe/air/logging/FileTarget.as
  5. +127 −0 com/adobe/crypto/HMAC.as
  6. +281 −0 com/adobe/crypto/MD5.as
  7. +402 −0 com/adobe/crypto/MD5Stream.as
  8. +271 −0 com/adobe/crypto/SHA1.as
  9. +257 −0 com/adobe/crypto/SHA224.as
  10. +261 −0 com/adobe/crypto/SHA256.as
  11. +114 −0 com/adobe/crypto/WSSEUsernameToken.as
  12. +63 −0 com/adobe/errors/IllegalStateError.as
  13. +47 −0 com/adobe/fileformats/vcard/Address.as
  14. +39 −0 com/adobe/fileformats/vcard/Email.as
  15. +39 −0 com/adobe/fileformats/vcard/Phone.as
  16. +54 −0 com/adobe/fileformats/vcard/VCard.as
  17. +246 −0 com/adobe/fileformats/vcard/VCardParser.as
  18. +39 −0 com/adobe/images/BitString.as
  19. +648 −0 com/adobe/images/JPGEncoder.as
  20. +141 −0 com/adobe/images/PNGEncoder.as
  21. +55 −0 com/adobe/net/DynamicURLLoader.as
  22. +76 −0 com/adobe/net/IURIResolver.as
  23. +196 −0 com/adobe/net/MimeTypeMap.as
  24. +2,466 −0 com/adobe/net/URI.as
  25. +139 −0 com/adobe/net/URIEncodingBitmap.as
  26. +198 −0 com/adobe/net/proxies/RFC2817Socket.as
  27. +34 −0 com/adobe/protocols/dict/Database.as
  28. +39 −0 com/adobe/protocols/dict/Definition.as
  29. +328 −0 com/adobe/protocols/dict/Dict.as
  30. +28 −0 com/adobe/protocols/dict/DictionaryServer.as
  31. +34 −0 com/adobe/protocols/dict/MatchStrategy.as
  32. +39 −0 com/adobe/protocols/dict/Response.as
  33. +14 −0 com/adobe/protocols/dict/events/ConnectedEvent.as
  34. +26 −0 com/adobe/protocols/dict/events/DatabaseEvent.as
  35. +27 −0 com/adobe/protocols/dict/events/DefinitionEvent.as
  36. +26 −0 com/adobe/protocols/dict/events/DefinitionHeaderEvent.as
  37. +26 −0 com/adobe/protocols/dict/events/DictionaryServerEvent.as
  38. +14 −0 com/adobe/protocols/dict/events/DisconnectedEvent.as
  39. +37 −0 com/adobe/protocols/dict/events/ErrorEvent.as
  40. +26 −0 com/adobe/protocols/dict/events/MatchEvent.as
  41. +26 −0 com/adobe/protocols/dict/events/MatchStrategiesEvent.as
  42. +14 −0 com/adobe/protocols/dict/events/NoMatchEvent.as
  43. +25 −0 com/adobe/protocols/dict/util/CompleteResponseEvent.as
  44. +49 −0 com/adobe/protocols/dict/util/SocketHelper.as
  45. +85 −0 com/adobe/serialization/json/JSON.as
  46. +221 −0 com/adobe/serialization/json/JSONDecoder.as
  47. +299 −0 com/adobe/serialization/json/JSONEncoder.as
  48. +87 −0 com/adobe/serialization/json/JSONParseError.as
  49. +104 −0 com/adobe/serialization/json/JSONToken.as
  50. +67 −0 com/adobe/serialization/json/JSONTokenType.as
  51. +583 −0 com/adobe/serialization/json/JSONTokenizer.as
  52. +187 −0 com/adobe/utils/ArrayUtil.as
  53. +699 −0 com/adobe/utils/DateUtil.as
  54. +87 −0 com/adobe/utils/DictionaryUtil.as
  55. +99 −0 com/adobe/utils/IntUtil.as
  56. +74 −0 com/adobe/utils/NumberFormatter.as
  57. +270 −0 com/adobe/utils/StringUtil.as
  58. +168 −0 com/adobe/utils/XMLUtil.as
  59. +48 −0 com/adobe/webapis/ServiceBase.as
  60. +108 −0 com/adobe/webapis/URLLoaderBase.as
  61. +75 −0 com/adobe/webapis/events/ServiceEvent.as
  62. +369 −0 mx/utils/Base64Encoder.as
  63. +123 −0 net/metafor/faceapi/FaceApi.as
  64. +11 −0 net/metafor/faceapi/FaceResult.as
  65. +265 −0 net/metafor/faceapi/auth/OAuth.as
  66. +15 −0 net/metafor/faceapi/auth/OAuthEvent.as
  67. +25 −0 net/metafor/faceapi/events/FaceEvent.as
  68. +63 −0 net/metafor/faceapi/services/AccountService.as
  69. +80 −0 net/metafor/faceapi/services/FaceService.as
  70. +34 −0 net/metafor/faceapi/services/FacebookService.as
  71. +175 −0 net/metafor/faceapi/services/RecognitionService.as
  72. +76 −0 net/metafor/faceapi/services/TagsService.as
  73. +27 −0 net/metafor/faceapi/utils/Cross.as
View
@@ -0,0 +1 @@
+Main.as
View
@@ -0,0 +1,18 @@
+AS3 port of the face.com API
+
+Need as3crypto.swc & Crypto.swc( it will be soon go on one of them ).
+
+
+### Usage ###
+
+ var faceApi:FaceApi = new FaceApi();
+ faceApi.apiKey = "dbcfca68572671b4c26a43d7231df505";
+ faceApi.apiSecret = "34ddf640f49747318df77a0d71e79ae3";
+
+ faceApi.recognitionService.recognize( urls , uids );
+ faceApi.recognitionService.addEventListener( FaceEvent.SUCCESS , recoHandler );
+
+ function recoHandler( evt : FaceEvent ) : void
+ {
+ var result:Object = evt.data;
+ }
View
@@ -0,0 +1,157 @@
+package {
+
+ import flash.events.*;
+ import flash.net.*;
+ import flash.utils.ByteArray;
+ import flash.utils.Endian;
+
+ /**
+ * Take a fileName, byteArray, and parameters object as input and return ByteArray post data suitable for a UrlRequest as output
+ *
+ * @see http://marstonstudio.com/?p=36
+ * @see http://www.w3.org/TR/html4/interact/forms.html
+ * @see http://www.jooce.com/blog/?p=143
+ * @see http://www.jooce.com/blog/wp%2Dcontent/uploads/2007/06/uploadFile.txt
+ * @see http://blog.je2050.de/2006/05/01/save-bytearray-to-file-with-php/
+ *
+ * @author Jonathan Marston
+ * @version 2007.08.19
+ *
+ * This work is licensed under a Creative Commons Attribution NonCommercial ShareAlike 3.0 License.
+ * @see http://creativecommons.org/licenses/by-nc-sa/3.0/
+ *
+ */
+ public class UploadPostHelper {
+
+ /**
+ * Boundary used to break up different parts of the http POST body
+ */
+ private static var _boundary:String = "";
+
+ /**
+ * Get the boundary for the post.
+ * Must be passed as part of the contentType of the UrlRequest
+ */
+ public static function getBoundary():String {
+
+ if(_boundary.length == 0) {
+ for (var i:int = 0; i < 0x20; i++ ) {
+ _boundary += String.fromCharCode( int( 97 + Math.random() * 25 ) );
+ }
+ }
+
+ return _boundary;
+ }
+
+ /**
+ * Create post data to send in a UrlRequest
+ */
+ public static function getPostData(fileName:String, byteArray:ByteArray, parameters:Object = null):ByteArray {
+
+ var i: int;
+ var bytes:String;
+
+ var postData:ByteArray = new ByteArray();
+ postData.endian = Endian.BIG_ENDIAN;
+
+ //add Filename to parameters
+ if(parameters == null) {
+ parameters = new Object();
+ }
+ parameters.Filename = fileName;
+
+ //add parameters to postData
+ for(var name:String in parameters) {
+ postData = BOUNDARY(postData);
+ postData = LINEBREAK(postData);
+ bytes = 'Content-Disposition: form-data; name="' + name + '"';
+ for ( i = 0; i < bytes.length; i++ ) {
+ postData.writeByte( bytes.charCodeAt(i) );
+ }
+ postData = LINEBREAK(postData);
+ postData = LINEBREAK(postData);
+ postData.writeUTFBytes(parameters[name]);
+ postData = LINEBREAK(postData);
+ }
+
+ //add Filedata to postData
+ postData = BOUNDARY(postData);
+ postData = LINEBREAK(postData);
+ bytes = 'Content-Disposition: form-data; filename="';
+ for ( i = 0; i < bytes.length; i++ ) {
+ postData.writeByte( bytes.charCodeAt(i) );
+ }
+ postData.writeUTFBytes(fileName);
+ postData = QUOTATIONMARK(postData);
+ postData = LINEBREAK(postData);
+ bytes = 'Content-Type: image/jpeg';
+ for ( i = 0; i < bytes.length; i++ ) {
+ postData.writeByte( bytes.charCodeAt(i) );
+ }
+ postData = LINEBREAK(postData);
+ postData = LINEBREAK(postData);
+ postData.writeBytes(byteArray, 0, byteArray.length);
+ postData = LINEBREAK(postData);
+
+ //add upload filed to postData
+ postData = LINEBREAK(postData);
+ postData = BOUNDARY(postData);
+ postData = LINEBREAK(postData);
+ bytes = 'Content-Disposition: form-data; name="Upload"';
+ for ( i = 0; i < bytes.length; i++ ) {
+ postData.writeByte( bytes.charCodeAt(i) );
+ }
+ postData = LINEBREAK(postData);
+ postData = LINEBREAK(postData);
+ bytes = 'Submit Query';
+ for ( i = 0; i < bytes.length; i++ ) {
+ postData.writeByte( bytes.charCodeAt(i) );
+ }
+ postData = LINEBREAK(postData);
+
+ //closing boundary
+ postData = BOUNDARY(postData);
+ postData = DOUBLEDASH(postData);
+
+ return postData;
+ }
+
+ /**
+ * Add a boundary to the PostData with leading doubledash
+ */
+ private static function BOUNDARY(p:ByteArray):ByteArray {
+ var l:int = UploadPostHelper.getBoundary().length;
+
+ p = DOUBLEDASH(p);
+ for (var i:int = 0; i < l; i++ ) {
+ p.writeByte( _boundary.charCodeAt( i ) );
+ }
+ return p;
+ }
+
+ /**
+ * Add one linebreak
+ */
+ private static function LINEBREAK(p:ByteArray):ByteArray {
+ p.writeShort(0x0d0a);
+ return p;
+ }
+
+ /**
+ * Add quotation mark
+ */
+ private static function QUOTATIONMARK(p:ByteArray):ByteArray {
+ p.writeByte(0x22);
+ return p;
+ }
+
+ /**
+ * Add Double Dash
+ */
+ private static function DOUBLEDASH(p:ByteArray):ByteArray {
+ p.writeShort(0x2d2d);
+ return p;
+ }
+
+ }
+}
@@ -0,0 +1,98 @@
+/*
+ Copyright (c) 2008, Adobe Systems Incorporated
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package com.adobe.air.logging
+{
+ import mx.logging.AbstractTarget;
+ import flash.filesystem.File;
+ import flash.filesystem.FileStream;
+ import flash.filesystem.FileMode;
+ import mx.logging.LogEvent;
+ import flash.system.System;
+ import flash.system.Capabilities;
+ import mx.logging.targets.LineFormattedTarget;
+ import mx.core.mx_internal;
+
+ use namespace mx_internal;
+
+ /**
+ * An Adobe AIR only class that provides a log target for the Flex logging
+ * framework, that logs files to a file on the user's system.
+ *
+ * This class will only work when running within Adobe AIR>
+ */
+ public class FileTarget extends LineFormattedTarget
+ {
+ private const DEFAULT_LOG_PATH:String = "app-storage:/application.log";
+
+ private var log:File;
+
+ public function FileTarget(logFile:File = null)
+ {
+ if(logFile != null)
+ {
+ log = logFile;
+ }
+ else
+ {
+ log = new File(DEFAULT_LOG_PATH);
+ }
+ }
+
+ public function get logURI():String
+ {
+ return log.url;
+ }
+
+ mx_internal override function internalLog(message:String):void
+ {
+ write(message);
+ }
+
+ private function write(msg:String):void
+ {
+ var fs:FileStream = new FileStream();
+ fs.open(log, FileMode.APPEND);
+ fs.writeUTFBytes(msg + "\n");
+ fs.close();
+ }
+
+ public function clear():void
+ {
+ var fs:FileStream = new FileStream();
+ fs.open(log, FileMode.WRITE);
+ fs.writeUTFBytes("");
+ fs.close();
+ }
+
+ }
+}
Oops, something went wrong.

0 comments on commit 1479462

Please sign in to comment.