|
1 /* |
|
2 * Copyright (c) 2008 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: Provides access to Agenda Model todo adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cpimtodoadapteraccess.h" |
|
21 #include "cpimtodoadaptermanager.h" |
|
22 #include "cpimtodolistadapter.h" |
|
23 #include "mpimlocalizationmanager.h" |
|
24 #include "mpimlocalizationdata.h" |
|
25 #include "pimlocalizationids.h" |
|
26 #include "logger.h" |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CPIMToDoAdapterAccess::CPIMToDoAdapterAccess |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CPIMToDoAdapterAccess::CPIMToDoAdapterAccess( |
|
35 MPIMLocalizationManager* aLocalizationManager, |
|
36 java::util::FunctionServer* aFuncServer) : |
|
37 iLocalizationManager(aLocalizationManager), iFuncServer(aFuncServer) |
|
38 { |
|
39 JELOG2(EPim); |
|
40 } |
|
41 |
|
42 void CPIMToDoAdapterAccess::ConstructL() |
|
43 { |
|
44 JELOG2(EPim); |
|
45 iToDoLocalizationData = iLocalizationManager->GetPIMLocalizationDataL( |
|
46 KPIMLocalizationIdToDo); |
|
47 |
|
48 iToDoListNames = new(ELeave) CDesCArrayFlat(KPIMNumberOfToDoLists); |
|
49 iNoListNames = new(ELeave) CDesCArrayFlat(1); // will be left empty |
|
50 |
|
51 HBufC* listName = iToDoLocalizationData->GetListNameL(); |
|
52 CleanupStack::PushL(listName); |
|
53 iToDoListNames->AppendL(*listName); |
|
54 CleanupStack::PopAndDestroy(listName); |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CPIMToDoAdapterAccess::NewL |
|
59 // Two-phased constructor. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CPIMToDoAdapterAccess* CPIMToDoAdapterAccess::NewL( |
|
63 MPIMLocalizationManager* aLocalizationManager, |
|
64 java::util::FunctionServer* aFuncServer) // not owned |
|
65 { |
|
66 JELOG2(EPim); |
|
67 CPIMToDoAdapterAccess * self = |
|
68 new(ELeave) CPIMToDoAdapterAccess(aLocalizationManager, aFuncServer); |
|
69 |
|
70 CleanupStack::PushL(self); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop(self); |
|
73 return self; |
|
74 } |
|
75 |
|
76 // destructor |
|
77 CPIMToDoAdapterAccess::~CPIMToDoAdapterAccess() |
|
78 { |
|
79 JELOG2(EPim); |
|
80 delete iToDoLocalizationData; |
|
81 delete iToDoListNames; |
|
82 delete iNoListNames; |
|
83 } |
|
84 |
|
85 const CDesCArray& CPIMToDoAdapterAccess::ListNamesL( |
|
86 const TPIMListType aListType) |
|
87 { |
|
88 JELOG2(EPim); |
|
89 if (aListType == EPIMToDoList) |
|
90 { |
|
91 return *iToDoListNames; |
|
92 } |
|
93 else |
|
94 { |
|
95 // no Contact or Event lists |
|
96 return *iNoListNames; |
|
97 } |
|
98 } |
|
99 |
|
100 TBool CPIMToDoAdapterAccess::OpenContactListL(const TDesC* /*aListName*/, |
|
101 MPIMContactAdapterManager** /*aRetAdapterManager*/, |
|
102 MPIMContactListAdapter** /*aRetListAdapter*/, MPIMLocalizationData** /*aRetLocalizationData*/) |
|
103 { |
|
104 JELOG2(EPim); |
|
105 // no Contact lists |
|
106 return EFalse; |
|
107 } |
|
108 |
|
109 TBool CPIMToDoAdapterAccess::OpenEventListL(const TDesC* /*aListName*/, |
|
110 MPIMEventAdapterManager** /*aRetAdapterManager*/, |
|
111 MPIMEventListAdapter** /*aRetListAdapter*/, MPIMLocalizationData** /*aRetLocalizationData*/) |
|
112 { |
|
113 JELOG2(EPim); |
|
114 // no Event lists |
|
115 return EFalse; |
|
116 } |
|
117 |
|
118 TBool CPIMToDoAdapterAccess::OpenToDoListL(const TDesC* aListName, |
|
119 MPIMToDoAdapterManager** aRetAdapterManager, |
|
120 MPIMToDoListAdapter** aRetListAdapter, |
|
121 MPIMLocalizationData** aRetLocalizationData) |
|
122 { |
|
123 JELOG2(EPim); |
|
124 // There is exactly one ToDo list, which is the default ToDo list. |
|
125 |
|
126 // If name is given, check that it matches the existing list name |
|
127 if (aListName && (*aListName != (*iToDoListNames)[0])) |
|
128 { |
|
129 // Not found |
|
130 return EFalse; |
|
131 } |
|
132 |
|
133 // OK, got this far - Open the Todo list |
|
134 |
|
135 MPIMToDoAdapterManager* adapterManager = CPIMToDoAdapterManager::NewL( |
|
136 (*iToDoListNames)[0]); |
|
137 CleanupDeletePushL(adapterManager); |
|
138 |
|
139 MPIMToDoListAdapter* listAdapter = CPIMToDoListAdapter::NewL(iFuncServer); |
|
140 CleanupStack::Pop(adapterManager); |
|
141 |
|
142 MPIMLocalizationData* localizationData = iToDoLocalizationData; |
|
143 |
|
144 // Return values |
|
145 *aRetAdapterManager = adapterManager; |
|
146 *aRetListAdapter = listAdapter; |
|
147 *aRetLocalizationData = localizationData; |
|
148 |
|
149 return ETrue; |
|
150 } |
|
151 |
|
152 // End of File |