--- a/logsui/logsapp/inc/logsbaseview.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/inc/logsbaseview.h Wed Aug 18 09:49:12 2010 +0300
@@ -45,6 +45,7 @@
{
Q_OBJECT
friend class UT_LogsBaseView;
+ friend class UT_LogsViewManager;
public:
@@ -68,7 +69,7 @@
virtual QVariant loadActivity(
const QString& activityId, QDataStream& serializedActivity, QVariantHash& metaData);
virtual bool matchWithActivityId(const QString& activityId);
-
+ virtual void cancelServiceRequest();
public slots:
@@ -80,7 +81,7 @@
void exitAllowed();
protected slots:
-
+
virtual void handleBackSoftkey();
virtual void dialpadOpened();
virtual void dialpadClosed();
@@ -108,7 +109,7 @@
void showCallDetails();
void deleteEvent();
- virtual void deleteEventOkAnswer();
+ virtual void deleteEventAnswer(int action);
void videoCallToCurrentNum();
void sendMessageToCurrentNum();
@@ -180,9 +181,6 @@
void addViewSwitchingEffects();
void toggleActionAvailability( HbAction* action, bool available );
- void askConfirmation( QString heading , QString text, QObject* receiver,
- const char* okSlot = 0, const char* cancelSlot = 0 );
-
void updateContactSearchAction();
bool isContactSearchEnabled() const;
bool isContactSearchPermanentlyDisabled() const;
--- a/logsui/logsapp/inc/logsdefs.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/inc/logsdefs.h Wed Aug 18 09:49:12 2010 +0300
@@ -88,10 +88,17 @@
const char logsInterfaceName[] = "com.nokia.symbian.ILogsView";
const char logsOperationName[] = "show(QVariantMap)";
+//param names below are deprecated
const char logsViewIndexParam[] = "view_index";
const char logsShowDialpadParam[] = "show_dialpad";
const char logsDialpadTextParam[] = "dialpad_text";
+//new params
+const char logsViewIndexParamNew[] = "ViewIndex";
+const char logsShowDialpadParamNew[] = "ShowDialpad";
+const char logsDialpadTextParamNew[] = "DialpadText";
+
+
// Activity related constants
const char logsActivityIdViewRecent[] = "LogsViewRecent";
const char logsActivityIdViewCalled[] = "LogsViewCalled";
--- a/logsui/logsapp/inc/logsdetailsview.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/inc/logsdetailsview.h Wed Aug 18 09:49:12 2010 +0300
@@ -60,7 +60,7 @@
//from LogsBaseView
virtual void handleBackSoftkey();
- virtual void deleteEventOkAnswer();
+ virtual void deleteEventAnswer(int action);
private: // from LogsBaseView
--- a/logsui/logsapp/inc/logsrecentcallsview.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/inc/logsrecentcallsview.h Wed Aug 18 09:49:12 2010 +0300
@@ -73,7 +73,7 @@
private slots:
void clearList();
- void clearListOkAnswer();
+ void clearListAnswer(int action);
void toggleContactSearch();
void updateView(LogsServices::LogsView view);
void leftFlick();
--- a/logsui/logsapp/inc/logsservicehandler.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/inc/logsservicehandler.h Wed Aug 18 09:49:12 2010 +0300
@@ -20,14 +20,12 @@
#include <xqserviceprovider.h>
#include <logsservices.h>
-class LogsMainWindow;
-
class LogsServiceHandler : public XQServiceProvider
{
Q_OBJECT
public:
- explicit LogsServiceHandler(LogsMainWindow& mainWindow);
+ explicit LogsServiceHandler();
~LogsServiceHandler();
public slots:
@@ -43,9 +41,9 @@
bool isStartedUsingService() const;
+
private:
- LogsMainWindow& mMainWindow;
bool mIsAppStartedUsingService;
private:
--- a/logsui/logsapp/inc/logsservicehandlerold.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/inc/logsservicehandlerold.h Wed Aug 18 09:49:12 2010 +0300
@@ -20,13 +20,11 @@
#include <xqserviceprovider.h>
#include <logsservices.h>
-class LogsMainWindow;
-
class LogsServiceHandlerOld : public XQServiceProvider
{
Q_OBJECT
public:
- explicit LogsServiceHandlerOld(LogsMainWindow& mainWindow);
+ explicit LogsServiceHandlerOld();
~LogsServiceHandlerOld();
public slots:
@@ -43,7 +41,6 @@
bool isStartedUsingService() const;
private:
- LogsMainWindow& mMainWindow;
bool mIsAppStartedUsingService;
private:
--- a/logsui/logsapp/inc/logsviewmanager.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/inc/logsviewmanager.h Wed Aug 18 09:49:12 2010 +0300
@@ -68,12 +68,14 @@
virtual HbMainWindow& mainWindow();
virtual void exitApplication();
+
private slots:
void proceedExit();
void handleOrientationChanged();
void completeViewActivation();
- void saveActivity();
+ void saveActivity();
+ void closeEmbeddedApplication();
private:
--- a/logsui/logsapp/resources/logs.docml Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/resources/logs.docml Wed Aug 18 09:49:12 2010 +0300
@@ -6,7 +6,7 @@
<bool name="collapsable" value="FALSE"/>
<string name="heading" value=" "/>
</widget>
- <string locid="Dialer" name="title" value="dialler"/>
+ <string locid="txt_dial_title_dialer" name="title" value="Dialer"/>
</widget>
<metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
<uistate name="Common ui state" sections="#common"/>
--- a/logsui/logsapp/src/logsbaseview.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/src/logsbaseview.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -45,6 +45,7 @@
#include <hbactivitymanager.h>
#include <hbmodeliterator.h>
#include <hbscrollbar.h>
+#include <hbstringutil.h>
Q_DECLARE_METATYPE(LogsCall*)
Q_DECLARE_METATYPE(LogsMessage*)
@@ -229,6 +230,19 @@
//
// -----------------------------------------------------------------------------
//
+void LogsBaseView::cancelServiceRequest()
+{
+ LOGS_QDEBUG( "logs [UI] -> LogsBaseView::cancelServiceRequest()" );
+ if (mContact) {
+ mContact->cancelServiceRequest();
+ }
+ LOGS_QDEBUG( "logs [UI] <- LogsBaseView::cancelServiceRequest()" );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
void LogsBaseView::notSupported()
{
HbMessageBox* messageBox = new HbMessageBox(QString("Not supported"));
@@ -643,7 +657,9 @@
bool called = false;
if ( isDialpadInput() ){
// Call to inputted number
- LogsCall::callToNumber( callType, mDialpad->editor().text() );
+ QString phoneNumber =
+ HbStringUtil::convertDigitsTo(mDialpad->editor().text(), WesternDigit);
+ LogsCall::callToNumber( callType, phoneNumber );
called = true;
}
LOGS_QDEBUG_2( "logs [UI] <- LogsBaseView::tryCallToDialpadNumber(), called",
@@ -921,10 +937,12 @@
{
LOGS_QDEBUG( "logs [UI] -> LogsBaseView::deleteEvent()" );
if ( mDetailsModel ) {
- askConfirmation(hbTrId("txt_dialer_ui_title_delete_event"),
+ HbMessageBox::question(
hbTrId("txt_dialer_info_call_event_will_be_removed_from"),
this,
- SLOT(deleteEventOkAnswer()));
+ SLOT(deleteEventAnswer(int)),
+ HbMessageBox::Ok | HbMessageBox::Cancel,
+ new HbLabel(hbTrId("txt_dialer_ui_title_delete_event")));
}
LOGS_QDEBUG( "logs [UI] <- LogsBaseView::deleteEvent()" );
}
@@ -933,13 +951,13 @@
//
// -----------------------------------------------------------------------------
//
-void LogsBaseView::deleteEventOkAnswer()
+void LogsBaseView::deleteEventAnswer(int action)
{
- LOGS_QDEBUG( "logs [UI] -> LogsBaseView::deleteEventOkAnswer()" );
- if (mDetailsModel) {
+ LOGS_QDEBUG( "logs [UI] -> LogsBaseView::deleteEventAnswer()" );
+ if ((action == HbMessageBox::Ok) && mDetailsModel) {
mDetailsModel->clearEvent();
}
- LOGS_QDEBUG( "logs [UI] <- LogsBaseView::deleteEventOkAnswer()" );
+ LOGS_QDEBUG( "logs [UI] <- LogsBaseView::deleteEventAnswer()" );
}
// -----------------------------------------------------------------------------
@@ -1071,37 +1089,6 @@
//
// -----------------------------------------------------------------------------
//
-void LogsBaseView::askConfirmation( QString heading , QString text,
- QObject* receiver, const char* okSlot, const char* cancelSlot )
-{
- LOGS_QDEBUG( "logs [UI] -> LogsBaseView::askConfirmation()" );
- HbMessageBox* note = new HbMessageBox(text, HbMessageBox::MessageTypeQuestion);
- note->setAttribute(Qt::WA_DeleteOnClose);
- note->setHeadingWidget(new HbLabel(heading));
- note->setDismissPolicy(HbPopup::TapOutside);
-
- if (note->actions().count() > 0 && note->actions().at(0)) {
- note->actions().at(0)->setText(hbTrId("txt_common_button_ok"));
-
- if (receiver && okSlot) {
- connect(note->actions().at(0), SIGNAL(triggered()), receiver, okSlot);
- }
- }
- if (note->actions().count() > 1 && note->actions().at(1)) {
- note->actions().at(1)->setText(hbTrId("txt_common_button_cancel"));
-
- if (receiver && cancelSlot) {
- connect(note->actions().at(1), SIGNAL(triggered()), receiver, cancelSlot);
- }
- }
- note->open();
- LOGS_QDEBUG( "logs [UI] <- LogsBaseView::askConfirmation()" );
-}
-
-// -----------------------------------------------------------------------------
-//
-// -----------------------------------------------------------------------------
-//
void LogsBaseView::updateContactSearchAction()
{
LOGS_QDEBUG( "logs [UI] -> LogsBaseView::updateContactSearchAction()" );
--- a/logsui/logsapp/src/logsdetailsview.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/src/logsdetailsview.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -248,14 +248,14 @@
//
// -----------------------------------------------------------------------------
//
-void LogsDetailsView::deleteEventOkAnswer()
+void LogsDetailsView::deleteEventAnswer(int action)
{
- LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::deleteEventOkAnswer()" );
- if (mDetailsModel) {
- mDetailsModel->clearEvent();
+ LOGS_QDEBUG( "logs [UI] -> LogsDetailsView::deleteEventAnswer()" );
+ LogsBaseView::deleteEventAnswer(action);
+ if (action == HbMessageBox::Ok) {
handleBackSoftkey();
}
- LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::deleteEventOkAnswer()" );
+ LOGS_QDEBUG( "logs [UI] <- LogsDetailsView::deleteEventAnswer()" );
}
// -----------------------------------------------------------------------------
--- a/logsui/logsapp/src/logsmainwindow.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/src/logsmainwindow.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -55,11 +55,9 @@
void LogsMainWindow::bringAppToForeground()
{
LOGS_QDEBUG( "logs [UI] -> LogsMainWindow::bringAppToForeground" );
- if ( !mForeground ){
- mForeground = true;
- show();
- raise();
- }
+ mForeground = true;
+ show();
+ raise();
LOGS_QDEBUG( "logs [UI] <- LogsMainWindow::bringAppToForeground" );
}
--- a/logsui/logsapp/src/logsrecentcallsview.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/src/logsrecentcallsview.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -40,9 +40,9 @@
#include <dialpad.h>
#include <hblineedit.h>
#include <hbgroupbox.h>
-#include <hbmessagebox.h>
#include <hbmainwindow.h>
#include <hbswipegesture.h>
+#include <hbmessagebox.h>
#include <QTimer>
#include <hbactivitymanager.h>
@@ -316,23 +316,24 @@
{
LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::clearList()->" );
if ( mFilter ) {
- askConfirmation(hbTrId("txt_dialer_ui_title_clear_list"),
+ HbMessageBox::question(
hbTrId("txt_dialer_ui_info_all_call_events_will_be_remo"),
this,
- SLOT(clearListOkAnswer()));
-
+ SLOT(clearListAnswer(int)),
+ HbMessageBox::Ok | HbMessageBox::Cancel,
+ new HbLabel(hbTrId("txt_dialer_ui_title_clear_list")));
}
LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::clearList()<-" );
}
// -----------------------------------------------------------------------------
-// LogsRecentCallsView::clearListOkAnswer
+// LogsRecentCallsView::clearListAnswer
// -----------------------------------------------------------------------------
//
-void LogsRecentCallsView::clearListOkAnswer()
+void LogsRecentCallsView::clearListAnswer(int action)
{
- LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::clearListOkAnswer()" );
- if (mFilter) {
+ LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::clearListAnswer()" );
+ if ((action == HbMessageBox::Ok) && mFilter) {
mModel->clearList( mFilter->clearType() );
}
LOGS_QDEBUG( "logs [UI] <- LogsRecentCallsView::clearListAnswer()" );
--- a/logsui/logsapp/src/logsservicehandler.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/src/logsservicehandler.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -18,7 +18,6 @@
#include "logsservicehandler.h"
#include "logslogger.h"
#include "logsdefs.h"
-#include "logsmainwindow.h"
#include <xqserviceutil.h>
//SYSTEM
@@ -27,9 +26,8 @@
// LogsServiceHandler::LogsServiceHandler
// -----------------------------------------------------------------------------
//
-LogsServiceHandler::LogsServiceHandler(LogsMainWindow& mainWindow)
- : XQServiceProvider(QLatin1String("logs.com.nokia.symbian.ILogsView"),0),
- mMainWindow(mainWindow)
+LogsServiceHandler::LogsServiceHandler()
+ : XQServiceProvider(QLatin1String("logs.com.nokia.symbian.ILogsView"),0)
{
LOGS_QDEBUG( "logs [UI] -> LogsServiceHandler::LogsServiceHandler(), ILogsView" )
@@ -63,11 +61,24 @@
QVariant(false)).toBool();
QString dialpadText = params.value(logsDialpadTextParam,
QVariant(QString())).toString();
-
+
LOGS_QDEBUG_2( "logs [UI] activatedView:", activatedView )
LOGS_QDEBUG_2( "logs [UI] showDialpad:", showDialpad )
LOGS_QDEBUG_2( "logs [UI] dialpadText:", dialpadText )
+ if (params.contains(logsViewIndexParamNew)) {
+ activatedView = params.value(logsViewIndexParamNew).toInt();
+ LOGS_QDEBUG_2( "logs [UI] new activatedView:", activatedView )
+ }
+ if (params.contains(logsShowDialpadParamNew)) {
+ showDialpad = params.value(logsShowDialpadParamNew).toBool();
+ LOGS_QDEBUG_2( "logs [UI] new showDialpad:", showDialpad )
+ }
+ if (params.contains(logsDialpadTextParamNew)) {
+ dialpadText = params.value(logsDialpadTextParamNew).toString();
+ LOGS_QDEBUG_2( "logs [UI] new dialpadText:", dialpadText )
+ }
+
if ( activatedView < LogsServices::ViewAll ||
activatedView > LogsServices::ViewMissed ){
LOGS_QDEBUG( "logs [UI] <- LogsServiceHandler::show(), incorrect view" )
@@ -76,9 +87,6 @@
mIsAppStartedUsingService = true;
- LOGS_QDEBUG( "logs [UI] Bring app to foreground" )
- mMainWindow.bringAppToForeground();
-
if (!dialpadText.isEmpty()) {
emit activateView(dialpadText);
} else {
--- a/logsui/logsapp/src/logsservicehandlerold.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/src/logsservicehandlerold.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -17,7 +17,6 @@
//USER
#include "logsservicehandlerold.h"
#include "logslogger.h"
-#include "logsmainwindow.h"
#include <xqserviceutil.h>
//SYSTEM
@@ -25,12 +24,11 @@
// -----------------------------------------------------------------------------
// LogsServiceHandlerOld::LogsServiceHandlerOld
// deprecated Use "logs.com.nokia.symbian.ILogsView" interface and
-// "show(int,bool,QString)" operation instead
+// "show(QVariantMap)" operation instead
// -----------------------------------------------------------------------------
//
-LogsServiceHandlerOld::LogsServiceHandlerOld(LogsMainWindow& mainWindow)
- : XQServiceProvider(QLatin1String("com.nokia.services.logsservices.starter"),0),
- mMainWindow(mainWindow)
+LogsServiceHandlerOld::LogsServiceHandlerOld()
+ : XQServiceProvider(QLatin1String("com.nokia.services.logsservices.starter"),0)
{
LOGS_QDEBUG( "logs [UI] -> LogsServiceHandlerOld::LogsServiceHandlerOld()" )
@@ -66,9 +64,6 @@
}
mIsAppStartedUsingService = true;
- LOGS_QDEBUG( "logs [UI] Bring app to foreground" )
- mMainWindow.bringAppToForeground();
-
emit activateView((LogsServices::LogsView)activatedView, showDialpad, QString());
LOGS_QDEBUG( "logs [UI] <- LogsServiceHandlerOld::start()" )
@@ -92,9 +87,6 @@
}
mIsAppStartedUsingService = true;
- LOGS_QDEBUG( "logs [UI] Bring app to foreground" )
- mMainWindow.bringAppToForeground();
-
emit activateView(dialpadText);
LOGS_QDEBUG( "logs [UI] <- LogsServiceHandlerOld::startWithNum()" )
--- a/logsui/logsapp/src/logsviewmanager.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/src/logsviewmanager.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -97,6 +97,8 @@
void LogsViewManager::changeRecentViewViaService(
LogsServices::LogsView view, bool showDialpad, QString dialpadText)
{
+ closeEmbeddedApplication();
+ mMainWindow.bringAppToForeground();
mComponentsRepository->dialpad()->editor().setText(dialpadText);
changeRecentView(view, showDialpad);
}
@@ -108,6 +110,8 @@
void LogsViewManager::changeMatchesViewViaService(QString dialpadText)
{
LOGS_QDEBUG( "logs [UI] -> LogsViewManager::changeMatchesView()" );
+ closeEmbeddedApplication();
+ mMainWindow.bringAppToForeground();
mComponentsRepository->dialpad()->editor().setText(dialpadText);
doActivateView(LogsMatchesViewId, true, QVariant());
LOGS_QDEBUG( "logs [UI] <- LogsViewManager::changeMatchesView()" );
@@ -311,7 +315,6 @@
}
QVariantHash metaData;
-
LOGS_QDEBUG( "logs [UI] Start taking screenshot" );
QImage* img = new QImage(mMainWindow.rect().size(), QImage::Format_ARGB32_Premultiplied);
QPainter p( img );
@@ -460,3 +463,16 @@
}
return newView;
}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void LogsViewManager::closeEmbeddedApplication()
+{
+ LOGS_QDEBUG( "logs [UI] -> LogsViewManager::closeEmbeddedApplication()" );
+ if (mViewStack.count()) {
+ mViewStack.at(0)->cancelServiceRequest();
+ }
+ LOGS_QDEBUG( "logs [UI] <- LogsViewManager::closeEmbeddedApplication()" );
+}
--- a/logsui/logsapp/src/main.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/src/main.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -33,7 +33,7 @@
{
LOGS_QDEBUG( "logs [UI] -> main()" )
- HbApplication app(argc, argv, Hb::NoSplash);
+ HbApplication app(argc, argv);
LogsMainWindow window;
HbTranslator translator("dialer");
translator.loadCommon();
@@ -44,8 +44,8 @@
// Servicehandler cannot be created before HbApplication creation.
// This can cause problem of service request not coming through if
// HbApplication creation takes long time.
- LogsServiceHandler service(window);
- LogsServiceHandlerOld serviceOld(window);
+ LogsServiceHandler service;
+ LogsServiceHandlerOld serviceOld;
LogsViewManager viewManager(window, service, serviceOld);
// Don't show window yet as app might be started at background
--- a/logsui/logsapp/tsrc/ut_logsapp/inc/ut_logsbaseview.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/inc/ut_logsbaseview.h Wed Aug 18 09:49:12 2010 +0300
@@ -84,13 +84,13 @@
void testAddToContacts();
void testSendMessageToCurrentNum();
void testDeleteEvent();
- void testDeleteEventOkAnswer();
- void testAskConfirmation();
+ void testDeleteEventAnswer();
void testMatchWithActivityId();
void testSaveActivity();
void testLoadActivity();
void testClearActivity();
void testEnsureListPositioning();
+ void testCancelServiceRequest();
private:
--- a/logsui/logsapp/tsrc/ut_logsapp/inc/ut_logsdetailsview.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/inc/ut_logsdetailsview.h Wed Aug 18 09:49:12 2010 +0300
@@ -58,7 +58,7 @@
void testInitiateVoiceCall();
void testInitiateVideoCall();
void testUpdateMenu();
- void testDeleteEventOkAnswer();
+ void testDeleteEventAnswer();
void testChangeFilter();
void testContactActionCompleted();
void testModel();
--- a/logsui/logsapp/tsrc/ut_logsapp/inc/ut_logsrecentcallsview.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/inc/ut_logsrecentcallsview.h Wed Aug 18 09:49:12 2010 +0300
@@ -78,7 +78,7 @@
void testGetListItemTextWidth();
void testDialpadClosed();
void testClearList();
- void testClearListOkAnswer();
+ void testClearListAnswer();
void testIsExitAllowed();
void testContactSearch();
void testDialpadOpened();
--- a/logsui/logsapp/tsrc/ut_logsapp/logsengine_stub/logscall.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/logsengine_stub/logscall.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -25,6 +25,7 @@
bool logsCallToNumberCalled = false;
QString logsLastCalledFunction = QString();
+QString logsLastCalledNumber = QString();
bool LogsCall::isCallToNumberCalled()
{
@@ -36,10 +37,16 @@
return logsLastCalledFunction;
}
+QString LogsCall::lastCalledNumber()
+{
+ return logsLastCalledNumber;
+}
+
void LogsCall::resetTestData()
{
logsCallToNumberCalled = false;
logsLastCalledFunction = QString();
+ logsLastCalledNumber = QString();
}
// -----------------------------------------------------------------------------
@@ -93,6 +100,7 @@
Q_UNUSED(serviceId);
logsCallToNumberCalled = true;
logsLastCalledFunction = QString("callToNumber");
+ logsLastCalledNumber = number;
}
// ----------------------------------------------------------------------------
--- a/logsui/logsapp/tsrc/ut_logsapp/logsengine_stub/logscall.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/logsengine_stub/logscall.h Wed Aug 18 09:49:12 2010 +0300
@@ -75,6 +75,7 @@
static bool isCallToNumberCalled();
static QString lastCalledFunction();
+ static QString lastCalledNumber();
static void resetTestData();
};
--- a/logsui/logsapp/tsrc/ut_logsapp/logsengine_stub/logscontact.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/logsengine_stub/logscontact.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -21,6 +21,7 @@
//SYSTEM
static LogsContact::RequestType logstTestRequestType = LogsContact::TypeLogsContactSave;
+bool LogsContact::mServiceRequestCanceled = false;
// -----------------------------------------------------------------------------
//
@@ -89,4 +90,10 @@
void LogsContact::reset()
{
logstTestRequestType = LogsContact::TypeLogsContactSave;
+ mServiceRequestCanceled = false;
}
+
+void LogsContact::cancelServiceRequest()
+{
+ mServiceRequestCanceled = true;
+}
--- a/logsui/logsapp/tsrc/ut_logsapp/logsengine_stub/logscontact.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/logsengine_stub/logscontact.h Wed Aug 18 09:49:12 2010 +0300
@@ -73,6 +73,8 @@
*/
bool updateExisting();
+ void cancelServiceRequest();
+
signals:
void openCompleted(bool modified);
@@ -84,7 +86,7 @@
static void reset();
QString mNumber;
-
+ static bool mServiceRequestCanceled;
};
#endif // LOGSCONTACT_H
--- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsbaseview.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsbaseview.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -37,6 +37,7 @@
#include <hblineedit.h>
#include <hblistviewitem.h>
#include <hblistview.h>
+#include <hbmessagebox.h>
#include <QStringListModel>
#include <hbapplication.h>
#include <hbactivitymanager.h>
@@ -547,36 +548,27 @@
QVERIFY( HbStubHelper::dialogShown() );
}
-void UT_LogsBaseView::testDeleteEventOkAnswer()
+void UT_LogsBaseView::testDeleteEventAnswer()
{
// No model, nothing happens
QVERIFY( LogsDetailsModel::mLastCallName.isEmpty() );
QVERIFY( !mBaseView->mDetailsModel );
- mBaseView->deleteEventOkAnswer();
+ mBaseView->deleteEventAnswer(HbMessageBox::Ok);
QVERIFY( LogsDetailsModel::mLastCallName.isEmpty() );
+ // Model exists, cancel button pressed
+ LogsDetailsModel* model = new LogsDetailsModel();
+ mBaseView->mDetailsModel = model;
+ mBaseView->deleteEventAnswer(HbMessageBox::Cancel);
+ QVERIFY( LogsDetailsModel::mLastCallName.isEmpty() );
+
// Model exists, call to delete event made and view is closed
mViewManager->reset();
- LogsDetailsModel* model = new LogsDetailsModel();
- mBaseView->mDetailsModel = model;
- mBaseView->deleteEventOkAnswer();
+ mBaseView->deleteEventAnswer(HbMessageBox::Ok);
QVERIFY( LogsDetailsModel::mLastCallName == QLatin1String("clearEvent") );
QVERIFY( !mViewManager->mPreviousActivated );
}
-void UT_LogsBaseView::testAskConfirmation()
-{
- // No receiver and slots specified
- mBaseView->askConfirmation(QLatin1String("heading"), QLatin1String("text"), 0);
- QVERIFY( HbStubHelper::dialogShown() );
-
- // Receiver and slots specified
- HbStubHelper::reset();
- mBaseView->askConfirmation(QLatin1String("heading"), QLatin1String("text"), this,
- SLOT("dummy()"), SLOT("dummy()"));
- QVERIFY( HbStubHelper::dialogShown() );
-}
-
void UT_LogsBaseView::testMatchWithActivityId()
{
QVERIFY( !mBaseView->matchWithActivityId(QString("")) );
@@ -683,6 +675,19 @@
delete HbStubHelper::listItems().takeLast();
mBaseView->ensureListPositioning(list);
QVERIFY( HbStubHelper::listEnsureVisibleCalled() );
- QVERIFY( HbStubHelper::listScrollToCalled() );
+ // TODO: stub does not work due it uses virtual table inside hbcore. Whole
+ // list should be stubbed.
+ //QVERIFY( HbStubHelper::listScrollToCalled() );
+}
+void UT_LogsBaseView::testCancelServiceRequest()
+{
+ QVERIFY( !mBaseView->mContact );
+ QVERIFY( !LogsContact::mServiceRequestCanceled );
+ mBaseView->cancelServiceRequest();
+ QVERIFY( !LogsContact::mServiceRequestCanceled );
+
+ mBaseView->mContact = new LogsContact();
+ mBaseView->cancelServiceRequest();
+ QVERIFY( LogsContact::mServiceRequestCanceled );
}
--- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsdetailsview.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsdetailsview.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -222,19 +222,23 @@
LogsContact::reset();
}
-void UT_LogsDetailsView::testDeleteEventOkAnswer()
+void UT_LogsDetailsView::testDeleteEventAnswer()
{
// No model, nothing happens
QVERIFY( LogsDetailsModel::mLastCallName.isEmpty() );
QVERIFY( !mDetailsView->mDetailsModel );
- mDetailsView->deleteEventOkAnswer();
+ mDetailsView->deleteEventAnswer(HbMessageBox::Ok);
+ QVERIFY( LogsDetailsModel::mLastCallName.isEmpty() );
+
+ // Model exists, cancel button pressed
+ LogsDetailsModel* model = new LogsDetailsModel();
+ mDetailsView->mDetailsModel = model;
+ mDetailsView->deleteEventAnswer(HbMessageBox::Cancel);
QVERIFY( LogsDetailsModel::mLastCallName.isEmpty() );
// Model exists, call to delete event made and view is closed
mViewManager->reset();
- LogsDetailsModel* model = new LogsDetailsModel();
- mDetailsView->mDetailsModel = model;
- mDetailsView->deleteEventOkAnswer();
+ mDetailsView->deleteEventAnswer(HbMessageBox::Ok);
QVERIFY( LogsDetailsModel::mLastCallName == QLatin1String("clearEvent") );
QVERIFY( mViewManager->mPreviousActivated );
}
--- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsmainwindow.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsmainwindow.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -79,10 +79,10 @@
QVERIFY( HbStubHelper::isWidgetRaised() );
QVERIFY( mMainWindow->isForeground() );
- // Subsequent call does not raise more
+ // Subsequent call raise tries to raise regardless of current state
HbStubHelper::reset();
mMainWindow->bringAppToForeground();
- QVERIFY( !HbStubHelper::isWidgetRaised() );
+ QVERIFY( HbStubHelper::isWidgetRaised() );
QVERIFY( mMainWindow->isForeground() );
}
--- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsrecentcallsview.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsrecentcallsview.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -319,8 +319,18 @@
view->mDialpad->editor().setText( dial );
view->callKeyPressed();
QVERIFY( LogsCall::isCallToNumberCalled() );
+ QCOMPARE( LogsCall::lastCalledNumber(), dial );
QVERIFY( LogsCall::lastCalledFunction() != "initiateCallback" );
+ // Make sure that SS numbers are left untouched when calling
+ LogsCall::resetTestData();
+ dial = "*#7370#";
+ view->mDialpad->editor().setText( dial );
+ view->callKeyPressed();
+ QVERIFY( LogsCall::isCallToNumberCalled() );
+ QCOMPARE( LogsCall::lastCalledNumber(), dial );
+ LogsCall::resetTestData();
+
// Dialpad closed but contains text, call to first item in the list
LogsCall::resetTestData();
view->mDialpad->mIsOpen = false;
@@ -770,16 +780,21 @@
}
-void UT_LogsRecentCallsView::testClearListOkAnswer()
+void UT_LogsRecentCallsView::testClearListAnswer()
{
// No filter ,list is not cleared
mRecentCallsView->mModel->mIsCleared = false;
- mRecentCallsView->clearListOkAnswer();
+ mRecentCallsView->clearListAnswer(HbMessageBox::Ok);
+ QVERIFY( !mRecentCallsView->mModel->mIsCleared );
+
+ // Filter exists, cancel button pressed
+ mRecentCallsView->mFilter = new LogsFilter(LogsFilter::Missed);
+ mRecentCallsView->clearListAnswer(HbMessageBox::Cancel);
QVERIFY( !mRecentCallsView->mModel->mIsCleared );
+
// Filter exists, list is cleared
- mRecentCallsView->mFilter = new LogsFilter( LogsFilter::Missed );
- mRecentCallsView->clearListOkAnswer();
+ mRecentCallsView->clearListAnswer(HbMessageBox::Ok);
QVERIFY( mRecentCallsView->mModel->mIsCleared );
}
--- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsservicehandler.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsservicehandler.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -44,8 +44,8 @@
void UT_LogsServiceHandler::init()
{
mMainWindow = new LogsMainWindow();
- mService = new LogsServiceHandler(*mMainWindow);
- mServiceOld = new LogsServiceHandlerOld(*mMainWindow);
+ mService = new LogsServiceHandler();
+ mServiceOld = new LogsServiceHandlerOld();
mLogsViewManager = new LogsViewManager(*mMainWindow, *mService, *mServiceOld);
@@ -77,11 +77,11 @@
QtHighwayStubHelper::setIsService(true);
- LogsServiceHandler serviceHandler(*mMainWindow);
+ LogsServiceHandler serviceHandler;
QVERIFY( serviceHandler.mIsAppStartedUsingService );
QVERIFY( serviceHandler.isStartedUsingService() );
- LogsServiceHandlerOld serviceHandlerOld(*mMainWindow);
+ LogsServiceHandlerOld serviceHandlerOld;
QVERIFY( serviceHandlerOld.mIsAppStartedUsingService );
QVERIFY( serviceHandlerOld.isStartedUsingService() );
}
@@ -96,13 +96,11 @@
QVERIFY( spy.count() == 0 );
// Correct view
- mServiceOld->mMainWindow.mForeground = false;
QVERIFY( mServiceOld->start( (int)LogsServices::ViewReceived, true ) == 0 );
QVERIFY( spy.count() == 1 );
LogsServices::LogsView view =
qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0));
QVERIFY( view == LogsServices::ViewReceived );
- QVERIFY( mServiceOld->mMainWindow.mForeground );
}
void UT_LogsServiceHandler::testStartWithNum()
@@ -110,12 +108,10 @@
qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView");
QSignalSpy spy2(mServiceOld, SIGNAL(activateView(QString)));
- mServiceOld->mMainWindow.mForeground = false;
QVERIFY( mServiceOld->startWithNum( (int)LogsServices::ViewReceived, true,
QString("+123456") ) == 0 );
QVERIFY( spy2.count() == 1 );
QVERIFY( spy2.at(0).at(0).toString() == QString("+123456"));
- QVERIFY( mServiceOld->mMainWindow.mForeground );
}
void UT_LogsServiceHandler::testShow()
@@ -134,37 +130,54 @@
// Correct view, dialpad text is empty
map.clear();
map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived));
- mService->mMainWindow.mForeground = false;
+ map.insert(logsShowDialpadParam, QVariant(true));
QVERIFY( mService->show(map) == 0 );
QVERIFY( spy.count() == 1 );
QVERIFY( spy2.count() == 0 );
LogsServices::LogsView view =
qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0));
- QVERIFY( view == LogsServices::ViewReceived );
- QVERIFY( mServiceOld->mMainWindow.mForeground );
+ QCOMPARE( view, LogsServices::ViewReceived );
+ QCOMPARE( spy.at(0).at(1).toBool(), true );
+ QCOMPARE( spy.at(0).at(2).toString(), QString(""));
// Correct view, dialpad text not empty
spy.clear();
map.clear();
map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived));
map.insert(logsDialpadTextParam, QVariant(QString("+123456")));
- mService->mMainWindow.mForeground = false;
QVERIFY( mService->show(map) == 0 );
QVERIFY( spy.count() == 0 );
QVERIFY( spy2.count() == 1 );
- QVERIFY( spy2.at(0).at(0).toString() == QString("+123456"));
- QVERIFY( mServiceOld->mMainWindow.mForeground );
+ QCOMPARE( spy2.at(0).at(0).toString(), QString("+123456"));
// Some completly dummy parameters or no params at all
spy.clear();
spy2.clear();
map.clear();
map.insert("dummy_param", QVariant(666));
- mService->mMainWindow.mForeground = false;
QVERIFY( mService->show(map) == 0 );
QVERIFY( spy.count() == 1 );
QVERIFY( spy2.count() == 0 );
view = qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0));
- QVERIFY( view == LogsServices::ViewAll );
- QVERIFY( mServiceOld->mMainWindow.mForeground );
+ QCOMPARE( view, LogsServices::ViewAll );
+ QCOMPARE( spy.at(0).at(1).toBool(), false );
+ QCOMPARE( spy.at(0).at(2).toString(), QString(""));
+
+ // Both new and deprecated params present, new params will be used
+ spy.clear();
+ map.clear();
+ map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived));
+ map.insert(logsShowDialpadParam, QVariant(false));
+ map.insert(logsDialpadTextParam, QVariant(QString("+123456")));
+
+ map.insert(logsViewIndexParamNew, QVariant((int)LogsServices::ViewCalled));
+ map.insert(logsShowDialpadParamNew, QVariant(true));
+ map.insert(logsDialpadTextParamNew, QVariant(QString("")));
+ QVERIFY( mService->show(map) == 0 );
+ QVERIFY( spy.count() == 1 );
+ QVERIFY( spy2.count() == 0 );
+ view = qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0));
+ QCOMPARE( view, LogsServices::ViewCalled );
+ QCOMPARE( spy.at(0).at(1).toBool(), true );
+ QCOMPARE( spy.at(0).at(2).toString(), QString(""));
}
--- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsviewmanager.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsviewmanager.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -26,6 +26,7 @@
#include "logsmatchesview.h"
#include "logsdetailsview.h"
#include "hbstubs_helper.h"
+#include "logscontact.h"
//SYSTEM
#include <HbMainWindow.h>
@@ -47,8 +48,8 @@
void UT_LogsViewManager::init()
{
mMainWindow = new LogsMainWindow();
- mService = new LogsServiceHandler(*mMainWindow);
- mServiceOld = new LogsServiceHandlerOld(*mMainWindow);
+ mService = new LogsServiceHandler();
+ mServiceOld = new LogsServiceHandlerOld();
mLogsViewManager = new LogsViewManager(*mMainWindow, *mService, *mServiceOld);
}
@@ -125,33 +126,73 @@
void UT_LogsViewManager::testchangeMatchesView()
{
+ mLogsViewManager->mMainWindow.mForeground = false;
//Open Matches view, dialpad visible with predefined number
mLogsViewManager->changeMatchesViewViaService(QString("+123456"));
QVERIFY( mLogsViewManager->mMainWindow.currentView() ==
mLogsViewManager->mComponentsRepository->matchesView() );
-
+ QVERIFY( mLogsViewManager->mMainWindow.mForeground );
+
// Contact search disabled, go to recent calls view instead
+ mLogsViewManager->mMainWindow.mForeground = false;
mLogsViewManager->mComponentsRepository->mModel->mPredectiveSearchStatus = 0;
QString dialString("+123456777");
mLogsViewManager->changeMatchesViewViaService(dialString);
QVERIFY( mLogsViewManager->mMainWindow.currentView() ==
mLogsViewManager->mComponentsRepository->recentCallsView() );
QVERIFY( mLogsViewManager->mComponentsRepository->mDialpad->mLineEdit->text() == dialString );
+ QVERIFY( mLogsViewManager->mMainWindow.mForeground );
+
+ //Open Matches view, view stack not empty, embedded service canceled
+ mLogsViewManager->mMainWindow.mForeground = false;
+ QVERIFY( mLogsViewManager->mViewStack.count() );
+ mLogsViewManager->mViewStack.at(0)->mContact = new LogsContact();
+ mLogsViewManager->changeMatchesViewViaService(QString("+123456"));
+ QVERIFY( LogsContact::mServiceRequestCanceled );
+ QVERIFY( mLogsViewManager->mMainWindow.mForeground );
+
+ //Open Matches view, view stack is empty, embedded service not canceled
+ mLogsViewManager->mMainWindow.mForeground = false;
+ LogsContact::reset();
+ mLogsViewManager->mViewStack.clear();
+ mLogsViewManager->changeMatchesViewViaService(QString("+123456"));
+ QVERIFY( !LogsContact::mServiceRequestCanceled );
+ QVERIFY( mLogsViewManager->mMainWindow.mForeground );
}
void UT_LogsViewManager::testchangeRecentView()
{
+ mLogsViewManager->mMainWindow.mForeground = false;
QString dialString("+123456777");
mLogsViewManager->changeRecentViewViaService(LogsServices::ViewCalled, false, dialString);
QVERIFY( mLogsViewManager->mMainWindow.currentView() ==
mLogsViewManager->mComponentsRepository->recentCallsView() );
QVERIFY( mLogsViewManager->mComponentsRepository->mDialpad->mLineEdit->text() == dialString );
+ QVERIFY( mLogsViewManager->mMainWindow.mForeground );
// Empty string clears dialpad input
+ mLogsViewManager->mMainWindow.mForeground = false;
mLogsViewManager->changeRecentViewViaService(LogsServices::ViewCalled, false, "");
QVERIFY( mLogsViewManager->mMainWindow.currentView() ==
mLogsViewManager->mComponentsRepository->recentCallsView() );
QVERIFY( mLogsViewManager->mComponentsRepository->mDialpad->mLineEdit->text().isEmpty() );
+ QVERIFY( mLogsViewManager->mMainWindow.mForeground );
+
+ //Open recent view, view stack not empty, embedded service canceled
+ mLogsViewManager->mMainWindow.mForeground = false;
+ QVERIFY( mLogsViewManager->mViewStack.count() );
+ mLogsViewManager->mViewStack.at(0)->mContact = new LogsContact();
+ mLogsViewManager->changeRecentViewViaService(LogsServices::ViewCalled, false, "");
+ QVERIFY( LogsContact::mServiceRequestCanceled );
+ QVERIFY( mLogsViewManager->mMainWindow.mForeground );
+
+ //Open recentt view, view stack is empty, embedded service not canceled
+ mLogsViewManager->mMainWindow.mForeground = false;
+ LogsContact::reset();
+ mLogsViewManager->mViewStack.clear();
+ mLogsViewManager->changeRecentViewViaService(LogsServices::ViewCalled, false, "");
+ QVERIFY( !LogsContact::mServiceRequestCanceled );
+ QVERIFY( mLogsViewManager->mMainWindow.mForeground );
}
void UT_LogsViewManager::testExitApplication()
@@ -185,8 +226,8 @@
// before service method call comes.
LogsMainWindow window;
window.setCurrentView(0); // clear stub static data
- LogsServiceHandler service(*mMainWindow);
- LogsServiceHandlerOld serviceOld(*mMainWindow);
+ LogsServiceHandler service;
+ LogsServiceHandlerOld serviceOld;
service.mIsAppStartedUsingService = true;
LogsViewManager vm(window, service, serviceOld);
QVERIFY( vm.mComponentsRepository );
--- a/logsui/logsapp/tsrc/ut_logsapp/stubs/hbstubs.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/stubs/hbstubs.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -20,7 +20,7 @@
#include <hbmainwindow.h>
#include <hbinstance.h>
#include "hbstubs_helper.h"
-#include <hbmessagebox.h>
+#include <hbdialog.h>
#include <hbapplication.h>
#include <hbcolorscheme.h>
#include <hbview.h>
@@ -31,6 +31,7 @@
#include <QGesture>
#include <hblistview.h>
#include <hblistviewitem.h>
+#include <hbmessagebox.h>
int actionCount = 0;
Qt::Orientation windowOrientation = Qt::Vertical;
@@ -296,6 +297,27 @@
testDialogShown = true;
}
+void HbDialog::open()
+{
+ testDialogShown = true;
+}
+
+void HbMessageBox::question(const QString &questionText,
+ QObject *receiver ,
+ const char *member,
+ HbMessageBox::StandardButtons buttons,
+ QGraphicsWidget *headingWidget,
+ QGraphicsScene *scene,
+ QGraphicsItem *parent)
+{
+ Q_UNUSED(questionText)
+ Q_UNUSED(receiver)
+ Q_UNUSED(member)
+ Q_UNUSED(buttons)
+ Q_UNUSED(scene)
+ Q_UNUSED(parent)
+ testDialogShown = true;
+}
// -----------------------------------------------------------------------------
//
@@ -394,15 +416,6 @@
return list;
}
-void HbMessageBox::setText(const QString &string)
-{
- if (string == "Ok") {
- selectedActionString = "primary";
- } else if (string == "Cancel") {
- selectedActionString = "secondary";
- }
-}
-
void QTimer::singleShot(int msec, QObject *receiver, const char *member)
{
testSingleShotTimer = true;
--- a/logsui/logscntfinder/bwins/logscntfinderu.def Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/bwins/logscntfinderu.def Wed Aug 18 09:49:12 2010 +0300
@@ -1,25 +1,28 @@
EXPORTS
- ?getEntry@LogsCntFinder@@QBEPAVLogsCntEntry@@ABVQObject@@@Z @ 1 NONAME ; class LogsCntEntry * LogsCntFinder::getEntry(class QObject const &) const
- ?deleteEntry@LogsCntFinder@@QAEXABVQObject@@@Z @ 2 NONAME ; void LogsCntFinder::deleteEntry(class QObject const &)
- ?contactId@LogsCntEntry@@QBEIXZ @ 3 NONAME ; unsigned int LogsCntEntry::contactId(void) const
- ?setFirstName@LogsCntEntry@@QAEXABVQString@@@Z @ 4 NONAME ; void LogsCntEntry::setFirstName(class QString const &)
- ??0LogsCntEntry@@QAE@AAVQObject@@I@Z @ 5 NONAME ; LogsCntEntry::LogsCntEntry(class QObject &, unsigned int)
- ?speedDial@LogsCntEntry@@QBEABVQString@@XZ @ 6 NONAME ; class QString const & LogsCntEntry::speedDial(void) const
- ?predictiveSearchQuery@LogsCntFinder@@QAEXABVQString@@@Z @ 7 NONAME ; void LogsCntFinder::predictiveSearchQuery(class QString const &)
- ?richText@LogsCntText@@QBE?AVQString@@V2@0@Z @ 8 NONAME ; class QString LogsCntText::richText(class QString, class QString) const
- ?setLastName@LogsCntEntry@@QAEXABVQString@@@Z @ 9 NONAME ; void LogsCntEntry::setLastName(class QString const &)
- ??0LogsCntFinder@@QAE@XZ @ 10 NONAME ; LogsCntFinder::LogsCntFinder(void)
- ?insertEntry@LogsCntFinder@@QAEXHPAVLogsCntEntry@@@Z @ 11 NONAME ; void LogsCntFinder::insertEntry(int, class LogsCntEntry *)
- ?resultsCount@LogsCntFinder@@QBEHXZ @ 12 NONAME ; int LogsCntFinder::resultsCount(void) const
- ?phoneNumber@LogsCntEntry@@QBEABVLogsCntText@@XZ @ 13 NONAME ; class LogsCntText const & LogsCntEntry::phoneNumber(void) const
- ?type@LogsCntEntry@@QBE?AW4EntryType@1@XZ @ 14 NONAME ; enum LogsCntEntry::EntryType LogsCntEntry::type(void) const
- ?resultAt@LogsCntFinder@@QAEABVLogsCntEntry@@H@Z @ 15 NONAME ; class LogsCntEntry const & LogsCntFinder::resultAt(int)
- ?lastName@LogsCntEntry@@QBEABV?$QList@VLogsCntText@@@@XZ @ 16 NONAME ; class QList<class LogsCntText> const & LogsCntEntry::lastName(void) const
- ?handle@LogsCntEntry@@QBEPAVQObject@@XZ @ 17 NONAME ; class QObject * LogsCntEntry::handle(void) const
- ?firstName@LogsCntEntry@@QBEABV?$QList@VLogsCntText@@@@XZ @ 18 NONAME ; class QList<class LogsCntText> const & LogsCntEntry::firstName(void) const
- ??1LogsCntFinder@@UAE@XZ @ 19 NONAME ; LogsCntFinder::~LogsCntFinder(void)
- ?setPhoneNumber@LogsCntEntry@@QAEXABVQString@@@Z @ 20 NONAME ; void LogsCntEntry::setPhoneNumber(class QString const &)
- ?setAvatarPath@LogsCntEntry@@QAEXABVQString@@@Z @ 21 NONAME ; void LogsCntEntry::setAvatarPath(class QString const &)
- ?avatarPath@LogsCntEntry@@QBEABVQString@@XZ @ 22 NONAME ; class QString const & LogsCntEntry::avatarPath(void) const
- ??0LogsCntFinder@@QAE@AAVQContactManager@QtMobility@@@Z @ 23 NONAME ; LogsCntFinder::LogsCntFinder(class QtMobility::QContactManager &)
+ ?setAvatarPath@LogsCntEntry@@QAEXABVQString@@@Z @ 1 NONAME ; void LogsCntEntry::setAvatarPath(class QString const &)
+ ?getEntry@LogsCntFinder@@QBEPAVLogsCntEntry@@ABVQObject@@@Z @ 2 NONAME ; class LogsCntEntry * LogsCntFinder::getEntry(class QObject const &) const
+ ?deleteEntry@LogsCntFinder@@QAEXABVQObject@@@Z @ 3 NONAME ; void LogsCntFinder::deleteEntry(class QObject const &)
+ ?contactId@LogsCntEntry@@QBEIXZ @ 4 NONAME ; unsigned int LogsCntEntry::contactId(void) const
+ ?setFirstName@LogsCntEntry@@QAEXABVQString@@@Z @ 5 NONAME ; void LogsCntEntry::setFirstName(class QString const &)
+ ??0LogsCntEntry@@QAE@AAVQObject@@I@Z @ 6 NONAME ; LogsCntEntry::LogsCntEntry(class QObject &, unsigned int)
+ ?speedDial@LogsCntEntry@@QBEABVQString@@XZ @ 7 NONAME ; class QString const & LogsCntEntry::speedDial(void) const
+ ??0LogsCntFinder@@QAE@AAVQContactManager@QtMobility@@_N@Z @ 8 NONAME ; LogsCntFinder::LogsCntFinder(class QtMobility::QContactManager &, bool)
+ ?predictiveSearchQuery@LogsCntFinder@@QAEXABVQString@@@Z @ 9 NONAME ; void LogsCntFinder::predictiveSearchQuery(class QString const &)
+ ?avatarPath@LogsCntEntry@@QBEABVQString@@XZ @ 10 NONAME ; class QString const & LogsCntEntry::avatarPath(void) const
+ ?richText@LogsCntText@@QBE?AVQString@@V2@0@Z @ 11 NONAME ; class QString LogsCntText::richText(class QString, class QString) const
+ ?setPreferDefaultNumber@LogsCntFinder@@QAEX_N@Z @ 12 NONAME ; void LogsCntFinder::setPreferDefaultNumber(bool)
+ ?preferDefaultNumber@LogsCntFinder@@QBE_NXZ @ 13 NONAME ; bool LogsCntFinder::preferDefaultNumber(void) const
+ ?setLastName@LogsCntEntry@@QAEXABVQString@@@Z @ 14 NONAME ; void LogsCntEntry::setLastName(class QString const &)
+ ?insertEntry@LogsCntFinder@@QAEXHPAVLogsCntEntry@@@Z @ 15 NONAME ; void LogsCntFinder::insertEntry(int, class LogsCntEntry *)
+ ?resultsCount@LogsCntFinder@@QBEHXZ @ 16 NONAME ; int LogsCntFinder::resultsCount(void) const
+ ?phoneNumber@LogsCntEntry@@QBEABVLogsCntText@@XZ @ 17 NONAME ; class LogsCntText const & LogsCntEntry::phoneNumber(void) const
+ ?type@LogsCntEntry@@QBE?AW4EntryType@1@XZ @ 18 NONAME ; enum LogsCntEntry::EntryType LogsCntEntry::type(void) const
+ ??0LogsCntFinder@@QAE@_N@Z @ 19 NONAME ; LogsCntFinder::LogsCntFinder(bool)
+ ?resultAt@LogsCntFinder@@QAEABVLogsCntEntry@@H@Z @ 20 NONAME ; class LogsCntEntry const & LogsCntFinder::resultAt(int)
+ ?lastName@LogsCntEntry@@QBEABV?$QList@VLogsCntText@@@@XZ @ 21 NONAME ; class QList<class LogsCntText> const & LogsCntEntry::lastName(void) const
+ ?handle@LogsCntEntry@@QBEPAVQObject@@XZ @ 22 NONAME ; class QObject * LogsCntEntry::handle(void) const
+ ?firstName@LogsCntEntry@@QBEABV?$QList@VLogsCntText@@@@XZ @ 23 NONAME ; class QList<class LogsCntText> const & LogsCntEntry::firstName(void) const
+ ??1LogsCntFinder@@UAE@XZ @ 24 NONAME ; LogsCntFinder::~LogsCntFinder(void)
+ ?setPhoneNumber@LogsCntEntry@@QAEXABVQString@@@Z @ 25 NONAME ; void LogsCntEntry::setPhoneNumber(class QString const &)
+ ?resetResults@LogsCntFinder@@QAEXXZ @ 26 NONAME ; void LogsCntFinder::resetResults(void)
--- a/logsui/logscntfinder/eabi/logscntfinderu.def Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/eabi/logscntfinderu.def Wed Aug 18 09:49:12 2010 +0300
@@ -1,30 +1,33 @@
EXPORTS
_ZN12LogsCntEntry11setLastNameERK7QString @ 1 NONAME
_ZN12LogsCntEntry12setFirstNameERK7QString @ 2 NONAME
- _ZN12LogsCntEntry14setPhoneNumberERK7QString @ 3 NONAME
- _ZN12LogsCntEntryC1ER7QObjectj @ 4 NONAME
- _ZN12LogsCntEntryC2ER7QObjectj @ 5 NONAME
- _ZN13LogsCntFinder11deleteEntryERK7QObject @ 6 NONAME
- _ZN13LogsCntFinder11insertEntryEiP12LogsCntEntry @ 7 NONAME
- _ZN13LogsCntFinder21predictiveSearchQueryERK7QString @ 8 NONAME
- _ZN13LogsCntFinder8resultAtEi @ 9 NONAME
- _ZN13LogsCntFinderC1Ev @ 10 NONAME
- _ZN13LogsCntFinderC2Ev @ 11 NONAME
- _ZN13LogsCntFinderD0Ev @ 12 NONAME
- _ZN13LogsCntFinderD1Ev @ 13 NONAME
- _ZN13LogsCntFinderD2Ev @ 14 NONAME
- _ZNK11LogsCntText8richTextE7QStringS0_ @ 15 NONAME
- _ZNK12LogsCntEntry11phoneNumberEv @ 16 NONAME
- _ZNK12LogsCntEntry4typeEv @ 17 NONAME
- _ZNK12LogsCntEntry6handleEv @ 18 NONAME
- _ZNK12LogsCntEntry8lastNameEv @ 19 NONAME
- _ZNK12LogsCntEntry9contactIdEv @ 20 NONAME
- _ZNK12LogsCntEntry9firstNameEv @ 21 NONAME
- _ZNK12LogsCntEntry9speedDialEv @ 22 NONAME
- _ZNK13LogsCntFinder12resultsCountEv @ 23 NONAME
- _ZNK13LogsCntFinder8getEntryERK7QObject @ 24 NONAME
- _ZN12LogsCntEntry13setAvatarPathERK7QString @ 25 NONAME
- _ZNK12LogsCntEntry10avatarPathEv @ 26 NONAME
- _ZN13LogsCntFinderC1ERN10QtMobility15QContactManagerE @ 27 NONAME
- _ZN13LogsCntFinderC2ERN10QtMobility15QContactManagerE @ 28 NONAME
+ _ZN12LogsCntEntry13setAvatarPathERK7QString @ 3 NONAME
+ _ZN12LogsCntEntry14setPhoneNumberERK7QString @ 4 NONAME
+ _ZN12LogsCntEntryC1ER7QObjectj @ 5 NONAME
+ _ZN12LogsCntEntryC2ER7QObjectj @ 6 NONAME
+ _ZN13LogsCntFinder11deleteEntryERK7QObject @ 7 NONAME
+ _ZN13LogsCntFinder11insertEntryEiP12LogsCntEntry @ 8 NONAME
+ _ZN13LogsCntFinder12resetResultsEv @ 9 NONAME
+ _ZN13LogsCntFinder21predictiveSearchQueryERK7QString @ 10 NONAME
+ _ZN13LogsCntFinder22setPreferDefaultNumberEb @ 11 NONAME
+ _ZN13LogsCntFinder8resultAtEi @ 12 NONAME
+ _ZN13LogsCntFinderC1ERN10QtMobility15QContactManagerEb @ 13 NONAME
+ _ZN13LogsCntFinderC1Eb @ 14 NONAME
+ _ZN13LogsCntFinderC2ERN10QtMobility15QContactManagerEb @ 15 NONAME
+ _ZN13LogsCntFinderC2Eb @ 16 NONAME
+ _ZN13LogsCntFinderD0Ev @ 17 NONAME
+ _ZN13LogsCntFinderD1Ev @ 18 NONAME
+ _ZN13LogsCntFinderD2Ev @ 19 NONAME
+ _ZNK11LogsCntText8richTextE7QStringS0_ @ 20 NONAME
+ _ZNK12LogsCntEntry10avatarPathEv @ 21 NONAME
+ _ZNK12LogsCntEntry11phoneNumberEv @ 22 NONAME
+ _ZNK12LogsCntEntry4typeEv @ 23 NONAME
+ _ZNK12LogsCntEntry6handleEv @ 24 NONAME
+ _ZNK12LogsCntEntry8lastNameEv @ 25 NONAME
+ _ZNK12LogsCntEntry9contactIdEv @ 26 NONAME
+ _ZNK12LogsCntEntry9firstNameEv @ 27 NONAME
+ _ZNK12LogsCntEntry9speedDialEv @ 28 NONAME
+ _ZNK13LogsCntFinder12resultsCountEv @ 29 NONAME
+ _ZNK13LogsCntFinder19preferDefaultNumberEv @ 30 NONAME
+ _ZNK13LogsCntFinder8getEntryERK7QObject @ 31 NONAME
--- a/logsui/logscntfinder/inc/logscntfinder.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/inc/logscntfinder.h Wed Aug 18 09:49:12 2010 +0300
@@ -26,6 +26,7 @@
QTM_BEGIN_NAMESPACE
class QContactManager;
+class QContact;
QTM_END_NAMESPACE
QTM_USE_NAMESPACE
@@ -44,8 +45,9 @@
public: // The exported API
- LOGSCNTFINDER_EXPORT LogsCntFinder();
- LOGSCNTFINDER_EXPORT LogsCntFinder(QContactManager& contactManager);
+ LOGSCNTFINDER_EXPORT LogsCntFinder(bool preferDefaultNumber = false);
+ LOGSCNTFINDER_EXPORT LogsCntFinder(QContactManager& contactManager,
+ bool preferDefaultNumber = false);
LOGSCNTFINDER_EXPORT ~LogsCntFinder();
/**
@@ -92,6 +94,30 @@
*/
LOGSCNTFINDER_EXPORT
void deleteEntry( const LogsCntEntryHandle& handle );
+
+
+ /**
+ * Used to define which phone number will be returned in search result
+ * in case a contact has multiple numbers
+ * @param preferDefault if set true, the number set as default for calling
+ * will be used, otherwise the first number from the number list
+ * will be used
+ */
+ LOGSCNTFINDER_EXPORT void setPreferDefaultNumber(bool preferDefault);
+
+ /**
+ * Used for checking whether default number for calling will be used in
+ * search results, if contact has multiple phone numbers set
+ * @return whether default number is used in search results
+ */
+ LOGSCNTFINDER_EXPORT bool preferDefaultNumber() const;
+
+
+ /**
+ * Used for resetting search results
+ */
+ LOGSCNTFINDER_EXPORT void resetResults();
+
signals:
@@ -100,6 +126,7 @@
*/
void queryReady();
+
private:
void doPredictiveHistoryQuery();
@@ -114,8 +141,7 @@
void updateResult( LogsCntEntry* entry );
bool isProgressivePattern( const QString& pattern ) const;
void setCurrentPattern( const QString& pattern );
-
-
+ QString phoneNumber(const QContact& contact) const;
private:
@@ -124,6 +150,7 @@
LogsCntEntryList mResults;
QContactManager* mContactManager;
LogsCntEntryList mHistoryEvents;
+ bool mPreferDefaultNumber;
int mCachedCounter;
friend class UT_LogsCntFinder;
--- a/logsui/logscntfinder/src/logscntfinder.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/src/logscntfinder.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -34,8 +34,8 @@
// LogsCntFinder::LogsCntFinder()
// -----------------------------------------------------------------------------
//
-LogsCntFinder::LogsCntFinder()
- : mCachedCounter(0)
+LogsCntFinder::LogsCntFinder(bool preferDefaultNumber)
+ : mPreferDefaultNumber(preferDefaultNumber), mCachedCounter(0)
{
LOGS_QDEBUG( "logs [FINDER] -> LogsCntFinder::LogsCntFinder()" )
@@ -51,8 +51,8 @@
// LogsCntFinder::LogsCntFinder()
// -----------------------------------------------------------------------------
//
-LogsCntFinder::LogsCntFinder(QContactManager& contactManager)
- : mCachedCounter(0)
+LogsCntFinder::LogsCntFinder(QContactManager& contactManager, bool preferDefaultNumber)
+ : mPreferDefaultNumber(preferDefaultNumber), mCachedCounter(0)
{
LOGS_QDEBUG( "logs [FINDER] -> LogsCntFinder::LogsCntFinder(), cntmgr from client" )
@@ -273,8 +273,33 @@
LogsPredictiveTranslator::instance();
mCurrentInputPattern = pattern;
- mCurrentPredictivePattern = translator->translatePattern( mCurrentInputPattern );
+ mCurrentPredictivePattern = translator->translatePattern( mCurrentInputPattern );
+}
+
+// -----------------------------------------------------------------------------
+// LogsCntFinder::phoneNumber
+// -----------------------------------------------------------------------------
+//
+QString LogsCntFinder::phoneNumber(const QContact& contact) const
+{
+ LOGS_QDEBUG( "logs [FINDER] -> LogsCntFinder::phoneNumber()" )
+ QString number;
+ if (mPreferDefaultNumber) {
+ number = contact.preferredDetail("call").value(
+ QContactPhoneNumber::FieldNumber );
+ if (number.isEmpty()) {
+ number = contact.detailWithAction("call").value(
+ QContactPhoneNumber::FieldNumber );
+ }
+ }
+ if (number.isEmpty()) {
+ QContactPhoneNumber contactPhoneNumber =
+ contact.detail( QContactPhoneNumber::DefinitionName );
+ number = contactPhoneNumber.value( QContactPhoneNumber::FieldNumber );
+ }
+ LOGS_QDEBUG_2( "logs [FINDER] -> LogsCntFinder::phoneNumber(): ", number )
+ return number;
}
// -----------------------------------------------------------------------------
@@ -302,21 +327,17 @@
QContactName contactName = contact.detail( QContactName::DefinitionName );
entry->setFirstName( contactName.value( QContactName::FieldFirstName ) );
entry->setLastName( contactName.value( QContactName::FieldLastName ) );
- QContactPhoneNumber contactPhoneNumber =
- contact.detail( QContactPhoneNumber::DefinitionName );
- entry->setPhoneNumber(
- contactPhoneNumber.value( QContactPhoneNumber::FieldNumber ) );
+ entry->setPhoneNumber(phoneNumber(contact));
QContactAvatar contactAvatar = contact.detail<QContactAvatar>();
QString avatar = contactAvatar.value( QContactAvatar::FieldImageUrl );
entry->setAvatarPath( avatar );
- updateResult( entry );
+ updateResult( entry );
}
LOGS_QDEBUG( "logs [FINDER] <- LogsCntFinder::resultAt()" )
return *entry;
}
-
// -----------------------------------------------------------------------------
// LogsCntFinder::insertEntry
// -----------------------------------------------------------------------------
@@ -338,7 +359,7 @@
LogsCntEntry* LogsCntFinder::getEntry( const LogsCntEntryHandle& handle ) const
{
LOGS_QDEBUG( "logs [FINDER] -> LogsCntFinder::getEntry()" )
- return doGetEntry( mHistoryEvents, handle );
+ return doGetEntry( mHistoryEvents, handle );
}
// -----------------------------------------------------------------------------
@@ -381,6 +402,38 @@
}
+// -----------------------------------------------------------------------------
+// LogsCntFinder::setPreferDefaultNumber
+// -----------------------------------------------------------------------------
+//
+void LogsCntFinder::setPreferDefaultNumber(bool preferDefault)
+{
+ if (mPreferDefaultNumber != preferDefault) {
+ resetResults();
+ mPreferDefaultNumber = preferDefault;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// LogsCntFinder::setPreferDefaultNumber
+// -----------------------------------------------------------------------------
+//
+bool LogsCntFinder::preferDefaultNumber() const
+{
+ return mPreferDefaultNumber;
+}
+
+
+// -----------------------------------------------------------------------------
+// LogsCntFinder::resetResults
+// -----------------------------------------------------------------------------
+//
+void LogsCntFinder::resetResults()
+{
+ qDeleteAll( mResults );
+ mResults.clear();
+ mCachedCounter = 0;
+}
--- a/logsui/logscntfinder/src/logspredictivelatin12keytranslator.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/src/logspredictivelatin12keytranslator.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -25,8 +25,8 @@
#include "logslogger.h"
//mapping char,key(name)
-const QChar SpecialMapping[] = {'+', '*', '*', '*','#','#'};
-const int SpecialsCount = 3;
+const QChar SpecialMapping[] = {'+', '*', '*', '*','#','#','%','1'};
+const int SpecialsCount = 4;
const QChar SpaceSepar(' ');
--- a/logsui/logscntfinder/tsrc/st_logscntfinder/inc/st_logscntfinder.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/tsrc/st_logscntfinder/inc/st_logscntfinder.h Wed Aug 18 09:49:12 2010 +0300
@@ -77,7 +77,7 @@
void testPredictiveSearchQueryLogsContactsPhoneNumberMatch();
void testPredictiveSearchQueryLimit();
void testQueryOrder();
- void testContactWithNonMappedChars();
+ void testContactWithSpecialChars();
private:
@@ -91,13 +91,15 @@
void createContacts();
void createContactsForQueryOrder();
void createContactsForQueryZero();
- void createContactsWithNonMappedChars();
+ void createContactsWithSpecialChars();
void createHistoryEvents();
void createLogEvent(
QString firstname,
QString Lastname,
QString phnumber);
+ bool checkHighlights( int index, int expected );
+
private:
QContactManager *m_manager;
LogsCntFinder *m_finder;
--- a/logsui/logscntfinder/tsrc/st_logscntfinder/src/st_logscntfinder.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/tsrc/st_logscntfinder/src/st_logscntfinder.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -22,18 +22,43 @@
#include <QtTest/QtTest>
#include <hbinputsettingproxy.h>
+#define CHECK_HIGHLIGHTS( index, expected )\
+ QVERIFY( checkHighlights( index, expected ) )
-#define CHECK_RESULTS( count, first, last )\
+#define CHECK_RESULTS( count, first, last, highlights )\
for(int i=0;i<count; i++ ) {\
if ( i == 0 ) {\
QCOMPARE(m_finder->resultAt(0).firstName().at(0).text(), QString(first));\
QCOMPARE(m_finder->resultAt(0).lastName().at(0).text(), QString(last));\
+ CHECK_HIGHLIGHTS( 0,highlights );\
} else {\
m_finder->resultAt(i);\
}\
}
-
+
+
+bool ST_LogsCntFinder::checkHighlights( int index,int expected )
+{
+ bool foundOne = false;
+ const LogsCntEntry& entry = m_finder->resultAt( index );
+ int ndx = 0;
+ while( !foundOne && ndx < entry.firstName().count() ) {
+ foundOne = entry.firstName().at( ndx++ ).highlights() == expected;
+ }
+
+ ndx = 0;
+ while( !foundOne && ndx < entry.lastName().count() ) {
+ foundOne = entry.lastName().at( ndx++ ).highlights() == expected;
+ }
+
+ foundOne = !foundOne ? entry.phoneNumber().highlights() == expected : foundOne;
+
+
+ return foundOne;
+}
+
+
void ST_LogsCntFinder::initTestCase()
{
//open symbian database
@@ -137,7 +162,7 @@
QCOMPARE(contactsCount, 18);
}
-void ST_LogsCntFinder::createContactsWithNonMappedChars()
+void ST_LogsCntFinder::createContactsWithSpecialChars()
{
createOneContact( QString("Hannu%"), QString(""), QString("932472398") );
@@ -369,21 +394,21 @@
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 5 );
//see half of matched results
- CHECK_RESULTS( 3, "Jonn", "Ennon" );
+ CHECK_RESULTS( 3, "Jonn", "Ennon", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("56") );
QCOMPARE( m_finder->resultsCount(), 2 );
//see half of matched results
- CHECK_RESULTS( 1, "Jonn", "Ennon" );
+ CHECK_RESULTS( 1, "Jonn", "Ennon", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 5 );
- CHECK_RESULTS( 3, "Jonn", "Ennon" );
+ CHECK_RESULTS( 3, "Jonn", "Ennon", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("56") );
QCOMPARE( m_finder->resultsCount(), 2 );
//see half of matched results
- CHECK_RESULTS( 1, "Jonn", "Ennon" );
+ CHECK_RESULTS( 1, "Jonn", "Ennon", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
}
@@ -396,22 +421,22 @@
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 5 );
//see all matched results
- CHECK_RESULTS( 5, "Jonn", "Ennon" );
+ CHECK_RESULTS( 5, "Jonn", "Ennon", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("56") );
QCOMPARE( m_finder->resultsCount(), 2 );
//see all of matched results
- CHECK_RESULTS( 2, "Jonn", "Ennon" );
+ CHECK_RESULTS( 2, "Jonn", "Ennon", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 5 );
//see all of matched results
- CHECK_RESULTS( 5, "Jonn", "Ennon" );
+ CHECK_RESULTS( 5, "Jonn", "Ennon", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("56") );
QCOMPARE( m_finder->resultsCount(), 2 );
//see all of matched results
- CHECK_RESULTS( 2, "Jonn", "Ennon" );
+ CHECK_RESULTS( 2, "Jonn", "Ennon", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
}
@@ -423,7 +448,7 @@
m_finder->predictiveSearchQuery( QString("6") );
QCOMPARE( m_finder->resultsCount(), 3 );
//see half of matched results
- CHECK_RESULTS( 2, "Maria-Zola", "Jones" );
+ CHECK_RESULTS( 2, "Maria-Zola", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("69") );
QCOMPARE( m_finder->resultsCount(), 0 );
@@ -435,7 +460,7 @@
m_finder->predictiveSearchQuery( QString("6") );
QCOMPARE( m_finder->resultsCount(), 3 );
//see half of matched results
- CHECK_RESULTS( 2, "Maria-Zola", "Jones" );
+ CHECK_RESULTS( 2, "Maria-Zola", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("69") );
QCOMPARE( m_finder->resultsCount(), 0 );
@@ -450,7 +475,7 @@
m_finder->predictiveSearchQuery( QString("6") );
QCOMPARE( m_finder->resultsCount(), 3 );
//see all of matched results
- CHECK_RESULTS( 3, "Maria-Zola", "Jones" );
+ CHECK_RESULTS( 3, "Maria-Zola", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("69") );
QCOMPARE( m_finder->resultsCount(), 0 );
@@ -462,7 +487,7 @@
m_finder->predictiveSearchQuery( QString("6") );
QCOMPARE( m_finder->resultsCount(), 3 );
//see all of matched results
- CHECK_RESULTS( 3, "Maria-Zola", "Jones" );
+ CHECK_RESULTS( 3, "Maria-Zola", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("69") );
QCOMPARE( m_finder->resultsCount(), 0 );
@@ -477,23 +502,31 @@
m_finder->predictiveSearchQuery( QString("2") );//db
QCOMPARE( m_finder->resultsCount(), 3 );
- CHECK_RESULTS( 2, "Levis", "Augustin" );//Augustin Zi
+ //Augustin Zi
+ CHECK_RESULTS( 2, "Levis", "Augustin", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("20") );//db
QCOMPARE( m_finder->resultsCount(), 3 );
- CHECK_RESULTS( 2, "Levis", "Augustin" );//Augustin Zi
+ //Augustin Zi
+ CHECK_RESULTS( 2, "Levis", "Augustin", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
+
m_finder->predictiveSearchQuery( QString("209") );//db
QCOMPARE( m_finder->resultsCount(), 1 );
- CHECK_RESULTS( 1, "Levis", "Augustin" ); //Augustin Zi
+ //Augustin Zi
+ CHECK_RESULTS( 1, "Levis", "Augustin", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
+
m_finder->predictiveSearchQuery( QString("20") );//db
QCOMPARE( m_finder->resultsCount(), 3 );
- CHECK_RESULTS( 2, "Levis", "Augustin" );//Augustin Zi
+ //Augustin Zi
+ CHECK_RESULTS( 2, "Levis", "Augustin", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("2") );//db
QCOMPARE( m_finder->resultsCount(), 3 );
- CHECK_RESULTS( 2, "Levis", "Augustin" );//Augustin Zi
+ //Augustin Zi
+ CHECK_RESULTS( 2, "Levis", "Augustin", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
+
}
@@ -504,31 +537,31 @@
m_finder->predictiveSearchQuery( QString("2") ); //db
QCOMPARE( m_finder->resultsCount(), 3 );
- CHECK_RESULTS( 3, "Levis", "Augustin" );//Augustin Zi
+ CHECK_RESULTS( 3, "Levis", "Augustin", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("20") );//cache
QCOMPARE( m_finder->resultsCount(), 3 );
- CHECK_RESULTS( 3, "Levis", "Augustin" );//Augustin Zi
+ CHECK_RESULTS( 3, "Levis", "Augustin", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("200") );//cache
QCOMPARE( m_finder->resultsCount(), 3 );
- CHECK_RESULTS( 3, "Levis", "Augustin" );//Augustin Zi
+ CHECK_RESULTS( 3, "Levis", "Augustin", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("2009") );//cache
QCOMPARE( m_finder->resultsCount(), 1 );
- CHECK_RESULTS( 1, "Levis", "Augustin" ); //Augustin Zi
+ CHECK_RESULTS( 1, "Levis", "Augustin", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("200") );//db
QCOMPARE( m_finder->resultsCount(), 3 );
- CHECK_RESULTS( 3, "Levis", "Augustin" );//Augustin Zi
+ CHECK_RESULTS( 3, "Levis", "Augustin", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("20") );//db
QCOMPARE( m_finder->resultsCount(), 3 );
- CHECK_RESULTS( 3, "Levis", "Augustin" );//Augustin Zi
+ CHECK_RESULTS( 3, "Levis", "Augustin", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("2") );//db
QCOMPARE( m_finder->resultsCount(), 3 );
- CHECK_RESULTS( 3, "Levis", "Augustin" );//Augustin Zi
+ CHECK_RESULTS( 3, "Levis", "Augustin", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
}
@@ -539,26 +572,26 @@
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 2 );
- CHECK_RESULTS( 2, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 2, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("53") );
QCOMPARE( m_finder->resultsCount(), 1 );
- CHECK_RESULTS( 1, "Jonn", "Lennon" );
+ CHECK_RESULTS( 1, "Jonn", "Lennon", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("539") );
QCOMPARE( m_finder->resultsCount(), 0 );
m_finder->predictiveSearchQuery( QString("53") );
QCOMPARE( m_finder->resultsCount(), 1 );
- CHECK_RESULTS( 1, "Jonn", "Lennon" );
+ CHECK_RESULTS( 1, "Jonn", "Lennon", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 2 );
- CHECK_RESULTS( 2, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 2, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 2 );
- CHECK_RESULTS( 2, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 2, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
}
void ST_LogsCntFinder::testPredictiveSearchQueryLogsZeroCase()
@@ -567,23 +600,23 @@
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 2 );
- CHECK_RESULTS( 2, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 2, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("50") );
QCOMPARE( m_finder->resultsCount(), 2 );
- CHECK_RESULTS( 2, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 2, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("503") );
QCOMPARE( m_finder->resultsCount(), 1 );
- CHECK_RESULTS( 1, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 1, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("50") );
QCOMPARE( m_finder->resultsCount(), 2 );
- CHECK_RESULTS( 2, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 2, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 2 );
- CHECK_RESULTS( 2, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 2, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
}
@@ -595,22 +628,22 @@
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 7 );
- CHECK_RESULTS( 5, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 5, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("56") );
QCOMPARE( m_finder->resultsCount(), 4 );
- CHECK_RESULTS( 2, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 2, "Dim-Petter", "Jones", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("569") );
QCOMPARE( m_finder->resultsCount(), 0 );
m_finder->predictiveSearchQuery( QString("56") );
QCOMPARE( m_finder->resultsCount(), 4 );
- CHECK_RESULTS( 2, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 2, "Dim-Petter", "Jones", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 7 );
- CHECK_RESULTS( 5, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 5, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
}
@@ -622,22 +655,22 @@
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 7 );
- CHECK_RESULTS( 7, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 7, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("56") );
QCOMPARE( m_finder->resultsCount(), 4 );
- CHECK_RESULTS( 4, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 4, "Dim-Petter", "Jones", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("569") );
QCOMPARE( m_finder->resultsCount(), 0 );
m_finder->predictiveSearchQuery( QString("56") );
QCOMPARE( m_finder->resultsCount(), 4 );
- CHECK_RESULTS( 4, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 4, "Dim-Petter", "Jones", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 7 );
- CHECK_RESULTS( 7, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 7, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
}
@@ -648,23 +681,23 @@
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 7 );
- CHECK_RESULTS( 5, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 5, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("50") );
QCOMPARE( m_finder->resultsCount(), 7 );
- CHECK_RESULTS( 2, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 2, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("503") );
QCOMPARE( m_finder->resultsCount(), 2 );
- CHECK_RESULTS( 2, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 2, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("50") );
QCOMPARE( m_finder->resultsCount(), 7 );
- CHECK_RESULTS( 5, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 5, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("5") );
QCOMPARE( m_finder->resultsCount(), 7 );
- CHECK_RESULTS( 5, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 5, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
}
@@ -675,11 +708,11 @@
m_finder->predictiveSearchQuery( QString("9") );
QCOMPARE( m_finder->resultsCount(), 6 ); //3 history + 3 contacts
- CHECK_RESULTS( 5, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 5, "Dim-Petter", "Jones", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("93") );
QCOMPARE( m_finder->resultsCount(), 3 );
- CHECK_RESULTS( 1, "Dim-Petter", "Jones" );
+ CHECK_RESULTS( 1, "Dim-Petter", "Jones", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
}
@@ -750,24 +783,39 @@
QCOMPARE(m_finder->resultAt(7).lastName().at(0).text(), QString("Yadira"));
}
-void ST_LogsCntFinder::testContactWithNonMappedChars()
+void ST_LogsCntFinder::testContactWithSpecialChars()
{
//Hannu%
//%Hannu
- createContactsWithNonMappedChars();
+ createContactsWithSpecialChars();
+
+ m_finder->predictiveSearchQuery( QString("4") );
+ QCOMPARE( m_finder->resultsCount(), 1 );
+ CHECK_RESULTS( 1, "Hannu%", "", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
+
+ m_finder->predictiveSearchQuery( QString("42") );
+ QCOMPARE( m_finder->resultsCount(), 1 );
+ CHECK_RESULTS( 1, "Hannu%", "", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
m_finder->predictiveSearchQuery( QString("4") );
- QCOMPARE( m_finder->resultsCount(), 1 );//Hannu%
- QCOMPARE(m_finder->resultAt(0).firstName().at(0).text(), QString("Hannu%"));
-
- m_finder->predictiveSearchQuery( QString("42") );//all cached
- QCOMPARE( m_finder->resultsCount(), 1 );//Hannu%
- QCOMPARE(m_finder->resultAt(0).firstName().at(0).text(), QString("Hannu%"));
-
- m_finder->predictiveSearchQuery( QString("") );//empty cache
- m_finder->predictiveSearchQuery( QString("42") );
- QCOMPARE( m_finder->resultsCount(), 1 );//Hannu%
- QCOMPARE(m_finder->resultAt(0).firstName().at(0).text(), QString("Hannu%"));
+ QCOMPARE( m_finder->resultsCount(), 1 );
+ CHECK_RESULTS( 1, "Hannu%", "", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
+
+ m_finder->predictiveSearchQuery( QString("") );
+ QCOMPARE( m_finder->resultsCount(), 0 );
+
+ m_finder->predictiveSearchQuery( QString("1") );
+ QCOMPARE( m_finder->resultsCount(), 1 );
+ CHECK_RESULTS( 1, "%Hannu", "", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
+
+ m_finder->predictiveSearchQuery( QString("14") );
+ QCOMPARE( m_finder->resultsCount(), 1 );
+ CHECK_RESULTS( 1, "%Hannu", "", 2 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
+
+ m_finder->predictiveSearchQuery( QString("1") );
+ QCOMPARE( m_finder->resultsCount(), 1 );
+ CHECK_RESULTS( 1, "%Hannu", "", 1 ); //SET: cache size, CHECK: 1. result fn, 1. result ln, highlights
+
}
--- a/logsui/logscntfinder/tsrc/stubs/qtcontacts_stubs.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/tsrc/stubs/qtcontacts_stubs.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -28,6 +28,17 @@
#include "qtcontacts_stubs.h"
ContactQueryResults* ContactQueryResults::mInstance = 0;
+QString cntPreferredPhoneNumber = "123456";
+
+void ContactStubHelper::setPreferredNumber(QString number)
+{
+ cntPreferredPhoneNumber = number;
+}
+
+QString ContactStubHelper::preferredNumber()
+{
+ return cntPreferredPhoneNumber;
+}
// -----------------------------------------------------------------------------
// ContactsDB::instance()
@@ -250,8 +261,7 @@
}
if ( definitionId == QContactPhoneNumber::DefinitionName ){
QContactPhoneNumber number;
- QString n( "555789987" );
- number.setValue(QContactPhoneNumber::FieldNumber, n );
+ number.setValue(QContactPhoneNumber::FieldNumber, cntDetailPhoneNumber );
return number;
}
if ( definitionId == QContactAvatar::DefinitionName){
@@ -263,6 +273,21 @@
return detail;
}
+QContactDetail QContact::preferredDetail(const QString& actionName) const
+{
+ Q_UNUSED(actionName)
+ QContactPhoneNumber number;
+ number.setValue(QContactPhoneNumber::FieldNumber, cntPreferredPhoneNumber );
+ return number;
+}
+
+QContactDetail QContact::detailWithAction(const QString& actionName) const
+{
+ Q_UNUSED(actionName)
+ QContactPhoneNumber number;
+ number.setValue(QContactPhoneNumber::FieldNumber, cntPhoneNumberWithActionCall );
+ return number;
+}
// ----------------------------------------------------------------------------
// QContactDetail
--- a/logsui/logscntfinder/tsrc/stubs/qtcontacts_stubs.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/tsrc/stubs/qtcontacts_stubs.h Wed Aug 18 09:49:12 2010 +0300
@@ -21,6 +21,17 @@
#include <QObject>
#include <QStringList>
+const QString cntDetailPhoneNumber = "555789987";
+const QString cntPhoneNumberWithActionCall = "98765";
+
+class ContactStubHelper
+{
+public:
+ static void setPreferredNumber(QString number);
+ static QString preferredNumber();
+};
+
+
class ContactQueryResults : public QObject
{
Q_OBJECT
--- a/logsui/logscntfinder/tsrc/ut_logscntfinder/inc/ut_logscntfinder.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/tsrc/ut_logscntfinder/inc/ut_logscntfinder.h Wed Aug 18 09:49:12 2010 +0300
@@ -52,6 +52,8 @@
//with latin 12 keys
void testPredictiveSearchQuery_latin12k();
void testResultAt_latin12k();
+ void testPhoneNumber();
+ void testSetPreferDefaultNumber();
private:
--- a/logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logscntentry.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logscntentry.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -626,6 +626,11 @@
mEntry->setLastName( QString( "Ming" ) );
QVERIFY( mEntry->match( PATTERN( "02806" ) ) );
QVERIFY( mEntry->match( PATTERN( "0280" ) ) );//not supported
+
+ mEntry->setFirstName( QString("Ali") + QString( QChar(3) ) + QString("ce") );
+ QVERIFY( mEntry->match( PATTERN( "2" ) ) );//A
+ QVERIFY( mEntry->match( PATTERN( "254" ) ) );//Ali
+ QVERIFY( !mEntry->match( PATTERN( "25423" ) ) );//Alice
mEntry->mType = LogsCntEntry::EntryTypeContact;
QVERIFY( !mEntry->match( PATTERN( "+202" ) ) );
--- a/logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logscntfinder.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logscntfinder.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -17,6 +17,7 @@
#include "ut_logscntfinder.h"
#include "logscntfinder.h"
#include "qtcontacts_stubs.h"
+#include <qcontact.h>
#include <QtTest/QtTest>
#include <QSignalSpy>
@@ -551,9 +552,40 @@
LogsCntEntry* entry3 = mFinder->getEntry( *handle1 );
QVERIFY( entry3 == entry1 );
QVERIFY( entry3->firstName()[0].text() == QString("foo") );
- QVERIFY( entry3->lastName()[0].text() == QString("bar") );
-
+ QVERIFY( entry3->lastName()[0].text() == QString("bar") );
}
+void UT_LogsCntFinder::testPhoneNumber()
+{
+ QContact contact;
+
+ //Prefer default is not set, first number from the list returned
+ QVERIFY( !mFinder->mPreferDefaultNumber );
+ QCOMPARE( mFinder->phoneNumber(contact), cntDetailPhoneNumber );
+
+ //Prefer default is set
+ mFinder->mPreferDefaultNumber = true;
+ QCOMPARE( mFinder->phoneNumber(contact), ContactStubHelper::preferredNumber() );
+
+ //Prefer default is set, but no preferred number
+ ContactStubHelper::setPreferredNumber("");
+ QCOMPARE( mFinder->phoneNumber(contact), cntPhoneNumberWithActionCall );
+}
-
+void UT_LogsCntFinder::testSetPreferDefaultNumber()
+{
+ LogsCntEntryHandle* handle = (LogsCntEntryHandle*)1;
+ LogsCntEntry* entry = new LogsCntEntry(*handle, 0);
+ mFinder->mResults.append(entry);
+
+ // Search results exist, mPreferDefaultNumber not changed
+ QVERIFY( !mFinder->mPreferDefaultNumber );
+ mFinder->setPreferDefaultNumber(false);
+ QVERIFY( !mFinder->mPreferDefaultNumber );
+ QCOMPARE( mFinder->mResults.count(), 1 );
+
+ // Search results exist, mPreferDefaultNumber is changed => results are reset
+ mFinder->setPreferDefaultNumber(true);
+ QVERIFY( mFinder->mPreferDefaultNumber );
+ QCOMPARE( mFinder->mResults.count(), 0 );
+}
--- a/logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logspredictivelatin12keytranslator.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logspredictivelatin12keytranslator.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -183,6 +183,7 @@
QCOMPARE( mTranslator->translateChar( QChar('ä'), ok ), QChar('2') );
QCOMPARE( mTranslator->translateChar( QChar('Ä'), ok ), QChar('2') );
QCOMPARE( mTranslator->translateChar( QChar('-'), ok ), QChar('1') );
+ QCOMPARE( mTranslator->translateChar( QChar('%'), ok ), QChar('1') );
// Romanian unicode character "sh"
QCOMPARE( mTranslator->translateChar( QChar(0x0219), ok ), QChar('7') );
// Chinese unicode character
--- a/logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logspredictivetranslator.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logscntfinder/tsrc/ut_logscntfinder/src/ut_logspredictivetranslator.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -87,15 +87,20 @@
2 );
QVERIFY( ok );
- QString test2( "Hannu%");
- QCOMPARE( mTranslator->LogsPredictiveTranslator::translate( test2, &ok ).length(),test2.length() -1 );
+ QString test2("abc");
+ test2.append(QChar(9));
+ test2.append("efghijklmn");
+
+ QCOMPARE( mTranslator->LogsPredictiveTranslator::translate( test2, &ok ).length(),
+ 3);
+
QVERIFY( !ok );
}
void UT_LogsPredictiveTranslator::testTranslatePattern()
{
- QString test1( "12345" );
+ QString test1( "%12345" );
QCOMPARE( mTranslator->LogsPredictiveTranslator::translatePattern( test1 ).length(),
test1.length() );
@@ -105,13 +110,10 @@
void UT_LogsPredictiveTranslator::testTranslateText()
{
- QString test1( "12345" );
+ QString test1( "%12345" );
QCOMPARE( mTranslator->translateText( test1 ).length(), test1.length() );
- QString test2( "Hannu%");
- QCOMPARE( mTranslator->translateText( test2 ).length(), test2.length() - 1 );
-
QEXPECT_FAIL("", "No proper Thai keymap yet", Abort );
//text is thai, input lang latin
const int ucsize = 9;
@@ -138,11 +140,6 @@
QVERIFY( !mTranslator->mNameTranslator );
QCOMPARE( mTranslator->mib(), MIBenumLatin );
- //unmapped
- QString test2( "Hannu%");
- QCOMPARE( mTranslator->nameTranslator( test2 ).mib(), MIBenumLatin );
- QVERIFY( !mTranslator->mNameTranslator );
- QCOMPARE( mTranslator->mib(), MIBenumLatin );
QEXPECT_FAIL("", "No proper Thai keymap yet", Abort );
--- a/logsui/logsengine/bwins/logsengineu.def Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/bwins/logsengineu.def Wed Aug 18 09:49:12 2010 +0300
@@ -65,4 +65,5 @@
?getLogsEvent@LogsDetailsModel@@QBE?AVLogsEvent@@XZ @ 64 NONAME ; class LogsEvent LogsDetailsModel::getLogsEvent(void) const
?serialize@LogsEvent@@QAE_NAAVQDataStream@@@Z @ 65 NONAME ; bool LogsEvent::serialize(class QDataStream &)
??0LogsEvent@@QAE@AAVQDataStream@@@Z @ 66 NONAME ; LogsEvent::LogsEvent(class QDataStream &)
+ ?cancelServiceRequest@LogsContact@@QAEXXZ @ 67 NONAME ; void LogsContact::cancelServiceRequest(void)
--- a/logsui/logsengine/eabi/logsengineu.def Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/eabi/logsengineu.def Wed Aug 18 09:49:12 2010 +0300
@@ -91,4 +91,5 @@
_ZN9LogsEventC2ER11QDataStream @ 90 NONAME
_ZN9LogsModel16logsDetailsModelER9LogsEvent @ 91 NONAME
_ZNK16LogsDetailsModel12getLogsEventEv @ 92 NONAME
+ _ZN11LogsContact20cancelServiceRequestEv @ 93 NONAME
--- a/logsui/logsengine/inc/logscontact.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/inc/logscontact.h Wed Aug 18 09:49:12 2010 +0300
@@ -81,6 +81,10 @@
*/
LOGSENGINE_EXPORT bool updateExisting();
+ /**
+ * Cancel outstanding phonebook request(open(), addNew(), updateExisting())
+ */
+ LOGSENGINE_EXPORT void cancelServiceRequest();
signals:
--- a/logsui/logsengine/inc/logsmatchesmodel.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/inc/logsmatchesmodel.h Wed Aug 18 09:49:12 2010 +0300
@@ -80,6 +80,7 @@
void doSearchQuery();
void doModelReset();
void forceSearchQuery();
+ void contactUpdated(bool updated);
private:
--- a/logsui/logsengine/logsengine.pro Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logsengine.pro Wed Aug 18 09:49:12 2010 +0300
@@ -46,8 +46,11 @@
HEADERS += inc/logscommondata.h
HEADERS += inc/logsconfigurationparams.h
HEADERS += logssymbianos/inc/logsdbconnector.h
+HEADERS += logssymbianos/inc/logsworker.h
HEADERS += logssymbianos/inc/logsreader.h
+HEADERS += logssymbianos/inc/logsstatebase.h
HEADERS += logssymbianos/inc/logsreaderstates.h
+HEADERS += logssymbianos/inc/logsremovestates.h
HEADERS += logssymbianos/inc/logsreaderstatecontext.h
HEADERS += logssymbianos/inc/logseventparser.h
HEADERS += logssymbianos/inc/logseventdataparser.h
@@ -68,8 +71,11 @@
SOURCES += src/logscommondata.cpp
SOURCES += src/logsconfigurationparams.cpp
SOURCES += logssymbianos/src/logsdbconnector.cpp
+SOURCES += logssymbianos/src/logsworker.cpp
SOURCES += logssymbianos/src/logsreader.cpp
+SOURCES += logssymbianos/src/logsstatebase.cpp
SOURCES += logssymbianos/src/logsreaderstates.cpp
+SOURCES += logssymbianos/src/logsremovestates.cpp
SOURCES += logssymbianos/src/logseventparser.cpp
SOURCES += logssymbianos/src/logseventdataparser.cpp
SOURCES += logssymbianos/src/logsremove.cpp
--- a/logsui/logsengine/logssymbianos/inc/logsreader.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/inc/logsreader.h Wed Aug 18 09:49:12 2010 +0300
@@ -24,6 +24,7 @@
#include <e32base.h>
#include <logclientchangeobserver.h>
#include <logviewchangeobserver.h>
+#include "logsworker.h"
#include "logsreaderstatecontext.h"
#include "logsreaderstates.h"
@@ -44,7 +45,7 @@
/**
* LogsReader is used to read events from database
*/
-class LogsReader : public CActive,
+class LogsReader : public LogsWorker,
public MLogClientChangeObserver,
public MLogViewChangeObserver,
public LogsReaderStateContext
@@ -117,8 +118,6 @@
protected: // From CActive
- void RunL();
- void DoCancel();
TInt RunError(TInt error);
private: // From MLogClientChangeObserver
@@ -142,19 +141,11 @@
TInt aChangeIndex, TInt aTotalChangeCount);
private: // From LogsReaderStateContext
-
- inline void setCurrentState(const LogsReaderStateBase& state);
- inline CLogView& logView();
- inline CLogViewDuplicate& duplicatesView();
+
inline QList<LogsEvent*>& events();
- inline int& index();
inline LogsEventStrings& strings();
- inline TRequestStatus& reqStatus();
inline LogsReaderObserver& observer();
inline QHash<QString, ContactCacheEntry>& contactCache();
- inline int currentEventId();
- inline CLogClient& logClient();
- inline bool isRecentView();
inline QList<LogsEvent*>& duplicatedEvents();
private:
@@ -168,7 +159,6 @@
* in progress, it will leave with error
*/
void cancelCurrentRequestL();
- LogsReaderStateBase& currentState();
void initializeReadStates();
void initializeModifyingStates();
void initializeDuplicateReadingStates();
@@ -183,28 +173,18 @@
private: // data
- CLogViewRecent* mLogViewRecent;
- CLogViewEvent* mLogViewEvent;
- CLogViewDuplicate* mDuplicatesView;
-
RFs& mFsSession;
- CLogClient& mLogClient;
LogsEventStrings& mStrings;
QList<LogsEvent*>& mEvents;
LogsReaderObserver& mObserver;
- bool mReadAllEvents;
-
- int mIndex;
- QList<LogsReaderStateBase*> mReadStates;
- QList<LogsReaderStateBase*> mModifyingStates;
- QList<LogsReaderStateBase*> mDuplicateReadingStates;
- int mCurrentStateIndex;
- QList<LogsReaderStateBase*>* mCurrentStateMachine;
-
+
+ QList<LogsStateBase*> mReadStates;
+ QList<LogsStateBase*> mModifyingStates;
+ QList<LogsStateBase*> mDuplicateReadingStates;
+
QHash<QString, ContactCacheEntry> mContactCache;
QList<LogsEvent*> mDuplicatedEvents;
- int mCurrentEventId;
bool mGlobalObserverSet;
};
--- a/logsui/logsengine/logssymbianos/inc/logsreaderstatecontext.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/inc/logsreaderstatecontext.h Wed Aug 18 09:49:12 2010 +0300
@@ -24,14 +24,9 @@
// FORWARD DECLARATION
class LogsReaderStateBase;
-class CLogView;
-class CLogViewDuplicate;
-class CLogViewEvent;
class LogsEvent;
class LogsEventStrings;
-class TRequestStatus;
class LogsReaderObserver;
-class CLogClient;
// CLASS DECLARATION
@@ -45,7 +40,6 @@
QString mRemoteParty;
unsigned int mContactLocalId;
};
-
/**
* Context for reader state machine
@@ -54,48 +48,17 @@
public:
/**
- * Change state
- * @param state, new state
- */
- virtual void setCurrentState(const LogsReaderStateBase& state) = 0;
-
- /**
- * Get log view
- * @return current log view
- */
- virtual CLogView& logView() = 0;
-
- /**
- * Get duplicates view
- * @return current duplicates view
- */
- virtual CLogViewDuplicate& duplicatesView() = 0;
-
- /**
* Get event container
* @return events
*/
virtual QList<LogsEvent*>& events() = 0;
/**
- * Get view index
- * @return ref to view index
- */
- virtual int& index() = 0;
-
- /**
* Get commonly used strings
* @return strings
*/
virtual LogsEventStrings& strings() = 0;
-
- /**
- * Request status for async operations
- * inside states
- * @return reqstatus
- */
- virtual TRequestStatus& reqStatus() = 0;
-
+
/**
* Get observer
* @return observer
@@ -109,24 +72,6 @@
virtual QHash<QString, ContactCacheEntry>& contactCache() = 0;
/**
- * Get ID of the event to be handled
- * @return ID of the event
- */
- virtual int currentEventId() = 0;
-
- /**
- * Get log client
- * @return log client
- */
- virtual CLogClient& logClient() = 0;
-
- /**
- * Check if current view is recent view.
- * @return true if recent view
- */
- virtual bool isRecentView() = 0;
-
- /**
* Get event container for duplicated events
* @return duplicated events
*/
--- a/logsui/logsengine/logssymbianos/inc/logsreaderstates.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/inc/logsreaderstates.h Wed Aug 18 09:49:12 2010 +0300
@@ -19,6 +19,7 @@
#define LOGSREADERSTATES_H
// INCLUDES
+#include "logsstatebase.h"
#include <e32std.h>
#include <logclientchangeobserver.h>
#include <logviewchangeobserver.h>
@@ -36,7 +37,7 @@
/**
* Reader state base
*/
-class LogsReaderStateBase {
+class LogsReaderStateBase : public LogsStateBase {
friend class UT_LogsReaderStates;
friend class UT_LogsReader;
@@ -47,49 +48,13 @@
* Destructor
*/
virtual ~LogsReaderStateBase();
-
- /**
- * Set next state to be used once this state has completed.
- * @param nextState
- */
- void setNextState(LogsReaderStateBase& nextState);
-
- /**
- * Enter to the state, may proceed immediately to next state.
- * @return true if entering started async operation, false if not
- */
- virtual bool enterL();
-
- /**
- * Continue running in the state, may proceed to next state
- * @return true if continue started async operation, false if not
- */
- virtual bool continueL();
protected:
/**
* Constructor
*/
- LogsReaderStateBase(LogsReaderStateContext& context);
-
- /**
- * Proceed to next state if such exists.
- * @return true if entering started async operation, false if not
- */
- virtual bool enterNextStateL();
-
- /**
- * Get number of events in view
- * @return view count
- */
- int viewCountL() const;
-
- /**
- * Get current event
- * @return event
- */
- CLogEvent& event() const;
+ LogsReaderStateBase(LogsStateBaseContext& context, LogsReaderStateContext& readerContext);
/**
* Fill dest event with source event data and insert to specified
@@ -133,18 +98,9 @@
* @return pointer to event or 0 if not found
*/
LogsEvent* eventById(int eventId);
-
- /**
- * Try to search duplicates for current event in the view
- * @param aFilter, filter to be used for searching duplicates
- * @return true, if duplicates are searched
- */
- bool duplicatesL(const CLogFilter* aFilter = 0);
protected:
LogsReaderStateContext& mContext;
- LogsReaderStateBase* mNextState;
- int mStateIndex;
};
/**
@@ -155,7 +111,7 @@
friend class UT_LogsReaderStates;
public:
- LogsReaderStateInitReading(LogsReaderStateContext& context);
+ LogsReaderStateInitReading(LogsStateBaseContext& context, LogsReaderStateContext& readerContext);
virtual ~LogsReaderStateInitReading(){}
public: // From LogsReaderStateBase
@@ -170,7 +126,7 @@
friend class UT_LogsReaderStates;
public:
- LogsReaderStateFiltering(LogsReaderStateContext& context);
+ LogsReaderStateFiltering(LogsStateBaseContext& context, LogsReaderStateContext& readerContext);
virtual ~LogsReaderStateFiltering();
public: // From LogsReaderStateBase
@@ -196,7 +152,7 @@
friend class UT_LogsReaderStates;
public:
- LogsReaderStateFilteringAll(LogsReaderStateContext& context);
+ LogsReaderStateFilteringAll(LogsStateBaseContext& context, LogsReaderStateContext& readerContext);
virtual ~LogsReaderStateFilteringAll();
protected: // From LogsReaderStateFiltering
@@ -211,7 +167,7 @@
friend class UT_LogsReaderStates;
public:
- LogsReaderStateReading(LogsReaderStateContext& context);
+ LogsReaderStateReading(LogsStateBaseContext& context, LogsReaderStateContext& readerContext);
virtual ~LogsReaderStateReading();
public: // From LogsReaderStateBase
@@ -235,7 +191,7 @@
*/
class LogsReaderStateFillDetails : public LogsReaderStateBase {
public:
- LogsReaderStateFillDetails(LogsReaderStateContext& context);
+ LogsReaderStateFillDetails(LogsStateBaseContext& context, LogsReaderStateContext& readerContext);
virtual ~LogsReaderStateFillDetails();
/**
@@ -252,30 +208,13 @@
*/
class LogsReaderStateDone : public LogsReaderStateBase {
public:
- LogsReaderStateDone(LogsReaderStateContext& context);
+ LogsReaderStateDone(LogsStateBaseContext& context, LogsReaderStateContext& readerContext);
virtual ~LogsReaderStateDone();
public: // From LogsReaderStateBase
virtual bool enterL();
};
-
-/**
- * Searching event state
- */
-class LogsReaderStateSearchingEvent : public LogsReaderStateBase
-{
- friend class UT_LogsReaderStates;
-
- public:
- LogsReaderStateSearchingEvent(LogsReaderStateContext& context);
- virtual ~LogsReaderStateSearchingEvent(){}
-
- public: // From LogsReaderStateBase
- virtual bool enterL();
- virtual bool continueL();
-};
-
/**
* Finding duplicate events state
*/
@@ -284,7 +223,7 @@
friend class UT_LogsReaderStates;
public:
- LogsReaderStateFindingDuplicates(LogsReaderStateContext& context);
+ LogsReaderStateFindingDuplicates(LogsStateBaseContext& context, LogsReaderStateContext& readerContext);
virtual ~LogsReaderStateFindingDuplicates();
public: // From LogsReaderStateBase
@@ -303,7 +242,7 @@
friend class UT_LogsReaderStates;
public:
- LogsReaderStateMarkingDuplicates(LogsReaderStateContext& context);
+ LogsReaderStateMarkingDuplicates(LogsStateBaseContext& context, LogsReaderStateContext& readerContext);
virtual ~LogsReaderStateMarkingDuplicates(){}
public: // From LogsReaderStateBase
@@ -322,7 +261,7 @@
friend class UT_LogsReaderStates;
public:
- LogsReaderStateReadingDuplicates(LogsReaderStateContext& context);
+ LogsReaderStateReadingDuplicates(LogsStateBaseContext& context, LogsReaderStateContext& readerContext);
virtual ~LogsReaderStateReadingDuplicates(){}
public: // From LogsReaderStateBase
@@ -338,7 +277,7 @@
friend class UT_LogsReaderStates;
public:
- LogsReaderStateModifyingDone(LogsReaderStateContext& context);
+ LogsReaderStateModifyingDone(LogsStateBaseContext& context, LogsReaderStateContext& readerContext);
virtual ~LogsReaderStateModifyingDone(){}
public: // From LogsReaderStateBase
@@ -353,7 +292,7 @@
friend class UT_LogsReaderStates;
public:
- LogsReaderStateReadingDuplicatesDone(LogsReaderStateContext& context);
+ LogsReaderStateReadingDuplicatesDone(LogsStateBaseContext& context, LogsReaderStateContext& readerContext);
virtual ~LogsReaderStateReadingDuplicatesDone(){}
public: // From LogsReaderStateBase
--- a/logsui/logsengine/logssymbianos/inc/logsremove.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/inc/logsremove.h Wed Aug 18 09:49:12 2010 +0300
@@ -19,7 +19,9 @@
#include <QObject>
#include <e32base.h>
+#include "logsworker.h"
#include "logsmodel.h"
+#include "logsremovestatecontext.h"
// FORWARDS DECLARATIONS
class CLogClient;
@@ -31,7 +33,7 @@
/**
* Clearing class.
*/
-class LogsRemove : public CActive
+class LogsRemove : public LogsWorker, public LogsRemoveStateContext
{
public:
friend class UT_LogsRemove;
@@ -55,25 +57,34 @@
int clearEvents(const QList<int>& eventIds, bool& async);
protected: // from CActive
-
- void DoCancel();
- void RunL();
+
TInt RunError(TInt aError);
+ private: // From LogsRemoveStateContext
+
+ inline LogsRemoveObserver& observer();
+ inline QList<int>& removedEvents();
+ inline int clearType();
+
private:
void initL();
+ bool clearListL(LogsModel::ClearType cleartype);
void clearEventsL(const QList<int>& eventIds, bool& async);
- bool DeleteNextEvent();
+ void initializeClearAllL();
+ void initializeIdBasedRemovalL();
+ bool startClearingL();
private: // data
LogsRemoveObserver& mObserver;
- bool mReadingAllEvents;
+ QList<int> mRemovedEvents;
+
+ RFs* mFsSession;
- QList<int> mRemovedEvents;
- CLogClient* mLogClient;
- CLogViewRecent* mRecentView;
- RFs* mFsSession;
+ int mClearType;
+ QList<LogsStateBase*> mRemoveStates;
+ QList<LogsStateBase*> mClearAllStates;
+
};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/logsui/logsengine/logssymbianos/inc/logsremovestatecontext.h Wed Aug 18 09:49:12 2010 +0300
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef LOGSREMOVESTATECONTEXT_H
+#define LOGSREMOVESTATECONTEXT_H
+
+// INCLUDES
+#include <QList>
+
+// FORWARD DECLARATION
+class LogsRemoveObserver;
+
+// CLASS DECLARATION
+
+/**
+ * Context for remove state machine
+ */
+class LogsRemoveStateContext {
+ public:
+
+ /**
+ * Get observer
+ * @return observer
+ */
+ virtual LogsRemoveObserver& observer() = 0;
+
+ /**
+ * Get ids of removed events
+ * @return ids of removed events
+ */
+ virtual QList<int>& removedEvents() = 0;
+
+ virtual int clearType() = 0;
+
+};
+
+
+#endif // LOGSREADERSTATECONTEXT_H
+
+
+// End of File
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/logsui/logsengine/logssymbianos/inc/logsremovestates.h Wed Aug 18 09:49:12 2010 +0300
@@ -0,0 +1,149 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef LOGSREMOVESTATES_H
+#define LOGSREMOVESTATES_H
+
+// INCLUDES
+#include <QList>
+#include "logsstatebase.h"
+
+class LogsRemoveStateContext;
+
+/**
+ * Base for remove states
+ */
+class LogsRemoveStateBase : public LogsStateBase {
+
+ friend class UT_LogsRemoveStates;
+
+ public:
+ LogsRemoveStateBase(LogsStateBaseContext& context, LogsRemoveStateContext& removeContext);
+ virtual ~LogsRemoveStateBase(){}
+
+ protected:
+ LogsRemoveStateContext& mContext;
+};
+
+/**
+ * State for clearing all events or specific event types from main db view
+ */
+class LogsRemoveStateClearAll : public LogsRemoveStateBase {
+
+ friend class UT_LogsRemoveStates;
+
+ public:
+ LogsRemoveStateClearAll(
+ LogsStateBaseContext& context, LogsRemoveStateContext& removeContext) :
+ LogsRemoveStateBase(context, removeContext) {}
+ virtual ~LogsRemoveStateClearAll(){}
+
+ public: // From LogsReaderStateBase
+ virtual bool enterL();
+ virtual bool continueL();
+};
+
+/**
+ * State for initializing removal from recent db view
+ */
+class LogsRemoveStateInit : public LogsRemoveStateBase {
+
+ friend class UT_LogsRemoveStates;
+
+ public:
+ LogsRemoveStateInit(
+ LogsStateBaseContext& context, LogsRemoveStateContext& removeContext) :
+ LogsRemoveStateBase(context, removeContext) {}
+ virtual ~LogsRemoveStateInit(){}
+
+ public: // From LogsReaderStateBase
+ virtual bool enterL();
+ virtual bool continueL();
+};
+
+/**
+ * State for event id based deletion of events from main db view
+ */
+class LogsRemoveStateDelete : public LogsRemoveStateBase {
+
+ friend class UT_LogsRemoveStates;
+
+ public:
+ LogsRemoveStateDelete(
+ LogsStateBaseContext& context, LogsRemoveStateContext& removeContext) :
+ LogsRemoveStateBase(context, removeContext), mRemoveIndex(0) {}
+ virtual ~LogsRemoveStateDelete(){}
+
+ public: // From LogsReaderStateBase
+ virtual bool enterL();
+ virtual bool continueL();
+ protected:
+ bool deleteNextEvent();
+ protected:
+ int mRemoveIndex;
+};
+
+/**
+ * State for deleting duplicate events from recent db view
+ */
+class LogsRemoveStateDeleteDuplicates : public LogsRemoveStateBase {
+
+ friend class UT_LogsRemoveStates;
+
+ public:
+ LogsRemoveStateDeleteDuplicates(
+ LogsStateBaseContext& context, LogsRemoveStateContext& removeContext) :
+ LogsRemoveStateBase(context, removeContext) {}
+ virtual ~LogsRemoveStateDeleteDuplicates(){}
+
+ public: // From LogsReaderStateBase
+ virtual bool enterL();
+ virtual bool continueL();
+ protected:
+ bool deleteNextEvent();
+ protected:
+ bool mDeleting;
+ QList<int> mDeleteDuplicateIds;
+};
+
+/**
+ * Completion state
+ */
+class LogsRemoveStateDone : public LogsRemoveStateBase {
+
+ friend class UT_LogsRemoveStates;
+
+ public:
+ LogsRemoveStateDone(
+ LogsStateBaseContext& context, LogsRemoveStateContext& removeContext) :
+ LogsRemoveStateBase(context, removeContext) {}
+ virtual ~LogsRemoveStateDone(){}
+
+ public: // From LogsReaderStateBase
+ virtual bool enterL();
+};
+
+
+
+#endif // LOGSREMOVESTATES_H
+
+
+// End of File
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/logsui/logsengine/logssymbianos/inc/logsstatebase.h Wed Aug 18 09:49:12 2010 +0300
@@ -0,0 +1,130 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef LOGSSTATEBASE_H
+#define LOGSSTATEBASE_H
+
+// INCLUDES
+#include <e32std.h>
+
+// FORWARD DECLARATION
+class LogsStateBaseContext;
+class CLogViewEvent;
+class CLogFilterList;
+class CLogFilter;
+class CLogEvent;
+
+// CLASS DECLARATION
+
+/**
+ * Reader state base
+ */
+class LogsStateBase {
+
+ friend class UT_LogsReaderStates;
+ friend class UT_LogsReader;
+
+ public:
+
+ /**
+ * Destructor
+ */
+ virtual ~LogsStateBase();
+
+ /**
+ * Set next state to be used once this state has completed.
+ * @param nextState
+ */
+ void setNextState(LogsStateBase& nextState);
+
+ /**
+ * Enter to the state, may proceed immediately to next state.
+ * @return true if entering started async operation, false if not
+ */
+ virtual bool enterL();
+
+ /**
+ * Continue running in the state, may proceed to next state
+ * @return true if continue started async operation, false if not
+ */
+ virtual bool continueL();
+
+ protected:
+
+ /**
+ * Constructor
+ */
+ LogsStateBase(LogsStateBaseContext& context);
+
+ /**
+ * Proceed to next state if such exists.
+ * @return true if entering started async operation, false if not
+ */
+ virtual bool enterNextStateL();
+
+ /**
+ * Get number of events in view
+ * @return view count
+ */
+ int viewCountL() const;
+
+ /**
+ * Get current event
+ * @return event
+ */
+ CLogEvent& event() const;
+
+ /**
+ * Try to search duplicates for current event in the view
+ * @param aFilter, filter to be used for searching duplicates
+ * @return true, if duplicates are searched
+ */
+ bool duplicatesL(const CLogFilter* aFilter = 0);
+
+ protected:
+ LogsStateBaseContext& mBaseContext;
+ LogsStateBase* mNextState;
+ int mStateIndex;
+};
+
+
+
+/**
+ * Searching event state
+ */
+class LogsStateSearchingEvent : public LogsStateBase
+{
+ friend class UT_LogsReaderStates;
+
+ public:
+ LogsStateSearchingEvent(LogsStateBaseContext& context);
+ virtual ~LogsStateSearchingEvent(){}
+
+ public: // From LogsReaderStateBase
+ virtual bool enterL();
+ virtual bool continueL();
+};
+
+
+#endif // LOGSSTATEBASE_H
+
+
+// End of File
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/logsui/logsengine/logssymbianos/inc/logsstatebasecontext.h Wed Aug 18 09:49:12 2010 +0300
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef LOGSSTATEBASECONTEXT_H
+#define LOGSSTATEBASECONTEXT_H
+
+// INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATION
+class LogsStateBase;
+class CLogView;
+class CLogViewDuplicate;
+class CLogViewEvent;
+class TRequestStatus;
+class CLogClient;
+
+// CLASS DECLARATION
+
+/**
+ * Context base for state machines
+ */
+class LogsStateBaseContext {
+ public:
+
+ /**
+ * Change state
+ * @param state, new state
+ */
+ virtual void setCurrentState(const LogsStateBase& state) = 0;
+
+ /**
+ * Get log view
+ * @return current log view
+ */
+ virtual CLogView& logView() = 0;
+
+ /**
+ * Get duplicates view
+ * @return current duplicates view
+ */
+ virtual CLogViewDuplicate& duplicatesView() = 0;
+
+ /**
+ * Get view index
+ * @return ref to view index
+ */
+ virtual int& index() = 0;
+
+ /**
+ * Request status for async operations
+ * inside states
+ * @return reqstatus
+ */
+ virtual TRequestStatus& reqStatus() = 0;
+
+ /**
+ * Get ID of the event to be handled
+ * @return ID of the event
+ */
+ virtual int currentEventId() = 0;
+
+ /**
+ * Get log client
+ * @return log client
+ */
+ virtual CLogClient& logClient() = 0;
+
+ /**
+ * Check if current view is recent view.
+ * @return true if recent view
+ */
+ virtual bool isRecentView() = 0;
+
+};
+
+
+#endif // LOGSSTATEBASECONTEXT_H
+
+
+// End of File
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/logsui/logsengine/logssymbianos/inc/logsworker.h Wed Aug 18 09:49:12 2010 +0300
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef LOGSWORKER_H
+#define LOGSWORKER_H
+
+// INCLUDES
+#include <QList>
+#include <e32base.h>
+#include "logsstatebasecontext.h"
+
+// FORWARD DECLARATION
+class CLogViewRecent;
+class CLogClient;
+class CLogViewEvent;
+class CLogViewDuplicate;
+class LogsStateBase;
+
+// CLASS DECLARATION
+
+
+
+/**
+ * LogsReader is used to read events from database
+ */
+class LogsWorker : public CActive,
+ public LogsStateBaseContext
+ {
+
+ friend class UT_LogsReader;
+ friend class UT_LogsDbConnector;
+
+ public:
+
+ /**
+ * Constructor
+ * @param readAllEvents, true if all events in db should be read,
+ * otherwise only recent events are read
+ */
+ LogsWorker( bool readAllEvents = false );
+
+ /**
+ * Destructor.
+ */
+ virtual ~LogsWorker();
+
+ protected: // From CActive
+
+ void RunL();
+ void DoCancel();
+ TInt RunError(TInt error);
+
+ protected: // From LogsStateBaseContext
+
+ inline void setCurrentState(const LogsStateBase& state);
+ inline CLogView& logView();
+ inline CLogViewDuplicate& duplicatesView();
+ inline int& index();
+ inline TRequestStatus& reqStatus();
+ inline int currentEventId();
+ inline CLogClient& logClient();
+ inline bool isRecentView();
+
+ protected:
+
+ LogsStateBase& currentState();
+
+ protected: // data
+
+ bool mReadAllEvents;
+
+ CLogClient* mLogClient;
+ CLogViewRecent* mLogViewRecent;
+ CLogViewEvent* mLogViewEvent;
+ CLogViewDuplicate* mDuplicatesView;
+
+ int mIndex;
+ int mCurrentStateIndex;
+ QList<LogsStateBase*>* mCurrentStateMachine;
+ int mCurrentEventId;
+ };
+
+#endif // LOGSWORKER_H
+
+
+// End of File
+
+
+
+
--- a/logsui/logsengine/logssymbianos/src/logsreader.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/src/logsreader.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -37,28 +37,17 @@
QList<LogsEvent*>& events,
LogsReaderObserver& observer,
bool readAllEvents)
- : CActive( EPriorityStandard ),
- mLogViewRecent(0),
- mLogViewEvent(0),
- mDuplicatesView(0),
+ : LogsWorker(readAllEvents),
mFsSession(fsSession),
- mLogClient(logClient),
mStrings(strings),
mEvents(events),
mObserver(observer),
- mReadAllEvents(readAllEvents),
- mIndex(0),
- mCurrentStateIndex(0),
- mCurrentStateMachine(0),
- mCurrentEventId(-1),
mGlobalObserverSet(false)
{
LOGS_QDEBUG( "logs [ENG] -> LogsReader::LogsReader()" )
-
- CActiveScheduler::Add( this );
-
- initializeReadStates();
-
+
+ mLogClient = &logClient;
+ initializeReadStates();
setGlobalObserver();
LOGS_QDEBUG( "logs [ENG] <- LogsReader::LogsReader()" )
@@ -77,8 +66,11 @@
qDeleteAll( mModifyingStates );
qDeleteAll( mDuplicateReadingStates );
delete mLogViewRecent;
+ mLogViewRecent = 0;
delete mLogViewEvent;
+ mLogViewEvent = 0;
delete mDuplicatesView;
+ mDuplicatesView = 0;
qDeleteAll( mDuplicatedEvents );
LOGS_QDEBUG( "logs [ENG] <- LogsReader::~LogsReader()" )
@@ -127,7 +119,7 @@
mContactCache.clear();
}
LogsReaderStateFillDetails* fillDetailsState =
- new LogsReaderStateFillDetails(*this);
+ new LogsReaderStateFillDetails(*this, *this);
fillDetailsState->fillDetails();
delete fillDetailsState;
LOGS_QDEBUG( "logs [ENG] <- LogsReader::updateDetails()" )
@@ -158,25 +150,6 @@
}
// ----------------------------------------------------------------------------
-// LogsReader::RunL
-// ----------------------------------------------------------------------------
-//
-void LogsReader::RunL()
-{
- LOGS_QDEBUG_3( "logs [ENG] -> LogsReader::RunL(), (state, status):",
- mCurrentStateIndex, iStatus.Int() )
-
- // Error handling in RunError
- __ASSERT_ALWAYS( iStatus.Int() == KErrNone, User::Leave( iStatus.Int() ) );
-
- if ( currentState().continueL() ){
- SetActive();
- }
-
- LOGS_QDEBUG( "logs [ENG] <- LogsReader::RunL()" )
-}
-
-// ----------------------------------------------------------------------------
// LogsReader::RunError
// ----------------------------------------------------------------------------
//
@@ -191,17 +164,6 @@
}
// ----------------------------------------------------------------------------
-// LogsReader::DoCancel
-// ----------------------------------------------------------------------------
-//
-void LogsReader::DoCancel()
-{
- logView().Cancel();
- mDuplicatesView->Cancel();
- mLogClient.Cancel();
-}
-
-// ----------------------------------------------------------------------------
// LogsReader::startL
// ----------------------------------------------------------------------------
//
@@ -375,44 +337,6 @@
}
// ----------------------------------------------------------------------------
-// LogsReader::setCurrentState
-// ----------------------------------------------------------------------------
-//
-void LogsReader::setCurrentState(const LogsReaderStateBase& state)
-{
- bool found(false);
- for( int i = 0; i < mCurrentStateMachine->count() && !found; i++ ){
- if ( mCurrentStateMachine->at(i) == &state ){
- mCurrentStateIndex = i;
- found = true;
- LOGS_QDEBUG_2( "logs [ENG] <-> LogsReader::setCurrentState, index:",
- mCurrentStateIndex )
- }
- }
-}
-
-// ----------------------------------------------------------------------------
-// LogsReader::logView
-// ----------------------------------------------------------------------------
-//
-CLogView& LogsReader::logView()
-{
- if ( mLogViewRecent ){
- return *mLogViewRecent;
- }
- return *mLogViewEvent;
-}
-
-// ----------------------------------------------------------------------------
-// LogsReader::duplicatesView
-// ----------------------------------------------------------------------------
-//
-CLogViewDuplicate& LogsReader::duplicatesView()
-{
- return *mDuplicatesView;
-}
-
-// ----------------------------------------------------------------------------
// LogsReader::events
// ----------------------------------------------------------------------------
//
@@ -422,15 +346,6 @@
}
// ----------------------------------------------------------------------------
-// LogsReader::index
-// ----------------------------------------------------------------------------
-//
-int& LogsReader::index()
-{
- return mIndex;
-}
-
-// ----------------------------------------------------------------------------
// LogsReader::strings
// ----------------------------------------------------------------------------
//
@@ -440,15 +355,6 @@
}
// ----------------------------------------------------------------------------
-// LogsReader::reqStatus
-// ----------------------------------------------------------------------------
-//
-TRequestStatus& LogsReader::reqStatus()
-{
- return iStatus;
-}
-
-// ----------------------------------------------------------------------------
// LogsReader::observer
// ----------------------------------------------------------------------------
//
@@ -467,33 +373,6 @@
}
// ----------------------------------------------------------------------------
-// LogsReader::currentEventId
-// ----------------------------------------------------------------------------
-//
-int LogsReader::currentEventId()
-{
- return mCurrentEventId;
-}
-
-// ----------------------------------------------------------------------------
-// LogsReader::logClient
-// ----------------------------------------------------------------------------
-//
-CLogClient& LogsReader::logClient()
-{
- return mLogClient;
-}
-
-// ----------------------------------------------------------------------------
-// LogsReader::isRecentView
-// ----------------------------------------------------------------------------
-//
-bool LogsReader::isRecentView()
-{
- return ( mLogViewRecent != 0 );
-}
-
-// ----------------------------------------------------------------------------
// LogsReader::duplicatedEvents
// ----------------------------------------------------------------------------
//
@@ -503,15 +382,6 @@
}
// ----------------------------------------------------------------------------
-// LogsReader::currentState
-// ----------------------------------------------------------------------------
-//
-LogsReaderStateBase& LogsReader::currentState()
-{
- return *(mCurrentStateMachine->at(mCurrentStateIndex));
-}
-
-// ----------------------------------------------------------------------------
// LogsReader::initializeReadStates
// ----------------------------------------------------------------------------
//
@@ -519,11 +389,11 @@
{
if ( mReadStates.count() == 0 ){
- LogsReaderStateInitReading* init = new LogsReaderStateInitReading(*this);
+ LogsReaderStateInitReading* init = new LogsReaderStateInitReading(*this, *this);
LogsReaderStateFiltering* filtering = createFilteringState();
- LogsReaderStateReading* reading = new LogsReaderStateReading(*this);
- LogsReaderStateFillDetails* fillDetails = new LogsReaderStateFillDetails(*this);
- LogsReaderStateDone* done = new LogsReaderStateDone(*this);
+ LogsReaderStateReading* reading = new LogsReaderStateReading(*this, *this);
+ LogsReaderStateFillDetails* fillDetails = new LogsReaderStateFillDetails(*this, *this);
+ LogsReaderStateDone* done = new LogsReaderStateDone(*this, *this);
init->setNextState(*filtering);
filtering->setNextState(*reading);
reading->setNextState(*fillDetails);
@@ -546,14 +416,14 @@
{
if ( mDuplicateReadingStates.count() == 0 ){
LogsReaderStateFiltering* filtering = createFilteringState();
- LogsReaderStateSearchingEvent* searching =
- new LogsReaderStateSearchingEvent(*this);
+ LogsStateSearchingEvent* searching =
+ new LogsStateSearchingEvent(*this);
LogsReaderStateFindingDuplicates* findingDuplicates =
- new LogsReaderStateFindingDuplicates(*this);
+ new LogsReaderStateFindingDuplicates(*this, *this);
LogsReaderStateReadingDuplicates* readingDuplicates =
- new LogsReaderStateReadingDuplicates(*this);
+ new LogsReaderStateReadingDuplicates(*this, *this);
LogsReaderStateReadingDuplicatesDone* done =
- new LogsReaderStateReadingDuplicatesDone(*this);
+ new LogsReaderStateReadingDuplicatesDone(*this, *this);
filtering->setNextState(*searching);
searching->setNextState(*findingDuplicates);
findingDuplicates->setNextState(*readingDuplicates);
@@ -576,11 +446,11 @@
{
if ( mModifyingStates.count() == 0 ){
LogsReaderStateFiltering* filtering = createFilteringState();
- LogsReaderStateSearchingEvent* searching =
- new LogsReaderStateSearchingEvent(*this);
+ LogsStateSearchingEvent* searching =
+ new LogsStateSearchingEvent(*this);
LogsReaderStateMarkingDuplicates* duplicates =
- new LogsReaderStateMarkingDuplicates(*this);
- LogsReaderStateModifyingDone* done = new LogsReaderStateModifyingDone(*this);
+ new LogsReaderStateMarkingDuplicates(*this, *this);
+ LogsReaderStateModifyingDone* done = new LogsReaderStateModifyingDone(*this, *this);
filtering->setNextState(*searching);
searching->setNextState(*duplicates);
duplicates->setNextState(*done);
@@ -629,15 +499,15 @@
{
if ( mReadAllEvents ){
if ( !mLogViewEvent ){
- mLogViewEvent = CLogViewEvent::NewL( mLogClient, *this );
+ mLogViewEvent = CLogViewEvent::NewL( *mLogClient, *this );
}
}
else if ( !mLogViewRecent ) {
- mLogViewRecent = CLogViewRecent::NewL( mLogClient, *this );
+ mLogViewRecent = CLogViewRecent::NewL( *mLogClient, *this );
}
if ( !mDuplicatesView ){
- mDuplicatesView = CLogViewDuplicate::NewL( mLogClient, *this );
+ mDuplicatesView = CLogViewDuplicate::NewL( *mLogClient, *this );
}
}
@@ -663,10 +533,10 @@
{
LogsReaderStateFiltering* filtering = 0;
if ( mReadAllEvents ) {
- filtering = new LogsReaderStateFilteringAll(*this);
+ filtering = new LogsReaderStateFilteringAll(*this, *this);
}
else {
- filtering = new LogsReaderStateFiltering(*this);
+ filtering = new LogsReaderStateFiltering(*this, *this);
}
return filtering;
}
@@ -695,7 +565,7 @@
// Have to ensure that same observer is not set twice, otherwise
// causes crash at later point inside eventlogger
if ( !mGlobalObserverSet ){
- TRAP_IGNORE( mLogClient.SetGlobalChangeObserverL( this ) )
+ TRAP_IGNORE( mLogClient->SetGlobalChangeObserverL( this ) )
mGlobalObserverSet = true;
}
}
@@ -707,7 +577,7 @@
void LogsReader::clearGlobalObserver()
{
if ( mGlobalObserverSet ){
- TRAP_IGNORE( mLogClient.SetGlobalChangeObserverL( 0 ) )
+ TRAP_IGNORE( mLogClient->SetGlobalChangeObserverL( 0 ) )
mGlobalObserverSet = false;
}
}
--- a/logsui/logsengine/logssymbianos/src/logsreaderstates.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/src/logsreaderstates.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -20,6 +20,7 @@
#include <logview.h>
#include <logwraplimits.h>
#include "logsreaderstates.h"
+#include "logsstatebasecontext.h"
#include "logsreaderstatecontext.h"
#include "logsevent.h"
#include "logseventdata.h"
@@ -35,9 +36,9 @@
// ----------------------------------------------------------------------------
//
LogsReaderStateBase::LogsReaderStateBase(
- LogsReaderStateContext& context)
- : mContext(context),
- mNextState(0)
+ LogsStateBaseContext& context, LogsReaderStateContext& readerContext)
+ : LogsStateBase(context),
+ mContext(readerContext)
{
}
@@ -51,67 +52,6 @@
}
// ----------------------------------------------------------------------------
-// LogsReaderStateFiltering::setNextState
-// ----------------------------------------------------------------------------
-//
-void LogsReaderStateBase::setNextState(LogsReaderStateBase& nextState)
-{
- mNextState = &nextState;
-}
-
-// ----------------------------------------------------------------------------
-// LogsReaderStateFiltering::enterNextStateL
-// ----------------------------------------------------------------------------
-//
-bool LogsReaderStateBase::enterNextStateL()
-{
- if ( mNextState ){
- mContext.setCurrentState(*mNextState);
- return mNextState->enterL();
- }
- return false;
-}
-
-// ----------------------------------------------------------------------------
-// LogsReaderStateBase::enterL
-// ----------------------------------------------------------------------------
-//
-bool LogsReaderStateBase::enterL()
-{
- return false;
-}
-
-// ----------------------------------------------------------------------------
-// LogsReaderStateBase::continueL
-// ----------------------------------------------------------------------------
-//
-bool LogsReaderStateBase::continueL()
-{
- return false;
-}
-
-// ----------------------------------------------------------------------------
-// LogsReaderStateBase::viewCount
-// ----------------------------------------------------------------------------
-//
-int LogsReaderStateBase::viewCountL() const
- {
- return mContext.logView().CountL();
- }
-
-// ----------------------------------------------------------------------------
-// LogsReaderStateBase::event
-// ----------------------------------------------------------------------------
-//
-CLogEvent& LogsReaderStateBase::event() const
- {
- //The RVCT compiler provides warnings "type qualifier on return type is meaningless"
- //for functions that return const values. In order to avoid these numerous warnings and
- //const cascading, the CLogEvent is const_casted here.
- return const_cast<CLogEvent&>( mContext.logView().Event() );
- }
-
-// ----------------------------------------------------------------------------
// LogsReaderStateBase::updateAndInsertEventL
// ----------------------------------------------------------------------------
//
@@ -191,32 +131,12 @@
}
// ----------------------------------------------------------------------------
-// LogsReaderStateBase::duplicatesL
-// ----------------------------------------------------------------------------
-//
-bool LogsReaderStateBase::duplicatesL(const CLogFilter* aFilter){
- bool gettingDuplicates( false );
- if ( mContext.isRecentView() ){
- if ( aFilter ){
- gettingDuplicates =
- static_cast<CLogViewRecent&>( mContext.logView() ).DuplicatesL(
- mContext.duplicatesView(), *aFilter, mContext.reqStatus() );
- } else {
- gettingDuplicates =
- static_cast<CLogViewRecent&>( mContext.logView() ).DuplicatesL(
- mContext.duplicatesView(), mContext.reqStatus() );
- }
- }
- return gettingDuplicates;
-}
-
-// ----------------------------------------------------------------------------
// LogsReaderStateInitReading::LogsReaderStateInitReading
// ----------------------------------------------------------------------------
//
LogsReaderStateInitReading::LogsReaderStateInitReading(
- LogsReaderStateContext& context )
- : LogsReaderStateBase(context)
+ LogsStateBaseContext& context, LogsReaderStateContext& readerContext )
+ : LogsReaderStateBase(context, readerContext)
{
}
@@ -236,8 +156,8 @@
// ----------------------------------------------------------------------------
//
LogsReaderStateFiltering::LogsReaderStateFiltering(
- LogsReaderStateContext& context )
- : LogsReaderStateBase(context),
+ LogsStateBaseContext& context, LogsReaderStateContext& readerContext )
+ : LogsReaderStateBase(context, readerContext),
mFilterList(0)
{
}
@@ -303,9 +223,9 @@
// ----------------------------------------------------------------------------
//
bool LogsReaderStateFiltering::setFilterL(CLogFilterList& filterList){
- __ASSERT_ALWAYS( mContext.isRecentView(), User::Leave( KErrNotFound ) );
- return static_cast<CLogViewRecent&>( mContext.logView() ).SetRecentListL(
- KLogNullRecentList, filterList, mContext.reqStatus() );
+ __ASSERT_ALWAYS( mBaseContext.isRecentView(), User::Leave( KErrNotFound ) );
+ return static_cast<CLogViewRecent&>( mBaseContext.logView() ).SetRecentListL(
+ KLogNullRecentList, filterList, mBaseContext.reqStatus() );
}
// ----------------------------------------------------------------------------
@@ -313,8 +233,8 @@
// ----------------------------------------------------------------------------
//
LogsReaderStateFilteringAll::LogsReaderStateFilteringAll(
- LogsReaderStateContext& context )
- : LogsReaderStateFiltering(context)
+ LogsStateBaseContext& context, LogsReaderStateContext& readerContext )
+ : LogsReaderStateFiltering(context, readerContext)
{
}
@@ -331,9 +251,9 @@
// ----------------------------------------------------------------------------
//
bool LogsReaderStateFilteringAll::setFilterL(CLogFilterList& filterList){
- __ASSERT_ALWAYS( !mContext.isRecentView(), User::Leave( KErrNotFound ) );
- return static_cast<CLogViewEvent&>( mContext.logView() ).SetFilterL(
- filterList, mContext.reqStatus() );
+ __ASSERT_ALWAYS( !mBaseContext.isRecentView(), User::Leave( KErrNotFound ) );
+ return static_cast<CLogViewEvent&>( mBaseContext.logView() ).SetFilterL(
+ filterList, mBaseContext.reqStatus() );
}
// ----------------------------------------------------------------------------
@@ -341,8 +261,8 @@
// ----------------------------------------------------------------------------
//
LogsReaderStateReading::LogsReaderStateReading(
- LogsReaderStateContext& context )
- : LogsReaderStateBase(context),
+ LogsStateBaseContext& context, LogsReaderStateContext& readerContext )
+ : LogsReaderStateBase(context, readerContext),
mDuplicateMissedFilter(0),
mCheckingMissed(false),
mEventIndex(0),
@@ -376,7 +296,7 @@
mDuplicateMissedFilter->SetNullFields(ELogFlagsField);
}
- if ( viewCountL() > 0 && mContext.logView().FirstL( mContext.reqStatus() ) ){
+ if ( viewCountL() > 0 && mBaseContext.logView().FirstL( mBaseContext.reqStatus() ) ){
return true;
}
@@ -390,12 +310,12 @@
//
bool LogsReaderStateReading::continueL()
{
- int& index = mContext.index();
+ int& index = mBaseContext.index();
QList<LogsEvent*> &events = mContext.events();
if ( mCheckingMissed ) {
events.at(mEventIndex-1)->setDuplicates(
- mContext.duplicatesView().CountL() );
+ mBaseContext.duplicatesView().CountL() );
mCheckingMissed = false;
}
else {
@@ -424,7 +344,7 @@
index++;
if ( canContinueReadingL(index) ){
- return mContext.logView().NextL( mContext.reqStatus() );
+ return mBaseContext.logView().NextL( mBaseContext.reqStatus() );
}
return enterNextStateL();
}
@@ -476,8 +396,8 @@
// ----------------------------------------------------------------------------
//
LogsReaderStateFillDetails::LogsReaderStateFillDetails(
- LogsReaderStateContext& context)
- : LogsReaderStateBase(context)
+ LogsStateBaseContext& context, LogsReaderStateContext& readerContext )
+ : LogsReaderStateBase(context, readerContext)
{
}
@@ -539,8 +459,8 @@
// ----------------------------------------------------------------------------
//
LogsReaderStateDone::LogsReaderStateDone(
- LogsReaderStateContext& context )
- : LogsReaderStateBase(context)
+ LogsStateBaseContext& context, LogsReaderStateContext& readerContext )
+ : LogsReaderStateBase(context, readerContext)
{
}
@@ -560,65 +480,21 @@
{
LOGS_QDEBUG( "logs [ENG] -> LogsReaderStateDone::enterL" );
- int numRead = qMin(mContext.index(),viewCountL());
+ int numRead = qMin(mBaseContext.index(),viewCountL());
mContext.observer().readCompleted(numRead);
LOGS_QDEBUG( "logs [ENG] <- LogsReaderStateDone::enterL" );
return false;
-}
-
-
-// ----------------------------------------------------------------------------
-// LogsReaderStateSearchingEvent::LogsReaderStateSearchingEvent
-// ----------------------------------------------------------------------------
-//
-LogsReaderStateSearchingEvent::LogsReaderStateSearchingEvent(
- LogsReaderStateContext& context )
- : LogsReaderStateBase(context)
-{
-}
-
-
-// ----------------------------------------------------------------------------
-// LogsReaderStateSearchingEvent::enterL
-// ----------------------------------------------------------------------------
-//
-bool LogsReaderStateSearchingEvent::enterL()
-{
- LOGS_QDEBUG( "logs [ENG] -> LogsReaderStateSearchingEvent::enterL" );
- if ( viewCountL() > 0 && mContext.logView().FirstL( mContext.reqStatus() ) ){
- return true;
- }
- return enterNextStateL();
-}
-
-
-// ----------------------------------------------------------------------------
-// LogsReaderStateSearchingEvent::continueL
-// ----------------------------------------------------------------------------
-//
-bool LogsReaderStateSearchingEvent::continueL()
-{
- LOGS_QDEBUG( "logs [ENG] -> LogsReaderStateSearchingEvent::continueL" );
- int& index = mContext.index();
- if ( event().Id() != mContext.currentEventId() ) {
- index++;
- if ( index < viewCountL() ){
- return mContext.logView().NextL( mContext.reqStatus() );
- }
- }
-
- return enterNextStateL();
-}
+}
// ----------------------------------------------------------------------------
// LogsReaderStateFindingDuplicates::LogsReaderStateFindingDuplicates
// ----------------------------------------------------------------------------
//
LogsReaderStateFindingDuplicates::LogsReaderStateFindingDuplicates(
- LogsReaderStateContext& context )
- : LogsReaderStateBase(context),
+ LogsStateBaseContext& context, LogsReaderStateContext& readerContext )
+ : LogsReaderStateBase(context, readerContext),
mDuplicateFilter(0)
{
}
@@ -673,8 +549,8 @@
// ----------------------------------------------------------------------------
//
LogsReaderStateMarkingDuplicates::LogsReaderStateMarkingDuplicates(
- LogsReaderStateContext& context )
- : LogsReaderStateBase(context)
+ LogsStateBaseContext& context, LogsReaderStateContext& readerContext )
+ : LogsReaderStateBase(context, readerContext)
{
}
@@ -687,10 +563,10 @@
LOGS_QDEBUG( "logs [ENG] -> LogsReaderStateMarkingDuplicates::enterL" );
mGettingDuplicates = false;
- if ( event().Id() == mContext.currentEventId() ) {
+ if ( event().Id() == mBaseContext.currentEventId() ) {
// Mark event read
event().SetFlags( event().Flags() | KLogEventRead );
- mContext.logClient().ChangeEvent(event(), mContext.reqStatus());
+ mBaseContext.logClient().ChangeEvent(event(), mBaseContext.reqStatus());
return true;
}
@@ -714,8 +590,8 @@
}
} else {
// Mark duplicate events read
- mContext.duplicatesView().SetFlagsL(
- mContext.duplicatesView().Event().Flags() | KLogEventRead );
+ mBaseContext.duplicatesView().SetFlagsL(
+ mBaseContext.duplicatesView().Event().Flags() | KLogEventRead );
}
LOGS_QDEBUG( "logs [ENG] <- LogsReaderStateMarkingDuplicates::continueL" );
@@ -728,8 +604,8 @@
// ----------------------------------------------------------------------------
//
LogsReaderStateReadingDuplicates::LogsReaderStateReadingDuplicates(
- LogsReaderStateContext& context )
- : LogsReaderStateBase(context)
+ LogsStateBaseContext& context, LogsReaderStateContext& readerContext )
+ : LogsReaderStateBase(context, readerContext)
{
}
@@ -740,8 +616,8 @@
bool LogsReaderStateReadingDuplicates::enterL()
{
LOGS_QDEBUG( "logs [ENG] -> LogsReaderStateReadingDuplicates::enterL" );
- if ( mContext.duplicatesView().CountL() > 0 &&
- mContext.duplicatesView().FirstL(mContext.reqStatus()) ){
+ if ( mBaseContext.duplicatesView().CountL() > 0 &&
+ mBaseContext.duplicatesView().FirstL(mBaseContext.reqStatus()) ){
LOGS_QDEBUG( "logs [ENG] duplicates exist!");
return true;
}
@@ -759,11 +635,11 @@
LOGS_QDEBUG( "logs [ENG] -> LogsReaderStateReadingDuplicates::continueL" );
int nextIndex = mContext.duplicatedEvents().count();
- const CLogEvent& sourceEvent = mContext.duplicatesView().Event();
+ const CLogEvent& sourceEvent = mBaseContext.duplicatesView().Event();
LogsEvent* event = new LogsEvent;
constructAndInsertEventL(
sourceEvent, event, nextIndex, mContext.duplicatedEvents() );
- if ( mContext.duplicatesView().NextL(mContext.reqStatus()) ) {
+ if ( mBaseContext.duplicatesView().NextL(mBaseContext.reqStatus()) ) {
return true;
}
@@ -777,7 +653,8 @@
// ----------------------------------------------------------------------------
//
LogsReaderStateModifyingDone::LogsReaderStateModifyingDone(
- LogsReaderStateContext& context) : LogsReaderStateBase(context)
+ LogsStateBaseContext& context, LogsReaderStateContext& readerContext )
+ : LogsReaderStateBase(context, readerContext)
{
}
@@ -790,7 +667,7 @@
{
LOGS_QDEBUG( "logs [ENG] -> LogsReaderStateModifyingDone::enterL" );
- LogsEvent* modifiedEvent = eventById(mContext.currentEventId());
+ LogsEvent* modifiedEvent = eventById(mBaseContext.currentEventId());
if ( modifiedEvent ){
// Update modified event to know that it has been marked. Real
// update of the event happens soon when db notifies the change.
@@ -808,7 +685,8 @@
// ----------------------------------------------------------------------------
//
LogsReaderStateReadingDuplicatesDone::LogsReaderStateReadingDuplicatesDone(
- LogsReaderStateContext& context) : LogsReaderStateBase(context)
+ LogsStateBaseContext& context, LogsReaderStateContext& readerContext )
+ : LogsReaderStateBase(context, readerContext)
{
}
--- a/logsui/logsengine/logssymbianos/src/logsremove.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/src/logsremove.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -20,27 +20,24 @@
#include "logsmodel.h"
#include "logslogger.h"
#include "logsremoveobserver.h"
+#include "logsremovestates.h"
#include <logcli.h>
#include <f32file.h>
#include <logview.h>
//SYSTEM
// CONSTANTS
-_LIT( KMaxLogsTime, "99991130:235959.999999");
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
LogsRemove::LogsRemove( LogsRemoveObserver& observer, bool readingAllEvents )
-: CActive(EPriorityStandard),
+: LogsWorker(readingAllEvents),
mObserver(observer),
- mReadingAllEvents(readingAllEvents),
- mLogClient(0),
- mRecentView(0)
+ mFsSession(0),
+ mClearType(-1)
{
- CActiveScheduler::Add( this );
- mFsSession = new RFs();
}
// -----------------------------------------------------------------------------
@@ -49,45 +46,21 @@
//
LogsRemove::~LogsRemove()
{
- LOGS_QDEBUG( "logs [ENG] <-> LogsRemove::~LogsRemove()" )
+ LOGS_QDEBUG( "logs [ENG] -> LogsRemove::~LogsRemove()" )
Cancel();
- delete mRecentView;
+ delete mLogViewRecent;
+ mLogViewRecent = 0;
+ delete mDuplicatesView;
+ mDuplicatesView = 0;
delete mLogClient;
+ mLogClient = 0;
if ( mFsSession ){
mFsSession->Close();
}
delete mFsSession;
-}
-
-// ----------------------------------------------------------------------------
-// LogsRemove::RunL
-// ----------------------------------------------------------------------------
-//
-void LogsRemove::RunL()
-{
- LOGS_QDEBUG( "logs [ENG] -> LogsRemove::RunL()->" )
- if (iStatus.Int() == KErrNone){
- LOGS_QDEBUG( "logs [ENG] -> LogsRemove::RunL() KErrNone" )
- if ( !DeleteNextEvent() ){
- mObserver.removeCompleted();
- }
- }
- else {
- User::Leave( iStatus.Int() );
- LOGS_QDEBUG( "logs [ENG] -> LogsRemove::RunL() !KErrNone" )
- }
- LOGS_QDEBUG( "logs [ENG] <- LogsRemove::RunL()<-" )
-}
-
-// ----------------------------------------------------------------------------
-// LogsRemove::DoCancel
-// ----------------------------------------------------------------------------
-//
-void LogsRemove::DoCancel()
-{
- if ( mLogClient ){
- mLogClient->Cancel();
- }
+ qDeleteAll( mRemoveStates );
+ qDeleteAll( mClearAllStates );
+ LOGS_QDEBUG( "logs [ENG] <- LogsRemove::~LogsRemove()" )
}
// ----------------------------------------------------------------------------
@@ -120,39 +93,53 @@
//
bool LogsRemove::clearList(LogsModel::ClearType cleartype)
{
- LOGS_QDEBUG( "logs [ENG] <- LogsRemove::clearList->" )
- if ( init() != KErrNone ) {
- return false;
- }
- bool clearingStarted(false);
- TTime time( KMaxLogsTime );
- if ( !IsActive() ){
- if (cleartype == LogsModel::TypeLogsClearAll){
- mLogClient->ClearLog( time, iStatus );
- }
- else{
- mLogClient->ClearLog( cleartype, iStatus );
- }
- SetActive();
- clearingStarted = true;
- } else {
- }
+ LOGS_QDEBUG( "logs [ENG] -> LogsRemove::clearList" )
+
+ bool clearingStarted( false );
+ TRAP_IGNORE( clearingStarted = clearListL(cleartype) )
+
LOGS_QDEBUG_2( "logs [ENG] <- LogsRemove::clearList, started", clearingStarted )
return clearingStarted;
}
// ----------------------------------------------------------------------------
+// LogsRemove::clearListL
+// ----------------------------------------------------------------------------
+//
+bool LogsRemove::clearListL(LogsModel::ClearType cleartype)
+{
+ LOGS_QDEBUG( "logs [ENG] -> LogsRemove::clearListL" )
+
+ initializeClearAllL();
+
+ mClearType = cleartype;
+
+ bool clearingStarted = startClearingL();
+
+ LOGS_QDEBUG_2( "logs [ENG] <- LogsRemove::clearListL, started", clearingStarted )
+ return clearingStarted;
+}
+
+// ----------------------------------------------------------------------------
// LogsRemove::initL
// ----------------------------------------------------------------------------
//
void LogsRemove::initL()
{
- if ( mLogClient ){
- // Already initialized
- return;
+ LOGS_QDEBUG( "logs [ENG] -> LogsRemove::initL" )
+
+ __ASSERT_ALWAYS( !IsActive(), User::Leave( KErrInUse ) );
+
+ if ( !mFsSession ){
+ mFsSession = new (ELeave) RFs();
+ User::LeaveIfError( mFsSession->Connect() );
+ }
+
+ if ( !mLogClient ){
+ mLogClient = CLogClient::NewL( *mFsSession );
}
- User::LeaveIfError( mFsSession->Connect() );
- mLogClient = CLogClient::NewL( *mFsSession );
+
+ LOGS_QDEBUG( "logs [ENG] <- LogsRemove::initL" )
}
@@ -172,49 +159,117 @@
//
void LogsRemove::clearEventsL(const QList<int>& eventIds, bool& async)
{
- LOGS_QDEBUG( "logs [ENG] -> LogsRemove::clearEventL()")
+ LOGS_QDEBUG( "logs [ENG] -> LogsRemove::clearEventsL()")
+
+ async = false;
+ initializeIdBasedRemovalL();
+
+ mRemovedEvents = eventIds;
+ mCurrentEventId = eventIds.isEmpty() ? -1 : eventIds.at(0);
+ if ( !mRemovedEvents.isEmpty() ){
+ async = startClearingL();
+ }
+
+ LOGS_QDEBUG_2( "logs [ENG] <- LogsRemove::clearEventsL(): async", async )
+}
- async = false;
-
+// ----------------------------------------------------------------------------
+// LogsRemove::initializeClearAllL
+// ----------------------------------------------------------------------------
+//
+void LogsRemove::initializeClearAllL()
+{
initL();
- if ( mReadingAllEvents ){
- // When all events are read, recent view cannot be used for
- // event removal.
- Cancel();
- mRemovedEvents = eventIds;
- async = DeleteNextEvent();
- } else {
- if ( !mRecentView ) {
- mRecentView = CLogViewRecent::NewL( *mLogClient );
- }
- foreach( int currId, eventIds ){
- LOGS_QDEBUG_2( "logs [ENG] Removing, currid: ", currId )
- mRecentView->RemoveL( currId );
- }
- delete mRecentView;
- mRecentView = NULL;
+ if ( mClearAllStates.count() == 0 ){
+ LogsRemoveStateClearAll* clearAll = new LogsRemoveStateClearAll(*this, *this);
+ LogsRemoveStateDone* done = new LogsRemoveStateDone(*this, *this);
+ clearAll->setNextState(*done);
+ mClearAllStates.append(clearAll);
+ mClearAllStates.append(done);
}
-
- LOGS_QDEBUG_2( "logs [ENG] <- LogsRemove::clearEventL(): async", async )
+ mCurrentStateMachine = &mClearAllStates;
+ setCurrentState(*mClearAllStates.at(0));
}
// ----------------------------------------------------------------------------
-// LogsRemove::DeleteNextEvent
+// LogsRemove::initializeIdBasedRemovalL
+// ----------------------------------------------------------------------------
+//
+void LogsRemove::initializeIdBasedRemovalL()
+{
+ initL();
+
+ if ( !mLogViewRecent ){
+ mLogViewRecent = CLogViewRecent::NewL( *mLogClient );
+ }
+ if ( !mDuplicatesView ) {
+ mDuplicatesView = CLogViewDuplicate::NewL( *mLogClient );
+ }
+
+ if ( mRemoveStates.count() == 0 ){
+ LogsRemoveStateInit* init = new LogsRemoveStateInit(*this, *this);
+ LogsStateSearchingEvent* searchEvent = new LogsStateSearchingEvent(*this);
+ LogsRemoveStateDeleteDuplicates* deleteDuplicates =
+ new LogsRemoveStateDeleteDuplicates(*this, *this);
+ LogsRemoveStateDelete* deleteFromMain = new LogsRemoveStateDelete(*this, *this);
+ LogsRemoveStateDone* done = new LogsRemoveStateDone(*this, *this);
+ init->setNextState(*searchEvent);
+ searchEvent->setNextState(*deleteDuplicates);
+ deleteDuplicates->setNextState(*deleteFromMain);
+ deleteFromMain->setNextState(*done);
+ mRemoveStates.append(init);
+ mRemoveStates.append(searchEvent);
+ mRemoveStates.append(deleteDuplicates);
+ mRemoveStates.append(deleteFromMain);
+ mRemoveStates.append(done);
+ }
+ mCurrentStateMachine = &mRemoveStates;
+ setCurrentState(*mRemoveStates.at(0));
+}
+
+// ----------------------------------------------------------------------------
+// LogsRemove::startClearingL
// ----------------------------------------------------------------------------
//
-bool LogsRemove::DeleteNextEvent()
+bool LogsRemove::startClearingL()
+{
+ __ASSERT_ALWAYS( !IsActive(), User::Leave( KErrInUse ) );
+
+ if ( currentState().enterL() ){
+ SetActive();
+ return true;
+ }
+ return false;
+}
+
+// ----------------------------------------------------------------------------
+// LogsRemove::observer
+// ----------------------------------------------------------------------------
+//
+LogsRemoveObserver& LogsRemove::observer()
{
- bool deleting(false);
- if ( !mRemovedEvents.isEmpty() ){
- int currId = mRemovedEvents.takeFirst();
- LOGS_QDEBUG_2( "logs [ENG] LogsRemove::DeleteNextEvent, id: ", currId )
- mLogClient->DeleteEvent( currId, iStatus );
- SetActive();
- deleting = true;
- }
- return deleting;
+ return mObserver;
+}
+
+// ----------------------------------------------------------------------------
+// LogsRemove::removedEvents
+// ----------------------------------------------------------------------------
+//
+QList<int>& LogsRemove::removedEvents()
+{
+ return mRemovedEvents;
}
+// ----------------------------------------------------------------------------
+// LogsRemove::clearType
+// ----------------------------------------------------------------------------
+//
+int LogsRemove::clearType()
+{
+ return mClearType;
+}
+
+
// End of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/logsui/logsengine/logssymbianos/src/logsremovestates.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -0,0 +1,205 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+// INCLUDE FILES
+#include "logsremovestates.h"
+#include "logsstatebasecontext.h"
+#include "logsremovestatecontext.h"
+#include "logslogger.h"
+#include "logsremoveobserver.h"
+#include "logsmodel.h"
+#include <logview.h>
+#include <logwraplimits.h>
+
+_LIT( KMaxLogsTime, "99991130:235959.999999");
+
+// ----------------------------------------------------------------------------
+// LogsRemoveStateBase
+// ----------------------------------------------------------------------------
+//
+LogsRemoveStateBase::LogsRemoveStateBase(
+ LogsStateBaseContext& context, LogsRemoveStateContext& removeContext) :
+ LogsStateBase(context), mContext(removeContext)
+{
+
+}
+
+// ----------------------------------------------------------------------------
+// LogsRemoveStateClearAll
+// ----------------------------------------------------------------------------
+//
+bool LogsRemoveStateClearAll::enterL()
+{
+ TTime time( KMaxLogsTime );
+ if (mContext.clearType() == LogsModel::TypeLogsClearAll){
+ mBaseContext.logClient().ClearLog( time, mBaseContext.reqStatus() );
+ }
+ else{
+ mBaseContext.logClient().ClearLog( mContext.clearType(), mBaseContext.reqStatus());
+ }
+ return true;
+}
+
+// ----------------------------------------------------------------------------
+//
+// ----------------------------------------------------------------------------
+//
+bool LogsRemoveStateClearAll::continueL()
+{
+ return enterNextStateL();
+}
+
+// ----------------------------------------------------------------------------
+// LogsRemoveStateInit
+// ----------------------------------------------------------------------------
+//
+bool LogsRemoveStateInit::enterL()
+{
+ mBaseContext.index() = 0;
+ if ( mBaseContext.isRecentView() &&
+ static_cast<CLogViewRecent&>( mBaseContext.logView() ).SetRecentListL(
+ KLogNullRecentList, mBaseContext.reqStatus() ) ){
+ return true;
+ }
+ return enterNextStateL();
+}
+
+// ----------------------------------------------------------------------------
+//
+// ----------------------------------------------------------------------------
+//
+bool LogsRemoveStateInit::continueL()
+{
+ return enterNextStateL();
+}
+
+// ----------------------------------------------------------------------------
+// LogsRemoveStateDelete
+// ----------------------------------------------------------------------------
+//
+bool LogsRemoveStateDelete::enterL()
+{
+ mRemoveIndex = 0;
+ if ( deleteNextEvent() ){
+ return true;
+ }
+ return enterNextStateL();
+}
+
+// ----------------------------------------------------------------------------
+//
+// ----------------------------------------------------------------------------
+//
+bool LogsRemoveStateDelete::continueL()
+{
+ if ( deleteNextEvent() ){
+ return true;
+ }
+ return enterNextStateL();
+}
+
+// ----------------------------------------------------------------------------
+//
+// ----------------------------------------------------------------------------
+//
+bool LogsRemoveStateDelete::deleteNextEvent()
+{
+ bool deleting(false);
+ if ( mRemoveIndex < mContext.removedEvents().count() ){
+ int currId = mContext.removedEvents().at(mRemoveIndex);
+ LOGS_QDEBUG_2( "logs [ENG] LogsRemove::DeleteNextEvent, id: ", currId )
+ mBaseContext.logClient().DeleteEvent( currId, mBaseContext.reqStatus() );
+ deleting = true;
+ mRemoveIndex++;
+ }
+ return deleting;
+}
+
+// ----------------------------------------------------------------------------
+// LogsRemoveStateDeleteDuplicates
+// ----------------------------------------------------------------------------
+//
+bool LogsRemoveStateDeleteDuplicates::enterL()
+{
+ mDeleting = false;
+ mBaseContext.index() = 0;
+ mDeleteDuplicateIds.clear();
+
+ // Duplicate deletion supported only for one event at the time
+ if ( mContext.removedEvents().count() == 1 &&
+ event().Id() == mBaseContext.currentEventId() &&
+ duplicatesL() ){
+ return true;
+ }
+ return enterNextStateL();
+}
+
+// ----------------------------------------------------------------------------
+//
+// ----------------------------------------------------------------------------
+//
+bool LogsRemoveStateDeleteDuplicates::continueL()
+{
+ bool continueFindingDuplicates = false;
+ if ( !mDeleting && mBaseContext.duplicatesView().CountL() > 0 &&
+ mBaseContext.index() <= mBaseContext.duplicatesView().CountL() ) {
+ LOGS_QDEBUG( "logs [ENG] duplicates exist!");
+ if ( mBaseContext.index() == 0 ){
+ continueFindingDuplicates =
+ mBaseContext.duplicatesView().FirstL(mBaseContext.reqStatus());
+ mBaseContext.index()++;
+ } else {
+ mDeleteDuplicateIds.append( mBaseContext.duplicatesView().Event().Id() );
+ continueFindingDuplicates =
+ mBaseContext.duplicatesView().NextL(mBaseContext.reqStatus());
+ mBaseContext.index()++;
+ }
+ }
+ if ( continueFindingDuplicates || deleteNextEvent() ){
+ return true;
+ }
+ return enterNextStateL();
+}
+
+// ----------------------------------------------------------------------------
+//
+// ----------------------------------------------------------------------------
+//
+bool LogsRemoveStateDeleteDuplicates::deleteNextEvent()
+{
+ mDeleting = false;
+ if ( !mDeleteDuplicateIds.isEmpty() ){
+ int currId = mDeleteDuplicateIds.takeFirst();
+ LOGS_QDEBUG_2( "logs [ENG] LogsRemoveStateDeleteDuplicates::deleteNextEvent id: ",
+ currId )
+ mBaseContext.logClient().DeleteEvent( currId, mBaseContext.reqStatus() );
+ mDeleting = true;
+ }
+ return mDeleting;
+}
+
+// ----------------------------------------------------------------------------
+// LogsRemoveStateDone
+// ----------------------------------------------------------------------------
+//
+bool LogsRemoveStateDone::enterL()
+{
+ mContext.observer().removeCompleted();
+ return false;
+}
+
+// CONSTANTS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/logsui/logsengine/logssymbianos/src/logsstatebase.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -0,0 +1,169 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+// INCLUDE FILES
+#include "logsstatebase.h"
+#include "logsstatebasecontext.h"
+#include "logslogger.h"
+#include <logview.h>
+
+// CONSTANTS
+
+// ----------------------------------------------------------------------------
+// LogsStateBase::LogsStateBase
+// ----------------------------------------------------------------------------
+//
+LogsStateBase::LogsStateBase(
+ LogsStateBaseContext& context)
+ : mBaseContext(context),
+ mNextState(0)
+{
+}
+
+// ----------------------------------------------------------------------------
+// LogsStateBase::~LogsStateBase
+// ----------------------------------------------------------------------------
+//
+LogsStateBase::~LogsStateBase()
+{
+
+}
+
+// ----------------------------------------------------------------------------
+// LogsReaderStateFiltering::setNextState
+// ----------------------------------------------------------------------------
+//
+void LogsStateBase::setNextState(LogsStateBase& nextState)
+{
+ mNextState = &nextState;
+}
+
+// ----------------------------------------------------------------------------
+// LogsReaderStateFiltering::enterNextStateL
+// ----------------------------------------------------------------------------
+//
+bool LogsStateBase::enterNextStateL()
+{
+ if ( mNextState ){
+ mBaseContext.setCurrentState(*mNextState);
+ return mNextState->enterL();
+ }
+ return false;
+}
+
+// ----------------------------------------------------------------------------
+// LogsStateBase::enterL
+// ----------------------------------------------------------------------------
+//
+bool LogsStateBase::enterL()
+{
+ return false;
+}
+
+// ----------------------------------------------------------------------------
+// LogsStateBase::continueL
+// ----------------------------------------------------------------------------
+//
+bool LogsStateBase::continueL()
+{
+ return false;
+}
+
+// ----------------------------------------------------------------------------
+// LogsStateBase::viewCount
+// ----------------------------------------------------------------------------
+//
+int LogsStateBase::viewCountL() const
+ {
+ return mBaseContext.logView().CountL();
+ }
+
+// ----------------------------------------------------------------------------
+// LogsStateBase::event
+// ----------------------------------------------------------------------------
+//
+CLogEvent& LogsStateBase::event() const
+ {
+ //The RVCT compiler provides warnings "type qualifier on return type is meaningless"
+ //for functions that return const values. In order to avoid these numerous warnings and
+ //const cascading, the CLogEvent is const_casted here.
+ return const_cast<CLogEvent&>( mBaseContext.logView().Event() );
+ }
+
+// ----------------------------------------------------------------------------
+// LogsStateBase::duplicatesL
+// ----------------------------------------------------------------------------
+//
+bool LogsStateBase::duplicatesL(const CLogFilter* aFilter){
+ bool gettingDuplicates( false );
+ if ( mBaseContext.isRecentView() ){
+ if ( aFilter ){
+ gettingDuplicates =
+ static_cast<CLogViewRecent&>( mBaseContext.logView() ).DuplicatesL(
+ mBaseContext.duplicatesView(), *aFilter, mBaseContext.reqStatus() );
+ } else {
+ gettingDuplicates =
+ static_cast<CLogViewRecent&>( mBaseContext.logView() ).DuplicatesL(
+ mBaseContext.duplicatesView(), mBaseContext.reqStatus() );
+ }
+ }
+ return gettingDuplicates;
+}
+
+
+// ----------------------------------------------------------------------------
+// LogsStateSearchingEvent::LogsStateSearchingEvent
+// ----------------------------------------------------------------------------
+//
+LogsStateSearchingEvent::LogsStateSearchingEvent(
+ LogsStateBaseContext& context )
+ : LogsStateBase(context)
+{
+}
+
+
+// ----------------------------------------------------------------------------
+// LogsStateSearchingEvent::enterL
+// ----------------------------------------------------------------------------
+//
+bool LogsStateSearchingEvent::enterL()
+{
+ LOGS_QDEBUG( "logs [ENG] -> LogsStateSearchingEvent::enterL" );
+ if ( viewCountL() > 0 && mBaseContext.logView().FirstL( mBaseContext.reqStatus() ) ){
+ return true;
+ }
+ return enterNextStateL();
+}
+
+
+// ----------------------------------------------------------------------------
+// LogsStateSearchingEvent::continueL
+// ----------------------------------------------------------------------------
+//
+bool LogsStateSearchingEvent::continueL()
+{
+ LOGS_QDEBUG( "logs [ENG] -> LogsStateSearchingEvent::continueL" );
+ int& index = mBaseContext.index();
+ if ( event().Id() != mBaseContext.currentEventId() ) {
+ index++;
+ if ( index < viewCountL() ){
+ return mBaseContext.logView().NextL( mBaseContext.reqStatus() );
+ }
+ }
+
+ return enterNextStateL();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/logsui/logsengine/logssymbianos/src/logsworker.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -0,0 +1,203 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+// INCLUDE FILES
+#include <exception>
+#include <logview.h>
+#include "logsworker.h"
+#include "logsstatebase.h"
+#include "logslogger.h"
+
+// CONSTANTS
+
+// ----------------------------------------------------------------------------
+// LogsWorker::LogsWorker
+// ----------------------------------------------------------------------------
+//
+LogsWorker::LogsWorker(bool readAllEvents)
+ : CActive( EPriorityStandard ),
+ mReadAllEvents(readAllEvents),
+ mLogClient(0),
+ mLogViewRecent(0),
+ mLogViewEvent(0),
+ mDuplicatesView(0),
+ mIndex(0),
+ mCurrentStateIndex(0),
+ mCurrentStateMachine(0),
+ mCurrentEventId(-1)
+{
+ LOGS_QDEBUG( "logs [ENG] -> LogsWorker::LogsWorker()" )
+
+ CActiveScheduler::Add( this );
+
+ LOGS_QDEBUG( "logs [ENG] <- LogsWorker::LogsWorker()" )
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::~LogsWorker
+// ----------------------------------------------------------------------------
+//
+LogsWorker::~LogsWorker()
+{
+ LOGS_QDEBUG( "logs [ENG] -> LogsWorker::~LogsWorker()" )
+
+ Cancel();
+
+ LOGS_QDEBUG( "logs [ENG] <- LogsWorker::~LogsWorker()" )
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::RunL
+// ----------------------------------------------------------------------------
+//
+void LogsWorker::RunL()
+{
+ LOGS_QDEBUG_3( "logs [ENG] -> LogsWorker::RunL(), (state, status):",
+ mCurrentStateIndex, iStatus.Int() )
+
+ // Error handling in RunError
+ __ASSERT_ALWAYS( iStatus.Int() == KErrNone, User::Leave( iStatus.Int() ) );
+
+ if ( currentState().continueL() ){
+ SetActive();
+ }
+
+ LOGS_QDEBUG( "logs [ENG] <- LogsWorker::RunL()" )
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::RunError
+// ----------------------------------------------------------------------------
+//
+TInt LogsWorker::RunError(TInt error)
+{
+ LOGS_QDEBUG_2( "logs [ENG] <-> LogsWorker::RunError(), err:", error )
+
+ return KErrNone;
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::DoCancel
+// ----------------------------------------------------------------------------
+//
+void LogsWorker::DoCancel()
+{
+ if ( mLogViewEvent ){
+ mLogViewEvent->Cancel();
+ }
+ if ( mLogViewRecent ){
+ mLogViewRecent->Cancel();
+ }
+ if ( mDuplicatesView ){
+ mDuplicatesView->Cancel();
+ }
+ if ( mLogClient ){
+ mLogClient->Cancel();
+ }
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::setCurrentState
+// ----------------------------------------------------------------------------
+//
+void LogsWorker::setCurrentState(const LogsStateBase& state)
+{
+ bool found(false);
+ for( int i = 0; i < mCurrentStateMachine->count() && !found; i++ ){
+ if ( mCurrentStateMachine->at(i) == &state ){
+ mCurrentStateIndex = i;
+ found = true;
+ LOGS_QDEBUG_2( "logs [ENG] <-> LogsWorker::setCurrentState, index:",
+ mCurrentStateIndex )
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::logView
+// ----------------------------------------------------------------------------
+//
+CLogView& LogsWorker::logView()
+{
+ if ( mLogViewRecent ){
+ return *mLogViewRecent;
+ }
+ return *mLogViewEvent;
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::duplicatesView
+// ----------------------------------------------------------------------------
+//
+CLogViewDuplicate& LogsWorker::duplicatesView()
+{
+ return *mDuplicatesView;
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::index
+// ----------------------------------------------------------------------------
+//
+int& LogsWorker::index()
+{
+ return mIndex;
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::reqStatus
+// ----------------------------------------------------------------------------
+//
+TRequestStatus& LogsWorker::reqStatus()
+{
+ return iStatus;
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::currentEventId
+// ----------------------------------------------------------------------------
+//
+int LogsWorker::currentEventId()
+{
+ return mCurrentEventId;
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::logClient
+// ----------------------------------------------------------------------------
+//
+CLogClient& LogsWorker::logClient()
+{
+ return *mLogClient;
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::isRecentView
+// ----------------------------------------------------------------------------
+//
+bool LogsWorker::isRecentView()
+{
+ return ( mLogViewRecent != 0 );
+}
+
+// ----------------------------------------------------------------------------
+// LogsWorker::currentState
+// ----------------------------------------------------------------------------
+//
+LogsStateBase& LogsWorker::currentState()
+{
+ return *(mCurrentStateMachine->at(mCurrentStateIndex));
+}
--- a/logsui/logsengine/logssymbianos/tsrc/stubs/logclient_stubs.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/tsrc/stubs/logclient_stubs.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -25,6 +25,7 @@
int stubViewCount = 1;
int stubLeaveWithError = KErrNone;
int stubViewFlagsValue = 0;
+QString stubLastCalledFunc;
// ----------------------------------------------------------------------------
// LogClientStubsHelper
@@ -35,6 +36,7 @@
stubAsyncCallPossible = true;
stubLeaveWithError = KErrNone;
stubViewFlagsValue = 0;
+ stubLastCalledFunc.clear();
}
void LogClientStubsHelper::createEvents(int numEvents)
@@ -62,6 +64,11 @@
return stubViewFlagsValue;
}
+QString LogClientStubsHelper::lastCalledFunc()
+{
+ return stubLastCalledFunc;
+}
+
// ----------------------------------------------------------------------------
// CLogActive
// ----------------------------------------------------------------------------
@@ -190,12 +197,14 @@
void CLogClient::ClearLog(const TTime& /*aDate*/, TRequestStatus& aStatus)
{
+ stubLastCalledFunc = "ClearLog";
aStatus = KRequestPending;
User::RequestComplete( &aStatus, KErrNone );
}
void CLogClient::ClearLog(TInt /*aRecentList*/, TRequestStatus& aStatus)
{
+ stubLastCalledFunc = "ClearLogRecentList";
aStatus = KRequestPending;
User::RequestComplete( &aStatus, KErrNone );
}
--- a/logsui/logsengine/logssymbianos/tsrc/stubs/logclient_stubs_helper.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/tsrc/stubs/logclient_stubs_helper.h Wed Aug 18 09:49:12 2010 +0300
@@ -15,6 +15,8 @@
*
*/
+#include <QString>
+
/**
* Helper class to control logcli stub behavior
*
@@ -27,4 +29,6 @@
static void setViewCount(int viewCount);
static void setLeaveWithError(int error);
static int stubViewFlags();
+ static QString lastCalledFunc();
+
};
--- a/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/inc/ut_logsreaderstates.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/inc/ut_logsreaderstates.h Wed Aug 18 09:49:12 2010 +0300
@@ -21,16 +21,20 @@
#include <QList>
#include <e32base.h>
#include "logsengdefs.h"
+#include "logsstatebasecontext.h"
#include "logsreaderstatecontext.h"
#include "logsreaderobserver.h"
class CLogClient;
class LogsEvent;
+class CLogView;
class CLogViewRecent;
class CLogViewEvent;
class LogsReaderStateBase;
+class CLogViewDuplicate;
class UT_LogsReaderStates : public QObject,
+ public LogsStateBaseContext,
public LogsReaderStateContext,
public LogsReaderObserver
{
@@ -70,23 +74,25 @@
void testStateReadingDuplicatesDone();
void testStateModifyingDone();
-protected: // From LogsReaderStateContext
+protected: // From LogsStateBaseContext
- void setCurrentState(const LogsReaderStateBase& state);
+ void setCurrentState(const LogsStateBase& state);
CLogView& logView();
CLogViewDuplicate& duplicatesView();
- QList<LogsEvent*>& events();
int& index();
- LogsEventStrings& strings();
TRequestStatus& reqStatus();
- LogsReaderObserver& observer();
- QHash<QString, ContactCacheEntry>& contactCache();
int currentEventId();
CLogClient& logClient();
bool isRecentView();
+
+protected: // From LogsReaderStateContext
+
+ QList<LogsEvent*>& events();
+ LogsEventStrings& strings();
+ LogsReaderObserver& observer();
+ QHash<QString, ContactCacheEntry>& contactCache();
QList<LogsEvent*>& duplicatedEvents();
-
protected: // From LogsReaderObserver
void readCompleted(int readCount);
@@ -104,7 +110,7 @@
private:
CLogClient* mLogClient;
- const LogsReaderStateBase* mCurrentState;
+ const LogsStateBase* mCurrentState;
CLogViewRecent* mLogView;
CLogViewEvent* mLogViewEvent;
CLogViewDuplicate* mDuplicatesView;
--- a/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/inc/ut_logsremove.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/inc/ut_logsremove.h Wed Aug 18 09:49:12 2010 +0300
@@ -60,8 +60,6 @@
void testConstructor();
void testclearList();
void testClearEvents();
- void testDoCancel();
- void testRunL();
void testRunError();
void testInit();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/inc/ut_logsremovestates.h Wed Aug 18 09:49:12 2010 +0300
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef UT_LOGSREMOVESTATES_H
+#define UT_LOGSREMOVESTATES_H
+
+#include <QObject>
+#include <QList>
+#include <e32base.h>
+#include "logsengdefs.h"
+#include "logsstatebasecontext.h"
+#include "logsremovestatecontext.h"
+#include "logsremoveobserver.h"
+
+class CLogClient;
+class LogsEvent;
+class CLogViewRecent;
+class CLogViewEvent;
+class LogsReaderStateBase;
+
+class UT_LogsRemoveStates : public QObject,
+ public LogsStateBaseContext,
+ public LogsRemoveStateContext,
+ public LogsRemoveObserver
+{
+ Q_OBJECT
+
+private slots:
+
+/*
+ * In addition, there are four private slots that are not treated as testfunctions.
+ * They will be executed by the testing framework and can be used to initialize and clean up
+ * either the entire test or the current test function.
+ *
+ * initTestCase() will be called before the first testfunction is executed.
+ * cleanupTestCase() will be called after the last testfunction was executed.
+ * init() will be called before each testfunction is executed.
+ * cleanup() will be called after every testfunction.
+*/
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots: //test methods
+
+ void testClearAll();
+ void testInit();
+ void testDelete();
+ void testDeleteDuplicates();
+ void testDone();
+
+protected: // From LogsStateBaseContext
+
+ void setCurrentState(const LogsStateBase& state);
+ CLogView& logView();
+ CLogViewDuplicate& duplicatesView();
+ int& index();
+ TRequestStatus& reqStatus();
+ int currentEventId();
+ CLogClient& logClient();
+ bool isRecentView();
+
+protected: // From LogsRemoveStateContext
+
+ LogsRemoveObserver& observer();
+ QList<int>& removedEvents();
+ int clearType();
+
+protected: // From LogsRemoveObserver
+
+ void removeCompleted();
+ void logsRemoveErrorOccured(int err);
+
+private:
+
+ void reset();
+
+
+private:
+
+ CLogClient* mLogClient;
+ const LogsStateBase* mCurrentState;
+ CLogViewRecent* mLogView;
+ CLogViewEvent* mLogViewEvent;
+ CLogViewDuplicate* mDuplicatesView;
+ int mIndex;
+ TRequestStatus mReqStatus;
+ bool mIsRecentView;
+
+ int mError;
+ bool mRemoveCompleted;
+
+ int mCurrentEventId;
+ QList<int> mRemovedEvents;
+ int mClearType;
+};
+
+
+#endif //UT_LOGSREMOVESTATES_H
--- a/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/main.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/main.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -25,6 +25,7 @@
#include "ut_logseventdataparser.h"
#include "testresultxmlparser.h"
#include "ut_logsremove.h"
+#include "ut_logsremovestates.h"
int main(int argc, char *argv[])
@@ -52,6 +53,13 @@
args_logsRemove << "-xml" << "-o" << resultFileName;
QTest::qExec(&ut_logsRemove, args_logsRemove);
parser.parseAndPrintResults(resultFileName,true);
+
+ UT_LogsRemoveStates ut_logsRemoveStates;
+ resultFileName = "c:/ut_logs_logsRemoveStates.xml";
+ QStringList args_logsRemoveStates( "ut_logsRemoveStates");
+ args_logsRemoveStates << "-xml" << "-o" << resultFileName;
+ QTest::qExec(&ut_logsRemoveStates, args_logsRemoveStates);
+ parser.parseAndPrintResults(resultFileName,true);
UT_LogsReader ut_logsReader;
resultFileName = "c:/ut_logs_logsReader.xml";
--- a/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/ut_logsreader.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/ut_logsreader.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -195,7 +195,7 @@
QVERIFY( mReader->mCurrentStateIndex == 1 );
//wrong state machine is set as current, state isn't changed
- LogsReaderStateBase* unknownState = new LogsReaderStateBase( *mReader );
+ LogsReaderStateBase* unknownState = new LogsReaderStateBase( *mReader, *mReader );
mReader->mModifyingStates.append(unknownState);
QVERIFY( mReader->mCurrentStateMachine == &mReader->mReadStates );
mReader->setCurrentState(*mReader->mModifyingStates[0]);
--- a/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/ut_logsreaderstates.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/ut_logsreaderstates.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -92,8 +92,8 @@
void UT_LogsReaderStates::testStateBase()
{
- LogsReaderStateBase state(*this);
- LogsReaderStateBase state2(*this);
+ LogsReaderStateBase state(*this, *this);
+ LogsReaderStateBase state2(*this, *this);
QVERIFY( state.mNextState == 0 );
QVERIFY( state2.mNextState == 0 );
@@ -233,7 +233,7 @@
void UT_LogsReaderStates::testStateInitReading()
{
- LogsReaderStateInitReading init(*this);
+ LogsReaderStateInitReading init(*this, *this);
CLogEvent* logEvent = CLogEvent::NewL();
CleanupStack::PushL(logEvent);
logEvent->SetNumber( _L("1234") );
@@ -249,7 +249,7 @@
void UT_LogsReaderStates::testStateFiltering()
{
- LogsReaderStateFiltering state(*this);
+ LogsReaderStateFiltering state(*this, *this);
QVERIFY( !state.mFilterList );
// State can be used only with recent view
@@ -272,14 +272,14 @@
QVERIFY( !state.continueL() );
// Continues as there's next state
- LogsReaderStateFiltering state2(*this);
+ LogsReaderStateFiltering state2(*this, *this);
state.setNextState(state2);
QVERIFY( state.continueL() );
}
void UT_LogsReaderStates::testStateFilteringAll()
{
- LogsReaderStateFilteringAll state(*this);
+ LogsReaderStateFilteringAll state(*this, *this);
QVERIFY( !state.mFilterList );
// State can be used only with full event view
@@ -301,7 +301,7 @@
void UT_LogsReaderStates::testStateReading()
{
- LogsReaderStateReading state(*this);
+ LogsReaderStateReading state(*this, *this);
// Reading starts ok
QVERIFY( state.enterL() );
@@ -376,7 +376,7 @@
LogsCommonData::getInstance().configureReadSize(3);
LogClientStubsHelper::setViewCount(5);
- LogsReaderStateReading state(*this);
+ LogsReaderStateReading state(*this, *this);
// Reading starts ok
QVERIFY( state.enterL() );
@@ -406,7 +406,7 @@
void UT_LogsReaderStates::testStateFillDetails()
{
- LogsReaderStateFillDetails state(*this);
+ LogsReaderStateFillDetails state(*this, *this);
int contactId = 2;
// No events, nothing to check
@@ -461,7 +461,7 @@
void UT_LogsReaderStates::testStateDone()
{
- LogsReaderStateDone state(*this);
+ LogsReaderStateDone state(*this, *this);
mIndex = 3;
LogClientStubsHelper::setViewCount(3);
QVERIFY( !state.enterL() );
@@ -479,7 +479,7 @@
void UT_LogsReaderStates::testStateSearchingEvent()
{
// Searching starts ok
- LogsReaderStateSearchingEvent state(*this);
+ LogsStateSearchingEvent state(*this);
mCurrentEventId = 10;
QVERIFY( state.enterL() );
@@ -508,7 +508,7 @@
void UT_LogsReaderStates::testStateFindingDuplicates()
{
// Finding starts ok
- LogsReaderStateFindingDuplicates state(*this);
+ LogsReaderStateFindingDuplicates state(*this, *this);
QVERIFY( state.enterL() );
// Duplicates cannot be searched for some reason
@@ -527,7 +527,7 @@
void UT_LogsReaderStates::testStateMarkingDuplicates()
{
// Marking does not start as no matching event in view
- LogsReaderStateMarkingDuplicates state(*this);
+ LogsReaderStateMarkingDuplicates state(*this, *this);
mCurrentEventId = 5;
const_cast<CLogEvent&>( mLogView->Event() ).SetId( 100 );
QVERIFY( !state.enterL() );
@@ -563,7 +563,7 @@
{
// Duplicates view empty, cannot start
LogClientStubsHelper::setViewCount(0);
- LogsReaderStateReadingDuplicates state(*this);
+ LogsReaderStateReadingDuplicates state(*this, *this);
QVERIFY( !state.enterL() );
@@ -588,7 +588,7 @@
void UT_LogsReaderStates::testStateReadingDuplicatesDone()
{
- LogsReaderStateReadingDuplicatesDone state(*this);
+ LogsReaderStateReadingDuplicatesDone state(*this, *this);
// No duplicates was found
QVERIFY( !state.enterL() );
@@ -606,7 +606,7 @@
void UT_LogsReaderStates::testStateModifyingDone()
{
- LogsReaderStateModifyingDone state(*this);
+ LogsReaderStateModifyingDone state(*this, *this);
// Modified event not found for some reason
LogsEvent* logsEvent = new LogsEvent;
@@ -627,18 +627,14 @@
}
// ----------------------------------------------------------------------------
-// From LogsReaderStateContext
+// From LogsStateBaseContext
// ----------------------------------------------------------------------------
//
-void UT_LogsReaderStates::setCurrentState(const LogsReaderStateBase& state)
+void UT_LogsReaderStates::setCurrentState(const LogsStateBase& state)
{
mCurrentState = &state;
}
-// ----------------------------------------------------------------------------
-// From LogsReaderStateContext
-// ----------------------------------------------------------------------------
-//
CLogView& UT_LogsReaderStates::logView()
{
if ( mIsRecentView ){
@@ -652,35 +648,16 @@
return *mDuplicatesView;
}
-QList<LogsEvent*>& UT_LogsReaderStates::events()
-{
- return mEvents;
-}
-
int& UT_LogsReaderStates::index()
{
return mIndex;
}
-LogsEventStrings& UT_LogsReaderStates::strings()
-{
- return mStrings;
-}
-
TRequestStatus& UT_LogsReaderStates::reqStatus()
{
return mReqStatus;
}
-LogsReaderObserver& UT_LogsReaderStates::observer()
-{
- return *this;
-}
-
-QHash<QString, ContactCacheEntry>& UT_LogsReaderStates::contactCache()
-{
- return mContactCache;
-}
int UT_LogsReaderStates::currentEventId()
{
@@ -697,6 +674,31 @@
return mIsRecentView;
}
+// ----------------------------------------------------------------------------
+// From LogsReaderStateContext
+// ----------------------------------------------------------------------------
+//
+
+LogsEventStrings& UT_LogsReaderStates::strings()
+{
+ return mStrings;
+}
+
+LogsReaderObserver& UT_LogsReaderStates::observer()
+{
+ return *this;
+}
+
+QHash<QString, ContactCacheEntry>& UT_LogsReaderStates::contactCache()
+{
+ return mContactCache;
+}
+
+QList<LogsEvent*>& UT_LogsReaderStates::events()
+{
+ return mEvents;
+}
+
QList<LogsEvent*>& UT_LogsReaderStates::duplicatedEvents()
{
return mDuplicatedEvents;
--- a/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/ut_logsremove.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/ut_logsremove.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -64,7 +64,7 @@
void UT_LogsRemove::testConstructor()
{
QVERIFY( mLogsRemove );
- QVERIFY( mLogsRemove->mFsSession );
+ QVERIFY( !mLogsRemove->mFsSession );
QVERIFY( !mLogsRemove->mLogClient );
}
@@ -93,13 +93,15 @@
QVERIFY( mLogsRemove->clearEvents(events, async) == 0 );
QVERIFY( !async );
QVERIFY( mLogsRemove->mRemovedEvents.count() == 0 );
+ QVERIFY( !mLogsRemove->IsActive() );
// Clearing with recent view (ids)
events.append(2);
events.append(100);
QVERIFY( mLogsRemove->clearEvents(events, async) == 0 );
- QVERIFY( !async );
- QVERIFY( mLogsRemove->mRemovedEvents.count() == 0 );
+ QVERIFY( async );
+ QVERIFY( mLogsRemove->mRemovedEvents.count() == 2 );
+ QVERIFY( mLogsRemove->IsActive() );
// Clearing with all events (no ids)
events.clear();
@@ -107,56 +109,24 @@
QVERIFY( removeWithAllEvents.clearEvents(events, async) == 0 );
QVERIFY( !async );
QVERIFY( removeWithAllEvents.mRemovedEvents.count() == 0 );
+ QVERIFY( !removeWithAllEvents.IsActive() );
// Clearing with all events (ids)
events.append(99);
events.append(100);
QVERIFY( removeWithAllEvents.clearEvents(events, async) == 0 );
QVERIFY( async );
- QVERIFY( removeWithAllEvents.mRemovedEvents.count() == 1 );
- QVERIFY( removeWithAllEvents.mRemovedEvents.at(0) == 100 );
-
-}
-
-void UT_LogsRemove::testDoCancel()
-{
- mLogsRemove->DoCancel();
-}
-
-void UT_LogsRemove::testRunL()
-{
- // Test ok scenario
- mLogsRemove->init();
- mLogsRemove->Cancel();
- mLogsRemove->iStatus = KErrNone;
- mLogsRemove->RunL();
- QVERIFY( mRemoveCompleted );
+ QVERIFY( removeWithAllEvents.mRemovedEvents.count() == 2 );
+ QVERIFY( removeWithAllEvents.mRemovedEvents.at(0) == 99 );
+ QVERIFY( removeWithAllEvents.mRemovedEvents.at(1) == 100 );
+ QVERIFY( removeWithAllEvents.IsActive() );
- // Ok scenario when more events to delete
- mRemoveCompleted = false;
- mLogsRemove->mRemovedEvents.append(2);
- mLogsRemove->mRemovedEvents.append(4);
- mLogsRemove->Cancel();
- mLogsRemove->RunL();
- QVERIFY( !mRemoveCompleted );
- QVERIFY( mLogsRemove->mRemovedEvents.count() == 1 );
-
- mLogsRemove->Cancel();
- mLogsRemove->RunL();
- QVERIFY( !mRemoveCompleted );
- QVERIFY( mLogsRemove->mRemovedEvents.count() == 0 );
-
- // Ok scenario when no more events to delete
- mLogsRemove->Cancel();
- mLogsRemove->RunL();
- QVERIFY( mRemoveCompleted );
- QVERIFY( mLogsRemove->mRemovedEvents.count() == 0 );
-
- // Test failure
- mLogsRemove->Cancel();
- mLogsRemove->iStatus = KErrNotFound;
- TRAPD( err, mLogsRemove->RunL() );
- QVERIFY( err == KErrNotFound );
+ // Clearing not allowed while previous is active
+ events.append(200);
+ QVERIFY( removeWithAllEvents.clearEvents(events, async) != 0 );
+ QVERIFY( mLogsRemove->mRemovedEvents.count() == 2 );
+ QVERIFY( !async );
+ QVERIFY( removeWithAllEvents.IsActive() );
}
void UT_LogsRemove::testRunError()
@@ -177,11 +147,13 @@
//initializing for the first time
QVERIFY( mLogsRemove->init() == KErrNone );
QVERIFY( mLogsRemove->mLogClient );
+ QVERIFY( mLogsRemove->mFsSession );
CLogClient* oldClient = mLogsRemove->mLogClient;
//2d time should be also ok
QVERIFY( mLogsRemove->init() == KErrNone );
QVERIFY( mLogsRemove->mLogClient );
+ QVERIFY( mLogsRemove->mFsSession );
QVERIFY( oldClient == mLogsRemove->mLogClient );
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/src/ut_logsremovestates.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -0,0 +1,265 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#include "ut_logsremovestates.h"
+#include "logsremovestates.h"
+#include "logclient_stubs_helper.h"
+#include "logsmodel.h"
+#include <logcli.h>
+#include <logview.h>
+
+#include <QtTest/QtTest>
+
+void UT_LogsRemoveStates::initTestCase()
+{
+ int rfsDummy = 0;
+ mLogClient = CLogClient::NewL( *((RFs*)&rfsDummy) );
+}
+
+void UT_LogsRemoveStates::cleanupTestCase()
+{
+ delete mLogClient;
+}
+
+
+void UT_LogsRemoveStates::init()
+{
+ reset();
+
+ mCurrentState = 0;
+ mIndex = 0;
+ mLogView = 0;
+ mLogViewEvent = 0;
+ mIsRecentView = true;
+
+ mLogView = CLogViewRecent::NewL(*mLogClient);
+ mLogViewEvent = 0;
+ mDuplicatesView = CLogViewDuplicate::NewL(*mLogClient);
+}
+
+void UT_LogsRemoveStates::cleanup()
+{
+ delete mLogView;
+ mLogView = 0;
+ delete mLogViewEvent;
+ mLogViewEvent = 0;
+ delete mDuplicatesView;
+ mDuplicatesView = 0;
+}
+
+void UT_LogsRemoveStates::reset()
+{
+ mRemoveCompleted = false;
+ mClearType = -1;
+ mRemovedEvents.clear();
+}
+
+void UT_LogsRemoveStates::testClearAll()
+{
+ LogsRemoveStateClearAll state(*this, *this);
+ mClearType = LogsModel::TypeLogsClearAll;
+ QVERIFY( state.enterL() );
+ QCOMPARE( LogClientStubsHelper::lastCalledFunc(), QString("ClearLog") );
+
+ mClearType = LogsModel::TypeLogsClearMissed;
+ QVERIFY( state.enterL() );
+ QCOMPARE( LogClientStubsHelper::lastCalledFunc(), QString("ClearLogRecentList") );
+
+ QVERIFY( !state.continueL() );
+}
+
+void UT_LogsRemoveStates::testInit()
+{
+ LogsRemoveStateInit state(*this, *this);
+
+ // Nothing happens when no recent view exists
+ mIsRecentView = false;
+ QVERIFY( !state.enterL() );
+
+ // Recent view exists and is getting initialized
+ mIndex = 4;
+ mIsRecentView = true;
+ QVERIFY( state.enterL() );
+ QCOMPARE( mIndex, 0 );
+
+ QVERIFY( !state.continueL() );
+}
+
+void UT_LogsRemoveStates::testDelete()
+{
+ LogsRemoveStateDelete state(*this, *this);
+
+ // Nothing to delete
+ QVERIFY( !state.enterL() );
+
+ // Delete several
+ mRemovedEvents.append(1);
+ mRemovedEvents.append(3);
+ mRemovedEvents.append(4);
+
+ QVERIFY( state.enterL() );
+ QCOMPARE( state.mRemoveIndex, 1 );
+ QVERIFY( state.continueL() );
+ QCOMPARE( state.mRemoveIndex, 2 );
+ QVERIFY( state.continueL() );
+ QCOMPARE( state.mRemoveIndex, 3 );
+ QVERIFY( !state.continueL() );
+}
+
+void UT_LogsRemoveStates::testDeleteDuplicates()
+{
+ LogsRemoveStateDeleteDuplicates state(*this, *this);
+
+ // More than one id, duplicate deletion not supported
+ mRemovedEvents.append(1);
+ mRemovedEvents.append(3);
+ QVERIFY( !state.enterL() );
+
+ // Dbview iterator is not at correct location
+ mRemovedEvents.clear();
+ mRemovedEvents.append(99);
+ const_cast<CLogEvent&>( mLogView->Event() ).SetId( 100 );
+ QVERIFY( !state.enterL() );
+
+ // No duplicates
+ LogClientStubsHelper::setStubAsyncCallPossible(false);
+ LogClientStubsHelper::setViewCount(0); // effective also for duplicates view
+ const_cast<CLogEvent&>( mLogView->Event() ).SetId( 99 );
+ QVERIFY( !state.enterL() );
+
+ // Duplicates
+ LogClientStubsHelper::setStubAsyncCallPossible(true);
+ LogClientStubsHelper::setViewCount(3); // effective also for duplicates view
+ QVERIFY( state.enterL() );
+ QVERIFY( !state.mDeleting );
+ QCOMPARE( state.mDeleteDuplicateIds.count(), 0 );
+
+ QVERIFY( state.continueL() );
+ QVERIFY( !state.mDeleting );
+ QCOMPARE( state.mDeleteDuplicateIds.count(), 0 );
+ QVERIFY( state.continueL() );
+ QVERIFY( !state.mDeleting );
+ QCOMPARE( state.mDeleteDuplicateIds.count(), 1 );
+ QVERIFY( state.continueL() );
+ QVERIFY( !state.mDeleting );
+ QCOMPARE( state.mDeleteDuplicateIds.count(), 2 );
+ QVERIFY( state.continueL() );
+ QVERIFY( !state.mDeleting );
+ QCOMPARE( state.mDeleteDuplicateIds.count(), 3 );
+
+ QVERIFY( state.continueL() );
+ QVERIFY( state.mDeleting );
+ QCOMPARE( state.mDeleteDuplicateIds.count(), 2 );
+ QVERIFY( state.continueL() );
+ QVERIFY( state.mDeleting );
+ QCOMPARE( state.mDeleteDuplicateIds.count(), 1 );
+ QVERIFY( state.continueL() );
+ QVERIFY( state.mDeleting );
+ QCOMPARE( state.mDeleteDuplicateIds.count(), 0 );
+ QVERIFY( !state.continueL() );
+
+}
+
+void UT_LogsRemoveStates::testDone()
+{
+ LogsRemoveStateDone state(*this, *this);
+ QVERIFY( !mRemoveCompleted );
+ QVERIFY( !state.enterL() );
+ QVERIFY( mRemoveCompleted );
+}
+
+// ----------------------------------------------------------------------------
+// From LogsStateBaseContext
+// ----------------------------------------------------------------------------
+//
+void UT_LogsRemoveStates::setCurrentState(const LogsStateBase& state)
+{
+ mCurrentState = &state;
+}
+
+CLogView& UT_LogsRemoveStates::logView()
+{
+ if ( mIsRecentView ){
+ return *mLogView;
+ }
+ return *mLogViewEvent;
+}
+
+CLogViewDuplicate& UT_LogsRemoveStates::duplicatesView()
+{
+ return *mDuplicatesView;
+}
+
+int& UT_LogsRemoveStates::index()
+{
+ return mIndex;
+}
+
+TRequestStatus& UT_LogsRemoveStates::reqStatus()
+{
+ return mReqStatus;
+}
+
+
+int UT_LogsRemoveStates::currentEventId()
+{
+ if ( !mRemovedEvents.isEmpty() ){
+ return mRemovedEvents.at(0);
+ }
+ return mCurrentEventId;
+}
+
+CLogClient& UT_LogsRemoveStates::logClient()
+{
+ return *mLogClient;
+}
+
+bool UT_LogsRemoveStates::isRecentView()
+{
+ return mIsRecentView;
+}
+
+
+// ----------------------------------------------------------------------------
+// From LogsRemoveStateContext
+// ----------------------------------------------------------------------------
+//
+
+LogsRemoveObserver& UT_LogsRemoveStates::observer()
+{
+ return *this;
+}
+QList<int>& UT_LogsRemoveStates::removedEvents()
+{
+ return mRemovedEvents;
+}
+int UT_LogsRemoveStates::clearType()
+{
+ return mClearType;
+}
+
+// ----------------------------------------------------------------------------
+// From LogsRemoveObserver
+// ----------------------------------------------------------------------------
+//
+void UT_LogsRemoveStates::removeCompleted()
+{
+ mRemoveCompleted = true;
+}
+void UT_LogsRemoveStates::logsRemoveErrorOccured(int err)
+{
+ mError = err;
+}
--- a/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/ut_logssymbianos.pro Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/logssymbianos/tsrc/ut_logssymbianos/ut_logssymbianos.pro Wed Aug 18 09:49:12 2010 +0300
@@ -45,11 +45,14 @@
HEADERS += inc/ut_logseventparser.h
HEADERS += inc/ut_logseventdataparser.h
HEADERS += inc/ut_logsremove.h
+HEADERS += inc/ut_logsremovestates.h
HEADERS += ../../inc/logsdbconnector.h
+HEADERS += ../../inc/logsworker.h
HEADERS += ../../inc/logsreader.h
HEADERS += ../../inc/logsreaderstates.h
HEADERS += ../../inc/logsreaderobserver.h
HEADERS += ../../inc/logsremove.h
+HEADERS += ../../inc/logsremovestates.h
HEADERS += ../../../../../recents_plat/logs_engine_api/inc/logsevent.h
HEADERS += ../../../inc/logseventdata.h
HEADERS += ../../../inc/logscommondata.h
@@ -64,12 +67,16 @@
SOURCES += src/ut_logseventparser.cpp
SOURCES += src/ut_logseventdataparser.cpp
SOURCES += src/ut_logsremove.cpp
+SOURCES += src/ut_logsremovestates.cpp
SOURCES += ../../src/logsdbconnector.cpp
+SOURCES += ../../src/logsworker.cpp
SOURCES += ../../src/logsreader.cpp
+SOURCES += ../../src/logsstatebase.cpp
SOURCES += ../../src/logsreaderstates.cpp
SOURCES += ../../src/logseventparser.cpp
SOURCES += ../../src/logseventdataparser.cpp
SOURCES += ../../src/logsremove.cpp
+SOURCES += ../../src/logsremovestates.cpp
SOURCES += ../../../src/logsevent.cpp
SOURCES += ../../../src/logseventdata.cpp
SOURCES += ../../../src/logscommondata.cpp
--- a/logsui/logsengine/src/logscontact.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/src/logscontact.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -157,6 +157,18 @@
//
// ----------------------------------------------------------------------------
//
+void LogsContact::cancelServiceRequest()
+{
+ LOGS_QDEBUG( "logs [ENG] -> LogsContact::cancelServiceRequest()" )
+ delete mService;
+ mService = 0;
+ LOGS_QDEBUG( "logs [ENG] <- LogsContact::cancelServiceRequest()" )
+}
+
+// ----------------------------------------------------------------------------
+//
+// ----------------------------------------------------------------------------
+//
bool LogsContact::save(QString message)
{
QList<QVariant> arguments;
@@ -191,17 +203,15 @@
bool LogsContact::requestFetchService( QString message,
const QList<QVariant> &arguments, bool sync )
{
- QString service("com.nokia.services.phonebookservices.Fetch");
-
- delete mService;
- mService = 0;
+ QString service("com.nokia.services.phonebookservices.Fetch");
+ cancelServiceRequest();
mService = new XQServiceRequest(service, message, sync);
connect(mService, SIGNAL(requestCompleted(QVariant)), this,
SLOT(handleRequestCompleted(QVariant)));
mService->setArguments(arguments);
XQRequestInfo info;
- info.setForeground(true);
+ info.setEmbedded(true);
mService->setInfo(info);
QVariant retValue;
@@ -218,6 +228,8 @@
//
void LogsContact::handleRequestCompleted(const QVariant& result)
{
+ delete mService;
+ mService = 0;
bool retValOk = false;
int serviceRetVal = result.toInt(&retValOk);
LOGS_QDEBUG_3( "logs [ENG] -> LogsContact::handleRequestCompleted(), (retval, is_ok)",
--- a/logsui/logsengine/src/logsmatchesmodel.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/src/logsmatchesmodel.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -195,7 +195,8 @@
delete logsContact;
logsContact = 0;
} else {
- connect( logsContact, SIGNAL(saveCompleted(bool)), this, SLOT(forceSearchQuery()) );
+ connect(logsContact, SIGNAL(saveCompleted(bool)), this, SLOT(contactUpdated(bool)));
+ connect(logsContact, SIGNAL(openCompleted(bool)), this, SLOT(contactUpdated(bool)));
}
QVariant var = qVariantFromValue(logsContact);
LOGS_QDEBUG( "logs [ENG] <- LogsMatchesModel::createContact()" )
@@ -340,7 +341,8 @@
int searchStatus = mDbConnector->predictiveSearchStatus();
//searchStatus equal to 0 means that search should be permanently disabled
if (searchStatus != 0) {
- mLogsCntFinder = new LogsCntFinder(LogsCommonData::getInstance().contactManager());
+ mLogsCntFinder = new LogsCntFinder(LogsCommonData::getInstance().contactManager(),
+ true);
connect(mLogsCntFinder, SIGNAL(queryReady()),this, SLOT(queryReady()));
connect( &mParentModel, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)),
@@ -500,6 +502,21 @@
//
// -----------------------------------------------------------------------------
//
+void LogsMatchesModel::contactUpdated(bool /*updated*/)
+{
+ LOGS_QDEBUG( "logs [ENG] -> LogsMatchesModel::contactUpdated()" )
+ // At the moment phonebook doesnt notify properly when contact was updated
+ // Let's reset all results (to clear cached contacts) for now, in the
+ // future do it only if the contact was changed for real
+ mLogsCntFinder->resetResults();
+ forceSearchQuery();
+ LOGS_QDEBUG( "logs [ENG] <- LogsMatchesModel::contactUpdated()" )
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
void LogsMatchesModel::updateSearchEntry(LogsCntEntry& entry, LogsEvent& event)
{
if ( event.remoteParty().length() > 0 ) {
@@ -614,16 +631,13 @@
//
QString LogsMatchesModelItemContainer::number() const
{
- QString num;
+ QString number;
if ( mEvent ){
- num = mEvent->getNumberForCalling();
+ number = mEvent->getNumberForCalling();
} else if ( mContactId > 0 ) {
- QContact contact = LogsCommonData::getInstance().contactManager().contact( mContactId );
- QContactPhoneNumber contactNum =
- contact.detail( QContactPhoneNumber::DefinitionName );
- num = contactNum.value(QContactPhoneNumber::FieldNumber);
+ number = mContactNumber;
}
- return num;
+ return number;
}
// -----------------------------------------------------------------------------
--- a/logsui/logsengine/tsrc/stubs/logscntfinder.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/tsrc/stubs/logscntfinder.h Wed Aug 18 09:49:12 2010 +0300
@@ -117,8 +117,8 @@
public: // The exported API
- LogsCntFinder();
- LogsCntFinder(QContactManager& contactManager);
+ LogsCntFinder(bool preferDefaultNumber = false);
+ LogsCntFinder(QContactManager& contactManager, bool preferDefaultNumber = false);
~LogsCntFinder();
/**
@@ -160,6 +160,8 @@
*/
void deleteEntry( const LogsCntEntryHandle& handle );
+ void resetResults();
+
signals:
/**
--- a/logsui/logsengine/tsrc/stubs/logscntfinder_stub.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/tsrc/stubs/logscntfinder_stub.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -272,7 +272,7 @@
// LogsCntFinder::LogsCntFinder()
// -----------------------------------------------------------------------------
//
-LogsCntFinder::LogsCntFinder()
+LogsCntFinder::LogsCntFinder(bool /*preferDefaultNumber*/)
{
LOGS_QDEBUG( "logs [FINDER] -> LogsCntFinder::LogsCntFinder()" )
@@ -288,7 +288,7 @@
// LogsCntFinder::LogsCntFinder()
// -----------------------------------------------------------------------------
//
-LogsCntFinder::LogsCntFinder(QContactManager& contactManager)
+LogsCntFinder::LogsCntFinder(QContactManager& contactManager,bool /*preferDefaultNumber*/)
{
LOGS_QDEBUG( "logs [FINDER] -> LogsCntFinder::LogsCntFinder(), cntmgr from client" )
@@ -473,9 +473,17 @@
delete toRemoveHistoryEv;
LOGS_QDEBUG( "logs [FINDER] <- LogsCntFinder::deleteEntry()" )
-
+}
+
+// -----------------------------------------------------------------------------
+// LogsCntFinder::resetResults
+// -----------------------------------------------------------------------------
+//
+void LogsCntFinder::resetResults()
+{
+ qDeleteAll( mResults );
+ mResults.clear();
}
-
--- a/logsui/logsengine/tsrc/stubs/qthighway_stub.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/tsrc/stubs/qthighway_stub.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -23,12 +23,14 @@
QString qtHighwayStubService;
QString qtHighwayStubMessage;
bool qtHighwayStubRequestBg = false;
+bool qtHighwayStubRequestEmbedded = false;
void QtHighwayStubHelper::reset()
{
qtHighwayStubService.clear();
qtHighwayStubMessage.clear();
qtHighwayStubRequestBg = false;
+ qtHighwayStubRequestEmbedded = false;
}
QString QtHighwayStubHelper::service()
@@ -46,6 +48,11 @@
return qtHighwayStubRequestBg;
}
+bool QtHighwayStubHelper::isRequestEmbedded()
+{
+ return qtHighwayStubRequestEmbedded;
+}
+
XQServiceRequest::XQServiceRequest(
const QString& service, const QString& message, const bool& synchronous)
{
@@ -110,5 +117,10 @@
void XQRequestInfo::setForeground(bool on)
{
- Q_UNUSED(on)
+ qtHighwayStubRequestBg = !on;
}
+
+void XQRequestInfo::setEmbedded(bool embedded)
+{
+ qtHighwayStubRequestEmbedded = embedded;
+}
--- a/logsui/logsengine/tsrc/stubs/qthighway_stub_helper.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/tsrc/stubs/qthighway_stub_helper.h Wed Aug 18 09:49:12 2010 +0300
@@ -25,4 +25,5 @@
static QString service();
static QString message();
static bool isRequestBg();
+ static bool isRequestEmbedded();
};
--- a/logsui/logsengine/tsrc/ut_logsengine/inc/ut_logscontact.h Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/tsrc/ut_logsengine/inc/ut_logscontact.h Wed Aug 18 09:49:12 2010 +0300
@@ -55,6 +55,7 @@
void testIsContactInPhonebook();
void testIsContactRequestAllowed();
void testHandleRequestCompeted();
+ void testCancelServiceRequest();
private:
--- a/logsui/logsengine/tsrc/ut_logsengine/src/ut_logscontact.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/tsrc/ut_logsengine/src/ut_logscontact.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -21,6 +21,7 @@
#include "logsdbconnector.h"
#include "logsdbconnector_stub_helper.h"
#include "qtcontacts_stubs_helper.h"
+#include "qthighway_stub_helper.h"
#include <xqservicerequest.h>
#include <QtTest/QtTest>
@@ -106,6 +107,7 @@
QVERIFY( mLogsContact->mCurrentRequest == LogsContact::TypeLogsContactSave );
//contact is in phonebook, open is ok
+ QtHighwayStubHelper::reset();
mLogsEvent->logsEventData()->setContactLocalId(2);
QtContactsStubsHelper::setContactId(2);
delete mLogsContact;
@@ -116,15 +118,17 @@
QVERIFY( mLogsContact->mCurrentRequest == LogsContact::TypeLogsContactOpen );
QVERIFY( mLogsContact->mService->service() == logsFetchService );
QVERIFY( mLogsContact->mService->message() == "open(int)" );
+ QVERIFY( QtHighwayStubHelper::isRequestEmbedded() );
// Same but without using logsevent at construction
+ QtHighwayStubHelper::reset();
LogsContact contactWithoutEvent("2345", *mDbConnector, 2);
QVERIFY( contactWithoutEvent.open() );
QVERIFY( contactWithoutEvent.mService );
QVERIFY( contactWithoutEvent.mCurrentRequest == LogsContact::TypeLogsContactOpen );
QVERIFY( contactWithoutEvent.mService->service() == logsFetchService );
QVERIFY( contactWithoutEvent.mService->message() == "open(int)" );
-
+ QVERIFY( QtHighwayStubHelper::isRequestEmbedded() );
}
void UT_LogsContact::testAddNew()
@@ -137,6 +141,7 @@
QVERIFY( mLogsContact->mCurrentRequest == LogsContact::TypeLogsContactSave );
//called ID present, contact not in phonebook => save is ok
+ QtHighwayStubHelper::reset();
mLogsEvent->setNumber(QString::number(12345));
mLogsEvent->setEventType(LogsEvent::TypeVoiceCall);
delete mLogsContact;
@@ -149,8 +154,10 @@
QVERIFY( mLogsContact->mCurrentRequest == LogsContact::TypeLogsContactSave );
QVERIFY( mLogsContact->mService->service() == logsFetchService );
QVERIFY( mLogsContact->mService->message() == "editCreateNew(QString,QString)" );
+ QVERIFY( QtHighwayStubHelper::isRequestEmbedded() );
//caller ID present, contact is in phonebook => save is ok
+ QtHighwayStubHelper::reset();
mLogsEvent->setEventType(LogsEvent::TypeVoIPCall);
mLogsEvent->setNumber("");
mLogsEvent->logsEventData()->mRemoteUrl = "someurl@blah";
@@ -165,11 +172,13 @@
QVERIFY( mLogsContact->mCurrentRequest == LogsContact::TypeLogsContactSave );
QVERIFY( mLogsContact->mService->service() == logsFetchService );
QVERIFY( mLogsContact->mService->message() == "editCreateNew(QString,QString)" );
+ QVERIFY( QtHighwayStubHelper::isRequestEmbedded() );
}
void UT_LogsContact::testUpdateExisting()
{
//caller ID present, contact is in phonebook => update is ok
+ QtHighwayStubHelper::reset();
mLogsEvent->setNumber(QString::number(12345));
mLogsEvent->setEventType(LogsEvent::TypeVoiceCall);
mLogsEvent->logsEventData()->setContactLocalId(2);
@@ -183,6 +192,7 @@
QVERIFY( mLogsContact->mCurrentRequest == LogsContact::TypeLogsContactSave );
QVERIFY( mLogsContact->mService->service() == logsFetchService );
QVERIFY( mLogsContact->mService->message() == "editUpdateExisting(QString,QString)" );
+ QVERIFY( QtHighwayStubHelper::isRequestEmbedded() );
}
void UT_LogsContact::testIsContactInPhonebook()
@@ -275,3 +285,11 @@
QVERIFY( spySaved.count() == 1 );
QVERIFY( LogsDbConnectorStubHelper::lastCalledFunction().isEmpty() );
}
+
+void UT_LogsContact::testCancelServiceRequest()
+{
+ QVERIFY( !mLogsContact->mService );
+ mLogsContact->mService = new XQServiceRequest("service", "message", false);
+ mLogsContact->cancelServiceRequest();
+ QVERIFY( !mLogsContact->mService );
+}
--- a/logsui/logsengine/tsrc/ut_logsengine/src/ut_logsmatchesmodel.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/logsengine/tsrc/ut_logsengine/src/ut_logsmatchesmodel.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -504,6 +504,7 @@
// With contact, calling supported
LogsMatchesModelItemContainer item3(*mModel, *mMatchesModel->mIconManager, 2);
item3.setContact(2);
+ item3.mContactNumber = "12345";
var = mMatchesModel->createCall(item3);
call = qVariantValue<LogsCall *>( var );
QVERIFY( call );
@@ -538,6 +539,7 @@
item3.setContact(2);
item3.mContactName = "<b>so</b>mename";
item3.mContactNameSimple = "somename";
+ item3.mContactNumber = "12345";
var = mMatchesModel->createMessage(item3);
message = qVariantValue<LogsMessage *>( var );
QVERIFY( message );
--- a/logsui/tsrc/logsengineapitester/src/logsengineapitester.cpp Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/tsrc/logsengineapitester/src/logsengineapitester.cpp Wed Aug 18 09:49:12 2010 +0300
@@ -16,11 +16,11 @@
*/
#include <QDebug>
-#include <HbListView.h>
-#include <HbMenu.h>
-#include <HbAction.h>
-#include <HbLabel.h>
-#include <HbMessageBox.h>
+#include <hblistview.h>
+#include <hbmenu.h>
+#include <hbaction.h>
+#include <hblabel.h>
+#include <hbmessagebox.h>
#include <QGraphicsLinearLayout>
#include <logsmodel.h>
#include <logsevent.h>
@@ -208,16 +208,12 @@
void TestView::markingCompleted(int err)
{
- HbMessageBox box(HbMessageBox::MessageTypeInformation);
- box.setText( QString("Marking completed, err:%1").arg(err) );
- box.exec();
+ HbMessageBox::information( QString("Marking completed, err:%1").arg(err) );
}
void TestView::clearingCompleted(int err)
{
- HbMessageBox box(HbMessageBox::MessageTypeInformation);
- box.setText( QString("Clearing completed, err:%1").arg(err) );
- box.exec();
+ HbMessageBox::information( QString("Clearing completed, err:%1").arg(err) );
}
TestModel::TestModel(QAbstractItemModel& logsModel) : mLogsModel(logsModel)
@@ -237,6 +233,7 @@
}
int TestModel::rowCount(const QModelIndex &parent) const
{
+ Q_UNUSED(parent);
return mEvents.count();
}
QVariant TestModel::data(const QModelIndex &index, int role) const
--- a/logsui/tsrc/unittestrunner/unittest_qt_config.txt Tue Jul 06 14:16:36 2010 +0300
+++ b/logsui/tsrc/unittestrunner/unittest_qt_config.txt Wed Aug 18 09:49:12 2010 +0300
@@ -1,4 +1,4 @@
ut_logsengine -noprompt,ut_logs_logsModel.xml,ut_logs_logsDetailsModel.xml,ut_logs_logsMatchesModel.xml,ut_logs_logsFilter.xml,ut_logs_logsCustomFilter.xml,ut_logs_logsCall.xml,ut_logs_logsContact.xml,ut_logs_logsMessage.xml,ut_logs_logsEvent.xml,ut_logs_logsEventData.xml
-ut_logssymbianos -noprompt,ut_logs_logsDbConnector.xml,ut_logs_logsRemove.xml,ut_logs_logsReader.xml,ut_logs_logsReaderStates.xml,ut_logs_logsEventParser.xml,ut_logs_logsEventDataParser.xml,ut_logs_logsForegroundWatcher.xml
+ut_logssymbianos -noprompt,ut_logs_logsDbConnector.xml,ut_logs_logsRemove.xml,ut_logs_logsReader.xml,ut_logs_logsReaderStates.xml,ut_logs_logsEventParser.xml,ut_logs_logsEventDataParser.xml,ut_logs_logsRemoveStates.xml
ut_logscntfinder -noprompt,UT_LogsPredictiveTranslator.xml, UT_LogsPredictive12KeyTranslator.xml, UT_LogsPredictiveLatin12KeyTranslator.xml, UT_LogsPredictiveThai12KeyTranslator.xml, UT_LogsCntEntry.xml, UT_LogsCntFinder.xml
ut_logsapp -noprompt,ut_logsMainWindow.xml,ut_logsRepository.xml,ut_logsViewManager.xml,ut_logsBaseView.xml,ut_logsRecentCallsView.xml,ut_logsDetailsView.xml,ut_logsMatchesView.xml,ut_logsEffectHandler.xml,ut_logsServiceHandler.xml,ut_logsPageIndicator.xml,ut_logsPageIndicatorItem.xml
--- a/recents_plat/logs_services_api/inc/logsservices.h Tue Jul 06 14:16:36 2010 +0300
+++ b/recents_plat/logs_services_api/inc/logsservices.h Wed Aug 18 09:49:12 2010 +0300
@@ -26,11 +26,18 @@
* Service name: "logs",
* Interface name: "com.nokia.symbian.ILogsView"
* Operation signature: "show(QVariantMap)"
+*
+* @deprecated don't use parameters below, they will be replaced (see xqaiwdecl.h mcl_w28-30)
* Operation parameters:
* "view_index": int, 0 - all recent, 1 - received, 2 - called, 3 - missed
* "show_dialpad": bool, if true view is shown with dialpad opened on top
* "dialpad_text": QString, number to be prefilled into dialpad
-*
+*
+* New params:
+* "ViewIndex": int, 0 - all recent, 1 - received, 2 - called, 3 - missed
+* "ShowDialpad": bool, if true view is shown with dialpad opened on top
+* "DialpadText": QString, number to be prefilled into dialpad
+*
* Example usage:
* XQApplicationManager appMgr;
* QScopedPointer<XQAiwRequest> request(appMgr.create(QString("logs"),
@@ -40,9 +47,9 @@
* int retValue = -1;
* QList<QVariant> arglist;
* QVariantMap map;
-* map.insert("view_index", QVariant(0));
-* map.insert("show_dialpad", QVariant(true));
-* map.insert("dialpad_text", QVariant(QString()));
+* map.insert("ViewIndex", QVariant(0));
+* map.insert("ShowDialpad", QVariant(true));
+* map.insert("DialpadText", QVariant(QString()));
* arglist.append(QVariant(map));
* request->setArguments(arglist);
* QVariant ret(retValue);