voipplugins/sipconnectionprovider/inc/scputility.h
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SCPUTILITY_H
       
    20 #define SCPUTILITY_H
       
    21 
       
    22 #include <cchservice.h>
       
    23 #include <cchclientserver.h>
       
    24 
       
    25 #include "scpdefs.h"
       
    26 #include "scpsipconnection.h"
       
    27 
       
    28 _LIT8( KSipScheme,  "sip:" );
       
    29 _LIT8( KSipsScheme, "sips:" );
       
    30 _LIT8( KAt, "@" );
       
    31 _LIT8( KColon, ":" );
       
    32 
       
    33 const TInt KSipSchemeMaxLength = 5;
       
    34 
       
    35 /**
       
    36 *  Static utility function for SCP usage.
       
    37 *
       
    38 *  @lib sipconnectionprovider.dll
       
    39 */
       
    40 class TScpUtility
       
    41     {
       
    42 public:
       
    43                               
       
    44    /**
       
    45     * Converts a sip connection state to connection event
       
    46     * @param aState sip connection state
       
    47     * @return CCH state
       
    48     */
       
    49     static TScpConnectionEvent ConvertToConnectionEvent( 
       
    50         CScpSipConnection::TConnectionState aState,
       
    51         TInt aError );
       
    52 
       
    53    /**
       
    54     * Converts a CCH state to conection event
       
    55     * @param aState sip connection state
       
    56     * @return CCH state
       
    57     */
       
    58     static TScpConnectionEvent ConvertToConnectionEvent( 
       
    59         TCCHSubserviceState aState );
       
    60     
       
    61    /**
       
    62     * Implementation for cleanup item.
       
    63     * Resets and destroys array of the RCSE
       
    64     * entries. 
       
    65     * @param anArray RPointerArray pointer.
       
    66     */
       
    67     static void ResetAndDestroyEntries( TAny* anArray );
       
    68     
       
    69    /**
       
    70     * Converts a sip error to CCH error
       
    71     * @param aState sip error
       
    72     * @return CCH error
       
    73     */
       
    74     static TInt ConvertToCchError( TInt aErrorCode );
       
    75 
       
    76     /**
       
    77      * Parse prefix and/or domain from username.
       
    78      * @param aUsername Username with prefix/domain
       
    79      * @param aFormattedUsername parsed username without prefix/domain is stored to this
       
    80      * @return Symbian error code
       
    81      */
       
    82     static TInt RemovePrefixAndDomain( 
       
    83         const TDesC8& aUsername, 
       
    84         RBuf8& aFormattedUsername );
       
    85     
       
    86     /**
       
    87      * Check if passed username is valid.
       
    88      * @param aUsername Username to check
       
    89      * @return True if valid, false if no.
       
    90      */
       
    91     static TBool CheckSipUsername( const TDesC8& aUsername );
       
    92 
       
    93     /**
       
    94      * Check if passed password is valid.
       
    95      * @param aPassweord Password to check
       
    96      * @return True if valid, false if no.
       
    97      */
       
    98     static TBool CheckSipPassword( const TDesC8& aPassword );
       
    99     
       
   100     /**
       
   101      * Prefix getter.
       
   102      * @param aUsername used username
       
   103      * @param aPrefix valid prefix
       
   104      */
       
   105     static void GetValidPrefix( const TDesC8& aUsername, TDes8& aPrefix );
       
   106     
       
   107 private:
       
   108 
       
   109     // Structure that maps protocol specific errors to generic CCH errors
       
   110     struct SCchErrorMapping 
       
   111         {
       
   112         TInt iServiceError;
       
   113         TInt iProtocolError;
       
   114         };
       
   115     
       
   116     // Collection of mapped error codes
       
   117     static const SCchErrorMapping iErrorTable[];
       
   118 
       
   119     };
       
   120 
       
   121 #endif      // SCPUTILITY_H   
       
   122             
       
   123 // End of File