mirror of
https://github.com/fergalmoran/chrometophone.git
synced 2025-12-22 01:30:25 +00:00
FoxToPhone. Compatibility with Seamonkey and folder uploads in Windows. Ready for public test.
This commit is contained in:
@@ -162,7 +162,7 @@ sendtophone.doDrop = function(event)
|
||||
for (var i = 0; i < dt.mozItemCount; i++)
|
||||
{
|
||||
var file = dt.mozGetDataAt("application/x-moz-file", i);
|
||||
if (file instanceof Ci.nsIFile )
|
||||
if (file instanceof Components.interfaces.nsIFile )
|
||||
sendtophoneCore.sendFile(file);
|
||||
else
|
||||
this.alert(this.getString("InvalidFile"));
|
||||
@@ -173,26 +173,31 @@ sendtophone.doDrop = function(event)
|
||||
|
||||
sendtophone.pickFile = function(folder)
|
||||
{
|
||||
var fp = Cc["@mozilla.org/filepicker;1"]
|
||||
.createInstance(Ci.nsIFilePicker);
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
||||
.createInstance(Components.interfaces.nsIFilePicker);
|
||||
|
||||
if (folder)
|
||||
fp.init(window, this.getString("SendFolderToPhone"), Ci.nsIFilePicker.modeGetFolder);
|
||||
fp.init(window, this.getString("SendFolderToPhone"), Components.interfaces.nsIFilePicker.modeGetFolder);
|
||||
else
|
||||
{
|
||||
fp.init(window, this.getString("SendFileToPhone"), Ci.nsIFilePicker.modeOpenMultiple);
|
||||
fp.appendFilters( Ci.nsIFilePicker.filterAll );
|
||||
fp.init(window, this.getString("SendFileToPhone"), Components.interfaces.nsIFilePicker.modeOpenMultiple);
|
||||
fp.appendFilters( Components.interfaces.nsIFilePicker.filterAll );
|
||||
}
|
||||
|
||||
var rv = fp.show();
|
||||
|
||||
if (rv == Ci.nsIFilePicker.returnOK)
|
||||
if (rv == Components.interfaces.nsIFilePicker.returnOK)
|
||||
{
|
||||
var files = fp.files;
|
||||
while (files.hasMoreElements())
|
||||
if (folder)
|
||||
sendtophoneCore.sendFile( fp.file );
|
||||
else
|
||||
{
|
||||
var file = files.getNext().QueryInterface(Ci.nsILocalFile);
|
||||
sendtophoneCore.sendFile( file );
|
||||
var files = fp.files;
|
||||
while (files.hasMoreElements())
|
||||
{
|
||||
var file = files.getNext().QueryInterface(Components.interfaces.nsILocalFile);
|
||||
sendtophoneCore.sendFile( file );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,24 +31,22 @@
|
||||
</groupbox>
|
||||
|
||||
<groupbox style="padding:1em; min-height:10em;" label="FileServer">
|
||||
<caption label="File transfers" />
|
||||
<caption label="&sendtophoneFileTransfers.label;" />
|
||||
<hbox align="center">
|
||||
<label value="Server"
|
||||
<label value="&sendtophoneFileServer.label;"
|
||||
flex="1"
|
||||
control="extensionsSendToPhoneFileServer"/>
|
||||
|
||||
<menulist id="extensionsSendToPhoneFileServer">
|
||||
<menupopup>
|
||||
<menuitem value="" label="None" />
|
||||
<menuitem value="" label="&sendtophoneFileServer.None;" />
|
||||
<menuitem value="http://min.us" label="Min.us" />
|
||||
<menuitem value="Custom" label="Custom" />
|
||||
<menuitem value="Custom" label="&sendtophoneFileServer.Custom;" />
|
||||
</menupopup>
|
||||
</menulist>
|
||||
|
||||
<description style="width: 300px;height:3em;" id="foxtophoneDisclaimer">
|
||||
Disclaimer: We (FoxToPhone developers) are not affiliated
|
||||
with any of the third party hosting services listed here.
|
||||
You should read their Terms Of Service before using them.
|
||||
&sendtophoneFileServer.Disclaimer;
|
||||
</description>
|
||||
</hbox>
|
||||
|
||||
|
||||
@@ -236,11 +236,9 @@ var sendtophone = {
|
||||
initPopup: function()
|
||||
{
|
||||
var fileServerUrl = this.prefs.getCharPref( "fileServerUrl" );
|
||||
if (!fileServerUrl)
|
||||
{
|
||||
document.getElementById("sendtophoneContextMenuSendFiles").hidden = true;
|
||||
document.getElementById("sendtophoneContextMenuSendFolder").hidden = true;
|
||||
}
|
||||
document.getElementById("sendtophoneContextMenuSendFiles").hidden = !fileServerUrl;
|
||||
document.getElementById("sendtophoneContextMenuSendFolder").hidden = !fileServerUrl;
|
||||
|
||||
document.getElementById("sendtophoneContextMenuSendClipboard").disabled = !this.clipboardHasText();
|
||||
|
||||
// returning true will make the popup show
|
||||
|
||||
@@ -34,6 +34,8 @@ let gUploadListener = {
|
||||
|
||||
// If no more pending uploads, close the tab.
|
||||
// Use a 0 ms timeout to avoid flicker while compress -> upload a folder
|
||||
// The trick won't work if in order to upload the file itself we have to perform an extra request before
|
||||
// (like creating a gallery in min.us)
|
||||
let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
checkTimer.initWithCallback( this.checkTimerEvent, 0, Ci.nsITimer.TYPE_ONE_SHOT );
|
||||
},
|
||||
@@ -42,7 +44,7 @@ let gUploadListener = {
|
||||
{
|
||||
notify: function(timer)
|
||||
{
|
||||
if (!sendtophoneUploadsManager.isWindowNeeded())
|
||||
if (!sendtophoneUploadsManager.isWindowNeeded(true))
|
||||
{
|
||||
if (gUploadListener.UploadsView.children.length==0)
|
||||
window.close();
|
||||
|
||||
@@ -22,3 +22,8 @@
|
||||
<!ENTITY sendtophoneContextSendClipboard.accesskey "C">
|
||||
<!ENTITY sendtophoneContextVideo.label "Send Video to Android">
|
||||
<!ENTITY sendtophoneContextVideo.accesskey "V">
|
||||
<!ENTITY sendtophoneFileTransfers.label "File transfers">
|
||||
<!ENTITY sendtophoneFileServer.label "Server">
|
||||
<!ENTITY sendtophoneFileServer.None "None">
|
||||
<!ENTITY sendtophoneFileServer.Custom "Custom">
|
||||
<!ENTITY sendtophoneFileServer.Disclaimer "Disclaimer: We (FoxToPhone developers) are not affiliated with any of the third party hosting services listed here. You should read their Terms Of Service before using them.">
|
||||
|
||||
@@ -22,3 +22,8 @@
|
||||
<!ENTITY sendtophoneContextSendClipboard.accesskey "C">
|
||||
<!ENTITY sendtophoneContextVideo.label "Enviar video a Android">
|
||||
<!ENTITY sendtophoneContextVideo.accesskey "V">
|
||||
<!ENTITY sendtophoneFileTransfers.label "Envío de ficheros">
|
||||
<!ENTITY sendtophoneFileServer.label "Servidor">
|
||||
<!ENTITY sendtophoneFileServer.None "Ninguno">
|
||||
<!ENTITY sendtophoneFileServer.Custom "Personalizado">
|
||||
<!ENTITY sendtophoneFileServer.Disclaimer "Aviso: Nosotros (los desarrolladores de Fox to Phone) no estamos relacionados con ninguno de los servidores de alojamiento mostrados aquí. Debes leer sus Terminos de Servicio antes de usarlos.">
|
||||
|
||||
@@ -393,7 +393,7 @@ var sendtophoneCore = {
|
||||
sendtophoneUploadsManager.finishedUpload( progressId );
|
||||
|
||||
// Send the zip and delete it afterwards
|
||||
sendtophoneCore.sendFile(nsZip, function() { nsZip.remove(false); });
|
||||
sendtophoneCore.sendFile(nsZip, function() { nsZip.remove(false); if (callback) callback(); } );
|
||||
}
|
||||
);
|
||||
return;
|
||||
|
||||
@@ -158,10 +158,14 @@ var sendtophoneUploadsManager = {
|
||||
// or there's some file that might take longer than 2 seconds.
|
||||
// If there's some file that we still don't know the speed
|
||||
// then consider it also as needed.
|
||||
isWindowNeeded: function()
|
||||
isWindowNeeded: function( alreadyOpen )
|
||||
{
|
||||
for (let id in this.uploads)
|
||||
{
|
||||
// If the progress window is already open and there's something pending then leave the window open
|
||||
if (alreadyOpen)
|
||||
return true;
|
||||
|
||||
let upload = this.uploads[id] ;
|
||||
|
||||
// zipping folder: if takes so long to compress it, it will also take some time to upload it
|
||||
@@ -198,7 +202,7 @@ var showTimerEvent =
|
||||
{
|
||||
notify: function(timer)
|
||||
{
|
||||
if (sendtophoneUploadsManager.isWindowNeeded())
|
||||
if (sendtophoneUploadsManager.isWindowNeeded(false))
|
||||
{
|
||||
cancelShowTimer();
|
||||
sendtophoneUploadsManager.showWindow();
|
||||
@@ -260,7 +264,7 @@ function openAndReuseOneTabPerURL(url) {
|
||||
var recentWindow = wm.getMostRecentWindow("navigator:browser");
|
||||
if (recentWindow) {
|
||||
// Use an existing browser window
|
||||
recentWindow.delayedOpenTab(url, null, null, null, null);
|
||||
recentWindow.getBrowser().loadOneTab( url, null, null, null, false, null );
|
||||
}
|
||||
else {
|
||||
// No browser windows are open, so open a new one.
|
||||
|
||||
Reference in New Issue
Block a user