void ConfigImporter::addContactDetails(Contact & contact, void * structVcard) { vcard_t * mVcard = (vcard_t *) structVcard; contact.setFirstName(mVcard->fname); contact.setLastName(mVcard->lname); contact.setCompany(mVcard->company); contact.setBirthdate(Date(mVcard->birthday.day, mVcard->birthday.month, mVcard->birthday.year)); contact.setNotes(mVcard->note); contact.setWebsite(mVcard->website); if (!mVcard->address.city.empty()) { StreetAddress adress; adress.setStreet1(mVcard->address.street); adress.setCity(mVcard->address.city); adress.setPostalCode(mVcard->address.post_code); adress.setStateProvince(mVcard->address.state); adress.setCountry(mVcard->address.country); contact.setStreetAddress(adress); } if (mVcard->gender != UNKNOWN) { contact.setSex(mVcard->gender == MALE ? EnumSex::SexMale : EnumSex::SexFemale); } telNumberIt it; for (it = mVcard->numbers.begin(); it != mVcard->numbers.end(); it++) { if (!(*it)->key.compare(HOME_NUMBER_KEY) && !((*it)->value.empty())) { contact.setHomePhone((*it)->value); } else if (!(*it)->key.compare(WORK_NUMBER_KEY) && !((*it)->value.empty())) { contact.setWorkPhone((*it)->value); } else if (!(*it)->key.compare(CELL_NUMBER_KEY) && !((*it)->value.empty())) { contact.setMobilePhone((*it)->value); } else if (!(*it)->key.compare(FAX_NUMBER_KEY) && !((*it)->value.empty())) { contact.setFax((*it)->value); } else if (!(*it)->key.compare(OTHER_NUMBER_KEY) && !((*it)->value.empty())) { contact.setOtherPhone((*it)->value); } } if (mVcard->emails.size() >= 1 && !mVcard->emails[0].empty()) { contact.setPersonalEmail(mVcard->emails[0]); } if (mVcard->emails.size() >= 2 && !mVcard->emails[1].empty()) { contact.setWorkPhone(mVcard->emails[1]); } if (mVcard->emails.size() >= 3 && !mVcard->emails[2].empty()) { contact.setOtherPhone(mVcard->emails[2]); } }
void CVoxSQLite::GetStreetAddresses( int nProfileId, StreetAddresses& rAddrs ) { CppSQLite3Buffer buf; buf.format( "SELECT * from StreetAddress WHERE profile_id = %d;", nProfileId ); try { CppSQLite3Statement stmt = m_db.compileStatement( (const char*)buf ); int nId = 0; CppSQLite3Query q = stmt.execQuery(); StreetAddress addr; //Process record set. while (!q.eof()) { // "( [profile_id], [type], [street], [locality], [region], [postcode], [country], [visibility] ) " nId = q.getIntField(0); //Not part of Profile. addr.setType ( q.getStringField(1) ); addr.setStreet1 ( q.getStringField(2) ); addr.setCity ( q.getStringField(3) ); addr.setStateProvince( q.getStringField(4) ); addr.setPostalCode ( q.getStringField(5) ); addr.setCountry ( q.getStringField(6) ); addr.setVisibility ( (EnumVisibility::Visibility)q.getIntField(7) ); rAddrs.Add( &addr ); q.nextRow(); } stmt.reset(); } catch (CppSQLite3Exception& e) { e.errorCode(); } }