|
|
@@ -66,6 +66,11 @@ function init() {
|
|
66
|
66
|
return;
|
|
67
|
67
|
}
|
|
68
|
68
|
|
|
|
69
|
+ var jid = document.getElementById('jid').value || config.hosts.domain || window.location.hostname;
|
|
|
70
|
+ connect(jid);
|
|
|
71
|
+}
|
|
|
72
|
+
|
|
|
73
|
+function connect(jid, password) {
|
|
69
|
74
|
connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
|
|
70
|
75
|
|
|
71
|
76
|
if (nickname) {
|
|
|
@@ -82,9 +87,11 @@ function init() {
|
|
82
|
87
|
connection.jingle.pc_constraints.optional.push({googIPv6: true});
|
|
83
|
88
|
}
|
|
84
|
89
|
|
|
85
|
|
- var jid = document.getElementById('jid').value || config.hosts.domain || window.location.hostname;
|
|
|
90
|
+ if(!password)
|
|
|
91
|
+ password = document.getElementById('password').value;
|
|
86
|
92
|
|
|
87
|
|
- connection.connect(jid, document.getElementById('password').value, function (status) {
|
|
|
93
|
+ var anonymousConnectionFailed = false;
|
|
|
94
|
+ connection.connect(jid, password, function (status, msg) {
|
|
88
|
95
|
if (status === Strophe.Status.CONNECTED) {
|
|
89
|
96
|
console.log('connected');
|
|
90
|
97
|
if (config.useStunTurn) {
|
|
|
@@ -98,6 +105,20 @@ function init() {
|
|
98
|
105
|
});
|
|
99
|
106
|
|
|
100
|
107
|
document.getElementById('connect').disabled = true;
|
|
|
108
|
+ } else if (status === Strophe.Status.CONNFAIL) {
|
|
|
109
|
+ if(msg === 'x-strophe-bad-non-anon-jid') {
|
|
|
110
|
+ anonymousConnectionFailed = true;
|
|
|
111
|
+ }
|
|
|
112
|
+ console.log('status', status);
|
|
|
113
|
+ } else if (status === Strophe.Status.DISCONNECTED) {
|
|
|
114
|
+ if(anonymousConnectionFailed) {
|
|
|
115
|
+ // prompt user for username and password
|
|
|
116
|
+ $(document).trigger('passwordrequired.main');
|
|
|
117
|
+ }
|
|
|
118
|
+ } else if (status === Strophe.Status.AUTHFAIL) {
|
|
|
119
|
+ // wrong password or username, prompt user
|
|
|
120
|
+ $(document).trigger('passwordrequired.main');
|
|
|
121
|
+
|
|
101
|
122
|
} else {
|
|
102
|
123
|
console.log('status', status);
|
|
103
|
124
|
}
|
|
|
@@ -825,6 +846,31 @@ $(document).bind('passwordrequired.muc', function (event, jid) {
|
|
825
|
846
|
});
|
|
826
|
847
|
});
|
|
827
|
848
|
|
|
|
849
|
+$(document).bind('passwordrequired.main', function (event) {
|
|
|
850
|
+ console.log('password is required');
|
|
|
851
|
+
|
|
|
852
|
+ $.prompt('<h2>Password required</h2>' +
|
|
|
853
|
+ '<input id="passwordrequired.username" type="text" placeholder="user@domain.net" autofocus>' +
|
|
|
854
|
+ '<input id="passwordrequired.password" type="password" placeholder="user password">', {
|
|
|
855
|
+ persistent: true,
|
|
|
856
|
+ buttons: { "Ok": true, "Cancel": false},
|
|
|
857
|
+ defaultButton: 1,
|
|
|
858
|
+ loaded: function (event) {
|
|
|
859
|
+ document.getElementById('passwordrequired.username').focus();
|
|
|
860
|
+ },
|
|
|
861
|
+ submit: function (e, v, m, f) {
|
|
|
862
|
+ if (v) {
|
|
|
863
|
+ var username = document.getElementById('passwordrequired.username');
|
|
|
864
|
+ var password = document.getElementById('passwordrequired.password');
|
|
|
865
|
+
|
|
|
866
|
+ if (username.value !== null && password.value != null) {
|
|
|
867
|
+ connect(username.value, password.value);
|
|
|
868
|
+ }
|
|
|
869
|
+ }
|
|
|
870
|
+ }
|
|
|
871
|
+ });
|
|
|
872
|
+});
|
|
|
873
|
+
|
|
828
|
874
|
/**
|
|
829
|
875
|
* Checks if video identified by given src is desktop stream.
|
|
830
|
876
|
* @param videoSrc eg.
|