24 #include <commdb.h> |
24 #include <commdb.h> |
25 #include <etel3rdparty.h> // Voice call notification |
25 #include <etel3rdparty.h> // Voice call notification |
26 #include <mmtsy_names.h> // KMmTsyModuleName |
26 #include <mmtsy_names.h> // KMmTsyModuleName |
27 #include <centralrepository.h> |
27 #include <centralrepository.h> |
28 #include <es_sock_partner.h> |
28 #include <es_sock_partner.h> |
|
29 #include <CoreApplicationUIsSDKCRKeys.h> |
29 |
30 |
30 #include "mpmserver.h" |
31 #include "mpmserver.h" |
31 #include "mpmserversession.h" |
32 #include "mpmserversession.h" |
32 #include "mpmconnmonevents.h" |
33 #include "mpmconnmonevents.h" |
33 #include "mpmlogger.h" |
34 #include "mpmlogger.h" |
42 #include "mpmdialog.h" |
43 #include "mpmdialog.h" |
43 #include "mpmprivatecrkeys.h" |
44 #include "mpmprivatecrkeys.h" |
44 #include "mpmcsidwatcher.h" |
45 #include "mpmcsidwatcher.h" |
45 #include "mpmdatausagewatcher.h" |
46 #include "mpmdatausagewatcher.h" |
46 #include "mpmpropertydef.h" |
47 #include "mpmpropertydef.h" |
|
48 #include "mpmofflinewatcher.h" |
47 |
49 |
48 // ============================= LOCAL FUNCTIONS =============================== |
50 // ============================= LOCAL FUNCTIONS =============================== |
49 |
51 |
50 // ----------------------------------------------------------------------------- |
52 // ----------------------------------------------------------------------------- |
51 // PanicServer |
53 // PanicServer |
89 iRoamingQueue( NULL ), |
91 iRoamingQueue( NULL ), |
90 iStartingQueue( NULL ), |
92 iStartingQueue( NULL ), |
91 iWlanQueryQueue( NULL ), |
93 iWlanQueryQueue( NULL ), |
92 iConnectDialogQueue( NULL ), |
94 iConnectDialogQueue( NULL ), |
93 iDefaultConnection( NULL ), |
95 iDefaultConnection( NULL ), |
94 iConnectionCounter( 0 ) |
96 iConnectionCounter( 0 ), |
|
97 iOfflineMode( ECoreAppUIsNetworkConnectionAllowed ) |
95 { |
98 { |
96 } |
99 } |
97 |
100 |
98 |
101 |
99 // ----------------------------------------------------------------------------- |
102 // ----------------------------------------------------------------------------- |
173 // Create central repository watcher and start it |
176 // Create central repository watcher and start it |
174 iMpmCsIdWatcher = CMpmCsIdWatcher::NewL(); |
177 iMpmCsIdWatcher = CMpmCsIdWatcher::NewL(); |
175 iMpmCsIdWatcher->StartL(); |
178 iMpmCsIdWatcher->StartL(); |
176 |
179 |
177 // Create another central repository watcher and start it |
180 // Create another central repository watcher and start it |
178 // TODO: Trapped, because currently it may fatally leave in HW. |
|
179 // (Possibly because of the capability updates of data usage watcher's CR-keys.) |
|
180 TRAPD( duwErr, iMpmDataUsageWatcher = CMpmDataUsageWatcher::NewL( this ) ); |
181 TRAPD( duwErr, iMpmDataUsageWatcher = CMpmDataUsageWatcher::NewL( this ) ); |
181 if (duwErr == KErrNone) |
182 if (duwErr == KErrNone) |
182 { |
183 { |
183 iMpmDataUsageWatcher->StartL(); |
184 iMpmDataUsageWatcher->StartL(); |
184 } |
185 } |
185 else |
186 else |
186 { |
187 { |
187 iMpmDataUsageWatcher = NULL; |
188 iMpmDataUsageWatcher = NULL; |
188 MPMLOGSTRING( "CMPMServer::ConstructL: CMpmDataUsageWatcher::NewL() failed!" ) |
189 MPMLOGSTRING( "CMPMServer::ConstructL: CMpmDataUsageWatcher::NewL() failed!" ) |
|
190 } |
|
191 |
|
192 // Create another central repository watcher and start it |
|
193 TRAPD( owErr, iMpmOfflineWatcher = CMpmOfflineWatcher::NewL( this ) ); |
|
194 if (owErr == KErrNone) |
|
195 { |
|
196 iMpmOfflineWatcher->StartL(); |
|
197 } |
|
198 else |
|
199 { |
|
200 iMpmOfflineWatcher = NULL; |
|
201 MPMLOGSTRING( "CMPMServer::ConstructL: CMpmOfflineWatcher::NewL() failed!" ) |
189 } |
202 } |
190 |
203 |
191 // Define P&S keys (snap & iap) for the user connection |
204 // Define P&S keys (snap & iap) for the user connection |
192 TInt ret = RProperty::Define( KMPMUserConnectionCategory, |
205 TInt ret = RProperty::Define( KMPMUserConnectionCategory, |
193 KMPMPSKeyUserConnectionSnap, |
206 KMPMPSKeyUserConnectionSnap, |
1528 // CMPMServer::StopConnections |
1510 // CMPMServer::StopConnections |
1529 // ----------------------------------------------------------------------------- |
1511 // ----------------------------------------------------------------------------- |
1530 // |
1512 // |
1531 void CMPMServer::StopConnections( TInt aIapId ) |
1513 void CMPMServer::StopConnections( TInt aIapId ) |
1532 { |
1514 { |
|
1515 MPMLOGSTRING2( "CMPMServer::StopConnections aIapId = %d", aIapId ) |
1533 for (TInt index = 0; index < iSessions.Count(); index++) |
1516 for (TInt index = 0; index < iSessions.Count(); index++) |
1534 { |
1517 { |
1535 /* if (iSessions[index]->UserConnection()) |
1518 CMPMServerSession* session = iSessions[index]; |
1536 continue; |
|
1537 */ |
|
1538 // Stop connection |
1519 // Stop connection |
1539 if ( aIapId == 0 ) |
1520 if ( aIapId == 0 ) |
1540 { |
1521 { |
1541 iSessions[index]->StopConnection(); |
1522 session->StopConnection(); |
1542 } |
1523 } |
1543 else |
1524 else if ( GetBMIap( session->ConnectionId() ) == aIapId ) |
1544 { |
1525 { |
1545 TRAP_IGNORE( iSessions[index]->StopIAPNotificationL( aIapId )); |
1526 TRAP_IGNORE( session->StopIAPNotificationL( aIapId )); |
1546 } |
1527 } |
1547 |
1528 } |
1548 } |
1529 } |
|
1530 |
|
1531 // ----------------------------------------------------------------------------- |
|
1532 // CMPMServer::UpdateActiveConnection |
|
1533 // ----------------------------------------------------------------------------- |
|
1534 // |
|
1535 void CMPMServer::UpdateActiveConnection( CMPMServerSession& aSession ) |
|
1536 { |
|
1537 // Update active connection |
|
1538 TInt ret = KErrNone; |
|
1539 |
|
1540 TRAP ( ret, UpdateActiveConnectionL( aSession ) ); |
|
1541 |
|
1542 if ( ret != KErrNone ) |
|
1543 { |
|
1544 iActiveBearerType = EMPMBearerTypeNone; |
|
1545 iActiveIapId = 0; |
|
1546 iActiveSnapId = 0; |
|
1547 } |
1549 } |
1548 } |
1550 |
1549 |
1551 // ----------------------------------------------------------------------------- |
1550 // ----------------------------------------------------------------------------- |
1552 // CMPMServer::UpdateActiveConnectionL |
1551 // CMPMServer::UpdateActiveConnectionL |
1553 // ----------------------------------------------------------------------------- |
1552 // ----------------------------------------------------------------------------- |
1554 // |
1553 // |
1555 void CMPMServer::UpdateActiveConnectionL( CMPMServerSession& aSession ) |
1554 void CMPMServer::UpdateActiveConnectionL( CMPMServerSession& aSession ) |
1556 { |
1555 { |
1557 MPMLOGSTRING( "CMPMServer::UpdateActiveConnectionL" ) |
1556 MPMLOGSTRING( "CMPMServer::UpdateActiveConnectionL" ) |
1558 TUint32 snapId; |
1557 |
1559 |
1558 TBool keysUpToDate( ETrue ); |
1560 if ( !NumberOfActiveConnections() ) |
1559 |
|
1560 // number of active iaps |
|
1561 TInt numberOfActive = NumberOfActiveConnections( keysUpToDate ); |
|
1562 |
|
1563 if ( numberOfActive == 0 ) |
1561 { |
1564 { |
1562 // If no active connections then just reset keys and publish |
1565 // If no active connections then just reset keys and publish |
1563 iActiveBearerType = EMPMBearerTypeNone; |
1566 iActiveBearerType = EMPMBearerTypeNone; |
1564 iActiveIapId = 0; |
1567 iActiveIapId = 0; |
1565 iActiveSnapId = 0; |
1568 iActiveSnapId = 0; |
1566 PublishActiveConnection(); |
1569 PublishActiveConnection(); |
1567 return; |
1570 return; |
1568 } |
1571 } |
1569 |
1572 |
1570 // Check if all active connections are in same snap |
1573 if ( keysUpToDate ) |
1571 if ( CommsDatAccess()->AreActiveIapsInSameSnapL( |
1574 { |
1572 iActiveBMConns, snapId ) ) |
1575 MPMLOGSTRING( "CMPMServer::UpdateActiveConnectionL: already up-to-date" ) |
1573 { |
1576 return; |
1574 // Select active connection according to priority |
1577 } |
1575 CommsDatAccess()->SelectActiveConnectionL ( |
1578 |
1576 snapId, |
1579 if ( numberOfActive > 1 ) |
1577 iActiveBMConns, |
1580 { |
1578 iActiveIapId, |
1581 // Check if all active connections are in same snap |
1579 iActiveSnapId, |
1582 TUint32 snapId; |
1580 iActiveBearerType, |
1583 |
1581 aSession ); |
1584 if ( CommsDatAccess()->AreActiveIapsInSameSnapL( |
1582 |
1585 iActiveBMConns, snapId, *this ) ) |
1583 PublishActiveConnection(); |
1586 { |
1584 return; |
1587 MPMLOGSTRING( "CMPMServer::UpdateActiveConnectionL: Active iaps are in one SNAP" ) |
|
1588 // Select active connection according to priority |
|
1589 CommsDatAccess()->SelectActiveConnectionL ( |
|
1590 snapId, |
|
1591 iActiveBMConns, |
|
1592 iActiveIapId, |
|
1593 iActiveSnapId, |
|
1594 iActiveBearerType, |
|
1595 aSession ); |
|
1596 |
|
1597 PublishActiveConnection(); |
|
1598 return; |
|
1599 } |
|
1600 |
|
1601 MPMLOGSTRING( "CMPMServer::UpdateActiveConnectionL: Active iaps are in different SNAPs" ) |
1585 } |
1602 } |
1586 |
1603 |
1587 // Reset active connections |
1604 // Reset active connections |
1588 iActiveBearerType = EMPMBearerTypeNone; |
1605 iActiveBearerType = EMPMBearerTypeNone; |
1589 iActiveIapId = 0; |
1606 iActiveIapId = 0; |
1590 iActiveSnapId = 0; |
1607 iActiveSnapId = 0; |
1591 |
1608 |
1592 // Active connections locating in different snaps |
1609 // Active connections locating in different snaps |
1593 // Use priority order vpn, wlan and packet |
1610 // Use priority order vpn, wlan and packet |
1594 for ( TInt index = 0; index < iActiveBMConns.Count(); index++ ) |
1611 for ( TInt index = 0; index < iActiveBMConns.Count(); index++ ) |
1595 { |
1612 { |
1596 CMPMServerSession* serverSession = GetServerSession( |
1613 CMPMServerSession* serverSession = GetServerSession( |
1600 if ( iActiveBMConns[index].iConnInfo.iState == EStarted && |
1617 if ( iActiveBMConns[index].iConnInfo.iState == EStarted && |
1601 serverSession->ChooseBestIapCalled() ) |
1618 serverSession->ChooseBestIapCalled() ) |
1602 { |
1619 { |
1603 TMPMBearerType bearerType = EMPMBearerTypeOther; |
1620 TMPMBearerType bearerType = EMPMBearerTypeOther; |
1604 |
1621 |
1605 if ( iDedicatedClients.Find( iActiveBMConns[index].iConnInfo.iAppUid ) == |
1622 TInt ret = iDedicatedClients.Find( iActiveBMConns[index].iConnInfo.iAppUid ); |
1606 KErrNone ) |
1623 if ( ret != KErrNotFound ) |
1607 { |
1624 { |
1608 // Skip dedicated client |
1625 // Skip dedicated client |
|
1626 MPMLOGSTRING2( "Skip dedicated client = %d", iActiveBMConns[index].iConnInfo.iAppUid ) |
1609 continue; |
1627 continue; |
1610 } |
1628 } |
1611 |
1629 |
1612 bearerType = CommsDatAccess()->GetBearerTypeL( |
1630 bearerType = CommsDatAccess()->GetBearerTypeL( |
1613 iActiveBMConns[index].iConnInfo.iIapId ); |
1631 iActiveBMConns[index].iConnInfo.iIapId ); |
1695 iActiveIapId, iActiveSnapId, iActiveBearerType ) |
1712 iActiveIapId, iActiveSnapId, iActiveBearerType ) |
1696 } |
1713 } |
1697 |
1714 |
1698 // ----------------------------------------------------------------------------- |
1715 // ----------------------------------------------------------------------------- |
1699 // CMPMServer::NumberOfActiveConnections |
1716 // CMPMServer::NumberOfActiveConnections |
1700 // ----------------------------------------------------------------------------- |
1717 // Returns number of active iaps. |
1701 // |
1718 // ----------------------------------------------------------------------------- |
1702 TInt CMPMServer::NumberOfActiveConnections() |
1719 // |
|
1720 TInt CMPMServer::NumberOfActiveConnections( TBool& aKeysUpToDate ) |
1703 { |
1721 { |
1704 MPMLOGSTRING( "CMPMServer::NumberOfActiveConnections" ) |
1722 MPMLOGSTRING( "CMPMServer::NumberOfActiveConnections" ) |
1705 |
1723 |
|
1724 aKeysUpToDate = ETrue; |
1706 TInt count( 0 ); |
1725 TInt count( 0 ); |
|
1726 RArray<TUint32> activeIaps; |
|
1727 |
|
1728 activeIaps.Reset(); |
1707 |
1729 |
1708 for ( TInt index = 0; index < iActiveBMConns.Count(); index++ ) |
1730 for ( TInt index = 0; index < iActiveBMConns.Count(); index++ ) |
1709 { |
1731 { |
1710 CMPMServerSession* serverSession = GetServerSession( |
1732 CMPMServerSession* serverSession = GetServerSession( |
1711 iActiveBMConns[index].iConnInfo.iConnId ); |
1733 iActiveBMConns[index].iConnInfo.iConnId ); |
1712 |
1734 |
1713 if ( iActiveBMConns[index].iConnInfo.iState == EStarted && |
1735 if ( iActiveBMConns[index].iConnInfo.iState == EStarted && |
1714 serverSession->ChooseBestIapCalled() ) |
1736 serverSession->ChooseBestIapCalled() ) |
1715 { |
1737 { |
1716 count++; |
1738 TInt ret = activeIaps.Find( iActiveBMConns[index].iConnInfo.iIapId ); |
1717 } |
1739 |
1718 } |
1740 if ( ret == KErrNotFound ) |
|
1741 { |
|
1742 activeIaps.Append ( iActiveBMConns[index].iConnInfo.iIapId ); |
|
1743 count++; |
|
1744 } |
|
1745 |
|
1746 if ( iActiveIapId != iActiveBMConns[index].iConnInfo.iIapId ) |
|
1747 { |
|
1748 // iap that is different from current active iap was found |
|
1749 aKeysUpToDate = EFalse; |
|
1750 } |
|
1751 } |
|
1752 } |
|
1753 |
|
1754 activeIaps.Close(); |
|
1755 MPMLOGSTRING2( "CMPMServer::NumberOfActiveConnections: count = %d", count ) |
1719 |
1756 |
1720 return count; |
1757 return count; |
1721 } |
1758 } |
1722 |
1759 |
1723 // ----------------------------------------------------------------------------- |
1760 // ----------------------------------------------------------------------------- |
2081 } |
2118 } |
2082 } |
2119 } |
2083 stoppedIaps.Close(); |
2120 stoppedIaps.Close(); |
2084 } |
2121 } |
2085 |
2122 |
|
2123 // --------------------------------------------------------------------------- |
|
2124 // CMPMServer::UpdateOfflineMode |
|
2125 // Offline watcher listens the offline mode and calls this when it's changed. |
|
2126 // --------------------------------------------------------------------------- |
|
2127 // |
|
2128 void CMPMServer::UpdateOfflineMode( TInt newModeValue ) |
|
2129 { |
|
2130 MPMLOGSTRING2( "CMPMServer::UpdateOfflineMode: Value %d", newModeValue ) |
|
2131 |
|
2132 iOfflineMode = newModeValue; |
|
2133 |
|
2134 if ( iOfflineMode == ECoreAppUIsNetworkConnectionAllowed ) |
|
2135 { |
|
2136 // Offline mode finished, reset the QueryResponse variable. |
|
2137 iOfflineWlanQueryResponse = EOfflineResponseUndefined; |
|
2138 } |
|
2139 } |
|
2140 |
|
2141 // --------------------------------------------------------------------------- |
|
2142 // CMPMServer::IsPhoneOffline |
|
2143 // Returns the current offline mode. |
|
2144 // --------------------------------------------------------------------------- |
|
2145 // |
|
2146 TBool CMPMServer::IsPhoneOffline() |
|
2147 { |
|
2148 MPMLOGSTRING( "CMPMServer::IsPhoneOffline" ) |
|
2149 |
|
2150 TBool retval = EFalse; |
|
2151 if ( iOfflineMode == ECoreAppUIsNetworkConnectionNotAllowed) |
|
2152 { |
|
2153 retval = ETrue; |
|
2154 MPMLOGSTRING( "CMPMServer::IsPhoneOffline: Yes." ) |
|
2155 } |
|
2156 return retval; |
|
2157 } |
|
2158 |
|
2159 // --------------------------------------------------------------------------- |
|
2160 // CMPMServer::OfflineWlanQueryResponse |
|
2161 // Tells the "Use WLAN in offline mode" query's response during the |
|
2162 // current offline mode session. |
|
2163 // --------------------------------------------------------------------------- |
|
2164 // |
|
2165 TOfflineWlanQueryResponse CMPMServer::OfflineWlanQueryResponse() |
|
2166 { |
|
2167 MPMLOGSTRING( "CMPMServer::OfflineWlanQueryResponse" ) |
|
2168 |
|
2169 #ifndef _PLATFORM_SIMULATOR_ |
|
2170 MPMLOGSTRING2( "CMPMServer::IsOfflineWlanQueryAccepted: %d", iOfflineWlanQueryResponse ) |
|
2171 return iOfflineWlanQueryResponse; |
|
2172 #else |
|
2173 // Platsim simulates WLAN and offline-mode. To ease automated testing, |
|
2174 // offline connection confirmation is not asked in Platsim-variant |
|
2175 MPMLOGSTRING( "CMPMServer::OfflineWlanQueryResponse: yes for Platsim" ) |
|
2176 return EOfflineResponseYes; |
|
2177 #endif |
|
2178 } |
|
2179 |
|
2180 // --------------------------------------------------------------------------- |
|
2181 // CMPMServer::SetOfflineWlanQueryResponse |
|
2182 // Called when the "Use WLAN in offline mode" note has been responded. |
|
2183 // --------------------------------------------------------------------------- |
|
2184 // |
|
2185 void CMPMServer::SetOfflineWlanQueryResponse( TOfflineWlanQueryResponse aResponse) |
|
2186 { |
|
2187 MPMLOGSTRING( "CMPMServer::SetOfflineWlanQueryResponse" ) |
|
2188 |
|
2189 iOfflineWlanQueryResponse = aResponse; |
|
2190 } |
|
2191 |
2086 // ----------------------------------------------------------------------------- |
2192 // ----------------------------------------------------------------------------- |
2087 // TMPMBlackListConnId::Append |
2193 // TMPMBlackListConnId::Append |
2088 // ----------------------------------------------------------------------------- |
2194 // ----------------------------------------------------------------------------- |
2089 // |
2195 // |
2090 void TMPMBlackListConnId::Append( TUint32 aIap, TBlacklistCategory aCategory ) |
2196 void TMPMBlackListConnId::Append( TUint32 aIap, TBlacklistCategory aCategory ) |