srsf/speechsynthesis/server/src/speechsynthesisserverutilities.cpp
branchRCL_3
changeset 23 e36f3802f733
parent 0 bf1d17376201
equal deleted inserted replaced
22:cad71a31b7fc 23:e36f3802f733
       
     1 /*
       
     2 * Copyright (c) 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:  Speech synthesis server utility classes
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 
       
    21 #include <swi/swispubsubdefs.h>         // For listening sw installer's actions
       
    22 #include <UikonInternalPSKeys.h>    // For listening memory card insertion/removal
       
    23 
       
    24 #include "speechsynthesisserverutilities.h"
       
    25 #include "rubydebug.h"
       
    26 
       
    27 
       
    28 // ----------------------------------------------------------------------------
       
    29 // PanicClient
       
    30 //
       
    31 // ----------------------------------------------------------------------------
       
    32 //
       
    33 void PanicClient( const RMessagePtr2& aMessage, TSpeechSynthesisPanic aPanic )
       
    34     {
       
    35     aMessage.Panic( KPanic, aPanic );
       
    36     }
       
    37     
       
    38     
       
    39 // ----------------------------------------------------------------------------
       
    40 // CShutdown::NewL
       
    41 // 
       
    42 // ----------------------------------------------------------------------------
       
    43 CShutdown* CShutdown::NewL()
       
    44     {
       
    45     CShutdown* self = new(ELeave) CShutdown();
       
    46     
       
    47     CleanupStack::PushL( self );
       
    48     self->ConstructL();
       
    49     CleanupStack::Pop( self );
       
    50     
       
    51     return self;
       
    52     }
       
    53 
       
    54 // ----------------------------------------------------------------------------
       
    55 // CShutdown::CShutdown
       
    56 // 
       
    57 // ----------------------------------------------------------------------------
       
    58 inline CShutdown::CShutdown():
       
    59     CTimer( EPriorityIdle ) 
       
    60     {
       
    61     CActiveScheduler::Add( this );
       
    62     }
       
    63     
       
    64 // ----------------------------------------------------------------------------
       
    65 // CShutdown::ConstructL
       
    66 // 
       
    67 // ----------------------------------------------------------------------------
       
    68 //
       
    69 inline void CShutdown::ConstructL()
       
    70     {
       
    71     CTimer::ConstructL();
       
    72     }
       
    73 
       
    74 // ----------------------------------------------------------------------------
       
    75 // CShutdown::Start
       
    76 // 
       
    77 // ----------------------------------------------------------------------------
       
    78 //
       
    79 void CShutdown::Start()
       
    80     {
       
    81     RUBY_DEBUG0( "SpeechSynthesisServer: starting shutdown timeout" );
       
    82     
       
    83     After( KSpeechSynthesisShutdownDelay );
       
    84     }
       
    85 
       
    86 // ----------------------------------------------------------------------------
       
    87 // CShutdown::RunL
       
    88 //
       
    89 // ----------------------------------------------------------------------------
       
    90 //
       
    91 void CShutdown::RunL()
       
    92     {
       
    93     RUBY_DEBUG0( "SpeechSynthesisServer: server timeout ... closing" );
       
    94     
       
    95     CActiveScheduler::Stop();
       
    96     }
       
    97 
       
    98 
       
    99 // ----------------------------------------------------------------------------
       
   100 // CConfigurationListener::NewL
       
   101 //
       
   102 // ----------------------------------------------------------------------------
       
   103 //
       
   104 CConfigurationListener* CConfigurationListener::NewL( MConfigurationObserver& aHost )
       
   105     {
       
   106     RUBY_DEBUG_BLOCK( "" );
       
   107     
       
   108     CConfigurationListener* self = new(ELeave) CConfigurationListener( aHost );
       
   109     
       
   110     CleanupStack::PushL( self );
       
   111     self->ConstructL();
       
   112     CleanupStack::Pop( self);
       
   113     
       
   114     return self;
       
   115     }
       
   116 
       
   117 // ----------------------------------------------------------------------------
       
   118 // CConfigurationListener::CConfigurationListener
       
   119 //
       
   120 // ----------------------------------------------------------------------------
       
   121 //
       
   122 CConfigurationListener::CConfigurationListener(  MConfigurationObserver& aHost ) :
       
   123     CActive( CActive::EPriorityLow ),
       
   124     iHost( aHost )
       
   125     {
       
   126     // Nothing 
       
   127     }
       
   128 
       
   129 // ----------------------------------------------------------------------------
       
   130 // CConfigurationListener::ConstructL
       
   131 //
       
   132 // ----------------------------------------------------------------------------
       
   133 //
       
   134 void CConfigurationListener::ConstructL()
       
   135     {
       
   136     User::LeaveIfError( iProperty.Attach( KUidSystemCategory, 
       
   137                                           Swi::KUidSoftwareInstallKey ) );
       
   138     
       
   139     CActiveScheduler::Add( this );
       
   140     
       
   141     // Initial subscription
       
   142     iProperty.Subscribe( iStatus );
       
   143     SetActive();
       
   144     }
       
   145 
       
   146 // ----------------------------------------------------------------------------
       
   147 // CConfigurationListener::~CConfigurationListener
       
   148 //
       
   149 // ----------------------------------------------------------------------------
       
   150 //
       
   151 CConfigurationListener::~CConfigurationListener()
       
   152     {
       
   153     RUBY_DEBUG0( "Destructing.." );
       
   154     Cancel();
       
   155     iProperty.Close();
       
   156     }
       
   157 
       
   158 // ----------------------------------------------------------------------------
       
   159 // CConfigurationListener::DoCancel
       
   160 //
       
   161 // ----------------------------------------------------------------------------
       
   162 //
       
   163 void CConfigurationListener::DoCancel()
       
   164     {
       
   165     RUBY_DEBUG0( "DoCancel" )
       
   166     iProperty.Cancel();
       
   167     }
       
   168 
       
   169 // ----------------------------------------------------------------------------
       
   170 // CConfigurationListener::RunL
       
   171 //
       
   172 // ----------------------------------------------------------------------------
       
   173 //
       
   174 void CConfigurationListener::RunL()
       
   175     {
       
   176     RUBY_DEBUG_BLOCK( "" );
       
   177     
       
   178     // Resubscribe before processing new value to prevent missing updates
       
   179     iProperty.Subscribe( iStatus );
       
   180     SetActive();
       
   181 
       
   182     // Property updated, get new value
       
   183     TInt value( 0 );
       
   184     if ( iProperty.Get( value ) == KErrNone )
       
   185         {
       
   186         TInt operation( value & Swi::KSwisOperationMask );
       
   187         TInt operationStatus( value & Swi::KSwisOperationStatusMask );
       
   188         
       
   189         RUBY_DEBUG1( "value = %d", value );
       
   190         RUBY_DEBUG2( "operation %d, status %d", operation, operationStatus );
       
   191         
       
   192         if ( operationStatus == Swi::ESwisStatusSuccess &&
       
   193                 ( operation == Swi::ESwisInstall ||
       
   194                   operation == Swi::ESwisUninstall ||
       
   195                   operation == Swi::ESwisRestore ) )
       
   196             {
       
   197             RUBY_DEBUG0( "Update needed!" );
       
   198             iHost.McoConfigurationChanged();
       
   199             }
       
   200         }
       
   201     }
       
   202 
       
   203 
       
   204 // ----------------------------------------------------------------------------
       
   205 // CMMCListener::NewL
       
   206 //
       
   207 // ----------------------------------------------------------------------------
       
   208 //
       
   209 CMMCListener* CMMCListener::NewL( MConfigurationObserver& aHost )
       
   210     {
       
   211     RUBY_DEBUG_BLOCK( "" );
       
   212     
       
   213     CMMCListener* self = new(ELeave) CMMCListener( aHost );
       
   214     
       
   215     CleanupStack::PushL( self );
       
   216     self->ConstructL();
       
   217     CleanupStack::Pop( self);
       
   218     
       
   219     return self;
       
   220     }
       
   221 
       
   222 // ----------------------------------------------------------------------------
       
   223 // CMMCListener::CMMCListener
       
   224 //
       
   225 // ----------------------------------------------------------------------------
       
   226 //
       
   227 CMMCListener::CMMCListener(  MConfigurationObserver& aHost ) :
       
   228     CActive( CActive::EPriorityLow ),
       
   229     iPrevValue( -1 ),
       
   230     iHost( aHost )
       
   231     {
       
   232     // Nothing 
       
   233     }
       
   234 
       
   235 // ----------------------------------------------------------------------------
       
   236 // CMMCListener::ConstructL
       
   237 //
       
   238 // ----------------------------------------------------------------------------
       
   239 //
       
   240 void CMMCListener::ConstructL()
       
   241     {
       
   242     User::LeaveIfError( iProperty.Attach( KPSUidUikon, KUikMMCInserted ) );
       
   243     
       
   244     CActiveScheduler::Add( this );
       
   245     
       
   246     // Initial subscription
       
   247     iProperty.Subscribe( iStatus );
       
   248     SetActive();
       
   249     }
       
   250 
       
   251 // ----------------------------------------------------------------------------
       
   252 // CMMCListener::~CMMCListener
       
   253 //
       
   254 // ----------------------------------------------------------------------------
       
   255 //
       
   256 CMMCListener::~CMMCListener()
       
   257     {
       
   258     RUBY_DEBUG0( "Destructing.." );
       
   259     Cancel();
       
   260     iProperty.Close();
       
   261     }
       
   262 
       
   263 // ----------------------------------------------------------------------------
       
   264 // CMMCListener::DoCancel
       
   265 //
       
   266 // ----------------------------------------------------------------------------
       
   267 //
       
   268 void CMMCListener::DoCancel()
       
   269     {
       
   270     RUBY_DEBUG0( "DoCancel" )
       
   271     iProperty.Cancel();
       
   272     }
       
   273 
       
   274 // ----------------------------------------------------------------------------
       
   275 // CMMCListener::RunL
       
   276 //
       
   277 // ----------------------------------------------------------------------------
       
   278 //
       
   279 void CMMCListener::RunL()
       
   280     {
       
   281     RUBY_DEBUG_BLOCK( "" );
       
   282     
       
   283     // Resubscribe before processing new value to prevent missing updates
       
   284     iProperty.Subscribe( iStatus );
       
   285     SetActive();
       
   286     
       
   287     TInt value( 0 );
       
   288     if ( iProperty.Get( value ) == KErrNone )
       
   289         {        
       
   290         RUBY_DEBUG1( "value = %d", value );
       
   291         
       
   292         // Extra calls coming -> check if status is changed
       
   293         if ( iPrevValue != value )
       
   294             {
       
   295             iPrevValue = value; 
       
   296             
       
   297             iHost.McoConfigurationChanged();
       
   298             }
       
   299         }
       
   300     }
       
   301 
       
   302 // End of file