1867 TInt CConnMonIAP::SetUintAttribute( |
1900 TInt CConnMonIAP::SetUintAttribute( |
1868 const RMessage2& /*aMessage*/, |
1901 const RMessage2& /*aMessage*/, |
1869 const TUint /*aValue*/ ) |
1902 const TUint /*aValue*/ ) |
1870 { |
1903 { |
1871 return KErrNotSupported; |
1904 return KErrNotSupported; |
|
1905 } |
|
1906 |
|
1907 // ----------------------------------------------------------------------------- |
|
1908 // CConnMonIAP::AsyncConnectionStopL |
|
1909 // Checks parameter validity first. If all ok creates an active object that |
|
1910 // completes the connection stop in a separate thread. |
|
1911 // ----------------------------------------------------------------------------- |
|
1912 // |
|
1913 TInt CConnMonIAP::AsyncConnectionStopL( const RMessage2& aMessage ) |
|
1914 { |
|
1915 LOGENTRFN("CConnMonIAP::AsyncConnectionStopL()") |
|
1916 TInt result( KErrGeneral ); |
|
1917 TUint connectionId( aMessage.Int0() ); |
|
1918 |
|
1919 TInt index = Index( connectionId ); |
|
1920 if ( index < 0 ) |
|
1921 { |
|
1922 LOGIT1("AsyncConnectionStopL: unknown connection index %d", connectionId) |
|
1923 result = KErrNotFound; |
|
1924 } |
|
1925 else |
|
1926 { |
|
1927 // Check if value is true or false |
|
1928 if ( !( aMessage.Int3() ) ) |
|
1929 { |
|
1930 LOGIT("AsyncConnectionStopL: boolean value was false, quitting") |
|
1931 result = KErrNone; |
|
1932 } |
|
1933 else |
|
1934 { |
|
1935 if ( iConnInfos[index].iAsyncStopStatus != EConnMonStopCompleted ) |
|
1936 { |
|
1937 TInt threadStartError( KErrNone ); |
|
1938 if ( iConnInfos[index].iAsyncStopStatus == EConnMonAsyncStopNotStarted ) |
|
1939 { |
|
1940 threadStartError = StartAsyncStopThreadL( index ); |
|
1941 } |
|
1942 if ( threadStartError == KErrNone ) |
|
1943 { |
|
1944 // Associate this connection into this stop request |
|
1945 TAsyncStopQueueElement request( aMessage ); |
|
1946 request.Add( connectionId ); |
|
1947 iAsyncStopQueue.Append( request ); |
|
1948 result = KRequestPending; |
|
1949 } |
|
1950 else |
|
1951 { |
|
1952 result = threadStartError; |
|
1953 } |
|
1954 } |
|
1955 else |
|
1956 { |
|
1957 // Connection has already been closed, but not yet removed from connection table |
|
1958 result = KErrNone; |
|
1959 } |
|
1960 } |
|
1961 } |
|
1962 LOGEXITFN1("CConnMonIAP::AsyncConnectionStopL()", result) |
|
1963 return result; |
|
1964 } |
|
1965 |
|
1966 // ----------------------------------------------------------------------------- |
|
1967 // CConnMonIAP::AsyncConnectionStopAllL |
|
1968 // Checks parameter validity first. If all ok creates an active object for each |
|
1969 // connection that completes the connection stop in a separate thread. If any |
|
1970 // errors occur, returns the first encountered error code. |
|
1971 // ----------------------------------------------------------------------------- |
|
1972 // |
|
1973 TInt CConnMonIAP::AsyncConnectionStopAllL( const RMessage2& aMessage ) |
|
1974 { |
|
1975 LOGENTRFN("CConnMonIAP::AsyncConnectionStopAllL()") |
|
1976 |
|
1977 TInt result( KErrNone ); |
|
1978 // Check if value is true or false |
|
1979 if ( !( aMessage.Int3() ) ) |
|
1980 { |
|
1981 LOGIT("AsyncConnectionStopAllL: boolean value was false, quitting") |
|
1982 result = KErrNone; |
|
1983 } |
|
1984 else |
|
1985 { |
|
1986 TAsyncStopQueueElement request( aMessage ); |
|
1987 TInt count = iConnInfos.Count(); |
|
1988 result = KErrNone; |
|
1989 |
|
1990 for ( TInt i = 0; i < count; i++ ) |
|
1991 { |
|
1992 if ( iConnInfos[i].iAsyncStopStatus != EConnMonStopCompleted ) |
|
1993 { |
|
1994 TInt threadStartError( KErrNone ); |
|
1995 if ( iConnInfos[i].iAsyncStopStatus == EConnMonAsyncStopNotStarted ) |
|
1996 { |
|
1997 threadStartError = StartAsyncStopThreadL( i ); |
|
1998 } |
|
1999 if ( threadStartError == KErrNone ) |
|
2000 { |
|
2001 // Associate this connection into this stop request |
|
2002 request.Add( iConnInfos[i].iConnectionId ); |
|
2003 } |
|
2004 else |
|
2005 { |
|
2006 // Thread start failed |
|
2007 if ( result == KErrNone ) |
|
2008 { |
|
2009 // Keep only the first error that occurs |
|
2010 result = threadStartError; |
|
2011 } |
|
2012 LOGIT2("AsyncConnectionStopAllL: Error starting stop thread for conn. id %d <%d>", |
|
2013 iConnInfos[i].iConnectionId, threadStartError) |
|
2014 } |
|
2015 } |
|
2016 } |
|
2017 // If one or more async connection stop threads have been started, and |
|
2018 // no errors have been encountered, set request to pending and add to |
|
2019 // queue to wait for thread(s) to complete. |
|
2020 if ( request.iIdCount > 0 ) |
|
2021 { |
|
2022 if ( result == KErrNone ) |
|
2023 { |
|
2024 iAsyncStopQueue.Append( request ); |
|
2025 result = KRequestPending; |
|
2026 } |
|
2027 } |
|
2028 } |
|
2029 LOGEXITFN1("CConnMonIAP::AsyncConnectionStopAllL()", result) |
|
2030 return result; |
|
2031 } |
|
2032 |
|
2033 // ----------------------------------------------------------------------------- |
|
2034 // CConnMonIAP::StartAsyncStopThread |
|
2035 // Starts a new thread to asynchronously stop a connection. Returns KErrNone if |
|
2036 // thread started successfully. |
|
2037 // ----------------------------------------------------------------------------- |
|
2038 // |
|
2039 TInt CConnMonIAP::StartAsyncStopThreadL( TInt aIndex ) |
|
2040 { |
|
2041 LOGENTRFN("CConnMonIAP::StartAsyncStopThreadL()") |
|
2042 TInt err( KErrNone ); |
|
2043 |
|
2044 if ( aIndex < 0 || aIndex >= iConnInfos.Count() ) |
|
2045 { |
|
2046 return KErrArgument; |
|
2047 } |
|
2048 |
|
2049 iConnInfos[aIndex].iAsyncStopStatus = EConnMonAsyncStopStarted; |
|
2050 if ( iConnInfos[aIndex].iBearer < EBearerExternalCSD ) |
|
2051 { |
|
2052 // Stop an internal connection |
|
2053 LOGIT("StartAsyncStopThreadL: connection type internal") |
|
2054 |
|
2055 // Cancel data volume and activity notifiers before stopping |
|
2056 if ( iConnInfos[aIndex].iDLDataNotifier != 0 ) |
|
2057 { |
|
2058 iConnInfos[aIndex].iDLDataNotifier->Cancel(); |
|
2059 } |
|
2060 if ( iConnInfos[aIndex].iULDataNotifier != 0 ) |
|
2061 { |
|
2062 iConnInfos[aIndex].iULDataNotifier->Cancel(); |
|
2063 } |
|
2064 if ( iConnInfos[aIndex].iDataVolumeAO != 0 ) |
|
2065 { |
|
2066 iConnInfos[aIndex].iDataVolumeAO->Cancel(); |
|
2067 } |
|
2068 if ( iConnInfos[aIndex].iActivityNotifier != 0 ) |
|
2069 { |
|
2070 iConnInfos[aIndex].iActivityNotifier->Cancel(); |
|
2071 } |
|
2072 |
|
2073 // Create and start a oneshot active object that starts and waits for |
|
2074 // the async stop thread to complete |
|
2075 CConnMonAsyncStopDaemon* asyncStopDaemon = CConnMonAsyncStopDaemon::NewL( this ); |
|
2076 err = asyncStopDaemon->Start( |
|
2077 iConnInfos[aIndex].iConnectionId, |
|
2078 iConnInfos[aIndex].iIapId, |
|
2079 iConnInfos[aIndex].iNetId ); |
|
2080 if ( err ) |
|
2081 { |
|
2082 // Error, cleanup the active object since it did not start |
|
2083 delete asyncStopDaemon; |
|
2084 } |
|
2085 } |
|
2086 else if ( iConnInfos[aIndex].iBearer == EBearerExternalGPRS || |
|
2087 iConnInfos[aIndex].iBearer == EBearerExternalEdgeGPRS || |
|
2088 iConnInfos[aIndex].iBearer == EBearerExternalWCDMA || |
|
2089 iConnInfos[aIndex].iBearer == EBearerExternalCDMA2000 || |
|
2090 ( !iConnInfos[aIndex].iBearerInfo.iInternal && |
|
2091 ( iConnInfos[aIndex].iBearerInfo.iBearer == EBearerInfoHSDPA || |
|
2092 iConnInfos[aIndex].iBearerInfo.iBearer == EBearerInfoHSUPA || |
|
2093 iConnInfos[aIndex].iBearerInfo.iBearer == EBearerInfoHSxPA ) ) ) |
|
2094 { |
|
2095 // Stop an external PSD connection |
|
2096 LOGIT("StartAsyncStopThreadL: connection type external PSD") |
|
2097 if ( iPsdFax ) |
|
2098 { |
|
2099 CConnMonAsyncStopDaemon* asyncStopDaemon = CConnMonAsyncStopDaemon::NewL( this ); |
|
2100 err = asyncStopDaemon->Start( |
|
2101 iConnInfos[aIndex].iConnectionId, |
|
2102 iPsdFax ); |
|
2103 if ( err ) |
|
2104 { |
|
2105 // Error, cleanup the active object since it did not start |
|
2106 delete asyncStopDaemon; |
|
2107 } |
|
2108 } |
|
2109 else |
|
2110 { |
|
2111 err = KErrNotFound; |
|
2112 } |
|
2113 } |
|
2114 else if ( iConnInfos[aIndex].iBearer == EBearerExternalCSD || |
|
2115 iConnInfos[aIndex].iBearer == EBearerExternalHSCSD || |
|
2116 iConnInfos[aIndex].iBearer == EBearerExternalWcdmaCSD ) |
|
2117 { |
|
2118 LOGIT("AsyncConnectionStopL: Error, connection type external CSD not supported") |
|
2119 err = KErrNotSupported; |
|
2120 } |
|
2121 else |
|
2122 { |
|
2123 LOGIT("AsyncConnectionStopL: Error, unknown bearer") |
|
2124 err = KErrNotSupported; |
|
2125 } |
|
2126 |
|
2127 LOGEXITFN1("CConnMonIAP::StartAsyncStopThreadL()", err) |
|
2128 return err; |
|
2129 } |
|
2130 |
|
2131 // ----------------------------------------------------------------------------- |
|
2132 // CConnMonIAP::CompleteAsyncStopReqs |
|
2133 // Called when an asynchronous connection stop has completed. |
|
2134 // This method will go through all pending async connection stop requests and |
|
2135 // mark this connections status to those requests that are waiting for it. |
|
2136 // Those requests that were only waiting for this connection anymore, are |
|
2137 // completed. |
|
2138 // ----------------------------------------------------------------------------- |
|
2139 // |
|
2140 void CConnMonIAP::CompleteAsyncStopReqs( const TUint aConnectionId, const TInt aError ) |
|
2141 { |
|
2142 LOGENTRFN("CConnMonIAP::CompleteAsyncStopReqs()") |
|
2143 |
|
2144 // Mark the internal status of the connection to stopped |
|
2145 TInt index = Index( aConnectionId ); |
|
2146 LOGIT3("Connection %d (index %d) marked as stopped <%d>", aConnectionId, index, aError) |
|
2147 if ( index >= 0 ) |
|
2148 { |
|
2149 iConnInfos[index].iAsyncStopStatus = EConnMonStopCompleted; |
|
2150 } |
|
2151 |
|
2152 #ifdef _DEBUG |
|
2153 LOGIT1("iAsyncStopQueue contents (%d:)", iAsyncStopQueue.Count() ) |
|
2154 for ( TInt i = 0; i < iAsyncStopQueue.Count(); i++ ) |
|
2155 { |
|
2156 LOGIT1("iIdCount = %d", iAsyncStopQueue[i].iIdCount) |
|
2157 LOGIT1("iStopCount = %d", iAsyncStopQueue[i].iStopCount) |
|
2158 LOGIT1("iStatus = %d", iAsyncStopQueue[i].iStatus) |
|
2159 for ( TInt j = 0; j < iAsyncStopQueue[i].iIdCount; j++ ) |
|
2160 { |
|
2161 LOGIT1(". id = %02d", iAsyncStopQueue[i].iId[j]) |
|
2162 } |
|
2163 } |
|
2164 #endif // _DEBUG |
|
2165 |
|
2166 // Go through all pending async stop requests. If a request has been |
|
2167 // cancelled, it has been removed from this array already. |
|
2168 for ( TInt i = 0; i < iAsyncStopQueue.Count(); i++ ) |
|
2169 { |
|
2170 // Go through all connections related to this request |
|
2171 for ( TInt j = 0; j < iAsyncStopQueue[i].iIdCount; j++ ) |
|
2172 { |
|
2173 // Was this request waiting for the connection that was just stopped |
|
2174 if ( iAsyncStopQueue[i].iId[j] == aConnectionId ) |
|
2175 { |
|
2176 iAsyncStopQueue[i].iStopCount++; |
|
2177 // Set iAsyncStopQueue[i].iId[j] to 0 if tracking is needed |
|
2178 |
|
2179 // Store the first encountered error |
|
2180 if ( aError && iAsyncStopQueue[i].iStatus == KErrNone ) |
|
2181 { |
|
2182 iAsyncStopQueue[i].iStatus = aError; |
|
2183 } |
|
2184 } |
|
2185 } |
|
2186 // Have all connections stopped that this request is waiting for |
|
2187 if ( iAsyncStopQueue[i].iStopCount >= iAsyncStopQueue[i].iIdCount ) |
|
2188 { |
|
2189 LOGIT3("Completing request at index %d, id count %d <%d>", |
|
2190 i, iAsyncStopQueue[i].iIdCount, iAsyncStopQueue[i].iStatus) |
|
2191 iAsyncStopQueue[i].iMessage.Complete( iAsyncStopQueue[i].iStatus ); |
|
2192 iAsyncStopQueue.Remove( i ); |
|
2193 i--; |
|
2194 } |
|
2195 } |
|
2196 LOGEXITFN("CConnMonIAP::CompleteAsyncStopReqs()") |
|
2197 } |
|
2198 |
|
2199 // ----------------------------------------------------------------------------- |
|
2200 // CConnMonIAP::CleanupConnectionInfo |
|
2201 // If the stopped connection is still in the connection info array and |
|
2202 // connection up/down notifier isn't running, removes the obsolete information |
|
2203 // and notifiers from the connection info array. |
|
2204 // ----------------------------------------------------------------------------- |
|
2205 // |
|
2206 TInt CConnMonIAP::CleanupConnectionInfo( const TUint& aConnectionId ) |
|
2207 { |
|
2208 LOGENTRFN("CConnMonIAP::CleanupConnectionInfo()") |
|
2209 TInt err( KErrNone ); |
|
2210 |
|
2211 TInt index = Index( aConnectionId ); |
|
2212 if ( index < 0 ) |
|
2213 { |
|
2214 LOGIT("CleanupConnectionInfo: ID no longer in connection table") |
|
2215 err = KErrNotFound; |
|
2216 } |
|
2217 else |
|
2218 { |
|
2219 // If conn up/down notifier is active, let the event remove connection later. |
|
2220 if ( !iConnUpDownNotifier || !iConnUpDownNotifier->IsActive() ) |
|
2221 { |
|
2222 err = RemoveConnection( iConnInfos[index] ); |
|
2223 } |
|
2224 else |
|
2225 { |
|
2226 LOGIT("CleanupConnectionInfo: iConnUpDownNotifier active, letting event do cleanup") |
|
2227 err = KErrNone; |
|
2228 } |
|
2229 } |
|
2230 LOGEXITFN1("CConnMonIAP::CleanupConnectionInfo()", err) |
|
2231 return err; |
|
2232 } |
|
2233 |
|
2234 // ----------------------------------------------------------------------------- |
|
2235 // CConnMonIAP::CancelAsyncStopReqs |
|
2236 // Cancels all asynchronous connection stop request for a specific client. |
|
2237 // ----------------------------------------------------------------------------- |
|
2238 // |
|
2239 void CConnMonIAP::CancelAsyncStopReqs( CSession2* aSession ) |
|
2240 { |
|
2241 LOGENTRFN("CConnMonIAP::CancelAsyncStopReqs()") |
|
2242 |
|
2243 LOGIT1("AsyncStopQueue count = %d", iAsyncStopQueue.Count()) |
|
2244 for ( TInt i = 0; i < iAsyncStopQueue.Count(); i++ ) |
|
2245 { |
|
2246 if ( iAsyncStopQueue[i].iMessage.Session() == aSession ) |
|
2247 { |
|
2248 iAsyncStopQueue[i].iMessage.Complete( KErrCancel ); |
|
2249 iAsyncStopQueue.Remove( i ); |
|
2250 i--; |
|
2251 LOGIT1("Cancelled a request for session %d", aSession) |
|
2252 } |
|
2253 } |
|
2254 |
|
2255 LOGEXITFN("CConnMonIAP::CancelAsyncStopReqs()") |
1872 } |
2256 } |
1873 |
2257 |
1874 // ----------------------------------------------------------------------------- |
2258 // ----------------------------------------------------------------------------- |
1875 // CConnMonIAP::SetBoolAttributeL |
2259 // CConnMonIAP::SetBoolAttributeL |
1876 // Used for stopping the connections. |
2260 // Used for stopping the connections. |