|
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 Group members Fetch API. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPbkGroupMembersFetchDlg.h" // This class |
|
22 #include <cntview.h> |
|
23 |
|
24 // PbkView APIs |
|
25 #include <PbkView.rsg> |
|
26 #include "CPbkFetchDlg.h" |
|
27 #include "MPbkFetchCallbacks.h" |
|
28 |
|
29 // PbkEng APIs |
|
30 #include <CPbkContactEngine.h> |
|
31 |
|
32 |
|
33 /// Unnamed namespace for local definitions |
|
34 namespace { |
|
35 |
|
36 // LOCAL CONSTANTS AND MACROS |
|
37 |
|
38 #ifdef _DEBUG |
|
39 enum TPanicCode |
|
40 { |
|
41 EPanicPostCond_Constructor = 1, |
|
42 EPanicPreCond_ConstructL, |
|
43 EPanicPreCond_ExecuteLD, |
|
44 }; |
|
45 #endif |
|
46 |
|
47 |
|
48 // ==================== LOCAL FUNCTIONS ==================== |
|
49 |
|
50 #ifdef _DEBUG |
|
51 void Panic(TPanicCode aReason) |
|
52 { |
|
53 _LIT(KPanicText, "CPbkGroupMembersFetchDlg"); |
|
54 User::Panic(KPanicText, aReason); |
|
55 } |
|
56 #endif |
|
57 |
|
58 } // namespace |
|
59 |
|
60 |
|
61 // ================= MEMBER FUNCTIONS ======================= |
|
62 |
|
63 // CPbkGroupMembersFetchDlg::TParams |
|
64 EXPORT_C CPbkGroupMembersFetchDlg::TParams::TParams() : |
|
65 iGroupId(KNullContactId), |
|
66 iMarkedEntries(NULL) |
|
67 { |
|
68 } |
|
69 |
|
70 EXPORT_C CPbkGroupMembersFetchDlg::TParams::operator TCleanupItem() |
|
71 { |
|
72 return TCleanupItem(Cleanup,this); |
|
73 } |
|
74 |
|
75 void CPbkGroupMembersFetchDlg::TParams::Cleanup(TAny* aPtr) |
|
76 { |
|
77 TParams* self = static_cast<TParams*>(aPtr); |
|
78 delete self->iMarkedEntries; |
|
79 self->iMarkedEntries = NULL; |
|
80 } |
|
81 |
|
82 |
|
83 // CPbkGroupMembersFetchDlg |
|
84 inline CPbkGroupMembersFetchDlg::CPbkGroupMembersFetchDlg |
|
85 (TParams& aParams, CPbkContactEngine& aPbkEngine) : |
|
86 iParams(aParams), iPbkEngine(aPbkEngine) |
|
87 { |
|
88 // PostCond |
|
89 __ASSERT_DEBUG(!iFetchDlg && !iDestroyedPtr, |
|
90 Panic(EPanicPostCond_Constructor)); |
|
91 } |
|
92 |
|
93 inline void CPbkGroupMembersFetchDlg::ConstructL() |
|
94 { |
|
95 // PreCond |
|
96 __ASSERT_DEBUG |
|
97 (!iFetchDlg && iParams.iGroupId != KNullContactId && !iGroupNonMembersSubView, |
|
98 Panic(EPanicPreCond_ConstructL)); |
|
99 |
|
100 iGroupNonMembersSubView = CContactGroupView::NewL |
|
101 (iPbkEngine.Database(), iPbkEngine.AllContactsView(), *this, |
|
102 iParams.iGroupId, CContactGroupView::EShowContactsNotInGroup); |
|
103 |
|
104 iGroupNonMembersSubView->SetViewFindConfigPlugin |
|
105 (iPbkEngine.AllContactsView().GetViewFindConfigPlugin()); |
|
106 } |
|
107 |
|
108 EXPORT_C CPbkGroupMembersFetchDlg* CPbkGroupMembersFetchDlg::NewL(TParams& aParams, CPbkContactEngine& aPbkEngine) |
|
109 { |
|
110 CPbkGroupMembersFetchDlg* self = new(ELeave) CPbkGroupMembersFetchDlg(aParams, aPbkEngine); |
|
111 CleanupStack::PushL(self); |
|
112 self->ConstructL(); |
|
113 CleanupStack::Pop(self); |
|
114 return self; |
|
115 } |
|
116 |
|
117 EXPORT_C TInt CPbkGroupMembersFetchDlg::ExecuteLD() |
|
118 { |
|
119 // PreCond |
|
120 __ASSERT_DEBUG(iParams.iGroupId != KNullContactId && !iFetchDlg, |
|
121 Panic(EPanicPreCond_ExecuteLD)); |
|
122 |
|
123 // "D" function semantics |
|
124 CleanupStack::PushL(this); |
|
125 TBool thisDestroyed = EFalse; |
|
126 iDestroyedPtr = &thisDestroyed; |
|
127 |
|
128 // Convert aParams for CPbkFetchEntryDlg |
|
129 CPbkFetchDlg::TParams params; |
|
130 params.iResId = R_PBK_GROUP_MEMBER_FETCH_DLG; |
|
131 params.iFlags = CPbkFetchDlg::FETCH_MARKED; |
|
132 params.iContactView = iGroupNonMembersSubView; |
|
133 |
|
134 // Run CPbkFetchEntryDlg dialog |
|
135 iFetchDlg = CPbkFetchDlg::NewL(params, iPbkEngine); |
|
136 iFetchDlg->ResetWhenDestroyed(&iFetchDlg); |
|
137 TInt result = iFetchDlg->ExecuteLD(); |
|
138 |
|
139 if (thisDestroyed) |
|
140 { |
|
141 // This object has been destroyed |
|
142 result = 0; |
|
143 CleanupStack::Pop(this); |
|
144 } |
|
145 else |
|
146 { |
|
147 // Convert output back to our format |
|
148 if (result) |
|
149 { |
|
150 iParams.iMarkedEntries = params.iMarkedEntries; |
|
151 params.iMarkedEntries = NULL; |
|
152 } |
|
153 CleanupStack::PopAndDestroy(this); |
|
154 } |
|
155 |
|
156 return result; |
|
157 } |
|
158 |
|
159 CPbkGroupMembersFetchDlg::~CPbkGroupMembersFetchDlg() |
|
160 { |
|
161 if (iDestroyedPtr) |
|
162 { |
|
163 *iDestroyedPtr = ETrue; |
|
164 } |
|
165 if (iGroupNonMembersSubView) |
|
166 { |
|
167 iGroupNonMembersSubView->Close(*this); |
|
168 } |
|
169 delete iFetchDlg; |
|
170 } |
|
171 |
|
172 void CPbkGroupMembersFetchDlg::HandleContactViewEvent |
|
173 (const CContactViewBase& /*aView*/, |
|
174 const TContactViewEvent& /*aEvent*/) |
|
175 { |
|
176 } |
|
177 |
|
178 |
|
179 // End of File |