Skip to content

Commit

Permalink
Add LLEntityCapsManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowdalic committed Dec 3, 2014
1 parent d020486 commit c03fb51
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public static void clearMemoryCache() {
CAPS_CACHE.clear();
}

private static void addCapsExtensionInfo(String from, CapsExtension capsExtension) {
protected static void addCapsExtensionInfo(String from, CapsExtension capsExtension) {
String capsExtensionHash = capsExtension.getHash();
String hashInUppercase = capsExtensionHash.toUpperCase(Locale.US);
// SUPPORTED_HASHES uses the format of MessageDigest, which is uppercase, e.g. "SHA-1" instead of "sha-1"
Expand All @@ -292,6 +292,11 @@ private static void addCapsExtensionInfo(String from, CapsExtension capsExtensio
*/
private String entityNode = DEFAULT_ENTITY_NODE;

protected EntityCapsManager() {
super(null);
throw new UnsupportedOperationException();
}

private EntityCapsManager(XMPPConnection connection) {
super(connection);
this.sdm = ServiceDiscoveryManager.getInstanceFor(connection);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
*
* Copyright 2014 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack.serverless;

import org.jivesoftware.smackx.caps.EntityCapsManager;
import org.jivesoftware.smackx.caps.packet.CapsExtension;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;

public class LLEntityCapsManager extends EntityCapsManager {
private LLEntityCapsManager() {
throw new UnsupportedOperationException();
}

static void addDiscoverInfo(String jid, DiscoverInfo discoverInfo) {
CapsExtension capsExtension = CapsExtension.from(discoverInfo);
if (capsExtension == null) {
return;
}
addCapsExtensionInfo(jid, capsExtension);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.jivesoftware.smack.serverless.service;
package org.jivesoftware.smack.serverless;


import org.jivesoftware.smack.AbstractConnectionListener;
Expand All @@ -38,9 +38,11 @@
import org.jivesoftware.smack.filter.PacketIDFilter;
import org.jivesoftware.smack.filter.IQTypeFilter;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.serverless.LLConnectionConfiguration;
import org.jivesoftware.smack.serverless.LLPresence;
import org.jivesoftware.smack.serverless.XMPPLLConnection;
import org.jivesoftware.smack.serverless.service.LLPresenceDiscoverer;
import org.jivesoftware.smack.serverless.service.LLPresenceListener;
import org.jivesoftware.smack.serverless.service.LLServiceConnectionListener;
import org.jivesoftware.smack.serverless.service.LLServiceListener;
import org.jivesoftware.smack.serverless.service.LLServiceStateListener;

import java.net.ServerSocket;
import java.net.Socket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PlainStreamElement;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.serverless.service.LLService;
import org.xmlpull.v1.XmlPullParser;

import java.io.BufferedReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.jivesoftware.smack.serverless.service;

import org.jivesoftware.smack.serverless.LLService;



/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.serverless.LLPresence;
import org.jivesoftware.smack.serverless.LLService;
import org.jivesoftware.smack.serverless.service.LLPresenceDiscoverer;
import org.jivesoftware.smack.serverless.service.LLService;

import javax.jmdns.JmDNS;
import javax.jmdns.ServiceEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@
package org.jivesoftware.smackx;

import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.serverless.LLPresence;
import org.jivesoftware.smack.serverless.LLServiceDiscoveryManager;
import org.jivesoftware.smack.serverless.service.LLService;
import org.jivesoftware.smack.serverless.LLService;
import org.jivesoftware.smack.serverless.service.LLServiceStateListener;
import org.jivesoftware.smack.serverless.service.jmdns.JmDNSService;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down Expand Up @@ -154,12 +151,12 @@ else if ("addfeature".equals(line)) {
String feature = stdIn.readLine();
// LLServiceDiscoveryManager.addDefaultFeature(feature);
}
else if ("disco".equals(line)) {
System.out.print("Enter user service name e.g (dave@service): ");
String user = stdIn.readLine();
DiscoverInfo info = LLServiceDiscoveryManager.getInstanceFor(service).discoverInfo(user);
System.out.println(" # Discovered: " + info.toXML());
}
// else if ("disco".equals(line)) {
// System.out.print("Enter user service name e.g (dave@service): ");
// String user = stdIn.readLine();
// DiscoverInfo info = LLServiceDiscoveryManager.getInstanceFor(service).discoverInfo(user);
// System.out.println(" # Discovered: " + info.toXML());
// }
else if ("status".equals(line)) {
System.out.print("Enter new status: ");
String status = stdIn.readLine();
Expand All @@ -181,15 +178,6 @@ else if ("status".equals(line)) {
System.out.println("Caught IOException: " + ioe);
ioe.printStackTrace();
done = true;
} catch (SmackException.NotConnectedException e) {
System.out.println("Caught NotConnectedException: " + e);
e.printStackTrace();
} catch (SmackException.NoResponseException e) {
System.out.println("Caught NoResponseException: " + e);
e.printStackTrace();
} catch (SmackException e) {
System.out.println("Caught SmackException: " + e);
e.printStackTrace();
}
}
System.exit(0);
Expand Down

0 comments on commit c03fb51

Please sign in to comment.