uifw/AknGlobalUI/NotifierWrapper/src/AknNotifierAppServerSession.cpp
changeset 0 2f259fa3e83a
child 54 4e76f14a5917
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2004-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:  Notifier server app session implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <e32notif.h>
       
    19 #include <eiksrvs.h>
       
    20 
       
    21 #include "AknNotiferAppServerApplication.h" 
       
    22 #include "AknNotifierAppServer.h" 
       
    23 #include "AknNotifierAppServerSession.h"
       
    24 #include "AknNotifierControllerUtilities.h"
       
    25 
       
    26 const TInt KINPUTSLOT = 1; 
       
    27 const TInt KREPLYSLOT = 2; 
       
    28 const TInt KEikonServerSecureId = 0x10003A4A;
       
    29 
       
    30 LOCAL_C void SetEikonServerFree(TAny* aPtr)
       
    31     {
       
    32     *(TBool*)aPtr = 0; // points to boolean
       
    33     }
       
    34   
       
    35 EXPORT_C CAknNotifierServerAppService::CAknNotifierServerAppService(
       
    36     const CAknNotifierAppServer& aAppServer) 
       
    37 :iOwner(const_cast<CAknNotifierAppServer&>(aAppServer))
       
    38     {
       
    39     }
       
    40 
       
    41 EXPORT_C CAknNotifierServerAppService::~CAknNotifierServerAppService()
       
    42     {       
       
    43     delete iInputBuf;
       
    44     delete iReplyBuf;       
       
    45     }
       
    46    
       
    47 EXPORT_C void CAknNotifierServerAppService::HandleMessageL(const RMessage2& aMessage)
       
    48     {    
       
    49     CAknNotifierAppServerAppUi* appUi = (CAknNotifierAppServerAppUi*)CEikonEnv::Static()->AppUi();
       
    50     
       
    51     if (appUi && aMessage.SecureId().iId == KEikonServerSecureId)
       
    52         {
       
    53         appUi->EikSrvBlocked() = ETrue;
       
    54         CleanupStack::PushL(TCleanupItem(SetEikonServerFree, &(appUi->EikSrvBlocked()) ));     
       
    55         }
       
    56     
       
    57     if (aMessage.Function() == KDoNotifierControllerCommand)
       
    58         {
       
    59         if (appUi && appUi->NotifierControllerUtility())
       
    60             {
       
    61             appUi->NotifierControllerUtility()->DoNotifierContollerCommandL(
       
    62                 (CAknNotifierControllerUtility::TNotifierControllerCommand)aMessage.Int0());
       
    63             
       
    64             CleanupStack::PopAndDestroy(); // Free eikon server 
       
    65             }
       
    66     
       
    67         aMessage.Complete(KErrNone);    
       
    68         return;
       
    69         }
       
    70             
       
    71     switch ( aMessage.Function() )
       
    72         {
       
    73         case EStartNotifier:
       
    74              {
       
    75              ResolveBuffersL(aMessage);
       
    76              TPtr8 ptr = iReplyBuf->Des();
       
    77              iOwner.StartNotifierL(TUid::Uid(aMessage.Int0()),*iInputBuf, ptr);
       
    78              WriteReplyL(aMessage);
       
    79              break;   
       
    80              }
       
    81         case EUpdateNotifier:
       
    82              {
       
    83              ResolveBuffersL(aMessage);
       
    84              TPtr8 ptr2 = iReplyBuf->Des();
       
    85              iOwner.UpdateNotifierL(TUid::Uid(aMessage.Int0()),*iInputBuf, ptr2);
       
    86              WriteReplyL(aMessage);
       
    87              break;
       
    88              }
       
    89         case ECancelNotifier:
       
    90              {
       
    91              iOwner.CancelNotifier(TUid::Uid(aMessage.Int0()));                 
       
    92              aMessage.Complete(KErrNone);
       
    93              break;
       
    94              }
       
    95         case EStartNotifierAndGetResponse:
       
    96              {
       
    97              if (appUi && appUi->EikSrvBlocked())
       
    98                  {
       
    99                  CleanupStack::PopAndDestroy(); // Free eikon server 
       
   100                  }
       
   101                     
       
   102              ResolveBuffersL(aMessage);
       
   103              
       
   104              iOwner.StartNotifierAndGetResponseL(
       
   105                  TUid::Uid(aMessage.Int0()), 
       
   106                  *iInputBuf, 
       
   107                  aMessage, 
       
   108                  KREPLYSLOT); 
       
   109                 
       
   110              break;
       
   111              }
       
   112         case EUpdateNotifierAndGetResponse:
       
   113              {
       
   114              if (appUi && appUi->EikSrvBlocked())
       
   115                  {
       
   116                  CleanupStack::PopAndDestroy(); // Free eikon server 
       
   117                  }
       
   118                     
       
   119              ResolveBuffersL(aMessage);
       
   120              
       
   121              iOwner.UpdateNotifierAndGetResponseL(
       
   122                 TUid::Uid(aMessage.Int0()), 
       
   123                 *iInputBuf, 
       
   124                 aMessage, 
       
   125                 KREPLYSLOT); 
       
   126                 
       
   127              break;
       
   128              }
       
   129         default:
       
   130             {
       
   131             CAknAppServiceBase::ServiceL(aMessage);           
       
   132             }
       
   133         }        
       
   134     
       
   135     if (appUi && appUi->EikSrvBlocked())
       
   136         {
       
   137         CleanupStack::PopAndDestroy(); // Free eikon server 
       
   138         }    
       
   139     }
       
   140     
       
   141 EXPORT_C TBool CAknNotifierServerAppService::AllowClientL(const RMessage2& aMessage)
       
   142     { 
       
   143     // By default, we don't serve other process than notifier server.
       
   144     return (aMessage.SecureId().iId == KEikonServerSecureId);
       
   145     }
       
   146 
       
   147                    
       
   148 EXPORT_C void CAknNotifierServerAppService::ServiceL(const RMessage2& aMessage)
       
   149     {
       
   150     if (!AllowClientL(aMessage)) 
       
   151         {  
       
   152         aMessage.Complete(KErrAccessDenied);
       
   153         }
       
   154     else 
       
   155         {
       
   156         HandleMessageL(aMessage);   
       
   157         }   
       
   158     }
       
   159 
       
   160     
       
   161 void CAknNotifierServerAppService::ResolveBuffersL(const RMessage2& aMessage)
       
   162     {
       
   163     delete iInputBuf;
       
   164     iInputBuf = 0;
       
   165     
       
   166     delete iReplyBuf;
       
   167     iReplyBuf = 0;
       
   168     
       
   169     iInputBuf = HBufC8::NewL(aMessage.GetDesLengthL(KINPUTSLOT));
       
   170     
       
   171     TPtr8 ptr = iInputBuf->Des();
       
   172     aMessage.Read(KINPUTSLOT,ptr);
       
   173     
       
   174     if (aMessage.Function() == EStartNotifier || aMessage.Function() == EUpdateNotifier)
       
   175         {
       
   176         iReplyBuf = HBufC8::NewL(aMessage.GetDesMaxLengthL(KREPLYSLOT));   
       
   177         }
       
   178     }
       
   179 
       
   180 
       
   181 void CAknNotifierServerAppService::WriteReplyL(const RMessage2& aMessage)
       
   182     {
       
   183     aMessage.WriteL(KREPLYSLOT, *iReplyBuf);
       
   184     aMessage.Complete(KErrNone);
       
   185     }
       
   186 
       
   187 // End of file