use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class TestImap method testAppend.
@Test
public void testAppend() throws Exception {
assertTrue(connection.hasCapability("UIDPLUS"));
Flags flags = Flags.fromSpec("afs");
Date date = new Date(System.currentTimeMillis());
Literal msg = message(100000);
try {
AppendResult res = connection.append("INBOX", flags, date, msg);
assertNotNull(res);
byte[] b = fetchBody(res.getUid());
assertArrayEquals("content mismatch", msg.getBytes(), b);
} finally {
msg.dispose();
}
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class ImapFolderSync method updateImapTrashFolderId.
private void updateImapTrashFolderId(ListData ld) throws ServiceException {
Flags flags = ld.getFlags();
if (flags.isSet("\\Trash") && ds.getImapTrashFolderId() != localFolder.getId()) {
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_zimbraDataSourceImapTrashFolderId, localFolder.getId());
ds.getProvisioning().modifyDataSource(ds.getAccount(), ds.getId(), attrs);
}
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class ImapSync method getLocalPath.
/*
* Returns the path to the Zimbra folder that stores messages for the given
* IMAP folder. The Zimbra folder has the same path as the IMAP folder,
* but is relative to the root folder specified by the DataSource.
*/
String getLocalPath(ListData ld) throws ServiceException {
String remotePath = ld.getMailbox();
char localDelimiter = ld.getDelimiter();
String relativePath = ld.getMailbox();
Flags flags = ld.getFlags();
if (localDelimiter != '/' && (remotePath.indexOf(localDelimiter) >= 0 || remotePath.indexOf('/') >= 0)) {
// Change remote path to use our separator
String[] parts = remotePath.split("\\" + localDelimiter);
for (int i = 0; i < parts.length; i++) {
// TODO Handle case where separator is not valid in Zimbra folder name
parts[i] = parts[i].replace('/', localDelimiter);
}
relativePath = StringUtil.join("/", parts);
}
relativePath = ILLEGAL_FOLDER_CHARS.matcher(relativePath).replaceAll("_");
if (dataSource.ignoreRemotePath(relativePath, flags)) {
// Do not synchronize folder
return null;
}
String localPath = joinPath(localRootFolder.getPath(), coalesce(dataSource.mapRemoteToLocalPath(relativePath, flags), relativePath));
if (isUniqueLocalPathNeeded(localPath)) {
int count = 1;
for (; ; ) {
String path = String.format("%s-%d", localPath, count++);
if (LocalFolder.fromPath(mbox, path) == null) {
return path;
}
}
} else {
return localPath;
}
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class RemoteFolder method getFlags.
/*
* Fetch message flags for specific UID sequence. Exclude messages which
* have been flagged \Deleted.
*/
public List<MessageData> getFlags(long startUid, long endUid) throws IOException {
final List<MessageData> mds = new ArrayList<MessageData>();
String end = endUid > 0 ? String.valueOf(endUid) : "*";
connection.uidFetch(startUid + ":" + end, "FLAGS", new FetchResponseHandler() {
public void handleFetchResponse(MessageData md) {
Flags flags = md.getFlags();
if (flags != null && !flags.isDeleted()) {
mds.add(md);
}
}
});
// result.
if (endUid <= 0 && mds.size() == 1 && mds.get(0).getUid() < startUid) {
return Collections.emptyList();
}
return mds;
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class SharedImapNotificationTests method testRenameTagNotificationActiveFolder.
@Test
public void testRenameTagNotificationActiveFolder() throws Exception {
String folderName = "TestRemoteImapNotifications-folder";
String tagName = "TestRemoteImapNotifications-tag";
String newTagName = "TestRemoteImapNotifications-tag2";
String subject = "TestRemoteImapNotifications-testMessage";
ZMailbox zmbox = TestUtil.getZMailbox(USER);
ZFolder folder = TestUtil.createFolder(zmbox, folderName);
ZTag tag = zmbox.createTag(tagName, Color.blue);
zmbox.addMessage(folder.getId(), null, tag.getId(), 0, TestUtil.getTestMessage(subject), true);
connection = connect();
connection.login(PASS);
MailboxInfo info = connection.select(folderName);
Flags flags = info.getPermanentFlags();
assertTrue(flags.contains(new Atom(tagName)));
MailboxOperation renameTag = new MailboxOperation() {
@Override
protected void run(ZMailbox zmbox) throws Exception {
zmbox.renameTag(tag.getId(), newTagName);
}
@Override
protected String checkResult() throws Exception {
MailboxInfo info = connection.select(folderName);
Flags flags = info.getPermanentFlags();
if (flags.contains(new Atom(tagName))) {
return String.format("Permanent flags should not contain %s", tagName);
}
if (!flags.contains(new Atom(newTagName))) {
return String.format("Permanent flags should contain %s", newTagName);
}
return null;
}
};
runOp(renameTag, zmbox, folder);
}
Aggregations