display pgp key id in muc details and use keys to encrypt groupchat

This commit is contained in:
Daniel Gultsch 2014-05-22 20:54:54 +02:00
parent b605577cd9
commit 655565eccc
3 changed files with 29 additions and 4 deletions

View file

@ -17,6 +17,7 @@ import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.ui.UiCallback;
@ -114,10 +115,15 @@ public class PgpEngine {
}
public void encrypt(final Message message,final UiCallback callback) {
long[] keys = { message.getConversation().getContact().getPgpKeyId() };
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_ENCRYPT);
params.putExtra(OpenPgpApi.EXTRA_KEY_IDS, keys);
if (message.getConversation().getMode() == Conversation.MODE_SINGLE) {
long[] keys = { message.getConversation().getContact().getPgpKeyId() };
params.putExtra(OpenPgpApi.EXTRA_KEY_IDS, keys);
} else {
params.putExtra(OpenPgpApi.EXTRA_KEY_IDS, message.getConversation().getMucOptions().getPgpKeyIds());
}
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, message.getConversation().getAccount().getJid());
if (message.getType() == Message.TYPE_TEXT) {

View file

@ -236,4 +236,18 @@ public class MucOptions {
public void flagAboutToRename() {
this.aboutToRename = true;
}
public long[] getPgpKeyIds() {
List<Long> ids = new ArrayList<Long>();
for(User user : getUsers()) {
if(user.getPgpKeyId()!=0) {
ids.add(user.getPgpKeyId());
}
}
long[] primitivLongArray = new long[ids.size()];
for(int i = 0; i < ids.size(); ++i) {
primitivLongArray[i] = ids.get(i);
}
return primitivLongArray;
}
}

View file

@ -3,6 +3,8 @@ package eu.siacs.conversations.ui;
import java.util.ArrayList;
import java.util.List;
import org.openintents.openpgp.util.OpenPgpUtils;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.MucOptions;
@ -176,12 +178,15 @@ public class MucDetailsActivity extends XmppActivity {
((TextView) view.findViewById(R.id.contact_display_name))
.setText(contact.getName());
TextView role = (TextView) view.findViewById(R.id.contact_jid);
role.setText(getReadableRole(contact.getRole()));
if (contact.getPgpKeyId()==0) {
role.setText(getReadableRole(contact.getRole()));
} else {
role.setText(getReadableRole(contact.getRole())+" \u00B7 "+OpenPgpUtils.convertKeyIdToHex(contact.getPgpKeyId()));
}
ImageView imageView = (ImageView) view
.findViewById(R.id.contact_photo);
imageView.setImageBitmap(UIHelper.getContactPicture(contact.getName(), 48,this.getApplicationContext(), false));
membersView.addView(view);
Log.d(LOGTAG,contact.getName()+" pgp id: "+contact.getPgpKeyId());
}
}
} else {