~ubuntu-branches/debian/sid/wordpress/sid

« back to all changes in this revision

Viewing changes to debian/missing-sources/plupload-1.5.4/csharp/Plupload/Page.xaml.cs

  • Committer: Package Import Robot
  • Author(s): Raphaël Hertzog, Raphaël Hertzog, Martin Bagge / brother
  • Date: 2012-06-16 01:19:20 UTC
  • mfrom: (1.2.22)
  • Revision ID: package-import@ubuntu.com-20120616011920-ivqcktmjehq4gpal
Tags: 3.4+dfsg-1
* New upstream release. Closes: #677534

[ Raphaël Hertzog ]
* [a1c0409] Refresh and update all patches to correctly apply on version
  3.4.
* [3804496] Update debian/missing-sources/ to match the current versions of
  embedded javascript and flash files.
* [185b051] Drop the old "default" theme (and its French translation)
* [966ce6c] Grab latest translations
* [1983326] Update Standards-Version to 3.9.3 (no change).
* [29c48b6] Increase debhelper compat level to 9.
* [73e16d0] Replace debian/dh_linktree by the packaged version.
* [359b660] Update debian/wordpress.linktrees to match latest developments.
* [645b650] Let setup-mysql lowercase the FQDN since the configuration
  scheme expects this. Thanks to Chris Butler <chrisb@debian.org> for the
  report (Closes: #658395)
* [5433e90] Fix setup-mysql to avoid creating /srv/www with restricted
  permissions (Closes: #616400)
* [dd2ef1d] Move back wp-config.php to /usr/share/wordpress/ since it's only
  a dispatcher to the real configuration file (Closes: #592502)
* [b602372] Improve wp-config.php so that WordPress works behind an https
  reverse-proxy.
* [ba0b729] Entirely update and rewrite README.debian. (Closes: #575985,
  #639980)
* [683a908] Update wp-config.php to not redefine constants which have
  already been set.  Thanks to Richard van den Berg <richard@vdberg.org> for
  the report. (Closes: #613283)
* [315eb68] Let wordpress-l10n depend on the same version than wordpress.
  (Closes: #623557)
* [a6d0b9f] Default configuration now sets WP_CONTENT_DIR to
  /var/lib/wordpress/wp-content. And the package provides this new directory
  appropriately setup with write rights to www-data on blogs.dir and
  uploads. themes and plugins are root-owned directories with symlinks
  pointing back to the default themes and plugins. (Closes: #675469)
* [4db98c6] Update setup-mysql to use WP_CONTENT_DIR (and no longer use
  $upload_dir). (Closes: #658508)
* [a1970da] Extend debian/wordpress.linktrees to cover swfobject.js.
* [8d46dab] Use dpkg-maintscript-helper to drop obsolete
  /etc/wordpress/wp-config.php

[ Martin Bagge / brother ]
* [56d0a34] Improve the setup script to be able to use a remote MySQL
  server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Page.xaml.cs
 
3
 *
 
4
 * Copyright 2009, Moxiecode Systems AB
 
5
 * Released under GPL License.
 
6
 *
 
7
 * License: http://www.plupload.com/license
 
8
 * Contributing: http://www.plupload.com/contributing
 
9
 */
 
10
 
 
11
using System;
 
12
using System.Windows;
 
13
using System.Windows.Controls;
 
14
using System.Windows.Documents;
 
15
using System.Windows.Ink;
 
16
using System.Windows.Input;
 
17
using System.Windows.Media;
 
18
using System.Windows.Media.Animation;
 
19
using System.Windows.Shapes;
 
20
using System.Windows.Browser;
 
21
using System.Net;
 
22
using System.IO;
 
23
using System.Collections.Generic;
 
24
using System.Threading;
 
25
using Moxiecode.Plupload;
 
26
 
 
27
namespace Moxiecode.Plupload {
 
28
        /// <summary>
 
29
        ///  Partial page class for the Silverlight page.
 
30
        /// </summary>
 
31
        public partial class Page : UserControl {
 
32
                #region private fields
 
33
                private Dictionary<string, FileReference> files;
 
34
                private int idCount = 0;
 
35
                private FileReference currentFile;
 
36
                private string id, filter;
 
37
                private bool multiselect;
 
38
                private bool disabled = false;
 
39
                #endregion
 
40
 
 
41
                /// <summary>
 
42
                ///  Main constructor.
 
43
                /// </summary>
 
44
                /// <param name="init_params">Silverlight init params.</param>
 
45
                public Page(IDictionary<string, string> init_params) {
 
46
                        InitializeComponent();
 
47
 
 
48
                        HtmlPage.RegisterScriptableObject("Upload", this);
 
49
 
 
50
                        this.files = new Dictionary<string, FileReference>();
 
51
                        this.id = init_params["id"];
 
52
                        this.filter = init_params["filter"];
 
53
                        this.multiselect = Convert.ToBoolean(init_params["multiselect"]);
 
54
 
 
55
                        this.FireEvent("Init");
 
56
                        this.MouseLeftButtonUp += new MouseButtonEventHandler(OnClick);
 
57
                        
 
58
                        this.MouseLeftButtonDown += new MouseButtonEventHandler(OnMouseLeftButtonDown);
 
59
                        this.MouseEnter += new MouseEventHandler(OnMouseEnter);
 
60
                        this.MouseLeave += new MouseEventHandler(OnMouseLeave);
 
61
                }
 
62
 
 
63
                private void OnClick(object sender, MouseEventArgs e) {
 
64
                        if (this.disabled) {
 
65
                                return;
 
66
                        }
 
67
 
 
68
                        OpenFileDialog dlg = new OpenFileDialog();
 
69
 
 
70
                        this.FireEvent("StartSelectFiles");
 
71
 
 
72
                        try {
 
73
                                dlg.Multiselect = this.multiselect;
 
74
                                dlg.Filter = this.filter;
 
75
 
 
76
                                if ((bool) dlg.ShowDialog()) {
 
77
                                        foreach (FileInfo file in dlg.Files) {
 
78
                                                FileReference uploadFile = new FileReference("u" + this.idCount++, file);
 
79
 
 
80
                                                uploadFile.UploadChunkComplete += delegate(object up_sender, UploadEventArgs args) {
 
81
                                                        FileReference evtFile = (FileReference) up_sender;
 
82
 
 
83
                                                        this.FireEvent("UploadChunkSuccessful", evtFile.Id, args.Chunk, args.Chunks, args.Response);
 
84
                                                };
 
85
 
 
86
                                                uploadFile.UploadComplete += delegate(object up_sender, UploadEventArgs args) {
 
87
                                                        FileReference evtFile = (FileReference) up_sender;
 
88
 
 
89
                                                        this.FireEvent("UploadSuccessful", evtFile.Id, args.Response);
 
90
                                                };
 
91
 
 
92
                                                uploadFile.Error += delegate(object up_sender, ErrorEventArgs args) {
 
93
                                                        FileReference evtFile = (FileReference) up_sender;
 
94
 
 
95
                                                        this.FireEvent("UploadChunkError", evtFile.Id, args.Chunk, args.Chunks, args.Message);
 
96
                                                };
 
97
 
 
98
                                                uploadFile.Progress += delegate(object up_sender, ProgressEventArgs args) {
 
99
                                                        FileReference evtFile = (FileReference) up_sender;
 
100
 
 
101
                                                        this.FireEvent("UploadFileProgress", evtFile.Id, args.Loaded, args.Total);
 
102
                                                };
 
103
 
 
104
                                                this.FireEvent("SelectFile", uploadFile.Id, uploadFile.Name, uploadFile.Size);
 
105
                                                this.files[uploadFile.Id] = uploadFile;
 
106
                                        }
 
107
 
 
108
                                        this.FireEvent("SelectSuccessful");
 
109
                                } else
 
110
                                        this.FireEvent("SelectCancelled");
 
111
                        } catch (Exception ex) {
 
112
                                this.FireEvent("SelectError", ex.Message);
 
113
                        }
 
114
                }
 
115
                
 
116
                
 
117
                private void OnMouseLeftButtonDown(object sender, MouseEventArgs e) {
 
118
                        this.FireEvent("MouseLeftButtonDown");
 
119
                }
 
120
                
 
121
                private void OnMouseEnter(object sender, MouseEventArgs e) {
 
122
                        this.FireEvent("MouseEnter");
 
123
                }
 
124
                
 
125
                private void OnMouseLeave(object sender, MouseEventArgs e) {
 
126
                        this.FireEvent("MouseLeave");
 
127
                }
 
128
 
 
129
                /// <summary>
 
130
                ///  Reference to page level plupload.silverlight script object.
 
131
                /// </summary>
 
132
                public ScriptObject PluploadScriptObject {
 
133
                        get { return ((ScriptObject) HtmlPage.Window.Eval("plupload.silverlight")); }
 
134
                }
 
135
 
 
136
                /// <summary>
 
137
                ///  Fires a specific event to the page level multi upload script.
 
138
                /// </summary>
 
139
                /// <param name="name">Event name to fire.</param>
 
140
                public void FireEvent(string name) {
 
141
                        this.PluploadScriptObject.Invoke("trigger", new string[] { this.id, name });
 
142
                }
 
143
 
 
144
                /// <summary>
 
145
                ///  Fires a specific event to the page level multi upload script.
 
146
                /// </summary>
 
147
                /// <param name="name">Event name to fire.</param>
 
148
                /// <param name="paramlist">Numerous parameters to send.</param>
 
149
                public void FireEvent(string name, params object[] paramlist) {
 
150
                        List<object> args = new List<object>(paramlist);
 
151
 
 
152
                        args.Insert(0, name);
 
153
                        args.Insert(0, this.id);
 
154
 
 
155
                        this.PluploadScriptObject.Invoke("trigger", args.ToArray());
 
156
                }
 
157
 
 
158
                [ScriptableMember]
 
159
                /// <summary>
 
160
                ///  Uploads a specific file by id to the specific url and using a chunks.
 
161
                /// </summary>
 
162
                /// <param name="id">File id to upload.</param>
 
163
                /// <param name="upload_url">Url to upload to.</param>
 
164
                /// <param name="chunk_size">Chunk size to use.</param>
 
165
                public void UploadFile(string id, string upload_url, string json_settings) {
 
166
                        if (this.files.ContainsKey(id)) {
 
167
                                FileReference file = this.files[id];
 
168
 
 
169
                                this.currentFile = file;
 
170
                                file.Upload(upload_url, json_settings);
 
171
                        }
 
172
                }
 
173
 
 
174
                [ScriptableMember]
 
175
                /// <summary>
 
176
                ///  Removes the specified file by id.
 
177
                /// </summary>
 
178
                /// <param name="id">File id to remove.</param>
 
179
                public void RemoveFile(string id) {
 
180
                        if (this.files.ContainsKey(id))
 
181
                                this.files[id] = null;
 
182
                }
 
183
 
 
184
                [ScriptableMember]
 
185
                /// <summary>
 
186
                ///  Clears all files.
 
187
                /// </summary>
 
188
                public void ClearFiles() {
 
189
                        this.files = new Dictionary<string, FileReference>();
 
190
                }
 
191
 
 
192
                [ScriptableMember]
 
193
                /// <summary>
 
194
                ///  Uploads the next chunk of the current file. Returns true/false if there is more chunks.
 
195
                /// </summary>
 
196
                /// <return>true/false if there is more chunks</return>
 
197
                public bool UploadNextChunk() {
 
198
                        if (this.currentFile != null)
 
199
                                return this.currentFile.UploadNextChunk();
 
200
 
 
201
                        return false;
 
202
                }
 
203
 
 
204
        [ScriptableMember]
 
205
        /// <summary>
 
206
        /// Cancel upload.
 
207
        /// </summary>
 
208
        public void CancelUpload() {
 
209
            if (this.currentFile != null)
 
210
                this.currentFile.CancelUpload();
 
211
        }
 
212
 
 
213
                [ScriptableMember]
 
214
                /// <summary>
 
215
                /// Disable dialog trigger.
 
216
                /// </summary>
 
217
                public void DisableBrowse(bool disabled = true)
 
218
                {
 
219
                        this.disabled = disabled;
 
220
                }
 
221
 
 
222
                /// <summary>
 
223
                ///  Send debug message to firebug console.
 
224
                /// </summary>
 
225
                /// <param name="msg">Message to write.</param>
 
226
                private void Debug(string msg) {
 
227
                        ((ScriptObject) HtmlPage.Window.Eval("console")).Invoke("log", new string[] { msg });
 
228
                }
 
229
        }
 
230
}