1. How do I add a contact with an email Address or Dekoh User Id?

To add a user with an Email Address or Dekoh User Id, you must have the JAR files, das_contacts.jar, butterfly.jar (for compilation) in the classpath (while deploying on Dekoh Desktop you don't need these, as the JAR is always in the classpath). In this case, you should also be aware of the user being added as the contact.

Paste the following code where you want to add the Email Address or Dekoh User Id as a contact.

import com.pramati.bfly.das.api.DesktopUser;
import com.pramati.bfly.das.contacts.helper.AddressBook;
import com.pramati.bfly.das.helper.SessionUtil;

//First get the logged in user. we need this as only registered dekoh users can only have contacts.
DesktopUser desktopUser = SessionUtil.getLoggedInDesktopUser(request);

//Then get the AddressBook of the user for whom contacts needs to be added
AddressBook addressBook = AddressBook.getAddressBookForUser(desktopUser);

//Add the emailAddress or dekohid whoch needs to added as contact.
addressBook.addContact("emailOrDekohId");

2. How do I add a contact with a 'Contact' Object?

To add a user with a Contact Object, you must have the JAR files, das_contacts.jar, butterfly.jar (this is used during compilation) in the classpath (while deploying on Dekoh Desktop you do not need these, as the JAR files are always in the classpath). You should also be aware of the user being added as the contact.

Paste the following code when you want to add a contact using “Contact” Object.

import com.pramati.bfly.das.api.DesktopUser;
import com.pramati.bfly.das.contacts.helper.AddressBook;
import com.pramati.bfly.das.helper.SessionUtil;
import com.pramati.bfly.cas.profile.dataObject.LocationType
import com.pramati.bfly.cas.profile.dataObject.PhoneType
import com.pramati.bfly.das.contacts.persistence.*

//First get the logged in user. we need this as only registered dekoh users can only have contacts.
DesktopUser desktopUser = SessionUtil.getLoggedInDesktopUser(request);

//Then get the AddressBook of the user for whom contacts needs to be added
AddressBook addressBook = AddressBook.getAddressBookForUser(desktopUser);

//Create a Contact instance with all information available
Contact contact = new Contact("ContactIdName", "DisplayName", "FirstName", "LastName");
Email email = new Email("default@pramati.com");
contact.addEmailId(email);
Location location = new Location("Address1", "Address2", "city", "State", "Country", "Pincode", LocationType.HOME);
contact.addLocation(location);
Tag tag = new Tag("Buddies");
contact.addTag(tag);
Phone phoneNo = new Phone("12345678", PhoneType.HOME);
contact.addPhone(phoneNo);

//Add Contacts Object
addressBook.addContact(contact);

3. How do I send out a contact invitation?

To invite a user to Dekoh Network, you must have the JAR files, das_contacts.jar, butterfly.jar (for compilation) in the classpath. You should also be aware of either the user's Dekoh ID or Email ID to whom the invitations are being sent. Once you invite the user, the contact gets added automatically to your address book.

Paste the following code where you want to send Invitation to an Email Address or Dekoh User ID.

import com.pramati.bfly.das.api.DesktopUser;
import com.pramati.bfly.das.contacts.helper.AddressBook;
import com.pramati.bfly.das.helper.SessionUtil;

//First get the logged in user. we need this as only registered dekoh users can only have contacts.
DesktopUser desktopUser = SessionUtil.getLoggedInDesktopUser(request);

//Then get the AddressBook of the user inviting another user to Dekoh
AddressBook addressBook = AddressBook.getAddressBookForUser(desktopUser);

//For inviting user "emailIdOrDekohId" 
addressBook.inviteUser("emailIdOrDekohId");

4. How do I verify whether a user already exists in my contact list?

To retrieve contact information of a user, given an Email address or Dekoh user ID, you should be aware of the contact's account ID.

Paste the following code in your application/code:

import com.pramati.bfly.das.api.DesktopUser;
import com.pramati.bfly.das.contacts.helper.AddressBook;
import com.pramati.bfly.das.helper.SessionUtil;

//First get the logged in user. we need this as only registered dekoh users can only have contacts.
DesktopUser desktopUser = SessionUtil.getLoggedInDesktopUser(request);

//Then get your AddressBook to search your contacts
AddressBook addressBook = AddressBook.getAddressBookForUser(desktopUser);

//For getting contact information of a user with a contact Id. The contactId is either the Dekohid or emailAddress with which the contact is added.
Contact contact = addressBook.getContactInfoForUser("contactId");