45
|
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 |
// System includes
|
|
19 |
#include <QFile>
|
|
20 |
#include <QCoreApplication>
|
|
21 |
#include <agendautil.h>
|
|
22 |
|
|
23 |
// User includes
|
|
24 |
#include "calenviewerservice.h"
|
|
25 |
#include "agendaeventviewer.h"
|
|
26 |
#include "OstTraceDefinitions.h"
|
|
27 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
28 |
#include "calenviewerserviceTraces.h"
|
|
29 |
#endif
|
|
30 |
|
|
31 |
|
|
32 |
// ----------------------------------------------------------------------------
|
|
33 |
// CalenViewerService::CalenViewerService
|
|
34 |
// Rest of the details are commented in the header
|
|
35 |
// ----------------------------------------------------------------------------
|
|
36 |
//
|
|
37 |
CalenViewerService::CalenViewerService(QObject* parent) :
|
|
38 |
XQServiceProvider(QLatin1String("calenviewerservice.com.nokia.symbian.IFileView"), parent),
|
|
39 |
mFileName(0),
|
|
40 |
mViewer(NULL),
|
|
41 |
mEntryViewReady(false),
|
|
42 |
mWaitingForEntryViewReady(false),
|
|
43 |
mAsyncReqIndex(0)
|
|
44 |
{
|
|
45 |
OstTraceFunctionEntry0( CALENVIEWERSERVICE_CALENVIEWERSERVICE_ENTRY );
|
|
46 |
|
|
47 |
// Construct the agenda util object
|
|
48 |
mAgendaUtil = new AgendaUtil();
|
|
49 |
connect(mAgendaUtil, SIGNAL(entryViewCreationCompleted(int)), this, SLOT(entryViewReady(int)));
|
|
50 |
connect(this, SIGNAL(clientDisconnected()), this, SLOT(handleClientDisconnected()));
|
|
51 |
|
|
52 |
publishAll();
|
|
53 |
|
|
54 |
OstTraceFunctionExit0( CALENVIEWERSERVICE_CALENVIEWERSERVICE_EXIT );
|
|
55 |
}
|
|
56 |
|
|
57 |
// ----------------------------------------------------------------------------
|
|
58 |
// CalenViewerService::~CalenViewerService
|
|
59 |
// Rest of the details are commented in the header
|
|
60 |
// ----------------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
CalenViewerService::~CalenViewerService()
|
|
63 |
{
|
|
64 |
OstTraceFunctionEntry0( DUP1_CALENVIEWERSERVICE_CALENVIEWERSERVICE_ENTRY );
|
|
65 |
|
|
66 |
// Cleanup
|
|
67 |
if (mAgendaUtil) {
|
|
68 |
delete mAgendaUtil;
|
|
69 |
mAgendaUtil = NULL;
|
|
70 |
}
|
|
71 |
if (mViewer) {
|
|
72 |
mViewer->deleteLater();
|
|
73 |
mViewer = NULL;
|
|
74 |
}
|
|
75 |
|
|
76 |
OstTraceFunctionExit0( DUP1_CALENVIEWERSERVICE_CALENVIEWERSERVICE_EXIT );
|
|
77 |
}
|
|
78 |
|
|
79 |
// ----------------------------------------------------------------------------
|
|
80 |
// CalenViewerService::view
|
|
81 |
// Rest of the details are commented in the header
|
|
82 |
// ----------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
bool CalenViewerService::view(QString file)
|
|
85 |
{
|
|
86 |
OstTraceFunctionEntry0( CALENVIEWERSERVICE_VIEW_ENTRY );
|
|
87 |
|
|
88 |
// Set the request as asynchronous
|
|
89 |
mAsyncReqIndex = setCurrentRequestAsync();
|
|
90 |
|
|
91 |
// Store the file name
|
|
92 |
mFileName = file;
|
|
93 |
|
|
94 |
if (mEntryViewReady) {
|
|
95 |
// View the entry only after the entry view
|
|
96 |
// is completely instantiated
|
|
97 |
viewEntry();
|
|
98 |
} else {
|
|
99 |
OstTrace0( TRACE_NORMAL, DUP1_CALENVIEWERSERVICE_VIEW, "Entry view not ready" );
|
|
100 |
// Mark the flag to indicate that after the
|
|
101 |
// entry view is ready, the file must be opened
|
|
102 |
mWaitingForEntryViewReady = true;
|
|
103 |
}
|
|
104 |
|
|
105 |
OstTraceFunctionExit0( CALENVIEWERSERVICE_VIEW_EXIT );
|
|
106 |
|
|
107 |
return true;
|
|
108 |
}
|
|
109 |
|
|
110 |
// ----------------------------------------------------------------------------
|
|
111 |
// CalenViewerService::view
|
|
112 |
// Rest of the details are commented in the header
|
|
113 |
// ----------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
bool CalenViewerService::view(XQSharableFile sf)
|
|
116 |
{
|
|
117 |
OstTraceFunctionEntry0( DUP1_CALENVIEWERSERVICE_VIEW_ENTRY );
|
|
118 |
|
|
119 |
Q_UNUSED(sf);
|
|
120 |
|
|
121 |
OstTrace0( TRACE_NORMAL, DUP2_CALENVIEWERSERVICE_VIEW, "Functionality not yet present" );
|
|
122 |
|
|
123 |
// Set the request as asynchronous
|
|
124 |
mAsyncReqIndex = setCurrentRequestAsync();
|
|
125 |
|
|
126 |
// TODO: Convert RFile to QFile handle and view
|
|
127 |
// Support for this has to come from Qt
|
|
128 |
complete(false);
|
|
129 |
|
|
130 |
OstTraceFunctionExit0( DUP1_CALENVIEWERSERVICE_VIEW_EXIT );
|
|
131 |
|
|
132 |
return true;
|
|
133 |
}
|
|
134 |
|
|
135 |
// ----------------------------------------------------------------------------
|
|
136 |
// CalenViewerService::entryViewReady
|
|
137 |
// Rest of the details are commented in the header
|
|
138 |
// ----------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
void CalenViewerService::entryViewReady(int error)
|
|
141 |
{
|
|
142 |
OstTraceFunctionEntry0( CALENVIEWERSERVICE_ENTRYVIEWREADY_ENTRY );
|
|
143 |
|
|
144 |
Q_UNUSED(error);
|
|
145 |
|
|
146 |
mEntryViewReady = true;
|
|
147 |
|
|
148 |
// Now open the file for viewing
|
|
149 |
if (mWaitingForEntryViewReady) {
|
|
150 |
// If control comes here, it means that
|
|
151 |
// the request to view the file has come before
|
|
152 |
// the entry view is ready. So view the entry now
|
|
153 |
viewEntry();
|
|
154 |
}
|
|
155 |
|
|
156 |
OstTraceFunctionExit0( CALENVIEWERSERVICE_ENTRYVIEWREADY_EXIT );
|
|
157 |
}
|
|
158 |
|
|
159 |
// ----------------------------------------------------------------------------
|
|
160 |
// CalenViewerService::handleClientDisconnected
|
|
161 |
// Rest of the details are commented in the header
|
|
162 |
// ----------------------------------------------------------------------------
|
|
163 |
//
|
|
164 |
void CalenViewerService::handleClientDisconnected()
|
|
165 |
{
|
|
166 |
OstTraceFunctionEntry0( CALENVIEWERSERVICE_HANDLECLIENTDISCONNECTED_ENTRY );
|
|
167 |
|
|
168 |
// Just exit the application
|
|
169 |
qApp->quit();
|
|
170 |
|
|
171 |
OstTraceFunctionExit0( CALENVIEWERSERVICE_HANDLECLIENTDISCONNECTED_EXIT );
|
|
172 |
}
|
|
173 |
|
|
174 |
// ----------------------------------------------------------------------------
|
|
175 |
// CalenViewerService::viewEntry
|
|
176 |
// Rest of the details are commented in the header
|
|
177 |
// ----------------------------------------------------------------------------
|
|
178 |
//
|
|
179 |
void CalenViewerService::viewEntry()
|
|
180 |
{
|
|
181 |
OstTraceFunctionEntry0( CALENVIEWERSERVICE_VIEWENTRY_ENTRY );
|
|
182 |
|
|
183 |
if (mFileName.isEmpty()) {
|
|
184 |
// Invalid file name or viewer is already being viewed
|
|
185 |
OstTrace0( TRACE_NORMAL, CALENVIEWERSERVICE_VIEWENTRY, "Filename is empty" );
|
|
186 |
|
|
187 |
// Just exit the application
|
|
188 |
qApp->quit();
|
|
189 |
|
|
190 |
return;
|
|
191 |
}
|
|
192 |
QFile fileHandle(mFileName);
|
|
193 |
|
|
194 |
if (!mViewer) {
|
|
195 |
mViewer = new AgendaEventViewer(mAgendaUtil, this);
|
|
196 |
connect(mViewer, SIGNAL(viewingCompleted()), qApp, SLOT(quit()));
|
|
197 |
}
|
|
198 |
|
|
199 |
// TODO : No indication if the parsing of vcal/ical is successful
|
|
200 |
mViewer->view(fileHandle, AgendaEventViewer::ActionSave);
|
|
201 |
complete(true);
|
|
202 |
|
|
203 |
OstTraceFunctionExit0( DUP1_CALENVIEWERSERVICE_VIEWENTRY_EXIT );
|
|
204 |
}
|
|
205 |
|
|
206 |
// ----------------------------------------------------------------------------
|
|
207 |
// CalenViewerService::complete
|
|
208 |
// Rest of the details are commented in the header
|
|
209 |
// ----------------------------------------------------------------------------
|
|
210 |
//
|
|
211 |
void CalenViewerService::complete(bool ok)
|
|
212 |
{
|
|
213 |
OstTraceFunctionEntry0( CALENVIEWERSERVICE_COMPLETE_ENTRY );
|
|
214 |
|
|
215 |
// TODO : Pass return value based on whether parsing
|
|
216 |
// of vcal or ical is successful or not
|
|
217 |
completeRequest(mAsyncReqIndex, ok);
|
|
218 |
|
|
219 |
OstTraceFunctionExit0( CALENVIEWERSERVICE_COMPLETE_EXIT );
|
|
220 |
}
|
|
221 |
|
|
222 |
// End of file --Don't remove this.
|
|
223 |
|