31
|
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 |
|
52
|
19 |
#include <QDir>
|
31
|
20 |
#include "creator_notepadwrapper.h"
|
|
21 |
|
|
22 |
/**
|
|
23 |
* Constructor
|
|
24 |
*/
|
|
25 |
CCreatorNotepadWrapper::CCreatorNotepadWrapper()
|
|
26 |
{
|
|
27 |
}
|
|
28 |
|
|
29 |
/**
|
|
30 |
* Destructor
|
|
31 |
*/
|
|
32 |
CCreatorNotepadWrapper::~CCreatorNotepadWrapper()
|
|
33 |
{
|
52
|
34 |
|
|
35 |
iNotepadApi = NULL;
|
|
36 |
|
|
37 |
if(iNotesEditorPluginLoader)
|
31
|
38 |
{
|
52
|
39 |
iNotesEditorPluginLoader->unload();
|
|
40 |
delete iNotesEditorPluginLoader;
|
|
41 |
iNotesEditorPluginLoader = NULL;
|
31
|
42 |
}
|
52
|
43 |
|
31
|
44 |
if(iAgendaUtil)
|
|
45 |
{
|
|
46 |
delete iAgendaUtil;
|
|
47 |
iAgendaUtil = NULL;
|
|
48 |
}
|
|
49 |
}
|
|
50 |
|
|
51 |
/**
|
|
52 |
* Two-Phased constructor
|
|
53 |
*/
|
|
54 |
CCreatorNotepadWrapper* CCreatorNotepadWrapper::NewL()
|
|
55 |
{
|
|
56 |
CCreatorNotepadWrapper* self = CCreatorNotepadWrapper::NewLC();
|
|
57 |
CleanupStack::Pop(self);
|
|
58 |
return self;
|
|
59 |
}
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Two-Phased constructor
|
|
63 |
*/
|
|
64 |
CCreatorNotepadWrapper* CCreatorNotepadWrapper::NewLC()
|
|
65 |
{
|
|
66 |
CCreatorNotepadWrapper* self = new (ELeave) CCreatorNotepadWrapper;
|
|
67 |
CleanupStack::PushL(self);
|
|
68 |
self->ConstructL();
|
|
69 |
return self;
|
|
70 |
}
|
|
71 |
|
|
72 |
/**
|
|
73 |
* ConstructL()
|
|
74 |
*/
|
|
75 |
|
|
76 |
void CCreatorNotepadWrapper::ConstructL()
|
|
77 |
{
|
|
78 |
iAgendaUtil = new AgendaUtil();
|
52
|
79 |
|
|
80 |
// iNotepadApi = new NotesEditor(iAgendaUtil);
|
|
81 |
|
|
82 |
// Load notes editor plugin.
|
|
83 |
// Launch the notes editor using notes editor plugin api
|
|
84 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
85 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
86 |
|
|
87 |
QT_TRYCATCH_LEAVING(
|
|
88 |
// Create NotesEditor plugin loader object.
|
|
89 |
iNotesEditorPluginLoader = new QPluginLoader(pluginName);
|
|
90 |
|
|
91 |
// Load the plugin
|
|
92 |
bool notesPluginLoaded = iNotesEditorPluginLoader->load();
|
|
93 |
QObject *plugin = qobject_cast<QObject*> ( iNotesEditorPluginLoader->instance());
|
|
94 |
|
|
95 |
iNotepadApi = qobject_cast<NotesEditorInterface*>(plugin);
|
|
96 |
);
|
|
97 |
|
31
|
98 |
}
|
|
99 |
|
|
100 |
TInt CCreatorNotepadWrapper::CreateNoteL( const TDesC& aText )
|
|
101 |
{
|
52
|
102 |
User::LeaveIfNull(iNotepadApi);
|
|
103 |
|
|
104 |
QString textNote = QString::fromUtf16( aText.Ptr(),aText.Length());
|
31
|
105 |
iNotepadApi->edit(textNote,iAgendaUtil);
|
|
106 |
iNotepadApi->close(NotesEditorInterface::CloseWithSave, iAgendaUtil);
|
52
|
107 |
|
|
108 |
return KErrNone;
|
31
|
109 |
}
|
|
110 |
void CCreatorNotepadWrapper::DeleteAllL()
|
|
111 |
{
|
|
112 |
|
|
113 |
QList<AgendaEntry> ael;
|
|
114 |
AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(AgendaUtil::IncludeNotes);
|
|
115 |
|
|
116 |
ael = iAgendaUtil->fetchAllEntries(filter);
|
|
117 |
for(int i=0 ; i<ael.count() ; i++)
|
|
118 |
{
|
|
119 |
iAgendaUtil->deleteEntry(ael[i].id());
|
|
120 |
}
|
|
121 |
|
|
122 |
}
|
|
123 |
|