79
|
1 |
/*
|
|
2 |
* Copyright (c) 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:
|
|
15 |
* CMsgEditorShutter implementation file
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include <e32base.h>
|
|
23 |
#include <aknenv.h>
|
|
24 |
#include <messaginginternalpskeys.h>
|
|
25 |
#include <MuiuMsgEditorLauncher.h>
|
|
26 |
#include "MsgEditorShutter.h"
|
|
27 |
|
|
28 |
// CONSTANTS
|
|
29 |
|
|
30 |
// ================= MEMBER FUNCTIONS =======================
|
|
31 |
|
|
32 |
// ---------------------------------------------------------
|
|
33 |
// CMsgEditorShutter::CMsgEditorShutter
|
|
34 |
//
|
|
35 |
// C++ constructor can NOT contain any code, that
|
|
36 |
// might leave.
|
|
37 |
// ---------------------------------------------------------
|
|
38 |
//
|
|
39 |
CMsgEditorShutter::CMsgEditorShutter(CMsgEditorDocument& aDoc)
|
|
40 |
: CActive( CActive::EPriorityStandard ),
|
|
41 |
iDoc( aDoc )
|
|
42 |
{
|
|
43 |
CActiveScheduler::Add( this );
|
|
44 |
}
|
|
45 |
|
|
46 |
// ---------------------------------------------------------
|
|
47 |
// CMsgEditorShutter::ConstructL()
|
|
48 |
//
|
|
49 |
// Symbian OS default constructor can leave.
|
|
50 |
// ---------------------------------------------------------
|
|
51 |
//
|
|
52 |
void CMsgEditorShutter::ConstructL()
|
|
53 |
{
|
|
54 |
User::LeaveIfError( iOpenAppProperty.Attach( KPSUidMuiu, KMuiuSysOpenMsgEditors ) );
|
|
55 |
|
|
56 |
// Complete self
|
|
57 |
TInt openEditors = 0;
|
|
58 |
TInt err = iOpenAppProperty.Get( openEditors );
|
|
59 |
|
|
60 |
switch ( err )
|
|
61 |
{
|
|
62 |
case KErrPermissionDenied:
|
|
63 |
case KErrArgument:
|
|
64 |
{
|
|
65 |
User::Leave( err );
|
|
66 |
}
|
|
67 |
break;
|
|
68 |
case KErrNotFound:
|
|
69 |
{
|
|
70 |
User::LeaveIfError (
|
|
71 |
RProperty::Define(
|
|
72 |
KPSUidMuiu,
|
|
73 |
KMuiuSysOpenMsgEditors,
|
|
74 |
RProperty::EInt,
|
|
75 |
ECapabilityReadDeviceData,
|
|
76 |
ECapabilityWriteDeviceData,
|
|
77 |
0 ) );
|
|
78 |
}
|
|
79 |
break;
|
|
80 |
case KErrNone:
|
|
81 |
default:
|
|
82 |
break;
|
|
83 |
}
|
|
84 |
err = iOpenAppStandAloneProperty.Attach(KPSUidMsgEditor,KMuiuStandAloneOpenMsgEditors);
|
|
85 |
TInt newValue = 0; // since only one stand alone editor can be launched
|
|
86 |
err = iOpenAppStandAloneProperty.Get(KPSUidMsgEditor, KMuiuStandAloneOpenMsgEditors, newValue);
|
|
87 |
switch ( err )
|
|
88 |
{
|
|
89 |
case KErrPermissionDenied:
|
|
90 |
case KErrArgument:
|
|
91 |
{
|
|
92 |
User::Leave( err );
|
|
93 |
}
|
|
94 |
break;
|
|
95 |
case KErrNotFound:
|
|
96 |
{
|
|
97 |
User::LeaveIfError (
|
|
98 |
RProperty::Define(
|
|
99 |
KPSUidMsgEditor,
|
|
100 |
KMuiuStandAloneOpenMsgEditors,
|
|
101 |
RProperty::EInt,
|
|
102 |
ECapabilityReadDeviceData,
|
|
103 |
ECapabilityWriteDeviceData,
|
|
104 |
0 ) );
|
|
105 |
}
|
|
106 |
break;
|
|
107 |
case KErrNone:
|
|
108 |
default:
|
|
109 |
break;
|
|
110 |
}
|
|
111 |
openEditors++;
|
|
112 |
iOpenAppProperty.Set( openEditors );
|
|
113 |
iStatus = KRequestPending;
|
|
114 |
iOpenAppProperty.Subscribe( iStatus );
|
|
115 |
SetActive();
|
|
116 |
}
|
|
117 |
|
|
118 |
// ---------------------------------------------------------
|
|
119 |
// CMsgEditorShutter::NewL
|
|
120 |
//
|
|
121 |
// Two-phased constructor.
|
|
122 |
// ---------------------------------------------------------
|
|
123 |
//
|
|
124 |
CMsgEditorShutter* CMsgEditorShutter::NewL(CMsgEditorDocument& aAppUi)
|
|
125 |
{
|
|
126 |
CMsgEditorShutter* self = new ( ELeave ) CMsgEditorShutter(aAppUi);
|
|
127 |
|
|
128 |
CleanupStack::PushL( self );
|
|
129 |
self->ConstructL();
|
|
130 |
CleanupStack::Pop( self );
|
|
131 |
|
|
132 |
return self;
|
|
133 |
}
|
|
134 |
|
|
135 |
// ---------------------------------------------------------
|
|
136 |
// CMsgEditorShutter::~CMsgEditorShutter
|
|
137 |
//
|
|
138 |
// Destructor
|
|
139 |
// ---------------------------------------------------------
|
|
140 |
//
|
|
141 |
CMsgEditorShutter::~CMsgEditorShutter()
|
|
142 |
{
|
|
143 |
Cancel();
|
|
144 |
|
|
145 |
TInt openEditors = 0;
|
|
146 |
iOpenAppProperty.Get( openEditors );
|
|
147 |
|
|
148 |
// Do not make open editor count negative
|
|
149 |
|
|
150 |
if ( openEditors > 0 )
|
|
151 |
{
|
|
152 |
openEditors--;
|
|
153 |
iOpenAppProperty.Set( openEditors );
|
|
154 |
}
|
|
155 |
|
|
156 |
TInt standAloneEditorCnt = 0; // since only one stand alone editor can be launched
|
|
157 |
iOpenAppStandAloneProperty.Get(KPSUidMsgEditor, KMuiuStandAloneOpenMsgEditors, standAloneEditorCnt);
|
|
158 |
|
|
159 |
if(standAloneEditorCnt > 0)
|
|
160 |
{
|
|
161 |
standAloneEditorCnt--;
|
|
162 |
iOpenAppStandAloneProperty.Set(KPSUidMsgEditor, KMuiuStandAloneOpenMsgEditors, standAloneEditorCnt);
|
|
163 |
}
|
|
164 |
|
|
165 |
iOpenAppProperty.Close();
|
|
166 |
iOpenAppStandAloneProperty.Close();
|
|
167 |
}
|
|
168 |
|
|
169 |
// ---------------------------------------------------------
|
|
170 |
// CMsgEditorShutter::DoCancel
|
|
171 |
//
|
|
172 |
// From active object framework
|
|
173 |
// ---------------------------------------------------------
|
|
174 |
//
|
|
175 |
void CMsgEditorShutter::DoCancel()
|
|
176 |
{
|
|
177 |
iOpenAppProperty.Cancel();
|
|
178 |
}
|
|
179 |
|
|
180 |
// ---------------------------------------------------------
|
|
181 |
// CMsgEditorShutter::RunL
|
|
182 |
//
|
|
183 |
// From active object framework
|
|
184 |
// ---------------------------------------------------------
|
|
185 |
//
|
|
186 |
void CMsgEditorShutter::RunL()
|
|
187 |
{
|
|
188 |
TInt openEditors = 0;
|
|
189 |
iOpenAppProperty.Get( openEditors );
|
|
190 |
|
|
191 |
TInt launchtype = iDoc.LaunchFlags();
|
|
192 |
|
|
193 |
TInt StandAloneEditorCnt = 0; // since only one stand alone editor can be launched
|
|
194 |
TInt err = iOpenAppStandAloneProperty.Get(KPSUidMsgEditor, KMuiuStandAloneOpenMsgEditors, StandAloneEditorCnt);
|
|
195 |
|
|
196 |
if((launchtype & EMsgLaunchEditorStandAlone ) && StandAloneEditorCnt > 1 )
|
|
197 |
{
|
|
198 |
// Run appshutter
|
|
199 |
CAknEnv::RunAppShutter();
|
|
200 |
}
|
|
201 |
else if ( openEditors )
|
|
202 |
{
|
|
203 |
iStatus = KRequestPending;
|
|
204 |
iOpenAppProperty.Subscribe( iStatus );
|
|
205 |
SetActive();
|
|
206 |
}
|
|
207 |
else
|
|
208 |
{
|
|
209 |
// Run appshutter
|
|
210 |
CAknEnv::RunAppShutter();
|
|
211 |
}
|
|
212 |
}
|
|
213 |
|
|
214 |
// End of File
|