simpleengine/engine/inc/simpleenginerequest.h
changeset 0 c8caa15ef882
equal deleted inserted replaced
-1:000000000000 0:c8caa15ef882
       
     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:    SIMPLE Engine request
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CSimpleEngineRequest_H
       
    21 #define CSimpleEngineRequest_H
       
    22 
       
    23 
       
    24 // INCLUDES
       
    25 #include <e32base.h>
       
    26 #include "simplecommon.h"
       
    27 #include "msimpleenginerequest.h"
       
    28 
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CSimpleSipConnection;
       
    32 class MSimpleOwnCallback;
       
    33 
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38  *  CSimpleEngineRequest
       
    39  *
       
    40  *  SIMPLE Engine request.
       
    41  *
       
    42  *  @lib simpleengine
       
    43  *  @since S60 3.2
       
    44  */
       
    45 
       
    46 class CSimpleEngineRequest : public CActive, public MSimpleEngineRequest
       
    47     {
       
    48 
       
    49 public:
       
    50 
       
    51     /**
       
    52      * Two-phased constructor.
       
    53      * @param aEngine callback method interface
       
    54      * @param aType request type
       
    55      * @param aOpId client operation id
       
    56      * @since S60 3.2
       
    57      */
       
    58     static CSimpleEngineRequest* NewL(
       
    59         MSimpleOwnCallback& aEngine,
       
    60         MSimpleEngineRequest::TSimpleRequest aType,
       
    61         TInt aOpId );
       
    62 
       
    63     /**
       
    64      * Destructor.
       
    65      */
       
    66     virtual ~CSimpleEngineRequest();
       
    67 
       
    68     /**
       
    69      * Delete this entity
       
    70      */
       
    71     void Destroy();
       
    72 
       
    73     /**
       
    74      * Request data setter
       
    75      * @param aData  data payload. Data is not copied but ownership is transferred.
       
    76      */
       
    77     void SetRequestData( TPtrC8 aData );
       
    78     
       
    79     inline static TInt LinkOffset();
       
    80     
       
    81     void SetRequestContentTypeL( const TDesC8& aData );         
       
    82 
       
    83 // from base class MSimpleEngineRequest
       
    84 
       
    85     /**
       
    86      * From MSimpleEngineRequest.
       
    87      * Request type accessor
       
    88      * @since S60 3.2
       
    89      * @return request type
       
    90      */
       
    91     MSimpleEngineRequest::TSimpleRequest RequestType();
       
    92 
       
    93     /**
       
    94      * Request type accessor
       
    95      * @since S60 3.2
       
    96      * @param aType request type
       
    97      */
       
    98     void ModifyType( MSimpleEngineRequest::TSimpleRequest aType );
       
    99 
       
   100     /**
       
   101      * From MSimpleEngineRequest.
       
   102      * Complete the open request
       
   103      * @since S60 3.2
       
   104      * @param aStatus result status
       
   105      */
       
   106     void Complete( TInt aStatus );
       
   107 
       
   108     /**
       
   109      * From MSimpleEngineRequest.
       
   110      * Request data type accessor
       
   111      * @since S60 3.2
       
   112      * @return request data content type
       
   113      */
       
   114     TPtrC8 RequestContentType();       
       
   115 
       
   116     /**
       
   117      * From MSimpleEngineRequest.
       
   118      * Request data accessor
       
   119      * @since S60 3.2
       
   120      * @return request data payload
       
   121      */
       
   122     TPtrC8 RequestData();
       
   123 
       
   124     /**
       
   125      * Response data type setter.
       
   126      * @since S60 3.2
       
   127      * @param aData content that is to be copied?
       
   128      */
       
   129     void SetResponseContentType( HBufC8* aData );
       
   130 
       
   131     /**
       
   132      * Response data MIME multipart boundary setter.
       
   133      * @since S60 3.2
       
   134      * @param aData boundary
       
   135      */
       
   136     void SetResponseBoundaryL( const TDesC8& aData );
       
   137 
       
   138     /**
       
   139      * Response data MIME multipart start content-id setter
       
   140      * @since S60 3.2
       
   141      * @param aData content-id
       
   142      */
       
   143     void SetResponseStartL( const TDesC8& aData );
       
   144 
       
   145     /**
       
   146      * From MSimpleEngineRequest.
       
   147      * Response data setter.
       
   148      * @since S60 3.2
       
   149      * @param aData content
       
   150      */
       
   151     void SetResponseDataL( const TDesC8& aData );
       
   152 
       
   153     /**
       
   154      * From MSimpleEngineRequest.
       
   155      * Response method setter.
       
   156      * @since S60 3.2
       
   157      * @param aMethod a method
       
   158      */
       
   159     void SetResponseMethod( TSimpleSIPResponse aMethod );
       
   160 
       
   161     /**
       
   162      * From MSimpleEngineRequest.
       
   163      * Aux data setter.
       
   164      * @since S60 3.2
       
   165      * @param aData data
       
   166      */
       
   167     void SetAux( TInt aData );
       
   168 
       
   169     /**
       
   170      * Server response/request method accessor
       
   171      * @return SIP method
       
   172      */
       
   173     TSimpleSIPResponse ResponseMethod();
       
   174 
       
   175     /**
       
   176      * From MSimpleEngineRequest.
       
   177      * Response data type accessor
       
   178      * @since S60 3.2
       
   179      * @return content type
       
   180      */
       
   181     TPtrC8 ResponseContentType();
       
   182 
       
   183     /**
       
   184      * Response data MIME multipart boundary getter.
       
   185      * @since S60 3.2
       
   186      * @return data boundary
       
   187      */
       
   188     TPtrC8 ResponseBoundary( );
       
   189 
       
   190     /**
       
   191      * Response data MIME multipart start content-id getter
       
   192      * @since S60 3.2
       
   193      * @return start content-id
       
   194      */
       
   195     TPtrC8 ResponseStart( );
       
   196 
       
   197     /**
       
   198      * From MSimpleEngineRequest.
       
   199      * Response data accessor
       
   200      * @since S60 3.2
       
   201      * @return response data payload
       
   202      */
       
   203     TPtrC8 ResponseData();
       
   204 
       
   205     /**
       
   206      * From MSimpleEngineRequest.
       
   207      * Refresh time accessor
       
   208      * @since S60 3.2
       
   209      * @return refresh time in seconds, 0 means query once
       
   210      */
       
   211     TUint RefreshTime();
       
   212 
       
   213     /**
       
   214      * Set refresh time
       
   215      * @param aTime time in seconds
       
   216      */
       
   217     void SetRefreshTime( TUint aTime );
       
   218 
       
   219     /**
       
   220      * From MSimpleEngineRequest.
       
   221      * Remote URI accessor
       
   222      * @since S60 3.2
       
   223      * @return remote URI
       
   224      */
       
   225     TPtrC8 RemoteURI();
       
   226 
       
   227     /**
       
   228      * Remote URI setter
       
   229      * @since S60 3.2     
       
   230      * @param aURI remote URI
       
   231      */
       
   232     void SetRemoteURIL( const TDesC8& aURI );
       
   233 
       
   234     /**
       
   235      * Get refresh parameter
       
   236      * @since S60 3.2
       
   237      * @return refresh parameter     
       
   238      */
       
   239     TBool IsRefresh();
       
   240 
       
   241     /**
       
   242      * Refresh parameter setter
       
   243      * @since S60 3.2       
       
   244      * @param aRefresh refresh value
       
   245      */
       
   246     void SetRefresh( TBool aRefresh );
       
   247 
       
   248     /**
       
   249      * operation id getter
       
   250      * @since S60 3.2       
       
   251      * @return operation id
       
   252      */
       
   253      TInt OpId();
       
   254 
       
   255     /**
       
   256      * auxiliary parameter needed sometimes
       
   257      * @since S60 3.2       
       
   258      * @return aux number
       
   259      */
       
   260      TInt Aux();
       
   261 
       
   262     /**
       
   263      * SIP Response reason setter
       
   264      * @since S60 3.2       
       
   265      * @param aReason reason
       
   266      */
       
   267     void SetResponseReason( TSimpleResponseReason aReason );
       
   268 
       
   269     /**
       
   270      * SIP Response reason getter
       
   271      * @since S60 3.2       
       
   272      * @return aReason reason
       
   273      */
       
   274     TSimpleResponseReason ResponseReason();
       
   275     
       
   276     /**
       
   277      * Set SIP-ETag value
       
   278      *
       
   279      * @since S60 3.2     
       
   280      * @param aTag tag
       
   281      */
       
   282     void SetETagL( const TDesC8& aTag );
       
   283 
       
   284     /**
       
   285      * get SIP-ETag value
       
   286      *
       
   287      * @since S60 3.2     
       
   288      * @return SIP-ETag value.
       
   289      */
       
   290     TPtrC8 ETag();      
       
   291         
       
   292     /**
       
   293      * IM message recipient setter
       
   294      *
       
   295      * @since S60 5.0
       
   296      * @param aRecipientId recipient ID
       
   297      */
       
   298     void SetRecipientL( const TDesC8& aRecipientId );
       
   299 
       
   300     /**
       
   301      * IM message recipient getter
       
   302      *
       
   303      * @since S60 5.0
       
   304      * @return recipient ID
       
   305      */
       
   306     TPtrC8 Recipient();
       
   307         
       
   308 protected:
       
   309 
       
   310     /**
       
   311      * C++ default constructor.
       
   312      */
       
   313     CSimpleEngineRequest(
       
   314         MSimpleOwnCallback& aEngine, TSimpleRequest aType, TInt aOpId );
       
   315 
       
   316 // from base class CActive
       
   317 
       
   318     /**
       
   319      * From CActive.
       
   320      * Implements cancellation of an outstanding request.
       
   321      *
       
   322      * @since S60 3.2
       
   323      */
       
   324     void DoCancel( );
       
   325 
       
   326     /**
       
   327      * From CActive.
       
   328      * Handles an active object's request completion event.
       
   329      *
       
   330      * @since S60 3.2
       
   331      */
       
   332     void RunL( );
       
   333 
       
   334 private:
       
   335 
       
   336 
       
   337 private:    // Data
       
   338 
       
   339     TDblQueLink iLink;
       
   340 
       
   341     /**
       
   342      * Request Time
       
   343      */
       
   344     TSimpleRequest iType;
       
   345 
       
   346     /**
       
   347      * Refresh Time
       
   348      */
       
   349     TUint iRefreshTime;
       
   350 
       
   351     /**
       
   352      * Client request data
       
   353      */
       
   354     TPtrC8 iRequestData;
       
   355 
       
   356     /**
       
   357      * IM message recipient ID
       
   358      * Own.
       
   359      */
       
   360     HBufC8* iRecipientId;
       
   361     
       
   362     /**
       
   363      * Buffer for server response data
       
   364      * Own.
       
   365      */
       
   366     HBufC8* iResponseData;
       
   367 
       
   368     /**
       
   369      * Server response method
       
   370      */
       
   371     TSimpleSIPResponse iResponseMethod;
       
   372 
       
   373     /**
       
   374      * Server response reason explanation
       
   375      */
       
   376     TSimpleResponseReason iReason;
       
   377 
       
   378     /**
       
   379      * Buffer for remote URI
       
   380      * Own.
       
   381      */
       
   382     HBufC8* iRemoteURI;
       
   383 
       
   384     /**
       
   385      * Buffer for request content type
       
   386      * Own.
       
   387      */
       
   388     HBufC8* iRequestContentType;
       
   389 
       
   390     /**
       
   391      * Buffer for response content type
       
   392      * Own.
       
   393      */
       
   394     HBufC8* iResponseContentType;
       
   395 
       
   396     /**
       
   397      * Buffer for response MIME multipart boundary
       
   398      * Own.
       
   399      */
       
   400     HBufC8* iResponseBoundary;
       
   401 
       
   402     /**
       
   403      * Buffer for response MIME multipart start content-id
       
   404      * Own.
       
   405      */
       
   406     HBufC8* iResponseStart;
       
   407 
       
   408     /**
       
   409      * operation id
       
   410      */
       
   411     TInt iOpId;
       
   412 
       
   413     /**
       
   414      * client callback observer
       
   415      */
       
   416     MSimpleOwnCallback& iEngine;
       
   417 
       
   418     /**
       
   419      * whether refresh is made automatically
       
   420      */
       
   421     TBool iRefresh;
       
   422 
       
   423     /**
       
   424      * operation id
       
   425      */
       
   426     TInt iAux;
       
   427     
       
   428     /**
       
   429      * SIP ETag header
       
   430      * Own.
       
   431      */
       
   432     HBufC8* iETag; 
       
   433     
       
   434     /**
       
   435      * Pointer to stack variable to detect the deletion of the heap
       
   436      * instance. This case takes place if a client
       
   437      * calls destructor in callback method.
       
   438      * Own.
       
   439      */
       
   440     TBool* iDestroyedPtr;          
       
   441 
       
   442   };
       
   443   
       
   444     TInt CSimpleEngineRequest::LinkOffset()
       
   445         {
       
   446         return _FOFF(CSimpleEngineRequest, iLink);
       
   447         }    
       
   448 
       
   449 #endif
       
   450 
       
   451 // End of File