realtimenetprots/sipfw/SIP/Client/inc/sipclient.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) 2006-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          : sipclient.h
* Part of       : SIPClient
* Version       : SIP/5.0 
*
*/




/**
 @internalComponent
*/

#ifndef CSIPCLIENT_H
#define CSIPCLIENT_H

#include "sipclientserver.h"
#include <e32base.h>
#include <badesca.h>
#include "_sipcodecdefs.h"

class MSIPClientObserver;
class MSIPHttpDigestChallengeObserver;
class MSIPHttpDigestChallengeObserver2;
class CSIPClientConnection;
class RSIP;
class CSIPClientReceiver;


/**
 * @brief Class for connecting to SIP server and for managing SIP transactions.
 * 
 * @class CSIPClient sipclient.h "sipclient.h"
 *
 * This class is used to communicate with the SIP server
 * Class provides functions for sending and receiving 
 * SIP requests and SIP responses.
 * This class also provides functions for creating and destroying SIP dialogs,
 * sending and receiving SIP requests and responses within SIP dialogs,
 * canceling the SIP requests.
 *
 * This class can only be created once by an application (a singleton class)
 *
 * If the preconditions or postconditions are not met the 
 * function call will result in panics. 
 * 
 * For SIP specific error codes @see TError
 */

class CSIPClient : public CBase
	{
public:

	/** SIP specific errors */
	enum TError
		{		
		/** Non-existing request Id provided */
		ENonExistingRequestId = 10,
		/** Non-existing dialog Id provided */
		ENonExistingDialogId,
		/** Non-existing refresh Id provided */
		ENonExistingRefreshId,
		/** Non-existing registration Id provided */
		ENonExistingRegistrationId
		};

	/**
	 * Constructs an object; leaves on failure.
	 *
	 * @param aUid an unique id that identifies an application
	 * @param aSIPObserver a sip observer. 
     *        This callback is used for passing 
     *        SIP requests and internal errors to application.
	 * @returns new instance, the ownership is transferred
	 */
	static CSIPClient* NewL (const TUid& aUid,
		                     MSIPClientObserver& aSIPObserver);

	/**
	 * Constructs an object and adds the pointer to the cleanup stack;
	 *
	 * @param aUid an unique id that identifies an application
	 * @param aSIPObserver a sip observer. 
     *        This callback is used for passing 
     *        SIP requests and internal errors to application.
	 * @returns new instance, the ownership is transferred
	 */
	static CSIPClient* NewLC (const TUid& aUid,
		                      MSIPClientObserver& aSIPObserver);

	/**
	 * Destructor
	 */

	~CSIPClient ();

    /**
     * Gets the names of all the supported security mechanisms
	 * @returns Supported SIP security mechanisms names (e.g. digest)
     *          The ownership is transferred.
	 */
    CDesC8Array* SupportedSecurityMechanismsL() const;
    
	/**
	 * Gets negotiated security mechanism with the next hop
	 * on the signaling path.
	 * @param aHop the next hop's FQDN or numeric IP address
	 * @return negotiated security mechanism or zero-pointer in case no
	 *		  security mechanism was negotiated with the next hop;
	 *		  the ownership is transferred
	 */
	HBufC8* NegotiatedSecurityMechanismL(const TDesC8& aHop);    

    /**
     * Checks if the signalling compression (SigComp) is supported.
     * Leaves on failure with a system wide error code.
     * @returns ETrue if supported, EFalse otherwise
     */
    TBool IsSigCompSupportedL() const;

	/**
     * Checks if the user has a connection created for given IAP-id
     * @param aIapId IAP-id
     * @returns a connection or 0-pointer if connection does not exist
     */
	CSIPClientConnection* Connection (TUint32 aIapId) const;

    /*
     * By default the SIP built-in security mechanisms are enabled.
     * @param aEnabled if set to EFalse the build-in SIP security handling 
     *        mechanism is disabled.
     */
    void SetSecurityHandlingL(TBool aEnabled);

	/**
	 * Sets the observer to listen for the possible received challenges.
	 * @param aObserver an observer for the received challenges.
	 * @returns KErrNone if the observer was set successfully.
	 *          KErrNoMemory if out of memory.
	 */
    TInt SetHttpDigestObserver(MSIPHttpDigestChallengeObserver& aObserver);
	
	/**
	 * Sets the observer to listen for the possible received challenges.
	 * @param aObserver an observer for the received challenges.
	 * @returns KErrNone if the observer was set successfully.
	 *          KErrNoMemory if out of memory.
	 */
    TInt SetHttpDigestObserver(MSIPHttpDigestChallengeObserver2& aObserver);	

	/**
	 * Removes the observer that listens for the possible received challenges.
	 */	
	void RemoveHttpDigestObserver();
	
    /**
	 * Sets credentials for a realm.
	 * @param aRequestId request id if needed, otherwise zero
	 * @param aRefreshId refresh id if needed, otherwise zero
	 * @param aRealm servers's realm
	 * @param aUsername user's name
	 * @param aPasswd user's password for the given server's realm
	 * @param aOutboundProxy an outbound proxy (FQDN or IP address)
	 *        Must be set to KNullDesC8 if not used.	 
	 * @leave KErrNoMemory if out of memory
	 */
    void SetCredentialsL(TUint32 aRequestId,
                         TUint32 aRefreshId,
                         const TDesC8& aRealm,
			             const TDesC8& aUsername,
			             const TDesC8& aPasswd,
			             const TDesC8& aOutboundProxy);
			            
    /**
	 * Removes all set credentials for the realm 
	 * @param aRealm servers's realm. 
	 *        If set to KNullDesC8 clears all the credentials for
	 *        this CSIPClient.
	 * @return KErrNone if no error; KErrNoMemory if out of memory; 
	 *         KErrNotFound if the given realm was not found
     */
	TInt RemoveCredentials(const TDesC8& aRealm);                          
		
    /**
     * Ignores the challenge for the realm. 
     * As a result the error will be generated to the original request.
	 * @param aRequestId request id if needed, otherwise zero
	 * @param aRefreshId refresh id if needed, otherwise zero      
	 * @param aRealm a realm for which the challenge was ignored
	 * @returns KErrNone if no error; KErrNoMemory if out of memory;
	 *          KErrNotFound if the given realm was not found
	 */
    TInt IgnoreChallenge(TUint32 aRequestId,
                         TUint32 aRefreshId,
                         const TDesC8& aRealm);	


public: // For SIP Client's internal use

    void AddL (CSIPClientConnection* aConnection);
    TInt Remove (const CSIPClientConnection* aConnection);
    RSIP& SIP ();

private:

	CSIPClient ();
	void ConstructL (const TUid& aUid, MSIPClientObserver& aObserver);
    TInt FindIndex (TUint32 aIapId) const;
    TInt SendHttpDigestObserverTypeToServer(
        const TSipHttpDigestObserverType& aObserverType); 

private: // Data
    
    RPointerArray<CSIPClientConnection> iConnections;
    RSIP* iSip;
	CSIPClientReceiver* iReceiver;

private: // For testing purposes

    UNIT_TEST(CSIPClientTest)
	};

#endif // CSIPCLIENT_H

// End of File