Ejemplo n.º 1
0
 private static void realizeStringArrayField(
     Contact contact,
     int field,
     int indexField,
     int index,
     int attributes,
     java.lang.String value,
     int action)
     throws PIMException {
   if (s_PIMList.isSupportedArrayElement(field, indexField)) {
     Logger.println(
         "DEBUG : realizeStringArrayField " + field + " and " + attributes + " supported");
     String[] values = new String[s_PIMList.stringArraySize(field)];
     for (int i = 0; i < values.length; i++) {
       values[i] = "";
     }
     values[indexField] = value;
     if (action == ADD_FIELD) {
       contact.addStringArray(field, attributes, values);
     } else {
       contact.setStringArray(field, index, attributes, values);
     }
     contact.commit();
   } else
     Logger.println(
         "DEBUG : realizeStringArrayField " + field + " and " + attributes + "not supported");
 }
Ejemplo n.º 2
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);
   }
 }
Ejemplo n.º 3
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 "";
 }
Ejemplo n.º 4
0
 // #ifdef api.pim
 private static void realizeStringField(
     Contact contact, int field, int index, int attributes, java.lang.String value, int action)
     throws PIMException {
   if (s_PIMList.isSupportedAttribute(field, attributes)) {
     Logger.println("DEBUG : realizeStringField " + field + " and " + attributes + " supported");
     inputStringField(contact, field, index, attributes, value, action);
   } else
     Logger.println(
         "DEBUG : realizeStringField " + field + " and " + attributes + "not supported");
 }
Ejemplo n.º 5
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;
   }
 }
Ejemplo n.º 6
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];
    }
  }
Ejemplo n.º 7
0
 static void closeContacts() {
   // #ifdef api.pim
   Logger.println("DEBUG : closeContacts IN");
   for (int i = 0; i < s_nbContacts; i++) {
     s_contacts[i] = null;
   }
   Logger.println("DEBUG : closeContacts init null for");
   s_contacts = null;
   Logger.println("DEBUG : closeContacts s_contacts null. Now try s_PIMList.close()");
   try {
     s_PIMList.close();
   } catch (Exception e) {
     Logger.println("Exception while closing list: " + e);
   }
   Logger.println("DEBUG : closeContacts OUT");
   // #endif
 }
Ejemplo n.º 8
0
 static int openContacts() {
   // #ifdef api.pim
   s_contacts = new JSContact[s_nbContacts + 64];
   s_nbContacts = 0;
   try {
     s_PIMList = PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
     Enumeration itemEnum = s_PIMList.items();
     while (itemEnum.hasMoreElements()) {
       try {
         addContact(s_PIMList, (Contact) itemEnum.nextElement());
       } catch (Exception e) {
         Logger.println("Exception while opening contacts: " + e);
       }
     }
   } catch (Exception e) {
     Logger.println("Exception while opening list: " + e);
   }
   // #endif
   return s_nbContacts;
 }
Ejemplo n.º 9
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);
   }
 }
Ejemplo n.º 10
0
 private void getEmail(PIMList list, Contact c) {
   if (list.isSupportedField(Contact.EMAIL)) {
     m_info[PIM_EMAIL] = getString(c, Contact.EMAIL, Contact.ATTR_NONE);
   }
 }
Ejemplo n.º 11
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;
  }