realtimenetprots/sipfw/ProfileAgent/Client/Src/SIPProfileServerStarter.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name        : sipprofileserverstarter
       
    15 // Part of     : SIP Profile Client
       
    16 // implementation
       
    17 // Version     : 1.0
       
    18 // INCLUDE FILES
       
    19 //
       
    20 
       
    21 
       
    22 
       
    23 #include <e32math.h>
       
    24 #include "SIPProfileServerStarter.h"
       
    25 #include "sipprofilecs.h"
       
    26 #include "sipprofileclient.pan"
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // TSIPProfileServerStarter::Start
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 TInt TSIPProfileServerStarter::Start()
       
    35 	{	
       
    36     TFindServer findServer(KSipProfileServerName);
       
    37     TFullName name;
       
    38 	TInt err = findServer.Next(name);
       
    39 	if (err == KErrNone) 
       
    40 	    {
       
    41 	    return KErrNone;
       
    42 	    }
       
    43 	// Start the server 
       
    44 	RSemaphore semaphore;
       
    45 	err = semaphore.CreateGlobal(KSipProfileServerSemaphoreName,0); 
       
    46     if (err != KErrNone)
       
    47         {
       
    48         err = semaphore.OpenGlobal(KSipProfileServerSemaphoreName);
       
    49         if (err != KErrNone)
       
    50             {
       
    51             return err;
       
    52             }
       
    53         }
       
    54     err = CreateServerProcess();
       
    55     if (err == KErrNone) 
       
    56         {
       
    57         semaphore.Wait();
       
    58 	    }
       
    59 	semaphore.Close();
       
    60     return err;
       
    61 	}
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // TSIPProfileServerStarter::CreateServerProcess
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 TInt TSIPProfileServerStarter::CreateServerProcess()
       
    68 	{
       
    69     TInt err;
       
    70 	const TUidType serverUid(KNullUid, KNullUid, KServerUid3);
       
    71 	RProcess server;
       
    72 	err = server.Create(KSipProfileServerName, _L(""), serverUid);
       
    73     if (err != KErrNone) 
       
    74         {
       
    75         return err;
       
    76         }
       
    77 	server.Resume();
       
    78 	server.Close();
       
    79     return  KErrNone;
       
    80 	}