localconnectivityservice/dun/server/src/DunServerUtils.cpp
branchRCL_3
changeset 19 0aa8cc770c8a
equal deleted inserted replaced
18:453dfc402455 19:0aa8cc770c8a
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Utility class for CDunServer
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32uid.h>
       
    20 #include "DunServer.h"
       
    21 #include "DunServerUtils.h"
       
    22 #include "DunDebug.h"
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // Two-phased constructor.
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 CDunServerUtils* CDunServerUtils::NewL( CDunServer& aParent )
       
    29     {
       
    30     CDunServerUtils* self = new (ELeave) CDunServerUtils( aParent );
       
    31     CleanupStack::PushL( self );
       
    32     self->ConstructL();
       
    33     CleanupStack::Pop( self );
       
    34     return self;
       
    35     }
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // Destructor.
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 CDunServerUtils::~CDunServerUtils()
       
    42     {
       
    43     FTRACE(FPrint(_L("CDunServerUtils::~CDunServerUtils()")));
       
    44     FTRACE(FPrint(_L("CDunServerUtils::~CDunServerUtils() complete")));
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CDunServerUtils::CDunServerUtils
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CDunServerUtils::CDunServerUtils( CDunServer& aParent ) :
       
    52     iParent( aParent ),
       
    53     iTransporter( aParent.iTransporter ),
       
    54     iCloseWait( aParent.iCloseWait ),
       
    55     iConnData( aParent.iConnData ),
       
    56     iPluginQueue( aParent.iPluginQueue ),
       
    57     iClosedQueue( aParent.iClosedQueue )
       
    58     {
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CDunServerUtils::ConstructL
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 void CDunServerUtils::ConstructL()
       
    66     {
       
    67     FTRACE(FPrint( _L("CDunServerUtils::ConstructL()" ) ));
       
    68     FTRACE(FPrint( _L("CDunServerUtils::ConstructL() complete" ) ));
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // From class MDunServerUtility.
       
    73 // Closes plugins with state marked as zombie
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 TInt CDunServerUtils::RemoveZombiePlugins()
       
    77     {
       
    78     FTRACE(FPrint(_L("CDunServerUtils::RemoveZombiePlugins()")));
       
    79     TInt i;
       
    80     TInt retVal = KErrNone;
       
    81     for ( i=iConnData.Count()-1; i>=0; i-- )
       
    82         {
       
    83         if ( iConnData[i].iPluginState == EDunStateZombie )
       
    84             {
       
    85             // Following closes and removes if remove ok
       
    86             FTRACE(FPrint(_L("CDunServerUtils::RemoveZombiePlugins() trying close at index %d"), i));
       
    87             TInt retTemp = TryClosePlugin( i, ETrue, EFalse, EFalse );
       
    88             if ( retTemp != KErrNone )
       
    89                 {
       
    90                 retVal = KErrGeneral;
       
    91                 }
       
    92             }
       
    93         }
       
    94     FTRACE(FPrint(_L("CDunServerUtils::RemoveZombiePlugins() complete")));
       
    95     return retVal;
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // From class MDunServerUtility.
       
   100 // Loads local media module
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 TInt CDunServerUtils::CreateNewPlugin( TUid aPluginUid )
       
   104     {
       
   105     FTRACE(FPrint(_L("CDunServerUtils::CreateNewPlugin()")));
       
   106     // plugin not constructed, construct now
       
   107     TFileName pluginFile;
       
   108     switch ( aPluginUid.iUid )
       
   109         {
       
   110         case KDunBtPluginUidValue:
       
   111             pluginFile.Copy( KDunPluginBt );
       
   112             break;
       
   113         case KDunIrPluginUidValue:
       
   114             pluginFile.Copy( KDunPluginIrda );
       
   115             break;
       
   116         case KDunUsbPluginUidValue:
       
   117             pluginFile.Copy( KDunPluginUsb );
       
   118             break;
       
   119         default:
       
   120             FTRACE(FPrint(_L("CDunServerUtils::CreateNewPlugin() (not supported) complete")));
       
   121             return KErrNotSupported;
       
   122         }
       
   123     TDunConnectionData emptyConn;
       
   124     emptyConn.iLocalModulePtr = NULL;
       
   125     emptyConn.iLocalModuleUid = TUid::Null();
       
   126     emptyConn.iPluginState = EDunStateNone;
       
   127     TInt retTemp = iConnData.Append( emptyConn );
       
   128     if ( retTemp != KErrNone )
       
   129         {
       
   130         FTRACE(FPrint(_L("CDunServerUtils::CreateNewPlugin() (append failed!) complete")));
       
   131         return retTemp;
       
   132         }
       
   133     retTemp = ConstructLocalMediaModule( aPluginUid, pluginFile );
       
   134     if ( retTemp != KErrNone )
       
   135         {
       
   136         iConnData.Remove( iConnData.Count()-1 );
       
   137         FTRACE(FPrint(_L("CDunServerUtils::CreateNewPlugin() (ERROR) complete")));
       
   138         return retTemp;
       
   139         }
       
   140     FTRACE(FPrint(_L("CDunServerUtils::CreateNewPlugin() complete")));
       
   141     return KErrNone;
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // From class MDunServerUtility.
       
   146 // Constructs local media module
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 TInt CDunServerUtils::ConstructLocalMediaModule( const TUid& aPluginUid,
       
   150                                                  const TPtrC& aDllName )
       
   151     {
       
   152     FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule()")));
       
   153     // Create a new library object
       
   154     if ( iConnData.Count() == 0 )
       
   155         {
       
   156         FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() (not ready) complete")));
       
   157         return KErrNotReady;
       
   158         }
       
   159     TInt index = iConnData.Count() - 1;
       
   160     iConnData[index].iLocalModuleUid = aPluginUid;
       
   161     iConnData[index].iPluginState = EDunStateTryLoad;
       
   162     // Load the DLL containing the plug-in
       
   163     TUidType uidType( KDynamicLibraryUid,
       
   164                       KDunLocalMediaPluginInterfaceUid,
       
   165                       aPluginUid );
       
   166     FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() loading")));
       
   167     TInt retTemp = iConnData[index].iModuleLibrary.Load( aDllName, uidType );
       
   168     if ( retTemp != KErrNone )
       
   169         {
       
   170         FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() (ERROR) complete")));
       
   171         return retTemp;
       
   172         }
       
   173     FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() plugin 0x%08X loaded"), aPluginUid.iUid));
       
   174     // Create the plugin object.
       
   175     FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() looking up")));
       
   176     TLibraryFunction factoryFunction = iConnData[index].iModuleLibrary.Lookup( 1 );
       
   177     if ( !factoryFunction )
       
   178         {
       
   179         iConnData[index].iModuleLibrary.Close();
       
   180         FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() (ERROR) complete")));
       
   181         return KErrNotFound;
       
   182         }
       
   183     MDunLocalMediaPlugin* localPlugin =
       
   184         reinterpret_cast<MDunLocalMediaPlugin*>( factoryFunction() );
       
   185     if ( !localPlugin )
       
   186         {
       
   187         iConnData[index].iModuleLibrary.Close();
       
   188         FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() (ERROR) complete")));
       
   189         return KErrGeneral;
       
   190         }
       
   191     iConnData[index].iLocalModulePtr = localPlugin;
       
   192     FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() constructing")));
       
   193     TRAPD( retTrap, localPlugin->ConstructL(&iParent, iTransporter) );
       
   194     if ( retTrap != KErrNone )
       
   195         {
       
   196         delete iConnData[index].iLocalModulePtr;
       
   197         iConnData[index].iLocalModulePtr = NULL;
       
   198         iConnData[index].iModuleLibrary.Close();
       
   199         FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() (ERROR) complete")));
       
   200         return retTrap;
       
   201         }
       
   202     iConnData[index].iPluginState = EDunStateLoaded;
       
   203     FTRACE(FPrint(_L("CDunServerUtils::ConstructLocalMediaModule() complete")));
       
   204     return KErrNone;
       
   205     }
       
   206 
       
   207 // ---------------------------------------------------------------------------
       
   208 // From class MDunServerUtility.
       
   209 // Clears queued UIDs
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 TBool CDunServerUtils::ClearQueuedUIDs( TUid aPluginUid,
       
   213                                         TBool aClearClosed,
       
   214                                         TBool aClearQueued )
       
   215     {
       
   216     FTRACE(FPrint(_L("CDunServerUtils::ClearQueuedUIDs()")));
       
   217     TInt i;
       
   218     TBool cleared = EFalse;
       
   219     if ( aClearClosed )
       
   220         {
       
   221         for ( i=iClosedQueue.Count()-1; i>=0; i-- )
       
   222             {
       
   223             if ( iClosedQueue[i] == aPluginUid )
       
   224                 {
       
   225                 iClosedQueue.Remove( i );
       
   226                 cleared = ETrue;
       
   227                 FTRACE(FPrint(_L("CDunServerUtils::ClearQueuedUIDs() removed from closed queue at %d"), i));
       
   228                 }
       
   229             }
       
   230         }
       
   231     if ( aClearQueued )
       
   232         {
       
   233         for ( i=iPluginQueue.Count()-1; i>=0; i-- )
       
   234             {
       
   235             if ( iPluginQueue[i] == aPluginUid )
       
   236                 {
       
   237                 iPluginQueue.Remove( i );
       
   238                 cleared = ETrue;
       
   239                 FTRACE(FPrint(_L("CDunServerUtils::ClearQueuedUIDs() removed from plugin queue at %d"), i));
       
   240                 }
       
   241             }
       
   242         }
       
   243     FTRACE(FPrint(_L("CDunServerUtils::ClearQueuedUIDs() complete")));
       
   244     return cleared;
       
   245     }
       
   246 
       
   247 // ---------------------------------------------------------------------------
       
   248 // From class MDunServerUtility.
       
   249 // Tries to close loaded local media plugin
       
   250 // ---------------------------------------------------------------------------
       
   251 //
       
   252 TInt CDunServerUtils::TryClosePlugin( TInt aIndex,
       
   253                                       TBool aDequeue,
       
   254                                       TBool aClientClose,
       
   255                                       TBool aSelfClose )
       
   256     {
       
   257     FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin()")));
       
   258     if ( aIndex < 0 ||
       
   259          aIndex >= iConnData.Count() )
       
   260         {
       
   261         FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin() (not found) complete")));
       
   262         return KErrNotFound;
       
   263         }
       
   264     TInt retTemp = TryUninitialize( aIndex );
       
   265     if ( retTemp != KErrNone )
       
   266         {
       
   267         FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin() (ERROR) complete")));
       
   268         return retTemp;
       
   269         }
       
   270     if ( !aSelfClose )
       
   271         {
       
   272         retTemp = DoClosePlugin( aIndex, aDequeue, aClientClose );
       
   273         FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin() complete")));
       
   274         return retTemp;
       
   275         }
       
   276     retTemp = iCloseWait->AddPluginToClose( iConnData[aIndex].iLocalModulePtr );
       
   277     if ( retTemp != KErrNone )
       
   278         {
       
   279         iConnData[aIndex].iPluginState = EDunStateZombie;
       
   280         FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin() state changed to %d"), EDunStateZombie));
       
   281         return retTemp;
       
   282         }
       
   283     retTemp = iCloseWait->IssueRequest();
       
   284     if ( retTemp != KErrNone )
       
   285         {
       
   286         iConnData[aIndex].iPluginState = EDunStateZombie;
       
   287         FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin() state changed to %d"), EDunStateZombie));
       
   288         return retTemp;
       
   289         }
       
   290     FTRACE(FPrint(_L("CDunServerUtils::TryClosePlugin() (waiting) complete")));
       
   291     return KErrNone;
       
   292     }
       
   293 
       
   294 // ---------------------------------------------------------------------------
       
   295 // From class MDunServerUtility.
       
   296 // Closes a plugin directly without uninitializing it
       
   297 // ---------------------------------------------------------------------------
       
   298 //
       
   299 TInt CDunServerUtils::DoClosePlugin(
       
   300     TInt aIndex,
       
   301     TBool aDequeue,
       
   302     TBool aClientClose )
       
   303     {
       
   304     FTRACE(FPrint(_L("CDunServerUtils::DoClosePlugin()")));
       
   305     if ( aIndex < 0 ||
       
   306          aIndex >= iConnData.Count() )
       
   307         {
       
   308         FTRACE(FPrint(_L("CDunServerUtils::DoClosePlugin() (not found) complete")));
       
   309         return KErrNotFound;
       
   310         }
       
   311     TUid pluginUid = iConnData[aIndex].iLocalModuleUid;
       
   312     DoImmediatePluginClose( aIndex, aDequeue );
       
   313     if ( !aClientClose )
       
   314         {
       
   315         // Plugin was closed by something else than client
       
   316         // Enqueue it to closed queue
       
   317         TInt i;
       
   318         TInt count = iClosedQueue.Count();
       
   319         for ( i=0; i<count; i++ )
       
   320             {
       
   321             if ( iClosedQueue[i] == pluginUid )
       
   322                 {
       
   323                 FTRACE(FPrint(_L("CDunServerUtils::DoClosePlugin() (already exists) complete")));
       
   324                 return KErrAlreadyExists;
       
   325                 }
       
   326             }
       
   327         TInt retTemp = iClosedQueue.Append( pluginUid );
       
   328         if ( retTemp != KErrNone )
       
   329             {
       
   330             FTRACE(FPrint(_L("CDunServerUtils::DoClosePlugin() (append failed!) complete")));
       
   331             return retTemp;
       
   332             }
       
   333         FTRACE(FPrint(_L("CDunServerUtils::DoClosePlugin() appended to index %d"), iClosedQueue.Count()-1));
       
   334         }
       
   335     FTRACE(FPrint(_L("CDunServerUtils::DoClosePlugin() complete")));
       
   336     return KErrNone;
       
   337     }
       
   338 
       
   339 // ---------------------------------------------------------------------------
       
   340 // From class MDunServerUtility.
       
   341 // Does immediate close of plugin
       
   342 // ---------------------------------------------------------------------------
       
   343 //
       
   344 TInt CDunServerUtils::DoImmediatePluginClose( TInt aIndex, TBool aDequeue )
       
   345     {
       
   346     FTRACE(FPrint(_L("CDunServerUtils::DoImmediatePluginClose()")));
       
   347     if ( aIndex < 0 ||
       
   348          aIndex >= iConnData.Count() )
       
   349         {
       
   350         FTRACE(FPrint(_L("CDunServerUtils::DoImmediatePluginClose() (not found) complete")));
       
   351         return KErrNotFound;
       
   352         }
       
   353     delete iConnData[aIndex].iLocalModulePtr;
       
   354     iConnData[aIndex].iLocalModulePtr = NULL;
       
   355     if ( iConnData[aIndex].iModuleLibrary.Handle() != KNullHandle )
       
   356         {
       
   357         iConnData[aIndex].iModuleLibrary.Close();
       
   358         }
       
   359     iConnData.Remove( aIndex );
       
   360     // Now, the following check is needed to avoid recursion by:
       
   361     // ReopenQueuedPlugins()->OpenMediaByUid()->TryClosePlugin()->
       
   362     // DoImmediatePluginClose()->ReopenQueuedPlugins()
       
   363     if ( aDequeue )
       
   364         {
       
   365         iParent.ReopenQueuedPlugins();
       
   366         }
       
   367     // Ignore error(s); this function must only report it's own operation status
       
   368     FTRACE(FPrint(_L("CDunServerUtils::DoImmediatePluginClose() complete")));
       
   369     return KErrNone;
       
   370     }
       
   371 
       
   372 // ---------------------------------------------------------------------------
       
   373 // From class MDunServerUtility.
       
   374 // Tries uninitialization and after that listening state switch on a plugin
       
   375 // ---------------------------------------------------------------------------
       
   376 //
       
   377 TInt CDunServerUtils::TryInitializeToListening( TUid aPluginUid )
       
   378     {
       
   379     FTRACE(FPrint(_L("CDunServerUtils::TryInitializeToListening()")));
       
   380     TInt i;
       
   381     TInt count = iConnData.Count();
       
   382     for ( i=0; i<count; i++ )
       
   383         {
       
   384         if ( iConnData[i].iLocalModuleUid == aPluginUid )
       
   385             {
       
   386             break;
       
   387             }
       
   388         }
       
   389     if ( i >= count )
       
   390         {
       
   391         FTRACE(FPrint(_L("CDunServerUtils::TryInitializeToListening() (not found) complete")));
       
   392         return KErrNotFound;
       
   393         }
       
   394     TInt retTemp = TryUninitialize( i );
       
   395     if ( retTemp != KErrNone )
       
   396         {
       
   397         FTRACE(FPrint(_L("CDunServerUtils::TryInitializeToListening() (uninitialize error) complete")));
       
   398         return retTemp;
       
   399         }
       
   400     // Change from Uninitialized to Loaded because listening mode needs it
       
   401     // (plugin is already loaded anyway)
       
   402     iConnData[i].iPluginState = EDunStateLoaded;
       
   403     retTemp = TryListening( i );
       
   404     if ( retTemp != KErrNone )
       
   405         {
       
   406         FTRACE(FPrint(_L("CDunServerUtils::TryInitializeToListening() (listening error) complete")));
       
   407         return retTemp;
       
   408         }
       
   409     FTRACE(FPrint(_L("CDunServerUtils::TryInitializeToListening() complete")));
       
   410     return KErrNone;
       
   411     }
       
   412 
       
   413 // ---------------------------------------------------------------------------
       
   414 // From class MDunServerUtility.
       
   415 // Tries listening state switch on a plugin
       
   416 // ---------------------------------------------------------------------------
       
   417 //
       
   418 TInt CDunServerUtils::TryListening( TInt aIndex )
       
   419     {
       
   420     FTRACE(FPrint(_L("CDunServerUtils::TryListening()")));
       
   421     if ( aIndex < 0 ||
       
   422          aIndex >= iConnData.Count() )
       
   423         {
       
   424         FTRACE(FPrint(_L("CDunServerUtils::TryListening() (not found) complete")));
       
   425         return KErrNotFound;
       
   426         }
       
   427     if ( iConnData[aIndex].iPluginState != EDunStateLoaded )
       
   428         {
       
   429         FTRACE(FPrint(_L("CDunServerUtils::TryListening() (not ready) complete")));
       
   430         return KErrNotReady;
       
   431         }
       
   432     FTRACE(FPrint(_L("CDunServerUtils::TryListening() notifying server state change (%d)"), EDunStateTryListen));
       
   433     TInt retTemp =
       
   434         iConnData[aIndex].iLocalModulePtr->NotifyServerStateChange( EDunStateTryListen );
       
   435     if ( retTemp != KErrNone )
       
   436         {
       
   437         iConnData[aIndex].iPluginState = EDunStateZombie;
       
   438         FTRACE(FPrint(_L("CDunServerUtils::TryListening() state changed to %d"), EDunStateZombie));
       
   439         FTRACE(FPrint(_L("CDunServerUtils::TryListening() (ERROR) complete")));
       
   440         return retTemp;
       
   441         }
       
   442     // Plugin could have changed state, only change state if possible
       
   443     // This can happen if plugin has no real listening and switches directly
       
   444     // from listening mode to channeled mode
       
   445     if ( iConnData[aIndex].iPluginState == EDunStateTryListen )
       
   446         {
       
   447         iConnData[aIndex].iPluginState = EDunStateListening;
       
   448         }
       
   449     FTRACE(FPrint(_L("CDunServerUtils::TryListening() state changed to %d"), EDunStateListening));
       
   450     FTRACE(FPrint(_L("CDunServerUtils::TryListening() complete")));
       
   451     return KErrNone;
       
   452     }
       
   453 
       
   454 // ---------------------------------------------------------------------------
       
   455 // From class MDunServerUtility.
       
   456 // Tries uninitialization of a plugin
       
   457 // ---------------------------------------------------------------------------
       
   458 //
       
   459 TInt CDunServerUtils::TryUninitialize( TInt aIndex )
       
   460     {
       
   461     FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize()")));
       
   462     if ( aIndex < 0 ||
       
   463          aIndex >= iConnData.Count() )
       
   464         {
       
   465         FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() (not found) complete")));
       
   466         return KErrNotFound;
       
   467         }
       
   468     if ( iConnData[aIndex].iPluginState == EDunStateUninitialized )
       
   469         {
       
   470         FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() (already uninitialized) complete")));
       
   471         return KErrNotReady;
       
   472         }
       
   473     FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() notifying server state change (%d)"), EDunStateTryUninitialize));
       
   474     TInt retTemp =
       
   475         iConnData[aIndex].iLocalModulePtr->NotifyServerStateChange( EDunStateTryUninitialize );
       
   476     if ( retTemp != KErrNone )
       
   477         {
       
   478         iConnData[aIndex].iPluginState = EDunStateZombie;
       
   479         FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() state changed to %d"), EDunStateZombie));
       
   480         FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() (ERROR) complete")));
       
   481         return retTemp;
       
   482         }
       
   483     // Plugin state must be EDunStateLoaded after uninitialization
       
   484     if ( iConnData[aIndex].iPluginState == EDunStateLoaded )
       
   485         {
       
   486         iConnData[aIndex].iPluginState = EDunStateUninitialized;
       
   487         FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() state changed to %d"), EDunStateUninitialized));
       
   488         }
       
   489     else
       
   490         {
       
   491         // Should never come here
       
   492         iConnData[aIndex].iPluginState = EDunStateZombie;
       
   493         FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() state changed to %d"), EDunStateZombie));
       
   494         }
       
   495     FTRACE(FPrint(_L("CDunServerUtils::TryUninitialize() complete")));
       
   496     return KErrNone;
       
   497     }