fixes npe in privacymanager

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12526 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Wolf Posdorfer
2011-06-22 17:16:39 +00:00
committed by wolf.posdorfer
parent 5e3016c911
commit 47f7b51145

View File

@ -52,7 +52,7 @@ public class PrivacyManager {
private PrivacyListManager privacyManager; private PrivacyListManager privacyManager;
private PrivacyPresenceHandler _presenceHandler = new PrivacyPresenceHandler(); private PrivacyPresenceHandler _presenceHandler = new PrivacyPresenceHandler();
private Set<SparkPrivacyListListener> _listListeners = new HashSet<SparkPrivacyListListener>(); private Set<SparkPrivacyListListener> _listListeners = new HashSet<SparkPrivacyListListener>();
private boolean _active = false;; private boolean _active = false;
/** /**
* Creating PrivacyListManager instance * Creating PrivacyListManager instance
@ -63,7 +63,7 @@ public class PrivacyManager {
Log.error("Privacy plugin: Connection not initialized."); Log.error("Privacy plugin: Connection not initialized.");
} }
checkIfPrivacyIsSupported(conn); _active = checkIfPrivacyIsSupported(conn);
if (_active) if (_active)
{ {
@ -91,25 +91,24 @@ public class PrivacyManager {
} }
private void checkIfPrivacyIsSupported(XMPPConnection conn) private boolean checkIfPrivacyIsSupported(XMPPConnection conn) {
{
ServiceDiscoveryManager servDisc = new ServiceDiscoveryManager(conn); ServiceDiscoveryManager servDisc = new ServiceDiscoveryManager(conn);
DiscoverInfo info = null; DiscoverInfo info = null;
try { try {
info = servDisc.discoverInfo(conn.getHost()); info = servDisc.discoverInfo(conn.getHost());
} catch (XMPPException e) { } catch (XMPPException e) {
// We could not query the server // We could not query the server
return false;
} }
for(Iterator<Feature> i = info.getFeatures(); i.hasNext();) for (Iterator<Feature> i = info.getFeatures(); i.hasNext();) {
{
String s = i.next().getVar(); String s = i.next().getVar();
if (s.contains("jabber:iq:privacy")) if (s.contains("jabber:iq:privacy")) {
{ return true;
_active = true;
} }
} }
return false;
} }
private void initializePrivacyLists() private void initializePrivacyLists()