browserui/browser/Launcher2/src/LauncherClientService.cpp
branchRCL_3
changeset 65 8e6fa1719340
parent 0 84ad3b177aa3
equal deleted inserted replaced
64:6385c4c93049 65:8e6fa1719340
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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: 
       
    15 *      Implementation of CLauncherClientService
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 #include "LauncherClientService.h"
       
    23 #include "LauncherReceiveHandler.h"
       
    24 #include "logger.h"
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // RLauncherClientService::ServiceUid()
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 TUid RLauncherClientService::ServiceUid() const
       
    31     {
       
    32     return TUid::Uid( 0x01010101 );
       
    33     }
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // RLauncherClientService::InitializeL()
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 void RLauncherClientService::InitializeL
       
    40     ( TUid aServerAppUid, MLaunchedServerObserver& aServerObserver )
       
    41     {
       
    42     LOG_ENTERFN( "RLauncherClientService::InitializeL" );
       
    43     
       
    44     iActiveHandler = CLauncherReceiveHandler::NewL( &aServerObserver, *this );
       
    45     CActiveScheduler::Add( iActiveHandler );
       
    46 
       
    47     ConnectChainedAppL( aServerAppUid );
       
    48     iServerExitMonitor = CApaServerAppExitMonitor::NewL( *this, 
       
    49                                                          aServerObserver, 
       
    50                                                          CActive::EPriorityStandard );
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // RLauncherClientService::ListenL()
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void RLauncherClientService::ListenL()
       
    58     {
       
    59     LOG_ENTERFN( "RLauncherClientService::ListenL" );
       
    60     
       
    61     if ( iActiveHandler )
       
    62         {
       
    63         __ASSERT_DEBUG(!iActiveHandler->IsActive(), User::Panic(_L("Already Listening..."),1));
       
    64         iActiveHandler->StartListen();
       
    65         }
       
    66     else
       
    67         {
       
    68         User::Leave( KErrNotFound );
       
    69         }
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // RLauncherClientService::StopListening()
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void RLauncherClientService::StopListening()
       
    77     {
       
    78     LOG_ENTERFN( "RLauncherClientService::StopListening" );
       
    79     
       
    80     // tell receive handler to cancel receive and stop listening
       
    81     iActiveHandler->Cancel();    
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // RLauncherClientService::SendData()
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 TInt RLauncherClientService::SendSync(  TDesC8& aBufferToSend )
       
    89     {
       
    90     LOG_ENTERFN( "RLauncherClientService::SendSync" );
       
    91     return SendReceive( ELauncherSendSync, TIpcArgs( &aBufferToSend ) );
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // RLauncherClientService::SendAsync()
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 void RLauncherClientService::SendAsync( TDesC8& aBufferToSend, TDes8& aBufferSize )
       
    99     {
       
   100     LOG_ENTERFN( "RLauncherClientService::SendAsync" );
       
   101     // If no previous request was done, which has not finished,
       
   102     // then request is ok, send it...
       
   103     SendReceive( ELauncherSendASync, TIpcArgs( &aBufferToSend, &aBufferSize ), 
       
   104                           iActiveHandler->iStatus );
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // RLauncherClientService::SendAsync()
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void RLauncherClientService::SendAsync()
       
   112     {
       
   113     LOG_ENTERFN( "RLauncherClientService::SendAsyncListen" );
       
   114     // If no previous request was done, which has not finished,
       
   115     // then request is ok, send it...
       
   116     SendReceive( ELauncherSendASyncListen, iActiveHandler->iStatus );
       
   117     }
       
   118 
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // RLauncherClientService::SendAsync()
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void RLauncherClientService::SendAsync(TDes8& aBufferSize )
       
   125     {
       
   126     LOG_ENTERFN( "RLauncherClientService::SendAsyncListen" );
       
   127     // If no previous request was done, which has not finished,
       
   128     // then request is ok, send it...
       
   129     
       
   130     
       
   131     TPckg<TInt> dummyParam(0);
       
   132     
       
   133     SendReceive( ELauncherSendASyncListen, TIpcArgs( &dummyParam, &aBufferSize ),iActiveHandler->iStatus );
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // RLauncherClientService::SendSyncBuffer()
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 TInt RLauncherClientService::SendSyncBuffer( TDes8& aReceiveBuffer )
       
   141     {
       
   142     LOG_ENTERFN( "RLauncherClientService::SendSyncBuffer" );
       
   143     // Else reset the state of the request, and send the buffer with
       
   144     // the size, set by the SendAsync() function 
       
   145     // So the server can write into it.
       
   146     return SendReceive( ELauncherSendSyncBuffer, TIpcArgs( &aReceiveBuffer ) );
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // RLauncherClientService::SendSyncBools()
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 TInt RLauncherClientService::SendSyncBools
       
   154     ( TBool aClientWantsToContinue, TBool aWasContentHandled )
       
   155     {
       
   156     LOG_ENTERFN( "RLauncherClientService::SendSyncBools" );
       
   157     // Else reset the state of the request, and send the buffer with
       
   158     // the size, set by the SendAsync() function 
       
   159     // So the server can write into it.
       
   160     return SendReceive( ELauncherSendSyncBools, 
       
   161                                      TIpcArgs( aClientWantsToContinue, aWasContentHandled ) );
       
   162     }
       
   163 	
       
   164 // -----------------------------------------------------------------------------
       
   165 // RLauncherClientService::SendCommand()
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 TInt RLauncherClientService::SendCommand( TInt aCommand )
       
   169     {
       
   170     LOG_ENTERFN( "RLauncherClientService::SendCommand" );
       
   171     LOG_WRITE_FORMAT(" aCommand: %d", aCommand);
       
   172     return SendReceive( aCommand, TIpcArgs() );
       
   173     }
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 // RLauncherClientService::CancelReceive()
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 void RLauncherClientService::CancelReceive()
       
   180     {
       
   181     LOG_ENTERFN( "RLauncherClientService::CancelReceive" );
       
   182     SendReceive( ELauncherCancelReceive, TIpcArgs( 0 ) );
       
   183     }
       
   184 
       
   185 // -----------------------------------------------------------------------------
       
   186 // RLauncherClientService::Close()
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 void RLauncherClientService::Close()
       
   190     {
       
   191     LOG_ENTERFN( "RLauncherClientService::Close" );
       
   192     
       
   193     delete iActiveHandler;
       
   194     iActiveHandler = 0;
       
   195     LOG_WRITE(" iActiveHandler OK");
       
   196 
       
   197     delete iServerExitMonitor;
       
   198     iServerExitMonitor = 0;
       
   199     LOG_WRITE(" iServerExitMonitor OK");
       
   200 
       
   201     REikAppServiceBase::Close();
       
   202     LOG_WRITE(" ServiceBase::Close OK");
       
   203     }
       
   204     
       
   205 // End of File