phonebookengines/contactsmodel/tsrc/dbcreator.h
changeset 0 e686773b3f54
child 24 0ba2181d7c28
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2008-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 * Summary:
       
    16 * A class for creating a CContactDatabase object with random data.
       
    17 * The contact items take the form of the following example:
       
    18 * [KUidContactFieldFamilyName]	Fasiokljno	<5-10 chars>
       
    19 * [KUidContactFieldGivenName]		Liasidwq	<5-10 chars>
       
    20 * [KUidContactFieldCompanyName]	Xwjweiohj	<5-10 chars>	
       
    21 * [KUidContactFieldPhoneNumber]	9874234891	<10 digits>
       
    22 * Usage example:
       
    23 * #include "dbcreator.h"
       
    24 * void MyFunctionL()
       
    25 * // create a database populated with 500 randomly created contact items
       
    26 * const TInt KNumContacts(500);
       
    27 * _LIT(KDbName, "C:mydb.cbd");
       
    28 * CContactDatabase* db = DbCreator::CreateDbL(KDbName, KNumContacts);
       
    29 * CleanupStack::PushL(db);
       
    30 * // do something interesting...
       
    31 * CleanupStack::PopAndDestroy(db);
       
    32 * CContactDatabase::DeleteDatabaseL(KDbName);
       
    33 * Written by:
       
    34 * James Clarke
       
    35 * 
       
    36 *
       
    37 */
       
    38 
       
    39 
       
    40 
       
    41 #ifndef __DBCREATOR_H__
       
    42 #define __DBCREATOR_H__
       
    43 
       
    44 #include <cntdb.h>
       
    45 #include <cntitem.h>
       
    46 #include <cntfield.h>
       
    47 #include <cntfldst.h>
       
    48 #include <e32math.h>
       
    49 #include <e32cmn.h>
       
    50 
       
    51 
       
    52 class DbCreator
       
    53 	{
       
    54 public:
       
    55 	static CContactDatabase* CreateDbL(const TDesC &aFileName, TInt aNumContacts);
       
    56 private:
       
    57 	static TUint RandomNum(TUint aMin, TUint aMax);
       
    58 	static TChar RandomAlphaChar(TBool aIsUpper);
       
    59 	static HBufC* RandomNameL();
       
    60 	static HBufC* RandomPhoneNumL();
       
    61 	static void PopulateDatabaseL(CContactDatabase& aDb, TInt aNumContacts);
       
    62 	};
       
    63 
       
    64 
       
    65 
       
    66 #endif //__DBCREATOR_H__