예제 #1
0
 private void getAddress(PIMList list, Contact c) {
   if (list.isSupportedField(Contact.FORMATTED_ADDR)) {
     m_info[PIM_ADDRESS] = getString(c, Contact.FORMATTED_ADDR, Contact.ATTR_NONE);
   } else if (list.isSupportedField(Contact.ADDR)) {
     m_info[PIM_ADDRESS] = getMultiString(c, Contact.ADDR, Contact.ATTR_NONE);
   }
 }
예제 #2
0
 private String getFieldValue(PIMList list, Contact c, int formattedName, int name) {
   if (list.isSupportedField(formattedName)) {
     return getString(c, formattedName, Contact.ATTR_NONE);
   } else if (list.isSupportedField(name)) {
     return getMultiString(c, name, Contact.ATTR_NONE);
   }
   return "";
 }
예제 #3
0
 private static int realizeStringField(
     Contact contact, int field, int index, java.lang.String value, int action)
     throws PIMException {
   if (s_PIMList.isSupportedField(field)) {
     Logger.println("DEBUG : realizeStringField " + field + " supported");
     inputStringField(contact, field, index, PIMItem.ATTR_NONE, value, action);
     return 1;
   } else {
     Logger.println("DEBUG : realizeStringField " + field + " not supported");
     return -1;
   }
 }
예제 #4
0
  private void getName(PIMList list, Contact c) {
    if (list.isSupportedField(Contact.NAME)) {

      if (c.countValues(Contact.NAME) != 0) {
        String[] array = c.getStringArray(Contact.NAME, Contact.ATTR_NONE);
        if (list.isSupportedArrayElement(Contact.NAME, Contact.NAME_FAMILY)) {
          if (array[Contact.NAME_FAMILY] != null) {
            m_info[PIM_LAST_NAME] = array[Contact.NAME_FAMILY];
          }
        }
        if (list.isSupportedArrayElement(Contact.NAME, Contact.NAME_GIVEN)) {
          if (array[Contact.NAME_GIVEN] != null) {
            m_info[PIM_FIRST_NAME] = array[Contact.NAME_GIVEN];
          }
        }
      }
    }
    if (list.isSupportedField(Contact.FORMATTED_NAME)) {
      m_info[PIM_FULL_NAME] = getString(c, Contact.FORMATTED_NAME, Contact.ATTR_NONE);
    } else {
      m_info[PIM_FULL_NAME] = m_info[PIM_LAST_NAME] + " " + m_info[PIM_FIRST_NAME];
    }
  }
예제 #5
0
 private void getPhoto(PIMList list, Contact c) {
   if (list.isSupportedField(Contact.EMAIL)) {
     m_info[PIM_PHOTO_URL] = getString(c, Contact.PHOTO_URL, Contact.ATTR_NONE);
   }
 }
예제 #6
0
 private void getEmail(PIMList list, Contact c) {
   if (list.isSupportedField(Contact.EMAIL)) {
     m_info[PIM_EMAIL] = getString(c, Contact.EMAIL, Contact.ATTR_NONE);
   }
 }
예제 #7
0
  // Create a new contact and returns a contactId used to add new fields by
  // using setInfo.
  static int createContact() {
    // #ifdef api.pim
    Contact contact = ((ContactList) s_PIMList).createContact();

    String[] name = new String[s_PIMList.stringArraySize(Contact.NAME)];
    name[Contact.NAME_GIVEN] = "";
    name[Contact.NAME_FAMILY] = "";

    Logger.println("DEBUG createContact : init");
    String[] addr = new String[s_PIMList.stringArraySize(Contact.ADDR)];
    addr[Contact.ADDR_COUNTRY] = "";
    addr[Contact.ADDR_LOCALITY] = "";
    addr[Contact.ADDR_POSTALCODE] = "";
    addr[Contact.ADDR_STREET] = "";
    if (s_PIMList.isSupportedField(Contact.FORMATTED_NAME))
      contact.addString(Contact.FORMATTED_NAME, PIMItem.ATTR_NONE, "");
    else Logger.println("DEBUG createContact not supported : FORMATTED_NAME");
    if (s_PIMList.isSupportedArrayElement(Contact.NAME, Contact.NAME_FAMILY))
      name[Contact.NAME_FAMILY] = "";
    else Logger.println("DEBUG createContact not supported : NAME_FAMILY");
    if (s_PIMList.isSupportedArrayElement(Contact.NAME, Contact.NAME_GIVEN))
      name[Contact.NAME_GIVEN] = "";
    else Logger.println("DEBUG createContact not supported : NAME_GIVEN");
    contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, name);
    if (s_PIMList.isSupportedArrayElement(Contact.ADDR, Contact.ADDR_COUNTRY))
      addr[Contact.ADDR_COUNTRY] = "";
    else Logger.println("DEBUG createContact not supported : ADDR_COUNTRY");
    if (s_PIMList.isSupportedArrayElement(Contact.ADDR, Contact.ADDR_LOCALITY))
      addr[Contact.ADDR_LOCALITY] = "";
    else Logger.println("DEBUG createContact not supported : ADDR_LOCALITY");
    if (s_PIMList.isSupportedArrayElement(Contact.ADDR, Contact.ADDR_POSTALCODE))
      addr[Contact.ADDR_POSTALCODE] = "";
    else Logger.println("DEBUG createContact not supported : ADDR_POSTALCODE");
    if (s_PIMList.isSupportedArrayElement(Contact.ADDR, Contact.ADDR_STREET))
      addr[Contact.ADDR_STREET] = "";
    else Logger.println("DEBUG createContact not supported : ADDR_STREET");
    if (s_PIMList.isSupportedField(Contact.ADDR))
      contact.addStringArray(Contact.ADDR, Contact.ATTR_HOME, addr);
    else Logger.println("DEBUG createContact not supported : ADDR ATTR_HOME");
    if (s_PIMList.isSupportedField(Contact.ADDR))
      contact.addStringArray(Contact.ADDR, Contact.ATTR_WORK, addr);
    else Logger.println("DEBUG createContact not supported : ADDR ATTR_WORK");
    if (s_PIMList.isSupportedField(Contact.FORMATTED_ADDR))
      contact.addString(Contact.FORMATTED_ADDR, Contact.ATTR_HOME, "");
    else Logger.println("DEBUG createContact not supported : FORMATTED_ADDR ATTR_HOME");
    if (s_PIMList.isSupportedField(Contact.FORMATTED_ADDR))
      contact.addString(Contact.FORMATTED_ADDR, Contact.ATTR_WORK, "");
    else Logger.println("DEBUG createContact not supported : FORMATTED_ADDR ATTR_WORK");
    //             if (s_PIMList.isSupportedField(Contact.TEL))
    //                    contact.addString(Contact.TEL, Contact.ATTR_HOME, "");
    if (s_PIMList.isSupportedAttribute(Contact.TEL, Contact.ATTR_HOME))
      contact.addString(Contact.TEL, Contact.ATTR_HOME, "");
    else Logger.println("DEBUG createContact not supported : TEL ATTR_HOME");
    if (s_PIMList.isSupportedAttribute(Contact.TEL, Contact.ATTR_WORK))
      contact.addString(Contact.TEL, Contact.ATTR_WORK, "");
    else Logger.println("DEBUG createContact not supported : TEL ATTR_WORK");
    if (s_PIMList.isSupportedAttribute(Contact.TEL, Contact.ATTR_FAX))
      contact.addString(Contact.TEL, Contact.ATTR_FAX, "");
    else Logger.println("DEBUG createContact not supported : TEL ATTR_FAX");
    if (s_PIMList.isSupportedAttribute(Contact.TEL, Contact.ATTR_MOBILE | Contact.ATTR_HOME))
      contact.addString(Contact.TEL, Contact.ATTR_MOBILE | Contact.ATTR_HOME, "");
    else Logger.println("DEBUG createContact not supported : TEL ATTR_MOBILE ATTR_HOME");
    if (s_PIMList.isSupportedAttribute(Contact.TEL, Contact.ATTR_MOBILE | Contact.ATTR_WORK))
      contact.addString(Contact.TEL, Contact.ATTR_MOBILE | Contact.ATTR_WORK, "");
    else Logger.println("DEBUG createContact not supported : TEL ATTR_MOBILE ATTR_WORK");
    if (s_PIMList.isSupportedField(Contact.EMAIL))
      contact.addString(Contact.EMAIL, PIMItem.ATTR_NONE, "");
    else Logger.println("DEBUG createContact not supported : EMAIL");
    if (s_PIMList.isSupportedField(Contact.PHOTO_URL))
      contact.addString(Contact.PHOTO_URL, PIMItem.ATTR_NONE, "");
    else Logger.println("DEBUG createContact not supported : PHOTO_URL");
    //              Logger.println("DEBUG createContact : NOTE");
    if (s_PIMList.isSupportedField(Contact.NOTE))
      contact.addString(Contact.NOTE, PIMItem.ATTR_NONE, "");
    else Logger.println("DEBUG createContact not supported : NOTE");

    try {
      //             contact.addString(Contact.FORMATTED_NAME, PIMItem.ATTR_NONE, "");
      //             contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, name);
      //             contact.addStringArray(Contact.ADDR, Contact.ATTR_HOME, addr);
      //             contact.addStringArray(Contact.ADDR, Contact.ATTR_WORK, addr);
      //             contact.addString(Contact.FORMATTED_ADDR, Contact.ATTR_WORK, "");
      //             contact.addString(Contact.FORMATTED_ADDR, Contact.ATTR_HOME, "");
      //             contact.addString(Contact.TEL, Contact.ATTR_HOME, "");
      //             contact.addString(Contact.TEL, Contact.ATTR_WORK, "");
      //             contact.addString(Contact.TEL, Contact.ATTR_FAX, "");
      //             contact.addString(Contact.TEL, Contact.ATTR_MOBILE | Contact.ATTR_HOME, "");
      //             contact.addString(Contact.TEL, Contact.ATTR_MOBILE | Contact.ATTR_WORK, "");
      //             contact.addString(Contact.EMAIL, PIMItem.ATTR_NONE, "");
      //             contact.addString(Contact.NOTE, PIMItem.ATTR_NONE, "");
      //             contact.addString(Contact.PHOTO_URL, PIMItem.ATTR_NONE, "");
      //             contact.addToCategory("");  // todo : catcher exception pour passer outre en
      // cas d'exception ca dépend des plateformes supportés pour "" vide.
      //
      //             String [] cat = contact.getCategories();
      //             for (int i=0; i< cat.length; i++) {
      //                 Logger.println("DEBUG categories "+i+"-"+cat[i]);
      //             }
      //
      contact.commit();
      //
      //          } catch (UnsupportedFieldException e) {
      //            // In this case, we choose not to save the contact at all if any of the
      //            // fields are not supported on this platform.
      //            Logger.println("createContact() tests Contact not saved :"+e);
      //            return 0;
    } catch (javax.microedition.pim.PIMException e) {
      Logger.println("createContacttests PIMException");
      return 0;
    }

    addContact((ContactList) s_PIMList, contact);
    // #endif
    return s_nbContacts;
  }