(
Context context,
EntityAccount account, EntityFolder folder, List<TupleOperationEx> ops,
EmailService iservice, Folder ifolder,
State state, long serial)
| 161 | } |
| 162 | |
| 163 | static void processOperations( |
| 164 | Context context, |
| 165 | EntityAccount account, EntityFolder folder, List<TupleOperationEx> ops, |
| 166 | EmailService iservice, Folder ifolder, |
| 167 | State state, long serial) |
| 168 | throws JSONException, FolderClosedException { |
| 169 | try { |
| 170 | Log.i(folder.name + " start process"); |
| 171 | |
| 172 | Store istore = iservice.getStore(); |
| 173 | DB db = DB.getInstance(context); |
| 174 | |
| 175 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
| 176 | int chunk_size = prefs.getInt("chunk_size", DEFAULT_CHUNK_SIZE); |
| 177 | |
| 178 | NotificationManager nm = Helper.getSystemService(context, NotificationManager.class); |
| 179 | |
| 180 | int retry = 0; |
| 181 | boolean group = true; |
| 182 | Log.i(folder.name + " executing serial=" + serial + " operations=" + ops.size()); |
| 183 | while (retry < LOCAL_RETRY_MAX && ops.size() > 0 && |
| 184 | state.isRunning() && |
| 185 | state.getSerial() == serial) { |
| 186 | TupleOperationEx op = ops.get(0); |
| 187 | |
| 188 | try { |
| 189 | Log.i(folder.name + |
| 190 | " start op=" + op.id + "/" + op.name + |
| 191 | " folder=" + op.folder + |
| 192 | " msg=" + op.message + |
| 193 | " args=" + op.args + |
| 194 | " group=" + group + |
| 195 | " retry=" + retry); |
| 196 | |
| 197 | if (EntityOperation.HEADERS.equals(op.name) || |
| 198 | EntityOperation.RAW.equals(op.name)) |
| 199 | nm.cancel(op.name + ":" + op.message, NotificationHelper.NOTIFICATION_TAGGED); |
| 200 | |
| 201 | if (!Objects.equals(folder.id, op.folder)) |
| 202 | throw new IllegalArgumentException("Invalid folder=" + folder.id + "/" + op.folder); |
| 203 | |
| 204 | if (account.protocol == EntityAccount.TYPE_IMAP && !folder.local && ifolder != null) { |
| 205 | try { |
| 206 | ((IMAPFolder) ifolder).doCommand(new IMAPFolder.ProtocolCommand() { |
| 207 | @Override |
| 208 | public Object doCommand(IMAPProtocol protocol) throws ProtocolException { |
| 209 | long ago = System.currentTimeMillis() - protocol.getTimestamp(); |
| 210 | if (ago > 20000) { |
| 211 | Log.i("NOOP ago=" + ago + " ms"); |
| 212 | protocol.noop(); |
| 213 | } |
| 214 | return null; |
| 215 | } |
| 216 | }); |
| 217 | } catch (MessagingException ex) { |
| 218 | throw new FolderClosedException(ifolder, account.name + "/" + folder.name + " unexpectedly closed", ex); |
| 219 | } |
| 220 | } |
no test coverage detected