|
1 /* |
|
2 * Copyright (c) 2010 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "engine.h" |
|
20 #include "enginewrapper.h" |
|
21 |
|
22 #include "creator_note.h" |
|
23 #include "creator_traces.h" |
|
24 |
|
25 //---------------------------------------------------------------------------- |
|
26 |
|
27 CNotepadParameters::CNotepadParameters() |
|
28 { |
|
29 LOGSTRING("Creator: CNotepadParameters::CNotepadParameters"); |
|
30 |
|
31 iNoteText = HBufC::New(KNotepadFieldLength); |
|
32 } |
|
33 |
|
34 CNotepadParameters::~CNotepadParameters() |
|
35 { |
|
36 LOGSTRING("Creator: CNotepadParameters::~CNotepadParameters"); |
|
37 |
|
38 delete iNoteText; |
|
39 } |
|
40 |
|
41 //---------------------------------------------------------------------------- |
|
42 |
|
43 CCreatorNotepad* CCreatorNotepad::NewL(CCreatorEngine* aEngine) |
|
44 { |
|
45 CCreatorNotepad* self = CCreatorNotepad::NewLC(aEngine); |
|
46 CleanupStack::Pop(self); |
|
47 return self; |
|
48 } |
|
49 |
|
50 CCreatorNotepad* CCreatorNotepad::NewLC(CCreatorEngine* aEngine) |
|
51 { |
|
52 CCreatorNotepad* self = new (ELeave) CCreatorNotepad; |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL(aEngine); |
|
55 return self; |
|
56 } |
|
57 |
|
58 CCreatorNotepad::CCreatorNotepad() : iFs ( CEikonEnv::Static()->FsSession() ) |
|
59 { |
|
60 } |
|
61 |
|
62 void CCreatorNotepad::ConstructL(CCreatorEngine* aEngine) |
|
63 { |
|
64 LOGSTRING("Creator: CCreatorNotepad::ConstructL"); |
|
65 |
|
66 iEngine = aEngine; |
|
67 iNotepadWrapper = CCreatorNotepadWrapper::NewL(); |
|
68 } |
|
69 |
|
70 CCreatorNotepad::~CCreatorNotepad() |
|
71 { |
|
72 LOGSTRING("Creator: CCreatorNotepad::~CCreatorNotepad"); |
|
73 |
|
74 if (iParameters) |
|
75 { |
|
76 delete iParameters; |
|
77 iParameters = NULL; |
|
78 } |
|
79 |
|
80 if (iNotepadWrapper) |
|
81 { |
|
82 delete iNotepadWrapper; |
|
83 iNotepadWrapper = NULL; |
|
84 } |
|
85 } |
|
86 |
|
87 //---------------------------------------------------------------------------- |
|
88 |
|
89 TBool CCreatorNotepad::AskDataFromUserL(TInt aCommand) |
|
90 { |
|
91 LOGSTRING("Creator: CCreatorNotepad::AskDataFromUserL"); |
|
92 |
|
93 CCreatorModuleBase::AskDataFromUserL(aCommand); |
|
94 |
|
95 if ( aCommand == ECmdDeleteNotes ) |
|
96 { |
|
97 return iEngine->GetEngineWrapper()->YesNoQueryDialog( _L("Delete all Notes?"), this, ECreatorModuleDelete ); |
|
98 } |
|
99 |
|
100 // By Creator not supported because |
|
101 // note id is not available via Notepad API |
|
102 |
|
103 return iEngine->GetEngineWrapper()->EntriesQueryDialog( &iEntriesToBeCreated, _L("How many entries to create?"), EFalse, this, ECreatorModuleStart ); |
|
104 } |
|
105 |
|
106 |
|
107 //---------------------------------------------------------------------------- |
|
108 |
|
109 TInt CCreatorNotepad::CreateNoteEntryL(CNotepadParameters *aParameters) |
|
110 { |
|
111 LOGSTRING("Creator: CCreatorNotepad::CreateNoteEntryL"); |
|
112 |
|
113 // clear any existing parameter definations |
|
114 delete iParameters; |
|
115 iParameters = NULL; |
|
116 |
|
117 // random data needed if no predefined data available |
|
118 if (!aParameters) |
|
119 { |
|
120 iParameters = new(ELeave) CNotepadParameters; |
|
121 } |
|
122 else |
|
123 { |
|
124 iParameters = aParameters; |
|
125 } |
|
126 |
|
127 TPtr noteTextPtr = iParameters->iNoteText->Des(); |
|
128 noteTextPtr.Copy( iEngine->RandomString(CCreatorEngine::EMessageText).Left( noteTextPtr.MaxLength() ) ); |
|
129 |
|
130 return iNotepadWrapper->CreateNoteL( noteTextPtr ); |
|
131 } |
|
132 |
|
133 //---------------------------------------------------------------------------- |
|
134 void CCreatorNotepad::DeleteAllL() |
|
135 { |
|
136 LOGSTRING("Creator: CCreatorNotepad::DeleteAllL"); |
|
137 iNotepadWrapper->DeleteAllL(); |
|
138 } |
|
139 |
|
140 //---------------------------------------------------------------------------- |
|
141 void CCreatorNotepad::DeleteAllCreatedByCreatorL() |
|
142 { |
|
143 LOGSTRING("Creator: CCreatorNotepad::DeleteAllCreatedByCreatorL"); |
|
144 // Not supported because note id is not available via Notepad API |
|
145 User::Leave( KErrNotSupported ); |
|
146 } |