private static boolean userIdListContainsAddress(
     String senderAddress, ArrayList<String> confirmedUserIds) {
   for (String rawUserId : confirmedUserIds) {
     UserId userId = OpenPgpUtils.splitUserId(rawUserId);
     if (senderAddress.equals(userId.email)) {
       return true;
     }
   }
   return false;
 }
예제 #2
0
  @Test
  public void migratePgpInlineClearsignedMessage() throws Exception {
    SQLiteDatabase db = createV50Database();
    insertPgpInlineClearsignedMessage(db);
    db.close();

    LocalStore localStore = LocalStore.getInstance(account, RuntimeEnvironment.application);

    LocalMessage msg = localStore.getFolder("dev").getMessage("8");
    FetchProfile fp = new FetchProfile();
    fp.add(FetchProfile.Item.BODY);
    localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);

    Assert.assertEquals(7, msg.getId());
    Assert.assertEquals(12, msg.getHeaderNames().size());
    Assert.assertEquals("text/plain", msg.getMimeType());
    Assert.assertEquals(0, msg.getAttachmentCount());
    Assert.assertTrue(msg.getBody() instanceof BinaryMemoryBody);

    String msgTextContent = MessageExtractor.getTextFromPart(msg);
    Assert.assertEquals(
        OpenPgpUtils.PARSE_RESULT_SIGNED_MESSAGE, OpenPgpUtils.parseMessage(msgTextContent));
  }
  private void populateView() {
    mAccountJid.setText(getString(R.string.using_account, conversation.getAccount().getJid()));
    mYourPhoto.setImageBitmap(avatarService().get(conversation.getAccount(), getPixel(48)));
    setTitle(conversation.getName());
    mFullJid.setText(conversation.getContactJid().split("/", 2)[0]);
    mYourNick.setText(conversation.getMucOptions().getActualNick());
    mRoleAffiliaton = (TextView) findViewById(R.id.muc_role);
    if (conversation.getMucOptions().online()) {
      mMoreDetails.setVisibility(View.VISIBLE);
      User self = conversation.getMucOptions().getSelf();
      switch (self.getAffiliation()) {
        case User.AFFILIATION_ADMIN:
          mRoleAffiliaton.setText(
              getReadableRole(self.getRole()) + " (" + getString(R.string.admin) + ")");
          break;
        case User.AFFILIATION_OWNER:
          mRoleAffiliaton.setText(
              getReadableRole(self.getRole()) + " (" + getString(R.string.owner) + ")");
          break;
        default:
          mRoleAffiliaton.setText(getReadableRole(self.getRole()));
          break;
      }
    }
    this.users.clear();
    this.users.addAll(conversation.getMucOptions().getUsers());
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    membersView.removeAllViews();
    for (final User user : conversation.getMucOptions().getUsers()) {
      View view = inflater.inflate(R.layout.contact, membersView, false);
      TextView name = (TextView) view.findViewById(R.id.contact_display_name);
      TextView key = (TextView) view.findViewById(R.id.key);
      TextView role = (TextView) view.findViewById(R.id.contact_jid);
      if (user.getPgpKeyId() != 0) {
        key.setVisibility(View.VISIBLE);
        key.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                viewPgpKey(user);
              }
            });
        key.setText(OpenPgpUtils.convertKeyIdToHex(user.getPgpKeyId()));
      }
      Bitmap bm;
      Contact contact = user.getContact();
      if (contact != null) {
        bm = avatarService().get(contact, getPixel(48));
        name.setText(contact.getDisplayName());
        role.setText(user.getName() + " \u2022 " + getReadableRole(user.getRole()));
      } else {
        bm = avatarService().get(user.getName(), getPixel(48));
        name.setText(user.getName());
        role.setText(getReadableRole(user.getRole()));
      }
      ImageView iv = (ImageView) view.findViewById(R.id.contact_photo);
      iv.setImageBitmap(bm);
      membersView.addView(view);
    }
  }