# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1278415023 -10800 # Node ID 98924d2efce931d3f6945210abd3b829942efcad # Parent e0ec97ec3cc43ba3e9a44c184d4081f8ca3be275 Revision: 201025 Kit: 2010127 diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/creator.pro --- a/creator/creator.pro Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/creator.pro Tue Jul 06 14:17:03 2010 +0300 @@ -19,16 +19,10 @@ symbian: { INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE HEADERS += engine/inc/creator.hrh \ - engine/inc/creator_accesspoint.h \ - engine/inc/creator_browser.h \ - engine/inc/creator_browserelement.h \ engine/inc/creator_calendar.h \ engine/inc/creator_calendarbase.h \ engine/inc/creator_calendarelement.h \ engine/inc/creator_cmdscriptrun.h \ - engine/inc/creator_connectionmethod.h \ - engine/inc/creator_connectionmethodbase.h \ - engine/inc/creator_connectionmethodelement.h \ engine/inc/creator_contactelement.h \ engine/inc/creator_contactsetcache.h \ engine/inc/creator_factory.h \ @@ -44,7 +38,10 @@ engine/inc/creator_messageelement.h \ engine/inc/creator_modulebase.h \ engine/inc/creator_note.h \ + engine/inc/creator_notepadwrapper.h \ engine/inc/creator_phonebook.h \ + engine/inc/creator_phonebookwrapper.h \ + engine/inc/creator_phonebookapi.h \ engine/inc/creator_phonebookbase.h \ engine/inc/creator_randomdatafield.h \ engine/inc/creator_randomdataparser.h \ @@ -59,14 +56,9 @@ inc/engine.h \ inc/enginewrapper.h - SOURCES += engine/src/creator_accesspoint.cpp \ - engine/src/creator_browser.cpp \ - engine/src/creator_browserelement.cpp \ - engine/src/creator_calendar.cpp \ + SOURCES += engine/src/creator_calendar.cpp \ engine/src/creator_calendarelement.cpp \ engine/src/creator_cmdscriptrun.cpp \ - engine/src/creator_connectionmethod.cpp \ - engine/src/creator_connectionmethodelement.cpp \ engine/src/creator_contactelement.cpp \ engine/src/creator_contactsetcache.cpp \ engine/src/creator_factory.cpp \ @@ -81,7 +73,10 @@ engine/src/creator_message.cpp \ engine/src/creator_messageelement.cpp \ engine/src/creator_note.cpp \ + engine/src/creator_notepadwrapper.cpp \ engine/src/creator_phonebook.cpp \ + engine/src/creator_phonebookwrapper.cpp \ + engine/src/creator_phonebookapi.cpp \ engine/src/creator_phonebookbase.cpp \ engine/src/creator_randomdataparser.cpp \ engine/src/creator_scriptelement.cpp \ @@ -100,7 +95,6 @@ -lapparc \ -lcone \ -lcntmodel \ - -lfavouritesengine \ -lmsgs \ -llogwrap \ -llogcli \ @@ -139,7 +133,6 @@ -lbitmaptransforms \ -lcmmanager \ -lcmmanagerdatabase \ - -lapengine \ -lnoteseditor \ -lxqservice \ -lQtContacts \ diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/inc/creator_accesspoint.h --- a/creator/engine/inc/creator_accesspoint.h Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/inc/creator_accesspoint.h Tue Jul 06 14:17:03 2010 +0300 @@ -28,11 +28,11 @@ #include #include -#include -#include -#include -#include -#include +//#include +//#include +//#include +//#include +//#include #include #include #include diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/inc/creator_browser.h --- a/creator/engine/inc/creator_browser.h Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/inc/creator_browser.h Tue Jul 06 14:17:03 2010 +0300 @@ -26,9 +26,9 @@ #include "creator_modulebase.h" #include -#include -#include -#include +//#include +//#include +//#include diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/inc/creator_contactsetcache.h --- a/creator/engine/inc/creator_contactsetcache.h Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/inc/creator_contactsetcache.h Tue Jul 06 14:17:03 2010 +0300 @@ -22,21 +22,19 @@ #define CREATORCONTACTSETCACHE_H_ #include -#include // Forward declarations class CContactLinkCacheImp; -QTM_USE_NAMESPACE class CCreatorContactSet : public CBase { public: static CCreatorContactSet* NewL(TInt aLinkId, TInt aNumOfExistingContacts); virtual ~CCreatorContactSet(); - void AppendL(QContactLocalId); + void AppendL(TUint32); TInt NumberOfExistingContacts() const; - RArray ContactLinks(); - const RArray ContactLinks() const; + RArray ContactLinks(); + const RArray ContactLinks() const; TInt LinkId() const; @@ -45,15 +43,15 @@ //void ConstructL(); TInt iLinkId; TInt iNumOfExistingContacts; - RArray iContactLinks; + RArray iContactLinks; }; class MContactLinkCache { public: virtual void AppendL(CCreatorContactSet* aContactSet) = 0; - virtual RArray ContactLinks(TInt aLinkId) = 0; - virtual const RArray ContactLinks(TInt aLinkId) const = 0; + virtual RArray ContactLinks(TInt aLinkId) = 0; + virtual const RArray ContactLinks(TInt aLinkId) const = 0; virtual RPointerArray& ContactSets() = 0; virtual const RPointerArray& ContactSets() const = 0; virtual const CCreatorContactSet& ContactSet(TInt aLinkId) const = 0; diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/inc/creator_factory.h --- a/creator/engine/inc/creator_factory.h Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/inc/creator_factory.h Tue Jul 06 14:17:03 2010 +0300 @@ -25,7 +25,7 @@ class CCreatorEngine; class CCreatorPhonebookBase; -class CCreatorConnectionSettingsBase; +//class CCreatorConnectionSettingsBase; class TCreatorFactory{ @@ -34,8 +34,8 @@ static CCreatorPhonebookBase* CreatePhoneBookL(CCreatorEngine* aEngine); static CCreatorModuleBaseParameters* CreatePhoneBookParametersL(); - static CCreatorConnectionSettingsBase* CreateConnectionSettingsL(CCreatorEngine* aEngine); - static CCreatorModuleBaseParameters* CreateConnectionSettingsParametersL(); +// static CCreatorConnectionSettingsBase* CreateConnectionSettingsL(CCreatorEngine* aEngine); +// static CCreatorModuleBaseParameters* CreateConnectionSettingsParametersL(); }; diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/inc/creator_note.h --- a/creator/engine/inc/creator_note.h Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/inc/creator_note.h Tue Jul 06 14:17:03 2010 +0300 @@ -16,27 +16,20 @@ */ - - - #ifndef __CREATORNOTEPAD_H__ #define __CREATORNOTEPAD_H__ #include "engine.h" #include "creator_modulebase.h" - +#include "creator_notepadwrapper.h" #include -//#include -#include -#include -#include - static const TInt KNotepadFieldLength = 1024; class CCreatorEngine; class CNotepadParameters; +class CCreatorNotepadWrapper; class CCreatorNotepad : public CCreatorModuleBase @@ -58,9 +51,7 @@ void DeleteAllCreatedByCreatorL(); private: - AgendaUtil *iAgendaUtil; - NotesEditorInterface *iNotepadApi; //QT Notes api - //CNotepadApi *iNotepadApi; + CCreatorNotepadWrapper* iNotepadWrapper; CNotepadParameters* iParameters; RFs& iFs; diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/inc/creator_notepadwrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/creator/engine/inc/creator_notepadwrapper.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,51 @@ +/* +* 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 __CREATORNOTEPADWRAPPER_H__ +#define __CREATORNOTEPADWRAPPER_H__ + +//#include "engine.h" +//#include "creator_modulebase.h" + + +#include +#include +#include +#include + + +class CCreatorNotepadWrapper : public CBase + { + public: + static CCreatorNotepadWrapper* NewL(); + static CCreatorNotepadWrapper* NewLC(); + ~CCreatorNotepadWrapper(); + + private: + CCreatorNotepadWrapper(); + void ConstructL(); + + public: + TInt CreateNoteL( const TDesC& aText ); + void DeleteAllL(); + + private: + AgendaUtil *iAgendaUtil; + NotesEditorInterface *iNotepadApi; //QT Notes api + }; + +#endif // __CREATORNOTEPADWRAPPER_H__ diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/inc/creator_phonebook.h --- a/creator/engine/inc/creator_phonebook.h Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/inc/creator_phonebook.h Tue Jul 06 14:17:03 2010 +0300 @@ -17,65 +17,21 @@ - - #ifndef __CREATORPHONEBOOK_H__ #define __CREATORPHONEBOOK_H__ #include "creator_phonebookbase.h" #include "creator_randomdatafield.h" +#include "creator_phonebookwrapper.h" -//#include //defines Q_SFW_EXPORT -//#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 -//#include -//#include -QTM_USE_NAMESPACE class CCreatorEngine; class CCreatorModuleBaseParameters; -//class QContactManager; -//class QContact; -//class QContactId; -//class QContactData; -//class QContactName; - -//class MVPbkStoreContact; //to change -//class MVPbkContactStore; //to change -//class CAsyncWaiter; //to change - remove class CContactDatabase; -//class MVPbkContactLinkArray; //to change class CPhonebookParameters; - +class CCreatorPhonebookWrapper; class CCreatorPhonebook : public CCreatorPhonebookBase { @@ -99,50 +55,42 @@ void DeleteAllGroupsL(); void DeleteAllGroupsCreatedByCreatorL(); + void TestPrintOut(CPhonebookParameters* aParam); + private: - void InitializeContactParamsL(/*CCreatorModuleBaseParameters* aParameters*/); - TBool IsContactGroupL( QContactLocalId& aLink ); - void StoreLinksForDeleteL( RArray& aLinks, TUid aStoreUid ); //modify - void DeleteContactsL( QList& contacts /*MVPbkContactLinkArray* aContacts, TBool aGroup*/ ); //modify + void InitializeContactParamsL(); + TBool IsContactGroupL( TUint32& aLink ); + void StoreLinksForDeleteL( RArray& aLinks, TUid aStoreUid ); + void DeleteContactsL( RArray& aContactsToDelete, TUid aStoreUid ); void DeleteItemsCreatedWithCreatorL( TUid aStoreUid ); void DoDeleteItemsCreatedWithCreatorL( TUid aStoreUid, CDictionaryFileStore* aStore ); - TBool HasOtherThanGroupsL( /*MVPbkContactLinkArray* aContacts */); //modify + TBool HasOtherThanGroupsL(); private: - - QContactManager* iContactMngr;//CVPbkContactManager* iContactManager; + CCreatorPhonebookWrapper* iPhonebookWrapper; TInt iOpCounter; CPhonebookParameters* iParameters; - static QString iPhoneNumberFields[]; static TInt iUrlFields[]; static TInt iEmailFields[]; - //QList - RArray iContactLinkArray;//CVPbkContactLinkArray* iContactLinkArray; //modify - RArray iContactsToDelete; //CVPbkContactLinkArray* iContactsToDelete; //modify - RArray iContactGroupsToDelete; //CVPbkContactLinkArray* iContactGroupsToDelete; //modify + + RArray iContactLinkArray; + RArray iContactsToDelete; + RArray iContactGroupsToDelete; RArray iPreviousDeleteLinks; - //RPointerArray iPreviousDeleteLinks; //modify private: //new variables /// Ref: the target of the copy - QContact* iStore; //MVPbkContactStore* iStore; - - //CAsyncWaiter* iWaiter; //remove + /// Own: Contact database for this store CContactDatabase* iContactDb; - //Contacts found in contacts db. - QList* iContactResults;//MVPbkContactLinkArray* iContactResults; - // Contact groups that are found in the store. These are used in filtering - // the groups from the find results. - QList* iContactGroupsInStore;//MVPbkContactLinkArray* iContactGroupsInStore; }; @@ -159,15 +107,16 @@ TInt CPhonebookParameters::ScriptLinkId() const; void CPhonebookParameters::SetScriptLinkId(TInt aLinkId); - QList iContactFields;// RPointerArray iContactFields; + TCreatorContactFields iContactFields; - QString iGroupName;//HBufC* iGroupName; + HBufC* iGroupName; TInt iContactsInGroup; TInt iNumberOfPhoneNumberFields; TInt iNumberOfURLFields; TInt iNumberOfEmailAddressFields; TInt iContactSetPtr; - RArray iLinkIds; //QList iLinkIds;// For contactgroup. Stores the linked contact ids. + RArray iLinkIds; // For contactgroup. Stores the linked contact ids. + public: CPhonebookParameters(); @@ -178,13 +127,12 @@ }; -class CCreatorContactField : public CBase//, public MCreatorRandomDataField +class CCreatorContactField : public CBase //, public MCreatorRandomDataField { public: static CCreatorContactField* NewL(); - QContactDetail CreateContactDetailL(CCreatorEngine* aEngine,CPhonebookParameters* aParameters,QString aDetail, QString aFieldContext, QString aFieldString, TInt aRand = KErrNotFound ); - QContactDetail CreateContactDetailL(CCreatorEngine* aEngine,CPhonebookParameters* aParameters,QString aDetail, QString aFieldContext, QString aFieldString, TPtrC aData ); - void AddFieldToParam( CPhonebookParameters* aParam, QContactDetail aDetail); + void AddFieldToParamL( CCreatorEngine* aEngine, CPhonebookParameters* aParam, TInt aType, TInt aRand = KErrNotFound ); + void AddFieldToParamL( CPhonebookParameters* aParam, TInt aType, TPtrC aContent ); ~CCreatorContactField(); private: CCreatorContactField(); diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/inc/creator_phonebookapi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/creator/engine/inc/creator_phonebookapi.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,53 @@ +/* +* 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 CREATOR_PHONEBOOKAPI_H_ +#define CREATOR_PHONEBOOKAPI_H_ + +#include +#include +#include +#include +QTM_USE_NAMESPACE + + +class CCreatorPhonebookAPI + { +public: + CCreatorPhonebookAPI (); + ~CCreatorPhonebookAPI (); + + quint32 saveContact( const QList& list ); + quint32 createGroup( const QString& groupName ); + int numberOfContacts(); + int addContactToGroup( QContactLocalId group, QContactLocalId contact ); + int addToGroup(QContactLocalId group, int amount); + bool deleteAllContacts(); + bool deleteAllContacts( const QString& type ); + bool deleteContacts( const QList& list ); + QContact contact( const QContactLocalId& contactId ); + +private: + bool IsContactGroupL( const QContact& contact ); + +private: + QContactManager* mContactMngr; + + }; + +#endif /* CREATOR_PHONEBOOKAPI_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/inc/creator_phonebookbase.h --- a/creator/engine/inc/creator_phonebookbase.h Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/inc/creator_phonebookbase.h Tue Jul 06 14:17:03 2010 +0300 @@ -24,7 +24,7 @@ #include "creator_modulebase.h" static const TInt KPhonebookFieldLength = 128; -static const TInt KCreateRandomAmountOfGroups = -9999; +static const TInt KCreateRandomAmountOfGroups = 1; class CCreatorModuleBaseParameters; diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/inc/creator_phonebookwrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/creator/engine/inc/creator_phonebookwrapper.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,197 @@ +/* +* 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 __CREATORPHONEBOOKWRAPPER_H__ +#define __CREATORPHONEBOOKWRAPPER_H__ + +#include "creator_phonebookbase.h" +#include "creator_randomdatafield.h" + +#include + +#include "creator_phonebookapi.h" + +class CCreatorEngine; +class CCreatorModuleBaseParameters; + +class CContactDatabase; +//class CPhonebookWrapperParameters; +class CPhonebookParameters; + +typedef typename std::map TCreatorContactFields; +typedef typename std::pair TCreatorContactField; + +class CCreatorPhonebookWrapper : public CBase + { +public: + enum ContactDetailType{ + ELastName, //0 + ELastNameReading, //1 + EFirstName, + EFirstNameReading, + EPrefix, + ESuffix, //5 + ESecondName, + ELandPhoneHome, + EMobilePhoneHome, + EVideoNumberHome, + EFaxNumberHome, //10 + EVoipHome, + EEmailHome, + EUrlHome, + EAddrLabelHome, + EAddrPoHome, //15 + EAddrExtHome, + EAddrStreetHome, + EAddrLocalHome, + EAddrRegionHome, + EAddrPostCodeHome, //20 + EAddrCountryHome, + EJobTitle, + ECompanyName, + ELandPhoneWork, + EMobilePhoneWork, //25 + EVideoNumberWork, + EFaxNumberWork, + EVoipWork, + EEmailWork, + EUrlWork, //30 + EAddrLabelWork, + EAddrPoWork, + EAddrExtWork, + EAddrStreetWork, + EAddrLocalWork, //35 + EAddrRegionWork, + EAddrPostCodeWork, + EAddrCountryWork, + ELandPhoneGen, + EMobilePhoneGen, //40 + EVideoNumberGen, + EFaxNumberGen, + EVoipGen, + EPoc, + ESwis, //45 + ESip, + EEmailGen, + EUrlGen, + EAddrLabelGen, + EAddrPoGen, //50 + EAddrExtGen, + EAddrStreetGen, + EAddrLocalGen, + EAddrRegionGen, + EAddrPostCodeGen, //55 + EAddrCountryGen, + EPagerNumber, + EDtmfString, + EWVAddress, + EDate, //60 + ENote, + EThumbnailPic, + ERingTone, + ECallerObjImg, + ECallerObjText, //65 + EMiddleName, + EDepartment, + EAsstName, + ESpouse, + EChildren, //70 + EAsstPhone, + ECarPhone, + EAnniversary, + ESyncClass, + ELocPrivacy, //75 + EGenLabel, + ETopContact, + EIMPP, + }; + + +public: + static CCreatorPhonebookWrapper* NewL(); + static CCreatorPhonebookWrapper* NewLC(); + ~CCreatorPhonebookWrapper(); + +private: + CCreatorPhonebookWrapper(); + void ConstructL(); + +public: + TUint32 CreateContactEntryL(const TCreatorContactFields& Map); + TUint32 CreateGroupEntryL( HBufC* aGroupName ); + TInt CreateSubscribedContactEntryL(); + + /** + * NumberOfContacts() will return all contacts from Contact API + */ + TInt NumberOfContacts(); + + TInt AddContactToGroup( TUint32 aGroupId, TUint32 aContact ); + TInt AddToGroup( TUint32 aGroupId, TInt aAmount ); + + + void DeleteAllL(); + void DeleteAllGroupsL(); + void DeleteContactsL( RArray& aContactsToDelete, TUid aStoreUid ); + +private: + QList CreateContactDetailsFromParameters( const TCreatorContactFields& Map ); + QContactDetail CreateContactDetail( QList& aContactDetailList,QString aDetail, QString aFieldContext, QString aFieldString, QString aData ); + void AddFieldToList( QList& aDetailList, QContactDetail aDetail); + + TBool IsContactGroupL( TUint32& aLink ); + + void DeleteItemsCreatedWithCreatorL( TUid aStoreUid ); + void DoDeleteItemsCreatedWithCreatorL( TUid aStoreUid, CDictionaryFileStore* aStore ); + TBool HasOtherThanGroupsL(); + + +private: + + TInt iOpCounter; + + static QString iPhoneNumberFields[]; + static TInt iUrlFields[]; + static TInt iEmailFields[]; + + RArray iContactLinkArray; + RArray iContactsToDelete; + RArray iContactGroupsToDelete; + + RArray iPreviousDeleteLinks; + //RPointerArray iPreviousDeleteLinks; //modify + +private: + //new variables + /// Ref: the target of the copy + QContact* iStore; + + /// Own: Contact database for this store + CContactDatabase* iContactDb; + + //Contacts found in contacts db. + QList* iContactResults; + // Contact groups that are found in the store. These are used in filtering + // the groups from the find results. + QList* iContactGroupsInStore; + + CCreatorPhonebookAPI* iPhonebookAPI; + }; + +#endif // __CREATORPHONEBOOKWRAPPER_H__ diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/inc/creator_virtualphonebook.h --- a/creator/engine/inc/creator_virtualphonebook.h Wed Jun 23 18:13:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,297 +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 __CREATORVIRTUALPHONEBOOK_H__ -#define __CREATORVIRTUALPHONEBOOK_H__ - -#include "engine.h" -#include "creator_phonebookbase.h" -#include "creator_randomdatafield.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class CCreatorEngine; -class CCreatorModuleBaseParameters; - -class MVPbkStoreContact; -class MVPbkContactStore; -class CAsyncWaiter; -class CContactDatabase; -class MVPbkContactLinkArray; -class CVirtualPhonebookParameters; - - -class CCreatorVirtualPhonebook : public CCreatorPhonebookBase, - public MVPbkContactStoreListObserver, public MVPbkBatchOperationObserver, - public MVPbkContactFindObserver, public MVPbkContactObserver, public MPbk2ImageSetObserver, - public MVPbkSingleContactOperationObserver, public MVPbkContactViewObserver - { -public: - static CCreatorVirtualPhonebook* NewL(CCreatorEngine* aEngine); - static CCreatorVirtualPhonebook* NewLC(CCreatorEngine* aEngine); - ~CCreatorVirtualPhonebook(); - -private: - CCreatorVirtualPhonebook(); - void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase - -public: - TInt CreateContactEntryL(CCreatorModuleBaseParameters *aParameters); - TInt CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters); - TInt CreateSubscribedContactEntryL(CCreatorModuleBaseParameters *aParameters); - - void AddFieldToContactItemL(MVPbkStoreContact& aItem, TPbkFieldId aFieldId, const TDesC& aFieldText); - void AddFieldToContactItemL(MVPbkStoreContact& aItem, TPbkFieldId aFieldId, const TDesC8& aFieldText); - void AddFieldToContactItemL(MVPbkStoreContact& aItem, TPbkFieldId aFieldId, const TTime& aFieldText); - - void AddImageToContactL(MVPbkStoreContact& aContact, TInt aFieldResId, const TDesC& aFileName); - TBool IsActive(); - void CancelOperation(); - void DeleteAllL(); - void DeleteAllCreatedByCreatorL(); - void DeleteAllGroupsL(); - void DeleteAllGroupsCreatedByCreatorL(); - -private: - void CompactPbkDatabaseL(TBool aCompressImmediately=EFalse); - void AddFieldToParamsL(TInt aFieldType, const TDesC& aData); - void AddFieldToParamsL(TInt aFieldType, const TDesC8& aData); - void AddFieldToParamsL(TInt aFieldType, const TTime& aData); - void InitializeContactParamsL(/*CCreatorModuleBaseParameters* aParameters*/); - TBool IsContactGroupL(const MVPbkContactLink& aLink); - void StoreLinksForDeleteL( MVPbkContactLinkArray& aLinks, TUid aStoreUid ); - void DeleteContactsL( MVPbkContactLinkArray* aContacts, TBool aGroup ); - void DeleteItemsCreatedWithCreatorL( TUid aStoreUid ); - void DoDeleteItemsCreatedWithCreatorL( TUid aStoreUid, CDictionaryFileStore* aStore ); - TBool HasOtherThanGroupsL( MVPbkContactLinkArray* aContacts ); - -public: // MVPbkSingleContactOperationObserver - - void VPbkSingleContactOperationComplete( - MVPbkContactOperationBase& aOperation, - MVPbkStoreContact* aContact ); - void VPbkSingleContactOperationFailed( - MVPbkContactOperationBase& aOperation, - TInt aError ); - -private: // MVPbkContactViewObserver - - void ContactViewReady( MVPbkContactViewBase& aView ); - void ContactViewUnavailable( - MVPbkContactViewBase& aView ); - void ContactAddedToView( - MVPbkContactViewBase& aView, - TInt aIndex, - const MVPbkContactLink& aContactLink ); - void ContactRemovedFromView( - MVPbkContactViewBase& aView, - TInt aIndex, - const MVPbkContactLink& aContactLink ); - void ContactViewError( - MVPbkContactViewBase& aView, - TInt aError, - TBool aErrorNotified ); - -private: - CVPbkContactManager* iContactManager; - TInt iOpCounter; - - CVirtualPhonebookParameters* iParameters; - - static TInt iPhoneNumberFields[]; - static TInt iUrlFields[]; - static TInt iEmailFields[]; - CVPbkContactLinkArray* iContactLinkArray; - CVPbkContactLinkArray* iContactsToDelete; - CVPbkContactLinkArray* iContactGroupsToDelete; - RPointerArray iPreviousDeleteLinks; - -private: - //new variables - /// Ref: the target of the copy - MVPbkContactStore* iStore; - - CAsyncWaiter* iWaiter; - - /// Own: Contact database for this store - CContactDatabase* iContactDb; - - //Contacts found in contacts db. - MVPbkContactLinkArray* iContactResults; - // Contact groups that are found in the store. These are used in filtering - // the groups from the find results. - MVPbkContactLinkArray* iContactGroupsInStore; - - // Phonebook asynchronous operation - MVPbkContactOperationBase* iOperation; - - // Flag to indicate whether it is required to notify - // iEngine after operation is complete. This happens - // when user has cancelled the operation during - // iOperation exists. - TBool iCancelCbRequested; - -public: - //Observer implentation from MVPbkContactStoreListObserver - void OpenComplete(); - - //observer implentation from MVPbkContactStoreObserver - - void StoreReady(MVPbkContactStore& aContactStore); - - void StoreUnavailable(MVPbkContactStore& aContactStore, - TInt aReason); - - void HandleStoreEventL( - MVPbkContactStore& aContactStore, - TVPbkContactStoreEvent aStoreEvent); - - TAny* ContactStoreObserverExtension(TUid aExtensionUid); - - - - - -public: - //Observer implementation for MVPbkBatchOperationObserver - - void StepComplete( - MVPbkContactOperationBase& aOperation, - TInt aStepSize ); - - TBool StepFailed( - MVPbkContactOperationBase& aOperation, - TInt aStepSize, TInt aError ); - - void OperationComplete( - MVPbkContactOperationBase& aOperation ); - - TAny* BatchOperationObserverExtension( - TUid aExtensionUid ) ; - - - //-------------------------------------------- - //Observer implementation for MVPbkContactFindObserver - public: // Interface - - void FindCompleteL( MVPbkContactLinkArray* aResults ); - - void FindFailed( TInt aError ); - - TAny* ContactFindObserverExtension( - TUid aExtensionUid ); - - - - //-------------------------------------------- - //Observer implementation for MVPbkContactObserver - - public: - void ContactOperationCompleted(TContactOpResult aResult); - - void ContactOperationFailed - (TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified); - - TAny* ContactObserverExtension(TUid aExtensionUid) ; - //~MVPbkContactObserver(); - - //-------------------------------------------- - // Implementation of MPbk2ImageSetObserver: - public: - void Pbk2ImageSetComplete(MPbk2ImageOperation& aOperation); - void Pbk2ImageSetFailed(MPbk2ImageOperation& aOperation, TInt aError ); - }; - -class CCreatorContactFieldImpl; -class CCreatorContactField : public CBase, public MCreatorRandomDataField - { -public: - static CCreatorContactField* NewL(TInt aFieldType, const TDesC& aData); - static CCreatorContactField* NewL(TInt aFieldType, const TDesC8& aData); - static CCreatorContactField* NewL(TInt aFieldType, const TTime& aData); - - static CCreatorContactField* NewL(TInt aFieldType, TRandomLengthType aRandomLenType, TInt aRandomLen); - - ~CCreatorContactField(); - TInt FieldType(); - virtual void AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk); - virtual void SetRandomParametersL( MCreatorRandomDataField::TRandomLengthType aRandomLenType = MCreatorRandomDataField::ERandomLengthDefault, - TInt aRandomLen = 0 ); - virtual void ParseL(CCommandParser* parser); - -private: - CCreatorContactField(); - void ConstructL(TInt aFieldType, const TDesC& aData); - void ConstructL(TInt aFieldType, const TDesC8& aData); - void ConstructL(TInt aFieldType, const TTime& aData); - CCreatorContactFieldImpl* pImpl; - }; - - -/** - * Virtual phonebook parameters - */ - - -class CVirtualPhonebookParameters : public CCreatorModuleBaseParameters - { -public: - void ParseL(CCommandParser* parser, TParseParams /*aCase = 0*/); - - TInt CVirtualPhonebookParameters::ScriptLinkId() const; - void CVirtualPhonebookParameters::SetScriptLinkId(TInt aLinkId); - RPointerArray iContactFields; - - HBufC* iGroupName; - TInt iContactsInGroup; - TInt iNumberOfPhoneNumberFields; - TInt iNumberOfURLFields; - TInt iNumberOfEmailAddressFields; - TInt iContactSetPtr; - RArray iLinkIds; // For contactgroup. Stores the linked contact ids. - -public: - CVirtualPhonebookParameters(); - ~CVirtualPhonebookParameters(); - -private: - TInt iLinkId; // For contact. Stores the contact id - }; - - - -#endif // __CREATORVIRTUALPHONEBOOK_H__ diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_accesspoint.cpp --- a/creator/engine/src/creator_accesspoint.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/src/creator_accesspoint.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -18,7 +18,7 @@ -#include "creator_accesspoint.h" +//#include "creator_accesspoint.h" #include "creator_traces.h" #include #include diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_connectionmethodelement.cpp --- a/creator/engine/src/creator_connectionmethodelement.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/src/creator_connectionmethodelement.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -20,7 +20,7 @@ #include "enginewrapper.h" #include "creator_connectionmethodelement.h" #include "creator_traces.h" -#include "creator_accesspoint.h" +//#include "creator_accesspoint.h" using namespace creatorconnectionmethod; diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_contactelement.cpp --- a/creator/engine/src/creator_contactelement.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/src/creator_contactelement.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -42,99 +42,98 @@ { public: TPtrC iElementName; - QString iDetail; - QString iContext; - QString iFieldCode; + TInt iFieldCode; TContactFieldDataType iDataType; }; -//********************************************************************************* FieldMapping fieldMappingTbl[] = { - {TPtrC(KFirstname), (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactName::FieldFirstName).operator QString() /*R_VPBK_FIELD_TYPE_FIRSTNAME*/, EDataTypeText}, - {TPtrC(KLastname), (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactName::FieldLastName).operator QString() /*R_VPBK_FIELD_TYPE_LASTNAME*/, EDataTypeText}, - {TPtrC(KPrefix), (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactName::FieldPrefix).operator QString()/*R_VPBK_FIELD_TYPE_PREFIX*/, EDataTypeText}, - {TPtrC(KSuffix), (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactName::FieldSuffix).operator QString()/*R_VPBK_FIELD_TYPE_SUFFIX*/, EDataTypeText}, - {TPtrC(KSecondname), (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactName::FieldMiddleName).operator QString()/*R_VPBK_FIELD_TYPE_SECONDNAME*/, EDataTypeText}, - {TPtrC(KLandphoneHome), (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactPhoneNumber::SubTypeLandline).operator QString()/*R_VPBK_FIELD_TYPE_LANDPHONEHOME*/, EDataTypeText}, - - {TPtrC(KMobilephoneHome), (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactPhoneNumber::SubTypeMobile).operator QString()/*R_VPBK_FIELD_TYPE_MOBILEPHONEHOME*/, EDataTypeText}, - {TPtrC(KVideonumberHome), (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactPhoneNumber::SubTypeVideo).operator QString()/*R_VPBK_FIELD_TYPE_VIDEONUMBERHOME*/, EDataTypeText}, - {TPtrC(KFaxnumberHome), (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactPhoneNumber::SubTypeFacsimile).operator QString()/*R_VPBK_FIELD_TYPE_FAXNUMBERHOME*/, EDataTypeText}, - //{TPtrC(KVoipHome), (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactPhoneNumber::SubType).operator QString()/*R_VPBK_FIELD_TYPE_VOIPHOME*/, EDataTypeText}, - {TPtrC(KEmailHome), (QContactEmailAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),""/*R_VPBK_FIELD_TYPE_EMAILHOME*/, EDataTypeText}, - {TPtrC(KUrlHome), (QContactUrl::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactUrl::SubTypeHomePage).operator QString()/*R_VPBK_FIELD_TYPE_URLHOME*/, EDataTypeText}, - //{TPtrC(KAddrlabelHome), R_VPBK_FIELD_TYPE_ADDRLABELHOME, EDataTypeText}, - {TPtrC(KAddrpoHome), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactAddress::FieldPostOfficeBox).operator QString()/*R_VPBK_FIELD_TYPE_ADDRPOHOME*/, EDataTypeText}, + {TPtrC(KFirstname), CCreatorPhonebookWrapper::EFirstName, EDataTypeText}, + {TPtrC(KLastname), CCreatorPhonebookWrapper::ELastName, EDataTypeText}, + {TPtrC(KFirstnameReading), CCreatorPhonebookWrapper::EFirstNameReading, EDataTypeText}, + {TPtrC(KLastnameReading), CCreatorPhonebookWrapper::ELastNameReading, EDataTypeText}, + {TPtrC(KPrefix), CCreatorPhonebookWrapper::EPrefix, EDataTypeText}, + {TPtrC(KSuffix), CCreatorPhonebookWrapper::ESuffix, EDataTypeText}, + {TPtrC(KSecondname), CCreatorPhonebookWrapper::ESecondName, EDataTypeText}, + {TPtrC(KLandphoneHome), CCreatorPhonebookWrapper::ELandPhoneHome, EDataTypeText}, - // {TPtrC(KAddrextHome), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactAddress::Field).operator QString()/*R_VPBK_FIELD_TYPE_ADDREXTHOME*/, EDataTypeText}, - {TPtrC(KAddrstreetHome), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactAddress::FieldStreet).operator QString()/*R_VPBK_FIELD_TYPE_ADDRSTREETHOME*/, EDataTypeText}, - {TPtrC(KAddrlocalHome), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactAddress::FieldLocality).operator QString()/*R_VPBK_FIELD_TYPE_ADDRLOCALHOME*/, EDataTypeText}, - {TPtrC(KAddrregionHome), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactAddress::FieldRegion).operator QString()/*R_VPBK_FIELD_TYPE_ADDRREGIONHOME*/, EDataTypeText}, - {TPtrC(KAddrpostcodeHome), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactAddress::FieldPostcode).operator QString()/*R_VPBK_FIELD_TYPE_ADDRPOSTCODEHOME*/, EDataTypeText}, - {TPtrC(KAddrcountryHome), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactAddress::FieldCountry).operator QString()/*R_VPBK_FIELD_TYPE_ADDRCOUNTRYHOME*/, EDataTypeText}, - {TPtrC(KJobtitle), (QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactOrganization::FieldTitle).operator QString()/*R_VPBK_FIELD_TYPE_JOBTITLE*/, EDataTypeText}, - {TPtrC(KCompanyname), (QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactOrganization::FieldName).operator QString()/*R_VPBK_FIELD_TYPE_COMPANYNAME*/, EDataTypeText}, + {TPtrC(KMobilephoneHome), CCreatorPhonebookWrapper::EMobilePhoneHome, EDataTypeText}, + {TPtrC(KVideonumberHome), CCreatorPhonebookWrapper::EVideoNumberHome, EDataTypeText}, + {TPtrC(KFaxnumberHome), CCreatorPhonebookWrapper::EFaxNumberHome, EDataTypeText}, + {TPtrC(KVoipHome), CCreatorPhonebookWrapper::EVoipHome, EDataTypeText}, + {TPtrC(KEmailHome), CCreatorPhonebookWrapper::EEmailHome, EDataTypeText}, + {TPtrC(KUrlHome), CCreatorPhonebookWrapper::EUrlHome, EDataTypeText}, + {TPtrC(KAddrlabelHome), CCreatorPhonebookWrapper::EAddrLabelHome, EDataTypeText}, + {TPtrC(KAddrpoHome), CCreatorPhonebookWrapper::EAddrPoHome, EDataTypeText}, - {TPtrC(KLandphoneWork), (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactPhoneNumber::SubTypeLandline).operator QString()/*R_VPBK_FIELD_TYPE_LANDPHONEWORK*/, EDataTypeText}, - {TPtrC(KMobilephoneWork), (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactPhoneNumber::SubTypeMobile).operator QString()/*R_VPBK_FIELD_TYPE_MOBILEPHONEWORK*/, EDataTypeText}, - {TPtrC(KVideonumberWork), (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactPhoneNumber::SubTypeVideo).operator QString()/*R_VPBK_FIELD_TYPE_VIDEONUMBERWORK*/, EDataTypeText}, - {TPtrC(KFaxnumberWork), (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactPhoneNumber::SubTypeFacsimile).operator QString()/*R_VPBK_FIELD_TYPE_FAXNUMBERWORK*/, EDataTypeText}, - //{TPtrC(KVoipWork), R_VPBK_FIELD_TYPE_VOIPWORK, EDataTypeText}, - {TPtrC(KEmailWork), (QContactEmailAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),""/*R_VPBK_FIELD_TYPE_EMAILWORK*/, EDataTypeText}, - {TPtrC(KUrlWork), (QContactUrl::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactUrl::SubTypeHomePage).operator QString()/*R_VPBK_FIELD_TYPE_URLWORK*/, EDataTypeText}, - //{TPtrC(KAddrlabelWork), R_VPBK_FIELD_TYPE_ADDRLABELWORK, EDataTypeText}, + {TPtrC(KAddrextHome), CCreatorPhonebookWrapper::EAddrExtHome, EDataTypeText}, + {TPtrC(KAddrstreetHome), CCreatorPhonebookWrapper::EAddrStreetHome, EDataTypeText}, + {TPtrC(KAddrlocalHome), CCreatorPhonebookWrapper::EAddrLocalHome, EDataTypeText}, + {TPtrC(KAddrregionHome), CCreatorPhonebookWrapper::EAddrRegionHome, EDataTypeText}, + {TPtrC(KAddrpostcodeHome), CCreatorPhonebookWrapper::EAddrPostCodeHome, EDataTypeText}, + {TPtrC(KAddrcountryHome), CCreatorPhonebookWrapper::EAddrCountryHome, EDataTypeText}, + {TPtrC(KJobtitle), CCreatorPhonebookWrapper::EJobTitle, EDataTypeText}, + {TPtrC(KCompanyname), CCreatorPhonebookWrapper::ECompanyName, EDataTypeText}, - {TPtrC(KAddrpoWork), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactAddress::FieldPostOfficeBox).operator QString()/*R_VPBK_FIELD_TYPE_ADDRPOWORK*/, EDataTypeText}, - //{TPtrC(KAddrextWork), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactAddress::FieldPostOfficeBox).operator QString()/*R_VPBK_FIELD_TYPE_ADDREXTWORK*/, EDataTypeText}, - {TPtrC(KAddrstreetWork), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactAddress::FieldStreet).operator QString()/*R_VPBK_FIELD_TYPE_ADDRSTREETWORK*/, EDataTypeText}, - {TPtrC(KAddrlocalWork), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactAddress::FieldLocality).operator QString()/*R_VPBK_FIELD_TYPE_ADDRLOCALWORK*/, EDataTypeText}, - {TPtrC(KAddrregionWork), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactAddress::FieldRegion).operator QString()/*R_VPBK_FIELD_TYPE_ADDRREGIONWORK*/, EDataTypeText}, - {TPtrC(KAddrpostcodeWork), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactAddress::FieldPostcode).operator QString()/*R_VPBK_FIELD_TYPE_ADDRPOSTCODEWORK*/, EDataTypeText}, - {TPtrC(KAddrcountryWork), (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactAddress::FieldCountry).operator QString()/*R_VPBK_FIELD_TYPE_ADDRCOUNTRYWORK*/, EDataTypeText}, + {TPtrC(KLandphoneWork), CCreatorPhonebookWrapper::ELandPhoneWork, EDataTypeText}, + {TPtrC(KMobilephoneWork), CCreatorPhonebookWrapper::EMobilePhoneWork, EDataTypeText}, + {TPtrC(KVideonumberWork), CCreatorPhonebookWrapper::EVideoNumberWork, EDataTypeText}, + {TPtrC(KFaxnumberWork), CCreatorPhonebookWrapper::EFaxNumberWork, EDataTypeText}, + {TPtrC(KVoipWork), CCreatorPhonebookWrapper::EVoipWork, EDataTypeText}, + {TPtrC(KEmailWork), CCreatorPhonebookWrapper::EEmailWork, EDataTypeText}, + {TPtrC(KUrlWork), CCreatorPhonebookWrapper::EUrlWork, EDataTypeText}, + {TPtrC(KAddrlabelWork), CCreatorPhonebookWrapper::EAddrLabelWork, EDataTypeText}, - {TPtrC(KLandphoneGen), (QContactPhoneNumber::DefinitionName).operator QString(), "",(QContactPhoneNumber::SubTypeLandline).operator QString(), EDataTypeText}, - {TPtrC(KMobilephoneGen), (QContactPhoneNumber::DefinitionName).operator QString(), "",(QContactPhoneNumber::SubTypeMobile).operator QString(), EDataTypeText}, - {TPtrC(KVideonumberGen), (QContactPhoneNumber::DefinitionName).operator QString(), "",(QContactPhoneNumber::SubTypeVideo).operator QString(), EDataTypeText}, - {TPtrC(KFaxnumberGen), (QContactPhoneNumber::DefinitionName).operator QString(), "",(QContactPhoneNumber::SubTypeFacsimile).operator QString(), EDataTypeText}, - // {TPtrC(KVoipGen), R_VPBK_FIELD_TYPE_VOIPGEN, EDataTypeText}, - // {TPtrC(KPoc), R_VPBK_FIELD_TYPE_POC, EDataTypeText}, - // {TPtrC(KSwis), R_VPBK_FIELD_TYPE_SWIS, EDataTypeText}, - // {TPtrC(KSip), R_VPBK_FIELD_TYPE_SIP, EDataTypeText}, - {TPtrC(KEmailGen), (QContactEmailAddress::DefinitionName).operator QString(), "","", EDataTypeText}, + {TPtrC(KAddrpoWork), CCreatorPhonebookWrapper::EAddrPoWork, EDataTypeText}, + {TPtrC(KAddrextWork), CCreatorPhonebookWrapper::EAddrExtWork, EDataTypeText}, + {TPtrC(KAddrstreetWork), CCreatorPhonebookWrapper::EAddrStreetWork, EDataTypeText}, + {TPtrC(KAddrlocalWork), CCreatorPhonebookWrapper::EAddrLocalWork, EDataTypeText}, + {TPtrC(KAddrregionWork), CCreatorPhonebookWrapper::EAddrRegionWork, EDataTypeText}, + {TPtrC(KAddrpostcodeWork), CCreatorPhonebookWrapper::EAddrPostCodeWork, EDataTypeText}, + {TPtrC(KAddrcountryWork), CCreatorPhonebookWrapper::EAddrCountryWork, EDataTypeText}, + {TPtrC(KLandphoneGen), CCreatorPhonebookWrapper::ELandPhoneGen, EDataTypeText}, - {TPtrC(KUrlGen), (QContactUrl::DefinitionName).operator QString(), "","", EDataTypeText}, - // {TPtrC(KAddrlabelGen), R_VPBK_FIELD_TYPE_ADDRLABELGEN, EDataTypeText}, - {TPtrC(KAddrpoGen), (QContactAddress::DefinitionName).operator QString(), "",(QContactAddress::FieldPostOfficeBox).operator QString()/*R_VPBK_FIELD_TYPE_ADDRPOGEN*/, EDataTypeText}, - // {TPtrC(KAddrextGen), R_VPBK_FIELD_TYPE_ADDREXTGEN, EDataTypeText}, - {TPtrC(KAddrstreetGen), (QContactAddress::DefinitionName).operator QString(), "" , (QContactAddress::FieldStreet).operator QString()/*R_VPBK_FIELD_TYPE_ADDRSTREETGEN*/, EDataTypeText}, - {TPtrC(KAddrlocalGen), (QContactAddress::DefinitionName).operator QString(), "" , (QContactAddress::FieldLocality).operator QString()/*R_VPBK_FIELD_TYPE_ADDRLOCALGEN*/, EDataTypeText}, - {TPtrC(KAddrregionGen), (QContactAddress::DefinitionName).operator QString(), "" , (QContactAddress::FieldRegion).operator QString()/*R_VPBK_FIELD_TYPE_ADDRREGIONGEN*/, EDataTypeText}, - {TPtrC(KAddrpostcodeGen), (QContactAddress::DefinitionName).operator QString(), "" , (QContactAddress::FieldPostcode).operator QString()/*R_VPBK_FIELD_TYPE_ADDRPOSTCODEGEN*/, EDataTypeText}, - {TPtrC(KAddrcountryGen), (QContactAddress::DefinitionName).operator QString(), "" , (QContactAddress::FieldCountry).operator QString()/*R_VPBK_FIELD_TYPE_ADDRCOUNTRYGEN*/, EDataTypeText}, + {TPtrC(KMobilephoneGen), CCreatorPhonebookWrapper::EMobilePhoneGen, EDataTypeText}, + {TPtrC(KVideonumberGen), CCreatorPhonebookWrapper::EVideoNumberGen, EDataTypeText}, + {TPtrC(KFaxnumberGen), CCreatorPhonebookWrapper::EFaxNumberGen, EDataTypeText}, + {TPtrC(KVoipGen), CCreatorPhonebookWrapper::EVoipGen, EDataTypeText}, + {TPtrC(KPoc), CCreatorPhonebookWrapper::EPoc, EDataTypeText}, + {TPtrC(KSwis), CCreatorPhonebookWrapper::ESwis, EDataTypeText}, + {TPtrC(KSip), CCreatorPhonebookWrapper::ESip, EDataTypeText}, + {TPtrC(KEmailGen), CCreatorPhonebookWrapper::EEmailGen, EDataTypeText}, - {TPtrC(KPagerNumber),(QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactPhoneNumber::SubTypePager).operator QString()/* R_VPBK_FIELD_TYPE_PAGERNUMBER*/, EDataTypeText}, - {TPtrC(KDtmfString), (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactPhoneNumber::SubTypeDtmfMenu).operator QString()/* R_VPBK_FIELD_TYPE_DTMFSTRING*/, EDataTypeText}, - // {TPtrC(KWvAddress), R_VPBK_FIELD_TYPE_WVADDRESS, EDataTypeText}, - {TPtrC(KDate), (QContactBirthday::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactBirthday::FieldBirthday).operator QString()/* R_VPBK_FIELD_TYPE_DATE*/, EDataTypeDateTime}, - {TPtrC(KNote), (QContactNote::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactNote::FieldNote).operator QString()/* R_VPBK_FIELD_TYPE_NOTE*/, EDataTypeText}, - {TPtrC(KThumbnailPath), (QContactAvatar::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactAvatar::SubTypeImage).operator QString()/* R_VPBK_FIELD_TYPE_THUMBNAILPIC*/, EDataTypeText}, - // {TPtrC(KThumbnailId), R_VPBK_FIELD_TYPE_THUMBNAILPIC, EDataTypeText}, - // {TPtrC(KRingTone), R_VPBK_FIELD_TYPE_RINGTONE, EDataTypeText}, - // {TPtrC(KRingToneId), R_VPBK_FIELD_TYPE_RINGTONE, EDataTypeText}, + {TPtrC(KUrlGen), CCreatorPhonebookWrapper::EUrlGen, EDataTypeText}, + {TPtrC(KAddrlabelGen), CCreatorPhonebookWrapper::EAddrLabelGen, EDataTypeText}, + {TPtrC(KAddrpoGen), CCreatorPhonebookWrapper::EAddrPoGen, EDataTypeText}, + {TPtrC(KAddrextGen), CCreatorPhonebookWrapper::EAddrExtGen, EDataTypeText}, + {TPtrC(KAddrstreetGen), CCreatorPhonebookWrapper::EAddrStreetGen, EDataTypeText}, + {TPtrC(KAddrlocalGen), CCreatorPhonebookWrapper::EAddrLocalGen, EDataTypeText}, + {TPtrC(KAddrregionGen), CCreatorPhonebookWrapper::EAddrRegionGen, EDataTypeText}, + {TPtrC(KAddrpostcodeGen), CCreatorPhonebookWrapper::EAddrPostCodeGen, EDataTypeText}, - //{TPtrC(KCallerobjImg), R_VPBK_FIELD_TYPE_CALLEROBJIMG, EDataTypeText}, - // {TPtrC(KCallerobjText), R_VPBK_FIELD_TYPE_CALLEROBJTEXT, EDataTypeText}, - {TPtrC(KMiddlename), (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactName::FieldMiddleName).operator QString()/*R_VPBK_FIELD_TYPE_MIDDLENAME*/, EDataTypeText}, - {TPtrC(KDepartment), (QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactOrganization::FieldDepartment).operator QString()/*R_VPBK_FIELD_TYPE_DEPARTMENT*/, EDataTypeText}, - {TPtrC(KAsstname), (QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactOrganization::FieldAssistantName).operator QString()/*R_VPBK_FIELD_TYPE_ASSTNAME*/, EDataTypeText}, - {TPtrC(KSpouse), (QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactFamily::FieldSpouse).operator QString()/* R_VPBK_FIELD_TYPE_SPOUSE*/, EDataTypeText}, - {TPtrC(KChildren), (QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactFamily::FieldChildren).operator QString()/*R_VPBK_FIELD_TYPE_CHILDREN, EDataTypeText}, - {TPtrC(KAsstphone), (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactPhoneNumber::SubTypeAssistant).operator QString()/* R_VPBK_FIELD_TYPE_ASSTPHONE*/, EDataTypeText}, + {TPtrC(KAddrcountryGen), CCreatorPhonebookWrapper::EAddrCountryGen, EDataTypeText}, + {TPtrC(KPagerNumber), CCreatorPhonebookWrapper::EPagerNumber, EDataTypeText}, + {TPtrC(KDtmfString), CCreatorPhonebookWrapper::EDtmfString, EDataTypeText}, + {TPtrC(KWvAddress), CCreatorPhonebookWrapper::EWVAddress, EDataTypeText}, + {TPtrC(KDate), CCreatorPhonebookWrapper::EDate, EDataTypeDateTime}, + {TPtrC(KNote), CCreatorPhonebookWrapper::ENote, EDataTypeText}, + {TPtrC(KThumbnailPath), CCreatorPhonebookWrapper::EThumbnailPic, EDataTypeText}, + {TPtrC(KThumbnailId), CCreatorPhonebookWrapper::EThumbnailPic, EDataTypeText}, + {TPtrC(KRingTone), CCreatorPhonebookWrapper::ERingTone, EDataTypeText}, + {TPtrC(KRingToneId), CCreatorPhonebookWrapper::ERingTone, EDataTypeText}, - {TPtrC(KCarphone), (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactPhoneNumber::SubTypeCar).operator QString()/* R_VPBK_FIELD_TYPE_CARPHONE*/, EDataTypeText}, - {TPtrC(KAnniversary), (QContactAnniversary::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(),(QContactAnniversary::SubTypeEmployment).operator QString()/*R_VPBK_FIELD_TYPE_ANNIVERSARY*/, EDataTypeDateTime}, - // {TPtrC(KSyncclass), R_VPBK_FIELD_TYPE_SYNCCLASS, EDataTypeText}, - // {TPtrC(KLocPrivacy), R_VPBK_FIELD_TYPE_LOCPRIVACY, EDataTypeText}, - {TPtrC(KGenlabel), (QContactDisplayLabel::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(),(QContactDisplayLabel::FieldLabel).operator QString()/*R_VPBK_FIELD_TYPE_GENLABEL*/, EDataTypeText} + {TPtrC(KCallerobjImg), CCreatorPhonebookWrapper::ECallerObjImg, EDataTypeText}, + {TPtrC(KCallerobjText), CCreatorPhonebookWrapper::ECallerObjText, EDataTypeText}, + {TPtrC(KMiddlename), CCreatorPhonebookWrapper::EMiddleName, EDataTypeText}, + {TPtrC(KDepartment), CCreatorPhonebookWrapper::EDepartment, EDataTypeText}, + {TPtrC(KAsstname), CCreatorPhonebookWrapper::EAsstName, EDataTypeText}, + {TPtrC(KSpouse), CCreatorPhonebookWrapper::ESpouse, EDataTypeText}, + {TPtrC(KChildren), CCreatorPhonebookWrapper::EChildren, EDataTypeText}, + {TPtrC(KAsstphone), CCreatorPhonebookWrapper::EAsstPhone, EDataTypeText}, + + {TPtrC(KCarphone), CCreatorPhonebookWrapper::ECarPhone, EDataTypeText}, + {TPtrC(KAnniversary), CCreatorPhonebookWrapper::EAnniversary, EDataTypeDateTime}, + {TPtrC(KSyncclass), CCreatorPhonebookWrapper::ESyncClass, EDataTypeText}, + {TPtrC(KLocPrivacy), CCreatorPhonebookWrapper::ELocPrivacy, EDataTypeText}, + {TPtrC(KGenlabel), CCreatorPhonebookWrapper::EGenLabel, EDataTypeText} }; //********************************************************************************* @@ -220,25 +219,19 @@ if( content == TPtrC(KEmpty) || content == TPtrC(KNullDesC) ) { - // random - CleanupStack::PushL( field ); - QContactDetail cntDetail = field->CreateContactDetailL(iEngine,param,mapping.iDetail,mapping.iContext,mapping.iFieldCode, KErrNotFound ); - if(!cntDetail.isEmpty()) - { - field->AddFieldToParam( param, cntDetail ); //it will do "param->iContactFields.AppendL(field);" - } - CleanupStack::Pop( field ); + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL( iEngine,param, mapping.iFieldCode, KErrNotFound ); + CleanupStack::Pop(field); } else - { - CleanupStack::PushL( field ); - QContactDetail cntDetail = field->CreateContactDetailL(iEngine,param,mapping.iDetail,mapping.iContext,mapping.iFieldCode, content ); - if(!cntDetail.isEmpty()) - { - field->AddFieldToParam( param, cntDetail ); //it will do "param->iContactFields.AppendL(field);" - } - CleanupStack::Pop( field ); - } + { + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL( param, mapping.iFieldCode, content ); + CleanupStack::Pop(field); + } + break; @@ -258,16 +251,12 @@ // Skip thumbnail and ringtone IDs, since they are duplicates with thumbnailpath and ringtonepath continue; } + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL( iEngine,param, fieldMappingTbl[i].iFieldCode, KErrNotFound ); + CleanupStack::Pop(field); + } - CCreatorContactField* field = CCreatorContactField::NewL(); - CleanupStack::PushL( field ); - QContactDetail cntDetail = field->CreateContactDetailL(iEngine,param,fieldMappingTbl[i].iDetail,fieldMappingTbl[i].iContext,fieldMappingTbl[i].iFieldCode, KErrNotFound ); - if(!cntDetail.isEmpty()) - { - field->AddFieldToParam( param, cntDetail ); //it will do "param->iContactFields.AppendL(field);" - } - CleanupStack::Pop( field ); - } } iEngine->AppendToCommandArrayL(ECmdCreatePhoneBookEntryContacts, param); iParameters.AppendL(param); // Save the pointer to the parametes. @@ -384,11 +373,11 @@ if( groupNameAttr ) { - param ->iGroupName = QString::fromUtf16(groupNameAttr->Value().Ptr(), groupNameAttr->Value().Length()); //param->iGroupName->Des().Copy( groupNameAttr->Value() ); + param->iGroupName->Des().Copy( groupNameAttr->Value() ); } else - { - param->iGroupName = QString::fromUtf16( iEngine->RandomString(CCreatorEngine::EGroupName).Ptr(), iEngine->RandomString(CCreatorEngine::EGroupName).Length()); //->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) ); + { + param->iGroupName->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) ); } iEngine->AppendToCommandArrayL(ECmdCreatePhoneBookEntryGroups, param); CleanupStack::Pop(param); diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_contactsetcache.cpp --- a/creator/engine/src/creator_contactsetcache.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/src/creator_contactsetcache.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -32,17 +32,17 @@ return iLinkId; } -void CCreatorContactSet::AppendL(QContactLocalId aContactLink) +void CCreatorContactSet::AppendL(TUint32 aContactLink) { iContactLinks.AppendL(aContactLink); } -RArray CCreatorContactSet::ContactLinks() +RArray CCreatorContactSet::ContactLinks() { return iContactLinks; } -const RArray CCreatorContactSet::ContactLinks() const +const RArray CCreatorContactSet::ContactLinks() const { return iContactLinks; } @@ -73,8 +73,8 @@ virtual ~CContactLinkCacheImp(); virtual void AppendL(CCreatorContactSet* aContactSet); - virtual RArray ContactLinks(TInt aLinkId); - virtual const RArray ContactLinks(TInt aLinkId) const; + virtual RArray ContactLinks(TInt aLinkId); + virtual const RArray ContactLinks(TInt aLinkId) const; virtual RPointerArray& ContactSets(); virtual const RPointerArray& ContactSets() const; @@ -85,7 +85,7 @@ void ConstructL(); CContactLinkCacheImp(); - RArray iEmptyLinks; + RArray iEmptyLinks; RPointerArray iContactSets; CCreatorContactSet* iDummyContactSet; @@ -123,7 +123,7 @@ { iContactSets.AppendL(aContactSet); } -RArray CContactLinkCacheImp::ContactLinks(TInt aLinkId) +RArray CContactLinkCacheImp::ContactLinks(TInt aLinkId) { for( TInt i = 0; i < iContactSets.Count(); ++i ) { @@ -135,7 +135,7 @@ return iEmptyLinks; } -const RArray CContactLinkCacheImp::ContactLinks(TInt aLinkId) const +const RArray CContactLinkCacheImp::ContactLinks(TInt aLinkId) const { for( TInt i = 0; i < iContactSets.Count(); ++i ) { diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_factory.cpp --- a/creator/engine/src/creator_factory.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/src/creator_factory.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -19,7 +19,7 @@ #include "engine.h" #include "creator_factory.h" -#include "creator_accesspoint.h" +//#include "creator_accesspoint.h" #include "creator_phonebook.h" CCreatorPhonebookBase* TCreatorFactory::CreatePhoneBookL(CCreatorEngine* aEngine) @@ -31,7 +31,7 @@ { return new(ELeave) CPhonebookParameters; } - +/* CCreatorConnectionSettingsBase* TCreatorFactory::CreateConnectionSettingsL(CCreatorEngine* aEngine) { return CCreatorAccessPoints::NewL(aEngine); @@ -41,3 +41,4 @@ { return new(ELeave) CAccessPointsParameters; } +*/ diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_note.cpp --- a/creator/engine/src/creator_note.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/src/creator_note.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -22,6 +22,7 @@ #include "creator_note.h" #include "creator_traces.h" + const TInt KCreatorDiskSpaceNeededForSingleDeletion( 8192 ); _LIT( KCreatorNotepadFile, "c:Notepad.dat" ); @@ -71,33 +72,23 @@ LOGSTRING("Creator: CCreatorNotepad::ConstructL"); iEngine = aEngine; - iAgendaUtil = new AgendaUtil(); - //iNotepadApi = new NotesEditor(iAgendaUtil); - //iNotepadApi = CNotepadApi::NewL(); + iNotepadWrapper = CCreatorNotepadWrapper::NewL(); } CCreatorNotepad::~CCreatorNotepad() { LOGSTRING("Creator: CCreatorNotepad::~CCreatorNotepad"); - - /* - if(iNotepadApi) - { - delete iNotepadApi; - iNotepadApi = NULL; - } -*/ - if(iAgendaUtil) - { - delete iAgendaUtil; - iAgendaUtil = NULL; - } if (iParameters) { delete iParameters; - iParameters = NULL; + iParameters; } + + if (iNotepadWrapper) + { + delete iNotepadWrapper; + } } //---------------------------------------------------------------------------- @@ -142,10 +133,7 @@ TInt err = KErrNone; - //iNotepadApi->AddContentL(parameters->iNoteText->Des()); - QString textNote = QString::fromUtf16(parameters->iNoteText->Ptr(),parameters->iNoteText->Length()); - iNotepadApi->edit(textNote, iAgendaUtil); - iNotepadApi->close(NotesEditorInterface::CloseWithSave, iAgendaUtil); + iNotepadWrapper->CreateNoteL(parameters->iNoteText->Des()); return err; } @@ -154,52 +142,7 @@ void CCreatorNotepad::DeleteAllL() { LOGSTRING("Creator: CCreatorNotepad::DeleteAllL"); - QList ael; - AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(AgendaUtil::IncludeNotes); - - ael = iAgendaUtil->fetchAllEntries(filter); - for(int i=0 ; ideleteEntry(ael[i].id()); - } - - // Open Notes db - /* RDbs dbs; - User::LeaveIfError( dbs.Connect() ); - CleanupClosePushL( dbs ); - RDbNamedDatabase db; - TInt openErr( db.Open( dbs, KCreatorNotepadFile, KCreatorNotepadFormat ) ); - CleanupClosePushL( db ); - - if ( openErr && openErr != KErrNotFound ) - { - User::Leave( openErr ); - } - - // do not leave if openErr == KErrNotFound, - // it means there is no notes (file) created -> no need to delete - - if ( openErr != KErrNotFound ) - { - TInt retval = iFs.ReserveDriveSpace( KDefaultDrive, KCreatorDiskSpaceNeededForSingleDeletion ); - if ( retval == KErrNone ) - { - retval = iFs.GetReserveAccess( KDefaultDrive ); - } - - // Delete all Notes. Ignore rowCount returnvalue - db.Execute( KCreatorNotepadDeleteAllSQL ); - - User::LeaveIfError( db.Compact() ); - - if ( retval == KErrNone ) - { - retval = iFs.ReleaseReserveAccess( KDefaultDrive ); - } - } - - CleanupStack::PopAndDestroy( &db ); - CleanupStack::PopAndDestroy( &dbs );*/ + iNotepadWrapper->DeleteAllL(); } //---------------------------------------------------------------------------- diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_notepadwrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/creator/engine/src/creator_notepadwrapper.cpp Tue Jul 06 14:17:03 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 "creator_notepadwrapper.h" + + /** + * Constructor + */ +CCreatorNotepadWrapper::CCreatorNotepadWrapper() + { + } + + /** + * Destructor + */ +CCreatorNotepadWrapper::~CCreatorNotepadWrapper() + { +/* + if(iNotepadApi) + { + delete iNotepadApi; + iNotepadApi = NULL; + } + */ + if(iAgendaUtil) + { + delete iAgendaUtil; + iAgendaUtil = NULL; + } + } + + /** + * Two-Phased constructor + */ +CCreatorNotepadWrapper* CCreatorNotepadWrapper::NewL() + { + CCreatorNotepadWrapper* self = CCreatorNotepadWrapper::NewLC(); + CleanupStack::Pop(self); + return self; + } + + /** + * Two-Phased constructor + */ +CCreatorNotepadWrapper* CCreatorNotepadWrapper::NewLC() + { + CCreatorNotepadWrapper* self = new (ELeave) CCreatorNotepadWrapper; + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + + /** + * ConstructL() + */ + +void CCreatorNotepadWrapper::ConstructL() + { + iAgendaUtil = new AgendaUtil(); +// iNotepadApi = new NotesEditor(iAgendaUtil); + } + +TInt CCreatorNotepadWrapper::CreateNoteL( const TDesC& aText ) + { + TInt err = KErrNone; + QString textNote = QString::fromUtf16( aText.Ptr(),aText.Length()); + iNotepadApi->edit(textNote,iAgendaUtil); + iNotepadApi->close(NotesEditorInterface::CloseWithSave, iAgendaUtil); + return err; + } +void CCreatorNotepadWrapper::DeleteAllL() + { + + QList ael; + AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(AgendaUtil::IncludeNotes); + + ael = iAgendaUtil->fetchAllEntries(filter); + for(int i=0 ; ideleteEntry(ael[i].id()); + } + + } + diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_phonebook.cpp --- a/creator/engine/src/creator_phonebook.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/src/creator_phonebook.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -20,102 +20,136 @@ #include "enginewrapper.h" #include "creator_contactsetcache.h" -#include "creator_phonebook.h" +#include "creator_phonebook.h" #include "creator_traces.h" #include -//#include -//#include _LIT(KTempPath, "C:\\Data\\Creator\\"); typedef struct { -QString iDetail; -QString iFieldContext; -QString iFieldString; +TInt iFieldCode; TInt iRandomType; } DetailFieldInfo; static const TInt RND_TYPE_UNDEF = -99; DetailFieldInfo CreatorPbkMiscTextFields[] = { - { (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldFirstName).operator QString(), (TInt) CCreatorEngine::EFirstName}, - { (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldLastName).operator QString(), (TInt) CCreatorEngine::ESurname}, - { (QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldName).operator QString(), (TInt) CCreatorEngine::ECompany}, - { (QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldTitle).operator QString(), (TInt) CCreatorEngine::EJobTitle}, - { (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldPrefix).operator QString(), (TInt) CCreatorEngine::EPrefix}, - { (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldSuffix).operator QString(), (TInt) CCreatorEngine::ESuffix}, - { (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldMiddleName).operator QString(), (TInt) CCreatorEngine::EFirstName}, - { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldStreet).operator QString(), (TInt) CCreatorEngine::EAddress}, - { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldLocality).operator QString(), (TInt) CCreatorEngine::ECity}, - { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldRegion).operator QString(), (TInt) CCreatorEngine::EState}, - { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldPostcode).operator QString(), (TInt) CCreatorEngine::EPostcode}, - { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldCountry).operator QString(), (TInt) CCreatorEngine::ECountry}, - { (QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldStreet).operator QString(), (TInt) CCreatorEngine::EAddress}, - { (QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldLocality).operator QString(), (TInt) CCreatorEngine::ECity}, - { (QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldRegion).operator QString(), (TInt) CCreatorEngine::EState}, - { (QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldPostcode).operator QString(), (TInt) CCreatorEngine::EPostcode}, - { (QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldCountry).operator QString(), (TInt) CCreatorEngine::ECountry}, - { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldStreet).operator QString(), (TInt) CCreatorEngine::EAddress}, - { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldLocality).operator QString(), (TInt) CCreatorEngine::ECity}, - { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldRegion).operator QString(), (TInt) CCreatorEngine::EState}, - { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldPostcode).operator QString(), (TInt) CCreatorEngine::EPostcode}, - { (QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldCountry).operator QString(), (TInt) CCreatorEngine::ECountry}, - { (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactPhoneNumber::SubTypeMobile).operator QString(), (TInt) CCreatorEngine::EPhoneNumber}, - { (QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactPhoneNumber::SubTypeLandline).operator QString(), (TInt) CCreatorEngine::EPhoneNumber}, - { (QContactNote::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactNote::FieldNote).operator QString(), (TInt) CCreatorEngine::EMemoText}, - { (QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldDepartment).operator QString(), (TInt) CCreatorEngine::ECompany}, - { (QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldAssistantName).operator QString(), (TInt) CCreatorEngine::ECompany}, - { (QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactFamily::FieldSpouse).operator QString(), (TInt) CCreatorEngine::EFirstName}, - { (QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactFamily::FieldChildren).operator QString(), (TInt) CCreatorEngine::EFirstName}, - { (QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldCustomLabel).operator QString(), (TInt) CCreatorEngine::EFirstName} + {CCreatorPhonebookWrapper::EFirstName, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::EFirstNameReading, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::ELastName, (TInt) CCreatorEngine::ESurname}, + {CCreatorPhonebookWrapper::ELastNameReading, (TInt) CCreatorEngine::ESurname}, + {CCreatorPhonebookWrapper::ECompanyName, (TInt) CCreatorEngine::ECompany}, + {CCreatorPhonebookWrapper::EJobTitle, (TInt) CCreatorEngine::EJobTitle}, + {CCreatorPhonebookWrapper::EPrefix, (TInt) CCreatorEngine::EPrefix}, + {CCreatorPhonebookWrapper::ESuffix, (TInt) CCreatorEngine::ESuffix}, + {CCreatorPhonebookWrapper::ESecondName, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::EAddrLabelGen, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrPoGen, (TInt) CCreatorEngine::EPobox}, + {CCreatorPhonebookWrapper::EAddrExtGen, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrStreetGen, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrLocalGen, (TInt) CCreatorEngine::ECity}, + {CCreatorPhonebookWrapper::EAddrRegionGen, (TInt) CCreatorEngine::EState}, + {CCreatorPhonebookWrapper::EAddrPostCodeGen, (TInt) CCreatorEngine::EPostcode}, + {CCreatorPhonebookWrapper::EAddrCountryGen, (TInt) CCreatorEngine::ECountry}, + {CCreatorPhonebookWrapper::EAddrLabelHome, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrPoHome, (TInt) CCreatorEngine::EPobox}, + {CCreatorPhonebookWrapper::EAddrExtHome, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrStreetHome, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrLocalHome, (TInt) CCreatorEngine::ECity}, + {CCreatorPhonebookWrapper::EAddrRegionHome, (TInt) CCreatorEngine::EState}, + {CCreatorPhonebookWrapper::EAddrPostCodeHome, (TInt) CCreatorEngine::EPostcode}, + {CCreatorPhonebookWrapper::EAddrCountryHome, (TInt) CCreatorEngine::ECountry}, + {CCreatorPhonebookWrapper::EAddrLabelWork, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrPoWork, (TInt) CCreatorEngine::EPobox}, + {CCreatorPhonebookWrapper::EAddrExtWork, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrStreetWork, (TInt) CCreatorEngine::EAddress}, + {CCreatorPhonebookWrapper::EAddrLocalWork, (TInt) CCreatorEngine::ECity}, + {CCreatorPhonebookWrapper::EAddrRegionWork, (TInt) CCreatorEngine::EState}, + {CCreatorPhonebookWrapper::EAddrPostCodeWork, (TInt) CCreatorEngine::EPostcode}, + {CCreatorPhonebookWrapper::EAddrCountryWork, (TInt) CCreatorEngine::ECountry}, + {CCreatorPhonebookWrapper::EPoc, (TInt) CCreatorEngine::EPhoneNumber}, + {CCreatorPhonebookWrapper::ESwis, (TInt) CCreatorEngine::EPhoneNumber}, + {CCreatorPhonebookWrapper::ESip, (TInt) CCreatorEngine::EPhoneNumber}, + {CCreatorPhonebookWrapper::EDtmfString, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::ENote,(TInt) CCreatorEngine::EMemoText}, + {CCreatorPhonebookWrapper::EMiddleName, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::EDepartment, (TInt) CCreatorEngine::ECompany}, + {CCreatorPhonebookWrapper::EAsstName, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::ESpouse, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::EChildren, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::ESyncClass, RND_TYPE_UNDEF}, + {CCreatorPhonebookWrapper::ELocPrivacy, RND_TYPE_UNDEF}, + {CCreatorPhonebookWrapper::EGenLabel, (TInt) CCreatorEngine::EFirstName}, + {CCreatorPhonebookWrapper::EWVAddress, (TInt) CCreatorEngine::EPhoneNumber}, + {CCreatorPhonebookWrapper::ERingTone, RND_TYPE_UNDEF}, + {CCreatorPhonebookWrapper::EThumbnailPic, RND_TYPE_UNDEF}, + {CCreatorPhonebookWrapper::ECallerObjText, (TInt) CCreatorEngine::EFirstName} }; -typedef struct{ -QString iFieldContext; -QString iFieldString; -}PhoneNumInfo; -PhoneNumInfo CreatorPhoneNumberFields[] = +TInt CreatorPbkBinaryFields[] = { + CCreatorPhonebookWrapper::ECallerObjImg//, + //R_VPBK_FIELD_TYPE_THUMBNAILPATH + }; + +TInt CreatorPbkDateTimeFields[] = { + CCreatorPhonebookWrapper::EAnniversary + }; + +//---------------------------------------------------------------------------- +TInt CreatorPbkPhoneNumberFields[] = { - { "", "Landline"}, - { "Home", "Landline"}, - { "Work", "Landline"}, - { "","Mobile"}, - { "Home","Mobile"}, - { "Work", "Mobile"}, - { "Home", "Facsimile"}, - { "Work", "Facsimile"}, - { "Work", "Pager"}, - { "Home", "Video"}, - { "Work", "Video"}, //{ "Home", "Voice" },//{ "Work", "Voice" }, - { "Work", "Assistant" }, - { "Home", "Car" } + CCreatorPhonebookWrapper::ELandPhoneGen, + CCreatorPhonebookWrapper::ELandPhoneHome, + CCreatorPhonebookWrapper::ELandPhoneWork, + CCreatorPhonebookWrapper::EMobilePhoneGen, + CCreatorPhonebookWrapper::EMobilePhoneHome, + CCreatorPhonebookWrapper::EMobilePhoneWork, + CCreatorPhonebookWrapper::EFaxNumberGen, + CCreatorPhonebookWrapper::EFaxNumberHome, + CCreatorPhonebookWrapper::EFaxNumberWork, + CCreatorPhonebookWrapper::EPagerNumber, + CCreatorPhonebookWrapper::EVideoNumberGen, + CCreatorPhonebookWrapper::EVideoNumberHome, + CCreatorPhonebookWrapper::EVideoNumberWork, + CCreatorPhonebookWrapper::EVoipGen, + CCreatorPhonebookWrapper::EVoipHome, + CCreatorPhonebookWrapper::EVoipWork, + CCreatorPhonebookWrapper::EAsstPhone, + CCreatorPhonebookWrapper::ECarPhone }; - -QString CreatorPbkEmailFields[] = +TInt CreatorPbkUrlFields[] = { - //R_VPBK_FIELD_TYPE_EMAILGEN, - (QContactDetail::ContextHome).operator QString(),//"Home",//R_VPBK_FIELD_TYPE_EMAILHOME, - (QContactDetail::ContextWork).operator QString()//R_VPBK_FIELD_TYPE_EMAILWORK + CCreatorPhonebookWrapper::EUrlGen, + CCreatorPhonebookWrapper::EUrlHome, + CCreatorPhonebookWrapper::EUrlWork }; +TInt CreatorPbkEmailFields[] = + { + CCreatorPhonebookWrapper::EEmailGen, + CCreatorPhonebookWrapper::EEmailHome, + CCreatorPhonebookWrapper::EEmailWork + }; CPhonebookParameters::CPhonebookParameters() { - LOGSTRING("Creator: CVirtualPhonebookParameters::CVirtualPhonebookParameters"); - //iGroupName = HBufC::New(KPhonebookFieldLength); + LOGSTRING("Creator: CPhonebookParameters::CVirtualPhonebookParameters"); + iGroupName = HBufC::New(KPhonebookFieldLength); } CPhonebookParameters::~CPhonebookParameters() { - LOGSTRING("Creator: CVirtualPhonebookParameters::~CVirtualPhonebookParameters"); + LOGSTRING("Creator: CPhonebookParameters::~CPhonebookParameters"); - //delete iGroupName; - //iContactFields.ResetAndDestroy(); - //iContactFields.Close(); - - //iLinkIds.clear(); + delete iGroupName; + for( TCreatorContactFields::iterator it = iContactFields.begin(); it != iContactFields.end(); ++it) + { + HBufC* temp = (*it).second; + iContactFields.erase(it); + delete temp; + } iLinkIds.Reset(); iLinkIds.Close(); } @@ -164,7 +198,7 @@ iEngine = aEngine; - iContactMngr = new QContactManager("symbian"); + iPhonebookWrapper = CCreatorPhonebookWrapper::NewL(); SetDefaultParameters(); } @@ -183,15 +217,16 @@ TRAP_IGNORE( StoreLinksForDeleteL( iContactGroupsToDelete, KUidDictionaryUidContactGroups ) ); } - if( iContactMngr ) + if( iPhonebookWrapper ) { - delete iContactMngr; + delete iPhonebookWrapper; } if (iParameters) { delete iParameters; } + } //---------------------------------------------------------------------------- @@ -202,7 +237,6 @@ delete iParameters; iParameters = 0; CPhonebookParameters* parameters = 0; - //InitializeContactParamsL(); if( aParameters == 0 ) { @@ -214,23 +248,13 @@ parameters = (CPhonebookParameters*) aParameters; } - bool success = false; + int numberOfFields = parameters->iContactFields.size(); // create a new contact item - QContact iStore; - int numberOfFields = parameters->iContactFields.count(); - QString phone; - for(int i=0; i< numberOfFields; i++ ) - { - QContactDetail* cntdet = new QContactDetail(parameters->iContactFields.at(i)); - success = iStore.saveDetail( cntdet ); - delete cntdet; - } + TUint32 contactId = iPhonebookWrapper->CreateContactEntryL( parameters->iContactFields ); //wrapper should return contact id to store + iContactsToDelete.Append( contactId ); - iContactMngr->saveContact( &iStore ); - - iContactsToDelete.Append( (TUint32)iStore.localId() ); - + // If this contact has a link id in script (i.e. belongs to a contact-set), we must cache the contact id: if( parameters->ScriptLinkId() > 0 ) { @@ -240,10 +264,10 @@ { if( contactsets[i]->LinkId() == parameters->ScriptLinkId() ) { - if( iStore.localId() ) + if( contactId ) { - contactsets[i]->AppendL( iStore.localId() ); - iContactLinkArray.AppendL( (TUint32)iStore.localId() ); + contactsets[i]->AppendL( contactId ); + iContactLinkArray.AppendL( contactId ); } setFound = ETrue; break; @@ -267,8 +291,7 @@ void CCreatorPhonebook::DeleteAllL() { - QList contacts = iContactMngr->contactIds(); - DeleteContactsL( contacts ); + iPhonebookWrapper->DeleteAllL(); } //---------------------------------------------------------------------------- @@ -282,19 +305,7 @@ void CCreatorPhonebook::DeleteAllGroupsL() { LOGSTRING("Creator: CCreatorPhonebook::DeleteAllGroupsL"); - - QList contacts = iContactMngr->contactIds(); - QList groups; - for(int i = 0; i < contacts.count(); i++) - { - QContact group = iContactMngr->contact( contacts.at(i) ); - if( group.type() == QContactType::TypeGroup ) - { - groups.append( group.localId() ); - } - } - DeleteContactsL( groups ); - + iPhonebookWrapper->DeleteAllGroupsL(); } //---------------------------------------------------------------------------- @@ -305,47 +316,44 @@ } //---------------------------------------------------------------------------- -void CCreatorPhonebook::DeleteContactsL( QList& aContacts /*MVPbkContactLinkArray* aContacts, TBool aGroup*/ ) +void CCreatorPhonebook::DeleteContactsL( RArray& aContactsToDelete, TUid aStoreUid ) { - //QList contacts = iContactMngr->contactIds(); - QMap errorMap; - iContactMngr->removeContacts( aContacts, &errorMap ); + iPhonebookWrapper->DeleteContactsL( aContactsToDelete, aStoreUid ); } //---------------------------------------------------------------------------- + + void CCreatorPhonebook::DeleteItemsCreatedWithCreatorL( TUid aStoreUid ) { CDictionaryFileStore* store = iEngine->FileStoreLC(); - User::LeaveIfNull( store ); - - QList contacts; - // backup previous contact links from store - // otherwise they would be overwritten when calling out.WriteL - TUint32 creatorLink; - if ( store->IsPresentL( aStoreUid ) ) - { - RDictionaryReadStream in; - in.OpenLC( *store, aStoreUid ); - TRAP_IGNORE( - do{ - creatorLink = in.ReadUint32L(); - QContact contact = iContactMngr->contact( creatorLink ); - if( (contact.type() == QContactType::TypeGroup && aStoreUid == KUidDictionaryUidContactGroups ) || (contact.type() != QContactType::TypeGroup && aStoreUid != KUidDictionaryUidContactGroups) ) - { - contacts.append( creatorLink ); - } - }while( creatorLink );) - - CleanupStack::PopAndDestroy(); // in - } - - - DeleteContactsL( contacts ); - - store->Remove( aStoreUid ); - store->CommitL(); - - CleanupStack::PopAndDestroy( store ); + User::LeaveIfNull( store ); + + RArray contacts; + // backup previous contact links from store + // otherwise they would be overwritten when calling out.WriteL + TUint32 creatorLink; + if ( store->IsPresentL( aStoreUid ) ) + { + RDictionaryReadStream in; + in.OpenLC( *store, aStoreUid ); + TRAP_IGNORE( + do{ + creatorLink = in.ReadUint32L(); + contacts.AppendL( creatorLink ); + }while( creatorLink ); + ); + + CleanupStack::PopAndDestroy(); // in + } + + + iPhonebookWrapper->DeleteContactsL( contacts, aStoreUid ); + + store->Remove( aStoreUid ); + store->CommitL(); + + CleanupStack::PopAndDestroy( store ); } //---------------------------------------------------------------------------- @@ -355,7 +363,7 @@ } //---------------------------------------------------------------------------- -TBool CCreatorPhonebook::HasOtherThanGroupsL( /*MVPbkContactLinkArray* aContacts */) +TBool CCreatorPhonebook::HasOtherThanGroupsL() { LOGSTRING("Creator: CCreatorPhonebook::HasOtherThanGroupsL"); TBool result( EFalse ); @@ -405,18 +413,14 @@ for ( TInt i = 0; i < iPreviousDeleteLinks.Count(); i++ ) { out.WriteUint32L( iPreviousDeleteLinks[i] ); - //CleanupStack::PopAndDestroy(); // PackLC } // write new links for(int i=0; i < aLinks.Count(); i++) { - //TUint32 localId = (TUint32) aLinks[i]; - //out.WriteUint32L( aLinks[i] ); out.WriteUint32L( aLinks[i] ); } out.CommitL(); - //CleanupStack::PopAndDestroy(); // aLinks.PackLC CleanupStack::PopAndDestroy(); // out store->CommitL(); @@ -425,10 +429,9 @@ } //---------------------------------------------------------------------------- - //---------------------------------------------------------------------------- -void CCreatorPhonebook::InitializeContactParamsL(/*CCreatorModuleBaseParameters* aParameters*/) +void CCreatorPhonebook::InitializeContactParamsL() { LOGSTRING("Creator: CCreatorPhonebook::InitializeContactParamsL"); @@ -438,166 +441,175 @@ iParameters->iNumberOfURLFields = iNumberOfURLFields; iParameters->iNumberOfEmailAddressFields = iNumberOfEmailAddressFields; - - QContactName name; - TPtrC fname = iEngine->RandomString(CCreatorEngine::EFirstName); TPtrC lname = iEngine->RandomString(CCreatorEngine::ESurname); - QString firstname = QString::fromUtf16( fname.Ptr(), fname.Length() ); - QString lastname = QString::fromUtf16( lname.Ptr(), lname.Length() ); - name.setFirstName(firstname); - name.setLastName(lastname); if( iAddAllFields ) { TInt textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) - { -// QContactDetail field = CreateContactDetail( CreatorPbkMiscTextFields[tfIndex].iDetail, CreatorPbkMiscTextFields[tfIndex].iFieldContext, CreatorPbkMiscTextFields[tfIndex].iFieldString, CreatorPbkMiscTextFields[tfIndex].iRandomType ); - - CCreatorContactField* field = CCreatorContactField::NewL(); - CleanupStack::PushL( field ); - QContactDetail cntDetail = field->CreateContactDetailL(iEngine,iParameters,CreatorPbkMiscTextFields[tfIndex].iDetail, CreatorPbkMiscTextFields[tfIndex].iFieldContext, CreatorPbkMiscTextFields[tfIndex].iFieldString, CreatorPbkMiscTextFields[tfIndex].iRandomType ); - if(!cntDetail.isEmpty()) - { - field->AddFieldToParam( iParameters, cntDetail ); //it will do "param->iContactFields.AppendL(field);" - } - CleanupStack::Pop( field ); - } + { + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL( iEngine,iParameters, CreatorPbkMiscTextFields[tfIndex].iFieldCode, CreatorPbkMiscTextFields[tfIndex].iRandomType ); + CleanupStack::Pop(field); + } + // Add binary fields: - TPtrC emptyData; - CCreatorContactField* fieldPicture = CCreatorContactField::NewL(); - CleanupStack::PushL( fieldPicture ); - QContactDetail cntDetail = fieldPicture->CreateContactDetailL(iEngine,iParameters,QContactAvatar::DefinitionName,"","",emptyData ); - if(!cntDetail.isEmpty()) - { - fieldPicture->AddFieldToParam( iParameters, cntDetail ); //it will do "param->iContactFields.AppendL(field);" - } - CleanupStack::Pop( fieldPicture ); + RFs& fs = CCoeEnv::Static()->FsSession(); + + TBuf srcPath; + iEngine->RandomPictureFileL(srcPath); + TBuf destPath(KTempPath); + + if(!BaflUtils::FolderExists( fs, destPath )) + { + BaflUtils::EnsurePathExistsL( fs, destPath ); + } + + TInt err=BaflUtils::CopyFile( fs, srcPath, destPath ); + + TParse temp; + temp.Set( srcPath,NULL,NULL ); + destPath.Append(temp.NameAndExt()); + TPtrC picture; + picture.Set(destPath); + CCreatorContactField* picturefield = CCreatorContactField::NewL(); + CleanupStack::PushL(picturefield); + picturefield->AddFieldToParamL( iParameters, CCreatorPhonebookWrapper::EThumbnailPic, picture ); + CleanupStack::Pop(picturefield); // Add date-time fields: + TPtrC anniv; + TBuf<20> timeString; + TTime datetime = iEngine->RandomDate( CCreatorEngine::EDateFuture ); + _LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3"); + TRAP_IGNORE( datetime.FormatL(timeString, KDateString) ); + + anniv.Set(timeString); + CCreatorContactField* fieldAnniv = CCreatorContactField::NewL(); CleanupStack::PushL( fieldAnniv ); - QContactDetail cntDetAnniv = fieldAnniv->CreateContactDetailL(iEngine,iParameters,QContactAnniversary::DefinitionName,"","",emptyData ); - if(!cntDetAnniv .isEmpty()) - { - fieldAnniv->AddFieldToParam( iParameters, cntDetAnniv ); //it will do "param->iContactFields.AppendL(field);" - } + fieldAnniv->AddFieldToParamL(iParameters,CCreatorPhonebookWrapper::EAnniversary, anniv ); CleanupStack::Pop( fieldAnniv ); - //*************************************************************************** } else - { - iParameters->iContactFields.append( name ); + { + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL( iParameters, CCreatorPhonebookWrapper::EFirstName, fname ); + field->AddFieldToParamL( iParameters, CCreatorPhonebookWrapper::ELastName, lname ); + CleanupStack::Pop(field); } // Phone numbers: - TInt phoneFieldCount = sizeof(CreatorPhoneNumberFields) / sizeof(PhoneNumInfo); + TInt phoneFieldCount = sizeof(CreatorPbkPhoneNumberFields) / sizeof(TInt); TInt inc=0; - for( int i=0; i= phoneFieldCount ) { inc = 0; } + + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL(iEngine, iParameters, CreatorPbkPhoneNumberFields[inc] ); + CleanupStack::Pop(field); - QContactPhoneNumber phoneNum; - TPtrC phoneNumber = iEngine->RandomString(CCreatorEngine::EPhoneNumber); - QString phone = QString::fromUtf16( phoneNumber.Ptr(), phoneNumber.Length() ); - if(!CreatorPhoneNumberFields[inc].iFieldContext.isEmpty()) - { - phoneNum.setContexts(CreatorPhoneNumberFields[inc].iFieldContext); - } - phoneNum.setSubTypes(CreatorPhoneNumberFields[inc].iFieldString); - - - phoneNum.setNumber( phone ); - - iParameters->iContactFields.append( phoneNum ); inc++; } // URLs: - for( int i=0; iCreateContactDetailL(iEngine,iParameters,QContactUrl::DefinitionName,"","",KErrNotFound ); - if(!cntDetUrl.isEmpty()) - { - fieldUrl->AddFieldToParam( iParameters, cntDetUrl ); //it will do "param->iContactFields.AppendL(field);" - } - CleanupStack::Pop( fieldUrl ); - + + if(inc >= urlFieldCount ) + { + inc = 0; + } + + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL(iEngine, iParameters, CreatorPbkUrlFields[inc] ); + CleanupStack::Pop(field); + inc++; } // EMail addresses: + TInt emailFieldCount = sizeof(CreatorPbkEmailFields) / sizeof(TInt); + inc = 0; for( int i=0; i= emailFieldCount ) + { + inc = 0; + } + CCreatorContactField* field = CCreatorContactField::NewL(); + CleanupStack::PushL(field); + field->AddFieldToParamL(iEngine, iParameters, CreatorPbkEmailFields[inc] ); + CleanupStack::Pop(field); + inc++; + } + + TestPrintOut(iParameters); + + } + +void CCreatorPhonebook::TestPrintOut(CPhonebookParameters* aParam) + { + LOGSTRING("Creator: CCreatorPhonebook::TestPrintOut"); + for( TCreatorContactFields::iterator it = aParam->iContactFields.begin(); it != aParam->iContactFields.end(); ++it) + { + HBufC* temp = (*it).second; + if(temp) { - CCreatorContactField* fieldEmail = CCreatorContactField::NewL(); - CleanupStack::PushL( fieldEmail ); - QContactDetail cntDetEmail = fieldEmail->CreateContactDetailL(iEngine,iParameters,QContactEmailAddress::DefinitionName,"","",KErrNotFound ); - if(!cntDetEmail.isEmpty()) - { - fieldEmail->AddFieldToParam( iParameters, cntDetEmail ); //it will do "param->iContactFields.AppendL(field);" - } - CleanupStack::Pop( fieldEmail ); + LOGSTRING3("Type: %d Content:%S ", (*it).first, &temp->Des() ); } - + } } - - // Checks if the link is a group or not -TBool CCreatorPhonebook::IsContactGroupL( QContactLocalId& aLink ) +TBool CCreatorPhonebook::IsContactGroupL( TUint32& aLink ) { - QContact group = iContactMngr->contact( aLink ); - if( group.type() == QContactType::TypeGroup ) - { - return ETrue; - } + //not used right now return EFalse; } + TInt CCreatorPhonebook::CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters) { - LOGSTRING("Creator: CCreatorVirtualPhonebook::CreateGroupEntryL"); + LOGSTRING("Creator: CCreatorPhonebook::CreateGroupEntryL"); + TInt err = KErrNone; + delete iParameters; iParameters = 0; CPhonebookParameters* parameters = (CPhonebookParameters*) aParameters; if( !parameters ) - { - iParameters = new (ELeave) CPhonebookParameters; - iParameters->iContactsInGroup = iContactsInGroup; - TPtrC gname = iEngine->RandomString(CCreatorEngine::EGroupName); - iParameters->iGroupName = QString::fromUtf16( gname.Ptr(),gname.Length() ); - iParameters->iGroupName += " #"; - int rnd = iEngine->RandomNumber(1000, 9999); - iParameters->iGroupName += QString::number( rnd, 10 ); - parameters = iParameters; - } - - TInt err = KErrNone; - + { + iParameters = new (ELeave) CPhonebookParameters; + iParameters->iContactsInGroup = iContactsInGroup; + iParameters->iGroupName->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) ); + iParameters->iGroupName->Des().Append( _L(" #") ); + iParameters->iGroupName->Des().AppendNum( iEngine->RandomNumber(1000, 9999) ); + parameters = iParameters; + } + // create a new contact group - QContact newGroup; - newGroup.setType(QContactType::TypeGroup); - QContactName newGroupName; - newGroupName.setCustomLabel( parameters->iGroupName ); - newGroup.saveDetail(&newGroupName); - iContactMngr->saveContact(&newGroup); - QContactLocalId newGroupId = newGroup.localId(); - - + + TUint32 newGroupId = iPhonebookWrapper->CreateGroupEntryL( parameters->iGroupName ); + // define amounts of contacts to be added to the group TInt amountOfContactsToBeAdded = 0; if (parameters->iContactsInGroup == KCreateRandomAmountOfGroups) @@ -615,7 +627,7 @@ { const CCreatorContactSet& set = ContactLinkCache::Instance()->ContactSet(parameters->iLinkIds[i].iLinkId); - const RArray links = set.ContactLinks();//ContactLinkCache::Instance()->ContactSets();//set.ContactLinks(); + const RArray links = set.ContactLinks();//ContactLinkCache::Instance()->ContactSets();//set.ContactLinks(); TInt numberOfExplicitLinks = links.Count(); // Number of defined contacts in contact-set TInt numberOfExistingContacts = set.NumberOfExistingContacts(); // Number of existing contacts in contact-set TInt maxAmount = numberOfExplicitLinks + numberOfExistingContacts; @@ -627,22 +639,9 @@ for( TInt j = 0; j < links.Count() && addedMembers < maxAmount; ++j ) { - QContactLocalId link = links[j]; - QContact contactLink = iContactMngr->contact( link ); - if( link && IsContactGroupL( link ) == EFalse ) - { - //QList relationships = contactLink.relationships(QContactRelationship::HasMember); - if(/*!relationships.count() && */contactLink.type() == QContactType::TypeContact ) //just for contacts that are not in relationship - not in group yet - { - QContactRelationship* contactRel = new QContactRelationship(); - contactRel->setRelationshipType(QContactRelationship::HasMember); - contactRel->setFirst(newGroup.id()); - contactRel->setSecond( contactLink.id() ); - iContactMngr->saveRelationship( contactRel ); - delete contactRel; - ++addedMembers; - } - } + + addedMembers += iPhonebookWrapper->AddContactToGroup(newGroupId,links[j]); + } if( addedMembers < maxAmount ) { @@ -653,46 +652,13 @@ } if( amountOfContactsToBeAdded > 0 ) { - QList contacts = iContactMngr->contactIds(); - QContactRelationshipFilter rFilter; - rFilter.setRelationshipType(QContactRelationship::HasMember); - rFilter.setRelatedContactRole(QContactRelationshipFilter::First); - rFilter.setRelatedContactId( newGroup.id() ); - - int cnt = 0; - for(int i=0; cnt < amountOfContactsToBeAdded && i < contacts.count() ; i++ ) - { - QContact contact = iContactMngr->contact( iContactMngr->contactIds().at(i) ); - if( iContactMngr->error() == QContactManager::DoesNotExistError ) - { - - } - else - { - QList relationships = contact.relationships(QContactRelationship::HasMember); - if(!relationships.count() && contact.type() == QContactType::TypeContact ) //just for contacts that are not in relationship - not in group yet - { - QContactRelationship* contactRel = new QContactRelationship(); - contactRel->setRelationshipType(QContactRelationship::HasMember); - contactRel->setFirst(newGroup.id()); - contactRel->setSecond(contact.id()); - iContactMngr->saveRelationship( contactRel ); - delete contactRel; - cnt++; - } - } - } - - // group members and their count - QList groupMemberIds = iContactMngr->contactIds( rFilter ); - int testcnt = groupMemberIds.count(); - - + TInt addedContacts = iPhonebookWrapper->AddToGroup(newGroupId, amountOfContactsToBeAdded); + } // store the link to contact, so that Creator is able to delete // it when user requests deletion of contacts that were created with Creator - iContactGroupsToDelete.Append( (TUint32)newGroupId ); + iContactGroupsToDelete.Append( newGroupId ); return err; } @@ -725,369 +691,79 @@ } void CCreatorContactField::ConstructL() { - //pImpl = CCreatorContactTextField::NewL(aFieldType, aData); - } -QContactDetail CCreatorContactField::CreateContactDetailL(CCreatorEngine* aEngine,CPhonebookParameters* aParameters,QString aDetail, QString aFieldContext, QString aFieldString, TInt aRand ) - { - QContactDetail emptyDet; - TPtrC contentData; - HBufC16* tempData = 0; - if(aRand == KErrNotFound) - { - TInt textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); - for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) - { - if( CreatorPbkMiscTextFields[tfIndex].iDetail == aDetail && CreatorPbkMiscTextFields[tfIndex].iFieldContext == aFieldContext && CreatorPbkMiscTextFields[tfIndex].iFieldString == aFieldString) - { - aRand = CreatorPbkMiscTextFields[tfIndex].iRandomType; - } - } - } - - if( aRand != KErrNotFound ) - { - contentData.Set(aEngine->RandomString((CCreatorEngine::TRandomStringType) aRand)); - } - else - { - if( aDetail == QContactPhoneNumber::DefinitionName ) - { - contentData.Set(aEngine->RandomString(CCreatorEngine::EPhoneNumber)); - } - else if( aDetail == QContactEmailAddress::DefinitionName ) - { - tempData = aEngine->CreateEmailAddressLC(); - contentData.Set( tempData->Des() ); - } - else if( aDetail == QContactUrl::DefinitionName ) - { - tempData = aEngine->CreateHTTPUrlLC(); - contentData.Set( tempData->Des() ); - } - else - { - return emptyDet; - } - } - emptyDet = CreateContactDetailL( aEngine, aParameters, aDetail, aFieldContext, aFieldString, contentData ); - if( tempData ) - { - CleanupStack::PopAndDestroy( tempData ); - } - return emptyDet; } -QContactDetail CCreatorContactField::CreateContactDetailL(CCreatorEngine* aEngine,CPhonebookParameters* aParameters,QString aDetail, QString aFieldContext, QString aFieldString, TPtrC aData ) + +void CCreatorContactField::AddFieldToParamL( CCreatorEngine* aEngine, CPhonebookParameters* aParam, TInt aType, TInt aRand ) { - QContactDetail contactDetail; - - if( aDetail == QContactPhoneNumber::DefinitionName) - { - QContactPhoneNumber phoneNumber;// = contactDetail; - if(!aFieldContext.isEmpty()) - { - phoneNumber.setContexts(aFieldContext); - } - phoneNumber.setSubTypes(aFieldString); - QString number = QString::fromUtf16(aData.Ptr(),aData.Length()); - phoneNumber.setNumber(number); - return phoneNumber; - } - else if( aDetail == QContactName::DefinitionName ) //--Contact NAME----------------------------- + HBufC* content = NULL; + if( aRand == KErrNotFound ) + { + TInt textFieldCount = sizeof(CreatorPbkPhoneNumberFields)/sizeof(TInt);; + for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) { - QContactName contactName; - for(int i = 0 ; i < aParameters->iContactFields.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details - { - if(aParameters->iContactFields.at(i).definitionName() == QContactName::DefinitionName ) - { - contactName = aParameters->iContactFields.at(i); - } - } - QString name = QString::fromUtf16(aData.Ptr(),aData.Length()); - if(aFieldString == QContactName::FieldFirstName) - { - if(contactName.firstName().isEmpty()) - { - contactName.setFirstName( name ); - } - } - else if(aFieldString == QContactName::FieldLastName) - { - if(contactName.lastName().isEmpty()) - { - contactName.setLastName( name ); - } - } - else if(aFieldString == QContactName::FieldMiddleName) - { - if(contactName.middleName().isEmpty()) - { - contactName.setMiddleName( name ); - } - } - else if(aFieldString == QContactName::FieldPrefix) - { - if(contactName.prefix().isEmpty()) - { - contactName.setPrefix( name ); - } - } - else if(aFieldString == QContactName::FieldSuffix) + if( CreatorPbkPhoneNumberFields[tfIndex] == aType ) { - if(contactName.suffix().isEmpty()) - { - contactName.setSuffix( name ); - } + content = aEngine->RandomString(CCreatorEngine::EPhoneNumber).AllocL(); + break; } - else //QContactName::FieldCustomLabel: - { - if(contactName.customLabel().isEmpty()) - { - contactName.setCustomLabel( name ); - } - } - return contactName; } - else if( aDetail == QContactOrganization::DefinitionName ) //--Contact Company----------------------------- + + textFieldCount = sizeof(CreatorPbkUrlFields)/sizeof(TInt);; + for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) { - QContactOrganization contactCompany; - - for(int i = 0 ; i < aParameters->iContactFields.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details - { - if(aParameters->iContactFields.at(i).definitionName() == QContactOrganization::DefinitionName ) - { - contactCompany = aParameters->iContactFields.at(i); - } - } - - QString company = QString::fromUtf16(aData.Ptr(),aData.Length()); - if(aFieldString == QContactOrganization::FieldName) + if( CreatorPbkUrlFields[tfIndex] == aType ) { - if(contactCompany.name().isEmpty()) - { - contactCompany.setName( company ); - } - } - if(aFieldString == QContactOrganization::FieldTitle) - { - if(contactCompany.title().isEmpty()) - { - contactCompany.setTitle( company ); - } + content = aEngine->CreateHTTPUrlLC(); + CleanupStack::Pop(); + break; } - if(aFieldString == QContactOrganization::FieldDepartment) - { - QStringList depList = contactCompany.department(); - depList.append(company); - contactCompany.setDepartment(depList); - } - if(aFieldString == QContactOrganization::FieldAssistantName) - { - if(contactCompany.assistantName().isEmpty()) - { - contactCompany.setAssistantName( company ); - } - } - return contactCompany; } - else if( aDetail == QContactAddress::DefinitionName ) //--Contact Address----------------------------- + textFieldCount = sizeof(CreatorPbkEmailFields)/sizeof(TInt);; + for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) + { + if( CreatorPbkEmailFields[tfIndex] == aType ) { - QContactAddress contactAddress; - - for(int i = 0 ; i < aParameters->iContactFields.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details - { - if(aParameters->iContactFields.at(i).definitionName() == QContactAddress::DefinitionName && aParameters->iContactFields.at(i).value(QContactDetail::FieldContext) == aFieldContext ) - { - contactAddress = aParameters->iContactFields.at(i); - } - } - if( !aFieldContext.isEmpty() ) - { - contactAddress.setContexts( aFieldContext ); - } - QString address = QString::fromUtf16(aData.Ptr(),aData.Length()); - if(aFieldString == QContactAddress::FieldStreet ) - { - if( contactAddress.street().isEmpty() ) - { - contactAddress.setStreet( address ); - } - } - else if(aFieldString == QContactAddress::FieldLocality ) - { - if( contactAddress.locality().isEmpty() ) - { - contactAddress.setLocality( address ); - } - } - else if(aFieldString == QContactAddress::FieldRegion ) - { - if( contactAddress.region().isEmpty() ) - { - contactAddress.setRegion( address ); - } - } - else if(aFieldString == QContactAddress::FieldPostcode ) - { - if( contactAddress.postcode().isEmpty() ) - { - contactAddress.setPostcode( address ); - } - } - else if(aFieldString == QContactAddress::FieldCountry ) - { - if( contactAddress.country().isEmpty() ) - { - contactAddress.setCountry( address ); - } - } - else - { - return contactDetail; - } - return contactAddress; + content = aEngine->CreateEmailAddressLC(); + CleanupStack::Pop(); + break; } - else if( aDetail == QContactNote::DefinitionName ) //--Contact Note----------------------------- - { - QContactNote contactNote; - QString note = QString::fromUtf16(aData.Ptr(),aData.Length()); - contactNote.setNote(note); - return contactNote; - } - else if( aDetail == QContactFamily::DefinitionName ) //--Contact Family----------------------------- - { - QContactFamily contactFamily; - - for(int i = 0 ; i < aParameters->iContactFields.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details - { - if(aParameters->iContactFields.at(i).definitionName() == QContactFamily::DefinitionName && aParameters->iContactFields.at(i).value(QContactDetail::FieldContext) == aFieldContext ) - { - contactFamily = aParameters->iContactFields.at(i); - } - } - - QString familyData = QString::fromUtf16(aData.Ptr(),aData.Length()); - if(aFieldString == QContactFamily::FieldSpouse ) - { - if( contactFamily.spouse().isEmpty() ) - { - contactFamily.setSpouse( familyData ); - } - } - if(aFieldString == QContactFamily::FieldChildren ) - { - QStringList children = contactFamily.children(); - children.append( familyData ); - contactFamily.setChildren( children ); - } - - return contactFamily; - } + } - if( aDetail == QContactAvatar::DefinitionName) //--Contact Picture----------------------------- - { - RFs& fs = CCoeEnv::Static()->FsSession(); - QContactAvatar contactAvatar; - TBuf srcPath; - aEngine->RandomPictureFileL(srcPath); - TBuf destPath(KTempPath); - - if(!BaflUtils::FolderExists( fs, destPath )) - { - BaflUtils::EnsurePathExistsL( fs, destPath ); - } - - TInt err=BaflUtils::CopyFile( fs, srcPath, destPath ); + + //if there is textfield without specified random number + textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); + for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) + { + if( CreatorPbkMiscTextFields[tfIndex].iFieldCode == aType && CreatorPbkMiscTextFields[tfIndex].iRandomType != RND_TYPE_UNDEF ) + { + TInt rand = CreatorPbkMiscTextFields[tfIndex].iRandomType; + content = aEngine->RandomString((CCreatorEngine::TRandomStringType) rand).AllocL(); + break; + } + } + } - TParse temp; - temp.Set( srcPath,NULL,NULL ); - destPath.Append(temp.NameAndExt()); - - QString avatarFile = QString::fromUtf16( destPath.Ptr(),destPath.Length() ); - - //QPixmap avatarPix(avatarFile); - - QUrl imageUrl; - imageUrl.setUrl(avatarFile); - contactAvatar.setImageUrl(imageUrl); - //contactAvatar.setAvatar(avatarFile); //deprecated - //contactAvatar.setPixmap(avatarPix); - - return contactAvatar; - } - if( aDetail == QContactAnniversary::DefinitionName) //--Anniversary------------------------------ - { - QContactAnniversary contactAnniversary; - QDate date; - TTime datetime = aEngine->RandomDate( CCreatorEngine::EDateFuture ); - date.setDate( datetime.DateTime().Year(),(int) (datetime.DateTime().Month()+1), datetime.DateTime().Day() ); - contactAnniversary.setOriginalDate( date ); - return contactAnniversary; - } - if( aDetail == QContactEmailAddress::DefinitionName) //--Email------------------------------------ + if( aRand != KErrNotFound && aRand != RND_TYPE_UNDEF ) + { + TInt textFieldCount = sizeof(CreatorPbkMiscTextFields) / sizeof(DetailFieldInfo); + for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) { - QContactEmailAddress email; - QString emailAddr = QString::fromUtf16(aData.Ptr(),aData.Length()); - if( !aFieldContext.isEmpty() ) - { - email.setContexts( aFieldContext ); - } - email.setEmailAddress( emailAddr ); - return email; - } - if( aDetail == QContactUrl::DefinitionName ) //--Url------------------------------------------- - { - QContactUrl url; - QString urlStr = QString::fromUtf16(aData.Ptr(),aData.Length()); - if( !aFieldContext.isEmpty() ) + if( CreatorPbkMiscTextFields[tfIndex].iFieldCode == aType ) { - url.setContexts( aFieldContext ); + content = aEngine->RandomString((CCreatorEngine::TRandomStringType) aRand).AllocL(); } - url.setUrl(urlStr); - return url; } - if( aDetail == QContactBirthday::DefinitionName ) //--Birthday----------------------------------- - { - QContactBirthday birthday; - QDate date; - TTime datetime = aEngine->RandomDate( CCreatorEngine::EDatePast ); - date.setDate( datetime.DateTime().Year(),(int) (datetime.DateTime().Month()+1), datetime.DateTime().Day() ); - birthday.setDate( date ); - return birthday; - } - - return contactDetail; + } + + aParam->iContactFields.insert( TCreatorContactField(aType, content) ); + } + +void CCreatorContactField::AddFieldToParamL( CPhonebookParameters* aParam, TInt aType, TPtrC aContent ) + { + aParam->iContactFields.insert( TCreatorContactField(aType, aContent.AllocL()) ); } -void CCreatorContactField::AddFieldToParam( CPhonebookParameters* aParam, QContactDetail aDetail) - { - bool replace = false; - for(int i = 0 ; i< aParam->iContactFields.count() ; i++) //go through - { - if( !aDetail.isEmpty() && aDetail.definitionName() == aParam->iContactFields.at(i).definitionName() - && aDetail.definitionName() != QContactPhoneNumber::DefinitionName - && aDetail.definitionName() != QContactEmailAddress::DefinitionName - && aDetail.definitionName() != QContactUrl::DefinitionName ) - { - QString context = aDetail.value(QContactDetail::FieldContext); - bool isContextEmpty = context.isEmpty(); - if( isContextEmpty || ( aDetail.value(QContactDetail::FieldContext) == aParam->iContactFields.at(i).value(QContactDetail::FieldContext)) ) - { - //replace - aParam->iContactFields.replace(i,aDetail); - replace = true; - } - } - } - if(!replace) - { - if(!aDetail.isEmpty()) - { - aParam->iContactFields.append(aDetail); - } - } - - } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_phonebookapi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/creator/engine/src/creator_phonebookapi.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,161 @@ +/* +* 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 "creator_phonebookapi.h" + +CCreatorPhonebookAPI::CCreatorPhonebookAPI () + { + mContactMngr = new QContactManager("symbian"); + } + +CCreatorPhonebookAPI::~CCreatorPhonebookAPI () + { + if( mContactMngr ) + { + delete mContactMngr; + mContactMngr = NULL; + } + } + +quint32 CCreatorPhonebookAPI::saveContact( const QList& list ) + { + // create a new contact item + QContact store; + quint32 id; + bool success = false; + for(int i = 0 ; i < list.count() ; i++ ) + { + QContactDetail cntdetail = list.at(i); + success = store.saveDetail(&cntdetail); + } + /*foreach( QContactDetail cntdetail, list ) + { + success = store.saveDetail( &cntdetail ); + } + */ + success = mContactMngr->saveContact( &store ); + id = store.localId(); + return id; + } + +quint32 CCreatorPhonebookAPI::createGroup( const QString& groupName ) + { + QContact newGroup; + newGroup.setType(QContactType::TypeGroup); + QContactName newGroupName; + newGroupName.setCustomLabel( groupName ); + newGroup.saveDetail(&newGroupName); + mContactMngr->saveContact(&newGroup); + return newGroup.localId(); + } + +int CCreatorPhonebookAPI::numberOfContacts() + { + QList contacts = mContactMngr->contactIds(); + return contacts.count(); + + } + +bool CCreatorPhonebookAPI::IsContactGroupL( const QContact& contact ) + { + + if( contact.type() == QContactType::TypeGroup ) + { + return true; + } + return false; + } + +int CCreatorPhonebookAPI::addContactToGroup( QContactLocalId group, QContactLocalId contact ) + { + QContact newGroup = mContactMngr->contact( group ); + QContact contactLink = mContactMngr->contact( contact ); + int ret = 0; + if( contact && IsContactGroupL( contactLink ) == false ) + { + QList relationships = contactLink.relationships(QContactRelationship::HasMember); + if( !relationships.count() && contactLink.type() == QContactType::TypeContact ) //just for contacts that are not in relationship - not in group yet + { + QContactRelationship* contactRel = new QContactRelationship(); + contactRel->setRelationshipType(QContactRelationship::HasMember); + contactRel->setFirst(newGroup.id()); + contactRel->setSecond( contactLink.id() ); + mContactMngr->saveRelationship( contactRel ); + delete contactRel; + ret++; + } + } + return ret; + } +int CCreatorPhonebookAPI::addToGroup(QContactLocalId group, int amount) + { + QList contacts = mContactMngr->contactIds(); + int ret = 0; + int tmp = 0; + int cnt = 0; + + for( int i=0; cnt < amount && i < contacts.count() ; i++ ) + { + QContact contact = mContactMngr->contact( mContactMngr->contactIds().at(i) ); + if( contact.type() == QContactType::TypeContact ) + { + tmp = addContactToGroup(group,mContactMngr->contactIds().at(i)); + ret += tmp; + if(tmp) + { + cnt++; + tmp = 0; + } + } + } + return ret; + } + + +bool CCreatorPhonebookAPI::deleteAllContacts() + { + QList all = mContactMngr->contactIds(); + return deleteContacts( all ); + } + +bool CCreatorPhonebookAPI::deleteAllContacts( const QString& type ) + { + QList contactsToDelete; + QList contacts = mContactMngr->contactIds(); + foreach(QContactLocalId contactId, contacts) + { + QContact contact = mContactMngr->contact( contactId ); + if( contact.type() == type ) + { + contactsToDelete.append( contact.localId() ); + } + } + return deleteContacts( contactsToDelete ); + } + + +bool CCreatorPhonebookAPI::deleteContacts( const QList& list ) + { + QMap errorMap; + return mContactMngr->removeContacts( list, &errorMap ); + } + +QContact CCreatorPhonebookAPI::contact( const QContactLocalId& contactId ) + { + return mContactMngr->contact( contactId ); + } +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_phonebookbase.cpp --- a/creator/engine/src/creator_phonebookbase.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/src/creator_phonebookbase.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -41,9 +41,16 @@ iEntriesToBeCreated = 1; break; case ECreatorPhonebookStart: - retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Fields in contact"), R_CONTACT_CREATION_TYPE_QUERY, - &iDummy, this, iCommand == ECmdCreatePhoneBookEntryContacts ? ECreatorPhonebookGetContactFields : ECreatorPhonebookGetGroupFields - ); + if(iCommand == ECmdCreatePhoneBookEntryContacts ) + { + retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Fields in contact"), R_CONTACT_CREATION_TYPE_QUERY, + &iDummy, this, ECreatorPhonebookGetContactFields ); + } + else + { + retval = iEngine->GetEngineWrapper()->ListQueryDialog(_L("Number of contacts "), R_GROUP_CREATION_TYPE_QUERY, + &iDummy, this, ECreatorPhonebookGetGroupFields ); + } break; case ECreatorPhonebookGetContactFields: if(iDummy==0)// first item, use default fields diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_phonebookwrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/creator/engine/src/creator_phonebookwrapper.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,654 @@ +/* +* 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 "engine.h" +#include "enginewrapper.h" +#include "creator_contactsetcache.h" + +#include "creator_phonebookwrapper.h" +#include "creator_traces.h" + +#include + +_LIT(KTempPath, "C:\\Data\\Creator\\"); + +typedef struct { +TInt iFieldCode; +QString iDetail; +QString iFieldContext; +QString iFieldString; +} QDetailFieldInfo; +//static const TInt RND_TYPE_UNDEF = -99; +QDetailFieldInfo CreatorPbkTextFields[] = { + { (TInt)CCreatorPhonebookWrapper::EFirstName,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldFirstName).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::ELastName,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldLastName).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::ECompanyName,(QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldName).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EJobTitle,(QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldTitle).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EPrefix,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldPrefix).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::ESuffix,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldSuffix).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EMiddleName,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldMiddleName).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrStreetHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldStreet).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrLocalHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldLocality).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrRegionHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldRegion).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrPostCodeHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldPostcode).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrCountryHome,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactAddress::FieldCountry).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrStreetGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldStreet).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrLocalGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldLocality).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrRegionGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldRegion).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrPostCodeGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldPostcode).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrCountryGen,(QContactAddress::DefinitionName).operator QString(), "", (QContactAddress::FieldCountry).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrStreetWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldStreet).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrLocalWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldLocality).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrRegionWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldRegion).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrPostCodeWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldPostcode).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAddrCountryWork,(QContactAddress::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactAddress::FieldCountry).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EMobilePhoneWork,(QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactPhoneNumber::SubTypeMobile).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::ELandPhoneWork,(QContactPhoneNumber::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactPhoneNumber::SubTypeLandline).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::ENote,(QContactNote::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactNote::FieldNote).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EDepartment,(QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldDepartment).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EAsstName,(QContactOrganization::DefinitionName).operator QString(), (QContactDetail::ContextWork).operator QString(), (QContactOrganization::FieldAssistantName).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::ESpouse,(QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactFamily::FieldSpouse).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EChildren,(QContactFamily::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactFamily::FieldChildren).operator QString()}, + { (TInt)CCreatorPhonebookWrapper::EGenLabel,(QContactName::DefinitionName).operator QString(), (QContactDetail::ContextHome).operator QString(), (QContactName::FieldCustomLabel).operator QString()} + }; + + +typedef struct{ +TInt iFieldCode; +QString iFieldContext; +QString iFieldString; +}PhoneNumInfo; +PhoneNumInfo CreatorPhoneNumberFields[] = + { + { CCreatorPhonebookWrapper::ELandPhoneGen,"", "Landline"}, + { CCreatorPhonebookWrapper::ELandPhoneHome,"Home", "Landline"}, + { CCreatorPhonebookWrapper::ELandPhoneWork,"Work", "Landline"}, + { CCreatorPhonebookWrapper::EMobilePhoneGen,"","Mobile"}, + { CCreatorPhonebookWrapper::EMobilePhoneHome,"Home","Mobile"}, + { CCreatorPhonebookWrapper::EMobilePhoneWork,"Work", "Mobile"}, + { CCreatorPhonebookWrapper::EFaxNumberGen, "", "Facsimile"}, + { CCreatorPhonebookWrapper::EFaxNumberHome, "Home", "Facsimile"}, + { CCreatorPhonebookWrapper::EFaxNumberWork, "Work", "Facsimile"}, + { CCreatorPhonebookWrapper::EPagerNumber, "Work", "Pager"}, + { CCreatorPhonebookWrapper::EVideoNumberGen, "", "Video"}, + { CCreatorPhonebookWrapper::EVideoNumberHome, "Home", "Video"}, + { CCreatorPhonebookWrapper::EVideoNumberWork, "Work", "Video"}, //{ "Home", "Voice" },//{ "Work", "Voice" }, + { CCreatorPhonebookWrapper::EAsstPhone, "Work", "Assistant" }, + { CCreatorPhonebookWrapper::ECarPhone, "Home", "Car" } + }; + + +typedef struct{ + TInt iFieldCode; + QString iFieldContext; +}EmailInfo; +EmailInfo CreatorEmailFields[] = + { + {CCreatorPhonebookWrapper::EEmailGen,""}, + {CCreatorPhonebookWrapper::EEmailHome,(QContactDetail::ContextHome).operator QString()}, + {CCreatorPhonebookWrapper::EEmailWork,(QContactDetail::ContextWork).operator QString()} + }; + +typedef struct{ + TInt iFieldCode; + QString iFieldContext; +}UrlInfo; +UrlInfo CreatorUrlFields[] = + { + {CCreatorPhonebookWrapper::EUrlGen,""}, + {CCreatorPhonebookWrapper::EUrlHome,(QContactDetail::ContextHome).operator QString()}, + {CCreatorPhonebookWrapper::EUrlWork,(QContactDetail::ContextWork).operator QString()} + }; + +CCreatorPhonebookWrapper* CCreatorPhonebookWrapper::NewL() + { + CCreatorPhonebookWrapper* self = CCreatorPhonebookWrapper::NewLC(); + CleanupStack::Pop(self); + return self; + } + +CCreatorPhonebookWrapper* CCreatorPhonebookWrapper::NewLC() + { + CCreatorPhonebookWrapper* self = new (ELeave) CCreatorPhonebookWrapper(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + + +CCreatorPhonebookWrapper::CCreatorPhonebookWrapper() + { + } + +void CCreatorPhonebookWrapper::ConstructL() + { + LOGSTRING("Creator: CCreatorPhonebookWrapper::ConstructL"); + + QT_TRYCATCH_LEAVING( iPhonebookAPI = new CCreatorPhonebookAPI() ); + + } + + +CCreatorPhonebookWrapper::~CCreatorPhonebookWrapper() + { + LOGSTRING("Creator: CCreatorPhonebookWrapper::~CCreatorPhonebookWrapper"); + if( iPhonebookAPI ) + { + delete iPhonebookAPI; + iPhonebookAPI = NULL; + } + } + +//---------------------------------------------------------------------------- + +QList CCreatorPhonebookWrapper::CreateContactDetailsFromParameters( const TCreatorContactFields& aFields ) + { + QList contDetList; + QString content; + HBufC* temp; + TInt arraySize = sizeof(CreatorPbkTextFields)/sizeof(QDetailFieldInfo); + for (TInt i = 0; i < arraySize; i++) + { + TCreatorContactFields::const_iterator it = aFields.find(CreatorPbkTextFields[i].iFieldCode); + if( it != aFields.end() ) + { + temp = (*it).second; + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, CreatorPbkTextFields[i].iDetail,CreatorPbkTextFields[i].iFieldContext,CreatorPbkTextFields[i].iFieldString, content ); + AddFieldToList( contDetList, contactDetail ); + } + + } + arraySize = sizeof(CreatorPhoneNumberFields)/sizeof(PhoneNumInfo); + for (TInt i = 0; i < arraySize; i++) + { + TCreatorContactFields::const_iterator it = aFields.find(CreatorPhoneNumberFields[i].iFieldCode); + if( it != aFields.end() ) + { + temp = (*it).second; + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, QContactPhoneNumber::DefinitionName ,CreatorPhoneNumberFields[i].iFieldContext,CreatorPhoneNumberFields[i].iFieldString, content ); + AddFieldToList( contDetList, contactDetail ); + } + } + + arraySize = sizeof(CreatorEmailFields)/sizeof(EmailInfo); + for (TInt i = 0; i < arraySize; i++) + { + TCreatorContactFields::const_iterator it = aFields.find(CreatorEmailFields[i].iFieldCode); + if( it != aFields.end() ) + { + temp = (*it).second; + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, QContactEmailAddress::DefinitionName ,CreatorEmailFields[i].iFieldContext,"", content ); + AddFieldToList( contDetList, contactDetail ); + } + } + + arraySize = sizeof(CreatorUrlFields)/sizeof(UrlInfo); + for (TInt i = 0; i < arraySize; i++) + { + TCreatorContactFields::const_iterator it = aFields.find(CreatorUrlFields[i].iFieldCode); + if( it != aFields.end() ) + { + temp = (*it).second; + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, QContactUrl::DefinitionName ,CreatorUrlFields[i].iFieldContext,"", content ); + AddFieldToList( contDetList, contactDetail ); + } + } + arraySize = sizeof(CreatorUrlFields)/sizeof(UrlInfo); + for (TInt i = 0; i < arraySize; i++) + { + TCreatorContactFields::const_iterator it = aFields.find(CreatorUrlFields[i].iFieldCode); + if( it != aFields.end() ) + { + temp = (*it).second; + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, QContactUrl::DefinitionName ,CreatorUrlFields[i].iFieldContext,"", content ); + AddFieldToList( contDetList, contactDetail ); + } + } + + TCreatorContactFields::const_iterator it = aFields.find(CCreatorPhonebookWrapper::EThumbnailPic); + if( it != aFields.end() ) + { + temp = (*it).second; + if(temp) + { + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, QContactAvatar::DefinitionName ,"","", content ); + AddFieldToList( contDetList, contactDetail ); + } + } + it = aFields.find(CCreatorPhonebookWrapper::EAnniversary); + if( it != aFields.end() ) + { + temp = (*it).second; + if(temp) + { + content = QString::fromUtf16( temp->Des().Ptr(), temp->Length() ); + QContactDetail contactDetail = CreateContactDetail(contDetList, QContactAnniversary::DefinitionName ,"","", content ); + AddFieldToList( contDetList, contactDetail ); + } + } + + return contDetList; + } +QContactDetail CCreatorPhonebookWrapper::CreateContactDetail( QList& aContactDetailList,QString aDetail, QString aFieldContext, QString aFieldString, QString aData ) + { + QContactDetail contactDetail; + + if( aDetail == QContactPhoneNumber::DefinitionName) + { + QContactPhoneNumber phoneNumber;// = contactDetail; + if(!aFieldContext.isEmpty()) + { + phoneNumber.setContexts(aFieldContext); + } + phoneNumber.setSubTypes(aFieldString); + //QString number = QString::fromUtf16(aData.Ptr(),aData.Length()); + phoneNumber.setNumber(aData); + return phoneNumber; + } + else if( aDetail == QContactName::DefinitionName ) //--Contact NAME----------------------------- + { + QContactName contactName; + for(int i = 0 ; i < aContactDetailList.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details + { + if(aContactDetailList.at(i).definitionName() == QContactName::DefinitionName ) + { + contactName = aContactDetailList.at(i); + } + } + //QString name = QString::fromUtf16(aData.Ptr(),aData.Length()); + if(aFieldString == QContactName::FieldFirstName) + { + if(contactName.firstName().isEmpty()) + { + contactName.setFirstName( aData ); + } + } + else if(aFieldString == QContactName::FieldLastName) + { + if(contactName.lastName().isEmpty()) + { + contactName.setLastName( aData ); + } + } + else if(aFieldString == QContactName::FieldMiddleName) + { + if(contactName.middleName().isEmpty()) + { + contactName.setMiddleName( aData ); + } + } + else if(aFieldString == QContactName::FieldPrefix) + { + if(contactName.prefix().isEmpty()) + { + contactName.setPrefix( aData ); + } + } + else if(aFieldString == QContactName::FieldSuffix) + { + if(contactName.suffix().isEmpty()) + { + contactName.setSuffix( aData ); + } + } + else //QContactName::FieldCustomLabel: + { + if(contactName.customLabel().isEmpty()) + { + contactName.setCustomLabel( aData ); + } + } + return contactName; + } + else if( aDetail == QContactOrganization::DefinitionName ) //--Contact Company----------------------------- + { + QContactOrganization contactCompany; + + for(int i = 0 ; i < aContactDetailList.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details + { + if(aContactDetailList.at(i).definitionName() == QContactOrganization::DefinitionName ) + { + contactCompany = aContactDetailList.at(i); + } + } + + //QString company = QString::fromUtf16(aData.Ptr(),aData.Length()); + if(aFieldString == QContactOrganization::FieldName) + { + if(contactCompany.name().isEmpty()) + { + contactCompany.setName( aData ); + } + } + if(aFieldString == QContactOrganization::FieldTitle) + { + if(contactCompany.title().isEmpty()) + { + contactCompany.setTitle( aData ); + } + } + if(aFieldString == QContactOrganization::FieldDepartment) + { + QStringList depList = contactCompany.department(); + depList.append(aData); + contactCompany.setDepartment(depList); + } + if(aFieldString == QContactOrganization::FieldAssistantName) + { + if(contactCompany.assistantName().isEmpty()) + { + contactCompany.setAssistantName( aData ); + } + } + return contactCompany; + } + else if( aDetail == QContactAddress::DefinitionName ) //--Contact Address----------------------------- + { + QContactAddress contactAddress; + + for(int i = 0 ; i < aContactDetailList.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details + { + if(aContactDetailList.at(i).definitionName() == QContactAddress::DefinitionName && aContactDetailList.at(i).value(QContactDetail::FieldContext) == aFieldContext ) + { + contactAddress = aContactDetailList.at(i); + } + } + if( !aFieldContext.isEmpty() ) + { + contactAddress.setContexts( aFieldContext ); + } + //QString address = QString::fromUtf16(aData.Ptr(),aData.Length()); + if(aFieldString == QContactAddress::FieldStreet ) + { + if( contactAddress.street().isEmpty() ) + { + contactAddress.setStreet( aData ); + } + } + else if(aFieldString == QContactAddress::FieldLocality ) + { + if( contactAddress.locality().isEmpty() ) + { + contactAddress.setLocality( aData ); + } + } + else if(aFieldString == QContactAddress::FieldRegion ) + { + if( contactAddress.region().isEmpty() ) + { + contactAddress.setRegion( aData ); + } + } + else if(aFieldString == QContactAddress::FieldPostcode ) + { + if( contactAddress.postcode().isEmpty() ) + { + contactAddress.setPostcode( aData ); + } + } + else if(aFieldString == QContactAddress::FieldCountry ) + { + if( contactAddress.country().isEmpty() ) + { + contactAddress.setCountry( aData ); + } + } + else + { + return contactDetail; + } + return contactAddress; + } + else if( aDetail == QContactNote::DefinitionName ) //--Contact Note----------------------------- + { + QContactNote contactNote; + //QString note = QString::fromUtf16(aData.Ptr(),aData.Length()); + contactNote.setNote(aData); + return contactNote; + } + else if( aDetail == QContactFamily::DefinitionName ) //--Contact Family----------------------------- + { + QContactFamily contactFamily; + + for(int i = 0 ; i < aContactDetailList.count() ; i++ ) //go through all contact details to check if there is already Contact Name to set other details + { + if(aContactDetailList.at(i).definitionName() == QContactFamily::DefinitionName && aContactDetailList.at(i).value(QContactDetail::FieldContext) == aFieldContext ) + { + contactFamily = aContactDetailList.at(i); + } + } + + //QString familyData = QString::fromUtf16(aData.Ptr(),aData.Length()); + if(aFieldString == QContactFamily::FieldSpouse ) + { + if( contactFamily.spouse().isEmpty() ) + { + contactFamily.setSpouse( aData ); + } + } + if(aFieldString == QContactFamily::FieldChildren ) + { + QStringList children = contactFamily.children(); + children.append( aData ); + contactFamily.setChildren( children ); + } + + return contactFamily; + } + + if( aDetail == QContactAvatar::DefinitionName) //--Contact Picture----------------------------- + { + QContactAvatar contactAvatar; + /*TBuf srcPath; + aEngine->RandomPictureFileL(srcPath); + TBuf destPath(KTempPath); + + if(!BaflUtils::FolderExists( fs, destPath )) + { + BaflUtils::EnsurePathExistsL( fs, destPath ); + } + + TInt err=BaflUtils::CopyFile( fs, srcPath, destPath ); + + TParse temp; + temp.Set( srcPath,NULL,NULL ); + destPath.Append(temp.NameAndExt()); + + QString avatarFile = QString::fromUtf16( destPath.Ptr(),destPath.Length() ); + */ + QUrl imageUrl; + imageUrl.setUrl(aData); + contactAvatar.setImageUrl(imageUrl); + + return contactAvatar; + } + if( aDetail == QContactAnniversary::DefinitionName) //--Anniversary------------------------------ + { + QContactAnniversary contactAnniversary; + aData.replace(QChar('/'), QChar('-')); + QDate date = QDate::fromString(aData, "dd-MM-yyyy"); + //TTime datetime = aEngine->RandomDate( CCreatorEngine::EDateFuture ); + //date.setDate( datetime.DateTime().Year(),(int) (datetime.DateTime().Month()+1), datetime.DateTime().Day() ); + contactAnniversary.setOriginalDate( date ); + return contactAnniversary; + } + if( aDetail == QContactEmailAddress::DefinitionName) //--Email------------------------------------ + { + QContactEmailAddress email; + //QString emailAddr = QString::fromUtf16(aData.Ptr(),aData.Length()); + if( !aFieldContext.isEmpty() ) + { + email.setContexts( aFieldContext ); + } + email.setEmailAddress( aData ); + return email; + } + if( aDetail == QContactUrl::DefinitionName ) //--Url------------------------------------------- + { + QContactUrl url; + //QString urlStr = QString::fromUtf16(aData.Ptr(),aData.Length()); + if( !aFieldContext.isEmpty() ) + { + url.setContexts( aFieldContext ); + } + url.setUrl(aData); + return url; + } + if( aDetail == QContactBirthday::DefinitionName ) //--Birthday----------------------------------- + { + QContactBirthday birthday; + QDate date = QDate::fromString(aData); + //TTime datetime = aEngine->RandomDate( CCreatorEngine::EDatePast ); + //date.setDate( datetime.DateTime().Year(),(int) (datetime.DateTime().Month()+1), datetime.DateTime().Day() ); + birthday.setDate( date ); + return birthday; + } + + return contactDetail; + } + +void CCreatorPhonebookWrapper::AddFieldToList( QList& aDetailList, QContactDetail aDetail) + { + bool replace = false; + for(int i = 0 ; i< aDetailList.count() ; i++) //go through + { + if( !aDetail.isEmpty() && aDetail.definitionName() == aDetailList.at(i).definitionName() + && aDetail.definitionName() != QContactPhoneNumber::DefinitionName + && aDetail.definitionName() != QContactEmailAddress::DefinitionName + && aDetail.definitionName() != QContactUrl::DefinitionName ) + { + QString context = aDetail.value(QContactDetail::FieldContext); + bool isContextEmpty = context.isEmpty(); + if( isContextEmpty || ( aDetail.value(QContactDetail::FieldContext) == aDetailList.at(i).value(QContactDetail::FieldContext)) ) + { + //replace + aDetailList.replace(i,aDetail); + replace = true; + } + } + } + if(!replace) + { + if(!aDetail.isEmpty()) + { + aDetailList.append(aDetail); + } + } + + } + +TUint32 CCreatorPhonebookWrapper::CreateContactEntryL(const TCreatorContactFields& aFields) + { + QList list = CreateContactDetailsFromParameters( aFields ); + + return iPhonebookAPI->saveContact( list ); + } + + +//---------------------------------------------------------------------------- + + + +//---------------------------------------------------------------------------- + +void CCreatorPhonebookWrapper::DeleteAllL() + { + iPhonebookAPI->deleteAllContacts(); + } + +//---------------------------------------------------------------------------- +void CCreatorPhonebookWrapper::DeleteAllGroupsL() + { + LOGSTRING("Creator: CCreatorPhonebookWrapper::DeleteAllGroupsL"); + + iPhonebookAPI->deleteAllContacts( QContactType::TypeGroup ); + + } + +//---------------------------------------------------------------------------- +void CCreatorPhonebookWrapper::DeleteContactsL( RArray& aContactsToDelete, TUid aStoreUid ) + { + QList contacts; + for( TInt i = 0; i < aContactsToDelete.Count(); ++i ) + { + QContact contact = iPhonebookAPI->contact( QContactLocalId( aContactsToDelete[i] ) ); + if( (contact.type() == QContactType::TypeGroup && aStoreUid == KUidDictionaryUidContactGroups ) || (contact.type() != QContactType::TypeGroup && aStoreUid != KUidDictionaryUidContactGroups) ) + { + contacts.append( QContactLocalId( aContactsToDelete[i] ) ); + } + } + QMap errorMap; + iPhonebookAPI->deleteContacts( contacts ); + } + +//---------------------------------------------------------------------------- +TBool CCreatorPhonebookWrapper::HasOtherThanGroupsL() + { + LOGSTRING("Creator: CCreatorPhonebookWrapper::HasOtherThanGroupsL"); + TBool result( EFalse ); + return result; + } + + +TUint32 CCreatorPhonebookWrapper::CreateGroupEntryL( HBufC* aGroupName ) + { + TUint32 id = 0; + QString groupName = QString::fromUtf16( aGroupName->Des().Ptr(), aGroupName->Length() ); + + id = iPhonebookAPI->createGroup( groupName ); + + return id; + } +TInt CCreatorPhonebookWrapper::NumberOfContacts() + { + //return all stored contacts + return iPhonebookAPI->numberOfContacts(); + } + +TInt CCreatorPhonebookWrapper::AddContactToGroup( TUint32 aGroupId, TUint32 aContact ) + { + QContactLocalId group = QContactLocalId(aGroupId); + QContactLocalId contact = QContactLocalId(aContact); + + TInt ret = iPhonebookAPI->addContactToGroup(group, contact); + + return ret; + } +TInt CCreatorPhonebookWrapper::AddToGroup( TUint32 aGroupId, TInt aAmount ) + { + QContactLocalId group = QContactLocalId(aGroupId); + TInt ret = iPhonebookAPI->addToGroup( group, (int) aAmount ); + return ret; + } + + +//---------------------------------------------------------------------------- + +TInt CCreatorPhonebookWrapper::CreateSubscribedContactEntryL() + { + LOGSTRING("Creator: CCreatorPhonebookWrapper::CreateSubscribedContactEntryL"); + + return KErrNotSupported; + } + diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_scriptelementfactory.cpp --- a/creator/engine/src/creator_scriptelementfactory.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/engine/src/creator_scriptelementfactory.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -23,13 +23,13 @@ #include "creator_calendarelement.h" #include "creator_messageelement.h" #include "creator_fileelement.h" -#include "creator_browserelement.h" +//#include "creator_browserelement.h" #include "creator_logelement.h" //#include "creator_noteelement.h" //#include "creator_impselement.h" #include "creator_landmarkelement.h" #include "creator_mailboxelement.h" -#include "creator_connectionmethodelement.h" +//#include "creator_connectionmethodelement.h" CCreatorScriptElement* TCreatorScriptElementFactory::CreateElementL(CCreatorEngine* aEngine, const TDesC& aElementName, const TDesC& aContext ) { @@ -73,6 +73,7 @@ { return CCreatorFileElement::NewL(aEngine, aElementName, aContext); } + /* else if( aElementName == creatorbrowser::KBookmark || aElementName == creatorbrowser::KBookmarkFolder || aElementName == creatorbrowser::KSavedPage || @@ -80,6 +81,7 @@ { return CCreatorBrowserElement::NewL(aEngine, aElementName, aContext); } + */ else if( aElementName == creatorlog::KLog ) { return CCreatorLogElement::NewL(aEngine, aElementName, aContext); @@ -106,10 +108,12 @@ { return CCreatorMailboxElement::NewL(aEngine, aElementName, aContext); } +/* else if( aElementName == creatorconnectionmethod::KCm ) { return CCreatorConnectionMethodElement::NewL(aEngine, aElementName, aContext); } +*/ else { return CCreatorScriptElement::NewL(aEngine, aElementName, aContext); diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/engine/src/creator_virtualphonebook.cpp --- a/creator/engine/src/creator_virtualphonebook.cpp Wed Jun 23 18:13:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1777 +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 "engine.h" -#include "enginewrapper.h" -#include "creator_virtualphonebook.h" -#include "creator_traces.h" -#include "creator_contactsetcache.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -typedef struct { -TInt iFieldCode; -TInt iRandomType; -} FieldInfo; -static const TInt RND_TYPE_UNDEF = -99; -FieldInfo CreatorVPbkMiscTextFields[] = { - {R_VPBK_FIELD_TYPE_FIRSTNAME, (TInt) CCreatorEngine::EFirstName}, - {R_VPBK_FIELD_TYPE_FIRSTNAMEREADING, (TInt) CCreatorEngine::EFirstName}, - {R_VPBK_FIELD_TYPE_LASTNAME, (TInt) CCreatorEngine::ESurname}, - {R_VPBK_FIELD_TYPE_LASTNAMEREADING, (TInt) CCreatorEngine::ESurname}, - {R_VPBK_FIELD_TYPE_COMPANYNAME, (TInt) CCreatorEngine::ECompany}, - {R_VPBK_FIELD_TYPE_JOBTITLE, (TInt) CCreatorEngine::EJobTitle}, - {R_VPBK_FIELD_TYPE_PREFIX, (TInt) CCreatorEngine::EPrefix}, - {R_VPBK_FIELD_TYPE_SUFFIX, (TInt) CCreatorEngine::ESuffix}, - {R_VPBK_FIELD_TYPE_SECONDNAME, (TInt) CCreatorEngine::EFirstName}, - {R_VPBK_FIELD_TYPE_ADDRLABELGEN, (TInt) CCreatorEngine::EAddress}, - {R_VPBK_FIELD_TYPE_ADDRPOGEN, (TInt) CCreatorEngine::EPobox}, - {R_VPBK_FIELD_TYPE_ADDREXTGEN, (TInt) CCreatorEngine::EAddress}, - {R_VPBK_FIELD_TYPE_ADDRSTREETGEN, (TInt) CCreatorEngine::EAddress}, - {R_VPBK_FIELD_TYPE_ADDRLOCALGEN, (TInt) CCreatorEngine::ECity}, - {R_VPBK_FIELD_TYPE_ADDRREGIONGEN, (TInt) CCreatorEngine::EState}, - {R_VPBK_FIELD_TYPE_ADDRPOSTCODEGEN, (TInt) CCreatorEngine::EPostcode}, - {R_VPBK_FIELD_TYPE_ADDRCOUNTRYGEN, (TInt) CCreatorEngine::ECountry}, - {R_VPBK_FIELD_TYPE_ADDRLABELHOME, (TInt) CCreatorEngine::EAddress}, - {R_VPBK_FIELD_TYPE_ADDRPOHOME, (TInt) CCreatorEngine::EPobox}, - {R_VPBK_FIELD_TYPE_ADDREXTHOME, (TInt) CCreatorEngine::EAddress}, - {R_VPBK_FIELD_TYPE_ADDRSTREETHOME, (TInt) CCreatorEngine::EAddress}, - {R_VPBK_FIELD_TYPE_ADDRLOCALHOME, (TInt) CCreatorEngine::ECity}, - {R_VPBK_FIELD_TYPE_ADDRREGIONHOME, (TInt) CCreatorEngine::EState}, - {R_VPBK_FIELD_TYPE_ADDRPOSTCODEHOME, (TInt) CCreatorEngine::EPostcode}, - {R_VPBK_FIELD_TYPE_ADDRCOUNTRYHOME, (TInt) CCreatorEngine::ECountry}, - {R_VPBK_FIELD_TYPE_ADDRLABELWORK, (TInt) CCreatorEngine::EAddress}, - {R_VPBK_FIELD_TYPE_ADDRPOWORK, (TInt) CCreatorEngine::EPobox}, - {R_VPBK_FIELD_TYPE_ADDREXTWORK, (TInt) CCreatorEngine::EAddress}, - {R_VPBK_FIELD_TYPE_ADDRSTREETWORK, (TInt) CCreatorEngine::EAddress}, - {R_VPBK_FIELD_TYPE_ADDRLOCALWORK, (TInt) CCreatorEngine::ECity}, - {R_VPBK_FIELD_TYPE_ADDRREGIONWORK, (TInt) CCreatorEngine::EState}, - {R_VPBK_FIELD_TYPE_ADDRPOSTCODEWORK, (TInt) CCreatorEngine::EPostcode}, - {R_VPBK_FIELD_TYPE_ADDRCOUNTRYWORK, (TInt) CCreatorEngine::ECountry}, - {R_VPBK_FIELD_TYPE_POC, (TInt) CCreatorEngine::EPhoneNumber}, - {R_VPBK_FIELD_TYPE_SWIS, (TInt) CCreatorEngine::EPhoneNumber}, - {R_VPBK_FIELD_TYPE_SIP, (TInt) CCreatorEngine::EPhoneNumber}, - {R_VPBK_FIELD_TYPE_DTMFSTRING, (TInt) CCreatorEngine::EFirstName}, - {R_VPBK_FIELD_TYPE_NOTE,(TInt) CCreatorEngine::EMemoText}, - {R_VPBK_FIELD_TYPE_MIDDLENAME, (TInt) CCreatorEngine::EFirstName}, - {R_VPBK_FIELD_TYPE_DEPARTMENT, (TInt) CCreatorEngine::ECompany}, - {R_VPBK_FIELD_TYPE_ASSTNAME, (TInt) CCreatorEngine::EFirstName}, - {R_VPBK_FIELD_TYPE_SPOUSE, (TInt) CCreatorEngine::EFirstName}, - {R_VPBK_FIELD_TYPE_CHILDREN, (TInt) CCreatorEngine::EFirstName}, - {R_VPBK_FIELD_TYPE_SYNCCLASS, RND_TYPE_UNDEF}, - {R_VPBK_FIELD_TYPE_LOCPRIVACY, RND_TYPE_UNDEF}, - {R_VPBK_FIELD_TYPE_GENLABEL, (TInt) CCreatorEngine::EFirstName}, - {R_VPBK_FIELD_TYPE_WVADDRESS, (TInt) CCreatorEngine::EPhoneNumber}, - {R_VPBK_FIELD_TYPE_RINGTONE, RND_TYPE_UNDEF}, - {R_VPBK_FIELD_TYPE_THUMBNAILPIC, RND_TYPE_UNDEF}, - {R_VPBK_FIELD_TYPE_CALLEROBJTEXT, (TInt) CCreatorEngine::EFirstName} - }; - -TInt CreatorVPbkBinaryFields[] = { - R_VPBK_FIELD_TYPE_CALLEROBJIMG//, - //R_VPBK_FIELD_TYPE_THUMBNAILPATH - }; - -TInt CreatorVPbkDateTimeFields[] = { - R_VPBK_FIELD_TYPE_ANNIVERSARY - }; - -//---------------------------------------------------------------------------- -TInt CreatorVPbkPhoneNumberFields[] = - { - R_VPBK_FIELD_TYPE_LANDPHONEGEN, - R_VPBK_FIELD_TYPE_LANDPHONEHOME, - R_VPBK_FIELD_TYPE_LANDPHONEWORK, - R_VPBK_FIELD_TYPE_MOBILEPHONEGEN, - R_VPBK_FIELD_TYPE_MOBILEPHONEHOME, - R_VPBK_FIELD_TYPE_MOBILEPHONEWORK, - R_VPBK_FIELD_TYPE_FAXNUMBERGEN, - R_VPBK_FIELD_TYPE_FAXNUMBERHOME, - R_VPBK_FIELD_TYPE_FAXNUMBERWORK, - R_VPBK_FIELD_TYPE_PAGERNUMBER, - R_VPBK_FIELD_TYPE_VIDEONUMBERGEN, - R_VPBK_FIELD_TYPE_VIDEONUMBERHOME, - R_VPBK_FIELD_TYPE_VIDEONUMBERWORK, - R_VPBK_FIELD_TYPE_VOIPGEN, - R_VPBK_FIELD_TYPE_VOIPHOME, - R_VPBK_FIELD_TYPE_VOIPWORK, - R_VPBK_FIELD_TYPE_ASSTPHONE, - R_VPBK_FIELD_TYPE_CARPHONE - }; - -TInt CreatorVPbkUrlFields[] = - { - R_VPBK_FIELD_TYPE_URLGEN, - R_VPBK_FIELD_TYPE_URLHOME, - R_VPBK_FIELD_TYPE_URLWORK - }; - -TInt CreatorVPbkEmailFields[] = - { - R_VPBK_FIELD_TYPE_EMAILGEN, - R_VPBK_FIELD_TYPE_EMAILHOME, - R_VPBK_FIELD_TYPE_EMAILWORK - }; - -//---------------------------------------------------------------------------- - -CVirtualPhonebookParameters::CVirtualPhonebookParameters() - { - LOGSTRING("Creator: CVirtualPhonebookParameters::CVirtualPhonebookParameters"); - iGroupName = HBufC::New(KPhonebookFieldLength); - } - -CVirtualPhonebookParameters::~CVirtualPhonebookParameters() - { - LOGSTRING("Creator: CVirtualPhonebookParameters::~CVirtualPhonebookParameters"); - - delete iGroupName; - iContactFields.ResetAndDestroy(); - iContactFields.Close(); - iLinkIds.Reset(); - iLinkIds.Close(); - } - -void CVirtualPhonebookParameters::ParseL(CCommandParser* /*parser*/, TParseParams /*aCase = 0*/) - { - } - -TInt CVirtualPhonebookParameters::ScriptLinkId() const - { - return iLinkId; - } - -void CVirtualPhonebookParameters::SetScriptLinkId(TInt aLinkId) - { - iLinkId = aLinkId; - } - -//---------------------------------------------------------------------------- - -CCreatorVirtualPhonebook* CCreatorVirtualPhonebook::NewL(CCreatorEngine* aEngine) - { - CCreatorVirtualPhonebook* self = CCreatorVirtualPhonebook::NewLC(aEngine); - CleanupStack::Pop(self); - return self; - } - -CCreatorVirtualPhonebook* CCreatorVirtualPhonebook::NewLC(CCreatorEngine* aEngine) - { - CCreatorVirtualPhonebook* self = new (ELeave) CCreatorVirtualPhonebook; - CleanupStack::PushL(self); - self->ConstructL(aEngine); - return self; - } - -CCreatorVirtualPhonebook::CCreatorVirtualPhonebook() - { - iAddAllFields = EFalse; - } - -void CCreatorVirtualPhonebook::ConstructL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::ConstructL"); - - iContactLinkArray = CVPbkContactLinkArray::NewL(); - iContactsToDelete = CVPbkContactLinkArray::NewL(); - iContactGroupsToDelete = CVPbkContactLinkArray::NewL(); - - iEngine = aEngine; - SetDefaultParameters(); - - // initialize virtual phonebook - CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC(); - uriArray->AppendL( TVPbkContactStoreUriPtr(VPbkContactStoreUris::DefaultCntDbUri())); - iContactManager = CVPbkContactManager::NewL( *uriArray, &CCoeEnv::Static()->FsSession()); - CleanupStack::PopAndDestroy(uriArray); - - //When the contact manager is created, the stores is opened - MVPbkContactStoreList& storeList = iContactManager->ContactStoresL(); - - iWaiter = CAsyncWaiter::NewL(); - - //MVPbkContactStoreListObserver must give as parameter - storeList.OpenAllL(*this); - // wait for OpenComplete() callback - iWaiter->StartAndWait(); - - _LIT(dbUri, "cntdb://c:contacts.cdb"); - const TVPbkContactStoreUriPtr uri = TVPbkContactStoreUriPtr(dbUri); - - iStore = storeList.Find(uri); - iOpCounter = 0; - } - -TBool CCreatorVirtualPhonebook::IsActive() - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::IsActive"); - return iOperation != NULL; - } - -void CCreatorVirtualPhonebook::CancelOperation() - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::CancelOperation"); - iCancelCbRequested = ETrue; - } - -CCreatorVirtualPhonebook::~CCreatorVirtualPhonebook() - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::~CCreatorVirtualPhonebook"); - - // this is done only once per phonebook operation - if ( iContactsToDelete && iContactsToDelete->Count() ) - { - TRAP_IGNORE( StoreLinksForDeleteL( *iContactsToDelete, KUidDictionaryUidContacts ) ); - } - delete iContactsToDelete; - if ( iContactGroupsToDelete && iContactGroupsToDelete->Count() ) - { - TRAP_IGNORE( StoreLinksForDeleteL( *iContactGroupsToDelete, KUidDictionaryUidContactGroups ) ); - } - delete iContactGroupsToDelete; - - iPreviousDeleteLinks.ResetAndDestroy(); - - delete iOperation; - - TInt err = 0; - TRAP(err, CompactPbkDatabaseL( ETrue )); - - if(iContactResults) - { - delete iContactResults; - } - - delete iContactLinkArray; - delete iContactGroupsInStore; - - if(iContactManager) - { - TRAP(err, iContactManager->ContactStoresL().CloseAll(*this)); - delete iContactManager; - } - if(iWaiter) - { - delete iWaiter; - } - if (iParameters) - { - delete iParameters; - } - } - -//---------------------------------------------------------------------------- -void CCreatorVirtualPhonebook::DeleteAllL() - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::DeleteAllL"); - - // Delete all contacts, not contact groups - - //get field types - const MVPbkFieldTypeList& fieldList = iStore->StoreProperties().SupportedFields(); - - // get all contact links, results will be set to iContactResults - MVPbkContactOperationBase* operation = iContactManager->FindL( _L(""), fieldList , *this ); - if ( operation ) - { - iWaiter->StartAndWait(); //Making asynchronous FindL to synchronous - delete operation; - } - - while( iContactResults->Count() && - !iCancelCbRequested && - HasOtherThanGroupsL( iContactResults ) ) - { - // delete all found contacts - DeleteContactsL( iContactResults, EFalse ); - - if ( !iCancelCbRequested ) - { - // find next set of contacts to delete - MVPbkContactOperationBase* operation = iContactManager->FindL( _L(""), fieldList , *this ); - if ( operation ) - { - iWaiter->StartAndWait(); //Making asynchronous FindL to synchronous - delete operation; - } - } - } - - if ( iCancelCbRequested && iEngine ) - { - // User cancelled, must callback to finish terminatio sequence - iEngine->CancelComplete(); - } - else - { - // contacts deleted, remove the Creator internal contact registry - // (no callback required) - CDictionaryFileStore* store = iEngine->FileStoreLC(); - if ( store ) - { - store->Remove( KUidDictionaryUidContacts ); - store->CommitL(); - } - CleanupStack::PopAndDestroy( store ); - } - } - -//---------------------------------------------------------------------------- -void CCreatorVirtualPhonebook::DeleteAllCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::DeleteAllCreatedByCreatorL"); - DeleteItemsCreatedWithCreatorL( KUidDictionaryUidContacts ); - } - -//---------------------------------------------------------------------------- -void CCreatorVirtualPhonebook::DeleteAllGroupsL() - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::DeleteAllGroupsL"); - User::LeaveIfNull( iStore ); - MVPbkContactLinkArray* groups = iStore->ContactGroupsLC(); - DeleteContactsL( groups, ETrue ); - CleanupStack::PopAndDestroy(); // cannot use groups as parameter - } - -//---------------------------------------------------------------------------- -void CCreatorVirtualPhonebook::DeleteAllGroupsCreatedByCreatorL() - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::DeleteAllGroupsCreatedByCreatorL"); - DeleteItemsCreatedWithCreatorL( KUidDictionaryUidContactGroups ); - } - -//---------------------------------------------------------------------------- -void CCreatorVirtualPhonebook::DeleteContactsL( MVPbkContactLinkArray* aContacts, TBool aGroup ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::DeleteContactsL"); - const MVPbkContactLink* link( NULL ); - delete iOperation; - iOperation = NULL; - TInt i(0); - while ( aContacts && i < aContacts->Count() && !iCancelCbRequested ) - { - link = &aContacts->At( i++ ); - if ( aGroup == IsContactGroupL( *link ) ) - { - iOperation = iContactManager->RetrieveContactL( *link, *this ); - // see VPbkSingleContactOperationComplete - if ( iOperation ) - { - iWaiter->StartAndWait(); - delete iOperation; - iOperation = NULL; - } - } - link = NULL; - } - } - -//---------------------------------------------------------------------------- -void CCreatorVirtualPhonebook::DeleteItemsCreatedWithCreatorL( TUid aStoreUid ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::DeleteItemsCreatedWithCreatorL"); - __ASSERT_ALWAYS( aStoreUid == KUidDictionaryUidContacts || - aStoreUid == KUidDictionaryUidContactGroups, - User::Panic( _L("CCreatorVPb"), KErrArgument ) ); - CDictionaryFileStore* store = iEngine->FileStoreLC(); - User::LeaveIfNull( store ); - if ( store->IsPresentL( aStoreUid ) ) - { - TRAP_IGNORE( DoDeleteItemsCreatedWithCreatorL( aStoreUid, store ) ); - - if ( iCancelCbRequested && iEngine ) - { - iEngine->CancelComplete(); - } - else - { - // contacts deleted, remove the Creator internal contact registry - store->Remove( aStoreUid ); - store->CommitL(); - } - } - CleanupStack::PopAndDestroy( store ); - } - -//---------------------------------------------------------------------------- -void CCreatorVirtualPhonebook::DoDeleteItemsCreatedWithCreatorL( TUid aStoreUid, CDictionaryFileStore* aStore ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::DoDeleteItemsCreatedWithCreatorL"); - RDictionaryReadStream in; - in.OpenLC( *aStore, aStoreUid ); - MVPbkContactLinkArray* contactsToDelete = NULL; - // fetch contact links from store - while ( ( contactsToDelete = iContactManager->CreateLinksLC( in ) ) != NULL && // will leave with KErrEof - !iCancelCbRequested ) - { - DeleteContactsL( contactsToDelete, aStoreUid == KUidDictionaryUidContactGroups ); - // PopAndDestroy for contactsToDelete causes E32USER-CBase:90 - // however there is no mem-leak even if not deleting contactsToDelete object - } - CleanupStack::PopAndDestroy(); // in - } - -//---------------------------------------------------------------------------- -TBool CCreatorVirtualPhonebook::HasOtherThanGroupsL( MVPbkContactLinkArray* aContacts ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::HasOtherThanGroupsL"); - TBool result( EFalse ); - TInt i(0); - while ( aContacts && i < aContacts->Count() && !iCancelCbRequested && !result ) - { - if ( !IsContactGroupL( aContacts->At( i++ ) ) ) - { - result = ETrue; - } - } - return result; - } - -//---------------------------------------------------------------------------- -void CCreatorVirtualPhonebook::VPbkSingleContactOperationComplete( - MVPbkContactOperationBase& /*aOperation*/, - MVPbkStoreContact* aContact ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::VPbkSingleContactOperationComplete"); - - // This callback is currently used only for deleting a contact - // See DeleteContactsL - - TRAP_IGNORE( - aContact->PushL(); - aContact->DeleteL( *this ); - CleanupStack::PopAndDestroy( aContact ); - ); - } - -void CCreatorVirtualPhonebook::VPbkSingleContactOperationFailed( - MVPbkContactOperationBase& /*aOperation*/, - TInt /*aError*/ ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::VPbkSingleContactOperationFailed"); - iWaiter->Cancel(); - } - -//---------------------------------------------------------------------------- -void CCreatorVirtualPhonebook::StoreLinksForDeleteL( MVPbkContactLinkArray& aLinks, TUid aStoreUid ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::StoreLinksForDeleteL"); - CDictionaryFileStore* store = iEngine->FileStoreLC(); - User::LeaveIfNull( store ); - - // backup previous contact links from store - // otherwise they would be overwritten when calling out.WriteL - MVPbkContactLinkArray* previousLinks( NULL ); - if ( store->IsPresentL( aStoreUid ) ) - { - RDictionaryReadStream in; - in.OpenLC( *store, aStoreUid ); - TRAP_IGNORE( - while ( ( previousLinks = iContactManager->CreateLinksLC( in )) != NULL ) // will leave with KErrEof - { - CleanupStack::Pop(); // previousLinks - iPreviousDeleteLinks.Append( previousLinks ); - previousLinks = NULL; - } - ); - CleanupStack::PopAndDestroy(); // in - } - - RDictionaryWriteStream out; - out.AssignLC( *store, aStoreUid ); - - // restore previous links - for ( TInt i = 0; i < iPreviousDeleteLinks.Count(); i++ ) - { - out.WriteL( *iPreviousDeleteLinks[i]->PackLC() ); - CleanupStack::PopAndDestroy(); // PackLC - } - iPreviousDeleteLinks.ResetAndDestroy(); - - // write new links - out.WriteL( *aLinks.PackLC() ); - out.CommitL(); - CleanupStack::PopAndDestroy(); // aLinks.PackLC - CleanupStack::PopAndDestroy(); // out - - store->CommitL(); - CleanupStack::PopAndDestroy( store ); - } - -//---------------------------------------------------------------------------- -void CCreatorVirtualPhonebook::AddFieldToParamsL(TInt aFieldType, const TDesC& aData) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::AddFieldToParamsL(TInt aFieldType, const TDesC& aData)"); - if(iParameters == 0) - return; - CCreatorContactField* field = CCreatorContactField::NewL(aFieldType, aData); - CleanupStack::PushL(field); - iParameters->iContactFields.AppendL(field); - CleanupStack::Pop(); - } - -void CCreatorVirtualPhonebook::AddFieldToParamsL(TInt aFieldType, const TDesC8& aData) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::AddFieldToParamsL(TInt aFieldType, const TDesC8& aData)"); - if(iParameters == 0) - return; - CCreatorContactField* field = CCreatorContactField::NewL(aFieldType, aData); - CleanupStack::PushL(field); - iParameters->iContactFields.AppendL(field); - CleanupStack::Pop(); - } - -void CCreatorVirtualPhonebook::AddFieldToParamsL(TInt aFieldType, const TTime& aData) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::AddFieldToParamsL(TInt aFieldType, const TTime& aData)"); - if(iParameters == 0) - return; - CCreatorContactField* field = CCreatorContactField::NewL(aFieldType, aData); - CleanupStack::PushL(field); - iParameters->iContactFields.AppendL(field); - CleanupStack::Pop(); - } - -//---------------------------------------------------------------------------- -TInt CCreatorVirtualPhonebook::iPhoneNumberFields[] = - { - R_VPBK_FIELD_TYPE_LANDPHONEGEN, - R_VPBK_FIELD_TYPE_LANDPHONEHOME, - R_VPBK_FIELD_TYPE_LANDPHONEWORK, - R_VPBK_FIELD_TYPE_MOBILEPHONEGEN, - R_VPBK_FIELD_TYPE_MOBILEPHONEHOME, - R_VPBK_FIELD_TYPE_MOBILEPHONEWORK, - R_VPBK_FIELD_TYPE_FAXNUMBERGEN, - R_VPBK_FIELD_TYPE_FAXNUMBERHOME, - R_VPBK_FIELD_TYPE_FAXNUMBERWORK, - R_VPBK_FIELD_TYPE_PAGERNUMBER, - R_VPBK_FIELD_TYPE_VIDEONUMBERGEN, - R_VPBK_FIELD_TYPE_VIDEONUMBERHOME, - R_VPBK_FIELD_TYPE_VIDEONUMBERWORK, - R_VPBK_FIELD_TYPE_VOIPGEN, - R_VPBK_FIELD_TYPE_VOIPHOME, - R_VPBK_FIELD_TYPE_VOIPWORK, - R_VPBK_FIELD_TYPE_ASSTPHONE, - R_VPBK_FIELD_TYPE_CARPHONE - }; - -TInt CCreatorVirtualPhonebook::iUrlFields[] = - { - R_VPBK_FIELD_TYPE_URLGEN, - R_VPBK_FIELD_TYPE_URLHOME, - R_VPBK_FIELD_TYPE_URLWORK - }; - -TInt CCreatorVirtualPhonebook::iEmailFields[] = - { - R_VPBK_FIELD_TYPE_EMAILGEN, - R_VPBK_FIELD_TYPE_EMAILHOME, - R_VPBK_FIELD_TYPE_EMAILWORK - }; - -void CCreatorVirtualPhonebook::InitializeContactParamsL(/*CCreatorModuleBaseParameters* aParameters*/) - { - LOGSTRING("Creator: CCreatorPhonebook::InitializeContactParamsL"); - iParameters = new (ELeave) CVirtualPhonebookParameters; - - iParameters->iNumberOfPhoneNumberFields = iNumberOfPhoneNumberFields; - iParameters->iNumberOfURLFields = iNumberOfURLFields; - iParameters->iNumberOfEmailAddressFields = iNumberOfEmailAddressFields; - - TPtrC firstname = iEngine->RandomString(CCreatorEngine::EFirstName); - TPtrC lastname = iEngine->RandomString(CCreatorEngine::ESurname); - - if( iAddAllFields ) - { - // Add text fields: - TInt textFieldCount = sizeof(CreatorVPbkMiscTextFields) / sizeof(FieldInfo); - for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) - { - CCreatorContactField* field = CCreatorContactField::NewL(CreatorVPbkMiscTextFields[tfIndex].iFieldCode, KNullDesC); - CleanupStack::PushL(field); - field->SetRandomParametersL(CCreatorContactField::ERandomLengthDefault); - iParameters->iContactFields.AppendL(field); - CleanupStack::Pop(field); - } - - // Add binary fields: - TInt binFieldCount = sizeof(CreatorVPbkBinaryFields) / sizeof(TInt); - for( TInt bfIndex = 0; bfIndex < binFieldCount; ++bfIndex ) - { - CCreatorContactField* field = CCreatorContactField::NewL(CreatorVPbkBinaryFields[bfIndex], KNullDesC8); - CleanupStack::PushL(field); - field->SetRandomParametersL(CCreatorContactField::ERandomLengthDefault); - iParameters->iContactFields.AppendL(field); - CleanupStack::Pop(field); - } - - // Add date-time fields: - TInt dtFieldCount = sizeof(CreatorVPbkDateTimeFields) / sizeof(TInt); - for( TInt dtIndex = 0; dtIndex < dtFieldCount; ++dtIndex ) - { - AddFieldToParamsL(CreatorVPbkDateTimeFields[dtIndex], iEngine->RandomDate(CCreatorEngine::EDateFuture)); - } - - AddFieldToParamsL(R_VPBK_FIELD_TYPE_CALLEROBJIMG, KNullDesC8); - AddFieldToParamsL(R_VPBK_FIELD_TYPE_THUMBNAILPIC, KNullDesC8); - AddFieldToParamsL(R_VPBK_FIELD_TYPE_CALLEROBJTEXT, firstname); - } - else - { - AddFieldToParamsL(R_VPBK_FIELD_TYPE_FIRSTNAME, firstname); - AddFieldToParamsL(R_VPBK_FIELD_TYPE_LASTNAME, lastname); - } - - // Phone numbers: - TInt arraySize = sizeof(iPhoneNumberFields)/sizeof(TInt); - TInt index = 0; - for (TInt i=0; iiNumberOfPhoneNumberFields; i++ ) - { - if( index >= arraySize ) - { - index = 0; - } - if( arraySize > 0 ) - { - CCreatorContactField* field = CCreatorContactField::NewL(iPhoneNumberFields[index], KNullDesC); - CleanupStack::PushL(field); - field->SetRandomParametersL(CCreatorContactField::ERandomLengthDefault); - iParameters->iContactFields.AppendL(field); - CleanupStack::Pop(field); - } - ++index; - } - - - // URLs: - arraySize = sizeof(iUrlFields)/sizeof(TInt); - index = 0; - for( TInt i = 0; i < iParameters->iNumberOfURLFields; ++i) - { - if( index >= arraySize ) - { - index = 0; - } - if( arraySize > 0 ) - { - CCreatorContactField* field = CCreatorContactField::NewL(iUrlFields[index], KNullDesC); - CleanupStack::PushL(field); - field->SetRandomParametersL(CCreatorContactField::ERandomLengthDefault); - iParameters->iContactFields.AppendL(field); - CleanupStack::Pop(field); - } - ++index; - } - - // EMail addresses: - arraySize = sizeof(iEmailFields)/sizeof(TInt); - index = 0; - for( TInt i = 0; i < iParameters->iNumberOfEmailAddressFields; ++i) - { - if( index >= arraySize ) - { - index = 0; - } - if( arraySize > 0 ) - { - CCreatorContactField* field = CCreatorContactField::NewL(iEmailFields[index], KNullDesC); - CleanupStack::PushL(field); - field->SetRandomParametersL(CCreatorContactField::ERandomLengthDefault); - iParameters->iContactFields.AppendL(field); - CleanupStack::Pop(field); - } - ++index; - } - } - -TInt CCreatorVirtualPhonebook::CreateContactEntryL(CCreatorModuleBaseParameters *aParameters) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::CreateContactEntryL"); - - delete iParameters; - iParameters = 0; - CVirtualPhonebookParameters* parameters = 0; - - if( aParameters == 0 ) - { - InitializeContactParamsL(); - parameters = iParameters; - } - else - { - parameters = (CVirtualPhonebookParameters*) aParameters; - } - - TInt err = KErrNone; - - // create a new contact item - MVPbkStoreContact* newContact = iStore->CreateNewContactLC(); - for( TInt i = 0; i < parameters->iContactFields.Count(); ++i ) - { - CCreatorContactField* cField = parameters->iContactFields[i]; - if( cField ) - { - cField->AddToContactL(iEngine, *newContact, this); - } - } - - RArray contacts; - CleanupClosePushL( contacts ); - contacts.Append(newContact); - - delete iOperation; - iOperation = NULL; - iOperation = iContactManager->CommitContactsL( contacts.Array(), *this ); - if ( iOperation ) - { - - iWaiter->StartAndWait();//Making asynchronous CommitContctsL to synchronous - delete iOperation; - iOperation = NULL; - } - - // store the link to contact, so that Creator is able to delete - // it when user requests deletion of contacts that are created by Creator - MVPbkContactLink* linkToContact = newContact->CreateLinkLC(); - iContactsToDelete->AppendL( linkToContact ); - CleanupStack::Pop(); // linkToContact - - // If this contact has a link id in script (i.e. belongs to a contact-set), we must cache the contact id: - if( parameters->ScriptLinkId() > 0 ) - { - RPointerArray& contactsets = ContactLinkCache::Instance()->ContactSets(); - TBool setFound(EFalse); - for(TInt i = 0; i < contactsets.Count(); ++i ) - { - if( contactsets[i]->LinkId() == parameters->ScriptLinkId()) - { - MVPbkContactLink* linkToContact = newContact->CreateLinkLC(); - if( linkToContact ) - { - contactsets[i]->AppendL(linkToContact); - iContactLinkArray->AppendL(linkToContact); - CleanupStack::Pop(); // linkToContact - } - setFound = ETrue; - break; - } - } - if( !setFound ) - { - LOGSTRING2("Error: Contact set id %d not found.", parameters->ScriptLinkId()); - } - } - - CleanupStack::Pop();//contacts - contacts.Close(); - CompactPbkDatabaseL(); - CleanupStack::PopAndDestroy();//newContact - if ( iCancelCbRequested && iEngine ) iEngine->CancelComplete(); - return err; - } - - -//---------------------------------------------------------------------------- - -void CCreatorVirtualPhonebook::AddImageToContactL(MVPbkStoreContact& aContact, TInt aFieldResId, const TDesC& aFileName) - { - LOGSTRING("Creator: CCreatorPhonebook::AddImageToContactL"); - CPbk2ImageManager* imageMgr = CPbk2ImageManager::NewL(*iContactManager); - CleanupStack::PushL(imageMgr); - const MVPbkFieldTypeList& fieldList = aContact.ParentStore().StoreProperties().SupportedFields(); - const MVPbkFieldType* fieldType = fieldList.Find(aFieldResId); - if( fieldType == 0 ) - { - return; - } - MPbk2ImageOperation* imageOp = 0; - TRAPD(err, imageOp = imageMgr->SetImageAsyncL(aContact, *fieldType, *this, aFileName)); - if( err == KErrNone) - { - if (imageOp) - { - CleanupDeletePushL( imageOp ); - iWaiter->StartAndWait(); // Making asynchronous SetImageAsyncL to synchronous - CleanupStack::Pop(imageOp); - delete imageOp; - } - } - else if(err != KErrNotSupported) - { - User::Leave(err); - } - CleanupStack::PopAndDestroy(imageMgr); - } - -// Checks if the link is a group or not -TBool CCreatorVirtualPhonebook::IsContactGroupL(const MVPbkContactLink& aLink) - { - LOGSTRING("Creator: CCreatorPhonebook::IsContactGroupL"); - if( iStore ) - { - delete iContactGroupsInStore; - iContactGroupsInStore = 0; - // Save contact group links here - iContactGroupsInStore = iStore->ContactGroupsLC(); - CleanupStack::Pop(); - } - - if( iContactGroupsInStore ) - { - // Loop all the groups and check if any of them matches to the given link. - for( TInt i = 0; i < iContactGroupsInStore->Count(); ++i ) - { - if( (*iContactGroupsInStore)[i].IsSame(aLink) ) - return ETrue; - } - } - return EFalse; - } - -TInt CCreatorVirtualPhonebook::CreateGroupEntryL(CCreatorModuleBaseParameters *aParameters) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::CreateGroupEntryL"); - delete iParameters; - iParameters = 0; - - CVirtualPhonebookParameters* parameters = (CVirtualPhonebookParameters*) aParameters; - - if( !parameters ) - { - iParameters = new (ELeave) CVirtualPhonebookParameters; - iParameters->iContactsInGroup = iContactsInGroup; - iParameters->iGroupName->Des().Copy( iEngine->RandomString(CCreatorEngine::EGroupName) ); - iParameters->iGroupName->Des().Append( _L(" #") ); - iParameters->iGroupName->Des().AppendNum( iEngine->RandomNumber(1000, 9999) ); - parameters = iParameters; - } - - TInt err = KErrNone; - - // create a new contact group - MVPbkContactGroup* newGroup = iStore->CreateNewContactGroupLC(); - - newGroup->SetGroupLabelL(parameters->iGroupName->Des()); - - // define amounts of contacts to be added to the group - TInt amountOfContactsToBeAdded = 0; - if (parameters->iContactsInGroup == KCreateRandomAmountOfGroups) - { - amountOfContactsToBeAdded = iEngine->RandomNumber(30); - } - else - { - amountOfContactsToBeAdded = parameters->iContactsInGroup; - } - - if( parameters->iLinkIds.Count() > 0 ) - { - for( TInt i = 0; i < parameters->iLinkIds.Count(); ++i ) - { - const CCreatorContactSet& set = ContactLinkCache::Instance()->ContactSet(parameters->iLinkIds[i].iLinkId); - - const RPointerArray& links = set.ContactLinks(); - TInt numberOfExplicitLinks = links.Count(); // Number of defined contacts in contact-set - TInt numberOfExistingContacts = set.NumberOfExistingContacts(); // Number of existing contacts in contact-set - TInt maxAmount = numberOfExplicitLinks + numberOfExistingContacts; - - if( parameters->iLinkIds[i].iLinkAmount > 0 ) - maxAmount = parameters->iLinkIds[i].iLinkAmount; // Max amount is limited - - TInt addedMembers = 0; - - for( TInt j = 0; j < links.Count() && addedMembers < maxAmount; ++j ) - { - MVPbkContactLink* link = links[j]; - if( link && IsContactGroupL(*link) == EFalse ) - { - TRAPD(err, newGroup->AddContactL(*link)); - if( err != KErrAlreadyExists ) - { - // Ignore "allready exists" -error - User::LeaveIfError(err); - ++addedMembers; - } - } - } - if( addedMembers < maxAmount ) - { - // Add existing contacts, withing the limits set by maxAmount: - amountOfContactsToBeAdded += maxAmount - addedMembers; - } - } - } - if( amountOfContactsToBeAdded > 0 ) - { - CVPbkContactViewDefinition* viewDef = CVPbkContactViewDefinition::NewL(); - CleanupStack::PushL( viewDef ); - viewDef->SetType( EVPbkContactsView ); - MVPbkContactView* contactView = iStore->CreateViewLC( - *viewDef, - *this, - iStore->StoreProperties().SupportedFields() ); - iWaiter->StartAndWait();//Making asynchronous CreateViewLC to synchronous - - TInt cnt = 0; - // assign some random contacts to the group - for ( TInt y = 0; cnt < amountOfContactsToBeAdded && y < contactView->ContactCountL(); ++y ) - { - MVPbkContactLink* link = contactView->CreateLinkLC( y ); - TRAPD( err, newGroup->AddContactL( *link ) ); - CleanupStack::PopAndDestroy(); // link - if( err != KErrAlreadyExists ) - { - // Ignore "allready exists" -error - User::LeaveIfError( err ); - ++cnt; - } - } - CleanupStack::PopAndDestroy(); // contactView - CleanupStack::PopAndDestroy( viewDef ); - } - - newGroup->CommitL(*this); - iWaiter->StartAndWait(); //Making asynchronous CommitL to synchronous - - // store the link to contact, so that Creator is able to delete - // it when user requests deletion of contacts that were created with Creator - MVPbkContactLink* linkToContact = newGroup->CreateLinkLC(); - iContactGroupsToDelete->AppendL( linkToContact ); - CleanupStack::Pop(); // linkToContact - - CleanupStack::PopAndDestroy(); // newGroup - - CompactPbkDatabaseL(); - - return err; - - } - -//---------------------------------------------------------------------------- - -TInt CCreatorVirtualPhonebook::CreateSubscribedContactEntryL(CCreatorModuleBaseParameters* /*aParameters*/) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::CreateSubscribedContactEntryL"); - - return KErrNotSupported; - } - -//---------------------------------------------------------------------------- - -void CCreatorVirtualPhonebook::AddFieldToContactItemL( - MVPbkStoreContact& newContact, TPbkFieldId aFieldId, const TDesC& aFieldText) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::AddFieldToContactItemL"); - - // Get field type object - const MVPbkFieldTypeList& fieldList = newContact.ParentStore().StoreProperties().SupportedFields(); - const MVPbkFieldType* fieldType = fieldList.Find(aFieldId); - if( fieldType == 0 ) - return; // field type is not supported - - // Create a new field - MVPbkStoreContactField* newField = newContact.CreateFieldLC(*fieldType); - if( !newField ) - { - User::Leave(KErrNotSupported); - } - - MVPbkContactFieldData& fieldData = newField->FieldData(); - - //data type must be text in this case - TVPbkFieldStorageType dataType = fieldData.DataType(); - - if(dataType == EVPbkFieldStorageTypeText) - { - //set text to field - MVPbkContactFieldTextData& tmpData = MVPbkContactFieldTextData::Cast(fieldData); - tmpData.SetTextL(aFieldText); - //set field to contact - newContact.AddFieldL(newField);//This object takes ownership of the field. - CleanupStack::Pop(newField); - } - else - { - User::Leave(KErrArgument); - } - - } - -//---------------------------------------------------------------------------- - -void CCreatorVirtualPhonebook::AddFieldToContactItemL( - MVPbkStoreContact& newContact, TPbkFieldId aFieldId, const TDesC8& aFieldText) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::AddFieldToContactItemL"); - - //get field types - const MVPbkFieldTypeList& fieldList = newContact.ParentStore().StoreProperties().SupportedFields(); - - //get wanted field type - const MVPbkFieldType* fieldType = fieldList.Find(aFieldId); - - //create a new field - MVPbkStoreContactField* newField = - newContact.CreateFieldLC(*fieldType); - //get field data - MVPbkContactFieldData& fieldData = newField->FieldData(); - - //data type must be text in this case - TVPbkFieldStorageType dataType = fieldData.DataType(); - - if(dataType == EVPbkFieldStorageTypeBinary){ - //set bindata to field - MVPbkContactFieldBinaryData& tmpData = MVPbkContactFieldBinaryData::Cast(fieldData); - tmpData.SetBinaryDataL(aFieldText); - //set field to contact - newContact.AddFieldL(newField);//This object takes ownership of the field. - CleanupStack::Pop(newField); - } - else - { - CleanupStack::PopAndDestroy(newField); - } - - } - -void CCreatorVirtualPhonebook::AddFieldToContactItemL( - MVPbkStoreContact& newContact, TPbkFieldId aFieldId, const TTime& aFieldText) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::AddFieldToContactItemL"); - //get field types - const MVPbkFieldTypeList& fieldList = newContact.ParentStore().StoreProperties().SupportedFields(); - - //get wanted field type - const MVPbkFieldType* fieldType = fieldList.Find(aFieldId); - - //create a new field - MVPbkStoreContactField* newField = newContact.CreateFieldLC(*fieldType); - //get field data - MVPbkContactFieldData& fieldData = newField->FieldData(); - - //data type must be datetime in this case - TVPbkFieldStorageType dataType = fieldData.DataType(); - - if(dataType == EVPbkFieldStorageTypeDateTime) - { - //set bindata to field - MVPbkContactFieldDateTimeData& tmpData = MVPbkContactFieldDateTimeData::Cast(fieldData); - tmpData.SetDateTime(aFieldText); - //set field to contact - newContact.AddFieldL(newField);//This object takes ownership of the field. - CleanupStack::Pop(newField); - } - else - { - CleanupStack::PopAndDestroy(newField); - } - } - -//---------------------------------------------------------------------------- - -void CCreatorVirtualPhonebook::CompactPbkDatabaseL(TBool aCompressImmediately) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::CompactPbkDatabase"); - - iOpCounter++; - - // compress the database immediately or after each 100th operation - if (aCompressImmediately || iOpCounter%100 == 0) - { - MVPbkContactOperationBase* operation= iContactManager->CompressStoresL(*this); - if (operation) - { - CleanupDeletePushL( operation ); - iWaiter->StartAndWait();//Making asynchronous CompressStoresL to synchronous - CleanupStack::Pop(operation); - delete operation; - } - } - } - -//---------------------------------------------------------------------------- -//Observer implementations for MVPbkContactStoreListObserver -//(and it's super class MVPbkContactStoreObserver) - -void CCreatorVirtualPhonebook::OpenComplete() - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::OpenComplete()"); - iWaiter->Cancel(); - } - -void CCreatorVirtualPhonebook::StoreReady(MVPbkContactStore& /*aContactStore*/) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::StoreReady()"); - } - - -void CCreatorVirtualPhonebook::StoreUnavailable(MVPbkContactStore& /*aContactStore*/, - TInt /*aReason*/) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::StoreUnavailable()"); - } - - -void CCreatorVirtualPhonebook::HandleStoreEventL( - MVPbkContactStore& /*aContactStore*/, - TVPbkContactStoreEvent /*aStoreEvent*/) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::HandleStoreEventL()"); - } - - - TAny* CCreatorVirtualPhonebook::ContactStoreObserverExtension( - TUid /*aExtensionUid*/) - - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::ContactStoreObserverExtension()"); - return NULL; - } - - -//---------------------------------------------------------------------------- -//Observer implementation for MVPbkBatchOperationObserver - -void CCreatorVirtualPhonebook::StepComplete( - MVPbkContactOperationBase& /*aOperation*/, - TInt /*aStepSize*/ ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::StepComplete" ); - } - - -TBool CCreatorVirtualPhonebook::StepFailed( - MVPbkContactOperationBase& /*aOperation*/, - TInt /*aStepSize*/, TInt /*aError*/ ) -{ - LOGSTRING("Creator: CCreatorVirtualPhonebook::StepFailed" ); - iWaiter->Cancel(); - return EFalse; -} - - -void CCreatorVirtualPhonebook::OperationComplete( - MVPbkContactOperationBase& /*aOperation*/ ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::OperationComplete" ); - //Canceling waiter when operation is done. - iWaiter->Cancel(); - } - - -TAny* CCreatorVirtualPhonebook::BatchOperationObserverExtension( - TUid /*aExtensionUid*/ ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::BatchOperationObserverExtension" ); - return NULL; - } - -//---------------------------------------------------------------------------- -//Observer implementation for MVPbkContactFindObserver -void CCreatorVirtualPhonebook::FindCompleteL( MVPbkContactLinkArray* aResults ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::FindCompleteL" ); - if(iContactResults) - { - delete iContactResults; - iContactResults = NULL; - } - iContactResults = aResults; - iWaiter->Cancel(); - } - -void CCreatorVirtualPhonebook::FindFailed( TInt aError ) - { - LOGSTRING2("Creator: CCreatorVirtualPhonebook::FindFailed - Error: %d", aError ); - iWaiter->Cancel(); - } - -TAny* CCreatorVirtualPhonebook::ContactFindObserverExtension( - TUid /*aExtensionUid*/ ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::ContactFindObserverExtension" ); - return NULL; - } - - -//Observer implementation for MVPbkContactObserver -//---------------------------------------------------------------------------- - -void CCreatorVirtualPhonebook::ContactOperationCompleted(TContactOpResult aResult) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::ContactOperationCompleted" ); - - TContactOp op = aResult.iOpCode; - switch ( op ) - { - case EContactCommit: - case EContactDelete: - { - iWaiter->Cancel(); - break; - } - case EContactLock: - default: break; - } - } - -void CCreatorVirtualPhonebook::ContactOperationFailed - (TContactOp /*aOpCode*/, TInt aErrorCode, TBool /*aErrorNotified*/) - { - LOGSTRING2("Creator: CCreatorVirtualPhonebook::ContactOperationFailed - Error: %d", aErrorCode ); - iWaiter->Cancel(); - } - -TAny* CCreatorVirtualPhonebook::ContactObserverExtension(TUid /*aExtensionUid*/) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::ContactObserverExtension" ); - return NULL; - } - -void CCreatorVirtualPhonebook::Pbk2ImageSetComplete(MPbk2ImageOperation& /*aOperation*/) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::Pbk2ImageSetComplete" ); - //Canceling waiter when operation is done. - iWaiter->Cancel(); - } - -void CCreatorVirtualPhonebook::Pbk2ImageSetFailed(MPbk2ImageOperation& /*aOperation*/, TInt /*aError*/) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::Pbk2ImageSetFailed" ); - //Canceling waiter when operation is done. - iWaiter->Cancel(); - } - - -//Observer implementation for MVPbkContactViewObserver -//---------------------------------------------------------------------------- -void CCreatorVirtualPhonebook::ContactViewReady( MVPbkContactViewBase& /*aView*/ ) - { - LOGSTRING("Creator: CCreatorVirtualPhonebook::ContactViewReady" ); - iWaiter->Cancel(); - } - -void CCreatorVirtualPhonebook::ContactViewUnavailable( - MVPbkContactViewBase& /*aView*/ ) - { - iWaiter->Cancel(); - } - -void CCreatorVirtualPhonebook::ContactAddedToView( - MVPbkContactViewBase& /*aView*/, - TInt /*aIndex*/, - const MVPbkContactLink& /*aContactLink*/ ) - { - } - -void CCreatorVirtualPhonebook::ContactRemovedFromView( - MVPbkContactViewBase& /*aView*/, - TInt /*aIndex*/, - const MVPbkContactLink& /*aContactLink*/ ) - { - } - -void CCreatorVirtualPhonebook::ContactViewError( - MVPbkContactViewBase& /*aView*/, - TInt /*aError*/, - TBool /*aErrorNotified*/ ) - { - iWaiter->Cancel(); - } - -/** - * CCreatorContactFieldImpl Base class for contact field implementations - */ -class CCreatorContactFieldImpl : public CBase - { -public: - virtual ~CCreatorContactFieldImpl() {}; - - virtual void AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk); - virtual void SetRandomParametersL(CCreatorContactField::TRandomLengthType aRandomLenType = CCreatorContactField::ERandomLengthDefault, TInt aRandomLen = 0 ); - virtual void ParseL(CCommandParser* parser); - - virtual TInt FieldType(); -protected: - CCreatorContactFieldImpl(TInt aFieldType); - TInt iFieldType; - CCreatorContactField::TRandomLengthType iRandomLenType; - TInt iRandomLen; - }; - -void CCreatorContactFieldImpl::AddToContactL(CCreatorEngine* /*aEngine*/, MVPbkStoreContact& /*aContact*/, CCreatorVirtualPhonebook* /*aVPbk*/ ) - {} - -void CCreatorContactFieldImpl::SetRandomParametersL(CCreatorContactField::TRandomLengthType aRandomLenType, TInt aRandomLen ) - { - iRandomLenType = aRandomLenType; - iRandomLen = aRandomLen; - } - -void CCreatorContactFieldImpl::ParseL(CCommandParser* /*parser*/) - {} - -CCreatorContactFieldImpl::CCreatorContactFieldImpl(TInt aFieldType) - { - iFieldType = aFieldType; - } - -TInt CCreatorContactFieldImpl::FieldType() - { - return iFieldType; - } - - -/** - * CCreatorContactTextField Text field implementation - */ -class CCreatorContactTextField : public CCreatorContactFieldImpl - { - public: - static CCreatorContactTextField* NewL(TInt aFieldType, const TDesC& aData); - ~CCreatorContactTextField(); - virtual void AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk); - virtual void ParseL(CCommandParser* parser); - - protected: - virtual void SetDefaultRandomContentL(CCreatorEngine* aEngine); - virtual void SetExplicitRandomContentL(CCreatorEngine* aEngine, TInt aRandomLen); - - private: - CCreatorContactTextField(TInt aFieldType); - void ConstructL(const TDesC& aData); - HBufC* iPtr; - }; - -CCreatorContactTextField::CCreatorContactTextField(TInt aFieldType) -: CCreatorContactFieldImpl(aFieldType) - { } -CCreatorContactTextField::~CCreatorContactTextField() - { - delete iPtr; - } - void CCreatorContactTextField::AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk) - { - LOGSTRING("Creator: CCreatorContactTextField::AddToContactL"); - if( aVPbk == 0 ) - User::Leave(KErrArgument); - - if( iPtr == 0 || iPtr->Length() == 0) - { - switch( iRandomLenType ) - { - case CCreatorContactField::ERandomLengthDefault: - { - SetDefaultRandomContentL(aEngine); - break; - } - case CCreatorContactField::ERandomLengthMax: - { - const MVPbkFieldTypeList& fieldList = aContact.ParentStore().StoreProperties().SupportedFields(); - const MVPbkFieldType* fieldType = fieldList.Find(iFieldType); - if( fieldType == 0 ) - return; // field type is not supported - - // Create a new field - MVPbkStoreContactField* newField = aContact.CreateFieldLC(*fieldType); - if( !newField ) - { - User::Leave(KErrNotSupported); - } - - MVPbkContactFieldData& fieldData = newField->FieldData(); - //data type must be text in this case - TVPbkFieldStorageType dataType = fieldData.DataType(); - - if(dataType == EVPbkFieldStorageTypeText) - { - //set text to field - MVPbkContactFieldTextData& tmpData = MVPbkContactFieldTextData::Cast(fieldData); - iRandomLen = tmpData.MaxLength(); - if( iRandomLen == KVPbkUnlimitedFieldLength ) - iRandomLen = 128; - } - CleanupStack::PopAndDestroy(newField); - SetExplicitRandomContentL(aEngine, iRandomLen); - break; - } - case CCreatorContactField::ERandomLengthExplicit: - { - SetExplicitRandomContentL(aEngine, iRandomLen); - break; - } - default: - break; - } - } - if( iPtr ) - { - if( iFieldType == R_VPBK_FIELD_TYPE_THUMBNAILPIC ) - { - if( iPtr && iPtr->Length() > 0 ) - { - aVPbk->AddImageToContactL(aContact, iFieldType, iPtr->Des()); - } - } - //Thumbnail id handling - /*else if( iFieldType == FIELD_TYPE_THUMBNAILPIC_ID ) - { - if( iPtr && iPtr->Length() > 0 ) - { - TInt id = aEngine->GetAttachmentIdL(iPtr->Des()); - if( id != KUndef ) - { - //get picture path by id - TFileName sourceFileName = aEngine->TestDataPathL((CCreatorEngine::TTestDataPath)id);// (CCreatorEngine::TTestDataPath) parameters.iAttachments->At(i) - //set image to contact - aVPbk->AddImageToContactL(aContact, R_VPBK_FIELD_TYPE_THUMBNAILPIC, sourceFileName); - } - } - }*/ - else - { - if( iPtr && iPtr->Length() > 0 ) - { - aVPbk->AddFieldToContactItemL(aContact, iFieldType, iPtr->Des()); - } - } - } - } - - void CCreatorContactTextField::SetDefaultRandomContentL(CCreatorEngine* aEngine) - { - LOGSTRING("Creator: CCreatorContactTextField::SetDefaultRandomContentL"); - if( aEngine == 0 ) - return; - - if( iPtr ) - { - delete iPtr; - iPtr = 0; - } - TPtrC contentData; - - TInt textFieldCount = sizeof(CreatorVPbkMiscTextFields) / sizeof(FieldInfo); - TBool found = EFalse; - for( TInt tfIndex = 0; tfIndex < textFieldCount; ++tfIndex ) - { - if( iFieldType == CreatorVPbkMiscTextFields[tfIndex].iFieldCode ) - { - found = ETrue; - if( CreatorVPbkMiscTextFields[tfIndex].iRandomType != RND_TYPE_UNDEF ) - { - contentData.Set(aEngine->RandomString((CCreatorEngine::TRandomStringType) CreatorVPbkMiscTextFields[tfIndex].iRandomType)); - } - else - { - switch( iFieldType ) - { - case R_VPBK_FIELD_TYPE_RINGTONE: - { - contentData.Set(aEngine->CreateRandomSoundFileL()); - break; - } - //Thumbnail (path) and thumbnailid handling with random is the same, only in script they have different handling - case R_VPBK_FIELD_TYPE_THUMBNAILPIC: - { - contentData.Set(aEngine->RandomPictureFileL()); - break; - } - case R_VPBK_FIELD_TYPE_SYNCCLASS: - case R_VPBK_FIELD_TYPE_LOCPRIVACY: - { - _LIT(KPublic, "Public"); - contentData.Set(KPublic); - break; - } - default: - break; - } - } - break; - } - } - - if( found == EFalse ) - { - TInt phNumFieldCount = sizeof(CreatorVPbkPhoneNumberFields) / sizeof(TInt); - for( TInt phIndex = 0; phIndex < phNumFieldCount; ++phIndex ) - { - if( iFieldType == CreatorVPbkPhoneNumberFields[phIndex] ) - { - contentData.Set(aEngine->RandomString(CCreatorEngine::EPhoneNumber)); - found = ETrue; - break; - } - } - } - - if( found == EFalse ) - { - TInt emailFieldCount = sizeof(CreatorVPbkEmailFields) / sizeof(TInt); - for( TInt eIndex = 0; eIndex < emailFieldCount; ++eIndex ) - { - if( iFieldType == CreatorVPbkEmailFields[eIndex] ) - { - iPtr = aEngine->CreateEmailAddressLC(); - CleanupStack::Pop(); - return; - } - } - } - iPtr = HBufC::NewL(contentData.Length()); - iPtr->Des().Copy(contentData); - } - - void CCreatorContactTextField::SetExplicitRandomContentL(CCreatorEngine* aEngine, TInt aRandomLen) - { - LOGSTRING("Creator: CCreatorContactTextField::SetExplicitRandomContentL"); - if( iPtr ) - { - delete iPtr; - iPtr = 0; - } - iPtr = aEngine->CreateRandomStringLC(aRandomLen); - CleanupStack::Pop(); // iPtr - } - - void CCreatorContactTextField::ParseL(CCommandParser* parser) - { - parser->StrParserL(iPtr, '|'); - } - - void CCreatorContactTextField::ConstructL(const TDesC& aData) - { - iPtr = HBufC::New(KPhonebookFieldLength); - iPtr->Des().Copy(aData); - } - - CCreatorContactTextField* CCreatorContactTextField::NewL(TInt aFieldType, const TDesC& aData) - { - CCreatorContactTextField* self = new (ELeave) CCreatorContactTextField(aFieldType); - CleanupStack::PushL(self); - self->ConstructL(aData); - CleanupStack::Pop(); - return self; - } - /** - * CCreatorContactBinaryField Binary field implementation - */ - class CCreatorContactBinaryField : public CCreatorContactFieldImpl - { -public: - static CCreatorContactBinaryField* NewL(TInt aFieldType, const TDesC8& aData); - ~CCreatorContactBinaryField(); - virtual void AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk); - virtual void ParseL(CCommandParser* parser); - virtual void SetDefaultRandomContentL(CCreatorEngine* aEngine); -private: - CCreatorContactBinaryField(TInt aFieldType); - void ConstructL(const TDesC8& aData); - HBufC8* iPtr; - }; - - CCreatorContactBinaryField::CCreatorContactBinaryField(TInt aFieldType) - : CCreatorContactFieldImpl(aFieldType) - { } - CCreatorContactBinaryField::~CCreatorContactBinaryField() - { - delete iPtr; - } - - void CCreatorContactBinaryField::ConstructL(const TDesC8& aData) - { - iPtr = HBufC8::New(KPhonebookFieldLength); - iPtr->Des() = aData; - } - - CCreatorContactBinaryField* CCreatorContactBinaryField::NewL(TInt aFieldType, const TDesC8& aData) - { - CCreatorContactBinaryField* self = new (ELeave) CCreatorContactBinaryField(aFieldType); - CleanupStack::PushL(self); - self->ConstructL(aData); - CleanupStack::Pop(); - return self; - } - -void CCreatorContactBinaryField::AddToContactL(CCreatorEngine* /*aEngine*/, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk) - { - LOGSTRING("Creator: CCreatorContactBinaryField::AddToContactL"); - if( aVPbk == 0 ) - User::Leave(KErrArgument); - if( iPtr ) - { - aVPbk->AddFieldToContactItemL(aContact, iFieldType, iPtr->Des()); - } - } -void CCreatorContactBinaryField::ParseL(CCommandParser* parser) - { - parser->StrParserL(iPtr, '&'); - } - -void CCreatorContactBinaryField::SetDefaultRandomContentL(CCreatorEngine* /*aEngine*/) - { - LOGSTRING("Creator: CCreatorContactBinaryField::SetDefaultRandomContentL"); - } - -/** - * CCreatorContactDateTimeField - */ -class CCreatorContactDateTimeField : public CCreatorContactFieldImpl - { -public: - static CCreatorContactDateTimeField* NewL(TInt aFieldType, const TTime& aData); - ~CCreatorContactDateTimeField(); - virtual void AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk); - virtual void ParseL(CCommandParser* parser); -private: -CCreatorContactDateTimeField(TInt aFieldType); - void ConstructL(const TTime& aData); - TTime iPtr; - }; - -CCreatorContactDateTimeField::CCreatorContactDateTimeField(TInt aFieldType) -: CCreatorContactFieldImpl(aFieldType) - { } -CCreatorContactDateTimeField::~CCreatorContactDateTimeField() - { - } - - void CCreatorContactDateTimeField::ConstructL(const TTime& aData) - { - iPtr = aData; - } - - CCreatorContactDateTimeField* CCreatorContactDateTimeField::NewL(TInt aFieldType, const TTime& aData) - { - CCreatorContactDateTimeField* self = new (ELeave) CCreatorContactDateTimeField(aFieldType); - CleanupStack::PushL(self); - self->ConstructL(aData); - CleanupStack::Pop(); - return self; - } - -void CCreatorContactDateTimeField::AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk) - { - LOGSTRING("Creator: CCreatorContactDateTimeField::AddToContactL"); - if( aVPbk == 0 ) - User::Leave(KErrArgument); - - //TTime undefTime(); - if( iPtr == Time::NullTTime() ) - { - iPtr = aEngine->RandomDate(CCreatorEngine::EDateFuture); - } - - aVPbk->AddFieldToContactItemL(aContact, iFieldType, iPtr); - } -void CCreatorContactDateTimeField::ParseL(CCommandParser* /*parser*/) - { - //parser->StrParserL(iPtr, '&'); - } - -/** - * CCreatorContactField Contact field API - */ -CCreatorContactField* CCreatorContactField::NewL(TInt aFieldType, const TDesC& aData) - { - CCreatorContactField* self = new (ELeave) CCreatorContactField(); - CleanupStack::PushL(self); - self->ConstructL(aFieldType, aData); - CleanupStack::Pop(); - return self; - } - -CCreatorContactField* CCreatorContactField::NewL(TInt aFieldType, const TDesC8& aData) - { - CCreatorContactField* self = new (ELeave) CCreatorContactField(); - CleanupStack::PushL(self); - self->ConstructL(aFieldType, aData); - CleanupStack::Pop(); - return self; - } - -CCreatorContactField* CCreatorContactField::NewL(TInt aFieldType, const TTime& aData) - { - CCreatorContactField* self = new (ELeave) CCreatorContactField(); - CleanupStack::PushL(self); - self->ConstructL(aFieldType, aData); - CleanupStack::Pop(); - return self; - } - -void CCreatorContactField::ConstructL(TInt aFieldType, const TDesC& aData) - { - pImpl = CCreatorContactTextField::NewL(aFieldType, aData); - } - -void CCreatorContactField::ConstructL(TInt aFieldType, const TDesC8& aData) - { - pImpl = CCreatorContactBinaryField::NewL(aFieldType, aData); - } - -void CCreatorContactField::ConstructL(TInt aFieldType, const TTime& aData) - { - pImpl = CCreatorContactDateTimeField::NewL(aFieldType, aData); - } - -CCreatorContactField::CCreatorContactField() - {} -CCreatorContactField::~CCreatorContactField() - { - delete pImpl; - } - -TInt CCreatorContactField::FieldType() - { - return pImpl->FieldType(); - } -void CCreatorContactField::AddToContactL(CCreatorEngine* aEngine, MVPbkStoreContact& aContact, CCreatorVirtualPhonebook* aVPbk) - { - pImpl->AddToContactL(aEngine, aContact, aVPbk); - } -void CCreatorContactField::ParseL(CCommandParser* parser) - { - pImpl->ParseL(parser); - } - -void CCreatorContactField::SetRandomParametersL(TRandomLengthType aRandomLenType, TInt aRandomLen ) - { - pImpl->SetRandomParametersL(aRandomLenType, aRandomLen); - } diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/inc/engine.h --- a/creator/inc/engine.h Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/inc/engine.h Tue Jul 06 14:17:03 2010 +0300 @@ -46,7 +46,7 @@ class CCreatorCalendarBase; class CCreatorNotepad; class CCreatorLogs; -class CCreatorAccessPoints; +//class CCreatorAccessPoints; class CCreatorMailboxes; class CCreatorIMPS; class CCreatorFiles; @@ -55,7 +55,7 @@ class MCreatorModuleBase; class CCreatorPhonebookBase; class CCreatorModuleBaseParameters; -class CCreatorConnectionSettingsBase; +//class CCreatorConnectionSettingsBase; class CDictionaryFileStore; class CImageDecoder; class CFbsBitmap; @@ -129,15 +129,18 @@ class TMemoryDetails { public: - TBuf<16> iCFree; - TBuf<16> iDFree; - TBuf<16> iEFree; - TBuf<16> iHFree; - TBuf<16> iCSize; - TBuf<16> iDSize; + + TBuf<16> iFree; + TBuf<16> iSize; + TChar iDriveLetter; + + TBuf<16> iRamFree; + TBuf<16> iRomFree; + TBool iENotAvailable; - TBuf<16> iESize; - TBuf<16> iHSize; + + TBuf<16> iRamSize; + TBuf<16> iRomSize; }; // Common constant for undefined integer value: const TInt KUndef = KErrNotFound; @@ -238,6 +241,7 @@ static CCreatorEngine* NewLC(EngineWrapper *aEngineWrapper); ~CCreatorEngine(); + inline RPointerArray GetMemoryDetailsList(){ return iMemoryDetailsList; }; inline TMemoryDetails GetMemoryDetails(){ return iMemoryDetails; }; inline EngineWrapper* GetEngineWrapper(){ return iEngineWrapper; }; @@ -406,7 +410,7 @@ CCreatorPhonebookBase* iPhonebook; CCreatorNotepad* iNotepad; CCreatorLogs* iLogs; - CCreatorConnectionSettingsBase* iAccessPoints; +// CCreatorConnectionSettingsBase* iAccessPoints; CCreatorMailboxes* iMailboxes; CCreatorIMPS* iIMPS; CCreatorFiles* iFiles; @@ -435,6 +439,9 @@ EngineWrapper* iEngineWrapper; // Enginewrapper that is used for communicating between QT and Symbian TMemoryDetails iMemoryDetails; + + RPointerArray iMemoryDetailsList; + TInt iResourceFileId; HBufC* iCommandLineScriptName; diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/inc/enginewrapper.h --- a/creator/inc/enginewrapper.h Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/inc/enginewrapper.h Tue Jul 06 14:17:03 2010 +0300 @@ -65,6 +65,11 @@ */ MemoryDetails GetMemoryDetails(); + /** + * Get memory details list + */ + QList GetMemoryDetailsList(); + public: /* Functions that are called from UI */ diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/inc/mainview.h --- a/creator/inc/mainview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/inc/mainview.h Tue Jul 06 14:17:03 2010 +0300 @@ -30,15 +30,13 @@ class MemoryDetails { public: - QString mCFree; - QString mDFree; - QString mEFree; - QString mHFree; - QString mCSize; - QString mDSize; + QString mFree; + QString mSize; + QString mDriveLetter; + + QString mRamFree; bool mENotAvailable; - QString mESize; - QString mHSize; + QString mRamSize; }; /** @@ -195,6 +193,7 @@ MemoryDetails mMemoryDetails; + QList mMemoryDetailsList; // signal mapper QSignalMapper *mSm; }; diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/src/engine.cpp --- a/creator/src/engine.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/src/engine.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -20,6 +20,8 @@ #include #include +#include + #include #include "mainview.h" @@ -31,12 +33,12 @@ #include "creator_scriptentry.h" #include "creator_modulebase.h" -#include "creator_browser.h" +//#include "creator_browser.h" #include "creator_calendar.h" #include "creator_phonebookbase.h" #include "creator_note.h" #include "creator_log.h" -#include "creator_connectionmethodbase.h" +//#include "creator_connectionmethodbase.h" #include "creator_mailbox.h" //#include "creator_imps.h" #include "creator_message.h" @@ -140,6 +142,7 @@ iEnv->DeleteResourceFile(iResourceFileId); + iMemoryDetailsList.Reset(); delete iPictureFileArray; delete iSoundFileArray; delete iTempPath; @@ -174,52 +177,49 @@ void CCreatorEngine::RequestMemoryDetails() { + + TDriveList dl; // variables for memory and disk handling - TDriveNumber cDrive=EDriveC; - TDriveNumber dDrive=EDriveD; - TDriveNumber eDrive=EDriveE; TVolumeInfo vinfo; - TBuf<16> cFree; - TBuf<16> dFree; - TBuf<16> eFree; - TBuf<16> cSize; - TBuf<16> dSize; - TBuf<16> eSize; + //************************************************************************* + + //************************************************************************* // get an access to file server RFs& fsSession = CEikonEnv::Static()->FsSession(); - // check the C-drive - fsSession.Volume(vinfo, cDrive); - iMemoryDetails.iCFree.Num(TInt64(vinfo.iFree/1024)); - iMemoryDetails.iCSize.Num(TInt64(vinfo.iSize/1024)); - - // the same thing for D-drive - fsSession.Volume(vinfo, dDrive); - iMemoryDetails.iDFree.Num(TInt64(vinfo.iFree/1024)); - iMemoryDetails.iDSize.Num(TInt64(vinfo.iSize/1024)); - - // the same thing for E-drive (MMC), if it exists - if (MMC_OK()) - { - fsSession.Volume(vinfo, eDrive); - iMemoryDetails.iEFree.Num(TInt64(vinfo.iFree/1024)); - iMemoryDetails.iESize.Num(TInt64(vinfo.iSize/1024)); - - } - - else { - iMemoryDetails.iEFree = KEDriveError; - iMemoryDetails.iENotAvailable = ETrue; - } + fsSession.DriveList(dl); + + for(TInt driveNum = EDriveC; driveNum <= EDriveZ ; driveNum ++ ) + { + if( dl[driveNum] ) + { + TMemoryDetails *memDet = new TMemoryDetails; + if(fsSession.Volume(vinfo, driveNum) == KErrNone) + { + memDet->iFree.Num(TInt64(vinfo.iFree/1024)); + memDet->iSize.Num(TInt64(vinfo.iSize/1024)); + } + else + { + memDet->iFree.Num( 0 ); + memDet->iSize.Num( 0 ); + } + User::LeaveIfError(fsSession.DriveToChar(driveNum,memDet->iDriveLetter)); + iMemoryDetailsList.AppendL( memDet ); + } + } + // available work memory TMemoryInfoV1Buf memory; UserHal::MemoryInfo(memory); TInt64 freeMemBytes=(TInt64)(memory().iFreeRamInBytes); TInt64 sizeMemBytes=(TInt64)(memory().iTotalRamInBytes); TInt64 sizeWorkMemBytes = sizeMemBytes; - iMemoryDetails.iHFree.Num(TInt64(freeMemBytes/1024)); - iMemoryDetails.iHSize.Num(TInt64(sizeWorkMemBytes/1024)); + TInt64 sizeRomBytes = (TInt64)(memory().iTotalRomInBytes); + iMemoryDetails.iRamFree.Num(TInt64(freeMemBytes/1024)); + iMemoryDetails.iRamSize.Num(TInt64(sizeWorkMemBytes/1024)); + iMemoryDetails.iRomSize.Num(TInt64(sizeRomBytes/1024)); } // --------------------------------------------------------------------------- @@ -304,11 +304,12 @@ TCreatorIds cmd = (TCreatorIds)iCommandArray->At(iCurrentEntry).iCommandId; switch( cmd ) { +/* case ECmdCreateBrowserBookmarkEntries: { iBrowser->CreateBookmarkEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; case ECmdCreateBrowserBookmarkFolderEntries: { iBrowser->CreateBookmarkFolderEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; case ECmdCreateBrowserSavedPageEntries: { iBrowser->CreateSavedDeckEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; case ECmdCreateBrowserSavedPageFolderEntries: { iBrowser->CreateSavedDeckFolderEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; - +*/ case ECmdCreateCalendarEntryAppointments: { iCalendar->CreateAppointmentEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; case ECmdCreateCalendarEntryEvents: { iCalendar->CreateEventEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; case ECmdCreateCalendarEntryAnniversaries: { iCalendar->CreateAnniversaryEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; @@ -325,11 +326,11 @@ case ECmdCreateLogEntryMissedCalls: { iLogs->CreateMissedCallEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; case ECmdCreateLogEntryReceivedCalls: { iLogs->CreateReceivedCallEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; case ECmdCreateLogEntryDialledNumbers: { iLogs->CreateDialledNumberEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; - +/* case ECmdCreateMiscEntryAccessPoints: { iAccessPoints->CreateConnectionSettingsEntryL(iCommandArray->At(iCurrentEntry).iParameters); } break; case ECmdDeleteIAPs: { iAccessPoints->DeleteAllL(); } break; case ECmdDeleteCreatorIAPs: { iAccessPoints->DeleteAllCreatedByCreatorL(); } break; - +*/ case ECmdCreateMiscEntryLandmarks: { iLandmarks->CreateLandmarkEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; case ECmdCreateMessagingEntryMailboxes: { iMailboxes->CreateMailboxEntryL(reinterpret_cast(iCommandArray->At(iCurrentEntry).iParameters)); } break; @@ -494,7 +495,8 @@ { // iIMPS->DeleteAllCreatedByCreatorL(); break; - } + } +/* case ECmdDeleteBrowserBookmarks: { iBrowser->DeleteAllBookmarksL(); @@ -535,6 +537,7 @@ iBrowser->DeleteAllSavedPageFoldersCreatedByCreatorL(); break; } +*/ case ECmdDeleteCreatorFiles: { iFiles->DeleteAllCreatedByCreatorL(); @@ -723,12 +726,12 @@ // init all modules here TInt err(KErrNone); - TRAP(err, iBrowser = CCreatorBrowser::NewL(this)); +// TRAP(err, iBrowser = CCreatorBrowser::NewL(this)); TRAP(err, iCalendar = CCreatorInterimCalendar::NewL(this)); TRAP(err, iPhonebook = (CCreatorPhonebookBase*)TCreatorFactory::CreatePhoneBookL(this)); TRAP(err, iNotepad = CCreatorNotepad::NewL(this)); TRAP(err, iLogs = CCreatorLogs::NewL(this)); - TRAP(err, iAccessPoints = (CCreatorConnectionSettingsBase*)TCreatorFactory::CreateConnectionSettingsL(this)); +// TRAP(err, iAccessPoints = (CCreatorConnectionSettingsBase*)TCreatorFactory::CreateConnectionSettingsL(this)); TRAP(err, iMailboxes = CCreatorMailboxes::NewL(this)); TRAP(err, iFiles = CCreatorFiles::NewL(this)); TRAP(err, iMessages = CCreatorMessages::NewL(this)); @@ -767,8 +770,8 @@ iFiles = NULL; delete iMailboxes; iMailboxes = NULL; - delete iAccessPoints; - iAccessPoints = NULL; + // delete iAccessPoints; +// iAccessPoints = NULL; delete iLogs; iLogs = NULL; delete iNotepad; @@ -777,8 +780,8 @@ iPhonebook = NULL; delete iCalendar; iCalendar = NULL; - delete iBrowser; - iBrowser = NULL; + // delete iBrowser; + // iBrowser = NULL; delete iLandmarks; iLandmarks = NULL; @@ -945,14 +948,14 @@ AppendToCommandArrayL( ECmdDeleteContacts, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteContactGroups, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteCalendarEntries, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteBrowserBookmarks, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteBrowserBookmarkFolders, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteBrowserSavedPages, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteBrowserSavedPageFolders, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteBrowserBookmarks, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteBrowserBookmarkFolders, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteBrowserSavedPages, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteBrowserSavedPageFolders, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteLogs, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteMessages, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteIAPs, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteIMPSs, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteIAPs, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteIMPSs, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteNotes, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteLandmarks, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteCreatorFiles, NULL, 1 ); @@ -964,15 +967,17 @@ AppendToCommandArrayL( ECmdDeleteCreatorContacts, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteCreatorContactGroups, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteCreatorCalendarEntries, NULL, 1 ); + /* AppendToCommandArrayL( ECmdDeleteCreatorBrowserBookmarks, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteCreatorBrowserBookmarkFolders, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteCreatorBrowserSavedPages, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteCreatorBrowserSavedPageFolders, NULL, 1 ); + */ AppendToCommandArrayL( ECmdDeleteCreatorFiles, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteCreatorLogs, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteCreatorMessages, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteCreatorIAPs, NULL, 1 ); - AppendToCommandArrayL( ECmdDeleteCreatorIMPSs, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteCreatorIAPs, NULL, 1 ); + //AppendToCommandArrayL( ECmdDeleteCreatorIMPSs, NULL, 1 ); AppendToCommandArrayL( ECmdDeleteCreatorLandmarks, NULL, 1 ); // started exucuting delete commands @@ -997,7 +1002,8 @@ // set the home module switch(aCommand) { - case ECmdCreateBrowserBookmarkEntries: +/* + case ECmdCreateBrowserBookmarkEntries: case ECmdCreateBrowserBookmarkFolderEntries: case ECmdCreateBrowserSavedPageEntries: case ECmdCreateBrowserSavedPageFolderEntries: @@ -1013,7 +1019,7 @@ iUsedOptionsMenuModule = iBrowser; } break; - +*/ case ECmdCreateCalendarEntryAppointments: case ECmdCreateCalendarEntryEvents: case ECmdCreateCalendarEntryAnniversaries: @@ -1054,7 +1060,7 @@ iUsedOptionsMenuModule = iLogs; } break; - +/* case ECmdCreateMiscEntryAccessPoints: case ECmdDeleteIAPs: case ECmdDeleteCreatorIAPs: @@ -1062,7 +1068,7 @@ iUsedOptionsMenuModule = iAccessPoints; } break; - +*/ case ECmdCreateMessagingEntryMailboxes: case ECmdDeleteMailboxes: case ECmdDeleteCreatorMailboxes: @@ -1835,7 +1841,8 @@ { LOGSTRING("Creator: CCreatorEngine::AccessPointNameToIdL"); // Accespoint impl moved from engine to accespoint implementations for supporting 3.0-3.1 and 3.2-> - return iAccessPoints->AccessPointNameToIdL(aAPName, aAnyIfNotFound ); + //return iAccessPoints->AccessPointNameToIdL(aAPName, aAnyIfNotFound ); + return 0; } static CCreatorEngine::TTestDataPath SoundFiles[] = { diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/src/enginewrapper.cpp --- a/creator/src/enginewrapper.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/src/enginewrapper.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -68,28 +68,37 @@ // --------------------------------------------------------------------------- +QList EngineWrapper::GetMemoryDetailsList() + { + RPointerArray tMemDetList = iEngine->GetMemoryDetailsList(); + QList memDetList; + MemoryDetails memDet; + for(int i=0; iiFree.Ptr(), tMemDetList.operator [](i)->iFree.Length());//QString((QChar*) temp->iFree.Ptr(), temp->iFree.Length()); + QString size = QString::fromUtf16(tMemDetList.operator [](i)->iSize.Ptr(), tMemDetList.operator [](i)->iSize.Length());//QString((QChar*) temp->iSize.Ptr(), temp->iSize.Length()); + QString driveLetter = QString::fromUtf8((const char*) &tMemDetList.operator [](i)->iDriveLetter, (int) sizeof(char) );//QString((QChar*) &temp->iDriveLetter, (int) sizeof( char ) ); + memDet.mFree = free; //QString((QChar*)tMemDetList[i]->iFree.Ptr(), tMemDetList[i]->iFree.Length()); + memDet.mSize = size; //QString((QChar*) tMemDetList[i]->iSize.Ptr(), tMemDetList[i]->iSize.Length()); + memDet.mDriveLetter = driveLetter; + + //memDetList[i].mDriveLetter = QString::fromUtf8( (char *) &tMemDetList[i]->iDriveLetter, (int) sizeof( char ) ); + memDetList.append( memDet ); + } + return memDetList; + } + MemoryDetails EngineWrapper::GetMemoryDetails() { + TMemoryDetails tMemoryDetails = iEngine->GetMemoryDetails(); MemoryDetails memoryDetails; // Convert TMemoryDetails to MemoryDetails - memoryDetails.mCFree = QString((QChar*)tMemoryDetails.iCFree.Ptr(), tMemoryDetails.iCFree.Length()); - memoryDetails.mDFree = QString((QChar*)tMemoryDetails.iDFree.Ptr(), tMemoryDetails.iDFree.Length()); - memoryDetails.mEFree = QString((QChar*)tMemoryDetails.iEFree.Ptr(), tMemoryDetails.iEFree.Length()); - memoryDetails.mHFree = QString((QChar*)tMemoryDetails.iHFree.Ptr(), tMemoryDetails.iHFree.Length()); - - memoryDetails.mCSize = QString((QChar*)tMemoryDetails.iCSize.Ptr(), tMemoryDetails.iCSize.Length()); - memoryDetails.mDSize = QString((QChar*)tMemoryDetails.iDSize.Ptr(), tMemoryDetails.iDSize.Length()); - memoryDetails.mHSize = QString((QChar*)tMemoryDetails.iHSize.Ptr(), tMemoryDetails.iHSize.Length()); - - if (tMemoryDetails.iENotAvailable == EFalse) { - memoryDetails.mESize = QString((QChar*)tMemoryDetails.iESize.Ptr(), tMemoryDetails.iESize.Length()); - memoryDetails.mENotAvailable = false; - } - else { - memoryDetails.mENotAvailable = true; - } + memoryDetails.mRamFree = QString((QChar*)tMemoryDetails.iRamFree.Ptr(), tMemoryDetails.iRamFree.Length()); + memoryDetails.mRamSize = QString((QChar*)tMemoryDetails.iRamSize.Ptr(), tMemoryDetails.iRamSize.Length()); + return memoryDetails; } diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/src/mainview.cpp --- a/creator/src/mainview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/src/mainview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -509,30 +509,31 @@ // get memory details from engine; mMemoryDetails = mEngineWrapper.GetMemoryDetails(); - if (layout != NULL) { - HbTextEdit* edit = new HbTextEdit(this); - if(edit != NULL) { - if (mMemoryDetails.mENotAvailable == false) { - edit->setPlainText(QString("\n\nFree RAM Memory:\n %1 of %2 kB \n\nFree disk memory: \nC: %3 of %4 kB \nD: %5 of %6 kB \nE: %7 of %8 kB") - .arg(mMemoryDetails.mHFree).arg(mMemoryDetails.mHSize) - .arg(mMemoryDetails.mCFree).arg(mMemoryDetails.mCSize) - .arg(mMemoryDetails.mDFree).arg(mMemoryDetails.mDSize) - .arg(mMemoryDetails.mEFree).arg(mMemoryDetails.mESize)); - } - else { - edit->setPlainText(QString("\n\nFree RAM Memory:\n %1 of %2 kB \n\nFree disk memory: \nC: %3 of %4 kB \nD: %5 of %6 kB \nE: %7") - .arg(mMemoryDetails.mHFree).arg(mMemoryDetails.mHSize) - .arg(mMemoryDetails.mCFree).arg(mMemoryDetails.mCSize) - .arg(mMemoryDetails.mDFree).arg(mMemoryDetails.mDSize) - .arg(mMemoryDetails.mEFree)); - } - edit->setReadOnly(true); + QList memDet = mEngineWrapper.GetMemoryDetailsList(); + + if (layout != NULL) + { + HbLabel* edit = new HbLabel(this); + //HbTextEdit* edit = new HbTextEdit(this); + if(edit != NULL) + { + QString text = QString("

Free RAM Memory:
%1 of %2 kB").arg(mMemoryDetails.mRamFree).arg(mMemoryDetails.mRamSize); + //QString text = QString("\n\nFree RAM Memory:\n %1 of %2 kB").arg(mMemoryDetails.mRamFree).arg(mMemoryDetails.mRamSize); + for(int i=0 ; i < memDet.count() ; i++ ) + { + text += QString("

Free %1: Memory:
%2 of %3 kB").arg(memDet[i].mDriveLetter).arg(memDet[i].mFree).arg(memDet[i].mSize);//text += QString("\n\nFree %1: Memory:\n %2 of %3 kB").arg(memDet[i].mDriveLetter).arg(memDet[i].mFree).arg(memDet[i].mSize); + } + edit->setTextWrapping(Hb::TextWordWrap); + edit->setHtml(text); + //edit->setPlainText(text); + + //edit->setReadOnly(true); //edit->setCursorHidden(true); - //edit->setAttribute(Qt::WA_InputMethodEnabled, false); + edit->setAttribute(Qt::WA_InputMethodEnabled, false); layout->addItem(edit); layout->setContentsMargins(5, 5, 5, 5); this->setLayout(layout); - } + } } diff -r e0ec97ec3cc4 -r 98924d2efce9 creator/src/notifications.cpp --- a/creator/src/notifications.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/creator/src/notifications.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -54,7 +54,7 @@ void Notifications::about() { showMessageBox(HbMessageBox::MessageTypeInformation, - "Version 6.0.1 - June 4th 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.", + "Version 6.1.0 - June 18th 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0.", "About Creator", HbPopup::NoTimeout ); diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/engine/FBFileOps.cpp --- a/filebrowser/engine/FBFileOps.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/engine/FBFileOps.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -254,6 +254,8 @@ } else { + // ensure that root target folder exists + BaflUtils::EnsurePathExistsL(iFs, iBuf2); // otherwise copy the file FileOpCopy(fullSourcePath, fullTargetPath, iUint1); } @@ -331,7 +333,11 @@ { path.Append(entry.iName); path.Append(_L("\\")); - DoFindEntries(aFileName, path); + // test path.Left(iBuf2.Length()).Compare(iBuf2) - to prevent never ending recursive copy (in case of copy folder under itself) + if( !(iRecursiveState == EFileOpCopy && !path.Left(iBuf2.Length()).Compare(iBuf2)) ) + { + DoFindEntries(aFileName, path); + } } } if ( iFileManObserverResult == MFileManObserver::ECancel ) @@ -380,17 +386,13 @@ iBuf2.Copy(targetPath); iUint1 = newSwitch; - // create initial directory - if it does not succeed, do not even try to continue - err = FileOpMkDirAll(targetPath, aSourceEntry.iEntry.iAtt); - - if (iOperationError == KErrNone) + TRAP(err, DoFindEntries(_L("*"), sourcePath)); // entries under current directory entry + if ( iFileManObserverResult != MFileManObserver::ECancel ) { - TRAP(err, DoFindEntries(_L("*"), sourcePath)); // entries under current directory entry - if ( iFileManObserverResult != MFileManObserver::ECancel ) - { - TRAP(err, DoFindEntriesRecursiveL(_L("*"), sourcePath)); // recursively under directories of current directory entry - } + TRAP(err, DoFindEntriesRecursiveL(_L("*"), sourcePath)); // recursively under directories of current directory entry } + // a path has a trailing backslash so it needs to be removed before the call + err = FileOpAttribs(targetPath.Left(targetPath.Length()-1), aSourceEntry.iEntry.iAtt, 0, 0, 0); } else if (aSourceEntry.iEntry.IsDir()) diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/engine/FBFileUtils.cpp --- a/filebrowser/engine/FBFileUtils.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/engine/FBFileUtils.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -33,9 +32,8 @@ #include #include #include -#include #include -#include +//#include #include #include #include @@ -121,7 +119,7 @@ iCurrentSelectionList = new(ELeave) CFileEntryList(64); iDocHandler = CDocumentHandler::NewL(); - iDocHandler->SetExitObserver(this); +// iDocHandler->SetExitObserver(this); // set defaults to the search settings iSearchAttributes.iSearchDir = KNullDesC; @@ -635,22 +633,6 @@ // if (iEngine->FileListContainer()) // { - // update navi pane text -// if (iListingMode == ENormalEntries) -// iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath); -// else if (iListingMode == ESearchResults) -// iEngine->FileListContainer()->SetNaviPaneTextL(_L("Search results")); -// else if (iListingMode == EOpenFiles) -// iEngine->FileListContainer()->SetNaviPaneTextL(_L("Open files")); -// else if (iListingMode == EMsgAttachmentsInbox) -// iEngine->FileListContainer()->SetNaviPaneTextL(_L("Attachments in Inbox")); -// else if (iListingMode == EMsgAttachmentsDrafts) -// iEngine->FileListContainer()->SetNaviPaneTextL(_L("Attachments in Drafts")); -// else if (iListingMode == EMsgAttachmentsSentItems) -// iEngine->FileListContainer()->SetNaviPaneTextL(_L("Attachments in Sent Items")); -// else if (iListingMode == EMsgAttachmentsOutbox) -// iEngine->FileListContainer()->SetNaviPaneTextL(_L("Attachments in Outbox")); -// // // create a list box if it doesn't already exist // if (!iEngine->FileListContainer()->ListBox()) // iEngine->FileListContainer()->CreateListBoxL(iEngine->Settings().iFileViewMode); @@ -683,153 +665,153 @@ // -------------------------------------------------------------------------------------------- -/*CAknIconArray* CFileBrowserFileUtils::GenerateIconArrayL(TBool aGenerateNewBasicIconArray) - { - // TODO - - CAknIconArray* iconArray = NULL; - - if (aGenerateNewBasicIconArray) - { - iconArray = new(ELeave) CAknIconArray(16); - } - else - { - if (iEngine->FileListContainer()) - iconArray = iEngine->FileListContainer()->ListBoxIconArrayL(); - - if (!iconArray) - iconArray = new(ELeave) CAknIconArray(16); - } - - - CleanupStack::PushL(iconArray); - - // generate basic items if not already existing - if (iconArray->Count() < EFixedIconListLength) - { - // reset arrays - iconArray->Reset(); - iAppIconList->Reset(); - - // get default control color - TRgb defaultColor; - defaultColor = iEngine->EikonEnv()->Color(EColorControlText); - - // create a color icon of the marking indicator - CFbsBitmap* markBitmap = NULL; - CFbsBitmap* markBitmapMask = NULL; - - AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(), - KAknsIIDQgnIndiMarkedAdd, - KAknsIIDQsnIconColors, - EAknsCIQsnIconColorsCG13, - markBitmap, - markBitmapMask, - AknIconUtils::AvkonIconFileName(), - EMbmAvkonQgn_indi_marked_add, - EMbmAvkonQgn_indi_marked_add_mask, - defaultColor - ); - - // 0 marking indicator - CGulIcon* markIcon = CGulIcon::NewL(markBitmap, markBitmapMask); - iconArray->AppendL(markIcon); - - // 1 empty - AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), - EMbmAvkonQgn_prop_empty, EMbmAvkonQgn_prop_empty_mask, KAknsIIDQgnPropEmpty); - // 2 phone memory - AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), - EMbmAvkonQgn_prop_phone_memc, EMbmAvkonQgn_prop_phone_memc_mask, KAknsIIDQgnPropPhoneMemc); - // 3 memory card - AppendGulIconToIconArrayL(iconArray, KMemoryCardUiBitmapFile, - EMbmAknmemorycarduiQgn_prop_mmc_memc, EMbmAknmemorycarduiQgn_prop_mmc_memc_mask, KAknsIIDQgnPropMmcMemc); - // 4 memory card disabled - AppendGulIconToIconArrayL(iconArray, KMemoryCardUiBitmapFile, - EMbmAknmemorycarduiQgn_prop_mmc_non, EMbmAknmemorycarduiQgn_prop_mmc_non_mask, KAknsIIDQgnPropMmcNon); - // 5 folder - AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), - EMbmAvkonQgn_prop_folder_small, EMbmAvkonQgn_prop_folder_small_mask, KAknsIIDQgnPropFolderSmall); - // 6 folder with subfolders - AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), - EMbmAvkonQgn_prop_folder_sub_small, EMbmAvkonQgn_prop_folder_sub_small_mask, KAknsIIDQgnPropFolderSubSmall); - // 7 current folder - AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), - EMbmAvkonQgn_prop_folder_current, EMbmAvkonQgn_prop_folder_current_mask, KAknsIIDQgnPropFolderCurrent); - } - - // append custom icons if not in drive list view and setting is enabled - if (!aGenerateNewBasicIconArray && !IsDriveListViewActive() && iEngine->Settings().iShowAssociatedIcons) - { - // init id counter - TInt idCounter(EFixedIconListLength + iAppIconList->Count()); - - // loop all items in the file list - for (TInt i=0; iCount(); i++) - { - TFileEntry& fileEntry = iFileEntryList->At(i); - - // just check for normal files - if (!fileEntry.iEntry.IsDir()) - { - TUid appUid = GetAppUid(fileEntry); - TInt iconId = AppIconIdForUid(appUid); - - if (appUid != KNullUid && iconId == KErrNotFound) - { - // icon not found from the icon array, generate it - CFbsBitmap* bitmap = NULL; - CFbsBitmap* mask = NULL; - CGulIcon* appIcon = NULL; - - TRAPD(err, - AknsUtils::CreateAppIconLC(AknsUtils::SkinInstance(), appUid, EAknsAppIconTypeList, bitmap, mask); - appIcon = CGulIcon::NewL(bitmap, mask); - CleanupStack::Pop(2); //bitmap, mask - ); - - if (err == KErrNone) - { - TAppIcon appIconEntry; - appIconEntry.iId = idCounter; - appIconEntry.iUid = appUid; - - appIcon->SetBitmapsOwnedExternally(EFalse); - iconArray->AppendL(appIcon); - iAppIconList->AppendL(appIconEntry); - - fileEntry.iIconId = idCounter; - - idCounter++; - } - else - { - delete bitmap; - delete mask; - - TAppIcon appIconEntry; - appIconEntry.iId = EFixedIconEmpty; - appIconEntry.iUid = appUid; - - iAppIconList->AppendL(appIconEntry); - } - } - - else if (appUid != KNullUid && iconId >= 0) - { - // we already have already generated an icon for this uid, use it - fileEntry.iIconId = iconId; - } - } - } - } - - CleanupStack::Pop(); //iconArray - return iconArray; - - } -*/ +//CAknIconArray* CFileBrowserFileUtils::GenerateIconArrayL(TBool aGenerateNewBasicIconArray) +// { +// // TODO +// +// CAknIconArray* iconArray = NULL; +// +// if (aGenerateNewBasicIconArray) +// { +// iconArray = new(ELeave) CAknIconArray(16); +// } +// else +// { +// if (iEngine->FileListContainer()) +// iconArray = iEngine->FileListContainer()->ListBoxIconArrayL(); +// +// if (!iconArray) +// iconArray = new(ELeave) CAknIconArray(16); +// } +// +// +// CleanupStack::PushL(iconArray); +// +// // generate basic items if not already existing +// if (iconArray->Count() < EFixedIconListLength) +// { +// // reset arrays +// iconArray->Reset(); +// iAppIconList->Reset(); +// +// // get default control color +// TRgb defaultColor; +// defaultColor = iEngine->EikonEnv()->Color(EColorControlText); +// +// // create a color icon of the marking indicator +// CFbsBitmap* markBitmap = NULL; +// CFbsBitmap* markBitmapMask = NULL; +// +// AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(), +// KAknsIIDQgnIndiMarkedAdd, +// KAknsIIDQsnIconColors, +// EAknsCIQsnIconColorsCG13, +// markBitmap, +// markBitmapMask, +// AknIconUtils::AvkonIconFileName(), +// EMbmAvkonQgn_indi_marked_add, +// EMbmAvkonQgn_indi_marked_add_mask, +// defaultColor +// ); +// +// // 0 marking indicator +// CGulIcon* markIcon = CGulIcon::NewL(markBitmap, markBitmapMask); +// iconArray->AppendL(markIcon); +// +// // 1 empty +// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), +// EMbmAvkonQgn_prop_empty, EMbmAvkonQgn_prop_empty_mask, KAknsIIDQgnPropEmpty); +// // 2 phone memory +// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), +// EMbmAvkonQgn_prop_phone_memc, EMbmAvkonQgn_prop_phone_memc_mask, KAknsIIDQgnPropPhoneMemc); +// // 3 memory card +// AppendGulIconToIconArrayL(iconArray, KMemoryCardUiBitmapFile, +// EMbmAknmemorycarduiQgn_prop_mmc_memc, EMbmAknmemorycarduiQgn_prop_mmc_memc_mask, KAknsIIDQgnPropMmcMemc); +// // 4 memory card disabled +// AppendGulIconToIconArrayL(iconArray, KMemoryCardUiBitmapFile, +// EMbmAknmemorycarduiQgn_prop_mmc_non, EMbmAknmemorycarduiQgn_prop_mmc_non_mask, KAknsIIDQgnPropMmcNon); +// // 5 folder +// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), +// EMbmAvkonQgn_prop_folder_small, EMbmAvkonQgn_prop_folder_small_mask, KAknsIIDQgnPropFolderSmall); +// // 6 folder with subfolders +// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), +// EMbmAvkonQgn_prop_folder_sub_small, EMbmAvkonQgn_prop_folder_sub_small_mask, KAknsIIDQgnPropFolderSubSmall); +// // 7 current folder +// AppendGulIconToIconArrayL(iconArray, AknIconUtils::AvkonIconFileName(), +// EMbmAvkonQgn_prop_folder_current, EMbmAvkonQgn_prop_folder_current_mask, KAknsIIDQgnPropFolderCurrent); +// } +// +// // append custom icons if not in drive list view and setting is enabled +// if (!aGenerateNewBasicIconArray && !IsDriveListViewActive() && iEngine->Settings().iShowAssociatedIcons) +// { +// // init id counter +// TInt idCounter(EFixedIconListLength + iAppIconList->Count()); +// +// // loop all items in the file list +// for (TInt i=0; iCount(); i++) +// { +// TFileEntry& fileEntry = iFileEntryList->At(i); +// +// // just check for normal files +// if (!fileEntry.iEntry.IsDir()) +// { +// TUid appUid = GetAppUid(fileEntry); +// TInt iconId = AppIconIdForUid(appUid); +// +// if (appUid != KNullUid && iconId == KErrNotFound) +// { +// // icon not found from the icon array, generate it +// CFbsBitmap* bitmap = NULL; +// CFbsBitmap* mask = NULL; +// CGulIcon* appIcon = NULL; +// +// TRAPD(err, +// AknsUtils::CreateAppIconLC(AknsUtils::SkinInstance(), appUid, EAknsAppIconTypeList, bitmap, mask); +// appIcon = CGulIcon::NewL(bitmap, mask); +// CleanupStack::Pop(2); //bitmap, mask +// ); +// +// if (err == KErrNone) +// { +// TAppIcon appIconEntry; +// appIconEntry.iId = idCounter; +// appIconEntry.iUid = appUid; +// +// appIcon->SetBitmapsOwnedExternally(EFalse); +// iconArray->AppendL(appIcon); +// iAppIconList->AppendL(appIconEntry); +// +// fileEntry.iIconId = idCounter; +// +// idCounter++; +// } +// else +// { +// delete bitmap; +// delete mask; +// +// TAppIcon appIconEntry; +// appIconEntry.iId = EFixedIconEmpty; +// appIconEntry.iUid = appUid; +// +// iAppIconList->AppendL(appIconEntry); +// } +// } +// +// else if (appUid != KNullUid && iconId >= 0) +// { +// // we already have already generated an icon for this uid, use it +// fileEntry.iIconId = iconId; +// } +// } +// } +// } +// +// CleanupStack::Pop(); //iconArray +// return iconArray; +// +// } +// // -------------------------------------------------------------------------------------------- //void CFileBrowserFileUtils::AppendGulIconToIconArrayL(CAknIconArray* aIconArray, const TDesC& aIconFile, TInt aIconId, TInt aMaskId, const TAknsItemID aAknsItemId) @@ -1991,7 +1973,7 @@ // iEngine->EikonEnv()->BusyMsgL(_L("** Searching **"), TGulAlignment(EHCenterVTop)); - iEngine->FileBrowserUI()->ShowWaitDialog(_L("** Searching **")); + iEngine->FileBrowserUI()->ShowWaitDialog(_L("Searching")); iFileEntryList->Reset(); // if search dir is empty, find from all drives @@ -2771,15 +2753,15 @@ // -------------------------------------------------------------------------------------------- -void CFileBrowserFileUtils::HandleServerAppExit(TInt aReason) - { +//void CFileBrowserFileUtils::HandleServerAppExit(TInt aReason) +// { // if (iOpenFileService) // { // delete iOpenFileService; // iOpenFileService = NULL; // } - MAknServerAppExitObserver::HandleServerAppExit(aReason); - } +// MAknServerAppExitObserver::HandleServerAppExit(aReason); +// } // -------------------------------------------------------------------------------------------- @@ -3155,7 +3137,7 @@ // update view RefreshViewL(); - if (err == KErrNone) + if (err == KErrNone) { iEngine->FileBrowserUI()->ShowConfirmationNote(_L("State changed")); } @@ -3298,7 +3280,7 @@ CleanupClosePushL(file); iFindFileEntryList->Reset(); - iEngine->FileBrowserUI()->ShowWaitDialog(_L("** Generating **")); + iEngine->FileBrowserUI()->ShowWaitDialog(_L("Generating")); for (TInt i=0; iCount(); i++) { @@ -3323,9 +3305,30 @@ writeBuf.Copy(fileEntry.iPath); writeBuf.Append(fileEntry.iEntry.iName); - writeBuf.Append(_L(" - ")); + writeBuf.Append(_L(",")); writeBuf.AppendNum(fileEntry.iEntry.iSize); writeBuf.Append(_L(" B")); + +// // date +// TTime entryModified = fileEntry.iEntry.iModified; +// // convert from universal time +// if ( iTz.ConvertToLocalTime( entryModified ) == KErrNone ) +// { +// entryModified = fileEntry.iEntry.iModified; // use universal time +// } +// +// _LIT(KDateFormat, "%D%M%Y%/0%1%/1%2%/2%3%/3"); +// TBuf<32> dateBuf; +// entryModified.FormatL(dateBuf, KDateFormat); +// writeBuf.Append(dateBuf); +// +// writeBuf.Append(_L(" ")); +// // time +// _LIT(KTimeFormat, "%-B%:0%J%:1%T%:2%S%:3%+B"); +// TBuf<32> timeBuf; +// entryModified.FormatL(timeBuf, KTimeFormat); +// writeBuf.Append(timeBuf); +// writeBuf.Append(KFileNewLine); file.Write(writeBuf); } @@ -3339,7 +3342,7 @@ TFileName noteMsg; noteMsg.Format(KMessage, &allFilesPath); - iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg, ETrue); // NoTimeout + iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg, EFalse); // NoTimeout } else { diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/engine/FBFileUtils.h --- a/filebrowser/engine/FBFileUtils.h Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/engine/FBFileUtils.h Tue Jul 06 14:17:03 2010 +0300 @@ -24,9 +24,7 @@ #include #include #include -#include #include -#include #include #include "FB.hrh" @@ -40,16 +38,10 @@ // FORWARD DECLARATIONS class CEngine; class CFileBrowserFileOps; -class CAknIconArray; -class TAknsItemID; class CDocumentHandler; -//class CAknWaitDialog; -//class CAknProgressDialog; class CEikProgressInfo; class CFBFileOpClient; -//class CAknProgressDialog; class CEikProgressInfo; -class CAknOpenFileService; class CMessageDigest; // CLASS DECLARATIONS @@ -182,7 +174,7 @@ -class CFileBrowserFileUtils : public CActive, public MAknServerAppExitObserver, public MMsvSessionObserver//, public MProgressDialogCallback +class CFileBrowserFileUtils : public CActive, public MMsvSessionObserver { private: enum TState // active object states @@ -209,9 +201,6 @@ TInt RunError(TInt aError); void DoCancel(); -private: // from MAknServerAppExitObserver - void HandleServerAppExit(TInt aReason); - private: // from MMsvSessionObserver void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); @@ -346,10 +335,10 @@ TState iState; CEngine* iEngine; CFileBrowserFileOps* iFileOps; -// CAknWaitDialog* iWaitDialog; + TBool isWaitDialog; TBool isProgressDialog; -// CAknProgressDialog* iProgressDialog; + CEikProgressInfo* iProgressInfo; CCommandArray* iCommandArray; TInt iCurrentEntry; @@ -375,7 +364,7 @@ CFileEntryList* iCurrentSelectionList; TSearchAttributes iSearchAttributes; CDocumentHandler* iDocHandler; - CAknOpenFileService* iOpenFileService; + RFile iMsgStoreWalkFile; TInt iPrevFolderIndex; TFileName iPrevFolderName; diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/engine/engine.cpp --- a/filebrowser/engine/engine.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/engine/engine.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -154,20 +154,20 @@ iSettings.iRememberLastPath = EFalse; iSettings.iLastPath = KNullDesC; iSettings.iRememberFolderSelection = ETrue; -#if 0 // TODO -#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__) - if ( AknLayoutUtils::PenEnabled() ) - { - iSettings.iEnableToolbar = ETrue; - } - else - { - iSettings.iEnableToolbar = EFalse; - } -#else - iSettings.iEnableToolbar = EFalse; -#endif -#endif // TODO +//#if 0 // TODO +//#if(!defined __SERIES60_30__ && !defined __SERIES60_31__ && !defined __S60_32__) +// if ( AknLayoutUtils::PenEnabled() ) +// { +// iSettings.iEnableToolbar = ETrue; +// } +// else +// { +// iSettings.iEnableToolbar = EFalse; +// } +//#else +// iSettings.iEnableToolbar = EFalse; +//#endif +//#endif // TODO iSettings.iSupportNetworkDrives = EFalse; iSettings.iBypassPlatformSecurity = EFalse; @@ -329,7 +329,7 @@ User::RequestComplete( s, KErrCancel ); } - //CAknEnv::StopSchedulerWaitWithBusyMessage( iWait ); + //CAknEnv::StopSchedulerWaitWithBusyMessage( iWait ); iWait.AsyncStop(); } diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/engine/engine.h --- a/filebrowser/engine/engine.h Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/engine/engine.h Tue Jul 06 14:17:03 2010 +0300 @@ -22,7 +22,7 @@ #include #include #include -#include + #include "FBFileUtils.h" // setting keys (do not change uids of existing keys to maintain compatibility to older versions!) @@ -48,7 +48,6 @@ class CFileBrowserScreenCapture; class CFileBrowserFileUtils; class CEikonEnv; -class CAknGlobalConfirmationQuery; class CDictionaryFileStore; class MFileBrowserUI; diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/group/ReleaseNotes_FileBrowser.txt --- a/filebrowser/group/ReleaseNotes_FileBrowser.txt Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/group/ReleaseNotes_FileBrowser.txt Tue Jul 06 14:17:03 2010 +0300 @@ -1,7 +1,7 @@ =============================================================================== -RELEASE NOTES - FILEBROWSER v5.0.1 -RELEASED 21st May 2010 +RELEASE NOTES - FILEBROWSER v5.1.0 +RELEASED 18th June 2010 SUPPORTS S60 3.0+ @@ -37,10 +37,10 @@ =============================================================================== -What's New in v5.0.1 +What's New in v5.1.0 ==================== - Error fixes -- All files to text file with file sizes +- File filtering - Usability improvements =============================================================================== @@ -111,6 +111,12 @@ Version History: ================ +Version 5.0.1 - 21th May 2010 +==================== +- Error fixes +- All files to text file with file sizes +- Usability improvements + Version 5.0.0 - 23th April 2010 ----------------------------- - Orbit UI diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/editorview.h --- a/filebrowser/ui/inc/editorview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/ui/inc/editorview.h Tue Jul 06 14:17:03 2010 +0300 @@ -19,8 +19,6 @@ #define EDITORVIEW_H #include -#include -//#include class HbTextEdit; class HbAction; @@ -30,7 +28,7 @@ Q_OBJECT public: - EditorView(HbMainWindow &mainWindow); + EditorView(); ~EditorView(); void open(const QString& fileName, bool flagReadOnly); @@ -56,8 +54,6 @@ void loadFile(const QString &fileName); void createMenu(); - /* Main Window of folderbrowser */ - HbMainWindow &mMainWindow; // editor HbTextEdit *mTextEdit; // if flag true, file is currently in hex format @@ -69,7 +65,6 @@ HbAction* mToTextAction; HbAction* mToHexAction; HbAction* mExitAction; - }; #endif // EDITORVIEW_H diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/fbdrivelistviewitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/inc/fbdrivelistviewitem.h Tue Jul 06 14:17:03 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: +* +*/ + +#ifndef FBDRIVELISTVIEWITEMS_H +#define FBDRIVELISTVIEWITEMS_H + +#include + +#include +#include + +class HbAbstractViewItem; +class HbLabel; +class HbCheckBox; +class HbWidget; + +class QGraphicsLinearLayout; +class QModelIndex; +class QGraphicsItem; + +class FbDriveListViewItem : public HbListViewItem +{ + Q_OBJECT + +public: + FbDriveListViewItem( QGraphicsItem *parent = 0 ); + ~FbDriveListViewItem(); + + virtual bool canSetModelIndex(const QModelIndex &index) const; + virtual HbAbstractViewItem *createItem(); + virtual void updateChildItems(); + +private slots: + void setCheckedState( int state ); + +private: + virtual void polish(HbStyleParameters& params); + +private: + void init(); + + QGraphicsLinearLayout *hLayout; + + HbLabel *mDiskNameLabel; + HbLabel *mSizeLabel; + HbLabel *mFreeLabel; + //HbCheckBox *mCheckBox; + HbLabel *mIconLabel; +}; + +#endif // FBDRIVELISTVIEWITEMS_H diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/fbdrivemodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/inc/fbdrivemodel.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,55 @@ +/* +* 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 FBDRIVEMODELH_H_ +#define FBDRIVEMODELH_H_ + +#include "driveentry.h" + +#include +#include + +// Forward declarations +class EngineWrapper; +class QModelIndex; +class QFileIconProvider; +class QObject; + +class FbDriveModel : public QAbstractListModel +{ + Q_OBJECT + +public: + explicit FbDriveModel(EngineWrapper *engineWrapper, QObject *parent = 0); + virtual ~FbDriveModel(); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + + DriveEntry driveEntry(const QModelIndex &index) const; + QString driveLetter( const QModelIndex &index ) const; + QString mediaTypeString(const QModelIndex &index) const; + +private: + EngineWrapper *mEngineWrapper; + QFileIconProvider *mFileIconProvider; +}; + + + +#endif /* FBDRIVEMODELH_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/fbdriveview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/inc/fbdriveview.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,244 @@ +/* +* 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 FBDRIVEVIEWH_H_ +#define FBDRIVEVIEWH_H_ + +#include "menuaction.h" +#include "enginewrapper.h" + +#include +#include + +#include + +// Forward declarations +class QFileInfo; +class QSignalMapper; +class QItemSelection; +class QString; +class QGraphicsLinearLayout; + +class HbListView; +class HbListWidget; +class HbToolBar; +class HbLabel; +class HbDialog; +class HbAbstractViewItem; +class HbMenu; +class HbSearchPanel; + +class EditorView; +class SearchView; +class SettingsView; +class EngineWrapper; +class FbDriveModel; +class FileBrowserSortFilterProxyModel; + +class FbDriveView : public HbView +{ + Q_OBJECT + +public: + explicit FbDriveView(); + virtual ~FbDriveView(); + void init(EngineWrapper *engineWrapper); + +public slots: + void refreshList(); + +private: + void openListDialog(const QStringList &items, const QString &titleText, QObject *receiver, const char *member); + + void openPropertyDialog(const QStringList &propertyList, const QString &title); + + QModelIndex currentItemIndex(); + void storeSelectedItemsOrCurrentItem(); + + // Menu related methods + void createMenu(); + void createFileMenu(); + void createEditMenu(); + void createViewMenu(); + void createToolsMenu(); + + void createSettingsMenuItem(); + void createAboutMenuItem(); + void createExitMenuItem(); + + void createContextMenu(); + void createFileContextMenu(); + void createEditContextMenu(); + void createViewContextMenu(); + void createDiskAdminContextMenu(); + +private slots: + // menu action slots + // file menu + void fileOpenDrive(); + void fileSearch(); + + void fileProperties(); + + void fileSetAttributes(); + + // edit menu + void editSnapShotToE(); + + // view menu + void viewRefresh(); + + // disk admin menu + void diskAdminSetDrivePassword(); + void diskAdminSetDrivePasswordNew(HbAction *); + void doDiskAdminSetDrivePassword(HbAction *); + + void diskAdminUnlockDrive(); + void doDiskAdminUnlockDrive(HbAction *); + + void diskAdminClearDrivePassword(); + void doDiskAdminClearDrivePassword(HbAction *); + + void diskAdminEraseDrivePassword(); + void doDiskAdminEraseDrivePassword(HbAction *); + + void diskAdminFormatDrive(); + void doDiskAdminFormatDrive(HbAction *); + + void diskAdminQuickFormatDrive(); + void doDiskAdminQuickFormatDrive(HbAction *); + + void diskAdminCheckDisk(); + + void diskAdminScanDrive(); + void doDiskAdminScanDrive(HbAction *); + + void diskAdminSetDriveName(); + void doDiskAdminSetDriveName(HbAction *); + + void diskAdminSetDriveVolumeLabel(); + void doDiskAdminSetDriveVolumeLabel(HbAction *); + + void diskAdminEjectDrive(); + void diskAdminDismountDrive(); + void doDiskAdminDismountDrive(HbAction *); + + void diskAdminEraseMBR(); + void doDiskAdminEraseMBR(HbAction *); + void doDiskAdminReallyEraseMBR(HbAction *); + void doDiskAdminNotRemovableReallyEraseMBR(HbAction *); + + void diskAdminPartitionDrive(); + void diskAdminPartitionDriveProceed(HbAction *); + void diskAdminPartitionDriveReallyProceed(HbAction *); + void diskAdminPartitionDriveIsNotRemovable(HbAction *); + void diskAdminPartitionDriveEraseMbr(HbAction *); + void diskAdminPartitionDriveGetCount(HbAction*); + + // tools menu + void toolsAllAppsToTextFile(); + void toolsAllFilesToTextFile(); +// void toolsAvkonIconCacheEnable(); +// void toolsAvkonIconCacheDisable(); + + void toolsDisableExtendedErrors(); + void toolsDumpMsgStoreWalk(); + void toolsEditDataTypes(); + void toolsEnableExtendedErrors(); + + void toolsErrorSimulateLeave(); + void doToolsErrorSimulateLeave(HbAction *); + + void toolsErrorSimulatePanic(); + void doToolsErrorSimulatePanicCode(HbAction *); + void doToolsErrorSimulatePanic(HbAction *); + + void toolsErrorSimulateException(); + void doToolsErrorSimulateException(HbAction *); + +// void toolsLocalConnectivityActivateInfrared(); +// void toolsLocalConnectivityLaunchBTUI(); +// void toolsLocalConnectivityLaunchUSBUI(); + void toolsMessageInbox(); + void toolsMessageDrafts(); + void toolsMessageSentItems(); + void toolsMessageOutbox(); + void toolsMemoryInfo(); + void toolsSecureBackStart(); + void toolsSecureBackRestore(); + void toolsSecureBackStop(); + void toolsSetDebugMaskQuestion(); + void toolsSetDebugMask(HbAction *); + void toolsShowOpenFilesHere(); + + // main menu items + void about(); + +signals: + void aboutToShowFileView(); + void aboutToShowSettingsView(); + void aboutToShowEditorView(const QString &, bool); + void aboutToShowSearchView(const QString &); + void aboutToSimulateLeave(int); + +private slots: + void updateOptionMenu(); + void updateContextMenu(); + void selectionChanged(const QItemSelection &, const QItemSelection &); + void activated(const QModelIndex& index); + + void onLongPressed(HbAbstractViewItem *, QPointF); + +private: + EngineWrapper *mEngineWrapper; + + HbListView *mListView; + HbLabel *mNaviPane; + + QGraphicsLinearLayout *mMainLayout; + + // file info contains all needed information of selected file from file model + QModelIndexList mClipboardIndexes; + QModelIndexList mSelectionIndexes; + + FbDriveModel *mFbDriveModel; + OptionMenuActions mOptionMenuActions; + ContextMenuActions mContextMenuActions; + HbMenu *mContextMenu; + + // flags + bool mLocationChanged; + // flag for removing source file after copied to target file + bool mRemoveFileAfterCopied; + bool mClipBoardInUse; + bool mFolderContentChanged; + QModelIndex mCurrentIndex; + + // temporarily storage + QString mOldPassword; + QString mPanicCategory; + QString mAbsoluteFilePath; + OverwriteOptions mOverwriteOptions; + QModelIndex mModelIndex; + QString mNewFileName; + bool mProceed; + bool mEraseMBR; +}; + + + +#endif /* FBDRIVEVIEWH_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/fbfilelistviewitem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/inc/fbfilelistviewitem.h Tue Jul 06 14:17:03 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: +* +*/ + +#ifndef FBFILELISTVIEWITEM_H +#define FBFILELISTVIEWITEM_H + +#include + +#include +#include + +class HbAbstractViewItem; +class HbLabel; +class HbCheckBox; +class HbWidget; + +class QGraphicsLinearLayout; +class QModelIndex; +class QGraphicsItem; + +class FbFileListViewItem : public HbListViewItem +{ + Q_OBJECT + +public: + FbFileListViewItem( QGraphicsItem *parent = 0 ); + ~FbFileListViewItem(); + + virtual bool canSetModelIndex(const QModelIndex &) const; + virtual HbAbstractViewItem *createItem(); + virtual void updateChildItems(); + +private slots: + void setCheckedState(int state); + +private: + virtual void polish(HbStyleParameters &); + +private: + void init(); + + QGraphicsLinearLayout *hLayout; + + HbLabel *mDiskNameLabel; + HbLabel *mSizeLabel; + HbLabel *mFreeLabel; + //HbCheckBox *mCheckBox; + HbLabel *mIconLabel; +}; + +#endif // FBFILELISTVIEWITEM_H diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/fbfilemodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/inc/fbfilemodel.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,47 @@ +/* +* 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 FBFILEMODELH_H_ +#define FBFILEMODELH_H_ + +#include + +// Forward declarations +class EngineWrapper; +class QModelIndex; +class QFileIconProvider; + +class FbFileModel : public QAbstractListModel +{ + Q_OBJECT + +public: + explicit FbFileModel(EngineWrapper *engineWrapper, QObject *parent = 0); + virtual ~FbFileModel(); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + +private: + EngineWrapper *mEngineWrapper; + QFileIconProvider *mFileIconProvider; +}; + + + +#endif /* FBFILEMODELH_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/fbfileview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/inc/fbfileview.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,248 @@ +/* +* 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 FBFILEVIEWH_H_ +#define FBFILEVIEWH_H_ + +#include "menuaction.h" +#include "enginewrapper.h" + +#include +#include + +#include + +// Forward declarations +class QFileInfo; +class QSignalMapper; +class QItemSelection; +class QString; +class QGraphicsLinearLayout; + +class HbListView; +class HbListWidget; +class HbToolBar; +class HbLabel; +class HbDialog; +class HbAbstractViewItem; +class HbMenu; +class HbSearchPanel; + +class EditorView; +class SearchView; +class SettingsView; +class EngineWrapper; +class FbFileModel; +class FileBrowserSortFilterProxyModel; + +class FbFileView : public HbView +{ + Q_OBJECT + +public: + explicit FbFileView(); + virtual ~FbFileView(); + void init(EngineWrapper *engineWrapper); + +public slots: + void refreshList(); + +private: + void fileOverwriteDialog(); + void openListDialog(const QStringList &items, const QString &titleText, QObject *receiver, const char *member); + + void openPropertyDialog(const QStringList &propertyList, const QString &title); + + QModelIndex currentItemIndex(); + void storeSelectedItemsOrCurrentItem(); + + // Menu related methods + void createMenu(); + void createFileMenu(); + void createEditMenu(); + void createViewMenu(); + void createToolsMenu(); + + void createSelectionMenuItem(); + void createSettingsMenuItem(); + void createAboutMenuItem(); + void createExitMenuItem(); + + void createContextMenu(); + void createFileContextMenu(); + void createEditContextMenu(); + void createViewContextMenu(); + void createToolBar(); + +private slots: + // menu action slots + // file menu + void fileBackMoveUp(); + void fileOpenDirectory(); + void fileSearch(); + + void fileNewFile(); + void doFileNewFile(HbAction *); + + void fileNewDirectory(); + void doFileNewDirectory(HbAction *); + + void fileDelete(); + void doFileDelete(HbAction *); + + void fileRename(); + void doFileRename(HbAction *); + void doFileRenameFileExist(HbAction *); + + void fileTouch(); + void doFileTouch(HbAction *); + void fileProperties(); + + void fileChecksumsMD5(); + void fileChecksumsMD2(); + void fileChecksumsSHA1(); + void fileChecksums(TFileBrowserCmdFileChecksums checksumType); + + void fileSetAttributes(); + + // edit menu + void editSnapShotToE(); + void editCut(); + void editCopy(); + void editPaste(); + + void editCopyToFolder(); + void doEditCopyToFolder(HbAction *); + + void editMoveToFolder(); + void doEditMoveToFolder(HbAction *); + + void editSelect(); + void editUnselect(); + void editSelectAll(); + void editUnselectAll(); + + // view menu + void viewFilterEntries(); + void filterCriteriaChanged(const QString &); + void clearFilterCriteria(); + void viewRefresh(); + + // tools menu + void toolsAllAppsToTextFile(); + void toolsAllFilesToTextFile(); +// void toolsAvkonIconCacheEnable(); +// void toolsAvkonIconCacheDisable(); + + void toolsDisableExtendedErrors(); + void toolsDumpMsgStoreWalk(); + void toolsEditDataTypes(); + void toolsEnableExtendedErrors(); + + void toolsErrorSimulateLeave(); + void doToolsErrorSimulateLeave(HbAction *); + + void toolsErrorSimulatePanic(); + void doToolsErrorSimulatePanicCode(HbAction *); + void doToolsErrorSimulatePanic(HbAction *); + + void toolsErrorSimulateException(); + void doToolsErrorSimulateException(HbAction *); + +// void toolsLocalConnectivityActivateInfrared(); +// void toolsLocalConnectivityLaunchBTUI(); +// void toolsLocalConnectivityLaunchUSBUI(); + void toolsMessageInbox(); + void toolsMessageDrafts(); + void toolsMessageSentItems(); + void toolsMessageOutbox(); + void toolsMemoryInfo(); + void toolsSecureBackStart(); + void toolsSecureBackRestore(); + void toolsSecureBackStop(); + void toolsSetDebugMaskQuestion(); + void toolsSetDebugMask(HbAction *); + void toolsShowOpenFilesHere(); + + // main menu items + void selectionModeChanged(); + void about(); + +signals: + void aboutToShowDriveView(); + void aboutToShowSettingsView(); + void aboutToShowEditorView(const QString &, bool); + void aboutToShowSearchView(const QString &); + void aboutToSimulateLeave(int); + +private slots: + void updateOptionMenu(); + void updateContextMenu(); + void selectionChanged(const QItemSelection &, const QItemSelection &); + void activated(const QModelIndex& index); + void activateSelectionMode(); + void deActivateSelectionMode(); + void onLongPressed(HbAbstractViewItem *, QPointF); + + void fileOpen(HbAction *); + void fileOverwrite(HbAction *); + void fileOverwritePostfix(HbAction *); + +private: + EngineWrapper *mEngineWrapper; + + HbListView *mListView; + HbToolBar *mToolBar; + HbLabel *mNaviPane; + HbSearchPanel *mSearchPanel; + + QGraphicsLinearLayout *mMainLayout; + + // file info contains all needed information of selected file from file model + QModelIndexList mClipboardIndexes; + QModelIndexList mSelectionIndexes; + + FbFileModel *mFbFileModel; + FileBrowserSortFilterProxyModel *mSortFilterProxyModel; + OptionMenuActions mOptionMenuActions; + ContextMenuActions mContextMenuActions; + HbMenu *mContextMenu; + HbAction *mToolbarBackAction; + + // flags + bool mItemHighlighted; + bool mLocationChanged; + // flag for removing source file after copied to target file + bool mRemoveFileAfterCopied; + bool mClipBoardInUse; + bool mFolderContentChanged; + QModelIndex mCurrentIndex; + + // temporarily storage + QString mOldPassword; + QString mPanicCategory; + QString mAbsoluteFilePath; + OverwriteOptions mOverwriteOptions; + QModelIndex mModelIndex; + QString mNewFileName; + bool mProceed; + bool mEraseMBR; +}; + + + +#endif /* FBFILEVIEWH_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/fbmainwindow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/inc/fbmainwindow.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,62 @@ +/* +* 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 FBMAINWINDOW_H_ +#define FBMAINWINDOW_H_ + +#include + +class HbApplication; +class HbView; + +class EngineWrapper; +class FbDriveView; +class FbFileView; +class SettingsView; +class EditorView; +class SearchView; + +class FbMainWindow : public HbMainWindow +{ + Q_OBJECT + +public: + explicit FbMainWindow(QWidget *parent = 0); + virtual ~FbMainWindow(); + + void init(); + +private slots: + void openPreviousBrowserView(); + void openFileBrowserView(bool); + void openDriveView(); + void openFileView(); + void openSettingsView(); + void openEditorView(const QString &, bool); + void openSearchView(const QString &); + +private: + EngineWrapper *mEngineWrapper; + FbDriveView *mDriveView; + FbFileView *mFileView; + SettingsView *mSettingsView; + EditorView *mEditorView; + SearchView *mSearchView; + HbView *mPreviousView; +}; + +#endif /* FBMAINWINDOW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/filebrowsermainwindow.h --- a/filebrowser/ui/inc/filebrowsermainwindow.h Wed Jun 23 18:13:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +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 FILEBROWSERMAINWINDOW_H_ -#define FILEBROWSERMAINWINDOW_H_ - -#include - -class HbApplication; -class EngineWrapper; -class FileBrowserView; -class SettingsView; -class EditorView; -class SearchView; - -class FileBrowserMainWindow : public HbMainWindow - { - Q_OBJECT - -public: - explicit FileBrowserMainWindow(QWidget *parent = 0); - virtual ~FileBrowserMainWindow(); - - void init(); - -private slots: - void openFileBrowserView(); - void openSettingsView(); - void openEditorView(const QString &, bool); - void openSearchView(const QString &); - -private: - EngineWrapper* mEngineWrapper; - FileBrowserView* mFileBrowserView; - SettingsView* mSettingsView; - EditorView* mEditorView; - SearchView* mSearchView; - }; - -#endif /* FILEBROWSERMAINWINDOW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/filebrowsermodel.h --- a/filebrowser/ui/inc/filebrowsermodel.h Wed Jun 23 18:13:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +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 FILEBROWSERMODELH_H_ -#define FILEBROWSERMODELH_H_ - -#include - -// Forward declarations -class EngineWrapper; -class QModelIndex; -class QFileIconProvider; - -class FileBrowserModel : public QAbstractListModel -{ - Q_OBJECT - -public: - explicit FileBrowserModel(EngineWrapper *engineWrapper, QObject *parent = 0); - virtual ~FileBrowserModel(); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - -private: - EngineWrapper *mEngineWrapper; - QFileIconProvider *mFileIconProvider; -}; - - - -#endif /* FILEBROWSERMODELH_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/filebrowsersortfilterproxymodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/inc/filebrowsersortfilterproxymodel.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,41 @@ +/* +* 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 FILEBROWSERSORTFILTERPROXYMODEL_H +#define FILEBROWSERSORTFILTERPROXYMODEL_H + +#include +#include + +class FileBrowserSortFilterProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT + +public: + FileBrowserSortFilterProxyModel(QObject *parent = 0); + + QString filterCriteria() const { return mFilterCriteria; } + void setFilterCriteria(const QString &criteria); + +protected: + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + +private: + QString mFilterCriteria; +}; + +#endif // FILEBROWSERSORTFILTERPROXYMODEL_H diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/filebrowserview.h --- a/filebrowser/ui/inc/filebrowserview.h Wed Jun 23 18:13:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,297 +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 FILEBROWSERVIEWH_H_ -#define FILEBROWSERVIEWH_H_ - -#include "menuaction.h" -#include "enginewrapper.h" - -#include -#include -#include - -#include - -// Forward declarations -class QFileInfo; -class QSignalMapper; -class QItemSelection; -class QString; -class QGraphicsLinearLayout; - -class HbListView; -class HbListWidget; -class HbToolBar; -class HbLabel; -class HbDialog; -class HbAbstractViewItem; -class HbMenu; - -class FileBrowserMainWindow; -class EditorView; -class SearchView; -class SettingsView; -class EngineWrapper; -class FileBrowserModel; - -class FileBrowserView : public HbView -{ - Q_OBJECT - -public: - explicit FileBrowserView(FileBrowserMainWindow &mainWindow); - virtual ~FileBrowserView(); - void init(EngineWrapper *engineWrapper); - -public slots: - void refreshList(); - -private: - void fileOverwriteDialog(); - void openListDialog(const QStringList &items, const QString &titleText, QObject *receiver, const char *member); - - void openPropertyDialog(const QStringList &propertyList, const QString &title); - - QModelIndex currentItemIndex(); - void storeSelectedItemsOrCurrentItem(); - - // Menu related methods - void createMenu(); - void createFileMenu(); - void createEditMenu(); - void createViewMenu(); - void createToolsMenu(); - - void createSelectionMenuItem(); - void createSettingsMenuItem(); - void createAboutMenuItem(); - void createExitMenuItem(); - - void createContextMenu(); - void createFileContextMenu(); - void createEditContextMenu(); - void createViewContextMenu(); - void createDiskAdminContextMenu(); - void createToolBar(); - -// void refreshList(); - void populateFolderContent(); - -private slots: - // menu action slots - // file menu - void fileBackMoveUp(); - void fileOpenDrive(); - void fileOpenDirectory(); - void fileSearch(); - - void fileNewFile(); - void doFileNewFile(HbAction *); - - void fileNewDirectory(); - void doFileNewDirectory(HbAction *); - - void fileDelete(); - void doFileDelete(HbAction *); - - void fileRename(); - void doFileRename(HbAction *); - void doFileRenameFileExist(HbAction *); - - void fileTouch(); - void doFileTouch(HbAction *); - void fileProperties(); - - void fileChecksumsMD5(); - void fileChecksumsMD2(); - void fileChecksumsSHA1(); - void fileChecksums(TFileBrowserCmdFileChecksums checksumType); - - void fileSetAttributes(); - - // edit menu - void editSnapShotToE(); - void editCut(); - void editCopy(); - void editPaste(); - - void editCopyToFolder(); - void doEditCopyToFolder(HbAction *); - - void editMoveToFolder(); - void doEditMoveToFolder(HbAction *); - - void editSelect(); - void editUnselect(); - void editSelectAll(); - void editUnselectAll(); - - // view menu - void viewFilterEntries(); - void viewRefresh(); - - // disk admin menu - void diskAdminSetDrivePassword(); - void diskAdminSetDrivePasswordNew(HbAction *); - void doDiskAdminSetDrivePassword(HbAction *); - - void diskAdminUnlockDrive(); - void doDiskAdminUnlockDrive(HbAction *); - - void diskAdminClearDrivePassword(); - void doDiskAdminClearDrivePassword(HbAction *); - - void diskAdminEraseDrivePassword(); - void doDiskAdminEraseDrivePassword(HbAction *); - - void diskAdminFormatDrive(); - void doDiskAdminFormatDrive(HbAction *); - - void diskAdminQuickFormatDrive(); - void doDiskAdminQuickFormatDrive(HbAction *); - - void diskAdminCheckDisk(); - - void diskAdminScanDrive(); - void doDiskAdminScanDrive(HbAction *); - - void diskAdminSetDriveName(); - void doDiskAdminSetDriveName(HbAction *); - - void diskAdminSetDriveVolumeLabel(); - void doDiskAdminSetDriveVolumeLabel(HbAction *); - - void diskAdminEjectDrive(); - void diskAdminDismountDrive(); - void doDiskAdminDismountDrive(HbAction *); - - void diskAdminEraseMBR(); - void doDiskAdminEraseMBR(HbAction *); - void doDiskAdminReallyEraseMBR(HbAction *); - void doDiskAdminNotRemovableReallyEraseMBR(HbAction *); - - void diskAdminPartitionDrive(); - void diskAdminPartitionDriveProceed(HbAction *); - void diskAdminPartitionDriveReallyProceed(HbAction *); - void diskAdminPartitionDriveIsNotRemovable(HbAction *); - void diskAdminPartitionDriveEraseMbr(HbAction *); - void diskAdminPartitionDriveGetCount(HbAction*); - - // tools menu - void toolsAllAppsToTextFile(); - void toolsAllFilesToTextFile(); - void toolsAvkonIconCacheEnable(); - void toolsAvkonIconCacheDisable(); - - void toolsDisableExtendedErrors(); - void toolsDumpMsgStoreWalk(); - void toolsEditDataTypes(); - void toolsEnableExtendedErrors(); - - void toolsErrorSimulateLeave(); - void doToolsErrorSimulateLeave(HbAction *); - - void toolsErrorSimulatePanic(); - void doToolsErrorSimulatePanicCode(HbAction *); - void doToolsErrorSimulatePanic(HbAction *); - - void toolsErrorSimulateException(); - void doToolsErrorSimulateException(HbAction *); - -// void toolsLocalConnectivityActivateInfrared(); -// void toolsLocalConnectivityLaunchBTUI(); -// void toolsLocalConnectivityLaunchUSBUI(); - void toolsMessageInbox(); - void toolsMessageDrafts(); - void toolsMessageSentItems(); - void toolsMessageOutbox(); - void toolsMemoryInfo(); - void toolsSecureBackStart(); - void toolsSecureBackRestore(); - void toolsSecureBackStop(); - void toolsSetDebugMaskQuestion(); - void toolsSetDebugMask(HbAction *); - void toolsShowOpenFilesHere(); - - // main menu items - void selectionModeChanged(); - void about(); - -signals: - void aboutToShowSettingsView(); - void aboutToShowEditorView(const QString &, bool); - void aboutToShowSearchView(const QString &); - void aboutToSimulateLeave(int); - -private slots: - void itemHighlighted(const QModelIndex &index); - //void itemSelected(const QModelIndex &index); - void updateOptionMenu(); - void updateContextMenu(); - void selectionChanged(const QItemSelection &, const QItemSelection &); - void activated(const QModelIndex& index); - void activateSelectionMode(); - void deActivateSelectionMode(); - void onLongPressed(HbAbstractViewItem *, QPointF); - - void fileOpen(HbAction *); - void fileOverwrite(HbAction *); - void fileOverwritePostfix(HbAction *); - -private: - FileBrowserMainWindow &mMainWindow; - EngineWrapper *mEngineWrapper; - - HbListView *mListView; - HbToolBar *mToolBar; - HbLabel *mNaviPane; - QGraphicsLinearLayout *mMainLayout; - - // file info contains all needed information of selected file from file model - QModelIndexList mClipboardIndexes; - QModelIndexList mSelectionIndexes; - - FileBrowserModel *mFileBrowserModel; - OptionMenuActions mOptionMenuActions; - ContextMenuActions mContextMenuActions; - HbMenu *mContextMenu; - HbAction *mToolbarBackAction; - - // flags - bool mItemHighlighted; - bool mLocationChanged; - // flag for removing source file after copied to target file - bool mRemoveFileAfterCopied; - bool mClipBoardInUse; - bool mFolderContentChanged; - QModelIndex mCurrentIndex; - - // temporarily storage - QString mOldPassword; - QString mPanicCategory; - QString mAbsoluteFilePath; - OverwriteOptions mOverwriteOptions; - QModelIndex mModelIndex; - QString mNewFileName; - bool mProceed; - bool mEraseMBR; -}; - - - -#endif /* FILEBROWSERVIEWH_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/searchview.h --- a/filebrowser/ui/inc/searchview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/ui/inc/searchview.h Tue Jul 06 14:17:03 2010 +0300 @@ -19,11 +19,9 @@ #define SEARCHVIEW_H #include -#include #include -class QDir; class QStringList; class EngineWrapper; diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/inc/settingsview.h --- a/filebrowser/ui/inc/settingsview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/ui/inc/settingsview.h Tue Jul 06 14:17:03 2010 +0300 @@ -22,7 +22,6 @@ class HbDataForm; class HbDataFormModelItem; -class FileBrowserMainWindow; class EngineWrapper; class FileBrowserSettings; @@ -31,9 +30,10 @@ Q_OBJECT public: - SettingsView(FileBrowserMainWindow &mainWindow, EngineWrapper &engineWrapper); + SettingsView(EngineWrapper &engineWrapper); virtual ~SettingsView(); + void initDataForm(); signals: void finished(bool ok); @@ -51,14 +51,12 @@ void reject(); private: - void initDataForm(); void createToolbar(); void constructMenu(); void loadSettings(const FileBrowserSettings &settings); void saveSettings(FileBrowserSettings &settings); private: - FileBrowserMainWindow &mMainWindow; EngineWrapper &mEngineWrapper; HbDataForm *mForm; diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/editorview.cpp --- a/filebrowser/ui/src/editorview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/ui/src/editorview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -16,7 +16,6 @@ */ #include -#include #include #include #include @@ -32,8 +31,7 @@ #include "editorview.h" -EditorView::EditorView(HbMainWindow &mainWindow) - : mMainWindow(mainWindow), +EditorView::EditorView() : mTextEdit(0), mFileHex(false), mFlagReadOnly(), diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/enginewrapper.cpp --- a/filebrowser/ui/src/enginewrapper.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/ui/src/enginewrapper.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -19,7 +19,7 @@ #include "engine.h" #include "FBFileUtils.h" #include "notifications.h" -#include "filebrowserview.h" +#include "fbfileview.h" #include "searchview.h" #include "filebrowsersettings.h" #include "settingsview.h" @@ -739,7 +739,7 @@ const QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); if (!mProgressDialog) { mProgressDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); - QObject::connect(mProgressDialog, SIGNAL(cancelled ()), this, SLOT(progressDialogCancelled())); + QObject::connect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(progressDialogCancelled())); } mProgressDialog->setText(qText); @@ -751,8 +751,11 @@ void EngineWrapper::CancelProgressDialog() { - if (mProgressDialog) + if (mProgressDialog) { + QObject::disconnect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(progressDialogCancelled())); mProgressDialog->cancel(); + QObject::connect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(progressDialogCancelled())); + } } void EngineWrapper::SetProgressValue(TInt aValue) @@ -771,7 +774,7 @@ const QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); if (!mWaitDialog) { mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); - QObject::connect(mWaitDialog, SIGNAL(cancelled ()), this, SLOT(waitDialogCancelled())); + QObject::connect(mWaitDialog, SIGNAL(cancelled()), this, SLOT(waitDialogCancelled())); } mWaitDialog->setText(qText); diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/fbdrivelistviewitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/src/fbdrivelistviewitem.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,173 @@ +/* +* 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 "fbdrivelistviewitem.h" +#include "driveentry.h" +#include "fbdrivemodel.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +FbDriveListViewItem::FbDriveListViewItem(QGraphicsItem *parent) : + HbListViewItem(parent), + hLayout(0), + mDiskNameLabel(0), + mSizeLabel(0), + mFreeLabel(0), + mIconLabel(0) +{ +} + +FbDriveListViewItem::~FbDriveListViewItem() +{ +} + +void FbDriveListViewItem::polish(HbStyleParameters& params) +{ + Q_UNUSED(params); +} + +bool FbDriveListViewItem::canSetModelIndex(const QModelIndex &index) const +{ + Q_UNUSED(index); + return true; +} + + +HbAbstractViewItem *FbDriveListViewItem::createItem() +{ + return new FbDriveListViewItem(*this); +} + +void FbDriveListViewItem::updateChildItems() +{ + if(!hLayout) { + init(); + } + + // Qt::DisplayRole +// QVariant displayRole = modelIndex().data(Qt::DisplayRole); +// QString diskName("default"); + QStringList stringList; +// if (displayRole.isValid()) { +// if (displayRole.canConvert()) { // EFileViewModeSimple +// stringList.append(displayRole.toString()); +// } else if (displayRole.canConvert()) { // EFileViewModeExtended +// stringList = displayRole.toStringList(); +// } +// if (stringList.count() > 0) +// diskName = stringList[0]; //modelIndex().data( Qt::UserRole ).toString(); +// +// mDiskNameLabel->setPlainText(diskName/*displayString*/); +// } +// if (stringList.count() > 1) +// mSizeLabel->setPlainText( stringList[1] ); + + + // Get the Drive Entry + const FbDriveModel* driveModel= qobject_cast(modelIndex().model()); + DriveEntry driveEntry = driveModel->driveEntry(modelIndex()); + + const QString SimpleDriveEntry("%1: <%2>"); + + QString diskName = SimpleDriveEntry.arg(driveEntry.driveLetter()).arg(driveEntry.mediaTypeString()); + mDiskNameLabel->setPlainText(diskName); + + const QString ExtendedDriveEntry("%1/%2 kB"); + QString diskSize = ExtendedDriveEntry.arg(QString::number(driveEntry.volumeInfoFree()/1024)) + .arg(QString::number(driveEntry.volumeInfoSize()/1024)); + mSizeLabel->setPlainText( diskSize ); + + //mFreeLabel->setPlainText( stringList[2] ); + + // mCheckBox->setCheckState( checkState() ); + + // Qt::DecorationRole + // QTBUG-11033 No Icon provided for QFileIconProvider::Desktop, Network, Drive on Symbian + QVariant decorationRole = modelIndex().data(Qt::DecorationRole); + if (decorationRole.isValid()) { + QIcon icon = qvariant_cast(decorationRole); + if( icon.isNull() ) { + QFileIconProvider fileIconProvider; + icon = fileIconProvider.icon(QFileIconProvider::File); + } + mIconLabel->setIcon(HbIcon(icon)); + } +} + +void FbDriveListViewItem::setCheckedState(int state) +{ + HbAbstractViewItem::setCheckState(static_cast(state)); +} + +void FbDriveListViewItem::init() +{ + hLayout = new QGraphicsLinearLayout(); + hLayout->setContentsMargins(0, 0, 0, 0); + + hLayout->setOrientation( Qt::Horizontal ); + hLayout->addItem(layout()); + + mIconLabel = new HbLabel(); + hLayout->addItem( mIconLabel ); + hLayout->setAlignment( mIconLabel, Qt::AlignTop ); + hLayout->setStretchFactor( mIconLabel, 0 ); + + QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); + //vLayout->setContentsMargins(0, 0, 0, 0); + vLayout->setOrientation( Qt::Vertical ); + + mDiskNameLabel = new HbLabel(); + HbFontSpec fontSpecPrimary(HbFontSpec::Primary); + //fontSpecPrimary.setTextHeight(18.0); + mDiskNameLabel->setFontSpec( fontSpecPrimary ); + vLayout->addItem( mDiskNameLabel ); + vLayout->setAlignment( mDiskNameLabel, Qt::AlignLeft ); + + mSizeLabel = new HbLabel(); + HbFontSpec fontSpecSecondary(HbFontSpec::Secondary); + //fontSpecSecondary.setTextHeight(18.0); + mSizeLabel->setFontSpec(fontSpecSecondary); + vLayout->addItem( mSizeLabel ); + vLayout->setAlignment(mSizeLabel, Qt::AlignLeft); + +// mFreeLabel = new HbLabel(); +// mFreeLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); +// vLayout->addItem( mFreeLabel ); +// vLayout->setAlignment( mFreeLabel, Qt::AlignLeft ); + + HbWidget *labelsWidget = new HbWidget(); + labelsWidget->setLayout(vLayout); + + hLayout->setAlignment( labelsWidget, Qt::AlignLeft ); + + hLayout->addItem( labelsWidget ); + hLayout->setStretchFactor( labelsWidget, 1 ); + + //this->setMaximumHeight( mDiskNameLabel->preferredHeight() ); + //setMaximumHeight( mIconLabel->preferredHeight() ); + + setLayout( hLayout ); +} diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/fbdrivemodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/src/fbdrivemodel.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,140 @@ +/* +* 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 "fbdrivemodel.h" +#include "enginewrapper.h" +#include "driveentry.h" +#include "settingsview.h" +#include "filebrowsersettings.h" +#include "FB.hrh" + +#include +#include + +/** + Constructs a file browser custom system model with the given \a engineWrapper and \a parent. + */ +FbDriveModel::FbDriveModel(EngineWrapper *engineWrapper, QObject *parent) : + QAbstractListModel(parent), + mEngineWrapper(engineWrapper), + mFileIconProvider(0) +{ + mFileIconProvider = new QFileIconProvider(); +} + +/** + Destroys this file browser custom system model. + */ +FbDriveModel::~FbDriveModel() +{ + if (mFileIconProvider) { + delete mFileIconProvider; + } +} + +/** + \reimp + */ +int FbDriveModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return mEngineWrapper->itemCount(); +} + +/** + \reimp + */ +QVariant FbDriveModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid() || index.model() != this) + return QVariant(); + + switch (role) { + case Qt::EditRole: + case Qt::DisplayRole: { + QStringList listItem; + DriveEntry driveEntry(mEngineWrapper->getDriveEntry(index)); + if (mEngineWrapper->settings().fileViewMode() == EFileViewModeSimple) + { + const QString SimpleDriveEntry("%1: <%2>"); + listItem /*<< driveEntry.IconId() */ + << SimpleDriveEntry.arg(driveEntry.driveLetter()) + .arg(driveEntry.mediaTypeString()); + } else if (mEngineWrapper->settings().fileViewMode() == EFileViewModeExtended) { + const QString SimpleDriveEntry("%1: <%2>"); + const QString ExtendedDriveEntry("%1/%2 kB"); + listItem /*<< driveEntry.IconId()*/ + << SimpleDriveEntry.arg(driveEntry.driveLetter()) + .arg(driveEntry.mediaTypeString()) + << ExtendedDriveEntry.arg(QString::number(driveEntry.volumeInfoFree()/1024)) + .arg(QString::number(driveEntry.volumeInfoSize()/1024)); + + } + return listItem; + } + case Qt::DecorationRole: { + if (mEngineWrapper) { + QIcon icon; + //TODO Drive ico has to be provided, for some reason it is not visible + icon = mFileIconProvider->icon(QFileIconProvider::Drive); + return QVariant(icon); + } + } + } + return QVariant(); +} + +/** + \reimp + */ +QVariant FbDriveModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + Q_UNUSED(section); + Q_UNUSED(orientation); + Q_UNUSED(role); + + // TODO, implement or remove + return QVariant(); +} + + +DriveEntry FbDriveModel::driveEntry(const QModelIndex &index) const +{ + return mEngineWrapper->getDriveEntry(index); +} + +QString FbDriveModel::driveLetter(const QModelIndex &index) const +{ + QString diskLetter; + if (index.row() >= 0 && index.row() < mEngineWrapper->itemCount()) { + DriveEntry driveEntry(mEngineWrapper->getDriveEntry(index)); + diskLetter = driveEntry.driveLetter(); + } + return diskLetter; +} + +QString FbDriveModel::mediaTypeString(const QModelIndex &index) const +{ + QString mediaTypeString; + if (index.row() >= 0 && index.row() < mEngineWrapper->itemCount()) { + DriveEntry driveEntry(mEngineWrapper->getDriveEntry(index)); + mediaTypeString = driveEntry.mediaTypeString(); + } + return mediaTypeString; +} + +// --------------------------------------------------------------------------- diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/fbdriveview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/src/fbdriveview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,1308 @@ +/* +* 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 "fbdriveview.h" +#include "settingsview.h" +#include "editorview.h" +#include "searchview.h" +#include "enginewrapper.h" +#include "notifications.h" + +#include "fbdrivemodel.h" +#include "filebrowsersortfilterproxymodel.h" +#include "fbdrivelistviewitem.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +//TODO check if needed to do this way +#include + +// --------------------------------------------------------------------------- + +FbDriveView::FbDriveView() : + mEngineWrapper(0), + mListView(0), + mNaviPane(0), + mMainLayout(0), + mFbDriveModel(0), + mOptionMenuActions(), + mContextMenuActions(), + mContextMenu(0), + mLocationChanged(false), + mRemoveFileAfterCopied(false), +// mClipBoardInUse(false), + mFolderContentChanged(false), + mCurrentIndex(), + mOldPassword(), + mPanicCategory(), + mAbsoluteFilePath(), + mOverwriteOptions(), + mModelIndex(), + mNewFileName(), + mProceed(false), + mEraseMBR(false) +{ + setTitle("File Browser"); + + createMenu(); + createContextMenu(); +} + +// --------------------------------------------------------------------------- + +void FbDriveView::init(EngineWrapper *engineWrapper) +{ + mEngineWrapper = engineWrapper; + + mListView = new HbListView(this); + mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape); + + mListView->setItemPrototype(new FbDriveListViewItem(mListView)); + + mFbDriveModel = new FbDriveModel(mEngineWrapper); + if (!mListView->model()) { + mEngineWrapper->refreshView(); + mListView->setModel(mFbDriveModel); + } + + //mListView->setRootIndex(mFileSystemModel->index(startPath)); + //mListView->setRootIndex(model->index()); + +// mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); + + connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); + connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), + this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF))); + + mNaviPane = new HbLabel(this); + mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default + //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); + HbFontSpec fontSpec(HbFontSpec::PrimarySmall); + mNaviPane->setFontSpec(fontSpec); + + // Create layout and add list view and naviPane into layout: + mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); + mMainLayout->addItem(mNaviPane); + mMainLayout->addItem(mListView); + setLayout(mMainLayout); +} + +// --------------------------------------------------------------------------- + +FbDriveView::~FbDriveView() +{ +// if (mEngineWrapper) { +// delete mEngineWrapper; +// } + if (mContextMenu) { + mContextMenu->deleteLater(); + } + + delete mFbDriveModel; + delete mListView; +} + +/** + Initial setup for options menu. + Dynamic menu update during the runtime is performed by updateOptionMenu() which + to menu's aboutToShow() signal. + */ +void FbDriveView::createMenu() +{ + createFileMenu(); + createEditMenu(); + createViewMenu(); + createToolsMenu(); + + createSettingsMenuItem(); + createAboutMenuItem(); + createExitMenuItem(); + + // menu dynamic update + connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateOptionMenu())); +} + +/** + Initial setup for File submenu + */ +void FbDriveView::createFileMenu() +{ + mOptionMenuActions.mFileMenu = menu()->addMenu("File"); + +// mOptionMenuActions.mFileOpenDrive = mOptionMenuActions.mFileMenu->addAction("Open drive", this, SLOT(fileOpenDrive())); + mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); + //mOptionMenuActions.mFileSearch->setVisible(false); + + //mOptionMenuActions.mFileNewMenu = mOptionMenuActions.mFileMenu->addMenu("New"); + + mOptionMenuActions.mFileSetAttributes = mOptionMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); + mOptionMenuActions.mFileSetAttributes->setVisible(false); +} + +/** + Initial setup for Edit submenu + */ +void FbDriveView::createEditMenu() +{ + mOptionMenuActions.mEditMenu = menu()->addMenu("Edit"); + + mOptionMenuActions.mEditSnapShotToE = mOptionMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); + mOptionMenuActions.mEditSnapShotToE->setVisible(false); +} + +/** + Initial setup for View submenu + */ +void FbDriveView::createViewMenu() +{ + mOptionMenuActions.mViewMenu = menu()->addMenu("View"); + //mOptionMenuActions.mViewMenu->menuAction()->setVisible(false); + + //mOptionMenuActions.mViewFilterEntries = mOptionMenuActions.mViewMenu->addAction("Filter entries", this, SLOT(viewFilterEntries())); + mOptionMenuActions.mViewRefresh = mOptionMenuActions.mViewMenu->addAction("Refresh", this, SLOT(viewRefresh())); +} + +/** + Initial setup for Tools submenu + */ +void FbDriveView::createToolsMenu() +{ + mOptionMenuActions.mToolsMenu = menu()->addMenu("Tools"); + + mOptionMenuActions.mToolsAllAppsToTextFile = mOptionMenuActions.mToolsMenu->addAction("All apps to a text file", this, SLOT(toolsAllAppsToTextFile())); + mOptionMenuActions.mToolsAllAppsToTextFile->setVisible(false); + mOptionMenuActions.mToolsAllFilesToTextFile = mOptionMenuActions.mToolsMenu->addAction("All files to a text file", this, SLOT(toolsAllFilesToTextFile())); + //mOptionMenuActions.mToolsAllFilesToTextFile->setVisible(false); + +// mOptionMenuActions.mToolsAvkonIconCacheMenu = mOptionMenuActions.mToolsMenu->addMenu("Avkon icon cache"); +// mOptionMenuActions.mToolsAvkonIconCacheMenu->menuAction()->setVisible(false); +// mOptionMenuActions.mToolsAvkonIconCacheEnable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Enable", this, SLOT(toolsAvkonIconCacheEnable())); +// mOptionMenuActions.mToolsAvkonIconCacheDisable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Clear and disable", this, SLOT(toolsAvkonIconCacheDisable())); + + mOptionMenuActions.mToolsDisableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Disable extended errors", this, SLOT(toolsDisableExtendedErrors())); + mOptionMenuActions.mToolsDumpMsgStoreWalk = mOptionMenuActions.mToolsMenu->addAction("Dump msg. store walk", this, SLOT(toolsDumpMsgStoreWalk())); + mOptionMenuActions.mToolsDumpMsgStoreWalk->setVisible(false); + mOptionMenuActions.mToolsEditDataTypes = mOptionMenuActions.mToolsMenu->addAction("Edit data types", this, SLOT(toolsEditDataTypes())); + mOptionMenuActions.mToolsEditDataTypes->setVisible(false); + mOptionMenuActions.mToolsEnableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Enable extended errors", this, SLOT(toolsEnableExtendedErrors())); + + mOptionMenuActions.mToolsErrorSimulateMenu = mOptionMenuActions.mToolsMenu->addMenu("Error simulate"); + mOptionMenuActions.mToolsErrorSimulateLeave = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Leave", this, SLOT(toolsErrorSimulateLeave())); + mOptionMenuActions.mToolsErrorSimulatePanic = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Panic", this, SLOT(toolsErrorSimulatePanic())); + mOptionMenuActions.mToolsErrorSimulatePanic->setVisible(false); + mOptionMenuActions.mToolsErrorSimulateException = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Exception", this, SLOT(toolsErrorSimulateException())); + +// mOptionMenuActions.mLocalConnectivityMenu = mOptionMenuActions.mToolsMenu->addMenu("Local connectivity"); +// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared = mOptionMenuActions.mLocalConnectivityMenu->addAction("Activate infrared", this, SLOT(toolsLocalConnectivityActivateInfrared())); +// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch BT UI", this, SLOT(toolsLocalConnectivityLaunchBTUI())); +// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch USB UI", this, SLOT(toolsLocalConnectivityLaunchUSBUI())); + + mOptionMenuActions.mToolsMessageAttachmentsMenu = mOptionMenuActions.mToolsMenu->addMenu("Message attachments"); + mOptionMenuActions.mToolsMessageAttachmentsMenu->menuAction()->setVisible(false); + mOptionMenuActions.mToolsMessageInbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Inbox", this, SLOT(toolsMessageInbox())); + mOptionMenuActions.mToolsMessageDrafts = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Drafts", this, SLOT(toolsMessageDrafts())); + mOptionMenuActions.mToolsMessageSentItems = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Sent items", this, SLOT(toolsMessageSentItems())); + mOptionMenuActions.mToolsMessageOutbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Outbox", this, SLOT(toolsMessageOutbox())); + + mOptionMenuActions.mToolsMemoryInfo = mOptionMenuActions.mToolsMenu->addAction("Memory info", this, SLOT(toolsMemoryInfo())); + mOptionMenuActions.mToolsMemoryInfo->setVisible(false); + + mOptionMenuActions.mToolsSecureBackupMenu = mOptionMenuActions.mToolsMenu->addMenu("Secure backup"); + mOptionMenuActions.mToolsSecureBackupMenu->menuAction()->setVisible(false); + mOptionMenuActions.mToolsSecureBackStart = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start backup", this, SLOT(toolsSecureBackStart())); + mOptionMenuActions.mToolsSecureBackRestore = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start restore", this, SLOT(toolsSecureBackRestore())); + mOptionMenuActions.mToolsSecureBackStop = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Stop", this, SLOT(toolsSecureBackStop())); + + mOptionMenuActions.mToolsSetDebugMask = mOptionMenuActions.mToolsMenu->addAction("Set debug mask", this, SLOT(toolsSetDebugMaskQuestion())); + mOptionMenuActions.mToolsShowOpenFilesHere = mOptionMenuActions.mToolsMenu->addAction("Show open files here", this, SLOT(toolsShowOpenFilesHere())); + mOptionMenuActions.mToolsShowOpenFilesHere->setVisible(false); +} + +/** + Creates Setting menu item in option menu + */ +void FbDriveView::createSettingsMenuItem() +{ + mOptionMenuActions.mSetting = menu()->addAction("Settings..."); + connect(mOptionMenuActions.mSetting, SIGNAL(triggered()), this, SIGNAL(aboutToShowSettingsView())); +} + + +/** + Creates About menu item in option menu + */ +void FbDriveView::createAboutMenuItem() +{ + // about note + mOptionMenuActions.mAbout = menu()->addAction("About"); + connect(mOptionMenuActions.mAbout, SIGNAL(triggered()), this, SLOT(about())); +} + +/** + Creates Exit menu item in option menu + */ +void FbDriveView::createExitMenuItem() +{ + // application exit + mOptionMenuActions.mExit = menu()->addAction("Exit"); + connect(mOptionMenuActions.mExit, SIGNAL(triggered()), qApp, SLOT(quit())); +} + +/** + update menu: disk admin available only in device root view. edit available only in folder view + when file or folder content exist in current folder, or clipboard has copied item. + file and view menus updated every time regarding the folder content. + tools, settings, about, exit always available. + If there's remove and add operations at same time, always remove first + to keep to the correct menu items order. + */ +void FbDriveView::updateOptionMenu() +{ + bool isFileItemListEmpty = mFbDriveModel->rowCount() == 0; +// bool isDriveListViewActive = true; //mEngineWrapper->isDriveListViewActive(); + bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); +// bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); //iModel->FileUtils()->IsCurrentDriveReadOnly(); +// bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); + // bool currentSelected = true; //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex()); +// bool isAllSelected = mListView->selectionModel()->selection().count() == mFbDriveModel->rowCount(); + //bool isNoneSelected = mListView->selectionModel()->selection().count() != 0; +// bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0; + //bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); + bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse(); + bool showSnapShot = false; //iModel->FileUtils()->DriveSnapShotPossible(); + + bool showEditMenu(true); + if (!showSnapShot || isFileItemListEmpty && isClipBoardEmpty) + showEditMenu = false; + else + showEditMenu = true; + + mOptionMenuActions.mEditMenu->menuAction()->setVisible(showEditMenu); + + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileOpen, isFileItemListEmpty || isDriveListViewActive || isCurrentItemDirectory); +// mOptionMenuActions.mFileOpenDrive->setVisible( !(isFileItemListEmpty || !isDriveListViewActive)); + + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive); + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive); + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || isCurrentItemDirectory); + + // TODO mOptionMenuActions.mFileCompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive)); + // TODO mOptionMenuActions.mFileDecompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive)); + + // TODO mOptionMenuActions.mEditSnapShotToE->setVisible(isDriveListViewActive); + + // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isDriveListViewActive || isFileItemListEmpty)); + // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive || isDriveListViewActive || isFileItemListEmpty)); + mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive); + //mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty); + + // TODO R_FILEBROWSER_VIEW_SORT_SUBMENU + // aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn); + + // TODO R_FILEBROWSER_VIEW_ORDER_SUBMENU + // aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn); + + // aResourceId == R_FILEBROWSER_TOOLS_SUBMENU + bool noExtendedErrorsAllowed = mEngineWrapper->ErrRdFileExists(); + mOptionMenuActions.mToolsDisableExtendedErrors->setVisible(noExtendedErrorsAllowed); + mOptionMenuActions.mToolsEnableExtendedErrors->setVisible(!noExtendedErrorsAllowed); + +// bool infraRedAllowed = mEngineWrapper->FileExists(KIRAppPath); +// bool bluetoothAllowed = mEngineWrapper->FileExists(KBTAppPath); +// bool usbAllowed = mEngineWrapper->FileExists(KUSBAppPath); +// +// bool noLocalCon = !infraRedAllowed && !bluetoothAllowed && !usbAllowed; +// mOptionMenuActions.mToolsLocalConnectivityMenu->menuAction()->setVisible(!noLocalCon); +// +// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared->setVisible(infraRedAllowed); +// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI->setVisible(bluetoothAllowed); +// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI->setVisible(usbAllowed); +} + +void FbDriveView::createContextMenu() +{ + mContextMenu = new HbMenu(); + connect(mContextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu())); + + createFileContextMenu(); + createEditContextMenu(); + createViewContextMenu(); + createDiskAdminContextMenu(); +} + + +void FbDriveView::createFileContextMenu() +{ + //mContextMenuActions.mFileMenu = mContextMenu->addMenu("File"); + + //mContextMenuActions.mFileOpenDrive = mContextMenuActions.mFileMenu->addAction("Open drive (->)", this, SLOT(fileOpenDrive())); +// mContextMenuActions.mFileSearch = mContextMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); + //mContextMenuActions.mFileSearch->setVisible(false); + + //mContextMenuActions.mFileProperties = mContextMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties())); + mContextMenuActions.mFileProperties = mContextMenu->addAction("Properties", this, SLOT(fileProperties())); + mContextMenuActions.mFileSearch = mContextMenu->addAction("Search...", this, SLOT(fileSearch())); + +// mContextMenuActions.mFileSetAttributes = mContextMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); +// mContextMenuActions.mFileSetAttributes->setVisible(false); +} + +void FbDriveView::createEditContextMenu() +{ +// mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit"); + + //mContextMenuActions.mEditSnapShotToE = mContextMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); +// mContextMenuActions.mEditSnapShotToE->setVisible(false); +// mContextMenuActions.mEditCut = mContextMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); +// mContextMenuActions.mEditCopy = mContextMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); +// mContextMenuActions.mEditPaste = mContextMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); +// mContextMenuActions.mEditCopyToFolder = mContextMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); +// mContextMenuActions.mEditMoveToFolder = mContextMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); +} + +void FbDriveView::createViewContextMenu() +{ + +} + +/** + Initial setup for Disk Admin submenu + */ +void FbDriveView::createDiskAdminContextMenu() +{ + mContextMenuActions.mDiskAdminMenu = mContextMenu->addMenu("Disk admin"); + //mContextMenuActions.mDiskAdminMenu->menuAction()->setVisible(false); + + mContextMenuActions.mDiskAdminSetDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Set drive password", this, SLOT(diskAdminSetDrivePassword())); + mContextMenuActions.mDiskAdminUnlockDrive = mContextMenuActions.mDiskAdminMenu->addAction("Unlock drive", this, SLOT(diskAdminUnlockDrive())); + mContextMenuActions.mDiskAdminClearDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Clear drive password", this, SLOT(diskAdminClearDrivePassword())); + mContextMenuActions.mDiskAdminEraseDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Erase drive password", this, SLOT(diskAdminEraseDrivePassword())); + + mContextMenuActions.mDiskAdminFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Format drive", this, SLOT(diskAdminFormatDrive())); + mContextMenuActions.mDiskAdminFormatDrive->setVisible(false); + mContextMenuActions.mDiskAdminQuickFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Quick format drive", this, SLOT(diskAdminQuickFormatDrive())); + mContextMenuActions.mDiskAdminQuickFormatDrive->setVisible(false); + + mContextMenuActions.mDiskAdminCheckDisk = mContextMenuActions.mDiskAdminMenu->addAction("Check disk", this, SLOT(diskAdminCheckDisk())); + mContextMenuActions.mDiskAdminScanDrive = mContextMenuActions.mDiskAdminMenu->addAction("Scan drive", this, SLOT(diskAdminScanDrive())); + mContextMenuActions.mDiskAdminSetDriveName = mContextMenuActions.mDiskAdminMenu->addAction("Set drive name", this, SLOT(diskAdminSetDriveName())); + mContextMenuActions.mDiskAdminSetDriveVolumeLabel = mContextMenuActions.mDiskAdminMenu->addAction("Set drive volume label", this, SLOT(diskAdminSetDriveVolumeLabel())); + mContextMenuActions.mDiskAdminEjectDrive = mContextMenuActions.mDiskAdminMenu->addAction("Eject drive", this, SLOT(diskAdminEjectDrive())); + mContextMenuActions.mDiskAdminDismountDrive = mContextMenuActions.mDiskAdminMenu->addAction("Dismount drive", this, SLOT(diskAdminDismountDrive())); + mContextMenuActions.mDiskAdminEraseMBR = mContextMenuActions.mDiskAdminMenu->addAction("Erase MBR", this, SLOT(diskAdminEraseMBR())); + mContextMenuActions.mDiskAdminPartitionDrive = mContextMenuActions.mDiskAdminMenu->addAction("Partition drive", this, SLOT(diskAdminPartitionDrive())); +} + +void FbDriveView::updateContextMenu() +{ + bool isFileItemListEmpty = mFbDriveModel->rowCount() == 0; + mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty); +} + +// --------------------------------------------------------------------------- + +void FbDriveView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords) +{ + mCurrentIndex = listViewItem->modelIndex(); + + mContextMenu->setPreferredPos(coords); + mContextMenu->show(); +} + +/** + Refresh FileBrowser view + */ +void FbDriveView::refreshList() +{ + mEngineWrapper->refreshView(); + mListView->reset(); + + TListingMode listingMode = mEngineWrapper->listingMode(); + if (listingMode == ENormalEntries) + mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); + else if (listingMode == ESearchResults) + mNaviPane->setPlainText(QString(tr("Search results"))); + else if (listingMode == EOpenFiles) + mNaviPane->setPlainText(QString(tr("Open files"))); + else if (listingMode == EMsgAttachmentsInbox) + mNaviPane->setPlainText(QString(tr("Attachments in Inbox"))); + else if (listingMode == EMsgAttachmentsDrafts) + mNaviPane->setPlainText(QString(tr("Attachments in Drafts"))); + else if (listingMode == EMsgAttachmentsSentItems) + mNaviPane->setPlainText(QString(tr("Attachments in Sent Items"))); + else if (listingMode == EMsgAttachmentsOutbox) + mNaviPane->setPlainText(QString(tr("Attachments in Outbox"))); +} + +// --------------------------------------------------------------------------- +/** + Show a list dialog + \param List aList of item to select item from. + \param Title text titleText of a dialog heading widget + \return None + */ +void FbDriveView::openListDialog(const QStringList& items, const QString &titleText, QObject* receiver, const char* member) +{ + // Create a list and some simple content for it + HbSelectionDialog *dlg = new HbSelectionDialog(); + dlg->setAttribute(Qt::WA_DeleteOnClose); + // Set items to be popup's content + dlg->setStringItems(items); + dlg->setSelectionMode(HbAbstractItemView::SingleSelection); + + HbLabel *title = new HbLabel(dlg); + title->setPlainText(titleText); + dlg->setHeadingWidget(title); + + // Launch popup and handle the user response: + dlg->open(receiver, member); +} + +// --------------------------------------------------------------------------- + +void FbDriveView::openPropertyDialog(const QStringList& propertyList, const QString& title) +{ + HbDialog *dialog = new HbDialog(); + dialog->setDismissPolicy(HbPopup::TapOutside); + dialog->setTimeout(HbPopup::NoTimeout); + + HbLabel *titleWidget = new HbLabel(); + titleWidget->setPlainText(title); + dialog->setHeadingWidget(titleWidget); + + // Create a list and some simple content for it + HbListWidget *list = new HbListWidget(); + QString str; + foreach (str, propertyList) { + list->addItem(str); + } + + // Connect list item activation signal to close the popup + connect(list, SIGNAL(activated(HbListWidgetItem*)), dialog, SLOT(close())); + + HbAction *cancelAction = new HbAction("Close"); + dialog->setPrimaryAction(cancelAction); + + // Set listwidget to be popup's content + dialog->setContentWidget(list); + // Launch popup and handle the user response: + dialog->open(); +} + +void FbDriveView::storeSelectedItemsOrCurrentItem() +{ + QItemSelectionModel *selectionIndexes = mListView->selectionModel(); + + // by default use selected items + if (selectionIndexes) { + if (selectionIndexes->hasSelection()) { + mSelectionIndexes = mListView->selectionModel()->selectedIndexes(); + } else { // or if none selected, use the current item index + mSelectionIndexes.clear(); + mSelectionIndexes.append(mCurrentIndex); +// QModelIndex currentIndex = currentItemIndex(); +// if (mFbDriveModel->rowCount(currentItemIndex) > currentItemIndex && currentItemIndex >= 0) +// { +// modelIndexList.append(currentIndex); +// } + } + } +// mClipBoardInUse = true; +} + +// --------------------------------------------------------------------------- + +QModelIndex FbDriveView::currentItemIndex() +{ + return mCurrentIndex;//mListView->selectionModel()->currentIndex(); +} + +// --------------------------------------------------------------------------- +// operations in File Menu +// --------------------------------------------------------------------------- + +void FbDriveView::fileOpenDrive() +{ + // TODO make a separate function to be called from here and fileOpenDirectory() + mLocationChanged = true; + // get selected drive or directory from list view model and open it: + //if (mListView->selectionModel()->hasSelection()) { +// if (mListView->selectionModel()->selection().count() != 0) { +// QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->moveDownToDirectory(mCurrentIndex); + mListView->setRootIndex(mCurrentIndex); + refreshList(); +// } else { +// Notifications::showErrorNote("not selected item!"); +// } +} + +void FbDriveView::fileSearch() +{ + QString searchPath; + HbAction *contextrMenuAction = static_cast(sender()); + if (contextrMenuAction + && contextrMenuAction->text().compare(QString("Search..."), Qt::CaseInsensitive) == 0 + && contextrMenuAction == mContextMenuActions.mFileSearch) { + DriveEntry driveEntry(mEngineWrapper->getDriveEntry(currentItemIndex())); + searchPath = driveEntry.driveLetter() + QString(":\\"); + } else { + searchPath = mEngineWrapper->currentPath(); + } + emit aboutToShowSearchView(searchPath); +} + +/** + Show file properties + */ +void FbDriveView::fileProperties() +{ + QModelIndex currentIndex = currentItemIndex(); + QStringList propertyList; + QString titleText; + mEngineWrapper->properties(currentIndex, propertyList, titleText); + openPropertyDialog(propertyList, titleText); +} + +void FbDriveView::fileSetAttributes() +{ + +} + +// edit menu +void FbDriveView::editSnapShotToE() +{ + +} + +// --------------------------------------------------------------------------- +// view menu +// --------------------------------------------------------------------------- + +/** + Refresh view + */ +void FbDriveView::viewRefresh() +{ + refreshList(); +} + +// --------------------------------------------------------------------------- +// disk admin menu +// --------------------------------------------------------------------------- + +/** + Open old password for the selected drive dialog. + */ +void FbDriveView::diskAdminSetDrivePassword() +{ + QModelIndex currentIndex = currentItemIndex(); + // check if the drive has a password + if (mEngineWrapper->hasDrivePassword(currentIndex)) { + QString heading = QString("Existing password"); + HbInputDialog::getText(heading, this, SLOT(diskAdminSetDrivePasswordNew(HbAction*)), QString(), scene()); + } else { + QString heading = QString("New password"); + HbInputDialog::getText(heading, this, SLOT(doDiskAdminSetDrivePassword(HbAction*)), mOldPassword, scene()); + } +} + +/** + Open new password for the selected drive dialog. + */ +void FbDriveView::diskAdminSetDrivePasswordNew(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + mOldPassword = dlg->value().toString(); + QString heading = QString("New password"); + HbInputDialog::getText(heading, this, SLOT(doDiskAdminSetDrivePassword(HbAction*)), mOldPassword, scene()); + } +} + +/** + Set password for the selected drive. + */ +void FbDriveView::doDiskAdminSetDrivePassword(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString newPassword = dlg->value().toString(); + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminSetDrivePassword(currentIndex, mOldPassword, newPassword); + refreshList(); + mOldPassword = QString(); + newPassword = QString(); + } +} + +/** + Open Unlock the selected drive dialog. + */ +void FbDriveView::diskAdminUnlockDrive() +{ + QModelIndex currentIndex = currentItemIndex(); + // check if the drive is locked + if (mEngineWrapper->isDriveLocked(currentIndex)) { + QString heading = QString("Existing password"); + HbInputDialog::getText(heading, this, SLOT(doDiskAdminUnlockDrive(HbAction*)), QString(), scene()); + } else { + Notifications::showInformationNote(QString("This drive is not locked")); + } +} + +/** + Unlock the selected drive. + */ +void FbDriveView::doDiskAdminUnlockDrive(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString oldPassword = dlg->value().toString(); + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminUnlockDrive(currentIndex, oldPassword); + refreshList(); + } +} + +/** + Open clear password of the selected drive dialog. + */ +void FbDriveView::diskAdminClearDrivePassword() +{ + QModelIndex currentIndex = currentItemIndex(); + // check if the drive has a password + if (mEngineWrapper->hasDrivePassword(currentIndex)) { + QString heading = QString("Existing password"); + HbInputDialog::getText(heading, this, SLOT(doDiskAdminClearDrivePassword(HbAction*)), QString(), scene()); + } else { + Notifications::showInformationNote(QString("This drive has no password")); + } +} + +/** + Clear password of the selected drive. + */ +void FbDriveView::doDiskAdminClearDrivePassword(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString oldPassword = dlg->value().toString(); + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminClearDrivePassword(currentIndex, oldPassword); + refreshList(); + } +} + + +/** + Question for erase password of the selected drive + */ +void FbDriveView::diskAdminEraseDrivePassword() +{ + // check if the drive has a password + QModelIndex currentIndex = currentItemIndex(); + if (mEngineWrapper->hasDrivePassword(currentIndex)) { + HbMessageBox::question(QString("Are you sure? All data can be lost!"), this, SLOT(doDiskAdminEraseDrivePassword(HbAction*))); + } else { + Notifications::showInformationNote(QString("This drive has no password")); + } +} + +/** + Erase password of the selected drive + */ +void FbDriveView::doDiskAdminEraseDrivePassword(HbAction* action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminEraseDrivePassword(currentIndex); + refreshList(); + } +} + +/** + Performs format on the selected drive + */ +void FbDriveView::diskAdminFormatDrive() +{ + HbMessageBox::question(QString("Are you sure? All data will be lost!"), this, SLOT(doDiskAdminFormatDrive(HbAction*))); +} + +/** + Performs format on the selected drive + */ +void FbDriveView::doDiskAdminFormatDrive(HbAction* action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminFormatDrive(currentIndex, false); + } +} + +/** + Performs quick format on the selected drive + */ +void FbDriveView::diskAdminQuickFormatDrive() +{ + HbMessageBox::question(QString("Are you sure? All data will be lost!"), this, SLOT(doDiskAdminQuickFormatDrive(HbAction*))); +} + +/** + Performs quick format on the selected drive + */ +void FbDriveView::doDiskAdminQuickFormatDrive(HbAction* action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminFormatDrive(currentIndex, true); + } +} + +/** + Checks the disk integrity on the selected drive + */ +void FbDriveView::diskAdminCheckDisk() +{ + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminCheckDisk(currentIndex); +} + +/** + Checks the selected drive for errors and corrects them + */ +void FbDriveView::diskAdminScanDrive() +{ + HbMessageBox::question(QString("This finds errors on disk and corrects them. Proceed?"), this, SLOT(doDiskAdminScanDrive(HbAction*))); +} + +/** + Checks the selected drive for errors and corrects them + */ +void FbDriveView::doDiskAdminScanDrive(HbAction* action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminScanDrive(currentIndex); + refreshList(); + } +} + +/** + Open drive name dialog + */ +void FbDriveView::diskAdminSetDriveName() +{ + QString driveName; + + // get existing drive name + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->GetDriveName(currentIndex, driveName); + + QString heading = QString("New name"); + HbInputDialog::getText(heading, this, SLOT(doDiskAdminSetDriveName(HbAction*)), driveName, scene()); +} + +/** + Set drive name. + */ +void FbDriveView::doDiskAdminSetDriveName(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString driveName = dlg->value().toString(); + + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminSetDriveName(currentIndex, driveName); + + refreshList(); + } +} + +/** + Open drive volume label dialog + */ +void FbDriveView::diskAdminSetDriveVolumeLabel() +{ + QString volumeLabel; + + // get existing drive name + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->GetDriveVolumeLabel(currentIndex, volumeLabel); + + QString heading = QString("New volume label"); + HbInputDialog::getText(heading, this, SLOT(doDiskAdminSetDriveVolumeLabel(HbAction*)), volumeLabel, scene()); +} + +/** + Set drive volume label. + */ +void FbDriveView::doDiskAdminSetDriveVolumeLabel(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString volumeLabel = dlg->value().toString(); + + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminSetDriveVolumeLabel(currentIndex, volumeLabel); + + refreshList(); + } +} + +/** + Eject the selected drive + */ +void FbDriveView::diskAdminEjectDrive() +{ + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminEjectDrive(currentIndex); + refreshList(); +} + +/** + Dismount the selected drive + */ +void FbDriveView::diskAdminDismountDrive() +{ + HbMessageBox::question(QString("Are you sure you know what are you doing?"), this, SLOT(doDiskAdminDismountDrive(HbAction*))); +} + +void FbDriveView::doDiskAdminDismountDrive(HbAction* action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminDismountDrive(currentIndex); + refreshList(); + } +} + +/** + Erase Master Boot Record of the selected drive + */ +void FbDriveView::diskAdminEraseMBR() +{ + // TODO What to do with FB LITE macros? + HbMessageBox::question(QString("Are you sure? Your media driver must support this!"), this, SLOT(doDiskAdminEraseMBR(HbAction*))); +} + +void FbDriveView::doDiskAdminEraseMBR(HbAction* action) +{ + // TODO What to do with FB LITE macros? + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + HbMessageBox::question(QString("Are you really sure you know what are you doing ?!?"), this, SLOT(doDiskAdminReallyEraseMBR(HbAction*))); + } +} + +void FbDriveView::doDiskAdminReallyEraseMBR(HbAction* action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + QModelIndex currentIndex = currentItemIndex(); + // warn if the selected drive is not detected as removable + if (mEngineWrapper->isDriveRemovable(currentIndex)) { + mEngineWrapper->DiskAdminEraseMBR(currentIndex); + refreshList(); + } else { + HbMessageBox::question(QString("Selected drive is not removable, really continue?"), this, SLOT(doDiskAdminNotRemovableReallyEraseMBR(HbAction*))); + } + } +} + +void FbDriveView::doDiskAdminNotRemovableReallyEraseMBR(HbAction* action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->DiskAdminEraseMBR(currentIndex); + refreshList(); + } + +} + +/** + Partition the selected drive + */ +void FbDriveView::diskAdminPartitionDrive() +{ + const QString message("Are you sure? Your media driver must support this!"); + HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveProceed(HbAction *))); +} + +/** + Partition the selected drive if user is sure + */ +void FbDriveView::diskAdminPartitionDriveProceed(HbAction *action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + const QString message("Are you really sure you know what are you doing ?!?"); + HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveReallyProceed(HbAction *))); + } +} + +/** + Partition the selected drive if user is really sure + */ +void FbDriveView::diskAdminPartitionDriveReallyProceed(HbAction *action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + QModelIndex currentIndex = currentItemIndex(); + mEraseMBR = false; + // warn if the selected drive is not detected as removable + mProceed = false; + if (mEngineWrapper->isDriveRemovable(currentIndex)) { + mProceed = true; + } else { + const QString message("Selected drive is not removable, really continue?"); + HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveIsNotRemovable(HbAction *))); + } + + if (mProceed) { + // query if erase mbr + mEraseMBR = false; + + QString message("Erase MBR first (normally needed)?"); + HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveEraseMbr(HbAction *))); + + // TODO use HbListDialog + QStringList list; + list << "1" << "2" << "3" << "4"; + openListDialog(list, QString("Partitions?"), this, SLOT(diskAdminPartitionDriveGetCount(HbAction*))); + } + } +} + +/** + Store result of user query about proceeding when drive is not removable. + */ +void FbDriveView::diskAdminPartitionDriveIsNotRemovable(HbAction *action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + mProceed = true; + } else { + mProceed = false; + } +} + +/** + Store result of user query about erase MBR + */ +void FbDriveView::diskAdminPartitionDriveEraseMbr(HbAction *action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + mEraseMBR = true; + } +} + +/** + Partition the selected drive + */ +void FbDriveView::diskAdminPartitionDriveGetCount(HbAction* action) +{ + HbSelectionDialog *dlg = static_cast(sender()); + if(!action && dlg && dlg->selectedItems().count()){ + int selectionIndex = dlg->selectedItems().at(0).toInt(); + QModelIndex currentIndex = currentItemIndex(); + int amountOfPartitions = selectionIndex + 1; + mEngineWrapper->DiskAdminPartitionDrive(currentIndex, mEraseMBR, amountOfPartitions); + refreshList(); + } +} + +// --------------------------------------------------------------------------- +// tools menu +// --------------------------------------------------------------------------- +void FbDriveView::toolsAllAppsToTextFile() +{ + +} + +/** + Write all files to text file + */ +void FbDriveView::toolsAllFilesToTextFile() +{ + mEngineWrapper->toolsWriteAllFiles(); +} + +//void FbDriveView::toolsAvkonIconCacheEnable() +//{ +// +//} +//void FbDriveView::toolsAvkonIconCacheDisable() +//{ +// +//} + +/** + Disable extended errors + */ +void FbDriveView::toolsDisableExtendedErrors() +{ + mEngineWrapper->ToolsSetErrRd(false); +} + +void FbDriveView::toolsDumpMsgStoreWalk() +{ + +} +void FbDriveView::toolsEditDataTypes() +{ + +} + +/** + Enable extended errors + */ +void FbDriveView::toolsEnableExtendedErrors() +{ + mEngineWrapper->ToolsSetErrRd(true); +} + +/** + Open simulate leave dialog + */ +void FbDriveView::toolsErrorSimulateLeave() +{ + int leaveCode = -6; + QString heading = QString("Leave code"); + //HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), leaveCode, scene()); + HbInputDialog::getText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene()); +} + + +/** + Simulate leave. + */ +void FbDriveView::doToolsErrorSimulateLeave(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + bool ok; + int leaveCode = dlg->value().toString().toInt(&ok); + if (leaveCode != 0 || ok) { + mEngineWrapper->ToolsErrorSimulateLeave(leaveCode); + } + } +} + +/** + Open simulate panic dialog. + */ +void FbDriveView::toolsErrorSimulatePanic() +{ + mPanicCategory = QString ("Test Category"); + QString heading = QString("Panic category"); + HbInputDialog::getText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene()); +} + +/** + Simulate panic. + */ +void FbDriveView::doToolsErrorSimulatePanicCode(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + mPanicCategory = dlg->value().toString(); + int panicCode(555); + QString heading = QString("Panic code"); + HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene()); + } +} + +/** + Simulate panic. + */ +void FbDriveView::doToolsErrorSimulatePanic(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + bool ok; + int panicCode = dlg->value().toInt(&ok); + if (panicCode != 0 || ok) { + mEngineWrapper->ToolsErrorSimulatePanic(mPanicCategory, panicCode); + } + } +} + +/** + Open simulate exception dialog. + */ +void FbDriveView::toolsErrorSimulateException() +{ + int exceptionCode = 0; + QString heading = QString("Exception code"); + HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene()); +} + +/** + Simulate exception. + */ +void FbDriveView::doToolsErrorSimulateException(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + bool ok; + int exceptionCode = dlg->value().toInt(&ok); + if (exceptionCode != 0 || ok) { + mEngineWrapper->ToolsErrorSimulateException(exceptionCode); + } + } +} + +// void FbDriveView::toolsLocalConnectivityActivateInfrared() +//{ +// +//} +// void FbDriveView::toolsLocalConnectivityLaunchBTUI() +//{ +// +//} +// void FbDriveView::toolsLocalConnectivityLaunchUSBUI() +//{ +// +//} +void FbDriveView::toolsMessageInbox() +{ + +} +void FbDriveView::toolsMessageDrafts() +{ + +} +void FbDriveView::toolsMessageSentItems() +{ + +} +void FbDriveView::toolsMessageOutbox() +{ + +} +void FbDriveView::toolsMemoryInfo() +{ + +} +void FbDriveView::toolsSecureBackStart() +{ + +} +void FbDriveView::toolsSecureBackRestore() +{ + +} +void FbDriveView::toolsSecureBackStop() +{ + +} + +/** + Open debug mask dialog + */ +void FbDriveView::toolsSetDebugMaskQuestion() +{ + quint32 dbgMask = mEngineWrapper->getDebugMask(); + QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16)); + QString heading = QString("Kernel debug mask in hex format"); + HbInputDialog::getText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene()); +} + +/** + Set debug mask + */ +void FbDriveView::toolsSetDebugMask(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString dbgMaskText = dlg->value().toString(); + if (dbgMaskText.length() > 2 && dbgMaskText[0]=='0' && dbgMaskText[1]=='x') { + bool ok; + quint32 dbgMask = dbgMaskText.toUInt(&ok, 16); + if (dbgMask != 0 || ok) { + mEngineWrapper->toolsSetDebugMask(dbgMask); + Notifications::showConfirmationNote(QString("Changed")); + } else { + Notifications::showErrorNote(QString("Cannot convert value")); + } + } else { + Notifications::showErrorNote(QString("Not in hex format")); + } + } +} + +void FbDriveView::toolsShowOpenFilesHere() +{ + +} + +// --------------------------------------------------------------------------- +// main menu items +// --------------------------------------------------------------------------- + +/** + Show about note + */ +void FbDriveView::about() +{ + Notifications::showAboutNote(); +} + +// --------------------------------------------------------------------------- +// End of operations +// --------------------------------------------------------------------------- + +// --------------------------------------------------------------------------- + +/** + Item is selected from list when selection mode is activated from menu + */ +void FbDriveView::selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/) +{ + //QItemSelectionModel *selectionModel = mListView->selectionModel(); +} + +/** + An item is clicked from navigation item list. Navigation item list contains + drive-, folder- or file items. Opens selected drive, folder or file popup menu + */ +void FbDriveView::activated(const QModelIndex& index) +{ + if (mFbDriveModel) { +// if (mEngineWrapper->isDriveListViewActive()) { + mEngineWrapper->moveDownToDirectory(index); + //emit aboutToShowFileView(QString(mEngineWrapper->currentPath())); + emit aboutToShowFileView(); + //refreshList(); +// } + } +} + +// --------------------------------------------------------------------------- diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/fbfilelistviewitem.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/src/fbfilelistviewitem.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,160 @@ +/* +* 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 "fbfilelistviewitem.h" + +#include +#include +#include +#include +#include + +#include +#include +#include + +FbFileListViewItem::FbFileListViewItem(QGraphicsItem *parent) : + HbListViewItem(parent), + hLayout(0), + mDiskNameLabel(0), + mSizeLabel(0), + mFreeLabel(0), + mIconLabel(0) +{ +} + +FbFileListViewItem::~FbFileListViewItem() +{ +} + +void FbFileListViewItem::polish(HbStyleParameters ¶ms) +{ + Q_UNUSED(params); +} + +bool FbFileListViewItem::canSetModelIndex(const QModelIndex &index) const +{ + Q_UNUSED(index); + return true; +} + + +HbAbstractViewItem *FbFileListViewItem::createItem() +{ + return new FbFileListViewItem(*this); +} + +void FbFileListViewItem::updateChildItems() +{ + if(!hLayout) { + init(); + } + + // Qt::DisplayRole + QVariant displayRole = modelIndex().data(Qt::DisplayRole); + QString diskName("default"); + QStringList stringList; + if (displayRole.isValid()) { + if (displayRole.canConvert()) { // EFileViewModeSimple + stringList.append(displayRole.toString()); + } else if (displayRole.canConvert()) { // EFileViewModeExtended + stringList = displayRole.toStringList(); + } + if (stringList.count() > 0) + diskName = stringList[0]; //modelIndex().data( Qt::UserRole ).toString(); + + mDiskNameLabel->setPlainText(diskName/*displayString*/); + } + +// mSizeLabel->setPlainText( hbTrId ( "Size: " ) /*+ FmUtils::formatStorageSize( driverInfo.size() )*/ ); +// mFreeLabel->setPlainText( hbTrId ( "Free: " ) /*+ FmUtils::formatStorageSize( driverInfo.freeSize() )*/ ); + if (stringList.count() > 1) + mSizeLabel->setPlainText( stringList[1] ); + + //mStorageSizeDiagram->setFreeSizePercentage(); + //mFreeLabel->setPlainText( stringList[2] ); + + // mCheckBox->setCheckState( checkState() ); + + // Qt::DecorationRole + QVariant decorationRole = modelIndex().data(Qt::DecorationRole); + if (decorationRole.isValid()) { + QIcon icon = qvariant_cast(decorationRole); +// if( icon.isNull() ) { +// QFileIconProvider fileIconProvider; +// icon = fileIconProvider.icon(QFileIconProvider::Drive); +// } + mIconLabel->setIcon(HbIcon(icon)); + } +} + +void FbFileListViewItem::setCheckedState(int state) +{ + HbAbstractViewItem::setCheckState(static_cast(state)); +} + +void FbFileListViewItem::init() +{ + hLayout = new QGraphicsLinearLayout(); + + hLayout->setOrientation( Qt::Horizontal ); + hLayout->addItem(layout()); + + mIconLabel = new HbLabel(); + hLayout->addItem( mIconLabel ); + hLayout->setAlignment( mIconLabel, Qt::AlignTop ); + hLayout->setStretchFactor( mIconLabel, 0 ); + +// mStorageSizeDiagram = new FbDriveStorageSizeDiagram(this); +// hLayout->addItem( mStorageSizeDiagram ); +// hLayout->setAlignment( mIconLabel, Qt::AlignTop ); +// hLayout->setStretchFactor( mStorageSizeDiagram, 0 ); + + QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); + vLayout->setOrientation( Qt::Vertical ); + + mDiskNameLabel = new HbLabel(); + //HbFontSpec fontSpecPrimary(HbFontSpec::Primary); + //fontSpecPrimary.setTextHeight(18.0); + //mDiskNameLabel->setFontSpec( fontSpecPrimary ); + vLayout->addItem( mDiskNameLabel ); + vLayout->setAlignment( mDiskNameLabel, Qt::AlignLeft ); + + mSizeLabel = new HbLabel(); + //HbFontSpec fontSpecSecondary(HbFontSpec::Secondary); + //fontSpecSecondary.setTextHeight(18.0); + //mSizeLabel->setFontSpec(fontSpecSecondary); + vLayout->addItem( mSizeLabel ); + vLayout->setAlignment(mSizeLabel, Qt::AlignLeft); + +// mFreeLabel = new HbLabel(); +// mFreeLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) ); +// vLayout->addItem( mFreeLabel ); +// vLayout->setAlignment( mFreeLabel, Qt::AlignLeft ); + + HbWidget *labelsWidget = new HbWidget(); + labelsWidget->setLayout(vLayout); + + hLayout->setAlignment( labelsWidget, Qt::AlignLeft ); + + hLayout->addItem( labelsWidget ); + hLayout->setStretchFactor( labelsWidget, 1 ); + +// this->setMaximumHeight(80); + + setLayout( hLayout ); +} diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/fbfilemodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/src/fbfilemodel.cpp Tue Jul 06 14:17:03 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: +* +*/ + +#include "fbfilemodel.h" +#include "enginewrapper.h" +#include "fileentry.h" +#include "driveentry.h" +#include "settingsview.h" +#include "filebrowsersettings.h" +#include "FB.hrh" + +#include +#include + +/** + Constructs a file browser custom system model with the given \a engineWrapper and \a parent. + */ +FbFileModel::FbFileModel(EngineWrapper *engineWrapper, QObject *parent) : + QAbstractListModel(parent), + mEngineWrapper(engineWrapper), + mFileIconProvider(0) +{ + mFileIconProvider = new QFileIconProvider(); +} + +/** + Destroys this file browser custom system model. + */ +FbFileModel::~FbFileModel() +{ + if (mFileIconProvider) { + delete mFileIconProvider; + } +} + +/** + \reimp + */ +int FbFileModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return mEngineWrapper->itemCount(); +} + +/** + \reimp + */ +QVariant FbFileModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid() || index.model() != this) + return QVariant(); + + switch (role) { + case Qt::EditRole: + case Qt::DisplayRole: { + QStringList listItem; +// if (mEngineWrapper->isDriveListViewActive()) { +// DriveEntry driveEntry(mEngineWrapper->getDriveEntry(index)); +// if (mEngineWrapper->settings().fileViewMode() == EFileViewModeSimple) +// { +// const QString SimpleDriveEntry("%1: <%2>"); +// listItem /*<< driveEntry.IconId() */ +// << SimpleDriveEntry.arg(driveEntry.driveLetter()) +// .arg(driveEntry.mediaTypeString()); +// } else if (mEngineWrapper->settings().fileViewMode() == EFileViewModeExtended) { +// const QString SimpleDriveEntry("%1: <%2>"); +// const QString ExtendedDriveEntry("%1/%2 kB"); +// listItem /*<< driveEntry.IconId()*/ +// << SimpleDriveEntry.arg(driveEntry.driveLetter()) +// .arg(driveEntry.mediaTypeString()) +// << ExtendedDriveEntry.arg(QString::number(driveEntry.volumeInfoFree()/1024)) +// .arg(QString::number(driveEntry.volumeInfoSize()/1024)); +// +// } +// } else { + FileEntry fileEntry(mEngineWrapper->getFileEntry(index)); + if (mEngineWrapper->settings().fileViewMode() == EFileViewModeSimple) + { + listItem /*<< fileEntry.IconId()*/ + << fileEntry.name(); + } else if (mEngineWrapper->settings().fileViewMode() == EFileViewModeExtended) { + QString extraData; + extraData.append(fileEntry.modifiedString()); + if (fileEntry.isDir() && fileEntry.dirEntries() >= 0) { + extraData.append(" - "); + extraData.append(fileEntry.dirEntriesString()); + } else if (!fileEntry.isDir()) { + extraData.append(" - "); + extraData.append(fileEntry.sizeString()); + } + listItem /*<< fileEntry.IconId()*/ + << fileEntry.name() << extraData << fileEntry.attributesString(); + } +// } + return listItem; + } + case Qt::DecorationRole: { + if (mEngineWrapper) { + QIcon icon; +// if (mEngineWrapper->isDriveListViewActive()) { +// icon = mFileIconProvider->icon(QFileIconProvider::Drive); +// } else { + FileEntry fileEntry(mEngineWrapper->getFileEntry(index)); + if (fileEntry.isDir()) { + icon = mFileIconProvider->icon(QFileIconProvider::Folder); + } else { + icon = mFileIconProvider->icon(QFileIconProvider::File); + } +// } + return QVariant(icon); + } + } + } + + return QVariant(); +} + +/** + \reimp + */ +QVariant FbFileModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + Q_UNUSED(section) + Q_UNUSED(orientation) + Q_UNUSED(role) + + // TODO, implement or remove + return QVariant(); +} + +// --------------------------------------------------------------------------- diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/fbfileview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/src/fbfileview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,1535 @@ +/* +* 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 "fbfileview.h" +#include "settingsview.h" +#include "editorview.h" +#include "searchview.h" +#include "enginewrapper.h" +#include "notifications.h" + +#include "fbfilemodel.h" +#include "filebrowsersortfilterproxymodel.h" +//#include "fbfilelistviewitem.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +//TODO check if needed to do this way +#include + +// --------------------------------------------------------------------------- + +FbFileView::FbFileView() : + mEngineWrapper(0), + mListView(0), + mToolBar(0), + mNaviPane(0), + mSearchPanel(0), + mMainLayout(0), + mFbFileModel(0), + mSortFilterProxyModel(0), + mOptionMenuActions(), + mContextMenuActions(), + mContextMenu(0), + mToolbarBackAction(0), + mItemHighlighted(false), + mLocationChanged(false), + mRemoveFileAfterCopied(false), +// mClipBoardInUse(false), + mFolderContentChanged(false), + mCurrentIndex(), + mOldPassword(), + mPanicCategory(), + mAbsoluteFilePath(), + mOverwriteOptions(), + mModelIndex(), + mNewFileName(), + mProceed(false), + mEraseMBR(false) +{ + setTitle("File Browser"); + + createMenu(); + createContextMenu(); + createToolBar(); +} + +// --------------------------------------------------------------------------- + +void FbFileView::init(EngineWrapper *engineWrapper) +{ + mEngineWrapper = engineWrapper; + + mListView = new HbListView(this); + mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape); + +// mListView->setItemPrototype(new FbDiskListViewItem(mListView)); + + mFbFileModel = new FbFileModel(mEngineWrapper); + if (!mListView->model()) { + + mEngineWrapper->refreshView(); + + mSortFilterProxyModel = new FileBrowserSortFilterProxyModel(this); + mSortFilterProxyModel->setSourceModel(mFbFileModel); + mSortFilterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + mSearchPanel->setPlaceholderText(QString("Type filter criteria")); + + mListView->setModel(mSortFilterProxyModel); + } + + //mListView->setRootIndex(mFileSystemModel->index(startPath)); + //mListView->setRootIndex(model->index()); + + //setItemVisible(Hb::ToolBarItem, !mEngineWrapper->isDriveListViewActive()); +// mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); + + connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); + connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), + this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF))); + + mNaviPane = new HbLabel(this); + mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default + //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); + HbFontSpec fontSpec(HbFontSpec::PrimarySmall); + mNaviPane->setFontSpec(fontSpec); + + // Create layout and add list view and toolbar into layout: + mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); + mMainLayout->addItem(mNaviPane); + mMainLayout->addItem(mListView); + setLayout(mMainLayout); +} + +// --------------------------------------------------------------------------- + +FbFileView::~FbFileView() +{ +// if (mEngineWrapper) { +// delete mEngineWrapper; +// } + if (mContextMenu) { + mContextMenu->deleteLater(); + } + + delete mSortFilterProxyModel; + delete mFbFileModel; + delete mListView; + delete mToolBar; +} + +/** + Initial setup for options menu. + Dynamic menu update during the runtime is performed by updateOptionMenu() which + to menu's aboutToShow() signal. + */ +void FbFileView::createMenu() +{ + createFileMenu(); + createEditMenu(); + createViewMenu(); + createToolsMenu(); + + createSelectionMenuItem(); + createSettingsMenuItem(); + createAboutMenuItem(); + createExitMenuItem(); + + // menu dynamic update + connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateOptionMenu())); +} + +/** + Initial setup for File submenu + */ +void FbFileView::createFileMenu() +{ + mOptionMenuActions.mFileMenu = menu()->addMenu("File"); + + mOptionMenuActions.mFileBackMoveUp = mOptionMenuActions.mFileMenu->addAction("Back/Move up", this, SLOT(fileBackMoveUp())); + mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); + //mOptionMenuActions.mFileSearch->setVisible(false); + + mOptionMenuActions.mFileNewMenu = mOptionMenuActions.mFileMenu->addMenu("New"); + mOptionMenuActions.mFileNewFile = mOptionMenuActions.mFileNewMenu->addAction("File", this, SLOT(fileNewFile())); + mOptionMenuActions.mFileNewDirectory = mOptionMenuActions.mFileNewMenu->addAction("Directory", this, SLOT(fileNewDirectory())); + + mOptionMenuActions.mFileDelete = mOptionMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete())); + mOptionMenuActions.mFileRename = mOptionMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename())); + mOptionMenuActions.mFileTouch = mOptionMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch())); + +// mOptionMenuActions.mFileChecksumsMenu = mOptionMenuActions.mFileMenu->addMenu("Checksums"); +// mOptionMenuActions.mFileChecksumsMD5 = mOptionMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5())); +// mOptionMenuActions.mFileChecksumsMD2 = mOptionMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2())); +// mOptionMenuActions.mFileChecksumsSHA1 = mOptionMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1())); + + mOptionMenuActions.mFileSetAttributes = mOptionMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); + mOptionMenuActions.mFileSetAttributes->setVisible(false); +} + +/** + Initial setup for Edit submenu + */ +void FbFileView::createEditMenu() +{ + mOptionMenuActions.mEditMenu = menu()->addMenu("Edit"); + + mOptionMenuActions.mEditSnapShotToE = mOptionMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); + mOptionMenuActions.mEditSnapShotToE->setVisible(false); + mOptionMenuActions.mEditCut = mOptionMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); + mOptionMenuActions.mEditCopy = mOptionMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); + mOptionMenuActions.mEditPaste = mOptionMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); + + mOptionMenuActions.mEditCopyToFolder = mOptionMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); + mOptionMenuActions.mEditMoveToFolder = mOptionMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); + + mOptionMenuActions.mEditSelect = mOptionMenuActions.mEditMenu->addAction("Select", this, SLOT(editSelect())); + mOptionMenuActions.mEditUnselect = mOptionMenuActions.mEditMenu->addAction("Unselect", this, SLOT(editUnselect())); + mOptionMenuActions.mEditSelectAll = mOptionMenuActions.mEditMenu->addAction("Select all", this, SLOT(editSelectAll())); + mOptionMenuActions.mEditUnselectAll = mOptionMenuActions.mEditMenu->addAction("Unselect all", this, SLOT(editUnselectAll())); +} + +/** + Initial setup for View submenu + */ +void FbFileView::createViewMenu() +{ + mOptionMenuActions.mViewMenu = menu()->addMenu("View"); + //mOptionMenuActions.mViewMenu->menuAction()->setVisible(false); + + mOptionMenuActions.mViewFilterEntries = mOptionMenuActions.mViewMenu->addAction("Filter entries", this, SLOT(viewFilterEntries())); + mOptionMenuActions.mViewRefresh = mOptionMenuActions.mViewMenu->addAction("Refresh", this, SLOT(viewRefresh())); +} + +/** + Initial setup for Tools submenu + */ +void FbFileView::createToolsMenu() +{ + mOptionMenuActions.mToolsMenu = menu()->addMenu("Tools"); + + mOptionMenuActions.mToolsAllAppsToTextFile = mOptionMenuActions.mToolsMenu->addAction("All apps to a text file", this, SLOT(toolsAllAppsToTextFile())); + mOptionMenuActions.mToolsAllAppsToTextFile->setVisible(false); + mOptionMenuActions.mToolsAllFilesToTextFile = mOptionMenuActions.mToolsMenu->addAction("All files to a text file", this, SLOT(toolsAllFilesToTextFile())); + //mOptionMenuActions.mToolsAllFilesToTextFile->setVisible(false); + +// mOptionMenuActions.mToolsAvkonIconCacheMenu = mOptionMenuActions.mToolsMenu->addMenu("Avkon icon cache"); +// mOptionMenuActions.mToolsAvkonIconCacheMenu->menuAction()->setVisible(false); +// mOptionMenuActions.mToolsAvkonIconCacheEnable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Enable", this, SLOT(toolsAvkonIconCacheEnable())); +// mOptionMenuActions.mToolsAvkonIconCacheDisable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Clear and disable", this, SLOT(toolsAvkonIconCacheDisable())); + + mOptionMenuActions.mToolsDisableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Disable extended errors", this, SLOT(toolsDisableExtendedErrors())); + mOptionMenuActions.mToolsDumpMsgStoreWalk = mOptionMenuActions.mToolsMenu->addAction("Dump msg. store walk", this, SLOT(toolsDumpMsgStoreWalk())); + mOptionMenuActions.mToolsDumpMsgStoreWalk->setVisible(false); + mOptionMenuActions.mToolsEditDataTypes = mOptionMenuActions.mToolsMenu->addAction("Edit data types", this, SLOT(toolsEditDataTypes())); + mOptionMenuActions.mToolsEditDataTypes->setVisible(false); + mOptionMenuActions.mToolsEnableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Enable extended errors", this, SLOT(toolsEnableExtendedErrors())); + + mOptionMenuActions.mToolsErrorSimulateMenu = mOptionMenuActions.mToolsMenu->addMenu("Error simulate"); + mOptionMenuActions.mToolsErrorSimulateLeave = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Leave", this, SLOT(toolsErrorSimulateLeave())); + mOptionMenuActions.mToolsErrorSimulatePanic = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Panic", this, SLOT(toolsErrorSimulatePanic())); + mOptionMenuActions.mToolsErrorSimulatePanic->setVisible(false); + mOptionMenuActions.mToolsErrorSimulateException = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Exception", this, SLOT(toolsErrorSimulateException())); + +// mOptionMenuActions.mLocalConnectivityMenu = mOptionMenuActions.mToolsMenu->addMenu("Local connectivity"); +// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared = mOptionMenuActions.mLocalConnectivityMenu->addAction("Activate infrared", this, SLOT(toolsLocalConnectivityActivateInfrared())); +// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch BT UI", this, SLOT(toolsLocalConnectivityLaunchBTUI())); +// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch USB UI", this, SLOT(toolsLocalConnectivityLaunchUSBUI())); + + mOptionMenuActions.mToolsMessageAttachmentsMenu = mOptionMenuActions.mToolsMenu->addMenu("Message attachments"); + mOptionMenuActions.mToolsMessageAttachmentsMenu->menuAction()->setVisible(false); + mOptionMenuActions.mToolsMessageInbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Inbox", this, SLOT(toolsMessageInbox())); + mOptionMenuActions.mToolsMessageDrafts = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Drafts", this, SLOT(toolsMessageDrafts())); + mOptionMenuActions.mToolsMessageSentItems = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Sent items", this, SLOT(toolsMessageSentItems())); + mOptionMenuActions.mToolsMessageOutbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Outbox", this, SLOT(toolsMessageOutbox())); + + mOptionMenuActions.mToolsMemoryInfo = mOptionMenuActions.mToolsMenu->addAction("Memory info", this, SLOT(toolsMemoryInfo())); + mOptionMenuActions.mToolsMemoryInfo->setVisible(false); + + mOptionMenuActions.mToolsSecureBackupMenu = mOptionMenuActions.mToolsMenu->addMenu("Secure backup"); + mOptionMenuActions.mToolsSecureBackupMenu->menuAction()->setVisible(false); + mOptionMenuActions.mToolsSecureBackStart = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start backup", this, SLOT(toolsSecureBackStart())); + mOptionMenuActions.mToolsSecureBackRestore = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start restore", this, SLOT(toolsSecureBackRestore())); + mOptionMenuActions.mToolsSecureBackStop = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Stop", this, SLOT(toolsSecureBackStop())); + + mOptionMenuActions.mToolsSetDebugMask = mOptionMenuActions.mToolsMenu->addAction("Set debug mask", this, SLOT(toolsSetDebugMaskQuestion())); + mOptionMenuActions.mToolsShowOpenFilesHere = mOptionMenuActions.mToolsMenu->addAction("Show open files here", this, SLOT(toolsShowOpenFilesHere())); + mOptionMenuActions.mToolsShowOpenFilesHere->setVisible(false); +} + +/** + Creates Selection mode menu item in option menu + */ +void FbFileView::createSelectionMenuItem() +{ + if (!mOptionMenuActions.mSelection) { + mOptionMenuActions.mSelection = menu()->addAction("Selection mode"); + mOptionMenuActions.mSelection->setToolTip("Selection mode"); + mOptionMenuActions.mSelection->setCheckable(true); + connect(mOptionMenuActions.mSelection, SIGNAL(triggered()), this, SLOT(selectionModeChanged())); + } +} + +/** + Creates Setting menu item in option menu + */ +void FbFileView::createSettingsMenuItem() +{ + mOptionMenuActions.mSetting = menu()->addAction("Settings..."); + connect(mOptionMenuActions.mSetting, SIGNAL(triggered()), this, SIGNAL(aboutToShowSettingsView())); +} + + +/** + Creates About menu item in option menu + */ +void FbFileView::createAboutMenuItem() +{ + // about note + mOptionMenuActions.mAbout = menu()->addAction("About"); + connect(mOptionMenuActions.mAbout, SIGNAL(triggered()), this, SLOT(about())); +} + +/** + Creates Exit menu item in option menu + */ +void FbFileView::createExitMenuItem() +{ + // application exit + mOptionMenuActions.mExit = menu()->addAction("Exit"); + connect(mOptionMenuActions.mExit, SIGNAL(triggered()), qApp, SLOT(quit())); +} + +/** + update menu: disk admin available only in device root view. edit available only in folder view + when file or folder content exist in current folder, or clipboard has copied item. + file and view menus updated every time regarding the folder content. + tools, settings, about, exit always available. + If there's remove and add operations at same time, always remove first + to keep to the correct menu items order. + */ +void FbFileView::updateOptionMenu() +{ + bool isFileItemListEmpty = mFbFileModel->rowCount() == 0; + bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); + bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); //iModel->FileUtils()->IsCurrentDriveReadOnly(); + bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); + // bool currentSelected = true; //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex()); + bool isAllSelected = mListView->selectionModel()->selection().count() == mFbFileModel->rowCount(); + //bool isNoneSelected = mListView->selectionModel()->selection().count() != 0; + bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0; + bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); + bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse(); + //bool showSnapShot = false; //iModel->FileUtils()->DriveSnapShotPossible(); + + bool showEditMenu(true); + if (isFileItemListEmpty && isClipBoardEmpty) + showEditMenu = false; + else + showEditMenu = true; + + mOptionMenuActions.mEditMenu->menuAction()->setVisible(showEditMenu); + + //mOptionMenuActions.mFileBackMoveUp->setVisible( !isDriveListViewActive); + + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory); + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory); + //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || isCurrentItemDirectory); + + mOptionMenuActions.mFileNewMenu->menuAction()->setVisible(!isCurrentDriveReadOnly); + mOptionMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems/*isSelectionMode*/); + mOptionMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems/*&& isSelectionMode*/); + mOptionMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems); + + // TODO mOptionMenuActions.mFileChecksumsMenu->setVisible(!(isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory)); + // TODO mOptionMenuActions.mFileSetAttributes->setVisible(!(isFileItemListEmpty || isCurrentDriveReadOnly)); + // TODO mOptionMenuActions.mFileCompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory)); + // TODO mOptionMenuActions.mFileDecompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory)); + + mOptionMenuActions.mEditCut->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && isSelectionMode); + mOptionMenuActions.mEditCopy->setVisible(!isFileItemListEmpty && isSelectionMode); + mOptionMenuActions.mEditPaste->setVisible(!(isClipBoardEmpty || isCurrentDriveReadOnly)); + mOptionMenuActions.mEditCopyToFolder->setVisible(!isFileItemListEmpty); + mOptionMenuActions.mEditMoveToFolder->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty)); + + mOptionMenuActions.mEditSelect->setVisible(false/*!currentSelected && !isFileItemListEmpty*/); + mOptionMenuActions.mEditUnselect->setVisible(false/*currentSelected && !isFileItemListEmpty*/); + mOptionMenuActions.mEditSelectAll->setVisible(isSelectionMode && !isAllSelected && !isFileItemListEmpty); + mOptionMenuActions.mEditUnselectAll->setVisible(hasSelectedItems && !isFileItemListEmpty); + + // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isFileItemListEmpty)); + // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive || isFileItemListEmpty)); + mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive); + mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty); + + // TODO R_FILEBROWSER_VIEW_SORT_SUBMENU + // aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn); + + // TODO R_FILEBROWSER_VIEW_ORDER_SUBMENU + // aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn); + + // aResourceId == R_FILEBROWSER_TOOLS_SUBMENU + bool noExtendedErrorsAllowed = mEngineWrapper->ErrRdFileExists(); + mOptionMenuActions.mToolsDisableExtendedErrors->setVisible(noExtendedErrorsAllowed); + mOptionMenuActions.mToolsEnableExtendedErrors->setVisible(!noExtendedErrorsAllowed); + +// bool infraRedAllowed = mEngineWrapper->FileExists(KIRAppPath); +// bool bluetoothAllowed = mEngineWrapper->FileExists(KBTAppPath); +// bool usbAllowed = mEngineWrapper->FileExists(KUSBAppPath); +// +// bool noLocalCon = !infraRedAllowed && !bluetoothAllowed && !usbAllowed; +// mOptionMenuActions.mToolsLocalConnectivityMenu->menuAction()->setVisible(!noLocalCon); +// +// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared->setVisible(infraRedAllowed); +// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI->setVisible(bluetoothAllowed); +// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI->setVisible(usbAllowed); +} + +void FbFileView::createContextMenu() +{ + mContextMenu = new HbMenu(); + connect(mContextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu())); + + createFileContextMenu(); + createEditContextMenu(); + createViewContextMenu(); +} + + +void FbFileView::createFileContextMenu() +{ + mContextMenuActions.mFileMenu = mContextMenu->addMenu("File"); + + //mContextMenuActions.mFileBackMoveUp = mContextMenuActions.mFileMenu->addAction("Back/Move up (<-)", this, SLOT(fileBackMoveUp())); + mContextMenuActions.mFileOpenDirectory = mContextMenuActions.mFileMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory())); +// mContextMenuActions.mFileSearch = mContextMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); + //mContextMenuActions.mFileSearch->setVisible(false); + + mContextMenuActions.mFileDelete = mContextMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete())); + mContextMenuActions.mFileRename = mContextMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename())); + mContextMenuActions.mFileTouch = mContextMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch())); + mContextMenuActions.mFileProperties = mContextMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties())); + + mContextMenuActions.mFileChecksumsMenu = mContextMenuActions.mFileMenu->addMenu("Checksums"); + mContextMenuActions.mFileChecksumsMD5 = mContextMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5())); + mContextMenuActions.mFileChecksumsMD2 = mContextMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2())); + mContextMenuActions.mFileChecksumsSHA1 = mContextMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1())); + +// mContextMenuActions.mFileSetAttributes = mContextMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); +// mContextMenuActions.mFileSetAttributes->setVisible(false); +} + +void FbFileView::createEditContextMenu() +{ + mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit"); + + //mContextMenuActions.mEditSnapShotToE = mContextMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); +// mContextMenuActions.mEditSnapShotToE->setVisible(false); + mContextMenuActions.mEditCut = mContextMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); + mContextMenuActions.mEditCopy = mContextMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); + mContextMenuActions.mEditPaste = mContextMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); + + mContextMenuActions.mEditCopyToFolder = mContextMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); + mContextMenuActions.mEditMoveToFolder = mContextMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); +} + +void FbFileView::createViewContextMenu() +{ + +} + +void FbFileView::updateContextMenu() +{ + bool isFileItemListEmpty = mFbFileModel->rowCount() == 0; + bool isDriveListViewActive = mEngineWrapper->isDriveListViewActive(); +// bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); + bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); + bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); + bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0; + bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); + bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse(); + + // File submenu + //mContextMenuActions.mFileBackMoveUp->setVisible( !isDriveListViewActive); + mContextMenuActions.mFileOpenDirectory->setVisible( !isFileItemListEmpty && !isDriveListViewActive && isCurrentItemDirectory); + + mContextMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isDriveListViewActive && !isCurrentDriveReadOnly); + mContextMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isDriveListViewActive && !isCurrentDriveReadOnly); + mContextMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isDriveListViewActive && !isCurrentDriveReadOnly); + mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty && !isSelectionMode); + + mContextMenuActions.mFileChecksumsMenu->menuAction()->setVisible(!(isFileItemListEmpty || isSelectionMode /*|| !hasSelectedItems*/ || isCurrentItemDirectory || isDriveListViewActive)); + // Edit submenu + mContextMenuActions.mEditMenu->menuAction()->setVisible(!isDriveListViewActive); + mContextMenuActions.mEditCut->setVisible(!(isDriveListViewActive || isCurrentDriveReadOnly || isFileItemListEmpty)); + mContextMenuActions.mEditCopy->setVisible(!(isDriveListViewActive || isFileItemListEmpty)); + mContextMenuActions.mEditPaste->setVisible(!isDriveListViewActive && !isClipBoardEmpty && !isCurrentDriveReadOnly); + mContextMenuActions.mEditCopyToFolder->setVisible(!(isDriveListViewActive || isFileItemListEmpty)); + mContextMenuActions.mEditMoveToFolder->setVisible(!(isDriveListViewActive || isCurrentDriveReadOnly || isFileItemListEmpty)); +} + +// --------------------------------------------------------------------------- + +void FbFileView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords) +{ + QModelIndex proxyIndex = listViewItem->modelIndex(); + //map to source model + mCurrentIndex = mSortFilterProxyModel->mapToSource(proxyIndex); + + mContextMenu->setPreferredPos(coords); + mContextMenu->show(); +} + +/** + Create a file browser tool bar + */ +void FbFileView::createToolBar() +{ + mToolBar = toolBar(); + + mToolbarBackAction = new HbAction(mToolBar); + mToolbarBackAction->setToolTip("Back"); + mToolbarBackAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_folder_parent.svg"))); + connect(mToolbarBackAction, SIGNAL(triggered()), this, SLOT(fileBackMoveUp())); + mToolBar->addAction(mToolbarBackAction); + + // Find button and its extension + HbToolBarExtension* filterExtension = new HbToolBarExtension(); + // Set search panel widget + mSearchPanel = new HbSearchPanel(filterExtension); + mSearchPanel->setMinimumWidth( 360 ); // TODO should be based on layout, screen width + connect(mSearchPanel, SIGNAL(criteriaChanged(const QString &)), this, SLOT(filterCriteriaChanged(const QString &))); + connect(mSearchPanel, SIGNAL(exitClicked()), filterExtension, SLOT(close())); + connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(clearFilterCriteria())); + filterExtension->setContentWidget(mSearchPanel); + + HbAction* mToolbarFilterAction = mToolBar->addExtension(filterExtension); +// mToolbarFilterAction->setText("Filter"); + mToolbarFilterAction->setToolTip("Filter"); + mToolbarFilterAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_find.svg"))); + //connect(mToolbarFilterAction, SIGNAL(triggered()), this, SLOT(viewFilterEntries())); + + if (mOptionMenuActions.mSelection) { + //mOptionMenuActions.mSelection->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_selection_active.svg"))); + mToolBar->addAction(mOptionMenuActions.mSelection); + } + +// // TODO Paste to be added +// if (mOptionMenuActions.mEditPaste) { +// //mOptionMenuActions.mEditPaste->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_selection_active.svg"))); +// mToolBar->addAction(mOptionMenuActions.mEditPaste); +// } +} + +/** + Refresh FileBrowser view + */ +void FbFileView::refreshList() +{ + editUnselectAll(); + mEngineWrapper->refreshView(); + mSearchPanel->setCriteria(QString("")); + mListView->model()->revert(); + mListView->reset(); + + if (mListView->model() && mListView->model()->rowCount() > 0) { + QModelIndex firstIndex = mListView->model()->index(0, 0); + mListView->scrollTo(firstIndex); + } + + TListingMode listingMode = mEngineWrapper->listingMode(); + if (listingMode == ENormalEntries) + mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); + else if (listingMode == ESearchResults) + mNaviPane->setPlainText(QString(tr("Search results"))); + else if (listingMode == EOpenFiles) + mNaviPane->setPlainText(QString(tr("Open files"))); + else if (listingMode == EMsgAttachmentsInbox) + mNaviPane->setPlainText(QString(tr("Attachments in Inbox"))); + else if (listingMode == EMsgAttachmentsDrafts) + mNaviPane->setPlainText(QString(tr("Attachments in Drafts"))); + else if (listingMode == EMsgAttachmentsSentItems) + mNaviPane->setPlainText(QString(tr("Attachments in Sent Items"))); + else if (listingMode == EMsgAttachmentsOutbox) + mNaviPane->setPlainText(QString(tr("Attachments in Outbox"))); +} + +// --------------------------------------------------------------------------- + +void FbFileView::fileOpen(HbAction *action) +{ +// Q_UNUSED(action); + HbSelectionDialog *dlg = static_cast(sender()); + if(!action && dlg && dlg->selectedItems().count()){ + int selectionIndex = dlg->selectedItems().at(0).toInt(); + + if (selectionIndex == 0) { + // open editor view + emit aboutToShowEditorView(mAbsoluteFilePath, true); + } else if (selectionIndex == 1) { + // AppArc + mEngineWrapper->openAppArc(mAbsoluteFilePath); + } else { + // DocHandler + mEngineWrapper->openDocHandler(mAbsoluteFilePath, true); + } + } +} + +/** + Open overwrite dialog + */ +void FbFileView::fileOverwriteDialog() +{ + mOverwriteOptions = OverwriteOptions(); + // open user-dialog to select: view as text/hex, open w/AppArc or open w/DocH. embed + QStringList list; + list << QString("Overwrite all") + << QString("Skip all existing") + << QString("Gen. unique filenames") + << QString("Query postfix"); + openListDialog(list, QString("Overwrite?"), this, SLOT(fileOverwrite(HbAction *))); +} + +/** + File overwrite + */ +void FbFileView::fileOverwrite(HbAction *action) +{ + HbSelectionDialog *dlg = static_cast(sender()); + if(!action && dlg && dlg->selectedItems().count()) { + mOverwriteOptions.queryIndex = dlg->selectedItems().at(0).toInt(); + if (mOverwriteOptions.queryIndex == EFileActionQueryPostFix) { + QString heading = QString("Postfix"); + HbInputDialog::getText(heading, this, SLOT(fileOverwritePostfix(HbAction *)), QString(), scene()); + } else if (mOverwriteOptions.queryIndex == EFileActionSkipAllExisting) { + mOverwriteOptions.overWriteFlags = 0; + } + } else { + mOverwriteOptions.doFileOperations = false; + } +} + +/** + File overwrite postfix query dialog + */ +void FbFileView::fileOverwritePostfix(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + mOverwriteOptions.postFix = dlg->value().toString(); + } else { + mOverwriteOptions.doFileOperations = false; + } +} + +// --------------------------------------------------------------------------- +/** + Show a list dialog + \param List aList of item to select item from. + \param Title text titleText of a dialog heading widget + \return None + */ +void FbFileView::openListDialog(const QStringList& items, const QString &titleText, QObject* receiver, const char* member) +{ + // Create a list and some simple content for it + HbSelectionDialog *dlg = new HbSelectionDialog(); + dlg->setAttribute(Qt::WA_DeleteOnClose); + // Set items to be popup's content + dlg->setStringItems(items); + dlg->setSelectionMode(HbAbstractItemView::SingleSelection); + + HbLabel *title = new HbLabel(dlg); + title->setPlainText(titleText); + dlg->setHeadingWidget(title); + + // Launch popup and handle the user response: + dlg->open(receiver, member); +} + +// --------------------------------------------------------------------------- + +void FbFileView::openPropertyDialog(const QStringList& propertyList, const QString& title) +{ + HbDialog *dialog = new HbDialog(); + dialog->setDismissPolicy(HbPopup::TapOutside); + dialog->setTimeout(HbPopup::NoTimeout); + + HbLabel *titleWidget = new HbLabel(); + titleWidget->setPlainText(title); + dialog->setHeadingWidget(titleWidget); + + // Create a list and some simple content for it + HbListWidget *list = new HbListWidget(); + QString str; + foreach (str, propertyList) { + list->addItem(str); + } + + // Connect list item activation signal to close the popup + connect(list, SIGNAL(activated(HbListWidgetItem*)), dialog, SLOT(close())); + + HbAction *cancelAction = new HbAction("Close"); + dialog->setPrimaryAction(cancelAction); + + // Set listwidget to be popup's content + dialog->setContentWidget(list); + // Launch popup and handle the user response: + dialog->open(); +} + +/** + Stores selection or current index mapped to source model + */ +void FbFileView::storeSelectedItemsOrCurrentItem() +{ + QItemSelectionModel *selectionIndexes = mListView->selectionModel(); + + // by default use selected items + if (selectionIndexes) { + if (selectionIndexes->hasSelection()) { + QItemSelection proxyItemSelection = mListView->selectionModel()->selection(); + QItemSelection itemSelection = mSortFilterProxyModel->mapSelectionToSource(proxyItemSelection); + mSelectionIndexes = itemSelection.indexes(); + } else { // or if none selected, use the current item index + mSelectionIndexes.clear(); + QModelIndex currentIndex = currentItemIndex(); //alreade mapped to source model + mSelectionIndexes.append(currentIndex); + } + } +} + +// --------------------------------------------------------------------------- + +QModelIndex FbFileView::currentItemIndex() +{ + return mCurrentIndex; +} + +// --------------------------------------------------------------------------- +// operations in File Menu +// --------------------------------------------------------------------------- + +/** + Move back/up in folder browsing history + */ +void FbFileView::fileBackMoveUp() +{ + mLocationChanged = true; + mEngineWrapper->moveUpOneLevel(); + //mListView->setRootIndex(currentItemIndex()); + refreshList(); + if (mEngineWrapper->isDriveListViewActive()) { + emit aboutToShowDriveView(); + } +} + +void FbFileView::fileOpenDirectory() +{ + mLocationChanged = true; + // get selected drive or directory from list view model and open it: + //if (mListView->selectionModel()->hasSelection()) { +// if (mListView->selectionModel()->selection().count() != 0) { +// QModelIndex currentIndex = currentItemIndex(); + mEngineWrapper->moveDownToDirectory(currentItemIndex()); +// mListView->setRootIndex(currentItemIndex()); + refreshList(); +// } else { +// Notifications::showErrorNote("not selected item!"); +// } +} + +void FbFileView::fileSearch() +{ + QString searchPath; +// if (mEngineWrapper->currentPath() != mInitDirPath.path()) { +// searchPath = mDirectory; +// searchPath.replace("/", "\\"); +// searchPath+="\\"; +// } + searchPath = mEngineWrapper->currentPath(); +// mSearch->open(searchPath); + emit aboutToShowSearchView(searchPath); +} + +/** + Open new file dialog + */ +void FbFileView::fileNewFile() +{ + QString heading = QString("Enter filename"); + HbInputDialog::getText(heading, this, SLOT(doFileNewFile(HbAction*)), QString(), scene()); +} + +/** + Create a new file in current directory with a name queried from user + */ +void FbFileView::doFileNewFile(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString newFileName = dlg->value().toString(); + mEngineWrapper->createNewFile(newFileName); + refreshList(); + } +} + +/** + Open new directory dialog + */ +void FbFileView::fileNewDirectory() +{ + QString heading = QString("Enter directory name"); + HbInputDialog::getText(heading, this, SLOT(doFileNewDirectory(HbAction*)), QString(), scene()); +} + +/** + Create a new directory in current directory with a name queried from user + */ +void FbFileView::doFileNewDirectory(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString newDirectoryName = dlg->value().toString(); + mEngineWrapper->createNewDirectory(newDirectoryName); + refreshList(); + } +} + +/** + Question for Delete actually selected files + */ +void FbFileView::fileDelete() +{ + storeSelectedItemsOrCurrentItem(); + const QString messageFormat = "Delete %1 entries?"; + QString message = messageFormat.arg(mSelectionIndexes.count()); + HbMessageBox::question(message, this, SLOT(doFileDelete(HbAction*))); +} + +/** + Delete actually selected files + */ +void FbFileView::doFileDelete(HbAction* action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + //storeSelectedItemsOrCurrentItem(); + mEngineWrapper->deleteItems(mSelectionIndexes); + refreshList(); + } +} + +/** + Open rename dialog for actually selected files + */ +void FbFileView::fileRename() +{ + storeSelectedItemsOrCurrentItem(); + mEngineWrapper->setCurrentSelection(mSelectionIndexes); + + for (int i(0), ie(mSelectionIndexes.count()); i < ie; ++i ) { + mProceed = (i == ie-1); // if the last item + mModelIndex = mSelectionIndexes.at(i); + FileEntry entry = mEngineWrapper->getFileEntry(mModelIndex); + + QString heading = QString("Enter new name"); + HbInputDialog::getText(heading, this, SLOT(doFileRename(HbAction*)), entry.name(), scene()); + } +} + +/** + Rename actually selected files + */ +void FbFileView::doFileRename(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + mNewFileName = dlg->value().toString(); + + if (mEngineWrapper->targetExists(mModelIndex, mNewFileName)) { + const QString messageTemplate = QString("%1 already exists, overwrite?"); + QString message = messageTemplate.arg(mNewFileName); + HbMessageBox::question(message, this, SLOT(doFileRenameFileExist(HbAction *))); + } else { + mEngineWrapper->rename(mModelIndex, mNewFileName); + if (mProceed) { + mEngineWrapper->startExecutingCommands(QString("Renaming")); + refreshList(); + } + } + } +} + +/** + Rename actually selected files + */ +void FbFileView::doFileRenameFileExist(HbAction *action) +{ + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + mEngineWrapper->rename(mModelIndex, mNewFileName); + if (mProceed) { + mEngineWrapper->startExecutingCommands(QString("Renaming")); + refreshList(); + } + } +} + +/** + Touch actually selected files + */ +void FbFileView::fileTouch() +{ + storeSelectedItemsOrCurrentItem(); + mEngineWrapper->setCurrentSelection(mSelectionIndexes); + + if (mEngineWrapper->selectionHasDirs()) { + const QString message = "Recurse touch for all selected dirs?"; + HbMessageBox::question(message, this, SLOT(doFileTouch(HbAction*))); + } + else{ + mEngineWrapper->touch(false); + refreshList(); + } +} + +/** + Touch actually selected files + */ +void FbFileView::doFileTouch(HbAction* action) +{ + bool recurse = false; + if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { + recurse = true; + } + mEngineWrapper->touch(recurse); + refreshList(); +} + +void FbFileView::fileChecksumsMD5() +{ + fileChecksums(EFileChecksumsMD5); +} + +void FbFileView::fileChecksumsMD2() +{ + fileChecksums(EFileChecksumsMD2); +} + +void FbFileView::fileChecksumsSHA1() +{ + fileChecksums(EFileChecksumsSHA1); +} + +void FbFileView::fileChecksums(TFileBrowserCmdFileChecksums checksumType) +{ + mEngineWrapper->showFileCheckSums(currentItemIndex(), checksumType); +} + +/** + Show file properties + */ +void FbFileView::fileProperties() +{ + QModelIndex currentIndex = currentItemIndex(); + QStringList propertyList; + QString titleText; + mEngineWrapper->properties(currentIndex, propertyList, titleText); + openPropertyDialog(propertyList, titleText); +} + +void FbFileView::fileSetAttributes() +{ + +} + +// edit menu +void FbFileView::editSnapShotToE() +{ + +} + +/** + Set selected files into clipboard. + Selected item will be removed after paste operation. + */ +void FbFileView::editCut() +{ + storeSelectedItemsOrCurrentItem(); + + // Store indices to clipboard + mClipboardIndexes.clear(); + for (int i = 0; i < mSelectionIndexes.size(); ++i) { + mClipboardIndexes.append(mSelectionIndexes.at(i)); + } + + mEngineWrapper->clipboardCut(mClipboardIndexes); + + int operations = mClipboardIndexes.count(); + const QString message = QString ("%1 entries cut to clipboard"); + QString noteMsg = message.arg(operations); + + Notifications::showInformationNote(noteMsg); +} + +/** + Set selected files into clipboard. + Selected item will not be removed after paste operation. + */ +void FbFileView::editCopy() +{ + storeSelectedItemsOrCurrentItem(); + + // Store indices to clipboard + mClipboardIndexes.clear(); + for (int i = 0; i < mSelectionIndexes.size(); ++i) { + mClipboardIndexes.append(mSelectionIndexes.at(i)); + } + + mEngineWrapper->clipboardCopy(mClipboardIndexes); + + int operations = mClipboardIndexes.count(); + + const QString message = QString ("%1 entries copied to clipboard"); + QString noteMsg = message.arg(operations); + + Notifications::showInformationNote(noteMsg); +} + +/** + Moves or copies file selection stored in clipboard to a actual directory. + Removing files depend on previous operation, i.e. Cut or Copy + */ +void FbFileView::editPaste() +{ + bool someEntryExists(false); + + // TODO Set entry items here + + someEntryExists = mEngineWrapper->isDestinationEntriesExists(mClipboardIndexes, mEngineWrapper->currentPath()); + if (someEntryExists) { + fileOverwriteDialog(); + } + + mEngineWrapper->clipboardPaste(mOverwriteOptions); +} + +/** + Open copy to folder new filename dialog + */ +void FbFileView::editCopyToFolder() +{ + QString heading = QString("Enter new name"); + HbInputDialog::getText(heading, this, SLOT(doEditCopyToFolder(HbAction*)), mEngineWrapper->currentPath(), scene()); +} + +/** + Copies current file selection to a queried directory. + */ +void FbFileView::doEditCopyToFolder(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString targetDir = dlg->value().toString(); + bool someEntryExists(false); + + // TODO Set entry items here + storeSelectedItemsOrCurrentItem(); + mEngineWrapper->setCurrentSelection(mSelectionIndexes); + + someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir); + if (someEntryExists) { + fileOverwriteDialog(); + } + mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, false); + refreshList(); + } +} + +/** + Open move to folder new filename dialog. + */ +void FbFileView::editMoveToFolder() +{ + QString heading = QString("Enter new name"); + HbInputDialog::getText(heading, this, SLOT(doEditMoveToFolder(HbAction*)), mEngineWrapper->currentPath(), scene()); +} + +/** + Moves current file selection to a queried directory. + */ +void FbFileView::doEditMoveToFolder(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString targetDir = dlg->value().toString(); + bool someEntryExists(false); + + // TODO Set entry items here + storeSelectedItemsOrCurrentItem(); + mEngineWrapper->setCurrentSelection(mSelectionIndexes); + + someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir); + if (someEntryExists) { + fileOverwriteDialog(); + } + mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, true); + refreshList(); + } +} + +/** + Select current file + */ +void FbFileView::editSelect() +{ + QItemSelectionModel *selectionModel = mListView->selectionModel(); + if (selectionModel) { + selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::SelectCurrent); + selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Select); +// itemHighlighted(selectionModel->currentIndex()); + refreshList(); + } +} + +/** + Unselect current file + */ +void FbFileView::editUnselect() +{ + QItemSelectionModel *selectionModel = mListView->selectionModel(); + if (selectionModel) { + selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Deselect); +// itemHighlighted(selectionModel->currentIndex()); + } +} + +/** + Select all files + */ +void FbFileView::editSelectAll() +{ + QItemSelectionModel *selectionModel = mListView->selectionModel(); + if (selectionModel) { + + //if (mFileBrowserModel->rowCount() > 0) { + if (mListView->model() && mListView->model()->rowCount() > 0) { + QModelIndex firstIndex = mListView->model()->index(0, 0); + QModelIndex lastIndex = mListView->model()->index( (mListView->model()->rowCount() - 1), 0); + + QItemSelection itemSelection(firstIndex, lastIndex); + selectionModel->select(itemSelection, QItemSelectionModel::SelectCurrent); + } + } +} + +/** + Unselect all files + */ +void FbFileView::editUnselectAll() +{ + QItemSelectionModel *selectionModel = mListView->selectionModel(); + if (selectionModel) { + selectionModel->clearSelection(); + } +} + +// --------------------------------------------------------------------------- +// view menu +// --------------------------------------------------------------------------- +void FbFileView::viewFilterEntries() +{ + if (mToolBar && mToolBar->actions().count() > 1 && mToolBar->actions().at(1)) { + HbAction* tbeFilterAction = qobject_cast(mToolBar->actions().at(1)); + if (tbeFilterAction && tbeFilterAction->toolBarExtension()) { + HbToolBarExtension *tbeFilter = tbeFilterAction->toolBarExtension(); + tbeFilter->open(); + } + } +} + +/** + Set filter criteria to proxy model + */ +void FbFileView::filterCriteriaChanged(const QString &criteria) +{ + mSortFilterProxyModel->setFilterCriteria(criteria); +} + +/** + Set filter criteria to proxy model + */ +void FbFileView::clearFilterCriteria() +{ + mSearchPanel->setCriteria(QString("")); +} + +/** + Refresh view + */ +void FbFileView::viewRefresh() +{ + refreshList(); +} + +// --------------------------------------------------------------------------- +// tools menu +// --------------------------------------------------------------------------- +void FbFileView::toolsAllAppsToTextFile() +{ + +} + +/** + Write all files to text file + */ +void FbFileView::toolsAllFilesToTextFile() +{ + mEngineWrapper->toolsWriteAllFiles(); +} + +//void FbFileView::toolsAvkonIconCacheEnable() +//{ +// +//} +//void FbFileView::toolsAvkonIconCacheDisable() +//{ +// +//} + +/** + Disable extended errors + */ +void FbFileView::toolsDisableExtendedErrors() +{ + mEngineWrapper->ToolsSetErrRd(false); +} + +void FbFileView::toolsDumpMsgStoreWalk() +{ + +} +void FbFileView::toolsEditDataTypes() +{ + +} + +/** + Enable extended errors + */ +void FbFileView::toolsEnableExtendedErrors() +{ + mEngineWrapper->ToolsSetErrRd(true); +} + +/** + Open simulate leave dialog + */ +void FbFileView::toolsErrorSimulateLeave() +{ + int leaveCode = -6; + QString heading = QString("Leave code"); + //HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), leaveCode, scene()); + HbInputDialog::getText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene()); +} + + +/** + Simulate leave. + */ +void FbFileView::doToolsErrorSimulateLeave(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + bool ok; + int leaveCode = dlg->value().toString().toInt(&ok); + if (leaveCode != 0 || ok) { + mEngineWrapper->ToolsErrorSimulateLeave(leaveCode); + } + } +} + +/** + Open simulate panic dialog. + */ +void FbFileView::toolsErrorSimulatePanic() +{ + mPanicCategory = QString ("Test Category"); + QString heading = QString("Panic category"); + HbInputDialog::getText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene()); +} + +/** + Simulate panic. + */ +void FbFileView::doToolsErrorSimulatePanicCode(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + mPanicCategory = dlg->value().toString(); + int panicCode(555); + QString heading = QString("Panic code"); + HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene()); + } +} + +/** + Simulate panic. + */ +void FbFileView::doToolsErrorSimulatePanic(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + bool ok; + int panicCode = dlg->value().toInt(&ok); + if (panicCode != 0 || ok) { + mEngineWrapper->ToolsErrorSimulatePanic(mPanicCategory, panicCode); + } + } +} + +/** + Open simulate exception dialog. + */ +void FbFileView::toolsErrorSimulateException() +{ + int exceptionCode = 0; + QString heading = QString("Exception code"); + HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene()); +} + +/** + Simulate exception. + */ +void FbFileView::doToolsErrorSimulateException(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + bool ok; + int exceptionCode = dlg->value().toInt(&ok); + if (exceptionCode != 0 || ok) { + mEngineWrapper->ToolsErrorSimulateException(exceptionCode); + } + } +} + +// void FbFileView::toolsLocalConnectivityActivateInfrared() +//{ +// +//} +// void FbFileView::toolsLocalConnectivityLaunchBTUI() +//{ +// +//} +// void FbFileView::toolsLocalConnectivityLaunchUSBUI() +//{ +// +//} +void FbFileView::toolsMessageInbox() +{ + +} +void FbFileView::toolsMessageDrafts() +{ + +} +void FbFileView::toolsMessageSentItems() +{ + +} +void FbFileView::toolsMessageOutbox() +{ + +} +void FbFileView::toolsMemoryInfo() +{ + +} +void FbFileView::toolsSecureBackStart() +{ + +} +void FbFileView::toolsSecureBackRestore() +{ + +} +void FbFileView::toolsSecureBackStop() +{ + +} + +/** + Open debug mask dialog + */ +void FbFileView::toolsSetDebugMaskQuestion() +{ + quint32 dbgMask = mEngineWrapper->getDebugMask(); + QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16)); + QString heading = QString("Kernel debug mask in hex format"); + HbInputDialog::getText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene()); +} + +/** + Set debug mask + */ +void FbFileView::toolsSetDebugMask(HbAction *action) +{ + HbInputDialog *dlg = static_cast(sender()); + if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { + QString dbgMaskText = dlg->value().toString(); + if (dbgMaskText.length() > 2 && dbgMaskText[0]=='0' && dbgMaskText[1]=='x') { + bool ok; + quint32 dbgMask = dbgMaskText.toUInt(&ok, 16); + if (dbgMask != 0 || ok) { + mEngineWrapper->toolsSetDebugMask(dbgMask); + Notifications::showConfirmationNote(QString("Changed")); + } else { + Notifications::showErrorNote(QString("Cannot convert value")); + } + } else { + Notifications::showErrorNote(QString("Not in hex format")); + } + } +} + +void FbFileView::toolsShowOpenFilesHere() +{ + +} + +// --------------------------------------------------------------------------- +// main menu items +// --------------------------------------------------------------------------- +void FbFileView::selectionModeChanged() +{ + if (mOptionMenuActions.mSelection->isChecked()) { + activateSelectionMode(); + } else { + deActivateSelectionMode(); + } +} + +/** + Show about note + */ +void FbFileView::about() +{ + Notifications::showAboutNote(); +} + +// --------------------------------------------------------------------------- +// End of operations +// --------------------------------------------------------------------------- + +// --------------------------------------------------------------------------- + +/** + Item is selected from list when selection mode is activated from menu + */ +void FbFileView::selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/) +{ + //QItemSelectionModel *selectionModel = mListView->selectionModel(); + //itemHighlighted(selectionModel->currentIndex()); +} + +/** + An item is clicked from navigation item list. Navigation item list contains + drive-, folder- or file items. Opens selected drive, folder or file popup menu + */ +void FbFileView::activated(const QModelIndex& index) +{ + if (mFbFileModel) { + //map to source model + QModelIndex activatedIndex = mSortFilterProxyModel->mapToSource(index); + + if (mEngineWrapper->getFileEntry(activatedIndex).isDir()) { + // populate new content of changed navigation view. + // mLocationChanged = true; + // mDirectory = filePath; + mEngineWrapper->moveDownToDirectory(activatedIndex); + refreshList(); + } else { // file item + // mSelectedFilePath = filePath; + FileEntry fileEntry = mEngineWrapper->getFileEntry(activatedIndex); + mAbsoluteFilePath = fileEntry.path() + fileEntry.name(); + + // open user-dialog to select: view as text/hex, open w/AppArc or open w/DocH. embed + QStringList list; + list << QString("View as text/hex") << QString("Open w/ AppArc") << QString("Open w/ DocH. embed"); + openListDialog(list, QString("Open file"), this, SLOT(fileOpen(HbAction *))); + } + } +} + +// --------------------------------------------------------------------------- + +void FbFileView::activateSelectionMode() +{ + QString path; + disconnect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); + mListView->setSelectionMode(HbListView::MultiSelection); + +// QModelIndex index = mFileSystemModel->index(path,0); +// mListView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent); +// mListView->selectionModel()->select(index, QItemSelectionModel::Select); +// //mListView->setHighlightMode(HbItemHighlight::HighlightAlwaysVisible); +// mListView->setFocus(); // TODO use focus in + if (mListView->selectionModel()) { + connect(mListView->selectionModel(), + SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, + SLOT(selectionChanged(QItemSelection, QItemSelection))); +// // flag to indicate that selection mode changed, "edit" sub-menu update needed +// mFolderContentChanged = true; + } +} + +// --------------------------------------------------------------------------- + +void FbFileView::deActivateSelectionMode() +{ + disconnect(mListView->selectionModel(), + SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, + SLOT(selectionChanged(QItemSelection, QItemSelection))); + mListView->setSelectionMode(HbListView::NoSelection); + connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); + editUnselectAll(); + // flag to indicate that selection mode changed, "edit" sub-menu update needed + mFolderContentChanged = true; +} + +// --------------------------------------------------------------------------- diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/fbmainwindow.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/src/fbmainwindow.cpp Tue Jul 06 14:17:03 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: +* +*/ +#include +#include + +#include "fbmainwindow.h" +#include "enginewrapper.h" +#include "fbfileview.h" +#include "fbdriveview.h" +#include "settingsview.h" +#include "editorview.h" +#include "searchview.h" + +FbMainWindow::FbMainWindow(QWidget *parent) + : HbMainWindow(parent), + mEngineWrapper(0), + mDriveView(0), + mFileView(0), + mSettingsView(0), + mEditorView(0), + mSearchView(0), + mPreviousView(0) +{ +} + +FbMainWindow::~FbMainWindow () +{ + if (mEngineWrapper) { + delete mEngineWrapper; + } +} + +void FbMainWindow::init() +{ + // Create Engine Wrapper and initialize it + mEngineWrapper = new EngineWrapper(); + int error = mEngineWrapper->init(); + Q_ASSERT_X(error == 1, "FileBrowser", "Engine initialization failed"); + + // Create drive view + mDriveView = new FbDriveView(); + connect(mDriveView, SIGNAL(aboutToShowSettingsView()), this, SLOT(openSettingsView())); + connect(mDriveView, SIGNAL(aboutToShowFileView()), this, SLOT(openFileView())); + mDriveView->init(mEngineWrapper); + addView(mDriveView); + + // Create file view + mFileView = new FbFileView(); + connect(mFileView, SIGNAL(aboutToShowSettingsView()), this, SLOT(openSettingsView())); + connect(mFileView, SIGNAL(aboutToShowDriveView()), this, SLOT(openDriveView())); + mFileView->init(mEngineWrapper); + addView(mFileView); + + // Create settings view + mSettingsView = new SettingsView(*mEngineWrapper); + connect(mSettingsView, SIGNAL(finished(bool)), this, SLOT(openPreviousBrowserView())); + addView(mSettingsView); + + // Create editor view + mEditorView = new EditorView(); + connect(mFileView, SIGNAL(aboutToShowEditorView(const QString &, bool)), this, SLOT(openEditorView(const QString &, bool))); + connect(mEditorView, SIGNAL(finished(bool)), this, SLOT(openFileView())); + addView(mEditorView); + + // Create Search view + mSearchView = new SearchView(*mEngineWrapper); + connect(mDriveView, SIGNAL(aboutToShowSearchView(QString)), this, SLOT(openSearchView(QString))); + connect(mFileView, SIGNAL(aboutToShowSearchView(QString)), this, SLOT(openSearchView(QString))); + connect(mSearchView, SIGNAL(finished(bool)), this, SLOT(openFileBrowserView(bool))); + addView(mSearchView); + + // Show ApplicationView at startup + setCurrentView(mDriveView); + mPreviousView = mDriveView; + + // Show HbMainWindow + show(); +} + + +void FbMainWindow::openPreviousBrowserView() +{ + mDriveView->refreshList(); + mFileView->refreshList(); + setCurrentView(mPreviousView); +} + +void FbMainWindow::openFileBrowserView(bool accepted) +{ + mDriveView->refreshList(); + mFileView->refreshList(); + if (accepted) { + setCurrentView(mFileView); + } else { + setCurrentView(mPreviousView); + } +} + +void FbMainWindow::openDriveView() +{ + mDriveView->refreshList(); + setCurrentView(mDriveView); + mPreviousView = mDriveView; +} + +void FbMainWindow::openFileView() +{ + mDriveView->refreshList(); +// mFileView->setCurrentpath(path); + mFileView->refreshList(); + setCurrentView(mFileView); + mPreviousView = mFileView; +} + +void FbMainWindow::openSettingsView() +{ + mSettingsView->initDataForm(); + setCurrentView(mSettingsView); +} + +void FbMainWindow::openEditorView(const QString &fileName, bool flagReadOnly) +{ + mEditorView->open(fileName, flagReadOnly); + setCurrentView(mEditorView); +} + +void FbMainWindow::openSearchView(const QString &path) +{ + mSearchView->open(path); + setCurrentView(mSearchView); +} diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/filebrowsermainwindow.cpp --- a/filebrowser/ui/src/filebrowsermainwindow.cpp Wed Jun 23 18:13:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +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 -#include - -#include "filebrowsermainwindow.h" -#include "enginewrapper.h" -#include "filebrowserview.h" -#include "settingsview.h" -#include "editorview.h" -#include "searchview.h" - -FileBrowserMainWindow::FileBrowserMainWindow(QWidget *parent) - : HbMainWindow(parent), - mEngineWrapper(0), - mFileBrowserView(0), - mSettingsView(0), - mEditorView(0), - mSearchView(0) -{ -} - -FileBrowserMainWindow::~FileBrowserMainWindow () -{ - if (mEngineWrapper) { - delete mEngineWrapper; - } -} - -void FileBrowserMainWindow::init() -{ - // Create Engine Wrapper and initialize it - mEngineWrapper = new EngineWrapper(); - int error = mEngineWrapper->init(); - Q_ASSERT_X(error == 1, "FileBrowser", "Engine initialization failed"); - - // Create file browser view - mFileBrowserView = new FileBrowserView(*this); - connect(mFileBrowserView, SIGNAL(aboutToShowSettingsView()), this, SLOT(openSettingsView())); - mFileBrowserView->init(mEngineWrapper); - addView(mFileBrowserView); - - // Create settings view - mSettingsView = new SettingsView(*this, *mEngineWrapper); - connect(mSettingsView, SIGNAL(finished(bool)), this, SLOT(openFileBrowserView())); - addView(mSettingsView); - - // Create settings view - mEditorView = new EditorView(*this); - connect(mFileBrowserView, SIGNAL(aboutToShowEditorView(const QString &, bool)), this, SLOT(openEditorView(const QString &, bool))); - connect(mEditorView, SIGNAL(finished(bool)), this, SLOT(openFileBrowserView())); - addView(mEditorView); - - // Create Search view - mSearchView = new SearchView(*mEngineWrapper); - connect(mFileBrowserView, SIGNAL(aboutToShowSearchView(QString)), this, SLOT(openSearchView(QString))); - connect(mSearchView, SIGNAL(finished(bool)), this, SLOT(openFileBrowserView())); - addView(mSearchView); - - // Show ApplicationView at startup - setCurrentView(mFileBrowserView); - - // Show HbMainWindow - show(); -} - -void FileBrowserMainWindow::openFileBrowserView() -{ - mFileBrowserView->refreshList(); - setCurrentView(mFileBrowserView); -} - -void FileBrowserMainWindow::openSettingsView() -{ - setCurrentView(mSettingsView); -} - -void FileBrowserMainWindow::openEditorView(const QString &fileName, bool flagReadOnly) -{ - mEditorView->open(fileName, flagReadOnly); - setCurrentView(mEditorView); -} - -void FileBrowserMainWindow::openSearchView(const QString &path) -{ - mSearchView->open(path); - setCurrentView(mSearchView); -} diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/filebrowsermodel.cpp --- a/filebrowser/ui/src/filebrowsermodel.cpp Wed Jun 23 18:13:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +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 "filebrowsermodel.h" -#include "enginewrapper.h" -#include "fileentry.h" -#include "driveentry.h" -#include "settingsview.h" -#include "filebrowsersettings.h" -#include "FB.hrh" - -#include -#include - -/** - Constructs a file browser custom system model with the given \a engineWrapper and \a parent. - */ -FileBrowserModel::FileBrowserModel(EngineWrapper *engineWrapper, QObject *parent) : - QAbstractListModel(parent), - mEngineWrapper(engineWrapper), - mFileIconProvider(0) -{ - mFileIconProvider = new QFileIconProvider(); -} - -/** - Destroys this file browser custom system model. - */ -FileBrowserModel::~FileBrowserModel() -{ - if (mFileIconProvider) { - delete mFileIconProvider; - } -} - -/** - \reimp - */ -int FileBrowserModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return mEngineWrapper->itemCount(); -} - -/** - \reimp - */ -QVariant FileBrowserModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || index.model() != this) - return QVariant(); - - switch (role) { - case Qt::EditRole: - case Qt::DisplayRole: { - QStringList listItem; - if (mEngineWrapper->isDriveListViewActive()) { - DriveEntry driveEntry(mEngineWrapper->getDriveEntry(index)); - if (mEngineWrapper->settings().fileViewMode() == EFileViewModeSimple) - { - const QString SimpleDriveEntry("%1: <%2>"); - listItem /*<< driveEntry.IconId() */ - << SimpleDriveEntry.arg(driveEntry.driveLetter()) - .arg(driveEntry.mediaTypeString()); - } else if (mEngineWrapper->settings().fileViewMode() == EFileViewModeExtended) { - const QString SimpleDriveEntry("%1: <%2>"); - const QString ExtendedDriveEntry("%1/%2 kB"); - listItem /*<< driveEntry.IconId()*/ - << SimpleDriveEntry.arg(driveEntry.driveLetter()) - .arg(driveEntry.mediaTypeString()) - << ExtendedDriveEntry.arg(QString::number(driveEntry.volumeInfoFree()/1024)) - .arg(QString::number(driveEntry.volumeInfoSize()/1024)); - - } - } else { - FileEntry fileEntry(mEngineWrapper->getFileEntry(index)); - if (mEngineWrapper->settings().fileViewMode() == EFileViewModeSimple) - { - listItem /*<< fileEntry.IconId()*/ - << fileEntry.name(); - } else if (mEngineWrapper->settings().fileViewMode() == EFileViewModeExtended) { - QString extraData; - extraData.append(fileEntry.modifiedString()); - if (fileEntry.isDir() && fileEntry.dirEntries() >= 0) { - extraData.append(" - "); - extraData.append(fileEntry.dirEntriesString()); - } else if (!fileEntry.isDir()) { - extraData.append(" - "); - extraData.append(fileEntry.sizeString()); - } - listItem /*<< fileEntry.IconId()*/ - << fileEntry.name() << extraData << fileEntry.attributesString(); - } - } - return listItem; - } - case Qt::DecorationRole: { - if (mEngineWrapper) { - QIcon icon; - if (mEngineWrapper->isDriveListViewActive()) { - icon = mFileIconProvider->icon(QFileIconProvider::Drive); - } else { - FileEntry fileEntry(mEngineWrapper->getFileEntry(index)); - if (fileEntry.isDir()) { - icon = mFileIconProvider->icon(QFileIconProvider::Folder); - } else { - icon = mFileIconProvider->icon(QFileIconProvider::File); - } - } - return QVariant(icon); - } - } - } - - return QVariant(); -} - -/** - \reimp - */ -QVariant FileBrowserModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - Q_UNUSED(section) - Q_UNUSED(orientation) - Q_UNUSED(role) - - // TODO, implement or remove - return QVariant(); -} - -// --------------------------------------------------------------------------- diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/filebrowsersortfilterproxymodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filebrowser/ui/src/filebrowsersortfilterproxymodel.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,62 @@ +/* +* 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 "filebrowsersortfilterproxymodel.h" + +#include +#include + +FileBrowserSortFilterProxyModel::FileBrowserSortFilterProxyModel(QObject *parent) + : QSortFilterProxyModel(parent) +{ +} + +bool FileBrowserSortFilterProxyModel::filterAcceptsRow(int sourceRow, + const QModelIndex &sourceParent) const +{ + QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); + + QVariant displayRole = index.data(Qt::DisplayRole); + QStringList stringList; + if (displayRole.isValid()) { + if (displayRole.canConvert()) { + stringList.append(displayRole.toString()); + } else if (displayRole.canConvert()) { + stringList = displayRole.toStringList(); + } + QString itemName = stringList.at(0); + //QString criteria = filterRegExp().pattern(); + QString criteria = filterCriteria(); + if (!criteria.isEmpty()) { + bool contains = itemName.contains(criteria, Qt::CaseInsensitive); + return contains; + } else { + //invalidateFilter(); + return true; + } + } + return true; +} + +void FileBrowserSortFilterProxyModel::setFilterCriteria(const QString &criteria) +{ + mFilterCriteria = criteria; + invalidate(); +} + + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/filebrowserview.cpp --- a/filebrowser/ui/src/filebrowserview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2034 +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 "filebrowserview.h" -#include "filebrowsermainwindow.h" -#include "settingsview.h" -#include "editorview.h" -#include "searchview.h" -#include "enginewrapper.h" -#include "notifications.h" - -#include "filebrowsermodel.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -//TODO check if needed to do this way -#include - -//const int DRIVEPATHLENGTH = 4; -const QString okActionText("OK"); -const QString cancelActionText("Cancel"); - -// --------------------------------------------------------------------------- - -FileBrowserView::FileBrowserView(FileBrowserMainWindow &mainWindow) - : mMainWindow(mainWindow), - mEngineWrapper(0), - mListView(0), - mToolBar(0), - mNaviPane(0), - mMainLayout(0), - mFileBrowserModel(0), - mOptionMenuActions(), - mContextMenuActions(), - mContextMenu(0), - mToolbarBackAction(0), - mItemHighlighted(false), - mLocationChanged(false), - mRemoveFileAfterCopied(false), -// mClipBoardInUse(false), - mFolderContentChanged(false), - mCurrentIndex(), - mOldPassword(), - mPanicCategory(), - mAbsoluteFilePath(), - mOverwriteOptions(), - mModelIndex(), - mNewFileName(), - mProceed(false), - mEraseMBR(false) -{ - setTitle("File Browser"); - - createMenu(); - createContextMenu(); - createToolBar(); -} - -// --------------------------------------------------------------------------- - -void FileBrowserView::init(EngineWrapper *engineWrapper) -{ - mEngineWrapper = engineWrapper; - - mListView = new HbListView(this); - mFileBrowserModel = new FileBrowserModel(mEngineWrapper); - if (!mListView->model()) { - mListView->setModel(mFileBrowserModel); - mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape); - mEngineWrapper->refreshView(); - mToolbarBackAction->setEnabled(!mEngineWrapper->isDriveListViewActive()); - } - - //mListView->setRootIndex(mFileSystemModel->index(startPath)); - //mListView->setRootIndex(model->index()); - - mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); - - connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); - connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), - this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF))); - - mNaviPane = new HbLabel(this); - mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default - //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); - HbFontSpec fontSpec(HbFontSpec::PrimarySmall); - mNaviPane->setFontSpec(fontSpec); - - // Create layout and add list view and toolbar into layout: - mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); - mMainLayout->addItem(mNaviPane); - mMainLayout->addItem(mListView); - //mMainLayout->addItem(mToolBar); - setLayout(mMainLayout); -} - -// --------------------------------------------------------------------------- - -FileBrowserView::~FileBrowserView() -{ -// if (mEngineWrapper) { -// delete mEngineWrapper; -// } - if (mContextMenu) { - mContextMenu->deleteLater(); - } - - delete mFileBrowserModel; - delete mListView; - delete mToolBar; -} - -/** - Initial setup for options menu. - Dynamic menu update during the runtime is performed by updateOptionMenu() which - to menu's aboutToShow() signal. - */ -void FileBrowserView::createMenu() -{ - createFileMenu(); - createEditMenu(); - createViewMenu(); - createToolsMenu(); - - createSelectionMenuItem(); - createSettingsMenuItem(); - createAboutMenuItem(); - createExitMenuItem(); - - // menu dynamic update - connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateOptionMenu())); -} - -/** - Initial setup for File submenu - */ -void FileBrowserView::createFileMenu() -{ - mOptionMenuActions.mFileMenu = menu()->addMenu("File"); - - mOptionMenuActions.mFileBackMoveUp = mOptionMenuActions.mFileMenu->addAction("Back/Move up (<-)", this, SLOT(fileBackMoveUp())); - mOptionMenuActions.mFileOpenDrive = mOptionMenuActions.mFileMenu->addAction("Open drive (->)", this, SLOT(fileOpenDrive())); - mOptionMenuActions.mFileOpenDirectory = mOptionMenuActions.mFileMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory())); - mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); - //mOptionMenuActions.mFileSearch->setVisible(false); - - mOptionMenuActions.mFileNewMenu = mOptionMenuActions.mFileMenu->addMenu("New"); - mOptionMenuActions.mFileNewFile = mOptionMenuActions.mFileNewMenu->addAction("File", this, SLOT(fileNewFile())); - mOptionMenuActions.mFileNewDirectory = mOptionMenuActions.mFileNewMenu->addAction("Directory", this, SLOT(fileNewDirectory())); - - mOptionMenuActions.mFileDelete = mOptionMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete())); - mOptionMenuActions.mFileRename = mOptionMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename())); - mOptionMenuActions.mFileTouch = mOptionMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch())); - mOptionMenuActions.mFileProperties = mOptionMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties())); - -// mOptionMenuActions.mFileChecksumsMenu = mOptionMenuActions.mFileMenu->addMenu("Checksums"); -// mOptionMenuActions.mFileChecksumsMD5 = mOptionMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5())); -// mOptionMenuActions.mFileChecksumsMD2 = mOptionMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2())); -// mOptionMenuActions.mFileChecksumsSHA1 = mOptionMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1())); - - mOptionMenuActions.mFileSetAttributes = mOptionMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); - mOptionMenuActions.mFileSetAttributes->setVisible(false); -} - -/** - Initial setup for Edit submenu - */ -void FileBrowserView::createEditMenu() -{ - mOptionMenuActions.mEditMenu = menu()->addMenu("Edit"); - - mOptionMenuActions.mEditSnapShotToE = mOptionMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); - mOptionMenuActions.mEditSnapShotToE->setVisible(false); - mOptionMenuActions.mEditCut = mOptionMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); - mOptionMenuActions.mEditCopy = mOptionMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); - mOptionMenuActions.mEditPaste = mOptionMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); - - mOptionMenuActions.mEditCopyToFolder = mOptionMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); - mOptionMenuActions.mEditMoveToFolder = mOptionMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); - - mOptionMenuActions.mEditSelect = mOptionMenuActions.mEditMenu->addAction("Select", this, SLOT(editSelect())); - mOptionMenuActions.mEditUnselect = mOptionMenuActions.mEditMenu->addAction("Unselect", this, SLOT(editUnselect())); - mOptionMenuActions.mEditSelectAll = mOptionMenuActions.mEditMenu->addAction("Select all", this, SLOT(editSelectAll())); - mOptionMenuActions.mEditUnselectAll = mOptionMenuActions.mEditMenu->addAction("Unselect all", this, SLOT(editUnselectAll())); -} - -/** - Initial setup for View submenu - */ -void FileBrowserView::createViewMenu() -{ - mOptionMenuActions.mViewMenu = menu()->addMenu("View"); - mOptionMenuActions.mViewMenu->menuAction()->setVisible(false); - - mOptionMenuActions.mViewFilterEntries = mOptionMenuActions.mViewMenu->addAction("Filter entries", this, SLOT(viewFilterEntries())); - mOptionMenuActions.mViewRefresh = mOptionMenuActions.mViewMenu->addAction("Refresh", this, SLOT(viewRefresh())); -} - -/** - Initial setup for Tools submenu - */ -void FileBrowserView::createToolsMenu() -{ - mOptionMenuActions.mToolsMenu = menu()->addMenu("Tools"); - - mOptionMenuActions.mToolsAllAppsToTextFile = mOptionMenuActions.mToolsMenu->addAction("All apps to a text file", this, SLOT(toolsAllAppsToTextFile())); - mOptionMenuActions.mToolsAllAppsToTextFile->setVisible(false); - mOptionMenuActions.mToolsAllFilesToTextFile = mOptionMenuActions.mToolsMenu->addAction("All files to a text file", this, SLOT(toolsAllFilesToTextFile())); - //mOptionMenuActions.mToolsAllFilesToTextFile->setVisible(false); - - mOptionMenuActions.mToolsAvkonIconCacheMenu = mOptionMenuActions.mToolsMenu->addMenu("Avkon icon cache"); - mOptionMenuActions.mToolsAvkonIconCacheMenu->menuAction()->setVisible(false); - mOptionMenuActions.mToolsAvkonIconCacheEnable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Enable", this, SLOT(toolsAvkonIconCacheEnable())); - mOptionMenuActions.mToolsAvkonIconCacheDisable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Clear and disable", this, SLOT(toolsAvkonIconCacheDisable())); - - mOptionMenuActions.mToolsDisableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Disable extended errors", this, SLOT(toolsDisableExtendedErrors())); - mOptionMenuActions.mToolsDumpMsgStoreWalk = mOptionMenuActions.mToolsMenu->addAction("Dump msg. store walk", this, SLOT(toolsDumpMsgStoreWalk())); - mOptionMenuActions.mToolsDumpMsgStoreWalk->setVisible(false); - mOptionMenuActions.mToolsEditDataTypes = mOptionMenuActions.mToolsMenu->addAction("Edit data types", this, SLOT(toolsEditDataTypes())); - mOptionMenuActions.mToolsEditDataTypes->setVisible(false); - mOptionMenuActions.mToolsEnableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Enable extended errors", this, SLOT(toolsEnableExtendedErrors())); - - mOptionMenuActions.mToolsErrorSimulateMenu = mOptionMenuActions.mToolsMenu->addMenu("Error simulate"); - mOptionMenuActions.mToolsErrorSimulateLeave = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Leave", this, SLOT(toolsErrorSimulateLeave())); - mOptionMenuActions.mToolsErrorSimulatePanic = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Panic", this, SLOT(toolsErrorSimulatePanic())); - mOptionMenuActions.mToolsErrorSimulatePanic->setVisible(false); - mOptionMenuActions.mToolsErrorSimulateException = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Exception", this, SLOT(toolsErrorSimulateException())); - -// mOptionMenuActions.mLocalConnectivityMenu = mOptionMenuActions.mToolsMenu->addMenu("Local connectivity"); -// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared = mOptionMenuActions.mLocalConnectivityMenu->addAction("Activate infrared", this, SLOT(toolsLocalConnectivityActivateInfrared())); -// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch BT UI", this, SLOT(toolsLocalConnectivityLaunchBTUI())); -// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch USB UI", this, SLOT(toolsLocalConnectivityLaunchUSBUI())); - - mOptionMenuActions.mToolsMessageAttachmentsMenu = mOptionMenuActions.mToolsMenu->addMenu("Message attachments"); - mOptionMenuActions.mToolsMessageAttachmentsMenu->menuAction()->setVisible(false); - mOptionMenuActions.mToolsMessageInbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Inbox", this, SLOT(toolsMessageInbox())); - mOptionMenuActions.mToolsMessageDrafts = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Drafts", this, SLOT(toolsMessageDrafts())); - mOptionMenuActions.mToolsMessageSentItems = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Sent items", this, SLOT(toolsMessageSentItems())); - mOptionMenuActions.mToolsMessageOutbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Outbox", this, SLOT(toolsMessageOutbox())); - - mOptionMenuActions.mToolsMemoryInfo = mOptionMenuActions.mToolsMenu->addAction("Memory info", this, SLOT(toolsMemoryInfo())); - mOptionMenuActions.mToolsMemoryInfo->setVisible(false); - - mOptionMenuActions.mToolsSecureBackupMenu = mOptionMenuActions.mToolsMenu->addMenu("Secure backup"); - mOptionMenuActions.mToolsSecureBackupMenu->menuAction()->setVisible(false); - mOptionMenuActions.mToolsSecureBackStart = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start backup", this, SLOT(toolsSecureBackStart())); - mOptionMenuActions.mToolsSecureBackRestore = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start restore", this, SLOT(toolsSecureBackRestore())); - mOptionMenuActions.mToolsSecureBackStop = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Stop", this, SLOT(toolsSecureBackStop())); - - mOptionMenuActions.mToolsSetDebugMask = mOptionMenuActions.mToolsMenu->addAction("Set debug mask", this, SLOT(toolsSetDebugMaskQuestion())); - mOptionMenuActions.mToolsShowOpenFilesHere = mOptionMenuActions.mToolsMenu->addAction("Show open files here", this, SLOT(toolsShowOpenFilesHere())); - mOptionMenuActions.mToolsShowOpenFilesHere->setVisible(false); -} - -/** - Creates Selection mode menu item in option menu - */ -void FileBrowserView::createSelectionMenuItem() -{ - if (!mOptionMenuActions.mSelection) { - mOptionMenuActions.mSelection = menu()->addAction("Selection mode"); - mOptionMenuActions.mSelection->setToolTip("Selection mode"); - mOptionMenuActions.mSelection->setCheckable(true); - connect(mOptionMenuActions.mSelection, SIGNAL(triggered()), this, SLOT(selectionModeChanged())); - } -} - -/** - Creates Setting menu item in option menu - */ -void FileBrowserView::createSettingsMenuItem() -{ - mOptionMenuActions.mSetting = menu()->addAction("Settings..."); - connect(mOptionMenuActions.mSetting, SIGNAL(triggered()), this, SIGNAL(aboutToShowSettingsView())); -} - - -/** - Creates About menu item in option menu - */ -void FileBrowserView::createAboutMenuItem() -{ - // about note - mOptionMenuActions.mAbout = menu()->addAction("About"); - connect(mOptionMenuActions.mAbout, SIGNAL(triggered()), this, SLOT(about())); -} - -/** - Creates Exit menu item in option menu - */ -void FileBrowserView::createExitMenuItem() -{ - // application exit - mOptionMenuActions.mExit = menu()->addAction("Exit"); - connect(mOptionMenuActions.mExit, SIGNAL(triggered()), qApp, SLOT(quit())); -} - -/** - update menu: disk admin available only in device root view. edit available only in folder view - when file or folder content exist in current folder, or clipboard has copied item. - file and view menus updated every time regarding the folder content. - tools, settings, about, exit always available. - If there's remove and add operations at same time, always remove first - to keep to the correct menu items order. - */ -void FileBrowserView::updateOptionMenu() -{ - bool isFileItemListEmpty = mFileBrowserModel->rowCount() == 0; - bool isDriveListActive = mEngineWrapper->isDriveListViewActive(); - bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); - bool currentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); //iModel->FileUtils()->IsCurrentDriveReadOnly(); - bool currentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir(); - bool listBoxSelections = mListView->selectionModel()->selection().count() == 0; - bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); - bool emptyClipBoard = !mEngineWrapper->isClipBoardListInUse(); - bool showSnapShot = false; //iModel->FileUtils()->DriveSnapShotPossible(); - - bool showEditMenu(true); - if (isDriveListActive) { - if (!showSnapShot || isFileItemListEmpty && emptyClipBoard) - showEditMenu = false; - else - showEditMenu = true; - } else { - if (isFileItemListEmpty && emptyClipBoard) - showEditMenu = false; - else - showEditMenu = true; - } - - mOptionMenuActions.mEditMenu->menuAction()->setVisible(showEditMenu); - // TODO mContextMenuActions.mDiskAdminMenu->menuAction()->setVisible(isDriveListActive); - - mOptionMenuActions.mFileBackMoveUp->setVisible( !isDriveListActive); - - //aMenuPane->SetItemDimmed(EFileBrowserCmdFileOpen, isFileItemListEmpty || isDriveListActive || currentItemDirectory); - mOptionMenuActions.mFileOpenDrive->setVisible( !(isFileItemListEmpty || !isDriveListActive)); - mOptionMenuActions.mFileOpenDirectory->setVisible( !(isFileItemListEmpty || isDriveListActive || !currentItemDirectory)); - - //aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, isFileItemListEmpty || listBoxSelections || currentItemDirectory || isDriveListActive); - //aMenuPane->SetItemDimmed(EFileBrowserCmd FileEdit, isFileItemListEmpty || listBoxSelections || currentItemDirectory || isDriveListActive); - //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || currentItemDirectory); - - mOptionMenuActions.mFileNewMenu->menuAction()->setVisible(!(isDriveListActive || currentDriveReadOnly)); - mOptionMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isDriveListActive && !currentDriveReadOnly && isSelectionMode); - mOptionMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isDriveListActive && !currentDriveReadOnly && !listBoxSelections && isSelectionMode); - mOptionMenuActions.mFileTouch->setVisible(!(isFileItemListEmpty || isDriveListActive || currentDriveReadOnly)); - mOptionMenuActions.mFileProperties->setVisible(!(isFileItemListEmpty || listBoxSelections)); - // TODO mOptionMenuActions.mFileChecksumsMenu->setVisible(!(isFileItemListEmpty || listBoxSelections || currentItemDirectory || isDriveListActive)); - // TODO mOptionMenuActions.mFileSetAttributes->setVisible(!(isFileItemListEmpty || isDriveListActive || currentDriveReadOnly)); - // TODO mOptionMenuActions.mFileCompress->setVisible(!(currentDriveReadOnly || isFileItemListEmpty || listBoxSelections || currentItemDirectory || isDriveListActive)); - // TODO mOptionMenuActions.mFileDecompress->setVisible(!(currentDriveReadOnly || isFileItemListEmpty || listBoxSelections || currentItemDirectory || isDriveListActive)); - -// bool currentSelected = true; //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex()); - bool allSelected = mListView->selectionModel()->selection().count() == mFileBrowserModel->rowCount(); - bool noneSelected = mListView->selectionModel()->selection().count() != 0; - - //mOptionMenuActions.mEditSnapShotToE->setVisible(isDriveListActive); // TODO - mOptionMenuActions.mEditCut->setVisible(!isDriveListActive && !currentDriveReadOnly && !isFileItemListEmpty && !isSelectionMode); - mOptionMenuActions.mEditCopy->setVisible(!isDriveListActive && !isFileItemListEmpty); - mOptionMenuActions.mEditPaste->setVisible(!(isDriveListActive || emptyClipBoard || currentDriveReadOnly)); - mOptionMenuActions.mEditCopyToFolder->setVisible(!(isDriveListActive || isFileItemListEmpty)); - mOptionMenuActions.mEditMoveToFolder->setVisible(!(isDriveListActive || currentDriveReadOnly || isFileItemListEmpty)); - - mOptionMenuActions.mEditSelect->setVisible(false/*!isDriveListActive && !currentSelected && !isFileItemListEmpty*/); - mOptionMenuActions.mEditUnselect->setVisible(false/*!isDriveListActive && currentSelected && !isFileItemListEmpty*/); - mOptionMenuActions.mEditSelectAll->setVisible(!isDriveListActive && !allSelected && !isFileItemListEmpty); - mOptionMenuActions.mEditUnselectAll->setVisible(!isDriveListActive && !noneSelected && !isFileItemListEmpty); - - // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isDriveListActive || isFileItemListEmpty)); - // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive || isDriveListActive || isFileItemListEmpty)); - mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive); - mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty); - - // TODO R_FILEBROWSER_VIEW_SORT_SUBMENU - // aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn); - - // TODO R_FILEBROWSER_VIEW_ORDER_SUBMENU - // aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn); - - // aResourceId == R_FILEBROWSER_TOOLS_SUBMENU - bool noExtendedErrorsAllowed = mEngineWrapper->ErrRdFileExists(); - mOptionMenuActions.mToolsDisableExtendedErrors->setVisible(noExtendedErrorsAllowed); - mOptionMenuActions.mToolsEnableExtendedErrors->setVisible(!noExtendedErrorsAllowed); - -// bool infraRedAllowed = mEngineWrapper->FileExists(KIRAppPath); -// bool bluetoothAllowed = mEngineWrapper->FileExists(KBTAppPath); -// bool usbAllowed = mEngineWrapper->FileExists(KUSBAppPath); -// -// bool noLocalCon = !infraRedAllowed && !bluetoothAllowed && !usbAllowed; -// mOptionMenuActions.mToolsLocalConnectivityMenu->menuAction()->setVisible(!noLocalCon); -// -// mOptionMenuActions.mToolsLocalConnectivityActivateInfrared->setVisible(infraRedAllowed); -// mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI->setVisible(bluetoothAllowed); -// mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI->setVisible(usbAllowed); -} - -void FileBrowserView::createContextMenu() -{ - mContextMenu = new HbMenu(); - connect(mContextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu())); - - createFileContextMenu(); - createEditContextMenu(); - createViewContextMenu(); - createDiskAdminContextMenu(); -} - - -void FileBrowserView::createFileContextMenu() -{ - mContextMenuActions.mFileMenu = mContextMenu->addMenu("File"); - - mContextMenuActions.mFileBackMoveUp = mContextMenuActions.mFileMenu->addAction("Back/Move up (<-)", this, SLOT(fileBackMoveUp())); - mContextMenuActions.mFileOpenDrive = mContextMenuActions.mFileMenu->addAction("Open drive (->)", this, SLOT(fileOpenDrive())); - mContextMenuActions.mFileOpenDirectory = mContextMenuActions.mFileMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory())); -// mContextMenuActions.mFileSearch = mContextMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch())); - //mContextMenuActions.mFileSearch->setVisible(false); - -// mContextMenuActions.mFileNewMenu = mContextMenuActions.mFileMenu->addMenu("New"); -// mContextMenuActions.mFileNewFile = mContextMenuActions.mFileNewMenu->addAction("File", this, SLOT(fileNewFile())); -// mContextMenuActions.mFileNewDirectory = mContextMenuActions.mFileNewMenu->addAction("Directory", this, SLOT(fileNewDirectory())); - - mContextMenuActions.mFileDelete = mContextMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete())); - mContextMenuActions.mFileRename = mContextMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename())); - mContextMenuActions.mFileTouch = mContextMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch())); - mContextMenuActions.mFileProperties = mContextMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties())); - - mContextMenuActions.mFileChecksumsMenu = mContextMenuActions.mFileMenu->addMenu("Checksums"); - mContextMenuActions.mFileChecksumsMD5 = mContextMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5())); - mContextMenuActions.mFileChecksumsMD2 = mContextMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2())); - mContextMenuActions.mFileChecksumsSHA1 = mContextMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1())); - -// mContextMenuActions.mFileSetAttributes = mContextMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes())); -// mContextMenuActions.mFileSetAttributes->setVisible(false); -} - -void FileBrowserView::createEditContextMenu() -{ - mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit"); - - //mContextMenuActions.mEditSnapShotToE = mContextMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE())); -// mContextMenuActions.mEditSnapShotToE->setVisible(false); - mContextMenuActions.mEditCut = mContextMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut())); - mContextMenuActions.mEditCopy = mContextMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy())); - mContextMenuActions.mEditPaste = mContextMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste())); - - mContextMenuActions.mEditCopyToFolder = mContextMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder())); - mContextMenuActions.mEditMoveToFolder = mContextMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder())); -} - -void FileBrowserView::createViewContextMenu() -{ - -} - -/** - Initial setup for Disk Admin submenu - */ -void FileBrowserView::createDiskAdminContextMenu() -{ - mContextMenuActions.mDiskAdminMenu = mContextMenu->addMenu("Disk admin"); - //mContextMenuActions.mDiskAdminMenu->menuAction()->setVisible(false); - - mContextMenuActions.mDiskAdminSetDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Set drive password", this, SLOT(diskAdminSetDrivePassword())); - mContextMenuActions.mDiskAdminUnlockDrive = mContextMenuActions.mDiskAdminMenu->addAction("Unlock drive", this, SLOT(diskAdminUnlockDrive())); - mContextMenuActions.mDiskAdminClearDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Clear drive password", this, SLOT(diskAdminClearDrivePassword())); - mContextMenuActions.mDiskAdminEraseDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Erase drive password", this, SLOT(diskAdminEraseDrivePassword())); - - mContextMenuActions.mDiskAdminFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Format drive", this, SLOT(diskAdminFormatDrive())); - mContextMenuActions.mDiskAdminFormatDrive->setVisible(false); - mContextMenuActions.mDiskAdminQuickFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Quick format drive", this, SLOT(diskAdminQuickFormatDrive())); - mContextMenuActions.mDiskAdminQuickFormatDrive->setVisible(false); - - mContextMenuActions.mDiskAdminCheckDisk = mContextMenuActions.mDiskAdminMenu->addAction("Check disk", this, SLOT(diskAdminCheckDisk())); - mContextMenuActions.mDiskAdminScanDrive = mContextMenuActions.mDiskAdminMenu->addAction("Scan drive", this, SLOT(diskAdminScanDrive())); - mContextMenuActions.mDiskAdminSetDriveName = mContextMenuActions.mDiskAdminMenu->addAction("Set drive name", this, SLOT(diskAdminSetDriveName())); - mContextMenuActions.mDiskAdminSetDriveVolumeLabel = mContextMenuActions.mDiskAdminMenu->addAction("Set drive volume label", this, SLOT(diskAdminSetDriveVolumeLabel())); - mContextMenuActions.mDiskAdminEjectDrive = mContextMenuActions.mDiskAdminMenu->addAction("Eject drive", this, SLOT(diskAdminEjectDrive())); - mContextMenuActions.mDiskAdminDismountDrive = mContextMenuActions.mDiskAdminMenu->addAction("Dismount drive", this, SLOT(diskAdminDismountDrive())); - mContextMenuActions.mDiskAdminEraseMBR = mContextMenuActions.mDiskAdminMenu->addAction("Erase MBR", this, SLOT(diskAdminEraseMBR())); - mContextMenuActions.mDiskAdminPartitionDrive = mContextMenuActions.mDiskAdminMenu->addAction("Partition drive", this, SLOT(diskAdminPartitionDrive())); -} - -void FileBrowserView::updateContextMenu() -{ - bool isFileItemListEmpty = mFileBrowserModel->rowCount() == 0; - bool isDriveListActive = mEngineWrapper->isDriveListViewActive(); -// bool isNormalModeActive = true; //iModel->FileUtils()->IsNormalModeActive(); - bool currentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly(); - bool currentItemDirectory = mEngineWrapper->getFileEntry(mCurrentIndex /*currentItemIndex()*/).isDir(); - bool listBoxSelections = mListView->selectionModel()->selection().count() == 0; - bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked(); - bool emptyClipBoard = !mEngineWrapper->isClipBoardListInUse(); -// bool showSnapShot = false; //iModel->FileUtils()->DriveSnapShotPossible(); - -// bool showEditMenu(true); -// if (isDriveListActive) { -// if (!showSnapShot || isFileItemListEmpty && emptyClipBoard) -// showEditMenu = false; -// else -// showEditMenu = true; -// } else { -// if (isFileItemListEmpty && emptyClipBoard) -// showEditMenu = false; -// else -// showEditMenu = true; -// } - - // File submenu - mContextMenuActions.mFileBackMoveUp->setVisible( !isDriveListActive); - mContextMenuActions.mFileOpenDrive->setVisible( !isFileItemListEmpty && isDriveListActive); - mContextMenuActions.mFileOpenDirectory->setVisible( !isFileItemListEmpty && !isDriveListActive && currentItemDirectory); - -// mContextMenuActions.mFileNewMenu->menuAction()->setVisible(!(isDriveListActive || currentDriveReadOnly)); - mContextMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isDriveListActive && !currentDriveReadOnly); - mContextMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isDriveListActive && !currentDriveReadOnly && !listBoxSelections); - mContextMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isDriveListActive && !currentDriveReadOnly); - mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty && !listBoxSelections && !isSelectionMode); - - mContextMenuActions.mFileChecksumsMenu->menuAction()->setVisible(!(isFileItemListEmpty || isSelectionMode /*|| listBoxSelections*/ || currentItemDirectory || isDriveListActive)); - // Edit submenu - mContextMenuActions.mEditMenu->menuAction()->setVisible(!isDriveListActive); - mContextMenuActions.mEditCut->setVisible(!(isDriveListActive || currentDriveReadOnly || isFileItemListEmpty)); - mContextMenuActions.mEditCopy->setVisible(!(isDriveListActive || isFileItemListEmpty)); - mContextMenuActions.mEditPaste->setVisible(!isDriveListActive && !emptyClipBoard && !currentDriveReadOnly); - mContextMenuActions.mEditCopyToFolder->setVisible(!(isDriveListActive || isFileItemListEmpty)); - mContextMenuActions.mEditMoveToFolder->setVisible(!(isDriveListActive || currentDriveReadOnly || isFileItemListEmpty)); - //DiskAdmin submenu - mContextMenuActions.mDiskAdminMenu->menuAction()->setVisible(isDriveListActive); -} - -// --------------------------------------------------------------------------- - -void FileBrowserView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords) -{ - //Q_UNUSED(listViewItem); - -// QItemSelectionModel *selectionIndexes = mListView->selectionModel(); - - // by default use selected items -// if (selectionIndexes && selectionIndexes->hasSelection()) { -// mSelectionIndexes = mListView->selectionModel()->selectedIndexes(); -// } else { - mCurrentIndex = listViewItem->modelIndex(); -// mSelectionIndexes.clear(); -// mSelectionIndexes.append(mModelIndex); -// } - mContextMenu->setPreferredPos(coords); - mContextMenu->show(); -} - - -/** - Create a file browser tool bar - */ -void FileBrowserView::createToolBar() -{ - mToolBar = new HbToolBar(this); - - mToolbarBackAction = new HbAction(/*"Back"*/); - mToolbarBackAction->setToolTip("Back"); - mToolbarBackAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_folder_parent.svg"))); - connect(mToolbarBackAction, SIGNAL(triggered()), this, SLOT(fileBackMoveUp())); - mToolBar->addAction(mToolbarBackAction); - - if (mOptionMenuActions.mSelection) { - mToolBar->addAction(mOptionMenuActions.mSelection); - } - - setToolBar(mToolBar); -} - -/** - Refresh FileBrowser view - */ -void FileBrowserView::refreshList() -{ - mEngineWrapper->refreshView(); -// mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); - mListView->reset(); - mListView->setModel(mFileBrowserModel); - mToolbarBackAction->setEnabled(!mEngineWrapper->isDriveListViewActive()); - - TListingMode listingMode = mEngineWrapper->listingMode(); - if (listingMode == ENormalEntries) - mNaviPane->setPlainText(QString(mEngineWrapper->currentPath())); - else if (listingMode == ESearchResults) - mNaviPane->setPlainText(QString(tr("Search results"))); - else if (listingMode == EOpenFiles) - mNaviPane->setPlainText(QString(tr("Open files"))); - else if (listingMode == EMsgAttachmentsInbox) - mNaviPane->setPlainText(QString(tr("Attachments in Inbox"))); - else if (listingMode == EMsgAttachmentsDrafts) - mNaviPane->setPlainText(QString(tr("Attachments in Drafts"))); - else if (listingMode == EMsgAttachmentsSentItems) - mNaviPane->setPlainText(QString(tr("Attachments in Sent Items"))); - else if (listingMode == EMsgAttachmentsOutbox) - mNaviPane->setPlainText(QString(tr("Attachments in Outbox"))); -} - -/** - Populate changed folder content, i.e. in practice navigation list items - */ -void FileBrowserView::populateFolderContent() -{ - // update the file browser by setting up the model with current directory as root path - if(mListView->model() == 0) { - mFileBrowserModel = new FileBrowserModel(mEngineWrapper); - mListView->setModel(mFileBrowserModel); - } - - refreshList(); - //mFileSystemModel->setFilter(mFileSystemModel->filter() | QDir::System | QDir::Hidden); - //mFileSystemModel->setRootPath(directory); - //mListView->setRootIndex(mFileSystemModel->index(directory)); -} - -// --------------------------------------------------------------------------- - -void FileBrowserView::fileOpen(HbAction *action) -{ -// Q_UNUSED(action); - HbSelectionDialog *dlg = static_cast(sender()); - if(!action && dlg && dlg->selectedItems().count()){ - int selectionIndex = dlg->selectedItems().at(0).toInt(); - - if (selectionIndex == 0) { - // open editor view - emit aboutToShowEditorView(mAbsoluteFilePath, true); - } else if (selectionIndex == 1) { - // AppArc - mEngineWrapper->openAppArc(mAbsoluteFilePath); - } else { - // DocHandler - mEngineWrapper->openDocHandler(mAbsoluteFilePath, true); - } - } -} - -/** - Open overwrite dialog - */ -void FileBrowserView::fileOverwriteDialog() -{ - mOverwriteOptions = OverwriteOptions(); - // open user-dialog to select: view as text/hex, open w/AppArc or open w/DocH. embed - QStringList list; - list << QString("Overwrite all") - << QString("Skip all existing") - << QString("Gen. unique filenames") - << QString("Query postfix"); - openListDialog(list, QString("Overwrite?"), this, SLOT(fileOverwrite(HbAction *))); -} - -/** - File overwrite - */ -void FileBrowserView::fileOverwrite(HbAction *action) -{ -// Q_UNUSED(action); - HbSelectionDialog *dlg = static_cast(sender()); - if(!action && dlg && dlg->selectedItems().count()) { - mOverwriteOptions.queryIndex = dlg->selectedItems().at(0).toInt(); - if (mOverwriteOptions.queryIndex == EFileActionQueryPostFix) { - QString heading = QString("Postfix"); - HbInputDialog::getText(heading, this, SLOT(fileOverwritePostfix(HbAction *)), QString(), scene()); - } else if (mOverwriteOptions.queryIndex == EFileActionSkipAllExisting) { - mOverwriteOptions.overWriteFlags = 0; - } - } else { - mOverwriteOptions.doFileOperations = false; - } -} - -/** - File overwrite postfix query dialog - */ -void FileBrowserView::fileOverwritePostfix(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - mOverwriteOptions.postFix = dlg->value().toString(); - } else { - mOverwriteOptions.doFileOperations = false; - } -} - -// --------------------------------------------------------------------------- -/** - Show a list dialog - \param List aList of item to select item from. - \param Title text titleText of a dialog heading widget - \return None - */ -void FileBrowserView::openListDialog(const QStringList& items, const QString &titleText, QObject* receiver, const char* member) -{ -// Q_UNUSED(items); -// Q_UNUSED(titleText); -// Q_UNUSED(receiver); -// Q_UNUSED(member); - // Create a list and some simple content for it - HbSelectionDialog *dlg = new HbSelectionDialog(); - dlg->setAttribute(Qt::WA_DeleteOnClose); - // Set items to be popup's content - dlg->setStringItems(items); - dlg->setSelectionMode(HbAbstractItemView::SingleSelection); - //dlg->setDismissPolicy(HbPopup::TapOutside); - - HbLabel *title = new HbLabel(dlg); - title->setPlainText(titleText); - dlg->setHeadingWidget(title); - - // Launch popup and handle the user response: - dlg->open(receiver, member); -} - -// --------------------------------------------------------------------------- - -void FileBrowserView::openPropertyDialog(const QStringList& propertyList, const QString& title) -{ - HbDialog *dialog = new HbDialog(); - dialog->setDismissPolicy(HbPopup::TapOutside); - dialog->setTimeout(HbPopup::NoTimeout); - - HbLabel *titleWidget = new HbLabel(); - titleWidget->setPlainText(title); - dialog->setHeadingWidget(titleWidget); - - // Create a list and some simple content for it - HbListWidget *list = new HbListWidget(); - QString str; - foreach (str, propertyList) { - list->addItem(str); - } - - // Connect list item activation signal to close the popup - connect(list, SIGNAL(activated(HbListWidgetItem*)), dialog, SLOT(close())); - - HbAction *cancelAction = new HbAction("Close"); - dialog->setPrimaryAction(cancelAction); - - // Set listwidget to be popup's content - dialog->setContentWidget(list); - // Launch popup and handle the user response: - dialog->open(); -} - -void FileBrowserView::storeSelectedItemsOrCurrentItem() -{ - QItemSelectionModel *selectionIndexes = mListView->selectionModel(); - - // by default use selected items - if (selectionIndexes) { - if (selectionIndexes->hasSelection()) { - mSelectionIndexes = mListView->selectionModel()->selectedIndexes(); - } else { // or if none selected, use the current item index - mSelectionIndexes.clear(); - mSelectionIndexes.append(mCurrentIndex); -// QModelIndex currentIndex = currentItemIndex(); -// if (mFileBrowserModel->rowCount(currentItemIndex) > currentItemIndex && currentItemIndex >= 0) -// { -// modelIndexList.append(currentIndex); -// } - } - } -// mClipBoardInUse = true; -} - -// --------------------------------------------------------------------------- - -QModelIndex FileBrowserView::currentItemIndex() -{ - return mCurrentIndex;//mListView->selectionModel()->currentIndex(); -} - -// --------------------------------------------------------------------------- -// operations in File Menu -// --------------------------------------------------------------------------- - -/** - Move back/up in folder browsing history - */ -void FileBrowserView::fileBackMoveUp() -{ - mLocationChanged = true; -// if(mDirectory.length() < DRIVEPATHLENGTH) { -// // location in the root of any drive -> move back/up to root of device -// QModelIndex index = currentItemIndex(); -// const QString filePath = mFileSystemModel->filePath(index); -// qDebug() << "handleBackButton filePath" << filePath; -// mDirectory = mInitDirPath.path(); -// populateFolderContent(mDirectory); -// } -// else if(mDirectory != mInitDirPath.path()) { -// // location in any folder in any drive -> move back/up -// QDir dir(mDirectory); -// dir.cdUp(); -// const QString currentPath = dir.absolutePath(); -// mDirectory = currentPath; -// populateFolderContent(currentPath); -// mSelectedFilePath = ""; -// } else { -// // location already in the device root, no way up. -// // do nothing. -// } - mEngineWrapper->moveUpOneLevel(); - populateFolderContent(); -} - -void FileBrowserView::fileOpenDrive() -{ - // TODO make a separate function to be called from here and fileOpenDirectory() - mLocationChanged = true; - // get selected drive or directory from list view model and open it: - //if (mListView->selectionModel()->hasSelection()) { -// if (mListView->selectionModel()->selection().count() != 0) { -// QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->moveDownToDirectory(mCurrentIndex); - populateFolderContent(); -// } else { -// Notifications::showErrorNote("not selected item!"); -// } -} - -void FileBrowserView::fileOpenDirectory() -{ - mLocationChanged = true; - // get selected drive or directory from list view model and open it: - //if (mListView->selectionModel()->hasSelection()) { -// if (mListView->selectionModel()->selection().count() != 0) { -// QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->moveDownToDirectory(mCurrentIndex); - populateFolderContent(); -// } else { -// Notifications::showErrorNote("not selected item!"); -// } -} - -void FileBrowserView::fileSearch() -{ - QString searchPath; -// if (mEngineWrapper->currentPath() != mInitDirPath.path()) { -// searchPath = mDirectory; -// searchPath.replace("/", "\\"); -// searchPath+="\\"; -// } - searchPath = mEngineWrapper->currentPath(); -// mSearch->open(searchPath); - emit aboutToShowSearchView(searchPath); -} - -/** - Open new file dialog - */ -void FileBrowserView::fileNewFile() -{ - QString heading = QString("Enter filename"); - HbInputDialog::getText(heading, this, SLOT(doFileNewFile(HbAction*)), QString(), scene()); -} - -/** - Create a new file in current directory with a name queried from user - */ -void FileBrowserView::doFileNewFile(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString newFileName = dlg->value().toString(); - mEngineWrapper->createNewFile(newFileName); - refreshList(); - } -} - -/** - Open new directory dialog - */ -void FileBrowserView::fileNewDirectory() -{ - QString heading = QString("Enter directory name"); - HbInputDialog::getText(heading, this, SLOT(doFileNewDirectory(HbAction*)), QString(), scene()); -} - -/** - Create a new directory in current directory with a name queried from user - */ -void FileBrowserView::doFileNewDirectory(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString newDirectoryName = dlg->value().toString(); - mEngineWrapper->createNewDirectory(newDirectoryName); - refreshList(); - } -} - -/** - Question for Delete actually selected files - */ -void FileBrowserView::fileDelete() -{ - storeSelectedItemsOrCurrentItem(); - const QString messageFormat = "Delete %1 entries?"; - QString message = messageFormat.arg(mSelectionIndexes.count()); - HbMessageBox::question(message, this, SLOT(doFileDelete(HbAction*))); -} - -/** - Delete actually selected files - */ -void FileBrowserView::doFileDelete(HbAction* action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - //storeSelectedItemsOrCurrentItem(); - mEngineWrapper->deleteItems(mSelectionIndexes); - refreshList(); - } -} - -/** - Open rename dialog for actually selected files - */ -void FileBrowserView::fileRename() -{ - storeSelectedItemsOrCurrentItem(); - mEngineWrapper->setCurrentSelection(mSelectionIndexes); - - for (int i(0), ie(mSelectionIndexes.count()); i < ie; ++i ) { - mProceed = (i == ie-1); // if the last item - mModelIndex = mSelectionIndexes.at(i); - FileEntry entry = mEngineWrapper->getFileEntry(mModelIndex); - - QString heading = QString("Enter new name"); - HbInputDialog::getText(heading, this, SLOT(doFileRename(HbAction*)), entry.name(), scene()); - } -} - -/** - Rename actually selected files - */ -void FileBrowserView::doFileRename(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - mNewFileName = dlg->value().toString(); - - if (mEngineWrapper->targetExists(mModelIndex, mNewFileName)) { - const QString messageTemplate = QString("%1 already exists, overwrite?"); - QString message = messageTemplate.arg(mNewFileName); - HbMessageBox::question(message, this, SLOT(doFileRenameFileExist(HbAction *))); - } else { - mEngineWrapper->rename(mModelIndex, mNewFileName); - if (mProceed) { - mEngineWrapper->startExecutingCommands(QString("Renaming")); - refreshList(); - } - } - } -} - -/** - Rename actually selected files - */ -void FileBrowserView::doFileRenameFileExist(HbAction *action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - mEngineWrapper->rename(mModelIndex, mNewFileName); - if (mProceed) { - mEngineWrapper->startExecutingCommands(QString("Renaming")); - refreshList(); - } - } -} - -/** - Touch actually selected files - */ -void FileBrowserView::fileTouch() -{ - storeSelectedItemsOrCurrentItem(); - mEngineWrapper->setCurrentSelection(mSelectionIndexes); - - if (mEngineWrapper->selectionHasDirs()) { - const QString message = "Recurse touch for all selected dirs?"; - HbMessageBox::question(message, this, SLOT(doFileTouch(HbAction*))); - } - else{ - mEngineWrapper->touch(false); - refreshList(); - } -} - -/** - Touch actually selected files - */ -void FileBrowserView::doFileTouch(HbAction* action) -{ - bool recurse = false; - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - recurse = true; - } - mEngineWrapper->touch(recurse); - refreshList(); -} - -void FileBrowserView::fileChecksumsMD5() -{ - fileChecksums(EFileChecksumsMD5); -} - -void FileBrowserView::fileChecksumsMD2() -{ - fileChecksums(EFileChecksumsMD2); -} - -void FileBrowserView::fileChecksumsSHA1() -{ - fileChecksums(EFileChecksumsSHA1); -} - -void FileBrowserView::fileChecksums(TFileBrowserCmdFileChecksums checksumType) -{ -// QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->showFileCheckSums(mCurrentIndex, checksumType); -} - -/** - Show file properties - */ -void FileBrowserView::fileProperties() -{ - QModelIndex currentIndex = currentItemIndex(); - QStringList propertyList; - QString titleText; - mEngineWrapper->properties(currentIndex, propertyList, titleText); - openPropertyDialog(propertyList, titleText); -} - -void FileBrowserView::fileSetAttributes() -{ - -} - -// edit menu -void FileBrowserView::editSnapShotToE() -{ - -} - -/** - Set selected files into clipboard. - Selected item will be removed after paste operation. - */ -void FileBrowserView::editCut() -{ - storeSelectedItemsOrCurrentItem(); - mClipboardIndexes = mSelectionIndexes; - - mEngineWrapper->clipboardCut(mClipboardIndexes); - - int operations = mClipboardIndexes.count(); - const QString message = QString ("%1 entries cut to clipboard"); - QString noteMsg = message.arg(operations); - - Notifications::showInformationNote(noteMsg); -} - -/** - Set selected files into clipboard. - Selected item will not be removed after paste operation. - */ -void FileBrowserView::editCopy() -{ - storeSelectedItemsOrCurrentItem(); - mClipboardIndexes = mSelectionIndexes; - - mEngineWrapper->clipboardCopy(mClipboardIndexes); - - int operations = mClipboardIndexes.count(); - - const QString message = QString ("%1 entries copied to clipboard"); - QString noteMsg = message.arg(operations); - - Notifications::showInformationNote(noteMsg); -} - -/** - Moves or copies file selection stored in clipboard to a actual directory. - Removing files depend on previous operation, i.e. Cut or Copy - */ -void FileBrowserView::editPaste() -{ - bool someEntryExists(false); - - // TODO Set entry items here - - someEntryExists = mEngineWrapper->isDestinationEntriesExists(mClipboardIndexes, mEngineWrapper->currentPath()); - if (someEntryExists) { - fileOverwriteDialog(); - } - mEngineWrapper->clipboardPaste(mOverwriteOptions); -} - -/** - Open copy to folder new filename dialog - */ -void FileBrowserView::editCopyToFolder() -{ - QString heading = QString("Enter new name"); - HbInputDialog::getText(heading, this, SLOT(doEditCopyToFolder(HbAction*)), mEngineWrapper->currentPath(), scene()); -} - -/** - Copies current file selection to a queried directory. - */ -void FileBrowserView::doEditCopyToFolder(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString targetDir = dlg->value().toString(); - bool someEntryExists(false); - - // TODO Set entry items here - storeSelectedItemsOrCurrentItem(); - mEngineWrapper->setCurrentSelection(mSelectionIndexes); - - someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir); - if (someEntryExists) { - fileOverwriteDialog(); - } - mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, false); - refreshList(); - } -} - -/** - Open move to folder new filename dialog. - */ -void FileBrowserView::editMoveToFolder() -{ - QString heading = QString("Enter new name"); - HbInputDialog::getText(heading, this, SLOT(doEditCopyToFolder(HbAction*)), mEngineWrapper->currentPath(), scene()); -} - -/** - Moves current file selection to a queried directory. - */ -void FileBrowserView::doEditMoveToFolder(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString targetDir = dlg->value().toString(); - bool someEntryExists(false); - - // TODO Set entry items here - storeSelectedItemsOrCurrentItem(); - mEngineWrapper->setCurrentSelection(mSelectionIndexes); - - someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir); - if (someEntryExists) { - fileOverwriteDialog(); - } - mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, true); - refreshList(); - } -} - -/** - Select current file - */ -void FileBrowserView::editSelect() -{ - QItemSelectionModel *selectionModel = mListView->selectionModel(); - if (selectionModel) { - selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::SelectCurrent); - selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Select); - itemHighlighted(selectionModel->currentIndex()); - refreshList(); - } -} - -/** - Unselect current file - */ -void FileBrowserView::editUnselect() -{ - QItemSelectionModel *selectionModel = mListView->selectionModel(); - if (selectionModel) { - selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Deselect); - itemHighlighted(selectionModel->currentIndex()); - } -} - -/** - Select all files - */ -void FileBrowserView::editSelectAll() -{ - QItemSelectionModel *selectionModel = mListView->selectionModel(); - if (selectionModel) { - - if (mFileBrowserModel->rowCount() > 0) { - QModelIndex firstIndex = mFileBrowserModel->index(0, 0); - QModelIndex lastIndex = mFileBrowserModel->index( (mFileBrowserModel->rowCount() - 1), 0); - - QItemSelection itemSelection(firstIndex, lastIndex); - //selectionModel->select(itemSelection, QItemSelectionModel::SelectCurrent); - selectionModel->select(itemSelection, QItemSelectionModel::Select); - } - } -} - -/** - Unselect all files - */ -void FileBrowserView::editUnselectAll() -{ - QItemSelectionModel *selectionModel = mListView->selectionModel(); - if (selectionModel) { - selectionModel->clearSelection(); - } -} - -// --------------------------------------------------------------------------- -// view menu -// --------------------------------------------------------------------------- -void FileBrowserView::viewFilterEntries() -{ - -} -void FileBrowserView::viewRefresh() -{ - refreshList(); -} - -// --------------------------------------------------------------------------- -// disk admin menu -// --------------------------------------------------------------------------- - -/** - Open old password for the selected drive dialog. - */ -void FileBrowserView::diskAdminSetDrivePassword() -{ - QModelIndex currentIndex = currentItemIndex(); - // check if the drive has a password - if (mEngineWrapper->hasDrivePassword(currentIndex)) { - QString heading = QString("Existing password"); - HbInputDialog::getText(heading, this, SLOT(diskAdminSetDrivePasswordNew(HbAction*)), QString(), scene()); - } -} - -/** - Open new password for the selected drive dialog. - */ -void FileBrowserView::diskAdminSetDrivePasswordNew(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - mOldPassword = dlg->value().toString(); - } - - QString heading = QString("New password"); - HbInputDialog::getText(heading, this, SLOT(doDiskAdminSetDrivePassword(HbAction*)), mOldPassword, scene()); -} - -/** - Set password for the selected drive. - */ -void FileBrowserView::doDiskAdminSetDrivePassword(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString newPassword = dlg->value().toString(); - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminSetDrivePassword(currentIndex, mOldPassword, newPassword); - refreshList(); - } -} - -/** - Open Unlock the selected drive dialog. - */ -void FileBrowserView::diskAdminUnlockDrive() -{ - QModelIndex currentIndex = currentItemIndex(); - // check if the drive is locked - if (mEngineWrapper->isDriveLocked(currentIndex)) { - QString heading = QString("Existing password"); - HbInputDialog::getText(heading, this, SLOT(doDiskAdminUnlockDrive(HbAction*)), QString(), scene()); - } else { - Notifications::showInformationNote(QString("This drive is not locked")); - } -} - -/** - Unlock the selected drive. - */ -void FileBrowserView::doDiskAdminUnlockDrive(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString oldPassword = dlg->value().toString(); - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminUnlockDrive(currentIndex, oldPassword); - refreshList(); - } -} - -/** - Open clear password of the selected drive dialog. - */ -void FileBrowserView::diskAdminClearDrivePassword() -{ - QModelIndex currentIndex = currentItemIndex(); - // check if the drive has a password - if (mEngineWrapper->hasDrivePassword(currentIndex)) { - QString heading = QString("Existing password"); - HbInputDialog::getText(heading, this, SLOT(doDiskAdminClearDrivePassword(HbAction*)), QString(), scene()); - } else { - Notifications::showInformationNote(QString("This drive has no password")); - } -} - -/** - Clear password of the selected drive. - */ -void FileBrowserView::doDiskAdminClearDrivePassword(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString oldPassword = dlg->value().toString(); - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminClearDrivePassword(currentIndex, oldPassword); - refreshList(); - } -} - - -/** - Question for erase password of the selected drive - */ -void FileBrowserView::diskAdminEraseDrivePassword() -{ - // check if the drive has a password - QModelIndex currentIndex = currentItemIndex(); - if (mEngineWrapper->hasDrivePassword(currentIndex)) { - HbMessageBox::question(QString("Are you sure? All data can be lost!"), this, SLOT(doDiskAdminEraseDrivePassword(HbAction*))); - } else { - Notifications::showInformationNote(QString("This drive has no password")); - } -} - -/** - Erase password of the selected drive - */ -void FileBrowserView::doDiskAdminEraseDrivePassword(HbAction* action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminEraseDrivePassword(currentIndex); - refreshList(); - } -} - -/** - Performs format on the selected drive - */ -void FileBrowserView::diskAdminFormatDrive() -{ - HbMessageBox::question(QString("Are you sure? All data will be lost!"), this, SLOT(doDiskAdminFormatDrive(HbAction*))); -} - -/** - Performs format on the selected drive - */ -void FileBrowserView::doDiskAdminFormatDrive(HbAction* action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminFormatDrive(currentIndex, false); - } -} - -/** - Performs quick format on the selected drive - */ -void FileBrowserView::diskAdminQuickFormatDrive() -{ - HbMessageBox::question(QString("Are you sure? All data will be lost!"), this, SLOT(doDiskAdminQuickFormatDrive(HbAction*))); -} - -/** - Performs quick format on the selected drive - */ -void FileBrowserView::doDiskAdminQuickFormatDrive(HbAction* action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminFormatDrive(currentIndex, true); - } -} - -/** - Checks the disk integrity on the selected drive - */ -void FileBrowserView::diskAdminCheckDisk() -{ - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminCheckDisk(currentIndex); -} - -/** - Checks the selected drive for errors and corrects them - */ -void FileBrowserView::diskAdminScanDrive() -{ - HbMessageBox::question(QString("This finds errors on disk and corrects them. Proceed?"), this, SLOT(doDiskAdminScanDrive(HbAction*))); -} - -/** - Checks the selected drive for errors and corrects them - */ -void FileBrowserView::doDiskAdminScanDrive(HbAction* action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminScanDrive(currentIndex); - refreshList(); - } -} - -/** - Open drive name dialog - */ -void FileBrowserView::diskAdminSetDriveName() -{ - QString driveName; - - // get existing drive name - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->GetDriveName(currentIndex, driveName); - - QString heading = QString("New name"); - HbInputDialog::getText(heading, this, SLOT(doDiskAdminSetDriveName(HbAction*)), driveName, scene()); -} - -/** - Set drive name. - */ -void FileBrowserView::doDiskAdminSetDriveName(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString driveName = dlg->value().toString(); - - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminSetDriveName(currentIndex, driveName); - - refreshList(); - } -} - -/** - Open drive volume label dialog - */ -void FileBrowserView::diskAdminSetDriveVolumeLabel() -{ - QString volumeLabel; - - // get existing drive name - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->GetDriveVolumeLabel(currentIndex, volumeLabel); - - QString heading = QString("New volume label"); - HbInputDialog::getText(heading, this, SLOT(doDiskAdminSetDriveVolumeLabel(HbAction*)), volumeLabel, scene()); -} - -/** - Set drive volume label. - */ -void FileBrowserView::doDiskAdminSetDriveVolumeLabel(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString volumeLabel = dlg->value().toString(); - - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminSetDriveVolumeLabel(currentIndex, volumeLabel); - - refreshList(); - } -} - -/** - Eject the selected drive - */ -void FileBrowserView::diskAdminEjectDrive() -{ - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminEjectDrive(currentIndex); - refreshList(); -} - -/** - Dismount the selected drive - */ -void FileBrowserView::diskAdminDismountDrive() -{ - HbMessageBox::question(QString("Are you sure you know what are you doing?"), this, SLOT(doDiskAdminDismountDrive(HbAction*))); -} - -void FileBrowserView::doDiskAdminDismountDrive(HbAction* action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminDismountDrive(currentIndex); - refreshList(); - } -} - -/** - Erase Master Boot Record of the selected drive - */ -void FileBrowserView::diskAdminEraseMBR() -{ - // TODO What to do with FB LITE macros? - HbMessageBox::question(QString("Are you sure? Your media driver must support this!"), this, SLOT(doDiskAdminEraseMBR(HbAction*))); -} - -void FileBrowserView::doDiskAdminEraseMBR(HbAction* action) -{ - // TODO What to do with FB LITE macros? - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - HbMessageBox::question(QString("Are you really sure you know what are you doing ?!?"), this, SLOT(doDiskAdminReallyEraseMBR(HbAction*))); - } -} - -void FileBrowserView::doDiskAdminReallyEraseMBR(HbAction* action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - QModelIndex currentIndex = currentItemIndex(); - // warn if the selected drive is not detected as removable - if (mEngineWrapper->isDriveRemovable(currentIndex)) { - mEngineWrapper->DiskAdminEraseMBR(currentIndex); - refreshList(); - } else { - HbMessageBox::question(QString("Selected drive is not removable, really continue?"), this, SLOT(doDiskAdminNotRemovableReallyEraseMBR(HbAction*))); - } - } -} - -void FileBrowserView::doDiskAdminNotRemovableReallyEraseMBR(HbAction* action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - QModelIndex currentIndex = currentItemIndex(); - mEngineWrapper->DiskAdminEraseMBR(currentIndex); - refreshList(); - } - -} - -/** - Partition the selected drive - */ -void FileBrowserView::diskAdminPartitionDrive() -{ - const QString message("Are you sure? Your media driver must support this!"); - HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveProceed(HbAction *))); -} - -/** - Partition the selected drive if user is sure - */ -void FileBrowserView::diskAdminPartitionDriveProceed(HbAction *action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - const QString message("Are you really sure you know what are you doing ?!?"); - HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveReallyProceed(HbAction *))); - } -} - -/** - Partition the selected drive if user is really sure - */ -void FileBrowserView::diskAdminPartitionDriveReallyProceed(HbAction *action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - QModelIndex currentIndex = currentItemIndex(); - mEraseMBR = false; - // warn if the selected drive is not detected as removable - mProceed = false; - if (mEngineWrapper->isDriveRemovable(currentIndex)) { - mProceed = true; - } else { - const QString message("Selected drive is not removable, really continue?"); - HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveIsNotRemovable(HbAction *))); - } - - if (mProceed) { - // query if erase mbr - mEraseMBR = false; - - QString message("Erase MBR first (normally needed)?"); - HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveEraseMbr(HbAction *))); - - // TODO use HbListDialog - QStringList list; - list << "1" << "2" << "3" << "4"; - openListDialog(list, QString("Partitions?"), this, SLOT(diskAdminPartitionDriveGetCount(HbAction*))); - } - } -} - -/** - Store result of user query about proceeding when drive is not removable. - */ -void FileBrowserView::diskAdminPartitionDriveIsNotRemovable(HbAction *action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - mProceed = true; - } else { - mProceed = false; - } -} - -/** - Store result of user query about erase MBR - */ -void FileBrowserView::diskAdminPartitionDriveEraseMbr(HbAction *action) -{ - if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) { - mEraseMBR = true; - } -} - -/** - Partition the selected drive - */ -void FileBrowserView::diskAdminPartitionDriveGetCount(HbAction* action) -{ -// Q_UNUSED(action); - HbSelectionDialog *dlg = static_cast(sender()); - if(!action && dlg && dlg->selectedItems().count()){ - int selectionIndex = dlg->selectedItems().at(0).toInt(); - QModelIndex currentIndex = currentItemIndex(); - int amountOfPartitions = selectionIndex + 1; - mEngineWrapper->DiskAdminPartitionDrive(currentIndex, mEraseMBR, amountOfPartitions); - refreshList(); - } -} - -// --------------------------------------------------------------------------- -// tools menu -// --------------------------------------------------------------------------- -void FileBrowserView::toolsAllAppsToTextFile() -{ - -} - -/** - Write all files to text file - */ -void FileBrowserView::toolsAllFilesToTextFile() -{ - mEngineWrapper->toolsWriteAllFiles(); -} - -void FileBrowserView::toolsAvkonIconCacheEnable() -{ - -} -void FileBrowserView::toolsAvkonIconCacheDisable() -{ - -} - -/** - Disable extended errors - */ -void FileBrowserView::toolsDisableExtendedErrors() -{ - mEngineWrapper->ToolsSetErrRd(false); -} - -void FileBrowserView::toolsDumpMsgStoreWalk() -{ - -} -void FileBrowserView::toolsEditDataTypes() -{ - -} - -/** - Enable extended errors - */ -void FileBrowserView::toolsEnableExtendedErrors() -{ - mEngineWrapper->ToolsSetErrRd(true); -} - -/** - Open simulate leave dialog - */ -void FileBrowserView::toolsErrorSimulateLeave() -{ - int leaveCode = -6; - QString heading = QString("Leave code"); - //HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), leaveCode, scene()); - HbInputDialog::getText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene()); -} - - -/** - Simulate leave. - */ -void FileBrowserView::doToolsErrorSimulateLeave(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - bool ok; - int leaveCode = dlg->value().toString().toInt(&ok); - if (leaveCode != 0 || ok) { - mEngineWrapper->ToolsErrorSimulateLeave(leaveCode); - } - } -} - -/** - Open simulate panic dialog. - */ -void FileBrowserView::toolsErrorSimulatePanic() -{ - mPanicCategory = QString ("Test Category"); - QString heading = QString("Panic category"); - HbInputDialog::getText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene()); -} - -/** - Simulate panic. - */ -void FileBrowserView::doToolsErrorSimulatePanicCode(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - mPanicCategory = dlg->value().toString(); - int panicCode(555); - QString heading = QString("Panic code"); - HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene()); - } -} - -/** - Simulate panic. - */ -void FileBrowserView::doToolsErrorSimulatePanic(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - bool ok; - int panicCode = dlg->value().toInt(&ok); - if (panicCode != 0 || ok) { - mEngineWrapper->ToolsErrorSimulatePanic(mPanicCategory, panicCode); - } - } -} - -/** - Open simulate exception dialog. - */ -void FileBrowserView::toolsErrorSimulateException() -{ - int exceptionCode = 0; - QString heading = QString("Exception code"); - HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene()); -} - -/** - Simulate exception. - */ -void FileBrowserView::doToolsErrorSimulateException(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - bool ok; - int exceptionCode = dlg->value().toInt(&ok); - if (exceptionCode != 0 || ok) { - mEngineWrapper->ToolsErrorSimulateException(exceptionCode); - } - } -} - -// void FileBrowserView::toolsLocalConnectivityActivateInfrared() -//{ -// -//} -// void FileBrowserView::toolsLocalConnectivityLaunchBTUI() -//{ -// -//} -// void FileBrowserView::toolsLocalConnectivityLaunchUSBUI() -//{ -// -//} -void FileBrowserView::toolsMessageInbox() -{ - -} -void FileBrowserView::toolsMessageDrafts() -{ - -} -void FileBrowserView::toolsMessageSentItems() -{ - -} -void FileBrowserView::toolsMessageOutbox() -{ - -} -void FileBrowserView::toolsMemoryInfo() -{ - -} -void FileBrowserView::toolsSecureBackStart() -{ - -} -void FileBrowserView::toolsSecureBackRestore() -{ - -} -void FileBrowserView::toolsSecureBackStop() -{ - -} - -/** - Open debug mask dialog - */ -void FileBrowserView::toolsSetDebugMaskQuestion() -{ - quint32 dbgMask = mEngineWrapper->getDebugMask(); - QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16)); - QString heading = QString("Kernel debug mask in hex format"); - HbInputDialog::getText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene()); -} - -/** - Set debug mask - */ -void FileBrowserView::toolsSetDebugMask(HbAction *action) -{ - HbInputDialog *dlg = static_cast(sender()); - if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) { - QString dbgMaskText = dlg->value().toString(); - if (dbgMaskText.length() > 2 && dbgMaskText[0]=='0' && dbgMaskText[1]=='x') { - bool ok; - quint32 dbgMask = dbgMaskText.toUInt(&ok, 16); - if (dbgMask != 0 || ok) { - mEngineWrapper->toolsSetDebugMask(dbgMask); - Notifications::showConfirmationNote(QString("Changed")); - } else { - Notifications::showErrorNote(QString("Cannot convert value")); - } - } else { - Notifications::showErrorNote(QString("Not in hex format")); - } - } -} - -void FileBrowserView::toolsShowOpenFilesHere() -{ - -} - -// --------------------------------------------------------------------------- -// main menu items -// --------------------------------------------------------------------------- -void FileBrowserView::selectionModeChanged() -{ - if (mOptionMenuActions.mSelection->isChecked()) { - activateSelectionMode(); - } else { - deActivateSelectionMode(); - } -} - -/** - Show about note - */ -void FileBrowserView::about() -{ - Notifications::showAboutNote(); -} - -// --------------------------------------------------------------------------- -// End of operations -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- - -/** - Item is selected from list when selection mode is activated from menu - */ -void FileBrowserView::selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/) -{ - //QItemSelectionModel *selectionModel = mListView->selectionModel(); - //itemHighlighted(selectionModel->currentIndex()); -} - -/** - An item is highlighted = single-clicked from file/folder list. - */ -void FileBrowserView::itemHighlighted(const QModelIndex& index) -{ - Q_UNUSED(index) -// mItemHighlighted = true; -// mFileInfo = mFileSystemModel->fileInfo(index); -} - - -/** - An item is clicked from navigation item list. Navigation item list contains - drive-, folder- or file items. Opens selected drive, folder or file popup menu - */ -void FileBrowserView::activated(const QModelIndex& index) -{ - if (mFileBrowserModel) { - if (mEngineWrapper->isDriveListViewActive()) { - mEngineWrapper->moveDownToDirectory(index); - populateFolderContent(); - } else if (mEngineWrapper->getFileEntry(index).isDir()) { - // populate new content of changed navigation view. - // mLocationChanged = true; - // mDirectory = filePath; - mEngineWrapper->moveDownToDirectory(index); - populateFolderContent(); - } else { // file item - // mSelectedFilePath = filePath; - FileEntry fileEntry = mEngineWrapper->getFileEntry(index); - mAbsoluteFilePath = fileEntry.path() + fileEntry.name(); - - // open user-dialog to select: view as text/hex, open w/AppArc or open w/DocH. embed - QStringList list; - list << QString("View as text/hex") << QString("Open w/ AppArc") << QString("Open w/ DocH. embed"); - openListDialog(list, QString("Open file"), this, SLOT(fileOpen(HbAction *))); - } - } -} - -// --------------------------------------------------------------------------- - -void FileBrowserView::activateSelectionMode() -{ - QString path; - disconnect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); - mListView->setSelectionMode(HbListView::MultiSelection); - -// if (mDirectory != mInitDirPath.path()) { -// QDir dir(mDirectory); -// path = mDirectory; -// QStringList dirs = dir.entryList(QDir::AllDirs | QDir::System | QDir::Hidden); -// if (dirs.count() > 0) { -// path.append("\\" + dirs.at(0) + "\\"); -// } -// } else { -// path = ("C:\\"); -// } -// QModelIndex index = mFileSystemModel->index(path,0); -// mListView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent); -// mListView->selectionModel()->select(index, QItemSelectionModel::Select); -// //mListView->setHighlightMode(HbItemHighlight::HighlightAlwaysVisible); -// mListView->setFocus(); // TODO use focus in - if (mListView->selectionModel()) { - connect(mListView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), - this, - SLOT(selectionChanged(QItemSelection, QItemSelection))); -// // flag to indicate that selection mode changed, "edit" sub-menu update needed -// mFolderContentChanged = true; - } -} - -// --------------------------------------------------------------------------- - -void FileBrowserView::deActivateSelectionMode() -{ - disconnect(mListView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), - this, - SLOT(selectionChanged(QItemSelection, QItemSelection))); - mListView->setSelectionMode(HbListView::NoSelection); - connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex))); - editUnselectAll(); - // flag to indicate that selection mode changed, "edit" sub-menu update needed - mFolderContentChanged = true; -} - -// --------------------------------------------------------------------------- diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/main.cpp --- a/filebrowser/ui/src/main.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/ui/src/main.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -18,13 +18,13 @@ #include #include -#include "filebrowsermainwindow.h" +#include "fbmainwindow.h" int main(int argc, char *argv[]) { HbApplication app(argc, argv); - FileBrowserMainWindow window; + FbMainWindow window; window.init(); int result = app.exec(); diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/notifications.cpp --- a/filebrowser/ui/src/notifications.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/ui/src/notifications.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -38,7 +38,7 @@ void Notifications::showAboutNote() { showMessageBox(HbMessageBox::MessageTypeInformation, - "Version 5.0.1 - 21st May 2010. Copyright © 2010 Nokia Corporation" + "Version 5.1.0 - 18th June 2010. Copyright © 2010 Nokia Corporation" "and/or its subsidiary(-ies). All rights reserved." "Licensed under Eclipse Public License v1.0.", "About File Browser" @@ -49,21 +49,23 @@ void Notifications::showInformationNote(const QString &text, const QString &title) { - showMessageBox(HbMessageBox::MessageTypeInformation, text, title, false); + showMessageBox(HbMessageBox::MessageTypeInformation, text, title, 3000); } // --------------------------------------------------------------------------- void Notifications::showErrorNote(const QString &text, bool noTimeout) { - showMessageBox(HbMessageBox::MessageTypeWarning, text, "", noTimeout ? HbPopup::NoTimeout : HbPopup::StandardTimeout); + showMessageBox(HbMessageBox::MessageTypeWarning, text, "", + noTimeout ? HbPopup::NoTimeout : 3000 /*HbPopup::StandardTimeout*/); } // --------------------------------------------------------------------------- void Notifications::showConfirmationNote(const QString &text, bool noTimeout) { - showMessageBox(HbMessageBox::MessageTypeWarning, text, "", noTimeout ? HbPopup::NoTimeout : HbPopup::ConfirmationNoteTimeout); + showMessageBox(HbMessageBox::MessageTypeInformation, text, "", + noTimeout ? HbPopup::NoTimeout : 3000 /*HbPopup::ConfirmationNoteTimeout*/); } // --------------------------------------------------------------------------- diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/src/settingsview.cpp --- a/filebrowser/ui/src/settingsview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/ui/src/settingsview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -16,7 +16,6 @@ */ #include "settingsview.h" -#include "filebrowsermainwindow.h" #include "enginewrapper.h" #include "filebrowsersettings.h" @@ -37,8 +36,7 @@ const QString acceptActionText = "OK"; const QString rejectActionText = "Cancel"; -SettingsView::SettingsView(FileBrowserMainWindow &mainWindow, EngineWrapper &engineWrapper) : - mMainWindow(mainWindow), +SettingsView::SettingsView(EngineWrapper &engineWrapper) : mEngineWrapper(engineWrapper), mForm(0), mDisplayModeItem(0), @@ -229,35 +227,6 @@ { } -// -//void SettingsView::displayModeChanged() -//{ -//} -// -//void SettingsView::fileViewChanged() -//{ -// -//} -// -//void SettingsView::subDirectoryInfoChanged() -//{ -//} -// -//void SettingsView::associatedIconsChanged() -//{ -//} -// -//void SettingsView::rememberFolderOnExitChanged() -//{ -//} -// -//void SettingsView::rememberLastFolderChanged() -//{ -//} -// -//void SettingsView::showToolbarChanged() -//{ -//} void SettingsView::accept() { diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/ui.pro --- a/filebrowser/ui/ui.pro Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/ui/ui.pro Tue Jul 06 14:17:03 2010 +0300 @@ -21,9 +21,14 @@ load(hb.prf) symbian:CONFIG -= symbian_i18n -HEADERS += ./inc/filebrowsermainwindow.h \ - ./inc/filebrowserview.h \ - ./inc/filebrowsermodel.h \ +HEADERS += ./inc/fbmainwindow.h \ + ./inc/fbdrivelistviewitem.h \ + ./inc/fbdrivemodel.h \ + ./inc/fbdriveview.h \ + ./inc/fbfilelistviewitem.h \ + ./inc/fbfilemodel.h \ + ./inc/fbfileview.h \ + ./inc/filebrowsersortfilterproxymodel.h \ ./inc/menuaction.h \ ./inc/filebrowsersettings.h \ ./inc/settingsview.h \ @@ -34,9 +39,14 @@ ./inc/fileentry.h \ ./inc/driveentry.h SOURCES += ./src/main.cpp \ - ./src/filebrowsermainwindow.cpp \ - ./src/filebrowserview.cpp \ - ./src/filebrowsermodel.cpp \ + ./src/fbmainwindow.cpp \ + ./src/fbdrivelistviewitem.cpp \ + ./src/fbdrivemodel.cpp \ + ./src/fbdriveview.cpp \ + ./src/fbfilelistviewitem.cpp \ + ./src/fbfilemodel.cpp \ + ./src/fbfileview.cpp \ + ./src/filebrowsersortfilterproxymodel.cpp \ ./src/settingsview.cpp \ ./src/editorview.cpp \ ./src/searchview.cpp \ diff -r e0ec97ec3cc4 -r 98924d2efce9 filebrowser/ui/ui.qrc --- a/filebrowser/ui/ui.qrc Wed Jun 23 18:13:31 2010 +0300 +++ b/filebrowser/ui/ui.qrc Tue Jul 06 14:17:03 2010 +0300 @@ -2,5 +2,6 @@ ../icons/qgn_indi_tb_filebrowser_folder_parent.svg ../icons/qgn_indi_tb_filebrowser_find.svg + ../icons/qgn_indi_tb_filebrowser_selection_active.svg diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/HtiAdmin/inc/HtiAdminAppUi.h --- a/htiui/HtiAdmin/inc/HtiAdminAppUi.h Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/HtiAdmin/inc/HtiAdminAppUi.h Tue Jul 06 14:17:03 2010 +0300 @@ -135,6 +135,8 @@ void HandleBtSearch(); void HandleIPConnect(); void HandleIPListen(); + + void StartTimer(); private: diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/HtiAdmin/src/HtiAdminAppUi.cpp --- a/htiui/HtiAdmin/src/HtiAdminAppUi.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/HtiAdmin/src/HtiAdminAppUi.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -109,6 +109,7 @@ iAppView->SetSelectedCommCaption( KHtiSelectedCommCaption ); UpdateVersion(); UpdateStatusL(); + StartTimer(); iHtiCfg = CHtiCfg::NewL(); UpdateAutoStartStatus(); // uses iHtiCfg UpdateSelectedComm(); // uses iHtiCfg @@ -810,6 +811,7 @@ { UpdateStatusL(); UpdateAutoStartStatus(); + StartTimer(); } else { @@ -889,15 +891,6 @@ { _LIT( KTxt, "Running" ); iAppView->SetStatus( KTxt ); - - // start timer to watch the status - if ( !iPeriodic ) - { - iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard ); - iPeriodic->Start( 5 * 1000 * 1000, - 5 * 1000 * 1000, - TCallBack( TimerCallBackL, this ) ); - } } break; @@ -906,7 +899,6 @@ { _LIT( KTxt, "Stopped" ); iAppView->SetStatus( KTxt ); - KillTimer(); } break; @@ -914,16 +906,11 @@ { _LIT( KTxt, "Panic" ); iAppView->SetStatus( KTxt ); - KillTimer(); } break; }; prs.Close(); } - else - { - KillTimer(); - } } void CHtiAdminAppUi::UpdateAutoStartStatus() @@ -1083,6 +1070,18 @@ } } +void CHtiAdminAppUi::StartTimer() + { + // start timer to watch the status + if ( !iPeriodic ) + { + iPeriodic = CPeriodic::NewL( CActive::EPriorityIdle ); + iPeriodic->Start( 1 * 1000 * 1000, + 10 * 1000 * 1000, + TCallBack( TimerCallBackL, this ) ); + } + } + void CHtiAdminAppUi::KillTimer() { if ( iPeriodic ) diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/HtiAdminQt/chtiadminengine.cpp --- a/htiui/HtiAdminQt/chtiadminengine.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/HtiAdminQt/chtiadminengine.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -121,6 +121,7 @@ iHtiCfg = CHtiCfg::NewL(); CheckStatusesL(); + StartTimer(); } // --------------------------------------------------------------------------- @@ -594,15 +595,6 @@ case EExitPending: { iEngineWrapper->updateStatus(HtiEngineWrapper::Running); - - // start timer to watch the status - if ( !iPeriodic ) - { - iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard ); - iPeriodic->Start( 5 * 1000 * 1000, - 5 * 1000 * 1000, - TCallBack( TimerCallBackL, this ) ); - } } break; @@ -610,23 +602,17 @@ case EExitTerminate: { iEngineWrapper->updateStatus(HtiEngineWrapper::Stopped); - KillTimer(); } break; case EExitPanic: { iEngineWrapper->updateStatus(HtiEngineWrapper::Panic); - KillTimer(); } break; }; prs.Close(); } - else - { - KillTimer(); - } } // --------------------------------------------------------------------------- @@ -647,6 +633,18 @@ } // --------------------------------------------------------------------------- +void CHtiAdminEngine::StartTimer() + { + // start timer to watch the status + if ( !iPeriodic ) + { + iPeriodic = CPeriodic::NewL( CActive::EPriorityIdle ); + iPeriodic->Start( 1 * 1000 * 1000, + 10 * 1000 * 1000, + TCallBack( TimerCallBackL, this ) ); + } + } +// --------------------------------------------------------------------------- void CHtiAdminEngine::KillTimer() { if ( iPeriodic ) diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/HtiAdminQt/chtiadminengine.h --- a/htiui/HtiAdminQt/chtiadminengine.h Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/HtiAdminQt/chtiadminengine.h Tue Jul 06 14:17:03 2010 +0300 @@ -160,6 +160,8 @@ void SetCfgParamL(const TDesC& aParamName, const TDesC& aParamValue, const TDesC& aFileName); void GetCfgParamL(const TDesC& aParamName, TDes& aParamValue, const TDesC& aFileName); + void StartTimer(); + private: // Enginewrapper that is used for communicating between QT and Symbian HtiEngineWrapper* iEngineWrapper; diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/HtiServicePlugins/HtiCameraServicePlugin/engine/inc/EngineVideoRecording.h --- a/htiui/HtiServicePlugins/HtiCameraServicePlugin/engine/inc/EngineVideoRecording.h Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/HtiServicePlugins/HtiCameraServicePlugin/engine/inc/EngineVideoRecording.h Tue Jul 06 14:17:03 2010 +0300 @@ -356,12 +356,12 @@ TInt aError ); void ViewFinderFrameReady( - CFbsBitmap& aFrame ){}; + CFbsBitmap& /*aFrame*/ ){}; void ImageReady( - CFbsBitmap* aBitmap, - HBufC8* aData, - TInt aError ){}; + CFbsBitmap* /*aBitmap*/, + HBufC8* /*aData*/, + TInt /*aError*/ ){}; void FrameBufferReady( MFrameBuffer* /*aFrameBuffer*/, @@ -371,11 +371,11 @@ void HandleEvent(const TECAMEvent& aEvent); - void ViewFinderReady(MCameraBuffer& aCameraBuffer,TInt aError){}; + void ViewFinderReady(MCameraBuffer& /*aCameraBuffer*/,TInt /*aError*/){}; - void ImageBufferReady(MCameraBuffer& aCameraBuffer,TInt aError){}; + void ImageBufferReady(MCameraBuffer& /*aCameraBuffer*/,TInt /*aError*/){}; - void VideoBufferReady(MCameraBuffer& aCameraBuffer,TInt aError){}; + void VideoBufferReady(MCameraBuffer& /*aCameraBuffer*/,TInt /*aError*/){}; protected: /** diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/HtiServicePlugins/HtiCameraServicePlugin/inc/HtiCameraServicePlugin.h --- a/htiui/HtiServicePlugins/HtiCameraServicePlugin/inc/HtiCameraServicePlugin.h Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/HtiServicePlugins/HtiCameraServicePlugin/inc/HtiCameraServicePlugin.h Tue Jul 06 14:17:03 2010 +0300 @@ -49,7 +49,7 @@ // commands enum TCommands { - ECmdInit = 0x01, + ECmdInitialize = 0x01, ECmdPrepareVideoRecording = 0x02, ECmdStartVideoRecording = 0x05, ECmdPausingVideoRecording = 0x06, @@ -59,8 +59,8 @@ ECmdGetZoom = 0x0a, ECmdSetZoom = 0x0b, - - EResultOk = 0xFF // only for response message + ECmdUninitialize = 0x51, + EResultOk = 0xFF // only for response message }; @@ -168,7 +168,8 @@ virtual void MevroVideoRecordingComplete(TInt aError); private: - void HandleInitCmdL(const TDesC8& aData); + void HandleInitializeCmdL(const TDesC8& aData); + void HandleUninitializeCmdL(const TDesC8& aData); void HandlePrepareVideoRecordingCmdL(const TDesC8& aData); void HandleStartVideoRecordingCmdL( const TDesC8& aData ); void HandlePausingVideoRecordingCmdL( const TDesC8& aData ); diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/HtiServicePlugins/HtiCameraServicePlugin/src/HtiCameraServicePlugin.cpp --- a/htiui/HtiServicePlugins/HtiCameraServicePlugin/src/HtiCameraServicePlugin.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/HtiServicePlugins/HtiCameraServicePlugin/src/HtiCameraServicePlugin.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -44,6 +44,7 @@ _LIT8( KErrorNoCommand, "ERROR: No command given" ); _LIT8( KErrorUnknownCmd, "ERROR: Unknown Camera Service command" ); _LIT8( KErrorInitFailed, "ERROR: Failed to init"); +_LIT8( KErrorUninitialized, "ERROR: Uninitialized"); _LIT8( KErrInvalidateParameters, "ERROR: Invalidate parameters"); _LIT8( KErrQualityLevel, "ERROR: Invalidate quality level"); _LIT8( KErrorPrepareVideoRecordingFailed, "ERROR: Prepare video recording failed"); @@ -83,7 +84,6 @@ void CHtiCameraServicePlugin::ConstructL() { HTI_LOG_TEXT( "CHtiCameraServicePlugin::ConstructL" ); - iVideoRecordingEngine = CEngineVideoRecording::NewL(*this, 0); iWaiter = new ( ELeave ) CActiveSchedulerWait; } @@ -106,8 +106,11 @@ // Destructor CHtiCameraServicePlugin::~CHtiCameraServicePlugin() { - delete iVideoRecordingEngine; - iVideoRecordingEngine = NULL; + if(iVideoRecordingEngine) + { + delete iVideoRecordingEngine; + iVideoRecordingEngine = NULL; + } delete iWaiter; iWaiter = NULL; @@ -146,8 +149,11 @@ switch (command) { - case ECmdInit: - TRAP(err, HandleInitCmdL(aMessage.Right( aMessage.Length() - 1 ))); + case ECmdInitialize: + TRAP(err, HandleInitializeCmdL(aMessage.Right( aMessage.Length() - 1 ))); + break; + case ECmdUninitialize: + TRAP(err, HandleUninitializeCmdL(aMessage.Right( aMessage.Length() - 1 ))); break; case ECmdPrepareVideoRecording: TRAP(err, HandlePrepareVideoRecordingCmdL(aMessage.Right( aMessage.Length() - 1 ))); @@ -187,9 +193,9 @@ HTI_LOG_FUNC_OUT( "CHtiCameraServicePlugin::ProcessMessageL" ); } -void CHtiCameraServicePlugin::HandleInitCmdL( const TDesC8& aData ) +void CHtiCameraServicePlugin::HandleInitializeCmdL( const TDesC8& aData ) { - HTI_LOG_FUNC_IN( "CHtiCameraServicePlugin::HandleInitCmdL" ); + HTI_LOG_FUNC_IN( "CHtiCameraServicePlugin::HandleInitializeCmdL" ); if(aData.Length() != 0) { SendErrorMessageL(KErrArgument, KErrInvalidateParameters); @@ -197,6 +203,13 @@ } HTI_LOG_TEXT("Initializes Camera Application Engine"); + if(iVideoRecordingEngine) + { + delete iVideoRecordingEngine; + iVideoRecordingEngine = NULL; + } + + iVideoRecordingEngine = CEngineVideoRecording::NewL(*this, 0); iVideoRecordingEngine->InitL(); iWaiter->Start(); if(iError != KErrNone) @@ -211,9 +224,30 @@ SendOkMsgL(KNullDesC8); } - HTI_LOG_FUNC_OUT( "CHtiCameraServicePlugin::HandleInitCmdL" ); + HTI_LOG_FUNC_OUT( "CHtiCameraServicePlugin::HandleInitializeCmdL" ); } +void CHtiCameraServicePlugin::HandleUninitializeCmdL(const TDesC8& aData) + { + HTI_LOG_FUNC_IN( "CHtiCameraServicePlugin::HandleUninitializeCmdL" ); + if(aData.Length() != 0) + { + SendErrorMessageL(KErrArgument, KErrInvalidateParameters); + return; + } + + if(iVideoRecordingEngine == NULL) + { + SendErrorMessageL(KErrNotReady, KErrorUninitialized); + return; + } + + delete iVideoRecordingEngine; + iVideoRecordingEngine = NULL; + + SendOkMsgL(KNullDesC8); + HTI_LOG_FUNC_OUT( "CHtiCameraServicePlugin::HandleUninitializeCmdL" ); + } void CHtiCameraServicePlugin::HandlePrepareVideoRecordingCmdL( const TDesC8& aData ) { @@ -224,6 +258,12 @@ return; } + if(iVideoRecordingEngine == NULL) + { + SendErrorMessageL(KErrNotReady, KErrorUninitialized); + return; + } + TInt qualityLevelIndex = aData[0]; if(qualityLevelIndex < 0 || qualityLevelIndex > iVideoRecordingEngine->VideoQualityCount() -1) { @@ -267,6 +307,12 @@ return; } + if(iVideoRecordingEngine == NULL) + { + SendErrorMessageL(KErrNotReady, KErrorUninitialized); + return; + } + HTI_LOG_TEXT("Start video recording..."); iVideoRecordingEngine->StartVideoRecording(); @@ -291,6 +337,12 @@ return; } + if(iVideoRecordingEngine == NULL) + { + SendErrorMessageL(KErrNotReady, KErrorUninitialized); + return; + } + HTI_LOG_TEXT("Pausing video recording"); iVideoRecordingEngine->PauseVideoRecording(); if(iError != KErrNone) @@ -313,6 +365,12 @@ return; } + if(iVideoRecordingEngine == NULL) + { + SendErrorMessageL(KErrNotReady, KErrorUninitialized); + return; + } + HTI_LOG_TEXT("Resume video recording..."); iVideoRecordingEngine->ResumeVideoRecording(); @@ -336,6 +394,12 @@ return; } + if(iVideoRecordingEngine == NULL) + { + SendErrorMessageL(KErrNotReady, KErrorUninitialized); + return; + } + HTI_LOG_TEXT("Stop video recording"); iVideoRecordingEngine->StopVideoRecording(); if(iError != KErrNone) @@ -358,6 +422,12 @@ return; } + if(iVideoRecordingEngine == NULL) + { + SendErrorMessageL(KErrNotReady, KErrorUninitialized); + return; + } + HTI_LOG_TEXT("Close video recording"); iVideoRecordingEngine->CloseVideoRecording(); SendOkMsgL(KNullDesC8); @@ -373,6 +443,12 @@ return; } + if(iVideoRecordingEngine == NULL) + { + SendErrorMessageL(KErrNotReady, KErrorUninitialized); + return; + } + TUint8 zoomMode = (TUint8)iVideoRecordingEngine->ZoomMode(); HTI_LOG_FORMAT("Current zoom mode: %d", zoomMode); @@ -404,6 +480,12 @@ return; } + if(iVideoRecordingEngine == NULL) + { + SendErrorMessageL(KErrNotReady, KErrorUninitialized); + return; + } + CEngineVideoRecording::TZoomMode zoomMode = (CEngineVideoRecording::TZoomMode)aData[0]; HTI_LOG_FORMAT("Set zoom mode: %d", zoomMode); TRAPD(err, iVideoRecordingEngine->SetZoomModeL(zoomMode)); @@ -515,7 +597,7 @@ { HTI_LOG_FUNC_IN( "CHtiCameraServicePlugin::MevroInitComplete" ); HTI_LOG_FORMAT("aError = %d", aError); - iError = aError; + iError = aError; iWaiter->AsyncStop(); HTI_LOG_FUNC_OUT( "CHtiCameraServicePlugin::MevroInitComplete" ); } diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/HtiServicePlugins/HtiSysInfoServicePlugin/group/HtiSysInfoServicePlugin.mmp --- a/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/group/HtiSysInfoServicePlugin.mmp Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/group/HtiSysInfoServicePlugin.mmp Tue Jul 06 14:17:03 2010 +0300 @@ -65,6 +65,7 @@ LIBRARY sysutil.lib LIBRARY tzclient.lib LIBRARY flogger.lib +LIBRARY featmgr.lib // Chinese support SMPSAFE diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/HtiServicePlugins/HtiSysInfoServicePlugin/inc/HtiSysInfoServicePlugin.h --- a/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/inc/HtiSysInfoServicePlugin.h Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/inc/HtiSysInfoServicePlugin.h Tue Jul 06 14:17:03 2010 +0300 @@ -98,7 +98,9 @@ void HandleHsdpaCommandL( const TDesC8& aMessage ); void HandleUpdateMediaGalleryL( const TDesC8& aMessage ); void HandleActivateSkinL( const TDesC8& aMessage ); + void HandleSetLanguageL( const TDesC8& aMessage ); + void SetDefaultNumberModeL(TInt aMode, TInt aNbrModeType); void ParseTimeDataL( const TDesC8& aTimeData, TTime& aResult ); TInt CleanUpTempFiles(); TBool CanTurnBluetoothOnL( const TBool aUseForce ); diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/HtiServicePlugins/HtiSysInfoServicePlugin/src/HtiSysInfoServicePlugin.cpp --- a/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/src/HtiSysInfoServicePlugin.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/HtiServicePlugins/HtiSysInfoServicePlugin/src/HtiSysInfoServicePlugin.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -31,6 +31,10 @@ #include #include #include +#include +#include //For chinese input modes +#include +#include #include #include #include @@ -61,6 +65,8 @@ const TInt KMaxBtNameLength = 30; const TInt KDateTimeFormatCmdLength = 6; +const TInt KFepChineseInputModeLength = 10; + _LIT( KTempFilePath, "\\" ); _LIT( KTempFileName, "HtiTempFile.tmp" ); _LIT( KMatchFileName, "HtiTempFile.tmp*" ); @@ -83,6 +89,7 @@ _LIT8( KErrDescrSysUtil, "SysUtil failed" ); _LIT8( KErrDescrSetTime, "Setting time failed" ); _LIT8( KErrDescrDateTimeFormat, "Setting date and time formats failed" ); +_LIT8( KErrDescrSetLanguage, "Setting language failed"); _LIT8( KErrDescrGetNetworkModes, "Getting network modes failed" ); _LIT8( KErrDescrSetNetworkMode, "Setting network mode failed" ); _LIT8( KErrDescrIrActivation, "IR activation failed" ); @@ -130,6 +137,8 @@ ESysInfoSetHomeTime = 0x20, ESysInfoGetHomeTime = 0x21, ESetDateTimeFormat = 0x22, + + ESetLanguage = 0x25, ELightStatus = 0x30, ELightOn = 0x31, @@ -164,6 +173,17 @@ EActivateSkin = 0x80 }; +enum TGSNumberModes + { + EGSNbrModeLatin, EGSNbrModeArabic = 1, EGSNbrModeIndic = 1 + }; + +// Number mode type +enum TGSNumberModeType + { + EGSNbrModeTypeArabic, EGSNbrModeTypeIndic, EGSNbrModeTypeEasternArabic + // for Urdu & Farsi languages + }; //------------------------------------------------------------------------------ // Create instance of concrete ECOM interface implementation @@ -211,6 +231,8 @@ iAllowSSProperty.Close(); #endif delete iAllowSSSubscriber; + + FeatureManager::UnInitializeLib(); } //------------------------------------------------------------------------------ @@ -221,6 +243,8 @@ HTI_LOG_TEXT( "CHtiSysInfoServicePlugin::ConstructL" ); User::LeaveIfError( iFs.Connect() ); iFileMan = CFileMan::NewL( iFs ); + + FeatureManager::InitializeLibL(); } //------------------------------------------------------------------------------ @@ -352,6 +376,12 @@ HandleSetDateTimeFormatL( aMessage ); } break; + case ESetLanguage: + { + HTI_LOG_TEXT("ESetLanguage"); + HandleSetLanguageL( aMessage); + } + break; case ELightStatus: case ELightOn: case ELightOff: @@ -2851,6 +2881,160 @@ } //------------------------------------------------------------------------------ +// CHtiSysInfoServicePlugin::HandleSetLanguageL +//------------------------------------------------------------------------------ +void CHtiSysInfoServicePlugin::HandleSetLanguageL( const TDesC8& aMessage ) + { + HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleSetLanguageL" ); + if ( aMessage.Length() != 3 ) + { + iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, + KErrDescrArgument, KSysInfoServiceUid ); + return; + } + + TInt language = aMessage[1] + ( aMessage[2] << 8 ); + if(language < 0) + { + iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, + KErrDescrSetLanguage, KSysInfoServiceUid ); + return; + } + HTI_LOG_FORMAT( "Set language to %d", language ); + + // Never set Language code 0 to HAL + if (language != 0) + { + User::LeaveIfError(HAL::Set(HAL::ELanguageIndex, language)); + } + + CRepository* commonEngineRepository = CRepository::NewL( + KCRUidCommonEngineKeys); + CleanupStack::PushL(commonEngineRepository); + + User::LeaveIfError(commonEngineRepository->Set(KGSDisplayTxtLang, language)); + + CleanupStack::PopAndDestroy(); + + TBool nbrModeSaved = EFalse; + if (language == ELangArabic || User::Language() == ELangArabic) + { + //numberMode = EGSNumberModeArabicIndic; + SetDefaultNumberModeL(EGSNbrModeArabic, EGSNbrModeTypeArabic); + nbrModeSaved = ETrue; + } + else if ((language == ELangUrdu || User::Language() == ELangUrdu) + || (language == ELangFarsi || User::Language() == ELangFarsi)) + { + //numberMode = EGSNumberModeEasternArabicIndic; + SetDefaultNumberModeL(EGSNbrModeLatin, EGSNbrModeTypeEasternArabic); + nbrModeSaved = ETrue; + } + else if (language == ELangHindi || User::Language() == ELangHindi + || language == ELangMarathi || User::Language() == ELangMarathi) + { + //numberMode = EGSNumberModeIndic; + SetDefaultNumberModeL(EGSNbrModeLatin, EGSNbrModeTypeIndic); + nbrModeSaved = ETrue; + } + + //if number mode is not set above, then set it to Latin with respective + //number mode types. This part might be executed when Automatic is + //selected and the SIM card does not support the language. + if (!nbrModeSaved) + { + TInt nbrModeType = EGSNbrModeTypeIndic; + if (language == ELangArabic || User::Language() == ELangArabic) + { + nbrModeType = EGSNbrModeTypeArabic; + } + else if ((language == ELangUrdu || User::Language() == ELangUrdu) + || (language == ELangFarsi || User::Language() == ELangFarsi)) + { + nbrModeType = EGSNbrModeTypeEasternArabic; + } + + //EGSNumberModeLatin is true in both cases; + SetDefaultNumberModeL(EGSNbrModeLatin, nbrModeType); + } + + // Change input language + CRepository* aknFepRepository = CRepository::NewL( KCRUidAknFep ); + CleanupStack::PushL(aknFepRepository); + User::LeaveIfError( aknFepRepository->Set( KAknFepInputTxtLang, + language )); + // Change input method for Chinese variants + if( FeatureManager::FeatureSupported( KFeatureIdChinese ) ) + { + TBuf conversion; + if( language == ELangPrcChinese ) + { + conversion.Num( EPinyin, EHex ); + User::LeaveIfError( aknFepRepository->Set( KAknFepChineseInputMode, conversion ) ); + } + else if( language == ELangHongKongChinese ) + { + conversion.Num( EStroke, EHex ); + User::LeaveIfError( aknFepRepository->Set( KAknFepChineseInputMode, conversion ) ); + } + else if( language == ELangTaiwanChinese ) + { + conversion.Num( EZhuyin, EHex ); + User::LeaveIfError( aknFepRepository->Set( KAknFepChineseInputMode, conversion ) ); + } + } + CleanupStack::PopAndDestroy(); + + iReply = HBufC8::NewL( 1 ); + iReply->Des().Append( 0 ); + HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleSetLanguageL" ); + } + +void CHtiSysInfoServicePlugin::SetDefaultNumberModeL(TInt aMode, TInt aNbrModeType) + { + + CRepository* localeRepository = CRepository::NewL(KCRUidLocaleSettings); + CleanupStack::PushL(localeRepository); + if (aNbrModeType == EGSNbrModeTypeArabic || aNbrModeType + == EGSNbrModeTypeEasternArabic) + { + localeRepository->Set(KSettingsDefaultNumberMode, aMode); + } + else + { + localeRepository->Set(KSettingsIndicDefaultNumberMode, aMode); + } + CleanupStack::PopAndDestroy(); + + TLocale locale; + if (aMode == EGSNbrModeLatin) + { + locale.SetDigitType(EDigitTypeWestern); + } + else + { + //if aMode <> EGSNbrModeLatin, then it should be either latin or arabic. However + //as EGSNbrModeArabic and EGsNbrModeIndic both have a value = 1, we can't use + //that constant for below comparison. Hence, need to depend on the 2nd param. + switch (aNbrModeType) + { + case EGSNbrModeTypeArabic: + locale.SetDigitType(EDigitTypeArabicIndic); + break; + case EGSNbrModeTypeIndic: + locale.SetDigitType(EDigitTypeDevanagari); + break; + case EGSNbrModeTypeEasternArabic: + locale.SetDigitType(EDigitTypeEasternArabicIndic); + break; + default: + break; + } + } + + locale.Set(); + } +//------------------------------------------------------------------------------ // CHtiSysInfoServicePlugin::ParseTimeDataL //------------------------------------------------------------------------------ void CHtiSysInfoServicePlugin::ParseTimeDataL( const TDesC8& aTimeData, diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/sis/HTI_S60-10_1.pkg --- a/htiui/sis/HTI_S60-10_1.pkg Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/sis/HTI_S60-10_1.pkg Tue Jul 06 14:17:03 2010 +0300 @@ -18,7 +18,7 @@ &EN ; Using UID of HtiFramework project -#{"HTI"},(0x1020DEB6),2,24,0 +#{"HTI"},(0x1020DEB6),2,25,0 ; Series60 product id for S60 5.2 [0x20022E6D], 0, 0, 0, {"Series60ProductID"} @@ -96,6 +96,9 @@ ; HTI watchdog "\epoc32\release\armv5\urel\HtiWatchDog.exe" - "!:\sys\bin\HtiWatchDog.exe" +; HTI Restart +"\epoc32\release\armv5\urel\HtiRestart.exe" - "!:\sys\bin\HtiRestart.exe" + ; HTI device reboot "\epoc32\release\armv5\urel\HtiDeviceRebootUI.exe" - "!:\sys\bin\HtiDeviceRebootUI.exe" diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/sis/HTI_S60-52.pkg --- a/htiui/sis/HTI_S60-52.pkg Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/sis/HTI_S60-52.pkg Tue Jul 06 14:17:03 2010 +0300 @@ -18,7 +18,7 @@ &EN ; Using UID of HtiFramework project -#{"HTI"},(0x1020DEB6),2,24,0 +#{"HTI"},(0x1020DEB6),2,25,0 ; Series60 product id for S60 5.2 [0x20022E6D], 0, 0, 0, {"Series60ProductID"} @@ -99,6 +99,9 @@ ; HTI watchdog "\epoc32\release\armv5\urel\HtiWatchDog.exe" - "!:\sys\bin\HtiWatchDog.exe" +; HTI Restart +"\epoc32\release\armv5\urel\HtiRestart.exe" - "!:\sys\bin\HtiRestart.exe" + ; HTI device reboot "\epoc32\release\armv5\urel\HtiDeviceRebootUI.exe" - "!:\sys\bin\HtiDeviceRebootUI.exe" diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/sis/HTI_S60_Upgrade-10_1.pkg --- a/htiui/sis/HTI_S60_Upgrade-10_1.pkg Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/sis/HTI_S60_Upgrade-10_1.pkg Tue Jul 06 14:17:03 2010 +0300 @@ -18,7 +18,7 @@ &EN ; Using UID of HtiFramework project -#{"HTI"},(0x1020DEB6),2,24,0,TYPE=SA,RU +#{"HTI"},(0x1020DEB6),2,25,0,TYPE=SA,RU ; Series60 product id for S60 5.2 [0x20022E6D], 0, 0, 0, {"Series60ProductID"} @@ -96,6 +96,9 @@ ; HTI watchdog "\epoc32\release\armv5\urel\HtiWatchDog.exe" - "!:\sys\bin\HtiWatchDog.exe" +; HTI Restart +"\epoc32\release\armv5\urel\HtiRestart.exe" - "!:\sys\bin\HtiRestart.exe" + ; HTI device reboot "\epoc32\release\armv5\urel\HtiDeviceRebootUI.exe" - "!:\sys\bin\HtiDeviceRebootUI.exe" diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/sis/HTI_S60_Upgrade-52.pkg --- a/htiui/sis/HTI_S60_Upgrade-52.pkg Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/sis/HTI_S60_Upgrade-52.pkg Tue Jul 06 14:17:03 2010 +0300 @@ -18,7 +18,7 @@ &EN ; Using UID of HtiFramework project -#{"HTI"},(0x1020DEB6),2,24,0,TYPE=SA,RU +#{"HTI"},(0x1020DEB6),2,25,0,TYPE=SA,RU ; Series60 product id for S60 5.2 [0x20022E6D], 0, 0, 0, {"Series60ProductID"} @@ -99,6 +99,9 @@ ; HTI watchdog "\epoc32\release\armv5\urel\HtiWatchDog.exe" - "!:\sys\bin\HtiWatchDog.exe" +; HTI Restart +"\epoc32\release\armv5\urel\HtiRestart.exe" - "!:\sys\bin\HtiRestart.exe" + ; HTI device reboot "\epoc32\release\armv5\urel\HtiDeviceRebootUI.exe" - "!:\sys\bin\HtiDeviceRebootUI.exe" diff -r e0ec97ec3cc4 -r 98924d2efce9 htiui/sis/HTI_stub.pkg --- a/htiui/sis/HTI_stub.pkg Wed Jun 23 18:13:31 2010 +0300 +++ b/htiui/sis/HTI_stub.pkg Tue Jul 06 14:17:03 2010 +0300 @@ -18,7 +18,7 @@ &EN ; Using UID of HtiFramework project -#{"HTI"},(0x1020DEB6),2,24,0 +#{"HTI"},(0x1020DEB6),2,25,0 ; Localised Vendor name %{"Nokia"} @@ -96,6 +96,9 @@ ; HTI watchdog ""- "z:\sys\bin\HtiWatchDog.exe" +; HTI Restart +""- "z:\sys\bin\HtiRestart.exe" + ; HTI device reboot ""- "z:\sys\bin\HtiDeviceRebootUI.exe" diff -r e0ec97ec3cc4 -r 98924d2efce9 launcher/launcher.pro --- a/launcher/launcher.pro Wed Jun 23 18:13:31 2010 +0300 +++ b/launcher/launcher.pro Tue Jul 06 14:17:03 2010 +0300 @@ -45,7 +45,8 @@ RSS_RULES += "group_name = \"RnD Tools\""; - LIBS += -lapgrfx -lPlatformEnv -lxqutils -lxmlframework -lbafl -lshareui + LIBS += -lapgrfx -lPlatformEnv -lxqutils -lxmlframework -lbafl -lshareui -lws32 -lapparc -lefsrv -lcone + TARGET.CAPABILITY = ReadUserData ReadDeviceData WriteUserData WriteDeviceData PowerMgmt AllFiles diff -r e0ec97ec3cc4 -r 98924d2efce9 launcher/rom/Launcher.iby --- a/launcher/rom/Launcher.iby Wed Jun 23 18:13:31 2010 +0300 +++ b/launcher/rom/Launcher.iby Tue Jul 06 14:17:03 2010 +0300 @@ -1,4 +1,4 @@ -//* +/* * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available diff -r e0ec97ec3cc4 -r 98924d2efce9 layers.sysdef.xml --- a/layers.sysdef.xml Wed Jun 23 18:13:31 2010 +0300 +++ b/layers.sysdef.xml Tue Jul 06 14:17:03 2010 +0300 @@ -34,7 +34,7 @@ - + diff -r e0ec97ec3cc4 -r 98924d2efce9 loadgen/engine/inc/loadgen_netconn.h --- a/loadgen/engine/inc/loadgen_netconn.h Wed Jun 23 18:13:31 2010 +0300 +++ b/loadgen/engine/inc/loadgen_netconn.h Tue Jul 06 14:17:03 2010 +0300 @@ -22,7 +22,8 @@ // INCLUDES #include #include -#include +//#include +//#include #include "loadgen_loadbase.h" #include "loadgen_loadattributes.h" diff -r e0ec97ec3cc4 -r 98924d2efce9 loadgen/group/bld.inf --- a/loadgen/group/bld.inf Wed Jun 23 18:13:31 2010 +0300 +++ b/loadgen/group/bld.inf Tue Jul 06 14:17:03 2010 +0300 @@ -1,13 +1,13 @@ // ============================================================================ // * Makefile for building: group -// * Generated by qmake (2.01a) (Qt 4.6.1) on: 2010-02-23T09:27:08 +// * Generated by qmake (2.01a) (Qt 4.6.3) on: 2010-06-17T13:18:03 // * This file is generated by qmake and should not be modified by the // * user. // * Project: group.pro // * Template: subdirs // ============================================================================ -#define BLD_INF_GROUP_0010C4D8 +#define BLD_INF_GROUP_037FC092 prj_platforms @@ -15,10 +15,17 @@ WINSCW GCCE ARMV5 ARMV6 #include "bld_generic.inf" -#include "../ui/avkon/group/bld.inf" prj_mmpfiles prj_extensions + +#if defined(WINSCW) +#endif + +START EXTENSION qt/qmake_store_build +END + + diff -r e0ec97ec3cc4 -r 98924d2efce9 loadgen/ui/hb/hb.pro --- a/loadgen/ui/hb/hb.pro Wed Jun 23 18:13:31 2010 +0300 +++ b/loadgen/ui/hb/hb.pro Tue Jul 06 14:17:03 2010 +0300 @@ -1,104 +1,100 @@ -# # 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: -# -# - - +# Description: TEMPLATE = app TARGET = LoadGen DEPENDPATH += . - -INCLUDEPATH += . /inc +INCLUDEPATH += . \ + /inc INCLUDEPATH += ./inc \ - ../../engine/inc \ - + ../../engine/inc load(hb.prf) symbian:CONFIG -= symbian_i18n - -HEADERS += inc/mainview.h inc/settingsview.h inc/notifications.h -SOURCES += src/main.cpp src/mainview.cpp src/settingsview.cpp src/notifications.cpp +HEADERS += inc/mainview.h \ + inc/settingsview.h \ + inc/notifications.h +SOURCES += src/main.cpp \ + src/mainview.cpp \ + src/settingsview.cpp \ + src/notifications.cpp RESOURCES += loadgen.qrc - -symbian: { - MMP_RULES -= PAGED - MMP_RULES *= UNPAGED - - BLD_INF_RULES.prj_exports += "./rom/loadgen.iby CORE_IBY_EXPORT_PATH(tools,loadgen.iby)" - - INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE - - HEADERS += inc/engine.h \ - inc/enginewrapper.h - SOURCES += src/engine.cpp \ - src/enginewrapper.cpp \ - ../../engine/src/loadgen_utils.cpp \ - ../../engine/src/loadgen_loadbase.cpp \ - ../../engine/src/loadgen_cpuload.cpp \ - ../../engine/src/loadgen_memoryeat.cpp \ - ../../engine/src/loadgen_phonecall.cpp \ - ../../engine/src/loadgen_netconn.cpp \ - ../../engine/src/loadgen_keypress.cpp \ - ../../engine/src/loadgen_messages.cpp \ - ../../engine/src/loadgen_applications.cpp \ - ../../engine/src/loadgen_photocapture.cpp \ - ../../engine/src/loadgen_bluetooth.cpp \ - ../../engine/src/loadgen_pointerevent.cpp - - - RSS_RULES += "group_name = \"RnD Tools\""; - LIBS += -leuser \ - -lcommonengine \ - -lapparc \ - -lcone \ - -leikcore \ - -leikcoctl \ - -leikctl \ - -leikdlg \ - -lws32 \ - -lapgrfx \ - -lefsrv \ - -lbafl \ - -lgdi \ - -legul \ - -letel3rdparty \ - -ldownloadmgr \ - -lcommdb \ - -lflogger \ - -lestor \ - -lmsgs \ - -lsmcm \ - -lgsmu \ - -letext \ - -lsendas2 \ - -lecam \ - -lfeatdiscovery \ - -lcentralrepository \ - -lesock \ - -lbluetooth \ - -lhal - TARGET.CAPABILITY = swevent ReadUserData WriteUserData NetworkServices UserEnvironment CAP_APPLICATION AllFiles - +symbian: { + MMP_RULES -= PAGED + MMP_RULES *= UNPAGED + BLD_INF_RULES.prj_exports += "./rom/loadgen.iby CORE_IBY_EXPORT_PATH(tools,loadgen.iby)" + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + HEADERS += inc/engine.h \ + inc/enginewrapper.h + SOURCES += src/engine.cpp \ + src/enginewrapper.cpp \ + ../../engine/src/loadgen_utils.cpp \ + ../../engine/src/loadgen_loadbase.cpp \ + ../../engine/src/loadgen_cpuload.cpp \ + ../../engine/src/loadgen_memoryeat.cpp \ + ../../engine/src/loadgen_phonecall.cpp \ + ../../engine/src/loadgen_keypress.cpp \ + ../../engine/src/loadgen_messages.cpp \ + ../../engine/src/loadgen_applications.cpp \ + ../../engine/src/loadgen_photocapture.cpp \ + ../../engine/src/loadgen_bluetooth.cpp \ + ../../engine/src/loadgen_pointerevent.cpp + RSS_RULES += "group_name = \"RnD Tools\""; + LIBS += -leuser \ + -lcommonengine \ + -lapparc \ + -lcone \ + -leikcore \ + -leikcoctl \ + -leikctl \ + -leikdlg \ + -lws32 \ + -lapgrfx \ + -lefsrv \ + -lbafl \ + -lgdi \ + -legul \ + -letel3rdparty \ + -lcommdb \ + -lflogger \ + -lestor \ + -lmsgs \ + -lsmcm \ + -lgsmu \ + -letext \ + -lsendas2 \ + -lecam \ + -lfeatdiscovery \ + -lcentralrepository \ + -lesock \ + -lbluetooth \ + -lhal + TARGET.CAPABILITY = swevent \ + ReadUserData \ + WriteUserData \ + NetworkServices \ + UserEnvironment \ + CAP_APPLICATION \ + AllFiles TARGET.UID2 = 0x100039CE TARGET.UID3 = 0x20011384 // TARGET.SID = 0x20011384 - TARGET.VID = 0x101FB657 // Nokia - - TARGET.EPOCHEAPSIZE = 0x10000 0x1000000 // Min 64Kb, Max 16Mb - - ICON = ../../icons/qgn_menu_loadgen.svg - -} else { - error("Only Symbian supported!") + TARGET.VID = 0x101FB657 \ + // \ + Nokia + TARGET.EPOCHEAPSIZE = 0x10000 \ + 0x1000000 \ + // \ + Min \ + 64Kb, \ + Max \ + 16Mb + ICON = ../../icons/qgn_menu_loadgen.svg } +else:error("Only Symbian supported!") diff -r e0ec97ec3cc4 -r 98924d2efce9 loadgen/ui/hb/src/engine.cpp --- a/loadgen/ui/hb/src/engine.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/loadgen/ui/hb/src/engine.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -24,7 +24,7 @@ #include "loadgen_cpuload.h" #include "loadgen_memoryeat.h" #include "loadgen_phonecall.h" -#include "loadgen_netconn.h" +//#include "loadgen_netconn.h" #include "loadgen_keypress.h" #include "loadgen_pointerevent.h" #include "loadgen_messages.h" @@ -530,11 +530,12 @@ item = CPhoneCall::NewL(iPhoneCallAttributes, iReferenceNumber); break; } - case ELoadGenCmdNewLoadNetConn: +/* case ELoadGenCmdNewLoadNetConn: { item = CNetConn::NewL(iNetConnAttributes, iReferenceNumber); break; } +*/ case ELoadGenCmdNewLoadKeyPress: { item = CKeyPress::NewL(iKeyPressAttributes, iReferenceNumber); @@ -1022,6 +1023,7 @@ TNetConnAttributes CEngine::GetNetConnAttributes() { +/* if (iEditExistingLoad == EFalse) { return iNetConnAttributes; @@ -1031,12 +1033,14 @@ CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); return (static_cast(aItem)->Attributes()); } +*/ } // -------------------------------------------------------------------------------------------- void CEngine::ChangeNetConnAttributes(TNetConnAttributes aAttributes) { +/* if (iEditExistingLoad == EFalse) { iNetConnAttributes = aAttributes; @@ -1045,7 +1049,8 @@ { CLoadBase* aItem = iLoadItemList->At(iCurrentItemIndex); static_cast(aItem)->SetAttributes(aAttributes); - } + } +*/ } // -------------------------------------------------------------------------------------------- diff -r e0ec97ec3cc4 -r 98924d2efce9 loadgen/ui/hb/src/mainview.cpp --- a/loadgen/ui/hb/src/mainview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/loadgen/ui/hb/src/mainview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -106,11 +106,12 @@ mMessagesLoadAction = mLoadSubMenu1->addAction("Messages"); connect(mMessagesLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); mSm->setMapping(mMessagesLoadAction, ELoadGenCmdNewLoadMessages); - +//TODO to be fixed using replacement for downloadmanager +/* mNetConnLoadAction = mLoadSubMenu1->addAction("Network conn."); connect(mNetConnLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); mSm->setMapping(mNetConnLoadAction, ELoadGenCmdNewLoadNetConn); - +*/ mKeyPressLoadAction = mLoadSubMenu2->addAction("Key presses"); connect(mKeyPressLoadAction, SIGNAL( triggered() ), mSm, SLOT(map())); mSm->setMapping(mKeyPressLoadAction, ELoadGenCmdNewLoadKeyPress); diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/inc/MemSpyAppUi.h --- a/memspyui/ui/avkon/inc/MemSpyAppUi.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/inc/MemSpyAppUi.h Tue Jul 06 14:17:03 2010 +0300 @@ -30,6 +30,7 @@ #include "MemSpyDeviceWideOperationDialog.h" #include "MemSpyContainerObserver.h" #include +#include "MemSpySettings.h" // Classes referenced class CEikMenuBar; @@ -41,7 +42,7 @@ class RMemSpySession; -class CMemSpyAppUi : public CAknAppUi, public MMemSpyContainerObserver, public MCoeControlObserver, public MMemSpyEngineObserver, public MMemSpyDeviceWideOperationDialogObserver +class CMemSpyAppUi : public CAknAppUi, public MMemSpyContainerObserver, public MCoeControlObserver, public MMemSpyEngineObserver//, public MMemSpyDeviceWideOperationDialogObserver { public: //CMemSpyAppUi( CMemSpyEngine& aEngine ); @@ -95,7 +96,8 @@ void OnCmdOutputToFileL(); // Phone-information - void OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::TOperation aOp ); + //void OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::TOperation aOp ); + void OnCmdPhoneInformationOperationL( TDeviceWideOperation aOperation ); void OnCmdPhoneInformationOperationKernelContainersL(); // Automatic capture @@ -116,6 +118,7 @@ //CMemSpyEngine& iEngine; RMemSpySession& iMemSpySession; CMemSpyContainer* iAppContainer; + CMemSpySettings* iSettings; // For phone information dialog TBool iRunningDeviceWideOperation; diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/inc/MemSpyDeviceWideOperationDialog.h --- a/memspyui/ui/avkon/inc/MemSpyDeviceWideOperationDialog.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/inc/MemSpyDeviceWideOperationDialog.h Tue Jul 06 14:17:03 2010 +0300 @@ -21,12 +21,41 @@ // System includes #include #include +#include // Engine includes #include +#include +#include + +//#include "MemSpyAppUi.h" // Classes referenced -class CMemSpyEngine; +//class RMemSpySession; + +enum TDeviceWideOperation +{ + OutputPhoneInfo = 0, + + OutputDetailedPhoneInfo, + + OutputHeapInfo, + + OutputCompactHeapInfo, + + OutputHeapCellListing, + + OutputHeapData, + + OutputStackInfo, + + OutputCompactStackInfo, + + OutputUserStackData, + + OutputKernelStackData +}; + class MMemSpyDeviceWideOperationDialogObserver { @@ -37,15 +66,94 @@ }; +class CMemSpyDwoProgressTracker : public CActive, public MProgressDialogCallback +{ +public: + CMemSpyDwoProgressTracker(RMemSpySession &aSession); + + virtual ~CMemSpyDwoProgressTracker(); + + void Start(); + + void Cancel(); + + TMemSpyDeviceWideOperationProgress Progress() { return iProgress; } + + CAknProgressDialog* ProgressDialog() { return iProgressDialog; } + + void UpdateProcessDialogL( TInt aProgress, const TDesC& aProgressText ); + +protected: // from CActive + + void DialogDismissedL(TInt aButtonId); + + virtual void RunL(); + + virtual void DoCancel(); + + virtual TInt RunError(TInt aError); + +private: + TMemSpyDeviceWideOperationProgress iProgress; + RMemSpySession iSession; + + CEikProgressInfo* iProgressInfo; + CAknProgressDialog* iProgressDialog; +}; + + + + + + +class CMemSpyDwoTracker : public CActive +{ +public: + CMemSpyDwoTracker(RMemSpySession &aSession, TDeviceWideOperation aOperation); + + virtual ~CMemSpyDwoTracker(); + + void Start(); + + void Cancel(); + +protected: // from CActive + + virtual void RunL(); + + virtual void DoCancel(); + + virtual TInt RunError(TInt aError); + +private: + RMemSpySession iSession; + CMemSpyDwoProgressTracker *iProgressTracker; + TDeviceWideOperation iOperation; +}; + + + + + + + class CMemSpyDeviceWideOperationDialog : public CBase, public MProgressDialogCallback, public MMemSpyDeviceWideOperationsObserver { public: - static void ExecuteLD( CMemSpyEngine& aEngine, MMemSpyDeviceWideOperationDialogObserver& aObserver, CMemSpyDeviceWideOperations::TOperation aOperation ); + //static void ExecuteLD( CMemSpyEngine& aEngine, MMemSpyDeviceWideOperationDialogObserver& aObserver, CMemSpyDeviceWideOperations::TOperation aOperation ); + //static void ExecuteLD( RMemSpySession& aSession, MMemSpyDeviceWideOperationDialogObserver& aObserver, CMemSpyDeviceWideOperations::TOperation aOperation ); + static void ExecuteLD( RMemSpySession& aSession, TDeviceWideOperation aOp ); ~CMemSpyDeviceWideOperationDialog(); + + //added + static CMemSpyDwoTracker* CreateDeviceWideOperation( RMemSpySession& aSession, TDeviceWideOperation aOp ); private: - CMemSpyDeviceWideOperationDialog( CMemSpyEngine& aEngine, MMemSpyDeviceWideOperationDialogObserver& aObserver ); - void ExecuteL( CMemSpyDeviceWideOperations::TOperation aOperation ); + //CMemSpyDeviceWideOperationDialog( CMemSpyEngine& aEngine, MMemSpyDeviceWideOperationDialogObserver& aObserver ); + //CMemSpyDeviceWideOperationDialog( RMemSpySession& aSession, MMemSpyDeviceWideOperationDialogObserver& aObserver ); + CMemSpyDeviceWideOperationDialog( RMemSpySession& aSession ); + //void ExecuteL( CMemSpyDeviceWideOperations::TOperation aOperation ); + void ExecuteL( TDeviceWideOperation aOp ); public: // API void Cancel(); @@ -60,13 +168,13 @@ void SetDialogCaptionL( const TDesC& aText ); private: // Member data - CMemSpyEngine& iEngine; - MMemSpyDeviceWideOperationDialogObserver& iObserver; + //CMemSpyEngine& iEngine; + RMemSpySession iSession; + //MMemSpyDeviceWideOperationDialogObserver& iObserver; TBool iForcedCancel; CEikProgressInfo* iProgressInfo; CAknProgressDialog* iProgressDialog; - CMemSpyDeviceWideOperations* iOperation; + CMemSpyDeviceWideOperations* iOperation; }; - #endif diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/inc/MemSpySettings.h --- a/memspyui/ui/avkon/inc/MemSpySettings.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/inc/MemSpySettings.h Tue Jul 06 14:17:03 2010 +0300 @@ -25,6 +25,7 @@ // Engine includes #include +#include // Classes referenced class CMemSpyEngine; @@ -48,6 +49,8 @@ public: // API inline RFs& FsSession() { return iFsSession; } void StoreSettingsL(); + + void SetSinkType( TMemSpySinkType aType ) { iSinkType = aType; } private: // Settings methods void RestoreSettingsL(); @@ -56,9 +59,13 @@ RFile SettingsFileLC( TBool aReplace = EFalse ); private: // Data members - RFs& iFsSession; - //CMemSpyEngine& iEngine; - //RMemSpySession& iMemSpySession; + RFs& iFsSession; + RMemSpySession& iMemSpySession; + +private: //Settings + TMemSpySinkType iSinkType; + TMemSpyEngineHelperSysMemTrackerConfig iSwmtConfig; + RArray iUidList; }; diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/inc/MemSpyUiUtils.h --- a/memspyui/ui/avkon/inc/MemSpyUiUtils.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/inc/MemSpyUiUtils.h Tue Jul 06 14:17:03 2010 +0300 @@ -20,13 +20,17 @@ // System includes #include +#include // Engine includes #include #include +typedef TBuf<20> TMemSpySizeText; + _LIT( KTab, "\t" ); - + +//ThreadInfoItemList view types _LIT( KTypeUnknown, "Unknown Type" ); _LIT( KGeneral, "General" ); _LIT( KHeap, "Heap" ); @@ -50,6 +54,26 @@ _LIT( KLogicalDrivers, "Logical Device Drivers" ); _LIT( KPhysicalDrivers, "Physical Device Drivers" ); +//Kernel Object types +_LIT( KTypeThread, "Thread" ); +_LIT( KTypeProcess, "Process" ); +_LIT( KTypeChunk, "Chunk" ); +_LIT( KTypeLibrary, "Library" ); +_LIT( KTypeSemaphore, "Semaphore" ); +_LIT( KTypeMutex, "Mutex" ); +_LIT( KTypeTimer, "Timer" ); +_LIT( KTypeServer, "Server" ); +_LIT( KTypeSession, "Session" ); +_LIT( KTypeLogicalDevice, "Logical Device" ); +_LIT( KTypePhysicalDevice, "Physical Device" ); +_LIT( KTypeLogicalChannel, "Logical Channel" ); +_LIT( KTypeChangeNotifier, "Change Notifier" ); +_LIT( KTypeUndertaker, "Undertaker" ); +_LIT( KTypeMsgQueue, "Msg. Queue" ); +_LIT( KTypePropertyRef, "Property Ref." ); +_LIT( KTypeCondVar, "Conditional Var." ); + + class MemSpyUiUtils : public MemSpyEngineUtils { public: @@ -57,6 +81,13 @@ static void GetErrorText( TDes& aBuf, TInt aError ); static HBufC* FormatItem( const TDesC& aCaption ); static TDesC& ThreadInfoItemNameByType( TMemSpyThreadInfoItemType aType ); + static void AppendPriority( TDes& aDes, TProcessPriority aPriority ); + static void AppendExitInfo( TDes& aDes, TExitType aType, TInt aExitReason, const TDesC& aExitCategory ); + static void AppendExitType( TDes& aDes, TExitType aType ); + + //for Kernel Objects + static TPtrC TypeAsString( TMemSpyDriverContainerType aType ); + static TMemSpySizeText FormatSizeText( const TInt64& aValue, TInt aDecimalPlaces, TBool aExtraRounding = EFalse ); }; diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/inc/MemSpyViewKernelObjects.h --- a/memspyui/ui/avkon/inc/MemSpyViewKernelObjects.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/inc/MemSpyViewKernelObjects.h Tue Jul 06 14:17:03 2010 +0300 @@ -66,8 +66,7 @@ TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); private: // From MAknTabObserver - void TabChangedL( TInt aIndex ); - TPtrC TypeAsString( TMemSpyDriverContainerType aType ); + void TabChangedL( TInt aIndex ); private: // Command handlers void OnCmdTerminateL(); diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/inc/MemSpyViewThreadInfoItemGeneric.h --- a/memspyui/ui/avkon/inc/MemSpyViewThreadInfoItemGeneric.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/inc/MemSpyViewThreadInfoItemGeneric.h Tue Jul 06 14:17:03 2010 +0300 @@ -52,7 +52,8 @@ CMemSpyThread& Thread() const; CMemSpyThreadInfoContainer& Container() const; CMemSpyThreadInfoItemBase& InfoItem() const; - + TThreadId ThreadId() { return iThreadId; } + public: // From CMemSpyViewBase void RefreshL(); TMemSpyViewType ViewType() const; diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/inc/MemSpyViewThreadInfoItemList.h --- a/memspyui/ui/avkon/inc/MemSpyViewThreadInfoItemList.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/inc/MemSpyViewThreadInfoItemList.h Tue Jul 06 14:17:03 2010 +0300 @@ -38,7 +38,7 @@ //CMemSpyViewThreadInfoItemList( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThread& aThread ); CMemSpyViewThreadInfoItemList( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aProcess, TThreadId aThread ); ~CMemSpyViewThreadInfoItemList(); - void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL ); + void ConstructL( const TRect& aRect, CCoeControl& aContainer, TMemSpyThreadInfoItemType iType); public: // API const CMemSpyThreadInfoItemBase& CurrentInfoItem() const; diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/inc/MemSpyViewThreads.h --- a/memspyui/ui/avkon/inc/MemSpyViewThreads.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/inc/MemSpyViewThreads.h Tue Jul 06 14:17:03 2010 +0300 @@ -36,7 +36,7 @@ { public: //CMemSpyViewThreads( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyProcess& aProcess ); - CMemSpyViewThreads( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aId ); + CMemSpyViewThreads( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aId, TThreadId aThreadId ); ~CMemSpyViewThreads(); void ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune = NULL ); diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyAppUi.cpp --- a/memspyui/ui/avkon/src/MemSpyAppUi.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyAppUi.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -257,13 +257,16 @@ case EMemSpyCmdToolsAbout: OnCmdAboutL(); break; - // + // case EMemSpyCmdPhoneInfoGeneralSummary: - OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityGeneralSummary ); + //OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityGeneralSummary ); + OnCmdPhoneInformationOperationL( OutputPhoneInfo ); + break; + case EMemSpyCmdPhoneInfoGeneralDetailed: + //OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityGeneralDetailed ); + OnCmdPhoneInformationOperationL( OutputDetailedPhoneInfo ); break; - case EMemSpyCmdPhoneInfoGeneralDetailed: - OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityGeneralDetailed ); - break; + /* case EMemSpyCmdPhoneInfoGeneralHandles: OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityGeneralHandles ); break; @@ -271,30 +274,40 @@ OnCmdPhoneInformationOperationKernelContainersL(); break; // + */ case EMemSpyCmdPhoneInfoHeapInfoSummary: - OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityHeapInfo ); + //OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityHeapInfo ); + OnCmdPhoneInformationOperationL (OutputHeapInfo ); break; case EMemSpyCmdPhoneInfoHeapInfoCompact: - OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EEntireDeviceHeapInfoCompact ); + //OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EEntireDeviceHeapInfoCompact ); + OnCmdPhoneInformationOperationL( OutputCompactHeapInfo ); break; case EMemSpyCmdPhoneInfoHeapCellListing: - OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityHeapCellListing ); + //OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityHeapCellListing ); + OnCmdPhoneInformationOperationL( OutputHeapCellListing ); break; + case EMemSpyCmdPhoneInfoHeapDump: - OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityHeapData ); + //OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityHeapData ); + OnCmdPhoneInformationOperationL( OutputHeapData ); break; - // + // case EMemSpyCmdPhoneInfoStackInfo: - OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityStackInfo ); + //OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityStackInfo ); + OnCmdPhoneInformationOperationL( OutputStackInfo ); break; case EMemSpyCmdPhoneInfoStackInfoCompact: - OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EEntireDeviceStackInfoCompact ); + //OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EEntireDeviceStackInfoCompact ); + OnCmdPhoneInformationOperationL( OutputCompactStackInfo ); break; case EMemSpyCmdPhoneInfoStackDumpUser: - OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityStackDataUser ); + //OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityStackDataUser ); + OnCmdPhoneInformationOperationL( OutputUserStackData ); break; case EMemSpyCmdPhoneInfoStackDumpKernel: - OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityStackDataKernel ); + //OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::EPerEntityStackDataKernel ); + OnCmdPhoneInformationOperationL( OutputKernelStackData ); break; case EMemSpyCmdAutoCaptureToggle: @@ -523,21 +536,26 @@ } -void CMemSpyAppUi::OnCmdPhoneInformationOperationL( CMemSpyDeviceWideOperations::TOperation aOp ) - { /* TODO +void CMemSpyAppUi::OnCmdPhoneInformationOperationL( TDeviceWideOperation aOperation ) + { + // + //CMemSpyDeviceWideOperationDialog::ExecuteLD( iMemSpySession, aOperation ); + CMemSpyDwoTracker* tracker = CMemSpyDeviceWideOperationDialog::CreateDeviceWideOperation( iMemSpySession, aOperation ); + tracker->Start(); + /* #ifdef _DEBUG RDebug::Printf( "[MemSpy] CMemSpyAppUi::OnCmdPhoneInformationOperationL() - START - aOp: %d, iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", aOp, iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() ); #endif if ( !iRunningDeviceWideOperation ) - { - //CMemSpyDeviceWideOperationDialog::ExecuteLD( iEngine, *this, aOp ); + { CMemSpyDeviceWideOperationDialog::ExecuteLD( iMemSpySession, *this, aOp ); } #ifdef _DEBUG RDebug::Printf( "[MemSpy] CMemSpyAppUi::OnCmdPhoneInformationOperationL() - END - aOp: %d, iRunningDeviceWideOperation: %d, iAutoCaptureTimer is active: %d", aOp, iRunningDeviceWideOperation, iAutoCaptureTimer->IsActive() ); -#endif*/ +#endif + */ } @@ -639,7 +657,7 @@ RDebug::Printf( "[MemSpy] CMemSpyAppUi::AutoCaptureCallBackL() - START - iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() ); #endif - OnCmdPhoneInformationOperationL( iAutoCaptureOperationType ); + // OnCmdPhoneInformationOperationL( iAutoCaptureOperationType ); #ifdef _DEBUG RDebug::Printf( "[MemSpy] CMemSpyAppUi::AutoCaptureCallBackL() - END - iAutoCaptureOperationType: %d, iAutoCaptureTimer is active: %d", iAutoCaptureOperationType, iAutoCaptureTimer->IsActive() ); @@ -668,25 +686,15 @@ void CMemSpyAppUi::OnCmdOutputToDebugL() { - /* TODO - iMemSpyAPI.OutputToDebug(); - */ - /* - iEngine.InstallSinkL( ESinkTypeDebug ); - MemSpyDocument().Settings().StoreSettingsL(); - */ + iMemSpySession.SwitchOutputSink( ESinkTypeDebug ); //set in engine + MemSpyDocument().Settings().SetSinkType( ESinkTypeDebug ); //set in settings } void CMemSpyAppUi::OnCmdOutputToFileL() { - /* TODO - iMemSpyAPI.OutputToFile(); - */ - /* - iEngine.InstallSinkL( ESinkTypeFile ); - MemSpyDocument().Settings().StoreSettingsL(); - */ + iMemSpySession.SwitchOutputSink( ESinkTypeFile ); //set in engine + MemSpyDocument().Settings().SetSinkType( ESinkTypeFile ); //set in settings } diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyDeviceWideOperationDialog.cpp --- a/memspyui/ui/avkon/src/MemSpyDeviceWideOperationDialog.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyDeviceWideOperationDialog.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -26,12 +26,25 @@ #include #include +#include +/* CMemSpyDeviceWideOperationDialog::CMemSpyDeviceWideOperationDialog( CMemSpyEngine& aEngine, MMemSpyDeviceWideOperationDialogObserver& aObserver ) : iEngine( aEngine ), iObserver( aObserver ) { } +CMemSpyDeviceWideOperationDialog::CMemSpyDeviceWideOperationDialog( RMemSpySession& aSession, MMemSpyDeviceWideOperationDialogObserver& aObserver ) +: iSession( aSession ), iObserver( aObserver ) + { + } +*/ + +CMemSpyDeviceWideOperationDialog::CMemSpyDeviceWideOperationDialog( RMemSpySession& aSession ) +: iSession( aSession ) + { + } + CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() { @@ -54,7 +67,7 @@ RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() - sending EDialogDismissed to observer..." ); #endif - iObserver.DWOperationCompleted(); + //iObserver.DWOperationCompleted(); //TODO #ifdef _DEBUG RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::~CMemSpyDeviceWideOperationDialog() - END" ); @@ -62,8 +75,10 @@ } -void CMemSpyDeviceWideOperationDialog::ExecuteL( CMemSpyDeviceWideOperations::TOperation aOperation ) +//void CMemSpyDeviceWideOperationDialog::ExecuteL( CMemSpyDeviceWideOperations::TOperation aOperation ) +void CMemSpyDeviceWideOperationDialog::ExecuteL( TDeviceWideOperation aOp ) { + /* #ifdef _DEBUG RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::ExecuteL() - START" ); #endif @@ -88,13 +103,15 @@ #ifdef _DEBUG RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::ExecuteL() - END" ); #endif + */ } -void CMemSpyDeviceWideOperationDialog::ExecuteLD( CMemSpyEngine& aEngine, MMemSpyDeviceWideOperationDialogObserver& aObserver, CMemSpyDeviceWideOperations::TOperation aOperation ) +void CMemSpyDeviceWideOperationDialog::ExecuteLD( RMemSpySession& aSession, TDeviceWideOperation aOp ) { - CMemSpyDeviceWideOperationDialog* self = new(ELeave) CMemSpyDeviceWideOperationDialog( aEngine, aObserver ); + //CMemSpyDeviceWideOperationDialog* self = new(ELeave) CMemSpyDeviceWideOperationDialog( aSession, aObserver ); + CMemSpyDeviceWideOperationDialog* self = new(ELeave) CMemSpyDeviceWideOperationDialog( aSession ); CleanupStack::PushL( self ); - self->ExecuteL( aOperation ); + self->ExecuteL( aOp ); CleanupStack::PopAndDestroy( self ); } @@ -112,7 +129,7 @@ iOperation->Cancel(); } // - iObserver.DWOperationCancelled(); + //iObserver.DWOperationCancelled(); #ifdef _DEBUG RDebug::Printf("[MemSpy] CMemSpyDeviceWideOperationDialog::Cancel() - END" ); @@ -147,7 +164,7 @@ case MMemSpyDeviceWideOperationsObserver::EOperationSized: break; case MMemSpyDeviceWideOperationsObserver::EOperationStarting: - iObserver.DWOperationStarted(); + //iObserver.DWOperationStarted(); break; case MMemSpyDeviceWideOperationsObserver::EOperationProgressStart: ASSERT( iProgressDialog != NULL ); @@ -191,7 +208,180 @@ } } +CMemSpyDwoTracker* CMemSpyDeviceWideOperationDialog::CreateDeviceWideOperation( RMemSpySession& aSession, TDeviceWideOperation aOp ) +{ + return new CMemSpyDwoTracker( aSession, aOp ); +} + + + + + + + + + +CMemSpyDwoProgressTracker::CMemSpyDwoProgressTracker(RMemSpySession &aSession) + : CActive( EPriorityStandard ), iSession( aSession ) + { + CActiveScheduler::Add(this); + } + +CMemSpyDwoProgressTracker::~CMemSpyDwoProgressTracker() + { + Cancel(); + } + +void CMemSpyDwoProgressTracker::Start() + { + ASSERT( iProgressDialog == NULL ); + iProgressDialog = new( ELeave ) CAknProgressDialog( reinterpret_cast< CEikDialog** >( &iProgressDialog ), ETrue ); + iProgressDialog->PrepareLC( R_MEMSPY_DEVICE_WIDE_OPERATION_PROGRESS_DIALOG ); + iProgressDialog->SetCallback( this ); + iProgressDialog->SetGloballyCapturing( ETrue ); + iProgressInfo = iProgressDialog->GetProgressInfoL(); + + iSession.NotifyDeviceWideOperationProgress( iProgress, iStatus ); + + UpdateProcessDialogL( iProgress.Progress(), iProgress.Description() ); + + SetActive(); + + iProgressDialog->RunLD(); + } + +void CMemSpyDwoProgressTracker::Cancel() + { + } + +void CMemSpyDwoProgressTracker::RunL() + { + // If an error occurred handle it in RunError(). + User::LeaveIfError(iStatus.Int()); + + // Resubmit the request immediately + iSession.NotifyDeviceWideOperationProgress( iProgress, iStatus ); + + SetActive(); + + UpdateProcessDialogL( iProgress.Progress(), iProgress.Description() ); + } + +void CMemSpyDwoProgressTracker::DoCancel() + { + } + +TInt CMemSpyDwoProgressTracker::RunError(TInt aError) + { + // KErrNotReady and KErrCancel errors are OK, they just notify + // us about the outstanding notification request that won't be + // processed. + return KErrNone; + } + +void CMemSpyDwoProgressTracker::UpdateProcessDialogL( TInt aProgress, const TDesC& aProgressText ) + { + if(iProgressDialog) + { + iProgressDialog->SetTextL( aProgressText ); + } + + if(iProgressInfo) + { + iProgressInfo->SetAndDraw( aProgress ); + } + } + +void CMemSpyDwoProgressTracker::DialogDismissedL(TInt aButtonId) + { + iProgressDialog = NULL; + iProgressInfo = NULL; + + Cancel(); + } + + + + + + + + + + + + + + +CMemSpyDwoTracker::CMemSpyDwoTracker( RMemSpySession &aSession, TDeviceWideOperation aOperation ) +: CActive( EPriorityStandard ), + iSession( aSession ), + iProgressTracker(new CMemSpyDwoProgressTracker( aSession )), + iOperation( aOperation ) + { + CActiveScheduler::Add(this); + } + +CMemSpyDwoTracker::~CMemSpyDwoTracker() + { + Cancel(); + + delete iProgressTracker; + } + +void CMemSpyDwoTracker::Start() +{ + void (RMemSpySession::*functions[])(TRequestStatus&) = { + &RMemSpySession::OutputPhoneInfo, + &RMemSpySession::OutputDetailedPhoneInfo, + &RMemSpySession::OutputHeapInfo, + &RMemSpySession::OutputCompactHeapInfo, + &RMemSpySession::OutputHeapCellListing, + &RMemSpySession::OutputHeapData, + &RMemSpySession::OutputStackInfo, + &RMemSpySession::OutputCompactStackInfo, + &RMemSpySession::OutputUserStackData, + &RMemSpySession::OutputKernelStackData }; + + (iSession.*functions[iOperation])(iStatus); + + SetActive(); + + iProgressTracker->Start(); +} + +void CMemSpyDwoTracker::Cancel() +{ +} + +void CMemSpyDwoTracker::RunL() + { + // If an error occurred handle it in RunError(). + User::LeaveIfError(iStatus.Int()); + + if( !IsActive() ) + { + iProgressTracker->ProgressDialog()->ProcessFinishedL(); + } + } + +void CMemSpyDwoTracker::DoCancel() +{ + // Cancel progress tracker + iProgressTracker->Cancel(); + + iSession.CancelDeviceWideOperationL(); +} + +TInt CMemSpyDwoTracker::RunError(TInt aError) +{ + // Emit the finished(false) signal to notify user + // operation was canceled + //emit finished(false); //TODO: + + return KErrNone; +} diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpySettings.cpp --- a/memspyui/ui/avkon/src/MemSpySettings.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpySettings.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -26,63 +26,38 @@ #include #include #include -#include #include // Constants -_LIT( KMemSpySettingsFileName, "settings.dat" ); +_LIT( KMemSpySettingsFileName, "settings.dat" ); //file or avkon client settings // Version 03 dumped some of the system wide memory tracker settings const TInt KMemSpySettingsFileFormatVersion = 6; -/* -CMemSpySettings::CMemSpySettings( RFs& aFsSession, CMemSpyEngine& aEngine ) -: iFsSession( aFsSession ), iEngine( aEngine ) - { - } -*/ CMemSpySettings::CMemSpySettings( RFs& aFsSession, RMemSpySession& aSession ) -: iFsSession( aFsSession ) +: iFsSession( aFsSession ), iMemSpySession( aSession ) { } CMemSpySettings::~CMemSpySettings() - { - /* + { TRACE( RDebug::Printf( "CMemSpySettings::~CMemSpySettings() - START" ) ); TRAP_IGNORE( StoreSettingsL() ); - TRACE( RDebug::Printf( "CMemSpySettings::~CMemSpySettings() - END" ) ); - */ - - //iMemSpyAPI.StoreSettings(); + TRACE( RDebug::Printf( "CMemSpySettings::~CMemSpySettings() - END" ) ); } void CMemSpySettings::ConstructL() - { - /* + { TRACE( RDebug::Print( _L("CMemSpySettings::ConstructL() - START") ) ); TRAP_IGNORE( RestoreSettingsL() ); - TRACE( RDebug::Print( _L("CMemSpySettings::ConstructL() - END") ) ); - */ - - //iMemSpyAPI.RestoreSettings(); + TRACE( RDebug::Print( _L("CMemSpySettings::ConstructL() - END") ) ); } -/* -CMemSpySettings* CMemSpySettings::NewL( RFs& aFsSession, CMemSpyEngine& aEngine ) - { - CMemSpySettings* self = new(ELeave) CMemSpySettings( aFsSession, aEngine ); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } -*/ CMemSpySettings* CMemSpySettings::NewL( RFs& aFsSession, RMemSpySession& aSession ) { CMemSpySettings* self = new(ELeave) CMemSpySettings( aFsSession, aSession ); @@ -92,7 +67,6 @@ return self; } -/* void CMemSpySettings::GetSettingsFileNameL( TDes& aFileName ) { GetSettingsPathL( aFileName ); @@ -120,7 +94,6 @@ TRACE( RDebug::Print( _L("CMemSpySettings::GetSettingsPathL() - END - %S"), &aPath ) ); } - RFile CMemSpySettings::SettingsFileLC( TBool aReplace ) { TRACE( RDebug::Print( _L("CMemSpySettings::SettingsFileLC() - START - aReplace: %d"), aReplace ) ); @@ -170,20 +143,23 @@ // Verion info stream.WriteInt32L( KMemSpySettingsFileFormatVersion ); - // Engine settings - TRACE( RDebug::Printf( "CMemSpySettings::StoreSettingsL() - sinkType: %d", iEngine.SinkType() ) ); - stream.WriteUint8L( iEngine.SinkType() ); - + stream.WriteUint8L( iSinkType ); + + // Get SWMT config - CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker(); - TMemSpyEngineHelperSysMemTrackerConfig swmtConfig; - swmt.GetConfig( swmtConfig ); + //CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker(); + //TMemSpyEngineHelperSysMemTrackerConfig swmtConfig; + //swmt.GetConfig( swmtConfig ); // Write SWMT settings - stream.WriteInt32L( swmtConfig.TimerPeriod().Int() ); - stream.WriteUint8L( swmtConfig.DumpData() ); + //stream.WriteInt32L( swmtConfig.TimerPeriod().Int() ); + //stream.WriteUint8L( swmtConfig.DumpData() ); + + stream.WriteInt32L( iSwmtConfig.TimerPeriod().Int() ); + stream.WriteUint8L( iSwmtConfig.DumpData() ); // Write memory tracking auto-start process list + /* const RArray& processUidList = iEngine.HelperProcess().MemoryTrackingAutoStartProcessList(); stream.WriteInt32L( processUidList.Count() ); for( TInt i=0; i 0 ) { stream.WriteL( swmtConfig.iThreadNameFilter, swmtConfig.iThreadNameFilter.Length() ); @@ -205,21 +193,25 @@ // Write mode stream.WriteInt32L( swmtConfig.iMode ); + */ + if ( iSwmtConfig.iThreadNameFilter.Length() > 0 ) + { + stream.WriteL( iSwmtConfig.iThreadNameFilter, iSwmtConfig.iThreadNameFilter.Length() ); + } + + // Write mode + stream.WriteInt32L( iSwmtConfig.iMode ); stream.CommitL(); - CleanupStack::PopAndDestroy( &stream ); // Closes file - TRACE( RDebug::Printf( "CMemSpySettings::StoreSettingsL() - END - sinkType: %d", iEngine.SinkType() ) ); + CleanupStack::PopAndDestroy( &stream ); // Closes file } - void CMemSpySettings::RestoreSettingsL() - { - TRACE( RDebug::Printf( "CMemSpySettings::RestoreSettingsL() - START - current engine sinkType: %d", iEngine.SinkType() ) ); - + { RFile file = SettingsFileLC(); RFileReadStream stream( file ); CleanupStack::Pop(); // file - CleanupClosePushL( stream ); + CleanupClosePushL( stream ); // Version info const TInt version = stream.ReadInt32L(); // discarded for now @@ -228,11 +220,13 @@ // Engine settings TMemSpySinkType type = static_cast< TMemSpySinkType >( stream.ReadUint8L() ); TRACE( RDebug::Printf( "CMemSpySettings::RestoreSettingsL() - read sinkType: %d", type ) ); - iEngine.InstallSinkL( type ); + + //iEngine.InstallSinkL( type ); + //iMemSpySession.SwitchOutputSink( type ); //TODO: to argue to set stuf in engine from here // Set SWMT config TMemSpyEngineHelperSysMemTrackerConfig swmtConfig; - swmtConfig.iTimerPeriod = TTimeIntervalMicroSeconds32( stream.ReadInt32L() ); + swmtConfig.iTimerPeriod = TTimeIntervalMicroSeconds32( stream.ReadInt32L() ); swmtConfig.iDumpData = static_cast< TBool >( stream.ReadUint8L() ); if ( version < 3 ) @@ -247,21 +241,28 @@ // Restore memory tracking auto-start process uids if file format supports it... if ( version >= 2 ) { - RArray list; + RArray list; CleanupClosePushL( list ); // const TInt count = stream.ReadInt32L(); + + //CArrayFixFlat* list = new(ELeave)CArrayFixFlat(count); + //CleanupStack::PushL(list ); + for( TInt i=0; i> processUid; - // - TRACE( RDebug::Printf( "CMemSpySettings::RestoreSettingsL() - process tracker uid[%02d]: 0x%08x", i, processUid.iUid ) ); - User::LeaveIfError( list.Append( processUid ) ); + // + User::LeaveIfError( list.Append( processUid ) ); + //list->AppendL( processUid ); } // - CMemSpyEngineHelperProcess& processHelper = iEngine.HelperProcess(); - processHelper.SetMemoryTrackingAutoStartProcessListL( list ); + //CMemSpyEngineHelperProcess& processHelper = iEngine.HelperProcess(); + //processHelper.SetMemoryTrackingAutoStartProcessListL( list ); + //iMemSpySession.SetSwmtAutoStartProcessList( list ); + iUidList = list; //TODO: to get it into the engine + CleanupStack::PopAndDestroy( &list ); } @@ -287,11 +288,13 @@ swmtConfig.iMode = (TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode)stream.ReadInt32L(); } - CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker(); - swmt.SetConfigL( swmtConfig ); - - CleanupStack::PopAndDestroy( &stream ); // Closes file - TRACE( RDebug::Printf( "CMemSpySettings::RestoreSettingsL() - END - engine sink type: %d", iEngine.SinkType() ) ); + //CMemSpyEngineHelperSysMemTracker& swmt = iEngine.HelperSysMemTracker(); + //swmt.SetConfigL( swmtConfig ); + //iMemSpySession.SetSwmtConfig( swmtConfig ); + + iSwmtConfig = swmtConfig; //TODO: to get it into the engine + + CleanupStack::PopAndDestroy( &stream ); // Closes file } -*/ + diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyUiUtils.cpp --- a/memspyui/ui/avkon/src/MemSpyUiUtils.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyUiUtils.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -149,3 +149,219 @@ return pType; } + +void MemSpyUiUtils::AppendPriority( TDes& aDes, TProcessPriority aPriority ) + { + switch( aPriority ) + { + case EPriorityLow: + aDes += _L("[L]"); + break; + case EPriorityBackground: + aDes += _L("[B]"); + break; + case EPriorityForeground: + aDes += _L("[F]"); + break; + case EPriorityHigh: + aDes += _L("[H]"); + break; + case EPriorityWindowServer: + aDes += _L("[WS]"); + break; + case EPriorityFileServer: + aDes += _L("[FS]"); + break; + case EPriorityRealTimeServer: + aDes += _L("[RTS]"); + break; + case EPrioritySupervisor: + aDes += _L("[SUP]"); + break; + default: + aDes += _L("[?]"); + break; + } + } + +void MemSpyUiUtils::AppendExitInfo( TDes& aDes, TExitType aType, TInt aExitReason, const TDesC& aExitCategory ) + { + aDes.Append( '[' ); + const TInt length = aDes.Length(); + AppendExitType( aDes, aType ); + aDes.SetLength( length + 1 ); // Remove all but the first letter + aDes.Append( ']' ); + + if ( aType == EExitKill || aType == EExitPending ) + { + // Kill implies "clean" exit. Pending implies not yet dead. + } + else + { + TMemSpyTruncateOverflow overflow; + + // Terminate or Panic implies abnormal exit condition, so + // show full exit info. + _LIT( KAbnormalFormatSpec, " %S-%d" ); + aDes.AppendFormat( KAbnormalFormatSpec, &overflow, &aExitCategory, aExitReason ); + } + } + + +void MemSpyUiUtils::AppendExitType( TDes& aDes, TExitType aType ) + { + _LIT( KExitTypeKilled, "Killed" ); + _LIT( KExitTypeTerminated, "Terminated" ); + _LIT( KExitTypePanicked, "Panicked" ); + _LIT( KExitTypePending, "Pending" ); + + // Panic and Terminate are exceptional exit conditions. + // Kill, is ironically, not an exceptional condition. + switch( aType ) + { + case EExitKill: + aDes += KExitTypeKilled; + break; + case EExitTerminate: + aDes += KExitTypeTerminated; + break; + case EExitPanic: + aDes += KExitTypePanicked; + break; + default: + case EExitPending: + aDes += KExitTypePending; + break; + } + } + + +TPtrC MemSpyUiUtils::TypeAsString( TMemSpyDriverContainerType aType ) + { + TPtrC pType( KTypeUnknown ); + // + switch( aType ) + { + case EMemSpyDriverContainerTypeThread: + pType.Set( KTypeThread ); + break; + case EMemSpyDriverContainerTypeProcess: + pType.Set( KTypeProcess ); + break; + case EMemSpyDriverContainerTypeChunk: + pType.Set( KTypeChunk ); + break; + case EMemSpyDriverContainerTypeLibrary: + pType.Set( KTypeLibrary ); + break; + case EMemSpyDriverContainerTypeSemaphore: + pType.Set( KTypeSemaphore ); + break; + case EMemSpyDriverContainerTypeMutex: + pType.Set( KTypeMutex ); + break; + case EMemSpyDriverContainerTypeTimer: + pType.Set( KTypeTimer ); + break; + case EMemSpyDriverContainerTypeServer: + pType.Set( KTypeServer ); + break; + case EMemSpyDriverContainerTypeSession: + pType.Set( KTypeSession ); + break; + case EMemSpyDriverContainerTypeLogicalDevice: + pType.Set( KTypeLogicalDevice ); + break; + case EMemSpyDriverContainerTypePhysicalDevice: + pType.Set( KTypePhysicalDevice ); + break; + case EMemSpyDriverContainerTypeLogicalChannel: + pType.Set( KTypeLogicalChannel ); + break; + case EMemSpyDriverContainerTypeChangeNotifier: + pType.Set( KTypeChangeNotifier ); + break; + case EMemSpyDriverContainerTypeUndertaker: + pType.Set( KTypeUndertaker ); + break; + case EMemSpyDriverContainerTypeMsgQueue: + pType.Set( KTypeMsgQueue ); + break; + case EMemSpyDriverContainerTypePropertyRef: + pType.Set( KTypePropertyRef ); + break; + case EMemSpyDriverContainerTypeCondVar: + pType.Set( KTypeCondVar ); + break; + + default: + break; + } + // + return pType; + } + +TMemSpySizeText MemSpyUiUtils::FormatSizeText( const TInt64& aValue, TInt aDecimalPlaces, TBool aExtraRounding ) + { + _LIT(KFormatKilo, "%dK"); + _LIT(KFormatMega, "%SM"); + _LIT(KFormatGiga, "%SG"); + + TMemSpySizeText buf; + if ( aValue < 1024000 ) // If < 1000K + { + TInt sizeInK = 0; + + if ( aValue != 0 ) + { + sizeInK = I64INT( (aValue + 512) >> 10 ); + if (sizeInK < 1) + { + sizeInK = 1; + } + if (sizeInK > 999) + { + sizeInK = 999; + } + } + + buf.Format( KFormatKilo, sizeInK ); + } + else + { + TReal sizeInM = I64INT( aValue ); + sizeInM /= 1048576; + if ( sizeInM < 1 ) + { + sizeInM = 1; + } + + TPtrC pFormat( KFormatMega ); + if ( sizeInM >= 1000 ) + { + sizeInM /= 1024; // Size in G + if (sizeInM < 1) + { + sizeInM = 1; + } + + pFormat.Set( KFormatGiga ); + } + + if ( sizeInM > 999.9) + { + sizeInM = 999.9; + } + + if ( aExtraRounding ) + { + sizeInM += 0.499999; + } + + TBuf<16> size; + size.Num( sizeInM, TRealFormat( 14, aDecimalPlaces ) ); // Allow for "17179869184.0"G which is 2^64 + buf.Format( pFormat, &size ); + } + + return buf; + } diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyViewKernel.cpp --- a/memspyui/ui/avkon/src/MemSpyViewKernel.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyViewKernel.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -102,13 +102,11 @@ const TInt index = iListBox->CurrentItemIndex(); // if ( index == 0 ) - { - //child = new(ELeave) CMemSpyViewKernelContainers( iEngine, iObserver ); + { child = new(ELeave) CMemSpyViewKernelContainers( iMemSpySession, iObserver ); } else if ( index == 1 ) - { - //child = new(ELeave) CMemSpyViewKernelHeap( iEngine, iObserver ); + { child = new(ELeave) CMemSpyViewKernelHeap( iMemSpySession, iObserver ); } diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyViewKernelContainers.cpp --- a/memspyui/ui/avkon/src/MemSpyViewKernelContainers.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyViewKernelContainers.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -56,7 +56,7 @@ { _LIT( KTitle, "Kernel Objects" ); SetTitleL( KTitle ); - // + // CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); } @@ -107,10 +107,10 @@ { TInt count = iKernelObjects[i]->Count(); TInt size = iKernelObjects[i]->Size(); - const TMemSpySizeText sizeText( MemSpyEngineUtils::FormatSizeText( size, 0 ) ); //TODO: is this OK to call Engine Utils? + const TMemSpySizeText sizeText( MemSpyUiUtils::FormatSizeText( size, 0 ) ); HBufC* tempName = HBufC::NewL( iKernelObjects[i]->Name().Length() + 32 ); - //HBufC* tempName = HBufC::NewL( KMaxFullName ); + CleanupStack::PushL( tempName ); TPtr tempNamePtr( tempName->Des() ); tempNamePtr.Copy( iKernelObjects[i]->Name() ); @@ -118,7 +118,7 @@ _LIT(KNameFormat, "\t%S\t\t%d item"); TPtr pName( tempName->Des() ); // - const TPtrC pType( TypeAsString( iKernelObjects[i]->Type() ) ); + const TPtrC pType( MemSpyUiUtils::TypeAsString( iKernelObjects[i]->Type() ) ); // pName.Format( KNameFormat, &pType, count ); // @@ -137,19 +137,6 @@ CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); listbox->Model()->SetItemTextArray( model ); listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); - - /* - // Take ownership of new model - CMemSpyEngineHelperKernelContainers& kernelContainerManager = iEngine.HelperKernelContainers(); - CMemSpyEngineGenericKernelObjectContainer* model = kernelContainerManager.ObjectsAllL(); - delete iModel; - iModel = model; - - // Set up list box - CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); - listbox->Model()->SetItemTextArray( model ); - listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); - */ } @@ -174,96 +161,5 @@ void CMemSpyViewKernelContainers::OnCmdOutputAllContainerContentsL() { - iMemSpySession.OutputAllContainerContents(); - - /* - CMemSpyEngineOutputSink& sink = iEngine.Sink(); - iModel->OutputL( sink ); - */ + iMemSpySession.OutputAllContainerContents(); } - -//formating methods -TPtrC CMemSpyViewKernelContainers::TypeAsString( TMemSpyDriverContainerType aType ) - { - _LIT( KTypeUnknown, "Unknown Type" ); - _LIT( KTypeThread, "Thread" ); - _LIT( KTypeProcess, "Process" ); - _LIT( KTypeChunk, "Chunk" ); - _LIT( KTypeLibrary, "Library" ); - _LIT( KTypeSemaphore, "Semaphore" ); - _LIT( KTypeMutex, "Mutex" ); - _LIT( KTypeTimer, "Timer" ); - _LIT( KTypeServer, "Server" ); - _LIT( KTypeSession, "Session" ); - _LIT( KTypeLogicalDevice, "Logical Device" ); - _LIT( KTypePhysicalDevice, "Physical Device" ); - _LIT( KTypeLogicalChannel, "Logical Channel" ); - _LIT( KTypeChangeNotifier, "Change Notifier" ); - _LIT( KTypeUndertaker, "Undertaker" ); - _LIT( KTypeMsgQueue, "Msg. Queue" ); - _LIT( KTypePropertyRef, "Property Ref." ); - _LIT( KTypeCondVar, "Conditional Var." ); - // - TPtrC pType( KTypeUnknown ); - // - switch( aType ) - { - case EMemSpyDriverContainerTypeThread: - pType.Set( KTypeThread ); - break; - case EMemSpyDriverContainerTypeProcess: - pType.Set( KTypeProcess ); - break; - case EMemSpyDriverContainerTypeChunk: - pType.Set( KTypeChunk ); - break; - case EMemSpyDriverContainerTypeLibrary: - pType.Set( KTypeLibrary ); - break; - case EMemSpyDriverContainerTypeSemaphore: - pType.Set( KTypeSemaphore ); - break; - case EMemSpyDriverContainerTypeMutex: - pType.Set( KTypeMutex ); - break; - case EMemSpyDriverContainerTypeTimer: - pType.Set( KTypeTimer ); - break; - case EMemSpyDriverContainerTypeServer: - pType.Set( KTypeServer ); - break; - case EMemSpyDriverContainerTypeSession: - pType.Set( KTypeSession ); - break; - case EMemSpyDriverContainerTypeLogicalDevice: - pType.Set( KTypeLogicalDevice ); - break; - case EMemSpyDriverContainerTypePhysicalDevice: - pType.Set( KTypePhysicalDevice ); - break; - case EMemSpyDriverContainerTypeLogicalChannel: - pType.Set( KTypeLogicalChannel ); - break; - case EMemSpyDriverContainerTypeChangeNotifier: - pType.Set( KTypeChangeNotifier ); - break; - case EMemSpyDriverContainerTypeUndertaker: - pType.Set( KTypeUndertaker ); - break; - case EMemSpyDriverContainerTypeMsgQueue: - pType.Set( KTypeMsgQueue ); - break; - case EMemSpyDriverContainerTypePropertyRef: - pType.Set( KTypePropertyRef ); - break; - case EMemSpyDriverContainerTypeCondVar: - pType.Set( KTypeCondVar ); - break; - - default: - break; - } - // - return pType; - } - diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyViewKernelHeap.cpp --- a/memspyui/ui/avkon/src/MemSpyViewKernelHeap.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyViewKernelHeap.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -107,20 +107,7 @@ CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); listbox->Model()->SetItemTextArray( model ); - listbox->Model()->SetOwnershipType( ELbmOwnsItemArray ); - - /* - // Get list contents - TMemSpyHeapInfo heapInfo; - iEngine.HelperHeap().GetHeapInfoKernelL( heapInfo ); - CMemSpyEngineOutputList* list = iEngine.HelperHeap().NewHeapSummaryShortLC( heapInfo ); - - // Set up list box - CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); - listbox->Model()->SetItemTextArray( list ); - listbox->Model()->SetOwnershipType( ELbmOwnsItemArray ); - CleanupStack::Pop( list ); - */ + listbox->Model()->SetOwnershipType( ELbmOwnsItemArray ); } diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyViewKernelObjects.cpp --- a/memspyui/ui/avkon/src/MemSpyViewKernelObjects.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyViewKernelObjects.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -624,7 +624,7 @@ void CMemSpyViewKernelObjects::CreateTabsL() { TMemSpyDriverContainerType type = iKernelObjectItems[ iListBox->CurrentItemIndex() ]->Type(); - const TPtrC pType( TypeAsString( type ) ); + const TPtrC pType( MemSpyUiUtils::TypeAsString( type ) ); CEikStatusPane* statusPane = static_cast ( iEikonEnv->EikAppUi() )->StatusPane(); TUid uid; @@ -634,89 +634,6 @@ iNaviPane->PushL(*iNavDecorator); } -TPtrC CMemSpyViewKernelObjects::TypeAsString( TMemSpyDriverContainerType aType ) - { - _LIT( KTypeUnknown, "Unknown Type" ); - _LIT( KTypeThread, "Thread" ); - _LIT( KTypeProcess, "Process" ); - _LIT( KTypeChunk, "Chunk" ); - _LIT( KTypeLibrary, "Library" ); - _LIT( KTypeSemaphore, "Semaphore" ); - _LIT( KTypeMutex, "Mutex" ); - _LIT( KTypeTimer, "Timer" ); - _LIT( KTypeServer, "Server" ); - _LIT( KTypeSession, "Session" ); - _LIT( KTypeLogicalDevice, "Logical Device" ); - _LIT( KTypePhysicalDevice, "Physical Device" ); - _LIT( KTypeLogicalChannel, "Logical Channel" ); - _LIT( KTypeChangeNotifier, "Change Notifier" ); - _LIT( KTypeUndertaker, "Undertaker" ); - _LIT( KTypeMsgQueue, "Msg. Queue" ); - _LIT( KTypePropertyRef, "Property Ref." ); - _LIT( KTypeCondVar, "Conditional Var." ); - // - TPtrC pType( KTypeUnknown ); - // - switch( aType ) - { - case EMemSpyDriverContainerTypeThread: - pType.Set( KTypeThread ); - break; - case EMemSpyDriverContainerTypeProcess: - pType.Set( KTypeProcess ); - break; - case EMemSpyDriverContainerTypeChunk: - pType.Set( KTypeChunk ); - break; - case EMemSpyDriverContainerTypeLibrary: - pType.Set( KTypeLibrary ); - break; - case EMemSpyDriverContainerTypeSemaphore: - pType.Set( KTypeSemaphore ); - break; - case EMemSpyDriverContainerTypeMutex: - pType.Set( KTypeMutex ); - break; - case EMemSpyDriverContainerTypeTimer: - pType.Set( KTypeTimer ); - break; - case EMemSpyDriverContainerTypeServer: - pType.Set( KTypeServer ); - break; - case EMemSpyDriverContainerTypeSession: - pType.Set( KTypeSession ); - break; - case EMemSpyDriverContainerTypeLogicalDevice: - pType.Set( KTypeLogicalDevice ); - break; - case EMemSpyDriverContainerTypePhysicalDevice: - pType.Set( KTypePhysicalDevice ); - break; - case EMemSpyDriverContainerTypeLogicalChannel: - pType.Set( KTypeLogicalChannel ); - break; - case EMemSpyDriverContainerTypeChangeNotifier: - pType.Set( KTypeChangeNotifier ); - break; - case EMemSpyDriverContainerTypeUndertaker: - pType.Set( KTypeUndertaker ); - break; - case EMemSpyDriverContainerTypeMsgQueue: - pType.Set( KTypeMsgQueue ); - break; - case EMemSpyDriverContainerTypePropertyRef: - pType.Set( KTypePropertyRef ); - break; - case EMemSpyDriverContainerTypeCondVar: - pType.Set( KTypeCondVar ); - break; - - default: - break; - } - // - return pType; - } void CMemSpyViewKernelObjects::DetailsL() { diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyViewProcesses.cpp --- a/memspyui/ui/avkon/src/MemSpyViewProcesses.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyViewProcesses.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -37,39 +37,18 @@ #include "MemSpyViewThreads.h" #include "MemSpyViewMainMenu.h" #include "MemSpyContainerObserver.h" +#include "MemSpyUiUtils.h" // Constants const TInt KMemSpyMaxSearchTextLength = 30; const TInt KMemSpyMaxSearchTextLengthWithWildcards = KMemSpyMaxSearchTextLength + 4; -/* -CMemSpyViewProcesses::CMemSpyViewProcesses( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver ) -: CMemSpyViewBase( aEngine, aObserver ) - { - } - - -CMemSpyViewProcesses::CMemSpyViewProcesses( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyProcess& aProcess ) -: CMemSpyViewBase( aEngine, aObserver ), iCurrentProcess( &aProcess ) - { - iCurrentProcess->Open(); - } -*/ - CMemSpyViewProcesses::CMemSpyViewProcesses( RMemSpySession& aSession, MMemSpyViewObserver& aObserver ) : CMemSpyViewBase( aSession, aObserver ) { } -/* -CMemSpyViewProcesses::CMemSpyViewProcesses( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyProcess& aProcess ) -: CMemSpyViewBase( aEngine, aObserver ), iCurrentProcess( &aProcess ) - { - iCurrentProcess->Open(); - } -*/ - CMemSpyViewProcesses::CMemSpyViewProcesses( RMemSpySession& aEngine, MMemSpyViewObserver& aObserver, TProcessId aId ) : CMemSpyViewBase( aEngine, aObserver ), iCurrentProcessId( aId ) { @@ -97,17 +76,18 @@ iMatcherBuffer = HBufC::NewL( KMemSpyMaxSearchTextLengthWithWildcards ); // iSearchField = CAknSearchField::NewL( *this, CAknSearchField::ESearch, NULL, KMemSpyMaxSearchTextLength ); + iSearchField->SetObserver( this ); iSearchField->SetFocus( ETrue ); iSearchField->SetComponentsToInheritVisibility( ETrue ); // - if ( aSelectionRune ) + if ( iCurrentProcessId > 0 ) { TInt index = 0; - TProcessId selectedItem = aSelectionRune; //static_cast< TProcessId >( *aSelectionRune ); + // TProcessId selectedItem = aSelectionRune; //static_cast< TProcessId >( *aSelectionRune ); for( TInt i=0; iId() == selectedItem ) + if( iProcesses[i]->Id() == iCurrentProcessId ) { index = i; } @@ -119,7 +99,7 @@ HandleListBoxItemSelectedL( index ); } } - else if ( iProcesses.Count() > 0 ) //TODO: to solve item selection when come back from previous view + else if ( iProcesses.Count() > 0 ) { iListBox->SetCurrentItemIndex( 0 ); HandleListBoxItemSelectedL( 0 ); @@ -164,7 +144,7 @@ CMemSpyViewBase* CMemSpyViewProcesses::PrepareChildViewL() { - CMemSpyViewThreads* child = new(ELeave) CMemSpyViewThreads( iMemSpySession, iObserver, iProcesses[iListBox->CurrentItemIndex()]->Id() ); + CMemSpyViewThreads* child = new(ELeave) CMemSpyViewThreads( iMemSpySession, iObserver, iProcesses[iListBox->CurrentItemIndex()]->Id(), 0 ); CleanupStack::PushL( child ); child->ConstructL( Rect(), *Parent() ); CleanupStack::Pop( child ); @@ -379,9 +359,9 @@ iModel = new (ELeave) CDesC16ArrayFlat( iProcesses.Count() + 1); //array for formated items _LIT( KTab, "\t" ); - //iModel = FormatModel( iProcesses ); //TODO Format model method with advanced formatting + iModel = FormatModel( iProcesses ); //TODO Format model method with advanced formatting - + /* for( TInt i=0; i < iProcesses.Count(); i++ ) { HBufC* tempName = HBufC::NewL( iProcesses[i]->Name().Length() + 16 ); @@ -393,7 +373,7 @@ CleanupStack::PopAndDestroy( tempName ); } - + */ CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); //listbox->Model()->SetItemTextArray( &iEngine.Container() ); listbox->Model()->SetItemTextArray( iModel ); @@ -578,7 +558,7 @@ //Model formating methods //TODO: to be debbuged -/* + CDesCArrayFlat* CMemSpyViewProcesses::FormatModel( RArray aProcesses ) { model = new (ELeave) CDesC16ArrayFlat( iProcesses.Count() + 16 ); //array for formated items @@ -592,17 +572,18 @@ tempNamePtr.Copy( aProcesses[i]->Name() ); TBuf<10> priority; - AppendPriority( priority, aProcesses[i]->Priority() ); + TProcessPriority tempPriority = aProcesses[i]->Priority(); + MemSpyUiUtils::AppendPriority( priority, tempPriority ); // Convert the full name to the format we want in the UI TBuf name; TMemSpyTruncateOverflow overflow; //included from EngineUtils TODO: to consider if this is needed to be removed or left there - - name.AppendFormat( KMemSpyProcessNameFormatSpecBasicName, &overflow, tempNamePtr, aProcesses[i]->SID() ); + TUint32 tempSID = aProcesses[i]->SID(); + name.AppendFormat( KMemSpyProcessNameFormatSpecBasicName, &overflow, tempName, tempSID ); //tempNamePtr if( aProcesses[i]->ExitType() != EExitPending ) // instead of IsDead() method { - AppendExitInfo( name, aProcesses[i]->ExitType(), aProcesses[i]->ExitReason(), aProcesses[i]->ExitCategory() ); + MemSpyUiUtils::AppendExitInfo( name, aProcesses[i]->ExitType(), aProcesses[i]->ExitReason(), aProcesses[i]->ExitCategory() ); } else { @@ -617,7 +598,7 @@ return model; } - +/* void CMemSpyViewProcesses::AppendPriority( TDes& aDes, TProcessPriority aPriority ) { switch( aPriority ) @@ -674,7 +655,8 @@ aDes.AppendFormat( KAbnormalFormatSpec, &overflow, &aExitCategory, aExitReason ); } } - +*/ +/* void CMemSpyViewProcesses::AppendExitType( TDes& aDes, TExitType aType ) { _LIT( KExitTypeKilled, "Killed" ); @@ -702,3 +684,4 @@ } } */ + diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyViewThreadInfoItemActiveObject.cpp --- a/memspyui/ui/avkon/src/MemSpyViewThreadInfoItemActiveObject.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyViewThreadInfoItemActiveObject.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -25,14 +25,14 @@ #include #include #include +#include // User includes #include "MemSpyContainerObserver.h" - -CMemSpyViewThreadInfoItemActiveObjectBase::CMemSpyViewThreadInfoItemActiveObjectBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer ) -: CMemSpyViewThreadInfoItemGeneric( aEngine, aObserver, aContainer, EMemSpyThreadInfoItemTypeActiveObject ) +CMemSpyViewThreadInfoItemActiveObjectBase::CMemSpyViewThreadInfoItemActiveObjectBase(RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aProcId, TThreadId aId, TMemSpyThreadInfoItemType aType ) +: CMemSpyViewThreadInfoItemGeneric( aSession, aObserver, aProcId, aId, EMemSpyThreadInfoItemTypeActiveObject ) { } @@ -40,6 +40,7 @@ TBool CMemSpyViewThreadInfoItemActiveObjectBase::HandleCommandL( TInt aCommand ) { TBool handled = ETrue; + /* // switch ( aCommand ) { @@ -51,6 +52,7 @@ break; } // + * */ return handled; } @@ -59,20 +61,23 @@ { if ( aResourceId == R_MEMSPY_MENUPANE ) { - aMenuPane->SetItemDimmed( EMemSpyCmdActiveObject, Thread().IsDead() ); + // aMenuPane->SetItemDimmed( EMemSpyCmdActiveObject, Thread().IsDead() ); } } CMemSpyEngineActiveObjectArray& CMemSpyViewThreadInfoItemActiveObjectBase::ActiveObjectArray() const { - CMemSpyThreadInfoActiveObjects* activeObjectArray = static_cast< CMemSpyThreadInfoActiveObjects* >( iInfoItem ); - return activeObjectArray->Array(); + // CMemSpyThreadInfoActiveObjects* activeObjectArray = static_cast< CMemSpyThreadInfoActiveObjects* >( iInfoItem ); + // return activeObjectArray->Array(); } void CMemSpyViewThreadInfoItemActiveObjectBase::OnCmdWriteAOListingL() { + iMemSpySession.OutputAOListL( ThreadId(), EMemSpyThreadInfoItemTypeActiveObject ); + + /* CMemSpyEngineActiveObjectArray& objects = ActiveObjectArray(); // Begin a new data stream @@ -100,6 +105,7 @@ // End data stream iEngine.Sink().DataStreamEndL(); + */ } @@ -112,8 +118,8 @@ -CMemSpyViewThreadInfoItemActiveObject::CMemSpyViewThreadInfoItemActiveObject( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TThreadId aId, TMemSpyThreadInfoItemType aType ) -: CMemSpyViewThreadInfoItemActiveObjectBase( aSession, aObserver, aId, aType ) +CMemSpyViewThreadInfoItemActiveObject::CMemSpyViewThreadInfoItemActiveObject( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aProcId, TThreadId aId, TMemSpyThreadInfoItemType aType ) +: CMemSpyViewThreadInfoItemActiveObjectBase( aSession, aObserver, aProcId, aId, aType ) { } @@ -127,6 +133,7 @@ SetTitleL( KTitle ); // Try to select the correct server + /* TODO: to consider this CMemSpyThreadInfoHandleObjectBase* infoItem = static_cast< CMemSpyThreadInfoHandleObjectBase* >( iInfoItem ); TInt selectedIndex = 0; if ( aSelectionRune ) @@ -142,9 +149,12 @@ // Select item if ( infoItem->DetailsCount() > 0 ) { - iListBox->SetCurrentItemIndex( selectedIndex ); - HandleListBoxItemSelectedL( selectedIndex ); + */ + iListBox->SetCurrentItemIndex( 0 ); //selectedIndex + HandleListBoxItemSelectedL( 0 ); //selectedIndex + /* } + */ } @@ -157,7 +167,7 @@ CMemSpyViewBase* CMemSpyViewThreadInfoItemActiveObject::PrepareChildViewL() { CMemSpyViewBase* child = NULL; - + /* // Get current entry address TInt index = iListBox->CurrentItemIndex(); if ( index > 0 ) @@ -177,6 +187,8 @@ } } // + * + */ return child; } @@ -189,7 +201,7 @@ - +/* CMemSpyViewThreadInfoItemActiveObjectDetails::CMemSpyViewThreadInfoItemActiveObjectDetails( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyThreadInfoContainer& aContainer, TAny* aObjectAddress ) : CMemSpyViewThreadInfoItemActiveObjectBase( aEngine, aObserver, aContainer ), iObjectAddress( aObjectAddress ) { @@ -233,9 +245,4 @@ listbox->Model()->SetItemTextArray( &object ); listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); } - - - - - - +*/ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyViewThreadInfoItemGeneric.cpp --- a/memspyui/ui/avkon/src/MemSpyViewThreadInfoItemGeneric.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyViewThreadInfoItemGeneric.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -63,18 +63,7 @@ { const TPtrC pTitle( MemSpyUiUtils::ThreadInfoItemNameByType( iType ) ); SetTitleL( pTitle ); - // - /* TODO: - if ( iInfoItem->IsReady() == EFalse ) - { -#ifdef _DEBUG - RDebug::Printf( "CMemSpyViewThreadInfoItemGeneric::ConstructL() - show wait note - item not ready, iType: %d", iInfoItem->Type() ); -#endif - // Wait for engine data to be made ready... - ShowWaitNoteL(); - } - */ CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); } @@ -202,7 +191,7 @@ { CMemSpyViewThreadInfoItemList* parent = new(ELeave) CMemSpyViewThreadInfoItemList( iMemSpySession, iObserver, iParentProcessId, iThreadId ); CleanupStack::PushL( parent ); - parent->ConstructL( Rect(), *Parent() ); //TODO: arguent removed: iInfoItem + parent->ConstructL( Rect(), *Parent(), iType ); CleanupStack::Pop( parent ); return parent; } @@ -232,16 +221,14 @@ for( TInt i=0; iCaption().Length() + iThreadInfoItems[i]->Value().Length() + 30 ); + HBufC* combined = HBufC::NewLC( iThreadInfoItems[i]->Caption().Length() + iThreadInfoItems[i]->Value().Length() + 30 ); /* - else if ( iCombined->Des().MaxLength() < requiredLength ) + else if ( combined->Des().MaxLength() < requiredLength ) { - iCombined = iCombined->ReAllocL( requiredLength ); - }*/ - - CleanupStack::PushL( iCombined ); + combined = combined->ReAllocL( requiredLength ); + }*/ - TPtr pCombined( iCombined->Des() ); + TPtr pCombined( combined->Des() ); pCombined.Zero(); pCombined.Copy( _L("\t") ); if( iThreadInfoItems[i]->Caption() != KNullDesC ) @@ -252,9 +239,7 @@ pCombined.Append( iThreadInfoItems[i]->Value() ); } - iModel->AppendL( pCombined ); - - CleanupStack::PopAndDestroy( iCombined ); + iModel->AppendL( pCombined ); } CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyViewThreadInfoItemHeap.cpp --- a/memspyui/ui/avkon/src/MemSpyViewThreadInfoItemHeap.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyViewThreadInfoItemHeap.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -26,11 +26,13 @@ #include #include #include +#include // User includes #include "MemSpyContainerObserver.h" #include "MemSpyViewThreads.h" #include "MemSpyViewThreadInfoItemHeap.h" +#include "MemSpyAppUi.h" /* @@ -74,19 +76,19 @@ void CMemSpyViewThreadInfoItemHeap::OnCmdHeapDataL() { - //iEngine.HelperHeap().OutputHeapDataUserL( Thread() ); //TODO + iMemSpySession.OutputThreadHeapDataL( ThreadId() ); } void CMemSpyViewThreadInfoItemHeap::OnCmdHeapCellListingL() { - //iEngine.HelperHeap().OutputCellListingUserL( Thread() ); //TODO + iMemSpySession.OutputThreadCellListL( ThreadId() ); } void CMemSpyViewThreadInfoItemHeap::OnCmdHeapInfoL() { - //iEngine.HelperHeap().OutputHeapInfoUserL( Thread() ); //TODO + iMemSpySession.OutputHeapInfoUserL( ThreadId() ); } diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyViewThreadInfoItemList.cpp --- a/memspyui/ui/avkon/src/MemSpyViewThreadInfoItemList.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyViewThreadInfoItemList.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -54,37 +54,42 @@ CMemSpyViewThreadInfoItemList::~CMemSpyViewThreadInfoItemList() { - /* TODO: to consider what to do with this - delete iIdleResetListboxTimer; - + /* TODO: TRAP_IGNORE( CMemSpyThreadInfoContainer& container = iThread.InfoContainerL(); container.ObserverRemove( *this ); ); - - if ( iCurrentInfoItem ) - { - iCurrentInfoItem->Close(); - } - */ + */ } -void CMemSpyViewThreadInfoItemList::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) +void CMemSpyViewThreadInfoItemList::ConstructL( const TRect& aRect, CCoeControl& aContainer, TMemSpyThreadInfoItemType aType ) { _LIT( KTitle, "Thread Objects" ); SetTitleL( KTitle ); // - iIdleResetListboxTimer = CPeriodic::NewL( CActive::EPriorityIdle ); - // - /* + //iIdleResetListboxTimer = CPeriodic::NewL( CActive::EPriorityIdle ); + /* TODO: to solve observer CMemSpyThreadInfoContainer& container = iThread.InfoContainerL(); container.ObserverAddL( *this ); - */ + */ + CMemSpyViewBase::ConstructL( aRect, aContainer ); // - CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); - // + if( aType > EMemSpyThreadInfoItemTypeFirst || aType < EMemSpyThreadInfoItemTypeLast ) + { + TInt index(aType); + if ( index >= 0 && index < iListBox->Model()->NumberOfItems() ) + { + iListBox->SetCurrentItemIndex( index ); + HandleListBoxItemSelectedL( index ); + } + } + else + { + iListBox->SetCurrentItemIndex( 0 ); + HandleListBoxItemSelectedL( 0 ); + } /*if ( aSelectionRune ) { CMemSpyThreadInfoItemBase* selectedItem = reinterpret_cast< CMemSpyThreadInfoItemBase* >( aSelectionRune ); @@ -97,8 +102,8 @@ } else if ( container.MdcaCount() > 0 ) {*/ - iListBox->SetCurrentItemIndex( 0 ); //for now - HandleListBoxItemSelectedL( 0 ); + //iListBox->SetCurrentItemIndex( 0 ); + //HandleListBoxItemSelectedL( 0 ); //} } @@ -123,7 +128,7 @@ CMemSpyViewBase* CMemSpyViewThreadInfoItemList::PrepareParentViewL() { - CMemSpyViewBase* parent = new(ELeave) CMemSpyViewThreads( iMemSpySession, iObserver, iParentProcessId ); + CMemSpyViewBase* parent = new(ELeave) CMemSpyViewThreads( iMemSpySession, iObserver, iParentProcessId, iThreadId ); CleanupStack::PushL( parent ); parent->ConstructL( Rect(), *Parent() ); CleanupStack::Pop( parent ); @@ -235,7 +240,7 @@ void CMemSpyViewThreadInfoItemList::OnCmdInfoHandlesL() { - //iThread.InfoContainerForceSyncronousConstructionL().PrintL(); //TODO: + iMemSpySession.OutputThreadInfoHandlesL( iThreadId ); } @@ -387,18 +392,6 @@ { iCurrentInfoItemId = aIndex; - /* - if ( iCurrentInfoItem ) - { - CMemSpyThreadInfoItemBase* item = iCurrentInfoItem; - iCurrentInfoItem = NULL; - item->Close(); - } - - // Identify the type of item to display... - iCurrentInfoItem = &iThread.InfoContainerL().Item( aIndex ); - iCurrentInfoItem->Open(); -*/ // Notify observer about item selection ReportEventL( MMemSpyViewObserver::EEventItemSelected ); } diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyViewThreadInfoItemStack.cpp --- a/memspyui/ui/avkon/src/MemSpyViewThreadInfoItemStack.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyViewThreadInfoItemStack.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -26,11 +26,13 @@ #include #include #include +#include // User includes #include "MemSpyContainerObserver.h" #include "MemSpyViewThreads.h" #include "MemSpyViewThreadInfoItemHeap.h" +#include "MemSpyAppUi.h" @@ -69,19 +71,19 @@ void CMemSpyViewThreadInfoItemStack::OnCmdStackInfoL() { - // TODO iEngine.HelperStack().OutputStackInfoL( Thread() ); + iMemSpySession.OutputStackInfoL( ThreadId() ); } void CMemSpyViewThreadInfoItemStack::OnCmdStackDataUserL() { - // TODO iEngine.HelperStack().OutputStackDataL( Thread(), EMemSpyDriverDomainUser ); + iMemSpySession.OutputStackDataL( ThreadId(), EMemSpyDriverDomainUser ); } void CMemSpyViewThreadInfoItemStack::OnCmdStackDataKernelL() { - // TODO iEngine.HelperStack().OutputStackDataL( Thread(), EMemSpyDriverDomainKernel ); + iMemSpySession.OutputStackDataL( ThreadId(), EMemSpyDriverDomainKernel ); } diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyViewThreads.cpp --- a/memspyui/ui/avkon/src/MemSpyViewThreads.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyViewThreads.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -38,15 +38,8 @@ -/* -CMemSpyViewThreads::CMemSpyViewThreads( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyProcess& aProcess ) -: CMemSpyViewBase( aEngine, aObserver ), iParentProcess( aProcess ) - { - iParentProcess.Open(); - } -*/ -CMemSpyViewThreads::CMemSpyViewThreads( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aId ) -: CMemSpyViewBase( aSession, aObserver ), iParentProcessId( aId ) +CMemSpyViewThreads::CMemSpyViewThreads( RMemSpySession& aSession, MMemSpyViewObserver& aObserver, TProcessId aId, TThreadId aThreadId ) +: CMemSpyViewBase( aSession, aObserver ), iParentProcessId( aId ), iCurrentThreadId( aThreadId ) { } @@ -58,30 +51,33 @@ void CMemSpyViewThreads::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) { + iMemSpySession.GetThreadsL( iParentProcessId, iThreads ); + _LIT( KTitle, "Threads" ); SetTitleL( KTitle ); // CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); - // - if ( aSelectionRune ) - { - iListBox->SetCurrentItemIndex( 0 ); //for now + // + if( iCurrentThreadId > 0 ) + { + for( TInt i = 0; i < iThreads.Count() ; i++ ) + { + if( iThreads[i]->Id() == iCurrentThreadId ) + { + const TInt index = i; + if ( index >= 0 && index < iListBox->Model()->NumberOfItems() ) + { + iListBox->SetCurrentItemIndex( index ); + HandleListBoxItemSelectedL( index ); + } + } + } + } + else if( iThreads.Count() > 0 ) + { + iListBox->SetCurrentItemIndex( 0 ); HandleListBoxItemSelectedL( 0 ); - /* TODO: - CMemSpyThread* selectedItem = reinterpret_cast< CMemSpyThread* >( aSelectionRune ); - const TInt index = iParentProcess.ThreadIndexById( selectedItem->Id() ); - if ( index >= 0 && index < iListBox->Model()->NumberOfItems() ) - { - iListBox->SetCurrentItemIndex( index ); - HandleListBoxItemSelectedL( index ); - } - */ - } - //else if ( iParentProcess.Count() > 0 ) - // { - iListBox->SetCurrentItemIndex( 0 ); - HandleListBoxItemSelectedL( 0 ); - // } + } } @@ -125,7 +121,7 @@ { CMemSpyViewThreadInfoItemList* child = new(ELeave) CMemSpyViewThreadInfoItemList( iMemSpySession, iObserver, iParentProcessId, iCurrentThreadId ); CleanupStack::PushL( child ); - child->ConstructL( Rect(), *Parent() ); + child->ConstructL( Rect(), *Parent(), EMemSpyThreadInfoItemTypeFirst ); CleanupStack::Pop( child ); return child; } @@ -331,16 +327,13 @@ void CMemSpyViewThreads::OnCmdInfoHandlesL() { - /* - CMemSpyThread& thread = CurrentThread(); - thread.InfoContainerForceSyncronousConstructionL().PrintL(); - */ + iMemSpySession.OutputThreadInfoHandlesL( iCurrentThreadId ); } void CMemSpyViewThreads::SetListBoxModelL() { - iMemSpySession.GetThreadsL( iParentProcessId, iThreads ); + //iMemSpySession.GetThreadsL( iParentProcessId, iThreads ); iModel = new (ELeave) CDesC16ArrayFlat( iThreads.Count() ); //array for formated items @@ -359,8 +352,7 @@ CleanupStack::PopAndDestroy( tempName ); } - CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); - //listbox->Model()->SetItemTextArray( &iParentProcess ); + CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); listbox->Model()->SetItemTextArray( iModel ); listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); } diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/avkon/src/MemSpyViewWindowGroups.cpp --- a/memspyui/ui/avkon/src/MemSpyViewWindowGroups.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/avkon/src/MemSpyViewWindowGroups.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -204,6 +204,7 @@ void CMemSpyViewWindowGroups::OnCmdEndL( TInt aCommand ) { + /* TBool doTerminate = ETrue; CMemSpyEngineObjectContainer& container = iEngine.Container(); @@ -252,6 +253,7 @@ } } RefreshL(); + */ } diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/hb.pro --- a/memspyui/ui/hb/hb.pro Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/hb.pro Tue Jul 06 14:17:03 2010 +0300 @@ -27,6 +27,7 @@ HEADERS += inc/enginewrapper.h \ inc/viewmanager.h \ inc/memspyview.h \ + inc/memspylistview.h \ inc/memspymainview.h \ inc/memspyprocessview.h \ inc/memspythreadview.h \ @@ -34,12 +35,17 @@ inc/memspythreaddetailview.h \ inc/memspykernelobjecttypeview.h \ inc/memspykernelobjectview.h \ - inc/memspykernelobjectdetailview.h + inc/memspykernelobjectdetailview.h \ + inc/memspytrackingview.h \ + inc/memspyswmtview.h \ + inc/memspyheapdumpsview.h \ + inc/memspysettingsview.h SOURCES += src/main.cpp \ src/enginewrapper.cpp \ src/viewmanager.cpp \ src/memspyview.cpp \ + src/memspylistview.cpp \ src/memspymainview.cpp \ src/memspyprocessview.cpp \ src/memspythreadview.cpp \ @@ -47,7 +53,11 @@ src/memspythreaddetailview.cpp \ src/memspykernelobjecttypeview.cpp \ src/memspykernelobjectview.cpp \ - src/memspykernelobjectdetailview.cpp + src/memspykernelobjectdetailview.cpp \ + src/memspytrackingview.cpp \ + src/memspyswmtview.cpp \ + src/memspyheapdumpsview.cpp \ + src/memspysettingsview.cpp RESOURCES += diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/enginewrapper.h --- a/memspyui/ui/hb/inc/enginewrapper.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/inc/enginewrapper.h Tue Jul 06 14:17:03 2010 +0300 @@ -19,6 +19,8 @@ #define ENGINEWRAPPER_H_ #include +#include +#include #include @@ -102,6 +104,49 @@ ThreadInfoTypePDD = EMemSpyThreadInfoItemTypePDD, }; +enum DeviceWideOperation +{ + OutputPhoneInfo = 0, + + OutputDetailedPhoneInfo, + + OutputHeapInfo, + + OutputCompactHeapInfo, + + OutputHeapCellListing, + + OutputHeapData, + + OutputStackInfo, + + OutputCompactStackInfo, + + OutputUserStackData, + + OutputKernelStackData +}; + +enum SwmtMode +{ + SwmtModeBasic = 0, + SwmtModeFull, + SwmtModeCustom +}; + +enum HeapDumpsMode +{ + HeapDumpsModeKernel = 0, + HeapDumpsModeUser, + HeapDumpsModeBoth +}; + +enum OutputMode +{ + OutputModeTrace = 0, + OutputModeFile +}; + class MemSpyProcess { public: @@ -109,12 +154,23 @@ : mProcess(process) {} - virtual ~MemSpyProcess() { delete mProcess; } + virtual ~MemSpyProcess() { delete mProcess; } ProcessId id() const { return mProcess->Id(); } QString name() const { return QString((QChar*) mProcess->Name().Ptr(), mProcess->Name().Length()); } + QString exitInfo() const; + + int priority() const { return mProcess->Priority(); } + + int threadCount() const { return mProcess->ThreadCount(); } + + int sid() const { return mProcess->SID(); } + + int vid() const { return mProcess->VID(); } + + bool isDead() const { return mProcess->IsDead(); } private: CMemSpyApiProcess *mProcess; @@ -283,12 +339,151 @@ CMemSpyApiThreadInfoItem* mItem; }; -class EngineWrapper : public QObject +class MemSpyDwoProgressTracker : public QObject, public CActive +{ + Q_OBJECT + +public: + MemSpyDwoProgressTracker(RMemSpySession &session); + virtual ~MemSpyDwoProgressTracker(); + +public slots: + + void start(); + + void cancel(); + +protected: // from CActive + + virtual void RunL(); + + virtual void DoCancel(); + + virtual TInt RunError(TInt aError); + +signals: + void progress(int progress, const QString& processName); + +private: + TMemSpyDeviceWideOperationProgress mProgress; + RMemSpySession mSession; +}; + +class MemSpyDwoTracker : public QObject, public CActive +{ + Q_OBJECT + +public: + MemSpyDwoTracker(RMemSpySession &session, DeviceWideOperation operation); + virtual ~MemSpyDwoTracker(); + +public slots: + + void start(); + + void cancel(); + +protected: // from CActive + + virtual void RunL(); + + virtual void DoCancel(); + + virtual TInt RunError(TInt aError); + +signals: + void finished(int errorCode); + void progress(int progress, const QString& processName); + +private: + RMemSpySession mSession; + MemSpyDwoProgressTracker *mProgressTracker; + DeviceWideOperation mOperation; +}; + +class MemSpyAsyncTracker : public QObject, public CActive +{ + Q_OBJECT + +public: + + MemSpyAsyncTracker(RMemSpySession& session, void (RMemSpySession::*function)(TRequestStatus&)); + + void start(); + + virtual void RunL(); + + virtual void DoCancel(); + + virtual TInt RunError(TInt aError); + +signals: + + void finished(int errorCode); + +private: + void (RMemSpySession::*mFunction)(TRequestStatus&); + RMemSpySession& mSession; +}; + +class MemSpySwmtDumpTracker : public MemSpyAsyncTracker { public: + MemSpySwmtDumpTracker(RMemSpySession& session) : + MemSpyAsyncTracker(session, &RMemSpySession::ForceSwmtUpdate) + {} +}; + +class MemSpyKernelHeapDumpTracker : public MemSpyAsyncTracker +{ +public: + MemSpyKernelHeapDumpTracker(RMemSpySession& session) : + MemSpyAsyncTracker(session, &RMemSpySession::OutputKernelHeapData) + {} +}; + +class MemSpySettings : private QSettings +{ +public: + + MemSpySettings(); + + OutputMode outputMode() const; + void setOutputMode(OutputMode mode); + + QString outputPath() const; + void setOutputPath(const QString& path); + + int swmtTimerPeriod() const; + void setSwmtTimerPeriod(int period); + + SwmtMode swmtMode() const; + void setSwmtMode(SwmtMode mode); + + QVariantList swmtCategories() const; + void setSwmtCategories(const QVariantList& categories); + + HeapDumpsMode heapDumpsMode() const; + void setHeapDumpsMode(HeapDumpsMode mode); +}; + +class EngineWrapper : public QObject +{ + Q_OBJECT + +public: + EngineWrapper(); + virtual ~EngineWrapper(); + bool initialize(); + MemSpySettings& settings(); + + const MemSpySettings& settings() const; + + + QList getProcesses(); QList getThreads(ProcessId processId); @@ -301,9 +496,34 @@ QList getKernelObjects(int type); + MemSpyDwoTracker* createDeviceWideOperation(DeviceWideOperation operation); + + MemSpyKernelHeapDumpTracker* createKernelHeapDumpTracker(); + + MemSpySwmtDumpTracker* createSwmtDumpTracker(); + + void setSwmtSettings(SwmtMode mode, const QVariantList& categories); + + bool isSwmtRunning(); + + void startSwmt(int period); + + void stopSwmt(); + + void forceSwmtDump(); + + void outputKernelHeapData(); + + int outputThreadHeapData(const QString& filter); + + void updateOutputSettings(); + private: RMemSpySession mSession; + bool mSwmtRunning; + + MemSpySettings mSettings; }; #endif /* ENGINEWRAPPER_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspyheapdumpsview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memspyui/ui/hb/inc/memspyheapdumpsview.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,61 @@ +/* + * 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 MEMSPYHEAPDUMPSVIEW_H_ +#define MEMSPYHEAPDUMPSVIEW_H_ + +#include "memspyview.h" + +class HbDataFormModel; +class HbDataFormModelItem; + +class MemSpyHeapDumpsView : public MemSpyView +{ + Q_OBJECT + +public: + MemSpyHeapDumpsView(EngineWrapper &engine, ViewManager &viewManager); + virtual ~MemSpyHeapDumpsView(); + + void initialize(const QVariantMap& params); + +protected: + HbToolBar* createToolBar(); + + HbWidget* createCentralWidget(); + +private slots: + void modeChanged(int mode); + void dump(); + + void updateDwoProgress(int progress, const QString& processName); + void asyncOperationFinished(int errorCode); + + +private: + void removeFilterItem(); + void createFilterItem(); + +private: + HbDataFormModel* mModel; + HbDataFormModelItem* mModeItem; + HbDataFormModelItem* mFilterItem; + + HbProgressDialog* mDwoProgressDialog; +}; + +#endif /* MEMSPYHEAPDUMPSVIEW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspykernelobjectdetailview.h --- a/memspyui/ui/hb/inc/memspykernelobjectdetailview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/inc/memspykernelobjectdetailview.h Tue Jul 06 14:17:03 2010 +0300 @@ -18,18 +18,39 @@ #ifndef MEMSPYKERNELOBJECTDETAILVIEW_H_ #define MEMSPYKERNELOBJECTDETAILVIEW_H_ -#include "memspyview.h" +#include "memspylistview.h" -class MemSpyKernelObjectDetailView : public MemSpyView +class MemSpyKernelObjectDetailModel : public QAbstractListModel +{ +public: + MemSpyKernelObjectDetailModel(const QStringList& details, QObject *parent = 0); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + +private: + QStringList mDetails; +}; + +class MemSpyKernelObjectDetailView : public MemSpyListView { Q_OBJECT public: MemSpyKernelObjectDetailView(EngineWrapper &engine, ViewManager &viewManager) - : MemSpyView(engine, viewManager) {} + : MemSpyListView(engine, viewManager) {} protected: virtual void initialize(const QVariantMap& params); + + virtual bool isBreadCrumbVisible() const; + + virtual QString getBreadCrumbText() const; + +private: + QString mTypeName; + QString mObjectName; }; #endif /* MEMSPYKERNELOBJECTDETAILVIEW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspykernelobjecttypeview.h --- a/memspyui/ui/hb/inc/memspykernelobjecttypeview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/inc/memspykernelobjecttypeview.h Tue Jul 06 14:17:03 2010 +0300 @@ -18,7 +18,7 @@ #ifndef MEMSPYKERNELOBJECTTYPESVIEW_H_ #define MEMSPYKERNELOBJECTTYPESVIEW_H_ -#include "memspyview.h" +#include "memspylistview.h" #include "enginewrapper.h" class MemSpyKernelObjectTypeModel : public QAbstractListModel @@ -26,7 +26,7 @@ public: MemSpyKernelObjectTypeModel(EngineWrapper &engine, QObject *parent = 0); - ~MemSpyKernelObjectTypeModel(); + virtual ~MemSpyKernelObjectTypeModel(); int rowCount(const QModelIndex &parent = QModelIndex()) const; @@ -37,15 +37,17 @@ private: QList mObjectTypes; + + QStringList mKernelObjectNames; }; -class MemSpyKernelObjectTypeView : public MemSpyView +class MemSpyKernelObjectTypeView : public MemSpyListView { Q_OBJECT public: MemSpyKernelObjectTypeView(EngineWrapper &engine, ViewManager &viewManager) - : MemSpyView(engine, viewManager) {} + : MemSpyListView(engine, viewManager) {} protected: virtual void initialize(const QVariantMap& params); diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspykernelobjectview.h --- a/memspyui/ui/hb/inc/memspykernelobjectview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/inc/memspykernelobjectview.h Tue Jul 06 14:17:03 2010 +0300 @@ -18,7 +18,7 @@ #ifndef MEMSPYKERNELOBJECTVIEW_H_ #define MEMSPYKERNELOBJECTVIEW_H_ -#include "memspyview.h" +#include "memspylistview.h" #include "enginewrapper.h" class MemSpyKernelObjectModel : public QAbstractListModel @@ -37,16 +37,20 @@ }; -class MemSpyKernelObjectView : public MemSpyView +class MemSpyKernelObjectView : public MemSpyListView { Q_OBJECT public: MemSpyKernelObjectView(EngineWrapper &engine, ViewManager &viewManager) - : MemSpyView(engine, viewManager) {} + : MemSpyListView(engine, viewManager) {} protected: virtual void initialize(const QVariantMap& params); + + virtual bool isBreadCrumbVisible() const; + + virtual QString getBreadCrumbText() const; private slots: void itemClicked(const QModelIndex& index); diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspylistview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memspyui/ui/hb/inc/memspylistview.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,38 @@ +/* + * 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 MEMSPYLISTVIEW_H_ +#define MEMSPYLISTVIEW_H_ + +#include + +#include "memspyview.h" + +class MemSpyListView : public MemSpyView + { +public: + MemSpyListView(EngineWrapper &engine, ViewManager &viewManager) : + MemSpyView(engine, viewManager) {} + +protected: + virtual HbWidget* createCentralWidget(); + +protected: + HbListView mListView; + }; + +#endif /* MEMSPYLISTVIEW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspymainview.h --- a/memspyui/ui/hb/inc/memspymainview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/inc/memspymainview.h Tue Jul 06 14:17:03 2010 +0300 @@ -18,17 +18,18 @@ #ifndef MEMSPYMAINVIEW_H_ #define MEMSPYMAINVIEW_H_ -#include "memspyview.h" +#include "memspylistview.h" -class MemSpyMainView : public MemSpyView +class MemSpyMainView : public MemSpyListView { Q_OBJECT public: MemSpyMainView(EngineWrapper &engine, ViewManager &viewManager) - : MemSpyView(engine, viewManager) {} + : MemSpyListView(engine, viewManager) {} protected: virtual void initialize(const QVariantMap& params); + virtual bool isBreadCrumbVisible() const; public slots: void itemClicked(const QModelIndex& index); diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspyprocessview.h --- a/memspyui/ui/hb/inc/memspyprocessview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/inc/memspyprocessview.h Tue Jul 06 14:17:03 2010 +0300 @@ -20,7 +20,7 @@ #include -#include "memspyview.h" +#include "memspylistview.h" #include "enginewrapper.h" @@ -35,17 +35,28 @@ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + void refresh(); + private: + EngineWrapper& mEngine; + QList mProcesses; + + QMap mPriorityMap; }; -class MemSpyProcessView : public MemSpyView +class MemSpyProcessView : public MemSpyListView { Q_OBJECT public: - MemSpyProcessView(EngineWrapper &engine, ViewManager &viewManager) - : MemSpyView(engine, viewManager) {} + MemSpyProcessView(EngineWrapper &engine, ViewManager &viewManager) : + MemSpyListView(engine, viewManager), + mModel(0) + {} + +public slots: + virtual void refresh(); protected: void initialize(const QVariantMap& params); @@ -55,6 +66,9 @@ private slots: void itemClicked(const QModelIndex& index); + +private: + MemSpyProcessModel* mModel; }; #endif /* MEMSPYPROCESSVIEW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspysettingsview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memspyui/ui/hb/inc/memspysettingsview.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,56 @@ +/* + * 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 MEMSPYSETTINGSVIEW_H_ +#define MEMSPYSETTINGSVIEW_H_ + +#include + +class HbDataForm; +class HbDataFormModel; +class HbDataFormModelItem; +class EngineWrapper; + +class MemSpySettingsView : public HbView +{ + Q_OBJECT + +public: + MemSpySettingsView(EngineWrapper &engine); + virtual ~MemSpySettingsView(); + + void initialize(const QVariantMap& params); + +private slots: + void updateModel(); + void accept(); + void reject(); + +signals: + void finished(bool ok); + +private: + HbDataForm* mForm; + HbDataFormModel* mModel; + HbDataFormModelItem* mModeItem; + HbDataFormModelItem* mPathItem; + HbDataFormModelItem* mCustomPathItem; + + EngineWrapper& mEngine; +}; + +#endif /* MEMSPYSETTINGSVIEW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspyswmtview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memspyui/ui/hb/inc/memspyswmtview.h Tue Jul 06 14:17:03 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: + * + */ + +#ifndef MEMSPYSWMTVIEW_H_ +#define MEMSPYSWMTVIEW_H_ + +#include "memspyview.h" + +class HbDataFormModel; +class HbDataFormModelItem; +class HbProgressDialog; + +class MemSpySwmtView : public MemSpyView +{ + Q_OBJECT + +public: + MemSpySwmtView(EngineWrapper &engine, ViewManager &viewManager); + virtual ~MemSpySwmtView(); + + void initialize(const QVariantMap& params); + +protected: + HbToolBar* createToolBar(); + + HbWidget* createCentralWidget(); + +private slots: + void toggleTimer(); + void forceDump(); + void modeChanged(int mode); + void asyncOperationFinished(int errorCode); + +private: + void updateTimerAction(bool isRunning); + void removeCategoriesItem(); + void createCategoriesItem(); + void updateSettings(); + +private: + HbAction* mToggleTimerAction; + + HbDataFormModel* mModel; + HbDataFormModelItem* mTimerItem; + HbDataFormModelItem* mModeItem; + HbDataFormModelItem* mCategoriesItem; + + HbProgressDialog* mProgressDialog; +}; + +#endif /* MEMSPYSWMTVIEW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspythreaddetailindexview.h --- a/memspyui/ui/hb/inc/memspythreaddetailindexview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/inc/memspythreaddetailindexview.h Tue Jul 06 14:17:03 2010 +0300 @@ -18,21 +18,26 @@ #ifndef MEMSPYTHREADDETAILINDEXVIEW_H_ #define MEMSPYTHREADDETAILINDEXVIEW_H_ -#include "memspyview.h" +#include "memspylistview.h" #include "enginewrapper.h" class HbMenu; -class MemSpyThreadDetailIndexView : public MemSpyView +class MemSpyThreadDetailIndexView : public MemSpyListView { Q_OBJECT public: MemSpyThreadDetailIndexView(EngineWrapper &engine, ViewManager &viewManager) - : MemSpyView(engine, viewManager) {} + : MemSpyListView(engine, viewManager) {} protected: virtual void initialize(const QVariantMap& params); + virtual HbMenu* createToolMenu(); + + virtual bool isBreadCrumbVisible() const; + + virtual QString getBreadCrumbText() const; private slots: void changePriority(); @@ -41,6 +46,8 @@ private: ThreadId mThreadId; HbMenu *mPriorityMenu; + QString mProcessName; + QString mThreadName; }; #endif /* MEMSPYTHREADDETAILINDEXVIEW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspythreaddetailview.h --- a/memspyui/ui/hb/inc/memspythreaddetailview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/inc/memspythreaddetailview.h Tue Jul 06 14:17:03 2010 +0300 @@ -18,7 +18,7 @@ #ifndef MEMSPYTHREADDETAILVIEW_H_ #define MEMSPYTHREADDETAILVIEW_H_ -#include "memspyview.h" +#include "memspylistview.h" #include "enginewrapper.h" class HbMenu; @@ -39,19 +39,25 @@ }; -class MemSpyThreadDetailView : public MemSpyView +class MemSpyThreadDetailView : public MemSpyListView { Q_OBJECT public: MemSpyThreadDetailView(EngineWrapper &engine, ViewManager &viewManager) - : MemSpyView(engine, viewManager) {} + : MemSpyListView(engine, viewManager) {} protected: virtual void initialize(const QVariantMap& params); + virtual bool isBreadCrumbVisible() const; + + virtual QString getBreadCrumbText() const; + private: ThreadId mThreadId; HbMenu *mPriorityMenu; + QString mProcessName; + QString mThreadName; }; #endif /* MEMSPYTHREADDETAILVIEW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspythreadview.h --- a/memspyui/ui/hb/inc/memspythreadview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/inc/memspythreadview.h Tue Jul 06 14:17:03 2010 +0300 @@ -18,7 +18,7 @@ #ifndef MEMSPYTHREADVIEW_H_ #define MEMSPYTHREADVIEW_H_ -#include "memspyview.h" +#include "memspylistview.h" #include "enginewrapper.h" class MemSpyThreadModel : public QAbstractListModel @@ -32,20 +32,29 @@ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + void refresh(); + private: + ProcessId mProcessId; + + EngineWrapper& mEngine; + QList mThreads; QMap mPriorityMap; }; -class MemSpyThreadView : public MemSpyView +class MemSpyThreadView : public MemSpyListView { Q_OBJECT public: MemSpyThreadView(EngineWrapper &engine, ViewManager &viewManager); ~MemSpyThreadView(); + +public slots: + virtual void refresh(); protected: void initialize(const QVariantMap& params); @@ -53,6 +62,10 @@ protected: virtual bool isRefreshable() const { return true; } + virtual bool isBreadCrumbVisible() const; + + QString getBreadCrumbText() const; + private slots: void itemClicked(const QModelIndex& index); void catchLongPress(HbAbstractViewItem *item, const QPointF &coords); @@ -62,6 +75,9 @@ HbMenu* mContextMenu; HbMenu* mPriorityMenu; ThreadId mThreadId; + QString mProcessName; + + MemSpyThreadModel* mModel; }; #endif /* MEMSPYTHREADVIEW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspytrackingview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memspyui/ui/hb/inc/memspytrackingview.h Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,38 @@ +/* + * 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 MEMSPYTRACKINGVIEW_H_ +#define MEMSPYTRACKINGVIEW_H_ + +#include "memspylistview.h" + +class MemSpyTrackingView : public MemSpyListView +{ + Q_OBJECT + +public: + MemSpyTrackingView(EngineWrapper &engine, ViewManager &viewManager) + : MemSpyListView(engine, viewManager) {} +protected: + virtual void initialize(const QVariantMap& params); + virtual bool isBreadCrumbVisible() const; + +public slots: + void itemClicked(const QModelIndex& index); +}; + +#endif /* MEMSPYTRACKINGVIEW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/memspyview.h --- a/memspyui/ui/hb/inc/memspyview.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/inc/memspyview.h Tue Jul 06 14:17:03 2010 +0300 @@ -22,9 +22,12 @@ #include #include +class HbLabel; +class HbProgressDialog; class EngineWrapper; class ViewManager; + class MemSpyView : public HbView { Q_OBJECT @@ -44,22 +47,33 @@ virtual bool isRefreshable() const; + virtual bool isBreadCrumbVisible() const; + + virtual QString getBreadCrumbText() const; + + virtual HbWidget* createCentralWidget() = 0; + public slots: virtual void initialize(const QVariantMap& params); virtual void refresh(); + void showSettings(); + void showAbout(); -protected: +private slots: - HbListView mListView; + void closeSettings(); + +protected: EngineWrapper &mEngine; ViewManager &mViewManager; + private: HbMenu* mOutputMenu; HbMenu* mOutputGenInfoMenu; @@ -67,6 +81,7 @@ HbMenu* mOutputStackInfoMenu; HbToolBar* mToolBar; + HbLabel* mBreadCrumb; }; #endif /* MEMSPYVIEW_H_ */ diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/inc/viewmanager.h --- a/memspyui/ui/hb/inc/viewmanager.h Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/inc/viewmanager.h Tue Jul 06 14:17:03 2010 +0300 @@ -30,7 +30,10 @@ ThreadDetailView, KernelObjectTypeView, KernelObjectView, - KernelObjectDetailView + KernelObjectDetailView, + TrackingView, + SwmtView, + HeapDumpsView }; class HbMainWindow; diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/enginewrapper.cpp --- a/memspyui/ui/hb/src/enginewrapper.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/src/enginewrapper.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -15,8 +15,272 @@ * */ +#include + +#include + #include "enginewrapper.h" -#include + +// CONSTANTS + +const QString OUTPUT_MODE = "output/mode"; +const QString OUTPUT_PATH = "output/path"; +const QString SWMT_PERIOD = "swmt/period"; +const QString SWMT_MODE = "swmt/mode"; +const QString SWMT_CATEGORIES = "swmt/categories"; +const QString HEAP_DUMPS_MODE = "heapdumps/mode"; + +QString MemSpyProcess::exitInfo() const +{ + QChar exitType[] = {'K', 'T', 'P', 'R'}; + QString result = QString("[%1]").arg(exitType[mProcess->ExitType()]); + + if (mProcess->ExitType() != EExitKill && mProcess->ExitType() != EExitPending) { + + QString exitCategory = QString((QChar*) mProcess->ExitCategory().Ptr(), mProcess->ExitCategory().Length()); + result.append(QString(" %1-%2").arg(exitCategory).arg(mProcess->ExitReason())); + } + + return result; +} + + +MemSpyDwoProgressTracker::MemSpyDwoProgressTracker(RMemSpySession &session) : + CActive(EPriorityStandard), mSession(session) +{ + CActiveScheduler::Add(this); +} + +MemSpyDwoProgressTracker::~MemSpyDwoProgressTracker() +{ + Cancel(); +} + +void MemSpyDwoProgressTracker::start() +{ + mSession.NotifyDeviceWideOperationProgress(mProgress, iStatus); + + SetActive(); +} + +void MemSpyDwoProgressTracker::cancel() +{ + Cancel(); +} + +// Event handler method. + +void MemSpyDwoProgressTracker::RunL() + { + + // If an error occurred handle it in RunError(). + User::LeaveIfError(iStatus.Int()); + + // Resubmit the request immediately + + mSession.NotifyDeviceWideOperationProgress(mProgress, iStatus); + + SetActive(); + + emit progress(mProgress.Progress(), QString((QChar*) mProgress.Description().Ptr(), mProgress.Description().Length())); + } + +void MemSpyDwoProgressTracker::DoCancel() +{ + // this is not yet implemented, as it is not required in current use cases +} + +TInt MemSpyDwoProgressTracker::RunError(TInt aError) +{ + // KErrNotReady and KErrCancel errors are OK, they just notify + // us about the outstanding notification request that won't be + // processed. + Q_UNUSED(aError); + + return KErrNone; +} + +MemSpyDwoTracker::MemSpyDwoTracker(RMemSpySession &session, DeviceWideOperation operation) : + CActive(EPriorityStandard), + mSession(session), + mProgressTracker(new MemSpyDwoProgressTracker(session)), + mOperation(operation) +{ + CActiveScheduler::Add(this); + connect(mProgressTracker, SIGNAL(progress(int,QString)), this, SIGNAL(progress(int,QString))); +} + +MemSpyDwoTracker::~MemSpyDwoTracker() +{ + Cancel(); + + delete mProgressTracker; +} + +void MemSpyDwoTracker::start() +{ + void (RMemSpySession::*functions[])(TRequestStatus&) = { + &RMemSpySession::OutputPhoneInfo, + &RMemSpySession::OutputDetailedPhoneInfo, + &RMemSpySession::OutputHeapInfo, + &RMemSpySession::OutputCompactHeapInfo, + &RMemSpySession::OutputHeapCellListing, + &RMemSpySession::OutputHeapData, + &RMemSpySession::OutputStackInfo, + &RMemSpySession::OutputCompactStackInfo, + &RMemSpySession::OutputUserStackData, + &RMemSpySession::OutputKernelStackData }; + + (mSession.*functions[mOperation])(iStatus); + + mProgressTracker->start(); + + SetActive(); +} + +void MemSpyDwoTracker::cancel() +{ + Cancel(); +} + +// Event handler method. + +void MemSpyDwoTracker::RunL() + { + + // If an error occurred handle it in RunError(). + User::LeaveIfError(iStatus.Int()); + + // Operation has finished successfully + emit finished(0); + } + +void MemSpyDwoTracker::DoCancel() +{ + // Cancel progress tracker + mProgressTracker->cancel(); + + mSession.CancelDeviceWideOperationL(); +} + +TInt MemSpyDwoTracker::RunError(TInt aError) +{ + // Emit the finished signal to notify user + // operation was canceled + emit finished(aError); + + return KErrNone; +} + +MemSpyAsyncTracker::MemSpyAsyncTracker(RMemSpySession& session, void (RMemSpySession::*function)(TRequestStatus&)) : + CActive(EPriorityStandard), + mFunction(function), + mSession(session) +{ + CActiveScheduler::Add(this); +} + +void MemSpyAsyncTracker::RunL() +{ + // If an error occurred handle it in RunError(). + User::LeaveIfError(iStatus.Int()); + + // Operation has finished successfully + emit finished(0); +} + +void MemSpyAsyncTracker::DoCancel() +{ + // nothing to do here +} + +TInt MemSpyAsyncTracker::RunError(TInt aError) +{ + // Emit the finished signal to notify user + // that operation was canceled + emit finished(aError); + + return KErrNone; +} + +void MemSpyAsyncTracker::start() +{ + (mSession.*mFunction)(iStatus); + + SetActive(); +} + +MemSpySettings::MemSpySettings() : + QSettings("Nokia", "MemSpy") +{ +} + +OutputMode MemSpySettings::outputMode() const +{ + return static_cast(value(OUTPUT_MODE, 0).toInt()); +} + +void MemSpySettings::setOutputMode(OutputMode mode) +{ + setValue(OUTPUT_MODE, mode); +} + +QString MemSpySettings::outputPath() const +{ + return value(OUTPUT_PATH).toString(); +} + +void MemSpySettings::setOutputPath(const QString& path) +{ + setValue(OUTPUT_PATH, path); +} + +int MemSpySettings::swmtTimerPeriod() const +{ + return value(SWMT_PERIOD, 30).toInt(); +} + +void MemSpySettings::setSwmtMode(SwmtMode mode) +{ + setValue(SWMT_MODE, mode); +} + +SwmtMode MemSpySettings::swmtMode() const +{ + return static_cast(value(SWMT_MODE, 0).toInt()); +} + +void MemSpySettings::setSwmtTimerPeriod(int period) +{ + setValue(SWMT_PERIOD, period); +} + + +QVariantList MemSpySettings::swmtCategories() const +{ + return value(SWMT_CATEGORIES).toList(); +} + +void MemSpySettings::setSwmtCategories(const QVariantList& categories) +{ + setValue(SWMT_CATEGORIES, categories); +} + +HeapDumpsMode MemSpySettings::heapDumpsMode() const +{ + return static_cast(value(HEAP_DUMPS_MODE).toInt()); +} + +void MemSpySettings::setHeapDumpsMode(HeapDumpsMode mode) +{ + setValue(HEAP_DUMPS_MODE, mode); +} + + +EngineWrapper::EngineWrapper() : + mSwmtRunning(false) +{ +} EngineWrapper::~EngineWrapper() { @@ -28,15 +292,28 @@ return mSession.Connect() == KErrNone; } +MemSpySettings& EngineWrapper::settings() +{ + return mSettings; +} + +const MemSpySettings& EngineWrapper::settings() const +{ + return mSettings; +} + + + QList EngineWrapper::getProcesses() { QList result; RArray proc; - TRAPD(error, mSession.GetProcessesL(proc)); - if (error == KErrNone) - for(TInt i=0; i result; RArray proc; - TRAPD(error, mSession.GetThreadsL(processId, proc)); - if (error == KErrNone) - for(TInt i=0; i result; RArray threadInfo; - TRAPD(error, mSession.GetThreadInfoItems(threadInfo, threadId, + qt_symbian_throwIfError(mSession.GetThreadInfoItems(threadInfo, threadId, static_cast(type))); - if (error == KErrNone) - for (TInt i=0; i result; RArray types; - TInt error = mSession.GetKernelObjects(types); - if (error == KErrNone) - for(TInt i=0; i result; RArray objects; - TInt error = mSession.GetKernelObjectItems(objects, - static_cast(type)); - if (error == KErrNone) - for(TInt i=0; i(type))); + + for(TInt i=0; i(filter.utf16()), filter.length()); + + TRAPD(err, mSession.OutputThreadHeapDataL(customFilterDesc)); + + return err; +} + +void EngineWrapper::updateOutputSettings() +{ + switch (mSettings.outputMode()) { + case OutputModeTrace: + TRAP_IGNORE(mSession.SwitchOutputToTraceL()); + break; + + case OutputModeFile: + + if (mSettings.outputPath().isEmpty()) { + TRAP_IGNORE(mSession.SwitchOutputToFileL(KNullDesC)); + + } else { + + QString root = mSettings.outputPath(); + TPtrC rootDesc (static_cast(root.utf16()), root.length()); + + TRAP_IGNORE(mSession.SwitchOutputToFileL(rootDesc)); + } + + } +} diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspyheapdumpsview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memspyui/ui/hb/src/memspyheapdumpsview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,184 @@ +/* + * 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 "memspyheapdumpsview.h" +#include "enginewrapper.h" + +const QStringList MODE_ITEMS = QStringList() << + MemSpyHeapDumpsView::tr("Kernel") << + MemSpyHeapDumpsView::tr("User") << + MemSpyHeapDumpsView::tr("Both"); + +MemSpyHeapDumpsView::MemSpyHeapDumpsView(EngineWrapper &engine, ViewManager &viewManager) : + MemSpyView(engine, viewManager), + mModel(0), + mModeItem(0), + mFilterItem(0), + mDwoProgressDialog(0) +{ +} + +MemSpyHeapDumpsView::~MemSpyHeapDumpsView() +{ + delete mDwoProgressDialog; +} + +void MemSpyHeapDumpsView::initialize(const QVariantMap& params) +{ + setTitle(tr("Heap Dumps")); + + MemSpyView::initialize(params); +} + +HbToolBar* MemSpyHeapDumpsView::createToolBar() +{ + HbToolBar* toolBar = new HbToolBar(); + toolBar->addAction(tr("Dump Now"), this, SLOT(dump())); + return toolBar; +} + +HbWidget* MemSpyHeapDumpsView::createCentralWidget() +{ + mModel = new HbDataFormModel(this); + + //TODO: uncomment after kernel heap dumps are implemented +// mModeItem = mModel->appendDataFormItem( +// HbDataFormModelItem::ComboBoxItem, tr("Heap Dump")); +// mModeItem->setContentWidgetData("items", MODE_ITEMS); +// mModeItem->setContentWidgetData("currentIndex", mEngine.settings().heapDumpsMode()); +// modeChanged(mEngine.settings().heapDumpsMode()); + + //TODO: remove after kernel heap dumps are implemented + createFilterItem(); + + HbDataForm* form = new HbDataForm(this); + form->setModel(mModel); + + //TODO: uncomment after kernel heap dumps are implemented +// form->addConnection(mModeItem, SIGNAL(currentIndexChanged(int)), this, SLOT(modeChanged(int))); + + return form; +} + +void MemSpyHeapDumpsView::modeChanged(int mode) +{ + if (mode == HeapDumpsModeKernel && mFilterItem) + removeFilterItem(); + else if (mode != HeapDumpsModeKernel && !mFilterItem) + createFilterItem(); +} + +void MemSpyHeapDumpsView::createFilterItem() +{ + mFilterItem = mModel->appendDataFormItem( + HbDataFormModelItem::TextItem, tr("Filter")); +} + +void MemSpyHeapDumpsView::removeFilterItem() +{ + mModel->removeItem(mFilterItem); + mFilterItem = 0; +} + +void MemSpyHeapDumpsView::dump() +{ + mEngine.updateOutputSettings(); + + HeapDumpsMode mode = HeapDumpsModeUser; + //TODO: uncomment after kernel heap dumps are implemented + //static_cast(mModeItem->contentWidgetData("currentIndex").toInt()); + + // save settings + //TODO: uncomment after kernel heap dumps are implemented + //mEngine.settings().setHeapDumpsMode(mode); + + if (mode == HeapDumpsModeKernel || mode == HeapDumpsModeBoth) { + // dump kernel heap + mDwoProgressDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); + mDwoProgressDialog->setText(tr("Please wait...")); + mDwoProgressDialog->show(); + + MemSpyKernelHeapDumpTracker* tracker = mEngine.createKernelHeapDumpTracker(); + connect(tracker, SIGNAL(finished(int)), this, SLOT(asyncOperationFinished(int))); + tracker->start(); + } + + if (mode == HeapDumpsModeUser || mode == HeapDumpsModeBoth) { + // dump user heap + + QString filter = mFilterItem->contentWidgetData("text").toString(); + if (!filter.isEmpty()) { + + int errorCode = mEngine.outputThreadHeapData(filter); + if (errorCode == KErrNotFound) { + HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); + messageBox->setText(tr("No thread matches your filter")); + HbLabel *header = new HbLabel(tr("No such thread"), messageBox); + messageBox->setHeadingWidget(header); + messageBox->setAttribute(Qt::WA_DeleteOnClose); + messageBox->setTimeout(HbPopup::StandardTimeout); + messageBox->open(); + } + + + } else { + mDwoProgressDialog = new HbProgressDialog(HbProgressDialog::ProgressDialog); + mDwoProgressDialog->setMinimum(0); + mDwoProgressDialog->setMaximum(100); + mDwoProgressDialog->show(); + + MemSpyDwoTracker* tracker = mEngine.createDeviceWideOperation(OutputHeapData); + connect(tracker, SIGNAL(progress(int,QString)), this, SLOT(updateDwoProgress(int,QString))); + connect(tracker, SIGNAL(finished(int)), this, SLOT(asyncOperationFinished(int))); + connect(mDwoProgressDialog, SIGNAL(cancelled()), tracker, SLOT(cancel())); + tracker->start(); + } + } +} + +void MemSpyHeapDumpsView::updateDwoProgress(int progress, const QString& processName) +{ + mDwoProgressDialog->setText(processName); + mDwoProgressDialog->setProgressValue(progress); +} + +void MemSpyHeapDumpsView::asyncOperationFinished(int errorCode) +{ + mDwoProgressDialog->hide(); + delete mDwoProgressDialog; + mDwoProgressDialog = 0; + + delete sender(); + + if (errorCode != KErrNone && errorCode != KErrCancel) { + HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning); + messageBox->setText(tr("An error occured during the operation. Error code: %1").arg(errorCode)); + HbLabel *header = new HbLabel(tr("Error"), messageBox); + messageBox->setHeadingWidget(header); + messageBox->setAttribute(Qt::WA_DeleteOnClose); + messageBox->setTimeout(HbPopup::StandardTimeout); + messageBox->open(); + } +} diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspykernelobjectdetailview.cpp --- a/memspyui/ui/hb/src/memspykernelobjectdetailview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/src/memspykernelobjectdetailview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -19,11 +19,49 @@ #include "memspykernelobjectdetailview.h" +MemSpyKernelObjectDetailModel::MemSpyKernelObjectDetailModel(const QStringList& details, QObject *parent) : + QAbstractListModel(parent), + mDetails(details) +{ + +} + +int MemSpyKernelObjectDetailModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return mDetails.count(); +} + +QVariant MemSpyKernelObjectDetailModel::data(const QModelIndex &index, int role) const +{ + if (role == Qt::DisplayRole) { + + // convert from semicolon delimited line to two lines + return mDetails.at(index.row()).split(": "); + } + + return QVariant(); +} + + void MemSpyKernelObjectDetailView::initialize(const QVariantMap& params) { - MemSpyView::initialize(params); + setTitle("Details"); - setTitle("Details"); + mTypeName = params["typeName"].toString(); + mObjectName = params["objectName"].toString(); + MemSpyView::initialize(params); + QStringList items = params.value("details").toStringList(); - mListView.setModel(new QStringListModel(items, this)); + mListView.setModel(new MemSpyKernelObjectDetailModel(items, this)); } + +bool MemSpyKernelObjectDetailView::isBreadCrumbVisible() const +{ + return true; +} + +QString MemSpyKernelObjectDetailView::getBreadCrumbText() const +{ + return tr("Kernel Objects > %1 > %2").arg(mTypeName).arg(mObjectName); +} diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspykernelobjecttypeview.cpp --- a/memspyui/ui/hb/src/memspykernelobjecttypeview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/src/memspykernelobjecttypeview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -24,6 +24,10 @@ QAbstractListModel(parent), mObjectTypes(engine.getKernelObjectTypes()) { + mKernelObjectNames << "Threads" << "Processes" << "Chunks" << "Libraries" << + "Semaphores" << "Mutexes" << "Timers" << "Servers" << "Sessions" << "Logical Devices" << + "Physical Devices" << "Logical Channels" << "Change Notifiers" << "Undertakers" << + "Message Queues" << "Property Refs." << "Conditional Vars."; } MemSpyKernelObjectTypeModel::~MemSpyKernelObjectTypeModel() @@ -41,7 +45,7 @@ { if (role == Qt::DisplayRole) { QStringList lines; - lines << mObjectTypes.at(index.row())->name(); + lines << mKernelObjectNames.at(index.row()); lines << QString("%1, %2"). arg(tr("%n item(s)", "", mObjectTypes.at(index.row())->count())). arg(formatSize(mObjectTypes.at(index.row())->size())); @@ -70,9 +74,9 @@ void MemSpyKernelObjectTypeView::initialize(const QVariantMap& params) { + setTitle(tr("Kernel Objects")); + MemSpyView::initialize(params); - - setTitle(tr("Kernel Objects")); mListView.setModel(new MemSpyKernelObjectTypeModel(mEngine, this)); diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspykernelobjectview.cpp --- a/memspyui/ui/hb/src/memspykernelobjectview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/src/memspykernelobjectview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -55,8 +55,6 @@ void MemSpyKernelObjectView::initialize(const QVariantMap& params) { - MemSpyView::initialize(params); - QStringList list = QStringList() << "Threads" << "Processes" << "Chunks" << "Libraries" << "Semaphores" << "Mutexes" << "Timers" << "Servers" << "Sessions" << "Logical Devices" << "Physical Devices" << "Logical Channels" << "Change Notifiers" << "Undertakers" << @@ -66,16 +64,31 @@ setTitle(list.at(type)); + MemSpyView::initialize(params); + //mListView.setModel(new MemSpyKernelObjectTypeModel(mEngine, this)); mListView.setModel(new MemSpyKernelObjectModel(mEngine, type, this)); connect(&mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemClicked(QModelIndex))); } +bool MemSpyKernelObjectView::isBreadCrumbVisible() const +{ + return true; +} + +QString MemSpyKernelObjectView::getBreadCrumbText() const +{ + return tr("Kernel Objects"); +} + + void MemSpyKernelObjectView::itemClicked(const QModelIndex& index) { QVariantMap map; map.insert("details", getDetails(static_cast(qVariantValue(index.data(Qt::UserRole))))); + map.insert("typeName", title()); + map.insert("objectName", static_cast(qVariantValue(index.data(Qt::UserRole)))->nameDetail()); mViewManager.showView(KernelObjectDetailView, map); } diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspylistview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memspyui/ui/hb/src/memspylistview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,23 @@ +/* + * 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 "memspylistview.h" + +HbWidget* MemSpyListView::createCentralWidget() +{ + return &mListView; +} diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspymainview.cpp --- a/memspyui/ui/hb/src/memspymainview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/src/memspymainview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -23,13 +23,14 @@ void MemSpyMainView::initialize(const QVariantMap& params) { + setTitle("MemSpy"); + MemSpyView::initialize(params); - setTitle("MemSpy"); QStringList items = QStringList() << tr("Processes & Threads") - << tr("Kernel Objects"); - //<< tr("Kernel Heap"); + << tr("Kernel Objects") + << tr("Tracking"); mListView.setModel(new QStringListModel(items, this)); QObject::connect(&mListView, SIGNAL(released(QModelIndex)), this, SLOT(itemClicked(QModelIndex))); @@ -38,7 +39,12 @@ void MemSpyMainView::itemClicked(const QModelIndex& index) { Q_UNUSED(index); - ViewIndex indexes[] = { ProcessView, KernelObjectTypeView, KernelObjectTypeView }; + ViewIndex indexes[] = { ProcessView, KernelObjectTypeView, TrackingView }; mViewManager.showView(indexes[index.row()]); } +bool MemSpyMainView::isBreadCrumbVisible() const +{ + return false; +} + diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspyprocessview.cpp --- a/memspyui/ui/hb/src/memspyprocessview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/src/memspyprocessview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -23,8 +23,17 @@ MemSpyProcessModel::MemSpyProcessModel(EngineWrapper &engine, QObject *parent) : QAbstractListModel(parent), + mEngine(engine), mProcesses(engine.getProcesses()) { + mPriorityMap.insert(EPriorityLow, tr("[L]")); + mPriorityMap.insert(EPriorityBackground, tr("[B]")); + mPriorityMap.insert(EPriorityForeground, tr("[F]")); + mPriorityMap.insert(EPriorityHigh, tr("[H]")); + mPriorityMap.insert(EPriorityWindowServer, tr("[WS]")); + mPriorityMap.insert(EPriorityFileServer, tr("[FS]")); + mPriorityMap.insert(EPriorityRealTimeServer, tr("[RTS]")); + mPriorityMap.insert(EPrioritySupervisor, tr("[SUP]")); } MemSpyProcessModel::~MemSpyProcessModel() @@ -41,8 +50,17 @@ QVariant MemSpyProcessModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole) { + const MemSpyProcess* process = mProcesses.at(index.row()); + QStringList lines; - lines << mProcesses.at(index.row())->name(); + lines << process->name(); + + lines << (process->isDead() ? + process->exitInfo() : + QString("%1, %2 thr, %3"). + arg(process->sid(), 0, 16). + arg(process->threadCount()). + arg(mPriorityMap.value(process->priority(), tr("[?]")))); return lines; } @@ -52,14 +70,24 @@ return QVariant(); } + +void MemSpyProcessModel::refresh() +{ + beginResetModel(); + QList data = mEngine.getProcesses(); + qDeleteAll(mProcesses); + mProcesses = data; + endResetModel(); +} void MemSpyProcessView::initialize(const QVariantMap& params) { + setTitle(tr("Processes")); MemSpyView::initialize(params); - setTitle(tr("Processes")); - mListView.setModel(new MemSpyProcessModel(mEngine, this)); + mModel = new MemSpyProcessModel(mEngine, this); + mListView.setModel(mModel); connect(&mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemClicked(QModelIndex))); } @@ -68,6 +96,12 @@ { QVariantMap map; map.insert("pid", index.data(Qt::UserRole)); + map.insert("pname", index.data(Qt::DisplayRole).toStringList().at(0)); mViewManager.showView(ThreadView, map); } +void MemSpyProcessView::refresh() +{ + mModel->refresh(); +} + diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspysettingsview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memspyui/ui/hb/src/memspysettingsview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -0,0 +1,127 @@ +/* + * 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 "memspysettingsview.h" +#include "enginewrapper.h" + +const QStringList MODE_ITEMS = QStringList() << + MemSpySettingsView::tr("RDebug") << + MemSpySettingsView::tr("File"); + +MemSpySettingsView::MemSpySettingsView(EngineWrapper &engine) : + mForm(new HbDataForm(this)), + mModel(0), + mModeItem(0), + mPathItem(0), + mCustomPathItem(0), + mEngine(engine) +{ + setTitle(tr("Settings")); + + toolBar()->addAction(tr("OK"), this, SLOT(accept())); + toolBar()->addAction(tr("Cancel"), this, SLOT(reject())); + + mModel = new HbDataFormModel(this); + + mModeItem = mModel->appendDataFormItem( + HbDataFormModelItem::ComboBoxItem, tr("Output")); + mModeItem->setContentWidgetData("items", MODE_ITEMS); + mModeItem->setContentWidgetData("currentIndex", mEngine.settings().outputMode()); + + updateModel(); + + + mForm->setModel(mModel); + mForm->addConnection(mModeItem, SIGNAL(currentIndexChanged(int)), this, SLOT(updateModel())); + setWidget(mForm); + + // change navigation action + HbAction* action = new HbAction(Hb::BackNaviAction, this); + connect(action, SIGNAL(triggered()), this, SLOT(reject())); + setNavigationAction(action); +} + +MemSpySettingsView::~MemSpySettingsView() +{ +} + +void MemSpySettingsView::updateModel() +{ + OutputMode mode = static_cast(mModeItem->contentWidgetData("currentIndex").toInt()); + if (mode == OutputModeTrace) { + // remove both path item and custom path item + if (mPathItem) + mModel->removeItem(mPathItem); + if (mCustomPathItem) + mModel->removeItem(mCustomPathItem); + + mPathItem = mCustomPathItem = 0; + } else if (mode == OutputModeFile) { + if (!mPathItem) { + // create path item + mPathItem = mModel->appendDataFormItem( + HbDataFormModelItem::CheckBoxItem, tr("Path")); + mPathItem->setContentWidgetData("text", tr("Use Default Path (\\MemSpy)")); + mPathItem->setContentWidgetData("checkState", + mEngine.settings().outputPath().isEmpty() ? Qt::Checked : Qt::Unchecked); + + mForm->addConnection(mPathItem, SIGNAL(stateChanged(int)), + this, SLOT(updateModel())); + } + + if (mPathItem->contentWidgetData("checkState").toInt() == Qt::Unchecked && !mCustomPathItem) { + // create custom path item + mCustomPathItem = mModel->appendDataFormItem( + HbDataFormModelItem::TextItem, tr("Custom Path")); + mCustomPathItem->setContentWidgetData("text", + mEngine.settings().outputPath().isEmpty() ? "\\MemSpy" : mEngine.settings().outputPath()); + } + + if (mPathItem->contentWidgetData("checkState").toInt() == Qt::Checked && mCustomPathItem) { + // remove cusom path item + mModel->removeItem(mCustomPathItem); + mCustomPathItem = 0; + } + } +} + +void MemSpySettingsView::accept() +{ + OutputMode mode = static_cast(mModeItem->contentWidgetData("currentIndex").toInt()); + + mEngine.settings().setOutputMode(mode); + + if (mode == OutputModeFile) { + QString path = mPathItem->contentWidgetData("checkState").toInt() == Qt::Checked ? + "" : + mCustomPathItem->contentWidgetData("text").toString(); + mEngine.settings().setOutputPath(path); + } + emit finished(true); +} + +void MemSpySettingsView::reject() +{ + emit finished(false); +} + diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspyswmtview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memspyui/ui/hb/src/memspyswmtview.cpp Tue Jul 06 14:17:03 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 +#include +#include +#include +#include + +#include "memspyswmtview.h" +#include "enginewrapper.h" + +const QStringList MODE_ITEMS = QStringList() << + MemSpySwmtView::tr("Basic") << + MemSpySwmtView::tr("Full") << + MemSpySwmtView::tr("Custom"); + +const QStringList CATEGORIES_ITEMS = QStringList() << + MemSpySwmtView::tr("FileServer Cache") << + //MemSpySwmtView::tr("Bitmap Handles") << + MemSpySwmtView::tr("User Heap") << + //MemSpySwmtView::tr("Kernel Heap") << + MemSpySwmtView::tr("Local Chunks") << + MemSpySwmtView::tr("Global Chunks") << + MemSpySwmtView::tr("RAM Drive") << + //MemSpySwmtView::tr("User Stacks") << + //MemSpySwmtView::tr("Global Data") << + MemSpySwmtView::tr("RAM-loaded Code") << + MemSpySwmtView::tr("Kernel Handles") << + MemSpySwmtView::tr("Open Files") << + MemSpySwmtView::tr("Disk Usage") << + MemSpySwmtView::tr("System Memory") << + MemSpySwmtView::tr("Windows Groups"); + +MemSpySwmtView::MemSpySwmtView(EngineWrapper &engine, ViewManager &viewManager) : + MemSpyView(engine, viewManager), + mToggleTimerAction(0), + mCategoriesItem(0), + mProgressDialog(0) +{ +} + +MemSpySwmtView::~MemSpySwmtView() +{ +} + +void MemSpySwmtView::initialize(const QVariantMap& params) +{ + setTitle(tr("SWMT")); + + MemSpyView::initialize(params); +} + +HbToolBar* MemSpySwmtView::createToolBar() +{ + HbToolBar* toolBar = new HbToolBar(); + mToggleTimerAction = toolBar->addAction("", this, SLOT(toggleTimer())); + toolBar->addAction(tr("Dump Now"), this, SLOT(forceDump())); + + updateTimerAction(mEngine.isSwmtRunning()); + + return toolBar; +} + +HbWidget* MemSpySwmtView::createCentralWidget() +{ + mModel = new HbDataFormModel(this); + + mTimerItem = mModel->appendDataFormItem( + HbDataFormModelItem::TextItem, tr("Timer (sec.)")); + mTimerItem->setContentWidgetData("maxLength", 2); + mTimerItem->setContentWidgetData("text", mEngine.settings().swmtTimerPeriod()); + + mModeItem = mModel->appendDataFormItem( + HbDataFormModelItem::ComboBoxItem, tr("Tracking mode")); + mModeItem->setContentWidgetData("items", MODE_ITEMS); + mModeItem->setContentWidgetData("currentIndex", mEngine.settings().swmtMode()); + + modeChanged(mEngine.settings().swmtMode()); + + HbDataForm* form = new HbDataForm(this); + form->setModel(mModel); + + form->addConnection(mModeItem, SIGNAL(currentIndexChanged(int)), this, SLOT(modeChanged(int))); + + return form; +} + +void MemSpySwmtView::updateTimerAction(bool isRunning) +{ + mToggleTimerAction->setText(isRunning ? tr("Stop Timer") : tr("Start Timer")); +} + +void MemSpySwmtView::toggleTimer() +{ + bool wasRunning = mEngine.isSwmtRunning(); + if (wasRunning) + mEngine.stopSwmt(); + else + { + updateSettings(); + mEngine.startSwmt(qBound(5, mTimerItem->contentWidgetData("text").toInt(), 60)); + } + + updateTimerAction(!wasRunning); +} + +void MemSpySwmtView::forceDump() +{ + updateSettings(); + mEngine.updateOutputSettings(); + + MemSpySwmtDumpTracker* tracker = mEngine.createSwmtDumpTracker(); + connect(tracker, SIGNAL(finished(int)), this, SLOT(asyncOperationFinished(int))); + + mProgressDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); + mProgressDialog->setText(tr("Please wait...")); + mProgressDialog->show(); + + tracker->start(); +} + +void MemSpySwmtView::updateSettings() +{ + mEngine.settings().setSwmtTimerPeriod(mTimerItem->contentWidgetData("text").toInt()); + mEngine.settings().setSwmtMode(static_cast( + mModeItem->contentWidgetData("currentIndex").toInt())); + if (mCategoriesItem) + mEngine.settings().setSwmtCategories(mCategoriesItem->contentWidgetData("selectedItems").toList()); + + mEngine.setSwmtSettings(static_cast(mEngine.settings().swmtMode()), + mEngine.settings().swmtCategories()); +} + +void MemSpySwmtView::modeChanged(int mode) +{ + if (mode != SwmtModeCustom && mCategoriesItem) + removeCategoriesItem(); + else if (mode == SwmtModeCustom && !mCategoriesItem) + createCategoriesItem(); +} + +void MemSpySwmtView::asyncOperationFinished(int errorCode) +{ + Q_UNUSED(errorCode); + + mProgressDialog->hide(); + delete mProgressDialog; + mProgressDialog = 0; + + delete sender(); +} + +void MemSpySwmtView::createCategoriesItem() +{ + mCategoriesItem = mModel->appendDataFormItem( + HbDataFormModelItem::MultiselectionItem, tr("Categories")); + mCategoriesItem->setContentWidgetData("items", CATEGORIES_ITEMS); + mCategoriesItem->setContentWidgetData("selectedItems", mEngine.settings().swmtCategories()); +} + +void MemSpySwmtView::removeCategoriesItem() +{ + mModel->removeItem(mCategoriesItem); + mCategoriesItem = 0; +} diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspythreaddetailindexview.cpp --- a/memspyui/ui/hb/src/memspythreaddetailindexview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/src/memspythreaddetailindexview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -24,9 +24,12 @@ void MemSpyThreadDetailIndexView::initialize(const QVariantMap& params) { - MemSpyView::initialize(params); + setTitle(tr("Details")); - setTitle(tr("Thread Details")); + mProcessName = params["pname"].toString(); + mThreadName = params["tname"].toString(); + + MemSpyView::initialize(params); mThreadId = qVariantValue(params["tid"]); @@ -69,7 +72,17 @@ return menu; } - + +bool MemSpyThreadDetailIndexView::isBreadCrumbVisible() const +{ + return true; +} + +QString MemSpyThreadDetailIndexView::getBreadCrumbText() const +{ + return tr("Processes > %1 > Threads > %2").arg(mProcessName).arg(mThreadName); +} + void MemSpyThreadDetailIndexView::changePriority() { QAction *s = qobject_cast(sender()); @@ -111,6 +124,8 @@ QVariantMap map; map.insert("tid", mThreadId); map.insert("type", types[index.row()]); + map.insert("pname", mProcessName); + map.insert("tname", mThreadName); mViewManager.showView(ThreadDetailView, map); } diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspythreaddetailview.cpp --- a/memspyui/ui/hb/src/memspythreaddetailview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/src/memspythreaddetailview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -35,16 +35,26 @@ int MemSpyThreadDetailModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); - return mThreadInfo.count(); + return qMax(mThreadInfo.count(), 1); } QVariant MemSpyThreadDetailModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole) { - QStringList lines; - lines << mThreadInfo.at(index.row())->caption(); - lines << mThreadInfo.at(index.row())->value(); - return lines; + + if (mThreadInfo.count()) { + QStringList lines; + lines << mThreadInfo.at(index.row())->caption(); + lines << mThreadInfo.at(index.row())->value(); + return lines; + } + + return tr("(no items found)"); + } + + if (role == Qt::TextAlignmentRole && mThreadInfo.count() == 0) { + + return Qt::AlignHCenter; } return QVariant(); @@ -52,12 +62,49 @@ void MemSpyThreadDetailView::initialize(const QVariantMap& params) { + mProcessName = params["pname"].toString(); + mThreadName = params["tname"].toString(); + + // TODO: Remove duplicates with memspythreaddetailindexview + QMap titleMap; + titleMap[ThreadInfoTypeGeneral] = tr("General"); + titleMap[ThreadInfoTypeHeap] = tr("Heap"); + titleMap[ThreadInfoTypeStack] = tr("Stack"); + titleMap[ThreadInfoTypeChunk] = tr("Chunks"); + titleMap[ThreadInfoTypeCodeSeg] = tr("Code Segments"); + titleMap[ThreadInfoTypeOpenFiles] = tr("Open Files"); + titleMap[ThreadInfoTypeActiveObjects] = tr("Active Objects"); + titleMap[ThreadInfoTypeOwnedThreadHandles] = tr("Handles to other Threads"); + titleMap[ThreadInfoTypeOwnedProcessHandles] = tr("Handles to other Processes"); + titleMap[ThreadInfoTypeServer] = tr("Servers Running in Thread"); + titleMap[ThreadInfoTypeSession] = tr("Client <-> Server connections"); + titleMap[ThreadInfoTypeSemaphore] = tr("Semaphores"); + titleMap[ThreadInfoTypeOtherThreads] = tr("References this Thread"); + titleMap[ThreadInfoTypeOtherProcesses] = tr("References this Process"); + titleMap[ThreadInfoTypeMutex] = tr("Mutexes"); + titleMap[ThreadInfoTypeTimer] = tr("Timers"); + titleMap[ThreadInfoTypeChannel] = tr("Logical DD Channels"); + titleMap[ThreadInfoTypeChangeNotifier] = tr("Change Notifiers"); + titleMap[ThreadInfoTypeUndertaker] = tr("Undertakers"); + titleMap[ThreadInfoTypeLDD] = tr("Logical Device Drivers"); + titleMap[ThreadInfoTypePDD] = tr("Physical Device Drivers"); + + setTitle(titleMap.value(params["type"].toInt())); + MemSpyView::initialize(params); - setTitle(tr("Thread Details")); - ThreadId threadId = qVariantValue(params["tid"]); ThreadInfoType type = static_cast(qVariantValue(params["type"])); mListView.setModel(new MemSpyThreadDetailModel(mEngine, threadId, type, this)); } + +bool MemSpyThreadDetailView::isBreadCrumbVisible() const +{ + return true; +} + +QString MemSpyThreadDetailView::getBreadCrumbText() const +{ + return tr("Processes > %1 > Threads > %2").arg(mProcessName).arg(mThreadName); +} diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspythreadview.cpp --- a/memspyui/ui/hb/src/memspythreadview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/src/memspythreadview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -22,9 +22,11 @@ #include "memspythreadview.h" #include "viewmanager.h" -MemSpyThreadModel::MemSpyThreadModel(EngineWrapper &engine, ProcessId threadId, QObject *parent) : +MemSpyThreadModel::MemSpyThreadModel(EngineWrapper &engine, ProcessId processId, QObject *parent) : QAbstractListModel(parent), - mThreads(engine.getThreads(threadId)) + mProcessId(processId), + mEngine(engine), + mThreads(engine.getThreads(processId)) { mPriorityMap.insert(ThreadPriorityNull, tr("[Null]")); mPriorityMap.insert(ThreadPriorityMuchLess, tr("[Much Less]")); @@ -78,11 +80,21 @@ return QVariant(); } +void MemSpyThreadModel::refresh() +{ + beginResetModel(); + QList data = mEngine.getThreads(mProcessId); + qDeleteAll(mThreads); + mThreads = data; + endResetModel(); +} + MemSpyThreadView::MemSpyThreadView(EngineWrapper &engine, ViewManager &viewManager) : - MemSpyView(engine, viewManager), + MemSpyListView(engine, viewManager), mContextMenu(0), mPriorityMenu(0), - mThreadId(0) + mThreadId(0), + mModel(0) { } @@ -94,13 +106,15 @@ void MemSpyThreadView::initialize(const QVariantMap& params) { + ProcessId pid = qVariantValue(params["pid"]); + setTitle(tr("Threads")); + + mProcessName = params["pname"].toString(); + MemSpyView::initialize(params); - ProcessId pid = qVariantValue(params["pid"]); - setTitle(tr("Threads").arg(pid)); - - mListView.setModel(new MemSpyThreadModel(mEngine, pid, this)); - mListView.setLongPressEnabled(true); + mModel = new MemSpyThreadModel(mEngine, pid, this); + mListView.setModel(mModel); connect(&mListView, SIGNAL(activated(QModelIndex)), this, SLOT(itemClicked(QModelIndex))); connect(&mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), @@ -128,16 +142,30 @@ mPriorityMenu->addAction(tr("Abs. Real Time 8"), this, SLOT(changePriority())); } + +bool MemSpyThreadView::isBreadCrumbVisible() const +{ + return true; +} + +QString MemSpyThreadView::getBreadCrumbText() const +{ + return tr("Processes > %1").arg(mProcessName); +} + void MemSpyThreadView::itemClicked(const QModelIndex& index) { QVariantMap map; map["tid"] = index.data(Qt::UserRole); + map.insert("pname", mProcessName); + map.insert("tname", index.data(Qt::DisplayRole).toStringList().at(0)); + mViewManager.showView(ThreadDetailIndexView, map); } void MemSpyThreadView::catchLongPress(HbAbstractViewItem *item, const QPointF &coords) { - mThreadId = qVariantValue(item->data(Qt::UserRole)); + mThreadId = qVariantValue(item->modelIndex().data(Qt::UserRole)); mContextMenu->setPreferredPos(coords); mContextMenu->open(); } @@ -167,4 +195,10 @@ ThreadPriorityAbsoluteRealTime8 }; mEngine.setThreadPriority(mThreadId, priorities[index]); + refresh(); } + +void MemSpyThreadView::refresh() +{ + mModel->refresh(); +} diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspytrackingview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/memspyui/ui/hb/src/memspytrackingview.cpp Tue Jul 06 14:17:03 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: + * + */ + +#include "memspytrackingview.h" +#include "viewmanager.h" + +#include +#include + +void MemSpyTrackingView::initialize(const QVariantMap& params) +{ + setTitle("MemSpy"); + + MemSpyView::initialize(params); + + QStringList items = QStringList() + << tr("System Wide Memory Tracking") + << tr("Heap Dumps"); + mListView.setModel(new QStringListModel(items, this)); + + QObject::connect(&mListView, SIGNAL(released(QModelIndex)), this, SLOT(itemClicked(QModelIndex))); +} + +void MemSpyTrackingView::itemClicked(const QModelIndex& index) +{ + Q_UNUSED(index); + ViewIndex indexes[] = { SwmtView, HeapDumpsView }; + mViewManager.showView(indexes[index.row()]); +} + +bool MemSpyTrackingView::isBreadCrumbVisible() const +{ + return false; +} + diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/memspyview.cpp --- a/memspyui/ui/hb/src/memspyview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/src/memspyview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -15,14 +15,21 @@ * */ +#include +#include +#include #include +#include #include #include #include +#include #include #include "memspyview.h" +#include "enginewrapper.h" +#include "memspysettingsview.h" MemSpyView::MemSpyView(EngineWrapper &engine, ViewManager &viewManager) : HbView(), @@ -32,13 +39,14 @@ mOutputGenInfoMenu(0), mOutputHeapInfoMenu(0), mOutputStackInfoMenu(0), - mToolBar(0) + mToolBar(0), + mBreadCrumb(0) { - setWidget(&mListView); } MemSpyView::~MemSpyView() { + delete mBreadCrumb; delete mToolBar; delete mOutputStackInfoMenu; delete mOutputHeapInfoMenu; @@ -48,32 +56,29 @@ void MemSpyView::initialize(const QVariantMap& params) { + Q_UNUSED(params); + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, this); + + if (isBreadCrumbVisible()) { + mBreadCrumb = new HbLabel(this); + mBreadCrumb->setTextWrapping(Hb::TextWordWrap); + mBreadCrumb->setElideMode(Qt::ElideLeft); + mBreadCrumb->setPlainText(getBreadCrumbText()); + HbFontSpec spec(HbFontSpec::PrimarySmall); + mBreadCrumb->setFontSpec(spec); + layout->addItem(mBreadCrumb); + } + layout->addItem(createCentralWidget()); + setLayout(layout); + if (isRefreshable()) - menu()->addAction(tr("Refresh")); + menu()->addAction(tr("Refresh"), this, SLOT(refresh())); HbMenu* toolMenu = createToolMenu(); if (toolMenu) menu()->addMenu(toolMenu); - mOutputMenu = menu()->addMenu(tr("Output")); - mOutputMenu->addActions(createOutputActions()); - mOutputGenInfoMenu = mOutputMenu->addMenu(tr("General Info")); - mOutputHeapInfoMenu = mOutputMenu->addMenu(tr("Heap Info")); - mOutputStackInfoMenu = mOutputMenu->addMenu(tr("Stack Info")); - mOutputGenInfoMenu->addAction(tr("Summary")); - mOutputGenInfoMenu->addAction(tr("Detailed Info")); - mOutputGenInfoMenu->addAction(tr("Handle Info")); - mOutputGenInfoMenu->addAction(tr("Kernel Containters")); - mOutputHeapInfoMenu->addAction(tr("Detailed Summary")); - mOutputHeapInfoMenu->addAction(tr("Compact Summary")); - mOutputHeapInfoMenu->addAction(tr("Cell Listing")); - mOutputHeapInfoMenu->addAction(tr("Data (Binary)")); - mOutputStackInfoMenu->addAction(tr("Detailed Summary")); - mOutputStackInfoMenu->addAction(tr("Compact Summary")); - mOutputStackInfoMenu->addAction(tr("User Stacks (Binary)")); - mOutputStackInfoMenu->addAction(tr("Kernel Stacks (Binary)")); - menu()->addAction(tr("Start Auto Capture")); - menu()->addAction(tr("Settings ...")); + menu()->addAction(tr("Settings ..."), this, SLOT(showSettings())); menu()->addAction(tr("About ..."), this, SLOT(showAbout())); menu()->addAction(tr("Exit"), qApp, SLOT(quit())); @@ -102,18 +107,51 @@ return false; } +bool MemSpyView::isBreadCrumbVisible() const +{ + return false; +} + +QString MemSpyView::getBreadCrumbText() const +{ + QStringList views; + for (int i=1; iviews().count() - 1; i++) { + const HbView *view = mainWindow()->views().at(i); + if (view == this) + break; + views.append(view->title()); + } + views.append(title()); + + return views.join(" > "); +} + void MemSpyView::refresh() { // Empty default implementation } +void MemSpyView::showSettings() +{ + MemSpySettingsView* settings = new MemSpySettingsView(mEngine); + connect(settings, SIGNAL(finished(bool)), this, SLOT(closeSettings())); + mainWindow()->addView(settings); + mainWindow()->setCurrentView(settings); +} + void MemSpyView::showAbout() { HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); - messageBox->setText("Version 2.0.0 - 23th April 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0."); + messageBox->setText("Version 2.1.0 - 15th June 2010. Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Licensed under Eclipse Public License v1.0."); HbLabel *header = new HbLabel("About MemSpy", messageBox); messageBox->setHeadingWidget(header); messageBox->setAttribute(Qt::WA_DeleteOnClose); messageBox->setTimeout(HbPopup::NoTimeout); messageBox->open(); } + +void MemSpyView::closeSettings() +{ + sender()->deleteLater(); + mainWindow()->setCurrentView(this); +} diff -r e0ec97ec3cc4 -r 98924d2efce9 memspyui/ui/hb/src/viewmanager.cpp --- a/memspyui/ui/hb/src/viewmanager.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/memspyui/ui/hb/src/viewmanager.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -17,6 +17,8 @@ #include #include +#include +#include #include "viewmanager.h" @@ -30,6 +32,9 @@ #include "memspykernelobjecttypeview.h" #include "memspykernelobjectview.h" #include "memspykernelobjectdetailview.h" +#include "memspytrackingview.h" +#include "memspyswmtview.h" +#include "memspyheapdumpsview.h" template static MemSpyView* factory(EngineWrapper &engine, ViewManager &viewManager) @@ -45,7 +50,10 @@ &factory, &factory, &factory, - &factory + &factory, + &factory, + &factory, + &factory }; @@ -59,8 +67,30 @@ void ViewManager::showView(ViewIndex viewIndex, const QVariantMap ¶ms) { - MemSpyView* view = sFactories[viewIndex](mEngine, *this); - view->initialize(params); + MemSpyView* view; + try { + view = sFactories[viewIndex](mEngine, *this); + view->initialize(params); + } + catch (std::exception& ex) + { + // show message box with exception + // TODO: qt_symbian_exception2Error shouldn't probably be here + QString error = tr("An error occured during the operation. Error code: %1").arg( + qt_symbian_exception2Error(ex)); + + HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning); + messageBox->setText(error); + HbLabel *header = new HbLabel(tr("Error"), messageBox); + messageBox->setHeadingWidget(header); + messageBox->setAttribute(Qt::WA_DeleteOnClose); + messageBox->setTimeout(HbPopup::StandardTimeout); + messageBox->open(); + + delete view; + return; + } + if (viewIndex != MainView) { HbAction* action = new HbAction(Hb::BackNaviAction, this); connect(action, SIGNAL(triggered()), this, SLOT(goBack())); diff -r e0ec97ec3cc4 -r 98924d2efce9 perfmon/ui/hb/app/app.pro --- a/perfmon/ui/hb/app/app.pro Wed Jun 23 18:13:31 2010 +0300 +++ b/perfmon/ui/hb/app/app.pro Tue Jul 06 14:17:03 2010 +0300 @@ -46,14 +46,20 @@ RESOURCES += symbian: { - INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE INCLUDEPATH += ../../../engine/inc HEADERS += ../../../engine/inc/perfmon_engine.h SOURCES += ../../../engine/src/perfmon_engine.cpp LIBS += -lestor \ - -lbafl + -lbafl \ + -lefsrv \ + -lavkon \ + -lapparc \ + -lapgrfx \ + -lgdi \ + -lcone TARGET.CAPABILITY = WriteDeviceData diff -r e0ec97ec3cc4 -r 98924d2efce9 piprofilerui/ui/hb/hb.pro --- a/piprofilerui/ui/hb/hb.pro Wed Jun 23 18:13:31 2010 +0300 +++ b/piprofilerui/ui/hb/hb.pro Tue Jul 06 14:17:03 2010 +0300 @@ -55,7 +55,7 @@ TARGET.CAPABILITY = ALL -TCB - LIBS += -lcharconv -lbafl -lsysutil + LIBS += -lcharconv -lbafl -lsysutil -lefsrv ICON = ../icons/qgn_menu_piprofilerui.svg diff -r e0ec97ec3cc4 -r 98924d2efce9 screengrabber/screengrabber.pro --- a/screengrabber/screengrabber.pro Wed Jun 23 18:13:31 2010 +0300 +++ b/screengrabber/screengrabber.pro Tue Jul 06 14:17:03 2010 +0300 @@ -49,7 +49,7 @@ BLD_INF_RULES.prj_extensions += screengrabber_buildstubsis_extension - LIBS += -lestor -lws32 -lPlatformEnv -limageconversion -lapgrfx -lcommonengine -lfbscli -lgdi -leikcore -lbafl + LIBS += -lestor -lws32 -lPlatformEnv -limageconversion -lapgrfx -lcommonengine -lfbscli -lgdi -leikcore -lbafl -lefsrv -lapparc -lcone HEADERS += inc/sgengine.h \ inc/enginewrapper.h \ diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/group/ReleaseNote.txt --- a/stifui/avkon/group/ReleaseNote.txt Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/group/ReleaseNote.txt Tue Jul 06 14:17:03 2010 +0300 @@ -1,5 +1,5 @@ ======================================================================== -RELEASE NOTE FOR STIF UI - STIF_201022 (7.3.34) +RELEASE NOTE FOR STIF UI - STIF_201024 (7.3.35) SUPPORTING SERIES 60 3.0 -> ======================================================================== diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/inc/AppUIApp.h --- a/stifui/avkon/stifui/inc/AppUIApp.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/inc/AppUIApp.h Tue Jul 06 14:17:03 2010 +0300 @@ -54,5 +54,3 @@ #endif // End of File - -// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/inc/AppUIDocument.h --- a/stifui/avkon/stifui/inc/AppUIDocument.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/inc/AppUIDocument.h Tue Jul 06 14:17:03 2010 +0300 @@ -69,5 +69,3 @@ #endif // End of File - -// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/inc/MenuListBox.h --- a/stifui/avkon/stifui/inc/MenuListBox.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/inc/MenuListBox.h Tue Jul 06 14:17:03 2010 +0300 @@ -73,3 +73,5 @@ }; #endif /*MENULISTBOX_H_*/ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/inc/Stifui.hrh --- a/stifui/avkon/stifui/inc/Stifui.hrh Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/inc/Stifui.hrh Tue Jul 06 14:17:03 2010 +0300 @@ -109,4 +109,5 @@ }; #endif // STIF_UI_HRH + // End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/inc/Stifui_loc.hrh --- a/stifui/avkon/stifui/inc/Stifui_loc.hrh Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/inc/Stifui_loc.hrh Tue Jul 06 14:17:03 2010 +0300 @@ -142,4 +142,3 @@ #define qtn_testcase_state_unknown "Undefined state!" // End of File - diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/inc/TestSetMenuView.h --- a/stifui/avkon/stifui/inc/TestSetMenuView.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/inc/TestSetMenuView.h Tue Jul 06 14:17:03 2010 +0300 @@ -164,4 +164,4 @@ #endif // TESTSETMENUVIEW_H -// End of File \ No newline at end of file +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/inc/version.h --- a/stifui/avkon/stifui/inc/version.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/inc/version.h Tue Jul 06 14:17:03 2010 +0300 @@ -20,10 +20,12 @@ #define STIFUI_MAJOR_VERSION 7 #define STIFUI_MINOR_VERSION 3 -#define STIFUI_BUILD_VERSION 34 +#define STIFUI_BUILD_VERSION 35 -#define STIFUI_REL_DATE "1st June 2010" +#define STIFUI_REL_DATE "15th June 2010" #define TO_UNICODE(text) _L(text) #endif /*VERSION_H_*/ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/AppUIApp.cpp --- a/stifui/avkon/stifui/src/AppUIApp.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/AppUIApp.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -67,5 +67,4 @@ return EikStart::RunApplication(NewApplication); } - // End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/AppUIDocument.cpp --- a/stifui/avkon/stifui/src/AppUIDocument.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/AppUIDocument.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -59,4 +59,4 @@ return new (ELeave) CAppUIAppUi; } -// End of File +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/CreatedTestSetMenuView.cpp --- a/stifui/avkon/stifui/src/CreatedTestSetMenuView.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/CreatedTestSetMenuView.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -188,12 +188,10 @@ substracted.Set(substracted.Right(substracted.Length()-2)); // Creating new view containing CTestSetMenuView* testSetMenu = (CTestSetMenuView*)AppUi()->View( TUid::Uid(ETestSetMenuViewId) ); - TInt error = testSetMenu->LoadTestSetL( substracted ); - AppUi()->HandleCommandL(ECmdGoToTestSetView); - + User::LeaveIfError( testSetMenu->LoadTestSetL( substracted ) ); + AppUi()->HandleCommandL(ECmdGoToTestSetView); } } - // End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/MainMenuContainer.cpp --- a/stifui/avkon/stifui/src/MainMenuContainer.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/MainMenuContainer.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -214,4 +214,4 @@ ((CMenuListBox*)iListBox)->SaveFocusPosition(); } -// End of File +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/MainMenuView.cpp --- a/stifui/avkon/stifui/src/MainMenuView.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/MainMenuView.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -159,5 +159,3 @@ } // End of File - -// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/MenuListBox.cpp --- a/stifui/avkon/stifui/src/MenuListBox.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/MenuListBox.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -106,3 +106,5 @@ this->SetTopItemIndex(0); } } + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/ShowStartedCasesContainer.cpp --- a/stifui/avkon/stifui/src/ShowStartedCasesContainer.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/ShowStartedCasesContainer.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -551,10 +551,8 @@ // void CShowStartedCasesContainer::RemoveAllExecutionsInViewL() { - TInt exutionsInViewCount = iStartedTestsPtrs.Count(); - iStartedTestsPtrs.Reset(); //Empties the array, does not delete the objects whose pointers are contained in the array + iStartedTestsPtrs.Reset(); // Empties the array, does not delete the objects whose pointers are contained in the array HandleItemRemovalL(); - } // ---------------------------------------------------------------------------- @@ -645,4 +643,4 @@ ((CMenuListBox*)iListBox)->SaveFocusPosition(); } -// End of File +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/StartedCasesMenuContainer.cpp --- a/stifui/avkon/stifui/src/StartedCasesMenuContainer.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/StartedCasesMenuContainer.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -230,5 +230,4 @@ ((CMenuListBox*)iListBox)->SaveFocusPosition(); } - -// End of File +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/StartedCasesMenuView.cpp --- a/stifui/avkon/stifui/src/StartedCasesMenuView.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/StartedCasesMenuView.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -157,4 +157,3 @@ } // End of File - diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/TestCaseMenuContainer.cpp --- a/stifui/avkon/stifui/src/TestCaseMenuContainer.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/TestCaseMenuContainer.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -221,4 +221,4 @@ ((CMenuListBox*)iListBox)->SaveFocusPosition(); } -// End of File +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/TestSetBaseMenuContainer.cpp --- a/stifui/avkon/stifui/src/TestSetBaseMenuContainer.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/TestSetBaseMenuContainer.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -185,4 +185,5 @@ { ((CMenuListBox*)iListBox)->SaveFocusPosition(); } -// End of File + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/TestSetInsertMenuContainer.cpp --- a/stifui/avkon/stifui/src/TestSetInsertMenuContainer.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/TestSetInsertMenuContainer.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -220,5 +220,5 @@ { ((CMenuListBox*)iListBox)->SaveFocusPosition(); } - + // End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/TestSetMenuView.cpp --- a/stifui/avkon/stifui/src/TestSetMenuView.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/TestSetMenuView.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -550,5 +550,4 @@ } } - // End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/TestSetStartedCasesContainer.cpp --- a/stifui/avkon/stifui/src/TestSetStartedCasesContainer.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/TestSetStartedCasesContainer.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -446,7 +446,6 @@ // void CTestSetStartedCasesContainer::RemoveAllExecutionsInViewL() { - TInt exutionsInViewCount = iStartedTestsPtrs.Count(); iStartedTestsPtrs.Reset(); //Empties the array, does not delete the objects whose pointers are contained in the array HandleItemRemovalL(); @@ -463,4 +462,4 @@ ((CMenuListBox*)iListBox)->SaveFocusPosition(); } -// End of File +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/Testmodulesmenuview.cpp --- a/stifui/avkon/stifui/src/Testmodulesmenuview.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/Testmodulesmenuview.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -277,4 +277,3 @@ } // End of File - diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/stifui/src/UIStoreHandler.cpp --- a/stifui/avkon/stifui/src/UIStoreHandler.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/stifui/src/UIStoreHandler.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -137,4 +137,4 @@ // ================= OTHER EXPORTED FUNCTIONS ================================= // None -// End of File +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/uitestserverstarter/inc/UITestServerStarter.hrh --- a/stifui/avkon/uitestserverstarter/inc/UITestServerStarter.hrh Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/uitestserverstarter/inc/UITestServerStarter.hrh Tue Jul 06 14:17:03 2010 +0300 @@ -21,3 +21,5 @@ #define _UID3 0x2000F8E8 #endif // __UITESTSERVERSTARTER_HRH__ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/uitestserverstarter/inc/UITestServerStarterApplication.h --- a/stifui/avkon/uitestserverstarter/inc/UITestServerStarterApplication.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/uitestserverstarter/inc/UITestServerStarterApplication.h Tue Jul 06 14:17:03 2010 +0300 @@ -109,3 +109,5 @@ #endif /*UITESTSERVERSTARTERAPPLICATION_H_*/ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/uitestserverstarter/inc/UITestServerStarterDocument.h --- a/stifui/avkon/uitestserverstarter/inc/UITestServerStarterDocument.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/uitestserverstarter/inc/UITestServerStarterDocument.h Tue Jul 06 14:17:03 2010 +0300 @@ -142,3 +142,5 @@ #endif /*UITESTSERVERSTARTERDOCUMENT_H_*/ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/uitestserverstarter/src/EventUtil.cpp --- a/stifui/avkon/uitestserverstarter/src/EventUtil.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/uitestserverstarter/src/EventUtil.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -884,7 +884,7 @@ int keyScanCodeNamesCount = (sizeof( keyScanCodeNames )/sizeof(TText*)); for ( int i = 0; i < keyScanCodeNamesCount; i++ ) { - if ( keyScanCodes[ i ] == aKeyScanCode ) + if ( keyScanCodes[ i ] == (TUint)aKeyScanCode ) { return keyScanCodeNames[ i ]; } diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/uitestserverstarter/src/UITestServerStarterAppContainer.cpp --- a/stifui/avkon/uitestserverstarter/src/UITestServerStarterAppContainer.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/uitestserverstarter/src/UITestServerStarterAppContainer.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -287,5 +287,4 @@ return CCoeControl::MopSupplyObject( aId ); } - // End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/avkon/uitestserverstarter/src/UITestServerStarterAppUi.cpp --- a/stifui/avkon/uitestserverstarter/src/UITestServerStarterAppUi.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/avkon/uitestserverstarter/src/UITestServerStarterAppUi.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -240,6 +240,9 @@ } } break; + default: + // Do nothing + break; } } else if ( aEvent.Type() == EEventPointer ) @@ -247,7 +250,7 @@ if ( iEventType == EPointerEvent ) { PointerEventHandled(); - } + } } } @@ -504,5 +507,4 @@ iEventStatus = aStatus; } - // End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/ReleaseNote.txt --- a/stifui/qt/ReleaseNote.txt Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/ReleaseNote.txt Tue Jul 06 14:17:03 2010 +0300 @@ -1,5 +1,5 @@ ======================================================================== -RELEASE NOTE FOR STFUI_201022 (7.3.34) +RELEASE NOTE FOR STFUI_201024 (7.3.35) ======================================================================== Product Description: diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/cstfcase.h --- a/stifui/qt/inc/cstfcase.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/cstfcase.h Tue Jul 06 14:17:03 2010 +0300 @@ -61,3 +61,5 @@ QString moduleName; }; #endif // CSTFCASE_H + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/cstfmodule.h --- a/stifui/qt/inc/cstfmodule.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/cstfmodule.h Tue Jul 06 14:17:03 2010 +0300 @@ -48,3 +48,5 @@ }; #endif // CSTFMODULE_H + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/dlgoutput.h --- a/stifui/qt/inc/dlgoutput.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/dlgoutput.h Tue Jul 06 14:17:03 2010 +0300 @@ -66,3 +66,5 @@ #endif /* DLGOUTPUT_H_ */ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/dlgrepeatrun.h --- a/stifui/qt/inc/dlgrepeatrun.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/dlgrepeatrun.h Tue Jul 06 14:17:03 2010 +0300 @@ -60,3 +60,5 @@ }; #endif /* DLGREPEATRUN_H_ */ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/dlgsetselector.h --- a/stifui/qt/inc/dlgsetselector.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/dlgsetselector.h Tue Jul 06 14:17:03 2010 +0300 @@ -62,3 +62,5 @@ #endif /* DLGSETSELECTOR_H_ */ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/dlgsetting.h --- a/stifui/qt/inc/dlgsetting.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/dlgsetting.h Tue Jul 06 14:17:03 2010 +0300 @@ -25,6 +25,8 @@ class QGridLayout; class QCheckBox; class QPushButton; +class QLabel; +class QLineEdit; QT_END_NAMESPACE class DlgSetting : public QDialog { @@ -40,6 +42,9 @@ QPushButton* btnOk; QPushButton* btnCancel; QCheckBox* chkShowoutput; + QLabel* lblFilter; + QLineEdit* ledFilter; + QCheckBox* chkFilterCaseSens; private slots: void on_btnOk_clicked(); @@ -51,3 +56,5 @@ }; #endif /* DLGSETTING_H_ */ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/frmmain.h --- a/stifui/qt/inc/frmmain.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/frmmain.h Tue Jul 06 14:17:03 2010 +0300 @@ -96,6 +96,8 @@ UiSetting* uiSetting; bool layoutType; QTreeWidgetItem* lastItemSelected; + QString currentFilter; + QString currentFilterCaseSens; private: //UI Components QWidget* centerWidget; @@ -199,3 +201,5 @@ }; #endif // FrmMain_H + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/istfqtuicontroller.h --- a/stifui/qt/inc/istfqtuicontroller.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/istfqtuicontroller.h Tue Jul 06 14:17:03 2010 +0300 @@ -82,3 +82,5 @@ #endif // ISTFQTUICONTROLLER_H + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/istfqtuimodel.h --- a/stifui/qt/inc/istfqtuimodel.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/istfqtuimodel.h Tue Jul 06 14:17:03 2010 +0300 @@ -53,3 +53,5 @@ }; #endif // ISTFQTUIMODEL_H + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/stfqtuicontroller.h --- a/stifui/qt/inc/stfqtuicontroller.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/stfqtuicontroller.h Tue Jul 06 14:17:03 2010 +0300 @@ -101,3 +101,5 @@ #endif /* STFQTUICONTROLLER_H_ */ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/stfqtuimodel.h --- a/stifui/qt/inc/stfqtuimodel.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/stfqtuimodel.h Tue Jul 06 14:17:03 2010 +0300 @@ -56,3 +56,5 @@ }; + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/stifexecutor.h --- a/stifui/qt/inc/stifexecutor.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/stifexecutor.h Tue Jul 06 14:17:03 2010 +0300 @@ -76,3 +76,5 @@ #endif /* STIFEXECUTOR_H_ */ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/uisetting.h --- a/stifui/qt/inc/uisetting.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/uisetting.h Tue Jul 06 14:17:03 2010 +0300 @@ -20,7 +20,8 @@ const QString KShowOutput = "showoutput"; const QString KStyleSheet = "StyleSheet"; - +const QString KFilter = "filter"; +const QString KFilterCaseSens = "filtercasesens"; class UiSetting { @@ -43,3 +44,5 @@ }; #endif /* UISETTING_H_ */ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/uiversion.h --- a/stifui/qt/inc/uiversion.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/uiversion.h Tue Jul 06 14:17:03 2010 +0300 @@ -24,3 +24,5 @@ const QString QtUIName = "STFUI"; #endif /* UIVERSION_H_ */ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/inc/version.h --- a/stifui/qt/inc/version.h Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/inc/version.h Tue Jul 06 14:17:03 2010 +0300 @@ -20,10 +20,12 @@ #define STIF_MAJOR_VERSION 7 #define STIF_MINOR_VERSION 3 -#define STIF_BUILD_VERSION 34 +#define STIF_BUILD_VERSION 35 -#define STIF_REL_DATE "1st June 2010" +#define STIF_REL_DATE "15th June 2010" #define TO_UNICODE(text) _L(text) #endif /*VERSION_H_*/ + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/rom/stfui.iby --- a/stifui/qt/rom/stfui.iby Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/rom/stfui.iby Tue Jul 06 14:17:03 2010 +0300 @@ -19,15 +19,15 @@ #ifndef __STIF_UI_IBY__ #define __STIF_UI_IBY__ -S60_APP_EXE(Stifqtui) +S60_APP_EXE(Stfqtui) #ifdef S60_UPGRADABLE_APP_REG_RSC - S60_UPGRADABLE_APP_REG_RSC(Stifqtui) + S60_UPGRADABLE_APP_REG_RSC(Stfqtui) #else - S60_APP_AIF_RSC(Stifqtui) + S60_APP_AIF_RSC(Stfqtui) #endif -S60_APP_RESOURCE(Stifqtui) +S60_APP_RESOURCE(Stfqtui) #endif // End of File \ No newline at end of file diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/sis/stifqtui.pkg --- a/stifui/qt/sis/stifqtui.pkg Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/sis/stifqtui.pkg Tue Jul 06 14:17:03 2010 +0300 @@ -22,6 +22,6 @@ (0x2001E61C), 4, 5, 2, {"QtLibs pre-release"} ; Executable and default resource files -"/S60/non_public/S60_5_0_200906/epoc32/release/armv5/urel/STFUI.exe" - "!:\sys\bin\STFUI.exe" -"/S60/non_public/S60_5_0_200906/epoc32/data/z/resource/apps/STFUI.rsc" - "!:\resource\apps\STFUI.rsc" -"/S60/non_public/S60_5_0_200906/epoc32/data/z/private/10003a3f/import/apps/STFUI_reg.rsc" - "!:\private\10003a3f\import\apps\STFUI_reg.rsc" +"/epoc32/release/armv5/urel/STFUI.exe" - "!:\sys\bin\STFUI.exe" +"/epoc32/data/z/resource/apps/STFUI.rsc" - "!:\resource\apps\STFUI.rsc" +"/epoc32/data/z/private/10003a3f/import/apps/STFUI_reg.rsc" - "!:\private\10003a3f\import\apps\STFUI_reg.rsc" diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/src/dlgoutput.cpp --- a/stifui/qt/src/dlgoutput.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/src/dlgoutput.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -69,8 +69,6 @@ void DlgOutput::CloseItem(QString index) { - int u = tabList.keys().indexOf(index); - delete tabList.value(index); tabList.remove(index); if (tabMain->count() == 0) @@ -141,3 +139,4 @@ } +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/src/dlgrepeatrun.cpp --- a/stifui/qt/src/dlgrepeatrun.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/src/dlgrepeatrun.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -129,3 +129,5 @@ lineEdit->setReadOnly(false); } } + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/src/dlgsetselector.cpp --- a/stifui/qt/src/dlgsetselector.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/src/dlgsetselector.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -112,3 +112,5 @@ { this->reject(); } + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/src/dlgsetting.cpp --- a/stifui/qt/src/dlgsetting.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/src/dlgsetting.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -33,6 +33,16 @@ chkShowoutput = new QCheckBox(this); chkShowoutput->setText(tr("Show output in execution.")); chkShowoutput->setChecked(setting->ReadSetting(KShowOutput) == "true"); + + lblFilter = new QLabel(this); + lblFilter->setText(tr("Filter for displayed titles.")); + ledFilter = new QLineEdit(this); + ledFilter->setFrame(true); + ledFilter->setText(setting->ReadSetting(KFilter)); + chkFilterCaseSens = new QCheckBox(this); + chkFilterCaseSens->setText(tr("Filter is case sensitive.")); + chkFilterCaseSens->setChecked(setting->ReadSetting(KFilterCaseSens) == "true"); + QWidget *toolWidget = new QWidget(this); QGridLayout *toolLayout = new QGridLayout(this); @@ -51,7 +61,10 @@ mainLayout->addWidget(nullWidget, 0, 0); mainLayout->addWidget(chkShowoutput, 1, 0); - mainLayout->addWidget(toolWidget, 3, 0); + mainLayout->addWidget(lblFilter, 3, 0); + mainLayout->addWidget(ledFilter, 4, 0); + mainLayout->addWidget(chkFilterCaseSens, 5, 0); + mainLayout->addWidget(toolWidget, 7, 0); } @@ -65,6 +78,8 @@ { setting->SetSetting(KShowOutput, "false"); } + setting->SetSetting(KFilter, ledFilter->text()); + setting->SetSetting(KFilterCaseSens, (chkFilterCaseSens->checkState() == Qt::Checked) ? ("true") : ("false")); this->accept(); } @@ -72,3 +87,5 @@ { this->reject(); } + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/src/frmmain.cpp --- a/stifui/qt/src/frmmain.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/src/frmmain.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -108,6 +108,51 @@ void FrmMain::setSetting() { controller->SetShowOutput(uiSetting->ReadSetting(KShowOutput) == "true"); + // Apply filter changes + QString newFilter = uiSetting->ReadSetting(KFilter); + QString newFilterCaseSens = uiSetting->ReadSetting(KFilterCaseSens); + if(currentFilter != newFilter || currentFilterCaseSens != newFilterCaseSens) + { + // Store new filter for further use + currentFilter = newFilter; + currentFilterCaseSens = newFilterCaseSens; + + // Create and setup regular expression for wildcard searching + QRegExp filter; + filter.setPattern((newFilter == "") ? ("*") : (tr("*") + newFilter + tr("*"))); + filter.setCaseSensitivity((newFilterCaseSens == "true") ? (Qt::CaseSensitive) : (Qt::CaseInsensitive)); + filter.setPatternSyntax(QRegExp::Wildcard); + + // Go through top level entries (modules) + bool isAnythingHidden = false; + for(int i = 0; i < treeModuleList->topLevelItemCount(); i++) + { + QTreeWidgetItem* top = treeModuleList->topLevelItem(i); + // And through test cases for each module + for(int j = 0; j < top->childCount(); j++) + { + QTreeWidgetItem *child = top->child(j); + // Remove first three chars to get valid test case title + QString title = (child->text(0)).mid(3); + // Check if title is matching to filter and show or hide it + if(filter.exactMatch(title)) + { + child->setHidden(false); + } + else + { + child->setHidden(true); + child->setText(0, child->text(0).replace(0, 3, UNSELECTITEMHEADER)); + isAnythingHidden = true; + } + } + } + + if(isAnythingHidden) + treeModuleList->headerItem()->setText(0, tr("Module List (filtered)")); + else + treeModuleList->headerItem()->setText(0, tr("Module List")); + } } void FrmMain::OnGetMessage(const QString& aMessage) @@ -801,11 +846,13 @@ QTreeWidgetItem* item = treeModuleList->topLevelItem(index); while (item != 0) { - item->setText(0, item->text(0).replace(0,3, header)); + if(!item->isHidden()) + item->setText(0, item->text(0).replace(0,3, header)); for (int i = 0; i < item->childCount(); i++) { QTreeWidgetItem* child = item->child(i); - child->setText(0,child->text(0).replace(0,3,header)); + if(!child->isHidden()) + child->setText(0,child->text(0).replace(0,3,header)); } index++; item = treeModuleList->topLevelItem(index); @@ -844,6 +891,8 @@ void FrmMain::on_actSetting_triggered() { DlgSetting dlgSet(uiSetting); + currentFilter = uiSetting->ReadSetting(KFilter); + currentFilterCaseSens = uiSetting->ReadSetting(KFilterCaseSens); int result = dlgSet.exec(); if(result == QDialog::Accepted) { @@ -1108,4 +1157,4 @@ controller->SetShowOutput(true); } - +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/src/main.cpp --- a/stifui/qt/src/main.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/src/main.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -27,3 +27,4 @@ return app.exec(); } +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/src/stfqtuicontroller.cpp --- a/stifui/qt/src/stfqtuicontroller.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/src/stfqtuicontroller.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -407,3 +407,5 @@ listener->OnSetListChanged(); } } + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/src/stfqtuimodel.cpp --- a/stifui/qt/src/stfqtuimodel.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/src/stfqtuimodel.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -91,6 +91,8 @@ case EStatusCrashed: crashedCaseList.append(aCase); break; + default: + break; } FireOnCaseStatisticChangedEvent(); } @@ -111,6 +113,8 @@ return abortCaseList; case EStatusCrashed: return crashedCaseList; + default: + break; } QList list; return list; @@ -159,3 +163,5 @@ crashedCaseList.clear(); FireOnCaseStatisticChangedEvent(); } + +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/src/stifexecutor.cpp --- a/stifui/qt/src/stifexecutor.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/src/stifexecutor.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -404,3 +404,4 @@ } +// End of File diff -r e0ec97ec3cc4 -r 98924d2efce9 stifui/qt/src/uisetting.cpp --- a/stifui/qt/src/uisetting.cpp Wed Jun 23 18:13:31 2010 +0300 +++ b/stifui/qt/src/uisetting.cpp Tue Jul 06 14:17:03 2010 +0300 @@ -65,6 +65,8 @@ settingList.clear(); settingList.insert(KShowOutput, getDefaultValue(KShowOutput)); settingList.insert(KStyleSheet, getDefaultValue(KStyleSheet)); + settingList.insert(KFilter, getDefaultValue(KFilter)); + settingList.insert(KFilterCaseSens, getDefaultValue(KFilterCaseSens)); //add mor default setting here. } @@ -79,6 +81,14 @@ { result = ":/qss/coffee.qss"; } + else if(item == KFilter) + { + result = ""; + } + else if(item == KFilterCaseSens) + { + result = "false"; + } return result; } @@ -102,6 +112,8 @@ { item = line.left(index).trimmed(); value = line.right(line.length() - index -1); + if(item == KFilter) //For filter do not care about stored value + value = ""; settingList.insert(item, value); } } @@ -131,3 +143,4 @@ return true; } +// End of File