| 2521 | } |
| 2522 | |
| 2523 | private static void onReport(Context context, JSONArray jargs, EntityFolder folder, IMAPStore istore, IMAPFolder ifolder, State state) throws JSONException, MessagingException { |
| 2524 | String msgid = jargs.getString(0); |
| 2525 | String keyword = jargs.getString(1); |
| 2526 | |
| 2527 | if (TextUtils.isEmpty(msgid)) |
| 2528 | throw new IllegalArgumentException("msgid missing"); |
| 2529 | |
| 2530 | if (TextUtils.isEmpty(keyword)) |
| 2531 | throw new IllegalArgumentException("keyword missing"); |
| 2532 | |
| 2533 | if (folder.read_only) { |
| 2534 | Log.w(folder.name + " read-only"); |
| 2535 | return; |
| 2536 | } |
| 2537 | |
| 2538 | if (!ifolder.getPermanentFlags().contains(Flags.Flag.USER)) { |
| 2539 | Log.w(folder.name + " has no keywords"); |
| 2540 | return; |
| 2541 | } |
| 2542 | |
| 2543 | Message[] imessages = ifolder.search(new MessageIDTerm(msgid)); |
| 2544 | if (imessages == null || imessages.length == 0) { |
| 2545 | Log.w(folder.name + " " + msgid + " not found"); |
| 2546 | return; |
| 2547 | } |
| 2548 | |
| 2549 | for (Message imessage : imessages) { |
| 2550 | long uid = ifolder.getUID(imessage); |
| 2551 | Log.i("Report uid=" + uid + " keyword=" + keyword); |
| 2552 | |
| 2553 | Flags flags = new Flags(keyword); |
| 2554 | imessage.setFlags(flags, true); |
| 2555 | |
| 2556 | if (BuildConfig.DEBUG) |
| 2557 | try { |
| 2558 | JSONArray fargs = new JSONArray(); |
| 2559 | fargs.put(uid); |
| 2560 | onFetch(context, fargs, folder, istore, ifolder, state); |
| 2561 | } catch (Throwable ex) { |
| 2562 | Log.w(ex); |
| 2563 | } |
| 2564 | } |
| 2565 | } |
| 2566 | |
| 2567 | static void onSynchronizeFolders( |
| 2568 | Context context, EntityAccount account, Store istore, State state, |