728 // |
735 // |
729 void CWsfWlanBearerConnectionMonitor::CheckClientCountL() |
736 void CWsfWlanBearerConnectionMonitor::CheckClientCountL() |
730 { |
737 { |
731 LOG_ENTERFN( "CWsfWlanBearerConnectionMonitor::CheckClientCountL" ); |
738 LOG_ENTERFN( "CWsfWlanBearerConnectionMonitor::CheckClientCountL" ); |
732 |
739 |
733 CWsfActiveWaiter* waiter = CWsfActiveWaiter::NewL(); |
740 RWsSession wsSession; |
734 |
741 if ( KErrNone == wsSession.Connect() ) |
735 TConnMonClientEnumBuf clientInfo; |
742 { |
736 |
743 LOG_WRITE( "Find browser task" ); |
737 iMonitor.GetPckgAttribute( iConnectionId, 0, |
744 TApaTaskList taskList( wsSession ); |
738 KClientInfo, |
745 TApaTask task = taskList.FindApp( KCRUidBrowser ); |
739 clientInfo, |
746 if ( task.Exists() ) |
740 waiter->iStatus ); |
747 { |
741 waiter->WaitForRequest(); |
748 LOG_WRITE( "Browser is running - auto disconnect to false" ); |
742 delete waiter; |
749 iAutoDisconnect = EFalse; |
743 |
750 iInactivityStart.UniversalTime(); |
744 // get the client count |
751 } |
745 iClientCount = clientInfo().iCount; |
752 else |
746 |
753 { |
747 // decrease count by each trivial client (Sniffer server, DHCP etc) |
754 LOG_WRITE( "Browser is not running - auto disconnect to true" ); |
748 for ( TInt i( 0 ); i < clientInfo().iCount; ++i ) |
755 iAutoDisconnect = ETrue; |
749 { |
756 } |
750 for ( TInt j( 0 ); j < KTrivialClientCount; ++j ) |
757 wsSession.Close(); |
751 { |
758 } |
752 if ( clientInfo().iUid[i] == KTrivialClientUids[j] ) |
759 else |
753 { |
760 { |
754 --iClientCount; |
761 LOG_WRITE( "Session connect failed" ); |
755 LOG_WRITEF( "trivial client [0x%08X] discarded", |
762 } |
756 clientInfo().iUid[i].iUid ); |
763 |
757 break; |
764 if ( iAutoDisconnect ) |
|
765 { |
|
766 CWsfActiveWaiter* waiter = CWsfActiveWaiter::NewL(); |
|
767 |
|
768 TConnMonClientEnumBuf clientInfo; |
|
769 |
|
770 iMonitor.GetPckgAttribute( iConnectionId, 0, |
|
771 KClientInfo, |
|
772 clientInfo, |
|
773 waiter->iStatus ); |
|
774 waiter->WaitForRequest(); |
|
775 delete waiter; |
|
776 |
|
777 // get the client count |
|
778 iClientCount = clientInfo().iCount; |
|
779 |
|
780 // decrease count by each trivial client (Sniffer server, DHCP etc) |
|
781 for ( TInt i( 0 ); i < clientInfo().iCount; ++i ) |
|
782 { |
|
783 for ( TInt j( 0 ); j < KTrivialClientCount; ++j ) |
|
784 { |
|
785 if ( clientInfo().iUid[i] == KTrivialClientUids[j] ) |
|
786 { |
|
787 --iClientCount; |
|
788 LOG_WRITEF( "trivial client [0x%08X] discarded", |
|
789 clientInfo().iUid[i].iUid ); |
|
790 break; |
|
791 } |
758 } |
792 } |
759 } |
793 } |
760 } |
794 |
761 |
795 LOG_WRITEF( "iClientCount = %d (trivial clients:%d)", |
762 |
796 iClientCount, |
763 LOG_WRITEF( "iClientCount = %d (trivial clients:%d)", |
797 clientInfo().iCount - iClientCount ); |
764 iClientCount, |
798 |
765 clientInfo().iCount - iClientCount ); |
|
766 |
|
767 if ( iAutoDisconnect ) |
|
768 { |
|
769 if ( iClientCount ) |
799 if ( iClientCount ) |
770 { |
800 { |
|
801 LOG_WRITE( "reset the inactivity start time to current time" ); |
771 // there are more clients than the default ones -> |
802 // there are more clients than the default ones -> |
772 // connection is considered active -> |
803 // connection is considered active -> |
773 // reset the inactivity start time to current time |
804 // reset the inactivity start time to current time |
774 iInactivityStart.UniversalTime(); |
805 iInactivityStart.UniversalTime(); |
775 |
|
776 } |
806 } |
777 else |
807 else |
778 { |
808 { |
779 // there are only trivial clients of the connection |
809 // there are only trivial clients of the connection |
780 // this means inactivity, so check the time elapsed |
810 // this means inactivity, so check the time elapsed |