/** * Test maPimItemGetValue syscall. */ void AppMoblet::testMaPimItemGetValue() { printf("\n=========Test maPimItemGetValue syscall======="); MAHandle list = maPimListOpen(MA_PIM_CONTACTS); printResultCode(list); MAHandle item = maPimItemCreate(list); printResultCode(item); PIMContact* contact = new PIMContact(item); MA_PIM_ARGS args; char buf[1024]; args.buf = buf; args.bufSize = 1024; printf("\nTest syscalls with invalid item handle"); args.item = 1234; printResultCode(maPimItemGetValue(&args, 0)); printf("\nTest syscalls with invalid field id"); args.item = item; args.field = 696; printResultCode(maPimItemGetValue(&args, 0)); printf("\nTest syscall with unsupported field id"); args.field = MA_PIM_FIELD_CONTACT_CLASS; printResultCode(maPimItemGetValue(&args, 0)); printf("\nTest syscall with invalid value index - empty field"); args.field = MA_PIM_FIELD_CONTACT_ADDR; printResultCode(maPimItemGetValue(&args, 0)); waitForClick(); printf("\nTest syscall with invalid value index - field not empty"); contact->addAddress(); printResultCode(maPimItemGetValue(&args, 15)); waitForClick(); printf("\nTest syscall for a write only field"); args.field = MA_PIM_FIELD_CONTACT_PHOTO_URL; printResultCode(maPimItemGetValue(&args, 0)); waitForClick(); printf("\nTest syscall with invalid buf size."); args.field = MA_PIM_FIELD_CONTACT_ADDR; args.bufSize = 20; printResultCode(maPimItemGetValue(&args, 0)); printf("\nTest syscall with valid parameters."); args.bufSize = 1024; printResultCode(maPimItemGetValue(&args, 0)); delete contact; maPimItemRemove(list, item); maPimListClose(list); waitForClick(); }
ContactScreen::ContactScreen(MainScreen *previous) { this->previous = previous; lprintfln("ContactScreen::Memory Heap %d, Free Heap %d", heapTotalMemory(), heapFreeMemory()); moved = 0; index = -1; isBusy = false; layout = Util::createMainLayout("Search", "Back", "", false); listBox = (KineticListBox*) layout->getChildren()[0]->getChildren()[2]; notice = (Label*) layout->getChildren()[0]->getChildren()[1]; label = new Label(0,0, scrWidth-PADDING*2, 24, NULL, "Enter contact name", 0, Util::getDefaultFont()); listBox->add(label); label = Util::createEditLabel(""); editBoxSearch = new NativeEditBox(0, 0, label->getWidth()-PADDING*2, 48-PADDING*2, 64, MA_TB_TYPE_ANY, label, "",L"Search term:"); #if defined(MA_PROF_SUPPORT_STYLUS) #else editBoxSearch->setInputMode(NativeEditBox::IM_NUMBERS); #endif editBoxSearch->setDrawBackground(false); label->addWidgetListener(this); listBox->add(label); contactListBox = new KineticListBox(0, 0, scrWidth, listBox->getHeight() - editBoxSearch->getParent()->getHeight() - 24, listBox, KineticListBox::LBO_VERTICAL, KineticListBox::LBA_LINEAR, false); this->setMain(layout); listBox->setSelectedIndex(1); editBoxSearch->setSelected(true); //load all the contacts into a list Contact *temp; char *name, *number; String strName, strNumber; MAHandle mContactsListHandle = maPimListOpen(MA_PIM_CONTACTS); MAHandle pimItemHandle = maPimListNext(mContactsListHandle); MA_PIM_ARGS args; args.item = pimItemHandle; args.bufSize = 512; char *mBuffer; mBuffer = new char[512]; args.buf = mBuffer; while (pimItemHandle > 0) { strName = ""; strNumber = ""; args.item = pimItemHandle; int countFields = maPimItemCount(pimItemHandle); if (countFields >= 0) { args.field = MA_PIM_FIELD_CONTACT_NAME; // Get value from name field at position 0. maPimItemGetValue(&args, 0); // there can be up to 8 parts of a name for (int i = 0; i < 8; i++) { const wchar* contactNameValue = Util::getWCharArrayFromBuf(args.buf, i); if (contactNameValue && *contactNameValue != 0) { name = new char[wcslen(contactNameValue)]; memset(name, '\0', wcslen(contactNameValue)); sprintf(name, "%S", contactNameValue); if (strName.length() > 0) { strName.append(", ", 2); } strName.append(name, strlen(name)); delete name; } } //printf("name: %s", strName.c_str()); args.field = MA_PIM_FIELD_CONTACT_TEL; // Get the number of values. int countValues = maPimItemFieldCount(pimItemHandle, MA_PIM_FIELD_CONTACT_TEL); for (int i = 0; i < countValues; i++) { int result = maPimItemGetValue(&args, i); if (result >= 0) { number = new char[wcslen((wchar*) args.buf)]; memset(number, '\0', wcslen((wchar*) args.buf)); sprintf(number, "%S", (wchar*) args.buf); } strNumber = number; temp = new Contact(strName, strNumber); allContacts.add(temp); delete number; //printf("number: %s", strNumber.c_str()); } } maPimItemClose(pimItemHandle); pimItemHandle = maPimListNext(mContactsListHandle); } maPimListClose(mContactsListHandle); }