webservices/wsutils/inc/senguidgen.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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: Header declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 #ifndef CCGUIDGEN_H
       
    28 #define CCGUIDGEN_H
       
    29 
       
    30 // INCLUDES
       
    31 #include <e32base.h>
       
    32 #include <e32std.h>
       
    33 
       
    34 // CONSTANTS
       
    35 _LIT8(KSenUuidPrefix, "uuid:"); // GUID is valid URN
       
    36 const TInt KSenUuidMaxHostIdLength = 64;
       
    37 const TInt KSenUuidMaxInt64Length = 20;
       
    38 const TInt KSenUuidNumOfSlashes = 4;
       
    39 const TInt KSenUuidHexWidth = 2;
       
    40 const TInt KSenUuidPrefixLength = 5; // KSenUuidPrefix().Length(); 
       
    41 const TInt KSenUuidHashMultiplier = 2;
       
    42 const TInt KSenUuidHashReserved = 2;
       
    43 const TInt KSenUuidMaxHashLength = KSenUuidMaxHostIdLength + KSenUuidMaxInt64Length * KSenUuidHashMultiplier + KSenUuidHashReserved;
       
    44 const TInt KSenUuidMaxLength = KSenUuidPrefixLength + KSenUuidMaxHashLength * KSenUuidHexWidth + KSenUuidNumOfSlashes; 
       
    45 
       
    46 // FORWARD DECLARATIONS
       
    47 class CMD5;
       
    48 
       
    49 // CLASS DECLARATION
       
    50 class CSenGuidGen : public CBase
       
    51     {
       
    52     public: // Constructors and destructor
       
    53         
       
    54         IMPORT_C static CSenGuidGen* NewL();
       
    55         IMPORT_C static CSenGuidGen* NewLC();
       
    56         ~CSenGuidGen();
       
    57         
       
    58         // New functions
       
    59         
       
    60         /**
       
    61         *  Generate totally random (but not cryptographically strong)
       
    62         *  GUIDs. The GUID is based on the MD5 hash of a random number
       
    63         *  and the current time. Some kind of host ID should be also
       
    64         *  used but the author did not find an easy way of getting it.
       
    65         */
       
    66         IMPORT_C HBufC* GetRandomGuidLC();
       
    67         IMPORT_C HBufC8* GetRandomGuid8LC();
       
    68         IMPORT_C HBufC16* GetRandomGuid16LC();
       
    69         
       
    70     private:
       
    71     /**
       
    72     * C++ default constructor.
       
    73         */
       
    74         CSenGuidGen();
       
    75         /**
       
    76         * By default Symbian 2nd phase constructor is private.
       
    77         */  
       
    78         void ConstructL();
       
    79         
       
    80         // New functions
       
    81         
       
    82         TPtrC8 GetRandomHash();
       
    83         
       
    84     private: // Data
       
    85         TInt64 iSeed;
       
    86         HBufC8 *ipHostId;
       
    87         CMD5 *ipMd5HashGen;
       
    88     };
       
    89 
       
    90 #endif // CCGUIDGEN_H
       
    91 
       
    92 // End of File
       
    93