utilities/serviceipcserver/serviceipcrequest.cpp
changeset 16 3c88a81ff781
equal deleted inserted replaced
14:6aeb7a756187 16:3c88a81ff781
       
     1 /**
       
     2    This file is part of CWRT package **
       
     3 
       
     4    Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). **
       
     5 
       
     6    This program is free software: you can redistribute it and/or modify
       
     7    it under the terms of the GNU (Lesser) General Public License as
       
     8    published by the Free Software Foundation, version 2.1 of the License.
       
     9    This program is distributed in the hope that it will be useful, but
       
    10    WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
       
    12    (Lesser) General Public License for more details. You should have
       
    13    received a copy of the GNU (Lesser) General Public License along
       
    14    with this program. If not, see <http://www.gnu.org/licenses/>.
       
    15 */
       
    16 
       
    17 
       
    18 #include "serviceipcrequest.h"
       
    19 #include "serviceipcserversession.h"
       
    20 #include <clientinfo.h>
       
    21 
       
    22 namespace WRT
       
    23 {
       
    24 /*!
       
    25  \class ServiceIPCRequest
       
    26  Class to encapsulate a service request
       
    27  */
       
    28 
       
    29 /*!
       
    30  Constructor
       
    31  @param aSession session associated with this request
       
    32  @param aDataLength amount of data to be received in this request
       
    33  @param aRequestOp operaion name
       
    34  */
       
    35 ServiceIPCRequest::ServiceIPCRequest(ServiceIPCSession* aSession,
       
    36                                      qint64 aDataLength,
       
    37                                      const QString& aRequestOp) 
       
    38     : QObject(NULL)
       
    39     , m_Session(aSession)
       
    40     , m_ClientInfo(NULL)
       
    41     , m_RequestOp(aRequestOp)
       
    42     , m_Datalength(aDataLength)
       
    43 {
       
    44 
       
    45 }
       
    46 
       
    47 /*!
       
    48  Destructor
       
    49  */
       
    50 ServiceIPCRequest::~ServiceIPCRequest()
       
    51 {
       
    52     delete m_ClientInfo;
       
    53 }
       
    54 
       
    55 /*!
       
    56  Get the requested operation
       
    57  @return QString operation ID
       
    58  */
       
    59 const QString& ServiceIPCRequest::getOperation()
       
    60 {
       
    61     return m_RequestOp;
       
    62 }
       
    63 
       
    64 /*!
       
    65  Get the requested data
       
    66  @return QByteArray data for this operation
       
    67  */
       
    68 const QByteArray& ServiceIPCRequest::getData()
       
    69 {
       
    70     return m_RequestData;
       
    71 }
       
    72 
       
    73 /*!
       
    74  Write some data to the request
       
    75  @param aData data to write to the socket
       
    76  */
       
    77 bool ServiceIPCRequest::write(const QByteArray& aData)
       
    78 {
       
    79     // Do we want to buffer the writes?
       
    80     return m_Session->write(aData);
       
    81 }
       
    82 
       
    83 /*!
       
    84  Complete the request
       
    85  @return true if request completed successfully
       
    86  */
       
    87 bool ServiceIPCRequest::completeRequest()
       
    88 {
       
    89     return m_Session->completeRequest();
       
    90 }
       
    91 
       
    92 /*!
       
    93  Append more data when creating the request
       
    94  @arg aMoreData data to be appended to the request
       
    95  @return true if m_Datalength now equals the full length
       
    96  */
       
    97 bool ServiceIPCRequest::addRequestdata(const QByteArray& aMoreData)
       
    98 {
       
    99     m_RequestData.append(aMoreData);
       
   100     return (m_RequestData.length() == m_Datalength);
       
   101 }
       
   102 
       
   103 /*!
       
   104  Sets the client info.  Onwership of the object is passed in.
       
   105  @arg aClientInfo Client information
       
   106  */
       
   107 void ServiceIPCRequest::setClientInfo(ClientInfo *aClientInfo)
       
   108 {
       
   109     delete m_ClientInfo;
       
   110     m_ClientInfo = aClientInfo;
       
   111 }
       
   112 
       
   113 /*!
       
   114  Gets the client info.
       
   115  @return Client Information object.  NULL if none is available
       
   116  */
       
   117 const ClientInfo *ServiceIPCRequest::clientInfo()
       
   118 {
       
   119     return m_ClientInfo;
       
   120 }
       
   121 }
       
   122 // END OF FILE