use of org.opentransactions.otapi.Contact in project otapij by FellowTraveler.
the class AddressBookHelper method getContactList.
public static List getContactList() {
List contactList = new ArrayList();
AddressBook addressBook = Helpers.getAddressBook();
if (addressBook == null) {
System.out.println("getContactList - addressBook returns null");
return null;
}
for (int i = 0; i < addressBook.GetContactCount(); i++) {
Contact contact = addressBook.GetContact(i);
if (contact == null)
continue;
String[] row = new String[2];
row[0] = contact.getGui_label() == null ? "" : contact.getGui_label();
System.out.println("contact.getGui_label():" + contact.getGui_label());
row[1] = contact.getContact_id() == null ? "" : contact.getContact_id();
contactList.add(row);
}
return contactList;
}
use of org.opentransactions.otapi.Contact in project otapij by FellowTraveler.
the class AddressBookHelper method removeContactAcct.
public static boolean removeContactAcct(String contactID, int index) {
boolean status = false;
AddressBook addressBook = Helpers.getAddressBook();
if (addressBook == null) {
System.out.println("removeContactAcct - addressBook returns null");
return false;
}
for (int i = 0; i < addressBook.GetContactCount(); i++) {
Contact contact = addressBook.GetContact(i);
if (contact == null)
continue;
if (contactID.equals(contact.getContact_id())) {
status = contact.RemoveContactAcct(index);
System.out.println("removeContactAcct status contact.RemoveContactAcct:" + status);
if (status)
status = otapi.StoreObject(addressBook, "moneychanger", "gui_contacts.dat");
System.out.println("removeContactAcct status addressBook otapi.StoreObject:" + status);
break;
}
}
return status;
}
use of org.opentransactions.otapi.Contact in project otapij by FellowTraveler.
the class AddressBookHelper method createContact.
public static String createContact(String name, String email, String publicKey, String memo) {
String contactID = "error";
System.out.println("in createContact");
AddressBook addressBook = Helpers.getAddressBook();
if (addressBook == null) {
System.out.println("createContact - addressBook returns null");
return contactID;
}
System.out.println("in createContact,addressBook:" + addressBook);
Storable storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_CONTACT);
System.out.println("in createContact, storable:" + storable);
if (storable != null) {
Contact contact = Contact.ot_dynamic_cast(storable);
System.out.println("contact:" + contact);
if (contact != null) {
contact.setContact_id(Helpers.generateID());
contact.setEmail(email);
contact.setGui_label(name);
contact.setMemo(memo);
contact.setPublic_key(publicKey);
boolean status = addressBook.AddContact(contact);
System.out.println("status addressBook.AddContact:" + status);
if (!status) {
return contactID;
}
status = otapi.StoreObject(addressBook, "moneychanger", "gui_contacts.dat");
System.out.println("status addressBook otapi.StoreObject:" + status);
if (!status) {
return contactID;
}
contactID = Helpers.generateID();
}
}
return contactID;
}
use of org.opentransactions.otapi.Contact in project otapij by FellowTraveler.
the class AddressBookHelper method getContactDetails.
public static ContactDetails getContactDetails(String contactID, int mode) {
ContactDetails contactDetails = null;
AddressBook addressBook = Helpers.getAddressBook();
if (addressBook == null) {
System.out.println("getContactDetails - addressBook returns null");
return null;
}
for (int i = 0; i < addressBook.GetContactCount(); i++) {
Contact contact = addressBook.GetContact(i);
if (contact == null)
continue;
if (contactID.equals(contact.getContact_id())) {
contactDetails = new ContactDetails();
contactDetails.setEmail(contact.getEmail());
contactDetails.setLabel(contact.getGui_label());
contactDetails.setPublicKey(contact.getPublic_key());
contactDetails.setMemo(contact.getMemo());
contactDetails.setContact(contact);
List data = new ArrayList();
System.out.println("mode:" + mode + " contact.GetContactAcctCount():" + contact.GetContactAcctCount());
if (mode == 1) {
for (int j = 0; j < contact.GetContactAcctCount(); j++) {
if (contact.GetContactAcct(j) == null)
continue;
data.add(new String[] { contact.GetContactAcct(j).getGui_label() });
}
contactDetails.setContactAccts(data);
} else {
for (int j = 0; j < contact.GetContactNymCount(); j++) {
if (contact.GetContactNym(j) == null)
continue;
data.add(new String[] { contact.GetContactNym(j).getGui_label() });
}
contactDetails.setContactNyms(data);
}
break;
}
}
return contactDetails;
}
Aggregations