* @param sortfield
* @return
*/
public static FetchProfile createFetchProfile( boolean complete, MessageListFields sortfield ) {
FetchProfile fp = new FetchProfile();
if ( complete ) {
fp.add( FetchProfile.Item.ENVELOPE );
fp.add( FetchProfile.Item.FLAGS );
fp.add( FetchProfile.Item.CONTENT_INFO );
fp.add( IMAPFolder.FetchProfileItem.SIZE );
fp.add( CubusConstants.FETCH_ITEM_PRIORITY );
fp.add( UIDFolder.FetchProfileItem.UID );
}
else {
if ( sortfield != null ) {
if ( MessageListFields.SUBJECT == sortfield || MessageListFields.FROM == sortfield
|| MessageListFields.TO == sortfield || MessageListFields.SEND_DATE == sortfield ) {
fp.add( FetchProfile.Item.ENVELOPE );
}
else if ( MessageListFields.SIZE == sortfield ) {
fp.add( IMAPFolder.FetchProfileItem.SIZE );
}
}
}
return fp;
}