Example #1
0
 public void addPendingCommand(PendingCommand command) throws MessagingException {
   for (int i = 0; i < command.arguments.length; i++) {
     command.arguments[i] = UrlEncodingHelper.encodeUtf8(command.arguments[i]);
   }
   final ContentValues cv = new ContentValues();
   cv.put("command", command.command);
   cv.put("arguments", Utility.combine(command.arguments, ','));
   database.execute(
       false,
       new DbCallback<Void>() {
         @Override
         public Void doDbWork(final SQLiteDatabase db) throws WrappedException {
           db.insert("pending_commands", "command", cv);
           return null;
         }
       });
 }
Example #2
0
  static String serializeFlags(Iterable<Flag> flags) {
    List<Flag> extraFlags = new ArrayList<>();

    for (Flag flag : flags) {
      switch (flag) {
        case DELETED:
        case SEEN:
        case FLAGGED:
        case ANSWERED:
        case FORWARDED:
          {
            break;
          }
        default:
          {
            extraFlags.add(flag);
          }
      }
    }

    return Utility.combine(extraFlags, ',').toUpperCase(Locale.US);
  }
Example #3
0
  public void writeTo(OutputStream out) throws IOException {
    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024);
    for (Field field : mFields) {
      if (!Utility.arrayContains(writeOmitFields, field.name)) {
        String v = field.value;

        if (hasToBeEncoded(v)) {
          Charset charset = null;

          if (mCharset != null) {
            charset = Charset.forName(mCharset);
          }
          v = EncoderUtil.encodeEncodedWord(field.value, charset);
        }

        writer.write(field.name);
        writer.write(": ");
        writer.write(v);
        writer.write("\r\n");
      }
    }
    writer.flush();
  }