Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/nsISipgateFFX.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function SipgateFFX() {
"44": ["^00","^\\+"],
"49": ["^00","^\\+"]
};
this.mLogBuffer = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
this.mLogBuffer = Components.classes["@mozilla.org/array;1"].createInstance(Components.interfaces.nsIMutableArray);
this.mLogBufferMaxSize = 1000;
this.getBalanceTimer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
this.getRecommendedIntervalsTimer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
Expand Down Expand Up @@ -1613,7 +1613,7 @@ SipgateFFX.prototype = {
}
}
while (this.mLogBuffer.Count() > this.mLogBufferMaxSize) {
this.mLogBuffer.DeleteElementAt(0);
this.mLogBuffer.RemoveElementAt(0);
}
} catch (ex) {
dump("Error in _log(): "+ex+"\n");
Expand Down
4 changes: 2 additions & 2 deletions components/nsISipgateFFXStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function SipgateFFXStorage() {

this.blacklisted = [];

this.mLogBuffer = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
this.mLogBuffer = Components.classes["@mozilla.org/array;1"].createInstance(Components.interfaces.nsIMutableArray);
this.mLogBufferMaxSize = 1000;
}

Expand Down Expand Up @@ -206,7 +206,7 @@ SipgateFFXStorage.prototype = {
this.mLogBuffer.AppendElement(_CStringLogMessage);
dump("[" + timestampFloat.toFixed(3) + "] " + logMessage + "\n");
while (this.mLogBuffer.Count() > this.mLogBufferMaxSize) {
this.mLogBuffer.DeleteElementAt(0);
this.mLogBuffer.RemoveElementAt(0);
}
} catch (ex) {
dump("Error in _log(): "+ex+"\n");
Expand Down
6 changes: 3 additions & 3 deletions content/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,11 +603,11 @@ var sipgateffx = {
var httpServer = sipgateffx.component.sipgateCredentials.HttpServer.replace(/^www/, 'secure');
var urlSessionLogin = protocol + httpServer + "/user/slogin.php";

var oHttpRequest = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.getService(Components.interfaces.nsIJSXMLHttpRequest);
var oHttpRequest = new XMLHttpRequest();
oHttpRequest.open("POST",urlSessionLogin,false);
oHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
oHttpRequest.send("username="+user+"&password="+pass);
oHttpRequest.send("username=" + encodeURIComponent(user) +
"&password=" + encodeURIComponent(pass));
return oHttpRequest.responseText.match(/\d\d\d/).toString();
},

Expand Down
25 changes: 13 additions & 12 deletions content/sms.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*****************************************************************************

sipgate FFX - Firefox Extension for Mozilla Firefox Webbrowser
Copyright (C) 2011 sipgate GmbH, Germany

The original code is hosted at
Copyright (C) 2011 sipgate GmbH, Germany
The original code is hosted at
http://www.github.com/sipgate/sipgateffx

sipgateFFX is free software; you can redistribute it and/or modify
Expand All @@ -29,15 +29,15 @@ var sipgateffx_sms = {

onLoad: function() {
sipgateffx_sms.promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);

try {
sipgateffx_sms.component = Components.classes['@api.sipgate.net/sipgateffx;1'].getService().wrappedJSObject;
}
catch (anError) {
dump("ERROR: " + anError);
return;
}

try {
sipgateffx_sms.component = Components.classes['@api.sipgate.net/sipgateffx;1'].getService().wrappedJSObject;
}
catch (anError) {
dump("ERROR: " + anError);
return;
}
sipgateffx_sms.strings = document.getElementById("sipgateffx_sms-strings");

if(sipgateffx_sms.component.tosList.indexOf('text') == -1) {
Expand Down Expand Up @@ -86,6 +86,7 @@ var sipgateffx_sms = {
}
if(typeof window.arguments[1] != "undefined") {
document.getElementById("sipgate_sms_number").setAttribute('value', window.arguments[1]);
document.getElementById("sipgate_sms_text").focus();
}
}

Expand Down
65 changes: 54 additions & 11 deletions content/thunderbirdABEditOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var sipgateffx_ABEditOverlay =
this.strings = document.getElementById("sipgateffx-strings");

// Create UI
// Call buttons
const containerIDs = [
"WorkPhoneContainer",
"HomePhoneContainer",
Expand All @@ -59,18 +60,37 @@ var sipgateffx_ABEditOverlay =
let container = document.getElementById(containerIDs[i]);

let button = document.createElement("button");
button.id = "call_" + containerIDs[i];
button.id = "sipgateFFX_call_" + containerIDs[i];
button.classList.add("call");
button.setAttribute("label", this.strings.getString("call.label"));
button.setAttribute("tooltiptext", this.strings.getString("call.tooltip"));
button.addEventListener("command", function(e) { sipgateffx_ABEditOverlay.onClick(e); }, false);
button.addEventListener("command", function(e) { sipgateffx_ABEditOverlay.onClickCall(e); }, false);
container.appendChild(button);

let smsButton = document.createElement("button");
smsButton.id = "sipgateFFX_sms_" + containerIDs[i];
smsButton.classList.add("sms");
smsButton.setAttribute("label", this.strings.getString("sms.label"));
smsButton.setAttribute("tooltiptext", this.strings.getString("sms.tooltip"));
if (containerIDs[i] == "CellularNumberContainer") {
smsButton.addEventListener("command", function(e) { sipgateffx_ABEditOverlay.onClickSMS(e); }, false);
} else {
smsButton.setAttribute("disabled", true);
}
container.appendChild(smsButton);

var textbox = container.getElementsByTagName("textbox").item(0);
textbox.addEventListener("change", function(e) { this.onPhoneChanged(e); }, false);
textbox.addEventListener("blur", function(e) { this.onPhoneChanged(e); }, false);
this.onPhoneChanged({ target : textbox }); // update right now
}

// SMS button
{
let containerID = "CellularNumberContainer";
let container = document.getElementById(containerID);

}
} catch (e) { alert(e); }
},

Expand All @@ -86,23 +106,25 @@ var sipgateffx_ABEditOverlay =
var textbox = e.target;
var button = textbox.parentNode.getElementsByClassName("call").item(0);
if ( !button) throw "button not found";

button.setAttribute("disabled", !textbox.value);

var smsButton = textbox.parentNode.getElementsByClassName("sms").item(0);
if ( !smsButton) throw "button not found";
if (smsButton.id == "sipgateFFX_sms_CellularNumberContainer") {
smsButton.setAttribute("disabled", !textbox.value);
}
},

/**
* Called when the user clicks on the "Call" button inside the contact overview pane.
* @param e {Event}
*/
onClick: function onClick(e)
* @param e {Event}
*/
onClickCall: function onClickCall(e)
{
try {
e.preventDefault();
var button = e.target;
var textbox = button.parentNode.getElementsByTagName("textbox").item(0);
if ( !textbox) throw "textfield not found";

var number = textbox.value;
var number = this._getNumber(button);
button.setAttribute("status", "calling");
var done = function() {
button.removeAttribute("status");
Expand All @@ -119,7 +141,6 @@ var sipgateffx_ABEditOverlay =
*/
call : function call(number, successCallback, errorCallback)
{
number = this.component.niceNumber(number);
if (this.component.getPref("extensions.sipgateffx.previewnumber", "bool")) {
window.openDialog('chrome://sipgateffx/content/previewnumber.xul', 'sipgatePreviewnumber', 'chrome,centerscreen,resizable=no,titlebar=yes,alwaysRaised=yes', number);
} else {
Expand All @@ -129,6 +150,28 @@ var sipgateffx_ABEditOverlay =
});
}
},

/**
* Called when the user clicks on the "SMS" button inside the contact overview pane.
* @param e {Event}
*/
onClickSMS: function onClickSMS(e)
{
try {
e.preventDefault();
var number = "+" + this._getNumber(e.target);
window.openDialog("chrome://sipgateffx/content/sms.xul", "sipgateSMS", "chrome,centerscreen,resizable=yes,titlebar=yes,alwaysRaised=yes", "", number);
} catch (e) { alert(e); }
},

_getNumber : function(button)
{
var textbox = button.parentNode.getElementsByTagName("textbox").item(0);
if ( !textbox) throw "textfield not found";
var number = textbox.value;
return this.component.niceNumber(number); // without leading +
},

};

window.addEventListener("load", function () { sipgateffx_ABEditOverlay.onLoad(); }, false);
50 changes: 42 additions & 8 deletions content/thunderbirdABOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ var sipgateffx_ABOverlay =
{
try {
// create UI

// Call button
const descrIDs = [
"cvPhWork",
"cvPhHome",
"cvPhFax",
//"cvPhFax",
"cvPhCellular",
"cvPhPager",
];
Expand All @@ -85,31 +87,42 @@ var sipgateffx_ABOverlay =
for (let i = 0; i < descrIDs.length; i++) {
let descr = document.getElementById(descrIDs[i]);
let button = document.createElement("button");
button.id = "call_" + descrIDs[i];
button.id = "sipgateFFX_call_" + descrIDs[i];
button.classList.add("call");
button.setAttribute("label", this.strings.getString("call.label"));
button.setAttribute("tooltiptext", this.strings.getString("call.tooltip"));
button.addEventListener("command", function(e) { sipgateffx_ABOverlay.onClick(e); }, false);
button.addEventListener("command", function(e) { sipgateffx_ABOverlay.onClickCall(e); }, false);
descr.appendChild(button);
// disabling not necessary, because TB collapses unused <descr>s.
//let hasContent = descr.firstChild.nodeName == "#text";
//button.setAttribute("disabled", !hasContent);
}

// SMS button
{
let descrID = "cvPhCellular";
let descr = document.getElementById(descrID);
let button = document.createElement("button");
button.id = "sipgateFFX_sms";
button.classList.add("sms");
button.setAttribute("label", this.strings.getString("sms.label"));
button.setAttribute("tooltiptext", this.strings.getString("sms.tooltip"));
button.addEventListener("command", function(e) { sipgateffx_ABOverlay.onClickSMS(e); }, false);
descr.appendChild(button);
}
} catch (e) { alert(e); }
},

/**
* Called when the user clicks on the "Call" button inside the contact overview pane.
* @param e {Event}
*/
onClick: function onClick(e)
onClickCall: function onClickCall(e)
{
try {
e.preventDefault();
var button = e.target;
var descr = button.parentNode.firstChild.textContent;
// descr is e.g. "Home: 1343"
var number = descr.substr(descr.indexOf(":") + 2);
var number = this._getNumber(button);
button.setAttribute("status", "calling");
var done = function() {
button.removeAttribute("status");
Expand All @@ -126,7 +139,6 @@ var sipgateffx_ABOverlay =
*/
call : function call(number, successCallback, errorCallback)
{
number = this.component.niceNumber(number);
if (this.component.getPref("extensions.sipgateffx.previewnumber", "bool")) {
window.openDialog('chrome://sipgateffx/content/previewnumber.xul', 'sipgatePreviewnumber', 'chrome,centerscreen,resizable=no,titlebar=yes,alwaysRaised=yes', number);
} else {
Expand All @@ -136,6 +148,28 @@ var sipgateffx_ABOverlay =
});
}
},

/**
* Called when the user clicks on the "SMS" button inside the contact overview pane.
* @param e {Event}
*/
onClickSMS: function onClickSMS(e)
{
try {
e.preventDefault();
var number = "+" + this._getNumber(e.target);
window.openDialog("chrome://sipgateffx/content/sms.xul", "sipgateSMS", "chrome,centerscreen,resizable=yes,titlebar=yes,alwaysRaised=yes", "", number);
} catch (e) { alert(e); }
},

_getNumber : function(button)
{
var descr = button.parentNode.firstChild.textContent;
// descr is e.g. "Home: 1343"
var number = descr.substr(descr.indexOf(":") + 2);
return this.component.niceNumber(number); // without leading +
},

};

window.addEventListener("load", function () { sipgateffx_ABOverlay.onLoad(); }, false);
14 changes: 7 additions & 7 deletions install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
<!-- firefox -->
<RDF:Description RDF:about="rdf:#$NV0g12"
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
em:minVersion="3.0a1"
em:maxVersion="17.*" />
em:minVersion="45.0"
em:maxVersion="59.*" />
<!-- thunderbird -->
<RDF:Description RDF:about="rdf:#$+z19m"
em:id="{3550f703-e582-4d05-9a08-453d09bdfdc6}"
em:minVersion="3.0a1pre"
em:maxVersion="20.*" />
em:minVersion="45.0"
em:maxVersion="59.*" />
<!-- postbox -->
<RDF:Description RDF:about="rdf:#$GrpsQ"
em:id="postbox@postbox-inc.com"
em:minVersion="1.0b16"
em:maxVersion="1.2.*" />
em:minVersion="5.0"
em:maxVersion="10.*" />
<RDF:Description RDF:about="urn:mozilla:install-manifest"
em:id="sipgateffx@michael.rotmanov"
em:name="sipgateFFX"
em:version="0.7.4"
em:version="0.7.5"
em:creator="sipgate"
em:type="2"
em:description="Browser and communication successfully merged"
Expand Down
2 changes: 2 additions & 0 deletions locale/de-DE/sipgateffx.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ notification.voice=%S neue Voicemails
notification.x-call=%S neue Anrufe
call.label=Anrufen
call.tooltip=Anrufen
sms.label=SMS
sms.tooltip=SMS
2 changes: 2 additions & 0 deletions locale/en-US/sipgateffx.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ notification.voice=%S new voicemails
notification.x-call=%S new calls
call.label=Call
call.tooltip=Call
sms.label=SMS
sms.tooltip=Text with SMS
Binary file added skin/icon_sms.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions skin/thunderbirdABOverlay.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ button.call
min-width: 20px;
}

button.sms
{
list-style-image: url("chrome://sipgateffx/skin/icon_sms.gif");
min-width: 20px;
}

/* remove label */
button.call label.button-text {
button.call label.button-text,
button.sms label.button-text {
display: none;
}

button.call[disabled=true]
button.call[disabled=true],
button.sms[disabled=true]
{
/* not using display:none or hidden=true, because these change the layout */
visibility: hidden;
Expand Down