Browser-Phone icon indicating copy to clipboard operation
Browser-Phone copied to clipboard

custom XMPP username and password

Open vieridipaola opened this issue 2 years ago • 5 comments

Hi,

I configured XMPP in Browser Phone. My Jabber server is Prosody 0.11. The websocket clients connect via a reverse proxy (Apache) to Prosody wss.

The problem I'm facing is that my Jabber service (which was already in production before using Browser Phone) enforces user authentication with an LDAP server. I cannot use the same SIP usernames and passwords for XMPP.

In function reconnectXmpp:

    var xmpp_username = profileUser +"@"+ XmppDomain;
    if(XmppRealm != "" && XmppRealmSeperator) xmpp_username = XmppRealm + XmppRealmSeperator + xmpp_username;
    var xmpp_password = SipPassword;

It would be great if both xmpp_username and xmpp_password could be set via phoneOptions.

Vieri

vieridipaola avatar May 06 '22 10:05 vieridipaola

Also, if my SIP username is X and my XMPP username is Y and X is on a call or ringing, will the status of Y change automatically?

I mean, if I register in Asterisk with 1234 (SIP) and I log into Jabber with [email protected], I would like the status of my JID to change to "unavailable" or "on the phone" whenever 1234 rings or is on a call.

Is this possible?

vieridipaola avatar May 06 '22 13:05 vieridipaola

I changed the way I use XMPP with Browser-Phone, so now I can use the unpatched phone.js code xmpp_username = profileUser +"@"+ XmppDomain;

Just a side-question though.

When the Browser-Client user logs in correctly it registers to Asterisk SIP and Prosody XMPP. The user's SIP extension number (num) is the same as the [email protected]. Now, when opening Browser-Phone, the SIP extension is "registered", but the xmpp status is "no status". I know I can manually set my status from the menu, but could Browser-Phone automatically set the xmpp client state according to its presence state. For instance, on SIP and XMPP registration, the status should be something like "available". If on a SIP call then the Status should change accordingly.

Currently, no matter what I do (idle, on SIP call, hang up, etc.) the Browser-Phone status us always "No Status".

vieridipaola avatar May 08 '22 08:05 vieridipaola

It would be great if both xmpp_username and xmpp_password could be set via phoneOptions.

Probably best to have this as an option. Having multiple passwords can be annoying to manage.

Also, if my SIP username is X and my XMPP username is Y and X is on a call or ringing, will the status of Y change automatically?

Also something for the settings - remember that Device State, and User Sate, are two totally different concepts, and how they overlap needs to be carefully managed. A device, may be "idle" (as in not in use), but does that man i'm available to be called... i could be busy on something else, or away from my desk. Also, If i'm not the phone, does that mean don't phone me... it could be a personal call, and i'm more then happy to put that down, and answer your call.

I like the idea's but they really should be settings.

Currently, no matter what I do (idle, on SIP call, hang up, etc.) the Browser-Phone status us always "No Status".

The status should be settable, from the settings menu Settings > Set Status. If that's not working, there is a bug.

InnovateAsterisk avatar May 16 '22 10:05 InnovateAsterisk

Yes, Settings > Set Status works.

As you say, it would be best to have a setting that auto-updates the XMPP user status. I agree with you that an xmpp user might want to be "available" even if on a SIP call, and vice versa.

However, there are some cases where one wants the xmpp user status to be the same as the status of the SIP user (on call, busy with DND client or server-side, etc.). Or maybe something in-between would be to update the status as:

myxmppStatus = user_set_status + " (" + sipStatus+ ")"

where sipStatus is something like "on the phone", "DND", "ringing" or whatever.

Maybe I'm asking too much, or it's too specific.

Thanks

vieridipaola avatar May 16 '22 14:05 vieridipaola

Hi,

This is the quick hack I'm using to update the call status within XMPP presence.

I changed the XmppSetMyPresence function in phone.js to:

function XmppSetMyPresence(str, desc, updateVcard, auto){
    if(!XMPP || XMPP.connected == false) {
        console.warn("XMPP not connected");
        return;
    }

    // ["away", "chat", "dnd", "xa"] => ["Away", "Available", "Busy", "Gone"]

    console.log("Setting My Own Presence to: "+ str + "("+ desc +")");

    if(desc == "") desc = lang.default_status;
    if((typeof auto !== "undefined") && (auto != "")) desc += " " + auto;
    $("#regStatus").html("<i class=\"fa fa-comments\"></i> "+ desc);

[...]

I then added calls within my custom web hooks such as:

var web_hook_on_invite = function(session) {
    XmppSetMyPresence(localDB.getItem("XmppLastPresence"), localDB.getItem("XmppLastStatus"), false, (DoNotDisturbEnabled == false) ? "On call" : "On call - DND");
[...]

var web_hook_on_terminate = function(session) {
    XmppSetMyPresence(localDB.getItem("XmppLastPresence"), localDB.getItem("XmppLastStatus"), false, (DoNotDisturbEnabled == false) ? "Not on call" : "Not on call - DND");
[...] 
 
var web_hook_enable_dnd = function(session) {
    XmppSetMyPresence(localDB.getItem("XmppLastPresence"), localDB.getItem("XmppLastStatus"), false, "DND");
}

var web_hook_disable_dnd = function(session) {
    XmppSetMyPresence(localDB.getItem("XmppLastPresence"), localDB.getItem("XmppLastStatus"), false, "no DND");
}

It's quick and dirty (and I'm not taking into account call waiting as most of my users don't use it), but it would be nice if Browser-Phone could support auto-updating the "call status" or "SIP status" in the XMPP presence data. Wouldn't that be useful info to everyone?

BTW you may want to change the value of "do_no_disturb" in en.json to "Do Not Disturb".

vieridipaola avatar Jul 20 '22 09:07 vieridipaola