XMPP协议中,隐私策略按内容分 presence-in, presence-out, message, iq 4种,分别可以用于 用户和用户组,属于扩展协议,命名空间是 jabber:iq:privacy 。
协议XML Schemas 在 http://xmpp.org/protocols/jabber_iq_privacy/
协议具体内容在 http://xmpp.org/extensions/xep-0016.html 【这里有大量的例子可供参考】
隐私消息的基本语法语义:
<iq> <query xmlns='jabber:iq:privacy'> <list name='foo'> <item type='[jid|group|subscription]' value='bar' action='[allow|deny]' order='unsignedInt'> [<message/>] [<presence-in/>] [<presence-out/>] [<iq/>] </item> </list> </query> </iq>
此协议最主要的应用场合就是添加、删除好友时的订阅关系处理 和 黑名单功能!
常见的几种 privacy list 及 active 和 default 设置
<iq type='result' id='getlist1' to='[email protected]/orchard'> <query xmlns='jabber:iq:privacy'> <active name='private'/> <default name='public'/> <list name='public'/> <list name='private'/> <list name='special'/> </query> </iq>
修改: ative或default
<iq from='[email protected]/orchard' type='set' id='active1'> <query xmlns='jabber:iq:privacy'> <active name='special'/> </query> </iq>
删除:active或default
<iq from='[email protected]/orchard' type='set' id='default2'> <query xmlns='jabber:iq:privacy'> <default/> </query> </iq>
屏蔽用户
<iq from='[email protected]/orchard' type='set' id='all1'> <query xmlns='jabber:iq:privacy'> <list name='all-jid-example'> <item type='jid' value='[email protected]' action='deny' order='23'/> </list> </query> </iq>
屏蔽组
<iq from='[email protected]/orchard' type='set' id='all2'> <query xmlns='jabber:iq:privacy'> <list name='all-group-example'> <item type='group' value='Enemies' action='deny' order='13'/> </list> </query> </iq>
只屏蔽消息
<iq from='[email protected]/orchard' type='set' id='msg1'> <query xmlns='jabber:iq:privacy'> <list name='message-jid-example'> <item type='jid' value='[email protected]' action='deny' order='3'> <message/> </item> </list> </query> </iq>
全局屏蔽用户
<iq from='[email protected]/orchard' type='set' id='all4'> <query xmlns='jabber:iq:privacy'> <list name='all-global-example'> <item action='deny' order='7'/> </list> </query> </iq>