List<GenericDetail> alreadySetDetails = new Vector<GenericDetail>();
Iterator<GenericDetail> iter
= infoRetreiver.getDetails(uin, currentDetailValue.getClass());
while (iter.hasNext())
{
GenericDetail item = iter.next();
if(item.equals(currentDetailValue))
{
isFound = true;
// add the details to the list. We will save the list on one pass
// most of the multiple details require saving at one time, like Spoken Language
// we are placing it at the right place. replacing the old one
alreadySetDetails.add(newDetailValue);
}
else
alreadySetDetails.add(item);
}
// current detail value does not exist
if(!isFound)
return false;
//replacing in case of image
if (newDetailValue instanceof ImageDetail)
{
if (iconListener == null)
{
iconListener = new IconUpdateListener();
this.icqProvider.getAimConnection().getExternalServiceManager().
getIconServiceArbiter().addIconRequestListener(
new IconUpdateListener());
}
icqProvider.getAimConnection().getMyBuddyIconManager()
.requestSetIcon(ByteBlock.wrap(
((ServerStoredDetails.ImageDetail) newDetailValue)
.getBytes()));
infoRetreiver.detailsChanged(uin);
fireServerStoredDetailsChangeEvent(icqProvider,
ServerStoredDetailsChangeEvent.DETAIL_REPLACED,
currentDetailValue,
newDetailValue);
return true;
}
SuccessResponseListener responseListener = new SuccessResponseListener();
// // if toBeCleared == null. make it empty one
// if(toBeCleared == null)
// toBeCleared = new ArrayList();
//
// // fix the spoken languages must be 3
// int lastSpokenIndex = -1;
// int countOfLanguages = 0;
// boolean isLanguageFound = false;
// for(int i = 0; i < changedData.size(); i++)
// {
// Object item = changedData.get(i);
// if(item instanceof ServerStoredDetails.SpokenLanguageDetail)
// {
// isLanguageFound = true;
// lastSpokenIndex = i;
// countOfLanguages++;
// }
// }
//
// if(isLanguageFound)
// {
// for (int i = countOfLanguages; i < 3; i++)
// {
// lastSpokenIndex++;
// changedData.add(lastSpokenIndex,
// new ServerStoredDetails.SpokenLanguageDetail(null));
// }
// }
//
// Iterator iter = changedData.iterator();
// while(iter.hasNext())
// {
// ServerStoredDetails.GenericDetail item =
// (ServerStoredDetails.GenericDetail)iter.next();
//
// if(toBeCleared.contains(item))
// changeDataTlvs.add(getClearTlv(item));
// else
// changeDataTlvs.add(getTlvForChange(item));
// }
MetaFullInfoSetCmd cmd =
new MetaFullInfoSetCmd(Integer.parseInt(uin), reqID++);
int typeOfDetail =
supportedTypes.get(newDetailValue.getClass())[1];
try
{
switch(typeOfDetail)
{
case 0x01A4 : cmd.setCountry(getCountryCode(((CountryDetail)newDetailValue).getLocale())); break;
case 0x0154 : cmd.setNickName(((StringDetail)newDetailValue).getString()); break;
case 0x0140 : cmd.setFirstName(((StringDetail)newDetailValue).getString()); break;
case 0x014A :
cmd.setLastName(((StringDetail)newDetailValue).getString()); break;
case 0x015E : cmd.setEmail(((StringDetail)newDetailValue).getString(), false); break;
case 0x0190 : cmd.setHomeCity(((StringDetail)newDetailValue).getString()); break;
case 0x019A : cmd.setHomeState(((StringDetail)newDetailValue).getString()); break;
case 0x0276 : cmd.setHomePhone(((StringDetail)newDetailValue).getString()); break;
case 0x0280 : cmd.setHomeFax(((StringDetail)newDetailValue).getString()); break;
case 0x0262 : cmd.setAddress(((StringDetail)newDetailValue).getString()); break;
case 0x028A : cmd.setCellPhone(((StringDetail)newDetailValue).getString()); break;
case 0x026C : cmd.setHomeZip(((StringDetail)newDetailValue).getString()); break;
case 0x017C :
if(newDetailValue.equals(ServerStoredDetails.GenderDetail.FEMALE))
cmd.setGender(1);
else if(newDetailValue.equals(ServerStoredDetails.GenderDetail.MALE))
cmd.setGender(2);
else
cmd.setGender(0); break;
case 0x0213 : cmd.setHomePage(((StringDetail)newDetailValue).getString()); break;
case 0x023A : cmd.setBirthDay(((BirthDateDetail)newDetailValue).getCalendar().getTime()); break;
case 0x0186 :
int[] langs = new int[3];
Arrays.fill(langs, -1);
int count = 0;
Iterator<GenericDetail> i = getDetails(SpokenLanguageDetail.class);
while (i.hasNext())
{
GenericDetail item = i.next();
if(item.equals(currentDetailValue))
langs[count++] = getLanguageCode(((SpokenLanguageDetail)newDetailValue).getLocale());
else
langs[count++] = getLanguageCode(((SpokenLanguageDetail)item).getLocale());
}
cmd.setLanguages(langs[0], langs[1], langs[2]);
break;
case 0x0320 : cmd.setOriginCity(((StringDetail)newDetailValue).getString()); break;
case 0x032A : cmd.setOriginState(((StringDetail)newDetailValue).getString()); break;
case 0x0334 : cmd.setOriginCountry(getCountryCode(((CountryDetail)newDetailValue).getLocale())); break;
case 0x029E : cmd.setWorkCity(((StringDetail)newDetailValue).getString()); break;
case 0x02A8 : cmd.setWorkState(((StringDetail)newDetailValue).getString()); break;
case 0x02C6 : cmd.setWorkPhone(((StringDetail)newDetailValue).getString()); break;
case 0x02D0 : cmd.setWorkFax(((StringDetail)newDetailValue).getString()); break;
case 0x0294 : cmd.setWorkAddress(((StringDetail)newDetailValue).getString()); break;
case 0x02BC : cmd.setWorkZip(((StringDetail)newDetailValue).getString()); break;
case 0x02B2 : cmd.setWorkCountry(getCountryCode(((CountryDetail)newDetailValue).getLocale())); break;
case 0x01AE : cmd.setWorkCompany(((StringDetail)newDetailValue).getString()); break;
case 0x01B8 : cmd.setWorkDepartment(((StringDetail)newDetailValue).getString()); break;
case 0x01C2 : cmd.setWorkPosition(((StringDetail)newDetailValue).getString()); break;
case 0x01CC :
cmd.setWorkOccupationCode(getOccupationCode(((StringDetail)newDetailValue).getString())); break;
case 0x02DA : cmd.setWorkWebPage(((StringDetail)newDetailValue).getString()); break;
case 0x0258 : cmd.setNotes(((StringDetail)newDetailValue).getString()); break;
case 0x01EA :
List<InterestDetail> interests
= new ArrayList<InterestDetail>();
Iterator<GenericDetail> intIter
= getDetails(InterestDetail.class);
while (intIter.hasNext())
{
InterestDetail item = (InterestDetail) intIter.next();
if(item.equals(currentDetailValue))
interests.add((InterestDetail) newDetailValue);
else
interests.add(item);
}
setInterests(cmd, interests);