rtsecuritymanager/rtsecuritymanagerclient/src/rtsecmgrclient.cpp
changeset 1 e20d19ef9b09
parent 0 99ef825efeca
child 10 a7062f7f0b79
equal deleted inserted replaced
0:99ef825efeca 1:e20d19ef9b09
    49 // This function attemtps to kick start security manager server if
    49 // This function attemtps to kick start security manager server if
    50 // it is not running already. The number of attempts is currently 2.
    50 // it is not running already. The number of attempts is currently 2.
    51 // The number of message slot is defaulted to 4.
    51 // The number of message slot is defaulted to 4.
    52 // ---------------------------------------------------------------------------
    52 // ---------------------------------------------------------------------------
    53 //
    53 //
    54 TInt RSecMgrSession::Connect()
    54 /*TInt RSecMgrSession::Connect()
    55 	{
    55 	{
    56 	RTSecMgrTraceFunction("RSecMgrSession::Connect()") ;
    56 	RTSecMgrTraceFunction("RSecMgrSession::Connect()") ;
    57 	TInt retry(KSecSrvClientTryCount); // Try this twice
    57 	TInt retry(KSecSrvClientTryCount); // Try this twice
    58 	TInt err(KErrNone);
    58 	TInt err(KErrNone);
    59 	while (retry>KErrNone)
    59 	while (retry>KErrNone)
    89 			}
    89 			}
    90 
    90 
    91 		retry--;
    91 		retry--;
    92 		}
    92 		}
    93 	return (err);
    93 	return (err);
    94 	}
    94 	}*/
       
    95 
       
    96 TInt RSecMgrSession::Connect()
       
    97     {
       
    98     RTSecMgrTraceFunction("RSecMgrSession::Connect()") ;
       
    99     TInt err(KErrNone);
       
   100         // Try to create a Server session
       
   101     err = CreateSession ( KSecServerProcessName, Version (),
       
   102             KDefaultMessageSlots);
       
   103 
       
   104     if ( err != KErrNotFound && err != KErrServerTerminated)
       
   105         {
       
   106         // KErrNone or unrecoverable error
       
   107         if ( err != KErrNone)
       
   108             {
       
   109 #ifdef _DEBUG
       
   110             RDebug::Print(KServerStartFailed);
       
   111 #endif
       
   112             }
       
   113         
       
   114         }
       
   115     else
       
   116         {
       
   117         // Return code was KErrNotFound or KErrServerTerminated.
       
   118         // Try to start a new security manager server instance
       
   119         TInt retry(KSecSrvClientTryCount);
       
   120         while(retry > 0)
       
   121             {
       
   122             err = StartSecManagerServer ();
       
   123             if ( err != KErrNone && err != KErrAlreadyExists)
       
   124                 {
       
   125                 // Unrecoverable error
       
   126                 #ifdef _DEBUG
       
   127                             RDebug::Print(KServerStartFailed);
       
   128                 #endif
       
   129                 retry = 0;
       
   130                 }
       
   131             else
       
   132                 {
       
   133                 err = CreateSession ( KSecServerProcessName, Version (),
       
   134                                                 KDefaultMessageSlots);
       
   135                 if(err != KErrNotFound && err != KErrServerTerminated)
       
   136                     {
       
   137                     if ( err != KErrNone)
       
   138                                 {
       
   139                     #ifdef _DEBUG
       
   140                                 RDebug::Print(KServerStartFailed);
       
   141                     #endif
       
   142                                 }
       
   143                     retry = 0;
       
   144                     }
       
   145                 }
       
   146             retry--;
       
   147             }
       
   148         }       
       
   149     return (err);
       
   150     }
    95 
   151 
    96 // ---------------------------------------------------------------------------
   152 // ---------------------------------------------------------------------------
    97 // Starts runtime security manager server
   153 // Starts runtime security manager server
    98 //
   154 //
    99 // ---------------------------------------------------------------------------
   155 // ---------------------------------------------------------------------------