diff -r e4ebb16b39ea -r 603d3f8b6302 plugins/contacts/symbiansim/src/cntsimstoreprivate.cpp --- a/plugins/contacts/symbiansim/src/cntsimstoreprivate.cpp Fri Sep 17 08:34:34 2010 +0300 +++ b/plugins/contacts/symbiansim/src/cntsimstoreprivate.cpp Mon Oct 04 01:37:06 2010 +0300 @@ -85,7 +85,8 @@ m_storeInfo.m_emailSupported = false; // SDN store is allways read only - if (m_storeInfo.m_storeName == KParameterValueSimStoreNameSdn) + if (m_storeInfo.m_storeName == KParameterValueSimStoreNameSdn || + m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) m_storeInfo.m_readOnlyAccess = true; } @@ -104,13 +105,23 @@ User::LeaveIfError(m_etelPhone.Open(m_etelServer, info.iName)); // Open Etel store - User::LeaveIfError(m_etelStore.Open(m_etelPhone, storeName)); + if (m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) { + User::LeaveIfError(m_etelOnStore.Open(m_etelPhone)); + } + else { + User::LeaveIfError(m_etelStore.Open(m_etelPhone, storeName)); + } // Update store info updateStoreInfoL(); // Start listening for events - m_listener = new (ELeave) CntSimStoreEventListener(m_engine, m_etelStore); + if (m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) { + m_listener = new (ELeave) CntSimStoreEventListener(m_engine, m_etelOnStore); + } + else { + m_listener = new (ELeave) CntSimStoreEventListener(m_engine, m_etelStore); + } m_listener->start(); } @@ -119,6 +130,7 @@ Cancel(); delete m_listener; m_etelStore.Close(); + m_etelOnStore.Close(); m_etelPhone.Close(); m_etelServer.Close(); } @@ -139,6 +151,8 @@ storeName.Copy(KETelIccAdnPhoneBook); } else if (m_storeInfo.m_storeName == KParameterValueSimStoreNameSdn) { storeName.Copy(KETelIccSdnPhoneBook); + } else if (m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) { + storeName.Copy(KETelOwnNumberStore); } // Check that we got a valid store name @@ -154,10 +168,48 @@ return false; } + // ON store requires different read approach. + // fetch ON contacts synchronously since there are usually only couple of them + if (m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) { + + TRequestStatus status; + QList fetchedContacts; + for (int i = index; i <= numSlots; i++) { + RMobileONStore::TMobileONEntryV1 onEntry; + onEntry.iIndex = i; + RMobileONStore::TMobileONEntryV1Pckg onEntryPkg(onEntry); + m_etelOnStore.Read(status, onEntryPkg); + User::WaitForRequest(status); + if (status.Int() == KErrNone) { + QContact c; + c.setType(QContactType::TypeContact); + QContactName name; + name.setCustomLabel(QString::fromUtf16(onEntry.iText.Ptr(), + onEntry.iText.Length())); + c.saveDetail(&name); + + QContactPhoneNumber number; + number.setNumber(QString::fromUtf16(onEntry.iNumber.iTelNumber.Ptr(), + onEntry.iNumber.iTelNumber.Length())); + c.saveDetail(&number); + + QScopedPointer contactId(new QContactId()); + contactId->setLocalId(i); + contactId->setManagerUri(m_managerUri); + c.setId(*contactId); + fetchedContacts.append(c); + } + } + emit m_simStore.readComplete(fetchedContacts, QContactManager::NoError); + *error = QContactManager::NoError; + return true; + } + // start reading m_buffer.Zero(); m_buffer.ReAlloc(KOneSimContactBufferSize*numSlots); m_etelStore.Read(iStatus, index, numSlots, m_buffer); + SetActive(); m_state = ReadState; @@ -172,6 +224,11 @@ return false; } + if (m_storeInfo.m_readOnlyAccess) { + *error = QContactManager::NotSupportedError; + return false; + } + // get index m_writeIndex = KErrNotFound; if (contact.id().managerUri() == m_managerUri && @@ -208,6 +265,11 @@ return false; } + if (m_storeInfo.m_readOnlyAccess) { + *error = QContactManager::NotSupportedError; + return false; + } + // NOTE: // If index points to an empty slot and running in hardware the // delete operation will not return any error. @@ -227,6 +289,13 @@ return false; } + // reserved slots are checked for sim contacts removing, + // this operation is not supported for read only stores + if (m_storeInfo.m_readOnlyAccess) { + *error = QContactManager::NotSupportedError; + return false; + } + // start reading m_buffer.Zero(); m_buffer.ReAlloc(KOneSimContactBufferSize*m_storeInfo.m_totalEntries); @@ -664,6 +733,10 @@ if (IsActive()) User::Leave(KErrLocked); + if (m_storeInfo.m_readOnlyAccess) { + User::Leave(KErrNotSupported); + } + // get index int index = KErrNotFound; if (contact->id().managerUri() == m_managerUri && @@ -694,6 +767,10 @@ if (IsActive()) User::Leave(KErrLocked); + if (m_storeInfo.m_readOnlyAccess) { + User::Leave(KErrNotSupported); + } + // NOTE: // If index points to an empty slot and running in hardware the // delete operation will not return any error. @@ -707,23 +784,41 @@ void CntSimStorePrivate::updateStoreInfoL() { #ifdef SYMBIANSIM_BACKEND_PHONEBOOKINFOV1 + TRequestStatus status; RMobilePhoneBookStore::TMobilePhoneBookInfoV1 info; RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg infoPckg(info); -#else - RMobilePhoneBookStore::TMobilePhoneBookInfoV5 info; - RMobilePhoneBookStore::TMobilePhoneBookInfoV5Pckg infoPckg(info); -#endif - - // Get info - TRequestStatus status; m_etelStore.GetInfo(status, infoPckg); User::WaitForRequest(status); User::LeaveIfError(status.Int()); - - // Update entry counts m_storeInfo.m_totalEntries = info.iTotalEntries; m_storeInfo.m_usedEntries = info.iUsedEntries; - +#else + // Get info + TRequestStatus status; + if (m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) { + RMobileONStore::TMobileONStoreInfoV1 onInfo; + RMobileONStore::TMobileONStoreInfoV1Pckg onInfoPckg(onInfo); + m_etelOnStore.GetInfo(status, onInfoPckg); + User::WaitForRequest(status); + User::LeaveIfError(status.Int()); + + // Update entry counts + m_storeInfo.m_totalEntries = onInfo.iTotalEntries; + m_storeInfo.m_usedEntries = onInfo.iUsedEntries; + } + else { + RMobilePhoneBookStore::TMobilePhoneBookInfoV5 info; + RMobilePhoneBookStore::TMobilePhoneBookInfoV5Pckg infoPckg(info); + m_etelStore.GetInfo(status, infoPckg); + User::WaitForRequest(status); + User::LeaveIfError(status.Int()); + + // Update entry counts + m_storeInfo.m_totalEntries = info.iTotalEntries; + m_storeInfo.m_usedEntries = info.iUsedEntries; + } +#endif + #ifdef SYMBIANSIM_BACKEND_TEST_EXTRADETAILS // Check if store supports the extra details // @@ -734,7 +829,7 @@ // // There is an API for checking these but it's Nokia internal so we must // do it this way - by checking if saving these details is possible. - + // Have we checked these already? if (m_extraDetailsChecked == false) {