Removed mms:, Added "send clipboard", option to remember whether to send the QR code, selection correction for iframes

This commit is contained in:
amla70
2010-08-13 15:01:36 +00:00
parent 7f93c4f1b5
commit 0249229eb7
11 changed files with 134 additions and 73 deletions

View File

@@ -56,13 +56,12 @@ sendtophone.installToolbarButton = function()
//Toggle Protocol Prefrences onFlyout Menu Click
sendtophone.onToggleOption = function(menuitem)
{
{
var option = menuitem.getAttribute("option");
var checked = menuitem.getAttribute("checked") == "true";
this.prefs.setBoolPref("protocols."+option, checked );
if(!option.indexOf("sms")|!option.indexOf("mms")){
if (!option.indexOf("sms"))
this.prefs.setBoolPref("protocols."+option+"to", checked );
}
}
//Set MenuItem as checked based on preferences.
@@ -95,7 +94,7 @@ sendtophone.showFirefoxContextMenu = function(event) {
if (data)
{
gContextMenu.showItem("context-sendtophone-qrimage", true);
var label = this.strings.getString("qrContextMenu");
var label = this.getString("qrContextMenu");
label = label.replace("%s", data.substring(0, 20) + "..." );
document.getElementById("context-sendtophone-qrimage").setAttribute("label", label);
}
@@ -159,7 +158,7 @@ sendtophone.doDrop = function(event)
if (file instanceof Ci.nsIFile )
sendtophoneCore.sendFile(file);
else
this.alert(this.strings.getString("InvalidFile"));
this.alert(this.getString("InvalidFile"));
}
break;
}
@@ -171,10 +170,10 @@ sendtophone.pickFile = function(folder)
.createInstance(Ci.nsIFilePicker);
if (folder)
fp.init(window, this.strings.getString("SendFolderToPhone"), Ci.nsIFilePicker.modeGetFolder);
fp.init(window, this.getString("SendFolderToPhone"), Ci.nsIFilePicker.modeGetFolder);
else
{
fp.init(window, this.strings.getString("SendFileToPhone"), Ci.nsIFilePicker.modeOpenMultiple);
fp.init(window, this.getString("SendFileToPhone"), Ci.nsIFilePicker.modeOpenMultiple);
fp.appendFilters(Ci.nsIFilePicker.filterAll | Ci.nsIFilePicker.filterImages);
}
@@ -191,4 +190,3 @@ sendtophone.pickFile = function(folder)
}
}

View File

@@ -11,6 +11,9 @@
<popupset id="mainPopupSet">
<menupopup id="sendtophoneContextMenu" onpopupshowing="sendtophone.initPopup();">
<menuitem label="&sendtophoneContextSendClipboard.label;"
accesskey="&sendtophoneContextSendClipboard.accesskey;"
oncommand="sendtophone.sendClipboard()" id="sendtophoneContextMenuSendClipboard"/>
<menuitem label="&sendtophoneContextSendFile.label;"
accesskey="&sendtophoneContextSendFile.accesskey;"
oncommand="sendtophone.pickFile(false)" id="sendtophoneContextMenuSendFiles"/>
@@ -20,7 +23,6 @@
<menu label="&sendtophoneProtocols.label;">
<menupopup id="menu_Protocols" onpopupshowing="sendtophone.onOptionsShowing(this)">
<menuitem type="checkbox" id="marketcheck" label="market:" oncommand="sendtophone.onToggleOption(this)" option="market"/>
<menuitem type="checkbox" id="mmscheck" label="mms:" oncommand="sendtophone.onToggleOption(this)" option="mms"/>
<menuitem type="checkbox" id="smscheck" label="sms:" oncommand="sendtophone.onToggleOption(this)" option="sms"/>
<menuitem type="checkbox" id="telcheck" label="tel:" oncommand="sendtophone.onToggleOption(this)" option="tel"/>
</menupopup>

View File

@@ -11,8 +11,6 @@
<preference id="extensions.sendtophone.protocols.market" name="extensions.sendtophone.protocols.market" 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.mms" name="extensions.sendtophone.protocols.mms" type="bool"/>
<preference id="extensions.sendtophone.protocols.mmsto" name="extensions.sendtophone.protocols.mmsto" type="bool"/>
<preference id="extensions.sendtophone.protocols.tel" name="extensions.sendtophone.protocols.tel" type="bool"/>
</preferences>
@@ -22,11 +20,6 @@
<checkbox preference="extensions.sendtophone.protocols.market"
label="market:" />
<checkbox preference="extensions.sendtophone.protocols.mms"
label="mms:" oncommand="var o = document.getElementById('mmsto'); o.checked=this.checked; o.doCommand();" />
<checkbox id="mmsto" preference="extensions.sendtophone.protocols.mmsto"
label="mmsto:" style="display:none" />
<checkbox id="sms" preference="extensions.sendtophone.protocols.sms"
label="sms:" oncommand="var o = document.getElementById('smsto'); o.checked=this.checked; o.doCommand();" />
<checkbox id="smsto" preference="extensions.sendtophone.protocols.smsto"

View File

@@ -40,6 +40,11 @@ var sendtophone = {
me.init();
},
getString: function(name)
{
return this.strings.getString(name);
},
// Detect images of QR codes generated by the Google Charts API
detectQR: function( url )
{
@@ -82,7 +87,7 @@ var sendtophone = {
//If the QR Image has no title text, give it one.
if (!title)
title=this.strings.getString("qrTitle");
title=this.getString("qrTitle");
break;
case 'text':
@@ -104,6 +109,11 @@ var sendtophone = {
case 'pageButton':
// Check if there's a single image with a QR code in the contents
var images = gBrowser.contentDocument.getElementsByTagName( "img" );
// 0: search and prompt, 1: search and launch automatically, 2: don't search
var pref = this.prefs.getIntPref("SearchQR")
if (pref!=2)
{
var QRs = [];
for( var i=0; i<images.length; i++)
{
@@ -114,9 +124,16 @@ var sendtophone = {
if (QRs.length==1)
{
var data = QRs[0].data;
var url = data.substring(0, 80);
var question = this.strings.getString("ConfirmQR").replace("%s", url) ;
if (this.confirm( question ) )
if (pref == 0)
{
var question = this.getString("ConfirmQR").replace("%s", data.substring(0, 80)) ;
var answer = this.confirm( question );
pref = (answer.confirm ? 1 : 2 );
if (answer.remember)
this.prefs.setIntPref("SearchQR", pref);
}
if ( pref!=2 )
{
title = QRs[0].img.title || QRs[0].img.alt;
@@ -126,12 +143,13 @@ var sendtophone = {
selection = data;
if (!title)
title=this.strings.getString("qrTitle");
title=this.getString("qrTitle");
// We got the data, break out of the select
break;
}
}
} // pref != 2
// fall through
case 'page':
@@ -151,7 +169,7 @@ var sendtophone = {
{
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Ci.nsIPromptService);
promptService.alert(window, this.strings.getString("SendToPhoneTitle"),
promptService.alert(window, this.getString("SendToPhoneTitle"),
text);
},
@@ -162,10 +180,12 @@ var sendtophone = {
.getService(Ci.nsIPromptService);
// https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIPromptService#confirmEx
var check = {value: true};
var check = {value: false};
var button = promptService.confirmEx(window, this.getString("SendToPhoneTitle"),
text, promptService.STD_YES_NO_BUTTONS, "", "", "", this.getString("RememberMyDecision"), check);
// confirmEx returns the pressed button, and Yes it's the first one.
return (0 == promptService.confirmEx(window, this.strings.getString("SendToPhoneTitle"),
text, promptService.STD_YES_NO_BUTTONS, "", "", "", null, check));
return ({confirm: (0 == button), remember: check.value});
},
onToolbarButtonCommand: function(e) {
@@ -175,10 +195,9 @@ var sendtophone = {
getInfo: function() {
var doc = gBrowser.contentDocument,
win = doc.defaultView;
var href = doc.location.href;
// Is it the Google Maps page?
href = doc.location.href;
// Is it the Google Maps page?
if (this.isMapsURL(href))
{
// Then try to send the current view:
@@ -187,11 +206,13 @@ var sendtophone = {
href = link.href;
}
return {
var focusedWindow = document.commandDispatcher.focusedWindow;
var selection = focusedWindow.getSelection().toString();
return {
"title": doc.title,
"url": href,
"selection": win.getSelection().toString()
"selection": selection
};
},
@@ -203,7 +224,7 @@ var sendtophone = {
validURI: function(uri)
{
return (/^(https?|market|tel|sms(to)?|mms(to)?|mailto|ftp):/i).test( uri );
return (/^(https?|market|tel|sms(to)?|mailto|ftp):/i).test( uri );
},
initPopup: function()
@@ -214,10 +235,55 @@ var sendtophone = {
document.getElementById("sendtophoneContextMenuSendFiles").hidden = true;
document.getElementById("sendtophoneContextMenuSendFolder").hidden = true;
}
document.getElementById("sendtophoneContextMenuSendClipboard").disabled = !this.clipboardHasText();
// returning true will make the popup show
return true;
},
clipboardHasText : function()
{
var clip = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
if (!clip) return false;
if (!clip.hasDataMatchingFlavors(["text/unicode"], 1, clip.kGlobalClipboard))
return false;
return true;
},
sendClipboard : function()
{
// https://developer.mozilla.org/en/using_the_clipboard
// Access Clipboard
var clip = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
if (!clip) return false;
if (!clip.hasDataMatchingFlavors(["text/unicode"], 1, clip.kGlobalClipboard))
return false;
var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
if (!trans) return false;
trans.addDataFlavor("text/unicode");
// Get the data
clip.getData(trans, clip.kGlobalClipboard);
var str = new Object();
var strLength = new Object();
var pastetext;
trans.getTransferData("text/unicode", str, strLength);
// Convert to js string
if (str) str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
if (str) pastetext = str.data.substring(0, strLength.value / 2);
// Send it.
if (pastetext)
sendtophoneCore.send("Clipboard", "http://google.com", pastetext);
},
logout: function()
{
sendtophoneCore.logout();

View File

@@ -18,3 +18,5 @@
<!ENTITY sendtophoneContextSendFolder.accesskey "F">
<!ENTITY sendtophoneContextQrImage.label "Send decoded QR Link to Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">
<!ENTITY sendtophoneContextSendClipboard.label "Send Clipboard">
<!ENTITY sendtophoneContextSendClipboard.accesskey "C">

View File

@@ -10,14 +10,13 @@ LogoutSuccessful=You are logged out
marketLink=Market Link
smsLink=SMS Number
smstoLink=SMS Number
mmsLink=MMS Number
mmstoLink=MMS Number
telLink=Telephone Number
InvalidFile=Not a valid file
SendFileToPhone=Send files to your phone.
SendFolderToPhone=Send a folder to your phone.
qrTitle=QR Image Link
ConfirmQR=A QR image has been detected\r\n"%s"\r\nDo you want to send that instead of the page?
RememberMyDecision=Remember my decision
qrContextMenu=Send "%s" to Android
FileUploadsDisabled=It's not possible to upload files to the phone.
FileTooBig=The file is too big.

View File

@@ -18,3 +18,5 @@
<!ENTITY sendtophoneContextSendFolder.accesskey "C">
<!ENTITY sendtophoneContextQrImage.label "Enviar imagen QR a Android">
<!ENTITY sendtophoneContextQrImage.accesskey "Q">
<!ENTITY sendtophoneContextSendClipboard.label "Enviar el portapapeles">
<!ENTITY sendtophoneContextSendClipboard.accesskey "C">

View File

@@ -10,14 +10,13 @@ LogoutSuccessful=Ha cerrado su sesión
marketLink=Market link
smsLink=Número SMS
smstoLink=Número SMS
mmsLink=Número MMS
mmstoLink=Número MMS
telLink=Número de teléfono
InvalidFile=No es un fichero válido.
SendFileToPhone=Envía ficheros al teléfono.
SendFolderToPhone=Envía una carpeta al teléfono.
qrTitle=Imagen QR
ConfirmQR=A QR image has been detected\r\n"%s"\r\nDo you want to send that instead of the page?
qrContextMenu=Send "%s" to Android
ConfirmQR=Se ha detectado una imagen QR\r\n"%s"\r\n¿Quiere enviarlo en lugar de la página?
RememberMyDecision=Recordar mi decisión
qrContextMenu=Enviar "%s" a Android
FileUploadsDisabled=No se pueden enviar ficheros al teléfono.
FileTooBig=El fichero que quiere enviar es demasiado grande.

View File

@@ -4,12 +4,11 @@ pref("extensions.sendtophone.appUrl", "https://chrometophone.appspot.com");
pref("extensions.sendtophone.proxyUrl", "http://smallroomstudios.net/s2p.php?ml=");
pref("extensions.sendtophone.fileServerUrl", "http://martinezdelizarrondo.com/sendtophone.php");
pref("extensions.sendtophone.fileUploadMaxKb", 50000);
pref("extensions.sendtophone.SearchQR", 0); // 0: search and prompt, 1: search and launch automatically, 2: don't search
pref("extensions.sendtophone.protocols.market", true);
pref("extensions.sendtophone.protocols.sms", true);
pref("extensions.sendtophone.protocols.smsto", true);
pref("extensions.sendtophone.protocols.mms", false); // conflicts with http://en.wikipedia.org/wiki/Microsoft_Media_Server
pref("extensions.sendtophone.protocols.mmsto", true);
pref("extensions.sendtophone.protocols.tel", true);
// https://developer.mozilla.org/en/Localizing_extension_descriptions

View File

@@ -124,8 +124,6 @@ var sendToPhoneProtocols = {
market: SendToPhone_ProtocolWrapper( { scheme: "market", ID: "{751de080-95d1-11df-981c-0800200c9a66}" } ) ,
sms: SendToPhone_ProtocolWrapper( { scheme: "sms", ID: "{345de080-95d1-11df-981c-0800200c9a66}" } ) ,
smsto: SendToPhone_ProtocolWrapper( { scheme: "smsto", ID: "{854de080-95d1-11df-981c-0800200c9a66}" } ) ,
mms: SendToPhone_ProtocolWrapper( { scheme: "mms", ID: "{457de080-95d1-11df-981c-0800200c9a66}" } ) ,
mmsto: SendToPhone_ProtocolWrapper( { scheme: "mmsto", ID: "{331de080-95d1-11df-981c-0800200c9a66}" } ) ,
tel: SendToPhone_ProtocolWrapper( { scheme: "tel", ID: "{948de080-95d1-11df-981c-0800200c9a66}" } )
};

View File

@@ -131,6 +131,9 @@ var sendtophoneCore = {
}
else
{
if (req.status==500 && body.substr(0,27) =="ERROR (Unable to send link)")
sendtophoneCore.openTab( "http://www.foxtophone.com/status500/" );
else
sendtophoneCore.alert(sendtophoneCore.getString("ErrorOnSend") + ' (status ' + req.status + ')\r\n' + body);
}
}
@@ -171,7 +174,7 @@ var sendtophoneCore = {
return;
}
if (!(/^(https?|market|tel|sms(to)?|mms(to)?|mailto|ftp):/i).test( url ))
if (!(/^(https?|market|tel|sms(to)?|mailto|ftp):/i).test( url ))
{
this.alert(this.getString("InvalidScheme"));
return;