|
1 /* |
|
2 * Copyright (c) 2002 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 * Provides methods for Phonebook Multiple Entry Fetch API. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPbkMultipleEntryFetchDlg.h" // This class |
|
22 #include <PbkView.rsg> |
|
23 #include "CPbkFetchDlg.h" |
|
24 #include "MPbkFetchDlgSelection.h" |
|
25 #include <CPbkContactEngine.h> |
|
26 |
|
27 // LOCAL CONSTANTS AND MACROS |
|
28 enum TPanicCode |
|
29 { |
|
30 EPanicPostCond_Constructor = 1, |
|
31 EPanicPreCond_ConstructL, |
|
32 EPanicPreCond_ExecuteLD |
|
33 }; |
|
34 |
|
35 // ================= MEMBER FUNCTIONS ======================= |
|
36 |
|
37 EXPORT_C CPbkMultipleEntryFetchDlg::TParams::TParams() : |
|
38 iContactView(NULL), |
|
39 iMarkedEntries(NULL), |
|
40 iCbaId(0), |
|
41 iFetchSelection(NULL) |
|
42 { |
|
43 } |
|
44 |
|
45 EXPORT_C CPbkMultipleEntryFetchDlg::TParams::operator TCleanupItem() |
|
46 { |
|
47 return TCleanupItem(Cleanup,this); |
|
48 } |
|
49 |
|
50 void CPbkMultipleEntryFetchDlg::TParams::Cleanup(TAny* aPtr) |
|
51 { |
|
52 TParams* self = static_cast<TParams*>(aPtr); |
|
53 delete self->iMarkedEntries; |
|
54 self->iMarkedEntries = NULL; |
|
55 } |
|
56 |
|
57 inline CPbkMultipleEntryFetchDlg::CPbkMultipleEntryFetchDlg |
|
58 (TParams& aParams, CPbkContactEngine& aEngine) : |
|
59 iParams(aParams), iPbkEngine(aEngine) |
|
60 { |
|
61 // PostCond |
|
62 __ASSERT_DEBUG(!iFetchDlg && iParams.iContactView, |
|
63 Panic(EPanicPostCond_Constructor)); |
|
64 } |
|
65 |
|
66 inline void CPbkMultipleEntryFetchDlg::ConstructL() |
|
67 { |
|
68 // PreCond |
|
69 __ASSERT_DEBUG(!iFetchDlg && iParams.iContactView, |
|
70 Panic(EPanicPreCond_ConstructL)); |
|
71 } |
|
72 |
|
73 EXPORT_C CPbkMultipleEntryFetchDlg* CPbkMultipleEntryFetchDlg::NewL |
|
74 (TParams& aParams, |
|
75 CPbkContactEngine& aEngine) |
|
76 { |
|
77 CPbkMultipleEntryFetchDlg* self = new(ELeave) CPbkMultipleEntryFetchDlg(aParams, aEngine); |
|
78 CleanupStack::PushL(self); |
|
79 self->ConstructL(); |
|
80 CleanupStack::Pop(self); |
|
81 return self; |
|
82 } |
|
83 |
|
84 EXPORT_C void CPbkMultipleEntryFetchDlg::SetMopParent(MObjectProvider* aParent) |
|
85 { |
|
86 iObjectProvider = aParent; |
|
87 } |
|
88 |
|
89 EXPORT_C TInt CPbkMultipleEntryFetchDlg::ExecuteLD() |
|
90 { |
|
91 // PreCond |
|
92 __ASSERT_DEBUG(iParams.iContactView && !iFetchDlg, |
|
93 Panic(EPanicPreCond_ExecuteLD)); |
|
94 |
|
95 // "D" function semantics |
|
96 CleanupStack::PushL(this); |
|
97 TBool thisDestroyed = EFalse; |
|
98 iDestroyedPtr = &thisDestroyed; |
|
99 |
|
100 // Convert iParams for CPbkFetchEntryDlg |
|
101 CPbkFetchDlg::TParams params; |
|
102 params.iResId = R_PBK_MULTIPLE_ENTRY_FETCH_DLG; |
|
103 params.iFlags = CPbkFetchDlg::FETCH_MARKED; |
|
104 params.iContactView = iParams.iContactView; |
|
105 params.iFetchSelection = iParams.iFetchSelection; |
|
106 params.iCbaId = iParams.iCbaId; |
|
107 |
|
108 // Run CPbkFetchEntryDlg dialog |
|
109 iFetchDlg = CPbkFetchDlg::NewL(params, iPbkEngine); |
|
110 iFetchDlg->ResetWhenDestroyed(&iFetchDlg); |
|
111 iFetchDlg->SetMopParent(iObjectProvider); |
|
112 TInt result = iFetchDlg->ExecuteLD(); |
|
113 |
|
114 if (thisDestroyed) |
|
115 { |
|
116 // this object is destroyed |
|
117 result = 0; |
|
118 CleanupStack::Pop(this); |
|
119 } |
|
120 else |
|
121 { |
|
122 // Convert params back to our format |
|
123 if (result) |
|
124 { |
|
125 iParams.iMarkedEntries = params.iMarkedEntries; |
|
126 params.iMarkedEntries = NULL; |
|
127 } |
|
128 CleanupStack::PopAndDestroy(this); |
|
129 } |
|
130 |
|
131 return result; |
|
132 } |
|
133 |
|
134 CPbkMultipleEntryFetchDlg::~CPbkMultipleEntryFetchDlg() |
|
135 { |
|
136 if (iDestroyedPtr) |
|
137 { |
|
138 *iDestroyedPtr = ETrue; |
|
139 } |
|
140 // Close the dialog |
|
141 delete iFetchDlg; |
|
142 } |
|
143 |
|
144 void CPbkMultipleEntryFetchDlg::Panic(TInt aReason) |
|
145 { |
|
146 _LIT(KPanicText, "CPbkMultipleEntryFetchDlg"); |
|
147 User::Panic(KPanicText, aReason); |
|
148 } |
|
149 |
|
150 // End of File |