PECengine/CoreUtilsLib2/SrvSrc/TPEngServerParams.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Server startup parameters.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "TPEngServerParams.h"
       
    19 #include "PresenceDebugPrint.h"
       
    20 #include <E32std.h>
       
    21 
       
    22 
       
    23 
       
    24 // -----------------------------------------------------------------------------
       
    25 // TPEngServerParams::TPEngServerParams()
       
    26 // -----------------------------------------------------------------------------
       
    27 //
       
    28 EXPORT_C TPEngServerParams::TPEngServerParams()
       
    29         : iServerName( KNullDesC ),
       
    30         iParam1( KErrNone ),
       
    31         iParam2( KErrNone )
       
    32     {
       
    33     }
       
    34 
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // TPEngServerParams::TPEngServerParams()
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 EXPORT_C TPEngServerParams::TPEngServerParams( const TDesC& aServerName,
       
    41                                                TInt aParam1,
       
    42                                                TInt aParam2 )
       
    43         : iServerName( aServerName ),
       
    44         iParam1( aParam1 ),
       
    45         iParam2( aParam2 )
       
    46     {
       
    47     }
       
    48 
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // TPEngServerParams::AsCommandLine()
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 EXPORT_C TPtrC TPEngServerParams::AsCommandLine() const
       
    55     {
       
    56     return TPtrC( ( TText16* )this, sizeof( TPEngServerParams ) / 2 );
       
    57     }
       
    58 
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // TPEngServerParams::InitFromCmdLine()
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 EXPORT_C TInt TPEngServerParams::InitFromCmdLine()
       
    65     {
       
    66     TPtr selfBuffer( ( TText16* )this, sizeof( TPEngServerParams ) / 2 );
       
    67 
       
    68 
       
    69     TInt commandLineLength = 0;
       
    70     commandLineLength = User::CommandLineLength();
       
    71 
       
    72     if ( commandLineLength == selfBuffer.MaxLength() )
       
    73         {
       
    74         User::CommandLine( selfBuffer );
       
    75 
       
    76 
       
    77         PENG_DP( D_PENG_LIT( "TPEngServerParams::InitFromCmdLine() N[%S] P1[%d] P2[%d]" ),
       
    78                  &iServerName, iParam1, iParam2 );
       
    79         return KErrNone;
       
    80         }
       
    81 
       
    82     PENG_DP( D_PENG_LIT( "TPEngServerParams::InitFromCmdLine() - No ServerParams present in commandline" ) );
       
    83     return KErrNotFound;
       
    84     }
       
    85 
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // TPEngServerParams::RenameMainThread()
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C void TPEngServerParams::RenameMainThread( const TDesC& aThreadName )
       
    92     {
       
    93     PENG_DP( D_PENG_LIT( "TPEngServerParams::RenameMainThread()" ) );
       
    94 
       
    95     //Do not care if renaming fails. Renaming is done only to find guilty
       
    96     //when something is crashing.
       
    97     User::RenameThread( aThreadName );
       
    98 
       
    99 #ifdef PENG_ENABLE_DEBUG_PRINT
       
   100     TBuf< 256 > buffer;
       
   101     buffer.Append( _L( "Process[" ) );          // CSI: 78 #
       
   102     buffer.Append( RProcess().Name() );
       
   103     buffer.Append( _L( "] Thread[" ) );         // CSI: 78 #
       
   104     buffer.Append( RThread().Name() );
       
   105     buffer.Append( _L( "]" ) );                 // CSI: 78 #
       
   106     PENG_DP( buffer );
       
   107 #endif //PENG_ENABLE_DEBUG_PRINT
       
   108     }
       
   109 
       
   110 
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // TPEngServerParams::Signal()
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 EXPORT_C void TPEngServerParams::Signal()
       
   117     {
       
   118     RProcess::Rendezvous( KErrNone );
       
   119     }
       
   120 
       
   121 
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // TPEngServerParams::Param1()
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 EXPORT_C TInt TPEngServerParams::Param1() const
       
   128     {
       
   129     return iParam1;
       
   130     }
       
   131 
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // TPEngServerParams::Param2()
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 EXPORT_C TInt TPEngServerParams::Param2() const
       
   138     {
       
   139     return iParam2;
       
   140     }
       
   141 
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // TPEngServerParams::ServerName()
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 EXPORT_C const TDesC& TPEngServerParams::ServerName() const
       
   148     {
       
   149     return iServerName;
       
   150     }
       
   151 
       
   152 
       
   153 
       
   154 //End of file
       
   155