upnp/upnpstack/ssdpserver/src/upnpssdpserver.cpp
changeset 31 b51a6f4f15ba
parent 0 f5a58ecadc66
equal deleted inserted replaced
28:0060d1e93dc3 31:b51a6f4f15ba
     1 /** @file
     1 /** @file
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies  this distribution, and is available 
     6 * which accompanies  this distribution, and is available 
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   134 // Message from multicast.
   134 // Message from multicast.
   135 // -----------------------------------------------------------------------------
   135 // -----------------------------------------------------------------------------
   136 //
   136 //
   137 void CUpnpSsdpServer::MessageFromMulticastL( CUpnpSsdpMessage* aMessage )
   137 void CUpnpSsdpServer::MessageFromMulticastL( CUpnpSsdpMessage* aMessage )
   138     {
   138     {
       
   139     ASSERT ( !iSocketDown );
   139     UdpMessageReceivedL( aMessage );
   140     UdpMessageReceivedL( aMessage );
   140     }
   141     }
   141 
   142 
   142 // -----------------------------------------------------------------------------
   143 // -----------------------------------------------------------------------------
   143 // CUpnpSsdpServer::UdpMessageReceivedL
   144 // CUpnpSsdpServer::UdpMessageReceivedL
   237 // -----------------------------------------------------------------------------
   238 // -----------------------------------------------------------------------------
   238 //
   239 //
   239 EXPORT_C void CUpnpSsdpServer::AdvertiseAliveL( CUpnpDeviceLibraryElement& aDev )
   240 EXPORT_C void CUpnpSsdpServer::AdvertiseAliveL( CUpnpDeviceLibraryElement& aDev )
   240     {
   241     {
   241     LOGS( "SSDP *** AdvertiseAliveL");
   242     LOGS( "SSDP *** AdvertiseAliveL");
       
   243     if ( iSocketDown )
       
   244         {
       
   245         // Leaves if the UDP socket is destroyed
       
   246         User::Leave(iLastSocketError);
       
   247         }
   242     // advertise this device
   248     // advertise this device
   243     SingleDeviceAdvertiseAliveL( aDev );
   249     SingleDeviceAdvertiseAliveL( aDev );
   244     SingleDeviceAdvertiseAliveL( aDev );
   250     SingleDeviceAdvertiseAliveL( aDev );
   245     }
   251     }
   246 
   252 
   249 // 
   255 // 
   250 // -----------------------------------------------------------------------------
   256 // -----------------------------------------------------------------------------
   251 //
   257 //
   252 EXPORT_C void CUpnpSsdpServer::AdvertiseByebyeL( CUpnpDeviceLibraryElement& aDev )
   258 EXPORT_C void CUpnpSsdpServer::AdvertiseByebyeL( CUpnpDeviceLibraryElement& aDev )
   253     {
   259     {
       
   260     if ( iSocketDown )
       
   261         {
       
   262         // Leaves if the UDP socket is destroyed
       
   263         User::Leave(iLastSocketError);
       
   264         }
   254     SingleDeviceAdvertiseByebyeL( aDev );
   265     SingleDeviceAdvertiseByebyeL( aDev );
   255     }
   266     }
   256 
   267 
   257 // -----------------------------------------------------------------------------
   268 // -----------------------------------------------------------------------------
   258 // CUpnpSsdpServer::SearchL
   269 // CUpnpSsdpServer::SearchL
   259 // 
   270 // 
   260 // -----------------------------------------------------------------------------
   271 // -----------------------------------------------------------------------------
   261 //
   272 //
   262 EXPORT_C void CUpnpSsdpServer::SearchL( TDesC8& aTarget )
   273 EXPORT_C void CUpnpSsdpServer::SearchL( TDesC8& aTarget )
   263     {
   274     {
       
   275     if ( iSocketDown )
       
   276         {
       
   277         // Leaves if the UDP socket is destroyed
       
   278         User::Leave(iLastSocketError);
       
   279         }
   264     SearchL(aTarget, (TDesC8&)UpnpSSDP::KDefaultResponseDelay());
   280     SearchL(aTarget, (TDesC8&)UpnpSSDP::KDefaultResponseDelay());
   265     }
   281     }
   266 
   282 
   267 // -----------------------------------------------------------------------------
   283 // -----------------------------------------------------------------------------
   268 // CUpnpSsdpServer::SearchL
   284 // CUpnpSsdpServer::SearchL
   269 // 
   285 // 
   270 // -----------------------------------------------------------------------------
   286 // -----------------------------------------------------------------------------
   271 //
   287 //
   272 EXPORT_C void CUpnpSsdpServer::SearchL( TDesC8& aTarget, TDesC8& aMaximumWaitTime )
   288 EXPORT_C void CUpnpSsdpServer::SearchL( TDesC8& aTarget, TDesC8& aMaximumWaitTime )
   273     {
   289     {
       
   290     if ( iSocketDown )
       
   291         {
       
   292         // Leaves if the UDP socket is destroyed
       
   293         User::Leave(iLastSocketError);
       
   294         }
   274     CUpnpSsdpMessage* msg = RUpnpSsdpMessageFactory::SearchL( aTarget );
   295     CUpnpSsdpMessage* msg = RUpnpSsdpMessageFactory::SearchL( aTarget );
   275     CleanupStack::PushL( msg );
   296     CleanupStack::PushL( msg );
   276     msg->AddMxL(aMaximumWaitTime);
   297     msg->AddMxL(aMaximumWaitTime);
   277     
   298     
   278     HBufC8* str = HBufC8::NewLC( KMaxSsdpMessageLength );
   299     HBufC8* str = HBufC8::NewLC( KMaxSsdpMessageLength );