qthighway/xqserviceipc/xqserviceipcserver/xqserviceipcserver_symbiansession.cpp
changeset 24 9d760f716ca8
parent 4 90517678cc4f
child 27 6bfad47013df
equal deleted inserted replaced
19:46686fb6258c 24:9d760f716ca8
    38 const TInt KIPCCancelAsync = 2;
    38 const TInt KIPCCancelAsync = 2;
    39 const TInt KIPCOperationWithSharableFile = 3;  // Sharable file support
    39 const TInt KIPCOperationWithSharableFile = 3;  // Sharable file support
    40 
    40 
    41 
    41 
    42 /*!
    42 /*!
    43  \class CServiceSymbianSession
    43     \class CServiceSymbianSession
    44  Symbian Session class
    44     \brief Symbian Session class
    45  */
    45 */
    46 
    46 
    47 /*!
    47 /*!
    48  Constructor
    48     Constructor.
    49  @param aObserver observer to the server
    49     \param aObserver Observer to the server.
    50  */
    50 */
    51 CServiceSymbianSession::CServiceSymbianSession(MServiceIPCObserver* aObserver) :
    51 CServiceSymbianSession::CServiceSymbianSession(MServiceIPCObserver* aObserver) :
    52     ServiceIPCSession(aObserver)
    52     ServiceIPCSession(aObserver)
    53 {
    53 {
    54     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::CServiceSymbianSession");
    54     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::CServiceSymbianSession");
    55 }
    55 }
    56 
    56 
    57 /*!
    57 /*!
    58  2nd phased constructor
    58     2nd phased constructor.
    59  */
    59 */
    60 void CServiceSymbianSession::ConstructL()
    60 void CServiceSymbianSession::ConstructL()
    61 {
    61 {
    62 }
    62 }
    63 
    63 
    64 /*!
    64 /*!
    65  Two-Phased Constructor
    65     Two-Phased Constructor.
    66  @param aObserver observer to the server
    66     \param aObserver Observer to the server.
    67  */
    67 */
    68 CServiceSymbianSession* CServiceSymbianSession::NewL(MServiceIPCObserver* aObserver)
    68 CServiceSymbianSession* CServiceSymbianSession::NewL(MServiceIPCObserver* aObserver)
    69 {
    69 {
    70     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::NewL");
    70     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::NewL");
    71     CServiceSymbianSession* self =
    71     CServiceSymbianSession* self =
    72                     new (ELeave) CServiceSymbianSession(aObserver);
    72                     new (ELeave) CServiceSymbianSession(aObserver);
    75     CleanupStack::Pop(self);
    75     CleanupStack::Pop(self);
    76     return self;
    76     return self;
    77 }
    77 }
    78 
    78 
    79 /*!
    79 /*!
    80  Destructor
    80     Destructor.
    81  */
    81 */
    82 CServiceSymbianSession::~CServiceSymbianSession()
    82 CServiceSymbianSession::~CServiceSymbianSession()
    83 {
    83 {
    84     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::~CServiceSymbianSession");
    84     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::~CServiceSymbianSession");
    85     if (iCurRequest) {
    85     if (iCurRequest) {
    86         iObserver->handleDeleteRequest(iCurRequest); 
    86         iObserver->handleDeleteRequest(iCurRequest); 
    88     }
    88     }
    89     iCurRequest = NULL;
    89     iCurRequest = NULL;
    90 }
    90 }
    91 
    91 
    92 /*!
    92 /*!
    93  Write some data in response to a request
    93     Write some data in response to a request.
    94  @param aData some data to write as response
    94     \param aData Some data to write as response.
    95  @return bool if write was successful
    95     \return bool if write was successful.
    96  */
    96 */
    97 bool CServiceSymbianSession::write(const QByteArray& aData)
    97 bool CServiceSymbianSession::write(const QByteArray& aData)
    98 {
    98 {
    99     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::write");
    99     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::write");
   100     XQSERVICE_DEBUG_PRINT("aData: %s", aData.constData());
   100     XQSERVICE_DEBUG_PRINT("aData: %s", aData.constData());
   101     // Implicitly shared
   101     // Implicitly shared
   102     iData = aData;
   102     iData = aData;
   103     return false;
   103     return false;
   104 }
   104 }
   105 
   105 
   106 /*!
   106 /*!
   107  Complete a Request
   107     Complete a Request.
   108  @return bool if request completed 
   108     \return bool if request completed 
   109  */
   109 */
   110 bool CServiceSymbianSession::completeRequest()
   110 bool CServiceSymbianSession::completeRequest()
   111 {
   111 {
   112     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::completeRequest");
   112     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::completeRequest");
   113     XQSERVICE_DEBUG_PRINT("iData: %s", iData.constData());
   113     XQSERVICE_DEBUG_PRINT("iData: %s", iData.constData());
   114     TPtrC8 data(reinterpret_cast<const TUint8*> (iData.constData()), iData.length());
   114     TPtrC8 data(reinterpret_cast<const TUint8*> (iData.constData()), iData.length());
   115     iMessage.Complete(data.Length());
   115     iMessage.Complete(data.Length());
   116     return true;
   116     return true;
   117 }
   117 }
   118 
   118 
   119 /*!
   119 /*!
   120  Close a session and gracefully shutdown
   120     Close a session and gracefully shutdown.
   121  */
   121 */
   122 void CServiceSymbianSession::close()
   122 void CServiceSymbianSession::close()
   123 {
   123 {
   124     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::close");
   124     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::close");
   125     // Symbian doens't really do anything
   125     // Symbian doens't really do anything
   126 }
   126 }
   127 
   127 
   128 /*!
   128 /*!
   129  From CSession2
   129     From CSession2.
   130  Service request
   130     Service request.
   131  @param aMessage message object
   131     \param aMessage Message object.
   132  */
   132 */
   133 void CServiceSymbianSession::ServiceL(const RMessage2& aMessage)
   133 void CServiceSymbianSession::ServiceL(const RMessage2& aMessage)
   134 {
   134 {
   135     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::ServiceL");
   135     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::ServiceL");
   136     // Default ServiceErrorL() will complete the message if this method leaves
   136     // Default ServiceErrorL() will complete the message if this method leaves
   137     TInt operation(aMessage.Function());
   137     TInt operation(aMessage.Function());
   162     }
   162     }
   163     }
   163     }
   164 }
   164 }
   165 
   165 
   166 /*!
   166 /*!
   167  From CSession2
   167     From CSession2.
   168  Handle any disconnection from the client
   168     Handle any disconnection from the client.
   169  @param aMessage message Object
   169     \param aMessage Message object.
   170  */
   170 */
   171 void CServiceSymbianSession::Disconnect(const RMessage2 &aMessage)
   171 void CServiceSymbianSession::Disconnect(const RMessage2 &aMessage)
   172 {
   172 {
   173     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::Disconnect");
   173     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::Disconnect");
   174     CSession2::Disconnect(aMessage);
   174     CSession2::Disconnect(aMessage);
   175 }
   175 }
   176 
   176 
   177 /*!
   177 /*!
   178  Handle an IPC request
   178     Handle an IPC request.
   179  @param aMessage message Object
   179     \param aMessage Message object.
   180  */
   180 */
   181 void CServiceSymbianSession::handleRequestL(const RMessage2& aMessage)
   181 void CServiceSymbianSession::handleRequestL(const RMessage2& aMessage)
   182 {
   182 {
   183     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::handleRequestL");
   183     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::handleRequestL");
   184     // Store the message
   184     // Store the message
   185     iMessage = aMessage;
   185     iMessage = aMessage;
   246 
   246 
   247     CleanupStack::PopAndDestroy(2, request);
   247     CleanupStack::PopAndDestroy(2, request);
   248 }
   248 }
   249 
   249 
   250 /*!
   250 /*!
   251  Handle getting the result buffer
   251     Handle getting the result buffer.
   252  */
   252     \param aMessage Message object.
       
   253 */
   253 void CServiceSymbianSession::handleGetBufferL(const RMessage2& aMessage)
   254 void CServiceSymbianSession::handleGetBufferL(const RMessage2& aMessage)
   254 {
   255 {
   255     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::handleGetBufferL");
   256     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::handleGetBufferL");
   256     XQSERVICE_DEBUG_PRINT("iData: %s", iData.constData());
   257     XQSERVICE_DEBUG_PRINT("iData: %s", iData.constData());
   257     TPtrC8 data(reinterpret_cast<const TUint8*> (iData.constData()), iData.length());
   258     TPtrC8 data(reinterpret_cast<const TUint8*> (iData.constData()), iData.length());
   258     TInt err = aMessage.Write(0, data);
   259     TInt err = aMessage.Write(0, data);
   259     aMessage.Complete(err);
   260     aMessage.Complete(err);
   260 }
   261 }
   261 
   262 
   262 /*!
   263 /*!
   263  Read a 16 bit descriptor from the message
   264     Read a 16 bit descriptor from the message.
   264  @param aMessage message to read from, 
   265     \param aMessage Message to read from.
   265  @param aMsgSlot slot to read from
   266     \param aMsgSlot Slot to read from.
   266  */
   267  */
   267 HBufC* CServiceSymbianSession::ReadDesLC(const RMessage2& aMessage,
   268 HBufC* CServiceSymbianSession::ReadDesLC(const RMessage2& aMessage,
   268                                          TInt aMsgSlot)
   269                                          TInt aMsgSlot)
   269 {
   270 {
   270     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::ReadDesLC");
   271     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::ReadDesLC");
   274     aMessage.ReadL(aMsgSlot, ptr);
   275     aMessage.ReadL(aMsgSlot, ptr);
   275     return des;
   276     return des;
   276 }
   277 }
   277 
   278 
   278 /*!
   279 /*!
   279  Read a 8 bit descriptor from the message
   280     Read a 8 bit descriptor from the message.
   280  @param aMessage message to read from, 
   281     \param aMessage Message to read from.
   281  @param aMsgSlot slot to read from
   282     \param aMsgSlot Slot to read from.
   282  */
   283 */
   283 HBufC8* CServiceSymbianSession::ReadDes8LC(const RMessage2& aMessage,
   284 HBufC8* CServiceSymbianSession::ReadDes8LC(const RMessage2& aMessage,
   284                                            TInt aMsgSlot)
   285                                            TInt aMsgSlot)
   285 {
   286 {
   286     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::ReadDes8LC");
   287     XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::ReadDes8LC");
   287     TInt length = aMessage.GetDesLengthL(aMsgSlot);
   288     TInt length = aMessage.GetDesLengthL(aMsgSlot);
   310     
   311     
   311     // On error the handle remains invalid !
   312     // On error the handle remains invalid !
   312     return ret;
   313     return ret;
   313 }
   314 }
   314 
   315 
   315 //
   316 /*!
   316 // Get client capabilities from the IPC request
   317     Get client capabilities from the IPC request.
   317 //
   318 */
   318 quint32 ClientCapabilities(const RMessage2& aMsg)
   319 quint32 ClientCapabilities(const RMessage2& aMsg)
   319 {
   320 {
   320     quint32 caps = 0;
   321     quint32 caps = 0;
   321     for(int i = 0; i < ECapability_Limit; i++)
   322     for(int i = 0; i < ECapability_Limit; i++)
   322     {
   323     {