tacticonserver/client/src/tacticon.cpp
changeset 0 d54f32e146dd
child 12 63c33341dc19
equal deleted inserted replaced
-1:000000000000 0:d54f32e146dd
       
     1 /*
       
     2 * Copyright (c) 2009 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: Client interface to tacticon server
       
    15 * Part of    : Tacticon Server
       
    16 */
       
    17 
       
    18 #include <tacticon.h>
       
    19 #include <featmgr.h>
       
    20 #include "tacticontrace.h"
       
    21 #include "tacticondefs.h"
       
    22 #include "osttracedefinitions.h" 
       
    23 #ifdef OST_TRACE_COMPILER_IN_USE 
       
    24 #include "tacticonTraces.h"
       
    25 #endif
       
    26 
       
    27 //------------------------------------------------------------
       
    28 // Starts the server
       
    29 //------------------------------------------------------------
       
    30 //
       
    31 TInt StartServer()
       
    32     {
       
    33     TRACE("Tacticon client StartServer() - Begin");
       
    34     TInt res = KErrNone;
       
    35 
       
    36     // DLL launch
       
    37     RProcess server;
       
    38     res = server.Create( KTacticonServerName, KNullDesC );
       
    39 
       
    40     // Loading failed.
       
    41     if ( res != KErrNone )
       
    42         {
       
    43         return res;
       
    44         }
       
    45     
       
    46     TRequestStatus status;
       
    47     server.Rendezvous( status );
       
    48 
       
    49     if ( status != KRequestPending )
       
    50         {
       
    51         TRACE( "Tacticon server StartServer() - Rendezvous failed" );
       
    52         server.Kill( 0 );       // abort startup
       
    53         server.Close();
       
    54         return KErrGeneral;
       
    55         }
       
    56     else
       
    57         {
       
    58         TRACE( "Tacticon server StartServer() - Resume" );
       
    59         server.Resume();    // Logon OK - start the server.
       
    60         }
       
    61         
       
    62     User::WaitForRequest( status );
       
    63     server.Close();
       
    64     
       
    65     TRACE("Tacticon client StartServer() - End");
       
    66     return status.Int();
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------
       
    70 // Default constructor
       
    71 // ---------------------------------------------------------
       
    72 //
       
    73 EXPORT_C RTacticon::RTacticon()
       
    74     {
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------
       
    78 // Creates connection to tacticon server
       
    79 // ---------------------------------------------------------
       
    80 //
       
    81 EXPORT_C TInt RTacticon::Connect()
       
    82     { 
       
    83     TRACE("RTacticon::Connect() - Begin");
       
    84     // Check if Tacticon feature is supported or not
       
    85     TRAPD( ret, FeatureManager::InitializeLibL() );
       
    86     if ( KErrNone == ret )
       
    87         {
       
    88         TBool supported = 
       
    89             FeatureManager::FeatureSupported( KFeatureIdFfTacticons );
       
    90         FeatureManager::UnInitializeLib();    
       
    91     
       
    92         ret = KErrNotSupported;
       
    93         if ( supported )          
       
    94             {
       
    95             TRACE("RTacticon::Connect() - CreateSession");
       
    96             ret = CreateSession( KTacticonServerName, Version() );
       
    97             if ( ret != KErrNone )
       
    98                 {
       
    99                 ret = StartServer();
       
   100                 if ( ret == KErrNone )
       
   101                     {
       
   102                     TRACE2("RTacticon::Connect() - StartServer(%d)", ret);
       
   103                     ret = CreateSession( KTacticonServerName, Version() );
       
   104                     }
       
   105                }
       
   106             }
       
   107         else
       
   108             {
       
   109             TRACE("RTacticon::Connect() - Feature not supported");
       
   110             }
       
   111         }
       
   112     else
       
   113         {
       
   114         TRACE2("RTacticon::Connect() - FeatureManager init leaves (%d)", ret );
       
   115         }    
       
   116     TRACE2("RTacticon::Connect() - End(%d)", ret);
       
   117     return ret;    
       
   118     }
       
   119     
       
   120 // ---------------------------------------------------------
       
   121 // Closes connection to tacticon server
       
   122 // ---------------------------------------------------------
       
   123 //      
       
   124 EXPORT_C void RTacticon::Close()
       
   125     {   
       
   126     if ( iHandle )
       
   127         {
       
   128         RSessionBase::Close();
       
   129         }
       
   130     }
       
   131         
       
   132 // --------------------------------------------------------------------------
       
   133 // Plays tacticon
       
   134 // --------------------------------------------------------------------------
       
   135 //     
       
   136 EXPORT_C void RTacticon::PlayTacticon( TTacticonType aTacticonType )
       
   137     {
       
   138     if ( iHandle )
       
   139         {
       
   140         TRACE("RTacticon::PlayTacticon - Begin");
       
   141         OstTrace0( TACTICON_PERFORMANCE, TACTICON_CLIENT_PLAY_TACTICON_1,
       
   142                    "e_TACTICON_CLIENT_PLAY_TACTICON 1" );
       
   143         SendReceive( EPlayTacticon, TIpcArgs( aTacticonType ) );   
       
   144         OstTrace0( TACTICON_PERFORMANCE, TACTICON_CLIENT_PLAY_TACTICON_0,
       
   145                    "e_TACTICON_CLIENT_PLAY_TACTICON 0" );
       
   146         TRACE("RTacticon::PlayTacticon - End");
       
   147         }
       
   148     }
       
   149     
       
   150 // --------------------------------------------------------------------------
       
   151 // Stops playing current tacticon
       
   152 //
       
   153 // --------------------------------------------------------------------------
       
   154 //     
       
   155 EXPORT_C void RTacticon::StopTacticon()
       
   156     {
       
   157     if ( iHandle )
       
   158         {
       
   159         TRACE("RTacticon::StopTacticon() - Begin");
       
   160         OstTrace0( TACTICON_PERFORMANCE, TACTICON_CLIENT_STOP_TACTICON_1,
       
   161                    "e_TACTICON_CLIENT_STOP_TACTICON 1" );
       
   162         SendReceive( EStopTacticon, TIpcArgs() );   
       
   163         OstTrace0( TACTICON_PERFORMANCE, TACTICON_CLIENT_STOP_TACTICON_0,
       
   164                    "e_TACTICON_CLIENT_STOP_TACTICON 0" );
       
   165         TRACE("RTacticon::StopTacticon() - End");
       
   166         }
       
   167     }   
       
   168 
       
   169 // --------------------------------------------------------------------------
       
   170 // Enable/disable tacticon playback.
       
   171 //
       
   172 // --------------------------------------------------------------------------
       
   173 //     
       
   174 EXPORT_C TInt RTacticon::EnableTacticons( TBool aEnabled )
       
   175     {
       
   176     TInt ret( KErrSessionClosed );
       
   177     if ( iHandle )
       
   178         {
       
   179         TRACE("RTacticon::EnableTacticons() - Begin");
       
   180         OstTrace0( TACTICON_PERFORMANCE, TACTICON_CLIENT_ENABLE_TACTICON_1,
       
   181                    "e_TACTICON_CLIENT_ENABLE_TACTICON 1" );
       
   182 
       
   183         ret = SendReceive( EEnableTacticons, TIpcArgs( aEnabled ) );
       
   184 
       
   185         OstTrace0( TACTICON_PERFORMANCE, TACTICON_CLIENT_ENABLE_TACTICON_0,
       
   186                    "e_TACTICON_CLIENT_ENABLE_TACTICON 0" );
       
   187         TRACE("RTacticon::EnableTacticons() - End");
       
   188         }
       
   189     return ret;
       
   190     }      
       
   191 
       
   192 // --------------------------------------------------------------------------
       
   193 // Returns boolean value whether tacticons are enabled or disabled.
       
   194 //
       
   195 // --------------------------------------------------------------------------
       
   196 //     
       
   197 EXPORT_C TBool RTacticon::TacticonsEnabled()
       
   198     {
       
   199     TBool enabled( EFalse );
       
   200     if ( iHandle )
       
   201         {
       
   202         TRACE("RTacticon::TacticonsEnabled() - Begin");
       
   203         TPckg<TBool> enabledBuf( enabled );
       
   204         SendReceive( ETacticonsEnabled, TIpcArgs( &enabledBuf ) );
       
   205 
       
   206         TRACE("RTacticon::TacticonsEnabled() - End");
       
   207         }
       
   208     return enabled;
       
   209     }   
       
   210 
       
   211 // ---------------------------------------------------------
       
   212 // Returns tacticon server version
       
   213 // ---------------------------------------------------------
       
   214 //      
       
   215 TVersion RTacticon::Version() const
       
   216     {
       
   217     return TVersion( KTacticonServerMajor, 
       
   218                      KTacticonServerMinor,
       
   219                      KTacticonServerBuild );
       
   220     }
       
   221 
       
   222 
       
   223 // End of File