aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/entities
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-05-22 15:36:41 +0200
committerDaniel Gultsch <daniel@gultsch.de>2014-05-28 10:41:55 +0200
commitfd4897e1a5a843c8b55b28b00afa6778b345c9a5 (patch)
tree9e7ee33bbcf36a99c9dc77c45baa26bda5c75dc8 /src/eu/siacs/conversations/entities
parentf4ce5082b9743743b8d2623401898ce9516acbd4 (diff)
first tries on crypto muc
Diffstat (limited to 'src/eu/siacs/conversations/entities')
-rw-r--r--src/eu/siacs/conversations/entities/Conversation.java2
-rw-r--r--src/eu/siacs/conversations/entities/MucOptions.java31
2 files changed, 29 insertions, 4 deletions
diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java
index 37a230df..a9699660 100644
--- a/src/eu/siacs/conversations/entities/Conversation.java
+++ b/src/eu/siacs/conversations/entities/Conversation.java
@@ -276,7 +276,7 @@ public class Conversation extends AbstractEntity {
public synchronized MucOptions getMucOptions() {
if (this.mucOptions == null) {
- this.mucOptions = new MucOptions();
+ this.mucOptions = new MucOptions(this.getAccount());
}
this.mucOptions.setConversation(this);
return this.mucOptions;
diff --git a/src/eu/siacs/conversations/entities/MucOptions.java b/src/eu/siacs/conversations/entities/MucOptions.java
index fbca8340..ba2b9bbf 100644
--- a/src/eu/siacs/conversations/entities/MucOptions.java
+++ b/src/eu/siacs/conversations/entities/MucOptions.java
@@ -3,11 +3,10 @@ package eu.siacs.conversations.entities;
import java.util.ArrayList;
import java.util.List;
-import eu.siacs.conversations.entities.MucOptions.User;
+import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.stanzas.PresencePacket;
import android.annotation.SuppressLint;
-import android.util.Log;
@SuppressLint("DefaultLocale")
public class MucOptions {
@@ -31,6 +30,7 @@ public class MucOptions {
private int role;
private int affiliation;
private String name;
+ private long pgpKeyId = 0;
public String getName() {
return name;
@@ -70,7 +70,15 @@ public class MucOptions {
this.affiliation = AFFILIATION_NONE;
}
}
+ public void setPgpKeyId(long id) {
+ this.pgpKeyId = id;
+ }
+
+ public long getPgpKeyId() {
+ return this.pgpKeyId;
+ }
}
+ private Account account;
private ArrayList<User> users = new ArrayList<User>();
private Conversation conversation;
private boolean isOnline = false;
@@ -80,6 +88,9 @@ public class MucOptions {
private User self = new User();
private String subject = null;
+ public MucOptions(Account account) {
+ this.account = account;
+ }
public void deleteUser(String name) {
for(int i = 0; i < users.size(); ++i) {
@@ -100,7 +111,7 @@ public class MucOptions {
users.add(user);
}
- public void processPacket(PresencePacket packet) {
+ public void processPacket(PresencePacket packet, PgpEngine pgp) {
String[] fromParts = packet.getFrom().split("/");
if (fromParts.length>=2) {
String name = fromParts[1];
@@ -119,6 +130,20 @@ public class MucOptions {
} else {
addUser(user);
}
+ if (pgp != null) {
+ Element x = packet.findChild("x",
+ "jabber:x:signed");
+ if (x != null) {
+ Element status = packet.findChild("status");
+ String msg;
+ if (status != null) {
+ msg = status.getContent();
+ } else {
+ msg = "";
+ }
+ user.setPgpKeyId(pgp.fetchKeyId(account,msg, x.getContent()));
+ }
+ }
} else if (type.equals("unavailable")) {
if (name.equals(getNick())) {
Element item = packet.findChild("x","http://jabber.org/protocol/muc#user").findChild("item");