Revision 29:ec9750e9cceb
b/.hgignore | ||
---|---|---|
1 | 1 |
syntax: glob |
2 | 2 |
|
3 |
.DS_Store/ |
|
3 |
.DS_Store/ |
|
4 |
.idea/ |
|
5 |
*.iml |
b/src/pithos/content/cache.js | ||
---|---|---|
27 | 27 |
if (((d.getTime() - e) > expiration) || (e == 0)) { |
28 | 28 |
cacheMap[key] = undefined; |
29 | 29 |
cacheExpired[key] = 0; |
30 |
|
|
30 | 31 |
return undefined; |
31 | 32 |
} |
32 | 33 |
|
b/src/pithos/content/connection.js | ||
---|---|---|
1 |
connection_obj = null; |
|
1 |
connection_obj = null;
|
|
2 | 2 |
|
3 | 3 |
function ConnectionObject() { |
4 | 4 |
// public properties |
... | ... | |
60 | 60 |
return d; |
61 | 61 |
} |
62 | 62 |
|
63 |
// accepts |
|
63 |
this.load_file_metadata = function(uri) { |
|
64 |
var fm_obj = null; |
|
65 |
|
|
66 |
if ( isRemoteDirectory(uri) ) { |
|
67 |
var req = this.rest_request_get(uri); |
|
68 |
|
|
69 |
} else if ( isLocalDirectory(uri) ) { |
|
70 |
fm_obj = loadLocalFile(uri); |
|
71 |
} |
|
72 |
|
|
73 |
return fm_obj; |
|
74 |
} |
|
75 |
|
|
64 | 76 |
this.create_request_get = function(rest_req) { |
65 | 77 |
if ( isRemoteDirectory(rest_req) ) { |
66 | 78 |
var gmtstring = (new Date()).toGMTString(); |
67 | 79 |
var sign_url = rest_req.replace(this.rest_url, ""); |
68 |
return rest_req + '?Date=' + gmtstring + '&Authorization=' + this.username + ' ' + sign(this.token, sign_url, gmtstring); |
|
80 |
var hash = sign(this.token, sign_url, gmtstring); |
|
81 |
|
|
82 |
return rest_req + ('?Date=' + encodeURIComponent(gmtstring) + '&Authorization=' + this.username + '%20' + encodeURIComponent(hash)); |
|
69 | 83 |
} else { |
70 | 84 |
if ( isUnix() ) { |
71 | 85 |
return 'file://' + rest_req; |
... | ... | |
86 | 100 |
return rest_request_generic(rest_req, "POST", data, false, null, null, null); |
87 | 101 |
} |
88 | 102 |
|
103 |
this.rest_request_get = function(rest_req) { |
|
104 |
return this.rest_request_sync(rest_req); |
|
105 |
} |
|
106 |
|
|
89 | 107 |
this.rest_request_sync = function(rest_req) { |
90 | 108 |
return rest_request_generic(rest_req, "GET", null, false, null, null, null); |
91 | 109 |
} |
... | ... | |
116 | 134 |
} |
117 | 135 |
req.setRequestHeader('Authorization', current.username + " " + sign(current.token, sign_url, gmtstring)); |
118 | 136 |
req.setRequestHeader('X-GSS-Date', gmtstring); |
137 |
|
|
119 | 138 |
if (method == "GET" || method == "HEAD") { |
120 | 139 |
req.send(null); |
121 | 140 |
} |
... | ... | |
129 | 148 |
return req; |
130 | 149 |
} |
131 | 150 |
|
132 |
function check_null_result(r,d) { |
|
151 |
function check_null_result(r, d) {
|
|
133 | 152 |
var res = r.exec(d); |
134 | 153 |
if (res == null) { return 'ERROR: no connection data'; } |
135 | 154 |
|
... | ... | |
226 | 245 |
|
227 | 246 |
/* |
228 | 247 |
[{"username":"ebstest@grnet-hq.admin.grnet.gr","uri":"http://pithos.grnet.gr/pithos/rest/aaitest@grnet-hq.admin.grnet.gr/others/ebstest@grnet-hq.admin.grnet.gr"},{"username":"louridas@grnet-hq.admin.grnet.gr","uri":"http://pithos.grnet.gr/pithos/rest/aaitest@grnet-hq.admin.grnet.gr/others/louridas@grnet-hq.admin.grnet.gr"}] |
229 |
*/ |
|
248 |
*/ |
b/src/pithos/content/file.js | ||
---|---|---|
40 | 40 |
|
41 | 41 |
function load_permissions() { |
42 | 42 |
// Sometimes, permissions do not exist in the JSON object! check if it is available before parsing |
43 |
|
|
44 | 43 |
if (!dlist.permissions){ |
45 | 44 |
|
46 | 45 |
current.permissions = new Array(); |
b/src/pithos/content/localfile.js | ||
---|---|---|
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
return dir_obj; |
64 |
} |
|
64 |
} |
|
65 |
|
|
66 |
function loadLocalFile(path) { |
|
67 |
var file_obj = new Object(); |
|
68 |
|
|
69 |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); |
|
70 |
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); |
|
71 |
try { |
|
72 |
file_obj.initWithPath(path); |
|
73 |
file_obj.name = file.leafName; |
|
74 |
file_obj.owner = connection_obj.username; |
|
75 |
file_obj.creationDate = file.lastModifiedTime; |
|
76 |
file_obj.modificationDate = file.lastModifiedTime; |
|
77 |
file_obj.size = file.fileSize; |
|
78 |
file_obj.content = mimes.getByExtension(file_obj.name); |
|
79 |
file_obj.version = 0; |
|
80 |
file_obj.uri = file.path; |
|
81 |
file_obj.path = file.path; |
|
82 |
} catch(error) { |
|
83 |
alert('Could load path - ' + path); |
|
84 |
} |
|
85 |
|
|
86 |
|
|
87 |
return file_obj; |
|
88 |
} |
b/src/pithos/content/operations.js | ||
---|---|---|
1 |
function create_folder() { |
|
1 |
function create_folder(source, folder_name) { |
|
2 |
return false; |
|
3 |
} |
|
4 |
|
|
5 |
function copy(sources, destination) { |
|
6 |
return false; |
|
7 |
} |
|
8 |
|
|
9 |
function move(source, destination) { |
|
10 |
return false; |
|
11 |
} |
|
12 |
|
|
13 |
function delete(source) { |
|
2 | 14 |
return false; |
3 | 15 |
} |
b/src/pithos/content/pithos.js | ||
---|---|---|
10 | 10 |
window.showModalDialog("shared/shared.xul", undefined, "dialogwidth: 640; dialogheight:480"); |
11 | 11 |
} |
12 | 12 |
|
13 |
function open_trash() { |
|
14 |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); |
|
15 |
window.showModalDialog("trash/trash.xul", undefined, "dialogwidth: 640; dialogheight:480"); |
|
16 |
} |
|
17 |
|
|
13 | 18 |
function TreeModel(tree_id) { |
14 | 19 |
// public members |
15 | 20 |
this.children_tag = document.getElementById(tree_id); |
b/src/pithos/content/pithos.xul | ||
---|---|---|
7 | 7 |
<!-- Load the standard libraries --> |
8 | 8 |
<script type="application/x-javascript" src="lib/jquery-1.3.2.min.js" /> |
9 | 9 |
<script type="application/x-javascript" src="lib/json2.js" /> |
10 |
<script type="application/x-javascript" src="lib/sha1.js" />
|
|
10 |
<script type="application/x-javascript" src="lib/sha1.js" /> |
|
11 | 11 |
<!-- Load our libraries, order matters --> |
12 | 12 |
<script type="application/x-javascript" src="pithos.js" /> |
13 | 13 |
<script type="application/x-javascript" src="connection.js" /> |
... | ... | |
26 | 26 |
<!-- <toolbarbutton id="toolbarbutton-setings" label="Settings" image="../skin/settingsgray.png" /> --> |
27 | 27 |
<toolbarbutton id="toolbarbutton-group" label="Groups" image="../skin/groupsgray.png" /> |
28 | 28 |
<toolbarbutton id="toolbarbutton-shared" label="Shared" image="../skin/gss/folder_blue.png" onclick="open_shared()" /> |
29 |
<toolbarbutton id="toolbarbutton-trash" label="Trash" image="../skin/gss/trashcan_empty.png" /> |
|
29 |
<toolbarbutton id="toolbarbutton-trash" label="Trash" image="../skin/gss/trashcan_empty.png" onclick="open_trash()" />
|
|
30 | 30 |
<spacer flex="1" /> |
31 | 31 |
<image src="../skin/pithos-grnet-full.png" width="200" height="30" /> |
32 | 32 |
</toolbar> |
b/src/pithos/content/trash/init.js | ||
---|---|---|
1 |
connection_obj = null; |
|
2 |
mimes = null; |
|
3 |
cache = null; |
|
4 |
|
|
5 |
function init() { |
|
6 |
// public properties |
|
7 |
connection_obj = new ConnectionObject(); |
|
8 |
mimes = new Mimes(); |
|
9 |
cache = new FileCache(); |
|
10 |
|
|
11 |
// run initialization |
|
12 |
|
|
13 |
populateList(); |
|
14 |
|
|
15 |
} |
|
16 |
|
b/src/pithos/content/trash/trash.js | ||
---|---|---|
1 |
// function to create the trash list entries according to the template shown below |
|
2 |
function createListEntry(trashitem,mimeicon) { |
|
3 |
|
|
4 |
/* This code creates vbox entries like the following |
|
5 |
<vbox flex="1" class="trashtitle" onclick="trashClickOnce(event);"> |
|
6 |
<hbox> |
|
7 |
<label value="foo.pdf"/> |
|
8 |
</hbox> |
|
9 |
<hbox class="deletebutton" align="right" collapsed="true"> |
|
10 |
<button label="Delete" disabled="false" /> |
|
11 |
</hbox> |
|
12 |
</vbox> |
|
13 |
*/ |
|
14 |
var h0 = document.createElement('hbox'); |
|
15 |
$mb(h0).attr({ |
|
16 |
flex: "1", |
|
17 |
align: "center", |
|
18 |
class: 'trashtitle', |
|
19 |
onclick: 'trashClickOnce(event);' |
|
20 |
}); |
|
21 |
|
|
22 |
var v1 = document.createElement('vbox'); |
|
23 |
|
|
24 |
$mb(v1).attr({ |
|
25 |
flex: "1" |
|
26 |
}); |
|
27 |
|
|
28 |
$mb('#mainpane').append(h0); |
|
29 |
i1 = document.createElement('image'); |
|
30 |
$mb(i1).attr({ |
|
31 |
src : mimeicon |
|
32 |
}); |
|
33 |
$mb(h0).append(i1); |
|
34 |
$mb(h0).append(v1); |
|
35 |
|
|
36 |
h1 = document.createElement('hbox'); |
|
37 |
l1 = document.createElement('label'); |
|
38 |
b1 = document.createElement('button'); |
|
39 |
|
|
40 |
h2 = document.createElement('hbox'); |
|
41 |
|
|
42 |
$mb(v1).append(h1); |
|
43 |
|
|
44 |
$mb(h1).append(l1); |
|
45 |
$mb(l1).attr({ |
|
46 |
value : trashitem.name |
|
47 |
}); |
|
48 |
|
|
49 |
$mb(v1).append(h2); |
|
50 |
$mb(h2).attr({ |
|
51 |
class:'trashbutton', |
|
52 |
align: "right", |
|
53 |
collapsed: "true" |
|
54 |
}); |
|
55 |
$mb(b1).attr({ |
|
56 |
label: 'Delete', |
|
57 |
onclick: 'deleteTrashElement(event)' |
|
58 |
}); |
|
59 |
$mb(h2).append(b1); |
|
60 |
$mb(v1).attr({ |
|
61 |
label: "expandDelete", |
|
62 |
disabled : "False" |
|
63 |
}); |
|
64 |
|
|
65 |
} |
|
66 |
|
|
67 |
// create an hbox+label displaying the category i.e. "FILES" or "DIRECTORIES" |
|
68 |
function createSection(labelname) { |
|
69 |
var h1 = document.createElement('hbox'); |
|
70 |
var l1 = document.createElement('label'); |
|
71 |
$mb(h1).attr({ |
|
72 |
flex: "1", |
|
73 |
class: "sectionlabel" |
|
74 |
}); |
|
75 |
$mb(l1).attr({ |
|
76 |
value: labelname |
|
77 |
}); |
|
78 |
|
|
79 |
$mb('#mainpane').append(h1); |
|
80 |
$mb(h1).append(l1); |
|
81 |
} |
|
82 |
|
|
83 |
function populateList() { |
|
84 |
// connection_obj.load_directory_sync(connection_obj.user_homepage().shared) |
|
85 |
|
|
86 |
//private properties |
|
87 |
var trashDirectory = connection_obj.load_directory_sync(connection_obj.user_homepage().trash); |
|
88 |
|
|
89 |
var $mb = jQuery.noConflict(); |
|
90 |
|
|
91 |
var trashFilesArray = trashDirectory.files; |
|
92 |
var trashDirsArray = trashDirectory.folders; |
|
93 |
|
|
94 |
createSection('Folders'); |
|
95 |
// walk through and display the directories |
|
96 |
trashDirsArray.forEach( function(trashdir) { |
|
97 |
// get the mimetype and relevant icon for each file |
|
98 |
var mimetype = mimes.getByExtension(trashdir.name); |
|
99 |
var mimeicon = '../' + mimes.getMime(mimetype); |
|
100 |
createListEntry(trashdir,mimeicon); |
|
101 |
}); |
|
102 |
|
|
103 |
createSection('Files'); |
|
104 |
// walk through and display the files |
|
105 |
trashFilesArray.forEach( function(trashfile) { |
|
106 |
// get the mimetype and relevant icon for each file |
|
107 |
var mimetype = mimes.getByExtension(trashfile.name); |
|
108 |
var mimeicon = '../' + mimes.getMime(mimetype); |
|
109 |
createListEntry(trashfile,mimeicon); |
|
110 |
}); |
|
111 |
|
|
112 |
|
|
113 |
} |
|
114 |
// even to display delete button when clicking on folder or file |
|
115 |
function trashClickOnce(event) { |
|
116 |
$mb = jQuery.noConflict(); |
|
117 |
|
|
118 |
//remove the focus from previously selected item marked as id="currenttrash" |
|
119 |
$mb("#currenttrash").css({"background-color": 'white'}); |
|
120 |
$mb("hbox:eq(1)","#currenttrash").attr("collapsed","true"); |
|
121 |
$mb("#currenttrash").removeAttr("id"); |
|
122 |
|
|
123 |
// and now highlight, give id of currenttrash and uncollapse the clicked hbox ... |
|
124 |
$mb(event.currentTarget).css({"background-color": 'lightblue'}); |
|
125 |
$mb("hbox:eq(1)",event.currentTarget).attr("collapsed","false"); |
|
126 |
$mb(event.currentTarget).attr("id","currenttrash"); |
|
127 |
|
|
128 |
} |
|
129 |
|
|
130 |
function deleteTrashElement(event) { |
|
131 |
alert(event.currentTarget); |
|
132 |
} |
|
133 |
|
b/src/pithos/content/trash/trash.xul | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?> |
|
3 |
<?xml-stylesheet href="../../skin/trash.css" type="text/css"?> |
|
4 |
<!DOCTYPE pithos SYSTEM "chrome://pithos/locale/pithos.dtd"> |
|
5 |
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" title="Pithos Trash Files"> |
|
6 |
<head> |
|
7 |
<!-- Load the standard libraries --> |
|
8 |
<script type="application/x-javascript" src="../lib/jquery-1.3.2.min.js" /> |
|
9 |
<script type="application/x-javascript" src="../lib/json2.js" /> |
|
10 |
<script type="application/x-javascript" src="../lib/sha1.js" /> |
|
11 |
<!-- Load our libraries, order matters --> |
|
12 |
<script type="application/x-javascript" src="trash.js" /> |
|
13 |
<script type="application/x-javascript" src="../connection.js" /> |
|
14 |
<script type="application/x-javascript" src="../file.js" /> |
|
15 |
<script type="application/x-javascript" src="../treeutil.js" /> |
|
16 |
<script type="application/x-javascript" src="../mimes.js" /> |
|
17 |
<script type="application/x-javascript" src="../cache.js" /> |
|
18 |
<script type="application/x-javascript" src="../events.js" /> |
|
19 |
<script type="application/x-javascript" src="../util.js" /> |
|
20 |
<script type="application/x-javascript" src="../localfile.js" /> |
|
21 |
<script type="application/x-javascript" src="./init.js" /> |
|
22 |
</head> |
|
23 |
|
|
24 |
<!-- The main pane --> |
|
25 |
<vbox flex="1"> |
|
26 |
<vbox id="mainpane"> |
|
27 |
</vbox> |
|
28 |
<spacer flex="1" /> |
|
29 |
<hbox> |
|
30 |
<button label="Close" onclick="window.close()" /> |
|
31 |
</hbox> |
|
32 |
</vbox> |
|
33 |
|
|
34 |
<!-- this must be executed after the initialization of trash.xul --> |
|
35 |
<script type="application/x-javascript"> |
|
36 |
$mb = jQuery.noConflict(); |
|
37 |
$mb(document).ready(function() { |
|
38 |
init(); |
|
39 |
}); |
|
40 |
</script> |
|
41 |
</window> |
b/src/pithos/content/util.js | ||
---|---|---|
15 | 15 |
return homeDirFile.path; |
16 | 16 |
} |
17 | 17 |
|
18 |
/* This function received an already parsed JSON object and converts it to a formatted string */ |
|
19 |
function jsonToString(jsonobj) { |
|
20 |
return JSON.stringify(jsonobj); |
|
21 |
} |
|
18 | 22 |
function isLocalDirectory(path) { |
19 | 23 |
return !isRemoteDirectory(path); |
20 | 24 |
} |
Also available in: Unified diff