uiacceltk/hitchcock/ServerCore/Src/alfsrvsubsessionbase.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Sub session base.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "alf/alfappserver.h"
       
    21 #include "alf/alfappsrvsessionbase.h"
       
    22 #include "alfsrvsubsessionbase.h"
       
    23 #include "alflogger.h"
       
    24 
       
    25 NONSHARABLE_CLASS(CAlfSrvSubSessionBase::TPrivateData)
       
    26     {
       
    27     public: 
       
    28         MAlfExtension* iObject; // owned, use Release() to destroy
       
    29     };
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // Constructor
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CAlfSrvSubSessionBase::CAlfSrvSubSessionBase( CAlfAppSrvSessionBase& aSession )
       
    38     : iSession( aSession )
       
    39     {
       
    40     }
       
    41 
       
    42 CAlfSrvSubSessionBase* CAlfSrvSubSessionBase::NewLC( const RMessage2& aMessage, 
       
    43                                                     TInt aImplementationUid,  
       
    44                                                     TInt aImplementationId,
       
    45                                                     CAlfAppSrvSessionBase& aSession) 
       
    46     {
       
    47     CAlfSrvSubSessionBase* me = new (ELeave) CAlfSrvSubSessionBase(aSession);
       
    48     CleanupClosePushL(*me);
       
    49     me->ConstructL(aMessage, aImplementationUid, aImplementationId);
       
    50     return me;
       
    51     }
       
    52 
       
    53 void CAlfSrvSubSessionBase::ConstructL(const RMessage2& aMessage, 
       
    54                                        TInt aImplementationUid,  
       
    55                                        TInt aImplementationId )
       
    56     {    
       
    57     ConstructL();
       
    58     
       
    59     // leaves if no implementation found   
       
    60     iData->iObject = iSession.AlfServer()->CreateExtensionL(
       
    61                            aImplementationUid, aImplementationId,aMessage);
       
    62 
       
    63     iFactoryUid = aImplementationUid;
       
    64     }
       
    65 
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // 2nd phase constructor
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 void CAlfSrvSubSessionBase::ConstructL()
       
    72     {
       
    73     iData = new (ELeave) TPrivateData;
       
    74     
       
    75     iData->iObject = 0;
       
    76     }
       
    77 
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // Destructor
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 CAlfSrvSubSessionBase::~CAlfSrvSubSessionBase()
       
    84     {
       
    85     if (iData && iData->iObject)
       
    86         {
       
    87         // todo: notify server about implementation removal
       
    88         iData->iObject->Release();
       
    89         }
       
    90         
       
    91     delete iData;
       
    92     }
       
    93   
       
    94 // ---------------------------------------------------------------------------
       
    95 // Process message
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CAlfSrvSubSessionBase::ProcessMessageL(const RMessage2& aMessage)
       
    99     {
       
   100     // Call the virtual function.
       
   101     DoProcessMessageL( aMessage );
       
   102     }
       
   103   
       
   104 // ---------------------------------------------------------------------------
       
   105 // Processes the message.
       
   106 // ---------------------------------------------------------------------------
       
   107 //  
       
   108 void CAlfSrvSubSessionBase::DoProcessMessageL(const RMessage2& aMessage)
       
   109     {
       
   110     if (iData && iData->iObject)
       
   111         {
       
   112         // session owns the buffers and everything related to msg handling     
       
   113         CAlfClientMessage* msg = iSession.CreateNewMessageHolderL(aMessage);
       
   114          
       
   115         TRAPD(err, iData->iObject->HandleCmdL(msg->iDecodedOp, 
       
   116                                               *msg->iInBuf, msg->ReplyBufAsTDes8()));
       
   117 
       
   118         iSession.CompleteCmd(0, err);  
       
   119         return;
       
   120         }
       
   121 
       
   122     User::Leave(KErrNotSupported);
       
   123     }
       
   124   
       
   125 // ---------------------------------------------------------------------------
       
   126 // Returns the session
       
   127 // ---------------------------------------------------------------------------
       
   128 //  
       
   129 CAlfAppSrvSessionBase& CAlfSrvSubSessionBase::Session()
       
   130     {
       
   131     return iSession;
       
   132     }
       
   133 
       
   134 
       
   135 MHuiVisualOwner* CAlfSrvSubSessionBase::AsVisualOwner()
       
   136     {
       
   137     if (iData && iData->iObject)
       
   138         {
       
   139         return static_cast<MHuiVisualOwner*>(iData->iObject->GetInterface(EHuiInterfaceVisualOwner));
       
   140         }
       
   141 
       
   142     return 0;
       
   143     }
       
   144 
       
   145 CHuiControl* CAlfSrvSubSessionBase::AsHuiControl()
       
   146     {
       
   147     if (iData && iData->iObject)
       
   148         {
       
   149         return static_cast<CHuiControl*>(iData->iObject->GetInterface(EHuiObjectTypeControl));
       
   150         }
       
   151 
       
   152     return 0;
       
   153     }
       
   154 
       
   155 CHuiVisual* CAlfSrvSubSessionBase::AsHuiVisual()
       
   156     {
       
   157     if (iData && iData->iObject)
       
   158         {
       
   159         return static_cast<CHuiVisual*>(iData->iObject->GetInterface(EHuiObjectTypeVisual));
       
   160         }
       
   161 
       
   162     return 0;
       
   163     }
       
   164 
       
   165 CHuiLayout* CAlfSrvSubSessionBase::AsHuiLayout()
       
   166     {
       
   167     if (iData && iData->iObject)
       
   168         {
       
   169         return static_cast<CHuiLayout*>(iData->iObject->GetInterface(EHuiObjectTypeLayout));
       
   170         }
       
   171 
       
   172     return 0;
       
   173     }
       
   174 
       
   175 CHuiBrush* CAlfSrvSubSessionBase::AsHuiBrush()
       
   176     {
       
   177     if (iData && iData->iObject)
       
   178         {
       
   179         return static_cast<CHuiBrush*>(iData->iObject->GetInterface(EHuiObjectTypeBrush));
       
   180         }
       
   181 
       
   182     return 0;
       
   183     }
       
   184 
       
   185 MHuiMappingFunction* CAlfSrvSubSessionBase::AsMappingFunction()
       
   186     {
       
   187     if (iData && iData->iObject)
       
   188         {
       
   189         return static_cast<MHuiMappingFunction*>(iData->iObject->GetInterface(EHuiInterfaceMappingFunction));
       
   190         }
       
   191 
       
   192     return 0;
       
   193     }
       
   194 
       
   195 CHuiControlGroup* CAlfSrvSubSessionBase::AsHuiControlCroup()
       
   196     {
       
   197     if (iData && iData->iObject)
       
   198         {
       
   199         return static_cast<CHuiControlGroup*>(iData->iObject->GetInterface(EHuiObjectTypeControlGroup));
       
   200         }
       
   201 
       
   202     return 0;    
       
   203     }
       
   204     
       
   205 CHuiDisplay* CAlfSrvSubSessionBase::AsHuiDisplay()
       
   206     {
       
   207     if (iData && iData->iObject)
       
   208         {
       
   209         return static_cast<CHuiDisplay*>(iData->iObject->GetInterface(EHuiObjectTypeDisplay));
       
   210         }
       
   211 
       
   212     return 0;    
       
   213     }
       
   214 
       
   215 CAlfBrushHandler* CAlfSrvSubSessionBase::AsBrushHandler()
       
   216     {
       
   217     if (iData && iData->iObject)
       
   218         {
       
   219         return static_cast<CAlfBrushHandler*>(iData->iObject->GetInterface(EAlfBrushHandler));
       
   220         }
       
   221 
       
   222     return 0;    
       
   223     }
       
   224 
       
   225 MAlfExtension* CAlfSrvSubSessionBase::AsCommandHandler()
       
   226     {
       
   227     if (iData)
       
   228         {
       
   229         return iData->iObject;
       
   230         }
       
   231 
       
   232     return 0;    
       
   233     }
       
   234 
       
   235 // Todo: Currently we don't support trulu asynch operations as 
       
   236 // MAlfExtension does not have interfaces to utilize for this purpose
       
   237 //
       
   238 // It should be evaluated whether there are real use cases for asynchronous command handling
       
   239 void CAlfSrvSubSessionBase::CancelAsynchRequests()
       
   240     {
       
   241     }
       
   242