-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebase to current master: add XEP-0333 (Chatmarker archiving)
- Loading branch information
Showing
8 changed files
with
221 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/java/org/jivesoftware/openfire/archive/ChatMarker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.jivesoftware.openfire.archive; | ||
|
||
public class ChatMarker { | ||
|
||
public enum MARKERTYPE | ||
{ | ||
NONE, | ||
MARKABLE, | ||
RECEIVED, | ||
DISPLAYED, | ||
ACKNOWLEGED; | ||
} | ||
|
||
public static MARKERTYPE searchForXep0333(String stanza) | ||
{ | ||
if (stanza==null) | ||
{ | ||
return MARKERTYPE.NONE; | ||
} | ||
|
||
int idxmarkable = stanza.indexOf("<markable"); | ||
int idxreceived= stanza.indexOf("<received"); | ||
int idxdisplayed = stanza.indexOf("<displayed"); | ||
int idxacknowled = stanza.indexOf("<acknowledged"); | ||
|
||
if (idxmarkable!=-1) | ||
{ | ||
int idxEnd = stanza.indexOf("/>",idxmarkable); | ||
if (idxEnd==-1) | ||
{ | ||
idxEnd = stanza.indexOf("</markable>",idxmarkable); | ||
} | ||
return idxEnd!=-1?(stanza.substring(idxmarkable, idxEnd).contains("urn:xmpp:chat-markers:0")?MARKERTYPE.MARKABLE:MARKERTYPE.NONE):MARKERTYPE.NONE; | ||
} | ||
else | ||
if (idxreceived!=-1) | ||
{ | ||
int idxEnd = stanza.indexOf("/>",idxreceived); | ||
if (idxEnd==-1) | ||
{ | ||
idxEnd = stanza.indexOf("</received>",idxmarkable); | ||
} | ||
return idxEnd!=-1?(stanza.substring(idxreceived, idxEnd).contains("urn:xmpp:chat-markers:0")?MARKERTYPE.RECEIVED:MARKERTYPE.NONE):MARKERTYPE.NONE; | ||
} | ||
else | ||
if (idxdisplayed!=-1) | ||
{ | ||
int idxEnd = stanza.indexOf("/>",idxdisplayed); | ||
if (idxEnd==-1) | ||
{ | ||
idxEnd = stanza.indexOf("</displayed>",idxmarkable); | ||
} | ||
return idxEnd!=-1?(stanza.substring(idxdisplayed, idxEnd).contains("urn:xmpp:chat-markers:0")?MARKERTYPE.DISPLAYED:MARKERTYPE.NONE):MARKERTYPE.NONE; | ||
} | ||
else | ||
if (idxacknowled!=-1) | ||
{ | ||
int idxEnd = stanza.indexOf("/>",idxacknowled); | ||
if (idxEnd==-1) | ||
{ | ||
idxEnd = stanza.indexOf("</acknowledged>",idxmarkable); | ||
} | ||
return idxEnd!=-1?(stanza.substring(idxacknowled, idxEnd).contains("urn:xmpp:chat-markers:0")?MARKERTYPE.ACKNOWLEGED:MARKERTYPE.NONE):MARKERTYPE.NONE; | ||
} | ||
else | ||
return MARKERTYPE.NONE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.