Skip to content

Commit

Permalink
Upgrade to latest client-common-java API
Browse files Browse the repository at this point in the history
Signed-off-by: Daniele Ricci <[email protected]>
  • Loading branch information
daniele-athome committed Jan 7, 2015
1 parent 5c6ea8e commit 479a0e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.lang.ref.WeakReference;
import java.security.GeneralSecurityException;
import java.util.Collection;
Expand Down Expand Up @@ -99,13 +97,13 @@
import org.kontalk.client.E2EEncryption;
import org.kontalk.client.EndpointServer;
import org.kontalk.client.KontalkConnection;
import org.kontalk.client.PublicKeyPresence;
import org.kontalk.client.PublicKeyPublish;
import org.kontalk.client.RosterMatch;
import org.kontalk.client.OutOfBandData;
import org.kontalk.client.PushRegistration;
import org.kontalk.client.RawPacket;
import org.kontalk.client.ServerlistCommand;
import org.kontalk.client.SubscribePublicKey;
import org.kontalk.client.UploadInfo;
import org.kontalk.client.VCard4;
import org.kontalk.crypto.Coder;
Expand Down Expand Up @@ -485,7 +483,7 @@ private void configure() {
ProviderManager.addIQProvider(ServerlistCommand.ELEMENT_NAME, ServerlistCommand.NAMESPACE, new ServerlistCommand.ResultProvider());
ProviderManager.addExtensionProvider(OutOfBandData.ELEMENT_NAME, OutOfBandData.NAMESPACE, new OutOfBandData.Provider());
ProviderManager.addExtensionProvider(BitsOfBinary.ELEMENT_NAME, BitsOfBinary.NAMESPACE, new BitsOfBinary.Provider());
ProviderManager.addExtensionProvider(SubscribePublicKey.ELEMENT_NAME, SubscribePublicKey.NAMESPACE, new SubscribePublicKey.Provider());
ProviderManager.addExtensionProvider(PublicKeyPresence.ELEMENT_NAME, PublicKeyPresence.NAMESPACE, new PublicKeyPresence.Provider());
ProviderManager.addExtensionProvider(E2EEncryption.ELEMENT_NAME, E2EEncryption.NAMESPACE, new E2EEncryption.Provider());
// we want to manually handle roster stuff
Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.IOException;

import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.packet.Presence;
Expand All @@ -37,9 +36,8 @@
import android.content.Intent;
import android.util.Log;

import org.kontalk.client.PublicKeyPresence;
import org.kontalk.client.PublicKeyPublish;
import org.kontalk.client.SubscribePublicKey;
import org.kontalk.client.VCard4;
import org.kontalk.crypto.PGP;
import org.kontalk.data.Contact;
import org.kontalk.provider.MyMessages.CommonColumns;
Expand Down Expand Up @@ -74,12 +72,12 @@ public PresenceListener(MessageCenterService instance) {
}

private Packet createSubscribe(Presence p) {
PacketExtension _pkey = p.getExtension(SubscribePublicKey.ELEMENT_NAME, SubscribePublicKey.NAMESPACE);
PacketExtension _pkey = p.getExtension(PublicKeyPresence.ELEMENT_NAME, PublicKeyPresence.NAMESPACE);

try {

if (_pkey instanceof SubscribePublicKey) {
SubscribePublicKey pkey = (SubscribePublicKey) _pkey;
if (_pkey instanceof PublicKeyPresence) {
PublicKeyPresence pkey = (PublicKeyPresence) _pkey;

PGPPublicKeyRing pubRing = PGP.readPublicKeyring(pkey.getKey());
PGPPublicKey publicKey = PGP.getMasterKey(pubRing);
Expand Down Expand Up @@ -169,9 +167,9 @@ private void handleSubscribe(Presence p)
// extract public key
String name = null, fingerprint = null;
byte[] publicKey = null;
PacketExtension _pkey = p.getExtension(SubscribePublicKey.ELEMENT_NAME, SubscribePublicKey.NAMESPACE);
if (_pkey instanceof SubscribePublicKey) {
SubscribePublicKey pkey = (SubscribePublicKey) _pkey;
PacketExtension _pkey = p.getExtension(PublicKeyPresence.ELEMENT_NAME, PublicKeyPresence.NAMESPACE);
if (_pkey instanceof PublicKeyPresence) {
PublicKeyPresence pkey = (PublicKeyPresence) _pkey;
byte[] _publicKey = pkey.getKey();
// extract the name from the uid
PGPPublicKeyRing ring = PGP.readPublicKeyring(_publicKey);
Expand Down Expand Up @@ -274,10 +272,10 @@ public static Intent createIntent(Context ctx, Presence p) {
i.putExtra(EXTRA_STAMP, timestamp);

// public key extension (for fingerprint)
PacketExtension _pkey = p.getExtension(SubscribePublicKey.ELEMENT_NAME, SubscribePublicKey.NAMESPACE);
PacketExtension _pkey = p.getExtension(PublicKeyPresence.ELEMENT_NAME, PublicKeyPresence.NAMESPACE);

if (_pkey instanceof SubscribePublicKey) {
SubscribePublicKey pkey = (SubscribePublicKey) _pkey;
if (_pkey instanceof PublicKeyPresence) {
PublicKeyPresence pkey = (PublicKeyPresence) _pkey;

String fingerprint = pkey.getFingerprint();
if (fingerprint != null) {
Expand Down Expand Up @@ -312,7 +310,7 @@ private int updateUsersDatabase(Presence p) {
values.put(Users.LAST_SEEN, timestamp);

// public key extension (for fingerprint)
SubscribePublicKey pkey = p.getExtension(SubscribePublicKey.ELEMENT_NAME, SubscribePublicKey.NAMESPACE);
PublicKeyPresence pkey = p.getExtension(PublicKeyPresence.ELEMENT_NAME, PublicKeyPresence.NAMESPACE);
if (pkey != null) {
String fingerprint = pkey.getFingerprint();
if (fingerprint != null)
Expand Down

0 comments on commit 479a0e5

Please sign in to comment.