diff -r 786160610b4d -r afcd8e6d025b ginebra2/emulator/FileService.cpp --- a/ginebra2/emulator/FileService.cpp Wed Sep 01 13:56:21 2010 -0400 +++ b/ginebra2/emulator/FileService.cpp Fri Sep 17 12:11:40 2010 -0400 @@ -19,8 +19,6 @@ * */ -#include - #include "FileService.h" #include #include "webpagecontroller.h" @@ -30,14 +28,12 @@ FileService::FileService(QObject* parent) : XQServiceProvider(QLatin1String("NokiaBrowser.com.nokia.symbian.IFileView"), parent) { - qDebug("FileService::FileService"); publishAll(); } FileService::~FileService() { - qDebug("FileService::~FileService"); } @@ -45,11 +41,14 @@ // indicates the completion of the request. void FileService::completeAsyncRequest(bool ok) { - qDebug() << "FileService::complete: ok=" << ok; - // Complete all - foreach (quint32 reqId, mAsyncReqIds) { - qDebug("FileService::complete %d", reqId); - completeRequest(reqId, QVariant(ok)); + // completing all requests on current page load not technically correct but + // not required to service more than one request at a time + foreach (int reqId, mAsyncReqIds) { + if (!completeRequest(reqId, QVariant(ok))) { + // failed to complete request + RemoveAsyncReqId(); + } + // else remove async request ID on returnValueDelivered() signal } // disconnect slots connected to WebPageController signals @@ -61,17 +60,18 @@ bool FileService::view(QString file) { XQRequestInfo info = requestInfo(); - qDebug() << "FileService::view(" << file << ")"; if (!info.isSynchronous()) { - qDebug() << "FileService::view: Asynchronous Request"; + // not required to service more than one request at a time + // but just in case we use a map for request IDs + // request ID needed to complete request mAsyncReqIds.insertMulti(info.clientSecureId(), setCurrentRequestAsync()); safe_connect(this, SIGNAL(returnValueDelivered()), this, SLOT(handleAnswerDelivered())); safe_connect(this, SIGNAL(clientDisconnected()), this, SLOT(handleClientDisconnect())); safe_connect(WebPageController::getSingleton(), SIGNAL(loadFinished(bool)), this, SLOT(completeAsyncRequest(bool))); } - // Load specified file. + // Load specified file in current window. file.prepend("file:///"); // create full URL from file path WebPageController::getSingleton()->loadInitialUrlFromOtherApp(file); @@ -79,16 +79,12 @@ } -// Handles clientDisconnected signal emitted by base class, XQServiceProvider. -// It's emitted if client accessing a service application terminates. -void FileService::handleClientDisconnect() +// Removes request from asynchronous IDs. This should be done after request +// handled or on client disconnect. +void FileService::RemoveAsyncReqId() { XQRequestInfo info = requestInfo(); - // Output some debug info. - qDebug("FileService::handleClientDisconnect"); - qDebug("\tRequest info: id=%d,sid=%X,vid=%X", info.id(),info.clientSecureId(), info.clientVendorId()); - // Remove request from asynchronous IDs. mAsyncReqIds.remove(info.clientSecureId()); @@ -99,26 +95,20 @@ } } +// Handles clientDisconnected signal emitted by base class, XQServiceProvider. +// It's emitted if client accessing a service application terminates. +void FileService::handleClientDisconnect() +{ + RemoveAsyncReqId(); +} + // Handles returnValueDelivered signal emitted by base class, XQServiceProvider. // It's emitted when asynchronous request has been completed and its return // value has been delivered to the service client. void FileService::handleAnswerDelivered() { - XQRequestInfo info = requestInfo(); - - // Output some debug info. - qDebug("FileService::handleAnswerDelivered"); - qDebug("\tRequest info: sid=%X,vid=%X", info.clientSecureId(), info.clientVendorId()); - - // Done servicing request, remove it from asynchronous IDs. - mAsyncReqIds.remove(info.clientSecureId()); - - // Disconnect signal from this slot if no more asynchronous requests. - if (!asyncAnswer()) { - // Disconnect all signals from this object to slots in this object. - disconnect(this, 0, this, 0); - } + RemoveAsyncReqId(); }