1 import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
3 import "UIConstants.js" as Const
4 import "ISOdate.js" as ISOdate
5 import "bytesconv.js" as Conv
12 property variant secrets
13 property variant properties
14 property bool isPublic
17 [qsTr("Download"),false],
18 [qsTr("Publish"),false],
19 [qsTr("Rename"),false],
20 [qsTr("Delete"),false]
23 function menuFun(id) {
24 if(id==qsTr("Download")) {
25 fileSelector.state = "visible";
27 if(id==qsTr("Publish")) {
29 dialogStopPublish.open();
31 dialogStartPublish.open();
34 if(id==qsTr("Rename")) {
37 if(id==qsTr("Delete")) {
46 tip.show(qsTr("File deleted!"));
48 pageStack.currentPage.init();
53 tip.show(qsTr("Authorization failed!"));
55 tip.show(qsTr("Error: ")+status);
64 secret: Utils.tokenSecret(),
65 consumer_key : Utils.customerKey(),
66 consumer_secret: Utils.customerSecret()
70 var name = U1.fixFilename(prop.path);
73 var crd = new Date(); crd.setISO8601(prop.when_created);
74 var chd = new Date(); chd.setISO8601(prop.when_changed);
75 created.text = Qt.formatDateTime(crd, "d/M/yyyy h:mm");
76 changed.text = Qt.formatDateTime(chd, "d/M/yyyy h:mm");
77 size.text = Conv.bytesToSize(prop.size);
78 if(prop && prop.is_public) {
79 url.text = prop.public_url;
83 tip.show(qsTr("Internal error!"));
85 root.properties = prop;
86 if(root.properties && root.properties.is_public) {
89 root.isPublic = false;
93 function setContentType(type)
96 //ctype.font.italic = false;
99 function onErr(status)
103 tip.show(qsTr("Authorization failed!"));
104 } else if(status==0) {
105 tip.show(qsTr("Unable to connect!"));
107 tip.show(qsTr("Error: ")+status);
111 function onRespRename(prop)
113 //console.log("onRespRename");
115 init(prop); pageStack.prevPage().init();
116 tip.show(qsTr("File renamed!"));
119 function onErrRename(status)
124 function onRespStopPublishing(prop)
126 //console.log("onRespStopPublishing");
128 init(prop); pageStack.prevPage().init();
129 tip.show(qsTr("Publishing stopped!"));
132 function onErrStopPublishing(status)
137 function onRespStartPublishing(prop)
139 //console.log("onRespStartPublishing");
141 init(prop); pageStack.prevPage().init();
142 tip.show(qsTr("Publishing started!"));
145 function onErrStartPublishing(status)
153 contentHeight: content.height+Const.SYSTEM_BAR_HEIGHT+Const.TEXT_MARGIN
154 y: Const.SYSTEM_BAR_HEIGHT+Const.TEXT_MARGIN
158 spacing: Const.DEFAULT_MARGIN
164 text: qsTr("File name:")
171 width: root.width - 6*Const.DEFAULT_MARGIN
174 width: root.width-2*Const.TEXT_MARGIN
188 width: root.width-2*Const.TEXT_MARGIN
193 text: qsTr("Created:")
201 width: root.width-2*Const.TEXT_MARGIN
206 text: qsTr("Changed:")
214 width: root.width-2*Const.TEXT_MARGIN
215 visible: root.isPublic
220 text: qsTr("Public URL:")
221 visible: root.isPublic
228 width: root.width - 6*Const.DEFAULT_MARGIN
229 visible: root.isPublic
234 visible: root.isPublic
236 Utils.setClipboardText(url.text);
237 tip.show(qsTr("Public URL copied to clipboard!"));
244 text: qsTr("Preview:")
247 color: Const.TRANSPARENT
248 height: 200; width: 200
249 border.color: Const.DEFAULT_FOREGROUND_COLOR
263 folder: Utils.lastFolder()=="" ? Const.DEFAULT_FOLDER : Utils.lastFolder()
265 fileSelector.state = "invisible";
266 U1.getFileContent(secrets,root,properties.content_path,folder,properties.size,Utils);
267 Utils.setLastFolder(folder);
274 text: qsTr("Delete file?")
275 onOpened: mask.state = "dialog"
280 U1.deleteFile(secrets,properties.resource_path,root,Utils);
283 onCanceled: mask.state = "idle"
287 id: dialogStopPublish
289 text: qsTr("Stop publishing?")
290 onOpened: mask.state = "dialog"
295 var currentPath = root.properties.resource_path;
296 U1.stopPublishing(root.secrets,currentPath,root);
299 onCanceled: mask.state = "idle"
303 id: dialogStartPublish
305 text: qsTr("Start publishing?")
306 onOpened: mask.state = "dialog"
311 var currentPath = root.properties.resource_path;
312 U1.startPublishing(root.secrets,currentPath,root);
315 onCanceled: mask.state = "idle"
319 function getParentPath(path) {
322 var ind = path.lastIndexOf("/");
324 ppath = path.substr(0,ind);
326 if(path=="") ppath = "/";
328 //console.log(ppath);
333 var l=0; var r=s.length -1;
334 while(l < s.length && s[l] == ' ')
336 while(r > l && s[r] == ' ')
338 return s.substring(l, r+1);
344 textWidth: root.width - 4*Const.DEFAULT_MARGIN
345 label: qsTr("Enter new file name:")
346 placeholderText: filename.text
349 Utils.setOrientation("auto");
350 mask.state = "dialog";
354 Utils.setOrientation(root.orientation);
358 var currentPath = root.properties.resource_path;
359 var targetPath = getParentPath(root.properties.path)+"/"+resp;
360 //console.log("targetPath: "+targetPath);
361 U1.renameFile(secrets,currentPath,targetPath,root);;
363 tip.show(qsTr("Invalid file name!"))
367 Utils.setOrientation(root.orientation);