Ejemplo n.º 1
0
 /**
  * Creates a single item in the proper PIMList
  *
  * @param content is the item in the sync source standard format (could be a vCard, SIF-C or any
  *     other valid format).
  * @return a PIMItem representing the given item
  * @throws PIMException if the PIMItem cannot be created (for example if the textual
  *     representation is invalid, or no new items can be added to the list)
  */
 protected PIMItem createItem(String content) throws PIMException {
   if (Log.isLoggable(Log.TRACE)) {
     Log.trace(TAG_LOG, "createItem");
   }
   ContactList cl = (ContactList) list;
   Contact contact = cl.createContact();
   // Now populate the contact
   fillItem(contact, content);
   return contact;
 }
Ejemplo n.º 2
0
 // Delete a contact given by contactId (between 0 and max contacts). Returns
 // 1 if success otherwish returns 0.
 static int deleteContact(int contactId) {
   // #ifdef api.pim
   if (contactId >= 0 && contactId < s_contacts.length) {
     try {
       ContactList list = (ContactList) s_contacts[contactId].m_contact.getPIMList();
       list.removeContact((s_contacts[contactId].m_contact));
       s_contacts[contactId] = null;
       s_nbContacts--;
       for (int i = contactId; i < s_nbContacts; i++) {
         s_contacts[i] = s_contacts[i + 1];
       }
       return 1;
     } catch (Exception e) {
       Logger.println("Exception while deleting contact: " + e);
     }
   }
   // #endif
   return 0;
 }
 private void populateToDoList(String searchTerm) {
   toDoList.setModel(new DefaultListModel());
   try {
     String[] pimListNames = pim.listPIMLists(PIM.TODO_LIST);
     for (int i = 0; i < pimListNames.length; ++i) {
       ContactList cl =
           (ContactList) pim.openPIMList(PIM.TODO_LIST, PIM.READ_ONLY, pimListNames[i]);
       Enumeration items = cl.items(searchTerm);
       while (items.hasMoreElements()) {
         Contact c = (Contact) items.nextElement();
         toDoList.addItem(c.getString(Contact.FORMATTED_NAME, 0));
       }
     }
   } catch (PIMException ex) {
     ex.printStackTrace();
   }
   if (toDoList.getModel().getSize() == 0) {
     toDoList.addItem("No matches");
   }
 }
Ejemplo n.º 4
0
 /**
  * Delete an item from the store
  *
  * @param item the item to be removed (the key is the only relevant field)
  * @return true iff the item was successfully removed
  * @throws PIMException if the item cannot be removed
  */
 protected boolean deleteItem(PIMItem item) throws PIMException {
   ContactList cl = (ContactList) list;
   cl.removeContact((Contact) item);
   return true;
 }