mmsharing/mmshavailability/inc/musavaterminal.h
changeset 0 f0cf47e981f9
equal deleted inserted replaced
-1:000000000000 0:f0cf47e981f9
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Discovered terminal
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CMUSAVATERMINAL_H
       
    19 #define CMUSAVATERMINAL_H
       
    20 
       
    21 #include <e32base.h>    // CBase
       
    22 #include "musunittesting.h"
       
    23 
       
    24 
       
    25 class CMusAvaCapabilityQueryBase;
       
    26 class CMusAvaCapability;
       
    27 class CSIPClientTransaction;
       
    28 class CSIPServerTransaction;
       
    29 class CMusAvaCapabilityExchange;
       
    30 class CSdpDocument;
       
    31 class CSIPHeaderBase;
       
    32 class CSIPResponseElements;
       
    33 
       
    34 /**
       
    35  * Discovered terminal
       
    36  *
       
    37  * @lib musavailabilityplugin.dll
       
    38  */
       
    39 class CMusAvaTerminal : public CBase
       
    40     {
       
    41 
       
    42 public: // constructors and destructor
       
    43 
       
    44 
       
    45     static CMusAvaTerminal* NewL( CMusAvaCapabilityExchange& aExchange,
       
    46                                 const TDesC8& aTerminalUri,
       
    47                                 const TDesC8& aTerminalId );
       
    48 
       
    49     virtual ~CMusAvaTerminal();
       
    50 
       
    51 
       
    52 private: // constructors
       
    53 
       
    54     CMusAvaTerminal( CMusAvaCapabilityExchange& aExchange );
       
    55 
       
    56     void ConstructL( const TDesC8& aTerminalUri ,
       
    57                      const TDesC8& aTerminalId );
       
    58 
       
    59 
       
    60 public: // new functions
       
    61 
       
    62     /**
       
    63      * Returns ID
       
    64      *
       
    65      * @return ID
       
    66      */
       
    67     const TDesC8& Id() const;
       
    68 
       
    69     /**
       
    70      * Returns (remote) URI
       
    71      *
       
    72      * @return (remote) URI
       
    73      */
       
    74     const TDesC8& Uri() const;
       
    75 
       
    76     /**
       
    77      * Checks if terminal matches given condition
       
    78      *
       
    79      * @param aTerminalUri terminal uri
       
    80      * @param aTerminalId terminal uri
       
    81      * @return ETrue, if there is a match
       
    82      */
       
    83     TBool MatchL( const TDesC8& aTerminalUri, 
       
    84                   const TDesC8& aTerminalId = KNullDesC8 );
       
    85 
       
    86     /**
       
    87      * Returns requested query (query from peer), if any
       
    88      *
       
    89      * @return executed query or NULL
       
    90      */
       
    91     const CMusAvaCapability* RequestedQuery() const;
       
    92     
       
    93     /**
       
    94      * Executes capability query.
       
    95      *
       
    96      * @param aQuery query to execute, ownership is transferred
       
    97      */
       
    98     void ExecuteQueryL( CMusAvaCapabilityQueryBase* aQuery );
       
    99 
       
   100     /**
       
   101      * Called when final response to OPTIONS has been received
       
   102      *
       
   103      * @param aResponse final response to OPTIONS 
       
   104      * @return EFalse, if response was not consumed
       
   105      */
       
   106     TBool QueryCompletedL( const CSIPClientTransaction& aResponse );
       
   107 
       
   108     /**
       
   109      * Called when query has been canceled.
       
   110      *
       
   111      * @return aTransaction the transaction, which caused cancelation
       
   112      * @return EFalse, if not consumed
       
   113      */
       
   114     TBool QueryCanceled( const CSIPClientTransaction& aTransaction );
       
   115 
       
   116     /**
       
   117      * Query state executing.
       
   118      *
       
   119      * @return ETrue if query executing, otherwise EFalse 
       
   120      */
       
   121     TBool QueryExecuting();
       
   122 
       
   123     /**
       
   124      * Called when OPTIONS request has been received
       
   125      *
       
   126      * @param aQuery query received 
       
   127      */
       
   128     void QueryRequestedL( CSIPServerTransaction& aQuery );
       
   129 
       
   130     /**
       
   131      * Attach query
       
   132      *
       
   133      * @param aQuery a query to be attached
       
   134      * @return number of attached queries
       
   135      */
       
   136     TInt AttachQuery( CMusAvaCapabilityQueryBase& aQuery );
       
   137     
       
   138     /**
       
   139      * Removes query
       
   140      *
       
   141      * @param aQuery a query to be detached
       
   142      * @return number of attached queries
       
   143      */
       
   144     TInt DetachQuery( CMusAvaCapabilityQueryBase& aQuery );
       
   145     
       
   146     /**
       
   147      * Returns ETrue, if terminal is fully discovered
       
   148      *
       
   149      * @return ETrue, if terminal is fully discovered
       
   150      */
       
   151     TBool IsDiscovered();
       
   152  
       
   153      
       
   154 private: // new functions
       
   155 
       
   156     void AttachIdL( const TDesC8& aTerminalId );
       
   157     void AttachUriL( const TDesC8& aUri );
       
   158     void ResetAndDestroyQuery();
       
   159     TBool PopulateResponseL( CSIPServerTransaction& aQuery,
       
   160                         RPointerArray<CSIPHeaderBase>& aResponseHeaders,
       
   161                              CSdpDocument& aSdpContent );
       
   162     void AddResponseHeadersL( CSIPResponseElements& aResponse,
       
   163                         RPointerArray<CSIPHeaderBase>& aResponseHeaders );
       
   164     void AddResponseContentL( CSIPResponseElements& aResponse,
       
   165                               CSdpDocument& aSdpContent );
       
   166     
       
   167     
       
   168 private: // NOT owned data
       
   169 
       
   170     CMusAvaCapabilityExchange& iExchange;
       
   171     CMusAvaCapability* iRequestedQuery;
       
   172 
       
   173 private: // data
       
   174 
       
   175     HBufC8* iTerminalId;
       
   176     HBufC8* iUri;
       
   177     CMusAvaCapabilityQueryBase* iQuery;
       
   178 
       
   179     TInt iQueries;
       
   180     
       
   181     MUS_UNITTEST ( UT_CMusAvaTerminal )
       
   182     MUS_UNITTEST ( UT_CMusAvaCapabilityExchange )
       
   183     MUS_UNITTEST ( UT_CMusAvaCapabilitySipAgent )
       
   184     MUS_UNITTEST ( UT_CMusAvaCapabilityQuery )
       
   185     };
       
   186 
       
   187 
       
   188 #endif // CMUSAVATERMINAL_H