Adds modification of Outlook display for home/work postal address. Corrects Outlook funcitons to get/set/delete email addresses: add the management of EX address type.

cusax-fix 4740
Vincent Lucas 12 years ago
parent cf71357a32
commit dd08179d07

@ -1092,13 +1092,13 @@ int MsOutlookAddrBookContactQuery_IMAPIProp_1DeleteProp
ULONG baseGroupEntryIdProp = 0;
switch(propId)
{
case 0x00008083: // dispidEmail1EmailAddress
case 0x00008084: // PidLidEmail1OriginalDisplayName
baseGroupEntryIdProp = 0x00008080;
break;
case 0x00008093: // dispidEmail2EmailAddress
case 0x00008094: // PidLidEmail2OriginalDisplayName
baseGroupEntryIdProp = 0x00008090;
break;
case 0x000080A3: // dispidEmail3EmailAddress
case 0x000080A4: // PidLidEmail3OriginalDisplayName
baseGroupEntryIdProp = 0x000080A0;
break;
}
@ -1382,13 +1382,13 @@ int MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString
ULONG baseGroupEntryIdProp = 0;
switch(propId)
{
case 0x00008083: // dispidEmail1EmailAddress
case 0x00008084: // PidLidEmail1OriginalDisplayName
baseGroupEntryIdProp = 0x00008080;
break;
case 0x00008093: // dispidEmail2EmailAddress
case 0x00008094: // PidLidEmail2OriginalDisplayName
baseGroupEntryIdProp = 0x00008090;
break;
case 0x000080A3: // dispidEmail3EmailAddress
case 0x000080A4: // PidLidEmail3OriginalDisplayName
baseGroupEntryIdProp = 0x000080A0;
break;
}
@ -1435,25 +1435,42 @@ int MsOutlookAddrBookContactQuery_IMAPIProp_1SetPropString
LONG providerEmailList[1];
switch(propId)
{
case 0x00008083: // dispidEmail1EmailAddress
case 0x00008084: // PidLidEmail1OriginalDisplayName
providerEmailList[0] = 0x00000000;
propArray[1].Value.l |= 0x00000001;
break;
case 0x00008093: // dispidEmail2EmailAddress
case 0x00008094: // PidLidEmail2OriginalDisplayName
providerEmailList[0] = 0x00000001;
propArray[1].Value.l |= 0x00000002;
break;
case 0x000080A3: // dispidEmail3EmailAddress
case 0x000080A4: // PidLidEmail3OriginalDisplayName
providerEmailList[0] = 0x00000002;
propArray[1].Value.l |= 0x00000004;
break;
}
propArray[0].Value.MVl.cValues = 1;
propArray[0].Value.MVl.lpl = providerEmailList;
propArray[2].Value.lpszW = wCharValue;
propArray[3].Value.lpszW = addressType;
propArray[4].Value.lpszW = wCharValue;
if(propArray[2].ulPropTag == PT_ERROR
|| propArray[2].Value.err == MAPI_E_NOT_FOUND
|| propArray[2].Value.lpszW == NULL)
{
propArray[2].Value.lpszW = wCharValue;
}
if(propArray[3].ulPropTag == PT_ERROR
|| propArray[3].Value.err == MAPI_E_NOT_FOUND
|| propArray[3].Value.lpszW == NULL)
{
propArray[3].Value.lpszW = addressType;
}
if(propArray[4].ulPropTag == PT_ERROR
|| propArray[4].Value.err == MAPI_E_NOT_FOUND
|| propArray[4].Value.lpszW == NULL
|| wcsncmp(propArray[3].Value.lpszW, addressType, 4) == 0)
{
propArray[4].Value.lpszW = wCharValue;
}
propArray[5].Value.lpszW = wCharValue;
if(MsOutlookAddrBookContactQuery_createEmailAddress(
@ -1885,6 +1902,7 @@ int MsOutlookAddrBookContactQuery_compareEntryIds(
}
result = res;
}
mapiId1->Release();
MAPIFreeBuffer(contactId1.lpb);
mapiId2->Release();

@ -91,17 +91,4 @@ public Vector<Long> getOutlookPropId()
{
return this.outlookPropId;
}
/**
* Sets the given detail value.
*
* @param value the new value of the detail
*/
@Override
public void setDetail(String value)
{
super.setDetail(value);
EditableSourceContact sourceContact = this.getSourceContact();
}
}

@ -30,11 +30,11 @@ public class MsOutlookAddrBookContactQuery
private static final Logger logger
= Logger.getLogger(MsOutlookAddrBookContactQuery.class);
private static final int dispidEmail1EmailAddress = 12;
public static final int dispidEmail1EmailAddress = 12;
private static final int dispidEmail2EmailAddress = 13;
public static final int dispidEmail2EmailAddress = 13;
private static final int dispidEmail3EmailAddress = 14;
public static final int dispidEmail3EmailAddress = 14;
/**
* The object type of a <tt>SourceContact</tt> in the Address Book of
@ -61,9 +61,9 @@ public class MsOutlookAddrBookContactQuery
0x3A1C /* PR_MOBILE_TELEPHONE_NUMBER */,
0x3A1F /* PR_OTHER_TELEPHONE_NUMBER */,
0x0FFE /* PR_OBJECT_TYPE */,
0x00008083 /* dispidEmail1EmailAddress */,
0x00008093 /* dispidEmail2EmailAddress */,
0x000080A3 /* dispidEmail3EmailAddress */,
0x00008084 /* dispidEmail1OriginalDisplayName */,
0x00008094 /* dispidEmail2OriginalDisplayName */,
0x000080A4 /* dispidEmail3OriginalDisplayName */,
0x3A16 /* PR_COMPANY_NAME */,
0x0FFF /* PR_ORIGINAL_ENTRYID */,
0x3A24 /* dispidFax1EmailAddress */,
@ -84,7 +84,9 @@ public class MsOutlookAddrBookContactQuery
0x3A5A, // PR_HOME_ADDRESS_COUNTRY
0x3A5B, // PR_HOME_ADDRESS_POSTAL_CODE
0x3A5C, // PR_HOME_ADDRESS_STATE_OR_PROVINCE
0x3A5D // PR_HOME_ADDRESS_STREET
0x3A5D, // PR_HOME_ADDRESS_STREET
0x0000801A, // dispidHomeAddress
0x0000801B // dispidWorkAddress
};
/**
@ -102,189 +104,199 @@ public class MsOutlookAddrBookContactQuery
/**
* The id of the <tt>PR_ATTACHMENT_CONTACTPHOTO</tt> MAPI property.
*/
private static final long PR_ATTACHMENT_CONTACTPHOTO = 0x7FFF;
public static final long PR_ATTACHMENT_CONTACTPHOTO = 0x7FFF;
/**
* The index of the id of the <tt>PR_BUSINESS_TELEPHONE_NUMBER</tt> property
* in {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_BUSINESS_TELEPHONE_NUMBER = 5;
public static final int PR_BUSINESS_TELEPHONE_NUMBER = 5;
/**
* The index of the id of the <tt>PR_BUSINESS2_TELEPHONE_NUMBER</tt>
* property in {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_BUSINESS2_TELEPHONE_NUMBER = 6;
public static final int PR_BUSINESS2_TELEPHONE_NUMBER = 6;
private static final int PR_COMPANY_NAME = 15;
public static final int PR_COMPANY_NAME = 15;
/**
* The index of the id of the <tt>PR_DISPLAY_NAME</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_DISPLAY_NAME = 0;
public static final int PR_DISPLAY_NAME = 0;
/**
* The index of the id of the <tt>PR_EMAIL_ADDRESS</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_EMAIL_ADDRESS = 1;
public static final int PR_EMAIL_ADDRESS = 1;
/**
* The index of the id of the <tt>PR_GIVEN_NAME</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_GIVEN_NAME = 2;
public static final int PR_GIVEN_NAME = 2;
/**
* The index of the id of the <tt>PR_HOME_TELEPHONE_NUMBER</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_HOME_TELEPHONE_NUMBER = 7;
public static final int PR_HOME_TELEPHONE_NUMBER = 7;
/**
* The index of the id of the <tt>PR_HOME2_TELEPHONE_NUMBER</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_HOME2_TELEPHONE_NUMBER = 8;
public static final int PR_HOME2_TELEPHONE_NUMBER = 8;
/**
* The index of the id of the <tt>PR_MIDDLE_NAME</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_MIDDLE_NAME = 3;
public static final int PR_MIDDLE_NAME = 3;
/**
* The index of the id of the <tt>PR_MOBILE_TELEPHONE_NUMBER</tt> property
* in {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_MOBILE_TELEPHONE_NUMBER = 9;
public static final int PR_MOBILE_TELEPHONE_NUMBER = 9;
/**
* The index of the id of the <tt>PR_OTHER_TELEPHONE_NUMBER</tt> property
* in {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_OTHER_TELEPHONE_NUMBER = 10;
public static final int PR_OTHER_TELEPHONE_NUMBER = 10;
/**
* The index of the id of the <tt>PR_OBJECT_TYPE</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_OBJECT_TYPE = 11;
public static final int PR_OBJECT_TYPE = 11;
/**
* The index of the id of the <tt>PR_SURNAME</tt> property in
* {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_SURNAME = 4;
public static final int PR_SURNAME = 4;
/**
* The index of the id of the <tt>PR_ORIGINAL_ENTRYID</tt> property
* in {@link #MAPI_MAILUSER_PROP_IDS}.
*/
private static final int PR_ORIGINAL_ENTRYID = 16;
public static final int PR_ORIGINAL_ENTRYID = 16;
/**
* The index of the 1st fax telephone number (business fax).
*/
private static final int dispidFax1EmailAddress = 17;
public static final int dispidFax1EmailAddress = 17;
/**
* The index of the 2nd fax telephone number (home fax).
*/
private static final int dispidFax2EmailAddress = 18;
public static final int dispidFax2EmailAddress = 18;
/**
* The index of the 3rd fax telephone number (other fax).
*/
private static final int dispidFax3EmailAddress = 19;
public static final int dispidFax3EmailAddress = 19;
/**
* The index of the nickname.
*/
private static final int PR_NICKNAME = 20;
public static final int PR_NICKNAME = 20;
/**
* The index of the name prefix.
*/
private static final int PR_DISPLAY_NAME_PREFIX = 21;
public static final int PR_DISPLAY_NAME_PREFIX = 21;
/**
* The index of the personnal home page
*/
private static final int PR_PERSONAL_HOME_PAGE = 22;
public static final int PR_PERSONAL_HOME_PAGE = 22;
/**
* The index of the business home page
*/
private static final int PR_BUSINESS_HOME_PAGE = 23;
public static final int PR_BUSINESS_HOME_PAGE = 23;
/**
* The index of the job title.
*/
private static final int PR_TITLE = 24;
public static final int PR_TITLE = 24;
/**
* The index of the instant messaging address.
*/
private static final int dispidInstMsg = 25;
public static final int dispidInstMsg = 25;
/**
* The index of the business city of the postal address.
*/
private static final int PR_BUSINESS_ADDRESS_CITY = 26;
public static final int PR_BUSINESS_ADDRESS_CITY = 26;
/**
* The index of the business country of the postal address.
*/
private static final int PR_BUSINESS_ADDRESS_COUNTRY = 27;
public static final int PR_BUSINESS_ADDRESS_COUNTRY = 27;
/**
* The index of the business postal code of the postal address.
*/
private static final int PR_BUSINESS_ADDRESS_POSTAL_CODE = 28;
public static final int PR_BUSINESS_ADDRESS_POSTAL_CODE = 28;
/**
* The index of the business state or province of the postal address.
*/
private static final int PR_BUSINESS_ADDRESS_STATE_OR_PROVINCE = 29;
public static final int PR_BUSINESS_ADDRESS_STATE_OR_PROVINCE = 29;
/**
* The index of the business street of the postal address.
*/
private static final int PR_BUSINESS_ADDRESS_STREET = 30;
public static final int PR_BUSINESS_ADDRESS_STREET = 30;
/**
* The index of the home city of the postal address.
*/
private static final int PR_HOME_ADDRESS_CITY = 31;
public static final int PR_HOME_ADDRESS_CITY = 31;
/**
* The index of the home country of the postal address.
*/
private static final int PR_HOME_ADDRESS_COUNTRY = 32;
public static final int PR_HOME_ADDRESS_COUNTRY = 32;
/**
* The index of the home postal code of the postal address.
*/
private static final int PR_HOME_ADDRESS_POSTAL_CODE = 33;
public static final int PR_HOME_ADDRESS_POSTAL_CODE = 33;
/**
* The index of the home state or province of the postal address.
*/
private static final int PR_HOME_ADDRESS_STATE_OR_PROVINCE = 34;
public static final int PR_HOME_ADDRESS_STATE_OR_PROVINCE = 34;
/**
* The index of the home street of the postal address.
*/
private static final int PR_HOME_ADDRESS_STREET = 35;
public static final int PR_HOME_ADDRESS_STREET = 35;
/**
* The index of the display for the home postal address.
*/
public static final int dispidHomeAddress = 36;
/**
* The index of the display for the work postal address.
*/
public static final int dispidWorkAddress = 37;
/**
* The indexes in {@link #MAPI_MAILUSER_PROP_IDS} of the property IDs which
* are to be represented in <tt>SourceContact</tt> as
* <tt>ContactDetail</tt>s.
*/
private static final int[] CONTACT_DETAIL_PROP_INDEXES
public static final int[] CONTACT_DETAIL_PROP_INDEXES
= new int[]
{
PR_EMAIL_ADDRESS,
@ -319,7 +331,9 @@ public class MsOutlookAddrBookContactQuery
PR_HOME_ADDRESS_COUNTRY,
PR_HOME_ADDRESS_POSTAL_CODE,
PR_HOME_ADDRESS_STATE_OR_PROVINCE,
PR_HOME_ADDRESS_STREET
PR_HOME_ADDRESS_STREET,
dispidHomeAddress,
dispidWorkAddress
};
/**
@ -398,7 +412,7 @@ public static native void foreachMailUser(
String query,
PtrOutlookContactCallback callback);
private static ContactDetail.Category getCategory(int propIndex)
public static ContactDetail.Category getCategory(int propIndex)
{
switch (propIndex)
{
@ -440,6 +454,8 @@ private static ContactDetail.Category getCategory(int propIndex)
case PR_HOME_ADDRESS_POSTAL_CODE:
case PR_HOME_ADDRESS_STATE_OR_PROVINCE:
case PR_HOME_ADDRESS_STREET:
case dispidHomeAddress:
case dispidWorkAddress:
return ContactDetail.Category.Address;
default:
return null;
@ -455,7 +471,7 @@ private static ContactDetail.Category getCategory(int propIndex)
* @return the set of <tt>ContactDetail</tt> labels to be assigned to the
* property specified by its index in <tt>MAPI_MAILUSER_PROP_IDS</tt>
*/
private static ContactDetail.SubCategory[] getSubCategories(int propIndex)
public static ContactDetail.SubCategory[] getSubCategories(int propIndex)
{
switch (propIndex)
{
@ -596,6 +612,18 @@ private static ContactDetail.SubCategory[] getSubCategories(int propIndex)
ContactDetail.SubCategory.Home,
ContactDetail.SubCategory.Street
};
case dispidHomeAddress:
return
new ContactDetail.SubCategory[]
{
ContactDetail.SubCategory.Home,
};
case dispidWorkAddress:
return
new ContactDetail.SubCategory[]
{
ContactDetail.SubCategory.Work,
};
default:
return null;
}
@ -691,6 +719,10 @@ else if(subCategories.contains(
{
return MAPI_MAILUSER_PROP_IDS[PR_BUSINESS_ADDRESS_STREET];
}
else
{
return MAPI_MAILUSER_PROP_IDS[dispidWorkAddress];
}
}
else if(subCategories.contains(ContactDetail.SubCategory.Home))
{
@ -718,6 +750,10 @@ else if(subCategories.contains(
{
return MAPI_MAILUSER_PROP_IDS[PR_HOME_ADDRESS_STREET];
}
else
{
return MAPI_MAILUSER_PROP_IDS[dispidHomeAddress];
}
}
}
return -1;

@ -92,6 +92,8 @@ public void save()
{
synchronized(this)
{
setDisplayPostalAddress();
MsOutlookAddrBookContactDetail outlookContactDetail;
for(ContactDetail contactDetail: this.contactDetails)
@ -350,4 +352,227 @@ public boolean match(String id)
return (localId.equals(id)
|| MsOutlookAddrBookContactQuery.compareEntryIds(id, localId));
}
/**
* Generates and stores the string representation of the home and work
* postall addresses.
*/
private void setDisplayPostalAddress()
{
synchronized(this)
{
MsOutlookAddrBookContactDetail detail;
// Setting the display work postal address.
boolean firstLineCR = false;
boolean secondLineCR = false;
String workAddress = "";
detail = findDetail(
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.PR_BUSINESS_ADDRESS_STREET]);
if(detail != null)
{
workAddress += detail.getDetail();
firstLineCR = true;
}
detail = findDetail(
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.PR_BUSINESS_ADDRESS_CITY]);
if(detail != null)
{
if(firstLineCR)
{
workAddress += "\r";
firstLineCR = false;
}
workAddress += detail.getDetail();
workAddress += " ";
secondLineCR = true;
}
detail = findDetail(
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.
PR_BUSINESS_ADDRESS_STATE_OR_PROVINCE]);
if(detail != null)
{
if(firstLineCR)
{
workAddress += "\r";
firstLineCR = false;
}
workAddress += detail.getDetail();
secondLineCR = true;
}
detail = findDetail(
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.
PR_BUSINESS_ADDRESS_POSTAL_CODE]);
if(detail != null)
{
if(firstLineCR)
{
workAddress += "\r";
firstLineCR = false;
}
workAddress += detail.getDetail();
workAddress += " ";
secondLineCR = true;
}
detail = findDetail(
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.PR_BUSINESS_ADDRESS_COUNTRY]);
if(detail != null)
{
if(secondLineCR)
{
workAddress += "\r";
secondLineCR = false;
}
workAddress += detail.getDetail();
}
detail = findDetail(
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.dispidWorkAddress]);
if(detail != null)
{
// set address.
detail.setDetail(workAddress);
}
else if(workAddress.length() > 0)
{
detail = new MsOutlookAddrBookContactDetail(
workAddress,
MsOutlookAddrBookContactQuery.getCategory(
MsOutlookAddrBookContactQuery.dispidWorkAddress),
MsOutlookAddrBookContactQuery.getSubCategories(
MsOutlookAddrBookContactQuery.dispidWorkAddress),
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.dispidWorkAddress]);
this.contactDetails.add(detail);
}
// Setting the display home postal address.
firstLineCR = false;
secondLineCR = false;
String homeAddress = "";
detail = findDetail(
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.PR_HOME_ADDRESS_STREET]);
if(detail != null)
{
homeAddress += detail.getDetail();
firstLineCR = true;
}
detail = findDetail(
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.PR_HOME_ADDRESS_CITY]);
if(detail != null)
{
if(firstLineCR)
{
homeAddress += "\r";
firstLineCR = false;
}
homeAddress += detail.getDetail();
homeAddress += " ";
secondLineCR = true;
}
detail = findDetail(
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.
PR_HOME_ADDRESS_STATE_OR_PROVINCE]);
if(detail != null)
{
if(firstLineCR)
{
homeAddress += "\r";
firstLineCR = false;
}
homeAddress += detail.getDetail();
secondLineCR = true;
}
detail = findDetail(
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.PR_HOME_ADDRESS_POSTAL_CODE]);
if(detail != null)
{
if(firstLineCR)
{
homeAddress += "\r";
firstLineCR = false;
}
homeAddress += detail.getDetail();
homeAddress += " ";
secondLineCR = true;
}
detail = findDetail(
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.PR_HOME_ADDRESS_COUNTRY]);
if(detail != null)
{
if(secondLineCR)
{
homeAddress += "\r";
secondLineCR = false;
}
homeAddress += detail.getDetail();
}
detail = findDetail(
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.dispidHomeAddress]);
if(detail != null)
{
// set address.
detail.setDetail(homeAddress);
}
else if(homeAddress.length() > 0)
{
detail = new MsOutlookAddrBookContactDetail(
homeAddress,
MsOutlookAddrBookContactQuery.getCategory(
MsOutlookAddrBookContactQuery.dispidHomeAddress),
MsOutlookAddrBookContactQuery.getSubCategories(
MsOutlookAddrBookContactQuery.dispidHomeAddress),
MsOutlookAddrBookContactQuery.MAPI_MAILUSER_PROP_IDS[
MsOutlookAddrBookContactQuery.dispidHomeAddress]);
this.contactDetails.add(detail);
}
}
}
/**
* Finds the detail corresponding to the given property id.
*
* @param detailPropId The detail identifier.
*
* @return The detail corresponding to the given property id. Null if not
* found.
*/
private MsOutlookAddrBookContactDetail findDetail(long detailPropId)
{
synchronized(this)
{
MsOutlookAddrBookContactDetail outlookContactDetail;
for(ContactDetail contactDetail: this.contactDetails)
{
if(contactDetail instanceof MsOutlookAddrBookContactDetail)
{
outlookContactDetail
= (MsOutlookAddrBookContactDetail) contactDetail;
for(Long propId: outlookContactDetail.getOutlookPropId())
{
if(propId.longValue() == detailPropId)
{
return outlookContactDetail;
}
}
}
}
}
return null;
}
}

Loading…
Cancel
Save