|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "engine.h" |
|
19 #include "enginewrapper.h" |
|
20 #include "creator_phonebookbase.h" |
|
21 #include "creator_traces.h" |
|
22 |
|
23 void CCreatorPhonebookBase::QueryDialogClosedL(TBool aPositiveAction, TInt aUserData) |
|
24 { |
|
25 LOGSTRING("Creator: CCreatorPhonebookBase::QueryDialogClosedL"); |
|
26 |
|
27 if(aPositiveAction == EFalse && aUserData!=ECreatorPhonebookGetContactFields ) |
|
28 { |
|
29 iEngine->ShutDownEnginesL(); |
|
30 return; |
|
31 } |
|
32 |
|
33 const TDesC* showText = &KSavingText; |
|
34 TBool finished(EFalse); |
|
35 TBool retval(ETrue); |
|
36 switch(aUserData) |
|
37 { |
|
38 case ECreatorPhonebookDelete: |
|
39 showText = &KDeletingText; |
|
40 finished = ETrue; |
|
41 iEntriesToBeCreated = 1; |
|
42 break; |
|
43 case ECreatorPhonebookStart: |
|
44 if(iCommand == ECmdCreatePhoneBookEntryContacts ) |
|
45 { |
|
46 retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Fields in contact"), R_CONTACT_CREATION_TYPE_QUERY, |
|
47 &iDummy, this, ECreatorPhonebookGetContactFields ); |
|
48 } |
|
49 else |
|
50 { |
|
51 retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Number of contacts "), R_GROUP_CREATION_TYPE_QUERY, |
|
52 &iDummy, this, ECreatorPhonebookGetGroupFields ); |
|
53 } |
|
54 break; |
|
55 case ECreatorPhonebookGetContactFields: |
|
56 if(iDummy==0)// first item, use default fields |
|
57 |
|
58 { |
|
59 iDefaultFieldsSelected = ETrue; |
|
60 finished = ETrue; |
|
61 } |
|
62 else |
|
63 { |
|
64 retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberOfPhoneNumberFields, _L("Amount of phone number fields in one contact?"), |
|
65 ETrue, this, ECreatorPhonebookGetPhoneNumbersCount |
|
66 ); |
|
67 } |
|
68 break; |
|
69 case ECreatorPhonebookGetPhoneNumbersCount: |
|
70 retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberOfURLFields, _L("Amount of URL fields in one contact?"), |
|
71 ETrue, this, ECreatorPhonebookGetUrlsCount |
|
72 ); |
|
73 break; |
|
74 case ECreatorPhonebookGetUrlsCount: |
|
75 retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iNumberOfEmailAddressFields, _L("Amount of email fields in one contact?"), |
|
76 ETrue, this, ECreatorPhonebookGetEmailsCount |
|
77 ); |
|
78 break; |
|
79 case ECreatorPhonebookGetEmailsCount: |
|
80 retval = iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Add all the other fields to contacts?"), this, ECreatorPhonebookContactsAllFields); |
|
81 break; |
|
82 case ECreatorPhonebookContactsAllFields: |
|
83 iAddAllFields = aPositiveAction; |
|
84 // finaly we have all informations from user, start engine |
|
85 finished = ETrue; |
|
86 break; |
|
87 case ECreatorPhonebookGetGroupFields: |
|
88 iContactsInGroup = KCreateRandomAmountOfGroups; |
|
89 if(iDummy==0)// first item, use default fields |
|
90 { |
|
91 finished = ETrue; |
|
92 } |
|
93 else |
|
94 { |
|
95 retval = iEngine->GetEngineWrapper()->EntriesQueryDialog(&iContactsInGroup, _L("Amount of contacts in one group?"), |
|
96 ETrue, this, ECreatorPhonebookGetContactsInGroup); |
|
97 } |
|
98 break; |
|
99 case ECreatorPhonebookGetContactsInGroup: |
|
100 // finaly we have all informations from user, start engine |
|
101 finished = ETrue; |
|
102 break; |
|
103 default: |
|
104 //some error |
|
105 retval = EFalse; |
|
106 break; |
|
107 } |
|
108 if( retval == EFalse ) |
|
109 { |
|
110 iEngine->ShutDownEnginesL(); |
|
111 } |
|
112 else if( finished ) |
|
113 { |
|
114 // add this command to command array |
|
115 iEngine->AppendToCommandArrayL(iCommand, NULL, iEntriesToBeCreated); |
|
116 // started exucuting commands |
|
117 iEngine->ExecuteFirstCommandL( *showText ); |
|
118 } |
|
119 } |
|
120 |
|
121 TBool CCreatorPhonebookBase::AskDataFromUserL(TInt aCommand) |
|
122 { |
|
123 LOGSTRING("Creator: CCreatorPhonebookBase::AskDataFromUserL"); |
|
124 iCommand = aCommand; |
|
125 |
|
126 if( aCommand == ECmdDeleteContacts ) |
|
127 { |
|
128 return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all contacts?"), this, ECreatorPhonebookDelete ); |
|
129 } |
|
130 if( aCommand == ECmdDeleteCreatorContacts ) |
|
131 { |
|
132 return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all contacts created with Creator?"), this, ECreatorPhonebookDelete ); |
|
133 } |
|
134 if( aCommand == ECmdDeleteContactGroups ) |
|
135 { |
|
136 return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all contact groups?"), this, ECreatorPhonebookDelete ); |
|
137 } |
|
138 if( aCommand == ECmdDeleteCreatorContactGroups ) |
|
139 { |
|
140 return iEngine->GetEngineWrapper()->YesNoQueryDialog(_L("Delete all contact groups created with Creator?"), this, ECreatorPhonebookDelete ); |
|
141 } |
|
142 // display queries |
|
143 return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorPhonebookStart); // ask number of entries to create |
|
144 } |
|
145 |
|
146 |
|
147 void CCreatorPhonebookBase::SetDefaultParameters() |
|
148 { |
|
149 iNumberOfPhoneNumberFields = 1; |
|
150 iNumberOfURLFields = 0; |
|
151 iNumberOfEmailAddressFields = 0; |
|
152 iContactsInGroup = 50; |
|
153 iDefaultFieldsSelected = EFalse; |
|
154 } |