|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Factory methods for model AND dialog construction |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "CMRObjectFactory.h" |
|
23 #include "CMRRequestModel.h" |
|
24 #include "CMRResponseModel.h" |
|
25 #include "CMRCancelModel.h" |
|
26 #include "CMRSummaryDlgBase.h" |
|
27 #include "CMRDescriptionDlgBase.h" |
|
28 #include "MRViewersPanic.h" |
|
29 #include "meetingrequestviewers.hrh" |
|
30 #include <cmrmailboxutils.h> |
|
31 |
|
32 /// Unnamed namespace for local definitions |
|
33 namespace { |
|
34 |
|
35 _LIT( KPanicMsg, "CMRObjectFactory" ); |
|
36 |
|
37 void Panic( TPanicCode aReason ) |
|
38 { |
|
39 User::Panic( KPanicMsg, aReason ); |
|
40 } |
|
41 |
|
42 } // namespace |
|
43 |
|
44 MMRModelInterface* CMRObjectFactory::CreateMRModelL( |
|
45 RPointerArray<CCalEntry>& aEntries, |
|
46 const MAgnEntryUi::TAgnEntryUiInParams& aParams, |
|
47 CMRMailboxUtils& aMRMailboxUtils, |
|
48 CMRUtilsInternal& aMRUtils ) |
|
49 { |
|
50 MMRModelInterface* model( NULL ); |
|
51 |
|
52 // all entries in the array have the same method |
|
53 switch ( aEntries[0]->MethodL() ) |
|
54 { |
|
55 case CCalEntry::EMethodRequest: |
|
56 { |
|
57 model = CMRRequestModel::NewL( aEntries, |
|
58 aMRMailboxUtils, |
|
59 aMRUtils, |
|
60 aParams ); |
|
61 break; |
|
62 } |
|
63 case CCalEntry::EMethodReply: |
|
64 { |
|
65 model = CMRResponseModel::NewL( aEntries, |
|
66 aMRMailboxUtils, |
|
67 aMRUtils, |
|
68 aParams ); |
|
69 break; |
|
70 } |
|
71 case CCalEntry::EMethodCancel: |
|
72 { |
|
73 model = CMRCancelModel::NewL( aEntries, |
|
74 aMRMailboxUtils, |
|
75 aMRUtils, |
|
76 aParams ); |
|
77 break; |
|
78 } |
|
79 default: |
|
80 { |
|
81 User::Leave( KErrNotSupported ); |
|
82 } |
|
83 } |
|
84 return model; |
|
85 } |
|
86 |
|
87 CMRDialogBase* CMRObjectFactory::CreateMRDialogL( |
|
88 CCalEntry::TMethod aMethod, |
|
89 const MAgnEntryUi::TAgnEntryUiInParams& aParams, |
|
90 MAgnEntryUiCallback& aHandlerCallback, |
|
91 CMRHandler::TMRViewStatus aRequestedView ) |
|
92 { |
|
93 CMRHandler::TMRViewStatus createdView( aRequestedView ); |
|
94 |
|
95 // if requested dialog is default for the view then we need to |
|
96 // define that here based on request method |
|
97 if ( aRequestedView == CMRHandler::EInitialView ) |
|
98 { |
|
99 if ( aMethod == CCalEntry::EMethodRequest || |
|
100 aMethod == CCalEntry::EMethodRefresh || |
|
101 aMethod == CCalEntry::EMethodCancel ) |
|
102 { |
|
103 createdView = CMRHandler::ELaunchMeetingRequestView; |
|
104 } |
|
105 else if ( aMethod == CCalEntry::EMethodReply ) |
|
106 { |
|
107 createdView = CMRHandler::ELaunchMeetingDescriptionView; |
|
108 } |
|
109 else |
|
110 { |
|
111 User::Leave( KErrNotSupported ); |
|
112 } |
|
113 } |
|
114 |
|
115 if ( createdView == CMRHandler::ELaunchMeetingRequestView ) |
|
116 { |
|
117 return CMRSummaryDlgBase::NewL( aHandlerCallback, |
|
118 aParams.iEditorMode ); |
|
119 } |
|
120 else |
|
121 { |
|
122 __ASSERT_DEBUG( createdView == |
|
123 CMRHandler::ELaunchMeetingDescriptionView, |
|
124 Panic( EIllegalParamValue ) ); |
|
125 return CMRDescriptionDlgBase::NewL( aHandlerCallback ); |
|
126 } |
|
127 } |
|
128 |
|
129 // End of file |