From a9c818418b81b93680170e1a84d4e221e578ad2f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 09:56:53 +0200 Subject: Adding debian version 6.4.3+dfsg1-1. Signed-off-by: Daniel Baumann --- debian/missing-sources/swfupload/Flash/FileItem.as | 112 +++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 debian/missing-sources/swfupload/Flash/FileItem.as (limited to 'debian/missing-sources/swfupload/Flash/FileItem.as') diff --git a/debian/missing-sources/swfupload/Flash/FileItem.as b/debian/missing-sources/swfupload/Flash/FileItem.as new file mode 100644 index 0000000..9eb3952 --- /dev/null +++ b/debian/missing-sources/swfupload/Flash/FileItem.as @@ -0,0 +1,112 @@ +package { + import flash.net.FileReference; + + internal class FileItem + { + private static var file_id_sequence:Number = 0; // tracks the file id sequence + + private var postObject:Object; + public var file_reference:FileReference; + public var id:String; + public var index:Number = -1; + public var file_status:int = 0; + private var js_object:Object; + + public static var FILE_STATUS_QUEUED:int = -1; + public static var FILE_STATUS_IN_PROGRESS:int = -2; + public static var FILE_STATUS_ERROR:int = -3; + public static var FILE_STATUS_SUCCESS:int = -4; + public static var FILE_STATUS_CANCELLED:int = -5; + public static var FILE_STATUS_NEW:int = -6; // This file status should never be sent to JavaScript + + public function FileItem(file_reference:FileReference, control_id:String, index:Number) + { + this.postObject = {}; + this.file_reference = file_reference; + this.id = control_id + "_" + (FileItem.file_id_sequence++); + this.file_status = FileItem.FILE_STATUS_NEW; + this.index = index; + + this.js_object = { + id: this.id, + index: this.index, + post: this.GetPostObject() + }; + + // Cleanly attempt to retrieve the FileReference info + // this can fail and so is wrapped in try..catch + try { + this.js_object.name = this.file_reference.name; + this.js_object.size = this.file_reference.size; + this.js_object.type = this.file_reference.type || ""; + this.js_object.creationdate = this.file_reference.creationDate || new Date(0); + this.js_object.modificationdate = this.file_reference.modificationDate || new Date(0); + } catch (ex:Error) { + this.file_status = FileItem.FILE_STATUS_ERROR; + } + + this.js_object.filestatus = this.file_status; + } + + public function AddParam(name:String, value:String):void { + this.postObject[name] = value; + } + + public function RemoveParam(name:String):void { + delete this.postObject[name]; + } + + public function GetPostObject(escape:Boolean = false):Object { + if (escape) { + var escapedPostObject:Object = { }; + for (var k:String in this.postObject) { + if (this.postObject.hasOwnProperty(k)) { + var escapedName:String = FileItem.EscapeParamName(k); + escapedPostObject[escapedName] = this.postObject[k]; + } + } + return escapedPostObject; + } else { + return this.postObject; + } + } + + // Create the simply file object that is passed to the browser + public function ToJavaScriptObject():Object { + this.js_object.filestatus = this.file_status; + this.js_object.post = this.GetPostObject(true); + + return this.js_object; + } + + public function toString():String { + return "FileItem - ID: " + this.id; + } + + /* + // The purpose of this function is to escape the property names so when Flash + // passes them back to javascript they can be interpretted correctly. + // ***They have to be unescaped again by JavaScript.** + // + // This works around a bug where Flash sends objects this way: + // object.parametername = "value"; + // instead of + // object["parametername"] = "value"; + // This can be a problem if the parameter name has characters that are not + // allowed in JavaScript identifiers: + // object.parameter.name! = "value"; + // does not work but, + // object["parameter.name!"] = "value"; + // would have worked. + */ + public static function EscapeParamName(name:String):String { + name = name.replace(/[^a-z0-9_]/gi, FileItem.EscapeCharacter); + name = name.replace(/^[0-9]/, FileItem.EscapeCharacter); + return name; + } + public static function EscapeCharacter():String { + return "$" + ("0000" + arguments[0].charCodeAt(0).toString(16)).substr(-4, 4); + } + + } +} \ No newline at end of file -- cgit v1.2.3