# HG changeset patch # User hgs # Date 1287134686 -10800 # Node ID 640d30f4fb646aba561a0a5e2a8176ce4850306f # Parent c18f9fa7f42e599d174975f08424f0dd1791ddda 201041 diff -r c18f9fa7f42e -r 640d30f4fb64 contacts_plat/contacts_ui_api/inc/cntabstractengine.h --- a/contacts_plat/contacts_ui_api/inc/cntabstractengine.h Fri Oct 08 11:42:51 2010 +0300 +++ b/contacts_plat/contacts_ui_api/inc/cntabstractengine.h Fri Oct 15 12:24:46 2010 +0300 @@ -23,6 +23,7 @@ class CntAbstractViewManager; class CntThumbnailManager; class CntExtensionManager; +class CntSaveManager; QTM_USE_NAMESPACE @@ -39,6 +40,7 @@ virtual CntAbstractViewManager& viewManager() = 0; virtual CntExtensionManager& extensionManager() = 0; virtual CntThumbnailManager& thumbnailManager() = 0; + virtual CntSaveManager& saveManager() = 0; }; #endif /* CNTABSTRACTENGINE_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 contacts_plat/contacts_ui_api/inc/cntabstractview.h --- a/contacts_plat/contacts_ui_api/inc/cntabstractview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/contacts_plat/contacts_ui_api/inc/cntabstractview.h Fri Oct 15 12:24:46 2010 +0300 @@ -34,7 +34,26 @@ * View is activated after its added to main window and is * ready to be drawn. */ - virtual void activate( const CntViewParameters aArgs ) = 0; + virtual void activate(const CntViewParameters aArgs) = 0; + + /** + * View details are internalized from stream to view parameters. + */ + virtual bool internalize(QDataStream &stream, CntViewParameters &viewParameters) + { + Q_UNUSED(stream); + Q_UNUSED(viewParameters); + return false; + } + + /** + * View is externalized parameters and return activity name. + */ + virtual QString externalize(QDataStream &stream) + { + Q_UNUSED(stream); + return QString(); + } /** * View is deactivated just before its removed from diff -r c18f9fa7f42e -r 640d30f4fb64 contacts_plat/contacts_ui_api/inc/cntviewparams.h --- a/contacts_plat/contacts_ui_api/inc/cntviewparams.h Fri Oct 08 11:42:51 2010 +0300 +++ b/contacts_plat/contacts_ui_api/inc/cntviewparams.h Fri Oct 15 12:24:46 2010 +0300 @@ -34,7 +34,9 @@ EViewId = 0, ESelectedAction, ESelectedContact, + ESelectedContactId, ESelectedGroupContact, + ESelectedGroupContactId, ESelectedDetail, ESelectionMode, EMyCard, diff -r c18f9fa7f42e -r 640d30f4fb64 contacts_plat/contacts_ui_extensions_api/tsrc/contactcardplugin/contactcardplugin.pro --- a/contacts_plat/contacts_ui_extensions_api/tsrc/contactcardplugin/contactcardplugin.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/contacts_plat/contacts_ui_extensions_api/tsrc/contactcardplugin/contactcardplugin.pro Fri Oct 15 12:24:46 2010 +0300 @@ -49,4 +49,5 @@ } target.path += $$[QT_INSTALL_PLUGINS]/contacts/extensions -INSTALLS += target \ No newline at end of file +INSTALLS += target +symbian:MMP_RULES += SMPSAFE \ No newline at end of file diff -r c18f9fa7f42e -r 640d30f4fb64 contacts_plat/presence_cache_api/tsrc/mt_preseceqt/entitytests.cpp --- a/contacts_plat/presence_cache_api/tsrc/mt_preseceqt/entitytests.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/contacts_plat/presence_cache_api/tsrc/mt_preseceqt/entitytests.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -614,10 +614,8 @@ QString testnewVal = aPresenceBuddyInfo->getAnyField( newKey ); QVERIFY ( testnewVal== newValue ); } - + } - - } void EntityTests::handlePresenceReadInClient(bool success, QList buddyInfoList) { int cnt = buddyInfoList.count(); @@ -636,8 +634,7 @@ } } -void EntityTests::handlePresencewriteInclient(bool success) - +void EntityTests::handlePresencewriteInclient(bool success) { if(success == true) { @@ -645,3 +642,95 @@ } } + +/*! + * A helper function for the test threads used in EntityTests::test9 + * Basically just creates a presence reader and records wether or not + * succesfull + */ + +TInt EntityTests::startupTestThreadFunction(TAny* any) + { + // 1. Add cleanup stack support. + CTrapCleanup* cleanupStack = CTrapCleanup::New(); + + // 2. Add support for active objects + CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler; + CActiveScheduler::Install(activeScheduler); + + // 3. create reader, which will cause the server startup (provided it is not running) + PrcPresenceReader* reader = PrcPresenceReader::createReader(); + + // 4. If reader created correctly, increase provided results counter + if (reader) + { + TInt* count = (TInt*) any; + (*count)++; + } + + delete reader; + + return(KErrNone); + } + +/*! + * Special server startup test. + * + * 1. This test first waits that the presence server timeouts and shuts down. + * 2. Then two test threads are created which simultaneously try to create + * presence reader instances. + * 3. That causes two server instances trying to start at the same time and + * the latter fails with KErrAlreadyExists + * 4. We check that is handled correctly by checking that neither test thread + * panics and succesfully creates the reader + */ +void EntityTests::test9() + { + // this will hold the count of succesfully created readers + TInt readerCount=0; + + // 1. Wait so the server time outs and shuts down. + // (we want to start fresh for this test) + User::After(3000000); + + // 2. Create two test threads and start them + _LIT(KMyThread1, "PresenceTestThread1"); + TBufC<48> threadName(KMyThread1); + RThread thread1; + TRequestStatus thread1Status; + + _LIT(KMyThread2, "PresenceTestThread2"); + TBufC<48> threadName2(KMyThread2); + RThread thread2; + TRequestStatus thread2Status; + + TInt r=thread1.Create(KMyThread1, + EntityTests::startupTestThreadFunction, + KDefaultStackSize, + NULL, + &readerCount); + + TInt x=thread2.Create(KMyThread2, + EntityTests::startupTestThreadFunction, + KDefaultStackSize, + NULL, + &readerCount); + + thread1.Logon(thread1Status); + thread2.Logon(thread2Status); + thread1.Resume(); + thread2.Resume(); + + // 3. When threads are ready, verify results + User::WaitForRequest(thread1Status); + User::WaitForRequest(thread2Status); + + // verify that neither thread paniced + QVERIFY(thread1.ExitType() != EExitPanic); + QVERIFY(thread2.ExitType() != EExitPanic); + // verify that both succesfully created presence readers + QVERIFY(readerCount == 2); + + thread1.Close(); + thread2.Close(); + } diff -r c18f9fa7f42e -r 640d30f4fb64 contacts_plat/presence_cache_api/tsrc/mt_preseceqt/entitytests.h --- a/contacts_plat/presence_cache_api/tsrc/mt_preseceqt/entitytests.h Fri Oct 08 11:42:51 2010 +0300 +++ b/contacts_plat/presence_cache_api/tsrc/mt_preseceqt/entitytests.h Fri Oct 15 12:24:46 2010 +0300 @@ -29,9 +29,7 @@ { Q_OBJECT public: - explicit EntityTests(QObject *parent = 0); - - + explicit EntityTests(QObject *parent = 0); private slots: // Init & cleanup void initTestCase(); @@ -44,8 +42,10 @@ void test6(); void test7(); void test8(); + void test9(); private: + static TInt startupTestThreadFunction(TAny *any); void saveBuddy(QMap& map); void fetchAndVerifyBuddy( QMap& map ); void subscribeBuddy( QString &buddyId); diff -r c18f9fa7f42e -r 640d30f4fb64 contacts_plat/presence_cache_api/tsrc/mt_preseceqt/mt_preseceqt.pro --- a/contacts_plat/presence_cache_api/tsrc/mt_preseceqt/mt_preseceqt.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/contacts_plat/presence_cache_api/tsrc/mt_preseceqt/mt_preseceqt.pro Fri Oct 15 12:24:46 2010 +0300 @@ -23,7 +23,7 @@ QT += testlib network webkit xmlpatterns CONFIG += mobility DEFINES += CNT_SOC_ENG_UNIT_TEST - +CONFIG += symbian_test TARGET.CAPABILITY = ALL -TCB DEPENDPATH += . @@ -32,8 +32,8 @@ INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE -INCLUDEPATH += ..\..\..\\presence_cache_api\inc -INCLUDEPATH += ..\..\inc +INCLUDEPATH += ../../..//presence_cache_api/inc +INCLUDEPATH += ../../inc HEADERS += entitytests.h diff -r c18f9fa7f42e -r 640d30f4fb64 contacts_plat/presence_cache_api/tsrc/mt_preseceqt/start.cpp --- a/contacts_plat/presence_cache_api/tsrc/mt_preseceqt/start.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/contacts_plat/presence_cache_api/tsrc/mt_preseceqt/start.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -22,10 +22,12 @@ #include #include - +#undef LOG_TO_FILE //QTEST_MAIN(TestOfTest); int main(int argc, char *argv[]) { +#ifdef LOG_TO_FILE + bool promptOnExit(0); for (int i=0; idetail(); } - // invoke action - if(mCommLauncherAction) - delete mCommLauncherAction; - mCommLauncherAction = QContactAction::action(messageActionDescriptors.at(0)); - mCleanupHandler.add(mCommLauncherAction); - - if (!messageNumber.isEmpty()) { - mCommLauncherAction->invokeAction(*mContact, messageNumber); - - qDebug() << "send to number " << messageNumber.number(); + + if (messageNumber.isEmpty()) { + qDebug() << "contact have not phone number, why am I here?"; + } else { + if (mRequest) { + delete mRequest; + } + mRequest = mApplicationManager->create(XQI_MESSAGE_SEND, + XQOP_MESSAGE_SEND_WITH_ID, + false); + if (mRequest) { + QList anArguments; + anArguments.append(QVariant::fromValue(messageNumber.number())); + anArguments.append(QVariant(0)); // unused contactId + anArguments.append(QVariant::fromValue( + mContact->displayLabel())); + mRequest->setArguments(anArguments); + mRequest->setSynchronous(false); + bool aResult = mRequest->send(); + if (!aResult) { + qDebug() << "request for message was not successful"; + } + } else { + qDebug() << "request for message was not created."; + } } } else { qDebug() << "contact has no Actions, can't send a message"; @@ -551,6 +557,7 @@ "Launch", "launch()", false); mCleanupHandler.add(mRequest); if (mRequest) { + mRequest->setSynchronous(false); QVariant retValue(-1); bool result = mRequest->send(retValue); if (!result) { diff -r c18f9fa7f42e -r 640d30f4fb64 contactwidgethsplugin/contactwidgeths/src/contactwidgeths.cpp --- a/contactwidgethsplugin/contactwidgeths/src/contactwidgeths.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/contactwidgethsplugin/contactwidgeths/src/contactwidgeths.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -55,18 +55,6 @@ // Docml file const QString contactWidgetDocml = ":/commlauncherwidget.docml"; - -// TODO: THESE STRINGS ARE IN W32 SDK. THESE DEFINITIONS CAN BE REMOVED -// WHEN EVERYBODY ARE USING IT OR LATER VERSION -#ifndef XQI_CONTACTS_FETCH -#define XQI_CONTACTS_FETCH QLatin1String("com.nokia.symbian.IContactsFetch") -#endif -#ifndef XQOP_CONTACTS_FETCH_SINGLE -#define XQOP_CONTACTS_FETCH_SINGLE QLatin1String("singleFetch(QString,QString)") -#endif - - - /*! \class ContactWidgetHs */ @@ -92,7 +80,8 @@ mThumbnailPixmap(QPixmap()), mThumbnailInProgress(false), mTranslator(new HbTranslator(translationsPath, translationsFile)), - mPendingExit(false) + mPendingExit(false), + mNoneContactMessage(0) { // Localization file loading mTranslator->loadCommon(); @@ -134,9 +123,6 @@ connect(mThumbnailManager.data(), SIGNAL(thumbnailReady(QPixmap, void*, int, int)), this, SLOT(thumbnailReady(QPixmap, void*, int, int))); - - - } /*! @@ -353,6 +339,15 @@ { if (mContactNameLabel) { mContactNameLabel->setPlainText(sName); + HbFontSpec aFontSpec(HbFontSpec::Secondary); + QFontMetrics aMetrics(aFontSpec.font()); + int aTextWidth = aMetrics.width(sName); + qreal aWidgetWidth = 11 * HbDeviceProfile::current().unitValue(); + if (aTextWidth > aWidgetWidth) { + mContactNameLabel->setAlignment(Qt::AlignLeft); + } else { + mContactNameLabel->setAlignment(Qt::AlignHCenter); + } } update(); @@ -406,15 +401,15 @@ fontSpec.setTextHeight(textHeight); } + mContactNameLabel = new HbLabel(this); + mContactNameLabel->setTextWrapping(Hb::TextNoWrap); + mContactNameLabel->setFontSpec(fontSpec); if (mContactLocalId == unUsedContactId) { - mContactNameLabel = new HbLabel(""); + setName(""); } else { - QString name = getContactDisplayName(mContact); - mContactNameLabel = new HbLabel(name); + setName(getContactDisplayName(mContact)); } - mContactNameLabel->setAlignment(Qt::AlignHCenter); - mContactNameLabel->setFontSpec(fontSpec); // color from theme QColor textColor = HbColorScheme::color(normalTextColor); if (textColor.isValid()) { @@ -484,7 +479,6 @@ { qDebug() << "mouseReleaseEvent event->type() = " << (int)event->type(); - //Q_UNUSED(event); if (event && event->type() == QEvent::GraphicsSceneMouseRelease) { // If the widget doesn't have contact yet and // there are contacts, select one. @@ -492,18 +486,8 @@ if (contactsExist()) { launchSingleContactSelecting(); } else { - // Otherwise ask if user wants to open phonebook - // tmp variable used for title, otherwise parent param is ignored in mb - QString title = hbTrId("txt_friend_widget_info_you_can_not_use_this_widge"); - HbDeviceMessageBox mb( title, HbMessageBox::MessageTypeQuestion, this); - mb.setAction(new QAction(hbTrId("txt_common_button_open"), &mb), - HbDeviceMessageBox::AcceptButtonRole); - mb.setAction(new QAction(hbTrId("txt_common_button_cancel"), &mb), - HbDeviceMessageBox::RejectButtonRole); - mb.setIconVisible(false); - if (mb.exec() == mb.action(HbDeviceMessageBox::AcceptButtonRole)) { - mLauncher->openPhonebookCreateNew(); - } + // otherwise ask user if want create one + showNoneContactMessage(); } } else if (!mLauncher->isVisible()) { // Change the frame layout @@ -679,25 +663,20 @@ if (!mContactManager) { createContactManager(); } - bool ret=false; - // + bool aResult = false; + if (mContactManager) { QList contactIds = mContactManager->contactIds(); qDebug() << "contact count " << contactIds.count(); - if (contactIds.count() > 0) { - qDebug() << "first " << contactIds.first(); - int i; - for(i=0; iselfContactId() || - contactIds.count() > 1) { - ret=true; - } + if (contactIds.count() > 1) { + aResult = true; + } else if (contactIds.count() == 1 && + contactIds.first() != mContactManager->selfContactId()) { + aResult = true; } } - return ret; + return aResult; } /*! @@ -717,20 +696,25 @@ mContactSelectRequest = mAppManager->create(XQI_CONTACTS_FETCH, XQOP_CONTACTS_FETCH_SINGLE, false); - mCleanupHandler.add(mContactSelectRequest); - connect(mContactSelectRequest, SIGNAL(requestOk(QVariant)), - this, SLOT(onContactSelectCompleted(QVariant))); - QList args; - args << hbTrId("txt_friend_widget_title_select_contact"); - args << KCntActionAll; - mContactSelectRequest->setArguments(args); + if (mContactSelectRequest) { + mCleanupHandler.add(mContactSelectRequest); + connect(mContactSelectRequest, SIGNAL(requestOk(QVariant)), + this, SLOT(onContactSelectCompleted(QVariant))); + QList args; + args << hbTrId("txt_friend_widget_title_select_contact"); + args << KCntActionAll; + mContactSelectRequest->setArguments(args); + mContactSelectRequest->setSynchronous(false); - qDebug() << "---- setArgs done ---------------------"; //,,28.5. + qDebug() << "---- setArgs done ---------------------"; //,,28.5. - result = mContactSelectRequest->send(); - if (!result) { - qDebug() << "Sending XQServiceRequest failed"; - } + result = mContactSelectRequest->send(); + if (!result) { + qDebug() << "Sending XQServiceRequest failed"; + } + } else { + qDebug() << "mContactSelectRequest not created !!!"; + } qDebug() << "- launchSingleContactSelecting() done"; //,, @@ -882,7 +866,11 @@ update(); } -void ContactWidgetHs::onSelfContactIdChanged(const QContactLocalId &theOldId, +/*! + * check if local contact was changed to self contact, + * if yes remove widget form homescreen + */ +void ContactWidgetHs::onSelfContactIdChanged(const QContactLocalId & /*theOldId*/, const QContactLocalId &theNewId) { if (0 != theNewId && mContactLocalId == theNewId) { qDebug() << "-deleting widget after selfcontact change" @@ -891,6 +879,9 @@ } } +/*! + * function to finish widget and remove widget from homescreen + */ void ContactWidgetHs::finishWidget() { mAvatarIconItem->deleteLater(); mContactNameLabel->deleteLater(); @@ -903,5 +894,42 @@ mPendingExit = true; } } + +/*! + * Ask if user wants to open phonebook + */ +void ContactWidgetHs::showNoneContactMessage() { + if (0 == mNoneContactMessage) { + QString aTitle = hbTrId("txt_friend_widget_info_you_can_not_use_this_widge"); + mNoneContactMessage = new HbDeviceMessageBox(aTitle, + HbMessageBox::MessageTypeQuestion, + this); + mNoneContactMessage->setAction( + new QAction(hbTrId("txt_common_button_open"), mNoneContactMessage), + HbDeviceMessageBox::AcceptButtonRole); + mNoneContactMessage->setAction( + new QAction(hbTrId("txt_common_button_cancel"), mNoneContactMessage), + HbDeviceMessageBox::RejectButtonRole); + mNoneContactMessage->setIconVisible(false); + connect(mNoneContactMessage, SIGNAL(aboutToClose()), + this, SLOT(onAboutCloseNoneContactMessage())); + } + mNoneContactMessage->show(); +} + +/*! + * if user select open in mNoneContactMessage, + * open a phonebook for creating new contact + */ +void ContactWidgetHs::onAboutCloseNoneContactMessage() { + if (mNoneContactMessage) { + const QAction * aResult = mNoneContactMessage->triggeredAction(); + bool aCanOpenPhonebook = mNoneContactMessage->isAcceptAction(aResult); + if (aCanOpenPhonebook) { + mLauncher->openPhonebookCreateNew(); + } + } +} + Q_IMPLEMENT_USER_METATYPE(CntServicesContact) Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CntServicesContactList) diff -r c18f9fa7f42e -r 640d30f4fb64 contactwidgethsplugin/contactwidgeths/t_contactwidgeths/t_contactwidgeths.pro --- a/contactwidgethsplugin/contactwidgeths/t_contactwidgeths/t_contactwidgeths.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/contactwidgethsplugin/contactwidgeths/t_contactwidgeths/t_contactwidgeths.pro Fri Oct 15 12:24:46 2010 +0300 @@ -53,6 +53,7 @@ TARGET.UID3 = 0x2002C355 TARGET.CAPABILITY = CAP_APPLICATION AllFiles TARGET.EPOCHEAPSIZE = 10000 54000000 + MMP_RULES += SMPSAFE BLD_INF_RULES.prj_exports += \ "./resource/test1_avatar.jpg $$PLUGIN_SUBDIR/test1_avatar.jpg" \ diff -r c18f9fa7f42e -r 640d30f4fb64 contactwidgethsplugin/t_contactwidgethsplugin/t_contactwidgethsplugin.pro --- a/contactwidgethsplugin/t_contactwidgethsplugin/t_contactwidgethsplugin.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/contactwidgethsplugin/t_contactwidgethsplugin/t_contactwidgethsplugin.pro Fri Oct 15 12:24:46 2010 +0300 @@ -49,6 +49,7 @@ symbian { TARGET.UID3 = 0x2002C354 TARGET.CAPABILITY = CAP_APPLICATION AllFiles + MMP_RULES += SMPSAFE } include(t_contactwidgethsplugin.pri) diff -r c18f9fa7f42e -r 640d30f4fb64 package_definition.xml --- a/package_definition.xml Fri Oct 08 11:42:51 2010 +0300 +++ b/package_definition.xml Fri Oct 15 12:24:46 2010 +0300 @@ -17,7 +17,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -35,30 +61,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -67,19 +69,16 @@ - - - - - - - - + + + + + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/bwins/cntimageutilityu.def --- a/phonebookengines/bwins/cntimageutilityu.def Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookengines/bwins/cntimageutilityu.def Fri Oct 15 12:24:46 2010 +0300 @@ -19,4 +19,19 @@ ?isImageRemovable@CntImageUtility@@QAE_NABVQString@@@Z @ 18 NONAME ; bool CntImageUtility::isImageRemovable(class QString const &) ??0CntImageUtility@@QAE@PAVQObject@@@Z @ 19 NONAME ; CntImageUtility::CntImageUtility(class QObject *) ?removeImage@CntImageUtility@@QAE_NABVQString@@@Z @ 20 NONAME ; bool CntImageUtility::removeImage(class QString const &) + ?orientation@CntOrientationHelper@@QAEAAW4Orientation@Qt@@XZ @ 21 NONAME ; enum Qt::Orientation & CntOrientationHelper::orientation(void) + ?metaObject@CntOrientationHelper@@UBEPBUQMetaObject@@XZ @ 22 NONAME ; struct QMetaObject const * CntOrientationHelper::metaObject(void) const + ?orientationChanged@CntOrientationHelper@@IAEXW4Orientation@Qt@@@Z @ 23 NONAME ; void CntOrientationHelper::orientationChanged(enum Qt::Orientation) + ?trUtf8@CntOrientationHelper@@SA?AVQString@@PBD0@Z @ 24 NONAME ; class QString CntOrientationHelper::trUtf8(char const *, char const *) + ?tr@CntOrientationHelper@@SA?AVQString@@PBD0@Z @ 25 NONAME ; class QString CntOrientationHelper::tr(char const *, char const *) + ?getStaticMetaObject@CntOrientationHelper@@SAABUQMetaObject@@XZ @ 26 NONAME ; struct QMetaObject const & CntOrientationHelper::getStaticMetaObject(void) + ?emitOrientationChanged@CntOrientationHelper@@AAEXABVXQSettingsKey@@ABVQVariant@@@Z @ 27 NONAME ; void CntOrientationHelper::emitOrientationChanged(class XQSettingsKey const &, class QVariant const &) + ??1CntOrientationHelper@@UAE@XZ @ 28 NONAME ; CntOrientationHelper::~CntOrientationHelper(void) + ?tr@CntOrientationHelper@@SA?AVQString@@PBD0H@Z @ 29 NONAME ; class QString CntOrientationHelper::tr(char const *, char const *, int) + ??_ECntOrientationHelper@@UAE@I@Z @ 30 NONAME ; CntOrientationHelper::~CntOrientationHelper(unsigned int) + ?qt_metacall@CntOrientationHelper@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 31 NONAME ; int CntOrientationHelper::qt_metacall(enum QMetaObject::Call, int, void * *) + ?trUtf8@CntOrientationHelper@@SA?AVQString@@PBD0H@Z @ 32 NONAME ; class QString CntOrientationHelper::trUtf8(char const *, char const *, int) + ?qt_metacast@CntOrientationHelper@@UAEPAXPBD@Z @ 33 NONAME ; void * CntOrientationHelper::qt_metacast(char const *) + ?staticMetaObject@CntOrientationHelper@@2UQMetaObject@@B @ 34 NONAME ; struct QMetaObject const CntOrientationHelper::staticMetaObject + ??0CntOrientationHelper@@QAE@PAVQObject@@@Z @ 35 NONAME ; CntOrientationHelper::CntOrientationHelper(class QObject *) diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntactions/src/cntemailaction.cpp --- a/phonebookengines/cntactions/src/cntemailaction.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookengines/cntactions/src/cntemailaction.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -68,7 +68,8 @@ m_request = m_AppManager.create(XQI_EMAIL_MESSAGE_SEND, "send(QVariant)", true); if (m_request) { - QMap map; + QVariantMap dataMap; + QVariantMap emailMap; QStringList recipients; QList data; @@ -76,16 +77,32 @@ if (QContactType::TypeGroup == m_contact.type()) { QStringList emails; QVariant value = m_data.value("email"); - if (value.canConvert()) { - emails = value.toStringList(); + if (value.canConvert()) { + emailMap = value.toMap(); } - if (!emails.isEmpty()) { - for (int i=0;i()) + displayLabel = i.value().toString(); + + // Email addresses format string: + // Firstname Lastname + if (!displayLabel.isEmpty()) + formatString += displayLabel + " "; + formatString += "<" + emailAddress + ">"; + recipients.append(formatString); + + ++i; } - map.insert(EMAIL_SEND_TO_KEY, recipients); - data.append(map); + dataMap.insert(EMAIL_SEND_TO_KEY, recipients); + data.append(dataMap); m_request->setArguments(data); m_request->send(retValue); @@ -100,9 +117,17 @@ else if (m_detail.definitionName() == QContactEmailAddress::DefinitionName) { const QContactEmailAddress &email = static_cast(m_detail); - recipients.append(email.emailAddress()); - map.insert(EMAIL_SEND_TO_KEY, recipients); - data.append(map); + // Email addresses format string: + // Firstname Lastname + QString formatString; + QString displayLabel = m_contact.displayLabel(); + if (!displayLabel.isEmpty()) + formatString += displayLabel + " "; + formatString += "<" + email.emailAddress() + ">"; + + recipients.append(formatString); + dataMap.insert(EMAIL_SEND_TO_KEY, recipients); + data.append(dataMap); m_request->setArguments(data); m_request->send(retValue); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntactions/tsrc/mt_cntactions/testrunner.cpp --- a/phonebookengines/cntactions/tsrc/mt_cntactions/testrunner.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookengines/cntactions/tsrc/mt_cntactions/testrunner.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -37,14 +37,19 @@ mCurrentTestFailed(false), mCurrentTestFailureLine(0) { + #ifdef __WINS__ mTestRunParams.append(name); + mTestRunParams.append("-xml"); + mTestRunParams.append("-o"); mHomeDir = QDir::homePath(); + mTestRunParams.append(QString()); // Initial result file name if (!mHomeDir.endsWith(QString::fromAscii("/"))) mHomeDir += QString::fromAscii("/"); +#endif } TestRunner::~TestRunner() @@ -55,13 +60,18 @@ { QString className(testObject.metaObject()->className()); printf("Running tests for %s ... ", className.toUtf8().data()); +#ifdef __WINS__ QString resultFileName = mHomeDir + className + ".xml"; mTestRunParams.replace(mTestRunParams.count()-1,resultFileName); int errorsBefore = mErrors.count(); int error = QTest::qExec(&testObject, mTestRunParams); parse(resultFileName); printf("Failures: %d\n",mErrors.count()-errorsBefore); - fflush(stdout); + fflush(stdout); +#else + int error = QTest::qExec(&testObject); +#endif + return error; } @@ -78,7 +88,7 @@ printf("All passed.\n\n"); } fflush(stdout); - +#ifdef __WINS__ //To write in file QFile file("C:\\TestResult.txt"); if(file.open(QIODevice::WriteOnly)) @@ -101,7 +111,8 @@ ts << endl; file.close(); - } + } +#endif } void TestRunner::parse(const QString& fileName) diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntfindplugin/group/cntfindplugin.mmp --- a/phonebookengines/cntfindplugin/group/cntfindplugin.mmp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* -* Copyright (c) 2002 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: -* Build information file for contact model plugin needed for chinese find -* -*/ - - -#include "cntfindpluginuid.h" -#include -#include - -TARGET cntfindplugin.dll -TARGETTYPE PLUGIN -UID KEComPluginUID2 KCntModelFindPluginDllUID3 -CAPABILITY CAP_ECOM_PLUGIN -VENDORID VID_DEFAULT - -SOURCEPATH ../src -SOURCE dllmain.cpp -SOURCE cntfindplugin.cpp - -USERINCLUDE ../group -APP_LAYER_SYSTEMINCLUDE - -START RESOURCE 101f85f4.rss -TARGET cntfindplugin -TARGETPATH resource/plugins -END - -LIBRARY euser.lib -LIBRARY ECom.lib -LIBRARY findutil.lib diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntfindplugin/group/cntfindpluginuid.h --- a/phonebookengines/cntfindplugin/group/cntfindpluginuid.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* -* Copyright (c) 2002 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: -* Common header for Contact Model Find Plugin UIDs. -* -* -*/ - -#ifndef __CntFindPluginUid_H__ -#define __CntFindPluginUid_H__ - -// Contact Model Find Plugin DLL UID -#define KCntModelFindPluginDllUID3 0x101F85F4 - -// Contact Model Find Plugin Interface UID -#define KCntModelFindPluginInterfaceUID 0x101F85F5 - -// Implementation UID -#define KCntModelFindPluginImplementationUID 0x101F85F6 - -// -// Common system UIDs -// - -// ECom Plugin UID 2 -#define KEComPluginUID2 0x10009D8D - -#endif // CntFindPluginUid - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntfindplugin/rom/cntfindplugin.iby --- a/phonebookengines/cntfindplugin/rom/cntfindplugin.iby Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -/* -* 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 __CNTFINDPLUGIN_IBY__ -#define __CNTFINDPLUGIN_IBY__ - -ECOM_PLUGIN(cntfindplugin.dll,101f85f4.RSC) - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntfindplugin/src/101f85f4.rss --- a/phonebookengines/cntfindplugin/src/101f85f4.rss Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* -* Copyright (c) 2002 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: -* Contact model ECOM plugin resource file -* -*/ - - -#include -#include "cntfindpluginuid.h" - -RESOURCE REGISTRY_INFO theInfo - { - dll_uid = KCntModelFindPluginDllUID3; - interfaces = - { - INTERFACE_INFO - { - interface_uid = KCntModelFindPluginInterfaceUID; - implementations = - { - IMPLEMENTATION_INFO - { - implementation_uid = KCntModelFindPluginImplementationUID; - version_no = 1; - display_name = "Contacts Find Plugin"; - default_data = ""; - opaque_data = ""; - } - }; - } - }; - } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntfindplugin/src/cntfindplugin.cpp --- a/phonebookengines/cntfindplugin/src/cntfindplugin.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/* -* Copyright (c) 2002 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: -* Contact model ECOM plugin for chinese find. -* -*/ - - -// INCLUDE FILES -#include "cntfindplugin.h" -#include - -// ========================== MEMBER FUNCTIONS =============================== - -// --------------------------------------------------------------------------- -// CAknFindUtilBase::NewL -// --------------------------------------------------------------------------- -// -CAknFindUtilBase* CAknFindUtilBase::NewL() - { - CAknFindUtilBase* self=new(ELeave) CAknFindUtilBase; - CleanupStack::PushL( self ); - self->OpenL(); - CleanupStack::Pop(); - return self; - } - -// --------------------------------------------------------------------------- -// CAknFindUtilBase::~CAknFindUtilBase -// --------------------------------------------------------------------------- -// -CAknFindUtilBase::~CAknFindUtilBase() - { - delete iFindUtil; - } - -// --------------------------------------------------------------------------- -// CAknFindUtilBase::CAknFindUtilBase -// --------------------------------------------------------------------------- -// -CAknFindUtilBase::CAknFindUtilBase() - { - } - -// --------------------------------------------------------------------------- -// CAknFindUtilBase::OpenL -// --------------------------------------------------------------------------- -// -void CAknFindUtilBase::OpenL() - { - if (!iFindUtil) - { - iFindUtil = CFindUtil::NewL(); - } - } - -// --------------------------------------------------------------------------- -// CAknFindUtilBase::Close -// --------------------------------------------------------------------------- -// -void CAknFindUtilBase::Close() - { - delete iFindUtil; - iFindUtil = NULL; - } - -// --------------------------------------------------------------------------- -// CAknFindUtilBase::Match -// --------------------------------------------------------------------------- -// -TBool CAknFindUtilBase::Match(const TDesC& aContactsField, const TDesC& aWord) - { - return iFindUtil->Interface()->Match(aContactsField, aWord); - } - -// --------------------------------------------------------------------------- -// CAknFindUtilBase::IsWordValidForMatching -// --------------------------------------------------------------------------- -// -TBool CAknFindUtilBase::IsWordValidForMatching(const TDesC& aWord) - { - return iFindUtil->Interface()->IsWordValidForMatching(aWord); - } - -// --------------------------------------------------------------------------- -// CAknFindUtilBase::MatchRefineL -// --------------------------------------------------------------------------- -// -TBool CAknFindUtilBase::MatchRefineL - (const TDesC& aItemString, const TDesC &aSearchText) - { - return iFindUtil->Interface()->MatchRefineL(aItemString, aSearchText); - } - -// End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntfindplugin/src/cntfindplugin.h --- a/phonebookengines/cntfindplugin/src/cntfindplugin.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* -* Copyright (c) 2002 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: -* Contact model ECOM plugin for chinese find. -* -*/ - - -#ifndef __CntFindPlugin_H__ -#define __CntFindPlugin_H__ - -// INCLUDES -#include - -// FORWARD DECLARATIONS -class CFindUtil; - -// CLASS DECLARATION - -/** - * This class implements the functionality promised by - * the CFindUtilInterface definition class. - */ -class CAknFindUtilBase : public CContactViewFindConfigInterface - { - public: // Construction / Destruction - /** - * Two phase static constructor. - * @return Newly created instance of CAknFindUtilBase. - */ - static CAknFindUtilBase* NewL(); - ~CAknFindUtilBase(); - - private: // From CContactViewFindConfigInterface - void OpenL(); - void Close(); - TBool Match(const TDesC& aContactsField, const TDesC& aWord); - TBool IsWordValidForMatching(const TDesC& aWord); - TBool MatchRefineL( const TDesC& aItemString, const TDesC& aSearchText); - - private: // Implementation - /** - * Standard C++ constructor. - */ - CAknFindUtilBase(); - - private: // Data - /// Own: Find utility that implements the actual finding functionality - CFindUtil* iFindUtil; - }; - -#endif // __CAknFindUtilBase_H__ - -// End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntfindplugin/src/dllmain.cpp --- a/phonebookengines/cntfindplugin/src/dllmain.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* -* Copyright (c) 2002 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: -* -*/ - - -// INCLUDES -#include -#include - -#include "cntfindplugin.h" -#include "cntfindpluginuid.h" - -// Define the interface UIDs -const TImplementationProxy ImplementationTable[] = - { - IMPLEMENTATION_PROXY_ENTRY(KCntModelFindPluginImplementationUID, - CAknFindUtilBase::NewL) - }; - -// The one and only exported function that is the ECom entry point -EXPORT_C const TImplementationProxy* ImplementationGroupProxy - (TInt& aTableCount) - { - aTableCount = - sizeof(ImplementationTable) / sizeof(TImplementationProxy); - - return ImplementationTable; - } - -/** - * Standard Symbian OS DLL entry point. - */ -#ifndef EKA2 -TBool E32Dll(TDllReason) - { - return ETrue; - } -#endif // EKA2 - -// End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntimageutility/cntimageutility.pro --- a/phonebookengines/cntimageutility/cntimageutility.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookengines/cntimageutility/cntimageutility.pro Fri Oct 15 12:24:46 2010 +0300 @@ -31,13 +31,16 @@ INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE INCLUDEPATH += inc +INCLUDEPATH += ../../inc HEADERS += inc/cntimageutilityglobal.h \ - inc/cntimageutility.h + inc/cntimageutility.h \ + inc/cntorientationhelper.h -SOURCES += src/cntimageutility.cpp +SOURCES += src/cntimageutility.cpp \ + src/cntorientationhelper.cpp -LIBS += -lplatformenv -lefsrv +LIBS += -lplatformenv -lefsrv -lxqsettingsmanager defBlock = \ "$${LITERAL_HASH}if defined(EABI)" \ "DEFFILE ../eabi/cntimageutility.def" \ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntimageutility/inc/cntimageutilityglobal.h --- a/phonebookengines/cntimageutility/inc/cntimageutilityglobal.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookengines/cntimageutility/inc/cntimageutilityglobal.h Fri Oct 15 12:24:46 2010 +0300 @@ -20,10 +20,13 @@ #include -#if defined(CNTIMAGEUTILITY_LIBRARY) -# define CNTIMAGEUTILITYLIB_EXPORT Q_DECL_EXPORT + +#ifdef CNTIMAGEUTILITY_NO_EXPORT +#define CNTIMAGEUTILITYLIB_EXPORT +#elif CNTIMAGEUTILITY_LIBRARY +#define CNTIMAGEUTILITYLIB_EXPORT Q_DECL_EXPORT #else -# define CNTIMAGEUTILITYLIB_EXPORT Q_DECL_IMPORT +#define CNTIMAGEUTILITYLIB_EXPORT Q_DECL_IMPORT #endif #endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntimageutility/inc/cntorientationhelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookengines/cntimageutility/inc/cntorientationhelper.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,49 @@ +/* +* 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 CNTORIENTATIONHELPER_H_ +#define CNTORIENTATIONHELPER_H_ + +#include "cntimageutilityglobal.h" + +#include +#include +#include + +class CNTIMAGEUTILITYLIB_EXPORT CntOrientationHelper : public QObject +{ + Q_OBJECT +public: + CntOrientationHelper( QObject* parent = NULL ); + ~CntOrientationHelper(); + + Qt::Orientation& orientation(); + +signals: + void orientationChanged( Qt::Orientation orientation ); + +private slots: + void emitOrientationChanged( const XQSettingsKey& key, const QVariant& value ); + +private: + XQSettingsManager* mSettings; // own + XQSettingsKey* mOrientationKey; // own + Qt::Orientation mOrientation; + + friend class TestCntOrientationHelper; +}; +#endif /* CNTORIENTATIONHELPER_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntimageutility/src/cntorientationhelper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookengines/cntimageutility/src/cntorientationhelper.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,68 @@ +/* +* 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 "cntorientationhelper.h" +#include + +CntOrientationHelper::CntOrientationHelper( QObject* parent ) : +QObject( parent ), +mSettings( NULL ), +mOrientationKey( NULL ) +{ + mSettings = new XQSettingsManager(); + + mOrientationKey = new XQSettingsKey( XQSettingsKey::TargetPublishAndSubscribe, + KHbPsForegroundAppOrientationCategoryUid.iUid, + KHbPsForegroundAppOrientationKey); + + connect( mSettings, SIGNAL(valueChanged(const XQSettingsKey&, const QVariant&)), + this, SLOT(emitOrientationChanged(const XQSettingsKey&, const QVariant&)) ); + + int orientation = mSettings->readItemValue(*mOrientationKey, XQSettingsManager::TypeInt).toInt(); + mOrientation = Qt::Orientation(orientation & 0x7F); + + mSettings->startMonitoring( *mOrientationKey, XQSettingsManager::TypeInt ); +} + +CntOrientationHelper::~CntOrientationHelper() +{ + mSettings->stopMonitoring( *mOrientationKey ); + + delete mSettings; + delete mOrientationKey; +} + +Qt::Orientation& CntOrientationHelper::orientation() +{ + return mOrientation; +} + +void CntOrientationHelper::emitOrientationChanged( const XQSettingsKey& key, const QVariant& value ) +{ + if ( key.uid() == mOrientationKey->uid() && key.key() == mOrientationKey->key() ) + { + bool ok; + int orientation = value.toInt( &ok ); + if ( ok ) { + // Bits 0-7 contain the Qt::Orientation value. + // If bit 8 is set then the orientation is a fixed (forced) one. + // If bit 8 is not set then the orientation is managed automatically by the framework. + mOrientation = Qt::Orientation( orientation & 0x7F ); + emit orientationChanged( mOrientation ); + } + } +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/cntlistmodel.pro --- a/phonebookengines/cntlistmodel/cntlistmodel.pro Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -# 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: -TEMPLATE = lib -TARGET = cntlistmodel -DEFINES += dll \ - BUILD_CNTLISTMODEL - -MOC_DIR = moc - -CONFIG += hb - -TARGET.CAPABILITY = CAP_GENERAL_DLL -TARGET.EPOCALLOWDLLDATA = 1 -TARGET.UID3 = 0x20026FC3 - -INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE -INCLUDEPATH += inc -INCLUDEPATH += ../../inc - -HEADERS += inc/cntlistmodelglobal.h \ - inc/cntlistmodel.h \ - inc/cntlistmodel_p.h \ - inc/cntcache.h \ - inc/cntcache_p.h \ - inc/cntnamefetcher.h \ - inc/cntdefaultinfoprovider.h \ - inc/cntpresenceinfoprovider.h \ - inc/cntdisplaytextformatter.h \ - ../../inc/cntdebug.h - -SOURCES += src/cntlistmodel.cpp \ - src/cntcache.cpp \ - src/cntcache_p.cpp \ - src/cntnamefetcher.cpp \ - src/cntdefaultinfoprovider.cpp \ - src/cntpresenceinfoprovider.cpp \ - src/cntdisplaytextformatter.cpp - -LIBS += -lQtContacts \ - -lhbcore \ - -lthumbnailmanagerqt \ - -lpresencecacheqt \ - -lxqsettingsmanager \ - -lestor \ - -lefsrv \ - -lxqutils - -DEPLOYMENT += exportheaders - -:BLD_INF_RULES.prj_exports += "../../contacts_plat/contacts_ui_extensions_api/inc/cntinfoproviderfactory.h APP_LAYER_PLATFORM_EXPORT_PATH(cntinfoproviderfactory.h)" -:BLD_INF_RULES.prj_exports += "../../contacts_plat/contacts_ui_extensions_api/inc/cntinfoprovider.h APP_LAYER_PLATFORM_EXPORT_PATH(cntinfoprovider.h)" - -defBlock = "$${LITERAL_HASH}if defined(EABI)" \ - "DEFFILE ../eabi/cntlistmodel.def" \ - "$${LITERAL_HASH}else" \ - "DEFFILE ../bwins/cntlistmodel.def" \ - "$${LITERAL_HASH}endif" -MMP_RULES += defBlock diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/inc/cntcache.h --- a/phonebookengines/cntlistmodel/inc/cntcache.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ -/* -* Copyright (c) 2010 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: Class for asynchronously fetching and caching -* basic contact info for list views. -* -*/ - -#ifndef CNTCACHE_H -#define CNTCACHE_H - -#include -#include -#include -#include -#include -#include -#include - -class CntContactInfoData; -class CntNameFetcher; -class CntCacheThread; -class CntInfoCacheItem; -class CntIconCacheItem; -class CntNameCacheItem; - -QTM_USE_NAMESPACE - -/* - Info about one contact that can be used by listviews: - - the id - - the full name, properly formatted - - text, secondary information like phone number - - icon1, the main icon - - icon2, a secondary icon - */ -class CntContactInfo : public QObject -{ - Q_OBJECT -public: - CntContactInfo(); - CntContactInfo(int id, const QString& name, const QString& text, const HbIcon& icon1, const HbIcon& icon2); - ~CntContactInfo(); - - CntContactInfo(const CntContactInfo& other); - CntContactInfo& operator=(const CntContactInfo& other); - - int id() const; - QString name() const; - QString text() const; - HbIcon icon1() const; - HbIcon icon2() const; - -private: - QSharedDataPointer d; -}; - -/* - Singleton class that acts as a proxy to get CntContactInfo objects for contacts. - It also implements caching for faster access. This is why the fetchContactInfo() - function takes a row number and the full list of contact IDs rather than just a - contact ID -- the former allows caching ahead. - - The usage pattern for clients is to call fetchContactInfo() to get at least the - name of the contact. If all the info is cached then it will be provided. If not, - then the uncached info is fetched asynchronously and contactInfoUpdated signals - are emitted as the pieces of information arrive -- up to three times per contact; - once for text, once for icon1 and once for icon2. - */ -class CntCache : public QObject -{ - friend class TestCntCache; - friend class TestCntListModel; - Q_OBJECT -public: - static CntCache* instance(QContactManager *manager); - CntContactInfo fetchContactInfo(int row, const QList& idList); - QList sortIdsByName(const QSet* idFilter = NULL) const; - QList sortIdsByName(const QStringList searchList) const; - -signals: - void contactInfoUpdated(QContactLocalId contactId); - void contactsChanged(const QList &changedContacts); - void contactsRemoved(const QList &removedContacts); - void contactsAdded(const QList &addedContacts); - void dataChanged(); - -private: - CntCache(QContactManager *manager); - ~CntCache(); - void loadNames(); - bool contactExists(QContactLocalId contactId) const; - QString contactName(QContactLocalId contactId) const; - CntInfoCacheItem* createInfoCacheItem(int contactId); - CntIconCacheItem* createIconCacheItem(const QString &iconName); - void updateReadAheadCache(int mostRecentRow, const QList &idList); - void emitContactInfoUpdated(int contactId); - -private slots: - void onShutdown(); - void reformatNames(CntNameOrder newFormat); - void onNewInfo(int contactId, const ContactInfoField &infoField, const QString &infoValue); - void onInfoCancelled(int contactId); - void scheduleOneReadAheadItem(); - void onNewIcon(const QString &iconName, const HbIcon &icon); - void onIconCancelled(const QString &iconName); - void updateContacts(const QList &changedContacts); - void removeContacts(const QList &removedContacts); - void addContacts(const QList &addedContacts); - void setNameList(QList newSortedNames); - -private: - static CntCache *mInstance; // the one and only instance of CntCache - QContactManager *mContactManager; // for getting notifications about changes to contacts - CntCacheThread *mWorker; // the background thread that does the actual fetching - CntNameFetcher *mNameFetcher; // the helper that fetches contact names - - QList mSortedNames; // list of all contact names, in sorted order - QHash mNameCache; // cache with all contact names, indexed by contact ids - QHash mInfoCache; // cache with contact info, indexed by contact ids - QHash mIconCache; // cache with icons, indexed by icon name - QList< QPair > mReadAheadCache; // cache with contacts to prefetch (they are likely to be needed soon) - - int mNextInfoCacheOrder; // cache order for the next item to be updated/inserted in info cache - int mNextIconCacheOrder; // cache order for the next item to be updated/inserted in icon cache - int mEmittedContactId; // id of the last contact emitted to UI - int mUrgentContacts; // the number of contacts left that need to be fetched asap - - bool mHasModifiedNames; // monitors whether any names have changed since file cache was last updated - bool mAllNamesFetchStarted; // false until the asynch fetching of all names from the DB has started; - // this operation is done only once -}; - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/inc/cntcache_p.h --- a/phonebookengines/cntlistmodel/inc/cntcache_p.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,142 +0,0 @@ -/* -* Copyright (c) 2010 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: Private data and helper classes used by class CntCache. -* -*/ - -#ifndef CNTCACHE_P_H -#define CNTCACHE_P_H - -#include -#include -#include -#include -#include "cntinfoprovider.h" - -class ThumbnailManager; - -QTM_USE_NAMESPACE - -/*! - Private shared data for the CntContactInfo class. - */ -class CntContactInfoData : public QSharedData -{ -public: - CntContactInfoData() : id(-1), fields(0) { } - ~CntContactInfoData() { } - -public: - int id; - int fields; - QString name; - QString text; - HbIcon icon1; - HbIcon icon2; -}; - -/*! - Cache item that holds info for one contact: text and two icon names. - */ -class CntInfoCacheItem -{ -public: - int cacheOrder; - int contactId; - int latestRow; - QString text; - QString icons[2]; -}; - -/*! - Cache item that holds one icon. Data member isFetched is false until the - icon has been fetched asynchronously. - */ -class CntIconCacheItem -{ -public: - int cacheOrder; - QString iconName; - bool isFetched; - QSet contactIds; - HbIcon icon; -}; - -/*! - Worker class that fetches contact info and icons in the background. - CntCacheThread uses info provider plugins and thumbnail manager to retrieve - the actual data. This class' responsibilities are 1) fetch the requested - data in a timely manner and 2) interfere with the UI as little as possible. - This is mainly orchestrated by the client, who calls postponeJobs() when - the UI is active. - - If the client sends many requests (e.g. during a long scrolling operation - in the UI), then the oldest jobs will be cancelled. However, the cancelled jobs - will be informed back to the client later so that it can choose to reschedule - the jobs. - */ -class CntCacheThread : public QObject -{ - friend class TestCntCache; - Q_OBJECT -public: - CntCacheThread(); - ~CntCacheThread(); - - void scheduleInfoJob(int contactId, int priority); - void scheduleIconJob(const QString& iconName, int priority); - void postponeJobs(int milliseconds = 0); - bool event(QEvent *event); - -public slots: - void resumeJobs(); - -signals: - void infoFieldUpdated(int contactId, ContactInfoField infoField, const QString& infoValue); - void infoCancelled(int contactId); - void iconUpdated(const QString& iconName, const HbIcon& icon); - void iconCancelled(const QString& iconName); - void allJobsDone(); - -private slots: - void onInfoFieldReady(CntInfoProvider* sender, int contactId, - ContactInfoField field, const QString& text); - void onIconReady(const QPixmap& pixmap, void *data, int id, int error); - -private: - void processJobs(); - int infoJobIndex(int contactId); - int takeNextInfoJob(); - int iconJobIndex(QString iconName); - QString takeNextIconJob(); - -private: - QContactManager* mContactManager; // for fetching QContact objects - ThumbnailManager* mThumbnailManager; // for fetching icons - - // maps info providers to their responsibilities - QMap mInfoProviders; - - bool mProcessingJobs; // true from when job loop event has been posted until job loop exits - int mJobsPostponed; // are jobs postponed (no / for some time / until further notice) - QList< QPair > mInfoJobs; // list of all info jobs and their priorities - QList mCancelledInfoJobs; // list of all cancelled info jobs - QList< QPair > mIconJobs; // list of all icon jobs and their priorities - QList mCancelledIconJobs; // list of all cancelled icon jobs - int mIconRequestId; // the id for the last request to thumbnail manager - QString mIconRequestName; // the name of the icon last requested from thumbnail manager - QTimer *mTimer; // timer used when postponing jobs -}; - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/inc/cntdefaultinfoprovider.h --- a/phonebookengines/cntlistmodel/inc/cntdefaultinfoprovider.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* -* Copyright (c) 2010 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: Default info provider plugin for CntListModel. It can provide -* the phone number and the image url of a contact (text and -* icon1 field respectively). -* -*/ - -#ifndef CNTDEFAULTPROVIDER_H -#define CNTDEFAULTPROVIDER_H - -#include -#include - -QTM_USE_NAMESPACE - -/* - The default info provider plugin. It can provide the phone number and the - image url of a contact (text and icon1 field respectively). - */ -class CntDefaultInfoProvider : public CntInfoProvider -{ - friend class TestCntDefaultInfoProvider; - Q_OBJECT - -public: - QString id() const { return "default"; }; - ContactInfoFields supportedFields() const; - void requestInfo(const QContact& contact, ContactInfoFields requestedInfo); - -signals: - void infoFieldReady(CntInfoProvider* sender, int contactId, ContactInfoField field, const QString& value); -}; - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/inc/cntdisplaytextformatter.h --- a/phonebookengines/cntlistmodel/inc/cntdisplaytextformatter.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* -* 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 CNTDISPLAYTEXTFORMATTER_H_ -#define CNTDISPLAYTEXTFORMATTER_H_ - -#include -#include -QTM_USE_NAMESPACE - -#define TAG_START "" -#define TAG_END "" - -class CntDisplayTextFormatter -{ -public: - virtual ~CntDisplayTextFormatter(){} - virtual QString formattedText( const QString aText, const QContactFilter& aCriteria ) = 0; -}; - -class CntDummyDisplayTextFormatter : public QObject, public CntDisplayTextFormatter -{ - Q_OBJECT -public: - CntDummyDisplayTextFormatter(){} - ~CntDummyDisplayTextFormatter(){} - - inline QString formattedText( const QString aText, const QContactFilter& aCriteria ) - { - Q_UNUSED( aCriteria ); - return aText; - } -}; - -class CntHTMLDisplayTextFormatter : public QObject, public CntDisplayTextFormatter -{ - Q_OBJECT - -public: - CntHTMLDisplayTextFormatter(); - virtual ~CntHTMLDisplayTextFormatter(); - - /*! - * Format given text with applied filter. Not that only following filter is supported: - * - * QContactDetailFilter filter; - * filter.setDetailDefinitionName( QContactDisplayLabel::DefinitionName ); - * filter.setMatchFlags( QContactDetailFilter::MatchStartsWith ); - * - * \param aText Buffer where to format - * \param aCriteria Applied filter - */ - QString formattedText( const QString aText, const QContactFilter& aCriteria ); - - /*! - * Insert tag to given text leaving given number - * of characters between start and end tag. - * By default highlight is inserted. - * - * \param aText Buffer where to insert tags - * \param aNumOfCharacters Number of characters to highlight - */ - virtual void insertTag( QString& aText, int aNumOfCharacters ); -}; -#endif /* CNTDISPLAYTEXTFORMATTER_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/inc/cntlistmodel.h --- a/phonebookengines/cntlistmodel/inc/cntlistmodel.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -/* -* 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 CNTLISTMODEL_H -#define CNTLISTMODEL_H - -#include -#include -#include - -#include "cntlistmodelglobal.h" -#include -#include -#include - -QTM_USE_NAMESPACE - -class CntListModelData; -class XQSettingsKey; -class CntDisplayTextFormatter; - -/*! - * CntListModel is a list model view for contacts database - * content. It will cache contacts database entries to be - * displayed on the screen. - * - * Note that that this is a prototype implementation and does - * not yet support more advanced features, such as automatic - * update and lazy fetching from contacts database. - */ -class CNTLISTMODEL_EXPORT CntListModel : public QAbstractListModel -{ - Q_OBJECT - friend class TestCntListModel; - -public: - CntListModel(QContactManager* manager, - const QContactFilter& contactFilter = QContactFilter(), - bool showMyCard = true, - QObject *parent = 0); - ~CntListModel(); - -public: // from QAbstractTableModel/QAbstractItemModel - QVariant data(const QModelIndex &index, int role) const; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - -public: - QContact contact(const QModelIndex &index) const; - QContactLocalId contactId(const QModelIndex &index) const; - QModelIndex indexOfContact(const QContact &contact) const; - QModelIndex indexOfContactId(const QContactLocalId &contactId) const; - void setFilter(const QContactFilter& contactFilter = QContactFilter()); - void showMyCard(bool enabled); - bool myCardStatus() const; - QContactLocalId myCardId() const; - -private: - void updateContactIdsArray(); - QContact contact(int row) const; - bool validRowId(int row) const; - int rowId(const QContactLocalId &contactId) const; - QVariant dataForRole(int row, int role) const; - void updateRelationships(); - -private slots: - void handleAdded(const QList& contactIds); - void handleChanged(const QList& contactIds); - void handleRemoved(const QList& contactIds); - void handleMyCardChanged(const QContactLocalId& oldId, const QContactLocalId& newId); - void handleContactInfoUpdated(QContactLocalId contactId); - void handleAddedRelationship(const QList& contactIds); - void handleRemovedRelationship(const QList& contactIds); - void handleRowSettingChanged(const XQSettingsKey& key, const QVariant& value); - void refreshModel(); - -private: - QSharedDataPointer d; - HbIcon m_defaultIcon; - HbIcon m_defaultMyCardIcon; -}; - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/inc/cntlistmodel_p.h --- a/phonebookengines/cntlistmodel/inc/cntlistmodel_p.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* -* 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 MOBCNTMODELPRIVATE_H -#define MOBCNTMODELPRIVATE_H - -#include -#include - -#include -#include -#include -#include -#include -#include "cntcache.h" -#include -#include "cntdisplaytextformatter.h" -#include -#include - -QTM_USE_NAMESPACE - -class CntListModelData : public QSharedData -{ -public: - CntListModelData( const QContactFilter& contactFilter = QContactFilter(), - bool showMyCard = true) : - m_contactManager(NULL), - m_ownedContactManager(false), - m_currentRow(-1), - m_showMyCard(showMyCard), - m_Settings(NULL), - m_NameListRowSettingkey(NULL), - m_currentRowSetting(0), - m_groupId(-1), - m_Format( new CntDummyDisplayTextFormatter ) - { - setFilter(contactFilter); - } - - ~CntListModelData() - { - if (m_ownedContactManager) - delete m_contactManager; - delete m_Settings; - delete m_NameListRowSettingkey; - delete m_Format; - } - - void setFilter(const QContactFilter& contactFilter) - { - CNT_LOG_ARGS(contactFilter.type()) - - m_filter = contactFilter; - m_currentRow = -1; - if (contactFilter.type() == QContactFilter::RelationshipFilter) { - QContactRelationshipFilter* relationshipFilter = static_cast(&m_filter); - CNT_LOG_ARGS("type:" << relationshipFilter->relationshipType() << "role:" << relationshipFilter->relatedContactRole()) - if (relationshipFilter->relationshipType() == QContactRelationship::HasMember && - relationshipFilter->relatedContactRole() == QContactRelationship::First) - m_groupId = relationshipFilter->relatedContactId().localId(); - } - else { - m_groupId = -1; - - // set proper text formatter for the display name. - if ( contactFilter.type() == QContactFilter::ContactDetailFilter ) - { - delete m_Format; - m_Format = NULL; - - QContactDetailFilter* detailFilter = static_cast( &m_filter ); - QStringList filter = detailFilter->value().toStringList(); - - if ( detailFilter->detailDefinitionName() == QContactDisplayLabel::DefinitionName && - detailFilter->matchFlags() & QContactFilter::MatchStartsWith && - !filter.isEmpty() ) - { - m_Format = new CntHTMLDisplayTextFormatter(); - } - else - { - m_Format = new CntDummyDisplayTextFormatter(); - } - } - - } - - CNT_LOG_ARGS(m_groupId) - } - -public: - QContactManager* m_contactManager; - CntCache* m_cache; - bool m_ownedContactManager; - mutable CntContactInfo m_currentContact; - mutable int m_currentRow; - - QList m_contactIds; - QContactFilter m_filter; - QList m_sortOrders; - bool m_showMyCard; - QContactLocalId m_myCardId; - int nameOrder; - - XQSettingsManager* m_Settings; - XQSettingsKey *m_NameListRowSettingkey; - int m_currentRowSetting; - QContactLocalId m_groupId; - - CntDisplayTextFormatter* m_Format; -}; - -#endif // QCONTACTMODELPRIVATE_H - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/inc/cntlistmodelglobal.h --- a/phonebookengines/cntlistmodel/inc/cntlistmodelglobal.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* -* 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 CNTLISTMODELGLOBAL_H -#define CNTLISTMODELGLOBAL_H - -#include -#include -#include - -#ifdef CNTLISTMODEL_NO_EXPORT -#define CNTLISTMODEL_EXPORT -#elif BUILD_CNTLISTMODEL -#define CNTLISTMODEL_EXPORT Q_DECL_EXPORT -#else -#define CNTLISTMODEL_EXPORT Q_DECL_IMPORT -#endif - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/inc/cntnamefetcher.h --- a/phonebookengines/cntlistmodel/inc/cntnamefetcher.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -/* -* Copyright (c) 2010 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: Private data and helper classes used by class CntCache. -* -*/ - -#ifndef CNTNAMEFETCHER_H -#define CNTNAMEFETCHER_H - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -QTM_USE_NAMESPACE - -class CntSrvSession; - -/*! - Cache item that holds the formatted name of one contact. - */ -class CntNameCacheItem -{ -public: - CntNameCacheItem(QContactLocalId id, const QString &firstName, const QString &lastName, CntNameOrder nameFormat); - ~CntNameCacheItem(); - QContactLocalId contactId() const { return mContactId; } - QString name() const { return mName; } - QString firstName() const; - QString lastName() const; - void setNameFormat(CntNameOrder newFormat); - void operator=(const CntNameCacheItem &other); - void externalize(QDataStream &stream); - static CntNameCacheItem* internalize(QDataStream &stream, CntNameOrder nameFormat); - -private: - void setFormattedName(const QString &firstName, const QString &lastName, CntNameOrder nameFormat); - -private: - QContactLocalId mContactId; // database contact id for this name - int mFirstNamePosition; // length << 16 | offset - int mLastNamePosition; // length << 16 | offset - QString mName; // formatted name -}; - -/*! - Issues requests to CntSrv. - */ -class CntSrvConnection : public QObject -{ - Q_OBJECT -public: - CntSrvConnection(); - ~CntSrvConnection(); - void setAsynchronous(); - bool executeSqlQuery(const QString &sqlQuery, CntNameOrder nameFormat, int sizeHintKB); - QList names() { return mNames; } - -protected: - bool event(QEvent *event); - -signals: - void namesRead(); - void namesSorted(); - -private: - QThread mThread; - QList mNames; - CntSrvSession *mSession; - QString mSqlQuery; - CntNameOrder mNameFormat; - int mSizeHintKB; - bool mIsAsynchronous; -}; - -/*! - Can fetches all contact names in sorted order: - - from file cache (= any changes since last app exit are not reflected in this list) - - from database syncronously - - from database asyncronously - Fetching from the file cache takes about 0.2 seconds for 10000 contacts. - Fetching from the database takes about 2 seconds for 10000 contacts. - */ -class CntNameFetcher : public QObject -{ - Q_OBJECT -public: - CntNameFetcher(); - ~CntNameFetcher(); - CntNameCacheItem * readOneName(QContactLocalId contactId) const; - void readAllNamesAsynch(); - bool readNamesFromCache(QList &names); - bool writeNamesToCache(const QList &names) const; - void sortNames(QList &names) const; - static bool compareNames(const CntNameCacheItem *a, const CntNameCacheItem *b); - -signals: - void nameFormatChanged(CntNameOrder nameFormat); - void databaseAccessComplete(); - void namesAvailable(QList contactNames); - -private slots: - void setNameFormat(const XQSettingsKey &key, const QVariant &value); - void sendCompletionSignal(); - -private: - CntSrvConnection *mDbConnection; - CntSrvConnection *mAsynchDbConnection; - XQSettingsManager *mSettingsManager; - XQSettingsKey *mNameFormatSetting; - CntNameOrder mNameFormat; - int mBufferSizeEstimate; -}; - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/inc/cntpresenceinfoprovider.h --- a/phonebookengines/cntlistmodel/inc/cntpresenceinfoprovider.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* -* Copyright (c) 2010 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: Presence info provider plugin for CntListModel. It can provide -* the presence information of a contact (icon2 field). -* -*/ - -#ifndef CNTPRESENCEINFOPROVIDER_H -#define CNTPRESENCEINFOPROVIDER_H - -#include -#include - -class PrcPresenceReader; -class PrcPresenceBuddyInfoQt; - -QTM_BEGIN_NAMESPACE -class QContactManager; -QTM_END_NAMESPACE - -QTM_USE_NAMESPACE - -/** - Presence info provider plugin for CntListModel. It can provide - the presence information of a contact (icon2 field). - */ -class CntPresenceInfoProvider : public CntInfoProvider -{ - friend class TestCntPresenceInfoProvider; - Q_OBJECT - -public: - CntPresenceInfoProvider(); - ~CntPresenceInfoProvider(); - - // From CntInfoProvider - QString id() const { return "presence"; }; - ContactInfoFields supportedFields() const; - void requestInfo(const QContact& contact, ContactInfoFields requestedInfo); - -private slots: - void handlePresenceUpdate(bool aSuccess, PrcPresenceBuddyInfoQt* aPresenceBuddyInfo); - -private: - QString parsePresence(const QList& buddyList); - -signals: - void infoFieldReady(CntInfoProvider* sender, int contactId, ContactInfoField field, const QString& value); - -private: - PrcPresenceReader* iReader; // owned - QContactManager* mManager; // owned - QMap mBuddyMap; -}; - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/src/cntcache.cpp --- a/phonebookengines/cntlistmodel/src/cntcache.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1007 +0,0 @@ -/* -* Copyright (c) 2010 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: Class for asynchronously fetching and caching basic -* contact info (see CntContactInfo) for list views. -* -*/ - -#include -#include -#include -#include - -#include -#include "cntcache.h" -#include "cntnamefetcher.h" -#include "cntcache_p.h" - -// set the singleton instance pointer to NULL -CntCache* CntCache::mInstance = NULL; - -// value for first cache order to be assigned -static const int CacheOrderStartValue = 1; -// for avoiding wrap around with cache orders -static const int MaxCacheOrderValue = 10000000; -// number of items to read quickly when a new instance is requested or cache is cleared -static const int ItemsToReadUrgently = 13; -// number of items to read ahead into cache; this number is for one direction -static const int ItemsToCacheAhead = 24; -// cache size for info items (name, text, icon1name, icon2name) -static const int InfoCacheSize = 128; -// cache size for icon items (iconName and HbIcon) -static const int IconCacheSize = 50; -// number of icons in a CntContactInfo object -static const int IconsInCntContactInfo = 2; -// default empty text info field for a contact; it cannot be empty -// as the listview will then ignore it, causing rendering problems -static const QString EmptyTextField = " "; - -/*! - Provides a pointer to the CntCache singleton instance. - */ -CntCache* CntCache::instance(QContactManager *manager) -{ - if (!mInstance) { - mInstance = new CntCache(manager); - } - - // whenever a client requests an instance the client will want to get all info - // for the first couple of contacts (~a screenfull) as fast as possible - mInstance->mUrgentContacts = ItemsToReadUrgently; - - return mInstance; -} - -/*! - Fetches information about a contact: name, text (e.g. phone number or - social status) and two icons (e.g. avatar, presence). Previously cached - content - at the very least the name - will be returned immediately. - Availability of more information will be checked asynchronously and - sent to clients via contactInfoUpdated() signals. - - The function takes a row and a list rather than just a contact id because - of read ahead caching - contacts near the requested contacts are expected - to be needed soon and are therefore also scheduled for caching. - - \param row the row of the contact to fetch - \param idList a list with all the IDs in the list - \return a contact with some details filled in - */ -CntContactInfo CntCache::fetchContactInfo(int row, const QList& idList) -{ - CNT_ENTRY_ARGS(row << "/" << idList.count()) - - Q_ASSERT(row >= 0 && row < idList.count()); - - QString name; - QString text = EmptyTextField; - HbIcon icons[IconsInCntContactInfo]; - - int contactId = idList.at(row); - - if (contactId != mEmittedContactId) { - // this request comes from the UI when a new view is created or in response to - // some scrolling activity; in the former case, the client should - // have set urgencymode on, but in the latter case: - // 1) postpone all jobs so the UI can use as much of the CPU as possible - // 2) update read ahead cache to contain all IDs of all items near this item - if (mUrgentContacts > 0) { - --mUrgentContacts; - } else { - mWorker->postponeJobs(150); - } - updateReadAheadCache(row, idList); - } - - // fetch contact - if (mInfoCache.contains(contactId)) { - // the item is in the cache - CntInfoCacheItem* infoItem = mInfoCache.value(contactId); - for (int i = 0; i < IconsInCntContactInfo; ++i) { - QString iconName = infoItem->icons[i]; - if (!iconName.isEmpty()) { - if (mIconCache.contains(iconName)) { - CntIconCacheItem* iconItem = mIconCache.value(iconName); - iconItem->cacheOrder = mNextIconCacheOrder++; - icons[i] = iconItem->icon; - if (!iconItem->isFetched) { - // if icon has not yet been received from backend, add - // this id to the list of contacts that want to be - // notified when the icon is received - iconItem->contactIds.insert(contactId); - // also reschedule it - mWorker->scheduleIconJob(iconName, row); - } - } else { - // needed icon is not in cache, so schedule it for retrieval - CntIconCacheItem* iconItem = createIconCacheItem(iconName); - iconItem->contactIds.insert(contactId); - mWorker->scheduleIconJob(iconName, row); - } - } - } - - // set return text - text = infoItem->text; - - // update cache order - infoItem->cacheOrder = mNextInfoCacheOrder++; - infoItem->latestRow = row; - } else { - // the contact info is not in cache, schedule it for retrieval - if (contactExists(contactId)) { - // contact found, so add new entry to cache - CntInfoCacheItem* item = createInfoCacheItem(contactId); - item->text = text; - item->latestRow = row; - - // ask the worker thread to fetch the information asynchronously - mWorker->scheduleInfoJob(contactId, row); - } - } - - name = contactName(contactId); - CNT_EXIT_ARGS("name:" << name << "sec:" << text) - - return CntContactInfo(contactId, name, text, icons[0], icons[1]); -} - -/*! - Creates a list of contact ids sorted according the corresponding contact names. - - \param idFilter the IDs to be returned; if NULL, all contact IDs are returned - \return the list of ids, sorted according the contact name - */ -QList CntCache::sortIdsByName(const QSet* idFilter) const -{ - CNT_ENTRY - - QList sortedIds; - - // allocate memory in advance to avoid repeated reallocation during population - // an extra 16 items are allocated to leave room for a few more contacts - // before reallocation is needed - if (!idFilter) { - sortedIds.reserve(mSortedNames.count() + 16); - } else { - sortedIds.reserve(idFilter->count() + 16); - } - - // the entries in mSortedNames are already sorted, so just pick - // out the ids from that list in the order that they appear - if (!idFilter) { - foreach (CntNameCacheItem* item, mSortedNames) { - sortedIds.append(item->contactId()); - } - } else { - foreach (CntNameCacheItem* item, mSortedNames) { - if (idFilter->contains(item->contactId())) { - sortedIds.append(item->contactId()); - } - } - } - - CNT_EXIT - - return sortedIds; -} - -/*! - Overloaded version of the function for string based searching of contact names. - Currently for multi part names only space and dash variations are used for filtering, - e.g. "Axx Bxx" or "Axx-Bxx" are the only possible matches along with the original string. - - \param searchList list of strings which are used for search - \return the list of ids, sorted according the contact name - */ -QList CntCache::sortIdsByName(const QStringList searchList) const -{ - CNT_ENTRY - - QList sortedIds; - int iterNames = 0; - int iterList = 0; - QString firstName = 0; - QString lastName = 0; - QString tempString = 0; - QString tempDash = 0; - QString tempSpace = 0; - int matchesFound = 0; - const QChar dash = '-'; - const QChar space = ' '; - QStringList searchVariations; - - for (iterList = 0; iterList < searchList.size(); iterList++) - { - tempString = searchList.at(iterList); - tempDash = tempString; - tempSpace = tempString; - tempDash.insert(0, dash); - tempSpace.insert(0, space); - - searchVariations.append(tempString); - searchVariations.append(tempDash); - searchVariations.append(tempSpace); - } - - for (iterNames = 0; iterNames < mSortedNames.size(); iterNames++) - { - matchesFound = 0; - firstName = (mSortedNames.at(iterNames))->firstName(); - lastName = (mSortedNames.at(iterNames))->lastName(); - for (iterList = 0; iterList < searchVariations.size(); iterList += 3) - { - // if the current name doesn't contain any of the possible variations then it can be skipped - if ( !( firstName.startsWith(searchVariations.at(iterList), Qt::CaseInsensitive) || - lastName.startsWith(searchVariations.at(iterList), Qt::CaseInsensitive) || - firstName.contains(searchVariations.at(iterList+1), Qt::CaseInsensitive) || - lastName.contains(searchVariations.at(iterList+1), Qt::CaseInsensitive) || - firstName.contains(searchVariations.at(iterList+2), Qt::CaseInsensitive) || - lastName.contains(searchVariations.at(iterList+2), Qt::CaseInsensitive) ) ) - { - break; - } - } - if (iterList == searchVariations.size()) - { - sortedIds.append(mSortedNames.at(iterNames)->contactId()); - } - } - - CNT_EXIT - - return sortedIds; -} - -/*! - Creates the CntCache singleton instance. - */ -CntCache::CntCache(QContactManager *manager) - : mContactManager(manager), - mWorker(new CntCacheThread()), - mNameFetcher(new CntNameFetcher()), - mNextInfoCacheOrder(CacheOrderStartValue), - mNextIconCacheOrder(CacheOrderStartValue), - mEmittedContactId(-1), - mUrgentContacts(0), - mHasModifiedNames(false), - mAllNamesFetchStarted(false) -{ - CNT_ENTRY - - // listen to name fetcher - connect(mNameFetcher, SIGNAL(nameFormatChanged(CntNameOrder)), this, SLOT(reformatNames(CntNameOrder))); - connect(mNameFetcher, SIGNAL(databaseAccessComplete()), mWorker, SLOT(resumeJobs())); - connect(mNameFetcher, SIGNAL(namesAvailable(QList)), this, SLOT(setNameList(QList))); - - // listen to info fetcher - connect(mWorker, SIGNAL(infoFieldUpdated(int, const ContactInfoField&, const QString&)), - this, SLOT(onNewInfo(int, const ContactInfoField&, const QString&))); - connect(mWorker, SIGNAL(infoCancelled(int)), this, SLOT(onInfoCancelled(int))); - - // listen to icon fetcher - connect(mWorker, SIGNAL(iconUpdated(const QString&, const HbIcon&)), - this, SLOT(onNewIcon(const QString&, const HbIcon&))); - connect(mWorker, SIGNAL(iconCancelled(const QString&)), this, SLOT(onIconCancelled(const QString&))); - connect(mWorker, SIGNAL(allJobsDone()), this, SLOT(scheduleOneReadAheadItem())); - - // listen to contact manager - connect(mContactManager, SIGNAL(contactsChanged(const QList&)), this, SLOT(updateContacts(const QList&))); - connect(mContactManager, SIGNAL(contactsRemoved(const QList&)), this, SLOT(removeContacts(const QList&))); - connect(mContactManager, SIGNAL(contactsAdded(const QList&)), this, SLOT(addContacts(const QList&))); - - // listen to application -- shut down cache only when the whole application quits - connect(HbApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(onShutdown())); - - // load all names to RAM - loadNames(); - - CNT_EXIT -} - -/*! - Destructs the CntCache singleton instance. - */ -CntCache::~CntCache() -{ - CNT_ENTRY - - if (mHasModifiedNames) { - mNameFetcher->writeNamesToCache(mSortedNames); - } - - delete mWorker; - delete mNameFetcher; - - qDeleteAll(mInfoCache); - mInfoCache.clear(); - - qDeleteAll(mIconCache); - mIconCache.clear(); - - qDeleteAll(mNameCache); - mNameCache.clear(); - mSortedNames.clear(); - - CNT_EXIT -} - -/*! - Processes a new info field that has arrived from the worker thread. - If the contact is in the info cache, then the info cache is updated - accordingly. - - A contactInfoUpdated() signal is usually also emitted. The exception - is if the info is the name of an icon and that icon is not in the icon - cache. In this case the icon is fetched before a signal is emitted. - */ -void CntCache::onNewInfo(int contactId, const ContactInfoField& infoField, const QString& infoValue) -{ - CNT_ENTRY_ARGS( "id:" << contactId << "infotype:" << infoField << "infovalue:" << infoValue ) - - Q_ASSERT(infoField == ContactInfoTextField || infoField == ContactInfoIcon1Field || infoField == ContactInfoIcon2Field); - - bool hasNewInfo; - - if (!mInfoCache.contains(contactId)) { - // contact is not in cache, so nothing needs to be done - // except notify clients that this contact has (possibly) - // been changed - hasNewInfo = true; - } - else if (infoField == ContactInfoTextField) { - // update cache with new text for contact - mInfoCache.value(contactId)->text = infoValue; - hasNewInfo = true; - } - else { - // update cache with new icon name for contact - int iconIndex = (infoField == ContactInfoIcon1Field ? 0 : 1); - - CntInfoCacheItem* item = mInfoCache.value(contactId); - QString iconName = infoValue; - if (item->icons[iconIndex] != iconName) { - item->icons[iconIndex] = iconName; - if (iconName.isEmpty()) { - hasNewInfo = true; - } - else if (mIconCache.contains(iconName)) { - CntIconCacheItem* iconItem = mIconCache.value(iconName); - if (!iconItem->isFetched) { - iconItem->contactIds.insert(contactId); - hasNewInfo = false; - } - else { - hasNewInfo = true; - } - } - else if (iconName.startsWith("qtg_", Qt::CaseInsensitive)) { - createIconCacheItem(iconName); - onNewIcon(iconName, HbIcon(iconName)); - hasNewInfo = true; - } - else { - CntIconCacheItem* iconItem = createIconCacheItem(iconName); - iconItem->contactIds.insert(contactId); - if (mInfoCache.contains(contactId)) { - mWorker->scheduleIconJob(iconName, mInfoCache.value(contactId)->latestRow); - } - else { - // less important icon, since this contact is not in cache - mWorker->scheduleIconJob(iconName, 100000); - } - hasNewInfo = false; - } - } - else { - hasNewInfo = false; - } - } - - if (hasNewInfo) { - emitContactInfoUpdated(contactId); - } - - CNT_EXIT -} - -/*! - Handle the case where a request for contact info is cancelled by the - worker because of too many subsequent requests. - */ -void CntCache::onInfoCancelled(int contactId) -{ - CNT_ENTRY_ARGS( "id:" << contactId ) - - if (mInfoCache.contains(contactId)) { - CntInfoCacheItem* item = mInfoCache.take(contactId); - delete item; - } - - emitContactInfoUpdated(contactId); - - CNT_EXIT -} - -/*! - Processes a new icon that has arrived from the worker thread. - The icon cache is updated and a contactInfoUpdated() signal is - emitted for all contacts that use this icon. - */ -void CntCache::onNewIcon(const QString& iconName, const HbIcon& icon) -{ - CNT_ENTRY_ARGS( iconName ) - - QSet contactsToNotify; - - if (mIconCache.contains(iconName)) { - CntIconCacheItem* item = mIconCache.value(iconName); - item->icon = icon; - item->isFetched = true; - contactsToNotify = item->contactIds; - item->contactIds.clear(); - } - - foreach (int contactId, contactsToNotify) { - emitContactInfoUpdated(contactId); - } - - CNT_EXIT -} - -/*! - Handle the case where a request for an icon is cancelled by the worker because - of too many subsequent requests. - */ -void CntCache::onIconCancelled(const QString& iconName) -{ - CNT_ENTRY_ARGS( iconName ) - - QSet contactsToNotify; - - if (mIconCache.contains(iconName)) { - CntIconCacheItem* item = mIconCache.take(iconName); - contactsToNotify = item->contactIds; - item->contactIds.clear(); - delete item; - } - - foreach (int contactId, contactsToNotify) { - emitContactInfoUpdated(contactId); - } - - CNT_EXIT -} - -/*! - Fetch the names of all contacts. - */ -void CntCache::loadNames() -{ - CNT_ENTRY - - // read names from file cache - mNameFetcher->readNamesFromCache(mSortedNames); - - // insert the names into the id-to-name map - foreach (CntNameCacheItem* item, mSortedNames) { - mNameCache.insert(item->contactId(), item); - } - - // if there are no names in file cache, start the asynch - // read of all names immediately (normally it is done - // after secondary info has been read) - if (mSortedNames.count() == 0) { - mWorker->postponeJobs(); - mAllNamesFetchStarted = true; - mNameFetcher->readAllNamesAsynch(); - } - - CNT_EXIT -} - -/*! - Checks whether a contact exists. - */ -bool CntCache::contactExists(QContactLocalId contactId) const -{ - return mNameCache.contains(contactId); -} - -/*! - Fetch the name of one contact. - */ -QString CntCache::contactName(QContactLocalId contactId) const -{ - CNT_ENTRY - - QString name; - - QHash::const_iterator i = mNameCache.find(contactId); - if (i != mNameCache.end()) { - name = i.value()->name(); - } - - CNT_EXIT - - return name; -} - -/*! - Collects all contact IDs near the latest fetch from the UI. These will be fetched and - precached when UI activity slows down. - - \param mostRecentRow the row of the contact that was most recently fetched - \param idList a list with all the IDs in the list - */ -void CntCache::updateReadAheadCache(int mostRecentRow, const QList& idList) -{ - CNT_ENTRY_ARGS( mostRecentRow ) - - int row; - - mReadAheadCache.clear(); - - // step through the area near to last fetch item and make sure all - // contacts in it are also in cache or in the read ahead list - for (int i = 1; i <= ItemsToCacheAhead; ++i) { - for (int j = 0; j < 2; ++j) { - if (j == 0) { - row = mostRecentRow - i; - if (row <= 0) { - continue; - } - } - else { - row = mostRecentRow + i; - if (row >= idList.count()) { - continue; - } - } - - int contactId = idList.at(row); - if (!mInfoCache.contains(contactId)) { - // contact is not in cache, so put the id to items to read into cache - mReadAheadCache.append(QPair(contactId,row)); - } - else { - // contact is in cache; update cache order as we want to keep this item in cache - mInfoCache.value(contactId)->cacheOrder = mNextInfoCacheOrder++; - } - } - } - - CNT_EXIT -} - -/*! - Schedules one uncached item in the read-ahead list for retrieval. - */ -void CntCache::scheduleOneReadAheadItem() -{ - CNT_ENTRY - - QString name; - - // fetch all names from the database if it hasn't been done yet - if (!mAllNamesFetchStarted) { - mWorker->postponeJobs(); - mAllNamesFetchStarted = true; - mNameFetcher->readAllNamesAsynch(); - } - - // pick the first contact from the read ahead cache and schedule it - while (mReadAheadCache.count() > 0) { - int contactId = mReadAheadCache.first().first; - int contactRow = mReadAheadCache.takeFirst().second; - if (!mInfoCache.contains(contactId)) { - // contact is not in cache, so schedule it for retreival - if (contactExists(contactId)) { - // contact found, so add new entry to cache - CntInfoCacheItem* item = createInfoCacheItem(contactId); - item->text = EmptyTextField; - item->latestRow = contactRow; - - // schedule the info - mWorker->scheduleInfoJob(contactId, contactRow); - break; - } - } - } - - CNT_EXIT -} - -/*! - Creates a new item in the info cache. If the cache is full, - then the least recently accessed item is removed from cache. - - /param contactId id of contact for which to create the new cache item - /return the newly created cache item - */ -CntInfoCacheItem* CntCache::createInfoCacheItem(int contactId) -{ - CNT_ENTRY_ARGS( contactId ) - - if (mInfoCache.count() >= InfoCacheSize) { - // cache is full, so remove the oldest contact - int minCacheOrder = mNextInfoCacheOrder; - CntInfoCacheItem* oldestItem = NULL; - foreach (CntInfoCacheItem* i, mInfoCache) { - if (i->cacheOrder < minCacheOrder) { - minCacheOrder = i->cacheOrder; - oldestItem = i; - } - } - - if (oldestItem) { - mInfoCache.remove(oldestItem->contactId); - delete oldestItem; - } - - // cache maintenance: if the cache ids become too large, - // reduce all of them by MaxCacheOrderValue - if (mNextInfoCacheOrder >= MaxCacheOrderValue) { - mNextInfoCacheOrder -= MaxCacheOrderValue; - foreach (CntInfoCacheItem* i, mInfoCache) { - i->cacheOrder -= MaxCacheOrderValue; - } - } - } - - // create and insert the new item - CntInfoCacheItem* item = new CntInfoCacheItem(); - item->cacheOrder = mNextInfoCacheOrder++; - item->contactId = contactId; - mInfoCache.insert(contactId, item); - - CNT_EXIT - - return item; -} - -/*! - Creates a new item in the icon cache. If the cache is full, - then the least recently accessed item is removed from cache. - - /param iconName name of the icon for which to create the new cache item - /return the newly created cache item - */ -CntIconCacheItem* CntCache::createIconCacheItem(const QString& iconName) -{ - CNT_ENTRY_ARGS( iconName ) - - if (mIconCache.count() >= IconCacheSize) { - // cache is full, so remove the oldest icon - int minCacheOrder = mNextIconCacheOrder; - CntIconCacheItem* oldestItem = NULL; - foreach (CntIconCacheItem* i, mIconCache) { - if (i->cacheOrder < minCacheOrder) { - minCacheOrder = i->cacheOrder; - oldestItem = i; - } - } - mIconCache.remove(oldestItem->iconName); - delete oldestItem; - - // cache maintenance: if the cache orders become too large, - // reduce all of them by MaxCacheOrderValue - if (mNextIconCacheOrder >= MaxCacheOrderValue) { - mNextIconCacheOrder -= MaxCacheOrderValue; - foreach (CntIconCacheItem* i, mIconCache) { - i->cacheOrder -= MaxCacheOrderValue; - } - } - } - - // create and insert the new item - CntIconCacheItem* item = new CntIconCacheItem(); - item->cacheOrder = mNextIconCacheOrder++; - item->iconName = iconName; - item->isFetched = false; - mIconCache.insert(iconName, item); - - CNT_EXIT - - return item; -} - -/*! - Notifies clients that a contact might have changed. - Clients can then request the info via fetchContactInfo() - if they are interested. - */ -void CntCache::emitContactInfoUpdated(int contactId) -{ - CNT_ENTRY_ARGS( contactId ) - - mEmittedContactId = contactId; - emit contactInfoUpdated(contactId); - mEmittedContactId = -1; - - CNT_EXIT -} - -/*! - Deletes the cache. - */ -void CntCache::onShutdown() -{ - CNT_ENTRY - - mInstance = NULL; - - disconnect(mContactManager, SIGNAL(contactsChanged(const QList&)), this, SLOT(updateContacts(const QList&))); - disconnect(mContactManager, SIGNAL(contactsRemoved(const QList&)), this, SLOT(removeContacts(const QList&))); - disconnect(mContactManager, SIGNAL(contactsAdded(const QList&)), this, SLOT(addContacts(const QList&))); - - deleteLater(); - - CNT_EXIT -} - -/*! - Updates the names in cache according to newFormat. - - This slot is called when name fetcher signals that the format of - names has been changed. - */ -void CntCache::reformatNames(CntNameOrder newFormat) -{ - foreach (CntNameCacheItem* item, mSortedNames) { - item->setNameFormat(newFormat); - } - - mNameFetcher->sortNames(mSortedNames); - - mNameFetcher->writeNamesToCache(mSortedNames); - mHasModifiedNames = false; - - emit dataChanged(); -} - -/*! - Replaces the names in cache with the ones in this list. - - \param newSortedNames the sorted list with names; this list will be cleared and - ownership will be taken of the items in the list - */ -void CntCache::setNameList(QList newSortedNames) -{ - CNT_ENTRY - - bool hasModifiedContacts = false; - int count = newSortedNames.count(); - - // check if there have been any changes - if (mSortedNames.count() != count) { - hasModifiedContacts = true; - } else { - for (int i = 0; i < count; ++i) { - CntNameCacheItem *oldItem = mSortedNames.at(i); - CntNameCacheItem *newItem = newSortedNames.at(i); - if (oldItem->contactId() != newItem->contactId() || oldItem->name() != newItem->name()) { - hasModifiedContacts = true; - break; - } - } - } - - // the list has changed, so use the new list instead - if (hasModifiedContacts) { - qDeleteAll(mSortedNames); - mNameCache.clear(); - mSortedNames.clear(); - - foreach (CntNameCacheItem* item, newSortedNames) { - mSortedNames.append(item); - mNameCache.insert(item->contactId(), item); - } - - // write names to file cache - mNameFetcher->writeNamesToCache(mSortedNames); - - // notify clients that the list of names has changed - emit dataChanged(); - } else { - qDeleteAll(newSortedNames); - } - - CNT_EXIT -} - -/*! - Updates data in response to some contacts having changed and - then notifies observers that these contacts have changed. - */ -void CntCache::updateContacts(const QList &changedContacts) -{ - QString name; - QList items; - - // reloads the names of the changed contacts and updates the - // list of sorted names accordingly - foreach (QContactLocalId contactId, changedContacts) { - CntNameCacheItem *newItem = mNameFetcher->readOneName(contactId); - if (newItem != NULL) { - CntNameCacheItem *oldItem = mNameCache.value(contactId); - if (oldItem->name() != newItem->name()) { - QList::iterator oldPos = qLowerBound(mSortedNames.begin(), mSortedNames.end(), oldItem, CntNameFetcher::compareNames); - while (*oldPos != oldItem && oldPos != mSortedNames.end()) { - ++oldPos; - } - QList::iterator newPos = qUpperBound(mSortedNames.begin(), mSortedNames.end(), newItem, CntNameFetcher::compareNames); - if (oldPos < newPos) { - mSortedNames.move(oldPos - mSortedNames.begin(), (newPos - mSortedNames.begin()) - 1); - } else { - mSortedNames.move(oldPos - mSortedNames.begin(), newPos - mSortedNames.begin()); - } - *oldItem = *newItem; - mHasModifiedNames = true; - } - } - } - - // if any of the changed items have cached info, the info - // is scheduled for refreshing - foreach (QContactLocalId contactId, changedContacts) { - if (mInfoCache.contains(contactId)) { - CntInfoCacheItem* infoItem = mInfoCache.value(contactId); - mWorker->scheduleInfoJob(contactId, infoItem->latestRow); - } - } - - // inform clients about these changes - emit contactsChanged(changedContacts); -} - -/*! - Updates data in response to some contacts having been removed - and then notifies observers that the contacts have been removed. - */ -void CntCache::removeContacts(const QList &removedContacts) -{ - // removed the deleted contacts from the name cache and from the - // list of sorted names - foreach (QContactLocalId contactId, removedContacts) { - CntNameCacheItem *item = mNameCache.take(contactId); - if (item) { - QList::iterator pos = qLowerBound(mSortedNames.begin(), mSortedNames.end(), item, CntNameFetcher::compareNames); - while (*pos != item && pos != mSortedNames.end()) { - ++pos; - } - mSortedNames.erase(pos); - delete item; - mHasModifiedNames = true; - } - } - - // info for these deleted items should be removed from cache - foreach (QContactLocalId contactId, removedContacts) { - if (mInfoCache.contains(contactId)) { - CntInfoCacheItem* item = mInfoCache.take(contactId); - delete item; - } - } - - // inform clients about these deleted contacts - emit contactsRemoved(removedContacts); -} - -/*! - Updates data in response to some contacts having been added - and then notifies observers that the contacts have been added. - */ -void CntCache::addContacts(const QList &addedContacts) -{ - // add the new contacts to the name cache and to the - // list of sorted names - foreach (QContactLocalId contactId, addedContacts) { - CntNameCacheItem *item = mNameFetcher->readOneName(contactId); - if (item != NULL) { - mNameCache.insert(contactId, item); - QList::iterator i = qUpperBound(mSortedNames.begin(), mSortedNames.end(), item, CntNameFetcher::compareNames); - mSortedNames.insert(i, item); - mHasModifiedNames = true; - } - } - - // inform clients about the new contacts - emit contactsAdded(addedContacts); -} - -/*! - Creates an empty CntContactInfo object. - */ -CntContactInfo::CntContactInfo() - : d(new CntContactInfoData()) -{ -} - -/*! - Creates a CntContactInfo object with all info fields set. - */ -CntContactInfo::CntContactInfo(int id, const QString& name, const QString& text, const HbIcon& icon1, const HbIcon& icon2) - : d(new CntContactInfoData()) -{ - d->id = id; - d->name = name; - d->text = text; - d->icon1 = icon1; - d->icon2 = icon2; -} - -/*! - Destroys the object. - */ -CntContactInfo::~CntContactInfo() -{ -} - -/*! - Copy constructor. - */ -CntContactInfo::CntContactInfo(const CntContactInfo& other) - : d(other.d) -{ -} - -/*! - Assignment operator. - */ -CntContactInfo& CntContactInfo::operator=(const CntContactInfo& other) -{ - d = other.d; - return *this; -} - -/*! - Getter function for the id. - */ -int CntContactInfo::id() const -{ - return d->id; -} - -/*! - Getter function for the name. - */ -QString CntContactInfo::name() const -{ - return d->name; -} - -/*! - Getter function for the text. - */ -QString CntContactInfo::text() const -{ - return d->text; -} - -/*! - Getter function for the first icon. - */ -HbIcon CntContactInfo::icon1() const -{ - return d->icon1; -} - -/*! - Getter function for the second icon. - */ -HbIcon CntContactInfo::icon2() const -{ - return d->icon2; -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/src/cntcache_p.cpp --- a/phonebookengines/cntlistmodel/src/cntcache_p.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,491 +0,0 @@ -/* -* Copyright (c) 2010 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: Private data and helper classes used by class CntCache. -* -*/ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "cntcache.h" -#include "cntcache_p.h" -#include -#include -#include "cntdefaultinfoprovider.h" -#include "cntpresenceinfoprovider.h" -#include - -// maximum amount of info and icon jobs respectively -- if there are more jobs, -// then the oldest job is skipped and the client informed that this happened -// in this way the client can request the job again if wanted -static const int CntMaxInfoJobs = 20; -static const int CntMaxIconJobs = 20; -// the event for starting to process all outstanding jobs -static const QEvent::Type ProcessJobsEvent = QEvent::User; -// the id that states that no icon is currently pending from thumbnail manager -static const int NoIconRequest = -1; -// the id that states that there is no job with that key -static const int NoSuchJob = -1; -// different states of postponement -static const int JobsNotPostponed = 0; -static const int JobsPostponedForDuration = 1; -static const int JobsPostponedUntilResume = 2; - -const char *CNT_INFO_PROVIDER_EXTENSION_PLUGIN_DIRECTORY = "/resource/qt/plugins/contacts/infoproviders/"; - -// TODO: Provide a way (cenrep keys?) for UI to set which provider to use for -// what info field (and what info fields are indeed even in use). - -/*! - Creates a new thread for fetching contact info and icons in the background. - */ -CntCacheThread::CntCacheThread() - : mContactManager(new QContactManager()), - mProcessingJobs(false), - mJobsPostponed(JobsNotPostponed), - mIconRequestId(NoIconRequest), - mTimer(new QTimer()) -{ - CNT_ENTRY - - // create static provider plugins - mInfoProviders.insert(new CntDefaultInfoProvider(), ContactInfoAllFields); - mInfoProviders.insert(new CntPresenceInfoProvider(), ContactInfoIcon2Field); - - // load dynamic provider plugins - QDir pluginsDir(CNT_INFO_PROVIDER_EXTENSION_PLUGIN_DIRECTORY); - foreach (QString fileName, pluginsDir.entryList(QDir::Files)) { - // Create plugin loader - QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); - if (pluginLoader.load()) { - CntInfoProviderFactory *factory = qobject_cast(pluginLoader.instance()); - - if (factory) { - CntInfoProvider *provider = factory->infoProvider(); - mInfoProviders.insert(provider, provider->supportedFields()); - } - } - } - - // connect the providers - QMapIterator i(mInfoProviders); - while (i.hasNext()) { - i.next(); - connect(static_cast(i.key()), - SIGNAL(infoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&)), - this, - SLOT(onInfoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&))); - } - - // create & connect the thumbnail manager - mThumbnailManager = new ThumbnailManager(this); - mThumbnailManager->setMode(ThumbnailManager::Default); - mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForPerformance); - mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailSmall); - connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)), - this, SLOT(onIconReady(QPixmap, void *, int, int))); - - mTimer->setSingleShot(true); - connect(mTimer, SIGNAL(timeout()), this, SLOT(resumeJobs())); - - CNT_EXIT -} - -/*! - Cleans up and destructs the thread. - */ -CntCacheThread::~CntCacheThread() -{ - CNT_ENTRY - - delete mContactManager; - disconnect(this); - - mInfoJobs.clear(); - mCancelledInfoJobs.clear(); - mIconJobs.clear(); - mCancelledIconJobs.clear(); - - if (mIconRequestId != NoIconRequest) { - mThumbnailManager->cancelRequest(mIconRequestId); - mIconRequestId = NoIconRequest; - } - - delete mThumbnailManager; - mThumbnailManager = NULL; - - qDeleteAll(mInfoProviders.keys()); - mInfoProviders.clear(); - - CNT_EXIT -} - -/*! - Schedules a info to be fetched for a contact. When info has been fetched - infoFieldUpdated() signals will be emitted, once for each field. - - /param contactId the contact for which the info is wanted - */ -void CntCacheThread::scheduleInfoJob(int contactId, int priority) -{ - CNT_ENTRY_ARGS( contactId ) - - if (contactId <= 0) - return; - - int index = infoJobIndex(contactId); - if (index != NoSuchJob) { - // if the job already exists, update the priority - if (priority < mInfoJobs.at(index).second) { - mInfoJobs[index] = QPair(contactId,priority); - } - return; - } - - if (!mProcessingJobs) { - // new job => start processing jobs - mProcessingJobs = true; - HbApplication::instance()->postEvent(this, new QEvent(ProcessJobsEvent)); - } - - if (mInfoJobs.count() >= CntMaxInfoJobs) { - // the queue of jobs is full, so remove the oldest job - mCancelledInfoJobs.append(mInfoJobs.takeFirst().first); - CNT_LOG_ARGS( mCancelledInfoJobs.last() << "removed from joblist" ) - } - - mInfoJobs.append(QPair(contactId, priority)); - CNT_LOG_ARGS( contactId << "(prio:" << priority << ") appended @" << (mInfoJobs.count() - 1) ); - - // since this job has now been scheduled, remove it from the list of - // cancelled jobs in case it is there - mCancelledInfoJobs.removeOne(contactId); - - CNT_EXIT -} - -/*! - Schedules an icon to be fetched. An iconUpdated() signal will be emitted when the icon - has been fetched. - - /param iconName the name of the icon to be fetched - */ -void CntCacheThread::scheduleIconJob(const QString& iconName, int priority) -{ - CNT_ENTRY_ARGS( iconName ) - - if (iconName.isEmpty()) - return; - - int index = iconJobIndex(iconName); - if (index != NoSuchJob) { - // if the job already exists, update the priority - if (priority < mIconJobs.at(index).second) { - mIconJobs[index] = QPair(iconName,priority); - } - return; - } - - if (!mProcessingJobs) { - // new job, so restart job loop - mProcessingJobs = true; - HbApplication::instance()->postEvent(this, new QEvent(ProcessJobsEvent)); - } - - if (mIconJobs.count() >= CntMaxIconJobs) { - // the queue of jobs is full, so remove the oldest job - mCancelledIconJobs.append(mIconJobs.takeLast().first); - CNT_LOG_ARGS( mCancelledIconJobs.last() << "removed from joblist" ); - } - - mIconJobs.append(QPair(iconName, priority)); - CNT_LOG_ARGS( iconName << "(prio:" << priority << ") appended @" << (mIconJobs.count() - 1) ); - - // since this job has now been rescheduled, remove it from the list of - // cancelled jobs in case it is there - mCancelledIconJobs.removeOne(iconName); - - CNT_EXIT -} - -/*! - Postpones outstanding jobs until milliseconds ms has passed or resumeJobs() is called. - This should be called if the client wants to reserve more CPU time for some urgent tasks. - - \param milliseconds The duration of the delay; 0, which is the default, means to delay - until resumeJobs() is called - */ -void CntCacheThread::postponeJobs(int milliseconds) -{ - CNT_ENTRY_ARGS("ms =" << milliseconds << " type =" << mJobsPostponed) - - Q_ASSERT(milliseconds >= 0); - - if (milliseconds == 0) { - mTimer->stop(); - mJobsPostponed = JobsPostponedUntilResume; - } else if (mJobsPostponed != JobsPostponedUntilResume) { - mTimer->stop(); - mJobsPostponed = JobsPostponedForDuration; - mTimer->start(milliseconds); - } - - CNT_EXIT -} - -/*! - Postpones outstanding jobs until resumeJobs() is called. This must always be called after - postponeJobs. - */ -void CntCacheThread::resumeJobs() -{ - CNT_ENTRY - - mTimer->stop(); - mJobsPostponed = JobsNotPostponed; - HbApplication::instance()->postEvent(this, new QEvent(ProcessJobsEvent)); - - CNT_EXIT -} - -/*! - Handles a class-specific event that is sent by the scheduleOrUpdate functions - when there are jobs. - */ -bool CntCacheThread::event(QEvent* event) -{ - if (event->type() == ProcessJobsEvent) { - processJobs(); - return true; - } - - return QObject::event(event); -} - -/*! - Processes all scheduled jobs. The loop runs until all jobs are done. - It pauses for a while if new info jobs appear -- this means that the - UI is updating and so the CPU is yielded to the UI. If there are - again new jobs after the pause, then it pauses again, and so on. - */ -void CntCacheThread::processJobs() -{ - CNT_ENTRY - - bool hasDoneJobs = false; - - forever { - int infoJobs = mInfoJobs.count(); - int iconJobs = mIconJobs.count(); - int totalJobs = infoJobs + iconJobs + mCancelledInfoJobs.count() + mCancelledIconJobs.count(); - - if (totalJobs == 0 || totalJobs == iconJobs && mIconRequestId != NoIconRequest || mJobsPostponed != JobsNotPostponed) { - if (mJobsPostponed == JobsNotPostponed || totalJobs == 0) { - mProcessingJobs = false; - } - - if (totalJobs == 0 && hasDoneJobs) { - emit allJobsDone(); - } - - break; - } - - if (infoJobs > 0) { - // get next job - int contactId = takeNextInfoJob(); - - // fetch qcontact - QContactFetchHint restrictions; - restrictions.setOptimizationHints(QContactFetchHint::NoRelationships); - QContact contact = mContactManager->contact(contactId, restrictions); - - // request contact info from providers - QMapIterator i(mInfoProviders); - while (i.hasNext()) { - i.next(); - if (i.value() != 0) { - i.key()->requestInfo(contact, i.value()); - } - } - } - else if (iconJobs > 0 && mIconRequestId == NoIconRequest) { - // request icon from thumbnail manager - QString iconName = takeNextIconJob(); - mIconRequestId = mThumbnailManager->getThumbnail(iconName, NULL, 0); - mIconRequestName = iconName; - } - else { - if (mCancelledInfoJobs.count() > 0) { - int contactId = mCancelledInfoJobs.takeLast(); - emit infoCancelled(contactId); - } - else if (mCancelledIconJobs.count() > 0) { - QString iconName = mCancelledIconJobs.takeFirst(); - emit iconCancelled(iconName); - } - } - - hasDoneJobs = true; - - // allow signals to be passed from providers and from the client - HbApplication::processEvents(); - } - - CNT_EXIT -} - -/*! - Passes an info field from a data provider up to the client via signals. The - client is not in the same thread, so Qt passes the signal as an event. - */ -void CntCacheThread::onInfoFieldReady(CntInfoProvider* sender, int contactId, - ContactInfoField field, const QString& text) -{ - CNT_ENTRY - - // there can be 3rd party providers, so we cannot blindly trust them; - // info is emitted only if: - // 1) the sender is in the list of providers - // 2) exactly one field bit is set in parameter 'field' - // 3) the field bit has been assigned to this provider - if (mInfoProviders.contains(sender) - && ((field & (field - 1)) == 0) - && ((field & mInfoProviders.value(sender)) != 0)) { - emit infoFieldUpdated(contactId, field, text); - } - - CNT_EXIT -} - -/*! - Passes an icon from thumbnail manager up to the client via a signal. The - client is not in the same thread, so Qt passes the signal as an event. - */ -void CntCacheThread::onIconReady(const QPixmap& pixmap, void *data, int id, int error) -{ - CNT_ENTRY - - Q_UNUSED(id); - Q_UNUSED(data); - - Q_ASSERT(id == mIconRequestId && !mIconRequestName.isEmpty()); - if (!mProcessingJobs) { - // job loop quit while waiting for this icon, so restart it - mProcessingJobs = true; - HbApplication::instance()->postEvent(this, new QEvent(ProcessJobsEvent)); - } - mIconRequestId = NoIconRequest; - - if (error == 0) { - emit iconUpdated(mIconRequestName, HbIcon(pixmap)); - } - - CNT_EXIT -} - -/*! - Finds out the index of an info job in the job list. - - \return index of the contact in the job list, or NoSuchJob if no job is scheduled for the contact - */ -int CntCacheThread::infoJobIndex(int contactId) -{ - int jobCount = mInfoJobs.count(); - for (int i = 0; i < jobCount; ++i) { - if (mInfoJobs.at(i).first == contactId) { - return i; - } - } - - return NoSuchJob; -} - -/*! - Picks the next job from the info job list (the one with the highest priority). - - \return the id of the contact for which the info should be fetched - */ -int CntCacheThread::takeNextInfoJob() -{ - int selectionIndex = -1; - int selectionPriority = -1; - - int jobCount = mInfoJobs.count(); - if (jobCount == 0) { - return NoSuchJob; - } - - for (int i = 0; i < jobCount; ++i) { - int jobPriority = mInfoJobs.at(i).second; - if (jobPriority < selectionPriority || selectionPriority == -1) { - selectionIndex = i; - selectionPriority = jobPriority; - } - } - - return mInfoJobs.takeAt(selectionIndex).first; -} - -/*! - Picks the next job from the icon job list (the one with the highest priority). - - \return the name of the icon that should be fetched - */ -QString CntCacheThread::takeNextIconJob() -{ - int selectionIndex = -1; - int selectionPriority = -1; - - int jobCount = mIconJobs.count(); - if (jobCount == 0) { - return QString(); - } - - for (int i = 0; i < jobCount; ++i) { - int jobPriority = mIconJobs.at(i).second; - if (jobPriority < selectionPriority || selectionPriority == -1) { - selectionIndex = i; - selectionPriority = jobPriority; - } - } - - return mIconJobs.takeAt(selectionIndex).first; -} - -/*! - Finds out the index of an icon job in the job list. - - \return index of the icon in the job list, or NoSuchJob if a job for the icon is not scheduled. - */ -int CntCacheThread::iconJobIndex(QString iconName) -{ - int jobCount = mIconJobs.count(); - for (int i = 0; i < jobCount; ++i) { - if (mIconJobs.at(i).first == iconName) { - return i; - } - } - - return NoSuchJob; -} - - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/src/cntdefaultinfoprovider.cpp --- a/phonebookengines/cntlistmodel/src/cntdefaultinfoprovider.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* -* Copyright (c) 2010 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: Default info provider plugin for CntListModel. It can provide -* the phone number and the image url of a contact (text and -* icon1 field respectively). -* -*/ - -#include -#include "cntdefaultinfoprovider.h" -#include - -/*! - /return the info fields supported by this provider - */ -ContactInfoFields CntDefaultInfoProvider::supportedFields() const -{ - // this provider does not have any info for the icon2 field - return ContactInfoIcon1Field | ContactInfoTextField; -} - -/*! - The contact contains all the info this provider needs, so signals with the requested info - fields are emitted immediately. - - /param contact the contact for which info is requested - /param requestedInfo one or more of the flags in ContactInfoFields - */ -void CntDefaultInfoProvider::requestInfo(const QContact& contact, ContactInfoFields requestedInfo) -{ - if (requestedInfo & ContactInfoTextField) { - QContactDetail detail = contact.preferredDetail("call"); - QString number; - - if (!detail.isEmpty()) - { - number = static_cast(detail).number(); - } - else - { - QList numbers = contact.details(); - if (numbers.count() > 1) - number = hbTrId("txt_phob_dblist_val_ln_numbers", numbers.count()); - else if (numbers.count() == 1) - number = numbers.at(0).number(); - } - - emit infoFieldReady(this, contact.localId(), ContactInfoTextField, number); - } - - if (requestedInfo & ContactInfoIcon1Field) { - QString imageUrl = contact.detail().imageUrl().toString(); - emit infoFieldReady(this, contact.localId(), ContactInfoIcon1Field, imageUrl); - } -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/src/cntdisplaytextformatter.cpp --- a/phonebookengines/cntlistmodel/src/cntdisplaytextformatter.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* -* 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 "cntdisplaytextformatter.h" -#include -#include -#include -#include -#include - -CntHTMLDisplayTextFormatter::CntHTMLDisplayTextFormatter() -{ -} - -CntHTMLDisplayTextFormatter::~CntHTMLDisplayTextFormatter() -{ -} - -QString CntHTMLDisplayTextFormatter::formattedText( const QString aText, const QContactFilter& aCriteria ) -{ - CNT_LOG_ARGS( "filter:" << aText ) - if ( aCriteria.type() == QContactFilter::ContactDetailFilter ) - { - const QContactDetailFilter& filter = static_cast( aCriteria ); - if ( filter.detailDefinitionName() == QContactDisplayLabel::DefinitionName && - filter.matchFlags() & QContactFilter::MatchStartsWith ) - { - QString formattedText; - // go through the words (e.g. Lastname, Firstname) and apply list of pattern to them. - foreach ( QString text, aText.split(QRegExp("\\s+"), QString::SkipEmptyParts) ) - { - bool match( false ); - // go through every search criteria word - foreach (QString pattern, filter.value().toStringList() ) - { - if ( text.startsWith(pattern, Qt::CaseInsensitive) ) - { - insertTag( text, pattern.length() ); - formattedText.append( text ); - match = true; - break; // break this inner foreach - } - } - - // if no match found, original text is returned - if ( !match ) - formattedText.append( text ); - - // put spaces back between words (split() looses them) - formattedText.append( " " ); - } - return formattedText.trimmed(); - } - } - return aText; -} - -void CntHTMLDisplayTextFormatter::insertTag( QString& aText, int aChars ) -{ - QColor highlight = HbColorScheme::color("qtc_lineedit_marker_normal"); - QColor color = HbColorScheme::color("qtc_lineedit_selected"); - - QString start = QString(TAG_START).arg( highlight.name().toUpper() ).arg(color.name().toUpper()); - aText.prepend( start ); - aText.insert( start.length() + aChars, TAG_END ); -} -// End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/src/cntlistmodel.cpp --- a/phonebookengines/cntlistmodel/src/cntlistmodel.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,780 +0,0 @@ -/* -* 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 "cntlistmodel_p.h" -#include "cntlistmodel.h" -#include "cntcache.h" -#include "cntdebug.h" - -#include -#include -#include - -#include -#include -#include -#include // for reading cenrep keys -#include - -const uint dummyMyCardId = 0; - -/*! - * Construct a new CntListModel object using manager as the QContactManager - * instance to communicate with the contacts database. - * - * \param manager A QContactManager instance to be used for - * communications with the contacts persistant store. - */ -CntListModel::CntListModel(QContactManager* manager, - const QContactFilter& contactFilter, - bool showMyCard, - QObject *parent) - : QAbstractListModel(parent) -{ - CNT_ENTRY - - // create icons - m_defaultIcon = HbIcon("qtg_large_avatar"); - m_defaultMyCardIcon = HbIcon("qtg_large_avatar_mycard"); - - // set up data - d = new CntListModelData(contactFilter, showMyCard); - d->m_contactManager = manager; - d->m_cache = CntCache::instance(d->m_contactManager); - d->m_myCardId = d->m_contactManager->selfContactId(); - updateContactIdsArray(); - - // get current setting how to show an item in the name list and subscribe for changes - d->m_Settings = new XQSettingsManager; - d->m_NameListRowSettingkey = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, - KCRCntSettings.iUid, - KCntNameListRowSetting); - d->m_currentRowSetting = d->m_Settings->readItemValue(*d->m_NameListRowSettingkey, - XQSettingsManager::TypeInt).toInt(); - d->m_Settings->startMonitoring(*d->m_NameListRowSettingkey, XQSettingsManager::TypeInt); - connect(d->m_Settings, SIGNAL(valueChanged(const XQSettingsKey&, const QVariant&)), this, SLOT(handleRowSettingChanged(const XQSettingsKey&, const QVariant&))); - - // listen to cache for changes in contacts - connect(d->m_cache, SIGNAL(contactInfoUpdated(QContactLocalId)), this, SLOT(handleContactInfoUpdated(QContactLocalId))); - connect(d->m_cache, SIGNAL(contactsAdded(const QList&)), this, SLOT(handleAdded(const QList&))); - connect(d->m_cache, SIGNAL(contactsChanged(const QList&)), this, SLOT(handleChanged(const QList&))); - connect(d->m_cache, SIGNAL(contactsRemoved(const QList&)), this, SLOT(handleRemoved(const QList&))); - connect(d->m_cache, SIGNAL(dataChanged()), this, SLOT(refreshModel())); - - // listen to contactmanager for changes in relationships or mycard - connect(d->m_contactManager, SIGNAL(selfContactIdChanged(const QContactLocalId&, const QContactLocalId&)), this, SLOT(handleMyCardChanged(const QContactLocalId&, const QContactLocalId&))); - connect(d->m_contactManager, SIGNAL(relationshipsAdded(const QList&)), this, SLOT(handleAddedRelationship(const QList&))); - connect(d->m_contactManager, SIGNAL(relationshipsRemoved(const QList&)), this, SLOT(handleRemovedRelationship(const QList&))); - - CNT_EXIT -} - -CntListModel::~CntListModel() -{ -} - -/*! - * Return the data to be used by the view or delegates for a particular - * item and role. - * - * \param index The index of the item to return data about. - * \param role The data should be relevant for this particular purpose. - * \return QVariant The data for the specified index and role. - */ -QVariant CntListModel::data(const QModelIndex &index, int role) const -{ - CNT_ENTRY - int row = index.row(); - - // check that row is ok - if (!validRowId(row)) { - // invalid row - return QVariant(); - } - - // update current contact if needed - if (row != d->m_currentRow ) { - if (d->m_contactIds[row] == dummyMyCardId) { - // row contains dummy MyCard, so create dummy CntContactInfo - d->m_currentContact = CntContactInfo(); - } - else { - d->m_currentContact = d->m_cache->fetchContactInfo(row, d->m_contactIds); - } - d->m_currentRow = row; - } - - if (role == Qt::DisplayRole) { - return dataForRole(row, role); - } - else if (role == Hb::IndexFeedbackRole) { - if (row == 0 && (d->m_myCardId == d->m_contactIds[0] || dummyMyCardId == d->m_contactIds[0])) { - // do not include MyCard in index feedback - return QVariant(); - } - else { - return dataForRole(row, role).toStringList().at(0).toUpper(); - } - } - else if (role == Qt::BackgroundRole) { - if (d->m_myCardId == d->m_contactIds[row] || dummyMyCardId == d->m_contactIds[row]) { - return HbFrameBackground("qtg_fr_list_parent_normal", HbFrameDrawer::NinePieces); - } - } - else if (role == Qt::DecorationRole) { - if (d->m_currentRowSetting == CntTwoRowsNameAndPhoneNumber) { - //icon fits only if user selected 2 rows in each name list item - QList icons; - HbIcon avatar = d->m_currentContact.icon1(); - HbIcon statusIcon = d->m_currentContact.icon2(); - - if (!avatar.isNull()) { - icons.append(avatar); - } - else if (d->m_myCardId == d->m_contactIds[row] || dummyMyCardId == d->m_contactIds[row]) { - icons.append(m_defaultMyCardIcon); - } - else { - icons.append(m_defaultIcon); - } - - if (!statusIcon.isNull()) { - icons.append(statusIcon); - } - - return icons; - } - else { - return QVariant(); - } - } - CNT_EXIT - return QVariant(); -} - -/*! - * Get the number of rows (contacts) in this model. - * - * \param parent Optional parent index value. - * \return Number of contacts in this model. - */ -int CntListModel::rowCount(const QModelIndex& /*parent*/) const -{ - return d->m_contactIds.count(); -} - -/*! - * Read a full contact entry from the database for the given model - * index value. Only the row part of the index information will be - * read. This is just an overload of CntListModel::contact() that - * supports old behaviour and calls: - * CntListModel::contact(int row); - * - * The entry at the requested row will have its full contact information - * (all fields) read from the database and returned as a QContact instance. - * - * \param index Index for the sought contact entry in this model. - * \return A newly constructed QContact instance for this entry - ownership - * is transferred to the caller. - * - */ -QContact CntListModel::contact(const QModelIndex &index) const -{ - return contact(index.row()); -} - -/*! - * Returns the id for the contact at the requested row. - * - * \param index Index for the sought contact entry in this model. - * \return The id for the contact, 0 if invalid index. - * - */ -QContactLocalId CntListModel::contactId(const QModelIndex &index) const -{ - CNT_ENTRY - - if (!validRowId(index.row())) { - return 0; - } - - CNT_EXIT - return d->m_contactIds[index.row()]; -} - -/*! - * Return an index that points to the row relating to the supplied contact. - * E.g. if the contact is at row 7, the index with the following properties - * is returned: - * index.row() == 7 - - * \param contact The contact for whose row an index is required - * \return a QModelIndex with the row set to match that of the contact. - */ -QModelIndex CntListModel::indexOfContact(const QContact &contact) const -{ - return createIndex(rowId(contact.localId()), 0); -} - -/*! - * Return an index that points to the row relating to the supplied contact id. - * E.g. if the contact with this id is at row 7, the index with the following - * properties is returned: - * index.row() == 7 - - * \param contactId The id of the contact for whose row an index is required - * \return a QModelIndex with the row set to match that of the contact id. - */ -QModelIndex CntListModel::indexOfContactId(const QContactLocalId &contactId) const -{ - return createIndex(rowId(contactId), 0); -} - -/*! - * Set new filter and sort order for the model. - * - * \param contactFilter New contact filter. - * \param contactSortOrders New sort order. - */ -void CntListModel::setFilter(const QContactFilter& contactFilter) -{ - CNT_ENTRY - - d->setFilter(contactFilter); - - //refresh model - updateContactIdsArray(); - - beginResetModel(); - reset(); - endResetModel(); - - CNT_EXIT -} - -/*! - * Enable/disable MyCard appearance in the model. - * - * \param enabled Status of MyCard appearance in the model. - */ -void CntListModel::showMyCard(bool enabled) -{ - CNT_ENTRY - if (d->m_showMyCard == enabled) { - return; - } - - QContactLocalId myCardId = d->m_myCardId; - if (enabled) { - //add MyCard to the list - if (myCardId <= 0) { - // create a placeholder for MyCard - d->m_contactIds.insert(0, dummyMyCardId); - } - else { - d->m_contactIds.insert(0, myCardId); - } - } - else { - // remove MyCard from the list - if (myCardId <= 0) { - d->m_contactIds.removeOne(dummyMyCardId); - } - else { - d->m_contactIds.removeOne(myCardId); - } - } - d->m_showMyCard = enabled; - d->m_currentRow = -1; - - beginResetModel(); - reset(); - endResetModel(); - CNT_EXIT -} - -/*! - * Returns MyCard status: shown or not. - * - * \return true if MyCard is shown, false otherwise. - */ -bool CntListModel::myCardStatus() const -{ - return d->m_showMyCard; -} - -/*! - * Returns MyCard id. - * - * \return MyCard id. - */ -QContactLocalId CntListModel::myCardId() const -{ - return d->m_myCardId; -} - -/*! - * Gets the filtered list of the contact Ids in a sorted order - * - * \return Error status - */ -void CntListModel::updateContactIdsArray() -{ - CNT_ENTRY - - QContactDetailFilter* detailFilter = NULL; - - if (d->m_filter.type() == QContactFilter::ContactDetailFilter) { - detailFilter = static_cast(&d->m_filter); - } - - // special handling for all-contacts filter - if (detailFilter - && detailFilter->detailDefinitionName() == QContactType::DefinitionName - && detailFilter->detailFieldName() == QContactType::FieldType - && detailFilter->value() == QContactType::TypeContact) { - d->m_contactIds = d->m_cache->sortIdsByName(NULL); - } else if (detailFilter - && detailFilter->detailDefinitionName() == QContactDisplayLabel::DefinitionName - && detailFilter->detailFieldName() == QContactDisplayLabel::FieldLabel - && detailFilter->matchFlags() == Qt::MatchStartsWith) { - QStringList searchList = detailFilter->value().toStringList(); - d->m_contactIds = d->m_cache->sortIdsByName(searchList); - } else { - QSet filterIds = d->m_contactManager->contactIds(d->m_filter).toSet(); - d->m_contactIds = d->m_cache->sortIdsByName(&filterIds); - } - - //find MyCard contact and move it to the first position - QContactLocalId myCardId = d->m_myCardId; - if (myCardId > 0) { - // MyCard exists - d->m_contactIds.removeOne(myCardId); - if (d->m_showMyCard) { - d->m_contactIds.insert(0, myCardId); - } - } - else if (d->m_showMyCard) { - // create a placeholder for MyCard - d->m_contactIds.insert(0, dummyMyCardId); - } - CNT_EXIT -} - -/*! - * Read a full contact entry from the database for the row number. - * - * The entry at the requested row will have its full contact information - * (all fields) read from the database and returned as a QContact instance. - * - * \param row Row at which the sought contact entry is in this model. - * \return A newly constructed QContact instance for this entry - ownership - * is transferred to the caller. - * - */ -QContact CntListModel::contact(int row) const -{ - CNT_ENTRY - if (!validRowId(row) || d->m_contactIds[row] == dummyMyCardId) { - return QContact(); - } - CNT_EXIT - return d->m_contactManager->contact(d->m_contactIds[row]); -} - -/*! - * Verify specified row id is valid. - * - * \param row A row number - * \return bool indicating validity of row id - */ -bool CntListModel::validRowId(int row) const -{ - return (row >= 0 && row < rowCount()); -} - -/*! - * Fetch the id of the row containing the contact of the specified id. - * - * \param contactId The id of the contact - * \return the row id of the contact or -1 if no item matched. - */ -int CntListModel::rowId(const QContactLocalId &contactId) const -{ - return d->m_contactIds.indexOf(contactId); -} - -/*! - * Return the data to be used by the view for a display role. - * - * \param row The row of the item to return data about. - * \param column The column of the item to return data about. - * \return QVariant The data for the specified index. - */ -QVariant CntListModel::dataForRole(int row, int role) const -{ - CNT_ENTRY - QStringList list; - QString name; - QString infoText; - bool isSelfContact = false; - bool isNonEmptySelfContact = false; - - QContactLocalId id = d->m_contactIds[row]; - if (d->m_myCardId == id || dummyMyCardId == id) { - isSelfContact = true; - if (d->m_currentContact.id() == -1) { - // empty card - name = hbTrId("txt_phob_dblist_mycard"); - infoText = hbTrId("txt_phob_dblist_mycard_val_create_my_identity"); - } - else { - isNonEmptySelfContact = true; - } - } - - if (!isSelfContact || isNonEmptySelfContact) { - name = d->m_currentContact.name(); - if (name.isEmpty()) { - name = hbTrId("txt_phob_list_unnamed"); - } - infoText = d->m_currentContact.text(); - } - - if ( role == Qt::DisplayRole ) - { - list << d->m_Format->formattedText(name, d->m_filter); - } - else - { - list << name; - } - - if (!isNonEmptySelfContact) { - if (d->m_currentRowSetting == CntTwoRowsNameAndPhoneNumber) { - //add additional text only if user wants 2 rows in each name list item - list << infoText; - } - } - CNT_EXIT - return list; -} - -/*! - * Handle adding of contacts. - * - * \param contactIds Ids of contacts added. - */ -void CntListModel::handleAdded(const QList& contactIds) -{ - CNT_ENTRY - - // if contacts are added already, no need to do anything - bool newContacts = false; - for (int k = 0; k < contactIds.count() && !newContacts; k++) { - if (!d->m_contactIds.contains(contactIds.at(k))) { - newContacts = true; - } - } - if (!newContacts) { - return; - } - - // invalidate cached contact - d->m_currentRow = -1; - - QList oldIdList = d->m_contactIds; - updateContactIdsArray(); - - QList newRows; - for (int i = 0; i < d->m_contactIds.count(); i++) { - if (!oldIdList.contains(d->m_contactIds.at(i))) { - newRows.append(i); - } - } - - if (newRows.size() == 1) { - beginInsertRows(QModelIndex(), newRows.at(0), newRows.at(0)); - endInsertRows(); - } else { - beginResetModel(); - reset(); - endResetModel(); - } - - CNT_EXIT -} - -/*! - * Handle changes in contacts. - * - * \param contactIds Ids of contacts changed. - */ -void CntListModel::handleChanged(const QList& contactIds) -{ - CNT_ENTRY - - if (contactIds.count() == 0) { - return; - } - - //invalidate cached contact - d->m_currentRow = -1; - - int firstChangedContactPosBefore = rowId(contactIds.at(0)); - updateContactIdsArray(); - int firstChangedContactPosAfter = rowId(contactIds.at(0)); - - // if only one contact was updated and its position didn't change, - // refresh the corresponding row - if (contactIds.count() == 1 && - firstChangedContactPosBefore == firstChangedContactPosAfter && - firstChangedContactPosBefore >= 0) { - QModelIndex top = index(firstChangedContactPosBefore); - QModelIndex bottom = index(firstChangedContactPosBefore); - emit dataChanged(top, bottom); - } - else { - beginResetModel(); - reset(); - endResetModel(); - } - - CNT_EXIT -} - -/*! - * Handle removing of contacts. - * - * \param contactIds Ids of contacts removed. - */ -void CntListModel::handleRemoved(const QList& contactIds) -{ - CNT_ENTRY - - bool removeContacts = false; - QList idList = d->m_contactIds; - for (int k = 0; k < contactIds.count() && !removeContacts; k++) { - if(idList.contains(contactIds.at(k))) { - removeContacts = true; - } - } - if (!removeContacts) { - return; - } - - //Find contacts to remove (=rows) - QList removeRows; - for(int i = 0; i < contactIds.count(); i++) { - if (idList.contains(contactIds.at(i))) { - removeRows.append(rowId(contactIds.at(i))); - } - } - - // invalidate cached contact - d->m_currentRow = -1; - - int myCardRow = -1; - if (contactIds.contains(d->m_myCardId)) { - myCardRow = rowId(d->m_myCardId); - d->m_myCardId = 0; - } - - // remove rows starting from the bottom - qSort(removeRows.begin(), removeRows.end(), qGreater()); - foreach (int row, removeRows) { - if (row != myCardRow || !d->m_showMyCard) { - beginRemoveRows(QModelIndex(), row, row); - endRemoveRows(); - } - } - - foreach (QContactLocalId id, contactIds) { - d->m_contactIds.removeOne(id); - } - - if (myCardRow != -1 && d->m_showMyCard) { - d->m_contactIds.insert(0, dummyMyCardId); - QModelIndex index = createIndex(0, 0); - emit dataChanged(index, index); - } - - CNT_EXIT -} - -/*! - * Handle my card change. - * - * \param oldId Id of the old MyCard. - * \param newId Id of the new MyCard. - */ -void CntListModel::handleMyCardChanged(const QContactLocalId& /*oldId*/, const QContactLocalId& newId) -{ - CNT_ENTRY - - //invalidate cached contact - d->m_currentRow = -1; - d->m_myCardId = newId; - - updateContactIdsArray(); - - beginResetModel(); - reset(); - endResetModel(); - - CNT_EXIT -} - -/*! - * Handle added relationships. - * - * \param contactIds Ids of contacts added (group id and contact ids). - */ -void CntListModel::handleAddedRelationship(const QList& contactIds) -{ - CNT_ENTRY - - if (contactIds.contains(d->m_groupId)) { - foreach (QContactLocalId id, contactIds) { - if (id != d->m_groupId && !d->m_contactIds.contains(id)) { - // at least one new contact id has been added to this group, - // so update the model - updateRelationships(); - break; - } - } - } - - CNT_EXIT -} - -/*! - * Handle removed relationships. - * - * \param contactIds Ids of contacts removed from a relationship (group id and contact ids). - */ -void CntListModel::handleRemovedRelationship(const QList& contactIds) -{ - CNT_ENTRY - - if (contactIds.contains(d->m_groupId)) { - foreach (QContactLocalId id, contactIds) { - if (d->m_contactIds.contains(id)) { - // at least one new contact id has been removed from this group, - // so update the model - updateRelationships(); - break; - } - } - } - - CNT_EXIT -} - -/*! - * Updates the model to reflect changes in the relationships. - */ -void CntListModel::updateRelationships() -{ - CNT_ENTRY - - //invalidate cached contact - d->m_currentRow = -1; - - QList oldIdList = d->m_contactIds; - updateContactIdsArray(); - - // find all changed rows - QList newRows, removedRows; - for (int i = 0; i < d->m_contactIds.count(); i++) { - if (!oldIdList.contains(d->m_contactIds.at(i))) { - newRows.append(i); - } - } - for (int i = 0; i < oldIdList.count(); i++) { - if (!d->m_contactIds.contains(oldIdList.at(i))) { - removedRows.append(i); - } - } - - // currently only one-row-changes are handled with beginInsertRows/beginRemoveRows - // if there are more than one change, the whole model is reset - if (removedRows.count() == 1 && newRows.count() == 0) { - beginRemoveRows(QModelIndex(), removedRows.at(0), removedRows.at(0)); - endRemoveRows(); - } - else if (newRows.count() == 1 && removedRows.count() == 0) { - beginInsertRows(QModelIndex(), newRows.at(0), newRows.at(0)); - endInsertRows(); - } - else { - beginResetModel(); - endResetModel(); - } - - CNT_EXIT -} - -/*! -* Notify views that info for a contact has become -* available or has changed. -* -* \param contactId the id of the contact -*/ -void CntListModel::handleContactInfoUpdated(QContactLocalId contactId) -{ - CNT_ENTRY - - QModelIndex index = createIndex(rowId(contactId), 0); - if (index.row() == d->m_currentRow) { - d->m_currentRow = -1; - } - emit dataChanged(index, index); - - CNT_EXIT -} - -/*! -* Handle a change in how name list item should be represented -* -* \param key Central repository key -* \param value New value in the key -*/ -void CntListModel::handleRowSettingChanged(const XQSettingsKey& /*key*/, const QVariant& value) -{ - bool ok = false; - int newSetting = value.toInt(&ok); - if (ok) { - d->m_currentRowSetting = newSetting; - beginResetModel(); - reset(); - endResetModel(); - } -} - -/*! -* Handle a change in data -*/ -void CntListModel::refreshModel() -{ - d->m_currentRow = -1; - - updateContactIdsArray(); - - beginResetModel(); - reset(); - endResetModel(); -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/src/cntnamefetcher.cpp --- a/phonebookengines/cntlistmodel/src/cntnamefetcher.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,643 +0,0 @@ -/* -* Copyright (c) 2010 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: Private data and helper classes used by class CntCache. -* -*/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "cntnamefetcher.h" - -// constants used when fetching names from CntSrv -#define KCntSearchResultList 99 -#define KCntOpenDataBase 100 -_LIT(KCntServerExe, "CNTSRV.EXE"); -_LIT(KCntServerName, "CNTSRV"); -const TInt KAsyncMessageSlots = 6; -const TInt KCntServerMajorVersionNumber=1; -const TInt KCntServerMinorVersionNumber=1; -const TInt KCntServerBuildVersionNumber=1; -static const QEvent::Type CntAsynchOperation = QEvent::User; - -// constants used for file cache -static const QString cacheFolder = "20022EF9"; -static const QString cacheFilename = "contactcache.dat"; - -/*! - Internal class used by CntSrvConnection to issues requests to CntSrv. - */ -class CntSrvSession : public RSessionBase -{ -public: - CntSrvSession() { mConnected = false; } - ~CntSrvSession() { RHandleBase::Close(); } - void executeSqlQueryL(const TDesC &sqlQuery, QList &names, CntNameOrder nameFormat, int sizeHintKB); - -private: - void connectCntSrvL(); - -private: - bool mConnected; -}; - -CntSrvConnection::CntSrvConnection() - : mSession(NULL), - mIsAsynchronous(false) -{ -} - -CntSrvConnection::~CntSrvConnection() -{ - disconnect(); - - if (mThread.isRunning()) { - mThread.quit(); - mThread.wait(); - } - - delete mSession; - - mNames.clear(); -} - -void CntSrvConnection::setAsynchronous() -{ - mIsAsynchronous = true; - mThread.start(); - moveToThread(&mThread); -} - -bool CntSrvConnection::executeSqlQuery(const QString &sqlQuery, CntNameOrder nameFormat, int sizeHintKB) -{ - CNT_ENTRY - - if (!mSession) { - mSession = new CntSrvSession(); - } - - if (mIsAsynchronous) { - mSqlQuery = sqlQuery; - mNameFormat = nameFormat; - mSizeHintKB = sizeHintKB; - HbApplication::instance()->postEvent(this, new QEvent(CntAsynchOperation)); - } else { - mNames.clear(); - TPtrC queryPtr(sqlQuery.utf16(), sqlQuery.length()); - TRAPD(err, mSession->executeSqlQueryL(queryPtr, mNames, nameFormat, sizeHintKB)); - if (err != KErrNone) { - qDeleteAll(mNames); - mNames.clear(); - CNT_EXIT - return false; - } - } - - CNT_EXIT - - return true; -} - -bool CntSrvConnection::event(QEvent *event) -{ - if (event->type() == CntAsynchOperation) { - CNT_ENTRY - - mNames.clear(); - TPtrC ptr(mSqlQuery.utf16(), mSqlQuery.length()); - TRAPD(err, mSession->executeSqlQueryL(ptr, mNames, mNameFormat, mSizeHintKB)); - if (err != KErrNone) { - qDeleteAll(mNames); - mNames.clear(); - } - emit namesRead(); - qStableSort(mNames.begin(), mNames.end(), CntNameFetcher::compareNames); - delete mSession; - mSession = NULL; - emit namesSorted(); - - CNT_EXIT - - return true; - } - - return QObject::event(event); -} - -/*! - Executes a special SQL query: the first column must be the contact id and - the subsequent columns must be varchar fields. - - \param sqlQuery the SQL to execute - \param names the list where the results will be stored - \param nameFormat the format the names should be stored in - \param sizeHintKB the expected size of the buffer needed to fit the results; a too - small value will effectively double the fetch time, since the - buffer is then resized and the data refetched a second time - */ -void CntSrvSession::executeSqlQueryL(const TDesC& sqlQuery, QList &names, CntNameOrder nameFormat, int sizeHintKB) -{ - int listSize = 0; - - // read the ids and names from the database - if (!mConnected) { - connectCntSrvL(); - } - - // allocate tmeporary buffer - TInt bufferSize = sizeHintKB * 1024; - CBufFlat* buffer = CBufFlat::NewL(256); - CleanupStack::PushL(buffer); - - // try to fetch the results, if the fetch fails with - // a positive value, it means the buffer was too small - // in this case the buffer is resized and the results - // are fetched again - for (TInt tries = 0; tries < 2 && bufferSize > 0; ++tries) { - buffer->ResizeL(bufferSize); - TPtr8 bufferPtr = buffer->Ptr(0); - TIpcArgs args; - args.Set(0, &bufferPtr); - args.Set(1, &sqlQuery); - bufferSize = SendReceive(KCntSearchResultList, args); - CNT_LOG_ARGS("buffer size =" << bufferSize) - User::LeaveIfError(bufferSize); - } - - // store the formatted names into the list - RBufReadStream readStream; - TInt id; - TBuf<256> firstName; - TBuf<256> lastName; - - readStream.Open(*buffer); - for (int i = 0; (id = readStream.ReadInt32L()) != 0; ++i) { - readStream >> firstName; - readStream >> lastName; - CntNameCacheItem* item = new (ELeave) CntNameCacheItem( - id, - QString::fromUtf16(firstName.Ptr(), firstName.Length()), - QString::fromUtf16(lastName.Ptr(), lastName.Length()), - nameFormat); - if (i >= listSize - 1) { - // if the list is runnning out of space, resize it; - // initial size is 1000 and after that it doubles - // every time it runs out of space - if (listSize == 0) { - listSize = 1000; - } else { - listSize *= 2; - } - QT_TRY { - names.reserve(listSize); - } QT_CATCH (...) { - // clean up and return - CleanupStack::PopAndDestroy(buffer); - qDeleteAll(names); - names.clear(); - return; - } - } - names.append(item); - } - - CleanupStack::PopAndDestroy(buffer); -} - -/*! - Connect to / create a contacts server session. - */ -void CntSrvSession::connectCntSrvL() -{ - // Assume the server is already running and attempt to create a session - // with a maximum of KAsyncMessageSlots message slots. - TInt err = CreateSession(KCntServerName, - TVersion(KCntServerMajorVersionNumber, KCntServerMinorVersionNumber, KCntServerBuildVersionNumber), - KAsyncMessageSlots); - - // Server is not running - if (err == KErrNotFound) { - // Use the RProcess API to start the server. - RProcess server; - User::LeaveIfError(server.Create(KCntServerExe, KNullDesC)); - - // Enforce server to be at system default priority EPriorityForeground - server.SetPriority(EPriorityForeground); - - // Synchronize with the server. - TRequestStatus reqStatus; - server.Rendezvous(reqStatus); - server.Resume(); - - // Server will call the reciprocal static synchronization call. - User::WaitForRequest(reqStatus); - server.Close(); - User::LeaveIfError(reqStatus.Int()); - - // Create the server session. - User::LeaveIfError(CreateSession(KCntServerName, - TVersion(KCntServerMajorVersionNumber, KCntServerMinorVersionNumber, KCntServerBuildVersionNumber), - KAsyncMessageSlots)); - } else { - User::LeaveIfError(err); - } - - TIpcArgs args; - args.Set(0, &KNullDesC); - User::LeaveIfError(SendReceive(KCntOpenDataBase, args)); - - mConnected = true; -} - -/*! - Creates a CntNameFetcher object. - */ -CntNameFetcher::CntNameFetcher() - : mDbConnection(NULL), - mAsynchDbConnection(NULL), - mSettingsManager(NULL), - mNameFormatSetting(NULL), - mBufferSizeEstimate(0) -{ - CNT_ENTRY - - // get name format setting and listen to changes - mSettingsManager = new XQSettingsManager(); - mNameFormatSetting = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, KCRCntSettings.iUid, KCntNameOrdering); - mNameFormat = static_cast(mSettingsManager->readItemValue(*mNameFormatSetting, XQSettingsManager::TypeInt).toInt()); - mSettingsManager->startMonitoring(*mNameFormatSetting, XQSettingsManager::TypeInt); - connect(mSettingsManager, SIGNAL(valueChanged(const XQSettingsKey&, const QVariant&)), this, SLOT(setNameFormat(const XQSettingsKey&, const QVariant&))); - - // connect to contacts server - mDbConnection = new CntSrvConnection(); - - CNT_EXIT -} - -/*! - Destroys a CntNameFetcher object. - */ -CntNameFetcher::~CntNameFetcher() -{ - CNT_ENTRY - - delete mSettingsManager; - delete mNameFormatSetting; - delete mDbConnection; - delete mAsynchDbConnection; - - CNT_EXIT -} - -/*! - Reads names from the file cache. - - \return true if the names were read successfully from the cache file - - */ -bool CntNameFetcher::readNamesFromCache(QList &names) -{ - CNT_ENTRY - - bool success = true; - quint32 itemCount; - quint32 nameFormat; - - QFile cacheFile(XQUtils::phoneMemoryRootPath() + cacheFolder + "\\" + cacheFilename); - if (!cacheFile.open(QIODevice::ReadOnly)) { - return false; - } - - QDataStream in(&cacheFile); - - mBufferSizeEstimate = 0; - QT_TRY { - // read header: nr of items, name format - in >> itemCount; - in >> nameFormat; - names.reserve(itemCount); - - // populate list with names - while (itemCount-- > 0) { - CntNameCacheItem *item = CntNameCacheItem::internalize(in, (CntNameOrder) nameFormat); - names.append(item); - mBufferSizeEstimate += 4 + 2 * item->name().length(); - } - } QT_CATCH (...) { - qDeleteAll(names); - names.clear(); - success = false; - } - - cacheFile.close(); - - CNT_EXIT - - return success; -} - -/*! - Write names to the file cache. - */ -bool CntNameFetcher::writeNamesToCache(const QList &names) const -{ - CNT_ENTRY - - bool success = true; - - // create folder for cache file if it does not already exist - QString path = XQUtils::phoneMemoryRootPath() + cacheFolder; - if (!QDir(path).exists()) { - QDir dir(XQUtils::phoneMemoryRootPath()); - if (!dir.mkdir(cacheFolder)) { - CNT_EXIT_ARGS("failed to create folder: " << path) - return false; - } - - // have to use native Symbian code to make the dir hidden - RFs fs; - fs.Connect(); - TPtrC pathPtr(path.utf16(), path.length()); - if (fs.SetAtt(pathPtr, KEntryAttHidden, 0) != KErrNone) { - fs.Close(); - return false; - } - fs.Close(); - } - - // open cache file for writing - QFile cacheFile(XQUtils::phoneMemoryRootPath() + cacheFolder + "\\" + cacheFilename); - if (!cacheFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { - CNT_EXIT_ARGS("failed to create file") - return false; - } - QDataStream out(&cacheFile); - - // write the names to the cache file - QT_TRY { - // write header - out << names.size(); - out << (quint32) mNameFormat; - - // write list with names - foreach (CntNameCacheItem* name, names) { - name->externalize(out); - } - } QT_CATCH (...) { - success = false; - } - - cacheFile.close(); - - CNT_EXIT - - return success; -} - -/*! - Reads the name of one contact from the contact database synchronously. - - \param contactId the id of the contact - */ -CntNameCacheItem* CntNameFetcher::readOneName(QContactLocalId contactId) const -{ - CNT_ENTRY - - QString sqlQuery = QString("SELECT contact_id, first_name, last_name FROM contact WHERE (type_flags>>24)<=1 AND contact_id=%1").arg(contactId); - mDbConnection->executeSqlQuery(sqlQuery, mNameFormat, 2); - - if (mDbConnection->names().size() == 0) { - return NULL; - } - - CNT_EXIT - - return mDbConnection->names().at(0); -} - -/*! - Reads the names of all contacts from the contact database asynchronously. - */ -void CntNameFetcher::readAllNamesAsynch() -{ - CNT_ENTRY - - if (mAsynchDbConnection != NULL) { - // an asynch fetch is already in progress, so no need to start a new one - return; - } - - if (mBufferSizeEstimate == 0) { - mBufferSizeEstimate = 240 * 1024; - } - - CNT_LOG_ARGS("buffer size =" << mBufferSizeEstimate) - - mAsynchDbConnection = new CntSrvConnection(); - mAsynchDbConnection->setAsynchronous(); - connect(mAsynchDbConnection, SIGNAL(namesRead()), this, SIGNAL(databaseAccessComplete())); - connect(mAsynchDbConnection, SIGNAL(namesSorted()), this, SLOT(sendCompletionSignal())); - mAsynchDbConnection->executeSqlQuery("SELECT contact_id, first_name, last_name FROM contact WHERE (type_flags>>24)<=1", mNameFormat, 16 + mBufferSizeEstimate / 1024); - - CNT_EXIT -} - -/*! - Sorts the names quickly and in a locale aware manner. - */ -void CntNameFetcher::sortNames(QList &names) const -{ - CNT_ENTRY - - qStableSort(names.begin(), names.end(), CntNameFetcher::compareNames); - - CNT_EXIT -} - -/*! - Compares a pair of contact names and returns true if the first - one should be presented before the second one in a list. This - static function is used e.g. when sorting lists of names. - */ -bool CntNameFetcher::compareNames(const CntNameCacheItem* a, const CntNameCacheItem* b) -{ - QString aName = a->name(); - QString bName = b->name(); - - if (aName.isEmpty()) { - return false; - } else if (bName.isEmpty()) { - return true; - } - - return (HbStringUtil::compareC(aName, bName) < 0); -} - -/*! - Notifies clients that the name format has changed. This function is called by the framework - if the name format settings is changed, see the constructor. - */ -void CntNameFetcher::setNameFormat(const XQSettingsKey &/*key*/, const QVariant &value) -{ - CNT_ENTRY - - bool ok = false; - CntNameOrder newNameFormat = static_cast(value.toInt(&ok)); - if (ok && newNameFormat != mNameFormat) { - mNameFormat = newNameFormat; - emit nameFormatChanged(mNameFormat); - } - - CNT_EXIT -} - -/*! - Emits the results of a completed asynch database operation. - */ -void CntNameFetcher::sendCompletionSignal() -{ - CNT_ENTRY - - emit namesAvailable(mAsynchDbConnection->names()); - - delete mAsynchDbConnection; - mAsynchDbConnection = NULL; - - CNT_EXIT -} - -/*! - Creates a CntNameCacheItem object. - */ -CntNameCacheItem::CntNameCacheItem(QContactLocalId id, const QString& firstName, const QString& lastName, CntNameOrder nameFormat) -{ - mContactId = id; - setFormattedName(firstName, lastName, nameFormat); -} - -/*! - Destroys a CntNameCacheItem object. - */ -CntNameCacheItem::~CntNameCacheItem() -{ -} - -/*! - Changes the format used to present the name. - */ -void CntNameCacheItem::setNameFormat(CntNameOrder newFormat) -{ - QString firstName = mName.mid(mFirstNamePosition&0xffff, mFirstNamePosition>>16); - QString lastName = mName.mid(mLastNamePosition&0xffff, mLastNamePosition>>16); - setFormattedName(firstName, lastName, newFormat); -} - -/*! - Copies the contents of the other cache item to this one. - */ -void CntNameCacheItem::operator=(const CntNameCacheItem &other) -{ - mContactId = other.mContactId; - mFirstNamePosition = other.mFirstNamePosition; - mLastNamePosition = other.mLastNamePosition; - mName = other.mName; -} - -/*! - Externalizes a CntNameCacheItem object. - */ -void CntNameCacheItem::externalize(QDataStream &stream) -{ - stream << mContactId; - stream << mFirstNamePosition; - stream << mLastNamePosition; - stream << mName; -} - -/*! - Internalizes a CntNameCacheItem object. - */ -CntNameCacheItem* CntNameCacheItem::internalize(QDataStream &stream, CntNameOrder nameFormat) -{ - quint32 id; - quint32 firstNamePosition; - quint32 lastNamePosition; - QString name; - - stream >> id; - stream >> firstNamePosition; - stream >> lastNamePosition; - stream >> name; - - QString firstName = name.mid(firstNamePosition&0xffff, firstNamePosition>>16); - QString lastName = name.mid(lastNamePosition&0xffff, lastNamePosition>>16); - - return new CntNameCacheItem(id, firstName, lastName, nameFormat); -} - -/*! - Sets the formatted name and positions of the first name and last name, - according to the name format in the parameter. - */ -void CntNameCacheItem::setFormattedName(const QString& firstName, const QString& lastName, CntNameOrder nameFormat) -{ - int firstNameLength = firstName.length(); - int lastNameLength = lastName.length(); - - if (lastNameLength == 0) { - mName = firstName; - mFirstNamePosition = firstNameLength << 16; - mLastNamePosition = 0; - } else if (firstNameLength == 0) { - mName = lastName; - mFirstNamePosition = 0; - mLastNamePosition = lastNameLength << 16; - } else { - if (nameFormat == CntOrderLastFirst) { - mName = lastName + " " + firstName; - mFirstNamePosition = (firstNameLength << 16) | (lastNameLength + 1); - mLastNamePosition = (lastNameLength << 16); - } else if (nameFormat == CntOrderLastCommaFirst) { - mName = lastName + ", " + firstName; - mFirstNamePosition = (firstNameLength << 16) | (lastNameLength + 2); - mLastNamePosition = (lastNameLength << 16); - } else { - mName = firstName + " " + lastName; - mFirstNamePosition = (firstNameLength << 16); - mLastNamePosition = (lastNameLength << 16) | (firstNameLength + 1); - } - } -} - -QString CntNameCacheItem::firstName() const -{ - return mName.mid(mFirstNamePosition&0xffff, mFirstNamePosition>>16); -} - -QString CntNameCacheItem::lastName() const -{ - return mName.mid(mLastNamePosition&0xffff, mLastNamePosition>>16); -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/src/cntpresenceinfoprovider.cpp --- a/phonebookengines/cntlistmodel/src/cntpresenceinfoprovider.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,172 +0,0 @@ -/* -* Copyright (c) 2010 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: Presence info provider plugin for CntListModel. It can provide -* the presence information of a contact (icon2 field). -* -*/ - -#include -#include "cntpresenceinfoprovider.h" - -#include -#include - -CntPresenceInfoProvider::CntPresenceInfoProvider() : - iReader(NULL), - mManager(NULL) -{ - iReader = PrcPresenceReader::createReader(); - connect(iReader, SIGNAL(signalPresenceNotification(bool , PrcPresenceBuddyInfoQt*)), - this, SLOT(handlePresenceUpdate(bool , PrcPresenceBuddyInfoQt*))); - - mManager = new QContactManager("symbian"); -} - -CntPresenceInfoProvider::~CntPresenceInfoProvider() -{ - delete iReader; - delete mManager; -} - -/*! - /return the info fields supported by this provider - */ -ContactInfoFields CntPresenceInfoProvider::supportedFields() const -{ - // this provider has only info for the icon2 field - return ContactInfoIcon2Field; -} - -/*! - The contact contains all the info this provider needs, so signals with the requested info - fields are emitted immediately. - - /param contact the contact for which info is requested - /param requestedInfo one or more of the flags in ContactInfoFields - */ -void CntPresenceInfoProvider::requestInfo(const QContact& contact, ContactInfoFields requestedInfo) -{ - if (requestedInfo & ContactInfoIcon2Field) - { - QList accounts = contact.details(); - - QList buddies; - - foreach (QContactOnlineAccount account, accounts) - { - QString fullAccount = account.serviceProvider() + ':' + account.accountUri(); - PrcPresenceBuddyInfoQt* buddy = iReader->presenceInfo(fullAccount); - - if (buddy) - { - buddies.append(buddy); - if (!mBuddyMap.contains(buddy->buddyId())) - { - mBuddyMap.insert(buddy->buddyId(), contact.localId()); - iReader->subscribePresenceBuddyChange(buddy->buddyId()); - } - } - } - - if (buddies.count()) - { - QString icon = parsePresence(buddies); - - if (!icon.isEmpty()) - { - emit infoFieldReady(this, contact.localId(), ContactInfoIcon2Field, icon); - } - - qDeleteAll(buddies); - } - } -} - -/*! - Update presence icon for contact if needed. Stop listening to presence changes for buddy - if online account detail was deleted. - - /param aErrorCode error (if any) - /param aPresenceBuddyInfo presence buddy that was updated - */ -void CntPresenceInfoProvider::handlePresenceUpdate(bool aSuccess, PrcPresenceBuddyInfoQt* aPresenceBuddyInfo) -{ - if (aSuccess && aPresenceBuddyInfo != NULL) - { - QContactLocalId id = mBuddyMap.value(aPresenceBuddyInfo->buddyId()); - QContact contact = mManager->contact(id); - - QList accounts = contact.details(); - - QList buddies; - bool accountFound = false; - - foreach (QContactOnlineAccount account, accounts) - { - QString fullAccount = account.serviceProvider() + ':' + account.accountUri(); - PrcPresenceBuddyInfoQt* buddy = iReader->presenceInfo(fullAccount); - - if (buddy) - { - buddies.append(buddy); - - if (fullAccount == aPresenceBuddyInfo->buddyId()) - { - accountFound = true; - } - - if (!mBuddyMap.contains(buddy->buddyId())) - { - mBuddyMap.insert(buddy->buddyId(), contact.localId()); - iReader->subscribePresenceBuddyChange(buddy->buddyId()); - } - } - } - - // Account was removed, no need to listen to presence changes anymore - if (accounts.isEmpty() || !accountFound) - { - mBuddyMap.remove(aPresenceBuddyInfo->buddyId()); - iReader->unSubscribePresenceBuddyChange(aPresenceBuddyInfo->buddyId()); - } - - if (id > 0) - { - QString icon = parsePresence(buddies); - emit infoFieldReady(this, id, ContactInfoIcon2Field, icon); - } - - qDeleteAll(buddies); - } -} - -/*! - Parse the required presence icon from multiple accounts. - - /param buddyList list of buddies - */ -QString CntPresenceInfoProvider::parsePresence(const QList& buddyList) -{ - foreach (PrcPresenceBuddyInfoQt* buddy, buddyList) - { - PrcPresenceBuddyInfoQt::AvailabilityValues availability = buddy->availability(); - - if (availability == PrcPresenceBuddyInfoQt::PrcAvailable) - { - return QString("qtg_small_online"); - } - } - - return QString(); -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/runperftests.bat --- a/phonebookengines/cntlistmodel/tsrc/runperftests.bat Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -@rem -@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -@rem All rights reserved. -@rem This component and the accompanying materials are made available -@rem under the terms of "Eclipse Public License v1.0" -@rem which accompanies this distribution, and is available -@rem at the URL "http://www.eclipse.org/legal/epl-v10.html". -@rem -@rem Initial Contributors: -@rem Nokia Corporation - initial contribution. -@rem -@rem Contributors: -@rem -@rem Description: -@rem - -echo OFF - -del \epoc32\winscw\c\private\e84eae91\mt_performance.log -\epoc32\release\winscw\urel\mt_performance.exe -o mt_performance.log -type \epoc32\winscw\c\private\e84eae91\mt_performance.log - - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/image1.png Binary file phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/image1.png has changed diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/image2.png Binary file phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/image2.png has changed diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/inc/testrunner.h --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/inc/testrunner.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* -* 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 TESTRUNNER_H -#define TESTRUNNER_H - -#include - - -class TestRunner : public QXmlDefaultHandler -{ -public: // Constructors and destructor - TestRunner(const QString& name); - ~TestRunner(); - -public: // New functions - - int runTests(QObject& testObject); - void printResults(); - -protected: // From QXmlContentHandler - bool startElement( - const QString& namespaceURI, - const QString& localName, - const QString& qName, - const QXmlAttributes& atts); - - bool endElement( - const QString& namespaceURI, - const QString& localName, - const QString& qName); - - bool characters(const QString& ch); - -private: // New functions - - void parse(const QString& fileName); - -private: // Data - QStringList mTestRunParams; - QString mHomeDir; - int mTestCount; - QStringList mErrors; - bool mParsingIncidentElement; - bool mParsingDescriptionElement; - bool mCurrentTestFailed; - QString mCurrentTestName; - QString mCurrentTestFile; - int mCurrentTestFailureLine; -}; - - -#endif // TESTRUNNER_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntcache.h --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntcache.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* -* 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 -#include -#include - -QTM_USE_NAMESPACE - -static const int CntTestContacts = 6; - -class TestCntCache : public QObject -{ - Q_OBJECT - -private: - void cleanDatabase(); - QContact createContact(QString firstName, QString lastName, QString phoneNumber, QString imageName); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void construction(); - void fetchContactInfo(); - void clearCache(); - -private: - QContactManager *mContactManager; - QContact mContacts[CntTestContacts]; - QList mContactOrder; -}; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntdefaultinfoprovider.h --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntdefaultinfoprovider.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* -* 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 -#include -#include - -class CntDefaultInfoProvider; - -QTM_USE_NAMESPACE - -class TestCntDefaultInfoProvider : public QObject -{ - Q_OBJECT - -private slots: - void initTestCase(); - void create(); - - void testSupportedFields(); - void testRequestInfo(); - - void cleanupTestCase(); - -private: - CntDefaultInfoProvider *mCntDefaultInfoProvider; - -}; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntdisplaytextformatter.h --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntdisplaytextformatter.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* -* 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 -#include -#include - -QTM_BEGIN_NAMESPACE -class QContactDetailFilter; -QTM_END_NAMESPACE - -QTM_USE_NAMESPACE - -class TestCntDisplayTextFormatter : public QObject -{ - Q_OBJECT - -private slots: - void testFormatter(); -}; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntlistmodel.h --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntlistmodel.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* -* 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 -#include -#include - -QTM_BEGIN_NAMESPACE -class QContactManager; -QTM_END_NAMESPACE - -QTM_USE_NAMESPACE - -class CntListModel; -class ModelListener; - -class TestCntListModel : public QObject -{ - Q_OBJECT - -private: - void contactReady(int start, int end); - QContact createContact(const QString& firstName, const QString& lastName); - void addGroupMember(const QContact& group, const QContact& contact); - void removeGroupMember(const QContact& group, const QContact& contact); - -private slots: - void initTestCase(); - void create(); - - void data(); - void rowCount(); - - void contact(); - void contactId(); - void indexOfContact(); - void indexOfContactId(); - void contactManager(); - void setFilter(); - void myCard(); - - void rowId(); - void dataForDisplayRole(); - - void handleAdded(); - void handleChanged(); - void handleRemoved(); - void handleMyCardChanged(); - void handleRelationships(); - - void cleanupTestCase(); - -private: - QContactManager *mManager; - CntListModel *mCntModel; - ModelListener *mModelListener; - bool mDataReady; - -friend class ModelListener; -}; - -class ModelListener : public QObject -{ - Q_OBJECT - -public: - ModelListener(TestCntListModel* parent); - -private slots: - void onDataChanged(QModelIndex start, QModelIndex end); - -private: - TestCntListModel* mParent; -}; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntpresenceinfoprovider.h --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntpresenceinfoprovider.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* -* 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 -#include -#include - -class CntPresenceInfoProvider; - -QTM_USE_NAMESPACE - -class TestCntPresenceInfoProvider : public QObject -{ - Q_OBJECT - -private slots: - void initTestCase(); - void create(); - - void testSupportedFields(); - void testRequestInfo(); - - void testHandlePresenceUpdate(); - - void testParsePresence(); - - void cleanupTestCase(); - -private: - CntPresenceInfoProvider *mCntPresenceInfoProvider; - -}; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/runtest.cmd --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/runtest.cmd Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -@echo off -rem -rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -rem All rights reserved. -rem This component and the accompanying materials are made available -rem under the terms of "Eclipse Public License v1.0" -rem which accompanies this distribution, and is available -rem at the URL "http://www.eclipse.org/legal/epl-v10.html". -rem -rem Initial Contributors: -rem Nokia Corporation - initial contribution. -rem -rem Contributors: -rem -rem Description: -rem -@echo on - -call del MON.sym -call del MON.dat -call del profile.txt - -call qmake -call sbs reallyclean -call sbs -c winscw_udeb -call sbs -c winscw_udeb -call qmake -call ctcwrap -i d -C "EXCLUDE+moc_*.cpp" -C "EXCLUDE+ut_*.*" sbs -c winscw_udeb - -call \epoc32\release\winscw\udeb\ut_cntlistmodel.exe -noprompt -call ctcpost MON.sym MON.dat -p profile.txt -call ctc2html -i profile.txt -nsb diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/src/main.cpp --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/src/main.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* -* 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 "testrunner.h" - -#include "ut_cntlistmodel.h" -#include "ut_cntcache.h" -#include "ut_cntpresenceinfoprovider.h" -#include "ut_cntdefaultinfoprovider.h" -#include "ut_cntdisplaytextformatter.h" - -#include - -int main(int argc, char *argv[]) -{ - bool promptOnExit(true); - for (int i=0; i -#include -#include - -const char testFunctionElement[] = "TestFunction"; -const char incidentElement[] = "Incident"; -const char descriptionElement[] = "Description"; -const char nameAttr[] = "name"; -const char typeAttr[] = "type"; -const char fileAttr[] = "file"; -const char lineAttr[] = "line"; -const char attrValueFail[] = "fail"; - - -TestRunner::TestRunner(const QString& name) -: mTestCount(0), - mParsingIncidentElement(false), - mParsingDescriptionElement(false), - mCurrentTestFailed(false), - mCurrentTestFailureLine(0) -{ - mTestRunParams.append(name); - mTestRunParams.append("-xml"); - mTestRunParams.append("-o"); - mHomeDir = QDir::homePath(); - mTestRunParams.append(QString()); // Initial result file name - - if (!mHomeDir.endsWith(QString::fromAscii("/"))) - mHomeDir += QString::fromAscii("/"); -} - -TestRunner::~TestRunner() -{ -} - -int TestRunner::runTests(QObject& testObject) -{ - QString className(testObject.metaObject()->className()); - printf("Running tests for %s ... ", className.toUtf8().data()); - QString resultFileName = mHomeDir + className + ".xml"; - mTestRunParams.replace(mTestRunParams.count()-1,resultFileName); - int errorsBefore = mErrors.count(); - int error = QTest::qExec(&testObject, mTestRunParams); - parse(resultFileName); - printf("Failures: %d\n",mErrors.count()-errorsBefore); - fflush(stdout); - return error; -} - -void TestRunner::printResults() -{ - printf("\nTests executed: %d\n",mTestCount); - if (mErrors.count() > 0) { - printf("Failures (%d):\n", mErrors.count()); - foreach(QString error, mErrors) { - printf("\n%s", error.toUtf8().data()); - } - printf("\n"); - } else { - printf("All passed.\n\n"); - } - fflush(stdout); -} - -void TestRunner::parse(const QString& fileName) -{ - QFile file(fileName); - QXmlInputSource inputSource(&file); - QXmlSimpleReader reader; - reader.setContentHandler(this); - reader.parse(inputSource); -} - -bool TestRunner::startElement( - const QString& /*namespaceURI*/, - const QString& /*localName*/, - const QString& qName, - const QXmlAttributes& atts) -{ - if (qName == QString::fromAscii(testFunctionElement)) { - mTestCount++; - mCurrentTestName = atts.value(QString::fromAscii(nameAttr)); - return true; - } - if (qName == QString::fromAscii(incidentElement)) { - mParsingIncidentElement = true; - if (atts.value(QString::fromAscii(typeAttr)) == QString::fromAscii(attrValueFail)) { - mCurrentTestFailed = true; - mCurrentTestFile = atts.value(QString::fromAscii(fileAttr)); - mCurrentTestFailureLine = atts.value(QString::fromAscii(lineAttr)).toInt(); - } - return true; - } - mParsingDescriptionElement = - (qName == QString::fromAscii(descriptionElement)); - return true; -} - -bool TestRunner::endElement( - const QString& /*namespaceURI*/, - const QString& /*localName*/, - const QString& qName) -{ - if (qName == QString::fromAscii(incidentElement)) { - mParsingIncidentElement = false; - mCurrentTestFailed = false; - return true; - } - if (qName == QString::fromAscii(descriptionElement)) { - mParsingDescriptionElement = false; - } - return true; -} - -bool TestRunner::characters(const QString& ch) -{ - if (mParsingIncidentElement && - mParsingDescriptionElement && - mCurrentTestFailed) { - QByteArray testResult = mCurrentTestName.toAscii() + " failed:\n"; - testResult += "File: "; - testResult += mCurrentTestFile.toAscii(); - testResult += "\n"; - testResult += "Line: "; - testResult += QByteArray::number(mCurrentTestFailureLine); - testResult += "\n"; - testResult += "Reason: "; - testResult += ch.toAscii(); - testResult += "\n"; - mErrors.append(QString::fromAscii(testResult.data())); - } - return true; -} - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntcache.cpp --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntcache.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,231 +0,0 @@ -/* -* 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_cntcache.h" -#include "cntcache.h" -#include "cntcache_p.h" - -void TestCntCache::initTestCase() -{ - // get contact manager - mContactManager = new QContactManager("symbian"); - - // start with a clean database - cleanDatabase(); - - // TODO: This test needs to be run with the default provider, so when there is a mechanism - // to variate the info provider, use that mechanism here to select the default provider. - - // create contacts; twins with same image at indexes 0,5 and 2,3 (good for increasing branch coverage) - mContacts[0] = createContact("Joe", "Doe", "1234567", "c:/data/images/image1.png"); - mContacts[1] = createContact("Marja", "Meikalainen", "7654321", ""); - mContacts[2] = createContact("Sven", "Dufva", "12121212", "c:/data/images/image2.png"); - mContacts[3] = createContact("Twin", "Dufva", "12121212", "c:/data/images/image2.png"); - mContacts[4] = createContact("", "", "123123", ""); - mContacts[5] = createContact("Twin", "Doe", "1234568", "c:/data/images/image1.png"); -} - -void TestCntCache::cleanupTestCase() -{ - // end with a clean database - cleanDatabase(); - - delete mContactManager; - mContactManager = NULL; -} - -/* - Test case: Constructing and deleting the cache. - */ -void TestCntCache::construction() -{ - // test creation - QPointer cache = CntCache::instance(); - QVERIFY(cache != NULL); - QPointer worker = cache->mWorker; - QVERIFY(worker != NULL); - - // test singleton property - QVERIFY(cache == CntCache::instance()); - - // test data members - QVERIFY(cache->mContactManager != NULL); - QVERIFY(worker->mContactManager != NULL); - QVERIFY(worker->mThumbnailManager != NULL); - QVERIFY(worker->mInfoProviders.count() >= 1); - - // test deletion - cache->onShutdown(); - QVERIFY(CntCache::mInstance == NULL); -} - -/* - Test case: Fetch contact info. - - Fetches all six contacts in two batches of four and two contacts. The contacts are - divided up so that one pair of twins is in the same batch and the other pair of twins - has one twin in each batch. This maximizes branch coverage. - */ -void TestCntCache::fetchContactInfo() -{ - CntContactInfo info[CntTestContacts]; // info for each of the contacts - - // create cache and attach a signal spy to it - CntCache* cache = CntCache::instance(); - QSignalSpy spy(cache, SIGNAL(contactInfoUpdated(QContactLocalId))); - - // create list of ids - QList idList; - for (int i = 0; i < CntTestContacts; ++i) { - idList << mContacts[i].localId(); - } - - // fetch three of the contacts in rapid succession, one of them twice - info[1] = cache->fetchContactInfo(1, idList); - info[0] = cache->fetchContactInfo(0, idList); - info[4] = cache->fetchContactInfo(4, idList); - info[0] = cache->fetchContactInfo(0, idList); - info[5] = cache->fetchContactInfo(5, idList); - - // check that names are ok - QVERIFY(info[1].name() == mContacts[1].displayLabel()); - QVERIFY(info[0].name() == mContacts[0].displayLabel()); - QVERIFY(info[4].name() == mContacts[4].displayLabel()); - QVERIFY(info[5].name() == mContacts[5].displayLabel()); - - // wait for possible signals to arrive (in the future, all info could be returned immediately) - QTest::qWait(4000); - spy.clear(); - - // fetch all contacts -- they should be cached now by the read-ahead mechanism - for (int i = 0; i < CntTestContacts; ++i) { - info[i] = cache->fetchContactInfo(i, idList); - } - - // confirm that no further signals from cache (i.e. they were all really cached) - QTest::qWait(2000); - QVERIFY(spy.count() == 0); - - // confirm that returned data equals created data - for (int i = 0; i < CntTestContacts; ++i) { - QVERIFY(info[i].name() == mContacts[i].displayLabel()); - QVERIFY(info[i].text() == mContacts[i].detail().number()); - } - - // confirm that info cache contains correct data - int cacheItemCount = 0; - foreach (CntInfoCacheItem* item, cache->mInfoCache) { - // find corresponding contact - for (int i = 0; i < CntTestContacts; ++i) { - if (mContacts[i].localId() == item->contactId) { - QVERIFY(item->name == mContacts[i].displayLabel()); - QVERIFY(item->text == mContacts[i].detail().number()); - QVERIFY(item->icons[0].replace('\\', '/') == mContacts[i].detail().imageUrl().toString().replace('\\', '/')); - ++cacheItemCount; - } - } - } - QVERIFY(cacheItemCount == CntTestContacts); - - // confirm that icon cache contains correct data - cacheItemCount = 0; - foreach (CntIconCacheItem* item, cache->mIconCache) { - // find corresponding contact - for (int i = 0; i < CntTestContacts; ++i) { - if (mContacts[i].detail().imageUrl().toString().replace('\\','/') == item->iconName.replace('\\','/')) { - QVERIFY(item->isFetched); - QVERIFY(!item->icon.isNull()); - ++cacheItemCount; - } - } - } - QVERIFY(cacheItemCount == 2*2); // two images, both used by two contacts - - cache->onShutdown(); -} - -/* - Test case: Clear cache. - */ -void TestCntCache::clearCache() -{ - CntCache* cache = CntCache::instance(); - - QList idList; - for (int i = 0; i < CntTestContacts; ++i) { - idList << mContacts[i].localId(); - } - - cache->fetchContactInfo(1, idList); - cache->fetchContactInfo(3, idList); - - QVERIFY(cache->mInfoCache.count() == 2); - QTest::qWait(3000); - QVERIFY(cache->mIconCache.count() == 2); - - cache->clearCache(); - QVERIFY(cache->mInfoCache.count() == 0); // icon cache needn't be cleared - - delete cache; -} - -/* TODO: Test cases for overflowing info and icon requests (>30) -- IDs need not be real, just confirm - that cancellation notifications eventually arrive */ - -/* - Helper function for cleaning the database. - */ -void TestCntCache::cleanDatabase() -{ - QList ids = mContactManager->contactIds(); - QMap errorMapInit; - mContactManager->removeContacts(ids, &errorMapInit); - mContactManager->removeContact(mContactManager->selfContactId()); -} - -/* - Helper function for creating contacts. - */ -QContact TestCntCache::createContact(QString firstName, QString lastName, QString phoneNumber, QString imageName) -{ - QContact contact; - - if (!firstName.isEmpty() && !lastName.isEmpty()) { - QContactName name; - name.setFirstName(firstName); - name.setLastName(lastName); - contact.saveDetail(&name); - } - - if (!phoneNumber.isEmpty()) { - QContactPhoneNumber number; - number.setNumber(phoneNumber); - number.setContexts(QContactDetail::ContextHome); - number.setSubTypes(QContactPhoneNumber::SubTypeMobile); - contact.saveDetail(&number); - } - - if (!imageName.isEmpty()) { - QContactAvatar avatar; - avatar.setImageUrl(imageName); - contact.saveDetail(&avatar); - } - - mContactManager->saveContact(&contact); - - return contact; -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntdefaultinfoprovider.cpp --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntdefaultinfoprovider.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/* -* 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_cntdefaultinfoprovider.h" -#include "cntdefaultinfoprovider.h" - -void TestCntDefaultInfoProvider::initTestCase() -{ - mCntDefaultInfoProvider = NULL; -} - -void TestCntDefaultInfoProvider::create() -{ - mCntDefaultInfoProvider = new CntDefaultInfoProvider(); -} - -void TestCntDefaultInfoProvider::testSupportedFields() -{ - QVERIFY(mCntDefaultInfoProvider->supportedFields() == ContactInfoIcon1Field | ContactInfoTextField); -} - -void TestCntDefaultInfoProvider::testRequestInfo() -{ - QSignalSpy spy(mCntDefaultInfoProvider, SIGNAL(infoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&))); - - QContact c; - QContactName name; - name.setFirstName("firstname"); - name.setLastName("lastname"); - c.saveDetail(&name); - - ContactInfoFields fields; - fields = ContactInfoIcon2Field; - - mCntDefaultInfoProvider->requestInfo(c, fields); - QCOMPARE(spy.count(), 0); - - fields = ContactInfoIcon1Field | ContactInfoTextField; - - mCntDefaultInfoProvider->requestInfo(c, fields); - QCOMPARE(spy.count(), 2); - spy.clear(); - - QContactPhoneNumber number; - number.setNumber("1234567"); - number.setContexts(QContactDetail::ContextHome); - number.setSubTypes(QContactPhoneNumber::SubTypeMobile); - c.saveDetail(&number); - - mCntDefaultInfoProvider->requestInfo(c, fields); - QCOMPARE(spy.count(), 2); - spy.clear(); - - c.setPreferredDetail("call", number); - - QContactPhoneNumber number2; - number2.setNumber("7654321"); - number2.setContexts(QContactDetail::ContextWork); - number2.setSubTypes(QContactPhoneNumber::SubTypeMobile); - c.saveDetail(&number2); - - mCntDefaultInfoProvider->requestInfo(c, fields); - QCOMPARE(spy.count(), 2); - spy.clear(); - - QContactAvatar avatar; - c.saveDetail(&avatar); - - mCntDefaultInfoProvider->requestInfo(c, fields); - QCOMPARE(spy.count(), 2); - spy.clear(); - - avatar.setImageUrl(QUrl("dummyavatar")); - c.saveDetail(&avatar); - - mCntDefaultInfoProvider->requestInfo(c, fields); - QCOMPARE(spy.count(), 2); -} - -void TestCntDefaultInfoProvider::cleanupTestCase() -{ - delete mCntDefaultInfoProvider; - mCntDefaultInfoProvider = NULL; -} - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntdisplaytextformatter.cpp --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntdisplaytextformatter.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* -* 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_cntdisplaytextformatter.h" -#include "cntdisplaytextformatter.h" -#include - -void TestCntDisplayTextFormatter::testFormatter() -{ - QColor color = HbColorScheme::color("qtc_lineedit_selected"); - QColor bg = HbColorScheme::color("qtc_lineedit_marker_normal"); - QString foo = QString("foo").arg(bg.name().toUpper()).arg(color.name().toUpper()); - - QContactDetailFilter filter; - filter.setDetailDefinitionName( QContactDisplayLabel::DefinitionName ); - filter.setMatchFlags( QContactFilter::MatchStartsWith ); - filter.setValue( "f" ); - - CntDisplayTextFormatter* format = new CntHTMLDisplayTextFormatter; - QString result = format->formattedText("foo", filter ); - QVERIFY( foo == result ); - QVERIFY( "" == format->formattedText("", filter) ); - // invalid filter - QContactRelationshipFilter invalidFilter; - QVERIFY( "foo" == format->formattedText("foo", invalidFilter) ); - QVERIFY( "" == format->formattedText("", invalidFilter) ); - - // dummy returns always the given text, dispite of the filter - CntDisplayTextFormatter* dummy = new CntDummyDisplayTextFormatter; - QVERIFY( "foo" == dummy->formattedText("foo", filter) ); - QVERIFY( "foo" == dummy->formattedText("foo", invalidFilter) ); - QVERIFY( "" == dummy->formattedText("", filter) ); -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntlistmodel.cpp --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntlistmodel.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,601 +0,0 @@ -/* -* 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_cntlistmodel.h" -#include "cntlistmodel.h" -#include "cntlistmodel_p.h" - -#include -#include -#include - -void TestCntListModel::initTestCase() -{ - //let's have clean database before running tests - mManager = new QContactManager("symbian"); - QList ids = mManager->contactIds(); - QMap errorMapInit; - mManager->removeContacts(ids, &errorMapInit); - mManager->removeContact(mManager->selfContactId()); -} - -void TestCntListModel::contactReady(int startRow, int endRow) -{ - QVERIFY(startRow == endRow); - mDataReady = true; -} - -void TestCntListModel::create() -{ - mCntModel = new CntListModel(); - QVERIFY(mCntModel != NULL); - QVERIFY(mCntModel->rowCount() == 1); - QVERIFY(mCntModel->d->m_cache); - QVERIFY(mCntModel->d->m_ownedContactManager); - QVERIFY(mCntModel->d->m_contactManager != NULL); - - delete mCntModel; - mCntModel = NULL; - - mCntModel = new CntListModel(mManager); - QVERIFY(mCntModel != NULL); - QCOMPARE(mCntModel->rowCount(), 1); - QVERIFY(mCntModel->rowCount() == 1); - QVERIFY(mCntModel->d->m_cache); - QVERIFY(!mCntModel->d->m_ownedContactManager); - QVERIFY(mCntModel->d->m_contactManager != NULL); -} - -void TestCntListModel::data() -{ - mModelListener = new ModelListener(this); - mDataReady = false; - - //create and save contact - QContact c; - QContactName name; - name.setFirstName("firstname"); - name.setLastName("lastname"); - c.saveDetail(&name); - QContactPhoneNumber number; - number.setNumber("1234567"); - number.setContexts(QContactDetail::ContextHome); - number.setSubTypes(QContactPhoneNumber::SubTypeMobile); - c.saveDetail(&number); - QContactEmailAddress email; - email.setEmailAddress("dummyemail"); - c.saveDetail(&email); - QVERIFY(mManager->saveContact(&c)); - QTest::qWait(1000); - - //check invalid row and column - QVariant ret; - ret = mCntModel->data(QModelIndex(), Qt::UserRole); - QVERIFY(ret.isNull()); - - //check the saved contact's info - QModelIndex modelIndex = mCntModel->indexOfContact(c); - int row = modelIndex.row(); - QContact contactFromModel = mCntModel->contact(modelIndex); - QVERIFY(c == contactFromModel); - - ret = mCntModel->data(modelIndex, Qt::UserRole); - QVERIFY(ret.isNull()); - - ret = mCntModel->data(modelIndex, Qt::DisplayRole); - QVERIFY(ret.type() == QVariant::StringList); - QStringList displayContent; - displayContent = ret.toStringList(); - QVERIFY(displayContent.count() == 2); - QVERIFY(displayContent.at(0) == "firstname lastname"); - // second string is only an empty placeholder, e.g. " ", until cache has fetched the value - - // wait for cache to signal that all contact info is ready - while (!mDataReady) { QTest::qWait(200); QApplication::processEvents(); } - mDataReady = false; - ret = mCntModel->data(modelIndex, Qt::DisplayRole); - - QVERIFY(ret.type() == QVariant::StringList); - displayContent = ret.toStringList(); - QVERIFY(displayContent.count() == 2); - QVERIFY(displayContent.at(0) == "firstname lastname"); - QVERIFY(displayContent.at(1) == "1234567"); - - // check backgroundrole - ret = mCntModel->data(modelIndex, Qt::BackgroundRole); - QVERIFY(ret.isNull()); - - //check decoration role - ret = mCntModel->data(modelIndex, Qt::DecorationRole); - QVERIFY(ret.type() == QVariant::List); - - ret = mCntModel->data(modelIndex, Hb::IndexFeedbackRole); - QVERIFY(ret.type() == QVariant::String); - - // add empty avatar and check decoration - QContactAvatar avatar; - c.saveDetail(&avatar); - QVERIFY(mManager->saveContact(&c)); - QTest::qWait(1000); - ret = mCntModel->data(modelIndex, Qt::DecorationRole); - QVERIFY(ret.type() == QVariant::List); - - // add data to the avatar and check decoration - avatar.setImageUrl(QUrl("dummyimagepath")); - c.saveDetail(&avatar); - QVERIFY(mManager->saveContact(&c)); - QTest::qWait(1000); - modelIndex = mCntModel->indexOfContact(c); - ret = mCntModel->data(modelIndex, Qt::DecorationRole); - - // wait for cache to signal that all contact info is ready - while (!mDataReady) { QTest::qWait(200); QApplication::processEvents(); } - mDataReady = false; - ret = mCntModel->data(modelIndex, Qt::DecorationRole); - QVERIFY(ret.type() == QVariant::List); - - // check MyCard info from the model - modelIndex = mCntModel->index(0, 0); - ret = mCntModel->data(modelIndex, Qt::BackgroundRole); - QVERIFY(!ret.isNull()); - - // create and assign empty MyCard - QContact myCard; - QVERIFY(mManager->saveContact(&myCard)); - QTest::qWait(1000); - mManager->setSelfContactId(myCard.localId()); - QTest::qWait(1000); - - // check that MyCard was really saved - QCOMPARE(mCntModel->myCardId(), myCard.localId()); - - // check MyCard info from the model - myCard = mManager->contact(mManager->selfContactId()); - modelIndex = mCntModel->indexOfContact(myCard); - ret = mCntModel->data(modelIndex, Qt::BackgroundRole); - QVERIFY(!ret.isNull()); - - ret = mCntModel->data(modelIndex, Qt::DisplayRole); - QVERIFY(ret.type() == QVariant::StringList); - displayContent = ret.toStringList(); - QVERIFY(displayContent.count() == 1); // "Unnamed" - - // add some content to MyCard - myCard.saveDetail(&number); - QVERIFY(mManager->saveContact(&myCard)); - QTest::qWait(1000); - ret = mCntModel->data(modelIndex, Qt::DisplayRole); - // wait for cache - QTest::qWait(1000); - ret = mCntModel->data(modelIndex, Qt::DisplayRole); - QVERIFY(ret.type() == QVariant::StringList); - displayContent = ret.toStringList(); - QVERIFY(displayContent.contains(hbTrId("txt_phob_list_unnamed"))); - - ret = mCntModel->data(modelIndex, Hb::IndexFeedbackRole); - QVERIFY(ret.isNull()); -} - -void TestCntListModel::rowCount() -{ - // we should have 2 contacts in the model saved from the last test case - QTest::qWait(5000); - QCOMPARE(mCntModel->rowCount(), 2); -} - -void TestCntListModel::contact() -{ - QList ids = mManager->contactIds(); - QMap errorMapContact; - mManager->removeContacts(ids,&errorMapContact); - QTest::qWait(1000); - - QModelIndex modelIndex = mCntModel->index(0, 0); - QContact empty = mCntModel->contact(modelIndex); - //QVERIFY(empty.isEmpty()); - - //create and save contact - QContact c; - QContactName name; - name.setFirstName("firstname"); - name.setLastName("lastname"); - c.saveDetail(&name); - QContactPhoneNumber number; - number.setNumber("1234567"); - number.setContexts(QContactDetail::ContextHome); - number.setSubTypes(QContactPhoneNumber::SubTypeMobile); - c.saveDetail(&number); - QContactEmailAddress email; - email.setEmailAddress("dummyemail"); - c.saveDetail(&email); - QVERIFY(mManager->saveContact(&c)); - QTest::qWait(1000); - - modelIndex = mCntModel->index(10, 0); - c = mCntModel->contact(modelIndex); - QVERIFY(c.isEmpty()); - - modelIndex = mCntModel->index(1, 0); - c = mCntModel->contact(modelIndex); - QVERIFY(!c.isEmpty()); -} - -void TestCntListModel::contactId() -{ - QModelIndex modelIndex = mCntModel->index(1, 0); - QContact c = mCntModel->contact(modelIndex); - - QVERIFY(mCntModel->contactId(modelIndex) == c.localId()); -} - -void TestCntListModel::indexOfContact() -{ - QModelIndex modelIndex = mCntModel->index(1, 0); - QContact c = mCntModel->contact(modelIndex); - - QVERIFY(mCntModel->indexOfContact(c) == modelIndex); -} - -void TestCntListModel::indexOfContactId() -{ - QModelIndex modelIndex = mCntModel->index(1, 0); - QContact c = mCntModel->contact(modelIndex); - - QVERIFY(mCntModel->indexOfContactId(c.localId()) == modelIndex); -} - -void TestCntListModel::contactManager() -{ - QVERIFY(mManager == &(mCntModel->contactManager())); -} - -void TestCntListModel::setFilter() -{ - QList ids = mManager->contactIds(); - QMap errorMap; - mManager->removeContacts(ids,&errorMap); - QTest::qWait(1000); - - QContact c; - QContactName name; - name.setFirstName("firstname"); - name.setLastName("lastname"); - c.saveDetail(&name); - QVERIFY(mManager->saveContact(&c)); - - QContactUnionFilter unionFilter; - - QContactDetailFilter landlineFilter; - landlineFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName, QContactPhoneNumber::FieldSubTypes); - landlineFilter.setValue(QLatin1String(QContactPhoneNumber::SubTypeLandline)); - unionFilter << landlineFilter; - - QContactDetailFilter mobileFilter; - mobileFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName, QContactPhoneNumber::FieldSubTypes); - mobileFilter.setValue(QLatin1String(QContactPhoneNumber::SubTypeMobile)); - unionFilter << mobileFilter; - - mCntModel->setFilter(unionFilter); - - QModelIndex modelIndex = mCntModel->indexOfContact(c); - QVERIFY(modelIndex.row() < 0); - QVERIFY(mCntModel->d->m_filter == unionFilter); - QVERIFY(mCntModel->d->m_sortOrders.count() == 2); -} - -void TestCntListModel::myCard() -{ - delete mCntModel; - mCntModel = 0; - - mCntModel = new CntListModel(mManager); - - QList ids = mManager->contactIds(); - QMap errorMap; - mManager->removeContacts(ids,&errorMap); - QTest::qWait(1000); - - QContact c; - QContactName name; - name.setFirstName("firstname"); - name.setLastName("lastname"); - c.saveDetail(&name); - QVERIFY(mManager->saveContact(&c)); - - QSignalSpy spy(mCntModel, SIGNAL(modelReset())); - - QVERIFY(mCntModel->myCardStatus()); - - mCntModel->showMyCard(false); - QVERIFY(!mCntModel->myCardStatus()); - QCOMPARE(spy.count(), 2); - - mCntModel->showMyCard(true); - QVERIFY(mCntModel->myCardStatus()); - QCOMPARE(spy.count(), 4); - - mManager->setSelfContactId(c.localId()); - QTest::qWait(1000); - spy.clear(); - - mCntModel->showMyCard(false); - QVERIFY(!mCntModel->myCardStatus()); - QCOMPARE(spy.count(), 2); - - mCntModel->showMyCard(true); - QVERIFY(mCntModel->myCardStatus()); - QCOMPARE(spy.count(), 4); - mCntModel->showMyCard(true); - QVERIFY(mCntModel->myCardStatus()); - QCOMPARE(spy.count(), 4); -} - -void TestCntListModel::rowId() -{ - QList ids = mManager->contactIds(); - QMap errorMap; - mManager->removeContacts(ids,&errorMap); - QTest::qWait(1000); - - QContact c; - QContactName name; - name.setFirstName("firstname"); - name.setLastName("lastname"); - c.saveDetail(&name); - QVERIFY(mManager->saveContact(&c)); - - int row = mCntModel->rowId(c.localId()); - QVERIFY(row > 0); - QVERIFY(mCntModel->validRowId(row)); - QVERIFY(!mCntModel->validRowId(-100)); - QVERIFY(!mCntModel->validRowId(100)); -} - -void TestCntListModel::dataForDisplayRole() -{ - QList ids = mManager->contactIds(); - QMap errorMap; - mManager->removeContacts(ids,&errorMap); - QTest::qWait(1000); - - QContact c; - QContactName name; - name.setFirstName("firstname"); - name.setLastName("lastname"); - c.saveDetail(&name); - QVERIFY(mManager->saveContact(&c)); - - int row = mCntModel->rowId(c.localId()); - QVariant var = mCntModel->dataForRole(row, Qt::DisplayRole); - QVERIFY(var.type() == QVariant::StringList); - - var = mCntModel->dataForRole(0, Qt::DisplayRole); - QVERIFY(var.type() == QVariant::StringList); -} - -void TestCntListModel::handleAdded() -{ - QList ids = mManager->contactIds(); - QMap errorMap; - mManager->removeContacts(ids,&errorMap); - QTest::qWait(1000); - - QSignalSpy spy(mCntModel, SIGNAL(rowsAboutToBeInserted(const QModelIndex&, int, int))); - - QContact c; - QContactName name; - name.setFirstName("firstname"); - name.setLastName("lastname"); - c.saveDetail(&name); - QVERIFY(mManager->saveContact(&c)); - - QCOMPARE(spy.count(), 1); - - QList emptyList; - mCntModel->handleAdded(emptyList); - QCOMPARE(spy.count(), 1); -} - -void TestCntListModel::handleChanged() -{ - QList ids = mManager->contactIds(); - QMap errorMap; - mManager->removeContacts(ids,&errorMap); - QTest::qWait(1000); - - QContact c; - QContactName name; - name.setFirstName("firstname"); - name.setLastName("lastname"); - c.saveDetail(&name); - QVERIFY(mManager->saveContact(&c)); - - QSignalSpy spy(mCntModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex&))); - - name.setMiddleName("mid"); - c.saveDetail(&name); - QVERIFY(mManager->saveContact(&c)); - - QCOMPARE(spy.count(), 1); - - QList emptyList; - mCntModel->handleChanged(emptyList); - QCOMPARE(spy.count(), 1); -} - -void TestCntListModel::handleRemoved() -{ - QSignalSpy spy(mCntModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int))); - - QList ids = mManager->contactIds(); - QMap errorMap; - mManager->removeContacts(ids,&errorMap); - QTest::qWait(1000); - - QCOMPARE(spy.count(), 1); - - QList emptyList; - mCntModel->handleRemoved(emptyList); - QCOMPARE(spy.count(), 1); -} - -void TestCntListModel::handleMyCardChanged() -{ - QList ids = mManager->contactIds(); - QMap errorMap; - mManager->removeContacts(ids,&errorMap); - QTest::qWait(1000); - - QContact c; - QContactName name; - name.setFirstName("firstname"); - name.setLastName("lastname"); - c.saveDetail(&name); - QVERIFY(mManager->saveContact(&c)); - - mCntModel->handleMyCardChanged(0, c.localId()); - QVERIFY(mCntModel->d->m_myCardId == c.localId()); -} - -void TestCntListModel::handleRelationships() -{ - // remove all contacts - QList ids = mManager->contactIds(); - QMap errorMap; - mManager->removeContacts(ids,&errorMap); - QTest::qWait(1000); - - // create group "myGroup" - QContact group; - group.setType(QContactType::TypeGroup); - QContactName groupName; - groupName.setCustomLabel("myGroup"); - group.saveDetail(&groupName); - mManager->saveContact(&group); - - // create a relationship filter - QContactRelationshipFilter groupFilter; - groupFilter.setRelationshipType(QContactRelationship::HasMember); - groupFilter.setRelatedContactRole(QContactRelationship::First); - groupFilter.setRelatedContactId(group.id()); - - // create new listmodel - CntListModel* groupListModel = new CntListModel(mManager, groupFilter, false); - QVERIFY(groupListModel != NULL); - - QCOMPARE(groupListModel->rowCount(), 0); - - // create contacts - QList contacts; - contacts << createContact("Alfa", "One"); - contacts << createContact("Beta", "Two"); - contacts << createContact("Gamma", "Three"); - QTest::qWait(1000); - QCOMPARE(groupListModel->rowCount(), 0); - - // add contacts to group - foreach (QContact contact, contacts) { - addGroupMember(group, contact); - } - QTest::qWait(1000); - QCOMPARE(groupListModel->rowCount(), 3); - - // remove contact from group - removeGroupMember(group, contacts.at(1)); - QTest::qWait(1000); - QCOMPARE(groupListModel->rowCount(), 2); - - // add and remove empty list - QList emptyList; - emptyList << group.localId(); - mCntModel->handleAddedRelationship(emptyList); - QCOMPARE(groupListModel->rowCount(), 2); - mCntModel->handleRemovedRelationship(emptyList); - QCOMPARE(groupListModel->rowCount(), 2); - - // verify that contact on second row is "Gamma Three" (comes after "Alfa One" - // regardless of sorting type and Beta Two was removed) - QVERIFY(groupListModel->indexOfContact(contacts.at(0)).row() == 0); - QVERIFY(groupListModel->indexOfContact(contacts.at(1)).row() == -1); - QVERIFY(groupListModel->indexOfContact(contacts.at(2)).row() == 1); - - // create a contact and make sure list model count does not change - createContact("Delta", "Four"); - QTest::qWait(1000); - QCOMPARE(groupListModel->rowCount(), 2); - - delete groupListModel; -} - -QContact TestCntListModel::createContact(const QString& firstName, const QString& lastName) -{ - QContact contact; - QContactName name; - name.setFirstName(firstName); - name.setLastName(lastName); - contact.saveDetail(&name); - mManager->saveContact(&contact); - - return contact; -} - -void TestCntListModel::addGroupMember(const QContact& group, const QContact& contact) -{ - QContactRelationship relationship; - relationship.setRelationshipType(QContactRelationship::HasMember); - relationship.setFirst(group.id()); - relationship.setSecond(contact.id()); - mManager->saveRelationship(&relationship); -} - -void TestCntListModel::removeGroupMember(const QContact& group, const QContact& contact) -{ - QContactRelationship relationship; - relationship.setRelationshipType(QContactRelationship::HasMember); - relationship.setFirst(group.id()); - relationship.setSecond(contact.id()); - mManager->removeRelationship(relationship); -} - -void TestCntListModel::cleanupTestCase() -{ - mCntModel->d->m_cache->onShutdown(); - delete mCntModel; - mCntModel = 0; - - //let's have clean database after running tests - QList ids = mManager->contactIds(); - QMap errorMap; - mManager->removeContacts(ids, &errorMap); - delete mManager; - mManager = 0; - delete mModelListener; - mModelListener = 0; -} - - -ModelListener::ModelListener(TestCntListModel* parent) - : mParent(parent) -{ - connect(mParent->mCntModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(onDataChanged(QModelIndex,QModelIndex))); -} - -void ModelListener::onDataChanged(QModelIndex start, QModelIndex end) -{ - mParent->contactReady(start.row(), end.row()); -} - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntpresenceinfoprovider.cpp --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntpresenceinfoprovider.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,190 +0,0 @@ -/* -* 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_cntpresenceinfoprovider.h" -#include "cntpresenceinfoprovider.h" - -#include -#include -#include - -void TestCntPresenceInfoProvider::initTestCase() -{ - mCntPresenceInfoProvider = NULL; -} - -void TestCntPresenceInfoProvider::create() -{ - mCntPresenceInfoProvider = new CntPresenceInfoProvider(); -} - -void TestCntPresenceInfoProvider::testSupportedFields() -{ - QVERIFY(mCntPresenceInfoProvider->supportedFields() == ContactInfoIcon2Field); -} - -void TestCntPresenceInfoProvider::testRequestInfo() -{ - PrcPresenceWriter *writer = PrcPresenceWriter::createWriter(); - - PrcPresenceBuddyInfoQt *buddy = PrcPresenceBuddyInfoQt::createInstance(); - buddy->setIdentity("sip:test@test.com"); - buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcNotAvailable, "meh"); - writer->writePresence(*buddy); - - QContactManager manager("symbian"); - - QContact c; - QContactName name; - name.setFirstName("firstname"); - name.setLastName("lastname"); - c.saveDetail(&name); - QContactPhoneNumber number; - number.setNumber("1234567"); - number.setContexts(QContactDetail::ContextHome); - number.setSubTypes(QContactPhoneNumber::SubTypeMobile); - c.saveDetail(&number); - manager.saveContact(&c); - - ContactInfoFields fields; - fields = ContactInfoTextField; - - QSignalSpy spy(mCntPresenceInfoProvider, SIGNAL(infoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&))); - - mCntPresenceInfoProvider->requestInfo(c, fields); - QCOMPARE(spy.count(), 0); - QVERIFY(mCntPresenceInfoProvider->mBuddyMap.isEmpty()); - - fields = ContactInfoIcon2Field; - - mCntPresenceInfoProvider->requestInfo(c, fields); - QCOMPARE(spy.count(), 0); - QVERIFY(mCntPresenceInfoProvider->mBuddyMap.isEmpty()); - - QContactOnlineAccount account; - account.setSubTypes(QStringList() << QContactOnlineAccount::SubTypeSip); - account.setServiceProvider("sip"); - account.setAccountUri("test@test.com"); - c.saveDetail(&account); - QContactOnlineAccount account2; - account2.setSubTypes(QStringList() << QContactOnlineAccount::SubTypeSipVoip); - account.setServiceProvider("sip"); - account2.setAccountUri("test@test.com"); - c.saveDetail(&account2); - QContactOnlineAccount account3; - account3.setSubTypes(QStringList() << QContactOnlineAccount::SubTypeSip); - account3.setAccountUri("malformatted"); - c.saveDetail(&account3); - manager.saveContact(&c); - - mCntPresenceInfoProvider->requestInfo(c, fields); - QCOMPARE(spy.count(), 0); - QCOMPARE(mCntPresenceInfoProvider->mBuddyMap.count(), 1); - - delete mCntPresenceInfoProvider; - mCntPresenceInfoProvider = NULL; - - buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcAvailable, "meh"); - writer->writePresence(*buddy); - - mCntPresenceInfoProvider = new CntPresenceInfoProvider(); - - QSignalSpy spy2(mCntPresenceInfoProvider, SIGNAL(infoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&))); - mCntPresenceInfoProvider->requestInfo(c, fields); - QCOMPARE(spy2.count(), 1); - QCOMPARE(mCntPresenceInfoProvider->mBuddyMap.count(), 1); - - delete buddy; - delete writer; -} - -void TestCntPresenceInfoProvider::testHandlePresenceUpdate() -{ - QSignalSpy spy(mCntPresenceInfoProvider, SIGNAL(infoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&))); - - PrcPresenceWriter *writer = PrcPresenceWriter::createWriter(); - PrcPresenceReader *reader = PrcPresenceReader::createReader(); - - PrcPresenceBuddyInfoQt *dummyBuddy = PrcPresenceBuddyInfoQt::createInstance(); - dummyBuddy->setIdentity("sip:dummy@dummy.com"); - dummyBuddy->setAvailability(PrcPresenceBuddyInfoQt::PrcAvailable, "meh"); - writer->writePresence(*dummyBuddy); - - mCntPresenceInfoProvider->handlePresenceUpdate(true, dummyBuddy); - QCOMPARE(spy.count(), 0); - - mCntPresenceInfoProvider->handlePresenceUpdate(false, dummyBuddy); - QCOMPARE(spy.count(), 0); - - mCntPresenceInfoProvider->handlePresenceUpdate(true, NULL); - QCOMPARE(spy.count(), 0); - - PrcPresenceBuddyInfoQt *buddy = reader->presenceInfo("sip:test@test.com"); - buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcNotAvailable, "meh"); - writer->writePresence(*buddy); - QTest::qWait(5000); - QCOMPARE(spy.count(), 1); - - QContactManager manager("symbian"); - QContact c = manager.contact(mCntPresenceInfoProvider->mBuddyMap.value("sip:test@test.com")); - - QList accounts = c.details(); - foreach (QContactOnlineAccount account, accounts) - { - c.removeDetail(&account); - } - manager.saveContact(&c); - - buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcAvailable, "meh"); - writer->writePresence(*buddy); - QTest::qWait(5000); - QCOMPARE(spy.count(), 2); - - delete writer; - delete reader; - delete dummyBuddy; - delete buddy; -} - -void TestCntPresenceInfoProvider::testParsePresence() -{ - PrcPresenceBuddyInfoQt *buddy = PrcPresenceBuddyInfoQt::createInstance(); - buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcNotAvailable, "meh"); - - QList buddies; - buddies.append(buddy); - - QVERIFY(mCntPresenceInfoProvider->parsePresence(buddies).isEmpty()); - - buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcAvailable, "meh"); - - QVERIFY(mCntPresenceInfoProvider->parsePresence(buddies) == "qtg_small_online"); - - delete buddy; -} - -void TestCntPresenceInfoProvider::cleanupTestCase() -{ - delete mCntPresenceInfoProvider; - mCntPresenceInfoProvider = NULL; - - QContactManager manager("symbian"); - QList ids = manager.contactIds(); - QMap errorMap; - manager.removeContacts(ids, &errorMap); -} - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/ut_cntlistmodel.pro --- a/phonebookengines/cntlistmodel/tsrc/ut_cntlistmodel/ut_cntlistmodel.pro Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -# -# 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: -# -# - - -TEMPLATE = app -TARGET = - -DEFINES += QT_NO_DEBUG_OUTPUT -DEFINES += QT_NO_WARNING_OUTPUT -DEFINES += CNTLISTMODEL_NO_EXPORT - -MOC_DIR = moc - -QT += testlib xml - -CONFIG += hb - -TARGET.CAPABILITY = ALL \ - -TCB - -INCLUDEPATH += . -INCLUDEPATH += ../../inc -INCLUDEPATH += ../../../../inc -INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE - -HEADERS += inc/testrunner.h \ - inc/ut_cntlistmodel.h \ - inc/ut_cntcache.h \ - inc/ut_cntpresenceinfoprovider.h \ - inc/ut_cntdefaultinfoprovider.h \ - inc/ut_cntdisplaytextformatter.h \ - ../../inc/cntlistmodelglobal.h \ - ../../inc/cntlistmodel.h \ - ../../inc/cntlistmodel_p.h \ - ../../inc/cntcache.h \ - ../../inc/cntcache_p.h \ - ../../inc/cntdefaultinfoprovider.h \ - ../../inc/cntpresenceinfoprovider.h \ - ../../inc/cntdisplaytextformatter.h \ - ../../../../inc/cntdebug.h - -SOURCES += src/testrunner.cpp \ - src/main.cpp \ - src/ut_cntlistmodel.cpp \ - src/ut_cntcache.cpp \ - src/ut_cntpresenceinfoprovider.cpp \ - src/ut_cntdefaultinfoprovider.cpp \ - src/ut_cntdisplaytextformatter.cpp \ - ../../src/cntlistmodel.cpp \ - ../../src/cntcache.cpp \ - ../../src/cntcache_p.cpp \ - ../../src/cntdefaultinfoprovider.cpp \ - ../../src/cntpresenceinfoprovider.cpp \ - ../../src/cntdisplaytextformatter.cpp - -BLD_INF_RULES.prj_exports += "image1.png /epoc32/winscw/c/data/images/" -BLD_INF_RULES.prj_exports += "image2.png /epoc32/winscw/c/data/images/" - -LIBS += -lQtContacts \ - -lhbcore \ - -lthumbnailmanagerqt \ - -lpresencecacheqt \ - -lxqsettingsmanager - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntsimutility/tsrc/ut_cntsimutility/start.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookengines/cntsimutility/tsrc/ut_cntsimutility/start.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2007, 2008 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: Implementation for presence cache reader and writer. +* +*/ +#include "ut_cntsimutility.h" +#include +#include + +#include +#include + +#define LOG_TO_FILE +//QTEST_MAIN(TestOfTest); +int main(int argc, char *argv[]) +{ +#ifdef LOG_TO_FILE + + bool promptOnExit(0); + for (int i=0; i +#include +#include +#include + +#ifdef SYMBIANSIM_BACKEND_USE_ETEL_TESTSERVER +#include +#else +#include +#endif +#include +#include "ut_cntsimutility.h" +#include "cntsimutility.h" + +bool TestCntSimUtility::returnErrorInStub_1 = false; +bool TestCntSimUtility::returnErrorInStub_2 = false; + + +TestCntSimUtility::TestCntSimUtility() : +m_SimStore(0) +{ + +} + +TestCntSimUtility::~TestCntSimUtility() +{ + +} + +void TestCntSimUtility::initTestCase() +{ + + int error = KErrNone; + + // remove all contacts +} + +void TestCntSimUtility::cleanupTestCase() +{ + + delete m_SimStore; + m_SimStore = 0; +} + +void TestCntSimUtility::TestStoreCreation() +{ + +} + +void TestCntSimUtility::TestGetSimInfo() +{ + // ok case + TestCntSimUtility::returnErrorInStub_1 = false; + int error = KErrNotSupported; + m_SimStore = new CntSimUtility(CntSimUtility::AdnStore, error); + error = KErrNotSupported; + CntSimUtility::SimInfo simInformation_adn = m_SimStore->getSimInfo(error); + QVERIFY(KErrNone == error); + outputSimInfo(simInformation_adn); + + // error case + TestCntSimUtility::returnErrorInStub_1 = true; + simInformation_adn = m_SimStore->getSimInfo(error); + QVERIFY(KErrNone == KErrGeneral); + + +} +void TestCntSimUtility::outputSimInfo(CntSimUtility::SimInfo &results) + { + return; + qDebug()<< "SIMUTILITY:Totalentries = "<< results.totalEntries; + qDebug()<< "SIMUTILITY:usedEntries = "<< results.usedEntries ; + qDebug()<< "SIMUTILITY:maxNumLength = "<< results.maxNumLength; + qDebug()<< "SIMUTILITY:maxTextLength = "<< results.maxTextLength; + qDebug()<< "SIMUTILITY:maxSecondNames = "<< results.maxSecondNames; + qDebug()<< "SIMUTILITY:maxTextLengthSecondName = "<< results.maxTextLengthSecondName ; + qDebug()<< "SIMUTILITY:maxAdditionalNumbers = "<< results.maxAdditionalNumbers ; + qDebug()<< "SIMUTILITY:maxNumLengthAdditionalNumber = "<< results.maxNumLengthAdditionalNumber; + qDebug()<< "SIMUTILITY:maxTextLengthAdditionalNumber = "<< results.maxTextLengthAdditionalNumber; + qDebug()<< "SIMUTILITY:maxGroupNames = "<< results.maxGroupNames ; + qDebug()<< "SIMUTILITY:maxTextLengthGroupName = "< +#include +#include +#include + +#include +#include "ut_cntsimutility.h" +#include "cntsimutility.h" + #include "centralrepository.h" +#include +#include +#include +#include +RTelServer::RTelServer( ) + { + + } +TInt RTelServer::Connect( + TInt aMessageSlots ) + { + if(true == TestCntSimUtility::returnErrorInStub_1) + { + return KErrGeneral; + } + return KErrNone; + } + + +TInt RTelServer::EnumeratePhones( + TInt & aNoOfPhones ) const + { + + } + +TInt RTelServer::GetPhoneInfo( + const TInt aIndex, + TPhoneInfo & aInfo ) const + { + + if(true == TestCntSimUtility::returnErrorInStub_1) + { + return KErrGeneral; + } + return KErrNone; + } + + +TInt RTelServer::GetTsyName( + const TInt aIndexOfPhone, + TDes & aTsyName ) const + { + } + + + +TInt RTelServer::LoadPhoneModule( + const TDesC & aFileName ) const + { + + if(true == TestCntSimUtility::returnErrorInStub_1) + { + return KErrGeneral; + } + return KErrNone; + } + + +TInt RTelServer::UnloadPhoneModule( + const TDesC & aFileName ) const + { + } + + +TInt RTelServer::IsSupportedByModule( + const TDesC & aTsyName, + const TInt aMixin, + TBool & aResult ) const + { + + } + + +TInt RTelServer::GetTsyVersionNumber( + const TDesC & aTsyName, + TVersion & aVersion ) const + { + + } + + + +TInt RTelServer::SetPriorityClient( ) const + { + + } + + +TInt RTelServer::SetExtendedErrorGranularity( + const TErrorGranularity aGranularity ) const + { + + } +TInt RTelServer::__DbgMarkHeap( ) + { + + } + +TInt RTelServer::__DbgCheckHeap( + TInt aCount ) + { + + } + +TInt RTelServer::__DbgMarkEnd( + TInt aCount ) + { + + } +TInt RTelServer::__DbgFailNext( + TInt aCount ) + { + + } +TInt RTelServer::__DbgFailNextAvailable( + TBool & aResult ) + { + + } +TInt RTelServer::SetPriorityClientV2( ) const + { + + } +RMobilePhone::RMobilePhone() + { + + + } +TInt RMobilePhone::GetMultimodeCaps( + TUint32 & aCaps ) const + { + + } +void RMobilePhone::SetFdnSetting(TRequestStatus& aReqStatus, TMobilePhoneFdnSetting aFdnSetting) const + { + TRequestStatus* req = & aReqStatus; + if(true == TestCntSimUtility::returnErrorInStub_1) + { + User::RequestComplete(req, KErrGeneral); + } + else + { + User::RequestComplete(req, KErrNone); + } + + + + } +void RMobilePhone::NotifyFdnStatusChange(TRequestStatus& aReqStatus, TMobilePhoneFdnStatus& aFdnStatus) const + { + + } + +TInt RMobilePhone::GetCurrentMode( + TMobilePhoneNetworkMode & aNetworkMode ) const + { + + } + + +TInt RMobilePhone::GetIccAccessCaps(TUint32 &acaps) const + { + if(true == TestCntSimUtility::returnErrorInStub_2) + { + return KErrGeneral; + } + acaps = RMobilePhone::KCapsUSimAccessSupported; + return KErrNone; + } +void RMobilePhone::GetServiceTable(TRequestStatus& aReqStatus, TMobilePhoneServiceTable aTable, TDes8& aTableData) const + { + + TRequestStatus* req = &aReqStatus; + if(true == TestCntSimUtility::returnErrorInStub_1) + { + User::RequestComplete(req, KErrGeneral); + } + else + { + User::RequestComplete(req, KErrNone); + } + + } +TInt RMobilePhone::GetFdnStatus(TMobilePhoneFdnStatus& aFdnStatus) const +{ + if(false == TestCntSimUtility::returnErrorInStub_1) + { + aFdnStatus = RMobilePhone::EFdnActive ; + return KErrNone; + + } + + aFdnStatus = RMobilePhone::EFdnNotActive ; + return KErrGeneral; +} +void RMobilePhone::GetFdnStatus(TRequestStatus& aReqStatus, TMobilePhoneFdnStatus& aFdnStatus) const +{ + +} + +void RMobilePhone::GetSignalStrength( + TRequestStatus & aReqStatus, + TInt32 & aSignalStrength, + TInt8 & aBar ) const + { + + } + + +void RMobilePhone::NotifySignalStrengthChange( + TRequestStatus & aReqStatus, + TInt32 & aSignalStrength, + TInt8 & aBar ) const + { + } +void RMobilePhone::GetSubscriberId(TRequestStatus& aReqStatus, TMobilePhoneSubscriberId& aId) const + { + + TRequestStatus* req = & aReqStatus; + if(true == TestCntSimUtility::returnErrorInStub_1) + { + User::RequestComplete(req, KErrGeneral); + } + else + { + User::RequestComplete(req, KErrNone); + } + + } +void RMobilePhone::ConstructL() + { + + } +void RMobilePhone::Destruct() + { + + } + +RMobilePhoneBookStore::RMobilePhoneBookStore () + { + + } + +void RMobilePhoneBookStore::Close () + { + + } + +RMobilePhoneBookStore::TMobilePhoneBookInfoV5::TMobilePhoneBookInfoV5() + { + + } +RMobilePhone::TMobilePhoneServiceTableV1::TMobilePhoneServiceTableV1() + { + + } +RMmCustomAPI::RMmCustomAPI() + { + + } +CSecuritySettings::CSecuritySettings() + { + + } +CSecuritySettings::~CSecuritySettings() + { + + } +CSecuritySettings* CSecuritySettings::NewL() + { + CSecuritySettings* self = new( ELeave ) CSecuritySettings; + CleanupStack::PushL( self ); + //self->ConstructL() + CleanupStack::Pop( self ); + return self; + } +TBool CSecuritySettings::AskPin2L() + { + return ETrue; + } +// ---- + + + +CRepository * CRepository::NewL( + TUid aRepositoryUid ) + { + + + CRepository* self = new( ELeave ) CRepository; + CleanupStack::PushL( self ); + //self->ConstructL() + CleanupStack::Pop( self ); + return self; + } + + + +CRepository * CRepository::NewLC( + TUid aRepositoryUid ) + { + + + CRepository* self = new( ELeave ) CRepository; + CleanupStack::PushL( self ); + //self->ConstructL() + return self; + } + + + +CRepository::~CRepository( ) + { + + } + +TInt CRepository::Get( + TUint32 aKey, + TInt & aValue ) + { + if(true == TestCntSimUtility::returnErrorInStub_1) + { + return KErrGeneral; + } + return KErrNone; + + } +TInt CRepository::Get(TUint32 aKey,TDes16 &aValue) + { + if(true == TestCntSimUtility::returnErrorInStub_1) + { + return KErrGeneral; + } + return KErrNone; + } + +TInt CRepository::Set(TUint32 aKey, const TDesC16& aValue) + { + if(true == TestCntSimUtility::returnErrorInStub_1) + { + return KErrGeneral; + } + return KErrNone; + } +TInt CRepository::Set(TUint32 aKey, TInt aValue) + { + if(true == TestCntSimUtility::returnErrorInStub_1) + { + return KErrGeneral; + } + return KErrNone; + } + +TInt RProperty::Get(TUid aCategory, TUint aKey, TInt& aValue) + { + if(true == TestCntSimUtility::returnErrorInStub_1) + { + return KErrGeneral; + aValue = ESimNotSupported; + + } + aValue = ESimUsable; + return KErrNone; + } +TSecUi::TSecUi( ) + { + + } + + +void TSecUi::ConstructL( ) + { + + } + + + +void TSecUi::InitializeLibL( ) + { + + } + + + +void TSecUi::UnInitializeLib( ) + { + } + + + +TBool TSecUi::CanBeFreed( ) + { + } + + + +void TSecUi::IncreaseClientCount( ) + { + } + + +void TSecUi::DecreaseClientCount( ) + { + } + + +RPhone::RPhone() + { + + +} +void RPhone::Close() + { + + } +void RPhone::ConstructL() + { + + } + +void RPhone::Destruct() + { + + } +RMobilePhoneStore::RMobilePhoneStore() + { + + + } + +void RMobilePhoneStore::GetInfo(TRequestStatus& aReqStatus, TDes8& aInfo) const + { + TRequestStatus* req = & aReqStatus; + if(true == TestCntSimUtility::returnErrorInStub_1) + { + User::RequestComplete(req, KErrGeneral); + } + else + { + User::RequestComplete(req, KErrNone); + } + + + + + } +void RMmCustomAPI::GetPndCacheStatus( TRequestStatus& aStatus, + RMmCustomAPI::TPndCacheStatus& aPndStatus, + const TName& aPndName ) const + { + TRequestStatus* req = & aStatus; + if(true == TestCntSimUtility::returnErrorInStub_1) + { + aPndStatus == RMmCustomAPI::ECacheNotReady; + User::RequestComplete(req, KErrGeneral); + } + else + { + aPndStatus = RMmCustomAPI::ECacheReady; + User::RequestComplete(req, KErrNone); + } + } +void RMmCustomAPI::NotifyPndCacheReady( TRequestStatus& aStatus, + TName& aPndName ) + { + + } +int RMmCustomAPI::Open(RMobilePhone& aPhone) + { + + if(true == TestCntSimUtility::returnErrorInStub_1) + { + return KErrGeneral; + } + return KErrNone; + } +RMobilePhoneBookStore::TMobilePhoneBookInfoV2::TMobilePhoneBookInfoV2() + { + + } +RMobilePhoneBookStore::TMobilePhoneBookInfoV1::TMobilePhoneBookInfoV1() + { + + } +RMobilePhoneBookStore::TMobilePhoneStoreInfoV1::TMobilePhoneStoreInfoV1() + { + + } + +RTelSubSessionBase::RTelSubSessionBase() + { + + } +RMobilePhone::TMultimodeType::TMultimodeType() + { + + } +TInt RMobilePhoneBookStore::Open(RMobilePhone & aPhone, const TDesC& aStore) + { + + if(true == TestCntSimUtility::returnErrorInStub_1) + { + return KErrGeneral; + } + return KErrNone; + } +TInt RPhone::Open(RTelServer& aServer, TDesC16 const & aDes) + { + + if(true == TestCntSimUtility::returnErrorInStub_1) + { + return KErrGeneral; + } + return KErrNone; + } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntsortplugin/group/cntsortplugin.mmp --- a/phonebookengines/cntsortplugin/group/cntsortplugin.mmp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* -* Copyright (c) 2002 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: -* Build information file for contact model plugin needed for japanese sort -* -*/ - - -#include "cntsortpluginuid.h" -#include -#include - -TARGET cntsortplugin.dll -TARGETTYPE PLUGIN -UID KEComPluginUID2 KCntModelSortPluginDllUID3 -CAPABILITY CAP_ECOM_PLUGIN -VENDORID VID_DEFAULT - -SOURCEPATH ../src -SOURCE dllmain.cpp -SOURCE ccntsortplugin.cpp -SOURCE csortkeyarray.cpp - -USERINCLUDE ../group -APP_LAYER_SYSTEMINCLUDE - -START RESOURCE 101f85a9.rss -TARGET cntsortplugin -TARGETPATH resource/plugins -END - -LIBRARY euser.lib -LIBRARY ECom.lib -LIBRARY cntmodel.lib -LIBRARY sortutil.lib diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntsortplugin/group/cntsortpluginuid.h --- a/phonebookengines/cntsortplugin/group/cntsortpluginuid.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* -* Copyright (c) 2002 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: -* Common header for Contact Model Sort Plugin UIDs. -* -* -*/ - -#ifndef __CntSortPluginUid_H__ -#define __CntSortPluginUid_H__ - -// Contact Model Sort Plugin DLL UID -#define KCntModelSortPluginDllUID3 0x101F85A9 - -// Contact Model Sort Plugin Interface UID -#define KCntModelSortPluginInterfaceUID 0x10200FBD - -// Implementation UID -#define KCntModelSortPluginImplementationUID 0x101F85AA - -// -// Common system UIDs -// - -// ECom Plugin UID 2 -#define KEComPluginUID2 0x10009D8D - -#endif // CntSortPluginUid - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntsortplugin/rom/cntsortplugin.iby --- a/phonebookengines/cntsortplugin/rom/cntsortplugin.iby Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -/* -* 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 __CNTSORTPLUGIN_IBY__ -#define __CNTSORTPLUGIN_IBY__ - -ECOM_PLUGIN(cntsortplugin.dll,101f85a9.rsc) - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntsortplugin/src/101f85a9.rss --- a/phonebookengines/cntsortplugin/src/101f85a9.rss Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* -* Copyright (c) 2002 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: -* Contact model ECOM plugin resource file -* -*/ - - -#include -#include "cntsortpluginuid.h" - -RESOURCE REGISTRY_INFO theInfo - { - dll_uid = KCntModelSortPluginDllUID3; - interfaces = - { - INTERFACE_INFO - { - interface_uid = KCntModelSortPluginInterfaceUID; - implementations = - { - IMPLEMENTATION_INFO - { - implementation_uid = KCntModelSortPluginImplementationUID; - version_no = 1; - display_name = "Contacts Sort Plugin"; - default_data = "/default"; - opaque_data = ""; - } - }; - } - }; - } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntsortplugin/src/ccntsortplugin.cpp --- a/phonebookengines/cntsortplugin/src/ccntsortplugin.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,200 +0,0 @@ -/* -* Copyright (c) 2002 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: -* Contact model ECOM sort plugin. -* -*/ - - -// INCLUDE FILES -#include "ccntsortplugin.h" - -#include -#include - -#include "csortkeyarray.h" - -namespace { - -#ifdef _DEBUG -enum TPanicType - { - EPanicPreCond_CompareViewContactsL = 1, - EPanicSortUtilFactoryReturnedNULL, - EPanicInvalidViewParameters, - EPanicDefaultCompareFunctionNULL, - EPanicDefaultIsSortableFunctionNULL - }; - -void Panic(TPanicType aPanicType) - { - _LIT(KPanicTxt, "CCntSortPlugin"); - User::Panic(KPanicTxt, aPanicType); - } -#endif -} // namespace - -// ========================== MEMBER FUNCTIONS =============================== - -// --------------------------------------------------------------------------- -// CCntSortPlugin::NewL -// --------------------------------------------------------------------------- -// -CCntSortPlugin* CCntSortPlugin::NewL(TAny* aParams) - { - CCntSortPlugin* self = new(ELeave) CCntSortPlugin; - CleanupStack::PushL( self ); - self->ConstructL(static_cast(aParams)); - CleanupStack::Pop(); - return self; - } - -// --------------------------------------------------------------------------- -// CCntSortPlugin::ConstructL -// --------------------------------------------------------------------------- -// -void CCntSortPlugin::ConstructL(TSortPluginParams* aParams) - { - // Validate parameters - if (!aParams || - (aParams->iParametersRevision != KCntSortPluginViewParamsRev1Uid)) - User::Leave(KErrArgument); - - TSortPluginViewParamsRev1* viewParams = - static_cast(aParams->iViewSortParams); - - __ASSERT_DEBUG(viewParams, - Panic(EPanicInvalidViewParameters)); - __ASSERT_DEBUG(viewParams->iCompareViewContactsL, - Panic(EPanicDefaultCompareFunctionNULL)); - __ASSERT_DEBUG(viewParams->iIsSortable, - Panic(EPanicDefaultIsSortableFunctionNULL)); - - iIsSortable = viewParams->iIsSortable; - - iSortUtil = CSortUtil::NewL(); - // Sort Util factory has to return valid pointer - // Factory should default to european sorting if nothing else is - // applicable - __ASSERT_DEBUG(iSortUtil, Panic(EPanicSortUtilFactoryReturnedNULL)); - - iLeftSortKeyArray = CSortKeyArray::NewL(); - iRightSortKeyArray = CSortKeyArray::NewL(); - } - -// --------------------------------------------------------------------------- -// CCntSortPlugin::CCntSortPlugin -// --------------------------------------------------------------------------- -// -CCntSortPlugin::CCntSortPlugin() - { - } - -// --------------------------------------------------------------------------- -// CCntSortPlugin::~CCntSortPlugin -// --------------------------------------------------------------------------- -// -CCntSortPlugin::~CCntSortPlugin() - { - delete iSortUtil; - iSortOrder.Close(); - delete iLeftSortKeyArray; - delete iRightSortKeyArray; - } - -void CCntSortPlugin::SetSortOrderL - (const RContactViewSortOrder& aViewSortOrder) - { - iSortOrder.Close(); - iSortOrder.CopyL(aViewSortOrder); - } - -TInt CCntSortPlugin::SortStart(TSortStartTypes aSortStartType, TInt aCount) - { - TRAPD(ret, DoSortStartL(aSortStartType, aCount)); - return ret; - } - -void CCntSortPlugin::DoSortStartL - (TSortStartTypes /* aSortStartType */, TInt /* aCount */) - { - iLeftSortKeyArray->Reset(); - iRightSortKeyArray->Reset(); - - const TInt count = iSortOrder.Count(); - for (TInt i = 0; i < count; ++i) - { - TFieldType fieldType = iSortOrder[i]; - if (fieldType == KUidContactFieldGivenNamePronunciation || - fieldType == KUidContactFieldFamilyNamePronunciation || - fieldType == KUidContactFieldCompanyNamePronunciation) - { - iLeftSortKeyArray->AppendL - (TSortKey(KNullDesC, ESortKeyPronounciation)); - iRightSortKeyArray->AppendL - (TSortKey(KNullDesC, ESortKeyPronounciation)); - } - else - { - iLeftSortKeyArray->AppendL(TSortKey(KNullDesC, ESortKeyBasic)); - iRightSortKeyArray->AppendL(TSortKey(KNullDesC, ESortKeyBasic)); - } - } - } - -void CCntSortPlugin::SortCompleted() - { - iLeftSortKeyArray->Reset(); - iRightSortKeyArray->Reset(); - } - -TInt CCntSortPlugin::SortCompareViewContactsL - (const CViewContact& aLhs, const CViewContact& aRhs) - { - __ASSERT_DEBUG(aLhs.FieldCount() == iSortOrder.Count(), - Panic(EPanicPreCond_CompareViewContactsL)); - __ASSERT_DEBUG(aRhs.FieldCount() == iSortOrder.Count(), - Panic(EPanicPreCond_CompareViewContactsL)); - __ASSERT_DEBUG(iLeftSortKeyArray && - iLeftSortKeyArray->SortKeyCount() == iSortOrder.Count(), - Panic(EPanicPreCond_CompareViewContactsL)); - __ASSERT_DEBUG(iRightSortKeyArray && - iRightSortKeyArray->SortKeyCount() == iSortOrder.Count(), - Panic(EPanicPreCond_CompareViewContactsL)); - - // Change the text in the sortkeys to correspond fields in the contacts - const TInt count = iSortOrder.Count(); - for (TInt i = 0; i < count; ++i) - { - iLeftSortKeyArray->SetText(aLhs.Field(i), i); - iRightSortKeyArray->SetText(aRhs.Field(i), i); - } - - return iSortUtil->Interface()->CompareItems - (*iLeftSortKeyArray, *iRightSortKeyArray); - } - -TInt CCntSortPlugin::ApiCompareViewContactsL - (const CViewContact& aLhs, const CViewContact& aRhs) - { - return SortCompareViewContactsL(aLhs, aRhs); - } - -TBool CCntSortPlugin::ViewContactIsSortable - (const CViewContact& aViewContact) - { - return iIsSortable(aViewContact); - } - -// End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntsortplugin/src/ccntsortplugin.h --- a/phonebookengines/cntsortplugin/src/ccntsortplugin.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* -* Copyright (c) 2002 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: -* Contact model ECOM sort plugin -* -*/ - - -#ifndef __CCntSortPlugin_H__ -#define __CCntSortPlugin_H__ - -// INCLUDES -#include -#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS -#include -#endif - -// FORWARD DECLARATIONS -class CSortUtil; -class CSortKeyArray; - -// CLASS DECLARATION - -/** - * This class implements the functionality promised by - * the CViewContactSortInterfaceDefinition definition class. - */ -class CCntSortPlugin : public CViewContactSortPlugin - { - public: // Construction / Destruction - /** - * Two phase static constructor. - * @param aParams Parameters for construction. - * @return Newly created instance of CCntSortPlugin. - */ - static CCntSortPlugin* NewL(TAny* aParams); - ~CCntSortPlugin(); - - private: // From CContactViewSortConfigInterface - void SetSortOrderL(const RContactViewSortOrder& aViewSortOrder); - TInt SortStart(TSortStartTypes aSortStartType, TInt aCount); - void SortCompleted(); - TInt SortCompareViewContactsL - (const CViewContact& aLhs, const CViewContact& aRhs); - TInt ApiCompareViewContactsL - (const CViewContact& aLhs, const CViewContact& aRhs); - TInt CompareViewContactsL(const CViewContact& aLhs, const CViewContact& aRhs); - TBool ViewContactIsSortable(const CViewContact& aViewContact); - - private: // Implementation - /** - * Standard C++ constructor. - */ - CCntSortPlugin(); - - /** - * 2nd phase constructor. - */ - void ConstructL(TSortPluginParams* aParams); - - /** - * Do the actual sort starting. - * @param aSortStartType Type of the sort to start. - * @param aCount Approximate number of contacts to process. - */ - void DoSortStartL(TSortStartTypes aSortStartType, TInt aCount); - private: // Data - /// Own: The sort util - CSortUtil* iSortUtil; - /// Currently active sort order - RContactViewSortOrder iSortOrder; - /// Ref: Is sortable function - TBool(*iIsSortable)(const CViewContact& aViewContact); - /// Own: sort key array for left hand side - CSortKeyArray* iLeftSortKeyArray; - /// Own: sort key array for right hand side - CSortKeyArray* iRightSortKeyArray; - }; - -#endif // __CCntSortPlugin_H__ - -// End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntsortplugin/src/csortkeyarray.cpp --- a/phonebookengines/cntsortplugin/src/csortkeyarray.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -/* -* Copyright (c) 2002 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: -* Sort key array for Contact model ECOM sort plugin. -* -*/ - - -#include "csortkeyarray.h" - -namespace { - -#ifdef _DEBUG - -enum TPanicReason - { - EPanicPreCond_SetText - }; - -void Panic(TPanicReason aReason) - { - _LIT(KPanicText, "CSortKeyArray"); - User::Panic(KPanicText, aReason); - } - -#endif // _DEBUG - -} // namespace - -inline CSortKeyArray::CSortKeyArray() - { - } - -CSortKeyArray* CSortKeyArray::NewL() - { - return new(ELeave) CSortKeyArray; - } - -CSortKeyArray::~CSortKeyArray() - { - iKeyTypes.Close(); - iTexts.Close(); - } - -void CSortKeyArray::AppendL(const TSortKey& aKey) - { - User::LeaveIfError(iKeyTypes.Append(aKey.Type())); - TInt err = iTexts.Append(aKey.Text()); - if (err != KErrNone) - { - // if appending to iTexts was not successful remove also the - // item in iKeyTypes to keep arrays in sync. - iKeyTypes.Remove(iKeyTypes.Count() - 1); - User::Leave(err); - } - } - -void CSortKeyArray::SetText(const TDesC& aText, TInt aIndex) - { - __ASSERT_DEBUG(aIndex < iTexts.Count(), Panic(EPanicPreCond_SetText)); - iTexts[aIndex].Set(aText); - } - -void CSortKeyArray::Reset() - { - iKeyTypes.Reset(); - iTexts.Reset(); - } - -TInt CSortKeyArray::SortKeyCount() const - { - return iKeyTypes.Count(); - } - -TSortKey CSortKeyArray::SortKeyAt(TInt aIndex) const - { - return TSortKey(iTexts[aIndex], iKeyTypes[aIndex]); - } - -// End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntsortplugin/src/csortkeyarray.h --- a/phonebookengines/cntsortplugin/src/csortkeyarray.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* -* Copyright (c) 2002 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: -* Sort key array for Contact model ECOM sort plugin. -* -*/ - - -#ifndef __CSortKeyArray_H__ -#define __CSortKeyArray_H__ - -// INCLUDES -#include - -// CLASS DESCRIPTION -/** - * Sort key array for Contact model ECOM sort plugin. - */ -class CSortKeyArray : public CBase, - public MSortKeyArray - { - public: - /** - * Static constructor. - * @return Newly created instance of this class. - */ - static CSortKeyArray* NewL(); - - /** - * Standard c++ destructor. - */ - ~CSortKeyArray(); - - public: // Interface - /** - * Appends new sortkey to the array. - * @param aKey New sortkey to append. - */ - void AppendL(const TSortKey& aKey); - - /** - * Resets the sortkey array. - */ - void Reset(); - - /** - * Sets the text of the key in specified index. - * @param aText The text to set to key in index. - * @param aIndex The index where the key to be modified is. - */ - void SetText(const TDesC& aText, TInt aIndex); - - public: // from MSortKeyArray - TInt SortKeyCount() const; - TSortKey SortKeyAt(TInt aIndex) const; - - private: - /** - * C++ constructor. - */ - CSortKeyArray(); - - private: // Data - /// Own: Array of key types. - RArray iKeyTypes; - /// Own: Array of texts that correspond to types in array iKeyTypes. - RArray iTexts; - }; - -#endif // __CSortKeyArray_H__ - -// End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/cntsortplugin/src/dllmain.cpp --- a/phonebookengines/cntsortplugin/src/dllmain.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* -* Copyright (c) 2002 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: -* -*/ - - -// INCLUDES -#include -#include - -#include "ccntsortplugin.h" -#include "cntsortpluginuid.h" - -// Define the interface UIDs -const TImplementationProxy ImplementationTable[] = - { - IMPLEMENTATION_PROXY_ENTRY(KCntModelSortPluginImplementationUID, - CCntSortPlugin::NewL) - }; - -// The one and only exported function that is the ECom entry point -EXPORT_C const TImplementationProxy* ImplementationGroupProxy - (TInt& aTableCount) - { - aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); - - return ImplementationTable; - } - -// End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/eabi/cntimageutilityu.def --- a/phonebookengines/eabi/cntimageutilityu.def Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookengines/eabi/cntimageutilityu.def Fri Oct 15 12:24:46 2010 +0300 @@ -19,4 +19,19 @@ _ZNK15CntImageUtility10metaObjectEv @ 18 NONAME _ZTI15CntImageUtility @ 19 NONAME _ZTV15CntImageUtility @ 20 NONAME + _ZN20CntOrientationHelper11orientationEv @ 21 NONAME + _ZN20CntOrientationHelper11qt_metacallEN11QMetaObject4CallEiPPv @ 22 NONAME + _ZN20CntOrientationHelper11qt_metacastEPKc @ 23 NONAME + _ZN20CntOrientationHelper16staticMetaObjectE @ 24 NONAME DATA 16 + _ZN20CntOrientationHelper18orientationChangedEN2Qt11OrientationE @ 25 NONAME + _ZN20CntOrientationHelper19getStaticMetaObjectEv @ 26 NONAME + _ZN20CntOrientationHelper22emitOrientationChangedERK13XQSettingsKeyRK8QVariant @ 27 NONAME + _ZN20CntOrientationHelperC1EP7QObject @ 28 NONAME + _ZN20CntOrientationHelperC2EP7QObject @ 29 NONAME + _ZN20CntOrientationHelperD0Ev @ 30 NONAME + _ZN20CntOrientationHelperD1Ev @ 31 NONAME + _ZN20CntOrientationHelperD2Ev @ 32 NONAME + _ZNK20CntOrientationHelper10metaObjectEv @ 33 NONAME + _ZTI20CntOrientationHelper @ 34 NONAME + _ZTV20CntOrientationHelper @ 35 NONAME diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookengines/phonebookengines.pro --- a/phonebookengines/phonebookengines.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookengines/phonebookengines.pro Fri Oct 15 12:24:46 2010 +0300 @@ -22,9 +22,6 @@ TEMPLATE = subdirs -SUBDIRS += cntfindplugin -SUBDIRS += cntsortplugin -SUBDIRS += cntlistmodel SUBDIRS += cntactions SUBDIRS += cntsimutility SUBDIRS += cntimageutility diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/bwins/cntcommonuiu.def --- a/phonebookui/bwins/cntcommonuiu.def Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/bwins/cntcommonuiu.def Fri Oct 15 12:24:46 2010 +0300 @@ -1,177 +1,187 @@ EXPORTS ?trUtf8@CntDefaultViewManager@@SA?AVQString@@PBD0@Z @ 1 NONAME ; class QString CntDefaultViewManager::trUtf8(char const *, char const *) - ?activate@CntBaseSelectionView@@UAEXV?$QMap@HVQVariant@@@@@Z @ 2 NONAME ; void CntBaseSelectionView::activate(class QMap) - ?setViewNavigator@CntDefaultViewManager@@QAEXPAVCntViewNavigator@@@Z @ 3 NONAME ; void CntDefaultViewManager::setViewNavigator(class CntViewNavigator *) - ?tr@CntActionPopup@@SA?AVQString@@PBD0@Z @ 4 NONAME ; class QString CntActionPopup::tr(char const *, char const *) - ?currentViewId@CntDefaultViewManager@@QAEHXZ @ 5 NONAME ; int CntDefaultViewManager::currentViewId(void) - ?cleanup@CntDefaultViewManager@@AAEXXZ @ 6 NONAME ; void CntDefaultViewManager::cleanup(void) - ??1CntMainWindow@@UAE@XZ @ 7 NONAME ; CntMainWindow::~CntMainWindow(void) - ?viewActivated@CntContactCardView@@IAEXPAVCntAbstractViewManager@@V?$QMap@HVQVariant@@@@@Z @ 8 NONAME ; void CntContactCardView::viewActivated(class CntAbstractViewManager *, class QMap) - ?view@CntEditView@@UBEPAVHbView@@XZ @ 9 NONAME ; class HbView * CntEditView::view(void) const - ?qt_metacall@CntBaseSelectionView@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 10 NONAME ; int CntBaseSelectionView::qt_metacall(enum QMetaObject::Call, int, void * *) - ?trUtf8@CntGroupMemberView@@SA?AVQString@@PBD0H@Z @ 11 NONAME ; class QString CntGroupMemberView::trUtf8(char const *, char const *, int) - ?d_func@CntGroupMemberView@@AAEPAVCntGroupMemberViewPrivate@@XZ @ 12 NONAME ; class CntGroupMemberViewPrivate * CntGroupMemberView::d_func(void) - ?tr@CntMainWindow@@SA?AVQString@@PBD0@Z @ 13 NONAME ; class QString CntMainWindow::tr(char const *, char const *) - ?staticMetaObject@CntBaseSelectionView@@2UQMetaObject@@B @ 14 NONAME ; struct QMetaObject const CntBaseSelectionView::staticMetaObject - ?d_func@CntEditView@@AAEPAVCntEditViewPrivate@@XZ @ 15 NONAME ; class CntEditViewPrivate * CntEditView::d_func(void) - ?changesDiscarded@CntEditView@@IAEXXZ @ 16 NONAME ; void CntEditView::changesDiscarded(void) - ?view@CntGroupMemberView@@UBEPAVHbView@@XZ @ 17 NONAME ; class HbView * CntGroupMemberView::view(void) const - ??_ECntDefaultViewManager@@UAE@I@Z @ 18 NONAME ; CntDefaultViewManager::~CntDefaultViewManager(unsigned int) - ??_ECntBaseSelectionView@@UAE@I@Z @ 19 NONAME ; CntBaseSelectionView::~CntBaseSelectionView(unsigned int) - ?view@CntBaseSelectionView@@UBEPAVHbView@@XZ @ 20 NONAME ; class HbView * CntBaseSelectionView::view(void) const - ??1CntDefaultViewFactory@@UAE@XZ @ 21 NONAME ; CntDefaultViewFactory::~CntDefaultViewFactory(void) - ??_ECntDefaultViewFactory@@UAE@I@Z @ 22 NONAME ; CntDefaultViewFactory::~CntDefaultViewFactory(unsigned int) - ?trUtf8@CntDefaultViewManager@@SA?AVQString@@PBD0H@Z @ 23 NONAME ; class QString CntDefaultViewManager::trUtf8(char const *, char const *, int) - ?staticMetaObject@CntGroupMemberView@@2UQMetaObject@@B @ 24 NONAME ; struct QMetaObject const CntGroupMemberView::staticMetaObject - ?qt_metacast@CntActionPopup@@UAEPAXPBD@Z @ 25 NONAME ; void * CntActionPopup::qt_metacast(char const *) - ?deleteOldView@CntDefaultViewManager@@AAEXXZ @ 26 NONAME ; void CntDefaultViewManager::deleteOldView(void) - ?trUtf8@CntMainWindow@@SA?AVQString@@PBD0H@Z @ 27 NONAME ; class QString CntMainWindow::trUtf8(char const *, char const *, int) - ?trUtf8@CntEditView@@SA?AVQString@@PBD0H@Z @ 28 NONAME ; class QString CntEditView::trUtf8(char const *, char const *, int) - ??1CntEditView@@UAE@XZ @ 29 NONAME ; CntEditView::~CntEditView(void) - ?qt_metacast@CntBaseSelectionView@@UAEPAXPBD@Z @ 30 NONAME ; void * CntBaseSelectionView::qt_metacast(char const *) - ?metaObject@CntBaseSelectionView@@UBEPBUQMetaObject@@XZ @ 31 NONAME ; struct QMetaObject const * CntBaseSelectionView::metaObject(void) const - ?engine@CntDefaultViewManager@@QAEAAVCntAbstractEngine@@XZ @ 32 NONAME ; class CntAbstractEngine & CntDefaultViewManager::engine(void) - ?back@CntDefaultViewManager@@UAEXV?$QMap@HVQVariant@@@@_N@Z @ 33 NONAME ; void CntDefaultViewManager::back(class QMap, bool) - ??0CntKeyGrabber@@QAE@PAVHbMainWindow@@PAVQObject@@@Z @ 34 NONAME ; CntKeyGrabber::CntKeyGrabber(class HbMainWindow *, class QObject *) - ?qt_metacall@CntViewNavigator@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 35 NONAME ; int CntViewNavigator::qt_metacall(enum QMetaObject::Call, int, void * *) - ?activate@CntContactCardView@@UAEXV?$QMap@HVQVariant@@@@@Z @ 36 NONAME ; void CntContactCardView::activate(class QMap) - ?tr@CntKeyGrabber@@SA?AVQString@@PBD0H@Z @ 37 NONAME ; class QString CntKeyGrabber::tr(char const *, char const *, int) - ?tr@CntDefaultViewManager@@SA?AVQString@@PBD0H@Z @ 38 NONAME ; class QString CntDefaultViewManager::tr(char const *, char const *, int) - ?viewId@CntEditView@@UBEHXZ @ 39 NONAME ; int CntEditView::viewId(void) const - ??1CntGroupMemberView@@UAE@XZ @ 40 NONAME ; CntGroupMemberView::~CntGroupMemberView(void) - ?tr@CntGroupMemberView@@SA?AVQString@@PBD0H@Z @ 41 NONAME ; class QString CntGroupMemberView::tr(char const *, char const *, int) - ?qt_metacast@CntContactCardView@@UAEPAXPBD@Z @ 42 NONAME ; void * CntContactCardView::qt_metacast(char const *) - ?viewClosed@CntBaseSelectionView@@IAEXXZ @ 43 NONAME ; void CntBaseSelectionView::viewClosed(void) - ??1CntKeyGrabber@@UAE@XZ @ 44 NONAME ; CntKeyGrabber::~CntKeyGrabber(void) - ?showActionPopup@CntActionPopup@@QAE_NVQString@@@Z @ 45 NONAME ; bool CntActionPopup::showActionPopup(class QString) - ?trUtf8@CntActionPopup@@SA?AVQString@@PBD0@Z @ 46 NONAME ; class QString CntActionPopup::trUtf8(char const *, char const *) - ?tr@CntBaseSelectionView@@SA?AVQString@@PBD0H@Z @ 47 NONAME ; class QString CntBaseSelectionView::tr(char const *, char const *, int) - ?metaObject@CntContactCardView@@UBEPBUQMetaObject@@XZ @ 48 NONAME ; struct QMetaObject const * CntContactCardView::metaObject(void) const - ??0CntViewNavigator@@QAE@PAVQObject@@@Z @ 49 NONAME ; CntViewNavigator::CntViewNavigator(class QObject *) - ?d_func@CntContactCardView@@ABEPBVCntContactCardViewPrivate@@XZ @ 50 NONAME ; class CntContactCardViewPrivate const * CntContactCardView::d_func(void) const - ?trUtf8@CntBaseSelectionView@@SA?AVQString@@PBD0H@Z @ 51 NONAME ; class QString CntBaseSelectionView::trUtf8(char const *, char const *, int) - ?getStaticMetaObject@CntBaseSelectionView@@SAABUQMetaObject@@XZ @ 52 NONAME ; struct QMetaObject const & CntBaseSelectionView::getStaticMetaObject(void) - ??0CntDefaultViewManager@@QAE@PAVHbMainWindow@@@Z @ 53 NONAME ; CntDefaultViewManager::CntDefaultViewManager(class HbMainWindow *) - ??_ECntGroupMemberView@@UAE@I@Z @ 54 NONAME ; CntGroupMemberView::~CntGroupMemberView(unsigned int) - ?actionPopupCancelPressed@CntActionPopup@@IAEXXZ @ 55 NONAME ; void CntActionPopup::actionPopupCancelPressed(void) - ?getStaticMetaObject@CntActionPopup@@SAABUQMetaObject@@XZ @ 56 NONAME ; struct QMetaObject const & CntActionPopup::getStaticMetaObject(void) - ?next@CntViewNavigator@@QAEXABHAAV?$QFlags@W4ViewSwitchFlag@Hb@@@@@Z @ 57 NONAME ; void CntViewNavigator::next(int const &, class QFlags &) - ?createView@CntDefaultViewFactory@@UAEPAVCntAbstractView@@H@Z @ 58 NONAME ; class CntAbstractView * CntDefaultViewFactory::createView(int) - ?viewId@CntGroupMemberView@@UBEHXZ @ 59 NONAME ; int CntGroupMemberView::viewId(void) const - ?qt_metacast@CntEditView@@UAEPAXPBD@Z @ 60 NONAME ; void * CntEditView::qt_metacast(char const *) - ??0CntContactCardView@@QAE@_N@Z @ 61 NONAME ; CntContactCardView::CntContactCardView(bool) - ?contactRemoved@CntEditView@@IAEX_N@Z @ 62 NONAME ; void CntEditView::contactRemoved(bool) - ?d_func@CntActionPopup@@ABEPBVCntActionPopupPrivate@@XZ @ 63 NONAME ; class CntActionPopupPrivate const * CntActionPopup::d_func(void) const - ?trUtf8@CntContactCardView@@SA?AVQString@@PBD0@Z @ 64 NONAME ; class QString CntContactCardView::trUtf8(char const *, char const *) - ?metaObject@CntActionPopup@@UBEPBUQMetaObject@@XZ @ 65 NONAME ; struct QMetaObject const * CntActionPopup::metaObject(void) const - ?staticMetaObject@CntDefaultViewManager@@2UQMetaObject@@B @ 66 NONAME ; struct QMetaObject const CntDefaultViewManager::staticMetaObject - ?removeException@CntViewNavigator@@QAEXABH@Z @ 67 NONAME ; void CntViewNavigator::removeException(int const &) - ?trUtf8@CntViewNavigator@@SA?AVQString@@PBD0@Z @ 68 NONAME ; class QString CntViewNavigator::trUtf8(char const *, char const *) - ?isDefault@CntGroupMemberView@@UBE_NXZ @ 69 NONAME ; bool CntGroupMemberView::isDefault(void) const - ?getStaticMetaObject@CntKeyGrabber@@SAABUQMetaObject@@XZ @ 70 NONAME ; struct QMetaObject const & CntKeyGrabber::getStaticMetaObject(void) - ?metaObject@CntMainWindow@@UBEPBUQMetaObject@@XZ @ 71 NONAME ; struct QMetaObject const * CntMainWindow::metaObject(void) const - ??_ECntMainWindow@@UAE@I@Z @ 72 NONAME ; CntMainWindow::~CntMainWindow(unsigned int) - ?metaObject@CntDefaultViewManager@@UBEPBUQMetaObject@@XZ @ 73 NONAME ; struct QMetaObject const * CntDefaultViewManager::metaObject(void) const - ?changeView@CntDefaultViewManager@@UAEXV?$QMap@HVQVariant@@@@@Z @ 74 NONAME ; void CntDefaultViewManager::changeView(class QMap) - ?qt_metacast@CntGroupMemberView@@UAEPAXPBD@Z @ 75 NONAME ; void * CntGroupMemberView::qt_metacast(char const *) - ??_ECntContactCardView@@UAE@I@Z @ 76 NONAME ; CntContactCardView::~CntContactCardView(unsigned int) - ?staticMetaObject@CntViewNavigator@@2UQMetaObject@@B @ 77 NONAME ; struct QMetaObject const CntViewNavigator::staticMetaObject - ?activate@CntEditView@@UAEXV?$QMap@HVQVariant@@@@@Z @ 78 NONAME ; void CntEditView::activate(class QMap) - ?qt_metacall@CntContactCardView@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 79 NONAME ; int CntContactCardView::qt_metacall(enum QMetaObject::Call, int, void * *) - ?qt_metacall@CntMainWindow@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 80 NONAME ; int CntMainWindow::qt_metacall(enum QMetaObject::Call, int, void * *) - ?trUtf8@CntMainWindow@@SA?AVQString@@PBD0@Z @ 81 NONAME ; class QString CntMainWindow::trUtf8(char const *, char const *) - ?trUtf8@CntKeyGrabber@@SA?AVQString@@PBD0H@Z @ 82 NONAME ; class QString CntKeyGrabber::trUtf8(char const *, char const *, int) - ?staticMetaObject@CntMainWindow@@2UQMetaObject@@B @ 83 NONAME ; struct QMetaObject const CntMainWindow::staticMetaObject - ?isDefault@CntContactCardView@@UBE_NXZ @ 84 NONAME ; bool CntContactCardView::isDefault(void) const - ??1CntContactCardView@@UAE@XZ @ 85 NONAME ; CntContactCardView::~CntContactCardView(void) - ?trUtf8@CntGroupMemberView@@SA?AVQString@@PBD0@Z @ 86 NONAME ; class QString CntGroupMemberView::trUtf8(char const *, char const *) - ?qt_metacall@CntActionPopup@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 87 NONAME ; int CntActionPopup::qt_metacall(enum QMetaObject::Call, int, void * *) - ??0CntBaseSelectionView@@QAE@XZ @ 88 NONAME ; CntBaseSelectionView::CntBaseSelectionView(void) - ?tr@CntKeyGrabber@@SA?AVQString@@PBD0@Z @ 89 NONAME ; class QString CntKeyGrabber::tr(char const *, char const *) - ??0CntMainWindow@@QAE@PAVQWidget@@H@Z @ 90 NONAME ; CntMainWindow::CntMainWindow(class QWidget *, int) - ?setEngine@CntGroupMemberView@@UAEXAAVCntAbstractEngine@@@Z @ 91 NONAME ; void CntGroupMemberView::setEngine(class CntAbstractEngine &) - ??1CntActionPopup@@UAE@XZ @ 92 NONAME ; CntActionPopup::~CntActionPopup(void) - ?viewId@CntContactCardView@@UBEHXZ @ 93 NONAME ; int CntContactCardView::viewId(void) const - ?removeEffect@CntViewNavigator@@QAEXABH@Z @ 94 NONAME ; void CntViewNavigator::removeEffect(int const &) - ?getStaticMetaObject@CntContactCardView@@SAABUQMetaObject@@XZ @ 95 NONAME ; struct QMetaObject const & CntContactCardView::getStaticMetaObject(void) - ?staticMetaObject@CntActionPopup@@2UQMetaObject@@B @ 96 NONAME ; struct QMetaObject const CntActionPopup::staticMetaObject - ?staticMetaObject@CntEditView@@2UQMetaObject@@B @ 97 NONAME ; struct QMetaObject const CntEditView::staticMetaObject - ?staticMetaObject@CntKeyGrabber@@2UQMetaObject@@B @ 98 NONAME ; struct QMetaObject const CntKeyGrabber::staticMetaObject - ?viewOpened@CntBaseSelectionView@@IAEXPAVCntAbstractViewManager@@V?$QMap@HVQVariant@@@@@Z @ 99 NONAME ; void CntBaseSelectionView::viewOpened(class CntAbstractViewManager *, class QMap) - ??0CntDefaultViewFactory@@QAE@AAVCntExtensionManager@@@Z @ 100 NONAME ; CntDefaultViewFactory::CntDefaultViewFactory(class CntExtensionManager &) - ?setEngine@CntEditView@@UAEXAAVCntAbstractEngine@@@Z @ 101 NONAME ; void CntEditView::setEngine(class CntAbstractEngine &) - ?backPressed@CntContactCardView@@IAEXH@Z @ 102 NONAME ; void CntContactCardView::backPressed(int) - ?isDefault@CntEditView@@UBE_NXZ @ 103 NONAME ; bool CntEditView::isDefault(void) const - ?qt_metacall@CntKeyGrabber@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 104 NONAME ; int CntKeyGrabber::qt_metacall(enum QMetaObject::Call, int, void * *) - ??_ECntViewNavigator@@UAE@I@Z @ 105 NONAME ; CntViewNavigator::~CntViewNavigator(unsigned int) - ?d_func@CntGroupMemberView@@ABEPBVCntGroupMemberViewPrivate@@XZ @ 106 NONAME ; class CntGroupMemberViewPrivate const * CntGroupMemberView::d_func(void) const - ?trUtf8@CntContactCardView@@SA?AVQString@@PBD0H@Z @ 107 NONAME ; class QString CntContactCardView::trUtf8(char const *, char const *, int) - ?metaObject@CntKeyGrabber@@UBEPBUQMetaObject@@XZ @ 108 NONAME ; struct QMetaObject const * CntKeyGrabber::metaObject(void) const - ?addException@CntViewNavigator@@QAEXABH0@Z @ 109 NONAME ; void CntViewNavigator::addException(int const &, int const &) - ?getStaticMetaObject@CntGroupMemberView@@SAABUQMetaObject@@XZ @ 110 NONAME ; struct QMetaObject const & CntGroupMemberView::getStaticMetaObject(void) - ?closeApp@CntDefaultViewManager@@MAEXXZ @ 111 NONAME ; void CntDefaultViewManager::closeApp(void) - ??0CntGroupMemberView@@QAE@XZ @ 112 NONAME ; CntGroupMemberView::CntGroupMemberView(void) - ?deactivate@CntGroupMemberView@@UAEXXZ @ 113 NONAME ; void CntGroupMemberView::deactivate(void) - ??_ECntKeyGrabber@@UAE@I@Z @ 114 NONAME ; CntKeyGrabber::~CntKeyGrabber(unsigned int) - ?deactivate@CntBaseSelectionView@@UAEXXZ @ 115 NONAME ; void CntBaseSelectionView::deactivate(void) - ?d_func@CntEditView@@ABEPBVCntEditViewPrivate@@XZ @ 116 NONAME ; class CntEditViewPrivate const * CntEditView::d_func(void) const - ?setViewFactory@CntDefaultViewManager@@QAEXPAVCntAbstractViewFactory@@@Z @ 117 NONAME ; void CntDefaultViewManager::setViewFactory(class CntAbstractViewFactory *) - ?trUtf8@CntActionPopup@@SA?AVQString@@PBD0H@Z @ 118 NONAME ; class QString CntActionPopup::trUtf8(char const *, char const *, int) - ?tr@CntViewNavigator@@SA?AVQString@@PBD0@Z @ 119 NONAME ; class QString CntViewNavigator::tr(char const *, char const *) - ?getStaticMetaObject@CntViewNavigator@@SAABUQMetaObject@@XZ @ 120 NONAME ; struct QMetaObject const & CntViewNavigator::getStaticMetaObject(void) - ?tr@CntViewNavigator@@SA?AVQString@@PBD0H@Z @ 121 NONAME ; class QString CntViewNavigator::tr(char const *, char const *, int) - ?tr@CntActionPopup@@SA?AVQString@@PBD0H@Z @ 122 NONAME ; class QString CntActionPopup::tr(char const *, char const *, int) - ?qt_metacall@CntGroupMemberView@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 123 NONAME ; int CntGroupMemberView::qt_metacall(enum QMetaObject::Call, int, void * *) - ?metaObject@CntGroupMemberView@@UBEPBUQMetaObject@@XZ @ 124 NONAME ; struct QMetaObject const * CntGroupMemberView::metaObject(void) const - ?qt_metacast@CntDefaultViewManager@@UAEPAXPBD@Z @ 125 NONAME ; void * CntDefaultViewManager::qt_metacast(char const *) - ?qt_metacall@CntDefaultViewManager@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 126 NONAME ; int CntDefaultViewManager::qt_metacall(enum QMetaObject::Call, int, void * *) - ??0CntEditView@@QAE@XZ @ 127 NONAME ; CntEditView::CntEditView(void) - ?qt_metacast@CntViewNavigator@@UAEPAXPBD@Z @ 128 NONAME ; void * CntViewNavigator::qt_metacast(char const *) - ?view@CntContactCardView@@UBEPAVHbView@@XZ @ 129 NONAME ; class HbView * CntContactCardView::view(void) const - ?addToContacts@CntContactCardView@@IAEXXZ @ 130 NONAME ; void CntContactCardView::addToContacts(void) - ?setEngine@CntBaseSelectionView@@UAEXAAVCntAbstractEngine@@@Z @ 131 NONAME ; void CntBaseSelectionView::setEngine(class CntAbstractEngine &) - ?tr@CntContactCardView@@SA?AVQString@@PBD0H@Z @ 132 NONAME ; class QString CntContactCardView::tr(char const *, char const *, int) - ?addRoot@CntViewNavigator@@QAEXABH@Z @ 133 NONAME ; void CntViewNavigator::addRoot(int const &) - ?tr@CntContactCardView@@SA?AVQString@@PBD0@Z @ 134 NONAME ; class QString CntContactCardView::tr(char const *, char const *) - ?tr@CntEditView@@SA?AVQString@@PBD0@Z @ 135 NONAME ; class QString CntEditView::tr(char const *, char const *) - ?d_func@CntContactCardView@@AAEPAVCntContactCardViewPrivate@@XZ @ 136 NONAME ; class CntContactCardViewPrivate * CntContactCardView::d_func(void) - ?metaObject@CntViewNavigator@@UBEPBUQMetaObject@@XZ @ 137 NONAME ; struct QMetaObject const * CntViewNavigator::metaObject(void) const - ?activate@CntGroupMemberView@@UAEXV?$QMap@HVQVariant@@@@@Z @ 138 NONAME ; void CntGroupMemberView::activate(class QMap) - ?staticMetaObject@CntContactCardView@@2UQMetaObject@@B @ 139 NONAME ; struct QMetaObject const CntContactCardView::staticMetaObject - ?trUtf8@CntBaseSelectionView@@SA?AVQString@@PBD0@Z @ 140 NONAME ; class QString CntBaseSelectionView::trUtf8(char const *, char const *) - ?tr@CntBaseSelectionView@@SA?AVQString@@PBD0@Z @ 141 NONAME ; class QString CntBaseSelectionView::tr(char const *, char const *) - ?trUtf8@CntKeyGrabber@@SA?AVQString@@PBD0@Z @ 142 NONAME ; class QString CntKeyGrabber::trUtf8(char const *, char const *) - ?switchView@CntDefaultViewManager@@AAEXV?$QMap@HVQVariant@@@@V?$QFlags@W4ViewSwitchFlag@Hb@@@@@Z @ 143 NONAME ; void CntDefaultViewManager::switchView(class QMap, class QFlags) - ?deactivate@CntEditView@@UAEXXZ @ 144 NONAME ; void CntEditView::deactivate(void) - ?addEffect@CntViewNavigator@@QAEXABH0@Z @ 145 NONAME ; void CntViewNavigator::addEffect(int const &, int const &) - ??_ECntActionPopup@@UAE@I@Z @ 146 NONAME ; CntActionPopup::~CntActionPopup(unsigned int) - ?d_func@CntActionPopup@@AAEPAVCntActionPopupPrivate@@XZ @ 147 NONAME ; class CntActionPopupPrivate * CntActionPopup::d_func(void) - ?metaObject@CntEditView@@UBEPBUQMetaObject@@XZ @ 148 NONAME ; struct QMetaObject const * CntEditView::metaObject(void) const - ?contactUpdated@CntEditView@@IAEXH@Z @ 149 NONAME ; void CntEditView::contactUpdated(int) - ??1CntDefaultViewManager@@UAE@XZ @ 150 NONAME ; CntDefaultViewManager::~CntDefaultViewManager(void) - ?deactivate@CntContactCardView@@UAEXXZ @ 151 NONAME ; void CntContactCardView::deactivate(void) - ?tr@CntGroupMemberView@@SA?AVQString@@PBD0@Z @ 152 NONAME ; class QString CntGroupMemberView::tr(char const *, char const *) - ?getStaticMetaObject@CntDefaultViewManager@@SAABUQMetaObject@@XZ @ 153 NONAME ; struct QMetaObject const & CntDefaultViewManager::getStaticMetaObject(void) - ?trUtf8@CntViewNavigator@@SA?AVQString@@PBD0H@Z @ 154 NONAME ; class QString CntViewNavigator::trUtf8(char const *, char const *, int) - ?tr@CntEditView@@SA?AVQString@@PBD0H@Z @ 155 NONAME ; class QString CntEditView::tr(char const *, char const *, int) - ?qt_metacall@CntEditView@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 156 NONAME ; int CntEditView::qt_metacall(enum QMetaObject::Call, int, void * *) - ?getStaticMetaObject@CntEditView@@SAABUQMetaObject@@XZ @ 157 NONAME ; struct QMetaObject const & CntEditView::getStaticMetaObject(void) - ?trUtf8@CntEditView@@SA?AVQString@@PBD0@Z @ 158 NONAME ; class QString CntEditView::trUtf8(char const *, char const *) - ??1CntViewNavigator@@UAE@XZ @ 159 NONAME ; CntViewNavigator::~CntViewNavigator(void) - ?qt_metacast@CntMainWindow@@UAEPAXPBD@Z @ 160 NONAME ; void * CntMainWindow::qt_metacast(char const *) - ?isDefault@CntBaseSelectionView@@UBE_NXZ @ 161 NONAME ; bool CntBaseSelectionView::isDefault(void) const - ?back@CntViewNavigator@@QAEABHAAV?$QFlags@W4ViewSwitchFlag@Hb@@@@_N@Z @ 162 NONAME ; int const & CntViewNavigator::back(class QFlags &, bool) - ?setEngine@CntContactCardView@@UAEXAAVCntAbstractEngine@@@Z @ 163 NONAME ; void CntContactCardView::setEngine(class CntAbstractEngine &) - ??1CntBaseSelectionView@@UAE@XZ @ 164 NONAME ; CntBaseSelectionView::~CntBaseSelectionView(void) - ?tr@CntMainWindow@@SA?AVQString@@PBD0H@Z @ 165 NONAME ; class QString CntMainWindow::tr(char const *, char const *, int) - ?createPluginView@CntDefaultViewFactory@@AAEPAVCntAbstractView@@H@Z @ 166 NONAME ; class CntAbstractView * CntDefaultViewFactory::createPluginView(int) - ??_ECntEditView@@UAE@I@Z @ 167 NONAME ; CntEditView::~CntEditView(unsigned int) - ??0CntActionPopup@@QAE@PAVQContact@QtMobility@@@Z @ 168 NONAME ; CntActionPopup::CntActionPopup(class QtMobility::QContact *) - ?backPressed@CntGroupMemberView@@IAEXXZ @ 169 NONAME ; void CntGroupMemberView::backPressed(void) - ?executeContactAction@CntActionPopup@@IAEXAAVQContact@QtMobility@@VQContactDetail@3@VQString@@@Z @ 170 NONAME ; void CntActionPopup::executeContactAction(class QtMobility::QContact &, class QtMobility::QContactDetail, class QString) - ?getStaticMetaObject@CntMainWindow@@SAABUQMetaObject@@XZ @ 171 NONAME ; struct QMetaObject const & CntMainWindow::getStaticMetaObject(void) - ?eventFilter@CntKeyGrabber@@MAE_NPAVQObject@@PAVQEvent@@@Z @ 172 NONAME ; bool CntKeyGrabber::eventFilter(class QObject *, class QEvent *) - ?qt_metacast@CntKeyGrabber@@UAEPAXPBD@Z @ 173 NONAME ; void * CntKeyGrabber::qt_metacast(char const *) - ?tr@CntDefaultViewManager@@SA?AVQString@@PBD0@Z @ 174 NONAME ; class QString CntDefaultViewManager::tr(char const *, char const *) - ?removeCurrentView@CntDefaultViewManager@@AAEXXZ @ 175 NONAME ; void CntDefaultViewManager::removeCurrentView(void) + ?externalize@CntDefaultViewManager@@QBE?AVQString@@AAVQDataStream@@@Z @ 2 NONAME ; class QString CntDefaultViewManager::externalize(class QDataStream &) const + ?activate@CntBaseSelectionView@@UAEXV?$QMap@HVQVariant@@@@@Z @ 3 NONAME ; void CntBaseSelectionView::activate(class QMap) + ?setViewNavigator@CntDefaultViewManager@@QAEXPAVCntViewNavigator@@@Z @ 4 NONAME ; void CntDefaultViewManager::setViewNavigator(class CntViewNavigator *) + ?internalize@CntDefaultViewManager@@QAE_NAAVQDataStream@@@Z @ 5 NONAME ; bool CntDefaultViewManager::internalize(class QDataStream &) + ?tr@CntActionPopup@@SA?AVQString@@PBD0@Z @ 6 NONAME ; class QString CntActionPopup::tr(char const *, char const *) + ?cleanup@CntDefaultViewManager@@AAEXXZ @ 7 NONAME ; void CntDefaultViewManager::cleanup(void) + ?externalize@CntEditView@@UAE?AVQString@@AAVQDataStream@@@Z @ 8 NONAME ; class QString CntEditView::externalize(class QDataStream &) + ??1CntMainWindow@@UAE@XZ @ 9 NONAME ; CntMainWindow::~CntMainWindow(void) + ?viewActivated@CntContactCardView@@IAEXPAVCntAbstractViewManager@@V?$QMap@HVQVariant@@@@@Z @ 10 NONAME ; void CntContactCardView::viewActivated(class CntAbstractViewManager *, class QMap) + ?view@CntEditView@@UBEPAVHbView@@XZ @ 11 NONAME ; class HbView * CntEditView::view(void) const + ?qt_metacall@CntBaseSelectionView@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 12 NONAME ; int CntBaseSelectionView::qt_metacall(enum QMetaObject::Call, int, void * *) + ?trUtf8@CntGroupMemberView@@SA?AVQString@@PBD0H@Z @ 13 NONAME ; class QString CntGroupMemberView::trUtf8(char const *, char const *, int) + ?d_func@CntGroupMemberView@@AAEPAVCntGroupMemberViewPrivate@@XZ @ 14 NONAME ; class CntGroupMemberViewPrivate * CntGroupMemberView::d_func(void) + ?tr@CntMainWindow@@SA?AVQString@@PBD0@Z @ 15 NONAME ; class QString CntMainWindow::tr(char const *, char const *) + ?externalize@CntViewNavigator@@QAEXAAVQDataStream@@@Z @ 16 NONAME ; void CntViewNavigator::externalize(class QDataStream &) + ?staticMetaObject@CntBaseSelectionView@@2UQMetaObject@@B @ 17 NONAME ; struct QMetaObject const CntBaseSelectionView::staticMetaObject + ?d_func@CntEditView@@AAEPAVCntEditViewPrivate@@XZ @ 18 NONAME ; class CntEditViewPrivate * CntEditView::d_func(void) + ?changesDiscarded@CntEditView@@IAEXXZ @ 19 NONAME ; void CntEditView::changesDiscarded(void) + ?view@CntGroupMemberView@@UBEPAVHbView@@XZ @ 20 NONAME ; class HbView * CntGroupMemberView::view(void) const + ??_ECntDefaultViewManager@@UAE@I@Z @ 21 NONAME ; CntDefaultViewManager::~CntDefaultViewManager(unsigned int) + ??_ECntBaseSelectionView@@UAE@I@Z @ 22 NONAME ; CntBaseSelectionView::~CntBaseSelectionView(unsigned int) + ?view@CntBaseSelectionView@@UBEPAVHbView@@XZ @ 23 NONAME ; class HbView * CntBaseSelectionView::view(void) const + ??1CntDefaultViewFactory@@UAE@XZ @ 24 NONAME ; CntDefaultViewFactory::~CntDefaultViewFactory(void) + ??_ECntDefaultViewFactory@@UAE@I@Z @ 25 NONAME ; CntDefaultViewFactory::~CntDefaultViewFactory(unsigned int) + ?trUtf8@CntDefaultViewManager@@SA?AVQString@@PBD0H@Z @ 26 NONAME ; class QString CntDefaultViewManager::trUtf8(char const *, char const *, int) + ?staticMetaObject@CntGroupMemberView@@2UQMetaObject@@B @ 27 NONAME ; struct QMetaObject const CntGroupMemberView::staticMetaObject + ?qt_metacast@CntActionPopup@@UAEPAXPBD@Z @ 28 NONAME ; void * CntActionPopup::qt_metacast(char const *) + ?deleteOldView@CntDefaultViewManager@@AAEXXZ @ 29 NONAME ; void CntDefaultViewManager::deleteOldView(void) + ?trUtf8@CntMainWindow@@SA?AVQString@@PBD0H@Z @ 30 NONAME ; class QString CntMainWindow::trUtf8(char const *, char const *, int) + ?trUtf8@CntEditView@@SA?AVQString@@PBD0H@Z @ 31 NONAME ; class QString CntEditView::trUtf8(char const *, char const *, int) + ??1CntEditView@@UAE@XZ @ 32 NONAME ; CntEditView::~CntEditView(void) + ?qt_metacast@CntBaseSelectionView@@UAEPAXPBD@Z @ 33 NONAME ; void * CntBaseSelectionView::qt_metacast(char const *) + ?externalize@CntContactCardView@@UAE?AVQString@@AAVQDataStream@@@Z @ 34 NONAME ; class QString CntContactCardView::externalize(class QDataStream &) + ?metaObject@CntBaseSelectionView@@UBEPBUQMetaObject@@XZ @ 35 NONAME ; struct QMetaObject const * CntBaseSelectionView::metaObject(void) const + ?engine@CntDefaultViewManager@@QAEAAVCntAbstractEngine@@XZ @ 36 NONAME ; class CntAbstractEngine & CntDefaultViewManager::engine(void) + ?back@CntDefaultViewManager@@UAEXV?$QMap@HVQVariant@@@@_N@Z @ 37 NONAME ; void CntDefaultViewManager::back(class QMap, bool) + ??0CntKeyGrabber@@QAE@PAVHbMainWindow@@PAVQObject@@@Z @ 38 NONAME ; CntKeyGrabber::CntKeyGrabber(class HbMainWindow *, class QObject *) + ?qt_metacall@CntViewNavigator@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 39 NONAME ; int CntViewNavigator::qt_metacall(enum QMetaObject::Call, int, void * *) + ?activate@CntContactCardView@@UAEXV?$QMap@HVQVariant@@@@@Z @ 40 NONAME ; void CntContactCardView::activate(class QMap) + ?tr@CntKeyGrabber@@SA?AVQString@@PBD0H@Z @ 41 NONAME ; class QString CntKeyGrabber::tr(char const *, char const *, int) + ?tr@CntDefaultViewManager@@SA?AVQString@@PBD0H@Z @ 42 NONAME ; class QString CntDefaultViewManager::tr(char const *, char const *, int) + ?viewId@CntEditView@@UBEHXZ @ 43 NONAME ; int CntEditView::viewId(void) const + ??1CntGroupMemberView@@UAE@XZ @ 44 NONAME ; CntGroupMemberView::~CntGroupMemberView(void) + ?tr@CntGroupMemberView@@SA?AVQString@@PBD0H@Z @ 45 NONAME ; class QString CntGroupMemberView::tr(char const *, char const *, int) + ?qt_metacast@CntContactCardView@@UAEPAXPBD@Z @ 46 NONAME ; void * CntContactCardView::qt_metacast(char const *) + ?viewClosed@CntBaseSelectionView@@IAEXXZ @ 47 NONAME ; void CntBaseSelectionView::viewClosed(void) + ??1CntKeyGrabber@@UAE@XZ @ 48 NONAME ; CntKeyGrabber::~CntKeyGrabber(void) + ?showActionPopup@CntActionPopup@@QAE_NVQString@@@Z @ 49 NONAME ; bool CntActionPopup::showActionPopup(class QString) + ?trUtf8@CntActionPopup@@SA?AVQString@@PBD0@Z @ 50 NONAME ; class QString CntActionPopup::trUtf8(char const *, char const *) + ?tr@CntBaseSelectionView@@SA?AVQString@@PBD0H@Z @ 51 NONAME ; class QString CntBaseSelectionView::tr(char const *, char const *, int) + ?metaObject@CntContactCardView@@UBEPBUQMetaObject@@XZ @ 52 NONAME ; struct QMetaObject const * CntContactCardView::metaObject(void) const + ??0CntViewNavigator@@QAE@PAVQObject@@@Z @ 53 NONAME ; CntViewNavigator::CntViewNavigator(class QObject *) + ?d_func@CntContactCardView@@ABEPBVCntContactCardViewPrivate@@XZ @ 54 NONAME ; class CntContactCardViewPrivate const * CntContactCardView::d_func(void) const + ?trUtf8@CntBaseSelectionView@@SA?AVQString@@PBD0H@Z @ 55 NONAME ; class QString CntBaseSelectionView::trUtf8(char const *, char const *, int) + ?getStaticMetaObject@CntBaseSelectionView@@SAABUQMetaObject@@XZ @ 56 NONAME ; struct QMetaObject const & CntBaseSelectionView::getStaticMetaObject(void) + ??0CntDefaultViewManager@@QAE@PAVHbMainWindow@@@Z @ 57 NONAME ; CntDefaultViewManager::CntDefaultViewManager(class HbMainWindow *) + ??_ECntGroupMemberView@@UAE@I@Z @ 58 NONAME ; CntGroupMemberView::~CntGroupMemberView(unsigned int) + ?actionPopupCancelPressed@CntActionPopup@@IAEXXZ @ 59 NONAME ; void CntActionPopup::actionPopupCancelPressed(void) + ?getStaticMetaObject@CntActionPopup@@SAABUQMetaObject@@XZ @ 60 NONAME ; struct QMetaObject const & CntActionPopup::getStaticMetaObject(void) + ?next@CntViewNavigator@@QAEXABHAAV?$QFlags@W4ViewSwitchFlag@Hb@@@@@Z @ 61 NONAME ; void CntViewNavigator::next(int const &, class QFlags &) + ?createView@CntDefaultViewFactory@@UAEPAVCntAbstractView@@H@Z @ 62 NONAME ; class CntAbstractView * CntDefaultViewFactory::createView(int) + ?viewId@CntGroupMemberView@@UBEHXZ @ 63 NONAME ; int CntGroupMemberView::viewId(void) const + ?qt_metacast@CntEditView@@UAEPAXPBD@Z @ 64 NONAME ; void * CntEditView::qt_metacast(char const *) + ??0CntContactCardView@@QAE@_N@Z @ 65 NONAME ; CntContactCardView::CntContactCardView(bool) + ?contactRemoved@CntEditView@@IAEX_N@Z @ 66 NONAME ; void CntEditView::contactRemoved(bool) + ?d_func@CntActionPopup@@ABEPBVCntActionPopupPrivate@@XZ @ 67 NONAME ; class CntActionPopupPrivate const * CntActionPopup::d_func(void) const + ?trUtf8@CntContactCardView@@SA?AVQString@@PBD0@Z @ 68 NONAME ; class QString CntContactCardView::trUtf8(char const *, char const *) + ?metaObject@CntActionPopup@@UBEPBUQMetaObject@@XZ @ 69 NONAME ; struct QMetaObject const * CntActionPopup::metaObject(void) const + ?staticMetaObject@CntDefaultViewManager@@2UQMetaObject@@B @ 70 NONAME ; struct QMetaObject const CntDefaultViewManager::staticMetaObject + ?removeException@CntViewNavigator@@QAEXABH@Z @ 71 NONAME ; void CntViewNavigator::removeException(int const &) + ?trUtf8@CntViewNavigator@@SA?AVQString@@PBD0@Z @ 72 NONAME ; class QString CntViewNavigator::trUtf8(char const *, char const *) + ?isDefault@CntGroupMemberView@@UBE_NXZ @ 73 NONAME ; bool CntGroupMemberView::isDefault(void) const + ?getStaticMetaObject@CntKeyGrabber@@SAABUQMetaObject@@XZ @ 74 NONAME ; struct QMetaObject const & CntKeyGrabber::getStaticMetaObject(void) + ?metaObject@CntMainWindow@@UBEPBUQMetaObject@@XZ @ 75 NONAME ; struct QMetaObject const * CntMainWindow::metaObject(void) const + ??_ECntMainWindow@@UAE@I@Z @ 76 NONAME ; CntMainWindow::~CntMainWindow(unsigned int) + ?metaObject@CntDefaultViewManager@@UBEPBUQMetaObject@@XZ @ 77 NONAME ; struct QMetaObject const * CntDefaultViewManager::metaObject(void) const + ?internalize@CntContactCardView@@UAE_NAAVQDataStream@@AAV?$QMap@HVQVariant@@@@@Z @ 78 NONAME ; bool CntContactCardView::internalize(class QDataStream &, class QMap &) + ?changeView@CntDefaultViewManager@@UAEXV?$QMap@HVQVariant@@@@@Z @ 79 NONAME ; void CntDefaultViewManager::changeView(class QMap) + ?qt_metacast@CntGroupMemberView@@UAEPAXPBD@Z @ 80 NONAME ; void * CntGroupMemberView::qt_metacast(char const *) + ??_ECntContactCardView@@UAE@I@Z @ 81 NONAME ; CntContactCardView::~CntContactCardView(unsigned int) + ?staticMetaObject@CntViewNavigator@@2UQMetaObject@@B @ 82 NONAME ; struct QMetaObject const CntViewNavigator::staticMetaObject + ?activate@CntEditView@@UAEXV?$QMap@HVQVariant@@@@@Z @ 83 NONAME ; void CntEditView::activate(class QMap) + ?qt_metacall@CntContactCardView@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 84 NONAME ; int CntContactCardView::qt_metacall(enum QMetaObject::Call, int, void * *) + ?qt_metacall@CntMainWindow@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 85 NONAME ; int CntMainWindow::qt_metacall(enum QMetaObject::Call, int, void * *) + ?trUtf8@CntMainWindow@@SA?AVQString@@PBD0@Z @ 86 NONAME ; class QString CntMainWindow::trUtf8(char const *, char const *) + ?trUtf8@CntKeyGrabber@@SA?AVQString@@PBD0H@Z @ 87 NONAME ; class QString CntKeyGrabber::trUtf8(char const *, char const *, int) + ?staticMetaObject@CntMainWindow@@2UQMetaObject@@B @ 88 NONAME ; struct QMetaObject const CntMainWindow::staticMetaObject + ?saveActivity@CntMainWindow@@AAEXXZ @ 89 NONAME ; void CntMainWindow::saveActivity(void) + ?isDefault@CntContactCardView@@UBE_NXZ @ 90 NONAME ; bool CntContactCardView::isDefault(void) const + ??1CntContactCardView@@UAE@XZ @ 91 NONAME ; CntContactCardView::~CntContactCardView(void) + ?trUtf8@CntGroupMemberView@@SA?AVQString@@PBD0@Z @ 92 NONAME ; class QString CntGroupMemberView::trUtf8(char const *, char const *) + ?qt_metacall@CntActionPopup@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 93 NONAME ; int CntActionPopup::qt_metacall(enum QMetaObject::Call, int, void * *) + ??0CntBaseSelectionView@@QAE@XZ @ 94 NONAME ; CntBaseSelectionView::CntBaseSelectionView(void) + ?tr@CntKeyGrabber@@SA?AVQString@@PBD0@Z @ 95 NONAME ; class QString CntKeyGrabber::tr(char const *, char const *) + ??0CntMainWindow@@QAE@PAVQWidget@@H@Z @ 96 NONAME ; CntMainWindow::CntMainWindow(class QWidget *, int) + ?setEngine@CntGroupMemberView@@UAEXAAVCntAbstractEngine@@@Z @ 97 NONAME ; void CntGroupMemberView::setEngine(class CntAbstractEngine &) + ??1CntActionPopup@@UAE@XZ @ 98 NONAME ; CntActionPopup::~CntActionPopup(void) + ?viewId@CntContactCardView@@UBEHXZ @ 99 NONAME ; int CntContactCardView::viewId(void) const + ?removeEffect@CntViewNavigator@@QAEXABH@Z @ 100 NONAME ; void CntViewNavigator::removeEffect(int const &) + ?getStaticMetaObject@CntContactCardView@@SAABUQMetaObject@@XZ @ 101 NONAME ; struct QMetaObject const & CntContactCardView::getStaticMetaObject(void) + ?staticMetaObject@CntEditView@@2UQMetaObject@@B @ 102 NONAME ; struct QMetaObject const CntEditView::staticMetaObject + ?staticMetaObject@CntActionPopup@@2UQMetaObject@@B @ 103 NONAME ; struct QMetaObject const CntActionPopup::staticMetaObject + ?staticMetaObject@CntKeyGrabber@@2UQMetaObject@@B @ 104 NONAME ; struct QMetaObject const CntKeyGrabber::staticMetaObject + ?viewOpened@CntBaseSelectionView@@IAEXPAVCntAbstractViewManager@@V?$QMap@HVQVariant@@@@@Z @ 105 NONAME ; void CntBaseSelectionView::viewOpened(class CntAbstractViewManager *, class QMap) + ??0CntDefaultViewFactory@@QAE@AAVCntExtensionManager@@@Z @ 106 NONAME ; CntDefaultViewFactory::CntDefaultViewFactory(class CntExtensionManager &) + ?setEngine@CntEditView@@UAEXAAVCntAbstractEngine@@@Z @ 107 NONAME ; void CntEditView::setEngine(class CntAbstractEngine &) + ?backPressed@CntContactCardView@@IAEXH@Z @ 108 NONAME ; void CntContactCardView::backPressed(int) + ?isDefault@CntEditView@@UBE_NXZ @ 109 NONAME ; bool CntEditView::isDefault(void) const + ?qt_metacall@CntKeyGrabber@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 110 NONAME ; int CntKeyGrabber::qt_metacall(enum QMetaObject::Call, int, void * *) + ??_ECntViewNavigator@@UAE@I@Z @ 111 NONAME ; CntViewNavigator::~CntViewNavigator(unsigned int) + ?d_func@CntGroupMemberView@@ABEPBVCntGroupMemberViewPrivate@@XZ @ 112 NONAME ; class CntGroupMemberViewPrivate const * CntGroupMemberView::d_func(void) const + ?trUtf8@CntContactCardView@@SA?AVQString@@PBD0H@Z @ 113 NONAME ; class QString CntContactCardView::trUtf8(char const *, char const *, int) + ?metaObject@CntKeyGrabber@@UBEPBUQMetaObject@@XZ @ 114 NONAME ; struct QMetaObject const * CntKeyGrabber::metaObject(void) const + ?addException@CntViewNavigator@@QAEXABH0@Z @ 115 NONAME ; void CntViewNavigator::addException(int const &, int const &) + ?getStaticMetaObject@CntGroupMemberView@@SAABUQMetaObject@@XZ @ 116 NONAME ; struct QMetaObject const & CntGroupMemberView::getStaticMetaObject(void) + ?closeApp@CntDefaultViewManager@@MAEXXZ @ 117 NONAME ; void CntDefaultViewManager::closeApp(void) + ??0CntGroupMemberView@@QAE@XZ @ 118 NONAME ; CntGroupMemberView::CntGroupMemberView(void) + ?deactivate@CntGroupMemberView@@UAEXXZ @ 119 NONAME ; void CntGroupMemberView::deactivate(void) + ??_ECntKeyGrabber@@UAE@I@Z @ 120 NONAME ; CntKeyGrabber::~CntKeyGrabber(unsigned int) + ?deactivate@CntBaseSelectionView@@UAEXXZ @ 121 NONAME ; void CntBaseSelectionView::deactivate(void) + ?d_func@CntEditView@@ABEPBVCntEditViewPrivate@@XZ @ 122 NONAME ; class CntEditViewPrivate const * CntEditView::d_func(void) const + ?setViewFactory@CntDefaultViewManager@@QAEXPAVCntAbstractViewFactory@@@Z @ 123 NONAME ; void CntDefaultViewManager::setViewFactory(class CntAbstractViewFactory *) + ?trUtf8@CntActionPopup@@SA?AVQString@@PBD0H@Z @ 124 NONAME ; class QString CntActionPopup::trUtf8(char const *, char const *, int) + ?tr@CntViewNavigator@@SA?AVQString@@PBD0@Z @ 125 NONAME ; class QString CntViewNavigator::tr(char const *, char const *) + ?getStaticMetaObject@CntViewNavigator@@SAABUQMetaObject@@XZ @ 126 NONAME ; struct QMetaObject const & CntViewNavigator::getStaticMetaObject(void) + ?tr@CntViewNavigator@@SA?AVQString@@PBD0H@Z @ 127 NONAME ; class QString CntViewNavigator::tr(char const *, char const *, int) + ?tr@CntActionPopup@@SA?AVQString@@PBD0H@Z @ 128 NONAME ; class QString CntActionPopup::tr(char const *, char const *, int) + ?qt_metacall@CntGroupMemberView@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 129 NONAME ; int CntGroupMemberView::qt_metacall(enum QMetaObject::Call, int, void * *) + ?metaObject@CntGroupMemberView@@UBEPBUQMetaObject@@XZ @ 130 NONAME ; struct QMetaObject const * CntGroupMemberView::metaObject(void) const + ?qt_metacast@CntDefaultViewManager@@UAEPAXPBD@Z @ 131 NONAME ; void * CntDefaultViewManager::qt_metacast(char const *) + ?qt_metacall@CntDefaultViewManager@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 132 NONAME ; int CntDefaultViewManager::qt_metacall(enum QMetaObject::Call, int, void * *) + ??0CntEditView@@QAE@XZ @ 133 NONAME ; CntEditView::CntEditView(void) + ?qt_metacast@CntViewNavigator@@UAEPAXPBD@Z @ 134 NONAME ; void * CntViewNavigator::qt_metacast(char const *) + ?view@CntContactCardView@@UBEPAVHbView@@XZ @ 135 NONAME ; class HbView * CntContactCardView::view(void) const + ?addToContacts@CntContactCardView@@IAEXXZ @ 136 NONAME ; void CntContactCardView::addToContacts(void) + ?setEngine@CntBaseSelectionView@@UAEXAAVCntAbstractEngine@@@Z @ 137 NONAME ; void CntBaseSelectionView::setEngine(class CntAbstractEngine &) + ?tr@CntContactCardView@@SA?AVQString@@PBD0H@Z @ 138 NONAME ; class QString CntContactCardView::tr(char const *, char const *, int) + ?addRoot@CntViewNavigator@@QAEXABH@Z @ 139 NONAME ; void CntViewNavigator::addRoot(int const &) + ?tr@CntContactCardView@@SA?AVQString@@PBD0@Z @ 140 NONAME ; class QString CntContactCardView::tr(char const *, char const *) + ?tr@CntEditView@@SA?AVQString@@PBD0@Z @ 141 NONAME ; class QString CntEditView::tr(char const *, char const *) + ?d_func@CntContactCardView@@AAEPAVCntContactCardViewPrivate@@XZ @ 142 NONAME ; class CntContactCardViewPrivate * CntContactCardView::d_func(void) + ?metaObject@CntViewNavigator@@UBEPBUQMetaObject@@XZ @ 143 NONAME ; struct QMetaObject const * CntViewNavigator::metaObject(void) const + ?staticMetaObject@CntContactCardView@@2UQMetaObject@@B @ 144 NONAME ; struct QMetaObject const CntContactCardView::staticMetaObject + ?activate@CntGroupMemberView@@UAEXV?$QMap@HVQVariant@@@@@Z @ 145 NONAME ; void CntGroupMemberView::activate(class QMap) + ?trUtf8@CntBaseSelectionView@@SA?AVQString@@PBD0@Z @ 146 NONAME ; class QString CntBaseSelectionView::trUtf8(char const *, char const *) + ?tr@CntBaseSelectionView@@SA?AVQString@@PBD0@Z @ 147 NONAME ; class QString CntBaseSelectionView::tr(char const *, char const *) + ?trUtf8@CntKeyGrabber@@SA?AVQString@@PBD0@Z @ 148 NONAME ; class QString CntKeyGrabber::trUtf8(char const *, char const *) + ?switchView@CntDefaultViewManager@@AAEXV?$QMap@HVQVariant@@@@V?$QFlags@W4ViewSwitchFlag@Hb@@@@@Z @ 149 NONAME ; void CntDefaultViewManager::switchView(class QMap, class QFlags) + ?deactivate@CntEditView@@UAEXXZ @ 150 NONAME ; void CntEditView::deactivate(void) + ?addEffect@CntViewNavigator@@QAEXABH0@Z @ 151 NONAME ; void CntViewNavigator::addEffect(int const &, int const &) + ??_ECntActionPopup@@UAE@I@Z @ 152 NONAME ; CntActionPopup::~CntActionPopup(unsigned int) + ?d_func@CntActionPopup@@AAEPAVCntActionPopupPrivate@@XZ @ 153 NONAME ; class CntActionPopupPrivate * CntActionPopup::d_func(void) + ?metaObject@CntEditView@@UBEPBUQMetaObject@@XZ @ 154 NONAME ; struct QMetaObject const * CntEditView::metaObject(void) const + ?contactUpdated@CntEditView@@IAEXH@Z @ 155 NONAME ; void CntEditView::contactUpdated(int) + ??1CntDefaultViewManager@@UAE@XZ @ 156 NONAME ; CntDefaultViewManager::~CntDefaultViewManager(void) + ?deactivate@CntContactCardView@@UAEXXZ @ 157 NONAME ; void CntContactCardView::deactivate(void) + ?clearViewStack@CntViewNavigator@@QAEXXZ @ 158 NONAME ; void CntViewNavigator::clearViewStack(void) + ?tr@CntGroupMemberView@@SA?AVQString@@PBD0@Z @ 159 NONAME ; class QString CntGroupMemberView::tr(char const *, char const *) + ?getStaticMetaObject@CntDefaultViewManager@@SAABUQMetaObject@@XZ @ 160 NONAME ; struct QMetaObject const & CntDefaultViewManager::getStaticMetaObject(void) + ?trUtf8@CntViewNavigator@@SA?AVQString@@PBD0H@Z @ 161 NONAME ; class QString CntViewNavigator::trUtf8(char const *, char const *, int) + ?tr@CntEditView@@SA?AVQString@@PBD0H@Z @ 162 NONAME ; class QString CntEditView::tr(char const *, char const *, int) + ?qt_metacall@CntEditView@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 163 NONAME ; int CntEditView::qt_metacall(enum QMetaObject::Call, int, void * *) + ?internalize@CntEditView@@UAE_NAAVQDataStream@@AAV?$QMap@HVQVariant@@@@@Z @ 164 NONAME ; bool CntEditView::internalize(class QDataStream &, class QMap &) + ?getStaticMetaObject@CntEditView@@SAABUQMetaObject@@XZ @ 165 NONAME ; struct QMetaObject const & CntEditView::getStaticMetaObject(void) + ?trUtf8@CntEditView@@SA?AVQString@@PBD0@Z @ 166 NONAME ; class QString CntEditView::trUtf8(char const *, char const *) + ?activateView@CntDefaultViewManager@@AAEXPAVCntAbstractView@@V?$QMap@HVQVariant@@@@V?$QFlags@W4ViewSwitchFlag@Hb@@@@@Z @ 167 NONAME ; void CntDefaultViewManager::activateView(class CntAbstractView *, class QMap, class QFlags) + ??1CntViewNavigator@@UAE@XZ @ 168 NONAME ; CntViewNavigator::~CntViewNavigator(void) + ?qt_metacast@CntMainWindow@@UAEPAXPBD@Z @ 169 NONAME ; void * CntMainWindow::qt_metacast(char const *) + ?isDefault@CntBaseSelectionView@@UBE_NXZ @ 170 NONAME ; bool CntBaseSelectionView::isDefault(void) const + ?back@CntViewNavigator@@QAEABHAAV?$QFlags@W4ViewSwitchFlag@Hb@@@@_N@Z @ 171 NONAME ; int const & CntViewNavigator::back(class QFlags &, bool) + ?setEngine@CntContactCardView@@UAEXAAVCntAbstractEngine@@@Z @ 172 NONAME ; void CntContactCardView::setEngine(class CntAbstractEngine &) + ??1CntBaseSelectionView@@UAE@XZ @ 173 NONAME ; CntBaseSelectionView::~CntBaseSelectionView(void) + ?tr@CntMainWindow@@SA?AVQString@@PBD0H@Z @ 174 NONAME ; class QString CntMainWindow::tr(char const *, char const *, int) + ?createPluginView@CntDefaultViewFactory@@AAEPAVCntAbstractView@@H@Z @ 175 NONAME ; class CntAbstractView * CntDefaultViewFactory::createPluginView(int) + ??_ECntEditView@@UAE@I@Z @ 176 NONAME ; CntEditView::~CntEditView(unsigned int) + ??0CntActionPopup@@QAE@PAVQContact@QtMobility@@@Z @ 177 NONAME ; CntActionPopup::CntActionPopup(class QtMobility::QContact *) + ?backPressed@CntGroupMemberView@@IAEXXZ @ 178 NONAME ; void CntGroupMemberView::backPressed(void) + ?executeContactAction@CntActionPopup@@IAEXAAVQContact@QtMobility@@VQContactDetail@3@VQString@@@Z @ 179 NONAME ; void CntActionPopup::executeContactAction(class QtMobility::QContact &, class QtMobility::QContactDetail, class QString) + ?getStaticMetaObject@CntMainWindow@@SAABUQMetaObject@@XZ @ 180 NONAME ; struct QMetaObject const & CntMainWindow::getStaticMetaObject(void) + ?eventFilter@CntKeyGrabber@@MAE_NPAVQObject@@PAVQEvent@@@Z @ 181 NONAME ; bool CntKeyGrabber::eventFilter(class QObject *, class QEvent *) + ?qt_metacast@CntKeyGrabber@@UAEPAXPBD@Z @ 182 NONAME ; void * CntKeyGrabber::qt_metacast(char const *) + ?tr@CntDefaultViewManager@@SA?AVQString@@PBD0@Z @ 183 NONAME ; class QString CntDefaultViewManager::tr(char const *, char const *) + ?internalize@CntViewNavigator@@QAEHAAVQDataStream@@@Z @ 184 NONAME ; int CntViewNavigator::internalize(class QDataStream &) + ?removeCurrentView@CntDefaultViewManager@@AAEXXZ @ 185 NONAME ; void CntDefaultViewManager::removeCurrentView(void) diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/bwins/cntlistmodelu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/bwins/cntlistmodelu.def Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,39 @@ +EXPORTS + ?updateRelationships@CntListModel@@AAEXXZ @ 1 NONAME ; void CntListModel::updateRelationships(void) + ?handleRemovedRelationship@CntListModel@@AAEXABV?$QList@I@@@Z @ 2 NONAME ; void CntListModel::handleRemovedRelationship(class QList const &) + ?refreshModel@CntListModel@@AAEXXZ @ 3 NONAME ; void CntListModel::refreshModel(void) + ?contact@CntListModel@@QBE?AVQContact@QtMobility@@ABVQModelIndex@@@Z @ 4 NONAME ; class QtMobility::QContact CntListModel::contact(class QModelIndex const &) const + ?updateContactIdsArray@CntListModel@@AAEXXZ @ 5 NONAME ; void CntListModel::updateContactIdsArray(void) + ?qt_metacall@CntListModel@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 6 NONAME ; int CntListModel::qt_metacall(enum QMetaObject::Call, int, void * *) + ?setFilter@CntListModel@@QAEXABVQContactFilter@QtMobility@@@Z @ 7 NONAME ; void CntListModel::setFilter(class QtMobility::QContactFilter const &) + ?row@CntListModel@@ABEHABI@Z @ 8 NONAME ; int CntListModel::row(unsigned int const &) const + ?indexOfContact@CntListModel@@QBE?AVQModelIndex@@ABVQContact@QtMobility@@@Z @ 9 NONAME ; class QModelIndex CntListModel::indexOfContact(class QtMobility::QContact const &) const + ?handleContactInfoUpdated@CntListModel@@AAEXI@Z @ 10 NONAME ; void CntListModel::handleContactInfoUpdated(unsigned int) + ?staticMetaObject@CntListModel@@2UQMetaObject@@B @ 11 NONAME ; struct QMetaObject const CntListModel::staticMetaObject + ?showMyCard@CntListModel@@QAEX_N@Z @ 12 NONAME ; void CntListModel::showMyCard(bool) + ?contact@CntListModel@@ABE?AVQContact@QtMobility@@H@Z @ 13 NONAME ; class QtMobility::QContact CntListModel::contact(int) const + ??_ECntListModel@@UAE@I@Z @ 14 NONAME ; CntListModel::~CntListModel(unsigned int) + ?handleAddedRelationship@CntListModel@@AAEXABV?$QList@I@@@Z @ 15 NONAME ; void CntListModel::handleAddedRelationship(class QList const &) + ?rowCount@CntListModel@@UBEHABVQModelIndex@@@Z @ 16 NONAME ; int CntListModel::rowCount(class QModelIndex const &) const + ?isValidRow@CntListModel@@ABE_NH@Z @ 17 NONAME ; bool CntListModel::isValidRow(int) const + ?trUtf8@CntListModel@@SA?AVQString@@PBD0H@Z @ 18 NONAME ; class QString CntListModel::trUtf8(char const *, char const *, int) + ?metaObject@CntListModel@@UBEPBUQMetaObject@@XZ @ 19 NONAME ; struct QMetaObject const * CntListModel::metaObject(void) const + ?myCardId@CntListModel@@QBEIXZ @ 20 NONAME ; unsigned int CntListModel::myCardId(void) const + ?contactId@CntListModel@@QBEIABVQModelIndex@@@Z @ 21 NONAME ; unsigned int CntListModel::contactId(class QModelIndex const &) const + ??0CntListModel@@QAE@PAVQContactManager@QtMobility@@ABVQContactFilter@2@_NPAVQObject@@@Z @ 22 NONAME ; CntListModel::CntListModel(class QtMobility::QContactManager *, class QtMobility::QContactFilter const &, bool, class QObject *) + ?handleRemoved@CntListModel@@AAEXABV?$QList@I@@@Z @ 23 NONAME ; void CntListModel::handleRemoved(class QList const &) + ?tr@CntListModel@@SA?AVQString@@PBD0@Z @ 24 NONAME ; class QString CntListModel::tr(char const *, char const *) + ?handleChanged@CntListModel@@AAEXABV?$QList@I@@@Z @ 25 NONAME ; void CntListModel::handleChanged(class QList const &) + ?getStaticMetaObject@CntListModel@@SAABUQMetaObject@@XZ @ 26 NONAME ; struct QMetaObject const & CntListModel::getStaticMetaObject(void) + ?indexOfContactId@CntListModel@@QBE?AVQModelIndex@@ABI@Z @ 27 NONAME ; class QModelIndex CntListModel::indexOfContactId(unsigned int const &) const + ?data@CntListModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z @ 28 NONAME ; class QVariant CntListModel::data(class QModelIndex const &, int) const + ?handleRowSettingChanged@CntListModel@@AAEXABVXQSettingsKey@@ABVQVariant@@@Z @ 29 NONAME ; void CntListModel::handleRowSettingChanged(class XQSettingsKey const &, class QVariant const &) + ?handleAdded@CntListModel@@AAEXABV?$QList@I@@@Z @ 30 NONAME ; void CntListModel::handleAdded(class QList const &) + ?trUtf8@CntListModel@@SA?AVQString@@PBD0@Z @ 31 NONAME ; class QString CntListModel::trUtf8(char const *, char const *) + ??1CntListModel@@UAE@XZ @ 32 NONAME ; CntListModel::~CntListModel(void) + ?tr@CntListModel@@SA?AVQString@@PBD0H@Z @ 33 NONAME ; class QString CntListModel::tr(char const *, char const *, int) + ?dataForRole@CntListModel@@ABE?AVQVariant@@HH@Z @ 34 NONAME ; class QVariant CntListModel::dataForRole(int, int) const + ?isMyCardShown@CntListModel@@QBE_NXZ @ 35 NONAME ; bool CntListModel::isMyCardShown(void) const + ?handleMyCardChanged@CntListModel@@AAEXABI0@Z @ 36 NONAME ; void CntListModel::handleMyCardChanged(unsigned int const &, unsigned int const &) + ?qt_metacast@CntListModel@@UAEPAXPBD@Z @ 37 NONAME ; void * CntListModel::qt_metacast(char const *) + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/cntcommonui.pro --- a/phonebookui/cntcommonui/cntcommonui.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/cntcommonui.pro Fri Oct 15 12:24:46 2010 +0300 @@ -27,11 +27,11 @@ DEPENDPATH += . INCLUDEPATH += . INCLUDEPATH += ../../inc -INCLUDEPATH += ../../phonebookengines/cntlistmodel/inc INCLUDEPATH += ../../phonebookengines/cntimageutility/inc INCLUDEPATH += ../../phonebookengines/cntsimutility/inc INCLUDEPATH += ../phonebookapp/inc -INCLUDEPATH += ../cnthistorymodel/inc +INCLUDEPATH += ../cntlistmodel +INCLUDEPATH += ../cnthistorymodel INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE @@ -68,6 +68,7 @@ # Input HEADERS += ../../inc/cntdebug.h \ + core/cntactivities.h \ core/cntabstractviewfactory.h \ core/cntdefaultengine.h \ core/cntdefaultviewmanager.h \ @@ -135,6 +136,7 @@ views/cntbaseselectionview.h \ views/cnthistoryview.h \ views/cnthistoryviewitem.h \ + views/cnthistoryviewitemwidget.h \ views/cntimageeditorview.h \ views/cntimportsview.h \ views/cntimportviewcallback.h \ @@ -143,13 +145,16 @@ views/cntnamesview_p.h \ views/cntsettingsmodel.h \ views/cntsettingsview.h \ + views/cntpinchgrabber.h \ + views/cntnamesviewitem.h \ widgets/cntactionpopup.h \ widgets/cntactionpopup_p.h \ widgets/cntfetchcontactpopup.h \ widgets/cntfetchmarkall.h \ widgets/cntimagelabel.h -SOURCES += core/cntdefaultengine.cpp \ +SOURCES += core/cntactivities.cpp \ + core/cntdefaultengine.cpp \ core/cntdefaultviewfactory.cpp \ core/cntdefaultviewmanager.cpp \ core/cntextensionmanager.cpp \ @@ -214,6 +219,7 @@ views/cntbaseselectionview.cpp \ views/cnthistoryview.cpp \ views/cnthistoryviewitem.cpp \ + views/cnthistoryviewitemwidget.cpp \ views/cntimageeditorview.cpp \ views/cntimportsview.cpp \ views/cntmycardview.cpp \ @@ -221,6 +227,8 @@ views/cntnamesview_p.cpp \ views/cntsettingsmodel.cpp \ views/cntsettingsview.cpp \ + views/cntpinchgrabber.cpp \ + views/cntnamesviewitem.cpp \ widgets/cntactionpopup_p.cpp \ widgets/cntactionpopup.cpp \ widgets/cntfetchcontactpopup.cpp \ @@ -270,4 +278,5 @@ "$${LITERAL_HASH}else" \ "DEFFILE ../bwins/cntcommonui.def" \ "$${LITERAL_HASH}endif" -MMP_RULES += defBlock \ No newline at end of file +MMP_RULES += defBlock +symbian:MMP_RULES += SMPSAFE \ No newline at end of file diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/collections/cntcollectionlistmodelworker.cpp --- a/phonebookui/cntcommonui/collections/cntcollectionlistmodelworker.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/collections/cntcollectionlistmodelworker.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -233,9 +233,8 @@ for(int i = 0;i < groupMemberIds.count();i++) { QContactFetchHint nameOnlyFetchHint; - /*QStringList details; - details << QContactDisplayLabel::DefinitionName; - nameOnlyFetchHint.setDetailDefinitionsHint(details);*/ + QStringList details(QContactDisplayLabel::DefinitionName); + nameOnlyFetchHint.setDetailDefinitionsHint(details); nameOnlyFetchHint.setOptimizationHints(QContactFetchHint::NoRelationships); QContact contact = mManager->contact(groupMemberIds.at(i), nameOnlyFetchHint); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/collections/cntcollectionview.cpp --- a/phonebookui/cntcommonui/collections/cntcollectionview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/collections/cntcollectionview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -48,6 +48,7 @@ #include const char *CNT_COLLECTIONVIEW_XML = ":/xml/contacts_collections.docml"; +const QString CNT_ACTIVITY_MAINVIEW = "ContactsMainView"; /*! @@ -193,6 +194,22 @@ CNT_EXIT } +QString CntCollectionView::externalize(QDataStream &stream) +{ + CntViewParameters viewParameters; + viewParameters.insert(EViewId, viewId()); + + stream << viewParameters; + + return CNT_ACTIVITY_MAINVIEW; +} + +bool CntCollectionView::internalize(QDataStream &stream, CntViewParameters &viewParameters) +{ + stream >> viewParameters; + return true; +} + void CntCollectionView::deactivate() { @@ -308,7 +325,7 @@ if (id != favoriteGrpId) { - HbAction* deleteAction = menu->addAction(hbTrId("txt_phob_menu_delete_group")); + HbAction* deleteAction = menu->addAction(hbTrId("txt_common_menu_delete")); deleteAction->setData( data ); } menu->open(this, SLOT(handleMenu(HbAction*))); @@ -414,7 +431,7 @@ else { CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup( - HbParameterLengthLimiter(hbTrId("txt_phob_title_members_of_1_group")).arg(groupNameCreated), + HbParameterLengthLimiter("txt_phob_title_members_of_1_group").arg(groupNameCreated), hbTrId("txt_common_button_save"), mEngine->contactManager(SYMBIAN_BACKEND)); connect( popup, SIGNAL(fetchReady(QSet)), this, SLOT(handleNewGroupMembers(QSet)) ); @@ -464,7 +481,7 @@ groupNameCreated = hbTrId("txt_phob_list_unnamed"); } HbDeviceNotificationDialog::notification(QString(), - HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_new_group_1_created")).arg(groupNameCreated)); + HbParameterLengthLimiter("txt_phob_dpophead_new_group_1_created").arg(groupNameCreated)); delete mHandledContact; mHandledContact = NULL; @@ -493,7 +510,7 @@ } HbLabel *headingLabel = new HbLabel(); - headingLabel->setPlainText(HbParameterLengthLimiter(hbTrId("txt_phob_dialog_delete_1_group")).arg(name)); + headingLabel->setPlainText(HbParameterLengthLimiter("txt_phob_dialog_delete_1_group").arg(name)); HbMessageBox::question(hbTrId("txt_phob_dialog_only_group_will_be_removed_contac") , this, SLOT(handleDeleteGroup(int)), HbMessageBox::Delete | HbMessageBox::Cancel, @@ -502,7 +519,7 @@ void CntCollectionView::handleDeleteGroup(int action) { - if (action == HbMessageBox::Delete) + if (action == HbMessageBox::Delete && mHandledContact != NULL) { getContactManager()->removeContact(mHandledContact->localId()); } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/collections/cntcollectionview.h --- a/phonebookui/cntcommonui/collections/cntcollectionview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/collections/cntcollectionview.h Fri Oct 15 12:24:46 2010 +0300 @@ -51,6 +51,8 @@ HbView* view() const { return mView; } int viewId() const { return collectionView; } inline void setEngine( CntAbstractEngine& aEngine ){mEngine = &aEngine;} + QString externalize(QDataStream &stream); + bool internalize(QDataStream &stream, CntViewParameters &viewParameters); public: // From CntExtensionGroupCallback void openView(CntViewParameters& viewParams); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/collections/cntfavoritesview.cpp --- a/phonebookui/cntcommonui/collections/cntfavoritesview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/collections/cntfavoritesview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -71,9 +71,9 @@ mContact = new QContact(aArgs.value(ESelectedGroupContact).value()); mViewManager = &mEngine->viewManager(); - HbPushButton *addButton = static_cast(mDocumentLoader.findWidget(QString("cnt_button_add"))); - connect(addButton, SIGNAL(clicked()), this, SLOT(openSelectionPopup())); - connect(addButton, SIGNAL(longPress(QPointF)), this, SLOT(openSelectionPopup())); + mAddButton = static_cast(mDocumentLoader.findWidget(QString("cnt_button_add"))); + connect(mAddButton, SIGNAL(released()), this, SLOT(openSelectionPopup())); + // If no contacts are present, then disable the button QContactDetailFilter filter; @@ -83,7 +83,7 @@ QList contactIds = getContactManager()->contactIds(filter); if (contactIds.isEmpty()) { - addButton->setEnabled(false); + mAddButton->setEnabled(false); } } @@ -94,15 +94,18 @@ void CntFavoritesView::openSelectionPopup() { - CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup( - hbTrId("txt_phob_title_favorite_contacts"), - hbTrId("txt_common_button_save"), - *getContactManager()); - connect(popup, SIGNAL(fetchReady(QSet)), - this, SLOT(handleMemberSelection(QSet))); - QSet ids; - popup->setSelectedContacts(ids); - popup->showPopup(); + if(mAddButton->isUnderMouse()) + { + CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup( + hbTrId("txt_phob_title_favorite_contacts"), + hbTrId("txt_common_button_save"), + *getContactManager()); + connect(popup, SIGNAL(fetchReady(QSet)), + this, SLOT(handleMemberSelection(QSet))); + QSet ids; + popup->setSelectedContacts(ids); + popup->showPopup(); + } } void CntFavoritesView::handleMemberSelection( QSet aIds ) diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/collections/cntfavoritesview.h --- a/phonebookui/cntcommonui/collections/cntfavoritesview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/collections/cntfavoritesview.h Fri Oct 15 12:24:46 2010 +0300 @@ -25,6 +25,7 @@ class HbAction; class HbView; +class HbPushButton; QTM_BEGIN_NAMESPACE class QContact; @@ -70,6 +71,7 @@ CntAbstractViewManager* mViewManager; HbDocumentLoader mDocumentLoader; CntAbstractEngine* mEngine; + HbPushButton *mAddButton; }; #endif // CNTFAVORITESVIEW_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/collections/cntgroupactionsview.cpp --- a/phonebookui/cntcommonui/collections/cntgroupactionsview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/collections/cntgroupactionsview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -173,10 +173,10 @@ mListView->setModel(mModel); mListView->setSelectionMode(HbAbstractItemView::NoSelection); - connect(mListView, SIGNAL(activated(const QModelIndex&)), - this, SLOT(listItemSelected(const QModelIndex&))); + connect( mListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(listItemSelected(const QModelIndex&))); - connect( mListView, SIGNAL(longPressed(HbAbstractViewItem*,const QPointF&)), this, SLOT(onLongPressed(HbAbstractViewItem*,const QPointF&)) ); + //This is to make long press act like short presswhen no tap menu + mListView->setLongPressEnabled(false); HbMainWindow* window = mView->mainWindow(); if (window) @@ -202,13 +202,6 @@ mModel->appendRow(items); } -void CntGroupActionsView::onLongPressed(HbAbstractViewItem *item, const QPointF &coords) -{ - Q_UNUSED(coords); - QModelIndex index = item->modelIndex(); - listItemSelected(index); -} - void CntGroupActionsView::listItemSelected(const QModelIndex &index) { if (index.isValid()) { @@ -245,7 +238,7 @@ } else { QContactEmailAddress email = contact.detail(); - mEmailActionParams.append(email.emailAddress()); + mEmailActionParams.insert(email.emailAddress(),QVariant(contact.displayLabel())); } } else { @@ -294,16 +287,9 @@ else if (action.compare("email", Qt::CaseInsensitive) == 0) { QContactEmailAddress email = static_cast(detail); - mEmailActionParams.append(email.emailAddress()); + mEmailActionParams.insert(email.emailAddress(),QVariant(contact.displayLabel())); } - - if (contact.preferredDetail(action).isEmpty()) - { - contact.setPreferredDetail(action, detail); - //return value will be ignored because we cannot do anything if it fails. - mEngine->contactManager(SYMBIAN_BACKEND).saveContact(&contact); - } - + //actionpopup executed, decrement counter mPopupCount--; if (mPopupCount==0) diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/collections/cntgroupactionsview.h --- a/phonebookui/cntcommonui/collections/cntgroupactionsview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/collections/cntgroupactionsview.h Fri Oct 15 12:24:46 2010 +0300 @@ -70,7 +70,6 @@ void actionExecuted(CntActionLauncher* aAction); void actionCancelled(); void executeConferenceCallAction(QContact& aContact, const QContactDetail& aDetail, const QString& aAction); - void onLongPressed (HbAbstractViewItem *item, const QPointF &coords); #ifdef PBK_UNIT_TEST public: @@ -96,7 +95,7 @@ HbAction* mSoftkey; // owned by view HbListView* mListView; // owned by layout int mPopupCount; - QStringList mEmailActionParams; + QVariantMap mEmailActionParams; QVariantMap mMessageActionParams; bool mIsExecutingAction; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/collections/cntgroupdeletepopup.cpp --- a/phonebookui/cntcommonui/collections/cntgroupdeletepopup.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/collections/cntgroupdeletepopup.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -18,7 +18,6 @@ #include "cntgroupdeletepopup.h" #include #include "cntglobal.h" -#include #include #include #include @@ -28,7 +27,8 @@ CntGroupDeletePopup::CntGroupDeletePopup(CntAbstractEngine *aEngine, QGraphicsItem *parent): HbSelectionDialog(parent), mContactManager( &aEngine->contactManager(SYMBIAN_BACKEND) ), - mModel(0) + mModel(NULL), + mPrimaryAction(NULL) { mModel = new CntGroupDeletePopupModel(aEngine, this); } @@ -41,20 +41,21 @@ void CntGroupDeletePopup::populateListOfGroup() { - HbLabel *headingLabel = new HbLabel(this); - headingLabel->setPlainText(hbTrId("txt_phob_opt_delete_groups")); - - setHeadingWidget(headingLabel); + setHeadingText(hbTrId("txt_phob_opt_delete_groups")); setSelectionMode( HbAbstractItemView::MultiSelection ); mModel->initializeGroupsList(); setModel(mModel); clearActions(); - HbAction *mPrimaryAction = new HbAction(hbTrId("txt_phob_button_delete_selected"), this); + mPrimaryAction = new HbAction(hbTrId("txt_phob_button_delete_selected"), this); addAction(mPrimaryAction); + mPrimaryAction->setEnabled(false); - HbAction *mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel"), this); - addAction(mSecondaryAction); + connect(this , SIGNAL(selectionChanged()), this, SLOT(checkPrimaryAction())); + QModelIndexList indexes = selectedModelIndexes(); + + HbAction *secondaryAction = new HbAction(hbTrId("txt_common_button_cancel"), this); + addAction(secondaryAction); setTimeout(HbDialog::NoTimeout); setDismissPolicy(HbDialog::NoDismiss); @@ -82,3 +83,17 @@ return selectionList; } + +void CntGroupDeletePopup::checkPrimaryAction() +{ + QModelIndexList indexes = selectedModelIndexes(); + if (indexes.count()) + { + mPrimaryAction->setEnabled(true); + } + else + { + mPrimaryAction->setEnabled(false); + } + +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/collections/cntgroupdeletepopup.h --- a/phonebookui/cntcommonui/collections/cntgroupdeletepopup.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/collections/cntgroupdeletepopup.h Fri Oct 15 12:24:46 2010 +0300 @@ -44,10 +44,15 @@ void populateListOfGroup(); QList deleteGroup() const; + +public slots: + + void checkPrimaryAction(); private: QContactManager *mContactManager; CntGroupDeletePopupModel *mModel; + HbAction *mPrimaryAction; }; #endif // CNTGROUPDELETEPOPUP_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/collections/cntgroupeditormodel.cpp --- a/phonebookui/cntcommonui/collections/cntgroupeditormodel.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/collections/cntgroupeditormodel.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -78,7 +78,7 @@ mContact->removeDetail( &iGroupName ); } - if(iGroupConfCallNumber.number().isEmpty()) + if (iGroupConfCallNumber.number().isEmpty()) { mContact->removeDetail( &iGroupConfCallNumber ); } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/collections/cntgroupmemberview_p.cpp --- a/phonebookui/cntcommonui/collections/cntgroupmemberview_p.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/collections/cntgroupmemberview_p.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -145,6 +145,7 @@ void CntGroupMemberViewPrivate::activate( const CntViewParameters aArgs ) { mArgs = aArgs; + mArgs.remove( ESelectedContact ); mViewManager = &mEngine->viewManager(); mThumbnailManager = &mEngine->thumbnailManager(); @@ -214,7 +215,7 @@ if (mArgs.value(ESelectedAction).toString() == CNT_SAVE_ACTION) { QString name = getContactManager()->synthesizedContactDisplayLabel(*mGroupContact); - HbNotificationDialog::launchDialog(HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_new_group_1_created").arg(name))); + HbNotificationDialog::launchDialog(HbParameterLengthLimiter("txt_phob_dpophead_new_group_1_created").arg(name)); } decideActionButtonContext(); } @@ -229,12 +230,10 @@ emit q->backPressed(); - //save the contact if avatar has been changed. - QContact contact = getContactManager()->contact(mGroupContact->localId()); - if ( contact != *mGroupContact ) - { - getContactManager()->saveContact(mGroupContact); - } + // SaveManager not used here. + // SaveManager checks for detail count and removes if contact empty. + getContactManager()->saveContact(mGroupContact); + mViewManager->back(mArgs); } @@ -265,7 +264,7 @@ } CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup( - HbParameterLengthLimiter(hbTrId("txt_phob_title_members_of_1_group")).arg(groupName), + HbParameterLengthLimiter("txt_phob_title_members_of_1_group").arg(groupName), hbTrId("txt_common_button_save"), mEngine->contactManager(SYMBIAN_BACKEND)); connect( popup, SIGNAL(fetchReady(QSet)),this, SLOT(handleManageMembers(QSet)) ); @@ -327,7 +326,7 @@ } HbLabel *headingLabel = new HbLabel(); - headingLabel->setPlainText(HbParameterLengthLimiter(hbTrId("txt_phob_dialog_delete_1_group")).arg(groupName)); + headingLabel->setPlainText(HbParameterLengthLimiter("txt_phob_dialog_delete_1_group").arg(groupName)); HbMessageBox::question(hbTrId("txt_phob_dialog_only_group_will_be_removed_contac"), this, SLOT(handleDeleteGroup(int)), HbMessageBox::Delete | HbMessageBox::Cancel, headingLabel); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/common/cntactionlauncher.cpp --- a/phonebookui/cntcommonui/common/cntactionlauncher.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/common/cntactionlauncher.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -19,63 +19,73 @@ /*! Action launcher. Caller should delete the instance. */ -CntActionLauncher::CntActionLauncher( QContactManager& aContactManager, QString aAction ) : QObject(), -mAction( aAction ), -mContactAction( NULL ), -mContactManager( &aContactManager ) +CntActionLauncher::CntActionLauncher( QContactManager& aContactManager, QString aAction ) : + QObject(), + mAction( aAction ), + mContactAction( NULL ), + mContactManager( &aContactManager ) +{ + +} + +CntActionLauncher::~CntActionLauncher() +{ + delete mContactAction; +} + +bool CntActionLauncher::execute( QContact aContact, QContactDetail aDetail ) +{ + bool executed = false; + QList all = QContactAction::actionDescriptors(mAction, "symbian"); + if ( all.count() ) { + mContactAction = QContactAction::action( all.first() ); + + if (mContactAction) + { + if (aContact.preferredDetail(mAction).isEmpty() && (mAction == "call")) + { + aContact.setPreferredDetail(mAction, aDetail); + //return value will be ignored because we cannot do anything if it fails. + mContactManager->saveContact(&aContact); + } + + connect(mContactAction, SIGNAL(stateChanged(QContactAction::State)), + this, SLOT(progress(QContactAction::State))); + executed = mContactAction->invokeAction( aContact, aDetail ); + } + else + { + progress(QContactAction::FinishedWithErrorState); + } + } + else + { + progress(QContactAction::FinishedWithErrorState); } -CntActionLauncher::~CntActionLauncher() - { - delete mContactAction; - } - -bool CntActionLauncher::execute( QContact aContact, QContactDetail aDetail ) - { + return executed; +} + +bool CntActionLauncher::execute( QContact aGrpContact, QContactDetail aDetail, QVariantMap aParameters ) +{ bool executed = false; QList all = QContactAction::actionDescriptors(mAction, "symbian"); mContactAction = QContactAction::action( all.first() ); if ( mContactAction ) - { - if (aContact.preferredDetail(mAction).isEmpty() && (mAction == "call" || mAction == "message" || mAction == "email")) - { - aContact.setPreferredDetail(mAction, aDetail); - //return value will be ignored because we cannot do anything if it fails. - mContactManager->saveContact(&aContact); - } - - connect(mContactAction, SIGNAL(stateChanged(QContactAction::State)), - this, SLOT(progress(QContactAction::State))); - executed = mContactAction->invokeAction( aContact, aDetail ); - } - else - { - progress(QContactAction::FinishedWithErrorState); - } - - return executed; - } - -bool CntActionLauncher::execute( QContact aGrpContact, QContactDetail aDetail, QVariantMap aParameters ) { - bool executed = false; - QList all = QContactAction::actionDescriptors(mAction, "symbian"); - mContactAction = QContactAction::action( all.first() ); - if ( mContactAction ) - { connect(mContactAction, SIGNAL(stateChanged(QContactAction::State)), this, SLOT(progress(QContactAction::State))); executed = mContactAction->invokeAction( aGrpContact, aDetail, aParameters ); - } + } else - { + { progress(QContactAction::FinishedWithErrorState); - } - + } + return executed; - } - +} + /*! Launch dynamic action */ @@ -98,16 +108,16 @@ } void CntActionLauncher::progress( QContactAction::State status ) - { +{ switch(status) - { - case QContactAction::FinishedState: - case QContactAction::FinishedWithErrorState: - emit actionExecuted( this ); - break; - default: - break; - } + { + case QContactAction::FinishedState: + case QContactAction::FinishedWithErrorState: + emit actionExecuted( this ); + break; + default: + break; } +} // End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/common/cntsavemanager.cpp --- a/phonebookui/cntcommonui/common/cntsavemanager.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/common/cntsavemanager.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -24,9 +24,8 @@ For example "forcing" phonebook to shut down (end key, from task swapper etc..) in detail editors. */ -CntSaveManager::CntSaveManager(CntContactType type, QObject* parent) : - QObject(parent), - mContactType(type) +CntSaveManager::CntSaveManager(QObject* parent) : + QObject(parent) { CNT_ENTRY @@ -43,6 +42,21 @@ CNT_EXIT } +CntSaveManager::CntSaveResult CntSaveManager::saveContact( QContact* contact, QContactManager* manager ) +{ + return saveContact( EContact, contact, manager ); +} + +CntSaveManager::CntSaveResult CntSaveManager::saveMyCard( QContact* myCard, QContactManager* manager ) +{ + return saveContact( EMyCard, myCard, manager ); +} + +CntSaveManager::CntSaveResult CntSaveManager::saveGroup( QContact* group, QContactManager* manager ) +{ + return saveContact( EGroup, group, manager ); +} + /*! Saves the given QContact to the given QContactManager. Also takes care of checking if the contact is MyCard or a group and behaves different accordingly. @@ -51,7 +65,7 @@ \param aManager the QContactManager which should be used for saving the contact, ownership not taken \return CntSaveResult enum to describe what was done to the contact (saved, updated etc...) */ -CntSaveManager::CntSaveResult CntSaveManager::saveContact(QContact* aContact, QContactManager* aManager) +CntSaveManager::CntSaveResult CntSaveManager::saveContact(CntContactType type, QContact* aContact, QContactManager* aManager) { CNT_ENTRY @@ -64,7 +78,7 @@ int detailCount = aContact->details().count(); // Don't set preferred details for a group - if (mContactType != EGroup) + if (type != EGroup) { setPreferredDetails( aContact ); } @@ -76,7 +90,7 @@ if ( detailCount > 2 ) { bool success = aManager->saveContact( aContact ); - if ( success && mContactType == EMyCard ) + if ( success && type == EMyCard ) { aManager->setSelfContactId( aContact->localId() ); } @@ -104,6 +118,7 @@ } CNT_EXIT_ARGS(result) + emit saveCompleted( result ); return result; } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/common/cntsavemanager.h --- a/phonebookui/cntcommonui/common/cntsavemanager.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/common/cntsavemanager.h Fri Oct 15 12:24:46 2010 +0300 @@ -57,17 +57,20 @@ }; public: - CntSaveManager(CntContactType type = EContact, QObject* parent = NULL); + CntSaveManager(QObject* parent = NULL); ~CntSaveManager(); - CntSaveResult saveContact(QContact* aContact, QContactManager* aManager); + CntSaveResult saveContact( QContact* aContact, QContactManager* aManager ); + CntSaveResult saveMyCard( QContact* aMyCard, QContactManager* aManager ); + CntSaveResult saveGroup( QContact* aGroup, QContactManager* aManager ); + +signals: + void saveCompleted( CntSaveManager::CntSaveResult result ); private: + CntSaveResult saveContact( CntContactType type, QContact* contact, QContactManager* manager ); void setPreferredDetails(QContact* aContact); -private: - CntContactType mContactType; - }; #endif // CNTIMAGEEDITORVIEW_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/common/cntsimengine.cpp --- a/phonebookui/cntcommonui/common/cntsimengine.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/common/cntsimengine.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -128,7 +128,7 @@ mAdnStorePresent = true; mAdnEntriesPresent = true; mWaitingForAdnCache = true; - connect(mAdnSimUtility, SIGNAL(getSimInfoAndUpdateUI(CntSimUtility::CacheStatus&, int)), this, SLOT(getSimInfoAndUpdateUI(CntSimUtility::CacheStatus&, int))); + connect(mAdnSimUtility, SIGNAL(adnCacheStatusReady(CntSimUtility::CacheStatus&, int)), this, SLOT(getSimInfoAndUpdateUI(CntSimUtility::CacheStatus&, int))); if (!mAdnSimUtility->notifyAdnCacheStatus()) { mAdnStorePresent = false; mAdnEntriesPresent = false; @@ -223,7 +223,7 @@ QString dateStr = locale.format(date.date(), r_qtn_date_usual); QString dateStrLocaleDigits = HbStringUtil::convertDigits(dateStr); QString dateStrFull = - HbParameterLengthLimiter(hbTrId("txt_phob_dblist_import_from_1_val_updated_1")).arg(dateStrLocaleDigits); + HbParameterLengthLimiter("txt_phob_dblist_import_from_1_val_updated_1").arg(dateStrLocaleDigits); simList << dateStrFull; } } @@ -324,12 +324,14 @@ QString dateStr = locale.format(date.date(), r_qtn_date_usual); QString dateStrLocaleDigits = HbStringUtil::convertDigits(dateStr); QString dateStrFull = - HbParameterLengthLimiter(hbTrId("txt_phob_dblist_import_from_1_val_updated_1")).arg(dateStrLocaleDigits); + HbParameterLengthLimiter("txt_phob_dblist_import_from_1_val_updated_1").arg(dateStrLocaleDigits); //simList << dateStrFull; mImportViewCallback.setListBoxItemText(simImport, dateStrFull); } } + + emit showNamesView(); } CNT_EXIT diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contactcard/cntcontactcarddatacontainer.cpp --- a/phonebookui/cntcommonui/contactcard/cntcontactcarddatacontainer.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contactcard/cntcontactcarddatacontainer.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -79,7 +79,7 @@ void CntContactCardDataContainer::setContactData(QContact* contact, bool aMyCard) { clearContactData(); - mContact = contact; + mContact = new QContact(*contact); mSeparatorIndex = -1; if (contact->type() == QContactType::TypeGroup) { @@ -104,6 +104,7 @@ mCallAction = NULL; delete mMessageAction; mMessageAction = NULL; + delete mContact; } void CntContactCardDataContainer::clearContactData() diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contactcard/cntcontactcarddetailitem.cpp --- a/phonebookui/cntcommonui/contactcard/cntcontactcarddetailitem.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contactcard/cntcontactcarddetailitem.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -123,7 +123,7 @@ mSecondLineText->setText(valueText); - if (!mFrameItem) + if (!mFrameItem && mIsFocusable) { mFrameItem = new HbFrameItem(this); mFrameItem->frameDrawer().setFrameGraphicsName("qtg_fr_list_normal"); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contactcard/cntcontactcarddetailitem.h --- a/phonebookui/cntcommonui/contactcard/cntcontactcarddetailitem.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contactcard/cntcontactcarddetailitem.h Fri Oct 15 12:24:46 2010 +0300 @@ -85,6 +85,7 @@ HbIcon secondaryIcon; friend class TestCntContactCardDetailItem; +friend class TestCntContactCardView; }; #endif // CNTCOMMLAUNCHERDETAILITEM_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contactcard/cntcontactcardview.cpp --- a/phonebookui/cntcommonui/contactcard/cntcontactcardview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contactcard/cntcontactcardview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -66,8 +66,20 @@ void CntContactCardView::setEngine( CntAbstractEngine& aEngine ) { - Q_D( CntContactCardView ); + Q_D(CntContactCardView); d->mEngine = &aEngine; } +QString CntContactCardView::externalize(QDataStream &stream) +{ + Q_D(CntContactCardView); + return d->externalize(stream); +} + +bool CntContactCardView::internalize(QDataStream &stream, CntViewParameters &viewParameters) +{ + Q_D(CntContactCardView); + return d->internalize(stream, viewParameters); +} + // end of file diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contactcard/cntcontactcardview.h --- a/phonebookui/cntcommonui/contactcard/cntcontactcardview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contactcard/cntcontactcardview.h Fri Oct 15 12:24:46 2010 +0300 @@ -54,6 +54,10 @@ int viewId() const; void setEngine( CntAbstractEngine& aEngine ); + + QString externalize(QDataStream &stream); + bool internalize(QDataStream &stream, CntViewParameters &viewParameters); + private: CntContactCardViewPrivate* const d_ptr; Q_DECLARE_PRIVATE_D(d_ptr, CntContactCardView) diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contactcard/cntcontactcardview_p.cpp --- a/phonebookui/cntcommonui/contactcard/cntcontactcardview_p.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contactcard/cntcontactcardview_p.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -84,6 +84,7 @@ static const int CntInitialPopulation = 8; const char *CNT_CONTACTCARDVIEW_XML = ":/xml/contacts_contactcard.docml"; +const QString CNT_ACTIVITY_CONTACTCARD = "ContactsCardView"; const char *CNT_MAPTILE_INPROGRESS_ICON = "qtg_anim_small_loading_1"; const char *CNT_MAPTILE_SEARCH_STOP_ICON = "qtg_mono_search_stop"; /*! @@ -107,7 +108,9 @@ mMyCardId(0), mSaveManager(NULL), mListPopulationProgress(CntListPopulationNotInProgress), - mStopListPopulation(false) + mStopListPopulation(false), + mFetchAvatar(false), + mSeparatorlabel(NULL) { bool ok; document()->load(CNT_CONTACTCARDVIEW_XML, &ok); @@ -160,20 +163,12 @@ mProgressTimer->stop(); } - // Clear the container to avoid double deletion - if (mContainerLayout != NULL) + if (mContainerLayout) { - int count = mContainerLayout->count(); - for (int i=0; iremoveAt(i); - } + // Remove the separator obj from layout + mContainerLayout->removeItem(mSeparatorlabel); } - - // Delete all the detail pointers if any - qDeleteAll(mDetailPtrs); - mDetailPtrs.clear(); + delete mSeparatorlabel; mView->deleteLater(); @@ -297,6 +292,7 @@ void CntContactCardViewPrivate::activate(const CntViewParameters aArgs) { CNT_ENTRY + mArgs = aArgs; mViewManager = &mEngine->viewManager(); @@ -388,6 +384,76 @@ CNT_EXIT } +QString CntContactCardViewPrivate::externalize(QDataStream &stream) +{ + // set activity parameters + CntViewParameters viewParameters; + viewParameters.insert(EViewId, mArgs.value(EViewId).toInt()); + + if (mArgs.value(ESelectedContact).isValid()) + { + QContact contact = mArgs.value(ESelectedContact).value(); + viewParameters.insert(ESelectedContactId, contact.localId()); + } + if (mArgs.value(ESelectedGroupContact).isValid()) + { + QContact contact = mArgs.value(ESelectedGroupContact).value(); + viewParameters.insert(ESelectedGroupContactId, QVariant(contact.localId())); + } + if (mArgs.value(EMyCard).isValid()) + { + viewParameters.insert(EMyCard, mArgs.value(EMyCard)); + } + if (mArgs.value(EExtraAction).isValid()) + { + viewParameters.insert(EExtraAction, mArgs.value(EExtraAction)); + } + + stream << viewParameters; + + return CNT_ACTIVITY_CONTACTCARD; +} + +bool CntContactCardViewPrivate::internalize(QDataStream &stream, CntViewParameters &viewParameters) +{ + CntViewParameters tempViewParameters; + stream >> tempViewParameters; + + viewParameters.insert(EViewId, tempViewParameters.value(EViewId)); + + if (tempViewParameters.value(ESelectedContactId).isValid()) + { + QContact contact = contactManager()->contact(tempViewParameters.value(ESelectedContactId).toInt()); + if (contact.isEmpty()) + { + // a contact has been deleted. + return false; + } + else + { + QVariant var; + var.setValue(contact); + viewParameters.insert(ESelectedContact, var); + } + } + if (tempViewParameters.value(ESelectedGroupContactId).isValid()) + { + QVariant var; + var.setValue(contactManager()->contact(tempViewParameters.value(ESelectedGroupContactId).toInt())); + viewParameters.insert(ESelectedGroupContact, var); + } + if (tempViewParameters.value(EMyCard).isValid()) + { + viewParameters.insert(EMyCard, tempViewParameters.value(EMyCard)); + } + if (tempViewParameters.value(EMyCard).isValid()) + { + viewParameters.insert(EExtraAction, tempViewParameters.value(EExtraAction)); + } + + return true; +} + void CntContactCardViewPrivate::populateHeadingItem() { CNT_ENTRY @@ -410,12 +476,13 @@ mHeadingItem->ungrabGesture(Qt::TapGesture); mImageLabel->ungrabGesture(Qt::TapGesture); } - + bool online; mInitiialPrecenceData = mPresenceListener->initialPresences(*mContact, online); mHeadingItem->setOnlineStatus(online); - if (!myCard) { + if (!myCard) + { bool setAsFavorite = CntFavourite::isMemberOfFavouriteGroup(contactManager(), mContact); mHeadingItem->setFavoriteStatus(setAsFavorite); // if contact is part of favourites group static_cast(document()->findObject("cnt:setasfavorite"))->setVisible( !setAsFavorite ); @@ -428,16 +495,11 @@ { if (details.at(i).imageUrl().isValid()) { - if (!mAvatar) - { - mAvatar = new QContactAvatar(details.at(i)); - mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString()); - } - else if (*mAvatar != details.at(i)) + if (!mAvatar || *mAvatar != details.at(i)) { delete mAvatar; mAvatar = new QContactAvatar(details.at(i)); - mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString()); + mFetchAvatar = true; } break; } @@ -452,10 +514,12 @@ Q_ASSERT(mContact != NULL && mScrollArea != NULL); - if (mListPopulationProgress == CntListPopulationNotInProgress) { + if (mListPopulationProgress == CntListPopulationNotInProgress) + { mListPopulationProgress = 0; - if (!mDataContainer) { + if (!mDataContainer) + { mDataContainer = new CntContactCardDataContainer( mMaptile, mEngine->extensionManager(), @@ -465,45 +529,41 @@ // fill the data container with contact details mDataContainer->setContactData(mContact); - // scroll area + container widget - mContainerWidget = mScrollArea->contentWidget(); - if (!mContainerWidget) { - // initialize - mScrollArea->setScrollDirections(Qt::Vertical); - - mContainerWidget = new QGraphicsWidget(); - mScrollArea->setContentWidget(mContainerWidget); // takes ownership. Old widget is deleted - - mContainerLayout = new QGraphicsLinearLayout(Qt::Vertical); - mContainerLayout->setContentsMargins(0, 0, 0, 0); - mContainerLayout->setSpacing(0); - mContainerLayout->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - - mContainerWidget->setLayout(mContainerLayout); // takes ownership. Old layout is deleted - } else { - // Already initialized - Q_ASSERT(mContainerLayout != NULL); - - // Clear the container - int count = mContainerLayout->count(); - for (int i = 0; i < count; i++) { - // do not delete items. They will be deleted automatically - mContainerLayout->removeAt(i); - } + if (mContainerLayout) + { + // Remove the separator obj from previous layout + // It needs to be reused + mContainerLayout->removeItem(mSeparatorlabel); } - - // Delete all the detail pointers if any - qDeleteAll(mDetailPtrs); - mDetailPtrs.clear(); + // initialize + mScrollArea->setScrollDirections(Qt::Vertical); + + mContainerWidget = new QGraphicsWidget(); + mScrollArea->setContentWidget(mContainerWidget); // takes ownership. + + mContainerLayout = new QGraphicsLinearLayout(Qt::Vertical); + mContainerLayout->setContentsMargins(0, 0, 0, 0); + mContainerLayout->setSpacing(0); + mContainerLayout->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + + mContainerWidget->setLayout(mContainerLayout); // takes ownership. } do { - if (mListPopulationProgress == mDataContainer->itemCount() || mStopListPopulation) { + if (mListPopulationProgress == mDataContainer->itemCount() || mStopListPopulation) + { + if (!mStopListPopulation && mFetchAvatar) + { + // fetch the avatar if it has not yet been fetched + mFetchAvatar = false; + mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString()); + } // population of the list has completed mListPopulationProgress = CntListPopulationNotInProgress; mStopListPopulation = false; disconnect(mView->mainWindow(), SIGNAL(viewReady()), this, SLOT(populateListItems())); + CNT_EXIT_ARGS("population completed") return; } @@ -514,7 +574,6 @@ if (pos < CntContactCardDataItem::ESeparator && dataItem->isFocusable()) { CntContactCardDetailItem* item = new CntContactCardDetailItem(mListPopulationProgress, mContainerWidget); - mDetailPtrs.append(item); connect(item, SIGNAL(clicked()), this, SLOT(onItemActivated())); @@ -554,12 +613,16 @@ // separator else if (pos == CntContactCardDataItem::ESeparator) - { - HbFrameItem* frameItem = new HbFrameItem(QString("qtg_fr_list_separator"), HbFrameDrawer::NinePieces); - HbLabel* label = static_cast(document()->findWidget(QString("separator"))); - label->setPlainText(dataItem->titleText()); - label->setBackgroundItem(frameItem); // takes ownership - mContainerLayout->addItem(label); + { + if (!mSeparatorlabel) + { + HbFrameItem* frameItem = new HbFrameItem(QString("qtg_fr_list_separator"), HbFrameDrawer::NinePieces); + mSeparatorlabel = static_cast(document()->findWidget(QString("separator"))); + mSeparatorlabel->setPlainText(dataItem->titleText()); + mSeparatorlabel->setBackgroundItem(frameItem); // takes ownership + mSeparatorlabel->setParent(this); + } + mContainerLayout->addItem(mSeparatorlabel); } // details @@ -588,7 +651,6 @@ else { CntContactCardDetailItem* item = new CntContactCardDetailItem(mListPopulationProgress, mContainerWidget, false); - mDetailPtrs.append(item); //To check whether maptile status icon is set with the address if( ( dataItem->titleText() == hbTrId("txt_phob_formlabel_address") || @@ -632,11 +694,21 @@ ++mListPopulationProgress; } while (mListPopulationProgress < CntInitialPopulation); - if (mListPopulationProgress <= CntInitialPopulation) { + if (mListPopulationProgress <= CntInitialPopulation) + { connect(mView->mainWindow(), SIGNAL(viewReady()), this, SLOT(populateListItems())); - } else { + } + else + { disconnect(mView->mainWindow(), SIGNAL(viewReady()), this, SLOT(populateListItems())); HbApplication::instance()->postEvent(this, new QEvent(ProcessPopulateListEvent)); + + if (mFetchAvatar) + { + // initial view has been shown, so starting fetching the avatar + mFetchAvatar = false; + mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString()); + } } CNT_EXIT @@ -648,9 +720,11 @@ void CntContactCardViewPrivate::connectAction(QString actionName, const char* slot) { HbAction *action = qobject_cast(document()->findObject(actionName)); - if (action) { + if (action) + { action->setParent(mView); - if (slot != NULL) { + if (slot != NULL) + { connect(action, SIGNAL(triggered()), this, slot); } } @@ -661,82 +735,82 @@ */ void CntContactCardViewPrivate::updateSpinningIndicator() { - //Check all address details( Preferred, Home, Work ) - for( int index = 0 ; index < mAddressList.count(); ) + CNT_ENTRY + + // Check all address details( Preferred, Home, Work ) + for (int index = 0 ; index < mAddressList.count();) { - //Maptile status not received update the rotating icon - if( mAddressList[index]->maptileStatus == CNT_UNKNOWN_MAPTILE_STATUS ) + // Maptile status not received update the rotating icon + if (mAddressList[index]->maptileStatus == CNT_UNKNOWN_MAPTILE_STATUS) { - QString iconName("qtg_anim_small_loading_"); - mAddressList[index]->mProgressCount = mAddressList[index]->mProgressCount % 10 + 1; - iconName.append(QVariant(mAddressList[index]->mProgressCount).toString()); + QString iconName("qtg_anim_small_loading_"); + mAddressList[index]->mProgressCount = mAddressList[index]->mProgressCount % 10 + 1; + iconName.append(QVariant(mAddressList[index]->mProgressCount).toString()); - HbIcon icon(iconName); - mAddressList[index]->mDetailItem->setSecondaryIconItem( icon ); - mAddressList[index]->mDetailItem->update(); - mProgressTimer->start(CNT_MAPTILE_PROGRESS_TIMER); - index++; + HbIcon icon(iconName); + mAddressList[index]->mDetailItem->setSecondaryIconItem(icon); + mAddressList[index]->mDetailItem->update(); + mProgressTimer->start(CNT_MAPTILE_PROGRESS_TIMER); + index++; } else { - //Maptile status received. Show the maptile image if available + // Maptile status received. Show the maptile image if available MapTileService::AddressType sourceAddressType = - static_cast ( mAddressList[index]->mAddressType ); + static_cast (mAddressList[index]->mAddressType); QContactLocalId contactId = mContact->localId(); - if( mAddressList[index] != NULL ) + if (mAddressList[index] != NULL) { - if( mAddressList[index]->maptileStatus == MapTileService::MapTileFetchingCompleted ) - { - - //Read the maptile path and update the image - QString imagePath; - mMaptile->getMapTileImage( - contactId, sourceAddressType, imagePath, mView->mainWindow()->orientation() ); + if (mAddressList[index]->maptileStatus == MapTileService::MapTileFetchingCompleted) + { + // Read the maptile path and update the image + QString imagePath; + mMaptile->getMapTileImage( + contactId, sourceAddressType, imagePath, mView->mainWindow()->orientation()); - if( !imagePath.isEmpty() ) - { - //Empty icon. Clear the inprogress icon - HbIcon emptyIcon; - mAddressList[index]->mDetailItem->setSecondaryIconItem( emptyIcon ); + if (!imagePath.isEmpty()) + { + //Empty icon. Clear the inprogress icon + HbIcon emptyIcon; + mAddressList[index]->mDetailItem->setSecondaryIconItem(emptyIcon); - HbIcon icon( imagePath ); + HbIcon icon(imagePath); - HbLabel* maptileLabel = loadMaptileLabel( sourceAddressType ); - setMaptileLabel( maptileLabel, icon ); - mMaptileLabelList.insert( sourceAddressType, maptileLabel ); - - //find the index of the item and insert maptile in the next index - for( int itemIndex = 0 ; itemIndex < mContainerLayout->count(); itemIndex++ ) - { - if( mContainerLayout->itemAt(itemIndex) == mAddressList[index]->mDetailItem ) - { - mContainerLayout->insertItem( itemIndex+1, maptileLabel ); - break; - } - } - - } - else - { - //Maptile image not available. Show the search stop icon - setMaptileSearchStopIcon( index ); - } - } - else - { - //Maptile fetching failed. Show the search stop icon - setMaptileSearchStopIcon( index ); - } + HbLabel* maptileLabel = loadMaptileLabel(sourceAddressType); + setMaptileLabel(maptileLabel, icon); + mMaptileLabelList.insert(sourceAddressType, maptileLabel); + + //find the index of the item and insert maptile in the next index + for (int itemIndex = 0 ; itemIndex < mContainerLayout->count(); itemIndex++) + { + if (mContainerLayout->itemAt(itemIndex) == mAddressList[index]->mDetailItem) + { + mContainerLayout->insertItem(itemIndex + 1, maptileLabel); + break; + } + } + } + else + { + //Maptile image not available. Show the search stop icon + setMaptileSearchStopIcon(index); + } + } + else + { + //Maptile fetching failed. Show the search stop icon + setMaptileSearchStopIcon(index); + } - delete mAddressList[index]; - mAddressList.removeAt(index); + delete mAddressList[index]; + mAddressList.removeAt(index); } else { - //increment the index now - index++; + //increment the index now + index++; } } } @@ -745,42 +819,42 @@ /* * Sets the search stop icon to secondary icon item */ -void CntContactCardViewPrivate::setMaptileSearchStopIcon( int index ) +void CntContactCardViewPrivate::setMaptileSearchStopIcon(int index) { - if( index < mAddressList.count() ) + if (index < mAddressList.count()) { QString iconName(CNT_MAPTILE_SEARCH_STOP_ICON); HbIcon icon(iconName); - mAddressList[index]->mDetailItem->setSecondaryIconItem( icon ); + mAddressList[index]->mDetailItem->setSecondaryIconItem(icon); mAddressList[index]->mDetailItem->update(); } } -/* -* Slot to receive the maptile status information -*/ -void CntContactCardViewPrivate::mapTileStatusReceived( int contactid, int addressType, int status) +/*! + Slot to receive the maptile status information. + */ +void CntContactCardViewPrivate::mapTileStatusReceived(int contactid, int addressType, int status) { - //Update the maptile status information for all 3( Preferred, Work, Home ) address - for( int index = 0 ; index < mAddressList.count(); index++ ) + // Update the maptile status information for all 3( Preferred, Work, Home ) address + for (int index = 0; index < mAddressList.count(); index++) { - if( mAddressList[index]->mContactId == contactid && - mAddressList[index]->mAddressType == addressType ) + if (mAddressList[index]->mContactId == contactid && + mAddressList[index]->mAddressType == addressType) { mAddressList[index]->maptileStatus = status; } } - + updateSpinningIndicator(); } -/* -* Updates correct maptile image when screen orientation changes. -*/ +/*! + Updates correct maptile image when screen orientation changes. + */ void CntContactCardViewPrivate::updateMaptileImage() { - //If there is no maptile displayed, return immediately - if( mMaptileLabelList.count() > 0 ) + // If there is no maptile displayed, return immediately + if (mMaptileLabelList.count() > 0) { QContactLocalId contactId = mContact->localId(); @@ -790,35 +864,35 @@ QString contextHome(QContactAddress::ContextHome.operator QString()); QString contextWork(QContactAddress::ContextWork.operator QString()); MapTileService::AddressType sourceAddressType - = MapTileService::AddressPreference; + = MapTileService::AddressPreference; QString imagePath; - for ( int i = 0; i < addressDetails.count(); i++ ) + for (int i = 0; i < addressDetails.count(); i++) { - if ( !addressDetails[i].contexts().isEmpty() && - addressDetails[i].contexts().at(0) == contextHome ) + if (!addressDetails[i].contexts().isEmpty() && + addressDetails[i].contexts().at(0) == contextHome) { sourceAddressType = MapTileService::AddressHome; } - else if ( !addressDetails[i].contexts().isEmpty() && - addressDetails[i].contexts().at(0) == contextWork ) + else if (!addressDetails[i].contexts().isEmpty() && + addressDetails[i].contexts().at(0) == contextWork) { sourceAddressType = MapTileService::AddressWork; } - + int status = mMaptile->getMapTileImage( contactId, sourceAddressType, imagePath, - mView->mainWindow()->orientation() ); - if( !imagePath.isEmpty() ) + mView->mainWindow()->orientation()); + if (!imagePath.isEmpty()) { - HbIcon icon( imagePath ); - HbLabel* label = mMaptileLabelList.value( sourceAddressType ); - if( label ) + HbIcon icon(imagePath); + HbLabel* label = mMaptileLabelList.value(sourceAddressType); + if (label) { - setMaptileLabel( label, icon ); + setMaptileLabel(label, icon); } } } @@ -826,39 +900,37 @@ } -/* -* Asscoiate the maptile label widget with maptile image -*/ -void CntContactCardViewPrivate::setMaptileLabel( HbLabel*& mapLabel, const HbIcon& icon ) +/*! + Asscoiate the maptile label widget with maptile image. + */ +void CntContactCardViewPrivate::setMaptileLabel(HbLabel*& mapLabel, const HbIcon& icon) { mapLabel->clear(); - mapLabel->setIcon( icon ); - - qreal leftMarginSize; - mapLabel->getContentsMargins( &leftMarginSize, 0 , 0 , 0 ); - mapLabel->setPreferredSize( - QSizeF(icon.width() + leftMarginSize, icon.height())); - + mapLabel->setIcon(icon); + + qreal leftMarginSize; + mapLabel->getContentsMargins(&leftMarginSize, 0, 0, 0); + mapLabel->setPreferredSize(QSizeF(icon.width() + leftMarginSize, icon.height())); } -/* -* Load the maptile label based on the address type -*/ -HbLabel* CntContactCardViewPrivate::loadMaptileLabel( int addressType ) +/*! + Load the maptile label based on the address type. + */ +HbLabel* CntContactCardViewPrivate::loadMaptileLabel(int addressType) { HbLabel* maptileLabel = NULL; - if( addressType == MapTileService::AddressPreference ) + if (addressType == MapTileService::AddressPreference) { maptileLabel = static_cast(document()->findWidget(QString("maptilePreferenceWidget"))); } - else if( addressType == MapTileService::AddressHome ) + else if (addressType == MapTileService::AddressHome) { - maptileLabel = static_cast(document()->findWidget(QString("maptileHomeWidget"))); + maptileLabel = static_cast(document()->findWidget(QString("maptileHomeWidget"))); } - else if( addressType == MapTileService::AddressWork ) + else if (addressType == MapTileService::AddressWork) { - maptileLabel = static_cast(document()->findWidget(QString("maptileWorkWidget"))); + maptileLabel = static_cast(document()->findWidget(QString("maptileWorkWidget"))); } return maptileLabel; @@ -1003,7 +1075,7 @@ name = hbTrId("txt_phob_list_unnamed"); } - HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_delete_1")).arg(name), this, SLOT(handleDeleteContact(int)), + HbMessageBox::question(HbParameterLengthLimiter("txt_phob_info_delete_1").arg(name), this, SLOT(handleDeleteContact(int)), HbMessageBox::Delete | HbMessageBox::Cancel); } @@ -1639,6 +1711,8 @@ if (contactManager()->error() == QContactManager::NoError && latestTimeStamp.lastModified() > localTimeStamp.lastModified()) { + mListPopulationProgress = CntListPopulationNotInProgress; + if (mContact) delete mContact; mContact = new QContact(c); @@ -1733,6 +1807,8 @@ QContact c = contactManager()->contact(mContact->localId()); if (contactManager()->error() == QContactManager::NoError) { + mListPopulationProgress = CntListPopulationNotInProgress; + if (mContact) delete mContact; mContact = new QContact(c); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contactcard/cntcontactcardview_p.h --- a/phonebookui/cntcommonui/contactcard/cntcontactcardview_p.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contactcard/cntcontactcardview_p.h Fri Oct 15 12:24:46 2010 +0300 @@ -145,6 +145,8 @@ CntContactCardView* q_ptr; void activate(const CntViewParameters aArgs); void deactivate(); + QString externalize(QDataStream &stream); + bool internalize(QDataStream &stream, CntViewParameters &viewParameters); CntDocumentLoader* document(); QContactManager* contactManager(); @@ -198,9 +200,12 @@ CntSaveManager* mSaveManager; // own CntAbstractEngine* mEngine; QTimer* mProgressTimer; // own - QList mDetailPtrs; int mListPopulationProgress; bool mStopListPopulation; + bool mFetchAvatar; + HbLabel* mSeparatorlabel; + + friend class TestCntContactCardView; }; #endif // CNTCOMMLAUNCHERVIEW_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cntdateeditorviewitem.cpp --- a/phonebookui/cntcommonui/contacteditors/cntdateeditorviewitem.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cntdateeditorviewitem.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -30,7 +30,6 @@ #include #include #include -#include #include CntDateEditorViewItem::CntDateEditorViewItem( QGraphicsItem* aParent ) : @@ -131,10 +130,7 @@ picker->setDateRange(CNT_DATEPICKER_FROM, CNT_DATEPICKER_TO ); picker->setDate( aCurrent ); - HbLabel *headingText = new HbLabel( popup ); - headingText->setPlainText( aTitle ); - - popup->setHeadingWidget(headingText); + popup->setHeadingText(aTitle); popup->setContentWidget(picker); popup->addAction(new HbAction(hbTrId("txt_common_button_ok"), popup)); popup->addAction(new HbAction(hbTrId("txt_common_button_cancel"), popup)); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cntdetailconst.h --- a/phonebookui/cntcommonui/contacteditors/cntdetailconst.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cntdetailconst.h Fri Oct 15 12:24:46 2010 +0300 @@ -21,7 +21,7 @@ #include #include #include -const int CNT_NOTE_EDITOR_MIN_ROWCOUNT = 5; +const int CNT_NOTE_EDITOR_MIN_ROWCOUNT = 3; const int CNT_PHONENUMBER_EDITOR_MAXLENGTH = 48; const int CNT_DTMF_EDITOR_MAXLENGTH = 60; const int CNT_URL_EDITOR_MAXLENGTH = 1000; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cntdetaileditor.cpp --- a/phonebookui/cntcommonui/contacteditors/cntdetaileditor.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cntdetaileditor.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -52,7 +52,6 @@ mViewManager(NULL), mEditorFactory(NULL), mCancel(NULL), - mSaveManager(NULL), mVirtualKeyboard(NULL) { bool ok; @@ -88,8 +87,6 @@ mLoader = NULL; delete mEditorFactory; mEditorFactory = NULL; - delete mSaveManager; - mSaveManager = NULL; delete mVirtualKeyboard; mVirtualKeyboard = NULL; } @@ -121,15 +118,14 @@ mView->setNavigationAction(mSoftkey); } - QContact selectedContact; if ( mId == groupEditorView ) { - selectedContact = aArgs.value(ESelectedGroupContact).value(); + mContact = aArgs.value(ESelectedGroupContact).value(); connect( mDataForm, SIGNAL(itemShown(const QModelIndex&)), this, SLOT(handleItemShown(const QModelIndex&)) ); } else { - selectedContact = aArgs.value(ESelectedContact).value(); + mContact = aArgs.value(ESelectedContact).value(); connect( mDataForm, SIGNAL(itemShown(const QModelIndex&)), this, SLOT(handleItemShown(const QModelIndex&)) ); } @@ -137,26 +133,7 @@ connect(&cm, SIGNAL(contactsRemoved(const QList&)), this, SLOT(contactDeletedFromOtherSource(const QList&))); - mEditorFactory->setupEditorView(*this, selectedContact); - - QString myCard = mArgs.value( EMyCard ).toString(); - QContactLocalId localId = selectedContact.localId(); - QContactLocalId selfContactId = cm.selfContactId(); - bool isMyCard = ( localId == selfContactId && localId != 0 ) || !myCard.isEmpty(); - - if (isMyCard) - { - mSaveManager = new CntSaveManager(CntSaveManager::EMyCard); - } - else if ( mId == groupEditorView ) - { - mSaveManager = new CntSaveManager(CntSaveManager::EGroup); - } - else - { - mSaveManager = new CntSaveManager(); - } - + mEditorFactory->setupEditorView(*this, mContact); mDataForm->setItemRecycling(true); // add new field if required @@ -173,20 +150,17 @@ mDataForm->verticalScrollBar()->setInteractive(true); mVirtualKeyboard = new HbShrinkingVkbHost(mView); - - connect(mVirtualKeyboard, SIGNAL(keypadOpened()), this, SLOT(handleKeypadOpen())); - connect(mVirtualKeyboard, SIGNAL(keypadClosed()), this, SLOT(handleKeypadClosed())); } void CntDetailEditor::deactivate() { QContactManager& mgr = mEngine->contactManager(SYMBIAN_BACKEND); - if( mId == groupEditorView) { - mgr.saveContact( mDataFormModel->contact() ); - } disconnect(&mgr, SIGNAL(contactsRemoved(const QList&)), this, SLOT(contactDeletedFromOtherSource(const QList&))); + + delete mVirtualKeyboard; + mVirtualKeyboard = NULL; } bool CntDetailEditor::isDefault() const @@ -309,17 +283,31 @@ name = hbTrId("txt_phob_list_unnamed"); } - CntSaveManager::CntSaveResult result = mSaveManager->saveContact(mDataFormModel->contact(), &mgr); - - if (mId != groupEditorView) - { + QString myCard = mArgs.value( EMyCard ).toString(); + QContactLocalId localId = mContact.localId(); + QContactLocalId selfContactId = mgr.selfContactId(); + bool isMyCard = ( localId == selfContactId && localId != 0 ) || !myCard.isEmpty(); + + CntSaveManager::CntSaveResult result; + CntSaveManager& saveMgr = mEngine->saveManager(); + if (isMyCard) { + result = saveMgr.saveMyCard( mDataFormModel->contact(), &mgr ); + } + else if ( mId == groupEditorView ) { + result = saveMgr.saveGroup( mDataFormModel->contact(), &mgr ); + } + else { + result = saveMgr.saveContact( mDataFormModel->contact(), &mgr ); + } + + if (mId != groupEditorView) { switch (result) { case CntSaveManager::ESaved: - HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contact_1_saved")).arg(name)); + HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter("txt_phob_dpophead_contact_1_saved").arg(name)); break; case CntSaveManager::EUpdated: - HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contacts_1_updated")).arg(name)); + HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter("txt_phob_dpophead_contacts_1_updated").arg(name)); break; case CntSaveManager::EFailed: HbDeviceNotificationDialog::notification(QString(),hbTrId("SAVING FAILED!")); @@ -389,22 +377,4 @@ mCancel->setDisabled(false); } - -void CntDetailEditor::handleKeypadOpen() -{ - CNT_ENTRY - - // enable full screen - mView->setContentFullScreen(true); - CNT_EXIT -} - -void CntDetailEditor::handleKeypadClosed() -{ - CNT_ENTRY - // disable full screen - mView->setContentFullScreen(false); - CNT_EXIT -} - // End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cntdetaileditor.h --- a/phonebookui/cntcommonui/contacteditors/cntdetaileditor.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cntdetaileditor.h Fri Oct 15 12:24:46 2010 +0300 @@ -31,7 +31,6 @@ class HbView; class HbAction; class CntEditorFactory; -class CntSaveManager; class HbShrinkingVkbHost; class CntDetailEditor : public QObject, @@ -52,8 +51,6 @@ void saveContact(); void contactDeletedFromOtherSource(const QList& contactIds); void showRootView(); - void handleKeypadOpen(); - void handleKeypadClosed(); public slots: void enableDiscardChanges(); @@ -91,9 +88,9 @@ HbAction *mSoftkey; HbAction *mCancel; CntViewParameters mArgs; - CntSaveManager *mSaveManager; // own CntAbstractEngine* mEngine; // not own HbShrinkingVkbHost* mVirtualKeyboard; + QContact mContact; friend class TestCntDetailEditor; }; #endif /* CNTDETAILEDITOR_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cntdetailpopup.cpp --- a/phonebookui/cntcommonui/contacteditors/cntdetailpopup.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cntdetailpopup.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -30,17 +30,14 @@ addListItem("qtg_small_mobile", hbTrId("txt_phob_list_number"), phoneNumberEditorView ); addListItem("qtg_small_email", hbTrId("txt_phob_list_email"), emailEditorView ); addListItem("qtg_small_url_address", hbTrId("txt_phob_list_url"), urlEditorView); - addListItem("qtg_small_location", hbTrId("txt_phob_list_address"), addressEditorView ); + addListItem("qtg_small_location", hbTrId("txt_phob_list_address2"), addressEditorView ); addListItem("qtg_small_note", hbTrId("txt_phob_list_note"), noteEditorView); addListItem("qtg_small_sound", hbTrId("txt_phob_list_personal_ringing_tone"), ringToneFetcherView ); addListItem("qtg_small_calendar", hbTrId("txt_phob_list_date"), dateEditorView); addListItem("qtg_small_company_details", hbTrId("txt_phob_list_company_details"), companyEditorView); addListItem("qtg_small_family", hbTrId("txt_phob_list_family"), familyDetailEditorView); - - HbLabel *label = new HbLabel(this); - label->setPlainText(hbTrId("txt_phob_title_add_field")); - setHeadingWidget(label); + setHeadingText(hbTrId("txt_phob_title_add_field")); setTimeout(HbDialog::NoTimeout); setDismissPolicy(HbDialog::NoDismiss); setAttribute(Qt::WA_DeleteOnClose, true); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cnteditview.cpp --- a/phonebookui/cntcommonui/contacteditors/cnteditview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cnteditview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -76,4 +76,16 @@ Q_D( CntEditView ); d->mEngine = &aEngine; } + +QString CntEditView::externalize(QDataStream &stream) +{ + Q_D(CntEditView); + return d->externalize(stream); +} + +bool CntEditView::internalize(QDataStream &stream, CntViewParameters &viewParameters) +{ + Q_D(CntEditView); + return d->internalize(stream, viewParameters); +} // EOF diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cnteditview.h --- a/phonebookui/cntcommonui/contacteditors/cnteditview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cnteditview.h Fri Oct 15 12:24:46 2010 +0300 @@ -47,6 +47,8 @@ int viewId() const; void setEngine( CntAbstractEngine& aEngine ); + QString externalize(QDataStream &stream); + bool internalize(QDataStream &stream, CntViewParameters &viewParameters); private: CntEditViewPrivate* const d_ptr; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cnteditview_p.cpp --- a/phonebookui/cntcommonui/contacteditors/cnteditview_p.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cnteditview_p.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -50,6 +50,7 @@ #include const char *CNT_EDIT_XML = ":/xml/contacts_ev.docml"; +const QString CNT_ACTIVITY_EDITOR = "ContactsCardEdit"; CntEditViewPrivate::CntEditViewPrivate() : mModel( NULL ), @@ -57,8 +58,7 @@ mThumbnailManager( NULL ), mContact( NULL ), mReq(NULL), - mMenu(NULL), - mSaveManager(NULL) + mMenu(NULL) { mDocument = new CntDocumentLoader; @@ -97,7 +97,7 @@ connect( add, SIGNAL(triggered()), this, SLOT(addDetailItem()) ); connect( mDelete, SIGNAL(triggered()), this, SLOT(deleteContact()) ); connect( mDiscard, SIGNAL(triggered()), this, SLOT(discardChanges()) ); - connect( mSave, SIGNAL(triggered()), this, SLOT(saveChanges()) ); + connect( mSave, SIGNAL(triggered()), this, SLOT(showPreviousView()) ); connect( mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView()) ); connect( mImageLabel, SIGNAL(iconClicked()), this, SLOT(openImageEditor()) ); @@ -105,9 +105,6 @@ connect( mHeading, SIGNAL(iconClicked()), this, SLOT(openImageEditor()) ); connect( mListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(activated(const QModelIndex&)) ); connect( mListView, SIGNAL(longPressed(HbAbstractViewItem*,const QPointF&)), this, SLOT(longPressed(HbAbstractViewItem*,const QPointF&)) ); - - // closing the application from task swapper or end key will cause the contact to be saved - connect( qApp, SIGNAL(aboutToQuit()), this, SLOT(saveChanges())); } CntEditViewPrivate::~CntEditViewPrivate() @@ -125,9 +122,6 @@ delete mMenu; mMenu = NULL; } - - delete mSaveManager; - mSaveManager = NULL; } void CntEditViewPrivate::setOrientation(Qt::Orientation orientation) @@ -159,6 +153,7 @@ if ( window ) { connect(window, SIGNAL(viewReady()), this, SLOT(setScrollPosition()) ); + connect(window, SIGNAL(viewReady()), this, SLOT(setObjectNames()) ); connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); setOrientation(window->orientation()); } @@ -176,14 +171,6 @@ QContactLocalId selfContactId = cm.selfContactId(); mIsMyCard = ( localId == selfContactId && localId != 0 ) || !myCard.isEmpty(); - if (mIsMyCard) - { - mSaveManager = new CntSaveManager(CntSaveManager::EMyCard); - } - else - { - mSaveManager = new CntSaveManager(); - } if ( mHeading ) mHeading->setDetails( mContact, mIsMyCard ); @@ -228,6 +215,82 @@ CNT_EXIT } +QString CntEditViewPrivate::externalize(QDataStream &stream) +{ + // closing the application from task swapper or end key will cause the contact to be saved + saveChanges(); + + CntViewParameters viewParameters; + viewParameters.insert(EViewId, mArgs.value(EViewId).toInt()); + + if (mArgs.value(ESelectedContact).isValid()) + { + QContact contact = mArgs.value(ESelectedContact).value(); + viewParameters.insert(ESelectedContactId, contact.localId()); + } + if (mArgs.value(ESelectedGroupContact).isValid()) + { + QContact contact = mArgs.value(ESelectedGroupContact).value(); + viewParameters.insert(ESelectedGroupContactId, contact.localId()); + } + if (mArgs.value(EMyCard).isValid()) + { + viewParameters.insert(EMyCard, mArgs.value(EMyCard)); + } + if (mArgs.value(EExtraAction).isValid()) + { + viewParameters.insert(EExtraAction, mArgs.value(EExtraAction)); + } + + stream << viewParameters; + + return CNT_ACTIVITY_EDITOR; +} + +bool CntEditViewPrivate::internalize(QDataStream &stream, CntViewParameters &viewParameters) +{ + CntViewParameters tempViewParameters; + stream >> tempViewParameters; + + viewParameters.insert(EViewId, tempViewParameters.value(EViewId)); + + if (tempViewParameters.value(ESelectedContactId).isValid()) + { + QContactManager &mgr = mEngine->contactManager(SYMBIAN_BACKEND); + + QContactLocalId localId = tempViewParameters.value(ESelectedContactId).toInt(); + + if (!mgr.contactIds().contains(localId) && localId != 0 && mgr.selfContactId() != localId) + { + // a contact has been deleted. + return false; + } + else + { + QVariant var; + var.setValue(mgr.contact(localId)); + viewParameters.insert(ESelectedContact, var); + } + } + if (tempViewParameters.value(ESelectedGroupContactId).isValid()) + { + QContactManager &mgr = mEngine->contactManager(SYMBIAN_BACKEND); + QVariant var; + var.setValue(mgr.contact(tempViewParameters.value(ESelectedGroupContactId).toInt())); + viewParameters.insert(ESelectedGroupContact, var); + } + if (tempViewParameters.value(EMyCard).isValid()) + { + viewParameters.insert(EMyCard, tempViewParameters.value(EMyCard)); + } + if (tempViewParameters.value(EExtraAction).isValid()) + { + viewParameters.insert(EExtraAction, tempViewParameters.value(EExtraAction)); + } + + return true; +} + void CntEditViewPrivate::deactivate() { } @@ -418,6 +481,7 @@ } else { + mReq->setSynchronous(false); connect(mReq, SIGNAL( requestOk( const QVariant&)), SLOT( ringToneFetchHandleOk(const QVariant&)) ); connect(mReq, SIGNAL( requestError( int,const QString&)), SLOT(ringToneFetchHandleError(int,const QString&)) ); } @@ -428,25 +492,19 @@ void CntEditViewPrivate::ringToneFetchHandleOk(const QVariant &result) { - QContactRingtone ringtone = mContact->detail(); - QUrl ringtoneUrl = ringtone.audioRingtoneUrl(); - QFileInfo ringtoneFileInfo(ringtoneUrl.toString()); - QString ringtoneFileName = ringtoneFileInfo.fileName(); - // Contact can have only one ringtone at a time - // remove existing ringtone detail if any + // Contact can have only one ringtone at a time + // remove existing ringtone detail if any + if(!(ringtone.isEmpty())) + { + mContact->removeDetail(&ringtone); + } - if(!(ringtone.isEmpty())) - { - mContact->removeDetail(&ringtone); - } - - ringtone.setAudioRingtoneUrl(result.value()); + ringtone.setAudioRingtoneUrl( QUrl::fromLocalFile( result.value() ) ); mContact->saveDetail( &ringtone ); mModel->updateRingtone(); mSave->setEnabled( true ); mDiscard->setEnabled( true ); - } void CntEditViewPrivate::ringToneFetchHandleError(int errorCode, const QString& errorMessage) @@ -476,7 +534,7 @@ name = hbTrId("txt_phob_list_unnamed"); } - HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_delete_1")).arg(name), this, SLOT(handleDeleteContact(int)), + HbMessageBox::question(HbParameterLengthLimiter("txt_phob_info_delete_1").arg(name), this, SLOT(handleDeleteContact(int)), HbMessageBox::Delete | HbMessageBox::Cancel); } @@ -545,7 +603,13 @@ disconnect(&mgr, SIGNAL(contactsRemoved(const QList&)), this, SLOT(contactDeletedFromOtherSource(const QList&))); - CntSaveManager::CntSaveResult result = mSaveManager->saveContact(mContact, &mgr); + + CntSaveManager& save = mEngine->saveManager(); + CntSaveManager::CntSaveResult result; + if ( mIsMyCard ) + result = save.saveMyCard(mContact, &mgr); + else + result = save.saveContact( mContact, &mgr ); QVariant var; bool backToRoot(false); @@ -554,14 +618,14 @@ { case CntSaveManager::ESaved: emit q->contactUpdated(KCntServicesReturnValueContactSaved); - HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contact_1_saved")).arg(name)); + HbDeviceNotificationDialog::notification(QString(), HbParameterLengthLimiter("txt_phob_dpophead_contact_1_saved").arg(name)); var.setValue(*mContact); mArgs.insert(ESelectedContact, var); mArgs.insert(ESelectedAction, CNT_CREATE_ACTION); break; case CntSaveManager::EUpdated: emit q->contactUpdated(KCntServicesReturnValueContactSaved); - HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contacts_1_updated")).arg(name)); + HbDeviceNotificationDialog::notification(QString(), HbParameterLengthLimiter("txt_phob_dpophead_contacts_1_updated").arg(name)); var.setValue(*mContact); mArgs.insert(ESelectedContact, var); mArgs.insert(ESelectedAction, CNT_EDIT_ACTION); @@ -808,5 +872,19 @@ CNT_EXIT } +void CntEditViewPrivate::setObjectNames() +{ + int itemCount = mModel->rowCount(); + + for (int itemRow = 0 ; itemRow < itemCount ; itemRow++) + { + QModelIndex modelIndex = mModel->index(itemRow); + HbListViewItem* item = static_cast(mListView->itemByIndex(modelIndex)); + if (NULL != item) + { + item->setObjectName(QString("ListViewItem %1").arg(itemRow)); + } + } +} // End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cnteditview_p.h --- a/phonebookui/cntcommonui/contacteditors/cnteditview_p.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cnteditview_p.h Fri Oct 15 12:24:46 2010 +0300 @@ -43,7 +43,6 @@ class QAction; class HbMenu; class XQAiwRequest; -class CntSaveManager; class CntAbstractEngine; QTM_BEGIN_NAMESPACE @@ -63,6 +62,8 @@ void activate( const CntViewParameters aArgs ); void deactivate(); + QString externalize(QDataStream &stream); + bool internalize(QDataStream &stream, CntViewParameters &viewParameters); public: // From CntEditViewItemCallback void openView(CntViewParameters& viewParams); @@ -93,6 +94,7 @@ void ringToneFetchHandleError(int errorCode, const QString& errorMessage); void ringToneFetchHandleOk(const QVariant &result); void contactDeletedFromOtherSource(const QList& contactIds); + void setObjectNames(); private: void loadAvatar(); @@ -132,7 +134,6 @@ XQAiwRequest* mReq; XQApplicationManager mAppMgr; HbMenu *mMenu; - CntSaveManager* mSaveManager; // own }; #endif /* CNTEDITVIEW_P_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cnteditviewlistmodel.cpp --- a/phonebookui/cntcommonui/contacteditors/cnteditviewlistmodel.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cnteditviewlistmodel.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -323,6 +323,7 @@ void CntEditViewListModel::refresh() { + mItemList.clear(); insertItem( EPhonenumber, mBuilder->phoneNumberItems(mContact) ); insertItem( EEmailAddress, mBuilder->emailAddressItems(mContact) ); insertItem( EAddressTemplate, mBuilder->addressItems(mContact) ); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cntnoteeditormodel.cpp --- a/phonebookui/cntcommonui/contacteditors/cntnoteeditormodel.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cntnoteeditormodel.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -25,6 +25,7 @@ foreach ( QContactNote note, mContact->details() ) { CntDetailModelItem* item = new CntDetailModelItem(note); + item->setLabel(hbTrId("txt_phob_formlabel_note")); appendDataFormItem( item, root ); connect( item, SIGNAL(itemDataChanged(CntDetailModelItem*)), this, SLOT(emitDataChanged(CntDetailModelItem*)) ); } @@ -39,6 +40,7 @@ QContactNote emptyNote; mNoteList.append( emptyNote ); CntDetailModelItem* newNote = new CntDetailModelItem(emptyNote); + newNote->setLabel(hbTrId("txt_phob_formlabel_note")); appendDataFormItem( newNote, invisibleRootItem() ); connect( newNote, SIGNAL(itemDataChanged(CntDetailModelItem*)), this, SLOT(emitDataChanged(CntDetailModelItem*)) ); emitDataChanged(newNote); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cntnoteeditorviewitem.cpp --- a/phonebookui/cntcommonui/contacteditors/cntnoteeditorviewitem.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cntnoteeditorviewitem.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -19,62 +19,63 @@ #include "cntdetailmodelitem.h" #include #include -#include -#include +#include +#include #include #include CntNoteEditorViewItem::CntNoteEditorViewItem( QGraphicsItem* aParent ) : -CntDetailViewItem(aParent), -mEdit(NULL), -mLayout(NULL) - { - } + CntDetailViewItem(aParent), + mEdit(NULL), + mLayout(NULL) +{ + +} CntNoteEditorViewItem::~CntNoteEditorViewItem() - { - } +{ +} + HbAbstractViewItem* CntNoteEditorViewItem::createItem() - { +{ return new CntNoteEditorViewItem( *this ); - } +} void CntNoteEditorViewItem::textChanged(const QString& aText) - { +{ HbDataFormModel* model = static_cast(itemView()->model()); CntDetailModelItem* item = static_cast( model->itemFromIndex(modelIndex()) ); QContactNote detail = item->detail(); detail.setNote( aText ); item->setDetail( detail ); - } +} HbWidget* CntNoteEditorViewItem::createCustomWidget() - { +{ HbDataFormModel* model = static_cast(itemView()->model()); CntDetailModelItem* item = static_cast( model->itemFromIndex(modelIndex()) ); QContactNote detail = item->detail(); mLayout = new QGraphicsLinearLayout(Qt::Vertical); + mLayout->setContentsMargins(0, 0, 0, 0); HbWidget* widget = new HbWidget(); - + mEdit = new HbLineEdit(); mEdit->setInputMethodHints(Qt::ImhNoPredictiveText); - + mEdit->setMaxLength( CNT_NOTE_EDITOR_MAXLENGTH ); mEdit->setMinRows( CNT_NOTE_EDITOR_MIN_ROWCOUNT ); mEdit->setText( detail.note() ); - HbLabel* label = new HbLabel(hbTrId("txt_phob_formlabel_note")); - mLayout->addItem(label); mLayout->addItem(mEdit); widget->setLayout( mLayout ); - + connect( mEdit, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)) ); - + // Naming UI components for automation testability QString editorObjName = detail.definitionName() + " line edit %1"; mEdit->setObjectName(editorObjName.arg(modelIndex().row())); return widget; - } +} // End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/contacteditors/cntnoteeditorviewitem.h --- a/phonebookui/cntcommonui/contacteditors/cntnoteeditorviewitem.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/contacteditors/cntnoteeditorviewitem.h Fri Oct 15 12:24:46 2010 +0300 @@ -21,12 +21,12 @@ #include "cntdetailviewitem.h" #include #include -#include -#include -#include + +class HbWidget; +class HbLineEdit; class CntNoteEditorViewItem : public CntDetailViewItem - { +{ Q_OBJECT public: @@ -45,6 +45,6 @@ QGraphicsLinearLayout* mLayout; friend class T_NoteEditorTest; - }; +}; #endif /* CNTNOTEEDITORVIEWITEM_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/core/cntactivities.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/core/cntactivities.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,90 @@ +/* +* 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 "cntactivities.h" +#include "cntglobal.h" +#include +#include +#include +#include + + +/*! +Constructor, initialize member variables. +*/ +CntActivities::CntActivities() +{ + mActivation = new AfActivation(); + mActivityStorage = new AfActivityStorage(); +} + +/*! +Destructor +*/ +CntActivities::~CntActivities() +{ + delete mActivation; + delete mActivityStorage; +} + +bool CntActivities::loadActivity(QByteArray &serializedModel) +{ + bool isActityStartup = false; + if (mActivation->reason() == Af::ActivationReasonActivity) + { + QVariant data = mActivityStorage->activityData(mActivation->name()); + // restore state from activity data + serializedModel = data.toByteArray(); + isActityStartup = true; + } + + // clean up all activities from the activity manager. + removeActivities(); + + return isActityStartup; +} + +void CntActivities::saveActivity(const QString &name, const QByteArray &serializedActivity, const QPixmap &screenshot) +{ + // clean up all activities from the activity manager. + removeActivities(); + + // do not save empty activity + if (name.isEmpty()) + return; + + // screen shot + QVariantHash metadata; + metadata.insert("screenshot", screenshot); + + // add the activity to the activity manager + bool ok = mActivityStorage->saveActivity(name, serializedActivity, metadata); + if ( !ok ) + { + qFatal("Add failed"); + } +} + +void CntActivities::removeActivities() +{ + QStringList activityList = mActivityStorage->allActivities(); + foreach (QString activity, activityList) + { + mActivityStorage->removeActivity(activity); + } +} + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/core/cntactivities.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/core/cntactivities.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,48 @@ +/* +* 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 CNTACTIVITIES_H_ +#define CNTACTIVITIES_H_ + +#include "cntviewparams.h" + +class AfActivation; +class AfActivityStorage; + +/* +* Class for load and save activities of contacts application. +*/ +class CntActivities : public QObject +{ + Q_OBJECT + +public: + CntActivities(); + ~CntActivities(); + bool loadActivity(QByteArray &serializedModel); + void saveActivity(const QString &name, const QByteArray &serializedActivity, const QPixmap &screenshot); + void removeActivities(); + +private: + AfActivation* mActivation; + AfActivityStorage* mActivityStorage; + +friend class TestCntActivities; + +}; + +#endif /* CNTACTIVITIES_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/core/cntdefaultengine.cpp --- a/phonebookui/cntcommonui/core/cntdefaultengine.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/core/cntdefaultengine.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -19,12 +19,14 @@ #include "cntdefaultengine.h" #include "cntextensionmanager.h" #include "cntthumbnailmanager.h" +#include "cntsavemanager.h" #include "cntdebug.h" CntDefaultEngine::CntDefaultEngine( CntAbstractViewManager& aManager ) : mViewManager( aManager ), mExtManager( NULL ), -mThumbnail( NULL ) +mThumbnail( NULL ), +mSaveManager( NULL ) { } @@ -82,4 +84,12 @@ return *mThumbnail; } +CntSaveManager& CntDefaultEngine::saveManager() +{ + if ( !mSaveManager ) + mSaveManager = new CntSaveManager( this ); + + return *mSaveManager; +} + // End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/core/cntdefaultengine.h --- a/phonebookui/cntcommonui/core/cntdefaultengine.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/core/cntdefaultengine.h Fri Oct 15 12:24:46 2010 +0300 @@ -29,17 +29,19 @@ CntDefaultEngine( CntAbstractViewManager& aManager ); ~CntDefaultEngine(); -public: - QContactManager& contactManager( const QString& aType ); +public: // From CntAbstractEngine + QContactManager& contactManager( const QString& type ); CntAbstractViewManager& viewManager(); CntExtensionManager& extensionManager(); CntThumbnailManager& thumbnailManager(); + CntSaveManager& saveManager(); private: - QList mBackends; + QList mBackends; // own list content CntAbstractViewManager& mViewManager; - CntExtensionManager* mExtManager; - CntThumbnailManager* mThumbnail; + CntExtensionManager* mExtManager; // own + CntThumbnailManager* mThumbnail; // own + CntSaveManager* mSaveManager; // own }; #endif /* CNTDEFAULTENGINE_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/core/cntdefaultviewfactory.cpp --- a/phonebookui/cntcommonui/core/cntdefaultviewfactory.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/core/cntdefaultviewfactory.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -38,10 +38,47 @@ #include "cntsettingsview.h" #include "cntextensionmanager.h" +const char *styleFiles = \ + ":/style/cntcollectionviewlistitem.css" \ + ":/style/cntcommondetailviewitem.css" \ + ":/style/cntcommondetailviewitem.widgetml" \ + ":/style/cntcontactcarddetailitem.css" \ + ":/style/cntcontactcarddetailitem.widgetml" \ + ":/style/cntcontactcarddetailitem_color.css" \ + ":/style/cntcontactcardheadingitem.css" \ + ":/style/cntcontactcardheadingitem.widgetml" \ + ":/style/cntcontactcardheadingitem_color.css" \ + ":/style/cnteditviewheadingitem.css" \ + ":/style/cnteditviewheadingitem.widgetml" \ + ":/style/cnteditviewheadingitem_color.css" \ + ":/style/cnteditviewlistitem.css" \ + ":/style/cnteditviewlistitem.hblistviewitem.widgetml" \ + ":/style/cntfetchmarkall.css" \ + ":/style/cntfetchmarkall.widgetml" \ + ":/style/cntfetchmarkall_color.css" \ + ":/style/cntgroupmemberviewlistitem.css" \ + ":/style/cnthistoryviewitemwidget.css" \ + ":/style/cnthistoryviewitemwidget.widgetml" \ + ":/style/cnthistoryviewitemwidget_color.css" \ + ":/style/cntimagelabel.css" \ + ":/style/cntimagelabel.widgetml" \ + ":/style/cntlocationbutton.css" \ + ":/style/cntlocationbutton.hbpushbutton.widgetml" \ + ":/style/cntselectiondialogmarkwidget_color.css"; + CntDefaultViewFactory::CntDefaultViewFactory( CntExtensionManager& aExt ): mExtensionManager( aExt ) { - HbStyleLoader::registerFilePath( ":/style" ); + QString files(styleFiles); + int lastPos = 0; + while (lastPos < files.length()) { + int pos = files.indexOf(":/style/", lastPos + 1); + if (pos == -1) { + pos = files.length(); + } + HbStyleLoader::registerFilePath(files.mid(lastPos, pos - lastPos)); + lastPos = pos; + } } CntDefaultViewFactory::~CntDefaultViewFactory() diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/core/cntdefaultviewmanager.cpp --- a/phonebookui/cntcommonui/core/cntdefaultviewmanager.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/core/cntdefaultviewmanager.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -133,6 +133,7 @@ { mArgs.insert( k, aArgs.value(k) ); } + mArgs.insert(EViewId, back ); if (mArgs.value(EViewId).toInt() != noView) @@ -140,9 +141,8 @@ switchView( mArgs, flags ); } else - { + { // exiting application - cleanup(); closeApp(); } @@ -164,34 +164,16 @@ QFlags flags; mNavigator->next(aArgs.value(EViewId).toInt(), flags); + + foreach(int k, aArgs.keys()) + { + mArgs.insert(k, aArgs.value(k)); + } + switchView(aArgs, flags); CNT_EXIT } -/* -QContactManager* CntDefaultViewManager::contactManager( const QString& aType ) -{ - CNT_ENTRY - - foreach ( QContactManager* mgr, mBackends ) - { - QString uri = mgr->managerUri(); - if ( aType.compare(uri, Qt::CaseInsensitive) == 0 ) - { - return mgr; - } - } - QContactManager* manager = QContactManager::fromUri( aType ); - - if ( manager ) - { - mBackends.append( manager ); - } - - CNT_EXIT - return manager; -} -*/ void CntDefaultViewManager::removeCurrentView() { @@ -234,11 +216,11 @@ CNT_EXIT } -void CntDefaultViewManager::switchView(const CntViewParameters aArgs, QFlags flags) +void CntDefaultViewManager::switchView(const CntViewParameters args, QFlags flags) { CNT_ENTRY - int id = aArgs.value(EViewId).toInt(); + int id = args.value(EViewId).toInt(); if ( id != noView ) { CntAbstractView* nextView(NULL); @@ -258,20 +240,79 @@ } mOldView = mCurrent; - mCurrent = nextView; - mMainWindow->addView(mCurrent->view()); - mMainWindow->setCurrentView(mCurrent->view(), true, flags); - mCurrent->activate(aArgs); - + activateView(nextView, args, flags); removeCurrentView(); } CNT_EXIT } -int CntDefaultViewManager::currentViewId() +void CntDefaultViewManager::activateView(CntAbstractView* nextView, const CntViewParameters args, QFlags flags) +{ + CNT_ENTRY + + mCurrent = nextView; + mMainWindow->addView(mCurrent->view()); + mMainWindow->setCurrentView(mCurrent->view(), true, flags); + mCurrent->activate(args); + + CNT_EXIT +} + +bool CntDefaultViewManager::internalize(QDataStream &stream) { - return mCurrent->viewId(); + CNT_ENTRY + + int id = mNavigator->internalize(stream); + if (id == noView) + { + return false; + } + + CntAbstractView* nextView(NULL); + nextView = mFactory->createView(id); + nextView->setEngine(*mEngine); + + CntViewParameters viewParams; + + bool success = nextView->internalize(stream, viewParams); + + if (success) + { + if (nextView->isDefault()) + { + mDefaults.insert(id, nextView); + } + QFlags flags; + mNavigator->next(id, flags); + + activateView(nextView, viewParams, flags); + } + else + { + mNavigator->clearViewStack(); + delete nextView; + } + + CNT_EXIT + return success; +} + +QString CntDefaultViewManager::externalize(QDataStream& stream) const +{ + CNT_ENTRY + + mNavigator->externalize(stream); + + QString activity; + + if (mCurrent) + { + activity = mCurrent->externalize(stream); + } + + CNT_EXIT + return activity; } // End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/core/cntdefaultviewmanager.h --- a/phonebookui/cntcommonui/core/cntdefaultviewmanager.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/core/cntdefaultviewmanager.h Fri Oct 15 12:24:46 2010 +0300 @@ -53,7 +53,11 @@ void back( const CntViewParameters aArgs, bool toRoot = false ); public: - int currentViewId(); + bool internalize(QDataStream &stream); + QString externalize(QDataStream &stream) const; + +private: + void activateView(CntAbstractView* nextView, const CntViewParameters args, QFlags flags); private slots: void removeCurrentView(); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/core/cntmainwindow.cpp --- a/phonebookui/cntcommonui/core/cntmainwindow.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/core/cntmainwindow.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -20,20 +20,29 @@ #include "cntviewnavigator.h" #include "cntabstractviewfactory.h" #include "cntkeygrabber.h" +#include "cntapplication.h" +#include "cntactivities.h" #include #include CntMainWindow::CntMainWindow(QWidget *parent, int defaultView) : HbMainWindow(parent), - mViewManager( NULL ), - mDefaultView( defaultView ) + mViewManager(NULL), + mDefaultView(defaultView), + mActivities(NULL) { CNT_ENTRY + CntKeyGrabber *keyGrabber = new CntKeyGrabber(this, this); if (defaultView != noView) { + mViewManager = new CntDefaultViewManager( this ); + mActivities = new CntActivities(); + + connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); + CntViewNavigator* navigator = new CntViewNavigator(this); navigator->addException( favoritesMemberView, collectionView ); navigator->addEffect( groupMemberView, groupActionsView ); @@ -44,15 +53,27 @@ navigator->addRoot( collectionView ); navigator->addRoot( groupMemberView ); navigator->addRoot( favoritesMemberView ); - - mViewManager = new CntDefaultViewManager( this ); + mViewManager->setViewNavigator( navigator ); mViewManager->setViewFactory( new CntDefaultViewFactory( mViewManager->engine().extensionManager()) ); + + //load the activity + QByteArray serializedModel; + if (mActivities->loadActivity(serializedModel)) + { + // restore state from activity data + QDataStream stream(&serializedModel, QIODevice::ReadOnly); + if (mViewManager->internalize(stream)) + { + // activity loaded. + return; + } + } //activate the view CntViewParameters viewParameters; viewParameters.insert(EViewId, defaultView); - mViewManager->changeView( viewParameters ); + mViewManager->changeView( viewParameters ); } CNT_EXIT @@ -61,10 +82,25 @@ CntMainWindow::~CntMainWindow() { CNT_ENTRY - + delete mViewManager; mViewManager = NULL; + delete mActivities; + mActivities = NULL; + + CNT_EXIT +} + +void CntMainWindow::saveActivity() +{ + CNT_ENTRY + + QByteArray serializedActivity; + QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append); + QString name = mViewManager->externalize(stream); + mActivities->saveActivity(name, serializedActivity, QPixmap::grabWidget(this, rect())); + CNT_EXIT } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/core/cntmainwindow.h --- a/phonebookui/cntcommonui/core/cntmainwindow.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/core/cntmainwindow.h Fri Oct 15 12:24:46 2010 +0300 @@ -25,6 +25,7 @@ class CntDefaultViewManager; class XqKeyCapture; +class CntActivities; class QTPBK_EXPORT CntMainWindow : public HbMainWindow { @@ -35,10 +36,13 @@ CntMainWindow(QWidget *parent=0, int defaultView = namesView); virtual ~CntMainWindow(); +private slots: + void saveActivity(); + private: CntDefaultViewManager *mViewManager; int mDefaultView; - + CntActivities *mActivities; }; #endif // CNTMAINWINDOW_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/core/cntviewnavigator.cpp --- a/phonebookui/cntcommonui/core/cntviewnavigator.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/core/cntviewnavigator.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -19,8 +19,9 @@ #include CntViewNavigator::CntViewNavigator( QObject* aParent ) : - QObject( aParent ), - iTop( noView ) + QObject(aParent), + mTop(noView), + mPreviousViewId(noView) { } @@ -32,12 +33,12 @@ void CntViewNavigator::next( const int& aId, QFlags &flags ) { - if ( !iViewStack.isEmpty() ) + if ( !mViewStack.isEmpty() ) { - int top = iViewStack.top(); + int top = mViewStack.top(); // If any special effects are defined for the current (top) view and associated with the next view - if ( iEffects.contains( top ) && iEffects.value( top ) == aId ) + if ( mEffects.contains( top ) && mEffects.value( top ) == aId ) { flags = Hb::ViewSwitchUseNormalAnim | Hb::ViewSwitchUseAltEvent; } @@ -46,61 +47,61 @@ flags = Hb::ViewSwitchUseNormalAnim; } } - iViewStack.push( aId ); + mViewStack.push( aId ); } const int& CntViewNavigator::back( QFlags &flags, bool toRoot ) { - iTop = noView; + mTop = noView; // Check if exception is set for current view item. Exception // means that instead of one step back, we go back until that // execption value is located. So all items that are jumped over, // their history will be eared. - if ( !iViewStack.isEmpty() ) + if ( !mViewStack.isEmpty() ) { - int top = iViewStack.top(); + int top = mViewStack.top(); // If we need to go to the latest root view if ( toRoot ) { - while ( !iViewStack.isEmpty() ) + while ( !mViewStack.isEmpty() ) { - int current = iViewStack.top(); + int current = mViewStack.top(); - if ( iRoots.contains( current ) ) + if ( mRoots.contains( current ) ) { - iTop = current; + mTop = current; break; } - iViewStack.pop(); + mPreviousViewId = mViewStack.pop(); } } // If any exception defined for the current (top) view - else if ( iExceptions.contains( top ) ) + else if ( mExceptions.contains( top ) ) { - iTop = iExceptions.value( top ); + mTop = mExceptions.value( top ); // cleanup the history until the exception value is found - while ( !iViewStack.isEmpty() ) + while ( !mViewStack.isEmpty() ) { - if ( iTop == iViewStack.top() ) + if ( mTop == mViewStack.top() ) { break; // don't pop the exception it self. } - iViewStack.pop(); + mPreviousViewId = mViewStack.pop(); } } // No exceptions defined, go one step back else { - iViewStack.pop(); - if ( !iViewStack.isEmpty() ) + mPreviousViewId = mViewStack.pop(); + if ( !mViewStack.isEmpty() ) { - iTop = iViewStack.top(); + mTop = mViewStack.top(); } } // If any special effects are defined for the current (top) view and associated with the previous view - if ( iEffects.contains( top ) && iEffects.value( top ) == iTop ) + if ( mEffects.contains( top ) && mEffects.value( top ) == mTop ) { flags = Hb::ViewSwitchUseBackAnim | Hb::ViewSwitchUseAltEvent; } @@ -110,38 +111,68 @@ } } - return iTop; + return mTop; } void CntViewNavigator::addException( const int& aCurrent, const int& aBack ) { - iExceptions.insert( aCurrent, aBack ); + mExceptions.insert( aCurrent, aBack ); } void CntViewNavigator::removeException( const int& aCurrent ) { - if ( iExceptions.contains(aCurrent) ) + if ( mExceptions.contains(aCurrent) ) { - iExceptions.remove( aCurrent ); + mExceptions.remove( aCurrent ); } } void CntViewNavigator::addEffect( const int& aCurrent, const int& aBack ) { - iEffects.insert( aCurrent, aBack ); + mEffects.insert( aCurrent, aBack ); } void CntViewNavigator::removeEffect( const int& aCurrent ) { - if ( iEffects.contains(aCurrent) ) + if ( mEffects.contains(aCurrent) ) { - iEffects.remove( aCurrent ); + mEffects.remove( aCurrent ); } } void CntViewNavigator::addRoot( const int& aCurrent ) { - iRoots.append( aCurrent ); + mRoots.append( aCurrent ); +} + +int CntViewNavigator::internalize(QDataStream &stream) +{ + int viewId = noView; + //read the view id and a view stack from stream. + stream >> viewId >> mViewStack; + + return viewId; } +void CntViewNavigator::externalize(QDataStream &stream) +{ + int viewId = noView; + + //remove top view id of stack. + if (!mViewStack.isEmpty()) { + viewId = mViewStack.pop(); + } + + if (viewId == noView) { + viewId = mPreviousViewId; + } + //stream the view id and a view stack + stream << viewId << mViewStack; +} + +void CntViewNavigator::clearViewStack() +{ + mViewStack.clear(); +} + // End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/core/cntviewnavigator.h --- a/phonebookui/cntcommonui/core/cntviewnavigator.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/core/cntviewnavigator.h Fri Oct 15 12:24:46 2010 +0300 @@ -70,12 +70,28 @@ * Set a view as a root view. */ void addRoot( const int& aCurrent ); + + /*! + * Internalize view data. Returns the previous view id. + */ + int internalize(QDataStream &stream); + + /*! + * Externalize view data. + */ + void externalize(QDataStream &stream); + + /*! + * Clear view stack. + */ + void clearViewStack(); private: - QStack iViewStack; - QMap< int, int > iExceptions; - QMap< int, int > iEffects; - QList iRoots; - int iTop; + QStack mViewStack; + QMap< int, int > mExceptions; + QMap< int, int > mEffects; + QList mRoots; + int mTop; + int mPreviousViewId; }; #endif /* CNTVIEWNAVIGATOR_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/resources/cntcommonui.qrc --- a/phonebookui/cntcommonui/resources/cntcommonui.qrc Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/resources/cntcommonui.qrc Fri Oct 15 12:24:46 2010 +0300 @@ -31,8 +31,9 @@ style/cntcontactcardheadingitem.widgetml style/cntcontactcardheadingitem.css style/cntcontactcardheadingitem_color.css - style/cnthistoryviewitem.widgetml - style/cnthistoryviewitem.css + style/cnthistoryviewitemwidget.widgetml + style/cnthistoryviewitemwidget.css + style/cnthistoryviewitemwidget_color.css style/cntcommondetailviewitem.widgetml style/cntcommondetailviewitem.css style/cntimagelabel.widgetml @@ -45,4 +46,7 @@ style/cntcollectionviewlistitem.css style/cntgroupmemberviewlistitem.css + + effects/item_change_layout.fxml + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/resources/contacts_namelist.docml --- a/phonebookui/cntcommonui/resources/contacts_namelist.docml Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/resources/contacts_namelist.docml Fri Oct 15 12:24:46 2010 +0300 @@ -60,7 +60,6 @@ -
@@ -81,7 +80,6 @@ -
@@ -104,7 +102,6 @@ - @@ -127,7 +124,6 @@ - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/resources/effects/item_change_layout.fxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/resources/effects/item_change_layout.fxml Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,9 @@ + + + + 0.4 + 1.0 + 0.0 1.0 + + + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/resources/style/cntcommondetailviewitem.widgetml --- a/phonebookui/cntcommonui/resources/style/cntcommondetailviewitem.widgetml Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/resources/style/cntcommondetailviewitem.widgetml Fri Oct 15 12:24:46 2010 +0300 @@ -1,24 +1,24 @@ - - - + + + - + - + - + - - + + - - - + + + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/resources/style/cnthistoryviewitem.css --- a/phonebookui/cntcommonui/resources/style/cnthistoryviewitem.css Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -CntHistoryViewItem[layoutName="history"][modelItemType="StandardItem"][incoming]{ - layout:custom-history-incoming; -} - -CntHistoryViewItem[layoutName="history"][modelItemType="StandardItem"][!incoming]{ - layout:custom-history-outgoing; -} - -CntHistoryViewItem::text-3[layoutName="history"]{ - text-height:var(hb-param-text-height-tiny); - font-variant:secondary; - text-align: left; -} - -CntHistoryViewItem::frame[layoutName="history"]{ - border-width: 0.0un; -} - -CntHistoryViewItem::newitem[layoutName="history"]{ - top:-1.0un; - bottom:1.0un; -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/resources/style/cnthistoryviewitem.widgetml --- a/phonebookui/cntcommonui/resources/style/cnthistoryviewitem.widgetml Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/resources/style/cnthistoryviewitemwidget.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/resources/style/cnthistoryviewitemwidget.css Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,52 @@ +CntHistoryViewItemWidget[incoming]{ + layout:custom-history-incoming; +} + +CntHistoryViewItemWidget[!incoming]{ + layout:custom-history-outgoing; +} + +CntHistoryViewItemWidget::text-1{ + text-height: var(hb-param-text-height-primary); + font-variant: primary; + pref-width:-1; + text-align: left; + size-policy-horizontal: ignored; + text-line-count-min:1; + text-line-count-max:1; + text-wrap-mode:no-wrap; +} + +CntHistoryViewItemWidget::text-2{ + text-height: var(hb-param-text-height-secondary); + font-variant: secondary; + pref-width:-1; + text-align: left top; + size-policy-horizontal: ignored; + text-line-count-min:1; + text-line-count-max:3; +} + +CntHistoryViewItemWidget::text-3{ + text-height:var(hb-param-text-height-tiny); + font-variant:secondary; + text-align: left; +} + +CntHistoryViewItemWidget::icon-1{ + fixed-height: var(hb-param-graphic-size-primary-small); + fixed-width: var(hb-param-graphic-size-primary-small); +} + +CntHistoryViewItemWidget::frame{ + border-width: 0.0un; +} + +CntHistoryViewItemWidget::focusframe{ + border-width: 0.0un; +} + +CntHistoryViewItemWidget::newitem{ + top:-1.0un; + bottom:1.0un; +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/resources/style/cnthistoryviewitemwidget.widgetml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/resources/style/cnthistoryviewitemwidget.widgetml Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/resources/style/cnthistoryviewitemwidget_color.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/resources/style/cnthistoryviewitemwidget_color.css Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,31 @@ +CntHistoryViewItemWidget::text-1{ + color: var(qtc_list_item_title_normal); +} + +CntHistoryViewItemWidget::text-1[state="pressed"]{ + color: var(qtc_list_item_pressed); +} + +CntHistoryViewItemWidget::text-2{ + color: var(qtc_list_item_content_normal); +} + +CntHistoryViewItemWidget::text-2[state="pressed"]{ + color: var(qtc_list_item_pressed); +} + +CntHistoryViewItemWidget::text-3{ + color: var(qtc_list_item_content_normal); +} + +CntHistoryViewItemWidget::text-3[state="pressed"]{ + color: var(qtc_list_item_pressed); +} + +CntHistoryViewItemWidget::icon-1{ + color: var(qtc_list_item_title_normal); +} + +CntHistoryViewItemWidget::icon-1[state="pressed"]{ + color: var(qtc_list_item_pressed); +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/cntactionextensionexample.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/cntactionextensionexample.pro Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,58 @@ +# +# 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: +# + +TEMPLATE = lib +CONFIG += plugin +CONFIG += hb +CONFIG += symbian_test +TARGET = $$qtLibraryTarget(cntexampleactionsplugin) +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += \ + inc/cntexampleactionfactory.h \ + inc/cntexamplebaseaction.h \ + inc/cntexampleaction.h \ + inc/cntexample2action.h \ + inc/cntexamplenodetailaction.h \ + inc/cntexampledynamicaction.h + +SOURCES += \ + src/cntexampleactionfactory.cpp \ + src/cntexamplebaseaction.cpp \ + src/cntexampleaction.cpp \ + src/cntexample2action.cpp \ + src/cntexamplenodetailaction.cpp \ + src/cntexampledynamicaction.cpp +MOC_DIR = moc + +symbian: + { + load(data_caging_paths) + TARGET.CAPABILITY = CAP_GENERAL_DLL + TARGET.EPOCALLOWDLLDATA = 1 + TARGET.UID3 = 0xefa11113 + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + LIBS += -lQtContacts \ + -lxqservice + target.path = /sys/bin + INSTALLS += target + symbianplugin.sources = $${TARGET}.dll + symbianplugin.path = /resource/qt/plugins/contacts + DEPLOYMENT += symbianplugin +} +symbian:MMP_RULES += SMPSAFE \ No newline at end of file diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/inc/cntexample2action.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/inc/cntexample2action.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2010 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 QMOBEXAMPLE2ACTION_H +#define QMOBEXAMPLE2ACTION_H + +#include "cntexamplebaseaction.h" + +class MobExample2Action : public MobBaseAction +{ + Q_OBJECT + +public: + MobExample2Action(const QString& actionName, const QString& vendorName); + ~MobExample2Action(); + + QVariantMap metaData() const; + QContactFilter contactFilter(const QVariant& value) const; + bool isDetailSupported(const QContactDetail &detail, const QContact &contact = QContact()) const; + QList supportedDetails(const QContact& contact) const; + State state() const; + MobExample2Action* clone() const; +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/inc/cntexampleaction.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/inc/cntexampleaction.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2010 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 QMOBEXAMPLEACTION_H +#define QMOBEXAMPLEACTION_H + +#include "cntexamplebaseaction.h" + +class MobExampleAction : public MobBaseAction +{ + Q_OBJECT + +public: + MobExampleAction(const QString& actionName, const QString& vendorName); + ~MobExampleAction(); + + QVariantMap metaData() const; + QContactFilter contactFilter(const QVariant& value) const; + bool isDetailSupported(const QContactDetail &detail, const QContact &contact = QContact()) const; + QList supportedDetails(const QContact& contact) const; + State state() const; + MobExampleAction* clone() const; +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/inc/cntexampleactionfactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/inc/cntexampleactionfactory.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2010 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 MOBEXAMPLEACTIONFACTORY_H +#define MOBEXAMPLEACTIONFACTORY_H + +#include +#include + +class MobBaseAction; + +QTM_USE_NAMESPACE + +class Q_DECL_EXPORT MobExampleActionFactory : public QContactActionFactory +{ + Q_OBJECT + Q_INTERFACES(QtMobility::QContactActionFactory) + +public: + MobExampleActionFactory(); + ~MobExampleActionFactory(); + + QString name() const; + QList actionDescriptors() const; + QContactAction* instance(const QContactActionDescriptor& descriptor) const; + QVariantMap actionMetadata(const QContactActionDescriptor& descriptor) const; + +private: + QList actionList; +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/inc/cntexamplebaseaction.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/inc/cntexamplebaseaction.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2010 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 MOBBASEACTION_H +#define MOBBASEACTION_H + +#include +#include + +#include +#include +#include + +QTM_USE_NAMESPACE + +class MobBaseAction : public QContactAction +{ + Q_OBJECT + +public: + MobBaseAction(const QString &actionName, const QString& vendorName); + virtual ~MobBaseAction(); + +public: + enum ErrorCodes { + GeneralError = 1, + DetailNotSupported + }; + + +public: //QContactAction + QContactActionDescriptor actionDescriptor() const; + bool invokeAction(const QContact& contact, const QContactDetail& detail = QContactDetail(), const QVariantMap& parameters = QVariantMap()); + QVariantMap results() const; + +public: + virtual void resetAction(); + virtual MobBaseAction* clone() const = 0; + +public: + //returns whether the actionDescription is supported by this action + bool actionDescriptionSupported(const QContactActionDescriptor& descriptor) const; + void emitResult(int errorCode, const QVariant &retValue); + + +protected: + QString m_actionName; + QString m_vendorName; + int m_implementationVersion; + + QVariantMap m_result; //result returned to client + QContact m_contact; //contact passed to invokeAction + QContactDetail m_detail; //detail passed to invokeAction +}; + +#endif //MOBBASEACTION_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/inc/cntexampledynamicaction.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/inc/cntexampledynamicaction.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2010 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 QMOBEXAMPLEDYNAMICACTION_H +#define QMOBEXAMPLEDYNAMICACTION_H + +#include "cntexamplebaseaction.h" + +#include + +class MobExampleDynamicAction : public MobBaseAction +{ + Q_OBJECT + +public: + MobExampleDynamicAction(const QString& actionName, const QString& vendorName); + MobExampleDynamicAction(const QString& actionName, const QString& vendorName, const MobExampleDynamicAction& copy); + ~MobExampleDynamicAction(); + + QVariantMap metaData() const; + QContactFilter contactFilter(const QVariant& value) const; + bool isDetailSupported(const QContactDetail &detail, const QContact &contact = QContact()) const; + QList supportedDetails(const QContact& contact) const; + State state() const; + MobExampleDynamicAction* clone() const; + + void setDefinitionName(const QString& definitionName); + void setFilter(QContactFilter filter); + void setIcon(QIcon icon); + void setTitleField(QString titleField); + void setValueField(QString valueField); + void setTitleFieldDetail(QString titleField); + void setValueFieldDetail(QString valueField); + +private: + QString mTitleField; + QString mValueField; + QString mTitleFieldDetail; + QString mValueFieldDetail; + QIcon mIcon; + QContactFilter mFilter; + QString mDefinitionName; +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/inc/cntexamplenodetailaction.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/inc/cntexamplenodetailaction.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2010 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 MOBEXAMPLENODETAILACTION_H_ +#define MOBEXAMPLENODETAILACTION_H_ + +#include "cntexamplebaseaction.h" + +class MobExampleNoDetailAction : public MobBaseAction +{ + Q_OBJECT + +public: + MobExampleNoDetailAction(const QString& actionName, const QString& vendorName); + ~MobExampleNoDetailAction(); + + QVariantMap metaData() const; + QContactFilter contactFilter(const QVariant& value) const; + bool isDetailSupported(const QContactDetail &detail, const QContact &contact = QContact()) const; + QList supportedDetails(const QContact& contact) const; + State state() const; + MobExampleNoDetailAction* clone() const; +}; + +#endif /* MOBEXAMPLENODETAILACTION_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/src/cntexample2action.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/src/cntexample2action.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2010 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 "cntexample2action.h" +#include +#include +#include +#include +#include + +//Action class +MobExample2Action::MobExample2Action(const QString& actionName, const QString& vendorName) : + MobBaseAction(actionName, vendorName) +{ +} + +MobExample2Action::~MobExample2Action() +{ +} + +QVariantMap MobExample2Action::metaData() const +{ + QVariantMap variantMap; + QVariant localization("Test action 2"); + variantMap.insert(KCntUiActionMetaTitleText, localization); + const QString& string(QContactPhoneNumber::FieldNumber); + QVariant detailField(string); + variantMap.insert(KCntUiActionMetaValueTextDetail, detailField); + QString menuString("Do example action2"); + QVariant longPressMenu(menuString); + variantMap.insert(KCntUiActionMetaValueTextLongPress, longPressMenu); + return variantMap; +} + +QContactFilter MobExample2Action::contactFilter(const QVariant& value) const +{ + Q_UNUSED(value); + + QContactDetailFilter mobileFilter; + mobileFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName, QContactPhoneNumber::FieldSubTypes); + mobileFilter.setValue(QLatin1String(QContactPhoneNumber::SubTypeMobile)); + + return mobileFilter; +} + +bool MobExample2Action::isDetailSupported(const QContactDetail &detail, const QContact &contact) const +{ + if(QContactPhoneNumber::DefinitionName == detail.definitionName()) + { + return true; + } + else + { + return false; + } +} + +QList MobExample2Action::supportedDetails(const QContact& contact) const +{ + +} + +QContactAction::State MobExample2Action::state() const +{ + +} + +MobExample2Action* MobExample2Action::clone() const +{ + return new MobExample2Action(m_actionName, m_vendorName); +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/src/cntexampleaction.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/src/cntexampleaction.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2010 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 "cntexampleaction.h" +#include +#include +#include +#include +#include +#include +#include + +//Action class +MobExampleAction::MobExampleAction(const QString& actionName, const QString& vendorName) : + MobBaseAction(actionName, vendorName) +{ +} + +MobExampleAction::~MobExampleAction() +{ +} + +QVariantMap MobExampleAction::metaData() const +{ + QVariantMap variantMap; + const QString& string("Test action 1"); + QVariant localization(string); + variantMap.insert(KCntUiActionMetaTitleText, localization); + const QString& string2(QContactOnlineAccount::FieldAccountUri); + const QVariant detailField(string2); + variantMap.insert(KCntUiActionMetaValueTextDetail, detailField); + QString menuString("Do example action"); + QVariant longPressMenu(menuString); + variantMap.insert(KCntUiActionMetaValueTextLongPress, longPressMenu); + HbIcon hIcon("qtg_large_voip.svg"); + // Must be QIcon + QIcon icon(hIcon.qicon()); + QVariant iconVariant(icon); + variantMap.insert("icon", iconVariant); + return variantMap; +} + +QContactFilter MobExampleAction::contactFilter(const QVariant& value) const +{ + Q_UNUSED(value); + + QContactDetailFilter onlineFilter; + onlineFilter.setDetailDefinitionName(QContactOnlineAccount::DefinitionName, QContactOnlineAccount::FieldSubTypes); + onlineFilter.setValue(QLatin1String(QContactOnlineAccount::SubTypeImpp)); + + return onlineFilter; +} + +bool MobExampleAction::isDetailSupported(const QContactDetail &detail, const QContact &contact) const +{ + if(QContactOnlineAccount::DefinitionName == detail.definitionName()) + { + return true; + } + else + { + return false; + } +} + +QList MobExampleAction::supportedDetails(const QContact& contact) const +{ + +} + +QContactAction::State MobExampleAction::state() const +{ + +} + +MobExampleAction* MobExampleAction::clone() const +{ + return new MobExampleAction(m_actionName, m_vendorName); +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/src/cntexampleactionfactory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/src/cntexampleactionfactory.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2010 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 ACTIONFACTORYPLUGINTARGET +#define ACTIONFACTORYPLUGINTARGET cntexampleactionsplugin +#endif +#ifndef ACTIONFACTORYPLUGINNAME +#define ACTIONFACTORYPLUGINNAME SymbianActionFactory +#endif + +#include "cntexampleactionfactory.h" +#include "cntexampleaction.h" +#include "cntexample2action.h" +#include "cntexamplenodetailaction.h" +#include "cntexampledynamicaction.h" + +#include +#include + +#define makestr(x) (#x) +#define makename(x) makestr(x) + + +//Factory class +MobExampleActionFactory::MobExampleActionFactory() +{ + // Next two actions are different, but for same service. These actions can be used + // also for other services, by changing "Test service". In real plugin all these actions + // would have been created once for each service. In this example third action is created for + // different service for testing purposes. + actionList.append(new MobExampleAction("staticaction1", "Test service")); + actionList.append(new MobExample2Action("staticaction2", "Test service")); + // This action is for second service. + actionList.append(new MobExampleNoDetailAction("nodetailaction", "Test service 2")); + + // create several variants of one action and change it behaviour in run time + MobExampleDynamicAction* nonUiItem = new MobExampleDynamicAction("dynamicaction", "Test service 2"); + nonUiItem->setDefinitionName(QContactOnlineAccount::DefinitionName); + QContactDetailFilter filter; + filter.setDetailDefinitionName(QContactOnlineAccount::DefinitionName); + nonUiItem->setFilter(filter); + nonUiItem->setIcon(QIcon()); + nonUiItem->setTitleField(""); + nonUiItem->setTitleFieldDetail(""); + actionList.append(nonUiItem); + + MobExampleDynamicAction* emptyValueField = new MobExampleDynamicAction("dynamicaction2", "Test service 2"); + emptyValueField->setDefinitionName(QContactOnlineAccount::DefinitionName); + QContactDetailFilter filter2; + filter2.setDetailDefinitionName(QContactOnlineAccount::DefinitionName); + emptyValueField->setFilter(filter2); + emptyValueField->setIcon(QIcon()); + emptyValueField->setTitleFieldDetail(QContactOnlineAccount::FieldServiceProvider); + emptyValueField->setValueField(""); + actionList.append(emptyValueField); +} + +MobExampleActionFactory::~MobExampleActionFactory() +{ + while (!actionList.isEmpty()) + delete actionList.takeFirst(); +} + +QString MobExampleActionFactory::name() const +{ + return QString(makename(ACTIONFACTORYPLUGINNAME)); +} + + +QList MobExampleActionFactory::actionDescriptors() const +{ + QList descriptorList; + + //loop through all the actions and add the descriptor to the list + for (int i = 0; i < actionList.size(); i++) + { + descriptorList << actionList.at(i)->actionDescriptor(); + } + + return descriptorList; +} + +QContactAction* MobExampleActionFactory::instance(const QContactActionDescriptor& descriptor) const +{ + QContactAction *action(0); + + //loop through the actions and return the one that supports the descriptor + for (int i = 0; i < actionList.size() && action == 0; i++) + { + if (actionList.at(i)->actionDescriptionSupported(descriptor)){ + //create a new heap object of the action + action = actionList.at(i)->clone(); + } + } + + return action; +} + +QVariantMap MobExampleActionFactory::actionMetadata(const QContactActionDescriptor& descriptor) const +{ + QVariantMap map; + + //loop through the actions and return the one that supports the descriptor + for (int i = 0; i < actionList.size() && map.isEmpty(); i++) + { + if (actionList.at(i)->actionDescriptionSupported(descriptor)) + { + map = actionList.at(i)->metaData(); + } + } + + return map; + +} + +Q_EXPORT_PLUGIN2(ACTIONFACTORYPLUGINTARGET, MobExampleActionFactory); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/src/cntexamplebaseaction.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/src/cntexamplebaseaction.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2010 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 "cntexamplebaseaction.h" + +#include +#include +#include +#include +#include + +MobBaseAction::MobBaseAction(const QString &actionName, const QString& vendorName) : + m_actionName(actionName), + m_vendorName(vendorName), + m_implementationVersion(1), + m_result(), + m_contact(), + m_detail() +{ +} + +MobBaseAction::~MobBaseAction() +{ +} + +QContactActionDescriptor MobBaseAction::actionDescriptor() const +{ + QContactActionDescriptor ret; + ret.setActionName(m_actionName); + ret.setVendorName(m_vendorName); + ret.setImplementationVersion(m_implementationVersion); + return ret; +} + +bool MobBaseAction::invokeAction(const QContact& contact, const QContactDetail& detail, const QVariantMap& parameters) +{ + m_contact = contact; + m_detail = detail; +} + +//Clears the action data, is called after the result has been emitted to contact (emitResult function) +void MobBaseAction::resetAction() +{ + m_contact = QContact(); + m_detail = QContactDetail(); +} + +//returns whether the actionDescription is supported by this action +bool MobBaseAction::actionDescriptionSupported(const QContactActionDescriptor& descriptor) const +{ + bool supported(false); + + if ((descriptor.actionName() == m_actionName) && (descriptor.vendorName() == m_vendorName) && (descriptor.implementationVersion() == m_implementationVersion)) + supported = true; + else + supported = false; + + return supported; +} + +//emit the result to the client +void MobBaseAction::emitResult(int errorCode, const QVariant &retValue) +{ +// m_result.clear(); +// m_result.insert("Error", QVariant(errorCode)); +// m_result.insert("ReturnValue", retValue); +// +// QContactAction::Status status; +// +// if (errorCode == 0){ +// status = QContactAction::Finished; +// } +// +// else{ +// status = QContactAction::FinishedWithError; +// } +// +// emit progress(status, m_result); + + resetAction(); //reset values in the action +} + +QVariantMap MobBaseAction::results() const +{ + return m_result; +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/src/cntexampledynamicaction.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/src/cntexampledynamicaction.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2010 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 "cntexampledynamicaction.h" +#include +#include +#include +#include +#include + +//Action class +MobExampleDynamicAction::MobExampleDynamicAction(const QString& actionName, const QString& vendorName) : + MobBaseAction(actionName, vendorName) +{ +} + +MobExampleDynamicAction::MobExampleDynamicAction(const QString& actionName, const QString& vendorName, const MobExampleDynamicAction& copy) : + MobBaseAction(actionName, vendorName) +{ + mTitleField = copy.mTitleField; + mValueField = copy.mValueField; + mTitleFieldDetail = copy.mTitleFieldDetail; + mValueFieldDetail = copy.mValueFieldDetail; + mIcon = copy.mIcon; + mFilter = copy.mFilter; + mDefinitionName = copy.mDefinitionName; +} + +MobExampleDynamicAction::~MobExampleDynamicAction() +{ +} + +QVariantMap MobExampleDynamicAction::metaData() const +{ + QVariantMap variantMap; + + variantMap.insert(KCntUiActionMetaTitleTextDetail, !mTitleField.isEmpty() ? mTitleField : mTitleFieldDetail); + + if(!mValueFieldDetail.isEmpty()) + variantMap.insert(KCntUiActionMetaValueTextDetail, mValueFieldDetail); + else if(!mValueField.isEmpty()) + variantMap.insert(KCntUiActionMetaValueText, mValueField); + // Must be QIcon + QIcon icon(mIcon); + QVariant iconVariant(icon); + variantMap.insert("icon", iconVariant); + return variantMap; +} + +QContactFilter MobExampleDynamicAction::contactFilter(const QVariant& value) const +{ + return mFilter; +} + +bool MobExampleDynamicAction::isDetailSupported(const QContactDetail &detail, const QContact &contact) const +{ + if(mDefinitionName == detail.definitionName()) + { + return true; + } + else + { + return false; + } +} + +QList MobExampleDynamicAction::supportedDetails(const QContact& contact) const +{ + +} + +QContactAction::State MobExampleDynamicAction::state() const +{ + +} + +MobExampleDynamicAction* MobExampleDynamicAction::clone() const +{ + return new MobExampleDynamicAction(m_actionName, m_vendorName, *this); +} + +void MobExampleDynamicAction::setDefinitionName(const QString& definitionName) +{ + mDefinitionName = definitionName; +} + +void MobExampleDynamicAction::setFilter(QContactFilter filter) +{ + mFilter = filter; +} + +void MobExampleDynamicAction::setIcon(QIcon icon) +{ + mIcon = icon; +} + +void MobExampleDynamicAction::setTitleField(QString titleField) +{ + mTitleField = titleField; +} + +void MobExampleDynamicAction::setValueField(QString valueField) +{ + mValueField = valueField; +} + +void MobExampleDynamicAction::setTitleFieldDetail(QString titleFieldDetail) +{ + mTitleFieldDetail = titleFieldDetail; +} + +void MobExampleDynamicAction::setValueFieldDetail(QString valueFieldDetail) +{ + mValueFieldDetail = valueFieldDetail; +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/src/cntexamplenodetailaction.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/tsrc/ut_contactcard/cntactionextensionexample/src/cntexamplenodetailaction.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2010 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 "cntexamplenodetailaction.h" +#include + +//Action class +MobExampleNoDetailAction::MobExampleNoDetailAction(const QString& actionName, const QString& vendorName) : + MobBaseAction(actionName, vendorName) +{ +} + +MobExampleNoDetailAction::~MobExampleNoDetailAction() +{ +} + +QVariantMap MobExampleNoDetailAction::metaData() const +{ + QVariantMap variantMap; + QVariant localization("Test action 3"); + variantMap.insert(KCntUiActionMetaTitleText, localization); + QVariant detailField("Description"); + variantMap.insert(KCntUiActionMetaValueText, detailField); + QString menuString("Do action 3"); + QVariant longPressMenu(menuString); + variantMap.insert(KCntUiActionMetaValueTextLongPress, longPressMenu); + return variantMap; +} + +QContactFilter MobExampleNoDetailAction::contactFilter(const QVariant& value) const +{ + Q_UNUSED(value); + + QContactFilter all; + + return all; +} + +// If detail is empty plugin knows that this is special action query that +// is targetted to whole contact not to specific detail on contact. +// If you want to create action to my card only, check cntuiactionextension.h for details +bool MobExampleNoDetailAction::isDetailSupported(const QContactDetail &detail, const QContact &contact) const +{ + if(detail.isEmpty()) + { + return true; + } + else + { + return false; + } +} + +QList MobExampleNoDetailAction::supportedDetails(const QContact& contact) const +{ + +} + +QContactAction::State MobExampleNoDetailAction::state() const +{ + +} + +MobExampleNoDetailAction* MobExampleNoDetailAction::clone() const +{ + return new MobExampleNoDetailAction(m_actionName, m_vendorName); +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/cntactionextensionexample.pro --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/cntactionextensionexample.pro Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -# -# 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: -# - -TEMPLATE = lib -CONFIG += plugin -CONFIG += hb -TARGET = $$qtLibraryTarget(cntexampleactionsplugin) -DEPENDPATH += . -INCLUDEPATH += . - -# Input -HEADERS += \ - inc/cntexampleactionfactory.h \ - inc/cntexamplebaseaction.h \ - inc/cntexampleaction.h \ - inc/cntexample2action.h \ - inc/cntexamplenodetailaction.h \ - inc/cntexampledynamicaction.h - -SOURCES += \ - src/cntexampleactionfactory.cpp \ - src/cntexamplebaseaction.cpp \ - src/cntexampleaction.cpp \ - src/cntexample2action.cpp \ - src/cntexamplenodetailaction.cpp \ - src/cntexampledynamicaction.cpp -MOC_DIR = moc - -symbian: - { - load(data_caging_paths) - TARGET.CAPABILITY = CAP_GENERAL_DLL - TARGET.EPOCALLOWDLLDATA = 1 - TARGET.UID3 = 0xefa11113 - INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE - LIBS += -lQtContacts \ - -lxqservice - target.path = /sys/bin - INSTALLS += target - symbianplugin.sources = $${TARGET}.dll - symbianplugin.path = /resource/qt/plugins/contacts - DEPLOYMENT += symbianplugin -} -symbian:MMP_RULES += SMPSAFE \ No newline at end of file diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/inc/cntexample2action.h --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/inc/cntexample2action.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* -* Copyright (c) 2010 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 QMOBEXAMPLE2ACTION_H -#define QMOBEXAMPLE2ACTION_H - -#include "cntexamplebaseaction.h" - -class MobExample2Action : public MobBaseAction -{ - Q_OBJECT - -public: - MobExample2Action(const QString& actionName, const QString& vendorName); - ~MobExample2Action(); - - QVariantMap metaData() const; - QContactFilter contactFilter(const QVariant& value) const; - bool isDetailSupported(const QContactDetail &detail, const QContact &contact = QContact()) const; - QList supportedDetails(const QContact& contact) const; - State state() const; - MobExample2Action* clone() const; -}; - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/inc/cntexampleaction.h --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/inc/cntexampleaction.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* -* Copyright (c) 2010 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 QMOBEXAMPLEACTION_H -#define QMOBEXAMPLEACTION_H - -#include "cntexamplebaseaction.h" - -class MobExampleAction : public MobBaseAction -{ - Q_OBJECT - -public: - MobExampleAction(const QString& actionName, const QString& vendorName); - ~MobExampleAction(); - - QVariantMap metaData() const; - QContactFilter contactFilter(const QVariant& value) const; - bool isDetailSupported(const QContactDetail &detail, const QContact &contact = QContact()) const; - QList supportedDetails(const QContact& contact) const; - State state() const; - MobExampleAction* clone() const; -}; - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/inc/cntexampleactionfactory.h --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/inc/cntexampleactionfactory.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* -* Copyright (c) 2010 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 MOBEXAMPLEACTIONFACTORY_H -#define MOBEXAMPLEACTIONFACTORY_H - -#include -#include - -class MobBaseAction; - -QTM_USE_NAMESPACE - -class Q_DECL_EXPORT MobExampleActionFactory : public QContactActionFactory -{ - Q_OBJECT - Q_INTERFACES(QtMobility::QContactActionFactory) - -public: - MobExampleActionFactory(); - ~MobExampleActionFactory(); - - QString name() const; - QList actionDescriptors() const; - QContactAction* instance(const QContactActionDescriptor& descriptor) const; - QVariantMap actionMetadata(const QContactActionDescriptor& descriptor) const; - -private: - QList actionList; -}; - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/inc/cntexamplebaseaction.h --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/inc/cntexamplebaseaction.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* -* Copyright (c) 2010 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 MOBBASEACTION_H -#define MOBBASEACTION_H - -#include -#include - -#include -#include -#include - -QTM_USE_NAMESPACE - -class MobBaseAction : public QContactAction -{ - Q_OBJECT - -public: - MobBaseAction(const QString &actionName, const QString& vendorName); - virtual ~MobBaseAction(); - -public: - enum ErrorCodes { - GeneralError = 1, - DetailNotSupported - }; - - -public: //QContactAction - QContactActionDescriptor actionDescriptor() const; - bool invokeAction(const QContact& contact, const QContactDetail& detail = QContactDetail(), const QVariantMap& parameters = QVariantMap()); - QVariantMap results() const; - -public: - virtual void resetAction(); - virtual MobBaseAction* clone() const = 0; - -public: - //returns whether the actionDescription is supported by this action - bool actionDescriptionSupported(const QContactActionDescriptor& descriptor) const; - void emitResult(int errorCode, const QVariant &retValue); - - -protected: - QString m_actionName; - QString m_vendorName; - int m_implementationVersion; - - QVariantMap m_result; //result returned to client - QContact m_contact; //contact passed to invokeAction - QContactDetail m_detail; //detail passed to invokeAction -}; - -#endif //MOBBASEACTION_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/inc/cntexampledynamicaction.h --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/inc/cntexampledynamicaction.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* -* Copyright (c) 2010 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 QMOBEXAMPLEDYNAMICACTION_H -#define QMOBEXAMPLEDYNAMICACTION_H - -#include "cntexamplebaseaction.h" - -#include - -class MobExampleDynamicAction : public MobBaseAction -{ - Q_OBJECT - -public: - MobExampleDynamicAction(const QString& actionName, const QString& vendorName); - MobExampleDynamicAction(const QString& actionName, const QString& vendorName, const MobExampleDynamicAction& copy); - ~MobExampleDynamicAction(); - - QVariantMap metaData() const; - QContactFilter contactFilter(const QVariant& value) const; - bool isDetailSupported(const QContactDetail &detail, const QContact &contact = QContact()) const; - QList supportedDetails(const QContact& contact) const; - State state() const; - MobExampleDynamicAction* clone() const; - - void setDefinitionName(const QString& definitionName); - void setFilter(QContactFilter filter); - void setIcon(QIcon icon); - void setTitleField(QString titleField); - void setValueField(QString valueField); - void setTitleFieldDetail(QString titleField); - void setValueFieldDetail(QString valueField); - -private: - QString mTitleField; - QString mValueField; - QString mTitleFieldDetail; - QString mValueFieldDetail; - QIcon mIcon; - QContactFilter mFilter; - QString mDefinitionName; -}; - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/inc/cntexamplenodetailaction.h --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/inc/cntexamplenodetailaction.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* -* Copyright (c) 2010 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 MOBEXAMPLENODETAILACTION_H_ -#define MOBEXAMPLENODETAILACTION_H_ - -#include "cntexamplebaseaction.h" - -class MobExampleNoDetailAction : public MobBaseAction -{ - Q_OBJECT - -public: - MobExampleNoDetailAction(const QString& actionName, const QString& vendorName); - ~MobExampleNoDetailAction(); - - QVariantMap metaData() const; - QContactFilter contactFilter(const QVariant& value) const; - bool isDetailSupported(const QContactDetail &detail, const QContact &contact = QContact()) const; - QList supportedDetails(const QContact& contact) const; - State state() const; - MobExampleNoDetailAction* clone() const; -}; - -#endif /* MOBEXAMPLENODETAILACTION_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/plugin_commonu.def --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/plugin_commonu.def Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -; ============================================================================== -; Generated by qmake (2.01a) (Qt 4.7.0) on: 2010-09-11T15:41:44 -; This file is generated by qmake and should not be modified by the -; user. -; Name : plugin_commonu.def -; Part of : cntexampleactionsplugin -; Description : Fixes common plugin symbols to known ordinals -; Version : -; -; ============================================================================== - - -EXPORTS - qt_plugin_query_verification_data @ 1 NONAME - qt_plugin_instance @ 2 NONAME - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/src/cntexample2action.cpp --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/src/cntexample2action.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* -* Copyright (c) 2010 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 "cntexample2action.h" -#include -#include -#include -#include -#include - -//Action class -MobExample2Action::MobExample2Action(const QString& actionName, const QString& vendorName) : - MobBaseAction(actionName, vendorName) -{ -} - -MobExample2Action::~MobExample2Action() -{ -} - -QVariantMap MobExample2Action::metaData() const -{ - QVariantMap variantMap; - QVariant localization("Test action 2"); - variantMap.insert(KCntUiActionMetaTitleText, localization); - const QString& string(QContactPhoneNumber::FieldNumber); - QVariant detailField(string); - variantMap.insert(KCntUiActionMetaValueTextDetail, detailField); - QString menuString("Do example action2"); - QVariant longPressMenu(menuString); - variantMap.insert(KCntUiActionMetaValueTextLongPress, longPressMenu); - return variantMap; -} - -QContactFilter MobExample2Action::contactFilter(const QVariant& value) const -{ - Q_UNUSED(value); - - QContactDetailFilter mobileFilter; - mobileFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName, QContactPhoneNumber::FieldSubTypes); - mobileFilter.setValue(QLatin1String(QContactPhoneNumber::SubTypeMobile)); - - return mobileFilter; -} - -bool MobExample2Action::isDetailSupported(const QContactDetail &detail, const QContact &contact) const -{ - if(QContactPhoneNumber::DefinitionName == detail.definitionName()) - { - return true; - } - else - { - return false; - } -} - -QList MobExample2Action::supportedDetails(const QContact& contact) const -{ - -} - -QContactAction::State MobExample2Action::state() const -{ - -} - -MobExample2Action* MobExample2Action::clone() const -{ - return new MobExample2Action(m_actionName, m_vendorName); -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/src/cntexampleaction.cpp --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/src/cntexampleaction.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* -* Copyright (c) 2010 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 "cntexampleaction.h" -#include -#include -#include -#include -#include -#include -#include - -//Action class -MobExampleAction::MobExampleAction(const QString& actionName, const QString& vendorName) : - MobBaseAction(actionName, vendorName) -{ -} - -MobExampleAction::~MobExampleAction() -{ -} - -QVariantMap MobExampleAction::metaData() const -{ - QVariantMap variantMap; - const QString& string("Test action 1"); - QVariant localization(string); - variantMap.insert(KCntUiActionMetaTitleText, localization); - const QString& string2(QContactOnlineAccount::FieldAccountUri); - const QVariant detailField(string2); - variantMap.insert(KCntUiActionMetaValueTextDetail, detailField); - QString menuString("Do example action"); - QVariant longPressMenu(menuString); - variantMap.insert(KCntUiActionMetaValueTextLongPress, longPressMenu); - HbIcon hIcon("qtg_large_voip.svg"); - // Must be QIcon - QIcon icon(hIcon.qicon()); - QVariant iconVariant(icon); - variantMap.insert("icon", iconVariant); - return variantMap; -} - -QContactFilter MobExampleAction::contactFilter(const QVariant& value) const -{ - Q_UNUSED(value); - - QContactDetailFilter onlineFilter; - onlineFilter.setDetailDefinitionName(QContactOnlineAccount::DefinitionName, QContactOnlineAccount::FieldSubTypes); - onlineFilter.setValue(QLatin1String(QContactOnlineAccount::SubTypeImpp)); - - return onlineFilter; -} - -bool MobExampleAction::isDetailSupported(const QContactDetail &detail, const QContact &contact) const -{ - if(QContactOnlineAccount::DefinitionName == detail.definitionName()) - { - return true; - } - else - { - return false; - } -} - -QList MobExampleAction::supportedDetails(const QContact& contact) const -{ - -} - -QContactAction::State MobExampleAction::state() const -{ - -} - -MobExampleAction* MobExampleAction::clone() const -{ - return new MobExampleAction(m_actionName, m_vendorName); -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/src/cntexampleactionfactory.cpp --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/src/cntexampleactionfactory.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* -* Copyright (c) 2010 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 ACTIONFACTORYPLUGINTARGET -#define ACTIONFACTORYPLUGINTARGET cntexampleactionsplugin -#endif -#ifndef ACTIONFACTORYPLUGINNAME -#define ACTIONFACTORYPLUGINNAME SymbianActionFactory -#endif - -#include "cntexampleactionfactory.h" -#include "cntexampleaction.h" -#include "cntexample2action.h" -#include "cntexamplenodetailaction.h" -#include "cntexampledynamicaction.h" - -#include -#include - -#define makestr(x) (#x) -#define makename(x) makestr(x) - - -//Factory class -MobExampleActionFactory::MobExampleActionFactory() -{ - // Next two actions are different, but for same service. These actions can be used - // also for other services, by changing "Test service". In real plugin all these actions - // would have been created once for each service. In this example third action is created for - // different service for testing purposes. - actionList.append(new MobExampleAction("staticaction1", "Test service")); - actionList.append(new MobExample2Action("staticaction2", "Test service")); - // This action is for second service. - actionList.append(new MobExampleNoDetailAction("nodetailaction", "Test service 2")); - - // create several variants of one action and change it behaviour in run time - MobExampleDynamicAction* nonUiItem = new MobExampleDynamicAction("dynamicaction", "Test service 2"); - nonUiItem->setDefinitionName(QContactOnlineAccount::DefinitionName); - QContactDetailFilter filter; - filter.setDetailDefinitionName(QContactOnlineAccount::DefinitionName); - nonUiItem->setFilter(filter); - nonUiItem->setIcon(QIcon()); - nonUiItem->setTitleField(""); - nonUiItem->setTitleFieldDetail(""); - actionList.append(nonUiItem); - - MobExampleDynamicAction* emptyValueField = new MobExampleDynamicAction("dynamicaction2", "Test service 2"); - emptyValueField->setDefinitionName(QContactOnlineAccount::DefinitionName); - QContactDetailFilter filter2; - filter2.setDetailDefinitionName(QContactOnlineAccount::DefinitionName); - emptyValueField->setFilter(filter2); - emptyValueField->setIcon(QIcon()); - emptyValueField->setTitleFieldDetail(QContactOnlineAccount::FieldServiceProvider); - emptyValueField->setValueField(""); - actionList.append(emptyValueField); -} - -MobExampleActionFactory::~MobExampleActionFactory() -{ - while (!actionList.isEmpty()) - delete actionList.takeFirst(); -} - -QString MobExampleActionFactory::name() const -{ - return QString(makename(ACTIONFACTORYPLUGINNAME)); -} - - -QList MobExampleActionFactory::actionDescriptors() const -{ - QList descriptorList; - - //loop through all the actions and add the descriptor to the list - for (int i = 0; i < actionList.size(); i++) - { - descriptorList << actionList.at(i)->actionDescriptor(); - } - - return descriptorList; -} - -QContactAction* MobExampleActionFactory::instance(const QContactActionDescriptor& descriptor) const -{ - QContactAction *action(0); - - //loop through the actions and return the one that supports the descriptor - for (int i = 0; i < actionList.size() && action == 0; i++) - { - if (actionList.at(i)->actionDescriptionSupported(descriptor)){ - //create a new heap object of the action - action = actionList.at(i)->clone(); - } - } - - return action; -} - -QVariantMap MobExampleActionFactory::actionMetadata(const QContactActionDescriptor& descriptor) const -{ - QVariantMap map; - - //loop through the actions and return the one that supports the descriptor - for (int i = 0; i < actionList.size() && map.isEmpty(); i++) - { - if (actionList.at(i)->actionDescriptionSupported(descriptor)) - { - map = actionList.at(i)->metaData(); - } - } - - return map; - -} - -Q_EXPORT_PLUGIN2(ACTIONFACTORYPLUGINTARGET, MobExampleActionFactory); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/src/cntexamplebaseaction.cpp --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/src/cntexamplebaseaction.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/* -* Copyright (c) 2010 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 "cntexamplebaseaction.h" - -#include -#include -#include -#include -#include - -MobBaseAction::MobBaseAction(const QString &actionName, const QString& vendorName) : - m_actionName(actionName), - m_vendorName(vendorName), - m_implementationVersion(1), - m_result(), - m_contact(), - m_detail() -{ -} - -MobBaseAction::~MobBaseAction() -{ -} - -QContactActionDescriptor MobBaseAction::actionDescriptor() const -{ - QContactActionDescriptor ret; - ret.setActionName(m_actionName); - ret.setVendorName(m_vendorName); - ret.setImplementationVersion(m_implementationVersion); - return ret; -} - -bool MobBaseAction::invokeAction(const QContact& contact, const QContactDetail& detail, const QVariantMap& parameters) -{ - m_contact = contact; - m_detail = detail; -} - -//Clears the action data, is called after the result has been emitted to contact (emitResult function) -void MobBaseAction::resetAction() -{ - m_contact = QContact(); - m_detail = QContactDetail(); -} - -//returns whether the actionDescription is supported by this action -bool MobBaseAction::actionDescriptionSupported(const QContactActionDescriptor& descriptor) const -{ - bool supported(false); - - if ((descriptor.actionName() == m_actionName) && (descriptor.vendorName() == m_vendorName) && (descriptor.implementationVersion() == m_implementationVersion)) - supported = true; - else - supported = false; - - return supported; -} - -//emit the result to the client -void MobBaseAction::emitResult(int errorCode, const QVariant &retValue) -{ -// m_result.clear(); -// m_result.insert("Error", QVariant(errorCode)); -// m_result.insert("ReturnValue", retValue); -// -// QContactAction::Status status; -// -// if (errorCode == 0){ -// status = QContactAction::Finished; -// } -// -// else{ -// status = QContactAction::FinishedWithError; -// } -// -// emit progress(status, m_result); - - resetAction(); //reset values in the action -} - -QVariantMap MobBaseAction::results() const -{ - return m_result; -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/src/cntexampledynamicaction.cpp --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/src/cntexampledynamicaction.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* -* Copyright (c) 2010 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 "cntexampledynamicaction.h" -#include -#include -#include -#include -#include - -//Action class -MobExampleDynamicAction::MobExampleDynamicAction(const QString& actionName, const QString& vendorName) : - MobBaseAction(actionName, vendorName) -{ -} - -MobExampleDynamicAction::MobExampleDynamicAction(const QString& actionName, const QString& vendorName, const MobExampleDynamicAction& copy) : - MobBaseAction(actionName, vendorName) -{ - mTitleField = copy.mTitleField; - mValueField = copy.mValueField; - mTitleFieldDetail = copy.mTitleFieldDetail; - mValueFieldDetail = copy.mValueFieldDetail; - mIcon = copy.mIcon; - mFilter = copy.mFilter; - mDefinitionName = copy.mDefinitionName; -} - -MobExampleDynamicAction::~MobExampleDynamicAction() -{ -} - -QVariantMap MobExampleDynamicAction::metaData() const -{ - QVariantMap variantMap; - - variantMap.insert(KCntUiActionMetaTitleTextDetail, !mTitleField.isEmpty() ? mTitleField : mTitleFieldDetail); - - if(!mValueFieldDetail.isEmpty()) - variantMap.insert(KCntUiActionMetaValueTextDetail, mValueFieldDetail); - else if(!mValueField.isEmpty()) - variantMap.insert(KCntUiActionMetaValueText, mValueField); - // Must be QIcon - QIcon icon(mIcon); - QVariant iconVariant(icon); - variantMap.insert("icon", iconVariant); - return variantMap; -} - -QContactFilter MobExampleDynamicAction::contactFilter(const QVariant& value) const -{ - return mFilter; -} - -bool MobExampleDynamicAction::isDetailSupported(const QContactDetail &detail, const QContact &contact) const -{ - if(mDefinitionName == detail.definitionName()) - { - return true; - } - else - { - return false; - } -} - -QList MobExampleDynamicAction::supportedDetails(const QContact& contact) const -{ - -} - -QContactAction::State MobExampleDynamicAction::state() const -{ - -} - -MobExampleDynamicAction* MobExampleDynamicAction::clone() const -{ - return new MobExampleDynamicAction(m_actionName, m_vendorName, *this); -} - -void MobExampleDynamicAction::setDefinitionName(const QString& definitionName) -{ - mDefinitionName = definitionName; -} - -void MobExampleDynamicAction::setFilter(QContactFilter filter) -{ - mFilter = filter; -} - -void MobExampleDynamicAction::setIcon(QIcon icon) -{ - mIcon = icon; -} - -void MobExampleDynamicAction::setTitleField(QString titleField) -{ - mTitleField = titleField; -} - -void MobExampleDynamicAction::setValueField(QString valueField) -{ - mValueField = valueField; -} - -void MobExampleDynamicAction::setTitleFieldDetail(QString titleFieldDetail) -{ - mTitleFieldDetail = titleFieldDetail; -} - -void MobExampleDynamicAction::setValueFieldDetail(QString valueFieldDetail) -{ - mValueFieldDetail = valueFieldDetail; -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/src/cntexamplenodetailaction.cpp --- a/phonebookui/cntcommonui/tsrc/ut_pbkcontactcard/cntactionextensionexample/src/cntexamplenodetailaction.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* -* Copyright (c) 2010 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 "cntexamplenodetailaction.h" -#include - -//Action class -MobExampleNoDetailAction::MobExampleNoDetailAction(const QString& actionName, const QString& vendorName) : - MobBaseAction(actionName, vendorName) -{ -} - -MobExampleNoDetailAction::~MobExampleNoDetailAction() -{ -} - -QVariantMap MobExampleNoDetailAction::metaData() const -{ - QVariantMap variantMap; - QVariant localization("Test action 3"); - variantMap.insert(KCntUiActionMetaTitleText, localization); - QVariant detailField("Description"); - variantMap.insert(KCntUiActionMetaValueText, detailField); - QString menuString("Do action 3"); - QVariant longPressMenu(menuString); - variantMap.insert(KCntUiActionMetaValueTextLongPress, longPressMenu); - return variantMap; -} - -QContactFilter MobExampleNoDetailAction::contactFilter(const QVariant& value) const -{ - Q_UNUSED(value); - - QContactFilter all; - - return all; -} - -// If detail is empty plugin knows that this is special action query that -// is targetted to whole contact not to specific detail on contact. -// If you want to create action to my card only, check cntuiactionextension.h for details -bool MobExampleNoDetailAction::isDetailSupported(const QContactDetail &detail, const QContact &contact) const -{ - if(detail.isEmpty()) - { - return true; - } - else - { - return false; - } -} - -QList MobExampleNoDetailAction::supportedDetails(const QContact& contact) const -{ - -} - -QContactAction::State MobExampleNoDetailAction::state() const -{ - -} - -MobExampleNoDetailAction* MobExampleNoDetailAction::clone() const -{ - return new MobExampleNoDetailAction(m_actionName, m_vendorName); -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntactionmenubuilder.cpp --- a/phonebookui/cntcommonui/views/cntactionmenubuilder.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntactionmenubuilder.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -14,80 +14,79 @@ * Description: * */ + #include "cntactionmenubuilder.h" -#include + #include "cntstringmapper.h" +#include "cntactionpopup.h" + #include -#include "cntactionpopup.h" CntActionMenuBuilder::CntActionMenuBuilder( QContactLocalId aMyCardId ) : -QObject(), -iMyCardId( aMyCardId ), -mContact( 0 ), -mMap( 0 ) - { + QObject(), + iMyCardId( aMyCardId ), + mContact( NULL ), + mMap( NULL ) +{ mMap = new CntStringMapper(); - } +} CntActionMenuBuilder::~CntActionMenuBuilder() { delete mMap; - mMap = 0; - delete mContact; - mContact = 0; +} + +HbMenu* CntActionMenuBuilder::actionMenu( QContact& aContact, QContactLocalId myCardId ) +{ + iMyCardId = myCardId; + mContact = new QContact( aContact ); + return buildActionMenu( aContact ); } HbMenu* CntActionMenuBuilder::buildActionMenu( QContact& aContact ) { HbMenu* menu = new HbMenu(); - + // Regular contact, NOT MyCard if ( aContact.localId() != iMyCardId ) - { + { QList actionDescriptors = aContact.availableActions(); QStringList actions; foreach ( QContactActionDescriptor d, aContact.availableActions() ) - { + { actions << d.actionName(); - } - + } + if ( actions.contains("call", Qt::CaseInsensitive) && isSupportedDetails("call", aContact)) - { + { createCallAction( *menu, aContact ); - } - + } + if ( actions.contains("message", Qt::CaseInsensitive) && isSupportedDetails("message", aContact) ) - { + { createMessageAction( *menu, aContact ); - } - + } + if ( actions.contains("email", Qt::CaseInsensitive) ) - { + { createEmailAction( *menu, aContact ); - } - + } + if ( menu->actions().size() > 0 ) menu->addSeparator(); - } - + } + // If contact is NOT MyCard OR MyCard is not empty (detail count is more than 4) if ( aContact.localId() != iMyCardId || aContact.details().size() > 4 ) - { - menu->addAction(hbTrId("txt_common_menu_open"), this, SLOT(emitOpenContact()) ); - menu->addAction(hbTrId("txt_common_menu_edit"), this, SLOT(emitEditContact()) ); - menu->addAction(hbTrId("txt_phob_menu_delete_contact"), this, SLOT(emitDeleteContact())); - } + { + menu->addAction( hbTrId("txt_common_menu_open"), this, SLOT(emitOpenContact()) ); + menu->addAction( hbTrId("txt_common_menu_edit"), this, SLOT(emitEditContact()) ); + menu->addAction( hbTrId("txt_phob_menu_delete_contact"), this, SLOT(emitDeleteContact())); + } return menu; } -HbMenu* CntActionMenuBuilder::actionMenu( QContact& aContact, QContactLocalId myCardId) -{ - iMyCardId = myCardId; - mContact = new QContact( aContact ); - return buildActionMenu( aContact ); -} - void CntActionMenuBuilder::emitOpenContact() { emit openContact( *mContact ); @@ -107,21 +106,21 @@ { QContactDetail detail = mContact->preferredDetail("call"); if (!detail.isEmpty()) - { + { emit performContactAction( *mContact, detail, "call" ); - } + } else if (mContact->details().count() == 1 ) { mContact->setPreferredDetail("call", mContact->details().first()); emit performContactAction(*mContact, mContact->details().first(), "call"); } else - { + { CntActionPopup *actionPopup = new CntActionPopup(mContact); actionPopup->showActionPopup("call"); connect( actionPopup, SIGNAL(executeContactAction(QContact&, QContactDetail, QString)), this, - SLOT(emitContactaction(QContact&,QContactDetail, QString))); - } + SLOT(emitContactAction(QContact&,QContactDetail, QString))); + } } void CntActionMenuBuilder::emitSmsContact() @@ -141,7 +140,7 @@ CntActionPopup *actionPopup = new CntActionPopup(mContact); actionPopup->showActionPopup("message"); connect( actionPopup, SIGNAL(executeContactAction(QContact&, QContactDetail, QString)), this, - SLOT(emitContactaction(QContact&,QContactDetail, QString))); + SLOT(emitContactAction(QContact&,QContactDetail, QString))); } } @@ -149,24 +148,24 @@ { QContactDetail detail = mContact->preferredDetail("email"); if (!detail.isEmpty()) - { + { emit performContactAction( *mContact,detail, "email" ); - } + } else if (mContact->details().count() == 1 ) { mContact->setPreferredDetail("email", mContact->details().first()); emit performContactAction(*mContact, mContact->details().first(), "email"); } else - { + { CntActionPopup *actionPopup = new CntActionPopup(mContact); actionPopup->showActionPopup("email"); connect( actionPopup, SIGNAL(executeContactAction(QContact&, QContactDetail, QString)), this, - SLOT(emitContactaction(QContact&,QContactDetail, QString))); - } + SLOT(emitContactAction(QContact&,QContactDetail, QString))); + } } -void CntActionMenuBuilder::emitContactaction(QContact& aContact,QContactDetail contactDetail, QString aAction) +void CntActionMenuBuilder::emitContactAction(QContact& aContact,QContactDetail contactDetail, QString aAction) { emit performContactAction( aContact,contactDetail, aAction); } @@ -175,11 +174,27 @@ { // Create call action QContactDetail detail = aContact.preferredDetail("call"); - QContactPhoneNumber number = detail.isEmpty() ? aContact.detail() : detail; - QString context = number.contexts().isEmpty() ? QString() : number.contexts().first(); - QString subtype = number.subTypes().isEmpty() ? number.definitionName() : number.subTypes().first(); + + // if preferredDetail is empty and phone munbers contain more then one, use "txt_phob_menu_voice_call" + if (detail.isEmpty() && aContact.details().count() > 1) + { + aMenu.addAction(hbTrId("txt_phob_menu_voice_call"), this, SLOT(emitCallContact())); + } + else + { + QContactPhoneNumber number = detail.isEmpty() ? aContact.detail() : detail; + QString context = number.contexts().isEmpty() ? QString() : number.contexts().first(); + QString subtype = number.subTypes().isEmpty() ? number.definitionName() : number.subTypes().first(); + + aMenu.addAction( mMap->getItemSpecificMenuLocString( subtype, context ), this, SLOT(emitCallContact()) ); + } +} - aMenu.addAction( mMap->getItemSpecificMenuLocString( subtype, context ), this, SLOT(emitCallContact()) ); +void CntActionMenuBuilder::createMessageAction( HbMenu& aMenu, QContact& aContact ) +{ + Q_UNUSED( aContact ); + + aMenu.addAction(hbTrId("txt_phob_menu_send_message"), this, SLOT(emitSmsContact())); } void CntActionMenuBuilder::createEmailAction( HbMenu& aMenu, QContact& aContact ) @@ -192,34 +207,27 @@ aMenu.addAction( mMap->getItemSpecificMenuLocString( email.definitionName(), context), this, SLOT(emitMailContact()) ); } -void CntActionMenuBuilder::createMessageAction( HbMenu& aMenu, QContact& aContact ) -{ - Q_UNUSED( aContact ); - - aMenu.addAction(hbTrId("txt_phob_menu_send_message"), this, SLOT(emitSmsContact())); -} - bool CntActionMenuBuilder::isSupportedDetails( const QString &actionName, const QContact &contact ) { QList actionDescriptors = QContactAction::actionDescriptors(actionName, "symbian"); if (actionDescriptors.isEmpty()) - { + { return false; - } - + } + QContactAction* contactAction = QContactAction::action(actionDescriptors.first()); QList details = contactAction->supportedDetails(contact); delete contactAction; - + for (int i = 0; i < details.count(); i++) - { + { if (contact.details().contains(details[i])) - { + { return true; - } } - + } + return false; } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntactionmenubuilder.h --- a/phonebookui/cntcommonui/views/cntactionmenubuilder.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntactionmenubuilder.h Fri Oct 15 12:24:46 2010 +0300 @@ -15,8 +15,8 @@ * */ -#ifndef CNTACTIONMENUBUILDER_H_ -#define CNTACTIONMENUBUILDER_H_ +#ifndef CNTACTIONMENUBUILDER_H +#define CNTACTIONMENUBUILDER_H #include #include @@ -24,6 +24,7 @@ #include class CntStringMapper; + QTM_BEGIN_NAMESPACE class QContact; class QContactDetail; @@ -32,16 +33,16 @@ QTM_USE_NAMESPACE class CntActionMenuBuilder : public QObject - { +{ Q_OBJECT + friend class TestCntActionMenuBuilder; + public: CntActionMenuBuilder( QContactLocalId aMyCardId ); ~CntActionMenuBuilder(); public: HbMenu* actionMenu( QContact& aContact, QContactLocalId myCardId ); - -public: HbMenu* buildActionMenu( QContact& aContact ); signals: @@ -57,22 +58,18 @@ void emitCallContact(); void emitSmsContact(); void emitMailContact(); - void emitContactaction(QContact& aContact, QContactDetail contactDetail, QString aAction); + void emitContactAction(QContact& aContact, QContactDetail contactDetail, QString aAction); -#ifdef PBK_UNIT_TEST -public: -#else -private: -#endif - +private: void createCallAction( HbMenu& aMenu, QContact& aContact ); void createMessageAction( HbMenu& aMenu, QContact& aContact ); void createEmailAction( HbMenu& aMenu, QContact& aContact ); bool isSupportedDetails( const QString &actionName, const QContact &contact ); private: - QContactLocalId iMyCardId; - QContact* mContact; - CntStringMapper* mMap; - }; -#endif /* CNTACTIONMENUBUILDER_H_ */ + QContactLocalId iMyCardId; + QContact *mContact; + CntStringMapper *mMap; +}; + +#endif /* CNTACTIONMENUBUILDER_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntbaseselectionview.cpp --- a/phonebookui/cntcommonui/views/cntbaseselectionview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntbaseselectionview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -29,8 +29,8 @@ const char *CNT_SELECTION_LISTVIEW_UI_XML = ":/xml/contacts_list.docml"; CntBaseSelectionView::CntBaseSelectionView() : -QObject(), -mDocument(NULL) + QObject(), + mDocument(NULL) { mDocument = new HbDocumentLoader(); @@ -80,7 +80,8 @@ mListView->setModel( mListModel ); - if ( aArgs.contains(ESelectionMode) ) { + if ( aArgs.contains(ESelectionMode) ) + { mListView->setSelectionMode( static_cast(aArgs.value(ESelectionMode).toInt()) ); } @@ -89,16 +90,8 @@ void CntBaseSelectionView::deactivate() { -} - -bool CntBaseSelectionView::isDefault() const -{ - return false; + } -HbView* CntBaseSelectionView::view() const -{ - return mView; -} // EOF diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntbaseselectionview.h --- a/phonebookui/cntcommonui/views/cntbaseselectionview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntbaseselectionview.h Fri Oct 15 12:24:46 2010 +0300 @@ -28,10 +28,10 @@ class HbAction; class CntListModel; - class QTPBK_EXPORT CntBaseSelectionView : public QObject, public CntAbstractView { Q_OBJECT + friend class TestCntBaseSelectionView; public: CntBaseSelectionView(); @@ -44,20 +44,20 @@ public: void activate( const CntViewParameters aArgs ); void deactivate(); - bool isDefault() const; - HbView* view() const; + bool isDefault() const { return false; } + HbView* view() const { return mView; } void setEngine( CntAbstractEngine& aEngine ){ mEngine = &aEngine; } virtual int viewId() const = 0; protected: - HbDocumentLoader* mDocument; - HbListView* mListView; - HbView* mView; - HbAction* mSoftkey; - CntAbstractViewManager* mMgr; - CntListModel* mListModel; - CntAbstractEngine* mEngine; + HbDocumentLoader *mDocument; + HbListView *mListView; + HbView *mView; + HbAction *mSoftkey; + CntAbstractViewManager *mMgr; + CntListModel *mListModel; + CntAbstractEngine *mEngine; }; #endif /* CNTBASESELECTIONVIEW_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cnthistoryview.cpp --- a/phonebookui/cntcommonui/views/cnthistoryview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cnthistoryview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -17,6 +17,10 @@ #include "cnthistoryview.h" +#include "cnthistoryviewitem.h" +#include "cntglobal.h" +#include "cntdebug.h" + #include #include #include @@ -24,19 +28,14 @@ #include #include #include -#include -#include -#include #include #include #include #include +#include +#include +#include #include -#include - -#include "cnthistoryviewitem.h" -#include "cntglobal.h" -#include "cntdebug.h" const char *CNT_HISTORYVIEW_XML = ":/xml/contacts_history.docml"; @@ -81,31 +80,10 @@ { mView->deleteLater(); - if (mDocumentLoader) { - delete mDocumentLoader; - mDocumentLoader = NULL; - } - if (mHistoryModel) { - delete mHistoryModel; - mHistoryModel = NULL; - } - if (mContact) { - delete mContact; - mContact = NULL; - } - + delete mDocumentLoader; + delete mHistoryModel; + delete mContact; delete mRequest; - mRequest = NULL; -} - -/*! - * Deactivate the view - */ -void CntHistoryView::deactivate() -{ - QContactManager* cm = &mEngine->contactManager(SYMBIAN_BACKEND); - disconnect(cm, SIGNAL(contactsRemoved(const QList&)), - this, SLOT(contactDeletedFromOtherSource(const QList&))); } /** @@ -126,24 +104,20 @@ { name = hbTrId("txt_phob_list_unnamed"); } - groupBox->setHeading(hbTrId("txt_phob_subtitle_history_with_1").arg(name)); + groupBox->setHeading(HbParameterLengthLimiter("txt_phob_subtitle_history_with_1").arg(name)); //construct listview mHistoryListView = static_cast(docLoader()->findWidget(QString("listView"))); - mHistoryListView->setLayoutName("history"); CntHistoryViewItem *item = new CntHistoryViewItem; - item->setSecondaryTextRowCount(1, 3); - item->setGraphicsSize(HbListViewItem::SmallIcon); mHistoryListView->setItemPrototype(item); //ownership is taken // Connect listview items to respective slots connect(mHistoryListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(itemActivated(const QModelIndex &))); - connect( mHistoryListView, SIGNAL(longPressed(HbAbstractViewItem*,const QPointF&)), - this, SLOT(onLongPressed(HbAbstractViewItem*,const QPointF&)) ); - - + // To make LongPress act like shortpress. After this only activated signal comes + mHistoryListView->setLongPressEnabled(false); + mHistoryModel = new CntHistoryModel(mContact->localId(), cm); mHistoryListView->setModel(mHistoryModel); //ownership is not taken @@ -174,6 +148,16 @@ } /*! + * Deactivate the view + */ +void CntHistoryView::deactivate() +{ + QContactManager* cm = &mEngine->contactManager(SYMBIAN_BACKEND); + disconnect(cm, SIGNAL(contactsRemoved(const QList&)), + this, SLOT(contactDeletedFromOtherSource(const QList&))); +} + +/*! Called after new items are added to or removed from comm history view */ void CntHistoryView::updateScrollingPosition() @@ -197,7 +181,7 @@ name = hbTrId("txt_phob_list_unnamed"); } - HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_clear_communications_history_with_1")).arg(name), this, + HbMessageBox::question(HbParameterLengthLimiter("txt_phob_info_clear_communications_history_with_1").arg(name), this, SLOT(handleClearHistory(int)), HbMessageBox::Delete | HbMessageBox::Cancel); } @@ -212,16 +196,6 @@ } } -void CntHistoryView::onLongPressed(HbAbstractViewItem *item, const QPointF &coords) -{ - Q_UNUSED(coords); - QModelIndex index = item->modelIndex(); - if (index.isValid()) - { - itemActivated(index); - } -} - /*! Once list item is pressed on the list view this slot handles the emitted signal @@ -237,11 +211,13 @@ QVariantList args; // If the list item is a call log a call is made to that item - if ( flags & CntCallLog ) { + if ( flags & CntCallLog ) + { // Make a call QVariant number = index.data(CntPhoneNumberRole); - if ( number.isValid() ) { + if ( number.isValid() ) + { interface = "com.nokia.symbian.ICallDial"; operation = "dial(QString)"; args << number; @@ -257,11 +233,14 @@ snd.send(); } - } else if ( flags & CntMessage ) { + } + else if ( flags & CntMessage ) + { // Open conversation view QVariant id = index.data(CntConverstaionIdRole); - if ( id.isValid() ) { + if ( id.isValid() ) + { interface = "com.nokia.symbian.IMessageView"; operation = "view(int)"; args << id; @@ -269,14 +248,16 @@ } } - if ( createRequest ) { + if ( createRequest ) + { XQApplicationManager appMng; delete mRequest; mRequest = NULL; mRequest = appMng.create(interface, operation, true); // embedded - if ( mRequest ) { + if ( mRequest ) + { mRequest->setArguments(args); mRequest->send(); } @@ -302,39 +283,48 @@ mViewMgr->back( mArgs, true ); } +/*! +Show or hide the clear history menu +*/ +void CntHistoryView::showClearHistoryMenu() +{ + if (mHistoryModel->rowCount() > 0) + { + mClearHistory->setEnabled(true); + } + else + { + mClearHistory->setEnabled(false); + } +} +/*! +Handle the situation where this contact is deleted from another source +*/ void CntHistoryView::contactDeletedFromOtherSource(const QList& contactIds) { CNT_ENTRY + if ( contactIds.contains(mContact->localId()) ) { // Do not switch to the previous view immediately. List views are // not updated properly if this is not done in the event loop QTimer::singleShot(0, this, SLOT(showRootView())); } + CNT_EXIT } /*! -Show or hide the clear history menu +Document loader */ -void CntHistoryView::showClearHistoryMenu() -{ - if (mHistoryModel->rowCount() > 0) { - mClearHistory->setEnabled(true); - } else { - mClearHistory->setEnabled(false); - } -} - -/*! - * Document loader - */ HbDocumentLoader* CntHistoryView::docLoader() { - if (!mDocumentLoader) { + if (!mDocumentLoader) + { mDocumentLoader = new HbDocumentLoader(); } + return mDocumentLoader; } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cnthistoryview.h --- a/phonebookui/cntcommonui/views/cnthistoryview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cnthistoryview.h Fri Oct 15 12:24:46 2010 +0300 @@ -20,16 +20,17 @@ #include #include -#include +#include class HbListView; -class CntHistoryModel; class HbView; -class QModelIndex; class HbAction; class HbDocumentLoader; +class HbAbstractViewItem; class XQAiwRequest; -class HbAbstractViewItem; +class QModelIndex; +class CntHistoryModel; + QTM_BEGIN_NAMESPACE class QContact; @@ -40,6 +41,7 @@ class CntHistoryView : public QObject, public CntAbstractView { Q_OBJECT + friend class TestCntHistoryView; public: // From CntAbstractView CntHistoryView(); @@ -57,32 +59,25 @@ void handleClearHistory(int action); void itemActivated(const QModelIndex &index); void showPreviousView(); + void showRootView(); void showClearHistoryMenu(); - void showRootView(); void contactDeletedFromOtherSource(const QList& contactIds); - void onLongPressed (HbAbstractViewItem *item, const QPointF &coords); - - private: HbDocumentLoader* docLoader(); -#ifdef PBK_UNIT_TEST -public: -#else -private: -#endif - HbListView* mHistoryListView; // not own - CntHistoryModel* mHistoryModel; // own - HbView* mView; // not own - HbDocumentLoader* mDocumentLoader; // own - CntAbstractViewManager* mViewMgr; // not own - HbAction* mBackKey; // not own - QContact* mContact; // own - HbAction* mClearHistory; // not own - CntViewParameters mArgs; - XQAiwRequest* mRequest; - CntAbstractEngine* mEngine; +private: + HbListView *mHistoryListView; // not own + CntHistoryModel *mHistoryModel; // own + HbView *mView; // not own + HbDocumentLoader *mDocumentLoader; // own + CntAbstractViewManager *mViewMgr; // not own + HbAction *mBackKey; // not own + QContact *mContact; // own + HbAction *mClearHistory; // not own + CntViewParameters mArgs; + XQAiwRequest *mRequest; + CntAbstractEngine *mEngine; }; #endif // CNTHISTORYVIEW_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cnthistoryviewitem.cpp --- a/phonebookui/cntcommonui/views/cnthistoryviewitem.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cnthistoryviewitem.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -1,136 +1,77 @@ /* - * 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: - * - */ +* 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 "cnthistoryviewitem.h" +#include "cnthistoryviewitemwidget.h" #include "cntdebug.h" -#include -#include -#include -#include - -#define NEW_EVENT_FRAME "qtg_fr_list_new_item" -#define INCOMING_FOCUS_FRAME "qtg_fr_convlist_received_pressed" -#define OUTGOING_FOCUS_FRAME "qtg_fr_convlist_sent_pressed" +#include -//--------------------------------------------------------------- -// HbListViewItem::HbListViewItem -// Constructor -//--------------------------------------------------------------- -CntHistoryViewItem::CntHistoryViewItem(QGraphicsItem* parent) -: HbListViewItem(parent), - mIncoming(false), - mNewMessage(false), - mNewItem(NULL), - mFocusItem(NULL) +/*! +Constructor, initialize member variables. +*/ +CntHistoryViewItem::CntHistoryViewItem(QGraphicsItem* parent) : + HbListViewItem(parent), + mWidget(NULL) { CNT_ENTRY CNT_EXIT } -//--------------------------------------------------------------- -// HbListViewItem::createItem -// Create a new decorator item. -//--------------------------------------------------------------- +/*! +Factory method to the items +*/ HbAbstractViewItem* CntHistoryViewItem::createItem() { return new CntHistoryViewItem(*this); } -//--------------------------------------------------------------- -// HbListViewItem::updateChildItems -// -//--------------------------------------------------------------- +/*! +Update the custom and standard parameters of this item identified by modelindex +*/ void CntHistoryViewItem::updateChildItems() { CNT_ENTRY - int flags = modelIndex().data(CntFlagsRole).toInt(); - mIncoming = flags & CntIncoming ? true : false; - mNewMessage = flags & CntUnseen ? true : false; - - CNT_LOG_ARGS(mIncoming << mNewMessage) - - if (mNewMessage) + if (!mWidget) { - if (!mNewItem) - { - mNewItem = new HbFrameItem(NEW_EVENT_FRAME, HbFrameDrawer::ThreePiecesVertical, this); - style()->setItemName(mNewItem, "newitem"); - } - } - else - { - if (mNewItem) - { - delete mNewItem; - mNewItem = NULL; - } + mWidget = new CntHistoryViewItemWidget(this); + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); + layout->setContentsMargins(0, 0, 0, 0); + layout->addItem(mWidget); + setLayout(layout); } - HbListViewItem::updateChildItems(); - - repolish(); + mWidget->setModelIndex(modelIndex()); CNT_EXIT } -//--------------------------------------------------------------- -// HbAbstractViewItem::pressStateChanged -// This function is called whenever item press state changes. -//--------------------------------------------------------------- +/*! +This function is called whenever item press state changes. +*/ void CntHistoryViewItem::pressStateChanged(bool pressed, bool animate) { CNT_ENTRY Q_UNUSED(animate); - if (pressed) - { - if (!mFocusItem) - { - // focus frame position can't be read from widgetml, we set it manually - QRectF frameRect = HbWidget::primitive("frame")->boundingRect(); - QPointF framePoint = HbWidget::primitive("frame")->pos(); - - frameRect.moveTo(framePoint); - - if (mIncoming) - { - mFocusItem = new HbFrameItem(INCOMING_FOCUS_FRAME, HbFrameDrawer::NinePieces, this); - } - else - { - mFocusItem = new HbFrameItem(OUTGOING_FOCUS_FRAME, HbFrameDrawer::NinePieces, this); - } - - mFocusItem->setGeometry(frameRect); - mFocusItem->setZValue(-1.0); - style()->setItemName(mFocusItem, "focusframe"); - } - } - else - { - if (mFocusItem) - { - delete mFocusItem; - mFocusItem = NULL; - } - } + + mWidget->pressStateChanged(pressed); CNT_EXIT } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cnthistoryviewitem.h --- a/phonebookui/cntcommonui/views/cnthistoryviewitem.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cnthistoryviewitem.h Fri Oct 15 12:24:46 2010 +0300 @@ -1,27 +1,26 @@ /* - * 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:Message chat View decorator item prototype - * - */ +* 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 CNTHISTORYVIEWITEM_H #define CNTHISTORYVIEWITEM_H -// INCLUDES #include -class HbFrameItem; +class CntHistoryViewItemWidget; /** * This class represents the item decorator of @@ -29,43 +28,20 @@ */ class CntHistoryViewItem : public HbListViewItem { + friend class TestCntHistoryView; Q_OBJECT - Q_PROPERTY( bool incoming READ getIncoming ) - Q_PROPERTY( bool newmessage READ isNewMessage ) public: - /* - * Constructor - * @param parent, reference of QGraphicsItem - * default set to 0 - */ - CntHistoryViewItem(QGraphicsItem* parent=0); + CntHistoryViewItem(QGraphicsItem* parent = NULL); - /* - * Factory method to the items - */ HbAbstractViewItem* createItem(); - - /* - * Overriden method to draw the custom item in the list view - */ void updateChildItems(); - bool getIncoming() const { return mIncoming; } - bool isNewMessage() const { return mNewMessage; } - protected: - /* - * Overriden method to overwrite the default "pressed" effect - */ void pressStateChanged(bool pressed, bool animate); private: - bool mIncoming; - bool mNewMessage; - - HbFrameItem* mNewItem; - HbFrameItem* mFocusItem; + CntHistoryViewItemWidget *mWidget; }; -#endif // CNTHISTORYVIEWITEM_H +#endif /* CNTHISTORYVIEWITEM_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cnthistoryviewitemwidget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/views/cnthistoryviewitemwidget.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,251 @@ +/* +* 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 "cnthistoryviewitemwidget.h" +#include "cntdebug.h" + +#include +#include +#include +#include +#include + +#define NEW_EVENT_FRAME "qtg_fr_list_new_item" +#define INCOMING_FOCUS_FRAME "qtg_fr_convlist_received_pressed" +#define OUTGOING_FOCUS_FRAME "qtg_fr_convlist_sent_pressed" + +CntHistoryViewItemWidget::CntHistoryViewItemWidget(QGraphicsItem *parent) : + HbWidget(parent), + mIcon(NULL), + mTitle(NULL), + mBodyText(NULL), + mTimeStamp(NULL), + mFrameItem(NULL), + mFocusItem(NULL), + mNewItem(NULL), + incoming(false), + newmessage(false) +{ + CNT_ENTRY + + setProperty("state", "normal"); + + CNT_EXIT +} + +CntHistoryViewItemWidget::~CntHistoryViewItemWidget() +{ + CNT_ENTRY + + CNT_EXIT +} + +void CntHistoryViewItemWidget::createPrimitives() +{ + CNT_ENTRY + + if (!icon.isNull()) + { + if (!mIcon) + { + mIcon = new HbIconItem(this); + mIcon->setAlignment(Qt::AlignCenter); + mIcon->setIcon(icon); + style()->setItemName(mIcon, "icon-1"); + } + } + else + { + if (mIcon) + { + delete mIcon; + } + mIcon = NULL; + } + + if (!title.isNull()) + { + if (!mTitle) + { + mTitle = new HbTextItem(this); + mTitle->setText(title); + style()->setItemName(mTitle, "text-1"); + } + } + else + { + if (mTitle) + { + delete mTitle; + } + mTitle = NULL; + } + + if (!bodyText.isNull()) + { + if (!mBodyText) + { + mBodyText = new HbTextItem(this); + mBodyText->setText(bodyText); + style()->setItemName(mBodyText, "text-2"); + } + } + else + { + if (mBodyText) + { + delete mBodyText; + } + mBodyText = NULL; + } + + if (!timeStamp.isNull()) + { + if (!mTimeStamp) + { + mTimeStamp = new HbTextItem(this); + mTimeStamp->setText(timeStamp); + style()->setItemName(mTimeStamp, "text-3"); + } + } + else + { + if (mTimeStamp) + { + delete mTimeStamp; + } + mTimeStamp = NULL; + } + + if (!mFrameItem) + { + mFrameItem = new HbFrameItem(this); + mFrameItem->frameDrawer().setFrameGraphicsName(backGround.frameGraphicsName()); + mFrameItem->frameDrawer().setFrameType(backGround.frameType()); + mFrameItem->setZValue(-2); + style()->setItemName(mFrameItem, "frame"); + } + + CNT_EXIT +} + +void CntHistoryViewItemWidget::recreatePrimitives() +{ + CNT_ENTRY + + HbWidget::recreatePrimitives(); + + delete mIcon; + mIcon = NULL; + + delete mTitle; + mTitle = NULL; + + delete mBodyText; + mBodyText = NULL; + + delete mTimeStamp; + mTimeStamp= NULL; + + delete mFrameItem; + mFrameItem = NULL; + + createPrimitives(); + + CNT_EXIT +} + +void CntHistoryViewItemWidget::setModelIndex(const QModelIndex& index) +{ + CNT_ENTRY + + // CntHistoryModel ALWAYS returns 3x QString for Qt::DisplayRole + QStringList texts = index.data(Qt::DisplayRole).toStringList(); + title = texts.at(0); + bodyText = texts.at(1); + timeStamp = texts.at(2); + + icon = index.data(Qt::DecorationRole).value(); + + backGround = index.data(Qt::BackgroundRole).value(); + + int flags = index.data(CntFlagsRole).toInt(); + incoming = flags & CntIncoming ? true : false; + newmessage = flags & CntUnseen ? true : false; + + if (newmessage) + { + if (!mNewItem) + { + mNewItem = new HbFrameItem(NEW_EVENT_FRAME, HbFrameDrawer::ThreePiecesVertical, this); + style()->setItemName(mNewItem, "newitem"); + } + } + else + { + if (mNewItem) + { + delete mNewItem; + mNewItem = NULL; + } + } + + recreatePrimitives(); + repolish(); + + setProperty("state", "normal"); + + CNT_EXIT +} + +void CntHistoryViewItemWidget::pressStateChanged(bool pressed) +{ + CNT_ENTRY + + if (pressed) + { + if (!mFocusItem) + { + if (incoming) + { + mFocusItem = new HbFrameItem(INCOMING_FOCUS_FRAME, HbFrameDrawer::NinePieces, this); + } + else + { + mFocusItem = new HbFrameItem(OUTGOING_FOCUS_FRAME, HbFrameDrawer::NinePieces, this); + } + mFocusItem->setZValue(-1.0); + style()->setItemName(mFocusItem, "focusframe"); + } + + setProperty("state", "pressed"); + } + else + { + if (mFocusItem) + { + delete mFocusItem; + mFocusItem = NULL; + } + + setProperty("state", "normal"); + } + + repolish(); + + CNT_EXIT +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cnthistoryviewitemwidget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/views/cnthistoryviewitemwidget.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,78 @@ +/* +* 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 CNTHISTORYVIEWITEMWIDGET_H +#define CNTHISTORYVIEWITEMWIDGET_H + +#include +#include +#include + +class HbIconItem; +class HbTextItem; +class HbFrameItem; + +class CntHistoryViewItemWidget : public HbWidget +{ + friend class TestCntHistoryView; + + Q_OBJECT + Q_PROPERTY( QString title READ getTitle ) + Q_PROPERTY( QString bodyText READ getBodyText ) + Q_PROPERTY( QString timeStamp READ getTimeStamp ) + Q_PROPERTY( HbIcon icon READ getIcon ) + Q_PROPERTY( bool incoming READ getIncoming ) + Q_PROPERTY( bool newmessage READ isNewMessage ) + +public: + CntHistoryViewItemWidget(QGraphicsItem *parent = 0); + ~CntHistoryViewItemWidget(); + +public: + void createPrimitives(); + void recreatePrimitives(); + + void setModelIndex(const QModelIndex& index); + + void pressStateChanged(bool pressed); + + QString getTitle() const { return title; } + QString getBodyText() const { return bodyText; } + QString getTimeStamp() const { return timeStamp; } + HbIcon getIcon() const { return icon; } + bool getIncoming() const { return incoming; } + bool isNewMessage() const { return newmessage; } + +private: + HbIconItem *mIcon; + HbTextItem *mTitle; + HbTextItem *mBodyText; + HbTextItem *mTimeStamp; + HbFrameItem *mFrameItem; + HbFrameItem *mFocusItem; + HbFrameItem *mNewItem; + + HbFrameBackground backGround; + QString title; + QString bodyText; + QString timeStamp; + HbIcon icon; + bool incoming; + bool newmessage; +}; + +#endif /* CNTHISTORYVIEWITEMWIDGET_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntimageeditorview.cpp --- a/phonebookui/cntcommonui/views/cntimageeditorview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntimageeditorview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -21,10 +21,6 @@ #include "cntsavemanager.h" #include "cntimagelabel.h" -#include -#include -#include - #include "cntdebug.h" #include "cntglobal.h" @@ -37,6 +33,9 @@ #include #include +#include +#include + #include #include @@ -52,8 +51,7 @@ mRequest(NULL), mViewManager(NULL), mListView(NULL), - mModel(NULL), - mSaveManager(NULL) + mModel(NULL) { bool ok = false; mDocumentLoader.load(CNT_IMAGE_XML, &ok); @@ -89,17 +87,10 @@ mView->deleteLater(); delete mAvatar; - mAvatar = NULL; delete mContact; - mContact = NULL; delete mRequest; - mRequest = NULL; delete mRemoveImage; - mRemoveImage = NULL; delete mModel; - mModel = NULL; - delete mSaveManager; - mSaveManager = NULL; CNT_EXIT } @@ -136,49 +127,31 @@ mContact = new QContact(mArgs.value(ESelectedGroupContact).value()); } - QString myCard = mArgs.value( EMyCard ).toString(); - QContactLocalId localId = mContact->localId(); - QContactLocalId selfContactId = mEngine->contactManager(SYMBIAN_BACKEND).selfContactId(); - bool isMyCard = ( localId == selfContactId && localId != 0 ) || !myCard.isEmpty(); - - if (isMyCard) - { - mSaveManager = new CntSaveManager(CntSaveManager::EMyCard); - } - else if (mContact->type() == QContactType::TypeGroup) - { - mSaveManager = new CntSaveManager(CntSaveManager::EGroup); - } - else - { - mSaveManager = new CntSaveManager(); - } - // set the correct image if the contact already has an image set mImageLabel = static_cast(mDocumentLoader.findWidget(QString("cnt_image_label"))); mImageLabel->ungrabGesture(Qt::TapGesture); QList details = mContact->details(); if (details.count() > 0) + { + for (int i = 0;i < details.count();i++) { - for (int i = 0;i < details.count();i++) + if (details.at(i).imageUrl().isValid()) { - if (details.at(i).imageUrl().isValid()) - { - mAvatar = new QContactAvatar(details.at(i)); - mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString()); - break; - } + mAvatar = new QContactAvatar(details.at(i)); + mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString()); + break; } } + } else - { + { mAvatar = new QContactAvatar(); mRemoveImage->setEnabled(false); if (mContact->type() == QContactType::TypeGroup) - { + { mImageLabel->setAvatarIcon(HbIcon("qtg_large_add_group_picture")); - } } + } // set up the list mListView = static_cast(mDocumentLoader.findWidget(QString("cnt_listview"))); @@ -204,6 +177,9 @@ } +/*! +Populate the list model +*/ void CntImageEditorView::populateModel(QStandardItemModel *model) { QStandardItem *newPhoto = new QStandardItem(); @@ -229,8 +205,9 @@ delete mRequest; mRequest = 0; } - + mRequest = mAppManager.create(XQI_CAMERA_CAPTURE, XQOP_CAMERA_CAPTURE, false); + if ( mRequest ) { int mode = 0; //image mode @@ -247,10 +224,10 @@ args << mode; args << map; mRequest->setArguments(args); + mRequest->setSynchronous(false); // this must be an Asynchronus request, If symchronous it crashes connect(mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleImageChange(const QVariant&))); - connect(mRequest, SIGNAL(requestError(int,const QString&)), this, SLOT(handleError(int,const QString&))); - + mRequest->send(); } @@ -271,6 +248,7 @@ mRequest = mAppManager.create(XQI_IMAGE_FETCH, XQOP_IMAGE_FETCH, true); if ( mRequest ) { + mRequest->setSynchronous(false); connect(mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleImageChange(const QVariant&))); mRequest->send(); } @@ -307,9 +285,12 @@ mViewManager->back( mArgs ); } +/*! +Called when user selects to remove the image +*/ void CntImageEditorView::removeImage() { - QString filePath=mAvatar->imageUrl().toString(); + QString filePath = mAvatar->imageUrl().toString(); if(!filePath.isEmpty()) { // Check if image removable. @@ -374,6 +355,9 @@ CNT_EXIT } +/*! +Called when thumbnailmanager is ready with the icon handling +*/ void CntImageEditorView::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error) { CNT_ENTRY_ARGS("error code = " << error) @@ -389,6 +373,9 @@ CNT_EXIT } +/*! +Load the layout according to orientation +*/ void CntImageEditorView::setOrientation(Qt::Orientation orientation) { if (orientation == Qt::Vertical) @@ -425,13 +412,9 @@ } } -void CntImageEditorView::handleError(int errorCode, const QString& errorMessage) -{ - Q_UNUSED(errorCode); - Q_UNUSED(errorMessage); - CNT_LOG_ARGS("error code = " << errorCode << "errorMessage=" << errorMessage) -} - +/*! +Saves the whole contact, called when user exits phonebook (via task switcher or end key) +*/ void CntImageEditorView::saveContact() { mContact->saveDetail(mAvatar); @@ -441,24 +424,44 @@ mContact->removeDetail(mAvatar); } - QString name = mEngine->contactManager(SYMBIAN_BACKEND).synthesizedContactDisplayLabel(*mContact); + QContactManager& mgr = mEngine->contactManager( SYMBIAN_BACKEND ); + QString name = mgr.synthesizedContactDisplayLabel(*mContact); if (name.isEmpty()) { name = hbTrId("txt_phob_list_unnamed"); } - CntSaveManager::CntSaveResult result = mSaveManager->saveContact(mContact, &mEngine->contactManager(SYMBIAN_BACKEND)); + QString myCard = mArgs.value( EMyCard ).toString(); + QContactLocalId localId = mContact->localId(); + QContactLocalId selfContactId = mgr.selfContactId(); + bool isMyCard = ( localId == selfContactId && localId != 0 ) || !myCard.isEmpty(); + + CntSaveManager::CntSaveResult result; + CntSaveManager& save = mEngine->saveManager(); + if (isMyCard) + { + result = save.saveMyCard( mContact, &mgr ); + } + else if (mContact->type() == QContactType::TypeGroup) + { + result = save.saveGroup( mContact, &mgr ); + } + else + { + result = save.saveContact( mContact, &mgr ); + } + if (mContact->type() != QContactType::TypeGroup) { switch (result) { case CntSaveManager::ESaved: - HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contact_1_saved")).arg(name)); + HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter("txt_phob_dpophead_contact_1_saved").arg(name)); break; case CntSaveManager::EUpdated: - HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contacts_1_updated")).arg(name)); + HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter("txt_phob_dpophead_contacts_1_updated").arg(name)); break; case CntSaveManager::EFailed: HbDeviceNotificationDialog::notification(QString(),hbTrId("SAVING FAILED!")); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntimageeditorview.h --- a/phonebookui/cntcommonui/views/cntimageeditorview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntimageeditorview.h Fri Oct 15 12:24:46 2010 +0300 @@ -20,17 +20,15 @@ #include #include +#include #include -#include - -class CntImageLabel; class HbListView; +class HbAction; class XQAiwRequest; -class HbAction; class QStandardItemModel; class QModelIndex; -class CntSaveManager; +class CntImageLabel; QTM_BEGIN_NAMESPACE class QContact; @@ -42,6 +40,7 @@ class CntImageEditorView : public QObject, public CntAbstractView { Q_OBJECT + friend class TestCntImageEditorView; public: CntImageEditorView(); @@ -54,41 +53,28 @@ HbView* view() const { return mView; } int viewId() const { return imageEditorView; } inline void setEngine( CntAbstractEngine& aEngine ){ mEngine = &aEngine; } -#ifdef PBK_UNIT_TEST -public: -#else + private: -#endif void populateModel(QStandardItemModel *model); void openCamera(); void openGallery(); -#ifdef PBK_UNIT_TEST -public slots: -#else private slots: -#endif void showPreviousView(); void removeImage(); void handleImageChange(const QVariant &value); void thumbnailReady( const QPixmap& pixmap, void *data, int id, int error ); void setOrientation(Qt::Orientation orientation); void listViewActivated(const QModelIndex &index); - void handleError(int errorCode, const QString& errorMessage); void saveContact(); - -#ifdef PBK_UNIT_TEST -public: -#else private: -#endif QContact *mContact; // own QContactAvatar *mAvatar; // own CntImageLabel *mImageLabel; // owned by layout XQAiwRequest *mRequest; // own XQApplicationManager mAppManager; - CntThumbnailManager *mThumbnailManager; // own + CntThumbnailManager *mThumbnailManager; // own HbView *mView; // own HbAction *mSoftkey; // owned by view HbAction *mRemoveImage; // own @@ -96,10 +82,9 @@ CntDocumentLoader mDocumentLoader; HbListView *mListView; // owned by layout QStandardItemModel *mModel; // own - CntSaveManager *mSaveManager; // own - CntViewParameters mArgs; - CntAbstractEngine* mEngine; + CntViewParameters mArgs; + CntAbstractEngine *mEngine; // not owned }; -#endif // CNTIMAGEEDITORVIEW_H +#endif /* CNTIMAGEEDITORVIEW_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntimportsview.cpp --- a/phonebookui/cntcommonui/views/cntimportsview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntimportsview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -14,51 +14,43 @@ * Description: * */ - -#include - #include "cntimportsview.h" -#include "cntglobal.h" - #include "cntsimengine.h" -#include +#include "cntglobal.h" +#include + #include #include -#include #include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include #include #include #include -#include +#include +#include + +#include +#include #include -#include -#include const char *CNT_IMPORT_UI_XML = ":/xml/contacts_sim.docml"; -CntImportsView::CntImportsView() : mViewManager(0), - mSimEngine(0), - mListView(0), - mView(0), - mSoftkey(0), - mModel(0), - mImportSimPopup(0), - mEngine(0) +/*! +Constructor +*/ +CntImportsView::CntImportsView() : + mViewManager(NULL), + mSimEngine(NULL), + mListView(NULL), + mView(NULL), + mSoftkey(NULL), + mModel(NULL), + mImportSimPopup(NULL), + mEngine(NULL) { CNT_ENTRY - CNT_LOG_ARGS(QString("All bools reset")); + bool ok = false; mDocumentLoader.load(CNT_IMPORT_UI_XML, &ok); @@ -72,49 +64,27 @@ } mSimEngine = new CntSimEngine(*this, *mView); + connect(mSimEngine, SIGNAL(showNamesView()), this, SLOT(showPreviousView())); + connect(mSimEngine, SIGNAL(closePopup()), this, SLOT(closeImportPopup())); //back button mSoftkey = new HbAction(Hb::BackNaviAction, mView); connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView())); - connect(mSimEngine, SIGNAL(showNamesView()), this, SLOT(showPreviousView())); - connect(mSimEngine, SIGNAL(closePopup()), this, SLOT(closeImportPopup())); - CNT_EXIT - -} -void CntImportsView::deactivate() -{ -} - - -CntImportsView::~CntImportsView() -{ - CNT_ENTRY - mView->deleteLater(); - delete mModel; - delete mSimEngine; CNT_EXIT } /*! -Activates a previous view +Destructor */ -void CntImportsView::showPreviousView() +CntImportsView::~CntImportsView() { CNT_ENTRY - CntViewParameters args; - mViewManager->back(args); - CNT_EXIT -} - -void CntImportsView::closeImportPopup() -{ - CNT_ENTRY - if (mImportSimPopup != NULL) - { - mImportSimPopup->close(); - mImportSimPopup = NULL; // Dilaog is deleted on close() - } + + mView->deleteLater(); + delete mModel; + delete mSimEngine; + CNT_EXIT } @@ -168,101 +138,140 @@ CNT_EXIT } +void CntImportsView::deactivate() +{ + +} +/*! +Returns the contact manager +*/ +QContactManager *CntImportsView::contactSymbianManager() +{ + if (mSimEngine) + { + return mSimEngine->contactSymbianManager(); + } + + return NULL; +} + +/*! +Activates a previous view +*/ +void CntImportsView::showPreviousView() +{ + CNT_ENTRY + + CntViewParameters args; + mViewManager->back(args); + + CNT_EXIT +} + +/*! +Close the import popup +*/ +void CntImportsView::closeImportPopup() +{ + CNT_ENTRY + + if (mImportSimPopup != NULL) + { + mImportSimPopup->close(); + mImportSimPopup = NULL; + } + + CNT_EXIT +} + +/*! +Called when list item is activated +*/ void CntImportsView::onListViewActivated(const QModelIndex &index) { CNT_ENTRY + int row = index.row(); if ( row == 0 ) // row 0 has "Imports from SIM" { - if (!mSimEngine->startSimImport()) - { - //show error note - mSimEngine->simInfoErrorMessage(KErrAccessDenied); - } - else - { - //start popup and progress - showWaitNote(); - } - } - CNT_EXIT - - } + if (!mSimEngine->startSimImport()) + { + //show error note + mSimEngine->simInfoErrorMessage(KErrAccessDenied); + } + else + { + //start popup and progress + showWaitNote(); + } + } -void CntImportsView::showWaitNote() -{ - CNT_ENTRY - mImportSimPopup = new HbDialog(); - mImportSimPopup->setDismissPolicy(HbPopup::NoDismiss); - mImportSimPopup->setTimeout(HbPopup::NoTimeout); - mImportSimPopup->setBackgroundFaded(true); - mImportSimPopup->setAttribute(Qt::WA_DeleteOnClose, true); - - HbLabel *headingLabel = new HbLabel(mImportSimPopup); - headingLabel->setPlainText(hbTrId("txt_phob_title_import_contacts")); - mImportSimPopup->setHeadingWidget(headingLabel); - - QGraphicsLinearLayout *containerLayout = new QGraphicsLinearLayout(Qt::Vertical); - containerLayout->setContentsMargins(0, 0, 0, 0); - containerLayout->setSpacing(10); - - HbLabel *icon = new HbLabel(mImportSimPopup); - icon->setIcon(HbIcon("qtg_large_sim")); - - HbLabel *simText= new HbLabel(mImportSimPopup); - simText->setPlainText(hbTrId("txt_phob_info_importing_contacts_from_sim")); - simText->setTextWrapping(Hb::TextWordWrap); - simText->setElideMode(Qt::ElideNone); - - HbProgressBar *progressBar = new HbProgressBar(mImportSimPopup); - progressBar->setRange(0,0); - - HbPushButton *stopButton = new HbPushButton(mImportSimPopup); - stopButton->setText(hbTrId("txt_phob_button_cancel")); - connect(stopButton, SIGNAL(clicked()), mSimEngine, SLOT(stopSimImport())); - - QGraphicsLinearLayout *containerLayout1 = new QGraphicsLinearLayout(Qt::Horizontal); - containerLayout1->addItem(icon); - containerLayout1->addItem(simText); - - QGraphicsWidget *containerWidget = new QGraphicsWidget; - containerLayout->addItem(containerLayout1); - containerLayout->addItem(progressBar); - containerLayout->addItem(stopButton); - containerWidget->setLayout(containerLayout); - mImportSimPopup->setContentWidget(containerWidget); - mImportSimPopup->open(); CNT_EXIT } -void CntImportsView::setPreferredDetails( QContact *aContact ) -{ - CNT_ENTRY - mSimEngine->setPreferredDetails(*aContact); - CNT_EXIT -} - - +/*! +Called when importing is cancelled +*/ void CntImportsView::userCancelsImport() { CNT_ENTRY + QString results; if(mSimEngine->userCancelsImport(results)) { HbDeviceNotificationDialog::notification(QString(),results); } + CNT_EXIT } +/*! +Display the wait note +*/ +void CntImportsView::showWaitNote() +{ + CNT_ENTRY + + mImportSimPopup = new HbProgressDialog(HbProgressDialog::WaitDialog); + mImportSimPopup->setDismissPolicy(HbPopup::NoDismiss); + mImportSimPopup->setTimeout(HbPopup::NoTimeout); + mImportSimPopup->setBackgroundFaded(true); + mImportSimPopup->setAttribute(Qt::WA_DeleteOnClose, true); + + mImportSimPopup->setHeadingText(hbTrId("txt_phob_title_import_contacts")); + mImportSimPopup->setIcon(HbIcon("qtg_large_sim")); + mImportSimPopup->setText(hbTrId("txt_phob_info_importing_contacts_from_sim")); + + connect(mImportSimPopup, SIGNAL(cancelled()), mSimEngine, SLOT(stopSimImport())); + + mImportSimPopup->show(); + + CNT_EXIT +} + +/*! +Set preferred details for the given contact +*/ +void CntImportsView::setPreferredDetails( QContact *aContact ) +{ + CNT_ENTRY + + mSimEngine->setPreferredDetails(*aContact); + + CNT_EXIT +} void CntImportsView::setListBoxItemText(QString& aPrimary, QString& aSecondary) { CNT_ENTRY + QList importItems = mModel->takeRow(0); QStandardItem* importItem = NULL; - if (importItems.count() > 0) { + + if (importItems.count() > 0) + { importItem = importItems.at(0); } @@ -278,14 +287,17 @@ mModel->insertRow(0, importItem); mListView->reset(); } + CNT_EXIT } void CntImportsView::setListBoxItemEnabled(bool aEnabled) { CNT_ENTRY + QList importItems = mModel->takeRow(0); QStandardItem* importItem = NULL; + if ( !importItems.isEmpty() ) { importItem = importItems.first(); @@ -295,17 +307,8 @@ { importItem->setEnabled(aEnabled); } + CNT_EXIT } -QContactManager *CntImportsView::contactSymbianManager() -{ - if (mSimEngine) - { - return mSimEngine->contactSymbianManager(); - } - - return NULL; -} - // EOF diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntimportsview.h --- a/phonebookui/cntcommonui/views/cntimportsview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntimportsview.h Fri Oct 15 12:24:46 2010 +0300 @@ -15,26 +15,25 @@ * */ -#ifndef CNTIMPORTSVIEW_H_ -#define CNTIMPORTSVIEW_H_ +#ifndef CNTIMPORTSVIEW_H +#define CNTIMPORTSVIEW_H #include -#include -#include -#include "cntactionmenubuilder.h" -#include #include "cntsimutility.h" #include "cntimportviewcallback.h" +#include #include +class HbProgressDialog; +class HbListView; class HbView; class HbAction; class QStandardItemModel; -class HbDialog; +class CntSimEngine; +class QModelIndex; -class CntSimEngine; QTM_BEGIN_NAMESPACE class QContact; QTM_END_NAMESPACE @@ -43,13 +42,8 @@ class CntImportsView : public QObject, public CntAbstractView, public CntImportViewCallback { - -Q_OBJECT - -public slots: - - void onListViewActivated(const QModelIndex &index); - void userCancelsImport(); + Q_OBJECT + friend class TestCntImportsView; public: CntImportsView(); @@ -64,6 +58,12 @@ inline void setEngine( CntAbstractEngine& aEngine ){ mEngine = &aEngine; } QContactManager *contactSymbianManager(); +private slots: + void showPreviousView(); + void closeImportPopup(); + void onListViewActivated(const QModelIndex &index); + void userCancelsImport(); + private: void showWaitNote(); void setPreferredDetails( QContact *aContact ); @@ -72,30 +72,16 @@ void setListBoxItemText(QString& aPrimary, QString& aSecondary); void setListBoxItemEnabled(bool aEnabled); -#ifdef PBK_UNIT_TEST -public slots: -#else -private slots: -#endif - void showPreviousView(); - void closeImportPopup(); - -#ifdef PBK_UNIT_TEST -public : -#else -private : -#endif - // QContact* mContact; - CntAbstractViewManager* mViewManager; - CntSimEngine *mSimEngine; +private: + CntAbstractViewManager *mViewManager; + CntSimEngine *mSimEngine; HbListView *mListView; - HbDocumentLoader mDocumentLoader; - HbView* mView; // own - HbAction* mSoftkey; - QStandardItemModel* mModel; - HbDialog *mImportSimPopup; - - CntAbstractEngine* mEngine; + HbDocumentLoader mDocumentLoader; + HbView *mView; + HbAction *mSoftkey; + QStandardItemModel *mModel; + HbProgressDialog *mImportSimPopup; + CntAbstractEngine *mEngine; }; -#endif /* CNTIMPORTSVIEW_H_ */ +#endif /* CNTIMPORTSVIEW_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntimportviewcallback.h --- a/phonebookui/cntcommonui/views/cntimportviewcallback.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntimportviewcallback.h Fri Oct 15 12:24:46 2010 +0300 @@ -15,8 +15,8 @@ * */ -#ifndef CNTIMPORTVIEWCALLBACK_H_ -#define CNTIMPORTVIEWCALLBACK_H_ +#ifndef CNTIMPORTVIEWCALLBACK_H +#define CNTIMPORTVIEWCALLBACK_H class QString; @@ -33,4 +33,4 @@ virtual void setListBoxItemEnabled(bool aEnabled) = 0; }; -#endif /* CNTIMPORTVIEWCALLBACK_H_ */ +#endif /* CNTIMPORTVIEWCALLBACK_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntmycardview.cpp --- a/phonebookui/cntcommonui/views/cntmycardview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntmycardview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -27,6 +27,9 @@ const char *CNT_MYCARD_UI_XML = ":/xml/contacts_mc.docml"; +/*! +Constructor +*/ CntMyCardView::CntMyCardView() : mContact(NULL), mViewManager(NULL) @@ -48,31 +51,25 @@ connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView())); } +/*! +Destructor +*/ CntMyCardView::~CntMyCardView() { mView->deleteLater(); delete mContact; - mContact = NULL; -} - -/*! -Activates a previous view -*/ -void CntMyCardView::showPreviousView() -{ - CntViewParameters args; - mViewManager->back(args); } /* -Activates a default view +Activates the view */ void CntMyCardView::activate(const CntViewParameters aArgs) { mViewManager = &mEngine->viewManager(); - if (mView->navigationAction() != mSoftkey) { + if (mView->navigationAction() != mSoftkey) + { mView->setNavigationAction(mSoftkey); } @@ -81,21 +78,20 @@ setOrientation(window->orientation()); mContact = new QContact(aArgs.value(ESelectedContact).value()); - HbPushButton *newButton = static_cast(mDocumentLoader.findWidget(QString("cnt_button_new"))); - connect(newButton, SIGNAL(clicked()), this, SLOT(openNameEditor())); - connect(newButton, SIGNAL(longPress(QPointF)), this, SLOT(openNameEditor())); + + mNewButton = static_cast(mDocumentLoader.findWidget(QString("cnt_button_new"))); + connect(mNewButton, SIGNAL(released()), this, SLOT(openEditor())); - HbPushButton *chooseButton = static_cast(mDocumentLoader.findWidget(QString("cnt_button_choose"))); - connect(chooseButton, SIGNAL(clicked()), this, SLOT(openMyCardSelectionView())); - connect(chooseButton, SIGNAL(longPress(QPointF)), this, SLOT(openMyCardSelectionView())); - + mChooseButton = static_cast(mDocumentLoader.findWidget(QString("cnt_button_choose"))); + connect(mChooseButton, SIGNAL(released()), this, SLOT(openMyCardSelectionDialog())); + QContactDetailFilter filter; filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); filter.setValue(QLatin1String(QContactType::TypeContact)); if (mEngine->contactManager( SYMBIAN_BACKEND ).contactIds(filter).isEmpty()) { - chooseButton->setEnabled(false); + mChooseButton->setEnabled(false); } } @@ -103,6 +99,72 @@ { } +/*! +Activates a previous view +*/ +void CntMyCardView::showPreviousView() +{ + CntViewParameters args; + mViewManager->back(args); +} + +/*! +Opens the editor view +*/ +void CntMyCardView::openEditor() +{ + if (mNewButton->isUnderMouse()) + { + CntViewParameters viewParameters; + viewParameters.insert(EViewId, editView); + viewParameters.insert(EMyCard, "myCard" ); + + QVariant var; + var.setValue(*mContact); + viewParameters.insert(ESelectedContact, var); + viewParameters.insert(EExtraAction, CNT_ROOT_ACTION); + mViewManager->changeView(viewParameters); + } + +} + +/*! +Opens the my card selection dialog +*/ +void CntMyCardView::openMyCardSelectionDialog() +{ + if (mChooseButton->isUnderMouse()) + { + CntFetchContactPopup* popup = CntFetchContactPopup::createSingleSelectionPopup( + hbTrId("txt_phob_title_select_contact"), + mEngine->contactManager(SYMBIAN_BACKEND)); + connect( popup, SIGNAL(fetchReady(QSet)), this, SLOT(handleMyCardSelection(QSet))); + QSet ids; + popup->setSelectedContacts(ids); + popup->showPopup(); + } +} + +/*! +Handle the contact selection +*/ +void CntMyCardView::handleMyCardSelection( QSet aIds ) +{ + QContactManager& manager = mEngine->contactManager( SYMBIAN_BACKEND ); + + if ( !aIds.isEmpty() ) { + QList selectedContactsList = aIds.values(); + QContact contact = manager.contact(selectedContactsList.front()); + removeFromGroup(&contact); + + manager.setSelfContactId( contact.localId() ); + showPreviousView(); + } +} + +/*! +Sets the layout according to the orientation +*/ void CntMyCardView::setOrientation(Qt::Orientation orientation) { if (orientation == Qt::Vertical) @@ -118,49 +180,8 @@ } /*! -Opens the name detail editor view -*/ -void CntMyCardView::openNameEditor() -{ - CntViewParameters viewParameters; - viewParameters.insert(EViewId, editView); - viewParameters.insert(EMyCard, "myCard" ); - - QVariant var; - var.setValue(*mContact); - viewParameters.insert(ESelectedContact, var); - viewParameters.insert(EExtraAction, CNT_ROOT_ACTION); - mViewManager->changeView(viewParameters); -} - -/*! -Opens the my card selection view +Removes the contact from all possible groups */ -void CntMyCardView::openMyCardSelectionView() -{ - CntFetchContactPopup* popup = CntFetchContactPopup::createSingleSelectionPopup( - hbTrId("txt_phob_title_select_contact"), - mEngine->contactManager(SYMBIAN_BACKEND)); - connect( popup, SIGNAL(fetchReady(QSet)), this, SLOT(handleMultiCardSelection(QSet))); - QSet ids; - popup->setSelectedContacts(ids); - popup->showPopup(); -} - -void CntMyCardView::handleMultiCardSelection( QSet aIds ) -{ - QContactManager& manager = mEngine->contactManager( SYMBIAN_BACKEND ); - - if ( !aIds.isEmpty() ) { - QList selectedContactsList = aIds.values(); - QContact contact = manager.contact(selectedContactsList.front()); - removeFromGroup(&contact); - - manager.setSelfContactId( contact.localId() ); - showPreviousView(); - } -} - void CntMyCardView::removeFromGroup(const QContact* aContact) { // Fetch all groups the contact is member and remove the relationships @@ -172,7 +193,8 @@ QList groupIds = mgr.contactIds(relationshipFilter); QList relationships; - for(int i = 0;i < groupIds.count();i++) { + for(int i = 0;i < groupIds.count();i++) + { QContact groupContact = mgr.contact(groupIds.at(i)); QContactRelationship relationship; relationship.setRelationshipType(QContactRelationship::HasMember); @@ -180,6 +202,7 @@ relationship.setSecond(aContact->id()); relationships.append(relationship); } + QMap errorMap; mgr.removeRelationships(relationships,&errorMap); } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntmycardview.h --- a/phonebookui/cntcommonui/views/cntmycardview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntmycardview.h Fri Oct 15 12:24:46 2010 +0300 @@ -15,8 +15,8 @@ * */ -#ifndef CNTMYCARDVIEW_H_ -#define CNTMYCARDVIEW_H_ +#ifndef CNTMYCARDVIEW_H +#define CNTMYCARDVIEW_H #include #include @@ -25,6 +25,7 @@ class HbView; class HbAction; +class HbPushButton; QTM_BEGIN_NAMESPACE class QContact; @@ -34,9 +35,9 @@ class CntMyCardView : public QObject, public CntAbstractView { - -Q_OBJECT - + Q_OBJECT + friend class TestCntMyCardView; + public: CntMyCardView(); ~CntMyCardView(); @@ -52,23 +53,23 @@ private slots: void showPreviousView(); - void openNameEditor(); - void openMyCardSelectionView(); - void handleMultiCardSelection(QSet aIds); + void openEditor(); + void openMyCardSelectionDialog(); + void handleMyCardSelection(QSet aIds); void setOrientation(Qt::Orientation orientation); private: - void removeFromGroup(const QContact* contact); private: - QContact* mContact; // own - CntAbstractViewManager* mViewManager; - HbDocumentLoader mDocumentLoader; - HbView* mView; // own - HbAction* mSoftkey; - CntAbstractEngine* mEngine; - friend class TestCntMyCardView; + QContact *mContact; // own + CntAbstractViewManager *mViewManager; + HbDocumentLoader mDocumentLoader; + HbView *mView; // own + HbAction *mSoftkey; + CntAbstractEngine *mEngine; + HbPushButton *mNewButton; + HbPushButton *mChooseButton; }; -#endif /* CNTMYCARDVIEW_H_ */ +#endif /* CNTMYCARDVIEW_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntnamesview.cpp --- a/phonebookui/cntcommonui/views/cntnamesview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntnamesview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -19,7 +19,8 @@ #include "cntnamesview_p.h" #include -CntNamesView::CntNamesView() : d_ptr( new CntNamesViewPrivate() ) +CntNamesView::CntNamesView() : + d_ptr( new CntNamesViewPrivate() ) { Q_D(CntNamesView); d->q_ptr = this; @@ -68,6 +69,18 @@ Q_D(CntNamesView); d->setEngine( aEngine ); } + +QString CntNamesView::externalize(QDataStream &stream) +{ + Q_D(CntNamesView); + return d->externalize(stream); +} + +bool CntNamesView::internalize(QDataStream &stream, CntViewParameters &viewParameters) +{ + Q_D(CntNamesView); + return d->internalize(stream, viewParameters); +} // end of file diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntnamesview.h --- a/phonebookui/cntcommonui/views/cntnamesview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntnamesview.h Fri Oct 15 12:24:46 2010 +0300 @@ -42,6 +42,9 @@ void setEngine( CntAbstractEngine& aEngine ); + QString externalize(QDataStream &stream); + bool internalize(QDataStream &stream, CntViewParameters &viewParameters); + private: CntNamesViewPrivate* const d_ptr; Q_DECLARE_PRIVATE_D(d_ptr, CntNamesView) diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntnamesview_p.cpp --- a/phonebookui/cntcommonui/views/cntnamesview_p.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntnamesview_p.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -23,8 +23,10 @@ #include "cntdebug.h" #include "cntapplication.h" #include "cntfavourite.h" +#include "cntpinchgrabber.h" +#include "cntnamesviewitem.h" + #include - #include #include @@ -34,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -51,6 +52,7 @@ #include const char *CNT_CONTACTLIST_XML = ":/xml/contacts_namelist.docml"; +const QString CNT_ACTIVITY_MAINVIEW = "ContactsMainView"; static const int CNT_MIN_ROW_COUNT = 2; bool CntNamesViewPrivate::mIsFirstTimeUse = true; @@ -58,23 +60,28 @@ QObject(), mViewManager(NULL), mListModel(NULL), + mView(NULL), mListView(NULL), - mEmptyList(NULL), mSearchPanel(NULL), mLoader(NULL), mVirtualKeyboard(NULL), + mSoftkey(NULL), mNamesAction(NULL), + mMultipleDeleter(NULL), mMenuBuilder(NULL), + mActionGroup(NULL), + mMenu(NULL), + mViewMenu(NULL), + mEngine(NULL), mHandledContactId(0), - mActionGroup(NULL), - mMenu(NULL), - mFilterChanged(false) + mFilterChanged(false) { CNT_ENTRY bool ok; document()->load( CNT_CONTACTLIST_XML, &ok); - if (!ok) { + if (!ok) + { qFatal("Unable to read %S", CNT_CONTACTLIST_XML); } @@ -87,9 +94,9 @@ mSoftkey = new HbAction(Hb::BackNaviAction, mView); connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView())); - mNewContact = static_cast (document()->findObject("cnt:newcontact")); - mNewContact->setParent(mView); - connect(mNewContact, SIGNAL(triggered()), this, SLOT(createNewContact())); + HbAction *newContact = static_cast (document()->findObject("cnt:newcontact")); + newContact->setParent(mView); + connect(newContact, SIGNAL(triggered()), this, SLOT(createNewContact())); mMultipleDeleter = static_cast (document()->findObject("cnt:delete")); mMultipleDeleter->setParent(mView); @@ -106,9 +113,9 @@ mNamesAction = static_cast (document()->findObject("cnt:names")); mNamesAction->setParent(mView); - mImportSim = static_cast (document()->findObject("cnt:importsim")); - mImportSim->setParent(mView); - connect(mImportSim, SIGNAL(triggered()), this, SLOT(importSim())); + HbAction *importSim = static_cast (document()->findObject("cnt:importsim")); + importSim->setParent(mView); + connect(importSim, SIGNAL(triggered()), this, SLOT(showImportsView())); mActionGroup = new QActionGroup(this); groups->setActionGroup(mActionGroup); @@ -120,17 +127,18 @@ HbAction* settings = static_cast(document()->findObject("cnt:settings") ); settings->setParent(mView); - connect( settings, SIGNAL(triggered()), this, SLOT(showSettings()) ); + connect( settings, SIGNAL(triggered()), this, SLOT(showSettingsView()) ); - HbMenu* viewMenu = static_cast(document()->findObject("viewMenu") ); - viewMenu->setParent(mView); + mViewMenu = static_cast(document()->findObject("viewMenu") ); + mViewMenu->setParent(mView); connect(list(), SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), this, SLOT(showContextMenu(HbAbstractViewItem*,QPointF))); - connect(list(), SIGNAL(activated (const QModelIndex&)), this, + connect(list(), SIGNAL(activated(const QModelIndex&)), this, SLOT(showContactView(const QModelIndex&))); + connect(list(), SIGNAL(pressed(const QModelIndex&)), this, + SLOT(setShowContextMenu(const QModelIndex&))); - mEmptyList = static_cast (document()->findWidget("emptyLabel")); mSearchPanel = static_cast (document()->findWidget("searchPanel")); connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(hideFinder())); connect(mSearchPanel, SIGNAL(criteriaChanged(QString)), this, SLOT(setFilter(QString))); @@ -139,36 +147,9 @@ CntApplication* cntApp = static_cast(qApp); connect(win, SIGNAL(viewReady()), cntApp, SIGNAL(applicationReady())); -#ifdef __WINS__ - mView->menu()->addAction("Change Orientation", this, SLOT(switchOrientation()) ); -#endif CNT_EXIT } -void CntNamesViewPrivate::handleImportContacts( HbAction *aAction ) -{ - CNT_ENTRY - - HbDialog *popup = static_cast(sender()); - - if (popup && aAction == popup->actions().first()) - { - CntViewParameters args; - args.insert(EViewId, importsView); - mViewManager->changeView(args); - } - - CNT_EXIT -} - -void CntNamesViewPrivate::switchOrientation() -{ - HbMainWindow* win = mView->mainWindow(); - Qt::Orientation orientation = win->orientation(); - - win->setOrientation( orientation == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal ); -} - CntNamesViewPrivate::~CntNamesViewPrivate() { CNT_ENTRY @@ -201,7 +182,7 @@ CNT_ENTRY mViewManager = &mEngine->viewManager(); - if (mView->mainWindow() != NULL && !(mView->visibleItems() & Hb::AllItems)) + if (mView->mainWindow() != NULL && !(mView->visibleItems() & Hb::ToolBarItem)) { hideFinder(); } @@ -247,7 +228,10 @@ if ( aArgs.value( EExtraAction ).toString() == CNT_FIND_ACTION ) { - showFinder(); + connect(mView->mainWindow(), SIGNAL(viewReady()), this, SLOT(showFinder())); + mIsFirstTimeUse = false; + //there is a problem with post event of QEvent::RequestSoftwareInputPanel + //showFinder(); } if (mIsFirstTimeUse) @@ -277,10 +261,8 @@ note->setStandardButtons(HbMessageBox::NoButton); note->addAction(new HbAction(hbTrId("txt_phob_button_import"), note)); note->addAction(new HbAction(hbTrId("txt_common_button_cancel"), note)); - - HbLabel *headingLabel = new HbLabel( note ); - headingLabel->setPlainText(hbTrId("txt_phob_title_import_contacts")); - note->setHeadingWidget(headingLabel); + + note->setHeadingText(hbTrId("txt_phob_title_import_contacts")); note->setIcon(HbIcon("qtg_large_sim")); note->setText(hbTrId("txt_phob_info_your_phonebook_is_empty_do_you_wish")); @@ -315,6 +297,26 @@ CNT_EXIT } +QString CntNamesViewPrivate::externalize(QDataStream &stream) +{ + CntViewParameters viewParameters; + viewParameters.insert(EViewId, namesView); + if (isFinderVisible()) + { + viewParameters.insert(EExtraAction, CNT_FIND_ACTION); + } + + stream << viewParameters; + + return CNT_ACTIVITY_MAINVIEW; +} + +bool CntNamesViewPrivate::internalize(QDataStream &stream, CntViewParameters &viewParameters) +{ + stream >> viewParameters; + return true; +} + void CntNamesViewPrivate::deactivate() { CNT_ENTRY @@ -330,84 +332,23 @@ CNT_EXIT } -void CntNamesViewPrivate::changeDeleteActionStatus() -{ - CNT_ENTRY - - bool multipleContactsFound = mListModel->rowCount() >= CNT_MIN_ROW_COUNT; - mMultipleDeleter->setEnabled(multipleContactsFound); - - CNT_EXIT -} - -void CntNamesViewPrivate::focusLineEdit() -{ - CNT_ENTRY - - HbLineEdit *editor = static_cast(mSearchPanel->primitive("lineedit")); - if (editor) - { - editor->setObjectName("focusLineEdit"); - editor->setInputMethodHints(Qt::ImhNoPredictiveText); - editor->setText(""); - editor->setFocus(); - - // This opens the VKB - QInputContext *ic = qApp->inputContext(); - if (ic) - { - QEvent *event = new QEvent(QEvent::RequestSoftwareInputPanel); - ic->filterEvent(event); - delete event; - } - } - - CNT_EXIT -} - -void CntNamesViewPrivate::setFilter(const QString &filterString) -{ - CNT_ENTRY - - QContactDetailFilter filter; - - if (filterString.isEmpty()) { - filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); - QString typeContact = QContactType::TypeContact; - filter.setValue(typeContact); - } else { - QStringList searchList = filterString.split(QRegExp("\\s+"), QString::SkipEmptyParts); - filter.setDetailDefinitionName(QContactDisplayLabel::DefinitionName, - QContactDisplayLabel::FieldLabel); - filter.setMatchFlags(QContactFilter::MatchStartsWith); - filter.setValue(searchList); - } - - mListModel->setFilter(filter); - mFilterChanged = true; - - if (mListModel->rowCount() == 0) { - document()->load( CNT_CONTACTLIST_XML, "find_empty" ); - } else { - document()->load( CNT_CONTACTLIST_XML, "find_list" ); - } - - CNT_EXIT -} - void CntNamesViewPrivate::showFinder() { CNT_ENTRY + disconnect(mView->mainWindow(), SIGNAL(viewReady()), this, SLOT(showFinder())); + mListModel->showMyCard(false); - HbListViewItem* proto = mListView->listItemPrototype(); + HbListViewItem* proto = list()->listItemPrototype(); proto->setTextFormat( Qt::RichText ); - mView->hideItems(Hb::AllItems); + mView->hideItems(Hb::ToolBarItem); focusLineEdit(); + mViewMenu = mView->takeMenu(); + CNT_EXIT } @@ -416,9 +357,9 @@ CNT_ENTRY document()->load( CNT_CONTACTLIST_XML, "no_find" ); - mView->showItems(Hb::AllItems); + mView->showItems(Hb::ToolBarItem); - HbListViewItem* proto = mListView->listItemPrototype(); + HbListViewItem* proto = list()->listItemPrototype(); proto->setTextFormat( Qt::PlainText ); mListModel->showMyCard(true); @@ -435,34 +376,42 @@ changeDeleteActionStatus(); + mView->setMenu(mViewMenu); + CNT_EXIT } -bool CntNamesViewPrivate::isFinderVisible() +void CntNamesViewPrivate::setFilter(const QString &filterString) { CNT_ENTRY - - bool isVisible = false; - if ( mSearchPanel ) + + QContactDetailFilter filter; + + if (filterString.isEmpty()) { - isVisible = mSearchPanel->isVisible(); - } - - CNT_EXIT - return isVisible; -} - -void CntNamesViewPrivate::showPreviousView() -{ - CNT_ENTRY - - if ( !isFinderVisible() ) - { - mViewManager->back( CntViewParameters() ); + filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); + QString typeContact = QContactType::TypeContact; + filter.setValue(typeContact); } else { - hideFinder(); + QStringList searchList = filterString.split(QRegExp("\\s+"), QString::SkipEmptyParts); + filter.setDetailDefinitionName(QContactDisplayLabel::DefinitionName, + QContactDisplayLabel::FieldLabel); + filter.setMatchFlags(QContactFilter::MatchStartsWith); + filter.setValue(searchList); + } + + mListModel->setFilter(filter); + mFilterChanged = true; + + if (mListModel->rowCount() == 0) + { + document()->load( CNT_CONTACTLIST_XML, "find_empty" ); + } + else + { + document()->load( CNT_CONTACTLIST_XML, "find_list" ); } CNT_EXIT @@ -515,12 +464,26 @@ mHandledContactId = aContact.localId(); - HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_delete_1")).arg(name), this, SLOT(handleDeleteContact(int)), + HbMessageBox::question(HbParameterLengthLimiter("txt_phob_info_delete_1").arg(name), this, SLOT(handleDeleteContact(int)), HbMessageBox::Delete | HbMessageBox::Cancel); CNT_EXIT } +void CntNamesViewPrivate::handleDeleteContact( int aAction ) +{ + CNT_ENTRY + + if (aAction == HbMessageBox::Delete) + { + mEngine->contactManager( SYMBIAN_BACKEND ).removeContact(mHandledContactId); + } + + mHandledContactId = 0; + + CNT_EXIT +} + void CntNamesViewPrivate::deleteMultipleContacts() { CNT_ENTRY @@ -545,6 +508,26 @@ CNT_EXIT } +void CntNamesViewPrivate::showPreviousView() +{ + CNT_ENTRY + + mViewManager->back( CntViewParameters() ); + + CNT_EXIT +} + +void CntNamesViewPrivate::showCollectionView() +{ + CNT_ENTRY + + CntViewParameters args; + args.insert(EViewId, collectionView); + mViewManager->changeView(args); + + CNT_EXIT +} + void CntNamesViewPrivate::showContactView( const QModelIndex& aIndex ) { CNT_ENTRY @@ -574,29 +557,93 @@ CNT_EXIT } +void CntNamesViewPrivate::showContactEditorView(QContact& aContact) +{ + CNT_ENTRY + + CntViewParameters args; + args.insert(EViewId, editView); + + QVariant contact; + contact.setValue(aContact); + args.insert(ESelectedContact, contact); + + mViewManager->changeView(args); + + CNT_EXIT +} + +void CntNamesViewPrivate::showSettingsView() +{ + CNT_ENTRY + + CntViewParameters args; + args.insert( EViewId, settingsView ); + mViewManager->changeView( args ); + + CNT_EXIT +} + +void CntNamesViewPrivate::showImportsView() +{ + CNT_ENTRY + + CntViewParameters args; + args.insert(EViewId, importsView); + mViewManager->changeView(args); + + CNT_EXIT +} + +void CntNamesViewPrivate::handleImportContacts( HbAction *aAction ) +{ + CNT_ENTRY + + HbDialog *popup = static_cast(sender()); + + if (popup && aAction == popup->actions().first()) + { + showImportsView(); + } + + CNT_EXIT +} + +void CntNamesViewPrivate::setShowContextMenu( const QModelIndex& aIndex ) +{ + CNT_ENTRY_ARGS(aIndex) + + QContactLocalId id = mListModel->contactId(aIndex); + + // if id is smaller than 1 (basically 0), it's the empty myCard + if (id < 1) + { + mListView->setLongPressEnabled(false); + } + else + { + mListView->setLongPressEnabled(true); + } + + CNT_EXIT +} + void CntNamesViewPrivate::showContextMenu(HbAbstractViewItem* aItem, QPointF aPoint) { CNT_ENTRY QContact contact = mListModel->contact(aItem->modelIndex()); - // In case of an empty MyCard, do not show any ContextMenu - if (!(contact.localId() == mListModel->myCardId() && contact.details().count() <= 4)) + if (mMenu) { - if (mMenu) - { - delete mMenu; - mMenu = NULL; - } - mMenu = mMenuBuilder->actionMenu( contact, mListModel->myCardId() ); - mMenu->setPreferredPos( aPoint ); - mMenu->open(); - } - else - { - showContactView(contact); + delete mMenu; + mMenu = NULL; } + mMenu = mMenuBuilder->actionMenu( contact, mListModel->myCardId() ); + mMenu->setPreferredPos( aPoint ); + mMenu->open(); + CNT_EXIT } @@ -620,69 +667,6 @@ CNT_EXIT } -void CntNamesViewPrivate::handleDeleteContact( int aAction ) -{ - CNT_ENTRY - - if (aAction == HbMessageBox::Delete) - { - mEngine->contactManager( SYMBIAN_BACKEND ).removeContact(mHandledContactId); - } - - mHandledContactId = 0; - - CNT_EXIT -} - -void CntNamesViewPrivate::showContactEditorView(QContact& aContact) -{ - CNT_ENTRY - - CntViewParameters args; - args.insert(EViewId, editView); - - QVariant contact; - contact.setValue(aContact); - args.insert(ESelectedContact, contact); - - mViewManager->changeView(args); - - CNT_EXIT -} - -void CntNamesViewPrivate::showCollectionView() -{ - CNT_ENTRY - - CntViewParameters args; - args.insert(EViewId, collectionView); - mViewManager->changeView(args); - - CNT_EXIT -} - -void CntNamesViewPrivate::importSim() -{ - CNT_ENTRY - - CntViewParameters args; - args.insert(EViewId, importsView); - mViewManager->changeView(args); - - CNT_EXIT -} - -void CntNamesViewPrivate::showSettings() -{ - CNT_ENTRY - - CntViewParameters args; - args.insert( EViewId, settingsView ); - mViewManager->changeView( args ); - - CNT_EXIT -} - void CntNamesViewPrivate::handleContactAddition(const QList& aAddedList) { CNT_ENTRY @@ -721,6 +705,55 @@ CNT_EXIT } +bool CntNamesViewPrivate::isFinderVisible() +{ + CNT_ENTRY + + bool isVisible = false; + if ( mSearchPanel ) + { + isVisible = mSearchPanel->isVisible(); + } + + CNT_EXIT + return isVisible; +} + +void CntNamesViewPrivate::changeDeleteActionStatus() +{ + CNT_ENTRY + + bool multipleContactsFound = mListModel->rowCount() >= CNT_MIN_ROW_COUNT; + mMultipleDeleter->setEnabled(multipleContactsFound); + + CNT_EXIT +} + +void CntNamesViewPrivate::focusLineEdit() +{ + CNT_ENTRY + + HbLineEdit *editor = static_cast(mSearchPanel->primitive("lineedit")); + if (editor) + { + editor->setObjectName("focusLineEdit"); + editor->setInputMethodHints(Qt::ImhNoPredictiveText); + editor->setText(""); + editor->setFocus(); + + // This opens the VKB + QInputContext *ic = qApp->inputContext(); + if (ic) + { + QEvent *event = new QEvent(QEvent::RequestSoftwareInputPanel); + ic->filterEvent(event); + delete event; + } + } + + CNT_EXIT +} + void CntNamesViewPrivate::setScrollPosition(int focusedContact) { CNT_ENTRY @@ -734,26 +767,28 @@ CNT_EXIT } -//// lazy accessors HbListView* CntNamesViewPrivate::list() { CNT_ENTRY if (!mListView) { mListView = static_cast (mLoader->findWidget("listView")); + + mListView->grabGesture(Qt::PinchGesture); + + CntNamesViewItem *item = new CntNamesViewItem(); + mListView->setItemPrototype(item); mListView->setFrictionEnabled(true); mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); - mListView->listItemPrototype()->setGraphicsSize(HbListViewItem::Thumbnail); - mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape); + item->setGraphicsSize(HbListViewItem::Thumbnail); + item->setStretchingStyle(HbListViewItem::StretchLandscape); mListView->verticalScrollBar()->setInteractive(true); HbFrameBackground frame; frame.setFrameGraphicsName("qtg_fr_list_normal"); frame.setFrameType(HbFrameDrawer::NinePieces); - - HbListViewItem* prototype = mListView->listItemPrototype(); - prototype->setDefaultFrame( frame ); + item->setDefaultFrame( frame ); mListView->setUniformItemSizes(true); mListView->setItemRecycling(true); @@ -761,6 +796,9 @@ HbIndexFeedback *indexFeedback = new HbIndexFeedback(mView); indexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter); indexFeedback->setItemView(mListView); + + CntPinchGrabber *grabber = new CntPinchGrabber(mListView); + mListView->installEventFilter(grabber); } CNT_EXIT @@ -779,5 +817,4 @@ return mLoader; } - // End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntnamesview_p.h --- a/phonebookui/cntcommonui/views/cntnamesview_p.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntnamesview_p.h Fri Oct 15 12:24:46 2010 +0300 @@ -15,8 +15,10 @@ * */ -#ifndef CNTABSTRACTLISTVIEW_H_ -#define CNTABSTRACTLISTVIEW_H_ +#ifndef CNTNAMESVIEWPRIVATE_H +#define CNTNAMESVIEWPRIVATE_H + +#include #include "cntnamesview.h" #include "cntactionlauncher.h" @@ -24,74 +26,86 @@ #include #include -#include - -#include +#include #include class HbView; class HbListView; -class HbLabel; class HbDocumentLoader; class HbSearchPanel; class HbShrinkingVkbHost; +class HbMenu; class CntExtensionManager; class CntFetchContacts; -class HbMenu; + +QTM_USE_NAMESPACE class CntNamesViewPrivate : public QObject { Q_OBJECT Q_DECLARE_PUBLIC(CntNamesView) + friend class TestCntNamesView; public: CntNamesViewPrivate(); virtual ~CntNamesViewPrivate(); + +public: + void activate( const CntViewParameters aArgs ); + void deactivate(); + void setEngine( CntAbstractEngine& aEngine ){ mEngine = &aEngine; } + QString externalize(QDataStream &stream); + bool internalize(QDataStream &stream, CntViewParameters &viewParameters); -public slots: +public slots: + // Search functions void showFinder(); void hideFinder(); void setFilter(const QString &filterString); + // Extension action (activity stream toolbar button) void handleExtensionAction(); + // New contact creation void createNewContact(); + + // Single and multiple contact deletion void deleteContact( QContact& aContact ); + void handleDeleteContact( int aAction ); void deleteMultipleContacts(); - void handleDeleteMultipleContacts( QSet aIds ); + // View switches void showPreviousView(); void showCollectionView(); + void showContactView( const QModelIndex& aIndex ); void showContactView( QContact& aContact ); - void showContactView( const QModelIndex& ); void showContactEditorView( QContact& aContact ); - void showContextMenu(HbAbstractViewItem* aItem, QPointF aPoint); - void showSettings(); + void showSettingsView(); + void showImportsView(); + // FTU import dialog + void handleImportContacts( HbAction *aAction ); + + // Context menu actions + void setShowContextMenu( const QModelIndex& aIndex ); + void showContextMenu(HbAbstractViewItem* aItem, QPointF aPoint); void executeAction( QContact& aContact, QContactDetail aDetail, QString aAction ); void actionExecuted( CntActionLauncher* aAction ); - void handleDeleteContact( int aAction ); - void importSim(); + // Contact database notifications void handleContactAddition(const QList & aAddedList); void handleContactRemoval(const QList & aRemovedList); void handleSelfContactIdChange(const QContactLocalId & aOldId, const QContactLocalId & aNewId); -private slots: - void switchOrientation(); - void handleImportContacts( HbAction *aAction ); - public: bool isFinderVisible(); - void activate( const CntViewParameters aArgs ); - void deactivate(); - void setEngine( CntAbstractEngine& aEngine ){ mEngine = &aEngine; } + private: void changeDeleteActionStatus(); void focusLineEdit(); void setScrollPosition(int focusedContact); - + public: CntNamesView *q_ptr; @@ -99,27 +113,28 @@ HbListView *list(); HbDocumentLoader *document(); + private: - CntAbstractViewManager* mViewManager; - CntListModel* mListModel; - HbView* mView; - HbListView* mListView; - HbLabel* mEmptyList; - HbSearchPanel* mSearchPanel; - HbDocumentLoader* mLoader; - HbShrinkingVkbHost* mVirtualKeyboard; - HbAction* mSoftkey; - HbAction* mNamesAction; - CntActionMenuBuilder* mMenuBuilder; - HbAction* mImportSim; - HbAction* mNewContact; - QContactLocalId mHandledContactId; - HbAction* mMultipleDeleter; - QActionGroup* mActionGroup; - HbMenu* mMenu; - bool mFilterChanged; - CntAbstractEngine* mEngine; - static bool mIsFirstTimeUse; // FTU flag + friend class T_NameListTest; + CntAbstractViewManager *mViewManager; + CntListModel *mListModel; + HbView *mView; + HbListView *mListView; + HbSearchPanel *mSearchPanel; + HbDocumentLoader *mLoader; + HbShrinkingVkbHost *mVirtualKeyboard; + HbAction *mSoftkey; + HbAction *mNamesAction; + HbAction *mMultipleDeleter; + CntActionMenuBuilder *mMenuBuilder; + QActionGroup *mActionGroup; + HbMenu *mMenu; + HbMenu *mViewMenu; + CntAbstractEngine *mEngine; + QContactLocalId mHandledContactId; + bool mFilterChanged; + + static bool mIsFirstTimeUse; // FTU flag }; -#endif /* CNTABSTRACTLISTVIEW_H_ */ +#endif /* CNTNAMESVIEWPRIVATE_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntnamesviewitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/views/cntnamesviewitem.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,72 @@ +/* +* 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 "cntnamesviewitem.h" +#include "cntdebug.h" + +#include +#include + +/*! +Constructor, initialize member variables. +*/ +CntNamesViewItem::CntNamesViewItem(QGraphicsItem* parent) : + HbListViewItem(parent) +{ + CNT_ENTRY + + setProperty("animationState", CNT_NAME_LIST_LAYOUT_PROPERTY_NORMAL); + HbEffect::add("nameslistitem", ":/effects/item_change_layout.fxml", "changed"); + + CNT_EXIT +} + + +/*! +Factory method to the items +*/ +HbAbstractViewItem* CntNamesViewItem::createItem() +{ + return new CntNamesViewItem(*this); +} + +/*! +Update the custom and standard parameters of this item identified by modelindex +*/ +void CntNamesViewItem::updateChildItems() +{ + CNT_ENTRY + + if (prototype()->property("animationState") == CNT_NAME_LIST_LAYOUT_PROPERTY_ANIMATE) + { + HbEffect::start(this, "nameslistitem", "changed"); + QTimer::singleShot(CNT_NAME_LIST_LAYOUT_CHANGED_TIMEOUT, this, SLOT(doUpdateChildItems())); + } + else + { + HbListViewItem::updateChildItems(); + } + + CNT_EXIT +} + +void CntNamesViewItem::doUpdateChildItems() +{ + HbListViewItem::updateChildItems(); +} + +// EOF diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntnamesviewitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/views/cntnamesviewitem.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,44 @@ +/* +* 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 CNTNAMESVIEWITEM_H +#define CNTNAMESVIEWITEM_H + +#include + +const int CNT_NAME_LIST_LAYOUT_CHANGED_TIMEOUT = 200; +const qreal CNT_NAME_LIST_LAYOUT_CHANGE_PINCH_IN_TRESHOLD = 0.6; +const qreal CNT_NAME_LIST_LAYOUT_CHANGE_PINCH_OUT_TRESHOLD = 1.4; +const QString CNT_NAME_LIST_LAYOUT_PROPERTY_ANIMATE = "animate"; +const QString CNT_NAME_LIST_LAYOUT_PROPERTY_NORMAL = "normal"; + +class CntNamesViewItem : public HbListViewItem +{ + friend class TestCntNamesView; + Q_OBJECT + +public: + CntNamesViewItem(QGraphicsItem* parent = NULL); + + HbAbstractViewItem* createItem(); + void updateChildItems(); + +private slots: + void doUpdateChildItems(); +}; + +#endif /* CNTNAMESVIEWITEM_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntpinchgrabber.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/views/cntpinchgrabber.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,111 @@ +/* +* 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 "cntpinchgrabber.h" +#include "cntnamesviewitem.h" + +#include +#include +#include +#include +#include +#include + +CntPinchGrabber::CntPinchGrabber(HbListView *parent) : + QObject(parent), + mSettingsKey(NULL), + mListView(parent), + mCurrentSetting(-1), + mUpdated(false) +{ + mSettingsKey = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, + KCRCntSettings.iUid, + KCntNameListRowSetting); +} + +CntPinchGrabber::~CntPinchGrabber() +{ + delete mSettingsKey; +} + +bool CntPinchGrabber::eventFilter(QObject *obj, QEvent *event) +{ + Q_UNUSED(obj) + + if (event->type() == QEvent::TouchBegin) + { + event->accept(); + return true; + } + + if (event->type() == QEvent::Gesture) + { + QGestureEvent *ge = static_cast(event); + + if (HbPinchGesture *pinch = qobject_cast(ge->gesture(Qt::PinchGesture))) + { + QPinchGesture::ChangeFlags changeFlags = pinch->changeFlags(); + + switch (pinch->state()) + { + case Qt::GestureStarted: + ge->accept(pinch); + mCurrentSetting = mSettings.readItemValue(*mSettingsKey, XQSettingsManager::TypeInt).toInt(); + mUpdated = false; + break; + case Qt::GestureUpdated: + if (changeFlags & QPinchGesture::ScaleFactorChanged && !mUpdated) + { + if (pinch->scaleFactor() < CNT_NAME_LIST_LAYOUT_CHANGE_PINCH_IN_TRESHOLD && mCurrentSetting != CntOneRowNameOnly) + { + mSettings.writeItemValue(*mSettingsKey, QVariant(CntOneRowNameOnly)); + mUpdated = true; + mListView->listItemPrototype()->setProperty("animationState", CNT_NAME_LIST_LAYOUT_PROPERTY_ANIMATE); + } + else if (pinch->scaleFactor() > CNT_NAME_LIST_LAYOUT_CHANGE_PINCH_OUT_TRESHOLD && mCurrentSetting != CntTwoRowsNameAndPhoneNumber) + { + mSettings.writeItemValue(*mSettingsKey, QVariant(CntTwoRowsNameAndPhoneNumber)); + mUpdated = true; + mListView->listItemPrototype()->setProperty("animationState", CNT_NAME_LIST_LAYOUT_PROPERTY_ANIMATE); + } + } + break; + case Qt::GestureFinished: + case Qt::GestureCanceled: + default: + mCurrentSetting = -1; + if (mUpdated) + { + mListView->ungrabGesture(Qt::PinchGesture); + QTimer::singleShot(CNT_NAME_LIST_LAYOUT_CHANGED_TIMEOUT, this, SLOT(timerTimeout())); + } + break; + } + + return true; + } + } + + return false; +} + +void CntPinchGrabber::timerTimeout() +{ + mListView->listItemPrototype()->setProperty("animationState", CNT_NAME_LIST_LAYOUT_PROPERTY_NORMAL); + mListView->grabGesture(Qt::PinchGesture); +} + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntpinchgrabber.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/views/cntpinchgrabber.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,51 @@ +/* +* 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 CNTPINCHGRABBER_H +#define CNTPINCHGRABBER_H + +#include + +#include + +class XQSettingsKey; +class HbListView; + +class CntPinchGrabber : public QObject +{ + friend class TestCntPinchGrabber; + Q_OBJECT + +public: + CntPinchGrabber(HbListView *parent = 0); + ~CntPinchGrabber(); + +protected: + bool eventFilter(QObject *obj, QEvent *event); + +private slots: + void timerTimeout(); + +private: + XQSettingsManager mSettings; + XQSettingsKey* mSettingsKey; + HbListView* mListView; + int mCurrentSetting; + bool mUpdated; +}; + +#endif /* CNTPINCHGRABBER_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntsettingsmodel.cpp --- a/phonebookui/cntcommonui/views/cntsettingsmodel.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntsettingsmodel.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -16,15 +16,21 @@ */ #include "cntsettingsmodel.h" -#include -#include -#include + #include "cntdebug.h" +#include +#include + +#include + +/*! +Constructor +*/ CntSettingsModel::CntSettingsModel() : -HbDataFormModel(), -mNameOrderkey(NULL), -mNameListRowSettingkey(NULL) + HbDataFormModel(), + mNameOrderkey(NULL), + mNameListRowSettingkey(NULL) { // Create name ordering setting item createNameOrderSettingsItem(); @@ -35,6 +41,18 @@ connect(this, SIGNAL(dataChanged(QModelIndex , QModelIndex)), this, SLOT(handleDataChanged(QModelIndex , QModelIndex))); } +/*! +Destructor +*/ +CntSettingsModel::~CntSettingsModel() +{ + delete mNameOrderkey; + delete mNameListRowSettingkey; +} + +/*! +Creates the name order settings item +*/ void CntSettingsModel::createNameOrderSettingsItem() { HbDataFormModelItem* ord = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, hbTrId( @@ -62,6 +80,9 @@ } } +/*! +Creates the names list row settings item +*/ void CntSettingsModel::createNamesListRowSettingItem() { HbDataFormModelItem* rowSetting = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, hbTrId( @@ -86,12 +107,9 @@ } } -CntSettingsModel::~CntSettingsModel() -{ - delete mNameOrderkey; - delete mNameListRowSettingkey; -} - +/*! +Handles data changes from settings items +*/ void CntSettingsModel::handleDataChanged(QModelIndex topLeft, QModelIndex bottomRight) { Q_UNUSED(bottomRight) @@ -105,9 +123,8 @@ written = mSettings.writeItemValue(*mNameOrderkey, QVariant(CntOrderLastCommaFirst)); } else if (selected == 2) { written = mSettings.writeItemValue(*mNameOrderkey, QVariant(CntOrderFirstLast)); - } - if (!written) { - CNT_LOG_ARGS(QString("failed writting cenrep key")) + } else { + written = false; } } else if (topLeft.row() == 1) { @@ -116,9 +133,12 @@ written = mSettings.writeItemValue(*mNameListRowSettingkey, QVariant(CntOneRowNameOnly)); } else if (selected == 1) { written = mSettings.writeItemValue(*mNameListRowSettingkey, QVariant(CntTwoRowsNameAndPhoneNumber)); - } - if (!written) { - CNT_LOG_ARGS(QString("failed writting cenrep key")) + } else { + written = false; } } + + if (!written) { + CNT_LOG_ARGS(QString("failed writting cenrep key")) + } } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntsettingsmodel.h --- a/phonebookui/cntcommonui/views/cntsettingsmodel.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntsettingsmodel.h Fri Oct 15 12:24:46 2010 +0300 @@ -30,6 +30,7 @@ class CntSettingsModel : public HbDataFormModel { Q_OBJECT + friend class TestCntSettingsModel; public: CntSettingsModel(); @@ -43,9 +44,9 @@ void handleDataChanged(QModelIndex topLeft, QModelIndex bottomRight); private: - XQSettingsManager mSettings; - XQSettingsKey *mNameOrderkey; - XQSettingsKey *mNameListRowSettingkey; + XQSettingsManager mSettings; + XQSettingsKey *mNameOrderkey; + XQSettingsKey *mNameListRowSettingkey; }; -#endif +#endif /* CNTSETTINGSMODEL_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntsettingsview.cpp --- a/phonebookui/cntcommonui/views/cntsettingsview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntsettingsview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -15,28 +15,34 @@ * */ +#include "cntsettingsview.h" +#include "cntsettingsmodel.h" +#include "cntdebug.h" + #include #include #include #include -#include "cntdebug.h" -#include "cntsettingsview.h" -#include "cntsettingsmodel.h" const char *CNT_SETTINGS_XML = ":/xml/contacts_settings.docml"; -CntSettingsView::CntSettingsView() : QObject(), -mView( NULL ), -mDoc( NULL ), -mForm( NULL ), -mViewMgr( NULL ), -mModel( NULL ) +/*! +Constructor +*/ +CntSettingsView::CntSettingsView() : + QObject(), + mView( NULL ), + mDoc( NULL ), + mForm( NULL ), + mViewMgr( NULL ), + mModel( NULL ) { CNT_ENTRY bool ok; document()->load(CNT_SETTINGS_XML, &ok); - if (!ok) { + if (!ok) + { qFatal("Unable to read %S", CNT_SETTINGS_XML); } @@ -48,11 +54,14 @@ mForm->setModel( mModel ); mBack = new HbAction(Hb::BackNaviAction, mView); - connect( mBack, SIGNAL(triggered()), this, SLOT(back()) ); + connect( mBack, SIGNAL(triggered()), this, SLOT(showPreviousView()) ); CNT_EXIT } +/*! +Destructor +*/ CntSettingsView::~CntSettingsView() { CNT_ENTRY @@ -65,6 +74,9 @@ CNT_EXIT } +/*! +Called when view is activated +*/ void CntSettingsView::activate( const CntViewParameters aArgs ) { CNT_ENTRY @@ -72,7 +84,8 @@ mArgs = aArgs; mViewMgr = &mEngine->viewManager(); - if ( mView->navigationAction() != mBack) { + if ( mView->navigationAction() != mBack) + { mView->setNavigationAction(mBack); } @@ -83,22 +96,10 @@ { } -bool CntSettingsView::isDefault() const -{ - return false; -} - -HbView* CntSettingsView::view() const -{ - return mView; -} - -int CntSettingsView::viewId() const -{ - return settingsView; -} - -void CntSettingsView::back() +/*! +Called when user presses back +*/ +void CntSettingsView::showPreviousView() { CNT_ENTRY @@ -106,6 +107,10 @@ CNT_EXIT } + +/*! +Returns the HbDocumentLoader pointer +*/ HbDocumentLoader* CntSettingsView::document() { CNT_ENTRY diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/views/cntsettingsview.h --- a/phonebookui/cntcommonui/views/cntsettingsview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/views/cntsettingsview.h Fri Oct 15 12:24:46 2010 +0300 @@ -14,8 +14,9 @@ * Description: * */ -#ifndef _CNTSETTINGSVIEW_H__ -#define _CNTSETTINGSVIEW_H__ + +#ifndef CNTSETTINGSVIEW_H +#define CNTSETTINGSVIEW_H #include #include @@ -32,6 +33,7 @@ class CntSettingsView : public QObject, public CntAbstractView { Q_OBJECT + friend class TestCntSettingsView; public: CntSettingsView(); @@ -40,29 +42,27 @@ protected: // From CntAbstractView void activate( const CntViewParameters aArgs ); void deactivate(); - bool isDefault() const; - HbView* view() const; - int viewId() const; + bool isDefault() const { return false; } + HbView* view() const { return mView; } + int viewId() const { return settingsView; } inline void setEngine( CntAbstractEngine& aEngine ){ mEngine = &aEngine; } private slots: - void back(); + void showPreviousView(); private: HbDocumentLoader* document(); private: - HbView* mView; - HbDocumentLoader* mDoc; - HbDataForm* mForm; - HbAction* mBack; - - CntAbstractViewManager* mViewMgr; - CntViewParameters mArgs; - - CntSettingsModel* mModel; - CntAbstractEngine* mEngine; - friend class TestCntSettings; + HbView *mView; + HbDocumentLoader *mDoc; + HbDataForm *mForm; + HbAction *mBack; + CntAbstractViewManager *mViewMgr; + CntViewParameters mArgs; + CntSettingsModel *mModel; + CntAbstractEngine *mEngine; + }; -#endif +#endif /* CNTSETTINGSVIEW_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/widgets/cntactionpopup.h --- a/phonebookui/cntcommonui/widgets/cntactionpopup.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/widgets/cntactionpopup.h Fri Oct 15 12:24:46 2010 +0300 @@ -56,6 +56,8 @@ CntActionPopupPrivate* const d_ptr; Q_DECLARE_PRIVATE_D(d_ptr, CntActionPopup) Q_DISABLE_COPY(CntActionPopup) + + friend class TestCntActionPopup; }; #endif // CNTACTIONPOPUP_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/widgets/cntactionpopup_p.cpp --- a/phonebookui/cntcommonui/widgets/cntactionpopup_p.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/widgets/cntactionpopup_p.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -24,10 +24,6 @@ #include #include #include -#include -//#include - - CntActionPopupPrivate::CntActionPopupPrivate( QContact* aContact, QGraphicsItem *parent ) : HbSelectionDialog(parent), @@ -194,16 +190,15 @@ mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); mListView->setFrictionEnabled(true); mListView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum ); + mListView->setLongPressEnabled(false);//This is to make longpress act like shortpress when no tap menu QString contactName = mContact->displayLabel(); if (contactName.isEmpty()) { contactName = hbTrId("txt_phob_list_unnamed"); } - HbLabel *label = new HbLabel(); - label->setPlainText(contactName); - setHeadingWidget(label); + setHeadingText(contactName); setContentWidget(mListView); mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"), this); @@ -212,10 +207,8 @@ setDismissPolicy(HbDialog::NoDismiss); setModal(true); - connect(mListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(listItemSelected(QModelIndex))); - connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,const QPointF&)), - this, SLOT(onLongPressed(HbAbstractViewItem*,const QPointF&)) ); - + connect(mListView, SIGNAL(activated (const QModelIndex &)), + this, SLOT(listItemSelected(QModelIndex)) ); //launch dialog asyncronously open(this, SLOT(handleUserResponse(HbAction*))); @@ -232,13 +225,6 @@ } -void CntActionPopupPrivate::onLongPressed(HbAbstractViewItem *item, const QPointF &coords) -{ - Q_UNUSED(coords); - QModelIndex index = item->modelIndex(); - listItemSelected(index); -} - void CntActionPopupPrivate::listItemSelected( QModelIndex index ) { if (index.isValid()) diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/widgets/cntactionpopup_p.h --- a/phonebookui/cntcommonui/widgets/cntactionpopup_p.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/widgets/cntactionpopup_p.h Fri Oct 15 12:24:46 2010 +0300 @@ -81,7 +81,6 @@ void listItemSelected( QModelIndex index ); void handleUserResponse(HbAction* action); - void onLongPressed (HbAbstractViewItem *item, const QPointF &coords); private: @@ -110,6 +109,6 @@ QList mDataItemList; HbAction *mCancelAction; - friend class T_CntActionPopupTest; + friend class TestCntActionPopup; }; #endif /* CNTACTIONPOPUP_P_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/widgets/cntfetchcontactpopup.cpp --- a/phonebookui/cntcommonui/widgets/cntfetchcontactpopup.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/widgets/cntfetchcontactpopup.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -161,22 +161,32 @@ HbListViewItem* prototype = mListView->listItemPrototype(); prototype->setTextFormat( Qt::RichText ); - qreal margin; + qreal screenMargin, popupMargin; HbStyle style; - style.parameter("hb-param-margin-gene-popup", margin); + style.parameter("hb-param-margin-gene-screen", screenMargin); + style.parameter("hb-param-margin-gene-popup", popupMargin); + + // screenMargin is the margin between the popup's top edge and the screen's top edge + qreal height = mVirtualKeyboard->activeViewRect().height() - + mSearch->size().height() - + screenMargin; - if (mPopup->mainWindow()->orientation() == Qt::Horizontal) - margin /= 2; - - qreal height = mPopup->size().height() - - mVirtualKeyboard->keyboardArea().height() - - mSearch->size().height() + - margin; - // in single selection we don't have the "mark all" option if ( mMarkAll->isVisible() ) { - height = height - mMarkAll->size().height(); + height -= mMarkAll->size().height(); + } + + // in landscape the headingwidget is not visible + if ( mPopup->headingWidget() != NULL ) + { + // 3 popup margin -> on top and below heading widget and between content and heading + height -= (mPopup->headingWidget()->size().height() + 3*popupMargin); + } + else + { + // 1 popup margin -> between content and "edge" of the popup + height -= popupMargin; } mEmptyView->setMaximumHeight( height ); @@ -412,6 +422,11 @@ { mPopup->setHeadingWidget( NULL ); mDoc->load( CNT_FETCHLIST_XML, "find_list_landscape"); + + //TODO: Remove when Wk40 is released + qreal popupWidth = mPopup->mainWindow()->layoutRect().width(); + mPopup->setMinimumWidth(popupWidth); + } else { @@ -434,6 +449,9 @@ { mPopup->setHeadingWidget( NULL ); mDoc->load( CNT_FETCHLIST_XML, "find_empty_landscape" ); + //TODO: Remove when Wk40 is released + qreal popupWidth = mPopup->mainWindow()->layoutRect().width(); + mPopup->setMinimumWidth(popupWidth); } else { diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/widgets/cntfetchcontactpopup.h --- a/phonebookui/cntcommonui/widgets/cntfetchcontactpopup.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/widgets/cntfetchcontactpopup.h Fri Oct 15 12:24:46 2010 +0300 @@ -101,6 +101,8 @@ CntDocumentLoader* mDoc; // own QString mTitle; QList mIds; + + friend class TestCntFetchUtility; }; #endif /* CNTFETCHCONTACTPOPUP_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/widgets/cntfetchselectionitems.cpp --- a/phonebookui/cntcommonui/widgets/cntfetchselectionitems.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* -* 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 "cntfetchselectionitems.h" - -#include - -#include -#include - - -CntFetchSelectionItems::CntFetchSelectionItems(QGraphicsItem *aParent) -: HbWidget(aParent), - mCheckBox(NULL), - mCounterLabel(NULL), - mLayout(NULL) -{ - if (!mLayout) { - mLayout = new QGraphicsLinearLayout(Qt::Horizontal); - } - - if (!mCheckBox) { - mCheckBox = new HbCheckBox(hbTrId("txt_common_list_mark_all_items")); - connect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(handleStateChange(int)), Qt::UniqueConnection); - mLayout->addItem(mCheckBox); - } - - if (!mCounterLabel) { - mCounterLabel = new HbLabel(); - mLayout->addItem(mCounterLabel); - } - - setLayout(mLayout); -} - -CntFetchSelectionItems::~CntFetchSelectionItems() -{ -} - -HbLabel* CntFetchSelectionItems::counter() const -{ - return mCounterLabel; -} - -void CntFetchSelectionItems::handleStateChange(int aState) -{ - emit passStateChanged(aState); -} - -// EOF diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/widgets/cntfetchselectionitems.h --- a/phonebookui/cntcommonui/widgets/cntfetchselectionitems.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* -* 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 CNTFETCHSELECTIONITEM_H -#define CNTFETCHSELECTIONITEM_H - -#include -#include - -class QGraphicsLinearLayout; -class HbCheckBox; -class HbLabel; - -/** - * Custom widget class for use with a HbPopup. - * This adds a "Mark All" checkbox and a selection counter. - */ -class CntFetchSelectionItems : public HbWidget -{ - Q_OBJECT - -public: - CntFetchSelectionItems(QGraphicsItem *aParent = 0); - ~CntFetchSelectionItems(); - - HbLabel* counter() const; - -signals: - void passStateChanged(int aState); - -public slots: - void handleStateChange(int aState); - -private: - friend class TestCntFetchSelectionItems; - - HbCheckBox* mCheckBox; - HbLabel* mCounterLabel; - QGraphicsLinearLayout* mLayout; // Ownership transferred to this class -}; - -#endif // CNTFETCHSELECTIONITEM_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntcommonui/widgets/cntimagelabel.h --- a/phonebookui/cntcommonui/widgets/cntimagelabel.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cntcommonui/widgets/cntimagelabel.h Fri Oct 15 12:24:46 2010 +0300 @@ -53,6 +53,9 @@ HbIconItem* mDefaultAvatar; HbIcon mIcon; QPixmap mPixmap; +#ifdef PBK_UNIT_TEST + friend class TestCntImageLabel; +#endif }; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/cnthistorymodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cnthistorymodel/cnthistorymodel.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,188 @@ +/* +* 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 "cnthistorymodel_p.h" +#include "cnthistorymodel.h" +#include "cntdebug.h" + +/*! + * Construct a new CntHistoryModel object to communicate + * with the conversations and logs databases. + * + * \param contactId History specific to this contact is cached. + * If no contact is specified all the call logs and conversation + * history from all contacts will be cached. + */ +CntHistoryModel::CntHistoryModel(QContactLocalId contactId, + QContactManager* manager, + QObject *parent) + : QAbstractListModel(parent), + d_ptr(new CntHistoryModelPrivate(contactId, manager)) +{ + CNT_ENTRY + + Q_D(CntHistoryModel); + d->q_ptr = this; + + CNT_EXIT +} + +CntHistoryModel::~CntHistoryModel() +{ + CNT_ENTRY + + Q_D(CntHistoryModel); + delete d; + + CNT_EXIT +} + +/*! + * Return the data to be used by the view or delegates for a particular + * item and role. + * + * \param index The index of the item to return data about. + * \param role The data should be relevant to this particular purpose. + * \return QVariant The data for the specified index and role. + */ +QVariant CntHistoryModel::data(const QModelIndex& index, int role) const +{ + Q_D(const CntHistoryModel); + return d->data(index, role); +} + +/*! + * Get the number of rows (conversations) in this model. + * + * \param parent Optional parent index value. + * \return Number of rows in this model. + */ +int CntHistoryModel::rowCount(const QModelIndex& parent) const +{ + Q_D(const CntHistoryModel); + return d->rowCount(parent); +} + +/*! + * Clear history from the database. If the history cached + * is specific to one contact, only that history is cleared. + * + */ +void CntHistoryModel::clearHistory() +{ + CNT_ENTRY + + Q_D(CntHistoryModel); + d->clearHistory(); + + CNT_EXIT +} + +/*! + * Mark all the conversations in the view as seen. + * + */ +void CntHistoryModel::markAllAsSeen() +{ + CNT_ENTRY + + Q_D(CntHistoryModel); + d->markAllAsSeen(); + + CNT_EXIT +} + +/*! + * Sort items in the model and refresh the view + * + * \param order Order to sort the list items. + */ +void CntHistoryModel::sortAndRefresh(Qt::SortOrder order) +{ + CNT_ENTRY_ARGS(order) + + Q_D(CntHistoryModel); + + doBeginResetModel(); + d->sort(order); + doEndResetModel(); + + CNT_EXIT +} + +void CntHistoryModel::doBeginInsertRows(const QModelIndex &parent, int first, int last) +{ + CNT_ENTRY_ARGS(parent << first << last) + + beginInsertRows(parent, first, last); + + CNT_EXIT +} + +void CntHistoryModel::doEndInsertRows() +{ + CNT_ENTRY + + endInsertRows(); + + CNT_EXIT +} + +void CntHistoryModel::doBeginRemoveRows(const QModelIndex &parent, int first, int last) +{ + CNT_ENTRY_ARGS(parent << first << last) + + beginRemoveRows(parent, first, last); + + CNT_EXIT +} + +void CntHistoryModel::doEndRemoveRows() +{ + CNT_ENTRY + + endRemoveRows(); + + CNT_EXIT +} + +void CntHistoryModel::doBeginResetModel() +{ + CNT_ENTRY + + beginResetModel(); + + CNT_EXIT +} + +void CntHistoryModel::doEndResetModel() +{ + CNT_ENTRY + + endResetModel(); + + CNT_EXIT +} + +void CntHistoryModel::doDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +{ + CNT_ENTRY_ARGS(topLeft << bottomRight) + + emit dataChanged(topLeft, bottomRight); + + CNT_EXIT +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/cnthistorymodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cnthistorymodel/cnthistorymodel.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,82 @@ +/* +* 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 CNTHISTORYMODEL_H +#define CNTHISTORYMODEL_H + +#include +#include +#include +#include + +#include "cnthistorymodelconsts.h" +#include "cnthistorymodelglobal.h" + +QTM_BEGIN_NAMESPACE +class QContactManager; +QTM_END_NAMESPACE + +QTM_USE_NAMESPACE + +class CntHistoryModelPrivate; + +/*! + * CntHistoryModel is a model used to fetch conversation history + * (SMS & call logs) from databases. It will + * cache content from the databases to be displayed on the screen + * by the conversation view. + * + * Note that that this is a prototype implementation and does + * not yet support more advanced features. + */ +class CNTHISTORYMODEL_EXPORT CntHistoryModel : public QAbstractListModel +{ + Q_OBJECT + +public: + CntHistoryModel(QContactLocalId contactId, + QContactManager* manager, + QObject *parent = 0); + ~CntHistoryModel(); + +public: // from QAbstractTableModel/QAbstractItemModel + QVariant data(const QModelIndex& index, int role) const; + int rowCount(const QModelIndex& parent = QModelIndex()) const; + +public: + void clearHistory(); + void markAllAsSeen(); + void sortAndRefresh(Qt::SortOrder order = Qt::AscendingOrder); + +private: + void doBeginInsertRows(const QModelIndex &parent, int first, int last); + void doEndInsertRows(); + void doBeginRemoveRows(const QModelIndex &parent, int first, int last); + void doEndRemoveRows(); + void doBeginResetModel(); + void doEndResetModel(); + void doDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + +private: + CntHistoryModelPrivate* const d_ptr; + Q_DECLARE_PRIVATE_D(d_ptr, CntHistoryModel) + Q_DISABLE_COPY(CntHistoryModel) + + // Testing related friend definitions + friend class TestCntHistoryModel; +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/cnthistorymodel.pro --- a/phonebookui/cnthistorymodel/cnthistorymodel.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cnthistorymodel/cnthistorymodel.pro Fri Oct 15 12:24:46 2010 +0300 @@ -23,8 +23,8 @@ TARGET = cnthistorymodel CONFIG += hb -DEFINES += dll \ - BUILD_CNTHISTORYMODEL +DEFINES += dll +DEFINES += BUILD_CNTHISTORYMODEL MOC_DIR = moc @@ -34,17 +34,16 @@ INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE INCLUDEPATH += ../../inc -INCLUDEPATH += inc HEADERS += \ - inc/cnthistorymodelglobal.h \ - inc/cnthistorymodelconsts.h \ - inc/cnthistorymodel.h \ - inc/cnthistorymodel_p.h + cnthistorymodelglobal.h \ + cnthistorymodelconsts.h \ + cnthistorymodel.h \ + cnthistorymodel_p.h SOURCES += \ - src/cnthistorymodel_p.cpp \ - src/cnthistorymodel.cpp + cnthistorymodel_p.cpp \ + cnthistorymodel.cpp LIBS += -llogsengine \ -lQtContacts \ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/cnthistorymodel_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cnthistorymodel/cnthistorymodel_p.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,850 @@ +/* +* 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 +#include +#include +#include +#include + +#include "cnthistorymodel_p.h" +#include "cntdebug.h" + + +// Unnamed namespace for helper functions +namespace +{ + bool greaterThan(const HItemPointer& t1, const HItemPointer& t2) + { + return ((*t1).timeStamp > (*t2).timeStamp); + } + + bool lessThan(const HItemPointer& t1, const HItemPointer& t2) + { + return ((*t1).timeStamp < (*t2).timeStamp); + } + +#ifdef TRACES +#define LOG_ITEM(i) logItem(i) + void logItem(const HistoryItem& item) + { + QStringList l; + + l << item.message << item.number << item.timeStamp.toString() << item.title; + l << (item.flags & CntIncoming ? "incoming" : "outgoing"); + l << (item.flags & CntUnseen ? "unseen" : "seen"); + l << (item.flags & CntAttachment ? "attachment" : ""); + l << (item.flags & CntCallLog ? "call" : "message"); + if (item.flags & CntReceivedCall) + l << "recieved"; + else if (item.flags & CntMissedCall) + l << "missed"; + else if (item.flags & CntDialledCall) + l << "dialled"; + + l.removeAll(""); + + qDebug() << l; + } +#else +#define LOG_ITEM(i) +#endif +} + +Q_DECLARE_METATYPE(LogsEvent *) + +/*! + * Construct a new CntHistoryModelPrivatePrivate object to communicate + * with the conversations and logs databases. + * + * \param contactId History specific to this contact is cached. + * If no contact is specified all the call logs and conversation + * history from all contacts will be cached. + */ +CntHistoryModelPrivate::CntHistoryModelPrivate(QContactLocalId contactId, QContactManager* manager) + : QObject(), + m_logsModel(NULL), + m_logsFilter(NULL), + m_AbstractLogsModel(NULL), + m_msgHistory(NULL), + m_contactId(contactId), + m_contactManager(manager), + m_isMyCard(false), + m_isMarkedAsSeen(false), + m_initLogs(false), + m_extendedLocale(HbExtendedLocale::system()) +{ + CNT_ENTRY + + // Create the model structure and cache history data from the databases + initializeModel(); + + CNT_EXIT +} + +CntHistoryModelPrivate::~CntHistoryModelPrivate() +{ + CNT_ENTRY + + delete m_logsModel; + delete m_logsFilter; + delete m_msgHistory; + + CNT_EXIT +} + +/*! + * Return the data to be used by the view or delegates for a particular + * item and role. + * + * \param index The index of the item to return data about. + * \param role The data should be relevant to this particular purpose. + * \return QVariant The data for the specified index and role. + */ +QVariant CntHistoryModelPrivate::data(const QModelIndex& index, int role) const +{ + CNT_ENTRY_ARGS(index << role) + // Invalid index + int row = index.row(); + + if ( !validateRowIndex(row) ) + return QVariant(); + + HItemPointer p = m_List.at(row); + if ( p.isNull() ) + return QVariant(); + + switch( role ) + { + case Qt::DisplayRole: + return displayRoleData(*p); + case Qt::DecorationRole: + return decorationRoleData(*p); + case Qt::BackgroundRole: + return backgroundRoleData(*p); + case CntFlagsRole: + return QVariant((*p).flags); + case CntPhoneNumberRole: + return QVariant((*p).number); + case CntConverstaionIdRole: + return conversationIdRoleData(row); + default: + return QVariant(); + } +} + +/*! + * Return the data to be used by the view for a display role. + * + * \param item The History item to return data about. + * return QVariant List of strings to be displayed on the view. + * The stings can also be NULL + * index 0 Title of the conversation item. + * index 1 Body text + * index 2 Time stamp + */ +QVariant CntHistoryModelPrivate::displayRoleData(const HistoryItem& item) const +{ + CNT_ENTRY + + QStringList list; + HbExtendedLocale locale = m_extendedLocale; + + if (item.timeStamp.date() == QDateTime::currentDateTime().date()) + { + list << item.title << item.message << locale.format(item.timeStamp.time(), r_qtn_time_usual); + } + else + { + list << item.title << item.message << locale.format(item.timeStamp.date(), r_qtn_date_usual); + } + + CNT_EXIT_ARGS(list) + + return QVariant(list); +} + +/*! + * Return the data to be used by the view for a decoration role. + * + * \param item The History item to return data about. + * return QVariant String of the icon path. + */ +QVariant CntHistoryModelPrivate::decorationRoleData(const HistoryItem& item) const +{ + CNT_ENTRY + + // Messages + if (item.flags & CntMessage) + return QVariant(HbIcon(MESSAGE_ICON)); + + // Call logs + if (item.flags & CntCallLog) { + if (item.flags & CntMissedCall) + return QVariant(HbIcon(MISSED_CALL_ICON)); + if (item.flags & CntDialledCall) + return QVariant(HbIcon(DAILED_CALL_ICON)); + if (item.flags & CntReceivedCall) + return QVariant(HbIcon(RECEIVED_CALL_ICON)); + } + + return QVariant(); +} + +/*! + * Return the data to be used to draw the background of list items + * + * \param item The History item to return data about. + * return QVariant HbFrameBackground of the list item. + */ +QVariant CntHistoryModelPrivate::backgroundRoleData(const HistoryItem& item) const +{ + if (item.flags & CntIncoming) + return QVariant(HbFrameBackground("qtg_fr_convlist_received_normal", HbFrameDrawer::NinePieces)); + else + return QVariant(HbFrameBackground("qtg_fr_convlist_sent_normal", HbFrameDrawer::NinePieces)); +} + +/*! + * Return the conversation id of this row if it is a message + * + * \param item The History item to return data about. + * return QVariant HbFrameBackground of the list item. + */ +QVariant CntHistoryModelPrivate::conversationIdRoleData(const int row) const +{ + HItemPointer p = m_List.at(row); + + int id(-1); + if ( p.data()->flags & CntMessage ) + id = m_msgMap.key(p, -1); + + if (id != -1) + return QVariant(id); + else + return QVariant(); +} + +/*! + * Get the number of rows (conversations) in this model. + * + * \param parent Optional parent index value. + * \return Number of rows in this model. + */ +int CntHistoryModelPrivate::rowCount(const QModelIndex& /*parent*/) const +{ + return m_List.size(); +} + +/*! + * Sort list items on the model. + * + * \param column Column to be sorted. It is not used. + * \param order Order to sort the list items. + */ +void CntHistoryModelPrivate::sort(int /*column*/, Qt::SortOrder order) +{ + CNT_ENTRY_ARGS(order) + + if ( order == Qt::AscendingOrder ) + qStableSort(m_List.begin(), m_List.end(), lessThan); + else + qStableSort(m_List.begin(), m_List.end(), greaterThan); + + CNT_EXIT +} + +/*! + * Clear history from the database. If the history cached + * is specific to one contact, only that history is cleared. + * + */ +void CntHistoryModelPrivate::clearHistory() +{ + CNT_ENTRY + + Q_Q(CntHistoryModel); + + if ( m_List.isEmpty() ) + return; + + // Clear all data from the history model. + int count = rowCount(); + + q->doBeginRemoveRows( QModelIndex(), 0, count ); + + // Call logs + if ( !m_isMyCard && m_logsFilter ) + m_logsFilter->clearEvents(); + else if ( m_logsModel ) + m_logsModel->clearList(LogsModel::TypeLogsClearAll); + + // Messages + if (m_msgHistory) + m_msgHistory->clearMessages( (int)m_contactId ); + + m_List.clear(); + m_msgMap.clear(); + m_logsMap.clear(); + + + q->doEndRemoveRows(); + + CNT_EXIT +} + +/*! + * Mark all the conversations in the view as seen. + * + */ +void CntHistoryModelPrivate::markAllAsSeen() +{ + CNT_ENTRY + + if ( m_isMarkedAsSeen ) + return; + + // Messages + if (m_msgHistory->markRead( m_contactId )) + m_isMarkedAsSeen = true; + + CNT_EXIT +} + +/*! + * Create the model structure and cache history data from + * conversations and call logs databases. + * + */ +void CntHistoryModelPrivate::initializeModel() +{ + CNT_ENTRY + + initializeLogsModel(); + initializeMsgModel(); + + CNT_EXIT +} + +void CntHistoryModelPrivate::initializeMsgModel() +{ + CNT_ENTRY + + if( m_isMyCard ) + return; + + // Contact centric + MsgHistory* m = new MsgHistory(); + + m_msgHistory = m; + + // Connect to signals emitted by msg model + connect(m, SIGNAL(messagesReady(QList& )), this, SLOT(messagesReady(QList& ))); + connect(m, SIGNAL(messageAdded(MsgItem& )), this, SLOT(messageAdded(MsgItem& ))); + connect(m, SIGNAL(messageChanged(MsgItem& )), this, SLOT(messageChanged(MsgItem& ))); + connect(m, SIGNAL(messageDeleted(MsgItem& )), this, SLOT(messageDeleted(MsgItem& ))); + + // Subscribe to get new messages + // received from this contact + m->subscribe(m_contactId); + + // Initial fetch of all messages + m->getMessages(m_contactId); + + CNT_EXIT +} + +void CntHistoryModelPrivate::initializeLogsModel() +{ + CNT_ENTRY + + //populate model with call events + m_logsModel = new LogsModel(LogsModel::LogsFullModel); + if (!m_isMyCard) { + //do the filtering to get call events for the target contact + m_logsFilter = new LogsCustomFilter; + m_logsFilter->setContactId(m_contactId); + m_logsFilter->setSourceModel(m_logsModel); + m_AbstractLogsModel = m_logsFilter; + } else { + //get all call events + m_AbstractLogsModel = m_logsModel; + } + + //read first call events if any and start listening for more + for ( int i = 0; i < m_AbstractLogsModel->rowCount(); ++i ) { + LogsEvent* event = qVariantValue( + m_AbstractLogsModel->data(m_AbstractLogsModel->index(i, 0), LogsModel::RoleFullEvent) ); + + if ( event ) { + HItemPointer item = HItemPointer(new HistoryItem()); + readLogEvent(event, *item); + m_logsMap.insert(i, item); + m_List.append( item ); + } + } + + connect(m_AbstractLogsModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), + this, SLOT(logsRowsInserted(const QModelIndex &, int, int))); + connect(m_AbstractLogsModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + this, SLOT(logsRowsRemoved(const QModelIndex &, int, int))); + connect(m_AbstractLogsModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), + this, SLOT(logsDataChanged(const QModelIndex &, const QModelIndex &))); + connect(m_AbstractLogsModel, SIGNAL(modelReset()), this, SLOT(handleLogsReset())); + + CNT_EXIT +} + +/*! + * Read call event into a history item + * + * \param event Call log event + * \param item Conversation history item + */ +void CntHistoryModelPrivate::readLogEvent(LogsEvent* event, HistoryItem& item) +{ + QString bodyText; + QString title; + + if ( m_isMyCard ) { + if ( event->remoteParty().length() > 0 ) { + title = QString(event->remoteParty()); + } + else { + title = QString(event->number()); + } + } else { + if ( event->direction() == LogsEvent::DirIn ) { + bodyText = hbTrId("txt_phob_list_received"); + item.flags |= CntReceivedCall; + } else if ( event->direction() == LogsEvent::DirOut ) { + bodyText = hbTrId("txt_phob_list_dialled_call"); + item.flags |= CntDialledCall; + } else if ( event->direction() == LogsEvent::DirMissed ) { + bodyText = hbTrId("txt_phob_list_missed_call"); + item.flags |= CntMissedCall; + } + } + + if ( event->direction() == LogsEvent::DirOut ) { + item.flags &= ~CntIncoming; + } else { + item.flags |= CntIncoming; + } + + item.message = bodyText; + item.title = title; + item.timeStamp = event->time().toLocalTime(); + item.flags |= CntCallLog; + item.number = QString(event->number()); + + LOG_ITEM(item); +} + +/*! + * Slot used for receiving new rows from the LogsModel. + * + * \param parent Optional parent index value. + * \param first The first row item to be received from the model. + * \param last The last row item to be received from the model. + */ +void CntHistoryModelPrivate::logsRowsInserted(const QModelIndex& /*parent*/, int first, int last) +{ + CNT_ENTRY_ARGS(first << last) + + Q_Q(CntHistoryModel); + + // Check if this is the first time to receive events + if ( !m_initLogs ) { + q->doBeginResetModel(); + } + else { + q->doBeginInsertRows( QModelIndex(), rowCount(), rowCount() + (last - first) ); + } + + QList l; + + for ( int i = first; i < m_AbstractLogsModel->rowCount() && i <= last; ++i ) { + LogsEvent* event = qVariantValue( + m_AbstractLogsModel->data(m_AbstractLogsModel->index(i, 0), LogsModel::RoleFullEvent) ); + + if ( event ) { + HItemPointer item(new HistoryItem()); + readLogEvent(event, *item); + m_logsMap.insert(i, item); + m_List.append( item ); + } + } + + // Check if this is the first time to receive events + // and sort the entire list. + if ( !m_initLogs ) { + sort(); + m_initLogs = true; + q->doEndResetModel(); + } + else { + q->doEndInsertRows(); + } + + CNT_EXIT +} + +/*! + * Slot used for receiving new rows from the LogsModel. + * + * \param parent Optional parent index value. + * \param first The first row item to be received from the model. + * \param last The last row item to be received from the model. + */ +void CntHistoryModelPrivate::logsRowsRemoved(const QModelIndex& /*parent*/, int first, int last) +{ + CNT_ENTRY_ARGS(first << last) + + Q_Q(CntHistoryModel); + + QList< int > indices; + + for ( int i = first; i <= last; ++i ) { + HItemPointer item = m_logsMap.value( i ); + int index = m_List.indexOf( item ); + if ( index > -1 ) { + m_logsMap.remove( i ); + indices.append( index ); + } + } + + foreach(int i, indices) { + m_List.removeAt( i ); + } + + // Remove list items in batches + if ( !indices.isEmpty() ) { + QList< QList > batches = findIndices(indices); + foreach( QList l, batches ) { + q->doBeginRemoveRows(QModelIndex(), l.first(), l.last()); + q->doEndRemoveRows(); + } + } + + CNT_EXIT +} + +/*! + * Update events from logs model. Events are + * received as a batch + * + * \param first First updated model index + * \param last Last updated model index + */ +void CntHistoryModelPrivate::logsDataChanged(const QModelIndex& first, const QModelIndex& last) +{ + CNT_ENTRY_ARGS(first << last) + + Q_Q(CntHistoryModel); + + int f = first.row(); + int l = last.row(); + QList< int > indices; + + for ( int i = f; i < m_AbstractLogsModel->rowCount() && i <= l; ++i ) { + + LogsEvent* event = qVariantValue( + m_AbstractLogsModel->data(m_AbstractLogsModel->index(i, 0), LogsModel::RoleFullEvent) ); + + // Fetch item from the mapped logs model items + HItemPointer item = m_logsMap.value( i ); + + // Found item in the logs map + if ( !item.isNull() && event ) { + int index = m_List.indexOf( item ); + readLogEvent( event, *item ); + indices.append( index ); + } + } + + // Emit dataChanged signal only if there were updates + if ( !indices.isEmpty() ) { + QList< QList > batches = findIndices( indices ); + foreach( QList l, batches ) + q->doDataChanged( q->index(l.first(), 0), q->index(l.last(), 0) ); + } + + CNT_EXIT +} + +/* + * Clear all call logs and refetches new call events after + * receiving a reset model signal from logs model + */ +void CntHistoryModelPrivate::handleLogsReset() +{ + CNT_ENTRY + + Q_Q(CntHistoryModel); + + q->doBeginResetModel(); + + // Remove all call logs + QList values = m_logsMap.values(); + foreach(HItemPointer p, values) { + m_List.removeOne( p ); + } + + m_logsMap.clear(); + + //read first call events if any and start listening for more + for ( int i = 0; i < m_AbstractLogsModel->rowCount(); ++i ) { + LogsEvent* event = qVariantValue( + m_AbstractLogsModel->data(m_AbstractLogsModel->index(i, 0), LogsModel::RoleFullEvent) ); + + if ( event ) { + HItemPointer item = HItemPointer(new HistoryItem()); + readLogEvent(event, *item); + m_logsMap.insert(i, item); + m_List.append( item ); + } + } + + sort(); + + q->doEndResetModel(); + + CNT_EXIT +} + +/*! + * Check whether an idex is out of bound of our list + * + * \param index Index to be validated + */ + +bool CntHistoryModelPrivate::validateRowIndex( const int index) const +{ + return( index < rowCount() && index >= 0 ); +} + +/*! + * Find the sequences of indices for the given indices from the private list + * + * \param indices List of indices + * \return sequences of indices + */ +QList< QList > CntHistoryModelPrivate::findIndices( const QList< int >& indices ) +{ + CNT_ENTRY_ARGS(indices) + + QList< QList > sequences; + QList currSequence; + int prevIndex = indices.at(0) - 1; + + foreach( int currIndex, indices ) + { + if ( currIndex >= 0 ) + { + if ( prevIndex+1 != currIndex && !currSequence.isEmpty() ) + { + sequences.append( currSequence ); + currSequence.clear(); + } + currSequence.append( currIndex ); + prevIndex = currIndex; + } + } + + if ( !currSequence.isEmpty() ) + { + // Add last sequence if such exist + sequences.append( currSequence ); + } + + CNT_EXIT_ARGS(sequences) + + return sequences; +} + +/*! + * Read message event into a history item + * + * \param event Message event + * \param item Conversation history item + */ +void CntHistoryModelPrivate::readMsgEvent(MsgItem& event, HistoryItem& item) +{ + CNT_ENTRY + + // Msg direction + if ( event.direction() == MsgItem::MsgDirectionIncoming ) { + item.flags |= CntIncoming; + // Read status + if ( event.isAttributeSet(MsgItem::MsgAttributeUnread) ) + item.flags |= CntUnseen; + else + item.flags &= ~CntUnseen; + } else if ( event.direction() == MsgItem::MsgDirectionOutgoing ) + item.flags &= ~CntIncoming; + + // Attachment + if (event.isAttributeSet(MsgItem::MsgAttributeAttachment)) + item.flags |= CntAttachment; + + item.flags |= CntMessage; + item.number = event.phoneNumber(); + + if (event.body().isEmpty()) + { + item.message = " "; + } + else + { + item.message = event.body(); + } + + item.timeStamp = event.timeStamp().toLocalTime(); + + LOG_ITEM(item); + + CNT_EXIT +} + +/*! + * Slot to receive new messages for the first time + * from the messages model + * + * \param event Message event + * \param item Conversation history item + */ +void CntHistoryModelPrivate::messagesReady(QList& msgs) +{ + CNT_ENTRY + + Q_Q(CntHistoryModel); + + q->doBeginResetModel(); + + foreach( MsgItem m, msgs ) { + // Create a new hst item + HItemPointer item(new HistoryItem()); + + // Parse the MsgItem and add data into hst item + readMsgEvent( m, *item ); + + // Map the hist item to a MsgItem in the msgModel + m_msgMap.insert( m.id(), item ); + + // Append the hst item to our list + m_List.append( item ); + } + + sort(); + + q->doEndResetModel(); + + CNT_EXIT +} + +/*! + * Slot to receive new messages from the messages model + * + * \param event Message event + * \param item Conversation history item + */ +void CntHistoryModelPrivate::messageAdded(MsgItem& msg) +{ + CNT_ENTRY + + Q_Q(CntHistoryModel); + + q->doBeginInsertRows( QModelIndex(), rowCount(), rowCount() ); + + // Create a new hst item + HItemPointer item(new HistoryItem()); + + // Parse the MsgItem and add data into hst item + readMsgEvent( msg, *item ); + + // Map the hist item to a MsgItem in the msgModel + m_msgMap.insert( msg.id(), item ); + + // Append the hst item to our list + m_List.append( item ); + + q->doEndInsertRows(); + + CNT_EXIT +} + +/*! + * Slot to update a message from the messages model + * + * \param event Message event + * \param item Conversation history item + */ +void CntHistoryModelPrivate::messageChanged(MsgItem& msg) +{ + CNT_ENTRY + + Q_Q(CntHistoryModel); + + // Fetch the hst item that maps to this MsgItem + HItemPointer p = m_msgMap.value( msg.id() ); + + // No item was found. + if ( p.isNull() ) + return; + + // Parse the MsgItem and add data into hst item + readMsgEvent(msg, *p); + + // Get the index of the the hst item in the list + int pIndex = m_List.indexOf( p ); + + q->doDataChanged(q->index(pIndex, 0), q->index(pIndex, 0)); + + CNT_EXIT +} + +/*! + * Slot to delete a message from the messages model + * + * \param event Message event + * \param item Conversation history item + */ +void CntHistoryModelPrivate::messageDeleted(MsgItem& msg) +{ + CNT_ENTRY + + Q_Q(CntHistoryModel); + + // Fetch the hst item that maps to this MsgItem + HItemPointer p = m_msgMap.value( msg.id() ); + + // No item was found. + if ( p.isNull() ) + return; + + // Remove the item in stored containers + m_msgMap.remove( msg.id() ); + int index = m_List.indexOf( p ); + if ( index > -1 ) { + q->doBeginRemoveRows(QModelIndex(), index, index); + m_List.removeAt( index ); + q->doEndRemoveRows(); + } + + CNT_EXIT +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/cnthistorymodel_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cnthistorymodel/cnthistorymodel_p.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,138 @@ +/* +* 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 CNTHISTORYMODELPRIVATE_H +#define CNTHISTORYMODELPRIVATE_H + +#include +#include +#include +#include +#include + +#ifdef PBK_UNIT_TEST +#include "stub_classes.h" +#else +#include +#include +#include +#endif +#include +#include +#include +#include "cnthistorymodel.h" +#include "cnthistorymodelconsts.h" + +QTM_USE_NAMESPACE + +class HistoryItem +{ +public: + HistoryItem() : flags(0) + {}; + + inline const HistoryItem& operator=(const HistoryItem& other) + { + flags = other.flags; + number = other.number; + title = other.title; + message = other.message; + timeStamp = other.timeStamp; + return *this; + } + + inline bool operator==(const HistoryItem& other) const + { + return timeStamp == other.timeStamp; + } + +public: + int flags; + QString number; + QString title; + QString message; + QDateTime timeStamp; +}; + +typedef QSharedPointer HItemPointer; + +class CntHistoryModelPrivate : public QObject +{ + Q_OBJECT + Q_DECLARE_PUBLIC(CntHistoryModel) + +public: + CntHistoryModelPrivate(QContactLocalId contactId, QContactManager* manager); + ~CntHistoryModelPrivate(); + +public: + QVariant data(const QModelIndex& index, int role) const; + int rowCount(const QModelIndex& parent = QModelIndex()) const; + void sort(int column = 0, Qt::SortOrder order = Qt::AscendingOrder); + void clearHistory(); + void markAllAsSeen(); + +public: + CntHistoryModel *q_ptr; + +public: + void initializeModel(); + QVariant displayRoleData(const HistoryItem& item) const; + QVariant decorationRoleData(const HistoryItem& item) const; + QVariant backgroundRoleData(const HistoryItem& item) const; + QVariant conversationIdRoleData(const int row) const; + + // Utility finctions + void readLogEvent(LogsEvent* event, HistoryItem& item); + void readMsgEvent(MsgItem& event, HistoryItem& item); + void initializeLogsModel(); + void initializeMsgModel(); + bool validateRowIndex(const int index) const; + QList< QList > findIndices( const QList< int >& indices ); + +public slots: + // Logs model slots + void logsRowsInserted(const QModelIndex& parent, int first, int last); + void logsRowsRemoved(const QModelIndex& parent, int first, int last); + void logsDataChanged(const QModelIndex& first, const QModelIndex& last); + void handleLogsReset(); + + // Messaging model slots + void messagesReady(QList& msgs); + void messageAdded(MsgItem& msg); + void messageChanged(MsgItem& msg); + void messageDeleted(MsgItem& msg); + +public: + LogsModel* m_logsModel; + LogsCustomFilter* m_logsFilter; + QAbstractItemModel* m_AbstractLogsModel; + MsgHistory* m_msgHistory; + QContactLocalId m_contactId; + QContactManager* m_contactManager; + bool m_isMyCard; + bool m_isMarkedAsSeen; + bool m_initLogs; + //this contains merged calls and messages history + QList m_List; + QMap m_logsMap; + QMap m_msgMap; + const HbExtendedLocale m_extendedLocale; +}; + +#endif + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/cnthistorymodelconsts.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cnthistorymodel/cnthistorymodelconsts.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,53 @@ +/* +* 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 CNTHISTORYMODELCONSTS_H +#define CNTHISTORYMODELCONSTS_H + +enum Attributes + { + CntIncoming = 1, + CntUnseen = 2, + CntAttachment = 4 + }; + +enum ItemType + { + CntCallLog = 32, + CntMessage = 64 + }; + +enum Icon + { + CntMissedCall = 128, + CntReceivedCall = 256, + CntDialledCall = 512 + }; + +enum CustomRoles + { + CntFlagsRole = Qt::UserRole + 1, + CntPhoneNumberRole, + CntConverstaionIdRole + }; + +// Constants +#define MISSED_CALL_ICON "qtg_small_missed_call" +#define DAILED_CALL_ICON "qtg_small_sent" +#define RECEIVED_CALL_ICON "qtg_small_received" +#define MESSAGE_ICON "qtg_small_message" + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/cnthistorymodelglobal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cnthistorymodel/cnthistorymodelglobal.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,33 @@ +/* +* 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 CNTHISTORYMODELGLOBAL_H +#define CNTHISTORYMODELGLOBAL_H + +#include +#include +#include +#include + +#ifdef CNTHISTORYMODEL_NO_EXPORT +#define CNTHISTORYMODEL_EXPORT +#elif BUILD_CNTHISTORYMODEL +#define CNTHISTORYMODEL_EXPORT Q_DECL_EXPORT +#else +#define CNTHISTORYMODEL_EXPORT Q_DECL_IMPORT +#endif + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/inc/cnthistorymodel.h --- a/phonebookui/cnthistorymodel/inc/cnthistorymodel.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* -* 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 CNTHISTORYMODEL_H -#define CNTHISTORYMODEL_H - -#include -#include -#include -#include -#include "cntglobal.h" - -#include "cnthistorymodelconsts.h" -#include "cnthistorymodelglobal.h" - -QTM_BEGIN_NAMESPACE -class QContactManager; -QTM_END_NAMESPACE - -QTM_USE_NAMESPACE - -class CntHistoryModelPrivate; - -/*! - * CntHistoryModel is a model used to fetch conversation history - * (SMS & call logs) from databases. It will - * cache content from the databases to be displayed on the screen - * by the conversation view. - * - * Note that that this is a prototype implementation and does - * not yet support more advanced features. - */ -class CNTHISTORYMODEL_EXPORT CntHistoryModel : public QAbstractListModel -{ - Q_OBJECT - -public: - CntHistoryModel(QContactLocalId contactId, - QContactManager* manager, - QObject *parent = 0); - ~CntHistoryModel(); - -public: // from QAbstractTableModel/QAbstractItemModel - QVariant data(const QModelIndex& index, int role) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; - -public: - void clearHistory(); - void markAllAsSeen(); - void sortAndRefresh(Qt::SortOrder order = Qt::AscendingOrder); - -private: - void doBeginInsertRows(const QModelIndex &parent, int first, int last); - void doEndInsertRows(); - void doBeginRemoveRows(const QModelIndex &parent, int first, int last); - void doEndRemoveRows(); - void doBeginResetModel(); - void doEndResetModel(); - void doDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); - -private: - CntHistoryModelPrivate* const d_ptr; - Q_DECLARE_PRIVATE_D(d_ptr, CntHistoryModel) - Q_DISABLE_COPY(CntHistoryModel) - - // Testing related friend definitions - friend class TestCntHistoryModel; -}; - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/inc/cnthistorymodel_p.h --- a/phonebookui/cnthistorymodel/inc/cnthistorymodel_p.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ -/* -* 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 CNTHISTORYMODELPRIVATE_H -#define CNTHISTORYMODELPRIVATE_H - -#include -#include -#include -#include -#include - -#ifdef PBK_UNIT_TEST -#include "stub_classes.h" -#else -#include -#include -#include -#endif -#include -#include -#include -#include "cnthistorymodel.h" -#include "cnthistorymodelconsts.h" - -QTM_USE_NAMESPACE - -class HistoryItem -{ -public: - HistoryItem() : flags(0) - {}; - - inline const HistoryItem& operator=(const HistoryItem& other) - { - flags = other.flags; - number = other.number; - title = other.title; - message = other.message; - timeStamp = other.timeStamp; - return *this; - } - - inline bool operator==(const HistoryItem& other) const - { - return timeStamp == other.timeStamp; - } - -public: - int flags; - QString number; - QString title; - QString message; - QDateTime timeStamp; -}; - -typedef QSharedPointer HItemPointer; - -class CntHistoryModelPrivate : public QObject -{ - Q_OBJECT - Q_DECLARE_PUBLIC(CntHistoryModel) - -public: - CntHistoryModelPrivate(QContactLocalId contactId, QContactManager* manager); - ~CntHistoryModelPrivate(); - -public: - QVariant data(const QModelIndex& index, int role) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; - void sort(int column = 0, Qt::SortOrder order = Qt::AscendingOrder); - void clearHistory(); - void markAllAsSeen(); - -public: - CntHistoryModel *q_ptr; - -public: - void initializeModel(); - QVariant displayRoleData(const HistoryItem& item) const; - QVariant decorationRoleData(const HistoryItem& item) const; - QVariant backgroundRoleData(const HistoryItem& item) const; - QVariant conversationIdRoleData(const int row) const; - - // Utility finctions - void readLogEvent(LogsEvent* event, HistoryItem& item); - void readMsgEvent(MsgItem& event, HistoryItem& item); - void initializeLogsModel(); - void initializeMsgModel(); - bool validateRowIndex(const int index) const; - QList< QList > findIndices( const QList< int >& indices ); - -public slots: - // Logs model slots - void logsRowsInserted(const QModelIndex& parent, int first, int last); - void logsRowsRemoved(const QModelIndex& parent, int first, int last); - void logsDataChanged(const QModelIndex& first, const QModelIndex& last); - void handleLogsReset(); - - // Messaging model slots - void messagesReady(QList& msgs); - void messageAdded(MsgItem& msg); - void messageChanged(MsgItem& msg); - void messageDeleted(MsgItem& msg); - -public: - LogsModel* m_logsModel; - LogsCustomFilter* m_logsFilter; - QAbstractItemModel* m_AbstractLogsModel; - MsgHistory* m_msgHistory; - QContactLocalId m_contactId; - QContactManager* m_contactManager; - bool m_isMyCard; - bool m_isMarkedAsSeen; - bool m_initLogs; - //this contains merged calls and messages history - QList m_List; - QMap m_logsMap; - QMap m_msgMap; - const HbExtendedLocale m_extendedLocale; -}; - -#endif - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/inc/cnthistorymodelconsts.h --- a/phonebookui/cnthistorymodel/inc/cnthistorymodelconsts.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* -* 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 CNTHISTORYMODELCONSTS_H -#define CNTHISTORYMODELCONSTS_H - -enum Attributes - { - CntIncoming = 1, - CntUnseen = 2, - CntAttachment = 4 - }; - -enum ItemType - { - CntCallLog = 32, - CntMessage = 64 - }; - -enum Icon - { - CntMissedCall = 128, - CntReceivedCall = 256, - CntDialledCall = 512 - }; - -enum CustomRoles - { - CntFlagsRole = Qt::UserRole + 1, - CntPhoneNumberRole, - CntConverstaionIdRole - }; - -// Constants -#define MISSED_CALL_ICON "qtg_small_missed_call" -#define DAILED_CALL_ICON "qtg_small_sent" -#define RECEIVED_CALL_ICON "qtg_small_received" -#define MESSAGE_ICON "qtg_small_message" - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/inc/cnthistorymodelglobal.h --- a/phonebookui/cnthistorymodel/inc/cnthistorymodelglobal.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* -* 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 CNTHISTORYMODELGLOBAL_H -#define CNTHISTORYMODELGLOBAL_H - -#include -#include -#include -#include - -#ifdef CNTHISTORYMODEL_NO_EXPORT -#define CNTHISTORYMODEL_EXPORT -#elif BUILD_CNTHISTORYMODEL -#define CNTHISTORYMODEL_EXPORT Q_DECL_EXPORT -#else -#define CNTHISTORYMODEL_EXPORT Q_DECL_IMPORT -#endif - -#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/src/cnthistorymodel.cpp --- a/phonebookui/cnthistorymodel/src/cnthistorymodel.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,188 +0,0 @@ -/* -* 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 "cnthistorymodel_p.h" -#include "cnthistorymodel.h" -#include "cntdebug.h" - -/*! - * Construct a new CntHistoryModel object to communicate - * with the conversations and logs databases. - * - * \param contactId History specific to this contact is cached. - * If no contact is specified all the call logs and conversation - * history from all contacts will be cached. - */ -CntHistoryModel::CntHistoryModel(QContactLocalId contactId, - QContactManager* manager, - QObject *parent) - : QAbstractListModel(parent), - d_ptr(new CntHistoryModelPrivate(contactId, manager)) -{ - CNT_ENTRY - - Q_D(CntHistoryModel); - d->q_ptr = this; - - CNT_EXIT -} - -CntHistoryModel::~CntHistoryModel() -{ - CNT_ENTRY - - Q_D(CntHistoryModel); - delete d; - - CNT_EXIT -} - -/*! - * Return the data to be used by the view or delegates for a particular - * item and role. - * - * \param index The index of the item to return data about. - * \param role The data should be relevant to this particular purpose. - * \return QVariant The data for the specified index and role. - */ -QVariant CntHistoryModel::data(const QModelIndex& index, int role) const -{ - Q_D(const CntHistoryModel); - return d->data(index, role); -} - -/*! - * Get the number of rows (conversations) in this model. - * - * \param parent Optional parent index value. - * \return Number of rows in this model. - */ -int CntHistoryModel::rowCount(const QModelIndex& parent) const -{ - Q_D(const CntHistoryModel); - return d->rowCount(parent); -} - -/*! - * Clear history from the database. If the history cached - * is specific to one contact, only that history is cleared. - * - */ -void CntHistoryModel::clearHistory() -{ - CNT_ENTRY - - Q_D(CntHistoryModel); - d->clearHistory(); - - CNT_EXIT -} - -/*! - * Mark all the conversations in the view as seen. - * - */ -void CntHistoryModel::markAllAsSeen() -{ - CNT_ENTRY - - Q_D(CntHistoryModel); - d->markAllAsSeen(); - - CNT_EXIT -} - -/*! - * Sort items in the model and refresh the view - * - * \param order Order to sort the list items. - */ -void CntHistoryModel::sortAndRefresh(Qt::SortOrder order) -{ - CNT_ENTRY_ARGS(order) - - Q_D(CntHistoryModel); - - doBeginResetModel(); - d->sort(order); - doEndResetModel(); - - CNT_EXIT -} - -void CntHistoryModel::doBeginInsertRows(const QModelIndex &parent, int first, int last) -{ - CNT_ENTRY_ARGS(parent << first << last) - - beginInsertRows(parent, first, last); - - CNT_EXIT -} - -void CntHistoryModel::doEndInsertRows() -{ - CNT_ENTRY - - endInsertRows(); - - CNT_EXIT -} - -void CntHistoryModel::doBeginRemoveRows(const QModelIndex &parent, int first, int last) -{ - CNT_ENTRY_ARGS(parent << first << last) - - beginRemoveRows(parent, first, last); - - CNT_EXIT -} - -void CntHistoryModel::doEndRemoveRows() -{ - CNT_ENTRY - - endRemoveRows(); - - CNT_EXIT -} - -void CntHistoryModel::doBeginResetModel() -{ - CNT_ENTRY - - beginResetModel(); - - CNT_EXIT -} - -void CntHistoryModel::doEndResetModel() -{ - CNT_ENTRY - - endResetModel(); - - CNT_EXIT -} - -void CntHistoryModel::doDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) -{ - CNT_ENTRY_ARGS(topLeft << bottomRight) - - emit dataChanged(topLeft, bottomRight); - - CNT_EXIT -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/src/cnthistorymodel_p.cpp --- a/phonebookui/cnthistorymodel/src/cnthistorymodel_p.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,860 +0,0 @@ -/* -* 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 -#include -#include -#include -#include - -#include "cnthistorymodel_p.h" -#include "cntdebug.h" - - -// Unnamed namespace for helper functions -namespace -{ - bool greaterThan(const HItemPointer& t1, const HItemPointer& t2) - { - return ((*t1).timeStamp > (*t2).timeStamp); - } - - bool lessThan(const HItemPointer& t1, const HItemPointer& t2) - { - return ((*t1).timeStamp < (*t2).timeStamp); - } - -#ifdef TRACES -#define LOG_ITEM(i) logItem(i) - void logItem(const HistoryItem& item) - { - QStringList l; - - l << item.message << item.number << item.timeStamp.toString() << item.title; - l << (item.flags & CntIncoming ? "incoming" : "outgoing"); - l << (item.flags & CntUnseen ? "unseen" : "seen"); - l << (item.flags & CntAttachment ? "attachment" : ""); - l << (item.flags & CntCallLog ? "call" : "message"); - if (item.flags & CntReceivedCall) - l << "recieved"; - else if (item.flags & CntMissedCall) - l << "missed"; - else if (item.flags & CntDialledCall) - l << "dialled"; - - l.removeAll(""); - - qDebug() << l; - } -#else -#define LOG_ITEM(i) -#endif -} - -Q_DECLARE_METATYPE(LogsEvent *) - -/*! - * Construct a new CntHistoryModelPrivatePrivate object to communicate - * with the conversations and logs databases. - * - * \param contactId History specific to this contact is cached. - * If no contact is specified all the call logs and conversation - * history from all contacts will be cached. - */ -CntHistoryModelPrivate::CntHistoryModelPrivate(QContactLocalId contactId, QContactManager* manager) - : QObject(), - m_logsModel(NULL), - m_logsFilter(NULL), - m_AbstractLogsModel(NULL), - m_msgHistory(NULL), - m_contactId(contactId), - m_contactManager(manager), - m_isMyCard(false), - m_isMarkedAsSeen(false), - m_initLogs(false), - m_extendedLocale(HbExtendedLocale::system()) -{ - CNT_ENTRY - - // Create the model structure and cache history data from the databases - initializeModel(); - - CNT_EXIT -} - -CntHistoryModelPrivate::~CntHistoryModelPrivate() -{ - CNT_ENTRY - - if (m_logsModel) { - delete m_logsModel; - m_logsModel = NULL; - } - if (m_logsFilter) { - delete m_logsFilter; - m_logsFilter = NULL; - } - if (m_msgHistory) { - delete m_msgHistory; - m_msgHistory = NULL; - } - - CNT_EXIT -} - -/*! - * Return the data to be used by the view or delegates for a particular - * item and role. - * - * \param index The index of the item to return data about. - * \param role The data should be relevant to this particular purpose. - * \return QVariant The data for the specified index and role. - */ -QVariant CntHistoryModelPrivate::data(const QModelIndex& index, int role) const -{ - CNT_ENTRY_ARGS(index << role) - // Invalid index - int row = index.row(); - - if ( !validateRowIndex(row) ) - return QVariant(); - - HItemPointer p = m_List.at(row); - if ( p.isNull() ) - return QVariant(); - - switch( role ) - { - case Qt::DisplayRole: - return displayRoleData(*p); - case Qt::DecorationRole: - return decorationRoleData(*p); - case Qt::BackgroundRole: - return backgroundRoleData(*p); - case CntFlagsRole: - return QVariant((*p).flags); - case CntPhoneNumberRole: - return QVariant((*p).number); - case CntConverstaionIdRole: - return conversationIdRoleData(row); - default: - return QVariant(); - } -} - -/*! - * Return the data to be used by the view for a display role. - * - * \param item The History item to return data about. - * return QVariant List of strings to be displayed on the view. - * The stings can also be NULL - * index 0 Title of the conversation item. - * index 1 Body text - * index 2 Time stamp - */ -QVariant CntHistoryModelPrivate::displayRoleData(const HistoryItem& item) const -{ - CNT_ENTRY - - QStringList list; - HbExtendedLocale locale = m_extendedLocale; - - if (item.timeStamp.date() == QDateTime::currentDateTime().date()) - { - list << item.title << item.message << locale.format(item.timeStamp.time(), r_qtn_time_usual); - } - else - { - list << item.title << item.message << locale.format(item.timeStamp.date(), r_qtn_date_usual); - } - - CNT_EXIT_ARGS(list) - - return QVariant(list); -} - -/*! - * Return the data to be used by the view for a decoration role. - * - * \param item The History item to return data about. - * return QVariant String of the icon path. - */ -QVariant CntHistoryModelPrivate::decorationRoleData(const HistoryItem& item) const -{ - CNT_ENTRY - - // Messages - if (item.flags & CntMessage) - return QVariant(HbIcon(MESSAGE_ICON)); - - // Call logs - if (item.flags & CntCallLog) { - if (item.flags & CntMissedCall) - return QVariant(HbIcon(MISSED_CALL_ICON)); - if (item.flags & CntDialledCall) - return QVariant(HbIcon(DAILED_CALL_ICON)); - if (item.flags & CntReceivedCall) - return QVariant(HbIcon(RECEIVED_CALL_ICON)); - } - - return QVariant(); -} - -/*! - * Return the data to be used to draw the background of list items - * - * \param item The History item to return data about. - * return QVariant HbFrameBackground of the list item. - */ -QVariant CntHistoryModelPrivate::backgroundRoleData(const HistoryItem& item) const -{ - if (item.flags & CntIncoming) - return QVariant(HbFrameBackground("qtg_fr_convlist_received_normal", HbFrameDrawer::NinePieces)); - else - return QVariant(HbFrameBackground("qtg_fr_convlist_sent_normal", HbFrameDrawer::NinePieces)); -} - -/*! - * Return the conversation id of this row if it is a message - * - * \param item The History item to return data about. - * return QVariant HbFrameBackground of the list item. - */ -QVariant CntHistoryModelPrivate::conversationIdRoleData(const int row) const -{ - HItemPointer p = m_List.at(row); - - int id(-1); - if ( p.data()->flags & CntMessage ) - id = m_msgMap.key(p, -1); - - if (id != -1) - return QVariant(id); - else - return QVariant(); -} - -/*! - * Get the number of rows (conversations) in this model. - * - * \param parent Optional parent index value. - * \return Number of rows in this model. - */ -int CntHistoryModelPrivate::rowCount(const QModelIndex& /*parent*/) const -{ - return m_List.size(); -} - -/*! - * Sort list items on the model. - * - * \param column Column to be sorted. It is not used. - * \param order Order to sort the list items. - */ -void CntHistoryModelPrivate::sort(int /*column*/, Qt::SortOrder order) -{ - CNT_ENTRY_ARGS(order) - - if ( order == Qt::AscendingOrder ) - qStableSort(m_List.begin(), m_List.end(), lessThan); - else - qStableSort(m_List.begin(), m_List.end(), greaterThan); - - CNT_EXIT -} - -/*! - * Clear history from the database. If the history cached - * is specific to one contact, only that history is cleared. - * - */ -void CntHistoryModelPrivate::clearHistory() -{ - CNT_ENTRY - - Q_Q(CntHistoryModel); - - if ( m_List.isEmpty() ) - return; - - // Clear all data from the history model. - int count = rowCount(); - - q->doBeginRemoveRows( QModelIndex(), 0, count ); - - // Call logs - if ( !m_isMyCard && m_logsFilter ) - m_logsFilter->clearEvents(); - else if ( m_logsModel ) - m_logsModel->clearList(LogsModel::TypeLogsClearAll); - - // Messages - if (m_msgHistory) - m_msgHistory->clearMessages( (int)m_contactId ); - - m_List.clear(); - m_msgMap.clear(); - m_logsMap.clear(); - - - q->doEndRemoveRows(); - - CNT_EXIT -} - -/*! - * Mark all the conversations in the view as seen. - * - */ -void CntHistoryModelPrivate::markAllAsSeen() -{ - CNT_ENTRY - - if ( m_isMarkedAsSeen ) - return; - - // Messages - if (m_msgHistory->markRead( m_contactId )) - m_isMarkedAsSeen = true; - - CNT_EXIT -} - -/*! - * Create the model structure and cache history data from - * conversations and call logs databases. - * - */ -void CntHistoryModelPrivate::initializeModel() -{ - CNT_ENTRY - - initializeLogsModel(); - initializeMsgModel(); - - CNT_EXIT -} - -void CntHistoryModelPrivate::initializeMsgModel() -{ - CNT_ENTRY - - if( m_isMyCard ) - return; - - // Contact centric - MsgHistory* m = new MsgHistory(); - - m_msgHistory = m; - - // Connect to signals emitted by msg model - connect(m, SIGNAL(messagesReady(QList& )), this, SLOT(messagesReady(QList& ))); - connect(m, SIGNAL(messageAdded(MsgItem& )), this, SLOT(messageAdded(MsgItem& ))); - connect(m, SIGNAL(messageChanged(MsgItem& )), this, SLOT(messageChanged(MsgItem& ))); - connect(m, SIGNAL(messageDeleted(MsgItem& )), this, SLOT(messageDeleted(MsgItem& ))); - - // Subscribe to get new messages - // received from this contact - m->subscribe(m_contactId); - - // Initial fetch of all messages - m->getMessages(m_contactId); - - CNT_EXIT -} - -void CntHistoryModelPrivate::initializeLogsModel() -{ - CNT_ENTRY - - //populate model with call events - m_logsModel = new LogsModel(LogsModel::LogsFullModel); - if (!m_isMyCard) { - //do the filtering to get call events for the target contact - m_logsFilter = new LogsCustomFilter; - m_logsFilter->setContactId(m_contactId); - m_logsFilter->setSourceModel(m_logsModel); - m_AbstractLogsModel = m_logsFilter; - } else { - //get all call events - m_AbstractLogsModel = m_logsModel; - } - - //read first call events if any and start listening for more - for ( int i = 0; i < m_AbstractLogsModel->rowCount(); ++i ) { - LogsEvent* event = qVariantValue( - m_AbstractLogsModel->data(m_AbstractLogsModel->index(i, 0), LogsModel::RoleFullEvent) ); - - if ( event ) { - HItemPointer item = HItemPointer(new HistoryItem()); - readLogEvent(event, *item); - m_logsMap.insert(i, item); - m_List.append( item ); - } - } - - connect(m_AbstractLogsModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), - this, SLOT(logsRowsInserted(const QModelIndex &, int, int))); - connect(m_AbstractLogsModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(logsRowsRemoved(const QModelIndex &, int, int))); - connect(m_AbstractLogsModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), - this, SLOT(logsDataChanged(const QModelIndex &, const QModelIndex &))); - connect(m_AbstractLogsModel, SIGNAL(modelReset()), this, SLOT(handleLogsReset())); - - CNT_EXIT -} - -/*! - * Read call event into a history item - * - * \param event Call log event - * \param item Conversation history item - */ -void CntHistoryModelPrivate::readLogEvent(LogsEvent* event, HistoryItem& item) -{ - QString bodyText; - QString title; - - if ( m_isMyCard ) { - if ( event->remoteParty().length() > 0 ) { - title = QString(event->remoteParty()); - } - else { - title = QString(event->number()); - } - } else { - if ( event->direction() == LogsEvent::DirIn ) { - bodyText = hbTrId("txt_phob_list_received"); - item.flags |= CntReceivedCall; - } else if ( event->direction() == LogsEvent::DirOut ) { - bodyText = hbTrId("txt_phob_list_dialled_call"); - item.flags |= CntDialledCall; - } else if ( event->direction() == LogsEvent::DirMissed ) { - bodyText = hbTrId("txt_phob_list_missed_call"); - item.flags |= CntMissedCall; - } - } - - if ( event->direction() == LogsEvent::DirMissed - || event->direction() == LogsEvent::DirIn ) { - item.flags |= CntIncoming; - } else { - item.flags &= ~CntIncoming; - } - - item.message = bodyText; - item.title = title; - item.timeStamp = event->time().toLocalTime(); - item.flags |= CntCallLog; - item.number = QString(event->number()); - - LOG_ITEM(item); -} - -/*! - * Slot used for receiving new rows from the LogsModel. - * - * \param parent Optional parent index value. - * \param first The first row item to be received from the model. - * \param last The last row item to be received from the model. - */ -void CntHistoryModelPrivate::logsRowsInserted(const QModelIndex& /*parent*/, int first, int last) -{ - CNT_ENTRY_ARGS(first << last) - - Q_Q(CntHistoryModel); - - // Check if this is the first time to receive events - if ( !m_initLogs ) { - q->doBeginResetModel(); - } - else { - q->doBeginInsertRows( QModelIndex(), rowCount(), rowCount() + (last - first) ); - } - - QList l; - - for ( int i = first; i < m_AbstractLogsModel->rowCount() && i <= last; ++i ) { - LogsEvent* event = qVariantValue( - m_AbstractLogsModel->data(m_AbstractLogsModel->index(i, 0), LogsModel::RoleFullEvent) ); - - if ( event ) { - HItemPointer item(new HistoryItem()); - readLogEvent(event, *item); - m_logsMap.insert(i, item); - m_List.append( item ); - } - } - - // Check if this is the first time to receive events - // and sort the entire list. - if ( !m_initLogs ) { - sort(); - m_initLogs = true; - q->doEndResetModel(); - } - else { - q->doEndInsertRows(); - } - - CNT_EXIT -} - -/*! - * Slot used for receiving new rows from the LogsModel. - * - * \param parent Optional parent index value. - * \param first The first row item to be received from the model. - * \param last The last row item to be received from the model. - */ -void CntHistoryModelPrivate::logsRowsRemoved(const QModelIndex& /*parent*/, int first, int last) -{ - CNT_ENTRY_ARGS(first << last) - - Q_Q(CntHistoryModel); - - QList< int > indices; - - for ( int i = first; i <= last; ++i ) { - HItemPointer item = m_logsMap.value( i ); - int index = m_List.indexOf( item ); - if ( index > -1 ) { - m_logsMap.remove( i ); - indices.append( index ); - } - } - - foreach(int i, indices) { - m_List.removeAt( i ); - } - - // Remove list items in batches - if ( !indices.isEmpty() ) { - QList< QList > batches = findIndices(indices); - foreach( QList l, batches ) { - q->doBeginRemoveRows(QModelIndex(), l.first(), l.last()); - q->doEndRemoveRows(); - } - } - - CNT_EXIT -} - -/*! - * Update events from logs model. Events are - * received as a batch - * - * \param first First updated model index - * \param last Last updated model index - */ -void CntHistoryModelPrivate::logsDataChanged(const QModelIndex& first, const QModelIndex& last) -{ - CNT_ENTRY_ARGS(first << last) - - Q_Q(CntHistoryModel); - - int f = first.row(); - int l = last.row(); - QList< int > indices; - - for ( int i = f; i < m_AbstractLogsModel->rowCount() && i <= l; ++i ) { - - LogsEvent* event = qVariantValue( - m_AbstractLogsModel->data(m_AbstractLogsModel->index(i, 0), LogsModel::RoleFullEvent) ); - - // Fetch item from the mapped logs model items - HItemPointer item = m_logsMap.value( i ); - - // Found item in the logs map - if ( !item.isNull() && event ) { - int index = m_List.indexOf( item ); - readLogEvent( event, *item ); - indices.append( index ); - } - } - - // Emit dataChanged signal only if there were updates - if ( !indices.isEmpty() ) { - QList< QList > batches = findIndices( indices ); - foreach( QList l, batches ) - q->doDataChanged( q->index(l.first(), 0), q->index(l.last(), 0) ); - } - - CNT_EXIT -} - -/* - * Clear all call logs and refetches new call events after - * receiving a reset model signal from logs model - */ -void CntHistoryModelPrivate::handleLogsReset() -{ - CNT_ENTRY - - Q_Q(CntHistoryModel); - - q->doBeginResetModel(); - - // Remove all call logs - QList values = m_logsMap.values(); - foreach(HItemPointer p, values) { - m_List.removeOne( p ); - } - - m_logsMap.clear(); - - //read first call events if any and start listening for more - for ( int i = 0; i < m_AbstractLogsModel->rowCount(); ++i ) { - LogsEvent* event = qVariantValue( - m_AbstractLogsModel->data(m_AbstractLogsModel->index(i, 0), LogsModel::RoleFullEvent) ); - - if ( event ) { - HItemPointer item = HItemPointer(new HistoryItem()); - readLogEvent(event, *item); - m_logsMap.insert(i, item); - m_List.append( item ); - } - } - - sort(); - - q->doEndResetModel(); - - CNT_EXIT -} - -/*! - * Check whether an idex is out of bound of our list - * - * \param index Index to be validated - */ - -bool CntHistoryModelPrivate::validateRowIndex( const int index) const -{ - return( index < rowCount() && index >= 0 ); -} - -/*! - * Find the sequences of indices for the given indices from the private list - * - * \param indices List of indices - * \return sequences of indices - */ -QList< QList > CntHistoryModelPrivate::findIndices( const QList< int >& indices ) -{ - CNT_ENTRY_ARGS(indices) - - QList< QList > sequences; - QList currSequence; - int prevIndex = indices.at(0) - 1; - - foreach( int currIndex, indices ) - { - if ( currIndex >= 0 ) - { - if ( prevIndex+1 != currIndex && !currSequence.isEmpty() ) - { - sequences.append( currSequence ); - currSequence.clear(); - } - currSequence.append( currIndex ); - prevIndex = currIndex; - } - } - - if ( !currSequence.isEmpty() ) - { - // Add last sequence if such exist - sequences.append( currSequence ); - } - - CNT_EXIT_ARGS(sequences) - - return sequences; -} - -/*! - * Read message event into a history item - * - * \param event Message event - * \param item Conversation history item - */ -void CntHistoryModelPrivate::readMsgEvent(MsgItem& event, HistoryItem& item) -{ - CNT_ENTRY - - // Msg direction - if ( event.direction() == MsgItem::MsgDirectionIncoming ) { - item.flags |= CntIncoming; - // Read status - if ( event.isAttributeSet(MsgItem::MsgAttributeUnread) ) - item.flags |= CntUnseen; - else - item.flags &= ~CntUnseen; - } else if ( event.direction() == MsgItem::MsgDirectionOutgoing ) - item.flags &= ~CntIncoming; - - // Attachment - if (event.isAttributeSet(MsgItem::MsgAttributeAttachment)) - item.flags |= CntAttachment; - - item.flags |= CntMessage; - item.number = event.phoneNumber(); - - if (event.body().isEmpty()) - { - item.message = " "; - } - else - { - item.message = event.body(); - } - - item.timeStamp = event.timeStamp().toLocalTime(); - - LOG_ITEM(item); - - CNT_EXIT -} - -/*! - * Slot to receive new messages for the first time - * from the messages model - * - * \param event Message event - * \param item Conversation history item - */ -void CntHistoryModelPrivate::messagesReady(QList& msgs) -{ - CNT_ENTRY - - Q_Q(CntHistoryModel); - - q->doBeginResetModel(); - - foreach( MsgItem m, msgs ) { - // Create a new hst item - HItemPointer item(new HistoryItem()); - - // Parse the MsgItem and add data into hst item - readMsgEvent( m, *item ); - - // Map the hist item to a MsgItem in the msgModel - m_msgMap.insert( m.id(), item ); - - // Append the hst item to our list - m_List.append( item ); - } - - sort(); - - q->doEndResetModel(); - - CNT_EXIT -} - -/*! - * Slot to receive new messages from the messages model - * - * \param event Message event - * \param item Conversation history item - */ -void CntHistoryModelPrivate::messageAdded(MsgItem& msg) -{ - CNT_ENTRY - - Q_Q(CntHistoryModel); - - q->doBeginInsertRows( QModelIndex(), rowCount(), rowCount() ); - - // Create a new hst item - HItemPointer item(new HistoryItem()); - - // Parse the MsgItem and add data into hst item - readMsgEvent( msg, *item ); - - // Map the hist item to a MsgItem in the msgModel - m_msgMap.insert( msg.id(), item ); - - // Append the hst item to our list - m_List.append( item ); - - q->doEndInsertRows(); - - CNT_EXIT -} - -/*! - * Slot to update a message from the messages model - * - * \param event Message event - * \param item Conversation history item - */ -void CntHistoryModelPrivate::messageChanged(MsgItem& msg) -{ - CNT_ENTRY - - Q_Q(CntHistoryModel); - - // Fetch the hst item that maps to this MsgItem - HItemPointer p = m_msgMap.value( msg.id() ); - - // No item was found. - if ( p.isNull() ) - return; - - // Parse the MsgItem and add data into hst item - readMsgEvent(msg, *p); - - // Get the index of the the hst item in the list - int pIndex = m_List.indexOf( p ); - - q->doDataChanged(q->index(pIndex, 0), q->index(pIndex, 0)); - - CNT_EXIT -} - -/*! - * Slot to delete a message from the messages model - * - * \param event Message event - * \param item Conversation history item - */ -void CntHistoryModelPrivate::messageDeleted(MsgItem& msg) -{ - CNT_ENTRY - - Q_Q(CntHistoryModel); - - // Fetch the hst item that maps to this MsgItem - HItemPointer p = m_msgMap.value( msg.id() ); - - // No item was found. - if ( p.isNull() ) - return; - - // Remove the item in stored containers - m_msgMap.remove( msg.id() ); - int index = m_List.indexOf( p ); - if ( index > -1 ) { - q->doBeginRemoveRows(QModelIndex(), index, index); - m_List.removeAt( index ); - q->doEndRemoveRows(); - } - - CNT_EXIT -} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/tsrc/branch_coverage.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cnthistorymodel/tsrc/branch_coverage.bat Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,13 @@ +pushd mt_cnthistorymodel +call del MON.sym +call del MON.dat +call del profile.txt + +call qmake +call sbs reallyclean +call ctcwrap -i d -2comp -no-conf-check sbs.bat -c winscw_urel.test + +call \epoc32\release\winscw\urel\mt_cnthistorymodel.exe +call ctcpost -p profile.txt +call ctc2html -i profile.txt -nsb +popd diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/tsrc/functional_coverage.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cnthistorymodel/tsrc/functional_coverage.bat Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,13 @@ +pushd mt_cnthistorymodel +call del MON.sym +call del MON.dat +call del profile.txt + +call qmake +call sbs reallyclean +call ctcwrap -i f -2comp -no-conf-check sbs.bat -c winscw_urel.test + +call \epoc32\release\winscw\urel\mt_cnthistorymodel.exe +call ctcpost -p profile.txt +call ctc2html -i profile.txt -nsb +popd diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/tsrc/mt_cnthistorymodel/main.cpp --- a/phonebookui/cnthistorymodel/tsrc/mt_cnthistorymodel/main.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* -* 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 "testrunner.h" - -#include "mt_cnthistorymodel.h" - -#include - -int main(int argc, char *argv[]) -{ - bool promptOnExit(true); - for (int i=0; imarkAllAsSeen(); model->clearHistory(); } + +QTEST_MAIN(TestCntHistoryModel); diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/tsrc/mt_cnthistorymodel/mt_cnthistorymodel.pro --- a/phonebookui/cnthistorymodel/tsrc/mt_cnthistorymodel/mt_cnthistorymodel.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/cnthistorymodel/tsrc/mt_cnthistorymodel/mt_cnthistorymodel.pro Fri Oct 15 12:24:46 2010 +0300 @@ -19,11 +19,11 @@ MOC_DIR = moc QT += testlib xml core -CONFIG += qtestlib hb +CONFIG += hb symbian_test DEFINES += QT_NO_DEBUG_OUTPUT DEFINES += QT_NO_WARNING_OUTPUT -DEFINES += PBK_UNIT_TEST -DEFINES += CNTHISTORYMODEL_NO_EXPORT +DEFINES += PBK_UNIT_TEST \ + CNTHISTORYMODEL_NO_EXPORT DEPENDPATH += . INCLUDEPATH += . @@ -32,16 +32,13 @@ INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE # Input -HEADERS += ../../inc/*.h +HEADERS += ../../*.h HEADERS += mt_cnthistorymodel.h HEADERS += stub_classes.h -HEADERS += testrunner.h -SOURCES += ../../src/*.cpp -SOURCES += main.cpp +SOURCES += ../../*.cpp SOURCES += stub_classes.cpp SOURCES += mt_cnthistorymodel.cpp -SOURCES += testrunner.cpp LIBS += -lQtContacts \ -lmsghistory diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/tsrc/mt_cnthistorymodel/testrunner.cpp --- a/phonebookui/cnthistorymodel/tsrc/mt_cnthistorymodel/testrunner.cpp Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,176 +0,0 @@ -/* -* 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 "testrunner.h" -#include -#include -#include - -const char testFunctionElement[] = "TestFunction"; -const char incidentElement[] = "Incident"; -const char descriptionElement[] = "Description"; -const char nameAttr[] = "name"; -const char typeAttr[] = "type"; -const char fileAttr[] = "file"; -const char lineAttr[] = "line"; -const char attrValueFail[] = "fail"; - - -TestRunner::TestRunner(const QString& name) -: mTestCount(0), - mParsingIncidentElement(false), - mParsingDescriptionElement(false), - mCurrentTestFailed(false), - mCurrentTestFailureLine(0) -{ - mTestRunParams.append(name); - mTestRunParams.append("-xml"); - mTestRunParams.append("-o"); - mHomeDir = QDir::homePath(); - mTestRunParams.append(QString()); // Initial result file name - - if (!mHomeDir.endsWith(QString::fromAscii("/"))) - mHomeDir += QString::fromAscii("/"); -} - -TestRunner::~TestRunner() -{ -} - -int TestRunner::runTests(QObject& testObject) -{ - QString className(testObject.metaObject()->className()); - printf("Running tests for %s ... ", className.toUtf8().data()); - QString resultFileName = mHomeDir + className + ".xml"; - mTestRunParams.replace(mTestRunParams.count()-1,resultFileName); - int errorsBefore = mErrors.count(); - int error = QTest::qExec(&testObject, mTestRunParams); - parse(resultFileName); - printf("Failures: %d\n",mErrors.count()-errorsBefore); - fflush(stdout); - return error; -} - -void TestRunner::printResults() -{ - printf("\nTests executed: %d\n",mTestCount); - if (mErrors.count() > 0) { - printf("Failures (%d):\n", mErrors.count()); - foreach(QString error, mErrors) { - printf("\n%s", error.toUtf8().data()); - } - printf("\n"); - } else { - printf("All passed.\n\n"); - } - fflush(stdout); - - //To write in file - QFile file("C:\\TestResult.txt"); - if(file.open(QIODevice::WriteOnly)) - { - QTextStream ts( &file ); - ts << "Tests executed: " << mTestCount << "\n"; - if (mErrors.count() > 0) - { - ts <<"Failures : " << mErrors.count() << "\n"; - foreach(QString error, mErrors) - { - ts << error.toUtf8().data(); - } - ts << "\n"; - } - else - { - ts<< "All passed.\n\n"; - } - - ts << endl; - file.close(); - } -} - -void TestRunner::parse(const QString& fileName) -{ - QFile file(fileName); - QXmlInputSource inputSource(&file); - QXmlSimpleReader reader; - reader.setContentHandler(this); - reader.parse(inputSource); -} - -bool TestRunner::startElement( - const QString& /*namespaceURI*/, - const QString& /*localName*/, - const QString& qName, - const QXmlAttributes& atts) -{ - if (qName == QString::fromAscii(testFunctionElement)) { - mTestCount++; - mCurrentTestName = atts.value(QString::fromAscii(nameAttr)); - return true; - } - if (qName == QString::fromAscii(incidentElement)) { - mParsingIncidentElement = true; - if (atts.value(QString::fromAscii(typeAttr)) == QString::fromAscii(attrValueFail)) { - mCurrentTestFailed = true; - mCurrentTestFile = atts.value(QString::fromAscii(fileAttr)); - mCurrentTestFailureLine = atts.value(QString::fromAscii(lineAttr)).toInt(); - } - return true; - } - mParsingDescriptionElement = - (qName == QString::fromAscii(descriptionElement)); - return true; -} - -bool TestRunner::endElement( - const QString& /*namespaceURI*/, - const QString& /*localName*/, - const QString& qName) -{ - if (qName == QString::fromAscii(incidentElement)) { - mParsingIncidentElement = false; - mCurrentTestFailed = false; - return true; - } - if (qName == QString::fromAscii(descriptionElement)) { - mParsingDescriptionElement = false; - } - return true; -} - -bool TestRunner::characters(const QString& ch) -{ - if (mParsingIncidentElement && - mParsingDescriptionElement && - mCurrentTestFailed) { - QByteArray testResult = mCurrentTestName.toAscii() + " failed:\n"; - testResult += "File: "; - testResult += mCurrentTestFile.toAscii(); - testResult += "\n"; - testResult += "Line: "; - testResult += QByteArray::number(mCurrentTestFailureLine); - testResult += "\n"; - testResult += "Reason: "; - testResult += ch.toAscii(); - testResult += "\n"; - mErrors.append(QString::fromAscii(testResult.data())); - } - return true; -} - diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/tsrc/mt_cnthistorymodel/testrunner.h --- a/phonebookui/cnthistorymodel/tsrc/mt_cnthistorymodel/testrunner.h Fri Oct 08 11:42:51 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* -* 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 TESTRUNNER_H -#define TESTRUNNER_H - -#include -#include -#include - -class Starter : public QObject -{ - Q_OBJECT -public: - Starter( HbApplication& aApp ); - ~Starter(); - - bool eventFilter( QObject* aObject, QEvent* aEvent ); - -private: - HbApplication& mApp; - bool mTestStarted; -}; - -class TestRunner : public QXmlDefaultHandler -{ - -public: // Constructors and destructor - TestRunner(const QString& name); - ~TestRunner(); - -public: // New functions - - int runTests(QObject& testObject); - void printResults(); - -protected: // From QXmlContentHandler - bool startElement( - const QString& namespaceURI, - const QString& localName, - const QString& qName, - const QXmlAttributes& atts); - - bool endElement( - const QString& namespaceURI, - const QString& localName, - const QString& qName); - - bool characters(const QString& ch); - -private: // New functions - void parse(const QString& fileName); - -private: // Data - QStringList mTestRunParams; - QString mHomeDir; - int mTestCount; - QStringList mErrors; - bool mParsingIncidentElement; - bool mParsingDescriptionElement; - bool mCurrentTestFailed; - QString mCurrentTestName; - QString mCurrentTestFile; - int mCurrentTestFailureLine; - - QList mTests; -}; - - -#endif // TESTRUNNER_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cnthistorymodel/tsrc/run_test.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cnthistorymodel/tsrc/run_test.bat Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,6 @@ +pushd mt_cnthistorymodel +call qmake +call sbs reallyclean +call sbs -c winscw_urel.test +call \epoc32\release\winscw\urel\mt_cnthistorymodel.exe -o c:\mt_cnthistorymodel.txt +popd \ No newline at end of file diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntabstractfetcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntabstractfetcher.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,225 @@ +/* +* Copyright (c) 2010 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: Base class for cache data fetchers. +* +*/ + +#include +#include + +/*! + \class CntAbstractCacheItem + \brief Base class for cache data for one contact. + */ + +/*! + \class CntAbstractFetcher + \brief CntAbstractFetcher is a base class for cache data fetchers. + + CntAbstractFetcher implements a priority queue for scheduling jobs. + A job is added using scheduleJob() and executed using processNextJob(). + If too many jobs are scheduled, the oldest jobs (not the ones with lowest + priority) are cancelled. However, the cancelled jobs will be informed + back to the client later so that it can reschedule them if needed. + */ + +/*! + Constructs a CntAbstractFetcher object. + */ +CntAbstractFetcher::CntAbstractFetcher(int maxAmountOfJobs) +{ + CNT_ENTRY + + // set the max amount of jobs + mMaxAmountOfJobs = maxAmountOfJobs; + + CNT_EXIT +} + +/*! + Cleans up and destructs the CntIconFetcher object. + */ +CntAbstractFetcher::~CntAbstractFetcher() +{ + CNT_ENTRY + + disconnect(this); + + for (int i = 0; i < mJobs.count(); ++i) { + delete mJobs.at(i).first; + } + mJobs.clear(); + + qDeleteAll(mCancelledJobs); + mCancelledJobs.clear(); + + CNT_EXIT +} + +/*! + Schedules a job. A fetched() signal will be emitted when the job + has been successfully completed; a failed() signal is sent if the + job cannot be completed. + + The oldest job is cancelled if there are too many scheduled jobs; in this + case a cancelled() signal is sent. + + \param job the job; ownership is taken + \return true, if the job is - or already was - scheduled + */ +bool CntAbstractFetcher::scheduleJob(CntAbstractJob* job, int priority) +{ + Q_ASSERT(job != NULL); + + CNT_ENTRY_ARGS("job =" << job->toString() << "prio =" << priority) + + if (job->isEmpty()) { + CNT_EXIT_ARGS("bad job") + return false; + } + + int index = jobIndex(job); + if (index != NoSuchJob) { + // if the job already exists, update the priority... + if (priority < mJobs.at(index).second) { + mJobs[index].second = priority; + } + + // ...and notify the client that an identical job already exists + delete job; + CNT_EXIT_ARGS("job already exists") + return true; + } + + if (mJobs.count() >= mMaxAmountOfJobs) { + // the queue of jobs is full, so remove the oldest job + mCancelledJobs.append(mJobs.takeFirst().first); + } + + mJobs.append(qMakePair(job, priority)); + + // since this job has now been scheduled, remove it from the list of + // cancelled jobs in case it is there + index = cancelledJobIndex(job); + if (index != NoSuchJob) { + delete mCancelledJobs.takeAt(index); + } + + CNT_EXIT + + return true; +} + +/*! + \return true if there are scheduled jobs left; otherwise returns false. + */ +bool CntAbstractFetcher::hasScheduledJobs() +{ + return (mJobs.count() > 0); +} + +/*! + \return true if there are cancelled jobs left; otherwise returns false. + */ +bool CntAbstractFetcher::hasCancelledJobs() +{ + return (mCancelledJobs.count() > 0); +} + +/*! + Picks the next job from the list of scheduled jobs, i.e. the job + with the highest priority. + + \return the next job in the job list + */ +CntAbstractJob * CntAbstractFetcher::takeNextJob() +{ + CNT_ENTRY + + int selectionIndex = -1; + int selectionPriority = -1; + + int jobCount = mJobs.count(); + if (jobCount == 0) { + CNT_EXIT_ARGS("no more jobs") + return NULL; + } + + for (int i = 0; i < jobCount; ++i) { + int jobPriority = mJobs.at(i).second; + if (jobPriority < selectionPriority || selectionPriority == -1) { + selectionIndex = i; + selectionPriority = jobPriority; + } + } + + CNT_EXIT_ARGS(mJobs.at(selectionIndex).first->toString()) + + return mJobs.takeAt(selectionIndex).first; +} + +/*! + \return the next job in the list of cancelled jobs + */ +CntAbstractJob * CntAbstractFetcher::takeNextCancelledJob() +{ + CNT_ENTRY + + return mCancelledJobs.takeFirst(); +} + + +/*! + Finds out the index of a scheduled job. + + \param job the kind of job to look for + \return index of the job, or NoSuchJob if such a job is not scheduled. + */ +int CntAbstractFetcher::jobIndex(CntAbstractJob *job) +{ + CNT_ENTRY + + for (int i = 0; i < mJobs.count(); ++i) { + CntAbstractJob *scheduledJob = mJobs.at(i).first; + if (job->equals(*scheduledJob)) { + CNT_EXIT + return i; + } + } + + CNT_EXIT_ARGS("no such job") + return NoSuchJob; +} + +/*! + Finds out the index of a cancelled job. + + \param job the kind of job to look for + \return index of the job, or NoSuchJob if such a job is not cancelled. + */ +int CntAbstractFetcher::cancelledJobIndex(CntAbstractJob *job) +{ + CNT_ENTRY + + for (int i = 0; i < mCancelledJobs.count(); ++i) { + CntAbstractJob *cancelledJob = mCancelledJobs.at(i); + if (job->equals(*cancelledJob)) { + CNT_EXIT + return i; + } + } + + CNT_EXIT_ARGS("no such cancelled job") + return NoSuchJob; +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntabstractfetcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntabstractfetcher.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2010 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: Base classes for fetchers and their jobs. +* +*/ + +#ifndef CNTABSTRACTFETCHER_H +#define CNTABSTRACTFETCHER_H + +#include + +#define NoSuchJob -1 + +QTM_USE_NAMESPACE + +class CntAbstractJob +{ +public: + virtual ~CntAbstractJob() {} + virtual bool isEmpty() = 0; + virtual bool equals(const CntAbstractJob &other) = 0; + virtual QString toString() = 0; +}; + +class CntAbstractFetcher : public QObject +{ + Q_OBJECT +public: + CntAbstractFetcher(int maxAmountOfJobs); + virtual ~CntAbstractFetcher(); + + bool scheduleJob(CntAbstractJob *job, int priority = 0); + bool hasScheduledJobs(); + bool hasCancelledJobs(); + virtual bool isProcessingJob() = 0; + virtual void processNextJob() = 0; + +protected: + CntAbstractJob * takeNextJob(); + CntAbstractJob * takeNextCancelledJob(); + int jobIndex(CntAbstractJob *job); + int cancelledJobIndex(CntAbstractJob *job); + +private: + QList< QPair > mJobs; // list of all scheduled jobs and their priorities + QList mCancelledJobs; // list of all cancelled jobs + int mMaxAmountOfJobs; // the maximum amount of concurrently scheduled jobs +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntcache.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntcache.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,1090 @@ +/* +* Copyright (c) 2010 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: Asynchronously fetches and caches basic contact info +* and icons. +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + \class CntContactInfo + \brief Info about one contact, intended for list views. + + This class contains info about one contact. The info is mainly intended + to be used in list views: + - name: the name of the contact, formatted for displaying + - text: secondary information like a phone number + - icon1: the main icon + - icon2: the smaller secondary icon + + \class CntCache + \brief Asynchronously fetches contact info and icons. + + Singleton class that acts as a proxy to get CntContactInfo objects for + contacts. It also implements caching for faster access. This is why the + fetchContactInfo() function takes a row number and the full list of + contact IDs rather than just a contact ID -- it allows precaching. + + The usage pattern for clients is to call fetchContactInfo() to get at + least the name of the contact. If all the info is cached then it will be + provided. If not, then the uncached info is fetched asynchronously and + contactInfoUpdated() signals are emitted as the pieces of information + arrive -- up to three times per contact; once for text, once for icon1 + and once for icon2. + + Internally CntCache uses three fetchers; one for names, one for info and + one for icons. + */ + +// set the singleton instance pointer to NULL +CntCache* CntCache::mInstance = NULL; + +// the event for starting to process all outstanding jobs +const QEvent::Type ProcessJobsEvent = QEvent::User; + +// different states of postponement +const int JobsNotPostponed = 0; +const int JobsPostponedForDuration = 1; +const int JobsPostponedUntilResume = 2; + +// number of items to read ahead into cache; this number is for one direction +const int ItemsToCacheAhead = 24; + +// cache size for info items +const int InfoCacheSize = 128; + +// cache size for icon items; must be larger than 2 * ItemsToCacheAhead +const int IconCacheSize = 60; + +// duration of urgency mode in milliseconds +const int UrgencyModeDuration = 100; + +// duration of a postponement in milliseconds +const int PostponeJobsDuration = 300; + +// number of icons in a CntContactInfo object +const int IconsInCntContactInfo = 2; + +// default empty text info field for a contact; it cannot be empty +// as the listview will then ignore it, causing rendering problems +const QString EmptyTextField = " "; + +/*! + Provides a pointer to the CntCache singleton instance. + + \param client a pointer to the client + \param manager + */ +CntCache* CntCache::createSession(void *client, QContactManager *manager) +{ + CNT_STATIC_ENTRY_ARGS("client =" << client << ", mngr =" << (void*) manager) + + if (!mInstance) { + mInstance = new CntCache(manager); + } + + // increase reference counter for cache clients + mInstance->mClients.insert(client); + + // whenever a client requests an instance, the client will want to get all info + // for the first screenful of contacts urgently + mInstance->startUrgencyMode(); + + CNT_EXIT_ARGS("instance =" << (void*) mInstance << ", refCount =" << mInstance->mClients.count()) + + return mInstance; +} + +/*! + Disconnects from CntCache. + */ +void CntCache::closeSession(void *client) +{ + CNT_ENTRY + + // delete singleton instance if there are no more clients + mInstance->mClients.remove(client); + if (mInstance->mClients.count() == 0) { + CNT_LOG_ARGS("no more clients, so deleting singleton instance") + mInstance = NULL; + delete this; + } + + CNT_EXIT +} + +/*! + Fetches visuals for a contact: name, text (e.g. phone number or social + status) and two icons (e.g. avatar, presence). Previously cached content, + at the very least the name, will be returned immediately. Availability of + more information will be checked asynchronously and sent to clients via + contactInfoUpdated() signals. + + The function takes a row and a list rather than just a contact ID because + of read ahead caching - contacts near the requested contacts are expected + to be needed soon and are therefore precached. + + \param row the row of the contact to fetch + \param idList a list with all the IDs in the list + \return a contact with some details filled in + */ +CntContactInfo* CntCache::fetchContactInfo(int row, const QList& idList) +{ + CNT_ENTRY_ARGS(row << "/" << idList.count()) + + Q_ASSERT(row >= 0 && row < idList.count()); + + QString name; + QString text = EmptyTextField; + HbIcon icons[IconsInCntContactInfo]; + + QContactLocalId contactId = idList.at(row); + + if (contactId != mLastEmittedContactId) { + // this is a new request from the UI (rather than a response to + // a change that the cache just emitted) + if (!mIsInUrgencyMode) { + postponeJobs(JobsPostponedForDuration, PostponeJobsDuration); + } + updateReadAheadCache(row, idList); + } + + // fetch the contact + if (mInfoCache.contains(contactId)) { + // the contact's info is cached + CntInfoCacheItem* infoItem = mInfoCache.value(contactId); + for (int i = 0; i < IconsInCntContactInfo; ++i) { + QString iconName = infoItem->icons[i]; + if (!iconName.isEmpty()) { + if (mIconCache.contains(iconName)) { + CntIconCacheItem* iconItem = mIconCache.value(iconName); + if (iconItem->requestedBy.count() > 0) { + // icon is being fetched -> add this contact to list of requestors + iconItem->requestedBy << contactId; + } + iconItem->lastRequest = QTime::currentTime(); + icons[i] = iconItem->icon; + } else { + // needed icon is not in cache, so schedule it for retrieval + CntIconCacheItem* iconItem = createIconCacheItem(iconName); + iconItem->requestedBy << contactId; + mIconFetcher->scheduleJob(new CntIconJob(iconName), row); + } + } + } + + // set return text + text = infoItem->text; + + // update cache order + infoItem->lastRequest = QTime::currentTime(); + } else if (contactExists(contactId)) { + // contact exists but info is not in cache, so schedule it for retrieval + CntInfoCacheItem* item = createInfoCacheItem(contactId); + item->text = text; + mInfoFetcher->scheduleJob(new CntInfoJob(contactId), row); + } else { + return NULL; + } + + name = contactName(contactId); + + if (!mProcessingJobs && mJobsPostponed == JobsNotPostponed) { + // there might be new jobs now + mProcessingJobs = true; + HbApplication::instance()->postEvent(this, new QEvent(ProcessJobsEvent)); + } + + CNT_EXIT_ARGS("name:" << name << "text:" << text) + + return new CntContactInfo(contactId, name, text, icons[0], icons[1]); +} + +/*! + Creates a list of contact ids sorted according the corresponding contact names. + + \param idFilter the IDs to be returned; if NULL, all contact IDs are returned + \return the list of ids, sorted by contact name + */ +QList CntCache::sortIdsByName(const QSet* idFilter) const +{ + CNT_ENTRY + + QList sortedIds; + + // allocate memory in advance to avoid repeated reallocation during population + // an extra 16 items are allocated to leave room for a few more contacts + // before reallocation is needed + if (!idFilter) { + sortedIds.reserve(mSortedNames.count() + 16); + } else { + sortedIds.reserve(idFilter->count() + 16); + } + + // the entries in mSortedNames are already sorted, so just pick + // out the ids from that list in the order that they appear + if (!idFilter) { + foreach (CntNameCacheItem* item, mSortedNames) { + sortedIds.append(item->contactId()); + } + } else { + foreach (CntNameCacheItem* item, mSortedNames) { + if (idFilter->contains(item->contactId())) { + sortedIds.append(item->contactId()); + } + } + } + + CNT_EXIT + + return sortedIds; +} + +/*! + Overloaded version of the function for string based searching of contact + names. Currently for multi part names only space and dash variations are + used for filtering, e.g. "A B" matches "Beta, Alfa" and "Alfa, Beta", + but also "Gamma, Alfa-Beta" and "Gamma, Alfa Beta" and "Alfa Beta, Gamma". + + \param searchList list of strings to search for + \return the list of ids, sorted by contact name + */ +QList CntCache::sortIdsByName(const QStringList &searchList) const +{ + CNT_ENTRY_ARGS("time:" << User::FastCounter()); + + QList sortedIds; + QSet checkedNames; + QStringList searchListSorted; + + // the given search string must be ordered to descending order according to word length + // so the search algorithm finds the correct contacts, this prevents cases where search string + // is e.g. "ax axx" so names starting with "axxyyz axyz" don't cause any problems for the search + foreach (QString oneString, searchList) { + searchListSorted.append(oneString.toLower()); + } + qSort(searchListSorted.begin(), searchListSorted.end(), qGreater()); + + for (int iter = 0; iter < mSortedNames.size(); iter++) { + int searchIndex; + QString currentName = (mSortedNames.at(iter))->name(); + checkedNames.clear(); + + for (searchIndex = 0; searchIndex < searchListSorted.size(); searchIndex++) { + int currentPos; + int tempStartPos = 0; + for (currentPos = 0; currentPos <= currentName.length(); currentPos++) { + // at the moment only differentiating character is the space (" ") + if (currentPos == currentName.length() || currentName.at(currentPos) == ' ') { + QString tempName = currentName.mid(tempStartPos, currentPos - tempStartPos); + + if (!checkedNames.contains(tempStartPos) + && tempName.startsWith(searchListSorted.at(searchIndex), Qt::CaseInsensitive)) { + checkedNames.insert(tempStartPos); + break; + } + tempStartPos = ++currentPos; + } + } + // if the name is parsed completely through then it can't be a match + if (currentPos > currentName.length()) { + break; + } + } + // if the whole search parameter list is parsed, then the name must match the given search string + if (searchIndex == searchListSorted.size()) { + sortedIds.append(mSortedNames.at(iter)->contactId()); + } + } + + CNT_EXIT_ARGS("time:" << User::FastCounter()); + + return sortedIds; +} + +/*! + Creates the CntCache singleton instance. + */ +CntCache::CntCache(QContactManager *manager) + : mContactManager(manager), + mNameFetcher(new CntNameFetcher()), + mInfoFetcher(new CntInfoFetcher(mContactManager)), + mIconFetcher(new CntIconFetcher()), + mProcessingJobs(false), + mJobsPostponed(JobsNotPostponed), + mIsInUrgencyMode(false), + mLastEmittedContactId(-1), + mHasModifiedNames(false), + mAllNamesFetchStarted(false) +{ + CNT_ENTRY + + // listen to name fetcher + QObject::connect(mNameFetcher, SIGNAL(nameFormatChanged(CntNameOrder)), + this, SLOT(reformatNames(CntNameOrder))); + QObject::connect(mNameFetcher, SIGNAL(databaseAccessComplete()), + this, SLOT(resumeJobs())); + QObject::connect(mNameFetcher, SIGNAL(namesAvailable(QList)), + this, SLOT(setNameList(QList))); + + // listen to info fetcher + QObject::connect(mInfoFetcher, SIGNAL(infoUpdated(QContactLocalId, const ContactInfoField &, const QString &)), + this, SLOT(updateCachedInfo(QContactLocalId, const ContactInfoField &, const QString &))); + QObject::connect(mInfoFetcher, SIGNAL(infoCancelled(QContactLocalId)), + this, SLOT(cancelInfoFetch(QContactLocalId))); + + // listen to icon fetcher + QObject::connect(mIconFetcher, SIGNAL(iconFetched(const QString &, const HbIcon &)), + this, SLOT(updateCachedIcon(const QString &, const HbIcon &))); + QObject::connect(mIconFetcher, SIGNAL(iconCancelled(const QString &)), + this, SLOT(cancelIconFetch(const QString &))); + + // listen to contact manager + QObject::connect(mContactManager, SIGNAL(contactsChanged(const QList&)), + this, SLOT(updateContacts(const QList&))); + QObject::connect(mContactManager, SIGNAL(contactsRemoved(const QList&)), + this, SLOT(removeContacts(const QList&))); + QObject::connect(mContactManager, SIGNAL(contactsAdded(const QList&)), + this, SLOT(addContacts(const QList&))); + + // listen to timer events; this is for postponing and resuming jobs + mResumeJobsTimer.setSingleShot(true); + QObject::connect(&mResumeJobsTimer, SIGNAL(timeout()), this, SLOT(resumeJobs())); + + // load all names to cache + loadNames(); + + CNT_EXIT +} + +/*! + Destructs the CntCache singleton instance. + */ +CntCache::~CntCache() +{ + CNT_ENTRY + + QObject::disconnect(this); + + if (mHasModifiedNames) { + mNameFetcher->writeNamesToCache(mSortedNames); + } + + delete mNameFetcher; + delete mInfoFetcher; + delete mIconFetcher; + + qDeleteAll(mInfoCache); + mInfoCache.clear(); + + qDeleteAll(mIconCache); + mIconCache.clear(); + + qDeleteAll(mNameCache); + mNameCache.clear(); + + mSortedNames.clear(); // contains same data as mNameCache, so no qDeleteAll + + CNT_EXIT +} + +/*! + Postpones outstanding jobs until milliseconds ms has passed or resumeJobs() is called. + + \param postponement Type the type of postponement; UntilResume or ForDuration + \param milliseconds The duration of the delay + */ +void CntCache::postponeJobs(int postponementType, int duration) +{ + CNT_ENTRY_ARGS("ms =" << duration) + + Q_ASSERT((postponementType == JobsPostponedUntilResume + || postponementType == JobsPostponedForDuration) + && duration >= 0); + + mJobsPostponed = postponementType; + mResumeJobsTimer.stop(); + + if (postponementType == JobsPostponedForDuration) { + mResumeJobsTimer.start(duration); + } + + CNT_EXIT_ARGS("type =" << mJobsPostponed) +} + +/*! + Postpones outstanding jobs until resumeJobs() is called. This must always be called after + postponeJobs. + */ +void CntCache::resumeJobs() +{ + CNT_ENTRY + + Q_ASSERT(!mProcessingJobs && mJobsPostponed != JobsNotPostponed); + + mResumeJobsTimer.stop(); + mJobsPostponed = JobsNotPostponed; + mProcessingJobs = true; + HbApplication::instance()->postEvent(this, new QEvent(ProcessJobsEvent)); + + CNT_EXIT +} + +/*! + Listens for ProcessJobsEvents and calls processJobs() if there is such an event. + */ +bool CntCache::event(QEvent* event) +{ + if (event->type() == ProcessJobsEvent) { + processJobs(); + return true; + } + + return QObject::event(event); +} + +/*! + Processes all scheduled jobs in all fetchers. The loop runs until all + jobs are done or postponed. + */ +void CntCache::processJobs() +{ + CNT_ENTRY + + // process fetcher jobs in order of priority + forever { + // 1: has all jobs been postponed? + if (mJobsPostponed != JobsNotPostponed) { + CNT_EXIT_ARGS("jobs postponed") + mProcessingJobs = false; + return; + + // 2: is there a request to fetch info? + } else if (mInfoFetcher->hasScheduledJobs()) { + mInfoFetcher->processNextJob(); + + // 3: is there a request to fetch an icon? + } else if (mIconFetcher->hasScheduledJobs()) { + // quit the loop; it will be started again when the icon has been fetched + if (!mIconFetcher->isProcessingJob()) { + mIconFetcher->processNextJob(); + } + mProcessingJobs = false; + CNT_EXIT_ARGS("jobs postponed until icon fetch returns") + return; + + // 4: are there any cancelled info jobs? + } else if (mInfoFetcher->hasCancelledJobs() && !mInfoFetcher->isProcessingJob()) { + mInfoFetcher->processNextJob(); + + // 5: are there any cancelled icon jobs? + } else if (mIconFetcher->hasCancelledJobs() && !mIconFetcher->isProcessingJob()) { + mIconFetcher->processNextJob(); + + // 6: is there an "all names" job? + } else if (mNameFetcher->hasScheduledJobs()) { + // fetch all contact names from the database so that the current + // list of names (from the file cache) can be synched with the + // database + if (!mNameFetcher->isProcessingJob()) { + mNameFetcher->processNextJob(); + } + mProcessingJobs = false; + postponeJobs(JobsPostponedUntilResume); + CNT_EXIT_ARGS("jobs postponed while fetching all names") + return; + + // 7: are there contacts left to precache? + } else if (mReadAheadCache.count() > 0) { + int contactId = mReadAheadCache.first().first; + int contactRow = mReadAheadCache.takeFirst().second; + if (!mInfoCache.contains(contactId) && contactExists(contactId)) { + // contact exists, but is not in cache, so schedule it for retrieval + CntInfoCacheItem* item = createInfoCacheItem(contactId); + item->text = EmptyTextField; + mInfoFetcher->scheduleJob(new CntInfoJob(contactId), contactRow); + } + // nothing more to do, so exit loop + } else { + mProcessingJobs = false; + CNT_EXIT_ARGS("no more jobs") + return; + } + + // allow events to be handled before continuing with the next job + HbApplication::processEvents(); + } +} + +/*! + Processes a new info field that has arrived from the info fetcher. + If the contact is in the info cache, then the info cache is updated + accordingly. + + A contactInfoUpdated() signal is usually also emitted. The exception is if + the info is the name of an icon and that icon is not in the icon cache. In + this case the icon is scheduled to be fetched and a signal will eventually + be emitted when the icon has been fetched (or cancelled). + */ +void CntCache::updateCachedInfo(QContactLocalId contactId, const ContactInfoField& infoField, const QString& infoValue) +{ + CNT_ENTRY_ARGS( "id:" << contactId << "infotype:" << infoField << "infovalue:" << infoValue ) + + Q_ASSERT(infoField == ContactInfoTextField || infoField == ContactInfoIcon1Field || infoField == ContactInfoIcon2Field); + + bool hasNewInfo; + + if (!mInfoCache.contains(contactId)) { + // contact is not in cache, so nothing needs to be done except notify + // clients that this contact has (possibly) been changed + hasNewInfo = true; + } else if (infoField == ContactInfoTextField) { + // update cache with new text for contact + mInfoCache.value(contactId)->text = infoValue; + hasNewInfo = true; + } else { + // update cache with new icon name for contact + int iconIndex = (infoField == ContactInfoIcon1Field ? 0 : 1); + CntInfoCacheItem* item = mInfoCache.value(contactId); + QString iconName = infoValue; + if (item->icons[iconIndex] != iconName) { + item->icons[iconIndex] = iconName; + if (iconName.isEmpty()) { + hasNewInfo = true; + } else if (mIconCache.contains(iconName)) { + hasNewInfo = true; + } else if (iconName.startsWith("qtg_", Qt::CaseInsensitive)) { + CntIconCacheItem* iconItem = createIconCacheItem(iconName); + iconItem->icon = HbIcon(iconName); + hasNewInfo = true; + } else { + CntIconCacheItem* iconItem = createIconCacheItem(iconName); + iconItem->requestedBy << contactId; + QList::iterator pos = qLowerBound(mSortedNames.begin(), mSortedNames.end(), mNameCache.value(contactId), CntNameFetcher::compareNames); + while (pos != mSortedNames.end() && (*pos)->contactId() != contactId) { + ++pos; + } + mIconFetcher->scheduleJob(new CntIconJob(iconName), pos - mSortedNames.begin()); + hasNewInfo = false; + } + } else { + hasNewInfo = false; + } + } + + if (hasNewInfo) { + emitContactInfoUpdated(contactId); + } + + if (!mProcessingJobs && mJobsPostponed == JobsNotPostponed) { + // there might be new jobs now + mProcessingJobs = true; + HbApplication::instance()->postEvent(this, new QEvent(ProcessJobsEvent)); + } + + CNT_EXIT +} + +/*! + Handle the case where a request for contact info is cancelled by the + info fetcher because of too many scheduled jobs. + */ +void CntCache::cancelInfoFetch(QContactLocalId contactId) +{ + CNT_ENTRY_ARGS( "cid =" << contactId ) + + if (mInfoCache.contains(contactId)) { + delete mInfoCache.take(contactId); + } + + emitContactInfoUpdated(contactId); + + CNT_EXIT +} + +/*! + Processes a new icon that has arrived from the icon fetcher. + The icon cache is updated and a contactInfoUpdated() signal is + emitted. + */ +void CntCache::updateCachedIcon(const QString& iconName, const HbIcon& icon) +{ + CNT_ENTRY_ARGS( "icon =" << iconName ) + + if (mIconCache.contains(iconName)) { + CntIconCacheItem* item = mIconCache.value(iconName); + item->icon = icon; + foreach (QContactLocalId contactId, item->requestedBy) { + emitContactInfoUpdated(contactId); + } + item->requestedBy.clear(); + + if (!mProcessingJobs && mJobsPostponed == JobsNotPostponed) { + // there might still be unfinished icon jobs; only one icon job is + // done at a time + mProcessingJobs = true; + HbApplication::instance()->postEvent(this, new QEvent(ProcessJobsEvent)); + } + } + + CNT_EXIT +} + +/*! + Handle the case where a request for an icon is cancelled by the icon + fetcher because of too many scheduled jobs. + */ +void CntCache::cancelIconFetch(const QString& iconName) +{ + CNT_ENTRY_ARGS(iconName) + + if (mIconCache.contains(iconName)) { + CntIconCacheItem* item = mIconCache.take(iconName); + foreach (QContactLocalId contactId, item->requestedBy) { + emitContactInfoUpdated(contactId); + } + delete item; + } + + CNT_EXIT +} + +/*! + Creates a new item in the info cache. If the cache is full, + then the least recently accessed item is removed from cache. + + /param contactId id of contact for which to create the new cache item + /return the newly created cache item + */ +CntInfoCacheItem * CntCache::createInfoCacheItem(QContactLocalId contactId) +{ + CNT_ENTRY_ARGS(contactId) + + if (mInfoCache.count() >= InfoCacheSize) { + // cache is full, so remove the oldest contact + CntInfoCacheItem* oldestItem = NULL; + QTime oldestRequest; + + foreach (CntInfoCacheItem* i, mInfoCache) { + if (oldestItem == NULL || i->lastRequest < oldestRequest) { + oldestRequest = i->lastRequest; + oldestItem = i; + } + } + + if (oldestItem != NULL) { + mInfoCache.remove(oldestItem->contactId); + delete oldestItem; + } + } + + // create and insert the new item + CntInfoCacheItem* item = new CntInfoCacheItem(); + item->contactId = contactId; + item->lastRequest = QTime::currentTime(); + mInfoCache.insert(contactId, item); + + CNT_EXIT + + return item; +} + +/*! + Creates a new item in the icon cache. If the cache is full, + then the least recently accessed item is removed from cache. + + /param iconName name of the icon for which to create the new cache item + /return the newly created cache item + */ +CntIconCacheItem* CntCache::createIconCacheItem(const QString& iconName) +{ + CNT_ENTRY_ARGS(iconName) + + if (mIconCache.count() >= IconCacheSize) { + // cache is full, so remove the oldest icon + CntIconCacheItem* oldestItem = NULL; + QTime oldestRequest; + + foreach (CntIconCacheItem* i, mIconCache) { + if (oldestItem == NULL || i->lastRequest < oldestRequest) { + oldestRequest = i->lastRequest; + oldestItem = i; + } + } + + if (oldestItem) { + mIconCache.remove(oldestItem->iconName); + delete oldestItem; + } + } + + // create and insert the new item + CntIconCacheItem* item = new CntIconCacheItem(); + item->iconName = iconName; + item->lastRequest = QTime::currentTime(); + mIconCache.insert(iconName, item); + + CNT_EXIT + + return item; +} + +/*! + Notifies clients that a contact might have changed. + Clients can then request the info via fetchContactInfo() + if they are interested. + */ +void CntCache::emitContactInfoUpdated(QContactLocalId contactId) +{ + CNT_ENTRY_ARGS(contactId) + + mLastEmittedContactId = contactId; + emit contactInfoUpdated(contactId); + mLastEmittedContactId = -1; + + CNT_EXIT +} + +/*! + Collects all contact IDs near the latest fetch from the UI. These will be fetched and + precached when UI activity slows down. + + \param mostRecentRow the row of the contact that was most recently fetched + \param idList a list with all the IDs in the list + */ +void CntCache::updateReadAheadCache(int mostRecentRow, const QList& idList) +{ + CNT_ENTRY_ARGS(mostRecentRow) + + int row; + + mReadAheadCache.clear(); + + // step through the area near to last fetch item and make sure all + // contacts in it are also in cache or in the read ahead list + for (int i = 1; i <= ItemsToCacheAhead; ++i) { + for (int j = 0; j < 2; ++j) { + if (j == 0) { + row = mostRecentRow - i; + if (row < 0) { + continue; + } + } else { + row = mostRecentRow + i; + if (row >= idList.count()) { + continue; + } + } + + int contactId = idList.at(row); + if (!mInfoCache.contains(contactId)) { + // contact is not in cache, so put the id to items to read into cache + mReadAheadCache.append(QPair(contactId, row)); + } else { + // contact is in cache; update lastRequest as we want to keep this item in cache + mInfoCache.value(contactId)->lastRequest = QTime::currentTime(); + } + } + } + + CNT_EXIT +} + +/*! + Starts the urgency mode, where all contact info is fetched immediately, + regardless of whether there is activity in the UI or not. + */ +void CntCache::startUrgencyMode() +{ + CNT_ENTRY + + mIsInUrgencyMode = true; + QTimer::singleShot(UrgencyModeDuration, this, SLOT(stopUrgencyMode())); + + CNT_EXIT +} + +/*! + Starts the urgency mode, where all contact info is fetched immediately, + regardless of whether there is activity in the UI or not. + */ +void CntCache::stopUrgencyMode() +{ + CNT_ENTRY + + mIsInUrgencyMode = false; + + CNT_EXIT +} + +/*! + Fetch the names of all contacts. + */ +void CntCache::loadNames() +{ + CNT_ENTRY + + // read names from file cache + mNameFetcher->readNamesFromCache(mSortedNames); + + // insert the names into the id-to-name map + foreach (CntNameCacheItem* item, mSortedNames) { + mNameCache.insert(item->contactId(), item); + } + + // schedule the job for reading all names from the database; it will be processed once + // info and icons for the first screenful of contacts have been read + mNameFetcher->scheduleJob(new CntAllNamesJob()); + mProcessingJobs = true; + HbApplication::instance()->postEvent(this, new QEvent(ProcessJobsEvent)); + + CNT_EXIT +} + +/*! + Checks whether a contact exists. + */ +bool CntCache::contactExists(QContactLocalId contactId) const +{ + CNT_ENTRY_ARGS(contactId) + CNT_EXIT_ARGS(mNameCache.contains(contactId)) + + return mNameCache.contains(contactId); +} + +/*! + Fetch the name of one contact. + */ +QString CntCache::contactName(QContactLocalId contactId) const +{ + CNT_ENTRY_ARGS(contactId) + + QString name; + + QHash::const_iterator i = mNameCache.find(contactId); + if (i != mNameCache.end()) { + name = i.value()->name(); + } + + CNT_EXIT_ARGS(name) + + return name; +} + +/*! + Updates the names in cache according to newFormat. + + \param newFormat the new name format, e.g. "Lastname, Firstname" + */ +void CntCache::reformatNames(CntNameOrder newFormat) +{ + CNT_ENTRY + + foreach (CntNameCacheItem* item, mSortedNames) { + item->setNameFormat(newFormat); + } + + mNameFetcher->sortNames(mSortedNames); + mNameFetcher->writeNamesToCache(mSortedNames); + mHasModifiedNames = false; + + emit dataChanged(); + + CNT_EXIT +} + +/*! + Replaces the names in cache with the ones in this list. + + \param newSortedNames the sorted list with names; this list will be cleared and + ownership will be taken of the items in the list + */ +void CntCache::setNameList(QList newSortedNames) +{ + CNT_ENTRY + + bool hasModifiedContacts = false; + int count = newSortedNames.count(); + + CNT_LOG_ARGS("curr_count=" << mSortedNames.count() << "db_count=" << count); + + // check if there have been any changes + if (mSortedNames.count() != count) { + hasModifiedContacts = true; + } else { + for (int i = 0; i < count; ++i) { + CntNameCacheItem *oldItem = mSortedNames.at(i); + CntNameCacheItem *newItem = newSortedNames.at(i); + CNT_LOG_ARGS("name=" << oldItem->name()); + if (oldItem->contactId() != newItem->contactId() || oldItem->name() != newItem->name()) { + hasModifiedContacts = true; + break; + } + } + } + + // the list has changed, so use the new list instead + if (hasModifiedContacts) { + CNT_LOG_ARGS("has modified contacts -> use new list") + qDeleteAll(mSortedNames); + mNameCache.clear(); + mSortedNames.clear(); + + foreach (CntNameCacheItem* item, newSortedNames) { + mSortedNames.append(item); + mNameCache.insert(item->contactId(), item); + } + + // write names to file cache + mNameFetcher->writeNamesToCache(mSortedNames); + + // notify clients that the list of names has changed + emit dataChanged(); + } else { + qDeleteAll(newSortedNames); + } + + CNT_EXIT +} + +/*! + Updates data in response to some contacts having changed and + then notifies observers that these contacts have changed. + */ +void CntCache::updateContacts(const QList &changedContacts) +{ + CNT_ENTRY + + QString name; + QList items; + + // reloads the names of the changed contacts and updates the + // list of sorted names accordingly + foreach (QContactLocalId contactId, changedContacts) { + CntNameCacheItem *newItem = mNameFetcher->fetchOneName(contactId); + if (newItem != NULL) { + CntNameCacheItem *oldItem = mNameCache.value(contactId); + if (oldItem->name() != newItem->name()) { + QList::iterator oldPos = qLowerBound(mSortedNames.begin(), mSortedNames.end(), oldItem, CntNameFetcher::compareNames); + while (oldPos != mSortedNames.end() && *oldPos != oldItem) { + ++oldPos; + } + QList::iterator newPos = qUpperBound(mSortedNames.begin(), mSortedNames.end(), newItem, CntNameFetcher::compareNames); + if (oldPos < newPos) { + mSortedNames.move(oldPos - mSortedNames.begin(), (newPos - mSortedNames.begin()) - 1); + } else { + mSortedNames.move(oldPos - mSortedNames.begin(), newPos - mSortedNames.begin()); + } + *oldItem = *newItem; + mHasModifiedNames = true; + } + } + } + + // if any of the changed items have cached info, the info + // is scheduled for refreshing + foreach (QContactLocalId contactId, changedContacts) { + if (mInfoCache.contains(contactId)) { + QList::iterator pos = qLowerBound(mSortedNames.begin(), mSortedNames.end(), mNameCache.value(contactId), CntNameFetcher::compareNames); + while (pos != mSortedNames.end() && (*pos)->contactId() != contactId) { + ++pos; + } + mInfoFetcher->scheduleJob(new CntInfoJob(contactId), pos - mSortedNames.begin()); + } + } + + // inform clients about these changes + emit contactsChanged(changedContacts); + + if (!mProcessingJobs && mJobsPostponed == JobsNotPostponed) { + // there might be new jobs now + mProcessingJobs = true; + HbApplication::instance()->postEvent(this, new QEvent(ProcessJobsEvent)); + } + + CNT_EXIT +} + +/*! + Updates data in response to some contacts having been removed + and then notifies observers that the contacts have been removed. + */ +void CntCache::removeContacts(const QList &removedContacts) +{ + CNT_ENTRY + + // removed the deleted contacts from the name cache and from the + // list of sorted names + foreach (QContactLocalId contactId, removedContacts) { + if (mNameCache.contains(contactId)) { + CntNameCacheItem *item = mNameCache.take(contactId); + QList::iterator pos = qLowerBound(mSortedNames.begin(), mSortedNames.end(), item, CntNameFetcher::compareNames); + while (*pos != item && pos != mSortedNames.end()) { + ++pos; + } + mSortedNames.erase(pos); + delete item; + mHasModifiedNames = true; + } + } + + // info for these deleted items should be removed from cache + foreach (QContactLocalId contactId, removedContacts) { + if (mInfoCache.contains(contactId)) { + CntInfoCacheItem* item = mInfoCache.take(contactId); + delete item; + } + } + + // inform clients about these deleted contacts + emit contactsRemoved(removedContacts); + + CNT_EXIT +} + +/*! + Updates data in response to some contacts having been added + and then notifies observers that the contacts have been added. + */ +void CntCache::addContacts(const QList &addedContacts) +{ + CNT_ENTRY + + // add the new contacts to the name cache and to the + // list of sorted names + foreach (QContactLocalId contactId, addedContacts) { + CntNameCacheItem *item = mNameFetcher->fetchOneName(contactId); + if (item != NULL) { + mNameCache.insert(contactId, item); + QList::iterator i = qUpperBound(mSortedNames.begin(), mSortedNames.end(), item, CntNameFetcher::compareNames); + mSortedNames.insert(i, item); + mHasModifiedNames = true; + } + } + + // inform clients about the new contacts + emit contactsAdded(addedContacts); + + CNT_EXIT +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntcache.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntcache.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,147 @@ +/* +* Copyright (c) 2010 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: Asynchronously fetches and caches visual contact info for +* e.g. list views. +* +*/ + +#ifndef CNTCACHE_H +#define CNTCACHE_H + +#include +#include +#include +#include +#include +#include +#include + +class CntNameFetcher; +class CntInfoFetcher; +class CntIconFetcher; +class CntNameCacheItem; +class CntInfoCacheItem; +class CntIconCacheItem; + +QTM_USE_NAMESPACE + +class CntContactInfo : public QObject +{ + Q_OBJECT +public: + CntContactInfo(QContactLocalId id, + const QString& name, + const QString& text, + const HbIcon& icon1, + const HbIcon& icon2) + { + mId = id; + mName = name; + mText = text; + mIcon1 = icon1; + mIcon2 = icon2; + } + ~CntContactInfo() {} + + int id() const { return mId; } + QString name() const { return mName; } + QString text() const { return mText; } + HbIcon icon1() const { return mIcon1; } + HbIcon icon2() const { return mIcon2; } + +private: + QContactLocalId mId; + QString mName; + QString mText; + HbIcon mIcon1; + HbIcon mIcon2; +}; + +class CntCache : public QObject +{ + Q_OBJECT +public: + static CntCache* createSession(void *client, QContactManager *manager); + void closeSession(void *client); + + CntContactInfo* fetchContactInfo(int row, const QList& idList); + QList sortIdsByName(const QSet* idFilter = NULL) const; + QList sortIdsByName(const QStringList &searchList) const; + + bool event(QEvent *event); + +signals: + void contactInfoUpdated(QContactLocalId contactId); + void contactsChanged(const QList &changedContacts); + void contactsRemoved(const QList &removedContacts); + void contactsAdded(const QList &addedContacts); + void dataChanged(); + +private slots: + void startUrgencyMode(); + void stopUrgencyMode(); + void processJobs(); + void postponeJobs(int postponementType, int duration = 0); + void resumeJobs(); + + void updateCachedInfo(QContactLocalId contactId, const ContactInfoField &infoField, const QString &infoValue); + void cancelInfoFetch(QContactLocalId contactId); + void updateCachedIcon(const QString &iconName, const HbIcon &icon); + void cancelIconFetch(const QString &iconName); + + void updateContacts(const QList &changedContacts); + void removeContacts(const QList &removedContacts); + void addContacts(const QList &addedContacts); + + void reformatNames(CntNameOrder newFormat); + void setNameList(QList newSortedNames); + +private: + CntCache(QContactManager *manager); + ~CntCache(); + void loadNames(); + bool contactExists(QContactLocalId contactId) const; + QString contactName(QContactLocalId contactId) const; + CntInfoCacheItem* createInfoCacheItem(QContactLocalId contactId); + CntIconCacheItem* createIconCacheItem(const QString &iconName); + void updateReadAheadCache(int mostRecentRow, const QList &idList); + void emitContactInfoUpdated(QContactLocalId contactId); + +private: + static CntCache *mInstance; // the one and only instance of CntCache + QSet mClients; // the current clients of cache + + QContactManager *mContactManager; // for getting notifications about changes to contacts + CntNameFetcher *mNameFetcher; // fetches contact names + CntInfoFetcher *mInfoFetcher; // fetches secondary text and icon paths + CntIconFetcher *mIconFetcher; // fetches icons + + QList mSortedNames; // list of all contact names, in sorted order + QHash mNameCache; // cache with all contact names, indexed by contact id + QHash mInfoCache; // cache with recent contact info, indexed by contact id + QHash mIconCache; // cache with recent icons, indexed by contact id and icon name + QList > mReadAheadCache; // cache with contacts to prefetch (they are likely to be needed soon) + + QTimer mResumeJobsTimer; // timer used to resume postponed jobs + bool mProcessingJobs; // true from when job loop event has been posted until job loop exits + int mJobsPostponed; // are jobs postponed (no / for some time / until further notice) + bool mIsInUrgencyMode; // true if cache is in urgency mode; secondary info is fetched immediately + int mLastEmittedContactId; // id of the last contact emitted to UI + bool mHasModifiedNames; // monitors whether any names have changed since file cache was last updated + bool mAllNamesFetchStarted; // false until the asynch fetching of all names from the DB has started; + // this operation is done only once + friend class TestCntCache; +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntcacheitems.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntcacheitems.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,145 @@ +/* +* Copyright (c) 2010 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: Classes for each of the items (name, info and icon) in cache. +* +*/ + +#include + +/*! + \class CntNameCacheItem + \brief Represents one name entry in cache. + + CntNameCacheItem wraps functionality for efficiently storing, serializing + and changing the display format of one name in cache. + + \class CntInfoCacheItem + \brief Holds data for info entry in cache. + + \class CntIconCacheItem + \brief Holds data for icon entry in cache. + */ + +/*! + Creates a CntNameCacheItem object. + */ +CntNameCacheItem::CntNameCacheItem(QContactLocalId id, const QString& firstName, const QString& lastName, CntNameOrder nameFormat) +{ + mContactId = id; + setFormattedName(firstName, lastName, nameFormat); +} + +/*! + Destroys the CntNameCacheItem object. + */ +CntNameCacheItem::~CntNameCacheItem() +{ +} + +/*! + Changes the format used to present the name. + */ +void CntNameCacheItem::setNameFormat(CntNameOrder newFormat) +{ + QString firstName = mName.mid(mFirstNamePosition&0xffff, mFirstNamePosition>>16); + QString lastName = mName.mid(mLastNamePosition&0xffff, mLastNamePosition>>16); + setFormattedName(firstName, lastName, newFormat); +} + +/*! + Copies the contents of the other cache item to this one. + */ +void CntNameCacheItem::operator=(const CntNameCacheItem &other) +{ + mContactId = other.mContactId; + mFirstNamePosition = other.mFirstNamePosition; + mLastNamePosition = other.mLastNamePosition; + mName = other.mName; +} + +/*! + Externalizes a CntNameCacheItem object. + */ +void CntNameCacheItem::externalize(QDataStream &stream) +{ + stream << mContactId; + stream << mFirstNamePosition; + stream << mLastNamePosition; + stream << mName; +} + +/*! + Internalizes a CntNameCacheItem object. + */ +CntNameCacheItem* CntNameCacheItem::internalize(QDataStream &stream, CntNameOrder nameFormat) +{ + quint32 id; + quint32 firstNamePosition; + quint32 lastNamePosition; + QString name; + + stream >> id; + stream >> firstNamePosition; + stream >> lastNamePosition; + stream >> name; + + QString firstName = name.mid(firstNamePosition&0xffff, firstNamePosition>>16); + QString lastName = name.mid(lastNamePosition&0xffff, lastNamePosition>>16); + + return new CntNameCacheItem(id, firstName, lastName, nameFormat); +} + +/*! + Sets the formatted name and positions of the first name and last name, + according to the name format in the parameter. + */ +void CntNameCacheItem::setFormattedName(const QString& firstName, const QString& lastName, CntNameOrder nameFormat) +{ + int firstNameLength = firstName.length(); + int lastNameLength = lastName.length(); + + if (lastNameLength == 0) { + mName = firstName; + mFirstNamePosition = firstNameLength << 16; + mLastNamePosition = 0; + } else if (firstNameLength == 0) { + mName = lastName; + mFirstNamePosition = 0; + mLastNamePosition = lastNameLength << 16; + } else { + if (nameFormat == CntOrderLastFirst) { + mName = lastName + " " + firstName; + mFirstNamePosition = (firstNameLength << 16) | (lastNameLength + 1); + mLastNamePosition = (lastNameLength << 16); + } else if (nameFormat == CntOrderLastCommaFirst) { + mName = lastName + ", " + firstName; + mFirstNamePosition = (firstNameLength << 16) | (lastNameLength + 2); + mLastNamePosition = (lastNameLength << 16); + } else { + mName = firstName + " " + lastName; + mFirstNamePosition = (firstNameLength << 16); + mLastNamePosition = (lastNameLength << 16) | (firstNameLength + 1); + } + } +} + +QString CntNameCacheItem::firstName() const +{ + return mName.mid(mFirstNamePosition&0xffff, mFirstNamePosition>>16); +} + +QString CntNameCacheItem::lastName() const +{ + return mName.mid(mLastNamePosition&0xffff, mLastNamePosition>>16); +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntcacheitems.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntcacheitems.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2010 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: Classes for each of the items (name, info and icon) in cache. +* +*/ + +#ifndef CNTCACHEITEMS_H +#define CNTCACHEITEMS_H + +#include +#include +#include + +QTM_USE_NAMESPACE + +class CntNameCacheItem +{ +public: + CntNameCacheItem(QContactLocalId id, const QString &firstName, const QString &lastName, CntNameOrder nameFormat); + ~CntNameCacheItem(); + QContactLocalId contactId() const { return mContactId; } + QString name() const { return mName; } + QString firstName() const; + QString lastName() const; + void setNameFormat(CntNameOrder newFormat); + void operator=(const CntNameCacheItem &other); + void externalize(QDataStream &stream); + static CntNameCacheItem* internalize(QDataStream &stream, CntNameOrder nameFormat); + +private: + void setFormattedName(const QString &firstName, const QString &lastName, CntNameOrder nameFormat); + +private: + QContactLocalId mContactId; // database contact id for this name + int mFirstNamePosition; // length << 16 | offset + int mLastNamePosition; // length << 16 | offset + QString mName; // formatted name +}; + +class CntInfoCacheItem +{ +public: + QContactLocalId contactId; + QString text; + QString icons[2]; + QTime lastRequest; +}; + +class CntIconCacheItem +{ +public: + QString iconName; + HbIcon icon; + QList requestedBy; + QTime lastRequest; +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntdefaultinfoprovider.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntdefaultinfoprovider.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2010 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: Default info provider plugin for CntListModel. It can provide +* the phone number and the image url of a contact (text and +* icon1 field respectively). +* +*/ + +#include +#include "cntdefaultinfoprovider.h" +#include + +/*! + /return the info fields supported by this provider + */ +ContactInfoFields CntDefaultInfoProvider::supportedFields() const +{ + // this provider does not have any info for the icon2 field + return ContactInfoIcon1Field | ContactInfoTextField; +} + +/*! + The contact contains all the info this provider needs, so signals with the requested info + fields are emitted immediately. + + /param contact the contact for which info is requested + /param requestedInfo one or more of the flags in ContactInfoFields + */ +void CntDefaultInfoProvider::requestInfo(const QContact& contact, ContactInfoFields requestedInfo) +{ + if (requestedInfo & ContactInfoTextField) { + QContactDetail detail = contact.preferredDetail("call"); + QString number; + + if (!detail.isEmpty()) + { + number = static_cast(detail).number(); + } + else + { + QList numbers = contact.details(); + if (numbers.count() > 1) + number = hbTrId("txt_phob_dblist_val_ln_numbers", numbers.count()); + else if (numbers.count() == 1) + number = numbers.at(0).number(); + } + + emit infoFieldReady(this, contact.localId(), ContactInfoTextField, number); + } + + if (requestedInfo & ContactInfoIcon1Field) { + QString imageUrl = contact.detail().imageUrl().toString(); + emit infoFieldReady(this, contact.localId(), ContactInfoIcon1Field, imageUrl); + } +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntdefaultinfoprovider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntdefaultinfoprovider.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2010 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: Default info provider plugin for CntListModel. It can provide +* the phone number and the image url of a contact (text and +* icon1 field respectively). +* +*/ + +#ifndef CNTDEFAULTPROVIDER_H +#define CNTDEFAULTPROVIDER_H + +#include +#include + +QTM_USE_NAMESPACE + +/* + The default info provider plugin. It can provide the phone number and the + image url of a contact (text and icon1 field respectively). + */ +class CntDefaultInfoProvider : public CntInfoProvider +{ + friend class TestCntDefaultInfoProvider; + Q_OBJECT + +public: + QString id() const { return "default"; }; + ContactInfoFields supportedFields() const; + void requestInfo(const QContact& contact, ContactInfoFields requestedInfo); + +signals: + void infoFieldReady(CntInfoProvider* sender, int contactId, ContactInfoField field, const QString& value); +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntdisplaytextformatter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntdisplaytextformatter.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,100 @@ +/* +* 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 "cntdisplaytextformatter.h" +#include +#include +#include +#include +#include + +CntHTMLDisplayTextFormatter::CntHTMLDisplayTextFormatter() +{ +} + +CntHTMLDisplayTextFormatter::~CntHTMLDisplayTextFormatter() +{ +} + +QString CntHTMLDisplayTextFormatter::formattedText( const QString aText, const QContactFilter& aCriteria ) +{ + CNT_LOG_ARGS( "filter:" << aText ) + + QString foundPattern; + QString pattern; + QString tempDash; + QString tempSpace; + const QChar dash = '-'; + const QChar space = ' '; + + if ( aCriteria.type() == QContactFilter::ContactDetailFilter ) + { + const QContactDetailFilter& filter = static_cast( aCriteria ); + if ( filter.detailDefinitionName() == QContactDisplayLabel::DefinitionName && + filter.matchFlags() & QContactFilter::MatchStartsWith ) + { + QString formattedText; + // go through the words (e.g. Lastname, Firstname) and apply list of pattern to them. + foreach ( QString text, aText.split(QRegExp("\\s+"), QString::SkipEmptyParts) ) + { + foundPattern = ""; + bool match( false ); + // go through every search criteria word + foreach (pattern, filter.value().toStringList()) + { + tempDash = pattern; + tempSpace = pattern; + tempDash.insert(0, dash); + tempSpace.insert(0, space); + + if ( text.startsWith(pattern, Qt::CaseInsensitive) ) + { + match = true; + if (pattern.length() > foundPattern.length()) + foundPattern = pattern; + } + } + + // if no match found, original text is returned + if ( !match ) + formattedText.append( text ); + // if match is found then the longest variation of the pattern is high lighted, e.g. "a ab" + else + { + insertTag( text, foundPattern.length() ); + formattedText.append( text ); + } + + // put spaces back between words (split() looses them) + formattedText.append( " " ); + } + return formattedText.trimmed(); + } + } + return aText; +} + +void CntHTMLDisplayTextFormatter::insertTag( QString& aText, int aChars ) +{ + QColor highlight = HbColorScheme::color("qtc_lineedit_marker_normal"); + QColor color = HbColorScheme::color("qtc_lineedit_selected"); + + QString start = QString(TAG_START).arg( highlight.name().toUpper() ).arg(color.name().toUpper()); + aText.prepend( start ); + aText.insert( start.length() + aChars, TAG_END ); +} +// End of File diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntdisplaytextformatter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntdisplaytextformatter.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,79 @@ +/* +* 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 CNTDISPLAYTEXTFORMATTER_H_ +#define CNTDISPLAYTEXTFORMATTER_H_ + +#include +#include +QTM_USE_NAMESPACE + +#define TAG_START "" +#define TAG_END "" + +class CntDisplayTextFormatter +{ +public: + virtual ~CntDisplayTextFormatter(){} + virtual QString formattedText( const QString aText, const QContactFilter& aCriteria ) = 0; +}; + +class CntDummyDisplayTextFormatter : public QObject, public CntDisplayTextFormatter +{ + Q_OBJECT +public: + CntDummyDisplayTextFormatter(){} + ~CntDummyDisplayTextFormatter(){} + + inline QString formattedText( const QString aText, const QContactFilter& aCriteria ) + { + Q_UNUSED( aCriteria ); + return aText; + } +}; + +class CntHTMLDisplayTextFormatter : public QObject, public CntDisplayTextFormatter +{ + Q_OBJECT + +public: + CntHTMLDisplayTextFormatter(); + virtual ~CntHTMLDisplayTextFormatter(); + + /*! + * Format given text with applied filter. Not that only following filter is supported: + * + * QContactDetailFilter filter; + * filter.setDetailDefinitionName( QContactDisplayLabel::DefinitionName ); + * filter.setMatchFlags( QContactDetailFilter::MatchStartsWith ); + * + * \param aText Buffer where to format + * \param aCriteria Applied filter + */ + QString formattedText( const QString aText, const QContactFilter& aCriteria ); + + /*! + * Insert tag to given text leaving given number + * of characters between start and end tag. + * By default highlight is inserted. + * + * \param aText Buffer where to insert tags + * \param aNumOfCharacters Number of characters to highlight + */ + virtual void insertTag( QString& aText, int aNumOfCharacters ); +}; +#endif /* CNTDISPLAYTEXTFORMATTER_H_ */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cnticonfetcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cnticonfetcher.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2010 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: Fetches icons for contacts. +* +*/ + +#include +#include +#include + +// maximum amount of scheduled jobs; if there are more jobs, the least +// important job is cancelled +const int MaxIconJobs = 20; + +// the id that states that no icon is currently pending from thumbnail manager +const int NoIconRequest = -1; + +/*! + \class CntIconJob + \brief Holds info about one icon job. + */ + +/*! + \class CntIconFetcher + \brief CntIconFetcher asynchronously fetches contact icons. + + CntIconFetcher queues requests for contact icons that are to be cached. + It fetches the icons later, when asked by the client to do so. + + Internally CntIconFetcher uses thumbnail manager to fetch the icons. + */ + +/*! + Creates a CntIconFetcher object. + */ +CntIconFetcher::CntIconFetcher() + : CntAbstractFetcher(MaxIconJobs), + mThumbnailManager(NULL), + mIconRequestId(NoIconRequest) +{ + CNT_ENTRY + + // create & connect the thumbnail manager + mThumbnailManager = new ThumbnailManager(this); + mThumbnailManager->setMode(ThumbnailManager::Default); + mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForPerformance); + mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailSmall); + connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)), + this, SLOT(forwardIconToClient(QPixmap, void *, int, int))); + + CNT_EXIT +} + +/*! + Cleans up and destructs the CntIconFetcher object. + */ +CntIconFetcher::~CntIconFetcher() +{ + CNT_ENTRY + + if (mIconRequestId != NoIconRequest) { + mThumbnailManager->cancelRequest(mIconRequestId); + } + + delete mThumbnailManager; + mThumbnailManager = NULL; + + CNT_EXIT +} + +/*! + Processes the next scheduled job. This function must not be + called until the previous job has completed. + */ +void CntIconFetcher::processNextJob() +{ + CNT_ENTRY + + Q_ASSERT(mIconRequestId == NoIconRequest); + + if (hasScheduledJobs()) { + // request icon from thumbnail manager + CntIconJob *job = static_cast(takeNextJob()); + mIconRequestName = job->iconName; + mIconRequestId = mThumbnailManager->getThumbnail(mIconRequestName, NULL, 0); + delete job; + } else if (hasCancelledJobs()) { + CntIconJob *job = static_cast(takeNextCancelledJob()); + emit iconCancelled(job->iconName); + delete job; + } + + CNT_EXIT +} + +/*! + \return true if a job is currently being processed; otherwise returns false. + */ +bool CntIconFetcher::isProcessingJob() +{ + return (mIconRequestId != NoIconRequest); +} + +/*! + Forwards an icon from thumbnail manager to the client. + */ +void CntIconFetcher::forwardIconToClient(const QPixmap &pixmap, void *data, int id, int error) +{ + CNT_ENTRY + + Q_UNUSED(data); + + if (id != mIconRequestId) { + // this pixmap was requested by someone else sharing the same thumbnail manager instance + CNT_EXIT_ARGS("not our pixmap") + return; + } + + mIconRequestId = NoIconRequest; + + if (error == 0) { + emit iconFetched(mIconRequestName, HbIcon(pixmap)); + } else { + emit iconFetched(mIconRequestName, HbIcon()); + } + + CNT_EXIT +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cnticonfetcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cnticonfetcher.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2010 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: Private data and helper classes used by class CntCache. +* +*/ + +#ifndef CNTICONFETCHER_H +#define CNTICONFETCHER_H + +#include +#include + +class ThumbnailManager; + +QTM_USE_NAMESPACE + +class CntIconJob : public CntAbstractJob +{ +public: + CntIconJob(QString iconName) { this->iconName = iconName; } + bool isEmpty() { return iconName.isEmpty(); } + bool equals(const CntAbstractJob &other) { const CntIconJob *o = static_cast(&other); return (iconName == o->iconName); } + QString toString() { return QString("iconName = '%1'").arg(iconName); } + +public: + QString iconName; // set by requester + HbIcon icon; // set by icon fetcher +}; + +class CntIconFetcher : public CntAbstractFetcher +{ + Q_OBJECT +public: + CntIconFetcher(); + ~CntIconFetcher(); + + bool isProcessingJob(); + void processNextJob(); + +signals: + void iconFetched(const QString &iconName, const HbIcon &icon); + void iconCancelled(const QString &iconName); + +private slots: + void forwardIconToClient(const QPixmap &pixmap, void *data, int id, int error); + +private: + ThumbnailManager *mThumbnailManager; // manager that fetches the icons; owned + int mIconRequestId; // the id of the last request to thumbnail manager + QString mIconRequestName; // the name of the icon last requested from thumbnail manager + + friend class TestIconFetcher; +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntinfofetcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntinfofetcher.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,171 @@ +/* +* Copyright (c) 2010 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: Fetches visual info about contacts. +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + \class CntInfoCacheItem + \brief Cache item that holds some visual info about a contact. + */ + +/*! + \class CntInfoFetcher + \brief CntInfoFetcher asynchronously fetches visual info about contacts. + + CntInfoFetcher queues requests for contact info that is to be cached. + It fetches the info later, when asked by the client to do so. + + There are three pieces of info that is fetched: + - secondary text, e.g. phone number + - primary icon, e.g. avatar for contact + - secondary icon, e.g. presence status + + Internally CntInfoFetcher uses plugins (info providers) to fetch the data. + */ + +// maximum amount of scheduled jobs; if there are more jobs, the least +// important job is cancelled +const int MaxInfoJobs = 20; + +// directory of info providers +const char *CNT_INFO_PROVIDER_EXTENSION_PLUGIN_DIRECTORY = "/resource/qt/plugins/contacts/infoproviders/"; + +/*! + Creates a CntIconFetcher object. + */ +CntInfoFetcher::CntInfoFetcher(QContactManager *contactManager) + : CntAbstractFetcher(MaxInfoJobs), + mContactManager(contactManager) +{ + CNT_ENTRY + + // create static info provider plugins + mInfoProviders.insert(new CntDefaultInfoProvider(), ContactInfoAllFields); + mInfoProviders.insert(new CntPresenceInfoProvider(), ContactInfoIcon2Field); + + // load dynamic info provider plugins + QDir pluginsDir(CNT_INFO_PROVIDER_EXTENSION_PLUGIN_DIRECTORY); + foreach (QString fileName, pluginsDir.entryList(QDir::Files)) { + // create plugin loader + QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); + if (pluginLoader.load()) { + CntInfoProviderFactory *factory = qobject_cast(pluginLoader.instance()); + if (factory) { + CntInfoProvider *provider = factory->infoProvider(); + mInfoProviders.insert(provider, provider->supportedFields()); + } + } + } + + // connect the providers + QMapIterator i(mInfoProviders); + while (i.hasNext()) { + i.next(); + connect(static_cast(i.key()), + SIGNAL(infoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&)), + this, + SLOT(forwardInfoToClient(CntInfoProvider*, int, ContactInfoField, const QString&))); + } + + CNT_EXIT +} + +/*! + Cleans up and destructs the CntIconFetcher object. + */ +CntInfoFetcher::~CntInfoFetcher() +{ + CNT_ENTRY + + qDeleteAll(mInfoProviders.keys()); + mInfoProviders.clear(); + + CNT_EXIT +} + +/*! + Processes the next scheduled job. This function must not be + called until the previous job has completed. + */ +void CntInfoFetcher::processNextJob() +{ + CNT_ENTRY + + if (hasScheduledJobs()) { + // get the next job + CntInfoJob *job = static_cast(takeNextJob()); + + // fetch a QContact object + QContactFetchHint restrictions; + restrictions.setOptimizationHints(QContactFetchHint::NoRelationships); + QContact contact = mContactManager->contact(job->contactId, restrictions); + + // request contact info from providers + QMapIterator i(mInfoProviders); + while (i.hasNext()) { + i.next(); + if (i.value() != 0) { + i.key()->requestInfo(contact, i.value()); + } + } + + delete job; + } else if (hasCancelledJobs()) { + CntInfoJob *cancelledJob = static_cast(takeNextCancelledJob()); + emit infoCancelled(cancelledJob->contactId); + delete cancelledJob; + } + + CNT_EXIT +} + +/*! + \return true if a job is currently being processed; otherwise returns false. + */ +bool CntInfoFetcher::isProcessingJob() +{ + return false; +} + +/*! + Forward info from a provider to the client. + */ +void CntInfoFetcher::forwardInfoToClient(CntInfoProvider *sender, + int contactId, + ContactInfoField field, + const QString &text) +{ + CNT_ENTRY + + // there can be 3rd party info providers, so we cannot blindly trust them; + // info is emitted iff: + if (mInfoProviders.contains(sender) + && ((field & (field - 1)) == 0) // 1) exactly one field bit is set in parameter 'field' + && ((field & mInfoProviders.value(sender)) != 0)) { // 2) the field bit has been assigned to this provider + emit infoUpdated(contactId, field, text); + } + + CNT_EXIT +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntinfofetcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntinfofetcher.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2010 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: Fetches visual info about contacts. +* +*/ + +#ifndef CNTINFOFETCHER_H +#define CNTINFOFETCHER_H + +#include +#include +#include +#include + +QTM_USE_NAMESPACE + +class CntInfoJob : public CntAbstractJob +{ +public: + CntInfoJob(QContactLocalId contactId) { this->contactId = contactId; } + virtual bool isEmpty() { return (contactId == 0); } + virtual bool equals(const CntAbstractJob &other) { return (contactId == static_cast(&other)->contactId); } + QString toString() { return QString("cid = %1").arg(contactId); } + +public: + QContactLocalId contactId; +}; + +class CntInfoFetcher : public CntAbstractFetcher +{ + Q_OBJECT +public: + CntInfoFetcher(QContactManager *contactManager); + ~CntInfoFetcher(); + + bool isProcessingJob(); + void processNextJob(); + +signals: + void infoUpdated(QContactLocalId contactId, ContactInfoField field, const QString &text); + void infoCancelled(QContactLocalId contactId); + +private slots: + void forwardInfoToClient(CntInfoProvider* sender, int contactId, + ContactInfoField field, const QString& text); + +private: + QContactManager *mContactManager; // manager that fetches QContact objects; not owned + QMap mInfoProviders; // maps info providers to their responsibilities + + friend class TestInfoFetcher; +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntlistmodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntlistmodel.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,777 @@ +/* +* 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + \class CntListModel + \brief List model for list with contacts. + + CntListModel is a list model view for contacts database content. It uses + CntCache to fetch and cache entries displayed on the screen. + */ + +const uint dummyMyCardId = 0; + +/*! + Construct a new CntListModel object using manager as the QContactManager + instance to communicate with the contacts database. + + \param manager a QContactManager instance to be used for communications + with the contacts persistant store + \param filter a filter that selects the contacts to show in the list + \param showMyCard true if my card entry should be shown at the top of + the list, otherwise false + \param parent parent of this QObject + */ +CntListModel::CntListModel(QContactManager* manager, + const QContactFilter& filter, + bool showMyCard, + QObject *parent) + : QAbstractListModel(parent) +{ + CNT_ENTRY + + // set up data + d = new CntListModelData(manager, filter, showMyCard); + + // fetch IDs + updateContactIdsArray(); + + // get current setting how to show an item in the name list and subscribe for changes + d->mSettings = new XQSettingsManager; + d->mNameListRowSettingkey = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, + KCRCntSettings.iUid, + KCntNameListRowSetting); + d->mCurrentRowSetting = d->mSettings->readItemValue(*d->mNameListRowSettingkey, + XQSettingsManager::TypeInt).toInt(); + d->mSettings->startMonitoring(*d->mNameListRowSettingkey, XQSettingsManager::TypeInt); + connect(d->mSettings, SIGNAL(valueChanged(const XQSettingsKey&, const QVariant&)), + this, SLOT(handleRowSettingChanged(const XQSettingsKey&, const QVariant&))); + + // listen to cache for changes in contacts + connect(d->mCache, SIGNAL(contactInfoUpdated(QContactLocalId)), + this, SLOT(handleContactInfoUpdated(QContactLocalId))); + connect(d->mCache, SIGNAL(contactsAdded(const QList&)), + this, SLOT(handleAdded(const QList&))); + connect(d->mCache, SIGNAL(contactsChanged(const QList&)), + this, SLOT(handleChanged(const QList&))); + connect(d->mCache, SIGNAL(contactsRemoved(const QList&)), + this, SLOT(handleRemoved(const QList&))); + connect(d->mCache, SIGNAL(dataChanged()), + this, SLOT(refreshModel())); + + // listen to contactmanager for changes in relationships or mycard + connect(d->mContactManager, SIGNAL(selfContactIdChanged(const QContactLocalId&, const QContactLocalId&)), + this, SLOT(handleMyCardChanged(const QContactLocalId&, const QContactLocalId&))); + connect(d->mContactManager, SIGNAL(relationshipsAdded(const QList&)), + this, SLOT(handleAddedRelationship(const QList&))); + connect(d->mContactManager, SIGNAL(relationshipsRemoved(const QList&)), + this, SLOT(handleRemovedRelationship(const QList&))); + + CNT_EXIT +} + +CntListModel::~CntListModel() +{ +} + +/*! + Return the data to be used by the view or delegates for a particular + item and role. + + \param index The index of the item to return data about. + \param role The data should be relevant for this particular purpose. + \return QVariant The data for the specified index and role. +*/ +QVariant CntListModel::data(const QModelIndex &index, int role) const +{ + CNT_ENTRY + + QVariant returnData; + int row = index.row(); + + // check that row is ok + if (!isValidRow(row)) { + // invalid row + return QVariant(); + } + + // update current contact if needed + if (row != d->mCurrentRow) { + delete d->mCurrentContact; + if (d->mContactIds[row] == dummyMyCardId) { + // row contains dummy MyCard, so create dummy CntContactInfo + d->mCurrentContact = NULL; + } else { + d->mCurrentContact = d->mCache->fetchContactInfo(row, d->mContactIds); + } + d->mCurrentRow = row; + } + + if (role == Qt::DisplayRole) { + returnData = dataForRole(row, role); + } else if (role == Hb::IndexFeedbackRole) { + if (row > 0 || (d->mMyCardId != d->mContactIds[0] && dummyMyCardId != d->mContactIds[0])) { + returnData = dataForRole(row, role).toStringList().at(0).toUpper(); + } + } else if (role == Qt::BackgroundRole) { + if (d->mMyCardId == d->mContactIds[row] || dummyMyCardId == d->mContactIds[row]) { + returnData = HbFrameBackground("qtg_fr_list_parent_normal", HbFrameDrawer::NinePieces); + } + } else if (role == Qt::DecorationRole) { + if (d->mCurrentRowSetting == CntTwoRowsNameAndPhoneNumber) { + //icon fits only if user selected 2 rows in each name list item + QList icons; + + if (d->mCurrentContact != NULL && !d->mCurrentContact->icon1().isNull()) { + icons.append(d->mCurrentContact->icon1()); + } else if (d->mMyCardId == d->mContactIds[row] || dummyMyCardId == d->mContactIds[row]) { + icons.append(d->mDefaultMyCardIcon); + } else { + icons.append(d->mDefaultIcon); + } + + if (d->mCurrentContact != NULL && !d->mCurrentContact->icon2().isNull()) { + icons.append(d->mCurrentContact->icon2()); + } + + returnData = icons; + } + } + + CNT_EXIT + return returnData; +} + +/*! + Get the number of rows (contacts) in this model. + + \param parent Optional parent index value. + \return Number of contacts in this model. + */ +int CntListModel::rowCount(const QModelIndex& /*parent*/) const +{ + return d->mContactIds.count(); +} + +/*! + Read a full contact entry from the database for the given model + index value. Only the row part of the index information will be + read. This is just an overload of CntListModel::contact() that + supports old behaviour and calls: + CntListModel::contact(int row); + + The entry at the requested row will have its full contact information + (all fields) read from the database and returned as a QContact instance. + + \param index Index for the sought contact entry in this model. + \return A newly constructed QContact instance for this entry - ownership + is transferred to the caller. + */ +QContact CntListModel::contact(const QModelIndex &index) const +{ + return contact(index.row()); +} + +/*! + Returns the id for the contact at the requested row. + + \param index Index for the sought contact entry in this model. + \return The id for the contact, 0 if invalid index. + */ +QContactLocalId CntListModel::contactId(const QModelIndex &index) const +{ + CNT_ENTRY + + if (!isValidRow(index.row())) { + return 0; + } + + CNT_EXIT + return d->mContactIds[index.row()]; +} + +/*! + Return an index that points to the row relating to the supplied contact. + E.g. if the contact is at row 7, the index with the following properties + is returned: + index.row() == 7 + + \param contact The contact for whose row an index is required + \return a QModelIndex with the row set to match that of the contact. + */ +QModelIndex CntListModel::indexOfContact(const QContact &contact) const +{ + return createIndex(row(contact.localId()), 0); +} + +/*! + Return an index that points to the row relating to the supplied contact id. + E.g. if the contact with this id is at row 7, the index with the following + properties is returned: + index.row() == 7 + + \param contactId The id of the contact for whose row an index is required + \return a QModelIndex with the row set to match that of the contact id. + */ +QModelIndex CntListModel::indexOfContactId(const QContactLocalId &contactId) const +{ + return createIndex(row(contactId), 0); +} + +/*! + Set new filter and sort order for the model. + + \param contactFilter New contact filter. + */ +void CntListModel::setFilter(const QContactFilter& contactFilter) +{ + CNT_ENTRY + + d->setFilter(contactFilter); + + //refresh model + updateContactIdsArray(); + + beginResetModel(); + endResetModel(); + + CNT_EXIT +} + +/*! + Enable/disable MyCard appearance in the model. + + \param enabled Status of MyCard appearance in the model. + */ +void CntListModel::showMyCard(bool enabled) +{ + CNT_ENTRY + + if (d->mShowMyCard == enabled) { + return; + } + + QContactLocalId myCardId = d->mMyCardId; + if (enabled) { + //add MyCard to the list + if (myCardId <= 0) { + // create a placeholder for MyCard + d->mContactIds.insert(0, dummyMyCardId); + } else { + d->mContactIds.insert(0, myCardId); + } + } else { + // remove MyCard from the list + if (myCardId <= 0) { + d->mContactIds.removeOne(dummyMyCardId); + } else { + d->mContactIds.removeOne(myCardId); + } + } + d->mShowMyCard = enabled; + d->mCurrentRow = -1; + + beginResetModel(); + reset(); + endResetModel(); + + CNT_EXIT +} + +/*! + \return true if MyCard is shown, false otherwise. + */ +bool CntListModel::isMyCardShown() const +{ + return d->mShowMyCard; +} + +/*! + \return the id of the MyCard contact. + */ +QContactLocalId CntListModel::myCardId() const +{ + return d->mMyCardId; +} + +/*! + Gets the filtered list of the contact Ids in a sorted order + + \return Error status + */ +void CntListModel::updateContactIdsArray() +{ + CNT_ENTRY + + QContactDetailFilter* detailFilter = NULL; + + if (d->mFilter.type() == QContactFilter::ContactDetailFilter) { + detailFilter = static_cast(&d->mFilter); + } + + // special handling for all-contacts filter + if (detailFilter + && detailFilter->detailDefinitionName() == QContactType::DefinitionName + && detailFilter->detailFieldName() == QContactType::FieldType + && detailFilter->value() == QContactType::TypeContact) { + d->mContactIds = d->mCache->sortIdsByName(NULL); + } else if (detailFilter + && detailFilter->detailDefinitionName() == QContactDisplayLabel::DefinitionName + && detailFilter->detailFieldName() == QContactDisplayLabel::FieldLabel + && detailFilter->matchFlags() == Qt::MatchStartsWith) { + QStringList searchList = detailFilter->value().toStringList(); + d->mContactIds = d->mCache->sortIdsByName(searchList); + } else { + QSet filterIds = d->mContactManager->contactIds(d->mFilter).toSet(); + d->mContactIds = d->mCache->sortIdsByName(&filterIds); + } + + //find MyCard contact and move it to the first position + QContactLocalId myCardId = d->mMyCardId; + if (myCardId > 0) { + // MyCard exists + d->mContactIds.removeOne(myCardId); + if (d->mShowMyCard) { + d->mContactIds.insert(0, myCardId); + } + } else if (d->mShowMyCard) { + // create a placeholder for MyCard + d->mContactIds.insert(0, dummyMyCardId); + } + + CNT_EXIT +} + +/*! + Read a full contact entry from the database for the row number. + + The entry at the requested row will have its full contact information + (all fields) read from the database and returned as a QContact instance. + + \param row Row at which the sought contact entry is in this model. + \return A newly constructed QContact instance for this entry - ownership + is transferred to the caller. + */ +QContact CntListModel::contact(int row) const +{ + CNT_ENTRY + + if (!isValidRow(row) || d->mContactIds[row] == dummyMyCardId) { + return QContact(); + } + + CNT_EXIT + return d->mContactManager->contact(d->mContactIds[row]); +} + +/*! + Verify specified row id is valid. + + \param row A row number + \return bool indicating validity of row id + */ +bool CntListModel::isValidRow(int row) const +{ + return (row >= 0 && row < rowCount()); +} + +/*! + Fetch the row containing the contact with the specified id. + + \param contactId The id of the contact + \return the row of the contact or -1 if no item matched. + */ +int CntListModel::row(const QContactLocalId &contactId) const +{ + return d->mContactIds.indexOf(contactId); +} + +/*! + Return the data to be used by the view for a display role. + + \param row The row of the item to return data about. + \param column The column of the item to return data about. + \return QVariant The data for the specified index. + */ +QVariant CntListModel::dataForRole(int row, int role) const +{ + CNT_ENTRY + + QStringList list; + QString name; + QString infoText; + bool isSelfContact = false; + bool isNonEmptySelfContact = false; + + QContactLocalId id = d->mContactIds[row]; + if (d->mMyCardId == id || dummyMyCardId == id) { + isSelfContact = true; + if (d->mCurrentContact == NULL) { + // empty card + name = hbTrId("txt_phob_dblist_mycard"); + infoText = hbTrId("txt_phob_dblist_mycard_val_create_my_identity"); + } else { + isNonEmptySelfContact = true; + } + } + + if (!isSelfContact || isNonEmptySelfContact) { + name = d->mCurrentContact->name(); + if (name.isEmpty()) { + name = hbTrId("txt_phob_list_unnamed"); + } + infoText = d->mCurrentContact->text(); + } + + if (role == Qt::DisplayRole) { + list << d->mFormat->formattedText(name, d->mFilter); + } else { + list << name; + } + + if (!isNonEmptySelfContact) { + if (d->mCurrentRowSetting == CntTwoRowsNameAndPhoneNumber) { + //add additional text only if user wants 2 rows in each name list item + list << infoText; + } + } + + CNT_EXIT + return list; +} + +/*! + Handle adding of contacts. + + \param contactIds Ids of contacts added. + */ +void CntListModel::handleAdded(const QList& contactIds) +{ + CNT_ENTRY + + // if contacts are added already, no need to do anything + bool newContacts = false; + for (int k = 0; k < contactIds.count() && !newContacts; k++) { + if (!d->mContactIds.contains(contactIds.at(k))) { + newContacts = true; + } + } + if (!newContacts) { + return; + } + + // invalidate cached contact + d->mCurrentRow = -1; + + QList oldIdList = d->mContactIds; + updateContactIdsArray(); + + QList newRows; + for (int i = 0; i < d->mContactIds.count(); i++) { + if (!oldIdList.contains(d->mContactIds.at(i))) { + newRows.append(i); + } + } + + if (newRows.size() == 1) { + beginInsertRows(QModelIndex(), newRows.at(0), newRows.at(0)); + endInsertRows(); + } else { + beginResetModel(); + reset(); + endResetModel(); + } + + CNT_EXIT +} + +/*! + Handle changes in contacts. + + \param contactIds Ids of contacts changed. + */ +void CntListModel::handleChanged(const QList& contactIds) +{ + CNT_ENTRY + + if (contactIds.count() == 0) { + return; + } + + //invalidate cached contact + d->mCurrentRow = -1; + + int firstChangedContactPosBefore = row(contactIds.at(0)); + updateContactIdsArray(); + int firstChangedContactPosAfter = row(contactIds.at(0)); + + // if only one contact was updated and its position didn't change, + // refresh the corresponding row + if (contactIds.count() == 1 && + firstChangedContactPosBefore == firstChangedContactPosAfter && + firstChangedContactPosBefore >= 0) { + QModelIndex top = index(firstChangedContactPosBefore); + QModelIndex bottom = index(firstChangedContactPosBefore); + emit dataChanged(top, bottom); + } else { + beginResetModel(); + reset(); + endResetModel(); + } + + CNT_EXIT +} + +/*! + Handle removing of contacts. + + \param contactIds Ids of contacts removed. + */ +void CntListModel::handleRemoved(const QList& contactIds) +{ + CNT_ENTRY + + bool removeContacts = false; + QList idList = d->mContactIds; + for (int k = 0; k < contactIds.count() && !removeContacts; k++) { + if(idList.contains(contactIds.at(k))) { + removeContacts = true; + } + } + if (!removeContacts) { + return; + } + + //Find contacts to remove (=rows) + QList removeRows; + for(int i = 0; i < contactIds.count(); i++) { + if (idList.contains(contactIds.at(i))) { + removeRows.append(row(contactIds.at(i))); + } + } + + // invalidate cached contact + d->mCurrentRow = -1; + + int myCardRow = -1; + if (contactIds.contains(d->mMyCardId)) { + myCardRow = row(d->mMyCardId); + d->mMyCardId = 0; + } + + // remove rows starting from the bottom + qSort(removeRows.begin(), removeRows.end(), qGreater()); + foreach (int row, removeRows) { + if (row != myCardRow || !d->mShowMyCard) { + beginRemoveRows(QModelIndex(), row, row); + endRemoveRows(); + } + } + + foreach (QContactLocalId id, contactIds) { + d->mContactIds.removeOne(id); + } + + if (myCardRow != -1 && d->mShowMyCard) { + d->mContactIds.insert(0, dummyMyCardId); + QModelIndex index = createIndex(0, 0); + emit dataChanged(index, index); + } + + CNT_EXIT +} + +/*! + Handle my card change. + + \param oldId Id of the old MyCard. + \param newId Id of the new MyCard. + */ +void CntListModel::handleMyCardChanged(const QContactLocalId& /*oldId*/, const QContactLocalId& newId) +{ + CNT_ENTRY + + //invalidate cached contact + d->mCurrentRow = -1; + d->mMyCardId = newId; + + updateContactIdsArray(); + + beginResetModel(); + reset(); + endResetModel(); + + CNT_EXIT +} + +/*! + Handle added relationships. + + \param contactIds Ids of contacts added (group id and contact ids). + */ +void CntListModel::handleAddedRelationship(const QList& contactIds) +{ + CNT_ENTRY + + if (contactIds.contains(d->mGroupId)) { + foreach (QContactLocalId id, contactIds) { + if (id != d->mGroupId && !d->mContactIds.contains(id)) { + // at least one new contact id has been added to this group, + // so update the model + updateRelationships(); + break; + } + } + } + + CNT_EXIT +} + +/*! + Handle removed relationships. + + \param contactIds Ids of contacts removed from a relationship (group id and contact ids). + */ +void CntListModel::handleRemovedRelationship(const QList& contactIds) +{ + CNT_ENTRY + + if (contactIds.contains(d->mGroupId)) { + foreach (QContactLocalId id, contactIds) { + if (d->mContactIds.contains(id)) { + // at least one new contact id has been removed from this group, + // so update the model + updateRelationships(); + break; + } + } + } + + CNT_EXIT +} + +/*! + Updates the model to reflect changes in the relationships. + */ +void CntListModel::updateRelationships() +{ + CNT_ENTRY + + //invalidate cached contact + d->mCurrentRow = -1; + + QList oldIdList = d->mContactIds; + updateContactIdsArray(); + + // find all changed rows + QList newRows, removedRows; + for (int i = 0; i < d->mContactIds.count(); i++) { + if (!oldIdList.contains(d->mContactIds.at(i))) { + newRows.append(i); + } + } + for (int i = 0; i < oldIdList.count(); i++) { + if (!d->mContactIds.contains(oldIdList.at(i))) { + removedRows.append(i); + } + } + + // currently only one-row-changes are handled with beginInsertRows/beginRemoveRows + // if there are more than one change, the whole model is reset + if (removedRows.count() == 1 && newRows.count() == 0) { + beginRemoveRows(QModelIndex(), removedRows.at(0), removedRows.at(0)); + endRemoveRows(); + } else if (newRows.count() == 1 && removedRows.count() == 0) { + beginInsertRows(QModelIndex(), newRows.at(0), newRows.at(0)); + endInsertRows(); + } else { + beginResetModel(); + endResetModel(); + } + + CNT_EXIT +} + +/*! + Notify views that info for a contact has become + available or has changed. + + \param contactId the id of the contact + */ +void CntListModel::handleContactInfoUpdated(QContactLocalId contactId) +{ + CNT_ENTRY + + QModelIndex index = createIndex(row(contactId), 0); + if (index.row() == d->mCurrentRow) { + d->mCurrentRow = -1; + } + + if (isValidRow(index.row())) { + emit dataChanged(index, index); + } + + CNT_EXIT +} + +/*! + Handle a change in how name list item should be represented. + + \param key Central repository key + \param value New value in the key + */ +void CntListModel::handleRowSettingChanged(const XQSettingsKey& /*key*/, const QVariant& value) +{ + bool ok = false; + int newSetting = value.toInt(&ok); + if (ok) { + d->mCurrentRowSetting = newSetting; + + if (rowCount() > 0) { + QModelIndex first = createIndex(0, 0); + QModelIndex last = createIndex(rowCount() - 1, 0); + emit dataChanged(first, last); + } + } +} + +/*! + Handle a change in data. + */ +void CntListModel::refreshModel() +{ + d->mCurrentRow = -1; + + updateContactIdsArray(); + + beginResetModel(); + reset(); + endResetModel(); +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntlistmodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntlistmodel.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,84 @@ +/* +* 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 CNTLISTMODEL_H +#define CNTLISTMODEL_H + +#include +#include +#include +#include +#include +#include +#include + +QTM_USE_NAMESPACE + +class CntListModelData; +class XQSettingsKey; +class CntDisplayTextFormatter; + +class CNTLISTMODEL_EXPORT CntListModel : public QAbstractListModel +{ + Q_OBJECT +public: + CntListModel(QContactManager *manager, + const QContactFilter &contactFilter = QContactFilter(), + bool showMyCard = true, + QObject *parent = 0); + ~CntListModel(); + +public: // from QAbstractTableModel/QAbstractItemModel + QVariant data(const QModelIndex &index, int role) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + +public: + QContact contact(const QModelIndex &index) const; + QContactLocalId contactId(const QModelIndex &index) const; + QModelIndex indexOfContact(const QContact &contact) const; + QModelIndex indexOfContactId(const QContactLocalId &contactId) const; + void setFilter(const QContactFilter& contactFilter = QContactFilter()); + void showMyCard(bool enabled); + bool isMyCardShown() const; + QContactLocalId myCardId() const; + +private: + void updateContactIdsArray(); + QContact contact(int row) const; + bool isValidRow(int row) const; + int row(const QContactLocalId &contactId) const; + QVariant dataForRole(int row, int role) const; + void updateRelationships(); + +private slots: + void handleAdded(const QList &contactIds); + void handleChanged(const QList &contactIds); + void handleRemoved(const QList &contactIds); + void handleMyCardChanged(const QContactLocalId &oldId, const QContactLocalId &newId); + void handleContactInfoUpdated(QContactLocalId contactId); + void handleAddedRelationship(const QList &contactIds); + void handleRemovedRelationship(const QList &contactIds); + void handleRowSettingChanged(const XQSettingsKey &key, const QVariant &value); + void refreshModel(); + +private: + QSharedDataPointer d; + + friend class TestCntListModel; +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntlistmodel.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntlistmodel.pro Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,74 @@ +# 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: +TEMPLATE = lib +TARGET = cntlistmodel +DEFINES += dll \ + BUILD_CNTLISTMODEL + +MOC_DIR = moc + +CONFIG += hb + +TARGET.CAPABILITY = CAP_GENERAL_DLL +TARGET.EPOCALLOWDLLDATA = 1 +TARGET.UID3 = 0x20026FC3 + +INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE +INCLUDEPATH += . +INCLUDEPATH += ../../inc + +HEADERS += cntlistmodelglobal.h \ + cntlistmodel.h \ + cntlistmodel_p.h \ + cntcache.h \ + cntcacheitems.h \ + cntabstractfetcher.h \ + cntnamefetcher.h \ + cntinfofetcher.h \ + cnticonfetcher.h \ + cntdefaultinfoprovider.h \ + cntpresenceinfoprovider.h \ + cntdisplaytextformatter.h \ + ../../inc/cntdebug.h + +SOURCES += cntlistmodel.cpp \ + cntlistmodel_p.cpp \ + cntcache.cpp \ + cntcacheitems.cpp \ + cntabstractfetcher.cpp \ + cntnamefetcher.cpp \ + cntinfofetcher.cpp \ + cnticonfetcher.cpp \ + cntdefaultinfoprovider.cpp \ + cntpresenceinfoprovider.cpp \ + cntdisplaytextformatter.cpp + +LIBS += -lQtContacts \ + -lhbcore \ + -lthumbnailmanagerqt \ + -lpresencecacheqt \ + -lxqsettingsmanager \ + -lestor \ + -lefsrv \ + -lxqutils + +DEPLOYMENT += exportheaders + +:BLD_INF_RULES.prj_exports += "../../contacts_plat/contacts_ui_extensions_api/inc/cntinfoproviderfactory.h APP_LAYER_PLATFORM_EXPORT_PATH(cntinfoproviderfactory.h)" +:BLD_INF_RULES.prj_exports += "../../contacts_plat/contacts_ui_extensions_api/inc/cntinfoprovider.h APP_LAYER_PLATFORM_EXPORT_PATH(cntinfoprovider.h)" + +defBlock = "$${LITERAL_HASH}if defined(EABI)" \ + "DEFFILE ../eabi/cntlistmodel.def" \ + "$${LITERAL_HASH}else" \ + "DEFFILE ../bwins/cntlistmodel.def" \ + "$${LITERAL_HASH}endif" +MMP_RULES += defBlock +symbian:MMP_RULES += SMPSAFE \ No newline at end of file diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntlistmodel_p.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntlistmodel_p.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,110 @@ +/* +* 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: Private data for CntListModel. +* +*/ + +#include +#include +#include +#include +#include +#include +#include + +/*! + \class CntListModel + \brief Private data for CntListModel. + */ + +/*! + Initializes all data. + */ +CntListModelData::CntListModelData(QContactManager *manager, const QContactFilter &filter, bool showMyCard) + : mContactManager(manager), + mCache(CntCache::createSession(this, manager)), + mGroupId(0), + mCurrentContact(NULL), + mCurrentRow(-1), + mShowMyCard(showMyCard), + mMyCardId(manager->selfContactId()), + mSettings(NULL), + mNameListRowSettingkey(NULL), + mCurrentRowSetting(0), + mFormat(new CntDummyDisplayTextFormatter), + mDefaultIcon(HbIcon("qtg_large_avatar")), + mDefaultMyCardIcon(HbIcon("qtg_large_avatar_mycard")) +{ + CNT_ENTRY + + setFilter(filter); + + CNT_EXIT +} + +/*! + Cleans up all data. + */ +CntListModelData::~CntListModelData() +{ + CNT_ENTRY + + mCache->closeSession(this); + + delete mSettings; + delete mNameListRowSettingkey; + delete mFormat; + delete mCurrentContact; + + CNT_EXIT +} + +/*! + Sets the filter for selecting contacts in the list. + */ +void CntListModelData::setFilter(const QContactFilter& contactFilter) +{ + CNT_ENTRY_ARGS(contactFilter.type()) + + mFilter = contactFilter; + mCurrentRow = -1; + if (contactFilter.type() == QContactFilter::RelationshipFilter) { + QContactRelationshipFilter* relationshipFilter = static_cast(&mFilter); + if (relationshipFilter->relationshipType() == QContactRelationship::HasMember && + relationshipFilter->relatedContactRole() == QContactRelationship::First) { + mGroupId = relationshipFilter->relatedContactId().localId(); + } + } else { + mGroupId = 0; + + // set proper text formatter for the display name. + if (contactFilter.type() == QContactFilter::ContactDetailFilter) { + delete mFormat; + mFormat = NULL; + + QContactDetailFilter *detailFilter = static_cast(&mFilter); + QStringList filter = detailFilter->value().toStringList(); + + if (detailFilter->detailDefinitionName() == QContactDisplayLabel::DefinitionName + && detailFilter->matchFlags() & QContactFilter::MatchStartsWith + && !filter.isEmpty()) { + mFormat = new CntHTMLDisplayTextFormatter(); + } else { + mFormat = new CntDummyDisplayTextFormatter(); + } + } + } + + CNT_EXIT_ARGS(mGroupId) +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntlistmodel_p.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntlistmodel_p.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,65 @@ +/* +* 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: Private data for CntListModel. +* +*/ + +#ifndef CNTLISTMODEL_P_H +#define CNTLISTMODEL_P_H + +#include +#include +#include +#include +#include + +QTM_USE_NAMESPACE + +class CntCache; +class CntContactInfo; +class XQSettingsManager; +class XQSettingsKey; +class CntDisplayTextFormatter; + +class CntListModelData : public QSharedData +{ +public: + CntListModelData(QContactManager *manager, const QContactFilter &filter, bool showMyCard); + ~CntListModelData(); + void setFilter(const QContactFilter &contactFilter); + +public: + QContactManager *mContactManager; // contact manager, not owned + CntCache *mCache; // cache instance, not owned + + QContactFilter mFilter; // filter for selecting contacts to display in the list + QList mContactIds; // the IDs of the selected contacts + QContactLocalId mGroupId; // the ID of the group if the filter is a group filter, otherwise 0 + + mutable CntContactInfo *mCurrentContact; // info about last requested contact, owned + mutable int mCurrentRow; // row of last requested contact + bool mShowMyCard; + QContactLocalId mMyCardId; // id of the my card contact + + XQSettingsManager *mSettings; // settings manager, owned + XQSettingsKey *mNameListRowSettingkey; // settings key, owned + int mCurrentRowSetting; // current setting for how a list item should be displayed; name only or name + info + + CntDisplayTextFormatter *mFormat; // text formatter used for highlighting search strings in list items, owned + + HbIcon mDefaultIcon; // default icon for contacts + HbIcon mDefaultMyCardIcon; // default icon for my card +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntlistmodelglobal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntlistmodelglobal.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,33 @@ +/* +* 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 CNTLISTMODELGLOBAL_H +#define CNTLISTMODELGLOBAL_H + +#include +#include +#include + +#ifdef CNTLISTMODEL_NO_EXPORT +#define CNTLISTMODEL_EXPORT +#elif BUILD_CNTLISTMODEL +#define CNTLISTMODEL_EXPORT Q_DECL_EXPORT +#else +#define CNTLISTMODEL_EXPORT Q_DECL_IMPORT +#endif + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntnamefetcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntnamefetcher.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,563 @@ +/* +* Copyright (c) 2010 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: Private data and helper classes used by class CntCache. +* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + \class CntAllNamesJob + \brief Holds info about one job that fetches all names from the database. + + \class CntSrvConnection + \brief Issues requests to CntSrv. + + \class CntNameFetcher + \brief CntNameFetcher asynchronously fetches all contact names. + + CntNameFetcher can only do one asynchronous job: fetch all contact names. + In addition, the class provides a number of synchronous functions: + - fetch one name + - read/write all names to/from a cache file + - compare two names; sort a list of names + + Fetching from file cache is about 10 times faster than fetching from the + database, but the file cache may be out-of-date. The intended use is to + first fetch from the file cache and later synchronize with the database. + */ + +// constants used when fetching names from CntSrv +#define KCntSearchResultList 99 +#define KCntOpenDataBase 100 +_LIT(KCntServerExe, "CNTSRV.EXE"); +_LIT(KCntServerName, "CNTSRV"); +const TInt KAsyncMessageSlots = 6; +const TInt KCntServerMajorVersionNumber=1; +const TInt KCntServerMinorVersionNumber=1; +const TInt KCntServerBuildVersionNumber=1; +static const QEvent::Type CntAsynchOperation = QEvent::User; + +// constants used for file cache +const QString cacheFolder = "20022EF9"; +const QString cacheFilename = "contactcache.dat"; + +// maximum number of scheduled jobs for name fetcher +const int MaxNameJobs = 1; + +/*! + Internal class used by CntSrvConnection to issues requests to CntSrv. + */ +class CntSrvSession : public RSessionBase +{ +public: + CntSrvSession() { mConnected = false; } + ~CntSrvSession() { RHandleBase::Close(); } + void executeSqlQueryL(const TDesC &sqlQuery, QList &names, CntNameOrder nameFormat, int sizeHintKB); + +private: + void connectCntSrvL(); + +private: + bool mConnected; +}; + +CntSrvConnection::CntSrvConnection() + : mSession(NULL), + mIsAsynchronous(false) +{ +} + +CntSrvConnection::~CntSrvConnection() +{ + disconnect(); + + if (mThread.isRunning()) { + mThread.quit(); + mThread.wait(); + } + + delete mSession; + + mNames.clear(); +} + +void CntSrvConnection::setAsynchronous() +{ + mIsAsynchronous = true; + mThread.start(); + moveToThread(&mThread); +} + +bool CntSrvConnection::executeSqlQuery(const QString &sqlQuery, CntNameOrder nameFormat, int sizeHintKB) +{ + CNT_ENTRY + + if (!mSession) { + mSession = new CntSrvSession(); + } + + if (mIsAsynchronous) { + mSqlQuery = sqlQuery; + mNameFormat = nameFormat; + mSizeHintKB = sizeHintKB; + HbApplication::instance()->postEvent(this, new QEvent(CntAsynchOperation)); + } else { + mNames.clear(); + TPtrC queryPtr(sqlQuery.utf16(), sqlQuery.length()); + TRAPD(err, mSession->executeSqlQueryL(queryPtr, mNames, nameFormat, sizeHintKB)); + if (err != KErrNone) { + qDeleteAll(mNames); + mNames.clear(); + CNT_EXIT + return false; + } + } + + CNT_EXIT + + return true; +} + +bool CntSrvConnection::event(QEvent *event) +{ + if (event->type() == CntAsynchOperation) { + CNT_ENTRY + + mNames.clear(); + TPtrC ptr(mSqlQuery.utf16(), mSqlQuery.length()); + TRAPD(err, mSession->executeSqlQueryL(ptr, mNames, mNameFormat, mSizeHintKB)); + if (err != KErrNone) { + qDeleteAll(mNames); + mNames.clear(); + } + emit namesRead(); + qStableSort(mNames.begin(), mNames.end(), CntNameFetcher::compareNames); + delete mSession; + mSession = NULL; + emit namesSorted(); + + CNT_EXIT + + return true; + } + + return QObject::event(event); +} + +/*! + Executes a special SQL query: the first column must be the contact id and + the subsequent columns must be varchar fields. + + \param sqlQuery the SQL to execute + \param names the list where the results will be stored + \param nameFormat the format the names should be stored in + \param sizeHintKB the expected size of the buffer needed to fit the results; a too + small value will effectively double the fetch time, since the + buffer is then resized and the data refetched a second time + */ +void CntSrvSession::executeSqlQueryL(const TDesC& sqlQuery, QList &names, CntNameOrder nameFormat, int sizeHintKB) +{ + int listSize = 0; + + // read the ids and names from the database + if (!mConnected) { + connectCntSrvL(); + } + + // allocate tmeporary buffer + TInt bufferSize = sizeHintKB * 1024; + CBufFlat* buffer = CBufFlat::NewL(256); + CleanupStack::PushL(buffer); + + // try to fetch the results, if the fetch fails with + // a positive value, it means the buffer was too small + // in this case the buffer is resized and the results + // are fetched again + for (TInt tries = 0; tries < 2 && bufferSize > 0; ++tries) { + buffer->ResizeL(bufferSize); + TPtr8 bufferPtr = buffer->Ptr(0); + TIpcArgs args; + args.Set(0, &bufferPtr); + args.Set(1, &sqlQuery); + bufferSize = SendReceive(KCntSearchResultList, args); + CNT_LOG_ARGS("buffer size =" << bufferSize) + User::LeaveIfError(bufferSize); + } + + // store the formatted names into the list + RBufReadStream readStream; + TInt id; + TBuf<256> firstName; + TBuf<256> lastName; + + readStream.Open(*buffer); + for (int i = 0; (id = readStream.ReadInt32L()) != 0; ++i) { + readStream >> firstName; + readStream >> lastName; + CntNameCacheItem* item = new (ELeave) CntNameCacheItem( + id, + QString::fromUtf16(firstName.Ptr(), firstName.Length()), + QString::fromUtf16(lastName.Ptr(), lastName.Length()), + nameFormat); + if (i >= listSize - 1) { + // if the list is runnning out of space, resize it; + // initial size is 1000 and after that it doubles + // every time it runs out of space + if (listSize == 0) { + listSize = 1000; + } else { + listSize *= 2; + } + QT_TRY { + names.reserve(listSize); + } QT_CATCH (...) { + // clean up and return + CleanupStack::PopAndDestroy(buffer); + qDeleteAll(names); + names.clear(); + return; + } + } + names.append(item); + } + + CleanupStack::PopAndDestroy(buffer); +} + +/*! + Connect to / create a contacts server session. + */ +void CntSrvSession::connectCntSrvL() +{ + // Assume the server is already running and attempt to create a session + // with a maximum of KAsyncMessageSlots message slots. + TInt err = CreateSession(KCntServerName, + TVersion(KCntServerMajorVersionNumber, KCntServerMinorVersionNumber, KCntServerBuildVersionNumber), + KAsyncMessageSlots); + + // Server is not running + if (err == KErrNotFound) { + // Use the RProcess API to start the server. + RProcess server; + User::LeaveIfError(server.Create(KCntServerExe, KNullDesC)); + + // Enforce server to be at system default priority EPriorityForeground + server.SetPriority(EPriorityForeground); + + // Synchronize with the server. + TRequestStatus reqStatus; + server.Rendezvous(reqStatus); + server.Resume(); + + // Server will call the reciprocal static synchronization call. + User::WaitForRequest(reqStatus); + server.Close(); + User::LeaveIfError(reqStatus.Int()); + + // Create the server session. + User::LeaveIfError(CreateSession(KCntServerName, + TVersion(KCntServerMajorVersionNumber, KCntServerMinorVersionNumber, KCntServerBuildVersionNumber), + KAsyncMessageSlots)); + } else { + User::LeaveIfError(err); + } + + TIpcArgs args; + args.Set(0, &KNullDesC); + User::LeaveIfError(SendReceive(KCntOpenDataBase, args)); + + mConnected = true; +} + +/*! + Creates a CntNameFetcher object. + */ +CntNameFetcher::CntNameFetcher() + : CntAbstractFetcher(MaxNameJobs), + mDbConnection(NULL), + mAsynchDbConnection(NULL), + mSettingsManager(NULL), + mNameFormatSetting(NULL), + mBufferSizeEstimate(0) +{ + CNT_ENTRY + + // get name format setting and listen to changes + mSettingsManager = new XQSettingsManager(); + mNameFormatSetting = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, KCRCntSettings.iUid, KCntNameOrdering); + mNameFormat = static_cast(mSettingsManager->readItemValue(*mNameFormatSetting, XQSettingsManager::TypeInt).toInt()); + mSettingsManager->startMonitoring(*mNameFormatSetting, XQSettingsManager::TypeInt); + connect(mSettingsManager, SIGNAL(valueChanged(const XQSettingsKey&, const QVariant&)), this, SLOT(setNameFormat(const XQSettingsKey&, const QVariant&))); + + // connect to contacts server + mDbConnection = new CntSrvConnection(); + + CNT_EXIT +} + +/*! + Destroys a CntNameFetcher object. + */ +CntNameFetcher::~CntNameFetcher() +{ + CNT_ENTRY + + delete mSettingsManager; + delete mNameFormatSetting; + delete mDbConnection; + delete mAsynchDbConnection; + + CNT_EXIT +} + +/*! + Reads names from the file cache. + + \return true if the names were read successfully from the cache file + + */ +bool CntNameFetcher::readNamesFromCache(QList &names) +{ + CNT_ENTRY + + bool success = true; + quint32 itemCount; + quint32 nameFormat; + + QFile cacheFile(XQUtils::phoneMemoryRootPath() + cacheFolder + "\\" + cacheFilename); + if (!cacheFile.open(QIODevice::ReadOnly)) { + return false; + } + + QDataStream in(&cacheFile); + + mBufferSizeEstimate = 0; + QT_TRY { + // read header: nr of items, name format + in >> itemCount; + in >> nameFormat; + names.reserve(itemCount); + + // populate list with names + while (itemCount-- > 0) { + CntNameCacheItem *item = CntNameCacheItem::internalize(in, (CntNameOrder) nameFormat); + names.append(item); + mBufferSizeEstimate += 4 + 2 * item->name().length(); + } + } QT_CATCH (...) { + qDeleteAll(names); + names.clear(); + success = false; + } + + cacheFile.close(); + + CNT_EXIT + + return success; +} + +/*! + Write names to the file cache. + */ +bool CntNameFetcher::writeNamesToCache(const QList &names) const +{ + CNT_ENTRY + + bool success = true; + + // create folder for cache file if it does not already exist + QString path = XQUtils::phoneMemoryRootPath() + cacheFolder; + if (!QDir(path).exists()) { + QDir dir(XQUtils::phoneMemoryRootPath()); + if (!dir.mkdir(cacheFolder)) { + CNT_EXIT_ARGS("failed to create folder: " << path) + return false; + } + + // have to use native Symbian code to make the dir hidden + RFs fs; + fs.Connect(); + TPtrC pathPtr(path.utf16(), path.length()); + if (fs.SetAtt(pathPtr, KEntryAttHidden, 0) != KErrNone) { + fs.Close(); + return false; + } + fs.Close(); + } + + // open cache file for writing + QFile cacheFile(XQUtils::phoneMemoryRootPath() + cacheFolder + "\\" + cacheFilename); + if (!cacheFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { + CNT_EXIT_ARGS("failed to create file") + return false; + } + QDataStream out(&cacheFile); + + // write the names to the cache file + QT_TRY { + // write header + out << names.size(); + out << (quint32) mNameFormat; + + // write list with names + foreach (CntNameCacheItem* name, names) { + name->externalize(out); + } + } QT_CATCH (...) { + success = false; + } + + cacheFile.close(); + + CNT_EXIT + + return success; +} + +/*! + Reads the name of one contact from the contact database synchronously. + + \param contactId the id of the contact + */ +CntNameCacheItem* CntNameFetcher::fetchOneName(QContactLocalId contactId) const +{ + CNT_ENTRY + + QString sqlQuery = QString("SELECT contact_id, first_name, last_name FROM contact WHERE (type_flags>>24)<=1 AND contact_id=%1").arg(contactId); + mDbConnection->executeSqlQuery(sqlQuery, mNameFormat, 2); + + if (mDbConnection->names().size() == 0) { + return NULL; + } + + CNT_EXIT + + return mDbConnection->names().at(0); +} + +/*! + Reads the names of all contacts from the contact database asynchronously. + */ +void CntNameFetcher::processNextJob() +{ + CNT_ENTRY + + if (isProcessingJob() || !hasScheduledJobs()) { + return; + } + + // there is only one type of job, so we can delete it without inspection + delete takeNextJob(); + + if (mBufferSizeEstimate == 0) { + mBufferSizeEstimate = 240 * 1024; + } + + CNT_LOG_ARGS("buffer size =" << mBufferSizeEstimate) + + mAsynchDbConnection = new CntSrvConnection(); + mAsynchDbConnection->setAsynchronous(); + connect(mAsynchDbConnection, SIGNAL(namesRead()), this, SIGNAL(databaseAccessComplete())); + connect(mAsynchDbConnection, SIGNAL(namesSorted()), this, SLOT(sendCompletionSignal())); + mAsynchDbConnection->executeSqlQuery("SELECT contact_id, first_name, last_name FROM contact WHERE (type_flags>>24)<=1", mNameFormat, 16 + mBufferSizeEstimate / 1024); + + CNT_EXIT +} + +bool CntNameFetcher::isProcessingJob() +{ + return (mAsynchDbConnection != NULL); +} + +/*! + Sorts the names quickly and in a locale aware manner. + */ +void CntNameFetcher::sortNames(QList &names) const +{ + CNT_ENTRY + + qStableSort(names.begin(), names.end(), CntNameFetcher::compareNames); + + CNT_EXIT +} + +/*! + Compares a pair of contact names and returns true if the first + one should be presented before the second one in a list. This + static function is used e.g. when sorting lists of names. + */ +bool CntNameFetcher::compareNames(const CntNameCacheItem* a, const CntNameCacheItem* b) +{ + QString aName = a->name(); + QString bName = b->name(); + + if (aName.isEmpty()) { + return false; + } else if (bName.isEmpty()) { + return true; + } + + return (HbStringUtil::compareC(aName, bName) < 0); +} + +/*! + Notifies clients that the name format has changed. This function is called by the framework + if the name format settings is changed, see the constructor. + */ +void CntNameFetcher::setNameFormat(const XQSettingsKey &/*key*/, const QVariant &value) +{ + CNT_ENTRY + + bool ok = false; + CntNameOrder newNameFormat = static_cast(value.toInt(&ok)); + if (ok && newNameFormat != mNameFormat) { + mNameFormat = newNameFormat; + emit nameFormatChanged(mNameFormat); + } + + CNT_EXIT +} + +/*! + Emits the results of a completed asynch database operation. + */ +void CntNameFetcher::sendCompletionSignal() +{ + CNT_ENTRY + + emit namesAvailable(mAsynchDbConnection->names()); + + delete mAsynchDbConnection; + mAsynchDbConnection = NULL; + + CNT_EXIT +} + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntnamefetcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntnamefetcher.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2010 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: Private data and helper classes used by class CntCache. +* +*/ + +#ifndef CNTNAMEFETCHER_H +#define CNTNAMEFETCHER_H + +#include +#include +#include +#include +#include +#include +#include + +QTM_USE_NAMESPACE + +class CntSrvSession; +class CntNameCacheItem; +class XQSettingsManager; +class XQSettingsKey; + +class CntSrvConnection : public QObject +{ + Q_OBJECT +public: + CntSrvConnection(); + ~CntSrvConnection(); + void setAsynchronous(); + bool executeSqlQuery(const QString &sqlQuery, CntNameOrder nameFormat, int sizeHintKB); + QList names() { return mNames; } + +protected: + bool event(QEvent *event); + +signals: + void namesRead(); + void namesSorted(); + +private: + QThread mThread; + QList mNames; + CntSrvSession *mSession; + QString mSqlQuery; + CntNameOrder mNameFormat; + int mSizeHintKB; + bool mIsAsynchronous; +}; + +class CntAllNamesJob : public CntAbstractJob +{ +public: + virtual bool isEmpty() { return false; } + virtual bool equals(const CntAbstractJob &/*other*/) { return true; } + QString toString() { return QString(); } +}; + +class CntNameFetcher : public CntAbstractFetcher +{ + Q_OBJECT +public: + CntNameFetcher(); + ~CntNameFetcher(); + + // functions for the asynchronous fetching of all names + bool isProcessingJob(); + void processNextJob(); + + // synchronous functions + CntNameCacheItem * fetchOneName(QContactLocalId contactId) const; + bool readNamesFromCache(QList &names); + bool writeNamesToCache(const QList &names) const; + void sortNames(QList &names) const; + static bool compareNames(const CntNameCacheItem *a, const CntNameCacheItem *b); + +signals: + void nameFormatChanged(CntNameOrder nameFormat); + void databaseAccessComplete(); + void namesAvailable(QList contactNames); + +private slots: + void setNameFormat(const XQSettingsKey &key, const QVariant &value); + void sendCompletionSignal(); + +private: + CntSrvConnection *mDbConnection; + CntSrvConnection *mAsynchDbConnection; + XQSettingsManager *mSettingsManager; + XQSettingsKey *mNameFormatSetting; + CntNameOrder mNameFormat; + int mBufferSizeEstimate; + + friend class TestNameFetcher; +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntpresenceinfoprovider.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntpresenceinfoprovider.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,172 @@ +/* +* Copyright (c) 2010 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: Presence info provider plugin for CntListModel. It can provide +* the presence information of a contact (icon2 field). +* +*/ + +#include +#include "cntpresenceinfoprovider.h" + +#include +#include + +CntPresenceInfoProvider::CntPresenceInfoProvider() : + iReader(NULL), + mManager(NULL) +{ + iReader = PrcPresenceReader::createReader(); + connect(iReader, SIGNAL(signalPresenceNotification(bool , PrcPresenceBuddyInfoQt*)), + this, SLOT(handlePresenceUpdate(bool , PrcPresenceBuddyInfoQt*))); + + mManager = new QContactManager("symbian"); +} + +CntPresenceInfoProvider::~CntPresenceInfoProvider() +{ + delete iReader; + delete mManager; +} + +/*! + /return the info fields supported by this provider + */ +ContactInfoFields CntPresenceInfoProvider::supportedFields() const +{ + // this provider has only info for the icon2 field + return ContactInfoIcon2Field; +} + +/*! + The contact contains all the info this provider needs, so signals with the requested info + fields are emitted immediately. + + /param contact the contact for which info is requested + /param requestedInfo one or more of the flags in ContactInfoFields + */ +void CntPresenceInfoProvider::requestInfo(const QContact& contact, ContactInfoFields requestedInfo) +{ + if (requestedInfo & ContactInfoIcon2Field) + { + QList accounts = contact.details(); + + QList buddies; + + foreach (QContactOnlineAccount account, accounts) + { + QString fullAccount = account.serviceProvider() + ':' + account.accountUri(); + PrcPresenceBuddyInfoQt* buddy = iReader->presenceInfo(fullAccount); + + if (buddy) + { + buddies.append(buddy); + if (!mBuddyMap.contains(buddy->buddyId())) + { + mBuddyMap.insert(buddy->buddyId(), contact.localId()); + iReader->subscribePresenceBuddyChange(buddy->buddyId()); + } + } + } + + if (buddies.count()) + { + QString icon = parsePresence(buddies); + + if (!icon.isEmpty()) + { + emit infoFieldReady(this, contact.localId(), ContactInfoIcon2Field, icon); + } + + qDeleteAll(buddies); + } + } +} + +/*! + Update presence icon for contact if needed. Stop listening to presence changes for buddy + if online account detail was deleted. + + /param aErrorCode error (if any) + /param aPresenceBuddyInfo presence buddy that was updated + */ +void CntPresenceInfoProvider::handlePresenceUpdate(bool aSuccess, PrcPresenceBuddyInfoQt* aPresenceBuddyInfo) +{ + if (aSuccess && aPresenceBuddyInfo != NULL) + { + QContactLocalId id = mBuddyMap.value(aPresenceBuddyInfo->buddyId()); + QContact contact = mManager->contact(id); + + QList accounts = contact.details(); + + QList buddies; + bool accountFound = false; + + foreach (QContactOnlineAccount account, accounts) + { + QString fullAccount = account.serviceProvider() + ':' + account.accountUri(); + PrcPresenceBuddyInfoQt* buddy = iReader->presenceInfo(fullAccount); + + if (buddy) + { + buddies.append(buddy); + + if (fullAccount == aPresenceBuddyInfo->buddyId()) + { + accountFound = true; + } + + if (!mBuddyMap.contains(buddy->buddyId())) + { + mBuddyMap.insert(buddy->buddyId(), contact.localId()); + iReader->subscribePresenceBuddyChange(buddy->buddyId()); + } + } + } + + // Account was removed, no need to listen to presence changes anymore + if (accounts.isEmpty() || !accountFound) + { + mBuddyMap.remove(aPresenceBuddyInfo->buddyId()); + iReader->unSubscribePresenceBuddyChange(aPresenceBuddyInfo->buddyId()); + } + + if (id > 0) + { + QString icon = parsePresence(buddies); + emit infoFieldReady(this, id, ContactInfoIcon2Field, icon); + } + + qDeleteAll(buddies); + } +} + +/*! + Parse the required presence icon from multiple accounts. + + /param buddyList list of buddies + */ +QString CntPresenceInfoProvider::parsePresence(const QList& buddyList) +{ + foreach (PrcPresenceBuddyInfoQt* buddy, buddyList) + { + PrcPresenceBuddyInfoQt::AvailabilityValues availability = buddy->availability(); + + if (availability == PrcPresenceBuddyInfoQt::PrcAvailable) + { + return QString("qtg_small_online"); + } + } + + return QString(); +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/cntpresenceinfoprovider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/cntpresenceinfoprovider.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2010 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: Presence info provider plugin for CntListModel. It can provide +* the presence information of a contact (icon2 field). +* +*/ + +#ifndef CNTPRESENCEINFOPROVIDER_H +#define CNTPRESENCEINFOPROVIDER_H + +#include +#include + +class PrcPresenceReader; +class PrcPresenceBuddyInfoQt; + +QTM_BEGIN_NAMESPACE +class QContactManager; +QTM_END_NAMESPACE + +QTM_USE_NAMESPACE + +/** + Presence info provider plugin for CntListModel. It can provide + the presence information of a contact (icon2 field). + */ +class CntPresenceInfoProvider : public CntInfoProvider +{ + friend class TestCntPresenceInfoProvider; + Q_OBJECT + +public: + CntPresenceInfoProvider(); + ~CntPresenceInfoProvider(); + + // From CntInfoProvider + QString id() const { return "presence"; }; + ContactInfoFields supportedFields() const; + void requestInfo(const QContact& contact, ContactInfoFields requestedInfo); + +private slots: + void handlePresenceUpdate(bool aSuccess, PrcPresenceBuddyInfoQt* aPresenceBuddyInfo); + +private: + QString parsePresence(const QList& buddyList); + +signals: + void infoFieldReady(CntInfoProvider* sender, int contactId, ContactInfoField field, const QString& value); + +private: + PrcPresenceReader* iReader; // owned + QContactManager* mManager; // owned + QMap mBuddyMap; +}; + +#endif diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/runperftests.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/runperftests.bat Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,23 @@ +@rem +@rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +@rem All rights reserved. +@rem This component and the accompanying materials are made available +@rem under the terms of "Eclipse Public License v1.0" +@rem which accompanies this distribution, and is available +@rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +@rem +@rem Initial Contributors: +@rem Nokia Corporation - initial contribution. +@rem +@rem Contributors: +@rem +@rem Description: +@rem + +echo OFF + +del \epoc32\winscw\c\private\e84eae91\mt_performance.log +\epoc32\release\winscw\urel\mt_performance.exe -o mt_performance.log +type \epoc32\winscw\c\private\e84eae91\mt_performance.log + + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/image1.png Binary file phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/image1.png has changed diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/image2.png Binary file phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/image2.png has changed diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/inc/testrunner.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/inc/testrunner.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,67 @@ +/* +* 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 TESTRUNNER_H +#define TESTRUNNER_H + +#include + + +class TestRunner : public QXmlDefaultHandler +{ +public: // Constructors and destructor + TestRunner(const QString& name); + ~TestRunner(); + +public: // New functions + + int runTests(QObject& testObject); + void printResults(); + +protected: // From QXmlContentHandler + bool startElement( + const QString& namespaceURI, + const QString& localName, + const QString& qName, + const QXmlAttributes& atts); + + bool endElement( + const QString& namespaceURI, + const QString& localName, + const QString& qName); + + bool characters(const QString& ch); + +private: // New functions + + void parse(const QString& fileName); + +private: // Data + QStringList mTestRunParams; + QString mHomeDir; + int mTestCount; + QStringList mErrors; + bool mParsingIncidentElement; + bool mParsingDescriptionElement; + bool mCurrentTestFailed; + QString mCurrentTestName; + QString mCurrentTestFile; + int mCurrentTestFailureLine; +}; + + +#endif // TESTRUNNER_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntcache.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntcache.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,46 @@ +/* +* 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 +#include +#include + +QTM_USE_NAMESPACE + +static const int CntTestContacts = 6; + +class TestCntCache : public QObject +{ + Q_OBJECT + +private: + void cleanDatabase(); + QContact createContact(QString firstName, QString lastName, QString phoneNumber, QString imageName); + +private slots: + void initTestCase(); + void cleanupTestCase(); + + void construction(); + void fetchContactInfo(); + void clearCache(); + +private: + QContactManager *mContactManager; + QContact mContacts[CntTestContacts]; + QList mContactOrder; +}; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntdefaultinfoprovider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntdefaultinfoprovider.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,42 @@ +/* +* 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 +#include +#include + +class CntDefaultInfoProvider; + +QTM_USE_NAMESPACE + +class TestCntDefaultInfoProvider : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void create(); + + void testSupportedFields(); + void testRequestInfo(); + + void cleanupTestCase(); + +private: + CntDefaultInfoProvider *mCntDefaultInfoProvider; + +}; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntdisplaytextformatter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntdisplaytextformatter.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,34 @@ +/* +* 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 +#include +#include + +QTM_BEGIN_NAMESPACE +class QContactDetailFilter; +QTM_END_NAMESPACE + +QTM_USE_NAMESPACE + +class TestCntDisplayTextFormatter : public QObject +{ + Q_OBJECT + +private slots: + void testFormatter(); +}; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntlistmodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntlistmodel.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,88 @@ +/* +* 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 +#include +#include + +QTM_BEGIN_NAMESPACE +class QContactManager; +QTM_END_NAMESPACE + +QTM_USE_NAMESPACE + +class CntListModel; +class ModelListener; + +class TestCntListModel : public QObject +{ + Q_OBJECT + +private: + void contactReady(int start, int end); + QContact createContact(const QString& firstName, const QString& lastName); + void addGroupMember(const QContact& group, const QContact& contact); + void removeGroupMember(const QContact& group, const QContact& contact); + +private slots: + void initTestCase(); + void create(); + + void data(); + void rowCount(); + + void contact(); + void contactId(); + void indexOfContact(); + void indexOfContactId(); + void contactManager(); + void setFilter(); + void myCard(); + + void rowId(); + void dataForDisplayRole(); + + void handleAdded(); + void handleChanged(); + void handleRemoved(); + void handleMyCardChanged(); + void handleRelationships(); + + void cleanupTestCase(); + +private: + QContactManager *mManager; + CntListModel *mCntModel; + ModelListener *mModelListener; + bool mDataReady; + +friend class ModelListener; +}; + +class ModelListener : public QObject +{ + Q_OBJECT + +public: + ModelListener(TestCntListModel* parent); + +private slots: + void onDataChanged(QModelIndex start, QModelIndex end); + +private: + TestCntListModel* mParent; +}; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntpresenceinfoprovider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/inc/ut_cntpresenceinfoprovider.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,46 @@ +/* +* 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 +#include +#include + +class CntPresenceInfoProvider; + +QTM_USE_NAMESPACE + +class TestCntPresenceInfoProvider : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void create(); + + void testSupportedFields(); + void testRequestInfo(); + + void testHandlePresenceUpdate(); + + void testParsePresence(); + + void cleanupTestCase(); + +private: + CntPresenceInfoProvider *mCntPresenceInfoProvider; + +}; diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/runtest.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/runtest.cmd Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,32 @@ +@echo off +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem +@echo on + +call del MON.sym +call del MON.dat +call del profile.txt + +call qmake +call sbs reallyclean +call sbs -c winscw_udeb +call sbs -c winscw_udeb +call qmake +call ctcwrap -i d -C "EXCLUDE+moc_*.cpp" -C "EXCLUDE+ut_*.*" sbs -c winscw_udeb + +call \epoc32\release\winscw\udeb\ut_cntlistmodel.exe -noprompt +call ctcpost MON.sym MON.dat -p profile.txt +call ctc2html -i profile.txt -nsb diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/src/main.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,71 @@ +/* +* 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 "testrunner.h" + +#include "ut_cntlistmodel.h" +#include "ut_cntcache.h" +#include "ut_cntpresenceinfoprovider.h" +#include "ut_cntdefaultinfoprovider.h" +#include "ut_cntdisplaytextformatter.h" + +#include + +int main(int argc, char *argv[]) +{ + bool promptOnExit(true); + for (int i=0; i +#include +#include + +const char testFunctionElement[] = "TestFunction"; +const char incidentElement[] = "Incident"; +const char descriptionElement[] = "Description"; +const char nameAttr[] = "name"; +const char typeAttr[] = "type"; +const char fileAttr[] = "file"; +const char lineAttr[] = "line"; +const char attrValueFail[] = "fail"; + + +TestRunner::TestRunner(const QString& name) +: mTestCount(0), + mParsingIncidentElement(false), + mParsingDescriptionElement(false), + mCurrentTestFailed(false), + mCurrentTestFailureLine(0) +{ + mTestRunParams.append(name); + mTestRunParams.append("-xml"); + mTestRunParams.append("-o"); + mHomeDir = QDir::homePath(); + mTestRunParams.append(QString()); // Initial result file name + + if (!mHomeDir.endsWith(QString::fromAscii("/"))) + mHomeDir += QString::fromAscii("/"); +} + +TestRunner::~TestRunner() +{ +} + +int TestRunner::runTests(QObject& testObject) +{ + QString className(testObject.metaObject()->className()); + printf("Running tests for %s ... ", className.toUtf8().data()); + QString resultFileName = mHomeDir + className + ".xml"; + mTestRunParams.replace(mTestRunParams.count()-1,resultFileName); + int errorsBefore = mErrors.count(); + int error = QTest::qExec(&testObject, mTestRunParams); + parse(resultFileName); + printf("Failures: %d\n",mErrors.count()-errorsBefore); + fflush(stdout); + return error; +} + +void TestRunner::printResults() +{ + printf("\nTests executed: %d\n",mTestCount); + if (mErrors.count() > 0) { + printf("Failures (%d):\n", mErrors.count()); + foreach(QString error, mErrors) { + printf("\n%s", error.toUtf8().data()); + } + printf("\n"); + } else { + printf("All passed.\n\n"); + } + fflush(stdout); +} + +void TestRunner::parse(const QString& fileName) +{ + QFile file(fileName); + QXmlInputSource inputSource(&file); + QXmlSimpleReader reader; + reader.setContentHandler(this); + reader.parse(inputSource); +} + +bool TestRunner::startElement( + const QString& /*namespaceURI*/, + const QString& /*localName*/, + const QString& qName, + const QXmlAttributes& atts) +{ + if (qName == QString::fromAscii(testFunctionElement)) { + mTestCount++; + mCurrentTestName = atts.value(QString::fromAscii(nameAttr)); + return true; + } + if (qName == QString::fromAscii(incidentElement)) { + mParsingIncidentElement = true; + if (atts.value(QString::fromAscii(typeAttr)) == QString::fromAscii(attrValueFail)) { + mCurrentTestFailed = true; + mCurrentTestFile = atts.value(QString::fromAscii(fileAttr)); + mCurrentTestFailureLine = atts.value(QString::fromAscii(lineAttr)).toInt(); + } + return true; + } + mParsingDescriptionElement = + (qName == QString::fromAscii(descriptionElement)); + return true; +} + +bool TestRunner::endElement( + const QString& /*namespaceURI*/, + const QString& /*localName*/, + const QString& qName) +{ + if (qName == QString::fromAscii(incidentElement)) { + mParsingIncidentElement = false; + mCurrentTestFailed = false; + return true; + } + if (qName == QString::fromAscii(descriptionElement)) { + mParsingDescriptionElement = false; + } + return true; +} + +bool TestRunner::characters(const QString& ch) +{ + if (mParsingIncidentElement && + mParsingDescriptionElement && + mCurrentTestFailed) { + QByteArray testResult = mCurrentTestName.toAscii() + " failed:\n"; + testResult += "File: "; + testResult += mCurrentTestFile.toAscii(); + testResult += "\n"; + testResult += "Line: "; + testResult += QByteArray::number(mCurrentTestFailureLine); + testResult += "\n"; + testResult += "Reason: "; + testResult += ch.toAscii(); + testResult += "\n"; + mErrors.append(QString::fromAscii(testResult.data())); + } + return true; +} + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntcache.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntcache.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,231 @@ +/* +* 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_cntcache.h" +#include "cntcache.h" +#include "cntcache_p.h" + +void TestCntCache::initTestCase() +{ + // get contact manager + mContactManager = new QContactManager("symbian"); + + // start with a clean database + cleanDatabase(); + + // TODO: This test needs to be run with the default provider, so when there is a mechanism + // to variate the info provider, use that mechanism here to select the default provider. + + // create contacts; twins with same image at indexes 0,5 and 2,3 (good for increasing branch coverage) + mContacts[0] = createContact("Joe", "Doe", "1234567", "c:/data/images/image1.png"); + mContacts[1] = createContact("Marja", "Meikalainen", "7654321", ""); + mContacts[2] = createContact("Sven", "Dufva", "12121212", "c:/data/images/image2.png"); + mContacts[3] = createContact("Twin", "Dufva", "12121212", "c:/data/images/image2.png"); + mContacts[4] = createContact("", "", "123123", ""); + mContacts[5] = createContact("Twin", "Doe", "1234568", "c:/data/images/image1.png"); +} + +void TestCntCache::cleanupTestCase() +{ + // end with a clean database + cleanDatabase(); + + delete mContactManager; + mContactManager = NULL; +} + +/* + Test case: Constructing and deleting the cache. + */ +void TestCntCache::construction() +{ + // test creation + QPointer cache = CntCache::instance(); + QVERIFY(cache != NULL); + QPointer worker = cache->mWorker; + QVERIFY(worker != NULL); + + // test singleton property + QVERIFY(cache == CntCache::instance()); + + // test data members + QVERIFY(cache->mContactManager != NULL); + QVERIFY(worker->mContactManager != NULL); + QVERIFY(worker->mThumbnailManager != NULL); + QVERIFY(worker->mInfoProviders.count() >= 1); + + // test deletion + cache->onShutdown(); + QVERIFY(CntCache::mInstance == NULL); +} + +/* + Test case: Fetch contact info. + + Fetches all six contacts in two batches of four and two contacts. The contacts are + divided up so that one pair of twins is in the same batch and the other pair of twins + has one twin in each batch. This maximizes branch coverage. + */ +void TestCntCache::fetchContactInfo() +{ + CntContactInfo info[CntTestContacts]; // info for each of the contacts + + // create cache and attach a signal spy to it + CntCache* cache = CntCache::instance(); + QSignalSpy spy(cache, SIGNAL(contactInfoUpdated(QContactLocalId))); + + // create list of ids + QList idList; + for (int i = 0; i < CntTestContacts; ++i) { + idList << mContacts[i].localId(); + } + + // fetch three of the contacts in rapid succession, one of them twice + info[1] = cache->fetchContactInfo(1, idList); + info[0] = cache->fetchContactInfo(0, idList); + info[4] = cache->fetchContactInfo(4, idList); + info[0] = cache->fetchContactInfo(0, idList); + info[5] = cache->fetchContactInfo(5, idList); + + // check that names are ok + QVERIFY(info[1].name() == mContacts[1].displayLabel()); + QVERIFY(info[0].name() == mContacts[0].displayLabel()); + QVERIFY(info[4].name() == mContacts[4].displayLabel()); + QVERIFY(info[5].name() == mContacts[5].displayLabel()); + + // wait for possible signals to arrive (in the future, all info could be returned immediately) + QTest::qWait(4000); + spy.clear(); + + // fetch all contacts -- they should be cached now by the read-ahead mechanism + for (int i = 0; i < CntTestContacts; ++i) { + info[i] = cache->fetchContactInfo(i, idList); + } + + // confirm that no further signals from cache (i.e. they were all really cached) + QTest::qWait(2000); + QVERIFY(spy.count() == 0); + + // confirm that returned data equals created data + for (int i = 0; i < CntTestContacts; ++i) { + QVERIFY(info[i].name() == mContacts[i].displayLabel()); + QVERIFY(info[i].text() == mContacts[i].detail().number()); + } + + // confirm that info cache contains correct data + int cacheItemCount = 0; + foreach (CntInfoCacheItem* item, cache->mInfoCache) { + // find corresponding contact + for (int i = 0; i < CntTestContacts; ++i) { + if (mContacts[i].localId() == item->contactId) { + QVERIFY(item->name == mContacts[i].displayLabel()); + QVERIFY(item->text == mContacts[i].detail().number()); + QVERIFY(item->icons[0].replace('\\', '/') == mContacts[i].detail().imageUrl().toString().replace('\\', '/')); + ++cacheItemCount; + } + } + } + QVERIFY(cacheItemCount == CntTestContacts); + + // confirm that icon cache contains correct data + cacheItemCount = 0; + foreach (CntIconCacheItem* item, cache->mIconCache) { + // find corresponding contact + for (int i = 0; i < CntTestContacts; ++i) { + if (mContacts[i].detail().imageUrl().toString().replace('\\','/') == item->iconName.replace('\\','/')) { + QVERIFY(item->isFetched); + QVERIFY(!item->icon.isNull()); + ++cacheItemCount; + } + } + } + QVERIFY(cacheItemCount == 2*2); // two images, both used by two contacts + + cache->onShutdown(); +} + +/* + Test case: Clear cache. + */ +void TestCntCache::clearCache() +{ + CntCache* cache = CntCache::instance(); + + QList idList; + for (int i = 0; i < CntTestContacts; ++i) { + idList << mContacts[i].localId(); + } + + cache->fetchContactInfo(1, idList); + cache->fetchContactInfo(3, idList); + + QVERIFY(cache->mInfoCache.count() == 2); + QTest::qWait(3000); + QVERIFY(cache->mIconCache.count() == 2); + + cache->clearCache(); + QVERIFY(cache->mInfoCache.count() == 0); // icon cache needn't be cleared + + delete cache; +} + +/* TODO: Test cases for overflowing info and icon requests (>30) -- IDs need not be real, just confirm + that cancellation notifications eventually arrive */ + +/* + Helper function for cleaning the database. + */ +void TestCntCache::cleanDatabase() +{ + QList ids = mContactManager->contactIds(); + QMap errorMapInit; + mContactManager->removeContacts(ids, &errorMapInit); + mContactManager->removeContact(mContactManager->selfContactId()); +} + +/* + Helper function for creating contacts. + */ +QContact TestCntCache::createContact(QString firstName, QString lastName, QString phoneNumber, QString imageName) +{ + QContact contact; + + if (!firstName.isEmpty() && !lastName.isEmpty()) { + QContactName name; + name.setFirstName(firstName); + name.setLastName(lastName); + contact.saveDetail(&name); + } + + if (!phoneNumber.isEmpty()) { + QContactPhoneNumber number; + number.setNumber(phoneNumber); + number.setContexts(QContactDetail::ContextHome); + number.setSubTypes(QContactPhoneNumber::SubTypeMobile); + contact.saveDetail(&number); + } + + if (!imageName.isEmpty()) { + QContactAvatar avatar; + avatar.setImageUrl(imageName); + contact.saveDetail(&avatar); + } + + mContactManager->saveContact(&contact); + + return contact; +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntdefaultinfoprovider.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntdefaultinfoprovider.cpp Fri Oct 15 12:24:46 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: +* +*/ + +#include "ut_cntdefaultinfoprovider.h" +#include "cntdefaultinfoprovider.h" + +void TestCntDefaultInfoProvider::initTestCase() +{ + mCntDefaultInfoProvider = NULL; +} + +void TestCntDefaultInfoProvider::create() +{ + mCntDefaultInfoProvider = new CntDefaultInfoProvider(); +} + +void TestCntDefaultInfoProvider::testSupportedFields() +{ + QVERIFY(mCntDefaultInfoProvider->supportedFields() == ContactInfoIcon1Field | ContactInfoTextField); +} + +void TestCntDefaultInfoProvider::testRequestInfo() +{ + QSignalSpy spy(mCntDefaultInfoProvider, SIGNAL(infoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&))); + + QContact c; + QContactName name; + name.setFirstName("firstname"); + name.setLastName("lastname"); + c.saveDetail(&name); + + ContactInfoFields fields; + fields = ContactInfoIcon2Field; + + mCntDefaultInfoProvider->requestInfo(c, fields); + QCOMPARE(spy.count(), 0); + + fields = ContactInfoIcon1Field | ContactInfoTextField; + + mCntDefaultInfoProvider->requestInfo(c, fields); + QCOMPARE(spy.count(), 2); + spy.clear(); + + QContactPhoneNumber number; + number.setNumber("1234567"); + number.setContexts(QContactDetail::ContextHome); + number.setSubTypes(QContactPhoneNumber::SubTypeMobile); + c.saveDetail(&number); + + mCntDefaultInfoProvider->requestInfo(c, fields); + QCOMPARE(spy.count(), 2); + spy.clear(); + + c.setPreferredDetail("call", number); + + QContactPhoneNumber number2; + number2.setNumber("7654321"); + number2.setContexts(QContactDetail::ContextWork); + number2.setSubTypes(QContactPhoneNumber::SubTypeMobile); + c.saveDetail(&number2); + + mCntDefaultInfoProvider->requestInfo(c, fields); + QCOMPARE(spy.count(), 2); + spy.clear(); + + QContactAvatar avatar; + c.saveDetail(&avatar); + + mCntDefaultInfoProvider->requestInfo(c, fields); + QCOMPARE(spy.count(), 2); + spy.clear(); + + avatar.setImageUrl(QUrl("dummyavatar")); + c.saveDetail(&avatar); + + mCntDefaultInfoProvider->requestInfo(c, fields); + QCOMPARE(spy.count(), 2); +} + +void TestCntDefaultInfoProvider::cleanupTestCase() +{ + delete mCntDefaultInfoProvider; + mCntDefaultInfoProvider = NULL; +} + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntdisplaytextformatter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntdisplaytextformatter.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,47 @@ +/* +* 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_cntdisplaytextformatter.h" +#include "cntdisplaytextformatter.h" +#include + +void TestCntDisplayTextFormatter::testFormatter() +{ + QColor color = HbColorScheme::color("qtc_lineedit_selected"); + QColor bg = HbColorScheme::color("qtc_lineedit_marker_normal"); + QString foo = QString("foo").arg(bg.name().toUpper()).arg(color.name().toUpper()); + + QContactDetailFilter filter; + filter.setDetailDefinitionName( QContactDisplayLabel::DefinitionName ); + filter.setMatchFlags( QContactFilter::MatchStartsWith ); + filter.setValue( "f" ); + + CntDisplayTextFormatter* format = new CntHTMLDisplayTextFormatter; + QString result = format->formattedText("foo", filter ); + QVERIFY( foo == result ); + QVERIFY( "" == format->formattedText("", filter) ); + // invalid filter + QContactRelationshipFilter invalidFilter; + QVERIFY( "foo" == format->formattedText("foo", invalidFilter) ); + QVERIFY( "" == format->formattedText("", invalidFilter) ); + + // dummy returns always the given text, dispite of the filter + CntDisplayTextFormatter* dummy = new CntDummyDisplayTextFormatter; + QVERIFY( "foo" == dummy->formattedText("foo", filter) ); + QVERIFY( "foo" == dummy->formattedText("foo", invalidFilter) ); + QVERIFY( "" == dummy->formattedText("", filter) ); +} diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntlistmodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntlistmodel.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,601 @@ +/* +* 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_cntlistmodel.h" +#include "cntlistmodel.h" +#include "cntlistmodel_p.h" + +#include +#include +#include + +void TestCntListModel::initTestCase() +{ + //let's have clean database before running tests + mManager = new QContactManager("symbian"); + QList ids = mManager->contactIds(); + QMap errorMapInit; + mManager->removeContacts(ids, &errorMapInit); + mManager->removeContact(mManager->selfContactId()); +} + +void TestCntListModel::contactReady(int startRow, int endRow) +{ + QVERIFY(startRow == endRow); + mDataReady = true; +} + +void TestCntListModel::create() +{ + mCntModel = new CntListModel(); + QVERIFY(mCntModel != NULL); + QVERIFY(mCntModel->rowCount() == 1); + QVERIFY(mCntModel->d->m_cache); + QVERIFY(mCntModel->d->m_ownedContactManager); + QVERIFY(mCntModel->d->m_contactManager != NULL); + + delete mCntModel; + mCntModel = NULL; + + mCntModel = new CntListModel(mManager); + QVERIFY(mCntModel != NULL); + QCOMPARE(mCntModel->rowCount(), 1); + QVERIFY(mCntModel->rowCount() == 1); + QVERIFY(mCntModel->d->m_cache); + QVERIFY(!mCntModel->d->m_ownedContactManager); + QVERIFY(mCntModel->d->m_contactManager != NULL); +} + +void TestCntListModel::data() +{ + mModelListener = new ModelListener(this); + mDataReady = false; + + //create and save contact + QContact c; + QContactName name; + name.setFirstName("firstname"); + name.setLastName("lastname"); + c.saveDetail(&name); + QContactPhoneNumber number; + number.setNumber("1234567"); + number.setContexts(QContactDetail::ContextHome); + number.setSubTypes(QContactPhoneNumber::SubTypeMobile); + c.saveDetail(&number); + QContactEmailAddress email; + email.setEmailAddress("dummyemail"); + c.saveDetail(&email); + QVERIFY(mManager->saveContact(&c)); + QTest::qWait(1000); + + //check invalid row and column + QVariant ret; + ret = mCntModel->data(QModelIndex(), Qt::UserRole); + QVERIFY(ret.isNull()); + + //check the saved contact's info + QModelIndex modelIndex = mCntModel->indexOfContact(c); + int row = modelIndex.row(); + QContact contactFromModel = mCntModel->contact(modelIndex); + QVERIFY(c == contactFromModel); + + ret = mCntModel->data(modelIndex, Qt::UserRole); + QVERIFY(ret.isNull()); + + ret = mCntModel->data(modelIndex, Qt::DisplayRole); + QVERIFY(ret.type() == QVariant::StringList); + QStringList displayContent; + displayContent = ret.toStringList(); + QVERIFY(displayContent.count() == 2); + QVERIFY(displayContent.at(0) == "firstname lastname"); + // second string is only an empty placeholder, e.g. " ", until cache has fetched the value + + // wait for cache to signal that all contact info is ready + while (!mDataReady) { QTest::qWait(200); QApplication::processEvents(); } + mDataReady = false; + ret = mCntModel->data(modelIndex, Qt::DisplayRole); + + QVERIFY(ret.type() == QVariant::StringList); + displayContent = ret.toStringList(); + QVERIFY(displayContent.count() == 2); + QVERIFY(displayContent.at(0) == "firstname lastname"); + QVERIFY(displayContent.at(1) == "1234567"); + + // check backgroundrole + ret = mCntModel->data(modelIndex, Qt::BackgroundRole); + QVERIFY(ret.isNull()); + + //check decoration role + ret = mCntModel->data(modelIndex, Qt::DecorationRole); + QVERIFY(ret.type() == QVariant::List); + + ret = mCntModel->data(modelIndex, Hb::IndexFeedbackRole); + QVERIFY(ret.type() == QVariant::String); + + // add empty avatar and check decoration + QContactAvatar avatar; + c.saveDetail(&avatar); + QVERIFY(mManager->saveContact(&c)); + QTest::qWait(1000); + ret = mCntModel->data(modelIndex, Qt::DecorationRole); + QVERIFY(ret.type() == QVariant::List); + + // add data to the avatar and check decoration + avatar.setImageUrl(QUrl("dummyimagepath")); + c.saveDetail(&avatar); + QVERIFY(mManager->saveContact(&c)); + QTest::qWait(1000); + modelIndex = mCntModel->indexOfContact(c); + ret = mCntModel->data(modelIndex, Qt::DecorationRole); + + // wait for cache to signal that all contact info is ready + while (!mDataReady) { QTest::qWait(200); QApplication::processEvents(); } + mDataReady = false; + ret = mCntModel->data(modelIndex, Qt::DecorationRole); + QVERIFY(ret.type() == QVariant::List); + + // check MyCard info from the model + modelIndex = mCntModel->index(0, 0); + ret = mCntModel->data(modelIndex, Qt::BackgroundRole); + QVERIFY(!ret.isNull()); + + // create and assign empty MyCard + QContact myCard; + QVERIFY(mManager->saveContact(&myCard)); + QTest::qWait(1000); + mManager->setSelfContactId(myCard.localId()); + QTest::qWait(1000); + + // check that MyCard was really saved + QCOMPARE(mCntModel->myCardId(), myCard.localId()); + + // check MyCard info from the model + myCard = mManager->contact(mManager->selfContactId()); + modelIndex = mCntModel->indexOfContact(myCard); + ret = mCntModel->data(modelIndex, Qt::BackgroundRole); + QVERIFY(!ret.isNull()); + + ret = mCntModel->data(modelIndex, Qt::DisplayRole); + QVERIFY(ret.type() == QVariant::StringList); + displayContent = ret.toStringList(); + QVERIFY(displayContent.count() == 1); // "Unnamed" + + // add some content to MyCard + myCard.saveDetail(&number); + QVERIFY(mManager->saveContact(&myCard)); + QTest::qWait(1000); + ret = mCntModel->data(modelIndex, Qt::DisplayRole); + // wait for cache + QTest::qWait(1000); + ret = mCntModel->data(modelIndex, Qt::DisplayRole); + QVERIFY(ret.type() == QVariant::StringList); + displayContent = ret.toStringList(); + QVERIFY(displayContent.contains(hbTrId("txt_phob_list_unnamed"))); + + ret = mCntModel->data(modelIndex, Hb::IndexFeedbackRole); + QVERIFY(ret.isNull()); +} + +void TestCntListModel::rowCount() +{ + // we should have 2 contacts in the model saved from the last test case + QTest::qWait(5000); + QCOMPARE(mCntModel->rowCount(), 2); +} + +void TestCntListModel::contact() +{ + QList ids = mManager->contactIds(); + QMap errorMapContact; + mManager->removeContacts(ids,&errorMapContact); + QTest::qWait(1000); + + QModelIndex modelIndex = mCntModel->index(0, 0); + QContact empty = mCntModel->contact(modelIndex); + //QVERIFY(empty.isEmpty()); + + //create and save contact + QContact c; + QContactName name; + name.setFirstName("firstname"); + name.setLastName("lastname"); + c.saveDetail(&name); + QContactPhoneNumber number; + number.setNumber("1234567"); + number.setContexts(QContactDetail::ContextHome); + number.setSubTypes(QContactPhoneNumber::SubTypeMobile); + c.saveDetail(&number); + QContactEmailAddress email; + email.setEmailAddress("dummyemail"); + c.saveDetail(&email); + QVERIFY(mManager->saveContact(&c)); + QTest::qWait(1000); + + modelIndex = mCntModel->index(10, 0); + c = mCntModel->contact(modelIndex); + QVERIFY(c.isEmpty()); + + modelIndex = mCntModel->index(1, 0); + c = mCntModel->contact(modelIndex); + QVERIFY(!c.isEmpty()); +} + +void TestCntListModel::contactId() +{ + QModelIndex modelIndex = mCntModel->index(1, 0); + QContact c = mCntModel->contact(modelIndex); + + QVERIFY(mCntModel->contactId(modelIndex) == c.localId()); +} + +void TestCntListModel::indexOfContact() +{ + QModelIndex modelIndex = mCntModel->index(1, 0); + QContact c = mCntModel->contact(modelIndex); + + QVERIFY(mCntModel->indexOfContact(c) == modelIndex); +} + +void TestCntListModel::indexOfContactId() +{ + QModelIndex modelIndex = mCntModel->index(1, 0); + QContact c = mCntModel->contact(modelIndex); + + QVERIFY(mCntModel->indexOfContactId(c.localId()) == modelIndex); +} + +void TestCntListModel::contactManager() +{ + QVERIFY(mManager == &(mCntModel->contactManager())); +} + +void TestCntListModel::setFilter() +{ + QList ids = mManager->contactIds(); + QMap errorMap; + mManager->removeContacts(ids,&errorMap); + QTest::qWait(1000); + + QContact c; + QContactName name; + name.setFirstName("firstname"); + name.setLastName("lastname"); + c.saveDetail(&name); + QVERIFY(mManager->saveContact(&c)); + + QContactUnionFilter unionFilter; + + QContactDetailFilter landlineFilter; + landlineFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName, QContactPhoneNumber::FieldSubTypes); + landlineFilter.setValue(QLatin1String(QContactPhoneNumber::SubTypeLandline)); + unionFilter << landlineFilter; + + QContactDetailFilter mobileFilter; + mobileFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName, QContactPhoneNumber::FieldSubTypes); + mobileFilter.setValue(QLatin1String(QContactPhoneNumber::SubTypeMobile)); + unionFilter << mobileFilter; + + mCntModel->setFilter(unionFilter); + + QModelIndex modelIndex = mCntModel->indexOfContact(c); + QVERIFY(modelIndex.row() < 0); + QVERIFY(mCntModel->d->m_filter == unionFilter); + QVERIFY(mCntModel->d->m_sortOrders.count() == 2); +} + +void TestCntListModel::myCard() +{ + delete mCntModel; + mCntModel = 0; + + mCntModel = new CntListModel(mManager); + + QList ids = mManager->contactIds(); + QMap errorMap; + mManager->removeContacts(ids,&errorMap); + QTest::qWait(1000); + + QContact c; + QContactName name; + name.setFirstName("firstname"); + name.setLastName("lastname"); + c.saveDetail(&name); + QVERIFY(mManager->saveContact(&c)); + + QSignalSpy spy(mCntModel, SIGNAL(modelReset())); + + QVERIFY(mCntModel->myCardStatus()); + + mCntModel->showMyCard(false); + QVERIFY(!mCntModel->myCardStatus()); + QCOMPARE(spy.count(), 2); + + mCntModel->showMyCard(true); + QVERIFY(mCntModel->myCardStatus()); + QCOMPARE(spy.count(), 4); + + mManager->setSelfContactId(c.localId()); + QTest::qWait(1000); + spy.clear(); + + mCntModel->showMyCard(false); + QVERIFY(!mCntModel->myCardStatus()); + QCOMPARE(spy.count(), 2); + + mCntModel->showMyCard(true); + QVERIFY(mCntModel->myCardStatus()); + QCOMPARE(spy.count(), 4); + mCntModel->showMyCard(true); + QVERIFY(mCntModel->myCardStatus()); + QCOMPARE(spy.count(), 4); +} + +void TestCntListModel::rowId() +{ + QList ids = mManager->contactIds(); + QMap errorMap; + mManager->removeContacts(ids,&errorMap); + QTest::qWait(1000); + + QContact c; + QContactName name; + name.setFirstName("firstname"); + name.setLastName("lastname"); + c.saveDetail(&name); + QVERIFY(mManager->saveContact(&c)); + + int row = mCntModel->rowId(c.localId()); + QVERIFY(row > 0); + QVERIFY(mCntModel->validRowId(row)); + QVERIFY(!mCntModel->validRowId(-100)); + QVERIFY(!mCntModel->validRowId(100)); +} + +void TestCntListModel::dataForDisplayRole() +{ + QList ids = mManager->contactIds(); + QMap errorMap; + mManager->removeContacts(ids,&errorMap); + QTest::qWait(1000); + + QContact c; + QContactName name; + name.setFirstName("firstname"); + name.setLastName("lastname"); + c.saveDetail(&name); + QVERIFY(mManager->saveContact(&c)); + + int row = mCntModel->rowId(c.localId()); + QVariant var = mCntModel->dataForRole(row, Qt::DisplayRole); + QVERIFY(var.type() == QVariant::StringList); + + var = mCntModel->dataForRole(0, Qt::DisplayRole); + QVERIFY(var.type() == QVariant::StringList); +} + +void TestCntListModel::handleAdded() +{ + QList ids = mManager->contactIds(); + QMap errorMap; + mManager->removeContacts(ids,&errorMap); + QTest::qWait(1000); + + QSignalSpy spy(mCntModel, SIGNAL(rowsAboutToBeInserted(const QModelIndex&, int, int))); + + QContact c; + QContactName name; + name.setFirstName("firstname"); + name.setLastName("lastname"); + c.saveDetail(&name); + QVERIFY(mManager->saveContact(&c)); + + QCOMPARE(spy.count(), 1); + + QList emptyList; + mCntModel->handleAdded(emptyList); + QCOMPARE(spy.count(), 1); +} + +void TestCntListModel::handleChanged() +{ + QList ids = mManager->contactIds(); + QMap errorMap; + mManager->removeContacts(ids,&errorMap); + QTest::qWait(1000); + + QContact c; + QContactName name; + name.setFirstName("firstname"); + name.setLastName("lastname"); + c.saveDetail(&name); + QVERIFY(mManager->saveContact(&c)); + + QSignalSpy spy(mCntModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex&))); + + name.setMiddleName("mid"); + c.saveDetail(&name); + QVERIFY(mManager->saveContact(&c)); + + QCOMPARE(spy.count(), 1); + + QList emptyList; + mCntModel->handleChanged(emptyList); + QCOMPARE(spy.count(), 1); +} + +void TestCntListModel::handleRemoved() +{ + QSignalSpy spy(mCntModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int))); + + QList ids = mManager->contactIds(); + QMap errorMap; + mManager->removeContacts(ids,&errorMap); + QTest::qWait(1000); + + QCOMPARE(spy.count(), 1); + + QList emptyList; + mCntModel->handleRemoved(emptyList); + QCOMPARE(spy.count(), 1); +} + +void TestCntListModel::handleMyCardChanged() +{ + QList ids = mManager->contactIds(); + QMap errorMap; + mManager->removeContacts(ids,&errorMap); + QTest::qWait(1000); + + QContact c; + QContactName name; + name.setFirstName("firstname"); + name.setLastName("lastname"); + c.saveDetail(&name); + QVERIFY(mManager->saveContact(&c)); + + mCntModel->handleMyCardChanged(0, c.localId()); + QVERIFY(mCntModel->d->m_myCardId == c.localId()); +} + +void TestCntListModel::handleRelationships() +{ + // remove all contacts + QList ids = mManager->contactIds(); + QMap errorMap; + mManager->removeContacts(ids,&errorMap); + QTest::qWait(1000); + + // create group "myGroup" + QContact group; + group.setType(QContactType::TypeGroup); + QContactName groupName; + groupName.setCustomLabel("myGroup"); + group.saveDetail(&groupName); + mManager->saveContact(&group); + + // create a relationship filter + QContactRelationshipFilter groupFilter; + groupFilter.setRelationshipType(QContactRelationship::HasMember); + groupFilter.setRelatedContactRole(QContactRelationship::First); + groupFilter.setRelatedContactId(group.id()); + + // create new listmodel + CntListModel* groupListModel = new CntListModel(mManager, groupFilter, false); + QVERIFY(groupListModel != NULL); + + QCOMPARE(groupListModel->rowCount(), 0); + + // create contacts + QList contacts; + contacts << createContact("Alfa", "One"); + contacts << createContact("Beta", "Two"); + contacts << createContact("Gamma", "Three"); + QTest::qWait(1000); + QCOMPARE(groupListModel->rowCount(), 0); + + // add contacts to group + foreach (QContact contact, contacts) { + addGroupMember(group, contact); + } + QTest::qWait(1000); + QCOMPARE(groupListModel->rowCount(), 3); + + // remove contact from group + removeGroupMember(group, contacts.at(1)); + QTest::qWait(1000); + QCOMPARE(groupListModel->rowCount(), 2); + + // add and remove empty list + QList emptyList; + emptyList << group.localId(); + mCntModel->handleAddedRelationship(emptyList); + QCOMPARE(groupListModel->rowCount(), 2); + mCntModel->handleRemovedRelationship(emptyList); + QCOMPARE(groupListModel->rowCount(), 2); + + // verify that contact on second row is "Gamma Three" (comes after "Alfa One" + // regardless of sorting type and Beta Two was removed) + QVERIFY(groupListModel->indexOfContact(contacts.at(0)).row() == 0); + QVERIFY(groupListModel->indexOfContact(contacts.at(1)).row() == -1); + QVERIFY(groupListModel->indexOfContact(contacts.at(2)).row() == 1); + + // create a contact and make sure list model count does not change + createContact("Delta", "Four"); + QTest::qWait(1000); + QCOMPARE(groupListModel->rowCount(), 2); + + delete groupListModel; +} + +QContact TestCntListModel::createContact(const QString& firstName, const QString& lastName) +{ + QContact contact; + QContactName name; + name.setFirstName(firstName); + name.setLastName(lastName); + contact.saveDetail(&name); + mManager->saveContact(&contact); + + return contact; +} + +void TestCntListModel::addGroupMember(const QContact& group, const QContact& contact) +{ + QContactRelationship relationship; + relationship.setRelationshipType(QContactRelationship::HasMember); + relationship.setFirst(group.id()); + relationship.setSecond(contact.id()); + mManager->saveRelationship(&relationship); +} + +void TestCntListModel::removeGroupMember(const QContact& group, const QContact& contact) +{ + QContactRelationship relationship; + relationship.setRelationshipType(QContactRelationship::HasMember); + relationship.setFirst(group.id()); + relationship.setSecond(contact.id()); + mManager->removeRelationship(relationship); +} + +void TestCntListModel::cleanupTestCase() +{ + mCntModel->d->m_cache->onShutdown(); + delete mCntModel; + mCntModel = 0; + + //let's have clean database after running tests + QList ids = mManager->contactIds(); + QMap errorMap; + mManager->removeContacts(ids, &errorMap); + delete mManager; + mManager = 0; + delete mModelListener; + mModelListener = 0; +} + + +ModelListener::ModelListener(TestCntListModel* parent) + : mParent(parent) +{ + connect(mParent->mCntModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(onDataChanged(QModelIndex,QModelIndex))); +} + +void ModelListener::onDataChanged(QModelIndex start, QModelIndex end) +{ + mParent->contactReady(start.row(), end.row()); +} + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntpresenceinfoprovider.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/src/ut_cntpresenceinfoprovider.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,190 @@ +/* +* 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_cntpresenceinfoprovider.h" +#include "cntpresenceinfoprovider.h" + +#include +#include +#include + +void TestCntPresenceInfoProvider::initTestCase() +{ + mCntPresenceInfoProvider = NULL; +} + +void TestCntPresenceInfoProvider::create() +{ + mCntPresenceInfoProvider = new CntPresenceInfoProvider(); +} + +void TestCntPresenceInfoProvider::testSupportedFields() +{ + QVERIFY(mCntPresenceInfoProvider->supportedFields() == ContactInfoIcon2Field); +} + +void TestCntPresenceInfoProvider::testRequestInfo() +{ + PrcPresenceWriter *writer = PrcPresenceWriter::createWriter(); + + PrcPresenceBuddyInfoQt *buddy = PrcPresenceBuddyInfoQt::createInstance(); + buddy->setIdentity("sip:test@test.com"); + buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcNotAvailable, "meh"); + writer->writePresence(*buddy); + + QContactManager manager("symbian"); + + QContact c; + QContactName name; + name.setFirstName("firstname"); + name.setLastName("lastname"); + c.saveDetail(&name); + QContactPhoneNumber number; + number.setNumber("1234567"); + number.setContexts(QContactDetail::ContextHome); + number.setSubTypes(QContactPhoneNumber::SubTypeMobile); + c.saveDetail(&number); + manager.saveContact(&c); + + ContactInfoFields fields; + fields = ContactInfoTextField; + + QSignalSpy spy(mCntPresenceInfoProvider, SIGNAL(infoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&))); + + mCntPresenceInfoProvider->requestInfo(c, fields); + QCOMPARE(spy.count(), 0); + QVERIFY(mCntPresenceInfoProvider->mBuddyMap.isEmpty()); + + fields = ContactInfoIcon2Field; + + mCntPresenceInfoProvider->requestInfo(c, fields); + QCOMPARE(spy.count(), 0); + QVERIFY(mCntPresenceInfoProvider->mBuddyMap.isEmpty()); + + QContactOnlineAccount account; + account.setSubTypes(QStringList() << QContactOnlineAccount::SubTypeSip); + account.setServiceProvider("sip"); + account.setAccountUri("test@test.com"); + c.saveDetail(&account); + QContactOnlineAccount account2; + account2.setSubTypes(QStringList() << QContactOnlineAccount::SubTypeSipVoip); + account.setServiceProvider("sip"); + account2.setAccountUri("test@test.com"); + c.saveDetail(&account2); + QContactOnlineAccount account3; + account3.setSubTypes(QStringList() << QContactOnlineAccount::SubTypeSip); + account3.setAccountUri("malformatted"); + c.saveDetail(&account3); + manager.saveContact(&c); + + mCntPresenceInfoProvider->requestInfo(c, fields); + QCOMPARE(spy.count(), 0); + QCOMPARE(mCntPresenceInfoProvider->mBuddyMap.count(), 1); + + delete mCntPresenceInfoProvider; + mCntPresenceInfoProvider = NULL; + + buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcAvailable, "meh"); + writer->writePresence(*buddy); + + mCntPresenceInfoProvider = new CntPresenceInfoProvider(); + + QSignalSpy spy2(mCntPresenceInfoProvider, SIGNAL(infoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&))); + mCntPresenceInfoProvider->requestInfo(c, fields); + QCOMPARE(spy2.count(), 1); + QCOMPARE(mCntPresenceInfoProvider->mBuddyMap.count(), 1); + + delete buddy; + delete writer; +} + +void TestCntPresenceInfoProvider::testHandlePresenceUpdate() +{ + QSignalSpy spy(mCntPresenceInfoProvider, SIGNAL(infoFieldReady(CntInfoProvider*, int, ContactInfoField, const QString&))); + + PrcPresenceWriter *writer = PrcPresenceWriter::createWriter(); + PrcPresenceReader *reader = PrcPresenceReader::createReader(); + + PrcPresenceBuddyInfoQt *dummyBuddy = PrcPresenceBuddyInfoQt::createInstance(); + dummyBuddy->setIdentity("sip:dummy@dummy.com"); + dummyBuddy->setAvailability(PrcPresenceBuddyInfoQt::PrcAvailable, "meh"); + writer->writePresence(*dummyBuddy); + + mCntPresenceInfoProvider->handlePresenceUpdate(true, dummyBuddy); + QCOMPARE(spy.count(), 0); + + mCntPresenceInfoProvider->handlePresenceUpdate(false, dummyBuddy); + QCOMPARE(spy.count(), 0); + + mCntPresenceInfoProvider->handlePresenceUpdate(true, NULL); + QCOMPARE(spy.count(), 0); + + PrcPresenceBuddyInfoQt *buddy = reader->presenceInfo("sip:test@test.com"); + buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcNotAvailable, "meh"); + writer->writePresence(*buddy); + QTest::qWait(5000); + QCOMPARE(spy.count(), 1); + + QContactManager manager("symbian"); + QContact c = manager.contact(mCntPresenceInfoProvider->mBuddyMap.value("sip:test@test.com")); + + QList accounts = c.details(); + foreach (QContactOnlineAccount account, accounts) + { + c.removeDetail(&account); + } + manager.saveContact(&c); + + buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcAvailable, "meh"); + writer->writePresence(*buddy); + QTest::qWait(5000); + QCOMPARE(spy.count(), 2); + + delete writer; + delete reader; + delete dummyBuddy; + delete buddy; +} + +void TestCntPresenceInfoProvider::testParsePresence() +{ + PrcPresenceBuddyInfoQt *buddy = PrcPresenceBuddyInfoQt::createInstance(); + buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcNotAvailable, "meh"); + + QList buddies; + buddies.append(buddy); + + QVERIFY(mCntPresenceInfoProvider->parsePresence(buddies).isEmpty()); + + buddy->setAvailability(PrcPresenceBuddyInfoQt::PrcAvailable, "meh"); + + QVERIFY(mCntPresenceInfoProvider->parsePresence(buddies) == "qtg_small_online"); + + delete buddy; +} + +void TestCntPresenceInfoProvider::cleanupTestCase() +{ + delete mCntPresenceInfoProvider; + mCntPresenceInfoProvider = NULL; + + QContactManager manager("symbian"); + QList ids = manager.contactIds(); + QMap errorMap; + manager.removeContacts(ids, &errorMap); +} + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/ut_cntlistmodel.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntlistmodel/tsrc/ut_cntlistmodel/ut_cntlistmodel.pro Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,79 @@ +# +# 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: +# +# + + +TEMPLATE = app +TARGET = + +DEFINES += QT_NO_DEBUG_OUTPUT +DEFINES += QT_NO_WARNING_OUTPUT +DEFINES += CNTLISTMODEL_NO_EXPORT + +MOC_DIR = moc + +QT += testlib xml + +CONFIG += hb + +TARGET.CAPABILITY = ALL \ + -TCB + +INCLUDEPATH += . +INCLUDEPATH += ../../inc +INCLUDEPATH += ../../../../inc +INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + +HEADERS += inc/testrunner.h \ + inc/ut_cntlistmodel.h \ + inc/ut_cntcache.h \ + inc/ut_cntpresenceinfoprovider.h \ + inc/ut_cntdefaultinfoprovider.h \ + inc/ut_cntdisplaytextformatter.h \ + ../../inc/cntlistmodelglobal.h \ + ../../inc/cntlistmodel.h \ + ../../inc/cntlistmodel_p.h \ + ../../inc/cntcache.h \ + ../../inc/cntcache_p.h \ + ../../inc/cntdefaultinfoprovider.h \ + ../../inc/cntpresenceinfoprovider.h \ + ../../inc/cntdisplaytextformatter.h \ + ../../../../inc/cntdebug.h + +SOURCES += src/testrunner.cpp \ + src/main.cpp \ + src/ut_cntlistmodel.cpp \ + src/ut_cntcache.cpp \ + src/ut_cntpresenceinfoprovider.cpp \ + src/ut_cntdefaultinfoprovider.cpp \ + src/ut_cntdisplaytextformatter.cpp \ + ../../src/cntlistmodel.cpp \ + ../../src/cntcache.cpp \ + ../../src/cntcache_p.cpp \ + ../../src/cntdefaultinfoprovider.cpp \ + ../../src/cntpresenceinfoprovider.cpp \ + ../../src/cntdisplaytextformatter.cpp + +BLD_INF_RULES.prj_exports += "image1.png /epoc32/winscw/c/data/images/" +BLD_INF_RULES.prj_exports += "image2.png /epoc32/winscw/c/data/images/" + +LIBS += -lQtContacts \ + -lhbcore \ + -lthumbnailmanagerqt \ + -lpresencecacheqt \ + -lxqsettingsmanager + +symbian:MMP_RULES += SMPSAFE \ No newline at end of file diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/eabi/cntcommonuiu.def --- a/phonebookui/eabi/cntcommonuiu.def Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/eabi/cntcommonuiu.def Fri Oct 15 12:24:46 2010 +0300 @@ -1,207 +1,217 @@ EXPORTS _ZN11CntEditView10deactivateEv @ 1 NONAME - _ZN11CntEditView11qt_metacallEN11QMetaObject4CallEiPPv @ 2 NONAME - _ZN11CntEditView11qt_metacastEPKc @ 3 NONAME - _ZN11CntEditView14contactRemovedEb @ 4 NONAME - _ZN11CntEditView14contactUpdatedEi @ 5 NONAME - _ZN11CntEditView16changesDiscardedEv @ 6 NONAME - _ZN11CntEditView16staticMetaObjectE @ 7 NONAME DATA 16 - _ZN11CntEditView19getStaticMetaObjectEv @ 8 NONAME - _ZN11CntEditView8activateE4QMapIi8QVariantE @ 9 NONAME - _ZN11CntEditView9setEngineER17CntAbstractEngine @ 10 NONAME - _ZN11CntEditViewC1Ev @ 11 NONAME - _ZN11CntEditViewC2Ev @ 12 NONAME - _ZN11CntEditViewD0Ev @ 13 NONAME - _ZN11CntEditViewD1Ev @ 14 NONAME - _ZN11CntEditViewD2Ev @ 15 NONAME - _ZN13CntKeyGrabber11eventFilterEP7QObjectP6QEvent @ 16 NONAME - _ZN13CntKeyGrabber11qt_metacallEN11QMetaObject4CallEiPPv @ 17 NONAME - _ZN13CntKeyGrabber11qt_metacastEPKc @ 18 NONAME - _ZN13CntKeyGrabber16staticMetaObjectE @ 19 NONAME DATA 16 - _ZN13CntKeyGrabber19getStaticMetaObjectEv @ 20 NONAME - _ZN13CntKeyGrabberC1EP12HbMainWindowP7QObject @ 21 NONAME - _ZN13CntKeyGrabberC2EP12HbMainWindowP7QObject @ 22 NONAME - _ZN13CntKeyGrabberD0Ev @ 23 NONAME - _ZN13CntKeyGrabberD1Ev @ 24 NONAME - _ZN13CntKeyGrabberD2Ev @ 25 NONAME - _ZN13CntMainWindow11qt_metacallEN11QMetaObject4CallEiPPv @ 26 NONAME - _ZN13CntMainWindow11qt_metacastEPKc @ 27 NONAME - _ZN13CntMainWindow16staticMetaObjectE @ 28 NONAME DATA 16 - _ZN13CntMainWindow19getStaticMetaObjectEv @ 29 NONAME - _ZN13CntMainWindowC1EP7QWidgeti @ 30 NONAME - _ZN13CntMainWindowC2EP7QWidgeti @ 31 NONAME - _ZN13CntMainWindowD0Ev @ 32 NONAME - _ZN13CntMainWindowD1Ev @ 33 NONAME - _ZN13CntMainWindowD2Ev @ 34 NONAME - _ZN14CntActionPopup11qt_metacallEN11QMetaObject4CallEiPPv @ 35 NONAME - _ZN14CntActionPopup11qt_metacastEPKc @ 36 NONAME - _ZN14CntActionPopup15showActionPopupE7QString @ 37 NONAME - _ZN14CntActionPopup16staticMetaObjectE @ 38 NONAME DATA 16 - _ZN14CntActionPopup19getStaticMetaObjectEv @ 39 NONAME - _ZN14CntActionPopup20executeContactActionERN10QtMobility8QContactENS0_14QContactDetailE7QString @ 40 NONAME - _ZN14CntActionPopup24actionPopupCancelPressedEv @ 41 NONAME - _ZN14CntActionPopupC1EPN10QtMobility8QContactE @ 42 NONAME - _ZN14CntActionPopupC2EPN10QtMobility8QContactE @ 43 NONAME - _ZN14CntActionPopupD0Ev @ 44 NONAME - _ZN14CntActionPopupD1Ev @ 45 NONAME - _ZN14CntActionPopupD2Ev @ 46 NONAME - _ZN16CntViewNavigator11qt_metacallEN11QMetaObject4CallEiPPv @ 47 NONAME - _ZN16CntViewNavigator11qt_metacastEPKc @ 48 NONAME - _ZN16CntViewNavigator12addExceptionERKiS1_ @ 49 NONAME - _ZN16CntViewNavigator12removeEffectERKi @ 50 NONAME - _ZN16CntViewNavigator15removeExceptionERKi @ 51 NONAME - _ZN16CntViewNavigator16staticMetaObjectE @ 52 NONAME DATA 16 - _ZN16CntViewNavigator19getStaticMetaObjectEv @ 53 NONAME - _ZN16CntViewNavigator4backER6QFlagsIN2Hb14ViewSwitchFlagEEb @ 54 NONAME - _ZN16CntViewNavigator4nextERKiR6QFlagsIN2Hb14ViewSwitchFlagEE @ 55 NONAME - _ZN16CntViewNavigator7addRootERKi @ 56 NONAME - _ZN16CntViewNavigator9addEffectERKiS1_ @ 57 NONAME - _ZN16CntViewNavigatorC1EP7QObject @ 58 NONAME - _ZN16CntViewNavigatorC2EP7QObject @ 59 NONAME - _ZN16CntViewNavigatorD0Ev @ 60 NONAME - _ZN16CntViewNavigatorD1Ev @ 61 NONAME - _ZN16CntViewNavigatorD2Ev @ 62 NONAME - _ZN18CntContactCardView10deactivateEv @ 63 NONAME - _ZN18CntContactCardView11backPressedEi @ 64 NONAME - _ZN18CntContactCardView11qt_metacallEN11QMetaObject4CallEiPPv @ 65 NONAME - _ZN18CntContactCardView11qt_metacastEPKc @ 66 NONAME - _ZN18CntContactCardView13addToContactsEv @ 67 NONAME - _ZN18CntContactCardView13viewActivatedEP22CntAbstractViewManager4QMapIi8QVariantE @ 68 NONAME - _ZN18CntContactCardView16staticMetaObjectE @ 69 NONAME DATA 16 - _ZN18CntContactCardView19getStaticMetaObjectEv @ 70 NONAME - _ZN18CntContactCardView8activateE4QMapIi8QVariantE @ 71 NONAME - _ZN18CntContactCardView9setEngineER17CntAbstractEngine @ 72 NONAME - _ZN18CntContactCardViewC1Eb @ 73 NONAME - _ZN18CntContactCardViewC2Eb @ 74 NONAME - _ZN18CntContactCardViewD0Ev @ 75 NONAME - _ZN18CntContactCardViewD1Ev @ 76 NONAME - _ZN18CntContactCardViewD2Ev @ 77 NONAME - _ZN18CntGroupMemberView10deactivateEv @ 78 NONAME - _ZN18CntGroupMemberView11backPressedEv @ 79 NONAME - _ZN18CntGroupMemberView11qt_metacallEN11QMetaObject4CallEiPPv @ 80 NONAME - _ZN18CntGroupMemberView11qt_metacastEPKc @ 81 NONAME - _ZN18CntGroupMemberView16staticMetaObjectE @ 82 NONAME DATA 16 - _ZN18CntGroupMemberView19getStaticMetaObjectEv @ 83 NONAME - _ZN18CntGroupMemberView8activateE4QMapIi8QVariantE @ 84 NONAME - _ZN18CntGroupMemberView9setEngineER17CntAbstractEngine @ 85 NONAME - _ZN18CntGroupMemberViewC1Ev @ 86 NONAME - _ZN18CntGroupMemberViewC2Ev @ 87 NONAME - _ZN18CntGroupMemberViewD0Ev @ 88 NONAME - _ZN18CntGroupMemberViewD1Ev @ 89 NONAME - _ZN18CntGroupMemberViewD2Ev @ 90 NONAME - _ZN20CntBaseSelectionView10deactivateEv @ 91 NONAME - _ZN20CntBaseSelectionView10viewClosedEv @ 92 NONAME - _ZN20CntBaseSelectionView10viewOpenedEP22CntAbstractViewManager4QMapIi8QVariantE @ 93 NONAME - _ZN20CntBaseSelectionView11qt_metacallEN11QMetaObject4CallEiPPv @ 94 NONAME - _ZN20CntBaseSelectionView11qt_metacastEPKc @ 95 NONAME - _ZN20CntBaseSelectionView16staticMetaObjectE @ 96 NONAME DATA 16 - _ZN20CntBaseSelectionView19getStaticMetaObjectEv @ 97 NONAME - _ZN20CntBaseSelectionView8activateE4QMapIi8QVariantE @ 98 NONAME - _ZN20CntBaseSelectionViewC2Ev @ 99 NONAME - _ZN20CntBaseSelectionViewD0Ev @ 100 NONAME - _ZN20CntBaseSelectionViewD1Ev @ 101 NONAME - _ZN20CntBaseSelectionViewD2Ev @ 102 NONAME - _ZN21CntDefaultViewFactory10createViewEi @ 103 NONAME - _ZN21CntDefaultViewFactory16createPluginViewEi @ 104 NONAME - _ZN21CntDefaultViewFactoryC1ER19CntExtensionManager @ 105 NONAME - _ZN21CntDefaultViewFactoryC2ER19CntExtensionManager @ 106 NONAME - _ZN21CntDefaultViewFactoryD0Ev @ 107 NONAME - _ZN21CntDefaultViewFactoryD1Ev @ 108 NONAME - _ZN21CntDefaultViewFactoryD2Ev @ 109 NONAME - _ZN21CntDefaultViewManager10changeViewE4QMapIi8QVariantE @ 110 NONAME - _ZN21CntDefaultViewManager10switchViewE4QMapIi8QVariantE6QFlagsIN2Hb14ViewSwitchFlagEE @ 111 NONAME - _ZN21CntDefaultViewManager11qt_metacallEN11QMetaObject4CallEiPPv @ 112 NONAME - _ZN21CntDefaultViewManager11qt_metacastEPKc @ 113 NONAME - _ZN21CntDefaultViewManager13currentViewIdEv @ 114 NONAME - _ZN21CntDefaultViewManager13deleteOldViewEv @ 115 NONAME - _ZN21CntDefaultViewManager14setViewFactoryEP22CntAbstractViewFactory @ 116 NONAME - _ZN21CntDefaultViewManager16setViewNavigatorEP16CntViewNavigator @ 117 NONAME - _ZN21CntDefaultViewManager16staticMetaObjectE @ 118 NONAME DATA 16 - _ZN21CntDefaultViewManager17removeCurrentViewEv @ 119 NONAME - _ZN21CntDefaultViewManager19getStaticMetaObjectEv @ 120 NONAME - _ZN21CntDefaultViewManager4backE4QMapIi8QVariantEb @ 121 NONAME - _ZN21CntDefaultViewManager6engineEv @ 122 NONAME - _ZN21CntDefaultViewManager7cleanupEv @ 123 NONAME - _ZN21CntDefaultViewManager8closeAppEv @ 124 NONAME - _ZN21CntDefaultViewManagerC1EP12HbMainWindow @ 125 NONAME - _ZN21CntDefaultViewManagerC2EP12HbMainWindow @ 126 NONAME - _ZN21CntDefaultViewManagerD0Ev @ 127 NONAME - _ZN21CntDefaultViewManagerD1Ev @ 128 NONAME - _ZN21CntDefaultViewManagerD2Ev @ 129 NONAME - _ZNK11CntEditView10metaObjectEv @ 130 NONAME - _ZNK11CntEditView4viewEv @ 131 NONAME - _ZNK11CntEditView6viewIdEv @ 132 NONAME - _ZNK11CntEditView9isDefaultEv @ 133 NONAME - _ZNK13CntKeyGrabber10metaObjectEv @ 134 NONAME - _ZNK13CntMainWindow10metaObjectEv @ 135 NONAME - _ZNK14CntActionPopup10metaObjectEv @ 136 NONAME - _ZNK16CntViewNavigator10metaObjectEv @ 137 NONAME - _ZNK18CntContactCardView10metaObjectEv @ 138 NONAME - _ZNK18CntContactCardView4viewEv @ 139 NONAME - _ZNK18CntContactCardView6viewIdEv @ 140 NONAME - _ZNK18CntContactCardView9isDefaultEv @ 141 NONAME - _ZNK18CntGroupMemberView10metaObjectEv @ 142 NONAME - _ZNK18CntGroupMemberView4viewEv @ 143 NONAME - _ZNK18CntGroupMemberView6viewIdEv @ 144 NONAME - _ZNK18CntGroupMemberView9isDefaultEv @ 145 NONAME - _ZNK20CntBaseSelectionView10metaObjectEv @ 146 NONAME - _ZNK20CntBaseSelectionView4viewEv @ 147 NONAME - _ZNK20CntBaseSelectionView9isDefaultEv @ 148 NONAME - _ZNK21CntDefaultViewManager10metaObjectEv @ 149 NONAME - _ZTI11CntEditView @ 150 NONAME - _ZTI13CntKeyGrabber @ 151 NONAME - _ZTI13CntMainWindow @ 152 NONAME - _ZTI14CntActionPopup @ 153 NONAME - _ZTI16CntViewNavigator @ 154 NONAME - _ZTI18CntContactCardView @ 155 NONAME - _ZTI18CntGroupMemberView @ 156 NONAME - _ZTI20CntBaseSelectionView @ 157 NONAME - _ZTI21CntDefaultViewFactory @ 158 NONAME - _ZTI21CntDefaultViewManager @ 159 NONAME - _ZTV11CntEditView @ 160 NONAME - _ZTV13CntKeyGrabber @ 161 NONAME - _ZTV13CntMainWindow @ 162 NONAME - _ZTV14CntActionPopup @ 163 NONAME - _ZTV16CntViewNavigator @ 164 NONAME - _ZTV18CntContactCardView @ 165 NONAME - _ZTV18CntGroupMemberView @ 166 NONAME - _ZTV20CntBaseSelectionView @ 167 NONAME - _ZTV21CntDefaultViewFactory @ 168 NONAME - _ZTV21CntDefaultViewManager @ 169 NONAME - _ZThn8_N11CntEditView10deactivateEv @ 170 NONAME - _ZThn8_N11CntEditView8activateE4QMapIi8QVariantE @ 171 NONAME - _ZThn8_N11CntEditView9setEngineER17CntAbstractEngine @ 172 NONAME - _ZThn8_N11CntEditViewD0Ev @ 173 NONAME - _ZThn8_N11CntEditViewD1Ev @ 174 NONAME - _ZThn8_N13CntMainWindowD0Ev @ 175 NONAME - _ZThn8_N13CntMainWindowD1Ev @ 176 NONAME - _ZThn8_N18CntContactCardView10deactivateEv @ 177 NONAME - _ZThn8_N18CntContactCardView8activateE4QMapIi8QVariantE @ 178 NONAME - _ZThn8_N18CntContactCardView9setEngineER17CntAbstractEngine @ 179 NONAME - _ZThn8_N18CntContactCardViewD0Ev @ 180 NONAME - _ZThn8_N18CntContactCardViewD1Ev @ 181 NONAME - _ZThn8_N18CntGroupMemberView10deactivateEv @ 182 NONAME - _ZThn8_N18CntGroupMemberView8activateE4QMapIi8QVariantE @ 183 NONAME - _ZThn8_N18CntGroupMemberView9setEngineER17CntAbstractEngine @ 184 NONAME - _ZThn8_N18CntGroupMemberViewD0Ev @ 185 NONAME - _ZThn8_N18CntGroupMemberViewD1Ev @ 186 NONAME - _ZThn8_N20CntBaseSelectionView10deactivateEv @ 187 NONAME - _ZThn8_N20CntBaseSelectionView8activateE4QMapIi8QVariantE @ 188 NONAME - _ZThn8_N20CntBaseSelectionViewD0Ev @ 189 NONAME - _ZThn8_N20CntBaseSelectionViewD1Ev @ 190 NONAME - _ZThn8_N21CntDefaultViewManager10changeViewE4QMapIi8QVariantE @ 191 NONAME - _ZThn8_N21CntDefaultViewManager4backE4QMapIi8QVariantEb @ 192 NONAME - _ZThn8_N21CntDefaultViewManagerD0Ev @ 193 NONAME - _ZThn8_N21CntDefaultViewManagerD1Ev @ 194 NONAME - _ZThn8_NK11CntEditView4viewEv @ 195 NONAME - _ZThn8_NK11CntEditView6viewIdEv @ 196 NONAME - _ZThn8_NK11CntEditView9isDefaultEv @ 197 NONAME - _ZThn8_NK18CntContactCardView4viewEv @ 198 NONAME - _ZThn8_NK18CntContactCardView6viewIdEv @ 199 NONAME - _ZThn8_NK18CntContactCardView9isDefaultEv @ 200 NONAME - _ZThn8_NK18CntGroupMemberView4viewEv @ 201 NONAME - _ZThn8_NK18CntGroupMemberView6viewIdEv @ 202 NONAME - _ZThn8_NK18CntGroupMemberView9isDefaultEv @ 203 NONAME - _ZThn8_NK20CntBaseSelectionView4viewEv @ 204 NONAME - _ZThn8_NK20CntBaseSelectionView9isDefaultEv @ 205 NONAME + _ZN11CntEditView11externalizeER11QDataStream @ 2 NONAME + _ZN11CntEditView11internalizeER11QDataStreamR4QMapIi8QVariantE @ 3 NONAME + _ZN11CntEditView11qt_metacallEN11QMetaObject4CallEiPPv @ 4 NONAME + _ZN11CntEditView11qt_metacastEPKc @ 5 NONAME + _ZN11CntEditView14contactRemovedEb @ 6 NONAME + _ZN11CntEditView14contactUpdatedEi @ 7 NONAME + _ZN11CntEditView16changesDiscardedEv @ 8 NONAME + _ZN11CntEditView16staticMetaObjectE @ 9 NONAME DATA 16 + _ZN11CntEditView19getStaticMetaObjectEv @ 10 NONAME + _ZN11CntEditView8activateE4QMapIi8QVariantE @ 11 NONAME + _ZN11CntEditView9setEngineER17CntAbstractEngine @ 12 NONAME + _ZN11CntEditViewC1Ev @ 13 NONAME + _ZN11CntEditViewC2Ev @ 14 NONAME + _ZN11CntEditViewD0Ev @ 15 NONAME + _ZN11CntEditViewD1Ev @ 16 NONAME + _ZN11CntEditViewD2Ev @ 17 NONAME + _ZN13CntKeyGrabber11eventFilterEP7QObjectP6QEvent @ 18 NONAME + _ZN13CntKeyGrabber11qt_metacallEN11QMetaObject4CallEiPPv @ 19 NONAME + _ZN13CntKeyGrabber11qt_metacastEPKc @ 20 NONAME + _ZN13CntKeyGrabber16staticMetaObjectE @ 21 NONAME DATA 16 + _ZN13CntKeyGrabber19getStaticMetaObjectEv @ 22 NONAME + _ZN13CntKeyGrabberC1EP12HbMainWindowP7QObject @ 23 NONAME + _ZN13CntKeyGrabberC2EP12HbMainWindowP7QObject @ 24 NONAME + _ZN13CntKeyGrabberD0Ev @ 25 NONAME + _ZN13CntKeyGrabberD1Ev @ 26 NONAME + _ZN13CntKeyGrabberD2Ev @ 27 NONAME + _ZN13CntMainWindow11qt_metacallEN11QMetaObject4CallEiPPv @ 28 NONAME + _ZN13CntMainWindow11qt_metacastEPKc @ 29 NONAME + _ZN13CntMainWindow12saveActivityEv @ 30 NONAME + _ZN13CntMainWindow16staticMetaObjectE @ 31 NONAME DATA 16 + _ZN13CntMainWindow19getStaticMetaObjectEv @ 32 NONAME + _ZN13CntMainWindowC1EP7QWidgeti @ 33 NONAME + _ZN13CntMainWindowC2EP7QWidgeti @ 34 NONAME + _ZN13CntMainWindowD0Ev @ 35 NONAME + _ZN13CntMainWindowD1Ev @ 36 NONAME + _ZN13CntMainWindowD2Ev @ 37 NONAME + _ZN14CntActionPopup11qt_metacallEN11QMetaObject4CallEiPPv @ 38 NONAME + _ZN14CntActionPopup11qt_metacastEPKc @ 39 NONAME + _ZN14CntActionPopup15showActionPopupE7QString @ 40 NONAME + _ZN14CntActionPopup16staticMetaObjectE @ 41 NONAME DATA 16 + _ZN14CntActionPopup19getStaticMetaObjectEv @ 42 NONAME + _ZN14CntActionPopup20executeContactActionERN10QtMobility8QContactENS0_14QContactDetailE7QString @ 43 NONAME + _ZN14CntActionPopup24actionPopupCancelPressedEv @ 44 NONAME + _ZN14CntActionPopupC1EPN10QtMobility8QContactE @ 45 NONAME + _ZN14CntActionPopupC2EPN10QtMobility8QContactE @ 46 NONAME + _ZN14CntActionPopupD0Ev @ 47 NONAME + _ZN14CntActionPopupD1Ev @ 48 NONAME + _ZN14CntActionPopupD2Ev @ 49 NONAME + _ZN16CntViewNavigator11externalizeER11QDataStream @ 50 NONAME + _ZN16CntViewNavigator11internalizeER11QDataStream @ 51 NONAME + _ZN16CntViewNavigator11qt_metacallEN11QMetaObject4CallEiPPv @ 52 NONAME + _ZN16CntViewNavigator11qt_metacastEPKc @ 53 NONAME + _ZN16CntViewNavigator12addExceptionERKiS1_ @ 54 NONAME + _ZN16CntViewNavigator12removeEffectERKi @ 55 NONAME + _ZN16CntViewNavigator14clearViewStackEv @ 56 NONAME + _ZN16CntViewNavigator15removeExceptionERKi @ 57 NONAME + _ZN16CntViewNavigator16staticMetaObjectE @ 58 NONAME DATA 16 + _ZN16CntViewNavigator19getStaticMetaObjectEv @ 59 NONAME + _ZN16CntViewNavigator4backER6QFlagsIN2Hb14ViewSwitchFlagEEb @ 60 NONAME + _ZN16CntViewNavigator4nextERKiR6QFlagsIN2Hb14ViewSwitchFlagEE @ 61 NONAME + _ZN16CntViewNavigator7addRootERKi @ 62 NONAME + _ZN16CntViewNavigator9addEffectERKiS1_ @ 63 NONAME + _ZN16CntViewNavigatorC1EP7QObject @ 64 NONAME + _ZN16CntViewNavigatorC2EP7QObject @ 65 NONAME + _ZN16CntViewNavigatorD0Ev @ 66 NONAME + _ZN16CntViewNavigatorD1Ev @ 67 NONAME + _ZN16CntViewNavigatorD2Ev @ 68 NONAME + _ZN18CntContactCardView10deactivateEv @ 69 NONAME + _ZN18CntContactCardView11backPressedEi @ 70 NONAME + _ZN18CntContactCardView11externalizeER11QDataStream @ 71 NONAME + _ZN18CntContactCardView11internalizeER11QDataStreamR4QMapIi8QVariantE @ 72 NONAME + _ZN18CntContactCardView11qt_metacallEN11QMetaObject4CallEiPPv @ 73 NONAME + _ZN18CntContactCardView11qt_metacastEPKc @ 74 NONAME + _ZN18CntContactCardView13addToContactsEv @ 75 NONAME + _ZN18CntContactCardView13viewActivatedEP22CntAbstractViewManager4QMapIi8QVariantE @ 76 NONAME + _ZN18CntContactCardView16staticMetaObjectE @ 77 NONAME DATA 16 + _ZN18CntContactCardView19getStaticMetaObjectEv @ 78 NONAME + _ZN18CntContactCardView8activateE4QMapIi8QVariantE @ 79 NONAME + _ZN18CntContactCardView9setEngineER17CntAbstractEngine @ 80 NONAME + _ZN18CntContactCardViewC1Eb @ 81 NONAME + _ZN18CntContactCardViewC2Eb @ 82 NONAME + _ZN18CntContactCardViewD0Ev @ 83 NONAME + _ZN18CntContactCardViewD1Ev @ 84 NONAME + _ZN18CntContactCardViewD2Ev @ 85 NONAME + _ZN18CntGroupMemberView10deactivateEv @ 86 NONAME + _ZN18CntGroupMemberView11backPressedEv @ 87 NONAME + _ZN18CntGroupMemberView11qt_metacallEN11QMetaObject4CallEiPPv @ 88 NONAME + _ZN18CntGroupMemberView11qt_metacastEPKc @ 89 NONAME + _ZN18CntGroupMemberView16staticMetaObjectE @ 90 NONAME DATA 16 + _ZN18CntGroupMemberView19getStaticMetaObjectEv @ 91 NONAME + _ZN18CntGroupMemberView8activateE4QMapIi8QVariantE @ 92 NONAME + _ZN18CntGroupMemberView9setEngineER17CntAbstractEngine @ 93 NONAME + _ZN18CntGroupMemberViewC1Ev @ 94 NONAME + _ZN18CntGroupMemberViewC2Ev @ 95 NONAME + _ZN18CntGroupMemberViewD0Ev @ 96 NONAME + _ZN18CntGroupMemberViewD1Ev @ 97 NONAME + _ZN18CntGroupMemberViewD2Ev @ 98 NONAME + _ZN20CntBaseSelectionView10deactivateEv @ 99 NONAME + _ZN20CntBaseSelectionView10viewClosedEv @ 100 NONAME + _ZN20CntBaseSelectionView10viewOpenedEP22CntAbstractViewManager4QMapIi8QVariantE @ 101 NONAME + _ZN20CntBaseSelectionView11qt_metacallEN11QMetaObject4CallEiPPv @ 102 NONAME + _ZN20CntBaseSelectionView11qt_metacastEPKc @ 103 NONAME + _ZN20CntBaseSelectionView16staticMetaObjectE @ 104 NONAME DATA 16 + _ZN20CntBaseSelectionView19getStaticMetaObjectEv @ 105 NONAME + _ZN20CntBaseSelectionView8activateE4QMapIi8QVariantE @ 106 NONAME + _ZN20CntBaseSelectionViewC2Ev @ 107 NONAME + _ZN20CntBaseSelectionViewD0Ev @ 108 NONAME + _ZN20CntBaseSelectionViewD1Ev @ 109 NONAME + _ZN20CntBaseSelectionViewD2Ev @ 110 NONAME + _ZN21CntDefaultViewFactory10createViewEi @ 111 NONAME + _ZN21CntDefaultViewFactory16createPluginViewEi @ 112 NONAME + _ZN21CntDefaultViewFactoryC1ER19CntExtensionManager @ 113 NONAME + _ZN21CntDefaultViewFactoryC2ER19CntExtensionManager @ 114 NONAME + _ZN21CntDefaultViewFactoryD0Ev @ 115 NONAME + _ZN21CntDefaultViewFactoryD1Ev @ 116 NONAME + _ZN21CntDefaultViewFactoryD2Ev @ 117 NONAME + _ZN21CntDefaultViewManager10changeViewE4QMapIi8QVariantE @ 118 NONAME + _ZN21CntDefaultViewManager10switchViewE4QMapIi8QVariantE6QFlagsIN2Hb14ViewSwitchFlagEE @ 119 NONAME + _ZN21CntDefaultViewManager11internalizeER11QDataStream @ 120 NONAME + _ZN21CntDefaultViewManager11qt_metacallEN11QMetaObject4CallEiPPv @ 121 NONAME + _ZN21CntDefaultViewManager11qt_metacastEPKc @ 122 NONAME + _ZN21CntDefaultViewManager12activateViewEP15CntAbstractView4QMapIi8QVariantE6QFlagsIN2Hb14ViewSwitchFlagEE @ 123 NONAME + _ZN21CntDefaultViewManager13deleteOldViewEv @ 124 NONAME + _ZN21CntDefaultViewManager14setViewFactoryEP22CntAbstractViewFactory @ 125 NONAME + _ZN21CntDefaultViewManager16setViewNavigatorEP16CntViewNavigator @ 126 NONAME + _ZN21CntDefaultViewManager16staticMetaObjectE @ 127 NONAME DATA 16 + _ZN21CntDefaultViewManager17removeCurrentViewEv @ 128 NONAME + _ZN21CntDefaultViewManager19getStaticMetaObjectEv @ 129 NONAME + _ZN21CntDefaultViewManager4backE4QMapIi8QVariantEb @ 130 NONAME + _ZN21CntDefaultViewManager6engineEv @ 131 NONAME + _ZN21CntDefaultViewManager7cleanupEv @ 132 NONAME + _ZN21CntDefaultViewManager8closeAppEv @ 133 NONAME + _ZN21CntDefaultViewManagerC1EP12HbMainWindow @ 134 NONAME + _ZN21CntDefaultViewManagerC2EP12HbMainWindow @ 135 NONAME + _ZN21CntDefaultViewManagerD0Ev @ 136 NONAME + _ZN21CntDefaultViewManagerD1Ev @ 137 NONAME + _ZN21CntDefaultViewManagerD2Ev @ 138 NONAME + _ZNK11CntEditView10metaObjectEv @ 139 NONAME + _ZNK11CntEditView4viewEv @ 140 NONAME + _ZNK11CntEditView6viewIdEv @ 141 NONAME + _ZNK11CntEditView9isDefaultEv @ 142 NONAME + _ZNK13CntKeyGrabber10metaObjectEv @ 143 NONAME + _ZNK13CntMainWindow10metaObjectEv @ 144 NONAME + _ZNK14CntActionPopup10metaObjectEv @ 145 NONAME + _ZNK16CntViewNavigator10metaObjectEv @ 146 NONAME + _ZNK18CntContactCardView10metaObjectEv @ 147 NONAME + _ZNK18CntContactCardView4viewEv @ 148 NONAME + _ZNK18CntContactCardView6viewIdEv @ 149 NONAME + _ZNK18CntContactCardView9isDefaultEv @ 150 NONAME + _ZNK18CntGroupMemberView10metaObjectEv @ 151 NONAME + _ZNK18CntGroupMemberView4viewEv @ 152 NONAME + _ZNK18CntGroupMemberView6viewIdEv @ 153 NONAME + _ZNK18CntGroupMemberView9isDefaultEv @ 154 NONAME + _ZNK20CntBaseSelectionView10metaObjectEv @ 155 NONAME + _ZNK21CntDefaultViewManager10metaObjectEv @ 156 NONAME + _ZNK21CntDefaultViewManager11externalizeER11QDataStream @ 157 NONAME + _ZTI11CntEditView @ 158 NONAME + _ZTI13CntKeyGrabber @ 159 NONAME + _ZTI13CntMainWindow @ 160 NONAME + _ZTI14CntActionPopup @ 161 NONAME + _ZTI16CntViewNavigator @ 162 NONAME + _ZTI18CntContactCardView @ 163 NONAME + _ZTI18CntGroupMemberView @ 164 NONAME + _ZTI20CntBaseSelectionView @ 165 NONAME + _ZTI21CntDefaultViewFactory @ 166 NONAME + _ZTI21CntDefaultViewManager @ 167 NONAME + _ZTV11CntEditView @ 168 NONAME + _ZTV13CntKeyGrabber @ 169 NONAME + _ZTV13CntMainWindow @ 170 NONAME + _ZTV14CntActionPopup @ 171 NONAME + _ZTV16CntViewNavigator @ 172 NONAME + _ZTV18CntContactCardView @ 173 NONAME + _ZTV18CntGroupMemberView @ 174 NONAME + _ZTV20CntBaseSelectionView @ 175 NONAME + _ZTV21CntDefaultViewFactory @ 176 NONAME + _ZTV21CntDefaultViewManager @ 177 NONAME + _ZThn8_N11CntEditView10deactivateEv @ 178 NONAME + _ZThn8_N11CntEditView11externalizeER11QDataStream @ 179 NONAME + _ZThn8_N11CntEditView11internalizeER11QDataStreamR4QMapIi8QVariantE @ 180 NONAME + _ZThn8_N11CntEditView8activateE4QMapIi8QVariantE @ 181 NONAME + _ZThn8_N11CntEditView9setEngineER17CntAbstractEngine @ 182 NONAME + _ZThn8_N11CntEditViewD0Ev @ 183 NONAME + _ZThn8_N11CntEditViewD1Ev @ 184 NONAME + _ZThn8_N13CntMainWindowD0Ev @ 185 NONAME + _ZThn8_N13CntMainWindowD1Ev @ 186 NONAME + _ZThn8_N18CntContactCardView10deactivateEv @ 187 NONAME + _ZThn8_N18CntContactCardView11externalizeER11QDataStream @ 188 NONAME + _ZThn8_N18CntContactCardView11internalizeER11QDataStreamR4QMapIi8QVariantE @ 189 NONAME + _ZThn8_N18CntContactCardView8activateE4QMapIi8QVariantE @ 190 NONAME + _ZThn8_N18CntContactCardView9setEngineER17CntAbstractEngine @ 191 NONAME + _ZThn8_N18CntContactCardViewD0Ev @ 192 NONAME + _ZThn8_N18CntContactCardViewD1Ev @ 193 NONAME + _ZThn8_N18CntGroupMemberView10deactivateEv @ 194 NONAME + _ZThn8_N18CntGroupMemberView8activateE4QMapIi8QVariantE @ 195 NONAME + _ZThn8_N18CntGroupMemberView9setEngineER17CntAbstractEngine @ 196 NONAME + _ZThn8_N18CntGroupMemberViewD0Ev @ 197 NONAME + _ZThn8_N18CntGroupMemberViewD1Ev @ 198 NONAME + _ZThn8_N20CntBaseSelectionView10deactivateEv @ 199 NONAME + _ZThn8_N20CntBaseSelectionView8activateE4QMapIi8QVariantE @ 200 NONAME + _ZThn8_N20CntBaseSelectionViewD0Ev @ 201 NONAME + _ZThn8_N20CntBaseSelectionViewD1Ev @ 202 NONAME + _ZThn8_N21CntDefaultViewManager10changeViewE4QMapIi8QVariantE @ 203 NONAME + _ZThn8_N21CntDefaultViewManager4backE4QMapIi8QVariantEb @ 204 NONAME + _ZThn8_N21CntDefaultViewManagerD0Ev @ 205 NONAME + _ZThn8_N21CntDefaultViewManagerD1Ev @ 206 NONAME + _ZThn8_NK11CntEditView4viewEv @ 207 NONAME + _ZThn8_NK11CntEditView6viewIdEv @ 208 NONAME + _ZThn8_NK11CntEditView9isDefaultEv @ 209 NONAME + _ZThn8_NK18CntContactCardView4viewEv @ 210 NONAME + _ZThn8_NK18CntContactCardView6viewIdEv @ 211 NONAME + _ZThn8_NK18CntContactCardView9isDefaultEv @ 212 NONAME + _ZThn8_NK18CntGroupMemberView4viewEv @ 213 NONAME + _ZThn8_NK18CntGroupMemberView6viewIdEv @ 214 NONAME + _ZThn8_NK18CntGroupMemberView9isDefaultEv @ 215 NONAME diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/eabi/cntlistmodelu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/eabi/cntlistmodelu.def Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,39 @@ +EXPORTS + _ZN12CntListModel10showMyCardEb @ 1 NONAME + _ZN12CntListModel11handleAddedERK5QListIjE @ 2 NONAME + _ZN12CntListModel11qt_metacallEN11QMetaObject4CallEiPPv @ 3 NONAME + _ZN12CntListModel11qt_metacastEPKc @ 4 NONAME + _ZN12CntListModel12refreshModelEv @ 5 NONAME + _ZN12CntListModel13handleChangedERK5QListIjE @ 6 NONAME + _ZN12CntListModel13handleRemovedERK5QListIjE @ 7 NONAME + _ZN12CntListModel16staticMetaObjectE @ 8 NONAME DATA 16 + _ZN12CntListModel19getStaticMetaObjectEv @ 9 NONAME + _ZN12CntListModel19handleMyCardChangedERKjS1_ @ 10 NONAME + _ZN12CntListModel19updateRelationshipsEv @ 11 NONAME + _ZN12CntListModel21updateContactIdsArrayEv @ 12 NONAME + _ZN12CntListModel23handleAddedRelationshipERK5QListIjE @ 13 NONAME + _ZN12CntListModel23handleRowSettingChangedERK13XQSettingsKeyRK8QVariant @ 14 NONAME + _ZN12CntListModel24handleContactInfoUpdatedEj @ 15 NONAME + _ZN12CntListModel25handleRemovedRelationshipERK5QListIjE @ 16 NONAME + _ZN12CntListModel9setFilterERKN10QtMobility14QContactFilterE @ 17 NONAME + _ZN12CntListModelC1EPN10QtMobility15QContactManagerERKNS0_14QContactFilterEbP7QObject @ 18 NONAME + _ZN12CntListModelC2EPN10QtMobility15QContactManagerERKNS0_14QContactFilterEbP7QObject @ 19 NONAME + _ZN12CntListModelD0Ev @ 20 NONAME + _ZN12CntListModelD1Ev @ 21 NONAME + _ZN12CntListModelD2Ev @ 22 NONAME + _ZNK12CntListModel10isValidRowEi @ 23 NONAME + _ZNK12CntListModel10metaObjectEv @ 24 NONAME + _ZNK12CntListModel11dataForRoleEii @ 25 NONAME + _ZNK12CntListModel13isMyCardShownEv @ 26 NONAME + _ZNK12CntListModel14indexOfContactERKN10QtMobility8QContactE @ 27 NONAME + _ZNK12CntListModel16indexOfContactIdERKj @ 28 NONAME + _ZNK12CntListModel3rowERKj @ 29 NONAME + _ZNK12CntListModel4dataERK11QModelIndexi @ 30 NONAME + _ZNK12CntListModel7contactERK11QModelIndex @ 31 NONAME + _ZNK12CntListModel7contactEi @ 32 NONAME + _ZNK12CntListModel8myCardIdEv @ 33 NONAME + _ZNK12CntListModel8rowCountERK11QModelIndex @ 34 NONAME + _ZNK12CntListModel9contactIdERK11QModelIndex @ 35 NONAME + _ZTI12CntListModel @ 36 NONAME + _ZTV12CntListModel @ 37 NONAME + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookapp/phonebookapp.pro --- a/phonebookui/phonebookapp/phonebookapp.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/phonebookapp/phonebookapp.pro Fri Oct 15 12:24:46 2010 +0300 @@ -52,7 +52,7 @@ SOURCES += src/cntappservicehandler.cpp # capability -TARGET.CAPABILITY = CAP_APPLICATION NetworkControl +TARGET.CAPABILITY = CAP_APPLICATION NetworkControl TrustedUI TRANSLATIONS = contacts.ts @@ -60,7 +60,7 @@ # Skip the UID2/3 thing TARGET.UID3 = 0x20022EF9 TARGET.EPOCSTACKSIZE = 0x14000 - TARGET.EPOCHEAPSIZE = 0x1000 0xA00000 + TARGET.EPOCHEAPSIZE = 0x1000 0x1000000 SKINICON = qtg_large_phonebook diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookservices/inc/cntserviceassigncontactcardview.h --- a/phonebookui/phonebookservices/inc/cntserviceassigncontactcardview.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/phonebookservices/inc/cntserviceassigncontactcardview.h Fri Oct 15 12:24:46 2010 +0300 @@ -26,6 +26,7 @@ class CntServiceHandler; class CntAbstractViewManager; class CntAbstractServiceProvider; +class HbPushButton; QTM_BEGIN_NAMESPACE class QContact; @@ -57,7 +58,8 @@ CntAbstractViewManager *mViewManager; QContact mContact; QContactDetail mDetail; - + HbPushButton* mAddButton; + HbPushButton* mUpdateButton; }; #endif // CNTSERVICEASSIGNCONTACTCARDVIEW_H diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookservices/inc/cntservices.h --- a/phonebookui/phonebookservices/inc/cntservices.h Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/phonebookservices/inc/cntservices.h Fri Oct 15 12:24:46 2010 +0300 @@ -169,14 +169,6 @@ void fillOnlineAccount( QContactOnlineAccount& account, const QString& value, const QString& subType, bool defaultForOnlineAccountIsImpp); QContactManager* contactManager(); - /** - * Checks if we already have the given contact global uid in database. If so, - * updates the local id and managerUri accordingly. - * - * If given contact has already a local id, method does nothing. - */ - void updateLocalId( QContact& aContact ); - private: // from CntAbstractServiceProvider void CompleteServiceAndCloseApp(const QVariant& retValue); void overrideReturnValue(const QVariant& retValue); @@ -186,6 +178,7 @@ CntAbstractEngine* mEngine; QStringList m_definitionNames; CntAbstractServiceProvider* mCurrentProvider; // not owned + friend class UT_CntServices; }; #endif /* CNTSERVICES_H */ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookservices/phonebookservices.pro --- a/phonebookui/phonebookservices/phonebookservices.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/phonebookservices/phonebookservices.pro Fri Oct 15 12:24:46 2010 +0300 @@ -26,7 +26,7 @@ ../cntcommonui/widgets \ ../../inc -INCLUDEPATH += ../../phonebookengines/cntlistmodel/inc \ +INCLUDEPATH += ../cntlistmodel \ ../../phonebookengines/cntimageutility/inc \ INCLUDEPATH += . \ @@ -74,7 +74,7 @@ src/cntservicesubeditview.cpp # capability -TARGET.CAPABILITY = CAP_APPLICATION NetworkControl +TARGET.CAPABILITY = CAP_APPLICATION NetworkControl TrustedUI TRANSLATIONS = contacts.ts diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookservices/src/cntserviceassigncontactcardview.cpp --- a/phonebookui/phonebookservices/src/cntserviceassigncontactcardview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/phonebookservices/src/cntserviceassigncontactcardview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -72,28 +72,23 @@ HbWidget* buttonWidget = new HbWidget(popup); QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical); - HbPushButton* addButton = new HbPushButton(buttonWidget); - addButton->setStretched(true); - addButton->setText(hbTrId("txt_phob_button_save_as_a_new_contact")); + mAddButton = new HbPushButton(buttonWidget); + mAddButton->setStretched(true); + mAddButton->setText(hbTrId("txt_phob_button_save_as_a_new_contact")); HbIcon plusIcon("qtg_mono_plus"); - addButton->setIcon(plusIcon); - connect(addButton, SIGNAL(clicked()), popup, SLOT(close())); - connect(addButton, SIGNAL(clicked()), this, SLOT(saveNew())); - connect(addButton, SIGNAL(longPress(QPointF)), popup, SLOT(close())); - connect(addButton, SIGNAL(longPress(QPointF)), this, SLOT(saveNew())); + mAddButton->setIcon(plusIcon); + connect(mAddButton, SIGNAL(released()), popup, SLOT(close())); + connect(mAddButton, SIGNAL(released()), this, SLOT(saveNew())); - HbPushButton* updateButton = new HbPushButton(buttonWidget); - updateButton->setStretched(true); - updateButton->setText(hbTrId("txt_phob_button_update_existing_contact")); - updateButton->setIcon(plusIcon); - connect(updateButton, SIGNAL(clicked()), popup, SLOT(close())); - connect(updateButton, SIGNAL(clicked()), this, SLOT(updateExisting())); - connect(updateButton, SIGNAL(longPress(QPointF)), popup, SLOT(close())); - connect(updateButton, SIGNAL(longPress(QPointF)), this, SLOT(updateExisting())); + mUpdateButton = new HbPushButton(buttonWidget); + mUpdateButton->setStretched(true); + mUpdateButton->setText(hbTrId("txt_phob_button_update_existing_contact")); + mUpdateButton->setIcon(plusIcon); + connect(mUpdateButton, SIGNAL(released()), popup, SLOT(close())); + connect(mUpdateButton, SIGNAL(released()), this, SLOT(updateExisting())); - - layout->addItem(addButton); - layout->addItem(updateButton); + layout->addItem(mAddButton); + layout->addItem(mUpdateButton); buttonWidget->setLayout(layout); popup->setContentWidget(buttonWidget); @@ -109,14 +104,17 @@ void CntServiceAssignContactCardView::saveNew() { CNT_ENTRY - CntViewParameters viewParameters; - viewParameters.insert(EViewId, serviceEditView); - QContactName contactName = mContact.detail(); - mContact.removeDetail(&contactName); - QVariant var; - var.setValue(mContact); - viewParameters.insert(ESelectedContact, var); - mViewManager->changeView(viewParameters); + if(mAddButton->isUnderMouse()) + { + CntViewParameters viewParameters; + viewParameters.insert(EViewId, serviceEditView); + QContactName contactName = mContact.detail(); + mContact.removeDetail(&contactName); + QVariant var; + var.setValue(mContact); + viewParameters.insert(ESelectedContact, var); + mViewManager->changeView(viewParameters); + } CNT_EXIT } @@ -126,12 +124,15 @@ void CntServiceAssignContactCardView::updateExisting() { CNT_ENTRY - CntViewParameters viewParameters; - viewParameters.insert(EViewId, serviceContactSelectionView); - QVariant var; - var.setValue(mDetail); - viewParameters.insert(ESelectedDetail, var); - mViewManager->changeView(viewParameters); + if(mUpdateButton->isUnderMouse()) + { + CntViewParameters viewParameters; + viewParameters.insert(EViewId, serviceContactSelectionView); + QVariant var; + var.setValue(mDetail); + viewParameters.insert(ESelectedDetail, var); + mViewManager->changeView(viewParameters); + } CNT_EXIT } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookservices/src/cntservicecontactfetchview.cpp --- a/phonebookui/phonebookservices/src/cntservicecontactfetchview.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/phonebookservices/src/cntservicecontactfetchview.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -301,7 +301,7 @@ mIndex--; } - if (aContact.preferredDetail(aAction).isEmpty() && (aAction == "call" || aAction == "message" || aAction == "email")) + if (aContact.preferredDetail(aAction).isEmpty() && (aAction == "call")) { aContact.setPreferredDetail(aAction, contactDetail); //return value will be ignored because we cannot do anything if it fails. diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookservices/src/cntservices.cpp --- a/phonebookui/phonebookservices/src/cntservices.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/phonebookservices/src/cntservices.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -36,9 +36,6 @@ #include #include #include -#include - -const int Latin1CharSetMIB = 4; CntServices::CntServices() : mViewManager(NULL), @@ -183,22 +180,6 @@ CntImageUtility imageUtility; QContact contact; QVersitReader reader; - QFile inputFile(fileName); - if (!inputFile.open(QIODevice::ReadOnly)) - return; - - // Versit parser default codec is UTF-8 - // Check if decoding text to unicode is possible, else use Latin-1 text codec - QByteArray ba = inputFile.readAll(); - if(!ba.isEmpty()) - { - QTextCodec *c = QTextCodec::codecForUtfText(ba); - // Text codec returned is Latin-1, set default to Latin-1 - if(c->mibEnum()==Latin1CharSetMIB) - reader.setDefaultCodec(QTextCodec::codecForName("ISO 8859-1")); - } - inputFile.close(); - QFile vCardFile(fileName); if (!vCardFile.open(QIODevice::ReadOnly)) return; @@ -217,9 +198,6 @@ } vCardFile.close(); - // check if the contact is in db already. - updateLocalId( contact ); - // Save thumbnail images QList details = contact.details(); for (int i = 0;i < details.count();i++) @@ -499,66 +477,39 @@ void CntServices::fillOnlineAccount( QContactOnlineAccount& account, const QString& value, const QString& subType, bool defaultForOnlineAccountIsImpp ) +{ + // The value should normally consist of two parts: + // : + // for eg. "serviceprovider:jack@serviceprovider.com" + QStringList accountDetails = value.split(":"); + if (accountDetails.count() == 1) { - // The value should normally consist of two parts: - // : - // for eg. "serviceprovider:jack@serviceprovider.com" - QStringList accountDetails = value.split(":"); - if (accountDetails.count() == 1) + // For some reason it only had one part, so we're assuming it's the user ID. + account.setAccountUri(accountDetails.at(0)); + } + else if (accountDetails.count() >= 2) + { + account.setServiceProvider(accountDetails.at(0)); + account.setAccountUri(accountDetails.at(1)); // the user ID + } + + if (!subType.isEmpty()) + { + account.setSubTypes(subType); + } + else + { + if (defaultForOnlineAccountIsImpp) { - // For some reason it only had one part, so we're assuming it's the user ID. - account.setAccountUri(accountDetails.at(0)); - } - else if (accountDetails.count() >= 2) - { - account.setServiceProvider(accountDetails.at(0)); - account.setAccountUri(accountDetails.at(1)); // the user ID - } - - if (!subType.isEmpty()) - { - account.setSubTypes(subType); + account.setSubTypes( QContactOnlineAccount::SubTypeImpp ); } else { - if (defaultForOnlineAccountIsImpp) - { - account.setSubTypes( QContactOnlineAccount::SubTypeImpp ); - } - else - { - account.setSubTypes( QContactOnlineAccount::SubTypeSipVoip ); - } + account.setSubTypes( QContactOnlineAccount::SubTypeSipVoip ); } } +} -void CntServices::updateLocalId( QContact& aContact ) -{ - CNT_ENTRY - if ( aContact.localId() == 0 ) - { - QContactGuid guid = aContact.detail(); - QString guidString = guid.guid(); - - QContactDetailFilter filter; - filter.setDetailDefinitionName( QContactGuid::DefinitionName, QContactGuid::FieldGuid ); - filter.setValue( guid.guid() ); - - QContactManager& cm = mEngine->contactManager( SYMBIAN_BACKEND ); - QList idList = cm.contactIds( filter, QList() ); - int count = idList.count(); - - if ( !idList.isEmpty() ) - { - QContactId id; - id.setLocalId( idList.first() ); - id.setManagerUri( cm.managerUri() ); - - aContact.setId( id ); - } - } - CNT_EXIT -} // This method is inherited from CntAbstractServiceProvider void CntServices::CompleteServiceAndCloseApp(const QVariant& retValue) { diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookservices/src/main.cpp --- a/phonebookui/phonebookservices/src/main.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/phonebookservices/src/main.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -38,18 +39,26 @@ #if defined (TRACES) || defined (TRACE2FILE) qInstallMsgHandler(MSG_HANDLER); #endif + qDebug() << "Enter"; + bool embedded = XQServiceUtil::isEmbedded( argc, argv ); + qDebug() << "Embedded: " << embedded; - HbApplication a( argc, argv ); - + HbApplication a( argc, argv, embedded ? Hb::NoSplash : Hb::DefaultApplicationFlags ); + qDebug() << "HbApplication ready"; + QTranslator translator; QString lang = QLocale::system().name(); QString path = "z:/resource/qt/translations/"; translator.load(path + "contacts_" + lang); a.installTranslator(&translator); - + qDebug() << "Translator installed"; + HbMainWindow mainWindow; + qDebug() << "MainWindow ready"; + CntKeyGrabber *keyGrabber = new CntKeyGrabber(&mainWindow, &mainWindow); - + qDebug() << "KeyGrabber ready"; + CntViewNavigator* navigator = new CntViewNavigator( &mainWindow ); navigator->addException( serviceEditView, noView ); navigator->addEffect( serviceContactCardView, historyView ); @@ -57,16 +66,20 @@ navigator->addEffect( serviceGroupMemberView, groupActionsView ); navigator->addEffect( groupActionsView, serviceGroupMemberView ); navigator->addRoot( serviceGroupMemberView ); - + qDebug() << "Navigator ready"; + // This object actually executes the services CntServices* services = new CntServices(); services->setParent( &mainWindow ); // for ownership - + qDebug() << "CntServices ready"; + QScopedPointer viewManager(new CntServiceViewManager( &mainWindow, *services )); // as CntAbstractServiceProvider + qDebug() << "Service ViewManager ready"; + viewManager->setViewNavigator( navigator ); - + services->setEngine( viewManager->engine() ); // These objects talk with QT Highway (send/receive) @@ -75,9 +88,11 @@ CntServiceProviderFetch* serviceProviderFetch = new CntServiceProviderFetch( *services, &mainWindow ); // phonebookservices.com.nokia.symbian.IContactFetch CntServiceProviderViewing* serviceProviderViewing = new CntServiceProviderViewing( *services, &mainWindow ); // phonebookservices.com.nokia.symbian.IContactView CntServiceProviderEdit* serviceProviderEdit = new CntServiceProviderEdit( *services, &mainWindow ); // phonebookservices.com.nokia.symbian.IContactEdit - + + qDebug() << "Service MainWindow about to show"; mainWindow.show(); - + qDebug() << "Service MainWindow show ready"; + return a.exec(); } diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookservices/tsrc/ut_cntservices/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/phonebookservices/tsrc/ut_cntservices/main.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,82 @@ +/* +* 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 "testrunner.h" + +#include "ut_cntservices.h" + +#include + +int main(int argc, char *argv[]) +{ + bool promptOnExit(true); + for (int i=0; iinstallTranslator(&translator); + starter->exec(); + + if (promptOnExit) { + printf("Press any key...\n"); + getchar(); + } + return 0; +} + +Starter::Starter(int &argc, char **argv) + : HbApplication(argc, argv) +{ + mTestStarted = false; +} + +Starter::~Starter() +{ +} + +bool Starter::event( QEvent* aEvent ) +{ + if (!mTestStarted) { + mTestStarted = true; + postEvent(this, new QEvent(QEvent::User)); + } + else if (aEvent->type() == QEvent::User) { + TestRunner testRunner("ut_phonebookservices"); + + UT_CntServices cntServicesTest; + testRunner.runTests( cntServicesTest ); + + testRunner.printResults(); + postEvent(this, new QEvent(static_cast(QEvent::User + 1)) ); + return true; + } + else if (aEvent->type() == QEvent::User + 1) { + quit(); + return true; + } + + return QObject::event( aEvent ); +} + diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookservices/tsrc/ut_cntservices/ut_cntservices.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/phonebookservices/tsrc/ut_cntservices/ut_cntservices.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,180 @@ +/* +* 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_cntservices.h" +#include "cntservices.h" +#include "testviewmanager.h" +#include +#include "testengine.h" +#include +#include "cntserviceviewparams.h" + + +void UT_CntServices::initTestCase() +{ + mTestViewManager = new TestViewManager(); + connect( mTestViewManager, SIGNAL(changeView( const CntViewParameters aArgs )), this, SLOT( onViewChanged( const CntViewParameters aArgs ) ) ); + mEngine = new TestEngine( *mTestViewManager ); +} + +void UT_CntServices::cleanupTestCase() +{ + delete mCntServices; + mCntServices = NULL; + delete mEngine; + mEngine = NULL; + delete mTestViewManager; + mTestViewManager = NULL; +} + +void UT_CntServices::testCreating() +{ + mCntServices = new CntServices(); + QVERIFY( mCntServices ); +} + +void UT_CntServices::test_setEngine() +{ + mCntServices = new CntServices(); + QVERIFY( mCntServices ); + mCntServices->setEngine( *mEngine ); +} + + +void UT_CntServices::test_singleFetch() +{ + mCntServices = new CntServices(); + // with empty action string + mCntServices->singleFetch( "someTitle", "someAction", *this ); + // a signal is sent to slot onViewChanged(). The view params are stored by the slot. + QString title = mViewParams.value(KCntServiceViewParamTitle).toString(); + QVERIFY( title == "someTitle" ); +} + +void UT_CntServices::test_multiFetch() +{ + mCntServices = new CntServices(); + // with empty action string + mCntServices->multiFetch( "someTitle", "someAction", *this ); + // a signal is sent to slot onViewChanged(). The view params are stored by the slot. + QString title = mViewParams.value(KCntServiceViewParamTitle).toString(); + QVERIFY( title == "someTitle" ); +} + +void UT_CntServices::test_editCreateNew() +{ + mCntServices = new CntServices(); + // with empty action string + mCntServices->editCreateNew( QContactPhoneNumber::DefinitionName, "123456", *this ); + // a signal is sent to slot onViewChanged(). The view params are stored by the slot. + QVariant contact = mViewParams.value( ESelectedContact ); + //QVERIFY( contact. ); +} + +void UT_CntServices::test_editCreateNew2() +{ + +} + +void UT_CntServices::test_editCreateNewFromVCard() +{ + +} + +void UT_CntServices::test_editUpdateExisting() +{ + +} + +void UT_CntServices::test_editUpdateExisting2() +{ + +} + +void UT_CntServices::test_editExisting() +{ + +} + +void UT_CntServices::test_launchContactCard() +{ + +} + +void UT_CntServices::test_launchGroupMemberView() +{ + +} + +void UT_CntServices::test_launchTemporaryContactCard() +{ + +} + + +void UT_CntServices::test_terminateService() +{ +} + + +void UT_CntServices::test_removeNotSupportedFields() +{ +} + + +void UT_CntServices::removeNotSupportedDetails() +{ +} + + +void UT_CntServices::test_fillOnlineAccount() +{ +} + + +void UT_CntServices::test_updateLocalId() +{ +} + + +void UT_CntServices::test_CompleteServiceAndCloseApp() +{ +} + + +void UT_CntServices::test_overrideReturnValue() +{ +} + + +void UT_CntServices::test_allowSubViewsExit() +{ +} + +// receives signal from testviewmanager +void UT_CntServices::onViewChanged( const CntViewParameters aArgs ) +{ + mViewParams = aArgs; +} + + +// from CntAbstractServiceProvider +void UT_CntServices::CompleteServiceAndCloseApp(const QVariant& /*retValue*/) +{ +} + +// EOF diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookservices/tsrc/ut_cntservices/ut_cntservices.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/phonebookservices/tsrc/ut_cntservices/ut_cntservices.h Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,103 @@ +/* +* 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 +#include +#include +#include +#include + +class CntServices; +class TestViewManager; +class HbMainWindow; +class TestEngine; + +/** + * A class for testing CntServices. + */ +class UT_CntServices : public QObject, public CntAbstractServiceProvider +{ + Q_OBJECT + +private slots: + void initTestCase(); + void cleanupTestCase(); + + void testCreating(); + + void test_setEngine(); + + + void test_singleFetch(); + + void test_multiFetch(); + + void test_editCreateNew(); + + void test_editCreateNew2(); + + void test_editCreateNewFromVCard(); + + void test_editUpdateExisting(); + + void test_editUpdateExisting2(); + + void test_editExisting(); + + void test_launchContactCard(); + + void test_launchGroupMemberView(); + + void test_launchTemporaryContactCard(); + + void test_terminateService(); + + void test_removeNotSupportedFields(); + + void removeNotSupportedDetails(); + + void test_fillOnlineAccount(); + + void test_updateLocalId(); + + void test_CompleteServiceAndCloseApp(); + + void test_overrideReturnValue(); + + void test_allowSubViewsExit(); + + //Pointless now: void test_quitApp(); + //Pointless now: void test_contactManager(); + +public slots: + void onViewChanged( const CntViewParameters aArgs ); + +private: + virtual void CompleteServiceAndCloseApp(const QVariant& retValue); + //virtual void overrideReturnValue(const QVariant& retValue) { Q_UNUSED(retValue) }; + //virtual bool allowSubViewsExit() { return true; }; + + +private: + CntServices* mCntServices; + TestViewManager* mTestViewManager; + TestEngine* mEngine; + CntViewParameters mViewParams; +}; + +// EOF diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookservices/tsrc/ut_cntservices/ut_cntservices.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/phonebookservices/tsrc/ut_cntservices/ut_cntservices.pro Fri Oct 15 12:24:46 2010 +0300 @@ -0,0 +1,100 @@ +# +# 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: +# +# + +TEMPLATE = app +TARGET = + +QT += testlib sql xml core +CONFIG += hb symbian_test +HB += hbfeedback +DEFINES += QT_NO_DEBUG_OUTPUT +DEFINES += QT_NO_WARNING_OUTPUT +DEFINES += PBK_UNIT_TEST + +MOC_DIR = moc + +INCLUDEPATH += ../../../../../inc +INCLUDEPATH += ../../../../../phonebookui/phonebookapp/inc +INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + +INCLUDEPATH += ../../../cntcommonui/core \ + ../../../cntcommonui/engine_inc \ + ../../../inc +INCLUDEPATH += ../../../../phonebookengines/cntimageutility/inc + + +# contacts/inc/ +HEADERS += ../../../../inc + +#======================================================================= +# phonebookservices being unit tested + +HEADERS += ../../inc/cntabstractserviceprovider.h +HEADERS += ../../inc/cntservices.h +SOURCES += ../../src/cntservices.cpp + + +#======================================================================= +# test utilities + +HEADERS += ../../../cntcommonui/tsrc/testutility/testrunner.h +SOURCES += ../../../cntcommonui/tsrc/testutility/testrunner.cpp + +HEADERS += ../../../cntcommonui/tsrc/testutility/testengine.h +SOURCES += ../../../cntcommonui/tsrc/testutility/testengine.cpp + +HEADERS += ../../../cntcommonui/tsrc/testutility/testviewmanager.h +SOURCES += ../../../cntcommonui/tsrc/testutility/testviewmanager.cpp + +#HEADERS += ../../../cntcommonui/tsrc/testutility/hbstubs_helper.h +#SOURCES += ../../../cntcommonui/tsrc/testutility/hbstubs.cpp + +#SOURCES += ../../../cntcommonui/tsrc/testutility/qthighway_stub.cpp +#qthighway_stub_helper.h + +#======================================================================= +# Dependencies from cntcommonui which are needed + +HEADERS += ../../../cntcommonui/core/cntextensionmanager.h +SOURCES += ../../../cntcommonui/core/cntextensionmanager.cpp + +HEADERS += ../../../cntcommonui/core/cntthumbnailmanager.h +SOURCES += ../../../cntcommonui/core/cntthumbnailmanager.cpp + +#======================================================================= + +# Tester sources +HEADERS += ./*.h +SOURCES += ./*.cpp + + + +# capability +TARGET.CAPABILITY = ALL -TCB + +TRANSLATIONS = contacts.ts + +LIBS += -lhbcore \ + -lqtcontacts \ + -lcntlistmodel \ + -lcntcommonui \ + -lqtversit \ + -lcntimageutility \ + -lxqkeycapture \ + -lxqservice \ + -lxqserviceutil +symbian:MMP_RULES += SMPSAFE \ No newline at end of file diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/phonebookui.pro --- a/phonebookui/phonebookui.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/phonebookui.pro Fri Oct 15 12:24:46 2010 +0300 @@ -19,7 +19,7 @@ TEMPLATE = subdirs -SUBDIRS = cnthistorymodel cntcommonui phonebookapp phonebookservices +SUBDIRS = cntlistmodel cnthistorymodel cntcommonui phonebookapp phonebookservices CONFIG += ordered deploy.path = /epoc32/rom/include/core/app/ diff -r c18f9fa7f42e -r 640d30f4fb64 phonebookui/rom/phonebook.iby --- a/phonebookui/rom/phonebook.iby Fri Oct 08 11:42:51 2010 +0300 +++ b/phonebookui/rom/phonebook.iby Fri Oct 15 12:24:46 2010 +0300 @@ -24,14 +24,14 @@ #define UPGRADABLE_APP_REG_RSC(NAME) data=DATAZ_\PRIVATE\10003A3F\IMPORT\APPS\ ## NAME ## _reg.rsc Private\10003a3f\import\apps\ ## NAME ## _reg.rsc // Engine -file=ABI_DIR\BUILD_DIR\cntlistmodel.dll SHARED_LIB_DIR\cntlistmodel.dll UNPAGED -file=ABI_DIR\BUILD_DIR\cnthistorymodel.dll SHARED_LIB_DIR\cnthistorymodel.dll UNPAGED -file=ABI_DIR\BUILD_DIR\cntactionsplugin.dll SHARED_LIB_DIR\cntactionsplugin.dll UNPAGED -file=ABI_DIR\BUILD_DIR\cntsimutility.dll SHARED_LIB_DIR\cntsimutility.dll UNPAGED -file=ABI_DIR\BUILD_DIR\cntimageutility.dll SHARED_LIB_DIR\cntimageutility.dll UNPAGED +file=ABI_DIR\BUILD_DIR\cntlistmodel.dll SHARED_LIB_DIR\cntlistmodel.dll +file=ABI_DIR\BUILD_DIR\cnthistorymodel.dll SHARED_LIB_DIR\cnthistorymodel.dll +file=ABI_DIR\BUILD_DIR\cntactionsplugin.dll SHARED_LIB_DIR\cntactionsplugin.dll +file=ABI_DIR\BUILD_DIR\cntsimutility.dll SHARED_LIB_DIR\cntsimutility.dll +file=ABI_DIR\BUILD_DIR\cntimageutility.dll SHARED_LIB_DIR\cntimageutility.dll // UI -file=ABI_DIR\BUILD_DIR\cntcommonui.dll SHARED_LIB_DIR\cntcommonui.dll UNPAGED +file=ABI_DIR\BUILD_DIR\cntcommonui.dll SHARED_LIB_DIR\cntcommonui.dll file=ABI_DIR\BUILD_DIR\phonebook.exe SHARED_LIB_DIR\phonebook.exe UPGRADABLE_APP_REG_RSC(phonebook) diff -r c18f9fa7f42e -r 640d30f4fb64 pimprotocols/phonebooksync/Server/SyncEngineServer.cpp --- a/pimprotocols/phonebooksync/Server/SyncEngineServer.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/pimprotocols/phonebooksync/Server/SyncEngineServer.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -500,7 +500,7 @@ CContactGroup* group = static_cast (iDb->ReadContactLC((*idList)[index])); CContactIdArray* itemList = group->ItemsContainedLC(); - if (itemList->Count() > 0) + if ( itemList && itemList->Count() > 0) { CContactItem* groupItem = iDb->ReadContactLC((*itemList)[0]); TContactItemId templateId = groupItem->TemplateRefId(); diff -r c18f9fa7f42e -r 640d30f4fb64 pimprotocols/phonebooksync/group/bld.inf --- a/pimprotocols/phonebooksync/group/bld.inf Fri Oct 08 11:42:51 2010 +0300 +++ b/pimprotocols/phonebooksync/group/bld.inf Fri Oct 15 12:24:46 2010 +0300 @@ -52,3 +52,4 @@ ../Test/TE_Sync/TE_Sync.mmp ../Test/TE_PhBkSync/TE_PhBkSync.mmp ../Test/TE_cntsync/te_cntsync.mmp + diff -r c18f9fa7f42e -r 640d30f4fb64 presencecache/presencecacheqt/tsrc/presencefeeddemo_qt/presencefeeddemo_qt.pro --- a/presencecache/presencecacheqt/tsrc/presencefeeddemo_qt/presencefeeddemo_qt.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/presencecache/presencecacheqt/tsrc/presencefeeddemo_qt/presencefeeddemo_qt.pro Fri Oct 15 12:24:46 2010 +0300 @@ -44,4 +44,5 @@ symbian: { TARGET.EPOCSTACKSIZE = 0x14000 TARGET.EPOCHEAPSIZE = 0x1000 0xA00000 -} \ No newline at end of file +} +symbian:MMP_RULES += SMPSAFE \ No newline at end of file diff -r c18f9fa7f42e -r 640d30f4fb64 presencecache/presencecachesymbian/presencecacheclient2/group/presencecacheclient2.mmp --- a/presencecache/presencecachesymbian/presencecacheclient2/group/presencecacheclient2.mmp Fri Oct 08 11:42:51 2010 +0300 +++ b/presencecache/presencecachesymbian/presencecacheclient2/group/presencecacheclient2.mmp Fri Oct 15 12:24:46 2010 +0300 @@ -53,5 +53,6 @@ deffile ../bwins/ #endif +SMPSAFE // End of file diff -r c18f9fa7f42e -r 640d30f4fb64 presencecache/presencecachesymbian/presencecacheclient2/src/presencecacheclient.cpp --- a/presencecache/presencecachesymbian/presencecacheclient2/src/presencecacheclient.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/presencecache/presencecachesymbian/presencecacheclient2/src/presencecacheclient.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -103,54 +103,65 @@ // ----------------------------------------------------------------------------- // CPresenceCacheClient::Connect() -// Connects to the server and create a session. +// Connect to the server, attempting to start it if necessary // ----------------------------------------------------------------------------- // TInt CPresenceCacheClient::Connect() { - TInt error = StartServer(); - - if ( KErrNone == error ) + TInt retry=2; + for (;;) { - error = CreateSession( NName::KSymbianServer, - Version(), - NRequest::KMsgSlotCount ); - } - return error; + TInt r = CreateSession( NName::KSymbianServer, + Version(), + NRequest::KMsgSlotCount ); + // Continue if there was error but caused from server not being + // started yet, in which case server start will be tried later in the loop. + // Otherwise return KErrNone or one of the system wide error codes. + if (r!=KErrNotFound && r!=KErrServerTerminated) + return r; + // + // Decreace retry counter and abort if too many retries already + if (--retry==0) + return r; + // + // Try to start server. If no error or the error was caused + // from server already started, continue to next iteration when + // the session creation will be tried again. + r=StartServer(); + if (r!=KErrNone && r!=KErrAlreadyExists) + return r; + + } } // ---------------------------------------------------- // CPresenceCacheClient::StartServer -// // ---------------------------------------------------- // TInt CPresenceCacheClient::StartServer() - { - TInt result; - TRequestStatus status = KRequestPending; - - TFindServer findCacheServer( NName::KSymbianServer ); - TFullName name; - - result = findCacheServer.Next( name ); - if ( result == KErrNone ) - { - // Server already running - return KErrNone; - } - + { + // Start the server process. Simultaneous launching + // of two such processes should be detected when the second one attempts to + // create the server object, failing with KErrAlreadyExists. + // RProcess server; - result = server.Create( NName::KExecutable, KNullDesC ); - if( result != KErrNone ) - return result; - server.Rendezvous( status ); - status != KRequestPending ? server.Kill( 0 ) : server.Resume(); - //Wait for start or death - User::WaitForRequest( status ); - result = server.ExitType() == EExitPanic ? KErrGeneral : status.Int(); - server.Close(); - - return result; + TInt r=server.Create( NName::KExecutable, KNullDesC ); + if (r!=KErrNone) + return r; + TRequestStatus stat; + server.Rendezvous(stat); + if (stat!=KRequestPending) + server.Kill(0); // abort startup + else + server.Resume(); // logon OK - start the server + User::WaitForRequest(stat); // wait for start or death + // we can't use the 'exit reason' if the server panicked as this + // is the panic 'reason' and may be '0' which cannot be distinguished + // from KErrNone + r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int(); + // here it may return KErrAlreadyExists or KErrNone + server.Close(); + return r; } // ----------------------------------------------------------------------------- diff -r c18f9fa7f42e -r 640d30f4fb64 presencecache/presencecachesymbian/presencecacheserver2/group/presencecacheserver2.mmp --- a/presencecache/presencecachesymbian/presencecacheserver2/group/presencecacheserver2.mmp Fri Oct 08 11:42:51 2010 +0300 +++ b/presencecache/presencecachesymbian/presencecacheserver2/group/presencecacheserver2.mmp Fri Oct 15 12:24:46 2010 +0300 @@ -52,6 +52,6 @@ LIBRARY ecom.lib LIBRARY presencecacheutils.lib - +SMPSAFE // End of file diff -r c18f9fa7f42e -r 640d30f4fb64 presencecache/presencecachesymbian/presencecacheserver2/src/presencecacheexpiry.cpp --- a/presencecache/presencecachesymbian/presencecacheserver2/src/presencecacheexpiry.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/presencecache/presencecachesymbian/presencecacheserver2/src/presencecacheexpiry.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -100,6 +100,7 @@ iServer.iPresenceCache; RPointerArray buddyStores; + CleanupClosePushL(buddyStores); const TInt serviceCount(presenceCache.Count()); for( TInt i = 0 ; i < serviceCount ; ++i ) @@ -112,6 +113,11 @@ { NotifySubscribersL( *( buddyStores[i] ) ); } + + // Close the buddyStores array and free all memory allocated to it. + // Doesn't delete the contained CPresenceCacheBuddyStor objects. + // Ownership of those remain in CPresenceCacheServiceStore. + CleanupStack::PopAndDestroy(); // calls buddyStores.Close() } // End of File diff -r c18f9fa7f42e -r 640d30f4fb64 presencecache/presencecachesymbian/presencecacheserver2/src/presencecacheserver.cpp --- a/presencecache/presencecachesymbian/presencecacheserver2/src/presencecacheserver.cpp Fri Oct 08 11:42:51 2010 +0300 +++ b/presencecache/presencecachesymbian/presencecacheserver2/src/presencecacheserver.cpp Fri Oct 15 12:24:46 2010 +0300 @@ -52,7 +52,7 @@ CPresenceCacheServer::~CPresenceCacheServer() { delete iExpiryCheck; - DoCancel(); + Cancel(); TInt count = iPresenceCache.Count(); for (TInt i=0;iStartL( NName::KSymbianServer ); //Signal client that we are started RProcess().Rendezvous( KErrNone ); diff -r c18f9fa7f42e -r 640d30f4fb64 presencecache/presencecachesymbian/presencecachesymbian.pro --- a/presencecache/presencecachesymbian/presencecachesymbian.pro Fri Oct 08 11:42:51 2010 +0300 +++ b/presencecache/presencecachesymbian/presencecachesymbian.pro Fri Oct 15 12:24:46 2010 +0300 @@ -21,9 +21,12 @@ TEMPLATE = subdirs BLD_INF_RULES.prj_mmpfiles = "./presencecacheutils/group/presencecacheutils.mmp" \ - "./presencecacheclient2/group/presencecacheclient2.mmp" \ + "./presencecacheclient2/group/presencecacheclient2.mmp" \ "./presencecacheserver2/group/presencecacheserver2.mmp" BLD_INF_RULES.prj_exports += \ "$${LITERAL_HASH}include " \ - "./rom/presencecache.iby CORE_APP_LAYER_IBY_EXPORT_PATH(presencecache.iby)" \ No newline at end of file + "./rom/presencecache.iby CORE_APP_LAYER_IBY_EXPORT_PATH(presencecache.iby)" + +symbian:MMP_RULES += SMPSAFE + \ No newline at end of file diff -r c18f9fa7f42e -r 640d30f4fb64 presencecache/presencecachesymbian/presencecacheutils/group/presencecacheutils.mmp --- a/presencecache/presencecachesymbian/presencecacheutils/group/presencecacheutils.mmp Fri Oct 08 11:42:51 2010 +0300 +++ b/presencecache/presencecachesymbian/presencecacheutils/group/presencecacheutils.mmp Fri Oct 15 12:24:46 2010 +0300 @@ -52,3 +52,4 @@ // DEBUG LIBRARY flogger.lib //todo: remove to DEBUGLIBRARY when ready. +SMPSAFE \ No newline at end of file diff -r c18f9fa7f42e -r 640d30f4fb64 sis/contacts.pkg --- a/sis/contacts.pkg Fri Oct 08 11:42:51 2010 +0300 +++ b/sis/contacts.pkg Fri Oct 15 12:24:46 2010 +0300 @@ -14,11 +14,9 @@ ; Description: pkg file of Contacts Application for IAD. ; - ; Language &EN - ; SIS header: name, uid, version #{"Contacts"},(0x20022EF9),1,1,0, TYPE=SA, RU @@ -28,31 +26,35 @@ ; Unique Vendor name :"Nokia" +; Contacts app dlls "/epoc32/release/armv5/urel/cntlistmodel.dll" - "!:/sys/bin/cntlistmodel.dll" -"/epoc32/release/armv5/urel/cnthistorymodel.dll" - "!:/sys/bin/cnthistorymodel.dll" -"/epoc32/release/armv5/urel/cntactionsplugin.dll" - "!:/sys/bin/cntactionsplugin.dll" -"/epoc32/release/armv5/urel/cntsimutility.dll" - "!:/sys/bin/cntsimutility.dll" -"/epoc32/release/armv5/urel/cntimageutility.dll" - "!:/sys/bin/cntimageutility.dll" +"/epoc32/release/armv5/urel/cnthistorymodel.dll" - "!:/sys/bin/cnthistorymodel.dll" +"/epoc32/release/armv5/urel/cntsimutility.dll" - "!:/sys/bin/cntsimutility.dll" +"/epoc32/release/armv5/urel/cntimageutility.dll" - "!:/sys/bin/cntimageutility.dll" +"/epoc32/release/armv5/urel/cntcommonui.dll" - "!:/sys/bin/cntcommonui.dll" +"/epoc32/release/armv5/urel/phonebook.exe" - "!:/sys/bin/phonebook.exe" -"/epoc32/release/armv5/urel/cntcommonui.dll" - "!:/sys/bin/cntcommonui.dll" -"/epoc32/release/armv5/urel/phonebook.exe" - "!:/sys/bin/phonebook.exe" +; Qt plugins & dlls +"/epoc32/data/z/resource/qt/plugins/contacts\cntactionsplugin.qtplugin" - "!:/resource/qt/plugins/contacts\cntactionsplugin.qtplugin" +"/epoc32/data/z/resource/qt/plugins/contacts\qtcontacts_symbian.qtplugin" - "!:/resource/qt/plugins/contacts\qtcontacts_symbian.qtplugin" +"/epoc32/data/z/resource/qt/plugins/contacts\qtcontacts_symbiansim.qtplugin" - "!:/resource/qt/plugins/contacts\qtcontacts_symbiansim.qtplugin" +"/epoc32/release/armv5/urel/cntactionsplugin.dll" - "!:/sys/bin/cntactionsplugin.dll" +"/epoc32/release/armv5/urel/qtcontacts_symbian.dll" - "!:/sys/bin/qtcontacts_symbian.dll" +"/epoc32/release/armv5/urel/qtcontacts_symbiansim.dll" - "!:/sys/bin/qtcontacts_symbiansim.dll" - -"/epoc32/data/z/resource/qt/plugins/contacts\cntactionsplugin.qtplugin" - "!:/resource/qt/plugins/contacts\cntactionsplugin.qtplugin" - +; Splash screen resource files "/epoc32/data/z/resource/hb/splashml/phonebook.splashml" - "!:\resource\hb\splashml\phonebook.splashml" "/epoc32/data/z/resource/hb/splashml/phonebook.splashml" - "!:\resource\hb\splashml\phonebook.splashml" ; Phonebook services -"/epoc32/release/armv5/urel/phonebookservices.exe" - "!:/sys/bin/phonebookservices.exe" -"/epoc32/data/z/resource/apps/phonebookservices.rsc" - "!:/resource/apps/phonebookservices.rsc" -"/epoc32/data/Z/private/10003a3f/import/apps/phonebookservices_reg.rsc" - "!:/private/10003a3f/import/apps/phonebookservices_reg.rsc" +"/epoc32/release/armv5/urel/phonebookservices.exe" - "!:/sys/bin/phonebookservices.exe" +"/epoc32/data/z/resource/apps/phonebookservices.rsc" - "!:/resource/apps/phonebookservices.rsc" +"/epoc32/data/Z/private/10003a3f/import/apps/phonebookservices_reg.rsc" - "!:/private/10003a3f/import/apps/phonebookservices_reg.rsc" - -;Phonebook resources -"/epoc32/data/z/resource/apps/phonebook.rsc" - "!:/resource/apps/phonebook.rsc" +; Phonebook resources +"/epoc32/data/z/resource/apps/phonebook.rsc" - "!:/resource/apps/phonebook.rsc" "/epoc32/data/z/resource/qt/translations/contacts_en.qm" - "!:/resource/qt/translations/contacts_en.qm" -;Cenrep settings -"/epoc32/data/z/private/10202be9/2002FF54.txt" - "!:/system/data/10202BE9/2002FF54.txt" -"/epoc32/data/z/private/10202be9/200315A8.txt" - "!:/system/data/10202BE9/200315A8.txt" \ No newline at end of file +; Cenrep files +"/epoc32/data/z/private/10202be9/2002FF54.txt" - "!:/system/data/10202BE9/2002FF54.txt" +"/epoc32/data/z/private/10202be9/200315A8.txt" - "!:/system/data/10202BE9/200315A8.txt" diff -r c18f9fa7f42e -r 640d30f4fb64 sis/contacts_stub.pkg --- a/sis/contacts_stub.pkg Fri Oct 08 11:42:51 2010 +0300 +++ b/sis/contacts_stub.pkg Fri Oct 15 12:24:46 2010 +0300 @@ -17,7 +17,6 @@ ; Language &EN - ; SIS header: name, uid, version #{"Contacts"},(0x20022EF9),1,0,0, TYPE=SA @@ -27,33 +26,35 @@ ; Unique Vendor name :"Nokia" - -; Phonebook.iby contents - +; Contacts app dlls "" - "z:\sys\bin\cntlistmodel.dll" "" - "z:\sys\bin\cnthistorymodel.dll" -"" - "z:\sys\bin\cntactionsplugin.dll" "" - "z:\sys\bin\cntsimutility.dll" "" - "z:\sys\bin\cntimageutility.dll" "" - "z:\sys\bin\cntcommonui.dll" "" - "z:\sys\bin\phonebook.exe" +; Qt plugins & dlls "" - "z:\resource\qt\plugins\contacts\cntactionsplugin.qtplugin" +"" - "z:\resource\qt\plugins\contacts\qtcontacts_symbian.qtplugin" +"" - "z:\resource\qt\plugins\contacts\qtcontacts_symbiansim.qtplugin" +"" - "z:\sys\bin\cntactionsplugin.dll" +"" - "z:\sys\bin\qtcontacts_symbian.dll" +"" - "z:\sys\bin\qtcontacts_symbiansim.dll" +; Splash screen resource files "" - "z:\resource\hb\splashml\phonebook.splashml" "" - "z:\resource\hb\splashml\phonebook.docml" -; Phonebookservices.iby contents +; Phonebook services "" - "z:\sys\bin\phonebookservices.exe" "" - "z:\resource\apps\phonebookservices.r*" "" - "z:\private\10003a3f\import\apps\phonebookservices_reg.rsc" - - -;Phonebookresources.iby contents +; Phonebook resources "" - "z:\resource\qt\translations\contacts*.qm" "" - "z:\resource\apps\phonebook.r*" -;Cenrep settings +; Cenrep files "" - "z:\system\data\10202BE9\2002FF54.txt" "" - "z:\system\data\10202BE9\200315A8.txt" diff -r c18f9fa7f42e -r 640d30f4fb64 sis/contacts_stub.sis Binary file sis/contacts_stub.sis has changed