5
|
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: TelephonyAudioRouting Test Application
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <avkon.hrh>
|
|
21 |
#include <aknmessagequerydialog.h>
|
|
22 |
#include <CAknMemorySelectionDialog.h>
|
|
23 |
#include <CAknFileSelectionDialog.h>
|
|
24 |
#include <AknCommonDialogs.h>
|
|
25 |
#include <aknnotewrappers.h>
|
|
26 |
#include <StringLoader.h>
|
|
27 |
#include <f32file.h>
|
|
28 |
#include <s32file.h>
|
|
29 |
#include <hlplch.h>
|
|
30 |
|
|
31 |
#include <myplayer_0xe0edbe14.rsg>
|
|
32 |
|
|
33 |
#include "myplayer.hrh"
|
|
34 |
#include "myplayer.pan"
|
|
35 |
#include "myplayerapplication.h"
|
|
36 |
#include "myplayerappui.h"
|
|
37 |
#include "myplayerappview.h"
|
|
38 |
|
|
39 |
_LIT( KFileName, "C:\\private\\E0EDBE14\\MyPlayer.txt" );
|
|
40 |
_LIT( KText, "My Player");
|
|
41 |
|
|
42 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
43 |
|
|
44 |
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
// CMyPlayerAppUi::ConstructL()
|
|
47 |
// Symbian 2nd phase constructor can leave.
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
void CMyPlayerAppUi::ConstructL()
|
|
51 |
{
|
|
52 |
// Initialise app UI with standard value.
|
|
53 |
BaseConstructL(CAknAppUi::EAknEnableSkin);
|
|
54 |
|
|
55 |
// Create view object
|
|
56 |
iAppView = CMyPlayerAppView::NewL(ClientRect());
|
|
57 |
|
|
58 |
// Create a file to write the text to
|
|
59 |
TInt err = CCoeEnv::Static()->FsSession().MkDirAll(KFileName);
|
|
60 |
if ((KErrNone != err) && (KErrAlreadyExists != err))
|
|
61 |
{
|
|
62 |
return;
|
|
63 |
}
|
|
64 |
|
|
65 |
RFile file;
|
|
66 |
err = file.Replace(CCoeEnv::Static()->FsSession(), KFileName, EFileWrite);
|
|
67 |
CleanupClosePushL(file);
|
|
68 |
if (KErrNone != err)
|
|
69 |
{
|
|
70 |
CleanupStack::PopAndDestroy(1); // file
|
|
71 |
return;
|
|
72 |
}
|
|
73 |
|
|
74 |
RFileWriteStream outputFileStream(file);
|
|
75 |
CleanupClosePushL(outputFileStream);
|
|
76 |
outputFileStream << KText;
|
|
77 |
|
|
78 |
CleanupStack::PopAndDestroy(2); // outputFileStream, file
|
|
79 |
|
|
80 |
|
|
81 |
}
|
|
82 |
// -----------------------------------------------------------------------------
|
|
83 |
// CMyPlayerAppUi::CMyPlayerAppUi()
|
|
84 |
// C++ default constructor can NOT contain any code, that might leave.
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
CMyPlayerAppUi::CMyPlayerAppUi()
|
|
88 |
{
|
|
89 |
// No implementation required
|
|
90 |
}
|
|
91 |
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
// CMyPlayerAppUi::~CMyPlayerAppUi()
|
|
94 |
// Destructor.
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
CMyPlayerAppUi::~CMyPlayerAppUi()
|
|
98 |
{
|
|
99 |
if (iAppView)
|
|
100 |
{
|
|
101 |
delete iAppView;
|
|
102 |
iAppView = NULL;
|
|
103 |
}
|
|
104 |
if(iPlayer)
|
|
105 |
delete iPlayer;
|
|
106 |
|
|
107 |
}
|
|
108 |
|
|
109 |
// -----------------------------------------------------------------------------
|
|
110 |
// CMyPlayerAppUi::HandleCommandL()
|
|
111 |
// Takes care of command handling.
|
|
112 |
// -----------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
void CMyPlayerAppUi::HandleCommandL(TInt aCommand)
|
|
115 |
{
|
|
116 |
switch (aCommand)
|
|
117 |
{
|
|
118 |
case EEikCmdExit:
|
|
119 |
case EAknSoftkeyExit:
|
|
120 |
Exit();
|
|
121 |
break;
|
|
122 |
|
|
123 |
case ECmdCreatePlayer:
|
|
124 |
{
|
|
125 |
|
|
126 |
// Load a string from the resource file and display it
|
|
127 |
|
|
128 |
iPlayer = CMyPlayer::NewL();
|
|
129 |
|
|
130 |
HBufC* textResource = StringLoader::LoadLC(R_AUDIO_PLAYER_TEXT);
|
|
131 |
CAknInformationNote* informationNote;
|
|
132 |
|
|
133 |
informationNote = new (ELeave) CAknInformationNote;
|
|
134 |
|
|
135 |
// Show the information Note with
|
|
136 |
// textResource loaded with StringLoader.
|
|
137 |
informationNote->ExecuteLD(*textResource);
|
|
138 |
|
|
139 |
// Pop HBuf from CleanUpStack and Destroy it.
|
|
140 |
CleanupStack::PopAndDestroy(textResource);
|
|
141 |
}
|
|
142 |
break;
|
|
143 |
case ECmdSetOutputL:
|
|
144 |
{
|
|
145 |
iPlayer->SetOutputL();
|
|
146 |
RFile rFile;
|
|
147 |
|
|
148 |
//Open file where the stream text is
|
|
149 |
User::LeaveIfError(rFile.Open(CCoeEnv::Static()->FsSession(),
|
|
150 |
KFileName, EFileStreamText));//EFileShareReadersOnly));// EFileStreamText));
|
|
151 |
CleanupClosePushL(rFile);
|
|
152 |
|
|
153 |
// copy stream from file to RFileStream object
|
|
154 |
RFileReadStream inputFileStream(rFile);
|
|
155 |
CleanupClosePushL(inputFileStream);
|
|
156 |
|
|
157 |
// HBufC descriptor is created from the RFileStream object.
|
|
158 |
HBufC* fileData = HBufC::NewLC(inputFileStream, 32);
|
|
159 |
|
|
160 |
CAknInformationNote* informationNote;
|
|
161 |
|
|
162 |
informationNote = new (ELeave) CAknInformationNote;
|
|
163 |
// Show the information Note
|
|
164 |
informationNote->ExecuteLD(*fileData);
|
|
165 |
|
|
166 |
// Pop loaded resources from the cleanup stack
|
|
167 |
CleanupStack::PopAndDestroy(3); // filedata, inputFileStream, rFile
|
|
168 |
}
|
|
169 |
break;
|
|
170 |
case ECmdSetShowNote:
|
|
171 |
{
|
|
172 |
iPlayer->SetShowNote();
|
|
173 |
}
|
|
174 |
break;
|
|
175 |
case ECmdGetShowNote:
|
|
176 |
{
|
|
177 |
iPlayer->GetShowNote();
|
|
178 |
}
|
|
179 |
break;
|
|
180 |
case ECmdOutputChanged:
|
|
181 |
{
|
|
182 |
iPlayer->OutputChangedTARManager();
|
|
183 |
}
|
|
184 |
break;
|
|
185 |
case ECmdOutputChangeReq:
|
|
186 |
{
|
|
187 |
iPlayer->OutputChangeRequestCompleted();
|
|
188 |
}
|
|
189 |
break;
|
|
190 |
default:
|
|
191 |
Panic(EMyPlayerUi);
|
|
192 |
break;
|
|
193 |
}
|
|
194 |
}
|
|
195 |
// -----------------------------------------------------------------------------
|
|
196 |
// Called by the framework when the application status pane
|
|
197 |
// size is changed. Passes the new client rectangle to the
|
|
198 |
// AppView
|
|
199 |
// -----------------------------------------------------------------------------
|
|
200 |
//
|
|
201 |
void CMyPlayerAppUi::HandleStatusPaneSizeChange()
|
|
202 |
{
|
|
203 |
iAppView->SetRect(ClientRect());
|
|
204 |
}
|
|
205 |
|
|
206 |
CArrayFix<TCoeHelpContext>* CMyPlayerAppUi::HelpContextL() const
|
|
207 |
{
|
|
208 |
#warning "Please see comment about help and UID3..."
|
|
209 |
// Note: Help will not work if the application uid3 is not in the
|
|
210 |
// protected range. The default uid3 range for projects created
|
|
211 |
// from this template (0xE0000000 - 0xEFFFFFFF) are not in the protected range so that they
|
|
212 |
// can be self signed and installed on the device during testing.
|
|
213 |
// Once you get your official uid3 from Symbian Ltd. and find/replace
|
|
214 |
// all occurrences of uid3 in your project, the context help will
|
|
215 |
// work. Alternatively, a patch now exists for the versions of
|
|
216 |
// HTML help compiler in SDKs and can be found here along with an FAQ:
|
|
217 |
// http://www3.symbian.com/faq.nsf/AllByDate/E9DF3257FD565A658025733900805EA2?OpenDocument
|
|
218 |
CArrayFixFlat<TCoeHelpContext>* array = new (ELeave) CArrayFixFlat<
|
|
219 |
TCoeHelpContext> (1);
|
|
220 |
CleanupStack::PushL(array);
|
|
221 |
//array->AppendL(TCoeHelpContext(KUidMyPlayerApp, KGeneral_Information));
|
|
222 |
CleanupStack::Pop(array);
|
|
223 |
return array;
|
|
224 |
}
|
|
225 |
|
|
226 |
// End of File
|