/** * Add values to URL field. */ void PIMContact::addURL() { MAUtil::String attribute; printf("Add values to URL field.\n\n"); mArgs.field = MA_PIM_FIELD_CONTACT_URL; // Print home URL value and attribute. attribute = getWebsiteAttributeString(MA_PIM_ATTR_WEBSITE_HOME); printf("Attribute: %s", attribute.c_str()); printf("URL1: %S", sURLHome); // Write home URL value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sURLHome); // Add value to URL field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_WEBSITE_HOME)); printf("\n"); // Print work URL value and attribute. attribute = getWebsiteAttributeString(MA_PIM_ATTR_WEBSITE_WORK); printf("Attribute: %s", attribute.c_str()); printf("URL2: %S", sURLWork); // Write work URL value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sURLWork); // Add value to URL field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_WEBSITE_WORK)); }
/** * Add values to relation field. */ void PIMContact::addRelation() { printf("Add values to relation field.\n\n"); mArgs.field = MA_PIM_FIELD_CONTACT_RELATION; MAUtil::String attribute; // Print brother relation value and attribute. attribute = getRelationAttributeString(MA_PIM_ATTR_RELATION_BROTHER); printf("Attribute: %s", attribute.c_str()); printf("Relation1: %S", sRelationBrother); // Write brother value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sRelationBrother); // Add value to relation field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_RELATION_BROTHER)); printf("\n"); // Print manager relation value and attribute. attribute = getRelationAttributeString(MA_PIM_ATTR_RELATION_MANAGER); printf("Attribute: %s", attribute.c_str()); printf("Relation2: %S", sRelationManager); // Write manager value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sRelationManager); // Add value to relation field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_RELATION_MANAGER)); }
/** * Add values to email field. */ void PIMContact::addEmail() { printf("Add values to email field.\n\n"); MAUtil::String attribute; mArgs.field = MA_PIM_FIELD_CONTACT_EMAIL; // Print home email value and attribute for on the screen. attribute = getEmailAttributeString(MA_PIM_ATTR_EMAIL_HOME); printf("Attribute: %s", attribute.c_str()); printf("Email: %S", sEmailHome); // Write home email value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sEmailHome); // Add value to the email field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_EMAIL_HOME)); printf("\n"); // Print work email value and attribute for on the screen. attribute = getEmailAttributeString(MA_PIM_ATTR_EMAIL_WORK); printf("Attribute: %s", attribute.c_str()); printf("Email: %S", sEmailWork); // Write work email value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sEmailWork); // Add value to the email field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_EMAIL_WORK)); }
/** * Modify the first value of the address field. * Set a custom label for that value. */ void PIMContact::modifyAddressField() { printf("==============Modify address field=============\n\n"); mArgs.field = MA_PIM_FIELD_CONTACT_ADDR; // Print new value on the screen. for (int i = 0; i < COUNT_ADDRESS_INDICES; i++) { MAUtil::String addressValueIndex = getAddressIndexString(i); const wchar* addressValue = sAddressModified[i]; printf("%s %S", addressValueIndex.c_str(), addressValue); } printf("\n"); // Write the address into the buffer. mArgs.bufSize = writeWCharArraysToBuf( mArgs.buf, sAddressModified, COUNT_ADDRESS_INDICES); // Set the value for the address field at position 0. // Use MA_PIM_ATTR_ADDR_CUSTOM so we can set the label later. checkResultCode(maPimItemSetValue(&mArgs, 0, MA_PIM_ATTR_ADDR_CUSTOM)); // Set custom attribute(label) for the above address. printf("\n Set label for the this address."); printf("Label: %S", sAddressLabel); // Write label value into buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sAddressLabel); // Set label value for address field at position 0. checkResultCode(maPimItemSetLabel(&mArgs, 0)); waitForClick(); }
/** * Add values to phone field. */ void PIMContact::addPhone() { printf("Add values to phone field field.\n\n"); mArgs.field = MA_PIM_FIELD_CONTACT_TEL; MAUtil::String attribute; // Print mobile number and attribute on the screen. attribute = getPhoneAttributeString(MA_PIM_ATTR_PHONE_MOBILE); printf("Attribute: %s", attribute.c_str()); printf("Mobile number: %S", sPhoneMobile); // Write mobile number value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sPhoneMobile); // Add value to phone field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_PHONE_MOBILE)); printf("\n"); // Print iPhone number and attribute on the screen. attribute = getPhoneAttributeString(MA_PIM_ATTR_PHONE_IPHONE); printf("Attribute: %s", attribute.c_str()); printf("iPhone number: %S", sPhoneIPhone); // Write iPhone number value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sPhoneIPhone); // Add value to the phone field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_PHONE_IPHONE)); printf("\n"); // Print home number and attribute on the screen. attribute = getPhoneAttributeString(MA_PIM_ATTR_PHONE_HOME); printf("Attribute: %s", attribute.c_str()); printf("Home number: %S", sPhoneHome); // Write home number value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sPhoneHome); // Add value to the phone field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_PHONE_HOME)); }
/** * Test maPimItemSetLabel syscall. */ void AppMoblet::testMaPimItemSetLabel() { printf("\n===========Test maPimItemSetLabel syscall==========="); MAHandle list = maPimListOpen(MA_PIM_CONTACTS); printResultCode(list); MAHandle item = maPimItemCreate(list); printResultCode(item); MA_PIM_ARGS args; char buf[1024]; args.buf = buf; args.bufSize = 1024; printf("\nTest with invalid item handle"); args.item = 323; printResultCode(maPimItemSetLabel(&args, 1)); printf("\nTest with invalid field"); args.item = item; args.field = 12333; printResultCode(maPimItemSetLabel(&args, 1)); printf("\nTest with unsupported field"); args.field = MA_PIM_FIELD_CONTACT_CLASS; printResultCode(maPimItemSetLabel(&args, 1)); printf("\nTest with invalid value index and empty field"); args.field = MA_PIM_FIELD_CONTACT_ADDR; printResultCode(maPimItemSetLabel(&args, 1)); waitForClick(); printf("\nTest with invalid value index and field is not empty"); PIMContact* contact = new PIMContact(item); contact->addAddress(); printResultCode(maPimItemSetLabel(&args, 5)); waitForClick(); printf("\nTest with a valid field, but value's attribute is not custom"); printResultCode(maPimItemSetLabel(&args, 0)); printf("\nTest with a valid field and value's attribute is custom"); // Write value to buffer. args.bufSize = writeWCharArraysToBuf(args.buf, sAddressHome, COUNT_ADDRESS_INDICES); int index = maPimItemAddValue(&args, MA_PIM_ATTR_ADDR_CUSTOM); args.bufSize = copyWCharArray(args.buf, L"My label"); printResultCode(maPimItemSetLabel(&args, index)); maPimItemRemove(list, item); maPimListClose(list); waitForClick(); }
/** * Add value to title field. */ void PIMContact::addTitle() { printf("Add value to title field.\n\n"); mArgs.field = MA_PIM_FIELD_CONTACT_TITLE; // Print value on the screen. printf("Public key string: %S", sTitle); // Write title value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sTitle); // Add value to title field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_PREFERRED)); }
/** * Add value to URL field. */ void PIMContact::addPhotoURL() { printf("Add value to photo URL field.\n\n"); mArgs.field = MA_PIM_FIELD_CONTACT_PHOTO_URL; // Write value on the screen. printf("Photo URL: %S", sPhotoURL); // Write photo URL value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sPhotoURL); // Add value to photo URL field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_PREFERRED)); }
/** * Add value to organization field. */ void PIMContact::addOrg() { printf("Add value to organization field.\n\n"); mArgs.field = MA_PIM_FIELD_CONTACT_ORG; // Print value on the screen. printf("Organization: %S", sOrg); // Write organization value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sOrg); // Add value to organization field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_PREFERRED)); }
/** * Add value to note field. */ void PIMContact::addNote() { printf("Add value to note field.\n\n"); mArgs.field = MA_PIM_FIELD_CONTACT_NOTE; // Print value on the screen. printf("Note: %S", sNote); // Write note value to buffer. mArgs.bufSize = copyWCharArray(mArgs.buf, sNote); // Add value to note field. checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_PREFERRED)); }