|
1 /* |
|
2 * Copyright (c) 2005-2006 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: This is the app ui implementation of default application server. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikserverapp.h> |
|
20 #include <akncontext.h> |
|
21 #include <apgicnfl.h> |
|
22 #include <AknIconArray.h> |
|
23 #include <AknsUtils.h> |
|
24 #include <aknlists.h> |
|
25 #include <defaultappserver.rsg> |
|
26 #include "das_appui.h" |
|
27 #include "das_view.h" |
|
28 #include "das_srvmime_dlg.h" |
|
29 #include "das_servmimeapps.h" |
|
30 #include "das.hrh" |
|
31 |
|
32 // ======== MEMBER FUNCTIONS ======== |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // Destructor |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CDefaultAppAppUi::~CDefaultAppAppUi() |
|
39 { |
|
40 if(iView) |
|
41 delete iView; |
|
42 if(iServMimeApps) |
|
43 delete iServMimeApps; |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // Default constructor |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CDefaultAppAppUi::CDefaultAppAppUi() : iView(NULL), iDlg(NULL), iExitBack(EFalse) |
|
51 { |
|
52 // No implementation required |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Symbian constructor |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 void CDefaultAppAppUi::ConstructL() |
|
60 { |
|
61 BaseConstructL(EAknEnableSkin|EAknEnableMSK|EAknSingleClickCompatible); |
|
62 // Create view object |
|
63 iView = CDefaultAppView::NewL( ClientRect() ); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // Continues the construction, after the client connects to the server and some data is known |
|
68 // (client UID and service flags) |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void CDefaultAppAppUi::ConstructSrvMimeDlgL(TUid aClientUid, TInt aServiceFlags) |
|
72 { |
|
73 SetClientIconL(aClientUid); |
|
74 iClientUid = aClientUid; |
|
75 iSelectedItemSimple=-1; |
|
76 iSelectedItemAdvanced=-1; |
|
77 iReloadDlgAdvanced=(aClientUid==KUidGS?EFalse:ETrue); |
|
78 iReloadDlg=ETrue; |
|
79 do |
|
80 { |
|
81 if(!iServMimeApps) |
|
82 iServMimeApps=CDefaultAppServMimeApps::NewL(aClientUid, aServiceFlags); |
|
83 |
|
84 if(iReloadDlgAdvanced) |
|
85 { |
|
86 //some settings for the advanced view |
|
87 iServMimeApps->iSimplifiedView=EFalse; |
|
88 } |
|
89 else |
|
90 { |
|
91 //some settings for the simple view |
|
92 iServMimeApps->iSimplifiedView=ETrue; |
|
93 }; |
|
94 iServMimeApps->GetServicesAndMimesListL(iServMimeApps->iList); |
|
95 |
|
96 iDlg=CDefaultAppSrvMimeDlg::NewL(this); |
|
97 SetDialogExist( ETrue ); |
|
98 iDlg->SetMopParent(this); |
|
99 iDlg->ExecuteLD(R_DAS_DLG); |
|
100 iDlg=NULL; |
|
101 } |
|
102 while(iReloadDlg); |
|
103 |
|
104 |
|
105 //exit the server |
|
106 if(iExitBack) |
|
107 { |
|
108 //if we exit by "Back" button, notify the client app, so that it does not exit. |
|
109 CEikAppServer* server = iEikonEnv->AppServer(); //if we do not do this, the client exits when backkey is pressed |
|
110 if ( server ) |
|
111 { |
|
112 server->NotifyServerExit( EAknSoftkeyBack ); |
|
113 } |
|
114 }; |
|
115 //exit this application |
|
116 RunAppShutter(); |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // From class CAknAppUi. |
|
121 // handle menu command |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 void CDefaultAppAppUi::HandleCommandL(TInt aCommand) |
|
125 { |
|
126 switch (aCommand) |
|
127 { |
|
128 case EAknSoftkeyExit: |
|
129 __ASSERT_ALWAYS(0,User::Leave(KErrGeneral)); |
|
130 break; |
|
131 case EEikCmdExit: |
|
132 |
|
133 Exit(); |
|
134 break; |
|
135 //no need for default. We may also have other commands that we do not handle here. |
|
136 } |
|
137 } |
|
138 |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // imports and displays the icon of the client application. |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CDefaultAppAppUi::SetClientIconL(TUid aClietAppUid) |
|
145 { |
|
146 CEikStatusPane *statusPane=StatusPane(); |
|
147 TUid contextPaneUid=TUid::Uid(EEikStatusPaneUidContext); |
|
148 if(statusPane && statusPane->PaneCapabilities(contextPaneUid).IsPresent()) |
|
149 { |
|
150 CAknContextPane *contextPane=(CAknContextPane*)(statusPane->ControlL(contextPaneUid)); //we don't get the ownership |
|
151 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); //we don't get the ownership |
|
152 |
|
153 CFbsBitmap* iconBmp = NULL; |
|
154 CFbsBitmap* iconBmpMask = NULL; |
|
155 |
|
156 AknsUtils::CreateAppIconLC(skinInstance,aClietAppUid,EAknsAppIconTypeContext, |
|
157 iconBmp,iconBmpMask); |
|
158 CleanupStack::Pop(2);//the 2 icons |
|
159 |
|
160 contextPane->SetPicture(iconBmp,iconBmpMask);// ownership transfer for the 2 pictures |
|
161 } |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // Handles layout changes (e.g. from portrait to landscape) |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 void CDefaultAppAppUi::HandleResourceChangeL(TInt aType) |
|
169 { |
|
170 CAknAppUi::HandleResourceChangeL( aType ); |
|
171 |
|
172 if(iView) |
|
173 iView->HandleResourceChange(aType); |
|
174 if( iDlg && iDialogExist ) |
|
175 iDlg->HandleResourceChange(aType); |
|
176 |
|
177 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
178 { |
|
179 if( iView ) |
|
180 iView->SetRect(ClientRect()); |
|
181 if( iDlg && iDialogExist ) |
|
182 iDlg->SetRect(ClientRect()); |
|
183 } |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // Handles Window Server events (we are interested in catching the end key event |
|
188 // and exiting the application |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void CDefaultAppAppUi::HandleWsEventL(const TWsEvent & aEvent, CCoeControl * aDestination) |
|
192 { |
|
193 CAknAppUi::HandleWsEventL(aEvent,aDestination); |
|
194 } |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // This functino is used to record the exist of the dialog; |
|
198 // and exiting the application |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 void CDefaultAppAppUi::SetDialogExist( TBool aExist ) |
|
202 { |
|
203 iDialogExist = aExist; |
|
204 } |