141 iBearerPriorityCache = CCmmBearerPriorityCache::NewL( |
144 iBearerPriorityCache = CCmmBearerPriorityCache::NewL( |
142 iTrans, |
145 iTrans, |
143 iCmManagerImpl->TableId( ECmmDbBearerPriorityRecord ) ); |
146 iCmManagerImpl->TableId( ECmmDbBearerPriorityRecord ) ); |
144 iListenerManager = CCmmListenerManager::NewL( this ); |
147 iListenerManager = CCmmListenerManager::NewL( this ); |
145 iInstanceMapping = CCmmInstanceMapping::NewL( *this ); |
148 iInstanceMapping = CCmmInstanceMapping::NewL( *this ); |
|
149 |
|
150 // Create CommsDat listeners to detect changes to the database from external sources. |
|
151 RArray<TUint32> tableIdArray; |
|
152 CleanupClosePushL( tableIdArray ); |
|
153 |
|
154 iSnapTableId = iCmManagerImpl->TableId( ECmmDbSnapRecord ); |
|
155 iSnapMetadataTableId = iCmManagerImpl->TableId( ECmmDestMetadataRecord ); |
|
156 |
|
157 // Instancemapping needs notifications on following tables. |
|
158 tableIdArray.Append( CommsDat::KCDTIdIAPRecord ); |
|
159 tableIdArray.Append( CommsDat::KCDTIdVPNServiceRecord ); |
|
160 tableIdArray.Append( iSnapTableId ); |
|
161 tableIdArray.Append( iSnapMetadataTableId ); |
|
162 |
|
163 // Destinations need notifications on following tables. |
|
164 tableIdArray.Append( CommsDat::KCDTIdNetworkRecord ); |
|
165 tableIdArray.Append( CommsDat::KCDTIdAccessPointRecord ); |
|
166 // Destination metadata table was already added. |
|
167 |
|
168 // Connection methods need notifications on following tables. |
|
169 TInt pluginCount( iPlugins->Count() ); |
|
170 if ( pluginCount ) |
|
171 { |
|
172 ( *iPlugins )[0]->GetGenericTableIdsToBeObservedL( tableIdArray ); |
|
173 for( TInt i = 0; i < pluginCount; i++ ) |
|
174 { |
|
175 ( *iPlugins )[i]->GetBearerTableIdsToBeObservedL( tableIdArray ); |
|
176 } |
|
177 } |
|
178 |
|
179 for ( TInt i = 0; i < tableIdArray.Count(); i++ ) |
|
180 { |
|
181 iListenerManager->AddListenerL( tableIdArray[i] ); |
|
182 } |
|
183 CleanupStack::PopAndDestroy( &tableIdArray ); |
146 |
184 |
147 OstTraceFunctionExit0( CCMMCACHE_CONSTRUCTL_EXIT ); |
185 OstTraceFunctionExit0( CCMMCACHE_CONSTRUCTL_EXIT ); |
148 } |
186 } |
149 |
187 |
150 // --------------------------------------------------------------------------- |
188 // --------------------------------------------------------------------------- |
268 // Check connection method ID. |
306 // Check connection method ID. |
269 TBool validAttributes( EFalse ); |
307 TBool validAttributes( EFalse ); |
270 if ( !aDestinationInstance ) |
308 if ( !aDestinationInstance ) |
271 { |
309 { |
272 // Check connection method exists in database. |
310 // Check connection method exists in database. |
273 validAttributes = iInstanceMapping->ValidConnMethodId( aConnMethodId ); // Embedded destinations not included. |
311 // Embedded destinations not included. |
|
312 validAttributes = iInstanceMapping->ValidConnMethodId( aConnMethodId ); |
274 } |
313 } |
275 else |
314 else |
276 { |
315 { |
277 // Check connection method is inside the destination. |
316 // Check connection method is inside the destination. |
278 if ( aDestinationInstance->ValidConnMethodIdInDestinationIncludeEmbedded( aConnMethodId ) ) |
317 if ( aDestinationInstance-> |
279 { |
318 ValidConnMethodIdInDestinationIncludeEmbedded( aConnMethodId ) ) |
280 // Check connection method (can be embedded destination too) exists in database. |
319 { |
|
320 // Check connection method (can be embedded destination too) |
|
321 // exists in database. |
281 if ( iInstanceMapping->ValidConnMethodId( aConnMethodId ) || |
322 if ( iInstanceMapping->ValidConnMethodId( aConnMethodId ) || |
282 iInstanceMapping->ValidDestinationId( aConnMethodId ) ) |
323 iInstanceMapping->ValidDestinationId( aConnMethodId ) ) |
283 { |
324 { |
284 validAttributes = ETrue; |
325 validAttributes = ETrue; |
285 } |
326 } |
294 |
335 |
295 // Check if connection method is already opened in cache. |
336 // Check if connection method is already opened in cache. |
296 TInt index = FindConnMethodFromCache( aConnMethodId ); |
337 TInt index = FindConnMethodFromCache( aConnMethodId ); |
297 if ( index != KErrNotFound ) |
338 if ( index != KErrNotFound ) |
298 { |
339 { |
|
340 // Update data from commsdat if necessary. |
|
341 if ( iConnMethodArray[index]->GetRecordStatus() == ECmmRecordStatusExpired ) |
|
342 { |
|
343 iConnMethodArray[index]->ReloadPluginDataIfNeededL(); |
|
344 // CopyDataL() will set the internal state of aConnMethodInstance. |
|
345 } |
|
346 |
299 // Already open in cache. Copy the connection method data to session |
347 // Already open in cache. Copy the connection method data to session |
300 // instance. |
348 // instance. |
301 aConnMethodInstance.CopyDataL( iConnMethodArray[index] ); // Will increase reference counter. |
349 // Will increase reference counter. |
|
350 aConnMethodInstance.CopyDataL( iConnMethodArray[index] ); |
302 } |
351 } |
303 else |
352 else |
304 { |
353 { |
305 // Not yet open in cache, open now. |
354 // Not yet open in cache, open now. |
306 OpenConnectionMethodInstanceL( aConnMethodInstance, aConnMethodId ); |
355 OpenConnectionMethodInstanceL( aConnMethodInstance, aConnMethodId ); |
473 |
530 |
474 OstTraceFunctionExit0( CCMMCACHE_CREATECOPYOFCONNMETHODL_EXIT ); |
531 OstTraceFunctionExit0( CCMMCACHE_CREATECOPYOFCONNMETHODL_EXIT ); |
475 } |
532 } |
476 |
533 |
477 // --------------------------------------------------------------------------- |
534 // --------------------------------------------------------------------------- |
478 // Re-loads a destination record if needed and copies the latest version to |
535 // Reloads a destination record if needed and copies the latest version to |
479 // the session instance given as parameter. |
536 // the session instance given as parameter. |
480 // --------------------------------------------------------------------------- |
537 // --------------------------------------------------------------------------- |
481 // |
538 // |
482 void CCmmCache::LoadDestinationRecordL( |
539 void CCmmCache::LoadDestinationRecordL( |
483 CCmmDestinationInstance& aDestinationInstance, |
540 CCmmDestinationInstance& aDestinationInstance, |
1616 // has possibly changed, the cache will refresh that information immediately. |
1673 // has possibly changed, the cache will refresh that information immediately. |
1617 // For other database tables, the tables are flagged and will be refreshed when |
1674 // For other database tables, the tables are flagged and will be refreshed when |
1618 // needed. |
1675 // needed. |
1619 // --------------------------------------------------------------------------- |
1676 // --------------------------------------------------------------------------- |
1620 // |
1677 // |
1621 void CCmmCache::DbChangeDetected( const TUint32 aTableId ) |
1678 void CCmmCache::DbChangeDetectedL( const TUint32 aTableId ) |
1622 { |
1679 { |
1623 OstTraceFunctionEntry0( CCMMCACHE_DBCHANGEDETECTED_ENTRY ); |
1680 OstTraceFunctionEntry0( CCMMCACHE_DBCHANGEDETECTED_ENTRY ); |
1624 |
1681 |
1625 (void)aTableId; //TODO |
1682 if ( aTableId == iSnapMetadataTableId ) |
1626 // Flag the table as: currently not up-to-date |
1683 { |
|
1684 for ( TInt i = 0; i < iDestinationArray.Count(); i++ ) |
|
1685 { |
|
1686 iDestinationArray[i]->NotifyRecordChange( ECmmDestMetadataRecord ); |
|
1687 } |
|
1688 } |
|
1689 else if ( aTableId == CommsDat::KCDTIdNetworkRecord ) |
|
1690 { |
|
1691 // Affects destinations. |
|
1692 for ( TInt i = 0; i < iDestinationArray.Count(); i++ ) |
|
1693 { |
|
1694 iDestinationArray[i]->NotifyRecordChange( ECmmDestNetworkRecord ); |
|
1695 } |
|
1696 } |
|
1697 else if ( aTableId == CommsDat::KCDTIdAccessPointRecord ) |
|
1698 { |
|
1699 // Affects destinations. |
|
1700 for ( TInt i = 0; i < iDestinationArray.Count(); i++ ) |
|
1701 { |
|
1702 iDestinationArray[i]->NotifyRecordChange( ECmmDestApRecord ); |
|
1703 } |
|
1704 } |
|
1705 |
|
1706 // Notify Connection Methods about the table changes in CommsDat. |
|
1707 NotifyPluginsForTableChangesL( aTableId ); |
|
1708 |
|
1709 // Update instancemapping. |
|
1710 iInstanceMapping->RefreshL(); |
|
1711 |
1627 OstTraceFunctionExit0( CCMMCACHE_DBCHANGEDETECTED_EXIT ); |
1712 OstTraceFunctionExit0( CCMMCACHE_DBCHANGEDETECTED_EXIT ); |
|
1713 } |
|
1714 |
|
1715 // --------------------------------------------------------------------------- |
|
1716 // Informs all the loaded iaps if something related to their tables |
|
1717 // changed in commsdat. |
|
1718 // --------------------------------------------------------------------------- |
|
1719 // |
|
1720 void CCmmCache::NotifyPluginsForTableChangesL( const TUint32 aTableId ) |
|
1721 { |
|
1722 OstTraceFunctionEntry0( CCMMCACHE_NOTIFYPLUGINSFORTABLECHANGESL_ENTRY ); |
|
1723 |
|
1724 if ( iConnMethodArray.Count() ) |
|
1725 { |
|
1726 RArray<TUint32> tableIdArray; |
|
1727 CleanupClosePushL( tableIdArray ); |
|
1728 |
|
1729 // Check if change concerns some table generic for all iaps |
|
1730 ( *iPlugins )[0]->GetGenericTableIdsToBeObservedL( tableIdArray ); |
|
1731 TBool generic( EFalse ); |
|
1732 for( TInt i = 0; i < tableIdArray.Count(); i++ ) |
|
1733 { |
|
1734 if ( aTableId == tableIdArray[i] ) |
|
1735 { |
|
1736 generic = ETrue; |
|
1737 break; |
|
1738 } |
|
1739 } |
|
1740 |
|
1741 if ( generic ) |
|
1742 { |
|
1743 // generic-->Notify all iaps |
|
1744 for( TInt i = 0; i < iConnMethodArray.Count(); i++ ) |
|
1745 { |
|
1746 iConnMethodArray[i]->NotifyRecordChange( aTableId ); |
|
1747 } |
|
1748 } |
|
1749 else |
|
1750 { |
|
1751 // Not generic: Check bearer specific tables |
|
1752 RArray<TUint32> affectedBearersArray; |
|
1753 CleanupClosePushL( affectedBearersArray ); |
|
1754 for( TInt i = 0; i < iPlugins->Count(); i++ ) |
|
1755 { |
|
1756 tableIdArray.Reset(); |
|
1757 ( *iPlugins )[i]->GetBearerTableIdsToBeObservedL( tableIdArray ); |
|
1758 TInt idCount = tableIdArray.Count(); |
|
1759 for( TInt j = 0; j < idCount; j++ ) |
|
1760 { |
|
1761 if ( aTableId == tableIdArray[j] ) |
|
1762 { |
|
1763 // Save the bearer type id which is affected |
|
1764 affectedBearersArray.AppendL( |
|
1765 ( *iPlugins )[i]->GetBearerInfoIntL( |
|
1766 CMManager::ECmBearerType ) ); |
|
1767 } |
|
1768 } |
|
1769 } |
|
1770 |
|
1771 // Go through all the loaded iaps and notify all the iaps |
|
1772 // which have the same bearer type saved above |
|
1773 for( TInt i = 0; i < iConnMethodArray.Count(); i++ ) |
|
1774 { |
|
1775 for( TInt j = 0; j < affectedBearersArray.Count(); j++ ) |
|
1776 { |
|
1777 if ( iConnMethodArray[i]->GetBearerType() == affectedBearersArray[j] ) |
|
1778 { |
|
1779 iConnMethodArray[i]->NotifyRecordChange( aTableId ); |
|
1780 break; |
|
1781 } |
|
1782 } |
|
1783 } |
|
1784 CleanupStack::PopAndDestroy( &affectedBearersArray ); |
|
1785 } |
|
1786 CleanupStack::PopAndDestroy( &tableIdArray ); |
|
1787 } |
|
1788 OstTraceFunctionExit0( CCMMCACHE_NOTIFYPLUGINSFORTABLECHANGESL_EXIT ); |
1628 } |
1789 } |
1629 |
1790 |
1630 // --------------------------------------------------------------------------- |
1791 // --------------------------------------------------------------------------- |
1631 // Tells the cache that an error has occured with a database listener. Any |
1792 // Tells the cache that an error has occured with a database listener. Any |
1632 // reads to this table need go through the database, since cache can't know if |
1793 // reads to this table need go through the database, since cache can't know if |
1637 { |
1798 { |
1638 OstTraceFunctionEntry0( CCMMCACHE_DBCHANGEERROR_ENTRY ); |
1799 OstTraceFunctionEntry0( CCMMCACHE_DBCHANGEERROR_ENTRY ); |
1639 |
1800 |
1640 (void)aTableId; //TODO |
1801 (void)aTableId; //TODO |
1641 // Flag the table as: permanently not up-to-date |
1802 // Flag the table as: permanently not up-to-date |
|
1803 |
|
1804 //TODO, How to do this? |
|
1805 // Implement some 'status locked' flags that are always checked before changing status back to 'loaded' after reading database? |
|
1806 // Or move record status info to CCmmCache-class? |
|
1807 // What about plugins? |
|
1808 // Or just ignore errors with notifiers? |
|
1809 |
|
1810 // For now, just ignore errors. |
|
1811 |
1642 OstTraceFunctionExit0( CCMMCACHE_DBCHANGEERROR_EXIT ); |
1812 OstTraceFunctionExit0( CCMMCACHE_DBCHANGEERROR_EXIT ); |
1643 } |
1813 } |
1644 |
1814 |
1645 // --------------------------------------------------------------------------- |
1815 // --------------------------------------------------------------------------- |
1646 // Tells the cache that a hadle to a destination was closed. The cache will |
1816 // Tells the cache that a hadle to a destination was closed. The cache will |
2126 { |
2296 { |
2127 OstTraceFunctionEntry0( CCMMCACHE_OPENCONNECTIONMETHODINSTANCEL_ENTRY ); |
2297 OstTraceFunctionEntry0( CCMMCACHE_OPENCONNECTIONMETHODINSTANCEL_ENTRY ); |
2128 |
2298 |
2129 // Find out the connection method bearer type. |
2299 // Find out the connection method bearer type. |
2130 TUint32 bearerType( 0 ); |
2300 TUint32 bearerType( 0 ); |
2131 User::LeaveIfError( iInstanceMapping->GetConnMethodBearerType( aConnMethodId, bearerType ) ); |
2301 User::LeaveIfError( iInstanceMapping-> |
|
2302 GetConnMethodBearerType( aConnMethodId, bearerType ) ); |
2132 |
2303 |
2133 // Check bearer type support and create plugin instance. |
2304 // Check bearer type support and create plugin instance. |
2134 CCmPluginBaseEng* plugin = NULL; |
2305 CCmPluginBaseEng* plugin = NULL; |
2135 for ( TInt i = 0; i < iPlugins->Count(); i++ ) |
2306 for ( TInt i = 0; i < iPlugins->Count(); i++ ) |
2136 { |
2307 { |
2137 if ( ( *iPlugins )[i]->GetBearerInfoIntL( CMManager::ECmBearerType ) == bearerType ) |
2308 if ( ( *iPlugins )[i]->GetBearerInfoIntL( |
|
2309 CMManager::ECmBearerType ) == bearerType ) |
2138 { |
2310 { |
2139 TCmPluginInitParam pluginParams( Session() ); |
2311 TCmPluginInitParam pluginParams( Session() ); |
2140 plugin = ( *iPlugins )[i]->CreateInstanceL( pluginParams ); |
2312 plugin = ( *iPlugins )[i]->CreateInstanceL( pluginParams ); |
2141 CleanupStack::PushL( plugin ); |
2313 CleanupStack::PushL( plugin ); |
2142 plugin->LoadL( aConnMethodId ); |
2314 plugin->LoadL( aConnMethodId ); |