Package net.java.sip.communicator.service.protocol.ServerStoredDetails

Examples of net.java.sip.communicator.service.protocol.ServerStoredDetails.GenericDetail


        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);
View Full Code Here


    private void fillTooltipLines(ExtendedTooltip tip,
                                  Iterator<GenericDetail> details)
    {
        while(details.hasNext())
        {
            GenericDetail d = details.next();
            if(d instanceof PhoneNumberDetail &&
                !(d instanceof FaxDetail) &&
                !(d instanceof PagerDetail))
            {
                PhoneNumberDetail pnd = (PhoneNumberDetail)d;
View Full Code Here

            {
                details = infoOpSet.getAllDetailsForContact(contact);

                while(details.hasNext())
                {
                    GenericDetail d = details.next();
                    if(d instanceof PhoneNumberDetail &&
                        !(d instanceof PagerDetail) &&
                        !(d instanceof FaxDetail))
                    {
                        PhoneNumberDetail pnd = (PhoneNumberDetail)d;
View Full Code Here

                {
                    details = infoOpSet.getAllDetailsForContact(contact);

                    while(details.hasNext())
                    {
                        GenericDetail d = details.next();
                        if(d instanceof PhoneNumberDetail &&
                            !(d instanceof PagerDetail) &&
                            !(d instanceof FaxDetail))
                        {
                            PhoneNumberDetail pnd = (PhoneNumberDetail)d;
View Full Code Here

            if(callButton.isEnabled())
                return;

            while(details.hasNext())
            {
                GenericDetail d = details.next();
                if(d instanceof PhoneNumberDetail &&
                    !(d instanceof PagerDetail) &&
                    !(d instanceof FaxDetail))
                {
                    PhoneNumberDetail pnd = (PhoneNumberDetail)d;
View Full Code Here

                        if(details != null)
                        {
                            while(details.hasNext())
                            {
                                GenericDetail d = details.next();
                                if(d instanceof PhoneNumberDetail &&
                                    !(d instanceof PagerDetail) &&
                                    !(d instanceof FaxDetail))
                                {
                                    PhoneNumberDetail pnd = (PhoneNumberDetail)d;
View Full Code Here

        JPanel valuesPanel = new TransparentPanel(new GridLayout(0, 1, 5, 5));

        detailsPanel.add(valuesPanel, BorderLayout.CENTER);

        Iterator<GenericDetail> contactDetails;
        GenericDetail genericDetail;

        // First name details.
        contactDetails =
            contactInfoOpSet.getDetails(contact, FirstNameDetail.class);

        String firstNameDetail = "";
        while (contactDetails.hasNext())
        {
            genericDetail = contactDetails.next();

            firstNameDetail =
                firstNameDetail + " " + genericDetail.getDetailValue();
        }

        if (firstNameDetail.equals(""))
            firstNameDetail
                = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");

        valuesPanel.add(new JLabel(firstNameDetail));

        // Middle name details.
        contactDetails =
            contactInfoOpSet.getDetails(contact, MiddleNameDetail.class);

        String middleNameDetail = "";
        while (contactDetails.hasNext())
        {
            genericDetail = contactDetails.next();
            middleNameDetail =
                middleNameDetail + " " + genericDetail.getDetailValue();
        }

        if (middleNameDetail.trim().equals(""))
            middleNameDetail
                = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");

        valuesPanel.add(new JLabel(middleNameDetail));

        // Last name details.
        contactDetails =
            contactInfoOpSet.getDetails(contact, LastNameDetail.class);

        String lastNameDetail = "";
        while (contactDetails.hasNext())
        {
            genericDetail = contactDetails.next();

            lastNameDetail =
                lastNameDetail + " " + genericDetail.getDetailValue();
        }

        if (lastNameDetail.trim().equals(""))
            lastNameDetail
                = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");

        valuesPanel.add(new JLabel(lastNameDetail));

        // Gender details.
        contactDetails =
            contactInfoOpSet.getDetails(contact, GenderDetail.class);

        String genderDetail = "";
        while (contactDetails.hasNext())
        {
            genericDetail = contactDetails.next();
            genderDetail = genderDetail + " " + genericDetail.getDetailValue();
        }

        if (genderDetail.trim().equals(""))
            genderDetail
                = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");

        valuesPanel.add(new JLabel(genderDetail));

        // Birthday details.
        contactDetails =
            contactInfoOpSet.getDetails(contact, BirthDateDetail.class);

        String birthDateDetail = "";
        String ageDetail = "";
        if (contactDetails.hasNext())
        {
            genericDetail = contactDetails.next();

            Calendar calendarDetail =
                (Calendar) genericDetail.getDetailValue();

            Date birthDate = calendarDetail.getTime();
            DateFormat dateFormat = DateFormat.getDateInstance();

            birthDateDetail = dateFormat.format(birthDate).trim();

            Calendar c = Calendar.getInstance();
            int age = c.get(Calendar.YEAR) - calendarDetail.get(Calendar.YEAR);

            if (c.get(Calendar.MONTH) < calendarDetail.get(Calendar.MONTH))
                age--;

            ageDetail = Integer.toString(age).trim();
        }

        if (birthDateDetail.equals(""))
            birthDateDetail
                = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");

        if (ageDetail.equals(""))
            ageDetail = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");

        valuesPanel.add(new JLabel(birthDateDetail));
        valuesPanel.add(new JLabel(ageDetail));

        // Email details.
        contactDetails =
            contactInfoOpSet.getDetails(contact, EmailAddressDetail.class);

        String emailDetail = "";
        while (contactDetails.hasNext())
        {
            genericDetail = contactDetails.next();
            emailDetail = emailDetail + " " + genericDetail.getDetailValue();
        }

        if (emailDetail.trim().equals(""))
            emailDetail
                = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");

        valuesPanel.add(new JLabel(emailDetail));

        // Phone number details.
        contactDetails =
            contactInfoOpSet.getDetails(contact, PhoneNumberDetail.class);

        String phoneNumberDetail = "";
        while (contactDetails.hasNext())
        {
            genericDetail = contactDetails.next();
            phoneNumberDetail =
                phoneNumberDetail + " " + genericDetail.getDetailValue();
        }

        if (phoneNumberDetail.trim().equals(""))
            phoneNumberDetail
                = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
View Full Code Here

        // Obtain all the details for a contact.
        Iterator<GenericDetail> iter
            = contactInfoOpSet.getAllDetailsForContact(contact);

        GenericDetail detail;
        JLabel detailLabel;
        JTextArea detailValueArea;
        JPanel detailPanel;

        while (iter.hasNext())
        {
            detail = iter.next();

            if (detail.getDetailValue().toString().equals(""))
                continue;

            detailLabel = new JLabel();
            detailValueArea = new JTextArea();
            detailPanel = new TransparentPanel(new BorderLayout(10, 10));

            detailValueArea.setAlignmentX(JTextArea.CENTER_ALIGNMENT);
            detailValueArea.setEditable(false);
            detailValueArea.setLineWrap(true);

            detailPanel.add(detailLabel, BorderLayout.WEST);
            detailPanel.add(detailValueArea, BorderLayout.CENTER);
            detailPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

            extendedPanel.add(detailPanel);

            if (detail instanceof BinaryDetail)
            {
                JLabel imageLabel =
                    new JLabel(new ImageIcon((byte[]) detail
                        .getDetailValue()));

                imagePanel.add(imageLabel);
            }
            else if (detail instanceof CalendarDetail)
            {
                detailLabel.setText(detail.getDetailDisplayName() + ": ");

                Date detailDate =
                    ((Calendar) detail.getDetailValue()).getTime();
                DateFormat df = DateFormat.getDateInstance();

                detailValueArea.setText(df.format(detailDate).trim());
            }
            else if (detail instanceof LocaleDetail)
            {
                detailLabel.setText(detail.getDetailDisplayName() + ": ");

                detailValueArea.setText(((Locale) detail.getDetailValue())
                        .getDisplayName().trim());
            }
            else if (detail instanceof TimeZoneDetail)
            {
                detailLabel.setText(detail.getDetailDisplayName() + ": ");

                detailValueArea.setText(((TimeZone) detail.getDetailValue())
                        .getDisplayName().trim());
            }
            else
            {
                detailLabel.setText(detail.getDetailDisplayName() + ": ");

                detailValueArea.setText(
                    detail.getDetailValue().toString().trim());
            }
        }

        // Add users status message to extended details if it exists
        String statusMessage = contact.getStatusMessage();
View Full Code Here

TOP

Related Classes of net.java.sip.communicator.service.protocol.ServerStoredDetails.GenericDetail

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.