Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
537c56ed
Commit
537c56ed
authored
Jul 28, 2012
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename 'status' to 'presence_type' to avoid confusion.
parent
cd67e80a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
32 deletions
+44
-32
converse.js
converse.js
+44
-32
No files found.
converse.js
View file @
537c56ed
...
@@ -311,15 +311,15 @@ xmppchat.ChatBoxView = Backbone.View.extend({
...
@@ -311,15 +311,15 @@ xmppchat.ChatBoxView = Backbone.View.extend({
$
(
'
body
'
).
append
(
$
(
this
.
el
).
hide
());
$
(
'
body
'
).
append
(
$
(
this
.
el
).
hide
());
xmppchat
.
roster
.
on
(
'
change
'
,
function
(
item
,
changed
)
{
xmppchat
.
roster
.
on
(
'
change
'
,
function
(
item
,
changed
)
{
if
(
_
.
has
(
changed
.
changes
,
'
status
'
))
{
if
(
_
.
has
(
changed
.
changes
,
'
presence_type
'
))
{
if
(
this
.
$el
.
is
(
'
:visible
'
))
{
if
(
this
.
$el
.
is
(
'
:visible
'
))
{
if
(
item
.
get
(
'
status
'
)
===
'
offline
'
)
{
if
(
item
.
get
(
'
presence_type
'
)
===
'
offline
'
)
{
this
.
insertStatusNotification
(
this
.
model
.
get
(
'
user_id
'
),
'
has gone offline
'
);
this
.
insertStatusNotification
(
this
.
model
.
get
(
'
user_id
'
),
'
has gone offline
'
);
}
else
if
(
item
.
get
(
'
status
'
)
===
'
away
'
)
{
}
else
if
(
item
.
get
(
'
presence_type
'
)
===
'
away
'
)
{
this
.
insertStatusNotification
(
this
.
model
.
get
(
'
user_id
'
),
'
has gone away
'
);
this
.
insertStatusNotification
(
this
.
model
.
get
(
'
user_id
'
),
'
has gone away
'
);
}
else
if
(
item
.
get
(
'
status
'
)
===
'
busy
'
)
{
}
else
if
(
(
item
.
get
(
'
presence_type
'
)
===
'
busy
'
)
||
(
item
.
get
(
'
presence_type
'
)
===
'
dnd
'
)
)
{
this
.
insertStatusNotification
(
this
.
model
.
get
(
'
user_id
'
),
'
is busy
'
);
this
.
insertStatusNotification
(
this
.
model
.
get
(
'
user_id
'
),
'
is busy
'
);
}
else
if
(
item
.
get
(
'
status
'
)
===
'
online
'
)
{
}
else
if
(
item
.
get
(
'
presence_type
'
)
===
'
online
'
)
{
this
.
$el
.
find
(
'
div.chat-event
'
).
remove
();
this
.
$el
.
find
(
'
div.chat-event
'
).
remove
();
}
}
}
}
...
@@ -822,6 +822,7 @@ xmppchat.RosterItem = Backbone.Model.extend({
...
@@ -822,6 +822,7 @@ xmppchat.RosterItem = Backbone.Model.extend({
'
subscription
'
:
subscription
,
'
subscription
'
:
subscription
,
'
fullname
'
:
user_id
,
'
fullname
'
:
user_id
,
'
resources
'
:
[],
'
resources
'
:
[],
'
presence_type
'
:
'
offline
'
,
'
status
'
:
'
offline
'
'
status
'
:
'
offline
'
},
{
'
silent
'
:
true
});
},
{
'
silent
'
:
true
});
}
}
...
@@ -892,7 +893,7 @@ xmppchat.RosterItemView = Backbone.View.extend({
...
@@ -892,7 +893,7 @@ xmppchat.RosterItemView = Backbone.View.extend({
that
=
this
,
that
=
this
,
subscription
=
item
.
get
(
'
subscription
'
);
subscription
=
item
.
get
(
'
subscription
'
);
$
(
this
.
el
).
addClass
(
item
.
get
(
'
status
'
)).
attr
(
'
id
'
,
'
online-users-
'
+
item
.
get
(
'
user_id
'
));
$
(
this
.
el
).
addClass
(
item
.
get
(
'
presence_type
'
)).
attr
(
'
id
'
,
'
online-users-
'
+
item
.
get
(
'
user_id
'
));
if
(
ask
===
'
subscribe
'
)
{
if
(
ask
===
'
subscribe
'
)
{
this
.
$el
.
addClass
(
'
pending-xmpp-contact
'
);
this
.
$el
.
addClass
(
'
pending-xmpp-contact
'
);
...
@@ -927,8 +928,8 @@ xmppchat.RosterItemView = Backbone.View.extend({
...
@@ -927,8 +928,8 @@ xmppchat.RosterItemView = Backbone.View.extend({
initialize
:
function
()
{
initialize
:
function
()
{
this
.
options
.
model
.
on
(
'
change
'
,
function
(
item
,
changed
)
{
this
.
options
.
model
.
on
(
'
change
'
,
function
(
item
,
changed
)
{
if
(
_
.
has
(
changed
.
changes
,
'
status
'
))
{
if
(
_
.
has
(
changed
.
changes
,
'
presence_type
'
))
{
$
(
this
.
el
).
attr
(
'
class
'
,
item
.
changed
.
status
);
$
(
this
.
el
).
attr
(
'
class
'
,
item
.
changed
.
presence_type
);
}
}
},
this
);
},
this
);
}
}
...
@@ -946,9 +947,9 @@ xmppchat.Roster = (function (_, $, console) {
...
@@ -946,9 +947,9 @@ xmppchat.Roster = (function (_, $, console) {
},
},
comparator
:
function
(
rosteritem
)
{
comparator
:
function
(
rosteritem
)
{
var
status
=
rosteritem
.
get
(
'
status
'
),
var
presence_type
=
rosteritem
.
get
(
'
presence_type
'
),
rank
=
4
;
rank
=
4
;
switch
(
status
)
{
switch
(
presence_type
)
{
case
'
offline
'
:
case
'
offline
'
:
rank
=
4
;
rank
=
4
;
break
;
break
;
...
@@ -961,6 +962,9 @@ xmppchat.Roster = (function (_, $, console) {
...
@@ -961,6 +962,9 @@ xmppchat.Roster = (function (_, $, console) {
case
'
busy
'
:
case
'
busy
'
:
rank
=
1
;
rank
=
1
;
break
;
break
;
case
'
dnd
'
:
rank
=
1
;
break
;
case
'
online
'
:
case
'
online
'
:
rank
=
0
;
rank
=
0
;
break
;
break
;
...
@@ -990,6 +994,7 @@ xmppchat.Roster = (function (_, $, console) {
...
@@ -990,6 +994,7 @@ xmppchat.Roster = (function (_, $, console) {
resources
;
resources
;
if
(
item
)
{
if
(
item
)
{
resources
=
item
.
get
(
'
resources
'
);
resources
=
item
.
get
(
'
resources
'
);
if
(
resources
)
{
if
(
_
.
indexOf
(
resources
,
resource
)
==
-
1
)
{
if
(
_
.
indexOf
(
resources
,
resource
)
==
-
1
)
{
resources
.
push
(
resource
);
resources
.
push
(
resource
);
item
.
set
({
'
resources
'
:
resources
});
item
.
set
({
'
resources
'
:
resources
});
...
@@ -997,6 +1002,7 @@ xmppchat.Roster = (function (_, $, console) {
...
@@ -997,6 +1002,7 @@ xmppchat.Roster = (function (_, $, console) {
}
else
{
}
else
{
item
.
set
({
'
resources
'
:
[
resource
]});
item
.
set
({
'
resources
'
:
[
resource
]});
}
}
}
},
},
removeResource
:
function
(
bare_jid
,
resource
)
{
removeResource
:
function
(
bare_jid
,
resource
)
{
...
@@ -1032,7 +1038,7 @@ xmppchat.Roster = (function (_, $, console) {
...
@@ -1032,7 +1038,7 @@ xmppchat.Roster = (function (_, $, console) {
getNumOnlineContacts
:
function
()
{
getNumOnlineContacts
:
function
()
{
var
count
=
0
;
var
count
=
0
;
for
(
var
i
=
0
;
i
<
this
.
models
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
this
.
models
.
length
;
i
++
)
{
if
(
_
.
indexOf
([
'
offline
'
,
'
unavailable
'
],
this
.
models
[
i
].
get
(
'
status
'
))
===
-
1
)
{
if
(
_
.
indexOf
([
'
offline
'
,
'
unavailable
'
],
this
.
models
[
i
].
get
(
'
presence_type
'
))
===
-
1
)
{
count
++
;
count
++
;
}
}
}
}
...
@@ -1062,26 +1068,26 @@ xmppchat.Roster = (function (_, $, console) {
...
@@ -1062,26 +1068,26 @@ xmppchat.Roster = (function (_, $, console) {
var
jid
=
$
(
presence
).
attr
(
'
from
'
),
var
jid
=
$
(
presence
).
attr
(
'
from
'
),
bare_jid
=
Strophe
.
getBareJidFromJid
(
jid
),
bare_jid
=
Strophe
.
getBareJidFromJid
(
jid
),
resource
=
Strophe
.
getResourceFromJid
(
jid
),
resource
=
Strophe
.
getResourceFromJid
(
jid
),
ptype
=
$
(
presence
).
attr
(
'
type
'
),
presence_type
=
$
(
presence
).
attr
(
'
type
'
),
item
,
item
,
show
;
status
=
''
;
if
((
$
(
presence
).
find
(
'
x
'
).
attr
(
'
xmlns
'
)
||
''
).
indexOf
(
Strophe
.
NS
.
MUC
)
===
0
)
{
if
((
$
(
presence
).
find
(
'
x
'
).
attr
(
'
xmlns
'
)
||
''
).
indexOf
(
Strophe
.
NS
.
MUC
)
===
0
)
{
// We don't take kindly to MUC stanzas around these here parts
// We don't take kindly to MUC stanzas around these here parts
return
true
;
return
true
;
}
else
if
((
ob
.
isSelf
(
bare_jid
))
||
(
ptype
===
'
error
'
))
{
}
else
if
((
ob
.
isSelf
(
bare_jid
))
||
return
true
;
(
presence_type
===
'
error
'
)
||
}
else
if
((
ptype
===
'
subscribed
'
)
||
(
ptype
===
'
unsubscribe
'
))
{
(
presence_type
===
'
subscribed
'
)
||
(
presence_type
===
'
unsubscribe
'
))
{
return
true
;
return
true
;
}
}
if
(
ptype
===
'
subscribe
'
)
{
if
(
p
resence_
type
===
'
subscribe
'
)
{
if
(
ob
.
getItem
(
bare_jid
))
{
if
(
ob
.
getItem
(
bare_jid
))
{
xmppchat
.
connection
.
roster
.
authorize
(
bare_jid
);
xmppchat
.
connection
.
roster
.
authorize
(
bare_jid
);
}
else
{
}
else
{
ob
.
addRosterItem
(
bare_jid
,
'
none
'
,
'
request
'
);
ob
.
addRosterItem
(
bare_jid
,
'
none
'
,
'
request
'
);
}
}
}
else
if
(
ptype
===
'
unsubscribed
'
)
{
}
else
if
(
p
resence_
type
===
'
unsubscribed
'
)
{
/* Upon receiving the presence stanza of type "unsubscribed",
/* Upon receiving the presence stanza of type "unsubscribed",
* the user SHOULD acknowledge receipt of that subscription state
* the user SHOULD acknowledge receipt of that subscription state
* notification by sending a presence stanza of type "unsubscribe"
* notification by sending a presence stanza of type "unsubscribe"
...
@@ -1094,20 +1100,26 @@ xmppchat.Roster = (function (_, $, console) {
...
@@ -1094,20 +1100,26 @@ xmppchat.Roster = (function (_, $, console) {
xmppchat
.
connection
.
roster
.
remove
(
bare_jid
);
xmppchat
.
connection
.
roster
.
remove
(
bare_jid
);
}
}
}
else
{
}
else
{
// Presence has changed
if
(
presence_type
===
undefined
)
{
if
(
_
.
indexOf
([
'
unavailable
'
,
'
offline
'
,
'
busy
'
,
'
away
'
],
ptype
)
!=
-
1
)
{
show
=
$
(
presence
).
find
(
'
show
'
).
text
();
status
=
ptype
;
if
(
show
===
'
chat
'
)
{
presence_type
=
'
online
'
;
}
else
if
(
show
===
'
dnd
'
)
{
presence_type
=
'
busy
'
;
}
else
if
(
show
===
'
xa
'
)
{
presence_type
=
'
offline
'
;
}
else
{
}
else
{
status
=
(
$
(
presence
).
find
(
'
show
'
).
text
()
===
''
)
?
'
online
'
:
'
away
'
;
presence_type
=
show
;
}
}
}
if
((
status
!==
'
offline
'
)
&&
(
status
!==
'
unavailable
'
))
{
if
((
presence_type
!==
'
offline
'
)
&&
(
presence_type
!==
'
unavailable
'
))
{
ob
.
addResource
(
bare_jid
,
resource
);
ob
.
addResource
(
bare_jid
,
resource
);
model
=
ob
.
getItem
(
bare_jid
);
model
=
ob
.
getItem
(
bare_jid
);
model
.
set
({
'
status
'
:
status
});
model
.
set
({
'
presence_type
'
:
presence_type
});
}
else
{
}
else
{
if
(
ob
.
removeResource
(
bare_jid
,
resource
)
===
0
)
{
if
(
ob
.
removeResource
(
bare_jid
,
resource
)
===
0
)
{
model
=
ob
.
getItem
(
bare_jid
);
model
=
ob
.
getItem
(
bare_jid
);
model
.
set
({
'
status
'
:
status
});
model
.
set
({
'
presence_type
'
:
presence_type
});
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment