# HG changeset patch # User hgs # Date 1283494384 -10800 # Node ID b51a6f4f15baab7e14dc21ebe709a4d5c9dfc4d3 # Parent 0060d1e93dc30f49eb5462e178eb57ea3ebcc3f5 201035 diff -r 0060d1e93dc3 -r b51a6f4f15ba services/terminalmodeservice/inc/upnptmserverimpl.h --- a/services/terminalmodeservice/inc/upnptmserverimpl.h Mon Aug 23 13:11:50 2010 +0300 +++ b/services/terminalmodeservice/inc/upnptmserverimpl.h Fri Sep 03 09:13:04 2010 +0300 @@ -69,7 +69,7 @@ void StopDeviceL(); CUpnpRemotableApp& GetRemotableApp( TUint aAppId, TInt& aErr ); void GenerateUrlComponents( CUpnpHttpServerSession& aHttpServerSession ); - const TDesC8& ConvertIntToDescriptor( TInt aIntVal ); + const TDesC8& ConvertIntToDescriptor( TUint aIntVal ); public: //Action handling methods diff -r 0060d1e93dc3 -r b51a6f4f15ba services/terminalmodeservice/src/upnptmappserverservice.cpp --- a/services/terminalmodeservice/src/upnptmappserverservice.cpp Mon Aug 23 13:11:50 2010 +0300 +++ b/services/terminalmodeservice/src/upnptmappserverservice.cpp Fri Sep 03 09:13:04 2010 +0300 @@ -187,11 +187,13 @@ // Fetch the value for app listing filter argument const TDesC8& filter = aAction->ArgumentValue(KAppFilter); // Validate the AppListing filter string - // AppListingFilter input argument can contain wither wildcard(*) or - // a well formatted string - if ( ( filter.Compare(KWildCard ) != KErrNone ) && ( filter.Find(Keq) == KErrNotFound )) + // AppListingFilter input argument can contain one of these: <1> an empty string ("") + // <2> wildcard(*) <3> a well formatted filter string + if ( ( filter.Compare(KNullDesC8()) != KErrNone ) && ( filter.Compare(KWildCard ) != KErrNone ) + && ( filter.Find(Keq) == KErrNotFound ) ) { - // The filter string is having neither wildcard(*) nor a proper string( =" is missing ) + // AppListingFilter argument is not having empty string ( "" ) , or wildcard(*) , + // or a valid filter string( =" is missing ) OstTrace0( TRACE_ERROR, DUP2_CUPNPTMAPPSERVERSERVICE_GETAPPLISTACTIONL, "CUpnpTmAppServerService::GetAppListActionL" ); return EInvalidArgs; // invalid AppListingFilter argument } diff -r 0060d1e93dc3 -r b51a6f4f15ba services/terminalmodeservice/src/upnptmserverimpl.cpp --- a/services/terminalmodeservice/src/upnptmserverimpl.cpp Mon Aug 23 13:11:50 2010 +0300 +++ b/services/terminalmodeservice/src/upnptmserverimpl.cpp Fri Sep 03 09:13:04 2010 +0300 @@ -193,8 +193,8 @@ AppendDataL(KAppListStart); for ( TInt i(0) ; i < iAppStore->AppIdArray().Count(); i++) { - // There can be 2 conditions assoicated with this - // 1. AppListingFilter is "*" + // There can be 2 conditions associated with this + // 1. AppListingFilter value is "*" or empty // 2. AppListingFilter has some filter string set const RArray& profileIdList = iAppStore->FetchRemotableApp(i).AllowedProfileIdList(); if ( ( profileIdList.Find(aProfileId) != KErrNotFound ) || @@ -216,9 +216,10 @@ } if ( ( filterStringFound == KErrNotFound ) || ( (iFilteredAppList->SignatureElement()).Length() != KErrNone )) { - // Append the xml signature value to the response buffer if - // 1. Filter string contains the signature element - // 2. Filter value is '*' + // Append the xml signature value to the response buffer only if + // 1. Filter string contains the signature element or + // 2. Filter value is '*' or + // 3. Filter value is empty AppendDataL(XmlSignature()); } AppendDataL(KAppListEnd); @@ -1043,10 +1044,10 @@ // @return Returns corresponding descriptor value // --------------------------------------------------------------------------------- // -const TDesC8& CUpnpTmServerImpl::ConvertIntToDescriptor( TInt aIntVal ) +const TDesC8& CUpnpTmServerImpl::ConvertIntToDescriptor( TUint aIntVal ) { OstTraceFunctionEntry0( CUPNPTMSERVERIMPL_CONVERTINTTODESCRIPTOR_ENTRY ); - OstTrace1( TRACE_NORMAL, CUPNPTMSERVERIMPL_CONVERTINTTODESCRIPTOR, "CUpnpTmServerImpl::ConvertIntToDescriptor;aIntVal=%d", aIntVal ); + OstTrace1( TRACE_NORMAL, CUPNPTMSERVERIMPL_CONVERTINTTODESCRIPTOR, "CUpnpTmServerImpl::ConvertIntToDescriptor;aIntVal=%u", aIntVal ); iBufVal.Num( aIntVal ); OstTraceFunctionExit0( CUPNPTMSERVERIMPL_CONVERTINTTODESCRIPTOR_EXIT ); return iBufVal; diff -r 0060d1e93dc3 -r b51a6f4f15ba services/terminalmodeservice/tsrc/upnptmservertest/inc/tmservertest.h --- a/services/terminalmodeservice/tsrc/upnptmservertest/inc/tmservertest.h Mon Aug 23 13:11:50 2010 +0300 +++ b/services/terminalmodeservice/tsrc/upnptmservertest/inc/tmservertest.h Fri Sep 03 09:13:04 2010 +0300 @@ -260,6 +260,7 @@ TInt HandleGetAppListActionInvalidArg5L(TTestResult& aResult ); TInt HandleInvalidProfileIdGetAppListActionL ( TTestResult& aResult ); TInt HandleGetAppListActionOperationRejectedL ( TTestResult& aResult ); + TInt HandleGetAppListActionWildCardFilterL ( TTestResult& aResult ); TInt HandleGetAppListActionNoFilterL ( TTestResult& aResult ); TInt HandleGetAppStatusActionL( TTestResult& aResult ); TInt HandleWildcardGetAppStatusActionL( TTestResult& aResult ); diff -r 0060d1e93dc3 -r b51a6f4f15ba services/terminalmodeservice/tsrc/upnptmservertest/src/tmservertestcases.cpp --- a/services/terminalmodeservice/tsrc/upnptmservertest/src/tmservertestcases.cpp Mon Aug 23 13:11:50 2010 +0300 +++ b/services/terminalmodeservice/tsrc/upnptmservertest/src/tmservertestcases.cpp Fri Sep 03 09:13:04 2010 +0300 @@ -160,6 +160,7 @@ ENTRY( "Handle GetAppList Command with Filter2", CTmServerTest:: HandleGetAppListActionFilter2L ), ENTRY( "Handle GetAppList Command with Filter3", CTmServerTest:: HandleGetAppListActionFilter3L ), ENTRY( "Handle GetAppList Command with Filter4", CTmServerTest:: HandleGetAppListActionFilter4L ), + ENTRY( "Handle GetAppList Command with WildCard Filter", CTmServerTest:: HandleGetAppListActionWildCardFilterL ), ENTRY( "Handle GetAppList Command with No Filter", CTmServerTest:: HandleGetAppListActionNoFilterL ), ENTRY( "Handle GetAppList Command with Invalid Arg1", CTmServerTest:: HandleGetAppListActionInvalidArg1L ), ENTRY( "Handle GetAppList Command with Invalid Arg2", CTmServerTest:: HandleGetAppListActionInvalidArg2L ), @@ -191,7 +192,7 @@ // OOM Testcases OOM_ENTRY( "[OOM_StartTmServerDevice]", CTmServerTest::StartTmServerDeviceL,ETrue,1,5 ), OOM_ENTRY( "[OOM_HandleGetAppListWithFilter]", CTmServerTest:: HandleGetAppListActionFilter1L,ETrue,1,5 ), - OOM_ENTRY( "[OOM_HandleGetAppListWithoutFilter]", CTmServerTest:: HandleGetAppListActionNoFilterL,ETrue,1,5 ), + OOM_ENTRY( "[OOM_HandleGetAppListWildCardFilter]", CTmServerTest:: HandleGetAppListActionWildCardFilterL,ETrue,1,5 ), OOM_ENTRY( "[OOM_HandleSetClientProfileCommand]", CTmServerTest:: HandleSetClientProfileActionL,ETrue,1,5 ), OOM_ENTRY( "[OOM_HandleGetAppStatusCommand]", CTmServerTest:: HandleGetAppStatusActionL,ETrue,1,5 ), OOM_ENTRY( "[OOM_HandleGetAppStatusForAllApplications]", CTmServerTest::HandleWildcardGetAppStatusActionL,ETrue,1,5 ), @@ -2236,9 +2237,9 @@ return KErrNone; } -TInt CTmServerTest::HandleGetAppListActionNoFilterL ( TTestResult& aResult ) +TInt CTmServerTest::HandleGetAppListActionWildCardFilterL ( TTestResult& aResult ) { - _LIT( KLogInfo, "Handle GetAppList Command With No Filter" ); + _LIT( KLogInfo, "Handle GetAppList Command With WildCard Filter" ); iLog->Log( KLogInfo ); iTmServerDeviceType = ETrue; @@ -2270,6 +2271,60 @@ CActiveScheduler::Start(); if (iGetAppList) { + _LIT( KDescription , "GetAppList Command With WildCard Filter handled successfully"); + aResult.SetResult( KErrNone, KDescription ); + iLog->Log( KDescription ); + } + else + { + aResult.iResult = KErrGeneral; + _LIT( KDescription , "GetAppList Command With WildCard Filter handling Failed"); + aResult.SetResult( KErrNone, KDescription ); + iLog->Log( KDescription ); + } + delete iDiscoveryTestTimer; + iDiscoveryTestTimer = NULL; + delete iTestTimer; + iTestTimer = NULL; + REComSession::FinalClose(); + return KErrNone; + } + +TInt CTmServerTest::HandleGetAppListActionNoFilterL ( TTestResult& aResult ) + { + _LIT( KLogInfo, "Handle GetAppList Command With No Filter" ); + iLog->Log( KLogInfo ); + + iTmServerDeviceType = ETrue; + + //Sets the information associated with the terminal mode server device + SetTmServerSettingsL(); + iTmServer = CUpnpTmServer::NewL( *iTmServerDeviceInfo, *this ); + + //Register all the desired applications + RegisterApplicationsL(*iTmServer); + + //Start the tmserver device and its services + iTmServer->StartL(); + + //Start the control point and search for device + iSearchDevice = CDiscoverDevice::NewL(*this); + iDiscoveryTestTimer = CDiscoveryTestTimer::NewL(*this); + iDiscoveryTestTimer->AfterDiscovery(15); + CActiveScheduler::Start(); + + if ( iDeviceVerified ) + { + _LIT8(KNoFilter, " "); + //Retrieve the list of applications + iSearchDevice->GetAppListActionL( KNoFilter(),KProfileIdValue); + } + + iTestTimer = CTestTimer::NewL(*this); + iTestTimer->After(15); + CActiveScheduler::Start(); + if (iGetAppList) + { _LIT( KDescription , "GetAppList Command With No Filter handled successfully"); aResult.SetResult( KErrNone, KDescription ); iLog->Log( KDescription ); @@ -2287,7 +2342,7 @@ iTestTimer = NULL; REComSession::FinalClose(); return KErrNone; - } + } TInt CTmServerTest::HandleInvalidProfileIdGetAppListActionL ( TTestResult& aResult ) { diff -r 0060d1e93dc3 -r b51a6f4f15ba upnp/upnpstack/ssdpserver/inc/upnpudpserver.h --- a/upnp/upnpstack/ssdpserver/inc/upnpudpserver.h Mon Aug 23 13:11:50 2010 +0300 +++ b/upnp/upnpstack/ssdpserver/inc/upnpudpserver.h Fri Sep 03 09:13:04 2010 +0300 @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -354,6 +354,12 @@ // If the interface goes to AutoIp address TBool iAutoIP; + + // Stores the error code for the socket failure operations + TInt iLastSocketError; + + // Indicates whether socket is alive or destroyed + TBool iSocketDown; }; #endif // C_CUPNPUDPSERVER_H diff -r 0060d1e93dc3 -r b51a6f4f15ba upnp/upnpstack/ssdpserver/src/upnpssdpserver.cpp --- a/upnp/upnpstack/ssdpserver/src/upnpssdpserver.cpp Mon Aug 23 13:11:50 2010 +0300 +++ b/upnp/upnpstack/ssdpserver/src/upnpssdpserver.cpp Fri Sep 03 09:13:04 2010 +0300 @@ -1,5 +1,5 @@ /** @file -* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -136,6 +136,7 @@ // void CUpnpSsdpServer::MessageFromMulticastL( CUpnpSsdpMessage* aMessage ) { + ASSERT ( !iSocketDown ); UdpMessageReceivedL( aMessage ); } @@ -239,6 +240,11 @@ EXPORT_C void CUpnpSsdpServer::AdvertiseAliveL( CUpnpDeviceLibraryElement& aDev ) { LOGS( "SSDP *** AdvertiseAliveL"); + if ( iSocketDown ) + { + // Leaves if the UDP socket is destroyed + User::Leave(iLastSocketError); + } // advertise this device SingleDeviceAdvertiseAliveL( aDev ); SingleDeviceAdvertiseAliveL( aDev ); @@ -251,6 +257,11 @@ // EXPORT_C void CUpnpSsdpServer::AdvertiseByebyeL( CUpnpDeviceLibraryElement& aDev ) { + if ( iSocketDown ) + { + // Leaves if the UDP socket is destroyed + User::Leave(iLastSocketError); + } SingleDeviceAdvertiseByebyeL( aDev ); } @@ -261,6 +272,11 @@ // EXPORT_C void CUpnpSsdpServer::SearchL( TDesC8& aTarget ) { + if ( iSocketDown ) + { + // Leaves if the UDP socket is destroyed + User::Leave(iLastSocketError); + } SearchL(aTarget, (TDesC8&)UpnpSSDP::KDefaultResponseDelay()); } @@ -271,6 +287,11 @@ // EXPORT_C void CUpnpSsdpServer::SearchL( TDesC8& aTarget, TDesC8& aMaximumWaitTime ) { + if ( iSocketDown ) + { + // Leaves if the UDP socket is destroyed + User::Leave(iLastSocketError); + } CUpnpSsdpMessage* msg = RUpnpSsdpMessageFactory::SearchL( aTarget ); CleanupStack::PushL( msg ); msg->AddMxL(aMaximumWaitTime); diff -r 0060d1e93dc3 -r b51a6f4f15ba upnp/upnpstack/ssdpserver/src/upnpudpserver.cpp --- a/upnp/upnpstack/ssdpserver/src/upnpudpserver.cpp Mon Aug 23 13:11:50 2010 +0300 +++ b/upnp/upnpstack/ssdpserver/src/upnpudpserver.cpp Fri Sep 03 09:13:04 2010 +0300 @@ -1,5 +1,5 @@ /** @file -* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -60,10 +60,12 @@ CUpnpUdpServer::CUpnpUdpServer( RSocketServ* aSocketServ, MUpnpUdpServerObserver* aObserver, TInt aListeningPort ) - : CActive( EPriorityHigh ), + : CActive( EPriorityStandard ), iMulticastFlags( 0 ), iMessagePtr( NULL, 0,0 ), - iIsStarted( EFalse ) + iIsStarted( EFalse ), + iSocketDown( EFalse ) + { LOGS( "SSDP *** CUpnpUdpServer::CUpnpUdpServer"); @@ -370,19 +372,29 @@ // void CUpnpUdpServer::RunL() { - - if ( iStatus.Int() != KErrNone ) + TInt socketStatus = iStatus.Int(); + LOGS1( "SSDP *** CUpnpUdpServer::RunL - UDPServer error, error code: %d", socketStatus ); + + if ( socketStatus != KErrNone ) { - LOGS1( "SSDP *** CUpnpUdpServer::RunL - UDPServer error, error code: %d", - iStatus.Int() ); - - if ( iStatus.Int() != KErrCancel ) + if ( ( socketStatus == KErrConnectionTerminated ) || ( socketStatus == KErrCannotFindProtocol ) + || ( socketStatus == KErrDisconnected ) ) { - ReceiveL(); + // When the WLAN newtork is lost or NCM cable is un-plugged, socket gets destroyed + // and no send-receive operation can be performed over this socket.Hence simply + // returning from RunL and setting the flag to true so that no further advertisement + // or search operations are carried over the dead socket. + iSocketDown = ETrue; + iLastSocketError = socketStatus; + } + else if ( socketStatus == KErrCancel ) + { + // Send the pending request msgs + RestartOrContinueSendProcessingL(); } else { - RestartOrContinueSendProcessingL(); + ReceiveL();; } } else