83 m_storeInfo.m_secondNameSupported = false; |
83 m_storeInfo.m_secondNameSupported = false; |
84 m_storeInfo.m_additionalNumberSupported = false; |
84 m_storeInfo.m_additionalNumberSupported = false; |
85 m_storeInfo.m_emailSupported = false; |
85 m_storeInfo.m_emailSupported = false; |
86 |
86 |
87 // SDN store is allways read only |
87 // SDN store is allways read only |
88 if (m_storeInfo.m_storeName == KParameterValueSimStoreNameSdn) |
88 if (m_storeInfo.m_storeName == KParameterValueSimStoreNameSdn || |
|
89 m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) |
89 m_storeInfo.m_readOnlyAccess = true; |
90 m_storeInfo.m_readOnlyAccess = true; |
90 } |
91 } |
91 |
92 |
92 void CntSimStorePrivate::ConstructL() |
93 void CntSimStorePrivate::ConstructL() |
93 { |
94 { |
102 RTelServer::TPhoneInfo info; |
103 RTelServer::TPhoneInfo info; |
103 User::LeaveIfError(m_etelServer.GetPhoneInfo(0, info)); |
104 User::LeaveIfError(m_etelServer.GetPhoneInfo(0, info)); |
104 User::LeaveIfError(m_etelPhone.Open(m_etelServer, info.iName)); |
105 User::LeaveIfError(m_etelPhone.Open(m_etelServer, info.iName)); |
105 |
106 |
106 // Open Etel store |
107 // Open Etel store |
107 User::LeaveIfError(m_etelStore.Open(m_etelPhone, storeName)); |
108 if (m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) { |
|
109 User::LeaveIfError(m_etelOnStore.Open(m_etelPhone)); |
|
110 } |
|
111 else { |
|
112 User::LeaveIfError(m_etelStore.Open(m_etelPhone, storeName)); |
|
113 } |
108 |
114 |
109 // Update store info |
115 // Update store info |
110 updateStoreInfoL(); |
116 updateStoreInfoL(); |
111 |
117 |
112 // Start listening for events |
118 // Start listening for events |
113 m_listener = new (ELeave) CntSimStoreEventListener(m_engine, m_etelStore); |
119 if (m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) { |
|
120 m_listener = new (ELeave) CntSimStoreEventListener(m_engine, m_etelOnStore); |
|
121 } |
|
122 else { |
|
123 m_listener = new (ELeave) CntSimStoreEventListener(m_engine, m_etelStore); |
|
124 } |
114 m_listener->start(); |
125 m_listener->start(); |
115 } |
126 } |
116 |
127 |
117 CntSimStorePrivate::~CntSimStorePrivate() |
128 CntSimStorePrivate::~CntSimStorePrivate() |
118 { |
129 { |
119 Cancel(); |
130 Cancel(); |
120 delete m_listener; |
131 delete m_listener; |
121 m_etelStore.Close(); |
132 m_etelStore.Close(); |
|
133 m_etelOnStore.Close(); |
122 m_etelPhone.Close(); |
134 m_etelPhone.Close(); |
123 m_etelServer.Close(); |
135 m_etelServer.Close(); |
124 } |
136 } |
125 |
137 |
126 void CntSimStorePrivate::convertStoreNameL(TDes &storeName) |
138 void CntSimStorePrivate::convertStoreNameL(TDes &storeName) |
137 storeName.Copy(KETelIccFdnPhoneBook); |
149 storeName.Copy(KETelIccFdnPhoneBook); |
138 } else if (m_storeInfo.m_storeName == KParameterValueSimStoreNameAdn) { |
150 } else if (m_storeInfo.m_storeName == KParameterValueSimStoreNameAdn) { |
139 storeName.Copy(KETelIccAdnPhoneBook); |
151 storeName.Copy(KETelIccAdnPhoneBook); |
140 } else if (m_storeInfo.m_storeName == KParameterValueSimStoreNameSdn) { |
152 } else if (m_storeInfo.m_storeName == KParameterValueSimStoreNameSdn) { |
141 storeName.Copy(KETelIccSdnPhoneBook); |
153 storeName.Copy(KETelIccSdnPhoneBook); |
|
154 } else if (m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) { |
|
155 storeName.Copy(KETelOwnNumberStore); |
142 } |
156 } |
143 |
157 |
144 // Check that we got a valid store name |
158 // Check that we got a valid store name |
145 if(storeName.Length() == 0) { |
159 if(storeName.Length() == 0) { |
146 User::Leave(KErrArgument); |
160 User::Leave(KErrArgument); |
151 { |
165 { |
152 if (IsActive()) { |
166 if (IsActive()) { |
153 *error = QContactManager::LockedError; |
167 *error = QContactManager::LockedError; |
154 return false; |
168 return false; |
155 } |
169 } |
|
170 |
|
171 // ON store requires different read approach. |
|
172 // fetch ON contacts synchronously since there are usually only couple of them |
|
173 if (m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) { |
|
174 |
|
175 TRequestStatus status; |
|
176 QList<QContact> fetchedContacts; |
|
177 for (int i = index; i <= numSlots; i++) { |
|
178 RMobileONStore::TMobileONEntryV1 onEntry; |
|
179 onEntry.iIndex = i; |
|
180 RMobileONStore::TMobileONEntryV1Pckg onEntryPkg(onEntry); |
|
181 m_etelOnStore.Read(status, onEntryPkg); |
|
182 User::WaitForRequest(status); |
|
183 if (status.Int() == KErrNone) { |
|
184 QContact c; |
|
185 c.setType(QContactType::TypeContact); |
|
186 QContactName name; |
|
187 name.setCustomLabel(QString::fromUtf16(onEntry.iText.Ptr(), |
|
188 onEntry.iText.Length())); |
|
189 c.saveDetail(&name); |
|
190 |
|
191 QContactPhoneNumber number; |
|
192 number.setNumber(QString::fromUtf16(onEntry.iNumber.iTelNumber.Ptr(), |
|
193 onEntry.iNumber.iTelNumber.Length())); |
|
194 c.saveDetail(&number); |
|
195 |
|
196 QScopedPointer<QContactId> contactId(new QContactId()); |
|
197 contactId->setLocalId(i); |
|
198 contactId->setManagerUri(m_managerUri); |
|
199 c.setId(*contactId); |
|
200 fetchedContacts.append(c); |
|
201 } |
|
202 } |
|
203 emit m_simStore.readComplete(fetchedContacts, QContactManager::NoError); |
|
204 *error = QContactManager::NoError; |
|
205 return true; |
|
206 } |
156 |
207 |
157 // start reading |
208 // start reading |
158 m_buffer.Zero(); |
209 m_buffer.Zero(); |
159 m_buffer.ReAlloc(KOneSimContactBufferSize*numSlots); |
210 m_buffer.ReAlloc(KOneSimContactBufferSize*numSlots); |
160 m_etelStore.Read(iStatus, index, numSlots, m_buffer); |
211 m_etelStore.Read(iStatus, index, numSlots, m_buffer); |
|
212 |
161 SetActive(); |
213 SetActive(); |
162 m_state = ReadState; |
214 m_state = ReadState; |
163 |
215 |
164 *error = QContactManager::NoError; |
216 *error = QContactManager::NoError; |
165 return true; |
217 return true; |
705 } |
782 } |
706 |
783 |
707 void CntSimStorePrivate::updateStoreInfoL() |
784 void CntSimStorePrivate::updateStoreInfoL() |
708 { |
785 { |
709 #ifdef SYMBIANSIM_BACKEND_PHONEBOOKINFOV1 |
786 #ifdef SYMBIANSIM_BACKEND_PHONEBOOKINFOV1 |
|
787 TRequestStatus status; |
710 RMobilePhoneBookStore::TMobilePhoneBookInfoV1 info; |
788 RMobilePhoneBookStore::TMobilePhoneBookInfoV1 info; |
711 RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg infoPckg(info); |
789 RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg infoPckg(info); |
712 #else |
|
713 RMobilePhoneBookStore::TMobilePhoneBookInfoV5 info; |
|
714 RMobilePhoneBookStore::TMobilePhoneBookInfoV5Pckg infoPckg(info); |
|
715 #endif |
|
716 |
|
717 // Get info |
|
718 TRequestStatus status; |
|
719 m_etelStore.GetInfo(status, infoPckg); |
790 m_etelStore.GetInfo(status, infoPckg); |
720 User::WaitForRequest(status); |
791 User::WaitForRequest(status); |
721 User::LeaveIfError(status.Int()); |
792 User::LeaveIfError(status.Int()); |
722 |
|
723 // Update entry counts |
|
724 m_storeInfo.m_totalEntries = info.iTotalEntries; |
793 m_storeInfo.m_totalEntries = info.iTotalEntries; |
725 m_storeInfo.m_usedEntries = info.iUsedEntries; |
794 m_storeInfo.m_usedEntries = info.iUsedEntries; |
726 |
795 #else |
|
796 // Get info |
|
797 TRequestStatus status; |
|
798 if (m_storeInfo.m_storeName == KParameterValueSimStoreNameOn) { |
|
799 RMobileONStore::TMobileONStoreInfoV1 onInfo; |
|
800 RMobileONStore::TMobileONStoreInfoV1Pckg onInfoPckg(onInfo); |
|
801 m_etelOnStore.GetInfo(status, onInfoPckg); |
|
802 User::WaitForRequest(status); |
|
803 User::LeaveIfError(status.Int()); |
|
804 |
|
805 // Update entry counts |
|
806 m_storeInfo.m_totalEntries = onInfo.iTotalEntries; |
|
807 m_storeInfo.m_usedEntries = onInfo.iUsedEntries; |
|
808 } |
|
809 else { |
|
810 RMobilePhoneBookStore::TMobilePhoneBookInfoV5 info; |
|
811 RMobilePhoneBookStore::TMobilePhoneBookInfoV5Pckg infoPckg(info); |
|
812 m_etelStore.GetInfo(status, infoPckg); |
|
813 User::WaitForRequest(status); |
|
814 User::LeaveIfError(status.Int()); |
|
815 |
|
816 // Update entry counts |
|
817 m_storeInfo.m_totalEntries = info.iTotalEntries; |
|
818 m_storeInfo.m_usedEntries = info.iUsedEntries; |
|
819 } |
|
820 #endif |
|
821 |
727 #ifdef SYMBIANSIM_BACKEND_TEST_EXTRADETAILS |
822 #ifdef SYMBIANSIM_BACKEND_TEST_EXTRADETAILS |
728 // Check if store supports the extra details |
823 // Check if store supports the extra details |
729 // |
824 // |
730 // NOTE: |
825 // NOTE: |
731 // We cannot rely on TMobilePhoneBookInfoV5 to check if we support |
826 // We cannot rely on TMobilePhoneBookInfoV5 to check if we support |
732 // these details. For example iMaxSecondNames is allways -1 even if the sim |
827 // these details. For example iMaxSecondNames is allways -1 even if the sim |
733 // card supports a second name. |
828 // card supports a second name. |
734 // |
829 // |
735 // There is an API for checking these but it's Nokia internal so we must |
830 // There is an API for checking these but it's Nokia internal so we must |
736 // do it this way - by checking if saving these details is possible. |
831 // do it this way - by checking if saving these details is possible. |
737 |
832 |
738 // Have we checked these already? |
833 // Have we checked these already? |
739 if (m_extraDetailsChecked == false) |
834 if (m_extraDetailsChecked == false) |
740 { |
835 { |
741 // Cannot test extra details if sim card is full |
836 // Cannot test extra details if sim card is full |
742 if (m_storeInfo.m_usedEntries == m_storeInfo.m_totalEntries) |
837 if (m_storeInfo.m_usedEntries == m_storeInfo.m_totalEntries) |