Revision 36:7e514685de80
b/src/pithos/content/localfile.js | ||
---|---|---|
20 | 20 |
var r_username = connection_obj.user_homepage().username; |
21 | 21 |
|
22 | 22 |
// set standard attributes |
23 |
dir_obj.name = file.leafName;
|
|
23 |
dir_obj.directoryName = file.leafName;
|
|
24 | 24 |
dir_obj.owner = r_username; |
25 | 25 |
dir_obj.deleted = false; |
26 | 26 |
dir_obj.createdBy = r_username; |
... | ... | |
80 | 80 |
try { |
81 | 81 |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); |
82 | 82 |
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); |
83 |
|
|
84 | 83 |
file.initWithPath(path); |
85 |
file_obj.name = file.leafName; |
|
84 |
|
|
85 |
if (file.isFile()) { |
|
86 |
file_obj.name = file.leafName; |
|
87 |
} else { |
|
88 |
file_obj.directoryName = file.leafName; |
|
89 |
} |
|
90 |
|
|
86 | 91 |
file_obj.owner = connection_obj.username; |
87 | 92 |
file_obj.creationDate = file.lastModifiedTime; |
88 | 93 |
file_obj.modificationDate = file.lastModifiedTime; |
b/src/pithos/content/login/pithos-login.html | ||
---|---|---|
1 | 1 |
<html> |
2 | 2 |
<head> |
3 | 3 |
<title>Pithos Firefox Plug-in</title> |
4 |
<script type="text/javascript" src="chrome://pithos/content/moz.js"/> |
|
5 |
|
|
6 |
<!-- FireFox BUG !!!!!!!!!!!!!! --> |
|
7 |
<!-- If this is not present, then the script on BODY will not execute !!!!! --> |
|
8 |
<script type="text/javascript"> |
|
9 |
</script> |
|
4 | 10 |
</head> |
11 |
|
|
5 | 12 |
<body> |
6 | 13 |
<script type="application/x-javascript"> |
7 |
window.setTimeout('update();', 10000); |
|
8 |
var attempts = 0; |
|
9 |
|
|
10 |
function update() { |
|
11 |
if( checkCookie('.pithos.grnet.gr', '_gss_a') ) { |
|
14 |
function hasCookie() { |
|
15 |
return moz.hasCookieByHostAndName('.pithos.grnet.gr', '_gss_a'); |
|
16 |
} |
|
17 |
|
|
18 |
function checkAndReplace() { |
|
19 |
if( hasCookie() ) { |
|
12 | 20 |
window.location.replace('chrome://pithos/content/pithos.xul'); |
13 |
} else { |
|
14 |
attempts++; |
|
15 |
window.setTimeout('update();', 3000); |
|
16 |
if (attempts % 10 == 0) { |
|
17 |
alert('Cannot launch pithos file manager (' + (3*attempts) + ' seconds passed)'); |
|
21 |
return true; |
|
22 |
} |
|
23 |
|
|
24 |
return false; |
|
25 |
} |
|
26 |
|
|
27 |
// Just in case we are already logged-in and the user wants one more tab. |
|
28 |
// Then it is up to the network how fast we get to the directory listing. |
|
29 |
var allRight = checkAndReplace(); |
|
30 |
|
|
31 |
if( !allRight ) { |
|
32 |
var attempts = 0; |
|
33 |
|
|
34 |
function update() { |
|
35 |
if( !checkAndReplace() ) { |
|
36 |
attempts++; |
|
37 |
window.setTimeout('update();', 1000); |
|
38 |
if (attempts % 30 == 0) { |
|
39 |
alert('Cannot open Pithos File Manager (' + attempts + ' seconds passed)'); |
|
40 |
} |
|
18 | 41 |
} |
19 | 42 |
} |
43 |
|
|
44 |
window.setTimeout('update();', 1000); |
|
20 | 45 |
} |
21 |
|
|
22 |
function checkCookie(uri, name) { |
|
23 |
// Allow access to cookie database of browser |
|
24 |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); |
|
25 | 46 |
|
26 |
var cookieManager = Components.classes["@mozilla.org/cookiemanager;1"].getService(Components.interfaces.nsICookieManager); |
|
27 |
var menum = cookieManager.enumerator; |
|
28 |
while (menum.hasMoreElements()){ |
|
29 |
var cookie = menum.getNext().QueryInterface(Components.interfaces.nsICookie); |
|
30 |
if ( (cookie.host == uri) && (cookie.name == name) ) { |
|
31 |
return true; |
|
32 |
} |
|
33 |
} |
|
34 |
|
|
35 |
return false; |
|
36 |
} |
|
37 | 47 |
</script> |
38 | 48 |
<iframe src="http://pithos.grnet.gr/pithos/login?next=http://pithos.grnet.gr/pithos/login" width="100%" height="100%" /> |
39 | 49 |
</body> |
b/src/pithos/content/moz.js | ||
---|---|---|
1 |
function Mozilla() { |
|
2 |
var mozThis = this |
|
3 |
|
|
4 |
this.classes = Components.classes; |
|
5 |
this.interfaces = Components.interfaces; |
|
6 |
|
|
7 |
this.newComponent = function(name, interf) { |
|
8 |
return this.classes[name].createInstance(interf); |
|
9 |
} |
|
10 |
|
|
11 |
// Just for convenience |
|
12 |
this.getComponent = this.newComponent; |
|
13 |
|
|
14 |
this.getService = function(name, interf) { |
|
15 |
return this.classes[name].getService(interf); |
|
16 |
} |
|
17 |
|
|
18 |
this.windowMediator = this.getService("@mozilla.org/appshell/window-mediator;1", this.interfaces.nsIWindowMediator); |
|
19 |
this.mainWindow = this.windowMediator.getMostRecentWindow("navigator:browser"); |
|
20 |
this.mainWindowBrowser = this.mainWindow.getBrowser(); |
|
21 |
|
|
22 |
this.newBrowserTab = function(label, url, activate) { |
|
23 |
var browser = this.mainWindowBrowser |
|
24 |
var tab = browser.addTab(url); |
|
25 |
tab.label = label; |
|
26 |
if (activate) { |
|
27 |
browser.selectedTab = tab; |
|
28 |
//browser.focus(); |
|
29 |
} |
|
30 |
return tab; |
|
31 |
} |
|
32 |
|
|
33 |
this.newLocalFile = function(path) { |
|
34 |
var file = this.newComponent("@mozilla.org/file/local;1", this.interfaces.nsILocalFile); |
|
35 |
if (path != undefined) { |
|
36 |
file.initWithPath(path) |
|
37 |
} |
|
38 |
return file; |
|
39 |
} |
|
40 |
|
|
41 |
this.getCookieManager = function() { |
|
42 |
return this.getService("@mozilla.org/cookiemanager;1", this.interfaces.nsICookieManager); |
|
43 |
} |
|
44 |
|
|
45 |
this.findCookieByHostAndName = function(host, name) { |
|
46 |
var menum = this.getCookieManager().enumerator; |
|
47 |
while (menum.hasMoreElements()) { |
|
48 |
var cookie = menum.getNext().QueryInterface(Components.interfaces.nsICookie); |
|
49 |
if ( (cookie.host == host) && (cookie.name == name) ) { |
|
50 |
return cookie; |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
return undefined; |
|
55 |
} |
|
56 |
|
|
57 |
this.hasCookieByHostAndName = function(host, name) { |
|
58 |
return this.findCookieByHostAndName(host, name) != undefined; |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
moz = new Mozilla(); |
b/src/pithos/content/operations.js | ||
---|---|---|
6 | 6 |
} else { |
7 | 7 |
if( create_folder(source_directory, new_directory) ) { |
8 | 8 |
alert(source_directory + '/' + new_directory + ' - created'); |
9 |
pithos_object.refreshLists(); |
|
10 |
|
|
11 |
return true; |
|
9 |
pithos_object.refreshLists(); |
|
10 |
return; |
|
12 | 11 |
} else { |
13 | 12 |
alert(source_directory + '/' + new_directory + ' - Directory creation failed'); |
14 | 13 |
} |
15 | 14 |
} |
16 |
|
|
17 |
return false; |
|
18 | 15 |
} |
19 | 16 |
|
20 | 17 |
function copy_event() { |
... | ... | |
30 | 27 |
|
31 | 28 |
if (resources.length == 0) { |
32 | 29 |
alert('No File/Directory is selected'); |
33 |
return false;
|
|
30 |
return; |
|
34 | 31 |
} |
35 | 32 |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); |
36 | 33 |
var prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); |
... | ... | |
43 | 40 |
b = prompt.confirm(window, "Failed!", "Deletion of " + resources[i] + " failed. Continue?"); |
44 | 41 |
if (!b) { |
45 | 42 |
alert('Action canceled'); |
46 |
return false;
|
|
43 |
return; |
|
47 | 44 |
} |
48 | 45 |
} |
49 | 46 |
} |
50 | 47 |
} else { |
51 | 48 |
alert('Action canceled'); |
52 | 49 |
} |
50 |
alert('Removed ' + resources.length + ' items.'); |
|
53 | 51 |
pithos_object.refreshLists(); |
54 |
|
|
55 |
return true; |
|
52 |
} |
|
53 |
|
|
54 |
function delete_context_menu(uri) { |
|
55 |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); |
|
56 |
var prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); |
|
57 |
var result = prompt.confirm(window, "Confirm action", "Delete " + uri + "?"); |
|
58 |
if ( result ) { |
|
59 |
var b = delete_resource(uri); |
|
60 |
if (!b) { |
|
61 |
alert('Cannot delete ' + uri); |
|
62 |
return; |
|
63 |
} |
|
64 |
} else { |
|
65 |
alert('Action canceled'); |
|
66 |
} |
|
67 |
pithos_object.refreshLists(); |
|
56 | 68 |
} |
57 | 69 |
|
58 | 70 |
function home_event() { |
b/src/pithos/content/overlay/overlay.js | ||
---|---|---|
15 | 15 |
onMenuItemCommand: function(e) { |
16 | 16 |
//var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); |
17 | 17 |
//promptService.alert(window, this.strings.getString("helloMessageTitle"), this.strings.getString("helloMessage")); |
18 |
window.open('chrome://pithos/content/login/pithos-login.html'); |
|
18 |
moz.newBrowserTab('Pithos File Manager', 'chrome://pithos/content/login/pithos-login.html', true); |
|
19 |
//window.open('chrome://pithos/content/login/pithos-login.html'); |
|
19 | 20 |
}, |
20 | 21 |
|
21 | 22 |
onToolbarButtonCommand: function(e) { |
b/src/pithos/content/overlay/overlay.xul | ||
---|---|---|
3 | 3 |
<!DOCTYPE overlay SYSTEM "chrome://pithos/locale/pithos.dtd"> |
4 | 4 |
<overlay id="pithos-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
5 | 5 |
<head> |
6 |
<script src="../moz.js"/> |
|
6 | 7 |
<script src="overlay.js"/> |
7 | 8 |
</head> |
8 | 9 |
<stringbundleset id="stringbundleset"> |
b/src/pithos/content/pithos.js | ||
---|---|---|
5 | 5 |
window.location.replace('https://pithos.grnet.gr/Shibboleth.sso/Logout'); |
6 | 6 |
} |
7 | 7 |
|
8 |
/* |
|
8 | 9 |
function open_shared() { |
9 | 10 |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); |
10 | 11 |
window.openDialog("shared/shared.xul", "Shared Folders/Files", "chrome,modal,dialog,resizable,centerscreen"); |
11 | 12 |
} |
13 |
*/ |
|
12 | 14 |
|
13 | 15 |
function open_trash() { |
14 | 16 |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); |
... | ... | |
113 | 115 |
} else { |
114 | 116 |
document.getElementById('tree-files-left').focus(); |
115 | 117 |
} |
116 |
} |
|
118 |
} |
|
119 |
|
|
120 |
function populatePopupMenu(){ |
|
121 |
var milist = document.getElementById('treepopupmenu'); |
|
122 |
var selection = pithos_object.getCurrentSelection(); |
|
123 |
var resource = vfs.getResourceMetadata(selection); |
|
124 |
|
|
125 |
while (milist.hasChildNodes()) { |
|
126 |
milist.removeChild(milist.firstChild); |
|
127 |
} |
|
128 |
|
|
129 |
// populate menupopup |
|
130 |
if (vfs.isDirectory(selection)) { |
|
131 |
addItem(resource.directoryName + " <folder>", ''); |
|
132 |
} else { |
|
133 |
addItem(resource.name + " <file>", ''); |
|
134 |
} |
|
135 |
|
|
136 |
addSeparator(); |
|
137 |
|
|
138 |
if ( connection_obj.get_shared_data().indexOf(selection) >= 0 ) { |
|
139 |
addItem('unshare', ''); |
|
140 |
} else { |
|
141 |
addItem('share', ''); |
|
142 |
} |
|
143 |
|
|
144 |
addItem('rename', ''); |
|
145 |
addItem('delete', "delete_context_menu('" + selection + "');"); |
|
146 |
|
|
147 |
addSeparator(); |
|
148 |
|
|
149 |
addItem('properties', ''); |
|
150 |
|
|
151 |
// helper functions |
|
152 |
function addSeparator() { |
|
153 |
var mi = document.createElement('menuseparator'); |
|
154 |
milist.appendChild(mi); |
|
155 |
} |
|
156 |
|
|
157 |
function addItem(item_label, item_action) { |
|
158 |
var mi = document.createElement('menuitem'); |
|
159 |
mi.setAttribute('label', item_label); |
|
160 |
mi.setAttribute('onclick', item_action); |
|
161 |
milist.appendChild(mi); |
|
162 |
} |
|
163 |
} |
b/src/pithos/content/pithos.xul | ||
---|---|---|
9 | 9 |
<script type="application/x-javascript" src="lib/json2.js" /> |
10 | 10 |
<script type="application/x-javascript" src="lib/sha1.js" /> |
11 | 11 |
<!-- Load our libraries --> |
12 |
<script type="application/x-javascript" src="pithos.js" /> |
|
12 |
<script type="application/x-javascript" src="moz.js" /> |
|
13 |
<script type="application/x-javascript" src="pithos.js" /> |
|
13 | 14 |
<script type="application/x-javascript" src="connection.js" /> |
14 | 15 |
<script type="application/x-javascript" src="file.js" /> |
15 | 16 |
<script type="application/x-javascript" src="mimes.js" /> |
... | ... | |
31 | 32 |
<key id="arrow" keycode="VK_LEFT" oncommand="alert('Left arrow pressed');" /> |
32 | 33 |
</keyset> |
33 | 34 |
<popupset> |
34 |
<menupopup id="treepopupmenu"> |
|
35 |
<menuitem label="item1" /> |
|
36 |
<menuitem label="item2" /> |
|
37 |
</menupopup> |
|
35 |
<menupopup id="treepopupmenu" onpopupshowing="populatePopupMenu();"> |
|
36 |
<!-- add items here --> |
|
37 |
</menupopup> |
|
38 | 38 |
</popupset> |
39 | 39 |
<!-- Window boxes --> |
40 | 40 |
<toolbar id="toolbarid"> |
b/src/pithos/content/pithos_object.js | ||
---|---|---|
44 | 44 |
source_tree.focus(); |
45 | 45 |
} |
46 | 46 |
|
47 |
this.getCurrentSelection = function() { |
|
48 |
return source_tree_children.children_tag.childNodes[source_tree.currentIndex].childNodes[0].id; |
|
49 |
} |
|
50 |
|
|
47 | 51 |
this.getSelectedResources = function() { |
48 | 52 |
var results = new Array(); |
49 | 53 |
var rowCount = source_tree.view.rowCount; |
b/src/pithos/content/util.js | ||
---|---|---|
95 | 95 |
|
96 | 96 |
if (isWindows()) { |
97 | 97 |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); |
98 |
var root = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); |
|
98 |
var root = null; //Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
|
|
99 | 99 |
try { |
100 |
root.initWithPath("\\\\.");
|
|
100 |
root = moz.newLocalFile("\\\\.");
|
|
101 | 101 |
} catch(error) { |
102 | 102 |
alert('ERROR: Cannot enumerate available drives'); |
103 | 103 |
return drives; |
b/src/pithos/content/vfs.js | ||
---|---|---|
31 | 31 |
} |
32 | 32 |
} |
33 | 33 |
if ( isLocalDirectory(uri) ) { |
34 |
fm_obj = loadLocalFile(uri); |
|
34 |
if (vfs.isDirectory(uri)) { |
|
35 |
fm_obj = load_local_directory(uri); |
|
36 |
} else { |
|
37 |
fm_obj = loadLocalFile(uri); |
|
38 |
} |
|
35 | 39 |
} |
36 | 40 |
|
37 | 41 |
return fm_obj; |
38 | 42 |
} |
39 | 43 |
|
44 |
this.isDirectory = function(uri) { |
|
45 |
if (isRemoteDirectory(uri)) { |
|
46 |
return (uri.charAt(uri.length - 1) == '/'); |
|
47 |
} else if (isLocalDirectory(uri)) { |
|
48 |
try { |
|
49 |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); |
|
50 |
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); |
|
51 |
file.initWithPath(uri); |
|
52 |
return file.isDirectory(); |
|
53 |
} catch (error) { |
|
54 |
return false; |
|
55 |
} |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
this.isFile = function(uri) { |
|
60 |
return !this.isDirectory(uri); |
|
61 |
} |
|
62 |
|
|
40 | 63 |
// private methods |
41 | 64 |
function load_directory_sync(uri) { |
42 | 65 |
var d = cache.get(uri); |
Also available in: Unified diff