| 863 | } |
| 864 | |
| 865 | private static Long findUid(Context context, EntityAccount account, IMAPFolder ifolder, String msgid, Long from) throws MessagingException, IOException { |
| 866 | String name = ifolder.getFullName(); |
| 867 | Log.i(name + " searching for msgid=" + msgid); |
| 868 | |
| 869 | Long uid = null; |
| 870 | |
| 871 | Message[] imessages = findMsgId(context, account, ifolder, msgid, from); |
| 872 | if (imessages != null) |
| 873 | for (Message iexisting : imessages) |
| 874 | try { |
| 875 | long muid = ifolder.getUID(iexisting); |
| 876 | if (muid < 0) |
| 877 | continue; |
| 878 | Log.i(name + " found uid=" + muid + " for msgid=" + msgid); |
| 879 | // RFC3501: Unique identifiers are assigned in a strictly ascending fashion |
| 880 | if (uid == null || muid > uid) |
| 881 | uid = muid; |
| 882 | } catch (MessageRemovedException ex) { |
| 883 | Log.w(ex); |
| 884 | } |
| 885 | |
| 886 | Log.i(name + " got uid=" + uid + " for msgid=" + msgid); |
| 887 | return uid; |
| 888 | } |
| 889 | |
| 890 | private static Message[] findMsgId(Context context, EntityAccount account, IMAPFolder ifolder, String msgid, Long from) throws MessagingException, IOException { |
| 891 | // https://stackoverflow.com/questions/18891509/how-to-get-message-from-messageidterm-for-yahoo-imap-profile |