creator/engine/src/creator_phonebook.cpp
author hgs
Fri, 17 Sep 2010 14:22:55 +0300
changeset 52 36d60d12b4af
parent 51 b048e15729d6
permissions -rw-r--r--
201037
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description: 
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include "engine.h"
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include "enginewrapper.h"
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
    21
#include "creator_contactsetcache.h"
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
31
hgs
parents: 29
diff changeset
    23
#include "creator_phonebook.h"
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include "creator_traces.h"
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <bautils.h> 
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
_LIT(KTempPath, "C:\\Data\\Creator\\");
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
typedef struct {
31
hgs
parents: 29
diff changeset
    32
TInt iFieldCode;
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
TInt iRandomType;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
} DetailFieldInfo;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
static const TInt RND_TYPE_UNDEF = -99;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
DetailFieldInfo CreatorPbkMiscTextFields[] = {        
31
hgs
parents: 29
diff changeset
    37
        {CCreatorPhonebookWrapper::EFirstName, (TInt) CCreatorEngine::EFirstName},
hgs
parents: 29
diff changeset
    38
        {CCreatorPhonebookWrapper::EFirstNameReading, (TInt) CCreatorEngine::EFirstName},
hgs
parents: 29
diff changeset
    39
        {CCreatorPhonebookWrapper::ELastName, (TInt) CCreatorEngine::ESurname},
hgs
parents: 29
diff changeset
    40
        {CCreatorPhonebookWrapper::ELastNameReading, (TInt) CCreatorEngine::ESurname},
hgs
parents: 29
diff changeset
    41
        {CCreatorPhonebookWrapper::ECompanyName, (TInt) CCreatorEngine::ECompany},
hgs
parents: 29
diff changeset
    42
        {CCreatorPhonebookWrapper::EJobTitle, (TInt) CCreatorEngine::EJobTitle},
hgs
parents: 29
diff changeset
    43
        {CCreatorPhonebookWrapper::EPrefix, (TInt) CCreatorEngine::EPrefix},
hgs
parents: 29
diff changeset
    44
        {CCreatorPhonebookWrapper::ESuffix, (TInt) CCreatorEngine::ESuffix},
hgs
parents: 29
diff changeset
    45
        {CCreatorPhonebookWrapper::ESecondName, (TInt) CCreatorEngine::EFirstName},
hgs
parents: 29
diff changeset
    46
        {CCreatorPhonebookWrapper::EAddrLabelGen, (TInt) CCreatorEngine::EAddress},
hgs
parents: 29
diff changeset
    47
        {CCreatorPhonebookWrapper::EAddrPoGen, (TInt) CCreatorEngine::EPobox},
hgs
parents: 29
diff changeset
    48
        {CCreatorPhonebookWrapper::EAddrExtGen, (TInt) CCreatorEngine::EAddress},
hgs
parents: 29
diff changeset
    49
        {CCreatorPhonebookWrapper::EAddrStreetGen, (TInt) CCreatorEngine::EAddress},
hgs
parents: 29
diff changeset
    50
        {CCreatorPhonebookWrapper::EAddrLocalGen, (TInt) CCreatorEngine::ECity},
hgs
parents: 29
diff changeset
    51
        {CCreatorPhonebookWrapper::EAddrRegionGen, (TInt) CCreatorEngine::EState},
hgs
parents: 29
diff changeset
    52
        {CCreatorPhonebookWrapper::EAddrPostCodeGen, (TInt) CCreatorEngine::EPostcode},
hgs
parents: 29
diff changeset
    53
        {CCreatorPhonebookWrapper::EAddrCountryGen, (TInt) CCreatorEngine::ECountry},
hgs
parents: 29
diff changeset
    54
        {CCreatorPhonebookWrapper::EAddrLabelHome, (TInt) CCreatorEngine::EAddress},
hgs
parents: 29
diff changeset
    55
        {CCreatorPhonebookWrapper::EAddrPoHome, (TInt) CCreatorEngine::EPobox},
hgs
parents: 29
diff changeset
    56
        {CCreatorPhonebookWrapper::EAddrExtHome, (TInt) CCreatorEngine::EAddress},
hgs
parents: 29
diff changeset
    57
        {CCreatorPhonebookWrapper::EAddrStreetHome, (TInt) CCreatorEngine::EAddress},
hgs
parents: 29
diff changeset
    58
        {CCreatorPhonebookWrapper::EAddrLocalHome, (TInt) CCreatorEngine::ECity},
hgs
parents: 29
diff changeset
    59
        {CCreatorPhonebookWrapper::EAddrRegionHome, (TInt) CCreatorEngine::EState},
hgs
parents: 29
diff changeset
    60
        {CCreatorPhonebookWrapper::EAddrPostCodeHome, (TInt) CCreatorEngine::EPostcode},
hgs
parents: 29
diff changeset
    61
        {CCreatorPhonebookWrapper::EAddrCountryHome, (TInt) CCreatorEngine::ECountry},
hgs
parents: 29
diff changeset
    62
        {CCreatorPhonebookWrapper::EAddrLabelWork, (TInt) CCreatorEngine::EAddress},
hgs
parents: 29
diff changeset
    63
        {CCreatorPhonebookWrapper::EAddrPoWork, (TInt) CCreatorEngine::EPobox},
hgs
parents: 29
diff changeset
    64
        {CCreatorPhonebookWrapper::EAddrExtWork, (TInt) CCreatorEngine::EAddress},
hgs
parents: 29
diff changeset
    65
        {CCreatorPhonebookWrapper::EAddrStreetWork, (TInt) CCreatorEngine::EAddress},
hgs
parents: 29
diff changeset
    66
        {CCreatorPhonebookWrapper::EAddrLocalWork, (TInt) CCreatorEngine::ECity},
hgs
parents: 29
diff changeset
    67
        {CCreatorPhonebookWrapper::EAddrRegionWork, (TInt) CCreatorEngine::EState},
hgs
parents: 29
diff changeset
    68
        {CCreatorPhonebookWrapper::EAddrPostCodeWork, (TInt) CCreatorEngine::EPostcode},
hgs
parents: 29
diff changeset
    69
        {CCreatorPhonebookWrapper::EAddrCountryWork, (TInt) CCreatorEngine::ECountry},
hgs
parents: 29
diff changeset
    70
        {CCreatorPhonebookWrapper::EPoc, (TInt) CCreatorEngine::EPhoneNumber},
hgs
parents: 29
diff changeset
    71
        {CCreatorPhonebookWrapper::ESwis, (TInt) CCreatorEngine::EPhoneNumber},
hgs
parents: 29
diff changeset
    72
        {CCreatorPhonebookWrapper::ESip, (TInt) CCreatorEngine::EPhoneNumber},
hgs
parents: 29
diff changeset
    73
        {CCreatorPhonebookWrapper::EDtmfString, (TInt) CCreatorEngine::EFirstName},
hgs
parents: 29
diff changeset
    74
        {CCreatorPhonebookWrapper::ENote,(TInt)  CCreatorEngine::EMemoText},
hgs
parents: 29
diff changeset
    75
        {CCreatorPhonebookWrapper::EMiddleName, (TInt) CCreatorEngine::EFirstName},
hgs
parents: 29
diff changeset
    76
        {CCreatorPhonebookWrapper::EDepartment, (TInt) CCreatorEngine::ECompany},
hgs
parents: 29
diff changeset
    77
        {CCreatorPhonebookWrapper::EAsstName, (TInt) CCreatorEngine::EFirstName},
hgs
parents: 29
diff changeset
    78
        {CCreatorPhonebookWrapper::ESpouse, (TInt) CCreatorEngine::EFirstName},
hgs
parents: 29
diff changeset
    79
        {CCreatorPhonebookWrapper::EChildren, (TInt) CCreatorEngine::EFirstName},
hgs
parents: 29
diff changeset
    80
        {CCreatorPhonebookWrapper::ESyncClass, RND_TYPE_UNDEF},
hgs
parents: 29
diff changeset
    81
        {CCreatorPhonebookWrapper::ELocPrivacy, RND_TYPE_UNDEF},
hgs
parents: 29
diff changeset
    82
        {CCreatorPhonebookWrapper::EGenLabel, (TInt) CCreatorEngine::EFirstName},
hgs
parents: 29
diff changeset
    83
        {CCreatorPhonebookWrapper::EWVAddress, (TInt) CCreatorEngine::EPhoneNumber},
hgs
parents: 29
diff changeset
    84
        {CCreatorPhonebookWrapper::ERingTone, RND_TYPE_UNDEF},
hgs
parents: 29
diff changeset
    85
        {CCreatorPhonebookWrapper::EThumbnailPic, RND_TYPE_UNDEF},
hgs
parents: 29
diff changeset
    86
        {CCreatorPhonebookWrapper::ECallerObjText, (TInt) CCreatorEngine::EFirstName}
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
        };
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
                  
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
31
hgs
parents: 29
diff changeset
    90
TInt CreatorPbkBinaryFields[] = {
hgs
parents: 29
diff changeset
    91
        CCreatorPhonebookWrapper::ECallerObjImg//,
hgs
parents: 29
diff changeset
    92
        //R_VPBK_FIELD_TYPE_THUMBNAILPATH
hgs
parents: 29
diff changeset
    93
        };
hgs
parents: 29
diff changeset
    94
hgs
parents: 29
diff changeset
    95
TInt CreatorPbkDateTimeFields[] = {
hgs
parents: 29
diff changeset
    96
        CCreatorPhonebookWrapper::EAnniversary
hgs
parents: 29
diff changeset
    97
        };
hgs
parents: 29
diff changeset
    98
hgs
parents: 29
diff changeset
    99
//----------------------------------------------------------------------------
hgs
parents: 29
diff changeset
   100
TInt CreatorPbkPhoneNumberFields[] =
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
    {
31
hgs
parents: 29
diff changeset
   102
    CCreatorPhonebookWrapper::ELandPhoneGen,
hgs
parents: 29
diff changeset
   103
    CCreatorPhonebookWrapper::ELandPhoneHome,
hgs
parents: 29
diff changeset
   104
    CCreatorPhonebookWrapper::ELandPhoneWork,                        
hgs
parents: 29
diff changeset
   105
    CCreatorPhonebookWrapper::EMobilePhoneGen,
hgs
parents: 29
diff changeset
   106
    CCreatorPhonebookWrapper::EMobilePhoneHome,
hgs
parents: 29
diff changeset
   107
    CCreatorPhonebookWrapper::EMobilePhoneWork,
hgs
parents: 29
diff changeset
   108
    CCreatorPhonebookWrapper::EFaxNumberGen,
hgs
parents: 29
diff changeset
   109
    CCreatorPhonebookWrapper::EFaxNumberHome,
hgs
parents: 29
diff changeset
   110
    CCreatorPhonebookWrapper::EFaxNumberWork,
hgs
parents: 29
diff changeset
   111
    CCreatorPhonebookWrapper::EPagerNumber,           
hgs
parents: 29
diff changeset
   112
    CCreatorPhonebookWrapper::EVideoNumberGen,
hgs
parents: 29
diff changeset
   113
    CCreatorPhonebookWrapper::EVideoNumberHome,
hgs
parents: 29
diff changeset
   114
    CCreatorPhonebookWrapper::EVideoNumberWork,
hgs
parents: 29
diff changeset
   115
    CCreatorPhonebookWrapper::EVoipGen,
hgs
parents: 29
diff changeset
   116
    CCreatorPhonebookWrapper::EVoipHome,
hgs
parents: 29
diff changeset
   117
    CCreatorPhonebookWrapper::EVoipWork,
hgs
parents: 29
diff changeset
   118
    CCreatorPhonebookWrapper::EAsstPhone,
hgs
parents: 29
diff changeset
   119
    CCreatorPhonebookWrapper::ECarPhone
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    };
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
31
hgs
parents: 29
diff changeset
   122
TInt CreatorPbkUrlFields[] =
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
    {
31
hgs
parents: 29
diff changeset
   124
    CCreatorPhonebookWrapper::EUrlGen,
hgs
parents: 29
diff changeset
   125
    CCreatorPhonebookWrapper::EUrlHome,
hgs
parents: 29
diff changeset
   126
    CCreatorPhonebookWrapper::EUrlWork
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
    };
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
31
hgs
parents: 29
diff changeset
   129
TInt CreatorPbkEmailFields[] =
hgs
parents: 29
diff changeset
   130
    {
hgs
parents: 29
diff changeset
   131
    CCreatorPhonebookWrapper::EEmailGen,
hgs
parents: 29
diff changeset
   132
    CCreatorPhonebookWrapper::EEmailHome,
hgs
parents: 29
diff changeset
   133
    CCreatorPhonebookWrapper::EEmailWork
hgs
parents: 29
diff changeset
   134
    };
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
CPhonebookParameters::CPhonebookParameters()
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
    {
31
hgs
parents: 29
diff changeset
   138
    LOGSTRING("Creator: CPhonebookParameters::CVirtualPhonebookParameters");
hgs
parents: 29
diff changeset
   139
    iGroupName = HBufC::New(KPhonebookFieldLength);  
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
CPhonebookParameters::~CPhonebookParameters()
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
    {
31
hgs
parents: 29
diff changeset
   144
    LOGSTRING("Creator: CPhonebookParameters::~CPhonebookParameters");
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
31
hgs
parents: 29
diff changeset
   146
    delete iGroupName;   
hgs
parents: 29
diff changeset
   147
    for( TCreatorContactFields::iterator it = iContactFields.begin(); it != iContactFields.end(); ++it)
hgs
parents: 29
diff changeset
   148
        {
hgs
parents: 29
diff changeset
   149
        HBufC* temp =  (*it).second;
hgs
parents: 29
diff changeset
   150
        iContactFields.erase(it);
hgs
parents: 29
diff changeset
   151
        delete temp;
hgs
parents: 29
diff changeset
   152
        }
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
    iLinkIds.Reset();
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    iLinkIds.Close();
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
void CPhonebookParameters::ParseL(CCommandParser* /*parser*/, TParseParams /*aCase = 0*/)
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
	{
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
	}
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
TInt CPhonebookParameters::ScriptLinkId() const
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
    return iLinkId;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
void CPhonebookParameters::SetScriptLinkId(TInt aLinkId)
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
    iLinkId = aLinkId;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
CCreatorPhonebook* CCreatorPhonebook::NewL(CCreatorEngine* aEngine)
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
    CCreatorPhonebook* self = CCreatorPhonebook::NewLC(aEngine);
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
    CleanupStack::Pop(self);
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
    return self;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
CCreatorPhonebook* CCreatorPhonebook::NewLC(CCreatorEngine* aEngine)
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
    CCreatorPhonebook* self = new (ELeave) CCreatorPhonebook();
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
    CleanupStack::PushL(self);
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
    self->ConstructL(aEngine);
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
    return self;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
CCreatorPhonebook::CCreatorPhonebook() 
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
    iAddAllFields = EFalse;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
void CCreatorPhonebook::ConstructL(CCreatorEngine* aEngine)
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
    LOGSTRING("Creator: CCreatorPhonebook::ConstructL");
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
	
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
	iEngine = aEngine;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
	
31
hgs
parents: 29
diff changeset
   201
	iPhonebookWrapper = CCreatorPhonebookWrapper::NewL();
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
	SetDefaultParameters();
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
	
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
CCreatorPhonebook::~CCreatorPhonebook()
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
    LOGSTRING("Creator: CCreatorPhonebook::~CCreatorPhonebook");
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
 
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
    if ( iContactsToDelete.Count() )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
    	{
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
        TRAP_IGNORE( StoreLinksForDeleteL( iContactsToDelete, KUidDictionaryUidContacts ) );
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
        }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
    if ( iContactGroupsToDelete.Count() )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
    	{
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
        TRAP_IGNORE( StoreLinksForDeleteL( iContactGroupsToDelete, KUidDictionaryUidContactGroups ) );
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
        }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
    
31
hgs
parents: 29
diff changeset
   220
	if( iPhonebookWrapper )
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
		{
31
hgs
parents: 29
diff changeset
   222
		delete iPhonebookWrapper;
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
		}
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
    if (iParameters)
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
    	{
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
        delete iParameters;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
    	}
31
hgs
parents: 29
diff changeset
   229
  
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
TInt CCreatorPhonebook::CreateContactEntryL(CCreatorModuleBaseParameters *aParameters)
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
    {
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   236
	TInt err = KErrNone;
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   237
	delete iParameters;
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   238
	    iParameters = 0;
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   239
	CPhonebookParameters* parameters = 0;
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   240
	
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   241
	if( aParameters == 0 )
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   242
	    {
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   243
	    InitializeContactParamsL();
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   244
	    parameters = iParameters;
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   245
	    }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   246
	else
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   247
	    {
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   248
	    parameters = (CPhonebookParameters*) aParameters;
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   249
	    }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   250
	    
31
hgs
parents: 29
diff changeset
   251
	int numberOfFields = parameters->iContactFields.size();
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
	// create a new contact item
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
	
31
hgs
parents: 29
diff changeset
   254
	TUint32 contactId = iPhonebookWrapper->CreateContactEntryL( parameters->iContactFields ); //wrapper should return contact id to store
52
hgs
parents: 51
diff changeset
   255
	iContactsToDelete.AppendL( contactId );
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
	
31
hgs
parents: 29
diff changeset
   257
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   258
	// If this contact has a link id in script (i.e. belongs to a contact-set), we must cache the contact id:
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   259
	    if( parameters->ScriptLinkId() > 0 )
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   260
	        {                
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   261
	        RPointerArray<CCreatorContactSet>& contactsets = ContactLinkCache::Instance()->ContactSets();
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   262
	        TBool setFound(EFalse);
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   263
	        for(TInt i = 0; i < contactsets.Count(); ++i )
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   264
	            {
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   265
	            if( contactsets[i]->LinkId() == parameters->ScriptLinkId() )
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   266
	                {
31
hgs
parents: 29
diff changeset
   267
	                if( contactId )
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   268
	                    {
31
hgs
parents: 29
diff changeset
   269
	                    contactsets[i]->AppendL( contactId );
hgs
parents: 29
diff changeset
   270
	                    iContactLinkArray.AppendL( contactId );
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   271
	                    }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   272
	                setFound = ETrue;
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   273
	                break;
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   274
	                }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   275
	            }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   276
	        if( !setFound )
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   277
	            {
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   278
	            LOGSTRING2("Error: Contact set id %d not found.", parameters->ScriptLinkId());
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   279
	            }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   280
	        }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   281
	    
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
    return err;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
void CCreatorPhonebook::DeleteAllL()
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
    {
31
hgs
parents: 29
diff changeset
   294
	iPhonebookWrapper->DeleteAllL();
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
void CCreatorPhonebook::DeleteAllCreatedByCreatorL()
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
    LOGSTRING("Creator: CCreatorPhonebook::DeleteAllCreatedByCreatorL");
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
    DeleteItemsCreatedWithCreatorL( KUidDictionaryUidContacts );
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
void CCreatorPhonebook::DeleteAllGroupsL()
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
    LOGSTRING("Creator: CCreatorPhonebook::DeleteAllGroupsL");
31
hgs
parents: 29
diff changeset
   308
    iPhonebookWrapper->DeleteAllGroupsL();
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
void CCreatorPhonebook::DeleteAllGroupsCreatedByCreatorL()
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
    LOGSTRING("Creator: CCreatorPhonebook::DeleteAllGroupsCreatedByCreatorL");
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
    DeleteItemsCreatedWithCreatorL( KUidDictionaryUidContactGroups );
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
//----------------------------------------------------------------------------
31
hgs
parents: 29
diff changeset
   319
void CCreatorPhonebook::DeleteContactsL( RArray<TUint32>& aContactsToDelete, TUid aStoreUid	)
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
    {
31
hgs
parents: 29
diff changeset
   321
	iPhonebookWrapper->DeleteContactsL( aContactsToDelete, aStoreUid );
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
//----------------------------------------------------------------------------
31
hgs
parents: 29
diff changeset
   325
hgs
parents: 29
diff changeset
   326
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
void CCreatorPhonebook::DeleteItemsCreatedWithCreatorL( TUid aStoreUid )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
	CDictionaryFileStore* store = iEngine->FileStoreLC();
31
hgs
parents: 29
diff changeset
   330
    User::LeaveIfNull( store );
hgs
parents: 29
diff changeset
   331
    
hgs
parents: 29
diff changeset
   332
    RArray<TUint32> contacts; 
hgs
parents: 29
diff changeset
   333
    // backup previous contact links from store
hgs
parents: 29
diff changeset
   334
    // otherwise they would be overwritten when calling out.WriteL
hgs
parents: 29
diff changeset
   335
    TUint32 creatorLink;
hgs
parents: 29
diff changeset
   336
    if ( store->IsPresentL( aStoreUid ) )
hgs
parents: 29
diff changeset
   337
       {
hgs
parents: 29
diff changeset
   338
       RDictionaryReadStream in;
hgs
parents: 29
diff changeset
   339
       in.OpenLC( *store, aStoreUid );
hgs
parents: 29
diff changeset
   340
       TRAP_IGNORE( 
hgs
parents: 29
diff changeset
   341
           do{ 
hgs
parents: 29
diff changeset
   342
               creatorLink = in.ReadUint32L();
hgs
parents: 29
diff changeset
   343
               contacts.AppendL( creatorLink );
hgs
parents: 29
diff changeset
   344
           }while( creatorLink );
hgs
parents: 29
diff changeset
   345
       );
hgs
parents: 29
diff changeset
   346
       
hgs
parents: 29
diff changeset
   347
       CleanupStack::PopAndDestroy(); // in
hgs
parents: 29
diff changeset
   348
       }
hgs
parents: 29
diff changeset
   349
    
hgs
parents: 29
diff changeset
   350
    
hgs
parents: 29
diff changeset
   351
    iPhonebookWrapper->DeleteContactsL( contacts, aStoreUid );
hgs
parents: 29
diff changeset
   352
    
hgs
parents: 29
diff changeset
   353
    store->Remove( aStoreUid );
hgs
parents: 29
diff changeset
   354
    store->CommitL();
hgs
parents: 29
diff changeset
   355
    
hgs
parents: 29
diff changeset
   356
    CleanupStack::PopAndDestroy( store );
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
//----------------------------------------------------------------------------
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   360
void CCreatorPhonebook::DoDeleteItemsCreatedWithCreatorL( TUid /*aStoreUid*/, CDictionaryFileStore* /*aStore*/ )
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
//----------------------------------------------------------------------------
31
hgs
parents: 29
diff changeset
   366
TBool CCreatorPhonebook::HasOtherThanGroupsL()
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
    LOGSTRING("Creator: CCreatorPhonebook::HasOtherThanGroupsL");
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
    TBool result( EFalse );
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
    return result;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
void CCreatorPhonebook::StoreLinksForDeleteL( RArray<TUint32>& aLinks, TUid aStoreUid )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
    LOGSTRING("Creator: CCreatorPhonebook::StoreLinksForDeleteL");
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
    CDictionaryFileStore* store = iEngine->FileStoreLC();
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
       User::LeaveIfNull( store );
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
       
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
       // backup previous contact links from store
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
       // otherwise they would be overwritten when calling out.WriteL
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
       TUint32 previousLink;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
       if ( store->IsPresentL( aStoreUid ) )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
           {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
           RDictionaryReadStream in;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
           in.OpenLC( *store, aStoreUid );
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
           bool r = false;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
           TRAP_IGNORE( 
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
               do{ //iContactMngr->CreateLinksLC( in )) != NULL ) // will leave with KErrEof
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
                   previousLink = in.ReadUint32L();
52
hgs
parents: 51
diff changeset
   395
                   iPreviousDeleteLinks.AppendL( previousLink );
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
                   if(previousLink)
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
                	   {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
					   r=true;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
                	   }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
                   else
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
                	   {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
					   r=false;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
                	   }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
               }while(r==true); );
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
           
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
           CleanupStack::PopAndDestroy(); // in
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
           }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
       RDictionaryWriteStream out;       
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
       out.AssignLC( *store, aStoreUid );
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
       
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
       // restore previous links
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
       for ( TInt i = 0; i < iPreviousDeleteLinks.Count(); i++ )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
           {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
           out.WriteUint32L( iPreviousDeleteLinks[i] );
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
           }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
       
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
       // write new links
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
       for(int i=0; i < aLinks.Count(); i++)
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
    	   {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
		   out.WriteUint32L( aLinks[i] );
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
    	   }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
       out.CommitL();
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
       CleanupStack::PopAndDestroy(); // out
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
       
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
       store->CommitL();
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
       CleanupStack::PopAndDestroy( store );
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
31
hgs
parents: 29
diff changeset
   434
void CCreatorPhonebook::InitializeContactParamsL()
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
    LOGSTRING("Creator: CCreatorPhonebook::InitializeContactParamsL");        
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
 
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
    iParameters = new (ELeave) CPhonebookParameters;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
           
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
    iParameters->iNumberOfPhoneNumberFields = iNumberOfPhoneNumberFields;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
    iParameters->iNumberOfURLFields = iNumberOfURLFields;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
    iParameters->iNumberOfEmailAddressFields = iNumberOfEmailAddressFields;       
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
    TPtrC fname = iEngine->RandomString(CCreatorEngine::EFirstName);
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
    TPtrC lname = iEngine->RandomString(CCreatorEngine::ESurname);
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
    if( iAddAllFields )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
        {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
		TInt textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo);
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
		for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex )
31
hgs
parents: 29
diff changeset
   452
			{ 
hgs
parents: 29
diff changeset
   453
			CCreatorContactField* field = CCreatorContactField::NewL();
hgs
parents: 29
diff changeset
   454
			CleanupStack::PushL(field);
hgs
parents: 29
diff changeset
   455
	        field->AddFieldToParamL( iEngine,iParameters, CreatorPbkMiscTextFields[tfIndex].iFieldCode, CreatorPbkMiscTextFields[tfIndex].iRandomType );
hgs
parents: 29
diff changeset
   456
  	        CleanupStack::Pop(field);
hgs
parents: 29
diff changeset
   457
            }
hgs
parents: 29
diff changeset
   458
		
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
		// Add binary fields:
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
		
31
hgs
parents: 29
diff changeset
   461
		RFs& fs = CCoeEnv::Static()->FsSession();
hgs
parents: 29
diff changeset
   462
		      
hgs
parents: 29
diff changeset
   463
        TBuf<KMaxFileName> srcPath;
hgs
parents: 29
diff changeset
   464
		iEngine->RandomPictureFileL(srcPath);
hgs
parents: 29
diff changeset
   465
		TBuf<KMaxFileName> destPath(KTempPath);
hgs
parents: 29
diff changeset
   466
		                            
hgs
parents: 29
diff changeset
   467
		if(!BaflUtils::FolderExists( fs, destPath ))
hgs
parents: 29
diff changeset
   468
			{
hgs
parents: 29
diff changeset
   469
		    BaflUtils::EnsurePathExistsL( fs, destPath );
hgs
parents: 29
diff changeset
   470
		    }
hgs
parents: 29
diff changeset
   471
		                
hgs
parents: 29
diff changeset
   472
		TInt err=BaflUtils::CopyFile( fs, srcPath, destPath );
hgs
parents: 29
diff changeset
   473
hgs
parents: 29
diff changeset
   474
		TParse temp;
hgs
parents: 29
diff changeset
   475
		temp.Set( srcPath,NULL,NULL );
hgs
parents: 29
diff changeset
   476
		destPath.Append(temp.NameAndExt());
hgs
parents: 29
diff changeset
   477
		TPtrC picture;
hgs
parents: 29
diff changeset
   478
		picture.Set(destPath);
hgs
parents: 29
diff changeset
   479
		CCreatorContactField* picturefield = CCreatorContactField::NewL();
hgs
parents: 29
diff changeset
   480
		CleanupStack::PushL(picturefield);
hgs
parents: 29
diff changeset
   481
		picturefield->AddFieldToParamL( iParameters, CCreatorPhonebookWrapper::EThumbnailPic, picture );
hgs
parents: 29
diff changeset
   482
		CleanupStack::Pop(picturefield);
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
		// Add date-time fields:
31
hgs
parents: 29
diff changeset
   484
		TPtrC anniv;
hgs
parents: 29
diff changeset
   485
		TBuf<20> timeString;
hgs
parents: 29
diff changeset
   486
		TTime datetime = iEngine->RandomDate( CCreatorEngine::EDateFuture );
hgs
parents: 29
diff changeset
   487
		_LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3");
hgs
parents: 29
diff changeset
   488
		TRAP_IGNORE( datetime.FormatL(timeString, KDateString) );
hgs
parents: 29
diff changeset
   489
		
hgs
parents: 29
diff changeset
   490
		anniv.Set(timeString);
hgs
parents: 29
diff changeset
   491
 
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   492
		CCreatorContactField* fieldAnniv = CCreatorContactField::NewL();
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   493
		CleanupStack::PushL( fieldAnniv );
31
hgs
parents: 29
diff changeset
   494
		fieldAnniv->AddFieldToParamL(iParameters,CCreatorPhonebookWrapper::EAnniversary, anniv );
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   495
		CleanupStack::Pop( fieldAnniv );
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
    //***************************************************************************
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
        }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
    else
31
hgs
parents: 29
diff changeset
   500
        {
hgs
parents: 29
diff changeset
   501
		CCreatorContactField* field = CCreatorContactField::NewL();
hgs
parents: 29
diff changeset
   502
    	CleanupStack::PushL(field);
hgs
parents: 29
diff changeset
   503
    	field->AddFieldToParamL( iParameters, CCreatorPhonebookWrapper::EFirstName, fname );
hgs
parents: 29
diff changeset
   504
		field->AddFieldToParamL( iParameters, CCreatorPhonebookWrapper::ELastName, lname );
hgs
parents: 29
diff changeset
   505
		CleanupStack::Pop(field);
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
        }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
                        
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
      // Phone numbers:
31
hgs
parents: 29
diff changeset
   509
    TInt phoneFieldCount = sizeof(CreatorPbkPhoneNumberFields) / sizeof(TInt);
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
    TInt inc=0;
31
hgs
parents: 29
diff changeset
   512
    for( TInt i=0; i<iNumberOfPhoneNumberFields; i++ )
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
    	{
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
		if(inc >= phoneFieldCount )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
        	{
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
    		inc = 0;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
        	}
31
hgs
parents: 29
diff changeset
   519
		
hgs
parents: 29
diff changeset
   520
		CCreatorContactField* field = CCreatorContactField::NewL();
hgs
parents: 29
diff changeset
   521
        CleanupStack::PushL(field);
hgs
parents: 29
diff changeset
   522
		field->AddFieldToParamL(iEngine, iParameters, CreatorPbkPhoneNumberFields[inc] );
hgs
parents: 29
diff changeset
   523
		CleanupStack::Pop(field);
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
		inc++;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
    	}
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
    // URLs:
31
hgs
parents: 29
diff changeset
   531
    TInt urlFieldCount = sizeof(CreatorPbkUrlFields) / sizeof(TInt);
hgs
parents: 29
diff changeset
   532
    inc = 0;
hgs
parents: 29
diff changeset
   533
    for( TInt i=0; i<iNumberOfURLFields; i++ )
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   534
        {
31
hgs
parents: 29
diff changeset
   535
    
hgs
parents: 29
diff changeset
   536
		if(inc >= urlFieldCount )
hgs
parents: 29
diff changeset
   537
          	{
hgs
parents: 29
diff changeset
   538
        	inc = 0;
hgs
parents: 29
diff changeset
   539
           	}
hgs
parents: 29
diff changeset
   540
    
hgs
parents: 29
diff changeset
   541
		CCreatorContactField* field = CCreatorContactField::NewL();
hgs
parents: 29
diff changeset
   542
        CleanupStack::PushL(field);
hgs
parents: 29
diff changeset
   543
    	field->AddFieldToParamL(iEngine, iParameters, CreatorPbkUrlFields[inc] );
hgs
parents: 29
diff changeset
   544
    	CleanupStack::Pop(field);
hgs
parents: 29
diff changeset
   545
    	inc++;
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   546
        }
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
    // EMail addresses:
31
hgs
parents: 29
diff changeset
   549
    TInt emailFieldCount = sizeof(CreatorPbkEmailFields) / sizeof(TInt);
hgs
parents: 29
diff changeset
   550
    inc = 0;
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
    for( int i=0; i<iNumberOfEmailAddressFields; i++ )
31
hgs
parents: 29
diff changeset
   552
    	{
hgs
parents: 29
diff changeset
   553
		if(inc >= emailFieldCount )
hgs
parents: 29
diff changeset
   554
           	{
hgs
parents: 29
diff changeset
   555
          	inc = 0;
hgs
parents: 29
diff changeset
   556
           	}
hgs
parents: 29
diff changeset
   557
        CCreatorContactField* field = CCreatorContactField::NewL();
hgs
parents: 29
diff changeset
   558
        CleanupStack::PushL(field);
hgs
parents: 29
diff changeset
   559
        field->AddFieldToParamL(iEngine, iParameters, CreatorPbkEmailFields[inc] );
hgs
parents: 29
diff changeset
   560
        CleanupStack::Pop(field);
hgs
parents: 29
diff changeset
   561
        inc++;
hgs
parents: 29
diff changeset
   562
    	}
hgs
parents: 29
diff changeset
   563
    
hgs
parents: 29
diff changeset
   564
    TestPrintOut(iParameters);
hgs
parents: 29
diff changeset
   565
    
hgs
parents: 29
diff changeset
   566
   }
hgs
parents: 29
diff changeset
   567
hgs
parents: 29
diff changeset
   568
void CCreatorPhonebook::TestPrintOut(CPhonebookParameters* aParam)
hgs
parents: 29
diff changeset
   569
	{
hgs
parents: 29
diff changeset
   570
	LOGSTRING("Creator: CCreatorPhonebook::TestPrintOut");
hgs
parents: 29
diff changeset
   571
	for( TCreatorContactFields::iterator it = aParam->iContactFields.begin(); it != aParam->iContactFields.end(); ++it)
hgs
parents: 29
diff changeset
   572
        {
hgs
parents: 29
diff changeset
   573
        HBufC* temp = (*it).second;
hgs
parents: 29
diff changeset
   574
        if(temp)
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
        	{
31
hgs
parents: 29
diff changeset
   576
			LOGSTRING3("Type: %d Content:%S ", (*it).first, &temp->Des() );
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
        	}
31
hgs
parents: 29
diff changeset
   578
        }
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
// Checks if the link is a group or not
51
hgs
parents: 31
diff changeset
   582
TBool CCreatorPhonebook::IsContactGroupL( TUint32& /*aLink*/ )
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
	{
31
hgs
parents: 29
diff changeset
   584
	//not used right now
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
	return EFalse;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
	}
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
31
hgs
parents: 29
diff changeset
   588
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
TInt CCreatorPhonebook::CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters)
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
    {
31
hgs
parents: 29
diff changeset
   591
	 LOGSTRING("Creator: CCreatorPhonebook::CreateGroupEntryL");
hgs
parents: 29
diff changeset
   592
	 TInt err = KErrNone;
hgs
parents: 29
diff changeset
   593
	 
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
	    delete iParameters;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   595
	    iParameters = 0;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
	    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
	    CPhonebookParameters* parameters = (CPhonebookParameters*) aParameters;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
	    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
	    if( !parameters )
31
hgs
parents: 29
diff changeset
   600
	       {
hgs
parents: 29
diff changeset
   601
	       iParameters = new (ELeave) CPhonebookParameters;
hgs
parents: 29
diff changeset
   602
	       iParameters->iContactsInGroup = iContactsInGroup;
hgs
parents: 29
diff changeset
   603
	       iParameters->iGroupName->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) );
hgs
parents: 29
diff changeset
   604
	       iParameters->iGroupName->Des().Append( _L(" #") );
hgs
parents: 29
diff changeset
   605
	       iParameters->iGroupName->Des().AppendNum( iEngine->RandomNumber(1000, 9999) );
hgs
parents: 29
diff changeset
   606
	       parameters = iParameters;
hgs
parents: 29
diff changeset
   607
	       }
hgs
parents: 29
diff changeset
   608
	   
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
	    // create a new contact group
31
hgs
parents: 29
diff changeset
   610
	    
hgs
parents: 29
diff changeset
   611
	    TUint32 newGroupId = iPhonebookWrapper->CreateGroupEntryL( parameters->iGroupName );
hgs
parents: 29
diff changeset
   612
	    
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
	    // define amounts of contacts to be added to the group
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
	    TInt amountOfContactsToBeAdded = 0;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
	    if (parameters->iContactsInGroup == KCreateRandomAmountOfGroups)
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
	    	{
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
	        amountOfContactsToBeAdded = iEngine->RandomNumber(30);
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
	    	}
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
	    else 
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
	    	{
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
	        amountOfContactsToBeAdded = parameters->iContactsInGroup;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
	    	}
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   623
	    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
	    if( parameters->iLinkIds.Count() > 0 )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   625
	        {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   626
	        for( TInt i = 0; i < parameters->iLinkIds.Count(); ++i )
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   627
	            {
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
	            const CCreatorContactSet& set = ContactLinkCache::Instance()->ContactSet(parameters->iLinkIds[i].iLinkId);
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
	          
31
hgs
parents: 29
diff changeset
   630
	            const RArray<TUint32> links = set.ContactLinks();//ContactLinkCache::Instance()->ContactSets();//set.ContactLinks();
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
	            TInt numberOfExplicitLinks = links.Count(); // Number of defined contacts in contact-set
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
	            TInt numberOfExistingContacts = set.NumberOfExistingContacts(); // Number of existing contacts in contact-set
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
	            TInt maxAmount = numberOfExplicitLinks + numberOfExistingContacts;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
	            
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
	            if( parameters->iLinkIds[i].iLinkAmount > 0 )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
	                maxAmount = parameters->iLinkIds[i].iLinkAmount; // Max amount is limited
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
	            
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
	            TInt addedMembers = 0;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   639
	            
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
	            for( TInt j = 0; j < links.Count() && addedMembers < maxAmount; ++j )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
	                {
31
hgs
parents: 29
diff changeset
   642
					
hgs
parents: 29
diff changeset
   643
					addedMembers += iPhonebookWrapper->AddContactToGroup(newGroupId,links[j]);
hgs
parents: 29
diff changeset
   644
	           
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   645
	                }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   646
	            if( addedMembers < maxAmount )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   647
	            	{
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   648
	            	// Add existing contacts, withing the limits set by maxAmount:
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   649
	            	amountOfContactsToBeAdded += maxAmount - addedMembers;
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   650
	            	}
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   651
	            }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   652
	        }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   653
	    if( amountOfContactsToBeAdded > 0 )
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   654
	        {
31
hgs
parents: 29
diff changeset
   655
			TInt addedContacts = iPhonebookWrapper->AddToGroup(newGroupId, amountOfContactsToBeAdded);
hgs
parents: 29
diff changeset
   656
		
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   657
	        }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   658
	    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
	    // store the link to contact, so that Creator is able to delete
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   660
	    // it when user requests deletion of contacts that were created with Creator 
52
hgs
parents: 51
diff changeset
   661
	    iContactGroupsToDelete.AppendL( newGroupId );
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
	    
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
	    return err;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
TInt CCreatorPhonebook::CreateSubscribedContactEntryL(CCreatorModuleBaseParameters* /*aParameters*/)
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
    {
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   670
    LOGSTRING("Creator: CCreatorPhonebook::CreateSubscribedContactEntryL");
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
    return KErrNotSupported;
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
    }
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   677
CCreatorContactField::CCreatorContactField()
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   678
    {
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   679
    }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   680
CCreatorContactField::~CCreatorContactField()
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   681
    {
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   682
    }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   683
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   684
CCreatorContactField* CCreatorContactField::NewL()
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   685
    {
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   686
    CCreatorContactField* self = new (ELeave) CCreatorContactField();
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   687
    CleanupStack::PushL(self);
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   688
    self->ConstructL();
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   689
    CleanupStack::Pop();
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   690
    return self;
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   691
    }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   692
void CCreatorContactField::ConstructL()
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   693
    {
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   694
    }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   695
31
hgs
parents: 29
diff changeset
   696
hgs
parents: 29
diff changeset
   697
void CCreatorContactField::AddFieldToParamL( CCreatorEngine* aEngine, CPhonebookParameters* aParam, TInt aType, TInt aRand )
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   698
    {
31
hgs
parents: 29
diff changeset
   699
    HBufC* content = NULL;
hgs
parents: 29
diff changeset
   700
    if( aRand == KErrNotFound ) 
hgs
parents: 29
diff changeset
   701
        {
hgs
parents: 29
diff changeset
   702
        TInt textFieldCount = sizeof(CreatorPbkPhoneNumberFields)/sizeof(TInt);;
hgs
parents: 29
diff changeset
   703
        for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex )
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   704
            {
31
hgs
parents: 29
diff changeset
   705
            if( CreatorPbkPhoneNumberFields[tfIndex] == aType )
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   706
                {
31
hgs
parents: 29
diff changeset
   707
                content = aEngine->RandomString(CCreatorEngine::EPhoneNumber).AllocL();
hgs
parents: 29
diff changeset
   708
                break;
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   709
                }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   710
            }
31
hgs
parents: 29
diff changeset
   711
    
hgs
parents: 29
diff changeset
   712
        textFieldCount = sizeof(CreatorPbkUrlFields)/sizeof(TInt);;
hgs
parents: 29
diff changeset
   713
        for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex )
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   714
            {
31
hgs
parents: 29
diff changeset
   715
            if( CreatorPbkUrlFields[tfIndex] == aType )
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   716
                {
31
hgs
parents: 29
diff changeset
   717
                content = aEngine->CreateHTTPUrlLC(); 
hgs
parents: 29
diff changeset
   718
                CleanupStack::Pop();
hgs
parents: 29
diff changeset
   719
                break;
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   720
                }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   721
            }
31
hgs
parents: 29
diff changeset
   722
        textFieldCount = sizeof(CreatorPbkEmailFields)/sizeof(TInt);;
hgs
parents: 29
diff changeset
   723
        for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex )
hgs
parents: 29
diff changeset
   724
            {
hgs
parents: 29
diff changeset
   725
            if( CreatorPbkEmailFields[tfIndex] == aType )
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   726
                {
31
hgs
parents: 29
diff changeset
   727
                content = aEngine->CreateEmailAddressLC();
hgs
parents: 29
diff changeset
   728
                CleanupStack::Pop();
hgs
parents: 29
diff changeset
   729
                break;
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   730
                }
31
hgs
parents: 29
diff changeset
   731
            }
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   732
        
31
hgs
parents: 29
diff changeset
   733
    
hgs
parents: 29
diff changeset
   734
        //if there is textfield without specified random number
hgs
parents: 29
diff changeset
   735
        textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo);
hgs
parents: 29
diff changeset
   736
        for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex )
hgs
parents: 29
diff changeset
   737
            {
hgs
parents: 29
diff changeset
   738
			if( CreatorPbkMiscTextFields[tfIndex].iFieldCode == aType && CreatorPbkMiscTextFields[tfIndex].iRandomType != RND_TYPE_UNDEF )
hgs
parents: 29
diff changeset
   739
            	{
hgs
parents: 29
diff changeset
   740
				TInt rand =  CreatorPbkMiscTextFields[tfIndex].iRandomType;
hgs
parents: 29
diff changeset
   741
				content = aEngine->RandomString((CCreatorEngine::TRandomStringType) rand).AllocL();
hgs
parents: 29
diff changeset
   742
				break;
hgs
parents: 29
diff changeset
   743
				}
hgs
parents: 29
diff changeset
   744
			}	
hgs
parents: 29
diff changeset
   745
        }
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   746
31
hgs
parents: 29
diff changeset
   747
    if( aRand != KErrNotFound && aRand != RND_TYPE_UNDEF ) 
hgs
parents: 29
diff changeset
   748
        {
hgs
parents: 29
diff changeset
   749
        TInt textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo);
hgs
parents: 29
diff changeset
   750
        for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex )
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   751
            {
31
hgs
parents: 29
diff changeset
   752
            if( CreatorPbkMiscTextFields[tfIndex].iFieldCode == aType )
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   753
                {
31
hgs
parents: 29
diff changeset
   754
                content = aEngine->RandomString((CCreatorEngine::TRandomStringType) aRand).AllocL();
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   755
                }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   756
            }
31
hgs
parents: 29
diff changeset
   757
        }
hgs
parents: 29
diff changeset
   758
	
hgs
parents: 29
diff changeset
   759
	aParam->iContactFields.insert( TCreatorContactField(aType, content) );
hgs
parents: 29
diff changeset
   760
	}
hgs
parents: 29
diff changeset
   761
hgs
parents: 29
diff changeset
   762
void CCreatorContactField::AddFieldToParamL( CPhonebookParameters* aParam, TInt aType, TPtrC aContent )
hgs
parents: 29
diff changeset
   763
    {
hgs
parents: 29
diff changeset
   764
    aParam->iContactFields.insert( TCreatorContactField(aType, aContent.AllocL()) );
27
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   765
    }
271e901a9423 201019_1
hgs
parents: 17
diff changeset
   766
17
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   767
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   768
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
//----------------------------------------------------------------------------
4f2773374eff Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770