realtimenetprots/sipfw/ClientResolver/Resolver/api/sipresolvedclient2.h
author Petteri Saari <petteri.saari@digia.com>
Thu, 25 Nov 2010 13:59:42 +0200
branchMSRP_FrameWork
changeset 58 cdb720e67852
parent 0 307788aac0a8
permissions -rw-r--r--
This release addresses the following issues: 1. The crash bug fix when receiving file 2. Now the sending is based on MSRP messages, there is no longer file receiving or sending. Client sends data as MSRP was designed. 3. Soma MSRP stack was created so that the client told the correct session-id, Symbian stack generated it by itself. This is not allowed, it was changed so that clients tell the session-id (same as used in SIP INVITE). 4. Unnecessary division of data to chunks removed when there is no need to interrupt sending. The message is sent in as few chunks as possible. 5. Stack can now receive files and chunks with ?unlimited? size. Old stack wrote the incoming data to memory and did not utilize disk space until the end of chunk was reached (large chunks from another client crashed it). 6. Now when writing the incoming data to file, it will take into account the byte-range header values. So, this complies with the RFC4975 requirements that stack must be able to handle chunks that come in any sequence. 7. Some buffering changes to outgoing/incoming data. 8. The outgoing data is now checked that it does not contain the created transaction-id before sending the data. 9. MSRP success reports are now implemented and tested against servers. 10. Progress report system fixed so progress is now visible on client (all the way to 100%). 11. Message Cancel receiving / Cancel sending now corrected and made to work as rfc4975 requires. (termination from sender and error code from receiver when cancelling). 12. Bug correction related to messages received not belonging to any session, old stack implementation did send error response, but after response was written it did give the buffer to client anyway. Now corrected.

/*
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
* Name        : sipresolvedclient2.h
* Part of     : SIP Client Resolver API
* Version     : 1.0
*
*/



#ifndef CSIPRESOLVEDCLIENT2_H
#define CSIPRESOLVEDCLIENT2_H

// INCLUDES
#include <sipacceptcontactheader.h>
#include <sipeventheader.h>
#include <stringpool.h>
#include <uri8.h>
#include <sipheaderbase.h>
#include <sipcontenttypeheader.h>
#include <e32base.h>

// FORWARD DECLARATIONS
class CSdpMediaField;

// CONSTANTS
/** Interface UID of this ECOM interface*/
const TUid KSIPResolvedClient2IFUid = { 0x10282EE5 };

// CLASS DEFINITION
/**
* @publishedAll
* @released
*
* Interface that SIP stack's clients must realize 
* in order to be able to receive incoming SIP requests outside SIP dialogs.
* Note that channel UIDs must be unique accross all SIP clients 
* e.g. clients may use UIDs assigned for binaries.
* 
* SIP stack utilizes the plug-ins that implement 
* this interface in the following manner:
*
* 1) If the SIP request does not contain Accept-Contact-header(s), go to step 2.
*    SIP stack calls CSIPResolvedClient2::MatchAcceptContactsL 
*    for all the plug-ins and applies the following logic: 
*    a) None of the clients match -> go to step 2
*    b) One client matches -> the SIP request is routed to the matching client
*    c) Several clients match -> go to step 2
*
* 2) If the SIP request does not contain Event-header, go to step 3.
*    SIP stack calls CSIPResolvedClient2::MatchEventL 
*    for all the plug-ins and applies the following logic:
*    a) None of the clients match -> go to step 3
*    b) One client matches -> the SIP request is routed to the matching client
*    c) Several clients match -> go to step 3
*
* 3) SIP stack calls CSIPResolvedClient2::MatchRequestL for all the plug-ins.
*    a) None of the clients match -> SIP generates an error response
*    b) One client matches -> the SIP request is routed to the matching client
*    c) Several clients match -> 
*       SIP picks one of these clients randomly and routes the request to it. 
*       The ROM-based clients are preferred.
*/
class CSIPResolvedClient2 : public CBase
    {
    public:    // Destructor

        /**
        * Destructor
        */
        inline ~CSIPResolvedClient2();

    public: // Abstract methods

        /**
        * Matches the Accept-Contact-headers 
        * to the client(s) represented by this plug-in.
        * This function is called for an incoming SIP request 
        * if it contains Accept-Contact-header(s).
        * @param aMethod the method of the SIP request
        * @param aRequestUri the request-URI of the SIP request
        * @param aHeaders all the headers in the SIP request
        * @param aContent SIP request body; 
        *        zero-length descriptor if not present
        * @param aContentType the content-type of the SIP request. 
        *        Zero-pointer if body is not present.
        * @param aClientUid indicates client's UID for 
        *        SIP e.g. the one passed as a parameter to CSIP::NewL().
        * @return ETrue, if the Accept-Contact-headers match to the client
        *         represented by this plug-in, otherwise EFalse. 
        */
        virtual TBool MatchAcceptContactsL(
            RStringF aMethod,
            const CUri8& aRequestUri,
            const RPointerArray<CSIPHeaderBase>& aHeaders,
            const TDesC8& aContent,
            const CSIPContentTypeHeader* aContentType,
            TUid& aClientUid) = 0;

        /**
        * Matches the Event-header to the client(s) represented by this plug-in.
        * This function is called for an incoming SIP request, 
        * if it contains an Event-header and 
        * MatchAcceptContactsL returned EFalse.
        * @param aMethod the method of the SIP request
        * @param aRequestUri the request-URI of the SIP request
        * @param aHeaders all the headers in the SIP request
        * @param aContent SIP request body; 
        *        zero-length descriptor if not present
        * @param aContentType the content-type of the SIP request. 
        *        Zero-pointer if body is not present.
        * @param aClientUid indicates client's UID for 
        *        SIP e.g. the one passed as a parameter to CSIP::NewL().
        * @return ETrue, if the Event-header matches to the client
        *         represented by this plug-in, otherwise EFalse. 
        */
        virtual TBool MatchEventL(
            RStringF aMethod,
            const CUri8& aRequestUri,
            const RPointerArray<CSIPHeaderBase>& aHeaders,
            const TDesC8& aContent,
            const CSIPContentTypeHeader* aContentType,
            TUid& aClientUid) = 0;

        /**
        * Matches the whole SIP request to the client(s) 
        * represented by this plug-in.
        * This function is called if the SIP request does not contain 
        * Accept- or Event-headers or  
        * MatchAcceptContactsL and MatchEventL returned EFalse.
        * @param aMethod the method of the SIP request
        * @param aRequestUri the request-URI of the SIP request
        * @param aHeaders all the headers in the SIP request
        * @param aContent SIP request body; 
        *        zero-length descriptor if not present
        * @param aContentType the content-type of the SIP request. 
        *        Zero-pointer if body is not present.
        * @param aClientUid indicates client's UID for 
        *        SIP e.g. the one passed as a parameter to CSIP::NewL().
        * @return ETrue, if the request can be handled by the client
        *         represented by this plug-in, otherwise EFalse. 
        */
        virtual TBool MatchRequestL(
            RStringF aMethod,
            const CUri8& aRequestUri,
            const RPointerArray<CSIPHeaderBase>& aHeaders,
            const TDesC8& aContent,
            const CSIPContentTypeHeader* aContentType,
            TUid& aClientUid) = 0;

        /**
        * Indicates whether the plug-in implements CSIPResolvedClient2::ConnectL
        * and by calling CSIPResolvedClient2::ConnectL 
        * SIP stack is able to force the client to connect to SIP stack.
        * @return ETrue, if the plug-in supports 
        *         CSIPResolvedClient2::ConnectL, otherwise EFalse.
        */
        virtual TBool ConnectSupported() = 0;

        /**
        * Requests the client to connect to SIP with 
        * the resolved UID in case there's no client connection with the UID.
        * @param aClientUid previously resolved client UID
        */
        virtual void ConnectL(const TUid& aClientUid) = 0;
        
        /**
        * Cancels a ConnectL request for a client.
        * Is called when for example a CANCEL for an INVITE is received 
        * before the client connects to SIP stack.
        * @param aClientUid a UID for which ConnectL was previously called
        */
        virtual void CancelConnect(const TUid& aClientUid) = 0;

        /** 
        * Gets all the SIP message content types supported by the client.
        * @return 0..n SIP Content-Type-headers.
        *         The ownership of the headers is transferred. 
        */
        virtual RPointerArray<CSIPContentTypeHeader> 
            SupportedContentTypesL() = 0;

        /** 
        * Gets all the SDP media-fields supported by the client.
        * @return 0..n SDP media-fields describing the client's media support.
        *         The ownership of the media-fields is transferred. 
        */
        virtual RPointerArray<CSdpMediaField> 
            SupportedSdpMediasL() = 0;
            

        /**
        * Adds client specific SIP-headers for the 200 OK for OPTIONS.
        * Each plug-in must check that the header to be added
        * is not yet in the array. For example when adding header 
        * "Allow: INVITE" the client must check that 
        * the header is not already present in the array.
        * @param aHeaders headers to be added to 200 OK for OPTIONS. 
        *        The ownership of the added headers is transferred to the caller.
        */            
        virtual void AddClientSpecificHeadersForOptionsResponseL(
            RPointerArray<CSIPHeaderBase>& aHeaders) = 0;

    public: // Data

        /// Unique key for implementations of this interface.
        TUid iInstanceKey;
		
		TUid iImplementationUid;
		
    protected: // Constructors:

        inline CSIPResolvedClient2();
    };

#include "sipresolvedclient2.inl"

#endif // CSIPRESOLVEDCLIENT2_H