1 package org.columba.mail.imap; 2 3 import java.io.IOException ; 4 import java.io.InputStream ; 5 import java.util.ArrayList ; 6 import java.util.List ; 7 import java.util.Observable ; 8 9 import org.columba.api.command.IStatusObservable; 10 import org.columba.core.command.CommandCancelledException; 11 import org.columba.core.filter.FilterRule; 12 import org.columba.core.filter.IFilterRule; 13 import org.columba.core.xml.XmlElement; 14 import org.columba.mail.config.ImapItem; 15 import org.columba.mail.folder.headercache.MemoryHeaderList; 16 import org.columba.mail.folder.imap.IMAPFolder; 17 import org.columba.mail.message.IColumbaHeader; 18 import org.columba.mail.message.IHeaderList; 19 import org.columba.ristretto.imap.IMAPException; 20 import org.columba.ristretto.imap.IMAPFlags; 21 import org.columba.ristretto.imap.ListInfo; 22 import org.columba.ristretto.imap.MailboxStatus; 23 import org.columba.ristretto.imap.NamespaceCollection; 24 import org.columba.ristretto.imap.SearchKey; 25 import org.columba.ristretto.imap.SequenceSet; 26 import org.columba.ristretto.message.Header; 27 import org.columba.ristretto.message.MailboxInfo; 28 import org.columba.ristretto.message.MimeTree; 29 30 public class TestServer implements IImapServer { 31 32 33 34 private MailboxStatus status; 35 private IHeaderList headerList; 36 private ArrayList <IColumbaHeader> indices; 37 38 39 public TestServer(MailboxStatus status) { 40 super(); 41 this.status = status; 42 indices = new ArrayList <IColumbaHeader>(); 43 headerList = new MemoryHeaderList(); 44 } 45 46 public void addHeader(IColumbaHeader h, Object uid) { 47 headerList.add(h, uid); 48 indices.add(h); 49 } 50 51 public IColumbaHeader removeHeader(int index) { 52 IColumbaHeader h = indices.remove(index-1); 53 headerList.remove(h.get("columba.uid")); 54 55 return h; 56 } 57 58 public String getDelimiter() throws IOException , IMAPException, 59 CommandCancelledException { 60 return null; 62 } 63 64 public void logout() throws Exception { 65 67 } 68 69 public List checkSupportedAuthenticationMethods() throws IOException { 70 return null; 72 } 73 74 public boolean isSupported(String command) throws IOException { 75 return false; 77 } 78 79 public void setFirstLoginAction(IFirstLoginAction action) { 80 82 } 83 84 public void ensureSelectedState(IMAPFolder folder) throws IOException , 85 IMAPException, CommandCancelledException { 86 88 } 89 90 public MailboxStatus getStatus(IMAPFolder folder) throws IOException , 91 IMAPException, CommandCancelledException { 92 return status; 93 } 94 95 public ListInfo[] list(String reference, String pattern) throws Exception { 96 return null; 98 } 99 100 public Integer append(InputStream messageSource, IMAPFlags flags, 101 IMAPFolder folder) throws Exception { 102 return null; 104 } 105 106 public Integer append(InputStream messageSource, IMAPFolder folder) 107 throws Exception { 108 return null; 110 } 111 112 public void createMailbox(String mailboxName, IMAPFolder folder) 113 throws IOException , IMAPException, CommandCancelledException { 114 116 } 117 118 public void deleteFolder(String path) throws Exception { 119 121 } 122 123 public void renameFolder(String oldMailboxName, String newMailboxName) 124 throws IOException , IMAPException, CommandCancelledException { 125 127 } 128 129 public void subscribeFolder(String mailboxName) throws IOException , 130 IMAPException, CommandCancelledException { 131 133 } 134 135 public void unsubscribeFolder(String mailboxName) throws IOException , 136 IMAPException, CommandCancelledException { 137 139 } 140 141 public void expunge(IMAPFolder folder) throws IOException , IMAPException, 142 CommandCancelledException { 143 145 } 146 147 public Integer [] copy(IMAPFolder destFolder, Object [] uids, 148 IMAPFolder folder) throws Exception { 149 return null; 151 } 152 153 public int fetchUid(SequenceSet set, IMAPFolder folder) throws IOException , 154 IMAPException, CommandCancelledException { 155 156 return (Integer )indices.get(indices.size()-1).get("columba.uid"); 158 } 159 160 public Integer [] fetchUids(SequenceSet set, IMAPFolder folder) 161 throws IOException , IMAPException, CommandCancelledException { 162 163 164 int[] idx = set.toArray(indices.size()); 165 Integer [] result = new Integer [idx.length]; 166 167 int pos = 0; 168 for( int i: idx) { 169 result[pos++] = (Integer )indices.get(i-1).get("columba.uid"); 170 } 171 172 return result; 173 } 174 175 public IMAPFlags[] fetchFlagsListStartFrom(int startIdx, IMAPFolder folder) 176 throws IOException , IMAPException, CommandCancelledException { 177 return null; 179 } 180 181 public IMAPFlags[] fetchFlagsListStartFrom2(int startIdx, IMAPFolder folder) 182 throws IOException , IMAPException, CommandCancelledException { 183 184 int size = indices.size() - startIdx + 1; 185 IMAPFlags[] result = new IMAPFlags[size]; 186 187 for(int i=0;i<size;i++) { 188 IColumbaHeader h = indices.get(startIdx-1+i); 189 IMAPFlags flags = new IMAPFlags(h.getFlags().getFlags()); 190 flags.setUid(h.get("columba.uid")); 191 192 result[i] = flags; 193 } 194 195 return result; 196 } 197 198 public NamespaceCollection fetchNamespaces() throws IOException , 199 IMAPException, CommandCancelledException { 200 return null; 202 } 203 204 public void fetchHeaderList(IHeaderList resultList, List list, 205 IMAPFolder folder) throws Exception { 206 207 for(Object uid: list) { 208 resultList.add(headerList.get(uid), uid); 209 } 210 } 211 212 public MimeTree getMimeTree(Object uid, IMAPFolder folder) 213 throws IOException , IMAPException, CommandCancelledException { 214 return null; 216 } 217 218 public InputStream getMimePartBodyStream(Object uid, Integer [] address, 219 IMAPFolder folder) throws IOException , IMAPException, 220 CommandCancelledException { 221 return null; 223 } 224 225 public Header getHeaders(Object uid, String [] keys, IMAPFolder folder) 226 throws IOException , IMAPException, CommandCancelledException { 227 return null; 229 } 230 231 public Header getAllHeaders(Object uid, IMAPFolder folder) 232 throws IOException , IMAPException, CommandCancelledException { 233 return null; 235 } 236 237 public InputStream getMimePartSourceStream(Object uid, Integer [] address, 238 IMAPFolder folder) throws IOException , IMAPException, 239 CommandCancelledException { 240 return null; 242 } 243 244 public InputStream getMessageSourceStream(Object uid, IMAPFolder folder) 245 throws IOException , IMAPException, CommandCancelledException { 246 return null; 248 } 249 250 public void markMessage(Object [] uids, int variant, IMAPFolder folder) 251 throws IOException , IMAPException, CommandCancelledException { 252 254 } 255 256 public void setFlags(Object [] uids, IMAPFlags flags, IMAPFolder folder) 257 throws IOException , IMAPException, CommandCancelledException { 258 260 } 261 262 public List search(Object [] uids, IFilterRule filterRule, IMAPFolder folder) 263 throws Exception { 264 return null; 266 } 267 268 public int getIndex(Integer uid, IMAPFolder folder) throws IOException , 269 IMAPException, CommandCancelledException { 270 int pos = 0; 271 for( IColumbaHeader h: indices) { 272 if(h.get("columba.uid").equals(uid)) { 273 return pos+1; 274 } 275 pos ++; 276 } 277 278 return -1; 279 } 280 281 public Integer [] search(SearchKey key, IMAPFolder folder) 282 throws IOException , IMAPException, CommandCancelledException { 283 return new Integer [0]; 284 } 285 286 public List search(IFilterRule filterRule, IMAPFolder folder) 287 throws IOException , IMAPException, CommandCancelledException { 288 289 return new ArrayList (); 290 } 291 292 public MailboxInfo getMessageFolderInfo(IMAPFolder folder) 293 throws IOException , IMAPException, CommandCancelledException { 294 return null; 296 } 297 298 public ListInfo[] fetchSubscribedFolders() throws IOException , 299 IMAPException, CommandCancelledException { 300 return null; 302 } 303 304 public boolean isSelected(IMAPFolder folder) throws IOException , 305 IMAPException, CommandCancelledException { 306 return false; 308 } 309 310 public void alertMessage(String arg0) { 311 313 } 314 315 public void connectionClosed(String arg0, String arg1) { 316 318 } 319 320 public void existsChanged(String arg0, int arg1) { 321 323 } 324 325 public void flagsChanged(String arg0, IMAPFlags arg1) { 326 328 } 329 330 public void parseError(String arg0) { 331 333 } 334 335 public void recentChanged(String arg0, int arg1) { 336 338 } 339 340 public void warningMessage(String arg0) { 341 343 } 344 345 public ImapItem getItem() { 346 return new ImapItem(new XmlElement()); 347 } 348 349 public void update(Observable o, Object arg) { 350 352 } 353 354 public void setExistsChangedAction(IExistsChangedAction existsChangedAction) { 355 357 } 358 359 public void setUpdateFlagAction(IUpdateFlagAction updateFlagAction) { 360 362 } 363 364 public void setObservable(IStatusObservable observable) { 365 367 } 368 369 public void setStatus(MailboxStatus status) { 370 this.status = status; 371 } 372 373 public IHeaderList getHeaderList() { 374 return headerList; 375 } 376 377 public int getLargestRemoteUid(IMAPFolder folder) throws IOException , IMAPException, CommandCancelledException { 378 return 0; 380 } 381 382 } 383 | Popular Tags |