Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
4f1f75e9
Unverified
Commit
4f1f75e9
authored
Nov 03, 2017
by
Dave Cridland
Committed by
GitHub
Nov 03, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #753 from Gugli/roster-restrictions-interceptor
Allow code reuse from plugins
parents
6286c4ac
fbc41a5b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
16 deletions
+33
-16
PresenceSubscribeHandler.java
...vesoftware/openfire/handler/PresenceSubscribeHandler.java
+31
-14
RosterItem.java
src/java/org/jivesoftware/openfire/roster/RosterItem.java
+2
-2
No files found.
src/java/org/jivesoftware/openfire/handler/PresenceSubscribeHandler.java
View file @
4f1f75e9
...
@@ -477,20 +477,24 @@ public class PresenceSubscribeHandler extends BasicModule implements ChannelHand
...
@@ -477,20 +477,24 @@ public class PresenceSubscribeHandler extends BasicModule implements ChannelHand
* <p>Indicate a state change.</p>
* <p>Indicate a state change.</p>
* <p>Use nulls to indicate fields that should not be changed.</p>
* <p>Use nulls to indicate fields that should not be changed.</p>
*/
*/
p
rivate
static
class
Change
{
p
ublic
static
class
Change
{
public
Change
(
RosterItem
.
RecvType
recv
,
RosterItem
.
SubType
sub
,
RosterItem
.
AskType
ask
)
{
public
Change
(
RosterItem
.
RecvType
recv
,
RosterItem
.
SubType
sub
,
RosterItem
.
AskType
ask
)
{
newRecv
=
recv
;
newRecv
=
recv
;
newSub
=
sub
;
newSub
=
sub
;
newAsk
=
ask
;
newAsk
=
ask
;
}
}
public
RosterItem
.
RecvType
newRecv
;
public
RosterItem
.
RecvType
getNewRecv
()
{
return
newRecv
;
}
public
RosterItem
.
SubType
newSub
;
public
RosterItem
.
SubType
getNewSub
()
{
return
newSub
;
}
public
RosterItem
.
AskType
newAsk
;
public
RosterItem
.
AskType
getNewAsk
()
{
return
newAsk
;
}
private
RosterItem
.
RecvType
newRecv
;
private
RosterItem
.
SubType
newSub
;
private
RosterItem
.
AskType
newAsk
;
}
}
/**
/**
* Determine
and call the update method based on the item'
s subscription state.
* Determine
the changes to apply to the item, according to it
s subscription state.
* The method also turns the action and sending status into an integer code
* The method also turns the action and sending status into an integer code
* for easier processing (switch statements).
* for easier processing (switch statements).
* <p/>
* <p/>
...
@@ -503,19 +507,32 @@ public class PresenceSubscribeHandler extends BasicModule implements ChannelHand
...
@@ -503,19 +507,32 @@ public class PresenceSubscribeHandler extends BasicModule implements ChannelHand
* @param item The item to be updated
* @param item The item to be updated
* @param action The new state change request
* @param action The new state change request
* @param isSending True if the roster owner of the item is sending the new state change request
* @param isSending True if the roster owner of the item is sending the new state change request
* @return Change changes to apply to the item
*/
*/
p
rivate
static
void
updateState
(
RosterItem
item
,
Presence
.
Type
action
,
boolean
isSending
)
{
p
ublic
static
Change
getStateChange
(
RosterItem
.
SubType
itemSubType
,
Presence
.
Type
action
,
boolean
isSending
)
{
Map
<
String
,
Map
<
Presence
.
Type
,
Change
>>
srTable
=
stateTable
.
get
(
item
.
getSubStatus
()
);
Map
<
String
,
Map
<
Presence
.
Type
,
Change
>>
srTable
=
stateTable
.
get
(
item
SubType
);
Map
<
Presence
.
Type
,
Change
>
changeTable
=
srTable
.
get
(
isSending
?
"send"
:
"recv"
);
Map
<
Presence
.
Type
,
Change
>
changeTable
=
srTable
.
get
(
isSending
?
"send"
:
"recv"
);
Change
change
=
changeTable
.
get
(
action
);
return
changeTable
.
get
(
action
);
if
(
change
.
newAsk
!=
null
&&
change
.
newAsk
!=
item
.
getAskStatus
())
{
}
item
.
setAskStatus
(
change
.
newAsk
);
/**
* Determine and call the update method based on the item's subscription state.
* <p/>
*
* @param item The item to be updated
* @param action The new state change request
* @param isSending True if the roster owner of the item is sending the new state change request
*/
private
static
void
updateState
(
RosterItem
item
,
Presence
.
Type
action
,
boolean
isSending
)
{
Change
change
=
getStateChange
(
item
.
getSubStatus
(),
action
,
isSending
);
if
(
change
.
getNewAsk
()
!=
null
&&
change
.
getNewAsk
()
!=
item
.
getAskStatus
())
{
item
.
setAskStatus
(
change
.
getNewAsk
());
}
}
if
(
change
.
newSub
!=
null
&&
change
.
newSub
!=
item
.
getSubStatus
())
{
if
(
change
.
getNewSub
()
!=
null
&&
change
.
getNewSub
()
!=
item
.
getSubStatus
())
{
item
.
setSubStatus
(
change
.
newSub
);
item
.
setSubStatus
(
change
.
getNewSub
()
);
}
}
if
(
change
.
newRecv
!=
null
&&
change
.
newRecv
!=
item
.
getRecvStatus
())
{
if
(
change
.
getNewRecv
()
!=
null
&&
change
.
getNewRecv
()
!=
item
.
getRecvStatus
())
{
item
.
setRecvStatus
(
change
.
newRecv
);
item
.
setRecvStatus
(
change
.
getNewRecv
()
);
}
}
}
}
...
...
src/java/org/jivesoftware/openfire/roster/RosterItem.java
View file @
4f1f75e9
...
@@ -283,7 +283,7 @@ public class RosterItem implements Cacheable, Externalizable {
...
@@ -283,7 +283,7 @@ public class RosterItem implements Cacheable, Externalizable {
new
LinkedList
<>(
item
.
getGroups
()));
new
LinkedList
<>(
item
.
getGroups
()));
}
}
p
rivate
static
RosterItem
.
AskType
getAskStatus
(
org
.
xmpp
.
packet
.
Roster
.
Item
item
)
{
p
ublic
static
RosterItem
.
AskType
getAskStatus
(
org
.
xmpp
.
packet
.
Roster
.
Item
item
)
{
if
(
item
.
getAsk
()
==
org
.
xmpp
.
packet
.
Roster
.
Ask
.
subscribe
)
{
if
(
item
.
getAsk
()
==
org
.
xmpp
.
packet
.
Roster
.
Ask
.
subscribe
)
{
return
RosterItem
.
ASK_SUBSCRIBE
;
return
RosterItem
.
ASK_SUBSCRIBE
;
}
}
...
@@ -295,7 +295,7 @@ public class RosterItem implements Cacheable, Externalizable {
...
@@ -295,7 +295,7 @@ public class RosterItem implements Cacheable, Externalizable {
}
}
}
}
p
rivate
static
RosterItem
.
SubType
getSubType
(
org
.
xmpp
.
packet
.
Roster
.
Item
item
)
{
p
ublic
static
RosterItem
.
SubType
getSubType
(
org
.
xmpp
.
packet
.
Roster
.
Item
item
)
{
if
(
item
.
getSubscription
()
==
org
.
xmpp
.
packet
.
Roster
.
Subscription
.
to
)
{
if
(
item
.
getSubscription
()
==
org
.
xmpp
.
packet
.
Roster
.
Subscription
.
to
)
{
return
RosterItem
.
SUB_TO
;
return
RosterItem
.
SUB_TO
;
}
}
...
...
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