Carddav: disable contact picture handling on Exchange 2007

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1314 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-28 21:10:58 +00:00
parent 5ea415bf49
commit 04bf3294bc
1 changed files with 20 additions and 17 deletions

View File

@ -776,23 +776,26 @@ public class EwsExchangeSession extends ExchangeSession {
ItemId newItemId = new ItemId(createOrUpdateItemMethod.getResponseItem()); ItemId newItemId = new ItemId(createOrUpdateItemMethod.getResponseItem());
// first delete current picture // disable contact picture handling on Exchange 2007
if (currentFileAttachment != null) { if (!"Exchange2010".equals(serverVersion)) {
DeleteAttachmentMethod deleteAttachmentMethod = new DeleteAttachmentMethod(currentFileAttachment.attachmentId); // first delete current picture
executeMethod(deleteAttachmentMethod); if (currentFileAttachment != null) {
} DeleteAttachmentMethod deleteAttachmentMethod = new DeleteAttachmentMethod(currentFileAttachment.attachmentId);
executeMethod(deleteAttachmentMethod);
if (photo != null) { }
// convert image to jpeg
byte[] resizedImageBytes = IOUtil.resizeImage(Base64.decodeBase64(photo.getBytes()), 90); if (photo != null) {
// convert image to jpeg
FileAttachment attachment = new FileAttachment("ContactPicture.jpg", "image/jpeg", new String(Base64.encodeBase64(resizedImageBytes))); byte[] resizedImageBytes = IOUtil.resizeImage(Base64.decodeBase64(photo.getBytes()), 90);
if ("Exchange2010".equals(serverVersion)) {
attachment.setIsContactPhoto(true); FileAttachment attachment = new FileAttachment("ContactPicture.jpg", "image/jpeg", new String(Base64.encodeBase64(resizedImageBytes)));
if ("Exchange2010".equals(serverVersion)) {
attachment.setIsContactPhoto(true);
}
// update photo attachment
CreateAttachmentMethod createAttachmentMethod = new CreateAttachmentMethod(newItemId, attachment);
executeMethod(createAttachmentMethod);
} }
// update photo attachment
CreateAttachmentMethod createAttachmentMethod = new CreateAttachmentMethod(newItemId, attachment);
executeMethod(createAttachmentMethod);
} }
GetItemMethod getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, newItemId, false); GetItemMethod getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, newItemId, false);
@ -1122,7 +1125,7 @@ public class EwsExchangeSession extends ExchangeSession {
String subFolderPath; String subFolderPath;
if (slashIndex >= 0) { if (slashIndex >= 0) {
mailbox = folderPath.substring(USERS_ROOT.length(), slashIndex); mailbox = folderPath.substring(USERS_ROOT.length(), slashIndex);
subFolderPath = folderPath.substring(slashIndex+1); subFolderPath = folderPath.substring(slashIndex + 1);
} else { } else {
mailbox = folderPath.substring(USERS_ROOT.length()); mailbox = folderPath.substring(USERS_ROOT.length());
subFolderPath = ""; subFolderPath = "";