mirror of
https://github.com/fergalmoran/chrometophone.git
synced 2025-12-22 09:41:51 +00:00
FoxToPhone: allow to customize the file upload server. Added support for min.us. Reorganization of the uploads pane.
This commit is contained in:
@@ -24,3 +24,5 @@ overlay chrome://navigator/content/navigator.xul chrome://sendtophone/content/ff
|
|||||||
|
|
||||||
style chrome://global/content/customizeToolbar.xul chrome://sendtophone/skin/overlay.css
|
style chrome://global/content/customizeToolbar.xul chrome://sendtophone/skin/overlay.css
|
||||||
|
|
||||||
|
# Support for Mac
|
||||||
|
override chrome://sendtophone/skin/uploads.css chrome://sendtophone/skin/uploads-mac.css os=Darwin
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ sendtophone.pickFile = function(folder)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fp.init(window, this.getString("SendFileToPhone"), Ci.nsIFilePicker.modeOpenMultiple);
|
fp.init(window, this.getString("SendFileToPhone"), Ci.nsIFilePicker.modeOpenMultiple);
|
||||||
fp.appendFilters(Ci.nsIFilePicker.filterAll | Ci.nsIFilePicker.filterImages);
|
fp.appendFilters( Ci.nsIFilePicker.filterAll );
|
||||||
}
|
}
|
||||||
|
|
||||||
var rv = fp.show();
|
var rv = fp.show();
|
||||||
|
|||||||
55
third_party/firefox_sendtophone/chrome/content/options.js
vendored
Normal file
55
third_party/firefox_sendtophone/chrome/content/options.js
vendored
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
let foxToPhonePreferences =
|
||||||
|
{
|
||||||
|
load: function()
|
||||||
|
{
|
||||||
|
let fileServerUrl = document.getElementById("extensions.sendtophone.fileServerUrl").value;
|
||||||
|
|
||||||
|
let fileserverMenuList = document.getElementById("extensionsSendToPhoneFileServer") ;
|
||||||
|
|
||||||
|
switch (fileServerUrl)
|
||||||
|
{
|
||||||
|
case '':
|
||||||
|
fileserverMenuList.value = fileServerUrl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'http://min.us':
|
||||||
|
fileserverMenuList.value = fileServerUrl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fileserverMenuList.value = 'Custom';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fileserverMenuList.addEventListener("command", function () {
|
||||||
|
let fileServer = fileserverMenuList.value;
|
||||||
|
switch (fileServer)
|
||||||
|
{
|
||||||
|
case '':
|
||||||
|
document.getElementById("extensions.sendtophone.fileServerUrl").value = '';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'Custom':
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
document.getElementById("extensions.sendtophone.fileServerUrl").value = fileServer;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("hboxFileServerUrl").hidden = ( fileServer != 'Custom');
|
||||||
|
|
||||||
|
window.sizeToContent();
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
document.getElementById("hboxFileServerUrl").hidden = ( fileserverMenuList.value != 'Custom');
|
||||||
|
|
||||||
|
window.sizeToContent();
|
||||||
|
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
this.addEventListener("load", function () {foxToPhonePreferences.load(); }, false);
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
<preference id="extensions.sendtophone.protocols.sms" name="extensions.sendtophone.protocols.sms" type="bool"/>
|
<preference id="extensions.sendtophone.protocols.sms" name="extensions.sendtophone.protocols.sms" type="bool"/>
|
||||||
<preference id="extensions.sendtophone.protocols.smsto" name="extensions.sendtophone.protocols.smsto" type="bool"/>
|
<preference id="extensions.sendtophone.protocols.smsto" name="extensions.sendtophone.protocols.smsto" type="bool"/>
|
||||||
<preference id="extensions.sendtophone.protocols.tel" name="extensions.sendtophone.protocols.tel" type="bool"/>
|
<preference id="extensions.sendtophone.protocols.tel" name="extensions.sendtophone.protocols.tel" type="bool"/>
|
||||||
|
<preference id="extensions.sendtophone.fileServerUrl" name="extensions.sendtophone.fileServerUrl" type="string"/>
|
||||||
</preferences>
|
</preferences>
|
||||||
|
|
||||||
<groupbox style="padding:1em;" label="ProtocolsGroup">
|
<groupbox style="padding:1em;" label="ProtocolsGroup">
|
||||||
@@ -29,6 +30,35 @@
|
|||||||
label="tel:" />
|
label="tel:" />
|
||||||
</groupbox>
|
</groupbox>
|
||||||
|
|
||||||
|
<groupbox style="padding:1em; min-height:10em;" label="FileServer">
|
||||||
|
<caption label="File transfers" />
|
||||||
|
<hbox align="center">
|
||||||
|
<label value="Server"
|
||||||
|
flex="1"
|
||||||
|
control="extensionsSendToPhoneFileServer"/>
|
||||||
|
|
||||||
|
<menulist id="extensionsSendToPhoneFileServer">
|
||||||
|
<menupopup>
|
||||||
|
<menuitem value="" label="None" />
|
||||||
|
<menuitem value="http://min.us" label="Min.us" />
|
||||||
|
<menuitem value="Custom" label="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.
|
||||||
|
</description>
|
||||||
|
</hbox>
|
||||||
|
|
||||||
|
|
||||||
|
<hbox align="center" id="hboxFileServerUrl">
|
||||||
|
<textbox id="extensionsSendToPhoneFileServerUrl" flex="1" preference="extensions.sendtophone.fileServerUrl" />
|
||||||
|
</hbox>
|
||||||
|
</groupbox>
|
||||||
|
|
||||||
</prefpane>
|
</prefpane>
|
||||||
|
<script type="application/x-javascript" src="options.js" />
|
||||||
|
|
||||||
</prefwindow>
|
</prefwindow>
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Core functions
|
// Core functions
|
||||||
Components.utils.import("resource://sendtophone/sendtophone.js");
|
Components.utils.import("resource://sendtophone/sendtophone.js");
|
||||||
// Protocol handlers
|
// Protocol handlers
|
||||||
|
|||||||
@@ -36,8 +36,7 @@
|
|||||||
if (!startEl.length)
|
if (!startEl.length)
|
||||||
startEl = [this];
|
startEl = [this];
|
||||||
|
|
||||||
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
return startEl[0].getElementsByTagNameNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "button");
|
||||||
return startEl[0].getElementsByTagNameNS(XULNS, "button");
|
|
||||||
]]>
|
]]>
|
||||||
</getter>
|
</getter>
|
||||||
</property>
|
</property>
|
||||||
@@ -62,7 +61,7 @@
|
|||||||
</xul:vbox>
|
</xul:vbox>
|
||||||
<xul:button class="cancel mini-button" tooltiptext="&cmd.cancel.label;"
|
<xul:button class="cancel mini-button" tooltiptext="&cmd.cancel.label;"
|
||||||
cmd="cmd_cancel" ondblclick="event.stopPropagation();"
|
cmd="cmd_cancel" ondblclick="event.stopPropagation();"
|
||||||
oncommand="performCommand('cmd_cancel', this);"/>
|
oncommand="FoxToPhoneUploadWindow.performCancelCommand(this);"/>
|
||||||
</xul:hbox>
|
</xul:hbox>
|
||||||
<xul:label xbl:inherits="value=status,tooltiptext=statusTip" flex="1"
|
<xul:label xbl:inherits="value=status,tooltiptext=statusTip" flex="1"
|
||||||
crop="right" class="status"/>
|
crop="right" class="status"/>
|
||||||
|
|||||||
@@ -1,16 +1,57 @@
|
|||||||
var Cc = Components.classes;
|
"use strict";
|
||||||
var Ci = Components.interfaces;
|
|
||||||
|
let Cc = Components.classes;
|
||||||
|
let Ci = Components.interfaces;
|
||||||
let Cu = Components.utils;
|
let Cu = Components.utils;
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/DownloadUtils.jsm");
|
Cu.import("resource://gre/modules/DownloadUtils.jsm");
|
||||||
Cu.import("resource://gre/modules/PluralForm.jsm");
|
Cu.import("resource://gre/modules/PluralForm.jsm");
|
||||||
|
|
||||||
Cu.import("resource://sendtophone/uploadsManager.js");
|
Cu.import("resource://sendtophone/uploadsManager.js");
|
||||||
|
|
||||||
let gUploadManager = sendtophoneUploadsManager;
|
let gUploadListener = {
|
||||||
let gUploadsView = null;
|
UploadsView: null,
|
||||||
|
|
||||||
function addFile(upload)
|
fileAdded: function(data)
|
||||||
{
|
{
|
||||||
|
this.addFile(data);
|
||||||
|
},
|
||||||
|
progressUpdate: function(data)
|
||||||
|
{
|
||||||
|
let item = document.getElementById( "upl" + data.id);
|
||||||
|
item.setAttribute("currBytes", data.currBytes);
|
||||||
|
item.setAttribute("maxBytes", data.maxBytes);
|
||||||
|
|
||||||
|
let percentComplete = Math.round(100 * data.currBytes / data.maxBytes);
|
||||||
|
item.setAttribute("progress", percentComplete);
|
||||||
|
|
||||||
|
// Status text
|
||||||
|
FoxToPhoneUploadWindow.updateStatus(item);
|
||||||
|
},
|
||||||
|
fileFinished: function(data)
|
||||||
|
{
|
||||||
|
let item = document.getElementById("upl" + data.id);
|
||||||
|
this.UploadsView.removeChild(item);
|
||||||
|
|
||||||
|
// If no more pending uploads, close the tab.
|
||||||
|
// Use a 0 ms timeout to avoid flicker while compress -> upload a folder
|
||||||
|
let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||||
|
checkTimer.initWithCallback( this.checkTimerEvent, 0, Ci.nsITimer.TYPE_ONE_SHOT );
|
||||||
|
},
|
||||||
|
|
||||||
|
checkTimerEvent :
|
||||||
|
{
|
||||||
|
notify: function(timer)
|
||||||
|
{
|
||||||
|
if (!sendtophoneUploadsManager.isWindowNeeded())
|
||||||
|
{
|
||||||
|
if (gUploadListener.UploadsView.children.length==0)
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
addFile: function(upload)
|
||||||
|
{
|
||||||
let dl = document.createElement("richlistitem");
|
let dl = document.createElement("richlistitem");
|
||||||
|
|
||||||
dl.setAttribute("file", upload.file.path);
|
dl.setAttribute("file", upload.file.path);
|
||||||
@@ -28,127 +69,45 @@ function addFile(upload)
|
|||||||
dl.setAttribute("id", "upl" + upload.id);
|
dl.setAttribute("id", "upl" + upload.id);
|
||||||
dl.setAttribute("uploadId", upload.id);
|
dl.setAttribute("uploadId", upload.id);
|
||||||
|
|
||||||
gUploadsView.appendChild( dl );
|
this.UploadsView.appendChild( dl );
|
||||||
}
|
|
||||||
|
|
||||||
var checkTimerEvent =
|
|
||||||
{
|
|
||||||
notify: function(timer)
|
|
||||||
{
|
|
||||||
if (sendtophoneUploadsManager.isWindowNeeded())
|
|
||||||
{
|
|
||||||
if (gUploadsView.children.length==0)
|
|
||||||
window.close();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelUpload(item)
|
|
||||||
{
|
|
||||||
gUploadManager.cancelUpload( parseInt(item.getAttribute("uploadId"), 10) );
|
|
||||||
}
|
|
||||||
|
|
||||||
let gUploadListener = {
|
|
||||||
fileAdded: function(data)
|
|
||||||
{
|
|
||||||
addFile(data);
|
|
||||||
},
|
|
||||||
progressUpdate: function(data)
|
|
||||||
{
|
|
||||||
let item = document.getElementById( "upl" + data.id);
|
|
||||||
item.setAttribute("currBytes", data.currBytes);
|
|
||||||
item.setAttribute("maxBytes", data.maxBytes);
|
|
||||||
|
|
||||||
let percentComplete = Math.round(100 * data.currBytes / data.maxBytes);
|
|
||||||
item.setAttribute("progress", percentComplete);
|
|
||||||
|
|
||||||
// Status text
|
|
||||||
updateStatus(item);
|
|
||||||
},
|
|
||||||
fileFinished: function(data)
|
|
||||||
{
|
|
||||||
let item = document.getElementById("upl" + data.id);
|
|
||||||
gUploadsView.removeChild(item);
|
|
||||||
|
|
||||||
// If no more pending uploads, close the tab.
|
|
||||||
// Use a 0 ms timeout to avoid flicker while compress -> upload a folder
|
|
||||||
let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
|
||||||
checkTimer.initWithCallback(checkTimerEvent, 0, Ci.nsITimer.TYPE_ONE_SHOT);
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let FoxToPhoneUploadWindow = {
|
||||||
|
UploadManager: null,
|
||||||
|
|
||||||
function Startup()
|
Startup: function()
|
||||||
{
|
|
||||||
gUploadsView = document.getElementById("UploadsBox");
|
|
||||||
|
|
||||||
gUploadManager.addListener(gUploadListener);
|
|
||||||
|
|
||||||
for (let id in gUploadManager.uploads)
|
|
||||||
addFile( gUploadManager.uploads[id] );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function Shutdown()
|
|
||||||
{
|
|
||||||
gUploadManager.removeListener(gUploadListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//// Command Updating and Command Handlers
|
|
||||||
|
|
||||||
var gUploadViewController = {
|
|
||||||
isCommandEnabled: function(aCommand, aItem)
|
|
||||||
{
|
{
|
||||||
let dl = aItem;
|
this.UploadManager = sendtophoneUploadsManager;
|
||||||
|
|
||||||
switch (aCommand) {
|
gUploadListener.UploadsView = document.getElementById("UploadsBox");
|
||||||
case "cmd_cancel":
|
|
||||||
return dl.inProgress;
|
this.UploadManager.addListener(gUploadListener);
|
||||||
}
|
|
||||||
return false;
|
for (let id in this.UploadManager.uploads)
|
||||||
|
gUploadListener.addFile( this.UploadManager.uploads[id] );
|
||||||
},
|
},
|
||||||
|
|
||||||
doCommand: function(aCommand, aItem)
|
Shutdown: function()
|
||||||
{
|
{
|
||||||
if (this.isCommandEnabled(aCommand, aItem))
|
this.UploadManager.removeListener(gUploadListener);
|
||||||
this.commands[aCommand](aItem);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
commands: {
|
performCancelCommand: function(aItem)
|
||||||
cmd_cancel: function(aSelectedItem) {
|
{
|
||||||
cancelUpload(aSelectedItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function to do commands.
|
|
||||||
*
|
|
||||||
* @param aCmd
|
|
||||||
* The command to be performed.
|
|
||||||
* @param aItem
|
|
||||||
* The richlistitem that represents the download that will have the
|
|
||||||
* command performed on it. If this is null, the command is performed on
|
|
||||||
* all downloads. If the item passed in is not a richlistitem that
|
|
||||||
* represents a download, it will walk up the parent nodes until it finds
|
|
||||||
* a DOM node that is.
|
|
||||||
*/
|
|
||||||
function performCommand(aCmd, aItem)
|
|
||||||
{
|
|
||||||
let elm = aItem;
|
let elm = aItem;
|
||||||
|
|
||||||
while (elm.nodeName != "richlistitem" ||
|
while (elm.nodeName != "richlistitem" ||
|
||||||
elm.getAttribute("type") != "upload")
|
elm.getAttribute("type") != "upload")
|
||||||
elm = elm.parentNode;
|
elm = elm.parentNode;
|
||||||
|
|
||||||
gUploadViewController.doCommand(aCmd, elm);
|
if (elm.inProgress)
|
||||||
}
|
this.UploadManager.cancelUpload( parseInt(elm.getAttribute("uploadId"), 10) );
|
||||||
|
},
|
||||||
|
|
||||||
function updateStatus(aItem)
|
updateStatus: function(aItem)
|
||||||
{
|
{
|
||||||
let currBytes = Number(aItem.getAttribute("currBytes"));
|
let currBytes = Number(aItem.getAttribute("currBytes"));
|
||||||
let maxBytes = Number(aItem.getAttribute("maxBytes"));
|
let maxBytes = Number(aItem.getAttribute("maxBytes"));
|
||||||
|
|
||||||
@@ -165,4 +124,8 @@ function updateStatus(aItem)
|
|||||||
aItem.setAttribute("lastSeconds", newLast);
|
aItem.setAttribute("lastSeconds", newLast);
|
||||||
|
|
||||||
aItem.setAttribute("status", status);
|
aItem.setAttribute("status", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||||
<?xml-stylesheet href="chrome://sendtophone/content/upload.css"?>
|
<?xml-stylesheet href="chrome://sendtophone/content/upload.css" type="text/css"?>
|
||||||
<?xml-stylesheet href="chrome://sendtophone/skin/uploads.css"?>
|
<?xml-stylesheet href="chrome://sendtophone/skin/uploads.css" type="text/css"?>
|
||||||
|
|
||||||
<!DOCTYPE window SYSTEM "chrome://sendtophone/locale/overlay.dtd">
|
<!DOCTYPE window SYSTEM "chrome://sendtophone/locale/overlay.dtd">
|
||||||
|
|
||||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
id="sendtophoneUploadsWindow"
|
id="sendtophoneUploadsWindow"
|
||||||
onload="Startup();" onunload="Shutdown();"
|
onload="FoxToPhoneUploadWindow.Startup();" onunload="FoxToPhoneUploadWindow.Shutdown();"
|
||||||
onclose="return closeWindow(false);">
|
onclose="return closeWindow(false);">
|
||||||
|
|
||||||
<script type="application/javascript" src="chrome://sendtophone/content/uploads.js"/>
|
<script type="application/javascript" src="chrome://sendtophone/content/uploads.js"/>
|
||||||
|
|
||||||
<richlistbox id="UploadsBox" flex="1">
|
<richlistbox id="UploadsBox" flex="1"></richlistbox>
|
||||||
</richlistbox>
|
|
||||||
|
|
||||||
</window>
|
</window>
|
||||||
63
third_party/firefox_sendtophone/chrome/skin/uploads-mac.css
vendored
Normal file
63
third_party/firefox_sendtophone/chrome/skin/uploads-mac.css
vendored
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#UploadsBox {
|
||||||
|
-moz-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Upload View Items */
|
||||||
|
richlistitem[type="upload"] {
|
||||||
|
padding: 5px;
|
||||||
|
min-height: 44px !important;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[type="upload"]:not([selected="true"]):nth-child(odd) {
|
||||||
|
background-color: -moz-oddtreerow;
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[type="upload"] .status {
|
||||||
|
font-size: smaller;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[selected="true"][type="upload"] {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistbox:focus > richlistitem[selected="true"][type="upload"] .status {
|
||||||
|
color: highlighttext;
|
||||||
|
}
|
||||||
|
|
||||||
|
richlistitem[type="upload"] button {
|
||||||
|
-moz-appearance: none;
|
||||||
|
min-height: 16px;
|
||||||
|
min-width: 16px;
|
||||||
|
max-height: 16px;
|
||||||
|
max-width: 16px;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0 1px 0 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Images for buttons in the interface
|
||||||
|
*/
|
||||||
|
richlistitem[type="upload"] button {
|
||||||
|
list-style-image: url(chrome://mozapps/skin/downloads/buttons.png);
|
||||||
|
}
|
||||||
|
.cancel {
|
||||||
|
-moz-image-region: rect(0px, 16px, 16px, 0px);
|
||||||
|
}
|
||||||
|
.cancel:hover {
|
||||||
|
-moz-image-region: rect(0px, 32px, 16px, 16px);
|
||||||
|
}
|
||||||
|
.cancel:hover:active {
|
||||||
|
-moz-image-region: rect(0px, 48px, 16px, 32px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* prevent flickering when changing states */
|
||||||
|
.uploadTypeIcon {
|
||||||
|
min-height: 32px;
|
||||||
|
min-width: 32px;
|
||||||
|
-moz-padding-end: 2px;
|
||||||
|
}
|
||||||
@@ -1,63 +1,63 @@
|
|||||||
#UploadsBox {
|
|
||||||
|
#sendtophoneUploadsWindow {
|
||||||
|
background-color: ThreeDFace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Upload View */
|
||||||
|
@media not all and (-moz-windows-classic) {
|
||||||
|
#UploadsBox {
|
||||||
-moz-appearance: none;
|
-moz-appearance: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
border-bottom: 2px solid;
|
||||||
border-width: 0;
|
-moz-border-bottom-colors: ThreeDHighlight ThreeDLightShadow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Upload View Items */
|
/* Upload View Items */
|
||||||
richlistitem[type="upload"] {
|
richlistitem[type="upload"] {
|
||||||
padding: 5px;
|
padding: 4px 8px 4px 4px;
|
||||||
min-height: 44px !important;
|
min-height: 46px;
|
||||||
border: 1px solid transparent;
|
border-bottom: 1px solid ThreeDLightShadow;
|
||||||
}
|
}
|
||||||
|
|
||||||
richlistitem[type="upload"]:not([selected="true"]):nth-child(odd) {
|
richlistitem[type="upload"][selected="true"] {
|
||||||
background-color: -moz-oddtreerow;
|
background-image: url(chrome://mozapps/skin/extensions/itemEnabledFader.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
richlistitem[type="upload"] .status {
|
richlistitem[type="upload"] .name {
|
||||||
font-size: smaller;
|
font-size: larger;
|
||||||
color: #555;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
richlistitem[selected="true"][type="upload"] {
|
.mini-button {
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
richlistbox:focus > richlistitem[selected="true"][type="upload"] .status {
|
|
||||||
color: highlighttext;
|
|
||||||
}
|
|
||||||
|
|
||||||
richlistitem[type="upload"] button {
|
|
||||||
-moz-appearance: none;
|
-moz-appearance: none;
|
||||||
min-height: 16px;
|
list-style-image: url(chrome://mozapps/skin/downloads/downloadButtons.png);
|
||||||
min-width: 16px;
|
background-color: transparent;
|
||||||
max-height: 16px;
|
border: none;
|
||||||
max-width: 16px;
|
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0 1px 0 1px;
|
margin: 0;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
.mini-button > .button-box {
|
||||||
* Images for buttons in the interface
|
padding: 0 !important;
|
||||||
*/
|
|
||||||
richlistitem[type="upload"] button {
|
|
||||||
list-style-image: url(chrome://mozapps/skin/downloads/buttons.png);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.cancel {
|
.cancel {
|
||||||
-moz-image-region: rect(0px, 16px, 16px, 0px);
|
|
||||||
}
|
|
||||||
.cancel:hover {
|
|
||||||
-moz-image-region: rect(0px, 32px, 16px, 16px);
|
-moz-image-region: rect(0px, 32px, 16px, 16px);
|
||||||
}
|
}
|
||||||
.cancel:hover:active {
|
.cancel:hover {
|
||||||
-moz-image-region: rect(0px, 48px, 16px, 32px);
|
-moz-image-region: rect(16px, 32px, 32px, 16px);
|
||||||
|
}
|
||||||
|
.cancel:active {
|
||||||
|
-moz-image-region: rect(32px, 32px, 48px, 16px);
|
||||||
|
}
|
||||||
|
.cancel[disabled="true"] {
|
||||||
|
-moz-image-region: rect(48px, 32px, 64px, 16px);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prevent flickering when changing states */
|
/* prevent flickering when changing states */
|
||||||
.uploadTypeIcon {
|
.uploadTypeIcon {
|
||||||
min-height: 32px;
|
min-height: 32px;
|
||||||
min-width: 32px;
|
min-width: 32px;
|
||||||
-moz-padding-end: 2px;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
/* This js module doesn't export anything, it's meant to handle the protocol registration/unregistration */
|
/* This js module doesn't export anything, it's meant to handle the protocol registration/unregistration */
|
||||||
var EXPORTED_SYMBOLS = [];
|
var EXPORTED_SYMBOLS = [];
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
"use strict";
|
||||||
|
|
||||||
// https://developer.mozilla.org/en/JavaScript_code_modules/Using_JavaScript_code_modules
|
// https://developer.mozilla.org/en/JavaScript_code_modules/Using_JavaScript_code_modules
|
||||||
var EXPORTED_SYMBOLS = ["sendtophoneCore"];
|
var EXPORTED_SYMBOLS = ["sendtophoneCore"];
|
||||||
@@ -332,9 +333,9 @@ var sendtophoneCore = {
|
|||||||
sendtophoneUploadsManager.finishedUpload( progressId );
|
sendtophoneUploadsManager.finishedUpload( progressId );
|
||||||
|
|
||||||
// Send the zip and delete it afterwards
|
// Send the zip and delete it afterwards
|
||||||
sendtophoneCore.sendFile(nsZip, function() { nsZip.remove(false) });
|
sendtophoneCore.sendFile(nsZip, function() { nsZip.remove(false); });
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,6 +345,32 @@ var sendtophoneCore = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( uri == "http://min.us" )
|
||||||
|
{
|
||||||
|
Minus.SendFile(nsFile, callback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sendFileXHR( nsFile, callback, uri, 'upload', function(target, uploadName)
|
||||||
|
{
|
||||||
|
var body = target.responseXML,
|
||||||
|
uploads;
|
||||||
|
|
||||||
|
// FoxToPhone custom script
|
||||||
|
if (body && (uploads = body.documentElement.getElementsByTagName("upload")) && uploads[0])
|
||||||
|
{
|
||||||
|
var url = uploads[0].firstChild.data;
|
||||||
|
sendtophoneCore.send(uploadName, url, "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// error.
|
||||||
|
sendtophoneCore.alert(uri + "\r\n" + event.target.responseText);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
sendFileXHR: function( nsFile, callback, uri, formElementName, onSuccess )
|
||||||
|
{
|
||||||
let size = Math.round(nsFile.fileSize / 1024);
|
let size = Math.round(nsFile.fileSize / 1024);
|
||||||
let maxSize = this.prefs.getIntPref( "fileUploadMaxKb" );
|
let maxSize = this.prefs.getIntPref( "fileUploadMaxKb" );
|
||||||
if (maxSize>0 && size>maxSize)
|
if (maxSize>0 && size>maxSize)
|
||||||
@@ -371,20 +398,20 @@ var sendtophoneCore = {
|
|||||||
bufInStream.init(inStream, 4096);
|
bufInStream.init(inStream, 4096);
|
||||||
|
|
||||||
//Setup the boundary start stream
|
//Setup the boundary start stream
|
||||||
var boundary = "--SendToPhone-------------" + Math.random();
|
var boundary = "--SendToPhone-------------" + Math.random().toString(16).substr(2);
|
||||||
var startBoundryStream = Cc["@mozilla.org/io/string-input-stream;1"]
|
var startBoundryStream = Cc["@mozilla.org/io/string-input-stream;1"]
|
||||||
.createInstance(Ci.nsIStringInputStream);
|
.createInstance(Ci.nsIStringInputStream);
|
||||||
startBoundryStream.setData("\r\n--"+boundary+"\r\n",-1);
|
startBoundryStream.setData("--"+boundary+"\r\n",-1);
|
||||||
|
|
||||||
// Setup the boundary end stream
|
// Setup the boundary end stream
|
||||||
var endBoundryStream = Cc["@mozilla.org/io/string-input-stream;1"]
|
var endBoundryStream = Cc["@mozilla.org/io/string-input-stream;1"]
|
||||||
.createInstance(Ci.nsIStringInputStream);
|
.createInstance(Ci.nsIStringInputStream);
|
||||||
endBoundryStream.setData("\r\n--"+boundary+"--",-1);
|
endBoundryStream.setData("\r\n\r\n--"+boundary+"--\r\n",-1);
|
||||||
|
|
||||||
// Setup the mime-stream - the 'part' of a multi-part mime type
|
// Setup the mime-stream - the 'part' of a multi-part mime type
|
||||||
var mimeStream = Cc["@mozilla.org/network/mime-input-stream;1"].createInstance(Ci.nsIMIMEInputStream);
|
var mimeStream = Cc["@mozilla.org/network/mime-input-stream;1"].createInstance(Ci.nsIMIMEInputStream);
|
||||||
mimeStream.addContentLength = false;
|
mimeStream.addContentLength = false;
|
||||||
mimeStream.addHeader("Content-disposition","form-data; charset: utf-8; name=\"upload\"; filename=\"" + this.toUTF8(uploadName) + "\"");
|
mimeStream.addHeader("Content-disposition",'form-data; charset: utf-8; name="' + formElementName + '"; filename="' + this.toUTF8(uploadName) + '"');
|
||||||
mimeStream.addHeader("Content-type", mimeType);
|
mimeStream.addHeader("Content-type", mimeType);
|
||||||
mimeStream.setData(bufInStream);
|
mimeStream.setData(bufInStream);
|
||||||
|
|
||||||
@@ -404,25 +431,16 @@ var sendtophoneCore = {
|
|||||||
req.open('POST', uri, true);
|
req.open('POST', uri, true);
|
||||||
|
|
||||||
req.setRequestHeader("Content-length",multiStream.available());
|
req.setRequestHeader("Content-length",multiStream.available());
|
||||||
req.setRequestHeader("Content-type","multipart/form-data; charset: utf-8; boundary="+boundary);
|
req.setRequestHeader("Content-type","multipart/form-data; boundary="+boundary);
|
||||||
req.addEventListener("load", function(event)
|
req.addEventListener("load", function(event)
|
||||||
{
|
{
|
||||||
// If there's a callback (to delete temporary files) we call it now
|
// If there's a callback (to delete temporary files) we call it now
|
||||||
if (callback)
|
if (callback)
|
||||||
callback();
|
callback();
|
||||||
|
|
||||||
var body = event.target.responseXML;
|
onSuccess(event.target, uploadName);
|
||||||
var uploads;
|
|
||||||
if (body && (uploads = body.documentElement.getElementsByTagName("upload")))
|
|
||||||
{
|
|
||||||
var data = uploads[0].firstChild.data;
|
|
||||||
// sendtophoneCore.toConsole(data);
|
|
||||||
sendtophoneCore.send(uploadName, data, "");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// error.
|
|
||||||
sendtophoneCore.alert(uri + "\r\n" + event.target.responseText);
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
// Handle errors or aborted uploads
|
// Handle errors or aborted uploads
|
||||||
req.addEventListener("error", function(evt)
|
req.addEventListener("error", function(evt)
|
||||||
{
|
{
|
||||||
@@ -432,6 +450,7 @@ var sendtophoneCore = {
|
|||||||
if (callback)
|
if (callback)
|
||||||
callback();
|
callback();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
req.addEventListener("abort", function(evt)
|
req.addEventListener("abort", function(evt)
|
||||||
{
|
{
|
||||||
// Silent.
|
// Silent.
|
||||||
@@ -451,8 +470,45 @@ var sendtophoneCore = {
|
|||||||
*/
|
*/
|
||||||
req.send(multiStream);
|
req.send(multiStream);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// http://min.us/
|
||||||
|
var Minus = {
|
||||||
|
prefix: 'http://min.us/api/',
|
||||||
|
|
||||||
|
SendFile : function(nsFile, callback) {
|
||||||
|
// Create a gallery
|
||||||
|
sendtophoneCore.processXHR( Minus.prefix + 'CreateGallery', 'GET', null, function(req) {
|
||||||
|
var body = req.responseText;
|
||||||
|
|
||||||
|
if (body.substring(0, 1) != '{')
|
||||||
|
{
|
||||||
|
sendtophoneCore.alert(sendtophoneCore.getString("ErrorOnSend") + ' (status ' + req.status + ')\r\n' + body);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var gallery = JSON.parse( body );
|
||||||
|
// Send the file
|
||||||
|
sendtophoneCore.sendFileXHR(nsFile, callback, Minus.prefix +
|
||||||
|
'UploadItem?editor_id=' + gallery.editor_id + '&key=OK&filename=' + encodeURIComponent(nsFile.leafName), 'file',
|
||||||
|
function(target, uploadName)
|
||||||
|
{
|
||||||
|
var body = target.responseText;
|
||||||
|
if (body.substring(0, 1) != '{')
|
||||||
|
{
|
||||||
|
sendtophoneCore.alert(sendtophoneCore.getString("ErrorOnSend") + ' (status ' + req.status + ')\r\n' + body);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var file = JSON.parse( body );
|
||||||
|
// var url = "http://k.min.us/j" + file.id;
|
||||||
|
var url = "http://min.us/m" + gallery.reader_id;
|
||||||
|
sendtophoneCore.send(uploadName, url, "");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Zipping functions */
|
/* Zipping functions */
|
||||||
@@ -478,7 +534,7 @@ function zipFolder(folder, callback)
|
|||||||
|
|
||||||
// Create a new file
|
// Create a new file
|
||||||
nsFile.append( folder.leafName + ".zip");
|
nsFile.append( folder.leafName + ".zip");
|
||||||
nsFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
|
nsFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 438); // 438 (decimal) = 0666 (octal)
|
||||||
|
|
||||||
var zipWriter = Components.Constructor("@mozilla.org/zipwriter;1", "nsIZipWriter");
|
var zipWriter = Components.Constructor("@mozilla.org/zipwriter;1", "nsIZipWriter");
|
||||||
var zipW = new zipWriter();
|
var zipW = new zipWriter();
|
||||||
@@ -497,7 +553,7 @@ function zipFolder(folder, callback)
|
|||||||
// Notify that we're done. Now it must be sent and deleted afterwards
|
// Notify that we're done. Now it must be sent and deleted afterwards
|
||||||
callback(nsFile);
|
callback(nsFile);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
zipW.processQueue(observer, null);
|
zipW.processQueue(observer, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["sendtophoneUploadsManager"];
|
var EXPORTED_SYMBOLS = ["sendtophoneUploadsManager"];
|
||||||
|
|
||||||
const Cc = Components.classes;
|
const Cc = Components.classes;
|
||||||
@@ -151,15 +153,6 @@ var sendtophoneUploadsManager = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// For use while debugging
|
|
||||||
toConsole: function(text)
|
|
||||||
{
|
|
||||||
var aConsoleService = Cc["@mozilla.org/consoleservice;1"]
|
|
||||||
.getService(Ci.nsIConsoleService);
|
|
||||||
|
|
||||||
aConsoleService.logStringMessage( text );
|
|
||||||
},
|
|
||||||
|
|
||||||
// Check if we might need to show the window.
|
// Check if we might need to show the window.
|
||||||
// Either some folder is being compressed,
|
// Either some folder is being compressed,
|
||||||
// or there's some file that might take longer than 2 seconds.
|
// or there's some file that might take longer than 2 seconds.
|
||||||
@@ -182,7 +175,6 @@ var sendtophoneUploadsManager = {
|
|||||||
let elapsedTime = (Date.now() - upload.startTime) / 1000;
|
let elapsedTime = (Date.now() - upload.startTime) / 1000;
|
||||||
let speed = upload.currBytes/elapsedTime;
|
let speed = upload.currBytes/elapsedTime;
|
||||||
let remainingSecs = (upload.maxBytes - upload.currBytes) / speed;
|
let remainingSecs = (upload.maxBytes - upload.currBytes) / speed;
|
||||||
// this.toConsole(elapsedTime + " " + speed + " " + remainingSecs);
|
|
||||||
|
|
||||||
if (remainingSecs > 2)
|
if (remainingSecs > 2)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user