# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1282203843 -10800 # Node ID 453dfc402455eb57fd5f1a993e2b844136286599 # Parent dbd1c5e08735e24bed43163c649dc0ec8c3720d7 Revision: 201030 Kit: 201033 diff -r dbd1c5e08735 -r 453dfc402455 backupandrestore/backupengine/src/sbecompressionandencryption.cpp --- a/backupandrestore/backupengine/src/sbecompressionandencryption.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/backupandrestore/backupengine/src/sbecompressionandencryption.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -709,7 +709,7 @@ iEncryptionHeader.iEncrypted, iEncryptionHeader.iBufferSize, iEncryptionHeader.iTotalSize); // Check we have a sensible encryption header - if ((iEncryptionHeader.iBufferSize < 0) || + if ((iEncryptionHeader.iBufferSize < 0) || (iEncryptionHeader.iBufferSize >= KMaxTInt/2) || (iEncryptionHeader.iTotalSize < 0)) { __LOG("CSBEDecompressAndEncrypt::CreateCipherL() - Corrupt data"); diff -r dbd1c5e08735 -r 453dfc402455 backupandrestore/backuptest/ABTester/group/bld.inf --- a/backupandrestore/backuptest/ABTester/group/bld.inf Thu Jul 15 19:35:12 2010 +0300 +++ b/backupandrestore/backuptest/ABTester/group/bld.inf Thu Aug 19 10:44:03 2010 +0300 @@ -33,10 +33,10 @@ ./abtester.oby /epoc32/rom/include/abtester.oby ./abtester.iby /epoc32/rom/include/abtester.iby - ../data/incremental_active_backup_registration.xml z:/private/0AB7E57C/backup_registration.xml - ../data/proxy_active_backup_registration.xml z:/private/0AB7E57D/backup_registration.xml - ../data/base_active_backup_registration.xml z:/private/0AB7E57E/backup_registration.xml - ../data/base_active_backup_registration2.xml z:/private/0AB7E58A/backup_registration.xml - ../data/base_active_backup_registration3.xml z:/private/0AB7E58B/backup_registration.xml - ../data/passive_backup_registration.xml z:/private/0AB7E58C/backup_registration.xml - ../data/backup_public_files_registration.xml z:/private/0FA00001/backup_registration.xml + ../data/incremental_active_backup_registration.xml z:/private/0ab7e57c/backup_registration.xml + ../data/proxy_active_backup_registration.xml z:/private/0ab7e57d/backup_registration.xml + ../data/base_active_backup_registration.xml z:/private/0ab7e57e/backup_registration.xml + ../data/base_active_backup_registration2.xml z:/private/0ab7e58a/backup_registration.xml + ../data/base_active_backup_registration3.xml z:/private/0ab7e58b/backup_registration.xml + ../data/passive_backup_registration.xml z:/private/0ab7e58c/backup_registration.xml + ../data/backup_public_files_registration.xml z:/private/0fa00001/backup_registration.xml diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/clients/syncclient/bwins/sconsyncclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/clients/syncclient/bwins/sconsyncclientu.def Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,43 @@ +EXPORTS + ??0RSconSyncSession@@QAE@XZ @ 1 NONAME ; RSconSyncSession::RSconSyncSession(void) + ??1CSconDataproviderInfo@@UAE@XZ @ 2 NONAME ; CSconDataproviderInfo::~CSconDataproviderInfo(void) + ??1RSconSyncSession@@QAE@XZ @ 3 NONAME ; RSconSyncSession::~RSconSyncSession(void) + ?AddedItemsL@RSconSyncSession@@QBEXAAV?$RArray@H@@@Z @ 4 NONAME ; void RSconSyncSession::AddedItemsL(class RArray &) const + ?CancelRequest@RSconSyncSession@@QAEXXZ @ 5 NONAME ; void RSconSyncSession::CancelRequest(void) + ?Close@RSconSyncSession@@QAEXXZ @ 6 NONAME ; void RSconSyncSession::Close(void) + ?CloseDataStore@RSconSyncSession@@QBEXXZ @ 7 NONAME ; void RSconSyncSession::CloseDataStore(void) const + ?CommitChangeInfoL@RSconSyncSession@@QAEXABV?$RArray@H@@@Z @ 8 NONAME ; void RSconSyncSession::CommitChangeInfoL(class RArray const &) + ?Connect@RSconSyncSession@@QAEHXZ @ 9 NONAME ; int RSconSyncSession::Connect(void) + ?CreateItemL@RSconSyncSession@@QAEXAAHHABVTDesC8@@11@Z @ 10 NONAME ; void RSconSyncSession::CreateItemL(int &, int, class TDesC8 const &, class TDesC8 const &, class TDesC8 const &) + ?CreateItemL@RSconSyncSession@@QAEXAAV?$TPckg@H@@HABVTDesC8@@11AAVTRequestStatus@@@Z @ 11 NONAME ; void RSconSyncSession::CreateItemL(class TPckg &, int, class TDesC8 const &, class TDesC8 const &, class TDesC8 const &, class TRequestStatus &) + ?DefaultStoreL@CSconDataproviderInfo@@QAEAAVTDesC16@@XZ @ 12 NONAME ; class TDesC16 & CSconDataproviderInfo::DefaultStoreL(void) + ?DeleteAllItems@RSconSyncSession@@QAEXAAVTRequestStatus@@@Z @ 13 NONAME ; void RSconSyncSession::DeleteAllItems(class TRequestStatus &) + ?DeleteItemL@RSconSyncSession@@QAEXH@Z @ 14 NONAME ; void RSconSyncSession::DeleteItemL(int) + ?DeletedItemsL@RSconSyncSession@@QBEXAAV?$RArray@H@@@Z @ 15 NONAME ; void RSconSyncSession::DeletedItemsL(class RArray &) const + ?DisplayNameL@CSconDataproviderInfo@@QAEAAVTDesC16@@XZ @ 16 NONAME ; class TDesC16 & CSconDataproviderInfo::DisplayNameL(void) + ?ExternalizeL@CSconDataproviderInfo@@QBEXAAVRWriteStream@@@Z @ 17 NONAME ; void CSconDataproviderInfo::ExternalizeL(class RWriteStream &) const + ?GetParent@RSconSyncSession@@QAEHHAAH@Z @ 18 NONAME ; int RSconSyncSession::GetParent(int, int &) + ?GetSyncTimeStampL@RSconSyncSession@@QBEXHHAAVTDateTime@@@Z @ 19 NONAME ; void RSconSyncSession::GetSyncTimeStampL(int, int, class TDateTime &) const + ?HasSyncHistoryL@RSconSyncSession@@QBEHXZ @ 20 NONAME ; int RSconSyncSession::HasSyncHistoryL(void) const + ?ImplementationUid@CSconDataproviderInfo@@QBE?AVTUid@@XZ @ 21 NONAME ; class TUid CSconDataproviderInfo::ImplementationUid(void) const + ?InternalizeL@CSconDataproviderInfo@@QAEXAAVRReadStream@@@Z @ 22 NONAME ; void CSconDataproviderInfo::InternalizeL(class RReadStream &) + ?ListAllImplementationsL@RSconSyncSession@@QAEXAAV?$RPointerArray@VCSconDataproviderInfo@@@@@Z @ 23 NONAME ; void RSconSyncSession::ListAllImplementationsL(class RPointerArray &) + ?ListStoresL@CSconDataproviderInfo@@QBEPAVCDesC16Array@@XZ @ 24 NONAME ; class CDesC16Array * CSconDataproviderInfo::ListStoresL(void) const + ?ModifiedItemsL@RSconSyncSession@@QBEXAAV?$RArray@H@@@Z @ 25 NONAME ; void RSconSyncSession::ModifiedItemsL(class RArray &) const + ?MoveItemL@RSconSyncSession@@QAEXHH@Z @ 26 NONAME ; void RSconSyncSession::MoveItemL(int, int) + ?MovedItemsL@RSconSyncSession@@QBEXAAV?$RArray@H@@@Z @ 27 NONAME ; void RSconSyncSession::MovedItemsL(class RArray &) const + ?NewL@CSconDataproviderInfo@@SAPAV1@XZ @ 28 NONAME ; class CSconDataproviderInfo * CSconDataproviderInfo::NewL(void) + ?OpenDataStoreL@RSconSyncSession@@QAEXHABVTDesC16@@H@Z @ 29 NONAME ; void RSconSyncSession::OpenDataStoreL(int, class TDesC16 const &, int) + ?OpenItemL@RSconSyncSession@@QAEXHAAH0AAVTDes8@@1AAVCBufFlat@@@Z @ 30 NONAME ; void RSconSyncSession::OpenItemL(int, int &, int &, class TDes8 &, class TDes8 &, class CBufFlat &) + ?ReplaceItemL@RSconSyncSession@@QAEXHHHABVTDesC8@@@Z @ 31 NONAME ; void RSconSyncSession::ReplaceItemL(int, int, int, class TDesC8 const &) + ?ReplaceItemL@RSconSyncSession@@QAEXHHHABVTDesC8@@AAVTRequestStatus@@@Z @ 32 NONAME ; void RSconSyncSession::ReplaceItemL(int, int, int, class TDesC8 const &, class TRequestStatus &) + ?ResetChangeInfoL@RSconSyncSession@@QAEXXZ @ 33 NONAME ; void RSconSyncSession::ResetChangeInfoL(void) + ?SetDefaultStoreL@CSconDataproviderInfo@@QAEXABVTDesC16@@@Z @ 34 NONAME ; void CSconDataproviderInfo::SetDefaultStoreL(class TDesC16 const &) + ?SetDisplayNameL@CSconDataproviderInfo@@QAEXABVTDesC16@@@Z @ 35 NONAME ; void CSconDataproviderInfo::SetDisplayNameL(class TDesC16 const &) + ?SetImplementationUid@CSconDataproviderInfo@@QAEXVTUid@@@Z @ 36 NONAME ; void CSconDataproviderInfo::SetImplementationUid(class TUid) + ?SetRemoteStoreFormatL@RSconSyncSession@@QAEXABVCSmlDataStoreFormat@@@Z @ 37 NONAME ; void RSconSyncSession::SetRemoteStoreFormatL(class CSmlDataStoreFormat const &) + ?SetStoresL@CSconDataproviderInfo@@QAEXABVCDesC16Array@@@Z @ 38 NONAME ; void CSconDataproviderInfo::SetStoresL(class CDesC16Array const &) + ?SoftDeleteItemL@RSconSyncSession@@QAEXH@Z @ 39 NONAME ; void RSconSyncSession::SoftDeleteItemL(int) + ?SoftDeletedItemsL@RSconSyncSession@@QBEXAAV?$RArray@H@@@Z @ 40 NONAME ; void RSconSyncSession::SoftDeletedItemsL(class RArray &) const + ?StoreFormatL@RSconSyncSession@@QAEPAVCSmlDataStoreFormat@@ABVRStringPool@@@Z @ 41 NONAME ; class CSmlDataStoreFormat * RSconSyncSession::StoreFormatL(class RStringPool const &) + diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/clients/syncclient/eabi/sconsyncclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/clients/syncclient/eabi/sconsyncclientu.def Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,49 @@ +EXPORTS + _ZN16RSconSyncSession11CreateItemLER5TPckgIiEiRK6TDesC8S5_S5_R14TRequestStatus @ 1 NONAME + _ZN16RSconSyncSession11CreateItemLERiiRK6TDesC8S3_S3_ @ 2 NONAME + _ZN16RSconSyncSession11DeleteItemLEi @ 3 NONAME + _ZN16RSconSyncSession12ReplaceItemLEiiiRK6TDesC8 @ 4 NONAME + _ZN16RSconSyncSession12ReplaceItemLEiiiRK6TDesC8R14TRequestStatus @ 5 NONAME + _ZN16RSconSyncSession12StoreFormatLERK11RStringPool @ 6 NONAME + _ZN16RSconSyncSession13CancelRequestEv @ 7 NONAME + _ZN16RSconSyncSession14DeleteAllItemsER14TRequestStatus @ 8 NONAME + _ZN16RSconSyncSession14OpenDataStoreLEiRK7TDesC16i @ 9 NONAME + _ZN16RSconSyncSession15SoftDeleteItemLEi @ 10 NONAME + _ZN16RSconSyncSession16ResetChangeInfoLEv @ 11 NONAME + _ZN16RSconSyncSession17CommitChangeInfoLERK6RArrayIiE @ 12 NONAME + _ZN16RSconSyncSession21SetRemoteStoreFormatLERK19CSmlDataStoreFormat @ 13 NONAME + _ZN16RSconSyncSession23ListAllImplementationsLER13RPointerArrayI21CSconDataproviderInfoE @ 14 NONAME + _ZN16RSconSyncSession5CloseEv @ 15 NONAME + _ZN16RSconSyncSession7ConnectEv @ 16 NONAME + _ZN16RSconSyncSession9GetParentEiRi @ 17 NONAME + _ZN16RSconSyncSession9MoveItemLEii @ 18 NONAME + _ZN16RSconSyncSession9OpenItemLEiRiS0_R5TDes8S2_R8CBufFlat @ 19 NONAME + _ZN16RSconSyncSessionC1Ev @ 20 NONAME + _ZN16RSconSyncSessionC2Ev @ 21 NONAME + _ZN16RSconSyncSessionD1Ev @ 22 NONAME + _ZN16RSconSyncSessionD2Ev @ 23 NONAME + _ZN21CSconDataproviderInfo10SetStoresLERK12CDesC16Array @ 24 NONAME + _ZN21CSconDataproviderInfo12DisplayNameLEv @ 25 NONAME + _ZN21CSconDataproviderInfo12InternalizeLER11RReadStream @ 26 NONAME + _ZN21CSconDataproviderInfo13DefaultStoreLEv @ 27 NONAME + _ZN21CSconDataproviderInfo15SetDisplayNameLERK7TDesC16 @ 28 NONAME + _ZN21CSconDataproviderInfo16SetDefaultStoreLERK7TDesC16 @ 29 NONAME + _ZN21CSconDataproviderInfo20SetImplementationUidE4TUid @ 30 NONAME + _ZN21CSconDataproviderInfo4NewLEv @ 31 NONAME + _ZN21CSconDataproviderInfoD0Ev @ 32 NONAME + _ZN21CSconDataproviderInfoD1Ev @ 33 NONAME + _ZN21CSconDataproviderInfoD2Ev @ 34 NONAME + _ZNK16RSconSyncSession11AddedItemsLER6RArrayIiE @ 35 NONAME + _ZNK16RSconSyncSession11MovedItemsLER6RArrayIiE @ 36 NONAME + _ZNK16RSconSyncSession13DeletedItemsLER6RArrayIiE @ 37 NONAME + _ZNK16RSconSyncSession14CloseDataStoreEv @ 38 NONAME + _ZNK16RSconSyncSession14ModifiedItemsLER6RArrayIiE @ 39 NONAME + _ZNK16RSconSyncSession15HasSyncHistoryLEv @ 40 NONAME + _ZNK16RSconSyncSession17GetSyncTimeStampLEiiR9TDateTime @ 41 NONAME + _ZNK16RSconSyncSession17SoftDeletedItemsLER6RArrayIiE @ 42 NONAME + _ZNK21CSconDataproviderInfo11ListStoresLEv @ 43 NONAME + _ZNK21CSconDataproviderInfo12ExternalizeLER12RWriteStream @ 44 NONAME + _ZNK21CSconDataproviderInfo17ImplementationUidEv @ 45 NONAME + _ZTI21CSconDataproviderInfo @ 46 NONAME ; ## + _ZTV21CSconDataproviderInfo @ 47 NONAME ; ## + diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/clients/syncclient/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/clients/syncclient/group/bld.inf Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2009-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: Build information file for project SyncClient +* +*/ + + +PRJ_EXPORTS +../rom/sconsyncclient.iby CORE_APP_LAYER_IBY_EXPORT_PATH(sconsyncclient.iby) + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +sconsyncclient.mmp + +PRJ_TESTMMPFILES diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/clients/syncclient/group/sconsyncclient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/clients/syncclient/group/sconsyncclient.mmp Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,50 @@ +/* +* 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: Client side of sconsyncserver +* +*/ + + +// To get the MW_LAYER_SYSTEMINCLUDE-definition +#include +#include + +TARGET sconsyncclient.dll +TARGETTYPE dll + +CAPABILITY CAP_CLIENT_DLL + +UID 0x1000008d 0x2001A963 +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE sconsyncclient.cpp +SOURCE scondataproviderinfo.cpp + +USERINCLUDE ../inc +USERINCLUDE ../../../inc + +// Server +USERINCLUDE ../../../servers/syncserver/inc + + +// Default system include paths for middleware layer modules. +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY estor.lib +LIBRARY bafl.lib +LIBRARY charconv.lib +LIBRARY smlstoreformat.lib +DEBUGLIBRARY flogger.lib diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/clients/syncclient/inc/scondataproviderinfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/clients/syncclient/inc/scondataproviderinfo.h Thu Aug 19 10:44: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: CSconDataproviderInfo header +* +*/ + + +#ifndef SCONDATAPROVIDERINFO_H_ +#define SCONDATAPROVIDERINFO_H_ + +#include +#include + +class RWriteStream; +class RReadStream; + +/** + * Contains information about DataSync dataprovider. + */ +class CSconDataproviderInfo : public CBase +{ +public: + IMPORT_C static CSconDataproviderInfo* NewL(); + IMPORT_C ~CSconDataproviderInfo(); + + IMPORT_C void ExternalizeL( RWriteStream& aStream ) const; + IMPORT_C void InternalizeL( RReadStream& aStream ); + + IMPORT_C TUid ImplementationUid() const; + IMPORT_C void SetImplementationUid( const TUid aUid ); + IMPORT_C TDesC& DisplayNameL(); + IMPORT_C void SetDisplayNameL( const TDesC& aName ); + IMPORT_C TDesC& DefaultStoreL(); + IMPORT_C void SetDefaultStoreL( const TDesC& aStore ); + IMPORT_C CDesCArray* ListStoresL() const; + IMPORT_C void SetStoresL( const CDesCArray& aStores ); +private: + CSconDataproviderInfo(); + void ConstructL(); + +private: + TInt iUid; + HBufC* iName; + HBufC* iDefaultStore; + CDesCArrayFlat* iStores; +}; + +typedef RPointerArray RSconDataProviderInfoArray; + +#endif /*SCONDATAPROVIDERINFO_H_*/ diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/clients/syncclient/inc/sconsyncclient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/clients/syncclient/inc/sconsyncclient.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: RSconSyncSession header +* +*/ + + +#ifndef _SCONSYNCCLIENT_H_ +#define _SCONSYNCCLIENT_H_ + +#include +#include +#include +#include + +#include "scondataproviderinfo.h" + + + +class CNSmlDataItemUidSet; + +class RSconSyncSession : public RSessionBase +{ +public: + IMPORT_C RSconSyncSession(); + IMPORT_C ~RSconSyncSession(); + + IMPORT_C TInt Connect(); + IMPORT_C void Close(); + + IMPORT_C void ListAllImplementationsL( RSconDataProviderInfoArray& aInfoArray ); + + IMPORT_C void OpenDataStoreL( const TSmlDataProviderId aProviderId, const TDesC& aStoreName, const TInt aContextId ); + + IMPORT_C void OpenItemL(TSmlDbItemUid aUid, TBool& aFieldChange, + TSmlDbItemUid& aParent, TDes8& aMimeType, TDes8& aMimeVer, + CBufFlat& aItemData ); + + IMPORT_C void CreateItemL(TSmlDbItemUid& aUid, TSmlDbItemUid aParent, + const TDesC8& aMimeType, const TDesC8& aMimeVer, const TDesC8& aData); + IMPORT_C void CreateItemL(TPckg& aUidPckg, TSmlDbItemUid aParent, + const TDesC8& aMimeType, const TDesC8& aMimeVer, const TDesC8& aData, + TRequestStatus& aStatus ); + + IMPORT_C void ReplaceItemL(TSmlDbItemUid aUid, TSmlDbItemUid aParent, + TBool aFieldChange, const TDesC8& aData); + IMPORT_C void ReplaceItemL(TSmlDbItemUid aUid, TSmlDbItemUid aParent, + TBool aFieldChange, const TDesC8& aData, + TRequestStatus& aStatus ); + + IMPORT_C void MoveItemL(TSmlDbItemUid aUid, TSmlDbItemUid aNewParent); + IMPORT_C void DeleteItemL(TSmlDbItemUid aUid); + IMPORT_C void SoftDeleteItemL(TSmlDbItemUid aUid); + IMPORT_C void DeleteAllItems( TRequestStatus& aStatus ); + + IMPORT_C TBool HasSyncHistoryL() const; + IMPORT_C void AddedItemsL( RArray& aItems ) const; + IMPORT_C void DeletedItemsL( RArray& aItems ) const; + IMPORT_C void SoftDeletedItemsL( RArray& aItems ) const; + IMPORT_C void ModifiedItemsL( RArray& aItems ) const; + IMPORT_C void MovedItemsL( RArray& aItems ) const; + + IMPORT_C void CloseDataStore() const; + + IMPORT_C void ResetChangeInfoL(); + IMPORT_C void CommitChangeInfoL(const RArray& aItems ); + + IMPORT_C void GetSyncTimeStampL( const TSmlDataProviderId aProviderId, const TInt aContextId, TDateTime& aTimeStamp ) const; + + IMPORT_C CSmlDataStoreFormat* StoreFormatL( const RStringPool& aStringPool ); + IMPORT_C void SetRemoteStoreFormatL( const CSmlDataStoreFormat& aServerDataStoreFormat ); + + + IMPORT_C void CancelRequest(); + + IMPORT_C TInt GetParent( TSmlDbItemUid aUid, TSmlDbItemUid& aParent ); +private: + TInt StartServer(); + TInt CreateAndSendChunkHandle(); +private: + RChunk iChunk; + TIpcArgs iArgs; + +}; + +#endif // _SCONSYNCCLIENT_H_ + +// End of File diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/clients/syncclient/rom/sconsyncclient.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/clients/syncclient/rom/sconsyncclient.iby Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,25 @@ +/* +* 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: IBY file for SconSyncClient +* +*/ + +#ifndef _SCONSYNCCLIENT_IBY_ +#define _SCONSYNCCLIENT_IBY_ + +#include + +file=ABI_DIR\BUILD_DIR\sconsyncclient.dll SHARED_LIB_DIR\sconsyncclient.dll + +#endif \ No newline at end of file diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/clients/syncclient/src/scondataproviderinfo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/clients/syncclient/src/scondataproviderinfo.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,220 @@ +/* +* 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: CSconDataproviderInfo implementation +* +*/ + + +#include "scondataproviderinfo.h" +#include +#include +#include // for CnvUtfConverter +#include "debug.h" + +CSconDataproviderInfo::CSconDataproviderInfo() + { + } + +EXPORT_C CSconDataproviderInfo::~CSconDataproviderInfo() + { + delete iName; + delete iDefaultStore; + delete iStores; + } + +EXPORT_C CSconDataproviderInfo* CSconDataproviderInfo::NewL() + { + return new (ELeave) CSconDataproviderInfo(); + } + +EXPORT_C void CSconDataproviderInfo::ExternalizeL( RWriteStream& aStream ) const + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("iUid: 0x%x", iUid); + aStream.WriteInt32L( iUid ); + if ( iName ) + { + HBufC8* temp = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iName->Des() ); + CleanupStack::PushL( temp ); + TPtrC8 tempPtr = temp->Des(); + aStream.WriteUint16L( tempPtr.Length() ); + aStream.WriteL( tempPtr ); + CleanupStack::PopAndDestroy( temp ); + } + else + { + aStream.WriteUint16L( 0 ); + } + + if ( iDefaultStore ) + { + HBufC8* temp = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iDefaultStore->Des() ); + CleanupStack::PushL( temp ); + TPtrC8 tempPtr = temp->Des(); + aStream.WriteUint16L( tempPtr.Length() ); + aStream.WriteL( tempPtr ); + CleanupStack::PopAndDestroy( temp ); + } + else + { + aStream.WriteUint16L( 0 ); + } + if ( iStores ) + { + aStream.WriteUint16L( iStores->Count() ); + for ( TInt i=0; iCount(); i++ ) + { + TPtrC storePtr = (*iStores)[i]; + HBufC8* temp = CnvUtfConverter::ConvertFromUnicodeToUtf8L( storePtr ); + CleanupStack::PushL( temp ); + TPtrC8 tempPtr = temp->Des(); + aStream.WriteUint16L( tempPtr.Length() ); + if ( tempPtr.Length() > 0 ) + { + aStream.WriteL( tempPtr ); + } + CleanupStack::PopAndDestroy( temp ); + } + } + else + { + aStream.WriteUint16L( 0 ); + } + aStream.CommitL(); + TRACE_FUNC_EXIT; + } + +EXPORT_C void CSconDataproviderInfo::InternalizeL( RReadStream& aStream ) + { + TRACE_FUNC_ENTRY; + delete iName; + iName = NULL; + delete iDefaultStore; + iDefaultStore = NULL; + delete iStores; + iStores = NULL; + iStores = new ( ELeave ) CDesCArrayFlat( 1 ); + iUid = aStream.ReadInt32L(); + TInt len = aStream.ReadUint16L(); + if ( len > 0 ) + { + HBufC8* tempBuf = HBufC8::NewLC( len ); + TPtr8 tempPtr = tempBuf->Des(); + aStream.ReadL( tempPtr, len ); + + iName = CnvUtfConverter::ConvertToUnicodeFromUtf8L( tempPtr ); + CleanupStack::PopAndDestroy( tempBuf ); + } + + len = aStream.ReadUint16L(); + if ( len > 0 ) + { + HBufC8* tempBuf = HBufC8::NewLC( len ); + TPtr8 tempPtr = tempBuf->Des(); + aStream.ReadL( tempPtr, len ); + + iDefaultStore = CnvUtfConverter::ConvertToUnicodeFromUtf8L( tempPtr ); + CleanupStack::PopAndDestroy( tempBuf ); + } + + TInt storeCount = aStream.ReadUint16L(); + for (TInt i=0; i 0 ) + { + HBufC8* tempBuf8 = HBufC8::NewLC( len ); + TPtr8 tempPtr8 = tempBuf8->Des(); + aStream.ReadL( tempPtr8, len ); + + HBufC* temp = CnvUtfConverter::ConvertToUnicodeFromUtf8L( tempPtr8 ); + CleanupStack::PushL( temp ); + TPtr tempPtr = temp->Des(); + iStores->AppendL( tempPtr ); + CleanupStack::PopAndDestroy( temp ); + CleanupStack::PopAndDestroy( tempBuf8 ); + } + } + TRACE_FUNC_EXIT; + } + +EXPORT_C TUid CSconDataproviderInfo::ImplementationUid() const + { + return TUid::Uid( iUid ); + } + +EXPORT_C void CSconDataproviderInfo::SetImplementationUid( const TUid aUid ) + { + iUid = aUid.iUid; + } + +EXPORT_C TDesC& CSconDataproviderInfo::DisplayNameL() + { + if ( iName ) + { + return *iName; + } + else + { + iName = KNullDesC().AllocL(); + return *iName; + } + } + +EXPORT_C void CSconDataproviderInfo::SetDisplayNameL( const TDesC& aName ) + { + delete iName; + iName = NULL; + iName = aName.AllocL(); + } + +EXPORT_C TDesC& CSconDataproviderInfo::DefaultStoreL() + { + if ( iDefaultStore ) + { + return *iDefaultStore; + } + else + { + iDefaultStore = KNullDesC().AllocL(); + return *iDefaultStore; + } + } + +EXPORT_C void CSconDataproviderInfo::SetDefaultStoreL( const TDesC& aStore ) + { + delete iDefaultStore; + iDefaultStore = NULL; + iDefaultStore = aStore.AllocL(); + } + +EXPORT_C CDesCArray* CSconDataproviderInfo::ListStoresL() const + { + if ( !iStores ) + { + User::Leave( KErrNotFound ); + } + return iStores; + } + +EXPORT_C void CSconDataproviderInfo::SetStoresL( const CDesCArray& aStores ) + { + delete iStores; + iStores = NULL; + iStores = new ( ELeave ) CDesCArrayFlat( 1 ); + for ( TInt i=0; iAppendL( aStores[i] ); + } + } diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/clients/syncclient/src/sconsyncclient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/clients/syncclient/src/sconsyncclient.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,668 @@ +/* +* 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: RSconSyncSession implementation +* +*/ + + +#include "sconsyncclient.h" + +#include +#include + +#include "sconsyncclientserver.h" +#include "debug.h" + +const TInt KSConSyncChunkSize = 0xFFFF; // 65535 bytes; +const TInt KSConSyncChunkMaxSize = 0x400000; // 4194304 bytes + +EXPORT_C RSconSyncSession::RSconSyncSession() + { + TRACE_FUNC; + } + +EXPORT_C RSconSyncSession::~RSconSyncSession() + { + TRACE_FUNC; + } + +EXPORT_C TInt RSconSyncSession::Connect() + { + TRACE_FUNC_ENTRY; + TInt retryCount = 2; + TInt error = KErrNone; + while(retryCount) + { + error = CreateSession(KSconSyncServerName, TVersion(1,0,0)); + if ( error != KErrNotFound && error != KErrServerTerminated ) + { + break; + } + error = StartServer(); + if( error != KErrNone && error != KErrAlreadyExists ) + { + break; + } + --retryCount; + } + + if ( error == KErrNone ) + { + error = CreateAndSendChunkHandle(); + if ( error != KErrNone ) + { + LOGGER_WRITE("CreateAndSendChunkHandle failed, close session"); + Close(); + } + } + TRACE_FUNC_EXIT; + return error; + } + +// ----------------------------------------------------------------------------- +// RSconSyncSession::Close() +// Closes the server connection +// ----------------------------------------------------------------------------- +// +EXPORT_C void RSconSyncSession::Close() + { + TRACE_FUNC_ENTRY; + iChunk.Close(); + RSessionBase::Close(); + TRACE_FUNC_EXIT + } + +EXPORT_C void RSconSyncSession::ListAllImplementationsL( RSconDataProviderInfoArray& aInfoArray ) + { + TRACE_FUNC_ENTRY; + TIpcArgs args; + TInt ret = SendReceive ( EListImplementations, args ); + + if ( ret != KErrNone) + { + LOGGER_WRITE_1( "RSconSyncSession::ListAllImplementationsL() :\ + Send Receive failed with code %d", ret ); + User::Leave( ret ); + }; + + // copy data from the chunk + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + + TInt count( readStream.ReadUint16L() ); + LOGGER_WRITE_1("count: %d", count); + for ( TInt i=0; iInternalizeL( readStream ); + aInfoArray.AppendL( dpInfo ); + CleanupStack::Pop( dpInfo ); + } + + CleanupStack::PopAndDestroy( &readStream ); + + TRACE_FUNC_EXIT; + } + +EXPORT_C void RSconSyncSession::OpenDataStoreL( const TSmlDataProviderId aProviderId, const TDesC& aStoreName, TInt aContextId ) + { + TRACE_FUNC_ENTRY; + User::LeaveIfError( iChunk.Adjust( + sizeof(TInt32) + + sizeof(TInt32) + + aStoreName.Size() + + sizeof(TInt) )); + + RMemWriteStream writeBuf( iChunk.Base(), iChunk.Size() ); + writeBuf.WriteInt32L( aProviderId ); + + writeBuf.WriteInt32L( aStoreName.Length() ); + writeBuf.WriteL( aStoreName ); + + writeBuf.WriteInt32L( aContextId ); + + writeBuf.CommitL(); + writeBuf.Close(); + + TIpcArgs args; + TInt ret = SendReceive ( EOpenStore, args ); + + if ( ret != KErrNone) + { + LOGGER_WRITE_1( "RSconSyncSession::OpenDataStoreL() :\ + Send Receive failed with code %d", ret ); + User::Leave( ret ); + }; + TRACE_FUNC_EXIT; + } + +EXPORT_C void RSconSyncSession::OpenItemL( TSmlDbItemUid aUid, TBool& aFieldChange, + TSmlDbItemUid& aParent, TDes8& aMimeType, TDes8& aMimeVer, CBufFlat& aItemData ) + { + TRACE_FUNC_ENTRY; + TIpcArgs args( aUid ); + TInt ret = SendReceive ( EOpenItem, args ); + if ( ret != KErrNone) + { + LOGGER_WRITE_1( "RSconSyncSession::OpenItemL() :\ + Send Receive failed with code %d", ret ); + User::Leave( ret ); + }; + + // copy data from the chunk + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + TInt32 length ( 0 ); + + aItemData.Reset(); + length = readStream.ReadInt32L(); + + HBufC8* data = HBufC8::NewLC( length ); + TPtr8 dataPtr = data->Des(); + + readStream.ReadL( dataPtr, length ); + aItemData.ExpandL( 0, length ); + aItemData.Write ( 0, dataPtr ); + + CleanupStack::PopAndDestroy( data ); + + aFieldChange = readStream.ReadInt8L(); + + aParent = readStream.ReadInt32L(); + length = readStream.ReadInt32L(); + readStream.ReadL( aMimeType, length ); + + length = readStream.ReadInt32L(); + readStream.ReadL( aMimeVer, length ); + + CleanupStack::PopAndDestroy( &readStream ); + TRACE_FUNC_EXIT; + } + +EXPORT_C void RSconSyncSession::CreateItemL(TSmlDbItemUid& aUid/*, TInt aSize*/, + TSmlDbItemUid aParent, const TDesC8& aMimeType, const TDesC8& aMimeVer, + const TDesC8& aData) + { + TRACE_FUNC_ENTRY; + User::LeaveIfError( iChunk.Adjust( + sizeof(TInt32) + + sizeof(TInt32) + + aMimeType.Length() + + sizeof(TInt32) + + aMimeVer.Length() + + sizeof(TInt32) + + aData.Length() )); + RMemWriteStream writeBuf( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( writeBuf ); + writeBuf.WriteInt32L( aParent ); + writeBuf.WriteInt32L( aMimeType.Length() ); + writeBuf.WriteL( aMimeType ); + writeBuf.WriteInt32L( aMimeVer.Length() ); + writeBuf.WriteL( aMimeVer ); + writeBuf.WriteInt32L( aData.Length() ); + writeBuf.WriteL( aData ); + + writeBuf.CommitL(); + CleanupStack::PopAndDestroy( &writeBuf ); + + + + TPckg pckg(aUid); + iArgs = TIpcArgs( &pckg ); + + TInt ret = SendReceive ( ECreateItem, iArgs ); + if ( ret != KErrNone) + { + LOGGER_WRITE_1( "RSconSyncSession::CreateItemL() :\ + Send Receive failed with code %d", ret ); + User::Leave( ret ); + }; + LOGGER_WRITE_1("aUid: %d", aUid); + TRACE_FUNC_EXIT; + } + +EXPORT_C void RSconSyncSession::CreateItemL(TPckg& aUidPckg, + TSmlDbItemUid aParent, const TDesC8& aMimeType, const TDesC8& aMimeVer, + const TDesC8& aData, TRequestStatus& aStatus) + { + TRACE_FUNC_ENTRY; + User::LeaveIfError( iChunk.Adjust( + sizeof(TInt32) + + sizeof(TInt32) + + aMimeType.Length() + + sizeof(TInt32) + + aMimeVer.Length() + + sizeof(TInt32) + + aData.Length() )); + RMemWriteStream writeBuf( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( writeBuf ); + writeBuf.WriteInt32L( aParent ); + writeBuf.WriteInt32L( aMimeType.Length() ); + writeBuf.WriteL( aMimeType ); + writeBuf.WriteInt32L( aMimeVer.Length() ); + writeBuf.WriteL( aMimeVer ); + writeBuf.WriteInt32L( aData.Length() ); + writeBuf.WriteL( aData ); + + writeBuf.CommitL(); + CleanupStack::PopAndDestroy( &writeBuf ); + + iArgs = TIpcArgs( &aUidPckg ); + SendReceive( ECreateItem, iArgs, aStatus ); + + TRACE_FUNC_EXIT; + } + +EXPORT_C void RSconSyncSession::ReplaceItemL(TSmlDbItemUid aUid, + TSmlDbItemUid aParent, TBool aFieldChange, const TDesC8& aData) + { + TRACE_FUNC_ENTRY; + User::LeaveIfError( iChunk.Adjust( + sizeof(TInt32) + + sizeof(TInt32) + + sizeof(TInt8) + + sizeof(TInt32) + + aData.Length() )); + RMemWriteStream writeBuf( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( writeBuf ); + writeBuf.WriteInt32L( aUid ); + writeBuf.WriteInt32L( aParent ); + writeBuf.WriteInt8L( aFieldChange ); + writeBuf.WriteInt32L( aData.Length() ); + writeBuf.WriteL( aData ); + writeBuf.CommitL(); + CleanupStack::PopAndDestroy( &writeBuf ); + + TIpcArgs args; + TInt ret = SendReceive( EReplaceItem, args ); + if ( ret != KErrNone) + { + LOGGER_WRITE_1( "RSconSyncSession::ReplaceItemL() :\ + Send Receive failed with code %d", ret ); + User::Leave( ret ); + }; + TRACE_FUNC_EXIT; + } + +EXPORT_C void RSconSyncSession::ReplaceItemL(TSmlDbItemUid aUid, + TSmlDbItemUid aParent, TBool aFieldChange, const TDesC8& aData, + TRequestStatus& aStatus) + { + TRACE_FUNC_ENTRY; + User::LeaveIfError( iChunk.Adjust( + sizeof(TInt32) + + sizeof(TInt32) + + sizeof(TInt8) + + sizeof(TInt32) + + aData.Length() )); + RMemWriteStream writeBuf( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( writeBuf ); + writeBuf.WriteInt32L( aUid ); + writeBuf.WriteInt32L( aParent ); + writeBuf.WriteInt8L( aFieldChange ); + writeBuf.WriteInt32L( aData.Length() ); + writeBuf.WriteL( aData ); + writeBuf.CommitL(); + CleanupStack::PopAndDestroy( &writeBuf ); + + TIpcArgs args; + SendReceive( EReplaceItem, args, aStatus ); + TRACE_FUNC_EXIT; + } + +EXPORT_C void RSconSyncSession::MoveItemL( TSmlDbItemUid aUid, TSmlDbItemUid aNewParent ) + { + TRACE_FUNC_ENTRY; + + TIpcArgs args(aUid, aNewParent); + TInt ret = SendReceive ( EMoveItem, args ); + if ( ret != KErrNone) + { + LOGGER_WRITE_1( "RSconSyncSession::MoveItemL() :\ + Send Receive failed with code %d", ret ); + User::Leave( ret ); + }; + TRACE_FUNC_EXIT; + } + +EXPORT_C void RSconSyncSession::DeleteItemL( TSmlDbItemUid aUid ) + { + TRACE_FUNC_ENTRY; + + TIpcArgs args( aUid ); + TInt ret = SendReceive ( EDeleteItem, args ); + if ( ret != KErrNone) + { + LOGGER_WRITE_1( "RSconSyncSession::DeleteItemL() :\ + Send Receive failed with code %d", ret ); + User::Leave( ret ); + }; + TRACE_FUNC_EXIT; + } + + +EXPORT_C void RSconSyncSession::SoftDeleteItemL( TSmlDbItemUid aUid ) + { + TRACE_FUNC_ENTRY; + + TIpcArgs args( aUid ); + TInt ret = SendReceive ( ESoftDeleteItem, args ); + if ( ret != KErrNone) + { + LOGGER_WRITE_1( "RSconSyncSession::SoftDeleteItemL() :\ + Send Receive failed with code %d", ret ); + User::Leave( ret ); + }; + TRACE_FUNC_EXIT; + } + +EXPORT_C void RSconSyncSession::DeleteAllItems( TRequestStatus& aStatus ) + { + TRACE_FUNC_ENTRY; + TIpcArgs args; + SendReceive( EDeleteAllItems, args, aStatus ); + TRACE_FUNC_EXIT; + } + + +EXPORT_C TBool RSconSyncSession::HasSyncHistoryL() const + { + TRACE_FUNC; + TBool history(EFalse); + TPckg pck(history); + TIpcArgs args(&pck); + TInt ret = SendReceive ( EHasHistory, args ); + User::LeaveIfError( ret ); + TRACE_FUNC_EXIT; + return history; + } + +EXPORT_C void RSconSyncSession::AddedItemsL( RArray& aItems) const + { + TRACE_FUNC_ENTRY; + TIpcArgs args; + TInt ret = SendReceive ( EAddedItems, args ); + User::LeaveIfError( ret ); + + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + + aItems.Reset(); + TInt itemCount = readStream.ReadInt32L(); + for (TInt i=0; i& aItems) const + { + TRACE_FUNC_ENTRY; + TIpcArgs args; + TInt ret = SendReceive ( EDeletedItems, args ); + User::LeaveIfError( ret ); + + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + + aItems.Reset(); + TInt itemCount = readStream.ReadInt32L(); + for (TInt i=0; i& aItems) const + { + TRACE_FUNC_ENTRY; + TIpcArgs args; + TInt ret = SendReceive ( ESoftDeletedItems, args ); + User::LeaveIfError( ret ); + + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + + aItems.Reset(); + TInt itemCount = readStream.ReadInt32L(); + for (TInt i=0; i& aItems) const + { + TRACE_FUNC_ENTRY; + TIpcArgs args; + TInt ret = SendReceive ( EModifiedItems, args ); + User::LeaveIfError( ret ); + + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + + aItems.Reset(); + TInt itemCount = readStream.ReadInt32L(); + for (TInt i=0; i& aItems) const + { + TRACE_FUNC_ENTRY; + TIpcArgs args; + TInt ret = SendReceive ( EMovedItems, args ); + User::LeaveIfError( ret ); + + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + + aItems.Reset(); + TInt itemCount = readStream.ReadInt32L(); + for (TInt i=0; i& aItems ) + { + TRACE_FUNC_ENTRY; + RMemWriteStream stream ( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( stream ); + LOGGER_WRITE_1("items count: %d", aItems.Count()); + stream.WriteInt32L( aItems.Count() ); + for (TInt i=0; i < aItems.Count(); i++ ) + { + LOGGER_WRITE("Write item"); + stream.WriteInt32L( aItems[i] ); + } + stream.CommitL(); + CleanupStack::PopAndDestroy( &stream ); + + TIpcArgs args; + TInt ret = SendReceive ( ECommitChangeInfo, args ); + User::LeaveIfError( ret ); + TRACE_FUNC_EXIT; + } + +EXPORT_C void RSconSyncSession::GetSyncTimeStampL( const TSmlDataProviderId aProviderId, const TInt aContextId, TDateTime& aTimeStamp ) const + { + TRACE_FUNC_ENTRY; + + TPckg timeBuf( aTimeStamp ); + TIpcArgs args( aProviderId, aContextId, &timeBuf ); + TInt ret = SendReceive ( EGetSyncTimeStamp, args ); + User::LeaveIfError( ret ); + + TRACE_FUNC_EXIT; + } + +EXPORT_C CSmlDataStoreFormat* RSconSyncSession::StoreFormatL( const RStringPool& aStringPool ) + { + TRACE_FUNC_ENTRY; + TIpcArgs args; + TInt ret = SendReceive ( EExportStoreFormat, args ); + User::LeaveIfError( ret ); + + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + TInt len = readStream.ReadInt32L(); + LOGGER_WRITE_1("data size from server: %d", len); + LOGGER_WRITE("CSmlDataStoreFormat::NewLC"); + CSmlDataStoreFormat* tempStoreFormat = CSmlDataStoreFormat::NewLC( aStringPool, readStream ); + LOGGER_WRITE("CSmlDataStoreFormat::NewLC -ok"); + CleanupStack::Pop( tempStoreFormat ); + + LOGGER_WRITE("PopAndDestroy( &readStream )"); + CleanupStack::PopAndDestroy( &readStream ); + LOGGER_WRITE("return"); + TRACE_FUNC_EXIT; + return tempStoreFormat; + } + +EXPORT_C void RSconSyncSession::SetRemoteStoreFormatL( const CSmlDataStoreFormat& aServerDataStoreFormat ) + { + TRACE_FUNC_ENTRY; + const TInt KMaximumDataStoreFormatSize = 100000; // 100kb should be enought + User::LeaveIfError( iChunk.Adjust( KMaximumDataStoreFormatSize )); + + RMemWriteStream stream ( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( stream ); + + aServerDataStoreFormat.ExternalizeL( stream ); + + stream.CommitL(); + CleanupStack::PopAndDestroy( &stream ); + + TIpcArgs args; + TInt ret = SendReceive ( ESetRemoteStoreFormat, args ); + User::LeaveIfError( ret ); + TRACE_FUNC_EXIT; + } + +EXPORT_C void RSconSyncSession::CancelRequest() + { + TRACE_FUNC_ENTRY; + SendReceive( ECancelRequest, TIpcArgs() ); + TRACE_FUNC_EXIT; + } + +EXPORT_C TInt RSconSyncSession::GetParent( TSmlDbItemUid aUid, TSmlDbItemUid& aParent ) + { + TRACE_FUNC_ENTRY; + TPckg pckg(aParent); + TIpcArgs args( aUid, &pckg ); + TInt ret = SendReceive( EReadParent, args ); + TRACE_FUNC_EXIT; + return ret; + } + +TInt RSconSyncSession::StartServer() + { + TRACE_FUNC_ENTRY; + + RProcess server; + TInt error = server.Create(KSconSyncServerExe, KNullDesC); + if ( error != KErrNone ) + { + return error; + } + // start server and wait for signal before proceeding + TRequestStatus status; + server.Rendezvous(status); + if ( status.Int() != KRequestPending ) + { + server.Kill(0); + } + else + { + server.Resume(); + } + + User::WaitForRequest( status ); + error = server.ExitType() == EExitPanic ? KErrGeneral : status.Int(); + server.Close(); + TRACE_FUNC_EXIT; + return error; + } + +// ----------------------------------------------------------------------------- +// RSconSyncSession::CreateAndSendChunkHandle() +// Creates a chunk and sends a handle to server +// ----------------------------------------------------------------------------- +// +TInt RSconSyncSession::CreateAndSendChunkHandle() + { + TRACE_FUNC_ENTRY; + + TInt err = iChunk.CreateGlobal( KNullDesC, + KSConSyncChunkSize, + KSConSyncChunkMaxSize ); + if ( err != KErrNone ) + { + LOGGER_WRITE_1("iChunk.CreateGlobal failed, err: %d", err); + return err; + } + TIpcArgs args; + args.Set( 0, iChunk ); + err = SendReceive( ESendChunkHandle, args ); + + LOGGER_WRITE_1("RSconSyncSession::CreateAndSendChunkHandle : returned: %d", err); + return err; + } + +// End of File diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/common/conmltask/inc/sconconmltask.h --- a/connectivitymodules/SeCon/common/conmltask/inc/sconconmltask.h Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/common/conmltask/inc/sconconmltask.h Thu Aug 19 10:44:03 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-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" @@ -212,7 +212,7 @@ { public: CSConInstApp() {}; - ~CSConInstApp() {}; + ~CSConInstApp(); CSConInstApp* CopyL(); TFileName iName; @@ -222,6 +222,7 @@ TInt64 iSize; TSConAppType iType; TUid iUid; + HBufC* iWidgetBundleId; // Widget bundle identifier like "com.nokia.widget.HelloWorld" }; //============================================================ diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/common/conmltask/src/sconconmltask.cpp --- a/connectivitymodules/SeCon/common/conmltask/src/sconconmltask.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/common/conmltask/src/sconconmltask.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-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" @@ -161,6 +161,10 @@ return copy; } +CSConInstApp::~CSConInstApp() + { + delete iWidgetBundleId; + } // ----------------------------------------------------------------------------- // CSConInstApp::Copy() // @@ -177,6 +181,14 @@ copy->iSize = iSize; copy->iType = iType; copy->iUid = iUid; + if ( iWidgetBundleId ) + { + copy->iWidgetBundleId = iWidgetBundleId->AllocL(); + } + else + { + copy->iWidgetBundleId = NULL; + } return copy; } diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/group/bld.inf --- a/connectivitymodules/SeCon/group/bld.inf Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/group/bld.inf Thu Aug 19 10:44:03 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2002-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" @@ -22,9 +22,14 @@ #include "../services/csc/bld/bld.inf" #include "../services/ftp/bld/bld.inf" #include "../services/pcd/bld/bld.inf" + #include "../wbxml/conmlhandler/bld/bld.inf" #include "../servers/pcconn/bld/bld.inf" +#include "../servers/syncserver/group/bld.inf" + #include "../clients/pcconn/bld/bld.inf" +#include "../clients/syncclient/group/bld.inf" + #include "../plugins/pcconn/bld/bld.inf" #include "../plugins/ftp/bld/bld.inf" #include "../plugins/hapticsconnplugin/group/bld.inf" diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/group/stubs/secon_stub.SIS Binary file connectivitymodules/SeCon/group/stubs/secon_stub.SIS has changed diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/group/stubs/secon_stub.pkg --- a/connectivitymodules/SeCon/group/stubs/secon_stub.pkg Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/group/stubs/secon_stub.pkg Thu Aug 19 10:44:03 2010 +0300 @@ -1,5 +1,5 @@ ; -; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; 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" @@ -17,7 +17,7 @@ &EN ; Header -#{"Service Controllers"},(0x101F99F6),1,0,0, TYPE=SA +#{"Service Controllers"},(0x101F99F6),1,72,0, TYPE=SA ; Localised Vendor name %{"Nokia"} diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/pcconn/bld/sconpcconnserver.mmp --- a/connectivitymodules/SeCon/servers/pcconn/bld/sconpcconnserver.mmp Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/servers/pcconn/bld/sconpcconnserver.mmp Thu Aug 19 10:44:03 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-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" @@ -27,14 +27,17 @@ TARGET sconpcconnserver.exe TARGETTYPE exe -EPOCSTACKSIZE 49152 -EPOCHEAPSIZE 0x10000 0x800000 +EPOCSTACKSIZE 0x10000 +EPOCHEAPSIZE 0x10000 0x1000000 // heap memory 16MB UID 0 0x101F99F6 // Server SOURCEPATH ../src SOURCE sconpcconnserver.cpp +SOURCE sconimsireader.cpp +SOURCE sconfolderlister.cpp +SOURCE sconbtengine.cpp // ConML SOURCEPATH ../../../wbxml/conmlhandler/src @@ -49,6 +52,7 @@ USERINCLUDE ../../../common/conmltask/inc USERINCLUDE ../../../services/pcd/inc USERINCLUDE ../../../services/csc/inc +USERINCLUDE ../../../services/oviaccounthandler/inc USERINCLUDE ../../../wbxml/conmlhandler/inc // Default system include paths for middleware layer modules. @@ -58,4 +62,16 @@ LIBRARY estor.lib // RMemWriteStream, RMemReadStream LIBRARY efsrv.lib // Rfs, RFile LIBRARY charconv.lib // For Unicode conversion +LIBRARY etel3rdparty.lib +LIBRARY platformenv.lib // For pathinfo +LIBRARY directorylocalizer.lib // For localizing directories +LIBRARY centralrepository.lib +LIBRARY commonengine.lib // For resource reader +LIBRARY bafl.lib // Basic Application Framework Library +LIBRARY btengdevman.lib +LIBRARY btmanclient.lib +LIBRARY btdevice.lib +LIBRARY bluetooth.lib +LIBRARY btengsettings.lib DEBUGLIBRARY flogger.lib + diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/pcconn/inc/sconbtengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/pcconn/inc/sconbtengine.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSconBtEngine declaration +* +*/ + + + +#ifndef SCONBTENGINE_H_ +#define SCONBTENGINE_H_ + +#include +#include +#include +#include +#include + +const TInt KCenRepAddrBufSize = 2 * KBTDevAddrSize; + +class CSconBtEngine : public CBase, + public MBTEngDevManObserver, + public MBTEngSettingsObserver + { +public: + static CSconBtEngine* NewL(); + ~CSconBtEngine(); + + void ReadBTInfoL( RBufWriteStream& aStream ); + + void SetBtAuthorizedL( const TDesC& aBtDevAddress, TBool aAuthorized ); + + TInt SetBtPowerState( TBool aPower ); + + TInt SetBtName( const TDesC& aBtName ); + +protected: + // From MBTEngDevManObserver + void HandleDevManComplete( TInt aErr ); + void HandleGetDevicesComplete( TInt aErr, + CBTDeviceArray* aDeviceArray ); + + // From MBTEngSettingsObserver + void PowerStateChanged( TBTPowerStateValue aState ); + void VisibilityModeChanged( TBTVisibilityMode aState ); + +private: + CSconBtEngine(); + void ConstructL(); + + void PrintDevicesL(); + +private: + enum TState + { + EIdle, + ERequestBtInfo, + EChangeBtState, + EChangeAuthorized + }; + TState iState; + TInt iOperationError; + CActiveSchedulerWait iWait; + RBufWriteStream* iStream; + CBTEngDevMan* iBtEng; + CBTDeviceArray* iBtDevArray; + CBTEngSettings* iBtSettings; + TBool iAuthorizedValue; + TBuf iBtAddress; + }; + +#endif /* SCONBTENGINE_H_ */ diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/pcconn/inc/sconfolderlister.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/pcconn/inc/sconfolderlister.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,136 @@ +/* +* 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: CSconFolderLister declaration +* +*/ + + +#ifndef CSCONFOLDERLISTER_H +#define CSCONFOLDERLISTER_H + +// INCLUDES +#include +#include +#include // For RMemReadStream +#include +// CLASS DECLARATION + +class TSconDriveInfoEntry + { +public: + TUint8 iDriveType; + TUint8 iDriveTypeCount; + TInt64 iSize; + TInt64 iFree; + }; + +class TSconDriveInfo : public TSconDriveInfoEntry + { +public: + TUint iDriveStatus; + TBuf16<2> iDriveLetter; + TUint iDriveAttr; + TBufC iVolumeName; + }; + + +class CSconFolderEntry : public CBase + { +public: + static CSconFolderEntry* NewLC(); + static CSconFolderEntry* NewLC( const TEntry& aEntry ); + ~CSconFolderEntry(); +private: + CSconFolderEntry(); + void ConstructL( const TEntry& aEntry ); + +public: + TUint iAtt; + TTime iModified; + HBufC *iName; + HBufC *iLabel; + TBool iDriveInfoEntryExists; + TSconDriveInfoEntry iDriveInfoEntry; + }; + + +class CDirectoryLocalizer; + +/** + * CSconFolderLister + * + */ +class CSconFolderLister : public CBase + { +public: + // Constructors and destructor + + /** + * Destructor. + */ + ~CSconFolderLister(); + + /** + * Two-phased constructor. + */ + static CSconFolderLister* NewL( RFs& aFs ); + + /** + * + * @param aStream + * @param aStartPath + * @param aLevelsToSearch -1 = Search all levels, 0 = Search only current level, 1..N Search N levels + */ + void GenerateFolderListL( RBufWriteStream& aStream, const TDesC& aStartPath, const TInt aLevelsToSearch ); + +private: + + void ListAllDrivesL( RBufWriteStream& aStream, const TInt aLevelsToSearch ); + void ListDriveAndPathL( RBufWriteStream& aStream, TInt aDrive, const TDesC& aStartPath, const TInt aLevelsToSearch ); + + void ExportDriveL( RBufWriteStream& aStream, const TSconDriveInfo& aDriveInfo, + const TDesC& aPathName, const TInt aLevelsToSearch ); + + /** + * + * @param aStream + * @param aPathName + */ + void ExportPathL( RBufWriteStream& aStream, const TDesC& aPathName, + const CSconFolderEntry& aEntry, const TBool aLocalize, const TInt aLevelsToSearch ); + + void GetDriveTypeNumberL( TInt aDrive , TUint driveStatus, TInt& aTypeNumber); + + /** + * Constructor for performing 1st stage construction + */ + CSconFolderLister( RFs& aFs ); + + /** + * EPOC default constructor for performing 2nd stage construction + */ + void ConstructL(); + + TBool IsDirectoryPrintable( const TDesC& aParentPath, const TEntry& aFolderEntry ); + + void GetLocalizedVolumeNameL( CSconFolderEntry& aDriveEntry ); +private: + RFs& iFs; + TInt iFolders; + TInt iFiles; + TInt iCriticalLevel; + CDirectoryLocalizer* iLocalizer; + }; + +#endif // CSCONFOLDERLISTER_H diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/pcconn/inc/sconimsireader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/pcconn/inc/sconimsireader.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2009-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: Imsi reader +* +*/ + + +#ifndef __SCONIMSIREADER_H__ +#define __SCONIMSIREADER_H__ + +#include +#include + +enum TImsiReaderStatus + { + EIdle, + ERequestingImsi, + ERequestingNetworkStatus + }; + +class CSconImsiReader : public CActive + { + public: + + static TInt GetImsiL( TDes& aImsi ); + + static TInt GetNetworkStatusL( CTelephony::TRegistrationStatus& aRegistrationStatus ); + + private: + CSconImsiReader( TDes& aImsi, CTelephony::TRegistrationStatus& aRegistrationStatus ); + void ConstructL(); + ~CSconImsiReader(); + + void RequestImsi(); + void RequestNetworkStatus(); + + private: // From CActive + + void RunL(); + void DoCancel(); + + private: // data + TDes& iImsi; + CTelephony::TRegistrationStatus& iNetworkStatus; + CTelephony* iTelephony; + CTelephony::TSubscriberIdV1 iSubscriberIdV1; + CTelephony::TSubscriberIdV1Pckg iSubscriberIdV1Pckg; + + CTelephony::TNetworkRegistrationV1 iNetworkRegistrationV1; + CTelephony::TNetworkRegistrationV1Pckg iNetworkRegistrationV1Pckg; + TImsiReaderStatus iImsiReaderStatus; + }; + +#endif // __SCONIMSIREADER_H__ diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/pcconn/inc/sconpcconnserver.h --- a/connectivitymodules/SeCon/servers/pcconn/inc/sconpcconnserver.h Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/servers/pcconn/inc/sconpcconnserver.h Thu Aug 19 10:44:03 2010 +0300 @@ -127,6 +127,10 @@ }; + +class CSconFolderLister; +class CSconBtEngine; + //********************************** //CSConPCConnSession - Server session class, handles the requested operations //********************************** @@ -216,7 +220,9 @@ TDesC8& HashToDesLC( const TDesC& aBuf ); TPtr DesToHashLC( const TDesC8& aDes ); TBool IsJavaHash( const TDesC8& aDes ); - + + TInt ReadOviAccountInfoL( RWriteStream& aAccountInfoStream ); + // data private: CSConPCConnServer& iServer; @@ -232,6 +238,10 @@ RChunk iChunk; CBufFlat* iBuffer; TInt iResult; + + CSconFolderLister* iFolderLister; + RFs iFs; + CSconBtEngine* iBtEngine; }; #endif // __SCONPCCONNSERVER_H__ diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/pcconn/src/sconbtengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/pcconn/src/sconbtengine.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,415 @@ +/* +* 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: CSconBtEngine implementation +* +*/ + + + +#include +#include + +#include +#include +#include + +#include "sconbtengine.h" +#include "debug.h" + +CSconBtEngine* CSconBtEngine::NewL() + { + TRACE_FUNC; + CSconBtEngine* self = new (ELeave) CSconBtEngine(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +CSconBtEngine::~CSconBtEngine() + { + TRACE_FUNC; + if ( iBtEng ) + { + iBtEng->Cancel(); + delete iBtEng; + } + + delete iBtSettings; + } + +CSconBtEngine::CSconBtEngine() + { + } + +void CSconBtEngine::ConstructL() + { + iBtEng = CBTEngDevMan::NewL( this ); + iBtSettings = CBTEngSettings::NewL( this ); + iState = EIdle; + } + +void CSconBtEngine::ReadBTInfoL( RBufWriteStream& aStream ) + { + TRACE_FUNC_ENTRY; + if ( iState != EIdle ) + { + User::Leave( KErrInUse ); + } + iStream = &aStream; + iOperationError = KErrNone; + + // Write local name (8 bit name length + unicode name) + TBuf<100> localName; + TInt err = iBtSettings->GetLocalName( localName ); + User::LeaveIfError( err ); + LOGGER_WRITE_1("localName: %S", &localName); + iStream->WriteUint8L( localName.Length() ); + iStream->WriteL( localName, localName.Length() ); + + if ( iBtAddress.Length() == 0 ) + { + LOGGER_WRITE("Try to read bt address"); + + CRepository* cenRep = NULL; + // Use TRAP to catch a leave if the CenRep key does not exist. + TRAP( err, cenRep = CRepository::NewL( KCRUidBluetoothLocalDeviceAddress ) ); + CleanupStack::PushL( cenRep ); + if( !err ) + { + err = cenRep->Get( KBTLocalDeviceAddress, iBtAddress ); + LOGGER_WRITE_1("cenRep->Get err: %d", err); + } + CleanupStack::PopAndDestroy( cenRep ); + + if ( err ) + { + iBtAddress.Zero(); + } + } + + // Write bt address (8 bit addr length + unicode address) + if ( iBtAddress.Length() > 0 ) + { + LOGGER_WRITE_1("btAddr: %S", &iBtAddress); + iStream->WriteUint8L( iBtAddress.Length() ); + iStream->WriteL( iBtAddress, iBtAddress.Length() ); + } + else + { + iStream->WriteUint8L( 0 ); + } + + // Write BT Power State (8-bit, 0=Off, 1=On) + TBTPowerStateValue state; + err = iBtSettings->GetPowerState( state ); + User::LeaveIfError( err ); + LOGGER_WRITE_1("PowerState: %d", state); + iStream->WriteUint8L( state ); + + // Get device info + TBTRegistrySearch crit; + crit.FindAll(); + if ( !iBtDevArray ) + { + LOGGER_WRITE("create arr"); + iBtDevArray = new (ELeave) CBTDeviceArray(5); + LOGGER_WRITE("create arr -ok"); + } + else + { + iBtDevArray->ResetAndDestroy(); + } + err = iBtEng->GetDevices( crit, iBtDevArray ); + LOGGER_WRITE_1("GetDevices err: %d", err); + User::LeaveIfError( err ); + iState = ERequestBtInfo; + + // Wait until completed + iWait.Start(); + iState = EIdle; + if ( iOperationError ) + { + LOGGER_WRITE_1("Operation failed, leave %d", iOperationError); + User::Leave( iOperationError ); + } + TRACE_FUNC_EXIT; + } + +void CSconBtEngine::SetBtAuthorizedL( const TDesC& aBtDevAddress, TBool aAuthorized ) + { + TRACE_FUNC_ENTRY; + if ( iState != EIdle ) + { + User::Leave( KErrInUse ); + } + + TBTRegistrySearch crit; + TBTDevAddr addr; + addr.SetReadable( aBtDevAddress ); + crit.FindAddress( addr ); + + if ( !iBtDevArray ) + { + LOGGER_WRITE("create arr"); + iBtDevArray = new (ELeave) CBTDeviceArray(5); + LOGGER_WRITE("create arr -ok"); + } + else + { + iBtDevArray->ResetAndDestroy(); + } + TInt err = iBtEng->GetDevices( crit, iBtDevArray ); + LOGGER_WRITE_1("GetDevices err: %d", err); + User::LeaveIfError( err ); + iState = EChangeAuthorized; + iOperationError = KErrNone; + iAuthorizedValue = aAuthorized; + + // Wait until completed + iWait.Start(); + iState = EIdle; + if ( iOperationError ) + { + LOGGER_WRITE_1("Operation failed, leave %d", iOperationError); + User::Leave( iOperationError ); + + } + + TRACE_FUNC_EXIT; + } + +TInt CSconBtEngine::SetBtPowerState( TBool aPower ) + { + TRACE_FUNC_ENTRY; + if ( iState != EIdle ) + { + return KErrInUse; + } + + TBTPowerStateValue state; + iOperationError = iBtSettings->GetPowerState( state ); + if ( iOperationError ) + { + return iOperationError; + } + else if ( ( aPower && state == EBTPowerOn ) + || ( !aPower && state == EBTPowerOff ) ) + { + // No need to change state + return KErrNone; + } + + state = EBTPowerOff; + if ( aPower ) + { + state = EBTPowerOn; + } + iOperationError = iBtSettings->SetPowerState( state ); + if ( iOperationError ) + { + return iOperationError; + } + iState = EChangeBtState; + + // Wait until completed + iWait.Start(); + + iState = EIdle; + TRACE_FUNC_RET( iOperationError ); + return iOperationError; + } + +TInt CSconBtEngine::SetBtName( const TDesC& aBtName ) + { + LOGGER_WRITE_1("SetBtName aBtName: %S", &aBtName); + TInt err = iBtSettings->SetLocalName( static_cast( aBtName ) ); + TRACE_FUNC_RET( err ); + return err; + } + +// From MBTEngDevManObserver +void CSconBtEngine::HandleDevManComplete( TInt aErr ) + { + TRACE_FUNC; + LOGGER_WRITE_1("aErr: %d", aErr ); + if ( iState == EChangeAuthorized ) + { + if ( iWait.IsStarted() ) + { + iOperationError = aErr; + iWait.AsyncStop(); + } + } + + } + +void CSconBtEngine::HandleGetDevicesComplete( TInt aErr, + CBTDeviceArray* aDeviceArray ) + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("aErr: %d", aErr); + //iBtReqOngoing = EFalse; + if ( iState == ERequestBtInfo ) + { + // Continue to write devices info + TRAP( iOperationError, PrintDevicesL() ); + LOGGER_WRITE_1("PrintDevicesL err: %d", iOperationError); + + if ( iWait.IsStarted() ) + { + iWait.AsyncStop(); + } + } + else if ( iState == EChangeAuthorized ) + { + iOperationError = aErr; + if ( !aErr && aDeviceArray->Count() == 1 ) + { + CBTDevice* btRef = aDeviceArray->At(0); + TBTDeviceSecurity devSec = btRef->GlobalSecurity(); + if ( btRef->IsPaired() && !devSec.Banned() ) + { + LOGGER_WRITE8_1("btAdrr: %S", &btRef->BDAddr().Des() ); + CBTDevice* btDevice = CBTDevice::NewLC( btRef->BDAddr() ); + + btDevice->SetPaired( ETrue ); + + btDevice->SetDeviceNameL( btRef->DeviceName() ); + btDevice->SetFriendlyNameL( btRef->FriendlyName() ); + LOGGER_WRITE8_1("name: %S", &btRef->DeviceName()); + LOGGER_WRITE8_1("FriendlyName: %S", &btRef->FriendlyName()); + + LOGGER_WRITE_1("iAuthorizedValue: %d", iAuthorizedValue); + // Set as authorized and store the device + TBTDeviceSecurity security; + security.SetNoAuthenticate( EFalse ); + security.SetNoAuthorise( iAuthorizedValue ); + security.SetBanned( EFalse ); + + btDevice->SetGlobalSecurity (security ); + + //iOperationError = iBtEng->ModifyDevice(*aDeviceArray->At(0)); + iOperationError = iBtEng->ModifyDevice( *btDevice ); + LOGGER_WRITE_1( "ModifyDevice err: %d", iOperationError ); + CleanupStack::PopAndDestroy( btDevice ); + } + else + { + LOGGER_WRITE("Device was not paired or it's banned") + iOperationError = KErrAccessDenied; + } + } + + // If error occured stop waiting, otherwise continue waiting until + // HandleDevManComplete has been called + if ( iOperationError && iWait.IsStarted() ) + { + iWait.AsyncStop(); + } + } + TRACE_FUNC_EXIT; + } + +void CSconBtEngine::PrintDevicesL() + { + TRACE_FUNC_ENTRY; + // calculate devices count + TInt devCount(0); + + for ( TInt i=0 ; iCount(); i++ ) + { + CBTDevice* device = iBtDevArray->At(i); + // show only paired and banned devices + if ( device->IsPaired() || device->GlobalSecurity().Banned() ) + { + devCount++; + } + } + + // Print info + iStream->WriteUint8L( devCount ); + + for ( TInt i=0 ; iCount(); i++ ) + { + CBTDevice* device = iBtDevArray->At(i); + + const TBTDeviceSecurity btSec = device->GlobalSecurity(); + + // show only paired and banned devices + if ( device->IsPaired() || btSec.Banned() ) + { + LOGGER_WRITE_1("IsValidDeviceName: %d", device->IsValidDeviceName()); + const TDesC8& deviceName = device->DeviceName(); + LOGGER_WRITE8_1("DeviceName: %S", &deviceName ); + iStream->WriteUint8L( deviceName.Length() ); + iStream->WriteL( deviceName, deviceName.Length() ); + + LOGGER_WRITE_1("IsValidFriendlyName: %d", device->IsValidFriendlyName()); + LOGGER_WRITE_1("FriendlyName: %S", &device->FriendlyName() ); + + const TBTDevAddr& addr = device->BDAddr(); + + TBuf<100> readable; + addr.GetReadable( readable ); + LOGGER_WRITE_1("readable addr: %S", &readable); + iStream->WriteUint8L( readable.Length() ); + iStream->WriteL( readable, readable.Length() ); + + LOGGER_WRITE_1("paired: %d", device->IsPaired() ); + LOGGER_WRITE_1("IsValidPaired: %d", device->IsValidPaired() ); + TUint8 paired(0); + if ( device->IsPaired() && device->IsValidPaired() ) + { + paired = 1; + } + iStream->WriteUint8L( paired ); + + TUint8 noAuthorise(0); + if ( btSec.NoAuthorise() ) + { + noAuthorise = 1; + } + iStream->WriteUint8L( noAuthorise ); + + TUint8 banned(0); + if ( btSec.Banned() ) + { + banned = 1; + } + iStream->WriteUint8L( banned ); + + LOGGER_WRITE(""); + } + } + iStream->CommitL(); + iStream = NULL; //delete reference only + TRACE_FUNC_EXIT; + } + +// From MBTEngSettingsObserver +void CSconBtEngine::PowerStateChanged( TBTPowerStateValue /*aState*/ ) + { + TRACE_FUNC; + if ( iState == EChangeBtState && iWait.IsStarted() ) + { + iWait.AsyncStop(); + } + + } + +void CSconBtEngine::VisibilityModeChanged( TBTVisibilityMode /*aState*/ ) + { + TRACE_FUNC; + } diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/pcconn/src/sconfolderlister.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/pcconn/src/sconfolderlister.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,717 @@ +/* +* 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: CSconFolderLister implementation +* +*/ + + +#include "sconfolderlister.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" + +const TUint16 KFormatVersion( 1 ); + +// Obex package size +const TInt KPackageSize = 65536; + +const TInt KMaxLevelsToSearch = 80; + +_LIT( KSConResourceName, "z:\\Resource\\sconftp.rsc" ); + +CSconFolderEntry* CSconFolderEntry::NewLC() + { + CSconFolderEntry* self = new (ELeave) CSconFolderEntry(); + CleanupStack::PushL( self ); + return self; + } +CSconFolderEntry* CSconFolderEntry::NewLC( const TEntry& aEntry ) + { + CSconFolderEntry* self = new (ELeave) CSconFolderEntry(); + CleanupStack::PushL( self ); + self->ConstructL( aEntry ); + return self; + } +CSconFolderEntry::CSconFolderEntry() + { + } +CSconFolderEntry::~CSconFolderEntry() + { + delete iName; + delete iLabel; + } + + +void CSconFolderEntry::ConstructL( const TEntry& aEntry ) + { + iAtt = aEntry.iAtt; + iModified = aEntry.iModified.Int64(); + iName = aEntry.iName.AllocL(); + } + +CSconFolderLister::CSconFolderLister( RFs& aFs ) : iFs(aFs) + { + // No implementation required + } + +CSconFolderLister::~CSconFolderLister() + { + TRACE_FUNC; + delete iLocalizer; + } + +CSconFolderLister* CSconFolderLister::NewL( RFs& aFs ) + { + TRACE_FUNC_ENTRY; + CSconFolderLister* self = new (ELeave) CSconFolderLister( aFs ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + TRACE_FUNC_EXIT; + return self; + } + +void CSconFolderLister::ConstructL() + { + TRACE_FUNC_ENTRY; + + iLocalizer = CDirectoryLocalizer::NewL(); + + // set free memory up to critical level for all drives + CRepository* repository = CRepository::NewLC( KCRUidDiskLevel ); + TInt iCriticalLevel(0); + User::LeaveIfError( repository->Get( KDiskCriticalThreshold, iCriticalLevel ) ); + CleanupStack::PopAndDestroy( repository ); + iCriticalLevel += KPackageSize; // add obex package size to critical level + TRACE_FUNC_EXIT; + } + + +void CSconFolderLister::GenerateFolderListL( RBufWriteStream& aStream, const TDesC& aStartPath, + const TInt aLevelsToSearch ) + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("aStartPath: %S", &aStartPath ); + LOGGER_WRITE_1("aLevelsToSearch: %d", aLevelsToSearch ); + TInt levelsToSearch = aLevelsToSearch; + if ( levelsToSearch > KMaxLevelsToSearch || levelsToSearch == KErrNotFound ) + levelsToSearch = KMaxLevelsToSearch; + iFolders = 0; + iFiles = 0; + const TInt KDriveNameLength( 3 ); + + if ( aStartPath.CompareF( _L("\\") ) == 0 ) + { + LOGGER_WRITE("List all drives"); + aStream.WriteUint16L( KFormatVersion ); + ListAllDrivesL( aStream, levelsToSearch ); + } + else if ( aStartPath.Length() >= KDriveNameLength ) + { + if ( aStartPath.Length() > KDriveNameLength ) + { + // check root path permissions, is listing allowed + TPtrC path = aStartPath.Mid(KDriveNameLength); + LOGGER_WRITE_1("pathFromRoot: %S", &path); + TInt pathEndMark = path.Locate(TChar('\\')); + if ( pathEndMark == KErrNotFound ) + { + User::Leave( KErrArgument ); + } + //"private\" locate = 7" + TPtrC pathName = aStartPath.Left( KDriveNameLength+pathEndMark ); + LOGGER_WRITE_1("pathName: %S", &path); + TEntry pathEntry; + User::LeaveIfError( iFs.Entry(pathName, pathEntry) ); + + TBool printable = IsDirectoryPrintable( aStartPath.Left(3), pathEntry ); + if ( !printable ) + { + // access denied + LOGGER_WRITE("Access denied!"); + User::Leave( KErrAccessDenied ); + } + User::LeaveIfError( iFs.Entry(aStartPath, pathEntry) ); + if ( pathEntry.IsSystem() ) + { + // access denied + LOGGER_WRITE("System folder, Access denied!"); + User::Leave( KErrAccessDenied ); + } + } + + + aStream.WriteUint16L( KFormatVersion ); + + TInt drive; + User::LeaveIfError( iFs.CharToDrive( aStartPath[0], drive) ); + ListDriveAndPathL( aStream, drive, aStartPath, levelsToSearch); + + } + else + { + LOGGER_WRITE("aStartPath KErrArgument"); + User::Leave( KErrArgument ); + } + + + LOGGER_WRITE_1("iFolders: %d", iFolders); + LOGGER_WRITE_1("iFiles: %d", iFiles); + TRACE_FUNC_EXIT; + } + +void CSconFolderLister::ListAllDrivesL( RBufWriteStream& aStream, const TInt aLevelsToSearch ) + { + TRACE_FUNC_ENTRY; + TInt devDriveCount = 0; + TInt mmcDriveCount = 0; + TChar driveLetter; + TBuf8<1> driveBuf; + RArray sconDriveInfo(5); + + // Write all drives to folderlisting object + TDriveList driveList; + // Get all drives that are visible to the user. + TInt driveCount; + User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveList, driveCount ) ); + + for( TInt i = EDriveA; i < KMaxDrives; i++ ) + { + if( driveList[i] ) + { + TUint driveStatus; + User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, i, driveStatus ) ); + //LOGGER_WRITE_1( "DriveInfo for drive: %d", i); + + if( !(driveStatus & DriveInfo::EDrivePresent ) + || driveStatus & DriveInfo::EDriveCorrupt + || (driveStatus & DriveInfo::EDriveRemote) ) + { + //LOGGER_WRITE_1( "skip drive %d", i); + continue; + } + + User::LeaveIfError( iFs.DriveToChar( i, driveLetter ) ); + //Letter to uppercase form. + driveLetter.UpperCase(); + + TSconDriveInfo info; + info.iDriveStatus = driveStatus; + info.iDriveLetter.Zero(); + info.iDriveLetter.Append( driveLetter ); + info.iDriveLetter.Append( _L(":") ); + + + info.iDriveAttr = KEntryAttNormal; // ReadWrite + + if( driveStatus & DriveInfo::EDriveInternal && devDriveCount==0 ) + { + //permission always R for first internal drive + info.iDriveAttr = KEntryAttReadOnly; + } + + //memory type + if( driveStatus & DriveInfo::EDriveInternal ) + { + LOGGER_WRITE( "DriveInfo::EDriveInternal" ); + devDriveCount++; + info.iDriveType = DriveInfo::EDriveInternal; // =1 + info.iDriveTypeCount = devDriveCount; + + } + else if( driveStatus & DriveInfo::EDriveRemovable ) + { + LOGGER_WRITE( "DriveInfo::EDriveRemovable" ); + mmcDriveCount++; + info.iDriveType = DriveInfo::EDriveRemovable;; // =2 + info.iDriveTypeCount = mmcDriveCount; + } + + TVolumeInfo volumeInfo; + User::LeaveIfError( iFs.Volume( volumeInfo, i) ); + + info.iVolumeName = volumeInfo.iName; + if ( volumeInfo.iFree > iCriticalLevel ) + { + volumeInfo.iFree = volumeInfo.iFree - iCriticalLevel; + } + else + { + volumeInfo.iFree = 0; + } + + info.iFree = volumeInfo.iFree; + info.iSize = volumeInfo.iSize; + + + sconDriveInfo.AppendL( info ); + + } + } + + LOGGER_WRITE_1("Drives: %d", sconDriveInfo.Count()); + aStream.WriteUint8L( sconDriveInfo.Count() ); + for ( TInt i=0; i < sconDriveInfo.Count(); i++ ) + { + + TBuf<3> path(KNullDesC); + path.Copy(sconDriveInfo[i].iDriveLetter); + path.Append(_L("\\")); + + ExportDriveL( aStream, sconDriveInfo[i], path, aLevelsToSearch); + } + sconDriveInfo.Close(); + TRACE_FUNC_EXIT; + } + +void CSconFolderLister::ListDriveAndPathL( RBufWriteStream& aStream, TInt aDrive, const TDesC& aStartPath, const TInt aLevelsToSearch ) + { + TRACE_FUNC_ENTRY; + TVolumeInfo volumeInfo; + User::LeaveIfError( iFs.Volume(volumeInfo, aDrive) ); + TInt driveCount(0); + TUint driveStatus; + User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, aDrive, driveStatus ) ); + GetDriveTypeNumberL( aDrive, driveStatus, driveCount ); + + + TSconDriveInfo info; + info.iDriveLetter.Copy( aStartPath.Left(2) ); + info.iVolumeName = volumeInfo.iName; + + info.iDriveAttr = KEntryAttNormal; // ReadWrite + if( driveStatus & DriveInfo::EDriveInternal && driveCount==0 ) + { + //permission always R for first internal drive + info.iDriveAttr = KEntryAttReadOnly; + } + info.iDriveType = 0; + if( driveStatus & DriveInfo::EDriveInternal ) + { + info.iDriveType = DriveInfo::EDriveInternal; // =1 + } + else if( driveStatus & DriveInfo::EDriveRemovable ) + { + info.iDriveType = DriveInfo::EDriveRemovable;; // =2 + } + + if ( volumeInfo.iFree > iCriticalLevel ) + { + volumeInfo.iFree = volumeInfo.iFree - iCriticalLevel; + } + else + { + volumeInfo.iFree = 0; + } + + info.iFree = volumeInfo.iFree; + info.iSize = volumeInfo.iSize; + + aStream.WriteUint8L( 1 ); + ExportDriveL( aStream, info, aStartPath, aLevelsToSearch); + + TRACE_FUNC_EXIT; + } + +void CSconFolderLister::ExportDriveL( RBufWriteStream& aStream, const TSconDriveInfo& aDriveInfo, + const TDesC& aPathName, const TInt aLevelsToSearch ) + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("Drive: %S", &aDriveInfo.iDriveLetter); + LOGGER_WRITE_1("aLevelsToSearch: %d", aLevelsToSearch ); + + CSconFolderEntry* driveEntry = CSconFolderEntry::NewLC(); + driveEntry->iName = aDriveInfo.iDriveLetter.AllocL(); + + if ( driveEntry->iLabel ) + { + LOGGER_WRITE_1("Label: %S", &driveEntry->iLabel->Des()); + } + driveEntry->iAtt = aDriveInfo.iDriveAttr; + + driveEntry->iDriveInfoEntryExists = ETrue; + driveEntry->iDriveInfoEntry.iDriveType = aDriveInfo.iDriveType; + driveEntry->iDriveInfoEntry.iDriveTypeCount = aDriveInfo.iDriveTypeCount; + + driveEntry->iDriveInfoEntry.iFree = aDriveInfo.iFree; + driveEntry->iDriveInfoEntry.iSize = aDriveInfo.iSize; + + driveEntry->iLabel = aDriveInfo.iVolumeName.AllocL(); + GetLocalizedVolumeNameL( *driveEntry ); + + ExportPathL( aStream, aPathName, *driveEntry, ETrue, aLevelsToSearch ); + CleanupStack::PopAndDestroy( driveEntry ); + TRACE_FUNC_EXIT; + } + +void CSconFolderLister::GetLocalizedVolumeNameL( CSconFolderEntry& aDriveEntry ) + { + TRACE_FUNC_ENTRY; + // Get localized names + if ( aDriveEntry.iDriveInfoEntry.iDriveType == DriveInfo::EDriveInternal + && aDriveEntry.iDriveInfoEntry.iDriveTypeCount > 1 ) + { + LOGGER_WRITE("Internal mass memory"); + // internal second memory (Mass memory) + TFileName file( KSConResourceName ); + BaflUtils::NearestLanguageFile( iFs, file ); + + CStringResourceReader* reader = CStringResourceReader::NewL( file ); + if ( aDriveEntry.iLabel ) + { + delete aDriveEntry.iLabel; + aDriveEntry.iLabel = NULL; + } + aDriveEntry.iLabel = reader->ReadResourceString( R_SECON_VALUE_MASS_STORAGE ).AllocL(); + delete reader; + } + else if ( aDriveEntry.iLabel && aDriveEntry.iLabel->Length()>0 ) + { + LOGGER_WRITE("Use normal volume label"); + + } + else + { + TFileName file( KSConResourceName ); + BaflUtils::NearestLanguageFile( iFs, file ); + CStringResourceReader* reader = CStringResourceReader::NewL( file ); + if (aDriveEntry.iLabel) + { + delete aDriveEntry.iLabel; + aDriveEntry.iLabel = NULL; + } + if ( aDriveEntry.iDriveInfoEntry.iDriveType == DriveInfo::EDriveRemovable ) + { + LOGGER_WRITE("EDriveRemovable"); + // read default MMC name + aDriveEntry.iLabel = reader->ReadResourceString( R_SECON_VALUE_MMC ).AllocL(); + } + else + { + LOGGER_WRITE("EDriveInternal"); + // read default DEV name + aDriveEntry.iLabel = reader->ReadResourceString( R_SECON_VALUE_DEVICE ).AllocL(); + } + delete reader; + } + TRACE_FUNC_EXIT; + } + +// ----------------------------------------------------------------------------- +// CSconFolderLister::GetDriveTypeNumberL() +// +// ----------------------------------------------------------------------------- +// +void CSconFolderLister::GetDriveTypeNumberL( TInt aDrive, TUint aDriveStatus , TInt& aTypeNumber) + { + TRACE_FUNC_ENTRY; + aTypeNumber = 0; + + //TUint driveStatus; + // + // if true, search internal drives, else search removable drives + TBool searchInternalDrives = (aDriveStatus & DriveInfo::EDriveInternal); + + TInt driveCount; + TDriveList driveList; + + User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveList, driveCount ) ); + + for( TInt i = EDriveA; i <= aDrive; i++ ) + { + if( driveList[i] ) + { + TUint driveStatus; + User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, i, driveStatus ) ); + + if( !(driveStatus & DriveInfo::EDrivePresent ) + || driveStatus & DriveInfo::EDriveCorrupt ) + { + LOGGER_WRITE( "not present or corrupted" ); + continue; + } + + if( driveStatus & DriveInfo::EDriveInternal ) + { + if( searchInternalDrives ) + { + aTypeNumber++; + } + } + else if( driveStatus & DriveInfo::EDriveRemovable ) + { + if( !searchInternalDrives ) + { + aTypeNumber++; + } + } + } + } + TRACE_FUNC_EXIT; + } + + +void CSconFolderLister::ExportPathL( RBufWriteStream& aStream, const TDesC& aPathName, + const CSconFolderEntry& aEntry, const TBool aLocalize, const TInt aLevelsToSearch ) + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("aPathName: %S", &aPathName ); + LOGGER_WRITE_1("aLevelsToSearch: %d", aLevelsToSearch ); + + LOGGER_WRITE_1("aEntry.iName: %S", &aEntry.iName->Des() ); + + TBool localized(EFalse); + + // foldername length + name + aStream.WriteUint8L( aEntry.iName->Length() ); + aStream.WriteL( aEntry.iName->Des() ); + + TUint att = aEntry.iAtt; + + if ( aEntry.iLabel && aEntry.iLabel->Length() > 0 ) + { + aStream.WriteUint8L( aEntry.iLabel->Length() ); + aStream.WriteL( aEntry.iLabel->Des() ); + } + else + { + if ( aLocalize ) + { + // initialize Localizer + iLocalizer->SetFullPath( aPathName ); + localized = iLocalizer->IsLocalized(); + } + + if( localized ) + { + const TDesC& localizedName = iLocalizer->LocalizedName(); + aStream.WriteUint8L( localizedName.Length() ); + aStream.WriteL( localizedName ); + LOGGER_WRITE_1("LocalizedName: %S", &localizedName ); + } + else if ( aPathName.CompareF(_L("C:\\Data\\")) == 0 ) + { + TFileName file( KSConResourceName ); + + BaflUtils::NearestLanguageFile( iFs, file ); + + CStringResourceReader* reader = CStringResourceReader::NewL( file ); + CleanupStack::PushL( reader ); + + const TDesC& localizedName = reader->ReadResourceString( R_SECON_DATA_FOLDER ); + aStream.WriteUint8L( localizedName.Length() ); + aStream.WriteL( localizedName ); + LOGGER_WRITE_1("LocalizedName: %S", &localizedName ); + + CleanupStack::PopAndDestroy( reader ); + localized = ETrue; + } + else + { + aStream.WriteUint8L( 0 ); + } + // attributes + if ( localized ) + { + // localized folder, set readonly flag + att = att | KEntryAttReadOnly; + } + } + + if ( aPathName.Length() == 3 && aLocalize ) + { + // enable subfolder localization, even when root cannot be localized + localized = ETrue; + } + + // DriveInfoEntry + if ( aEntry.iDriveInfoEntryExists ) + { + aStream.WriteUint8L( 1 ); + aStream.WriteUint8L( aEntry.iDriveInfoEntry.iDriveType ); + aStream.WriteUint8L( aEntry.iDriveInfoEntry.iDriveTypeCount ); + aStream << aEntry.iDriveInfoEntry.iFree; + aStream << aEntry.iDriveInfoEntry.iSize; + } + else + { + aStream.WriteUint8L( 0 ); + } + + + // modified time + TDateTime time = aEntry.iModified.DateTime(); + aStream.WriteInt16L( time.Year() ); + aStream.WriteInt8L( time.Month()+1 ); // range 1...12 + aStream.WriteInt8L( time.Day()+1 ); + aStream.WriteInt8L( time.Hour() ); + aStream.WriteInt8L( time.Minute() ); + aStream.WriteInt8L( time.Second() ); + + // write attribute + aStream.WriteUint32L( att ); + + + if ( aLevelsToSearch == 0 ) + { + // don't list directory content + LOGGER_WRITE("Not listing directory content"); + aStream.WriteInt16L( 0 ); // files count + aStream.WriteInt16L( 0 ); // directory count + return; + } + + CDir *fileList = 0; + CDir *dirList = 0; + + // show normal and hidden files and folders + TUint entryAttMask = KEntryAttNormal | KEntryAttHidden; + + // get folders and files + TInt err = iFs.GetDir( aPathName, entryAttMask, ESortByName, + fileList, dirList ); + + if ( err ) + { + LOGGER_WRITE_1( "ParseFolderListL GetDir returned: %d", err ); + User::Leave( err ); + } + + CleanupStack::PushL( dirList ); + CleanupStack::PushL( fileList ); + + + LOGGER_WRITE_1("files: %d", fileList->Count()); + aStream.WriteUint16L( fileList->Count() ); + + // Print files to folder listing object + for( TInt i = 0; i < fileList->Count(); i++ ) + { + const TEntry& fileEntry = ( *fileList )[i]; + iFiles++; + LOGGER_WRITE_1("fileEntry.iName: %S", &fileEntry.iName); + // filename length + name + aStream.WriteUint8L( fileEntry.iName.Length() ); + aStream.WriteL( fileEntry.iName ); + + // modified time + TDateTime time = fileEntry.iModified.DateTime(); + aStream.WriteInt16L( time.Year() ); + aStream.WriteInt8L( time.Month()+1 ); // range 1...12 + aStream.WriteInt8L( time.Day()+1 ); + aStream.WriteInt8L( time.Hour() ); + aStream.WriteInt8L( time.Minute() ); + aStream.WriteInt8L( time.Second() ); + + // attributes + aStream.WriteUint32L( fileEntry.iAtt ); + + // file size + aStream.WriteUint32L( fileEntry.iSize ); + } + CleanupStack::PopAndDestroy( fileList ); + + + // calculate ow many directories we are going to list + TInt directoryCount(0); + for( TInt i = 0; i < dirList->Count(); i++ ) + { + if ( IsDirectoryPrintable(aPathName, ( *dirList )[i] ) ) + { + directoryCount++; + } + } + LOGGER_WRITE_1("directories: %d", directoryCount); + aStream.WriteUint16L( directoryCount ); + + HBufC* fullpath = HBufC::NewL( KMaxPath ); + TPtr fullpathPtr = fullpath->Des(); + CleanupStack::PushL( fullpath ); + + // Print folders to folder listing object + for( TInt i = 0; i < dirList->Count(); i++ ) + { + const TEntry& folderEntry = ( *dirList )[i]; + if ( !IsDirectoryPrintable(aPathName, folderEntry) ) + { + continue; + } + iFolders++; + + fullpathPtr.Copy( aPathName ); + fullpathPtr.Append( folderEntry.iName ); + fullpathPtr.Append( _L("\\") ); + CSconFolderEntry* subFolderEntry = CSconFolderEntry::NewLC( folderEntry ); + if ( aLevelsToSearch == KErrNotFound ) + { + ExportPathL( aStream, fullpathPtr, *subFolderEntry, localized, aLevelsToSearch); + } + else + { + ExportPathL( aStream, fullpathPtr, *subFolderEntry, localized, aLevelsToSearch-1); + } + CleanupStack::PopAndDestroy( subFolderEntry ); + } + CleanupStack::PopAndDestroy( fullpath ); + CleanupStack::PopAndDestroy( dirList ); + + TRACE_FUNC_EXIT; + } +TBool CSconFolderLister::IsDirectoryPrintable( const TDesC& aParentPath, const TEntry& aFolderEntry ) + { + if ( aFolderEntry.IsSystem() ) + { + LOGGER_WRITE_1("folder '%S' was system folder", &aFolderEntry.iName); + return EFalse; + } + if ( aParentPath.Length() == 3 ) + { + if ( aParentPath.FindF(_L("C:\\")) == 0 && aFolderEntry.iName.CompareF(_L("data")) != 0 ) + { + // C root not visible, exept Data folder + LOGGER_WRITE_1("folder '%S' not visible to user in c-root", &aFolderEntry.iName); + return EFalse; + } + + if ( aFolderEntry.iName.CompareF(_L("private")) == 0 ) + { + LOGGER_WRITE_1("folder '%S' not visible to user", &aFolderEntry.iName); + return EFalse; + } + else if ( aFolderEntry.iName.CompareF(_L("sys")) == 0 ) + { + LOGGER_WRITE_1("folder '%S' not visible to user", &aFolderEntry.iName); + return EFalse; + } + else if ( aFolderEntry.iName.CompareF(_L("system")) == 0 ) + { + LOGGER_WRITE_1("folder '%S' not visible to user", &aFolderEntry.iName); + return EFalse; + } + else if ( aFolderEntry.iName.CompareF(_L("resource")) == 0 ) + { + LOGGER_WRITE_1("folder '%S' not visible to user", &aFolderEntry.iName); + return EFalse; + } + } + return ETrue; + } + diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/pcconn/src/sconimsireader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/pcconn/src/sconimsireader.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2009-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: CSconImsiReader implementation +* +*/ + + +#include "sconimsireader.h" +#include "debug.h" + +TInt CSconImsiReader::GetImsiL( TDes& aImsi ) + { + TRACE_FUNC_ENTRY; + CTelephony::TRegistrationStatus temp; + CSconImsiReader* self = new (ELeave) CSconImsiReader(aImsi, temp); + CleanupStack::PushL(self); + self->ConstructL(); + + self->RequestImsi(); + + TInt err = self->iStatus.Int(); + CleanupStack::PopAndDestroy(self); + TRACE_FUNC_RET(err); + return err; + } + +TInt CSconImsiReader::GetNetworkStatusL( CTelephony::TRegistrationStatus& aRegistrationStatus ) + { + TRACE_FUNC_ENTRY; + TBuf temp; + CSconImsiReader* self = new (ELeave) CSconImsiReader(temp, aRegistrationStatus); + CleanupStack::PushL(self); + self->ConstructL(); + + self->RequestNetworkStatus(); + + TInt err = self->iStatus.Int(); + CleanupStack::PopAndDestroy(self); + TRACE_FUNC_RET(err); + return err; + } + +void CSconImsiReader::ConstructL() + { + TRACE_FUNC_ENTRY; + iTelephony = CTelephony::NewL(); + CActiveScheduler::Add(this); + TRACE_FUNC_EXIT; + } + +void CSconImsiReader::RequestImsi() + { + iImsiReaderStatus = ERequestingImsi; + iTelephony->GetSubscriberId(iStatus,iSubscriberIdV1Pckg); + SetActive(); + CActiveScheduler::Start(); + } + +void CSconImsiReader::RequestNetworkStatus() + { + iImsiReaderStatus = ERequestingNetworkStatus; + iTelephony->GetNetworkRegistrationStatus(iStatus, iNetworkRegistrationV1Pckg); + SetActive(); + CActiveScheduler::Start(); + } + +CSconImsiReader::~CSconImsiReader() + { + TRACE_FUNC_ENTRY; + delete iTelephony; + TRACE_FUNC_EXIT; + } + +CSconImsiReader::CSconImsiReader(TDes& aImsi, CTelephony::TRegistrationStatus& aRegistrationStatus): CActive(EPriorityStandard), + iImsi(aImsi), iNetworkStatus(aRegistrationStatus), iSubscriberIdV1Pckg(iSubscriberIdV1), iNetworkRegistrationV1Pckg(iNetworkRegistrationV1) + { + } + +void CSconImsiReader::RunL() + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("iStatus: %d", iStatus.Int() ); + if ( iStatus == KErrNone ) + { + if ( iImsiReaderStatus == ERequestingImsi ) + { + iImsi = iSubscriberIdV1.iSubscriberId; + LOGGER_WRITE_1("iImsi: %S", &iImsi); + } + else if ( iImsiReaderStatus == ERequestingNetworkStatus ) + { + iNetworkStatus = iNetworkRegistrationV1.iRegStatus; + LOGGER_WRITE_1( "iNetworkStatus: %d", (TInt)iNetworkStatus); + } + } + CActiveScheduler::Stop(); + TRACE_FUNC_EXIT; + } + +void CSconImsiReader::DoCancel() + { + TRACE_FUNC_ENTRY; + if ( iImsiReaderStatus == ERequestingImsi ) + { + iTelephony->CancelAsync( CTelephony::EGetSubscriberIdCancel ); + } + else if ( iImsiReaderStatus == ERequestingNetworkStatus ) + { + iTelephony->CancelAsync( CTelephony::EGetNetworkRegistrationStatusCancel ); + } + TRACE_FUNC_EXIT; + } diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/pcconn/src/sconpcconnserver.cpp --- a/connectivitymodules/SeCon/servers/pcconn/src/sconpcconnserver.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/servers/pcconn/src/sconpcconnserver.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-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" @@ -18,12 +18,18 @@ #include // For RMemReadStream #include +#include +#include #include "sconpcconnclientserver.h" #include "sconpcconnserver.h" #include "sconpcd.h" #include "sconcsc.h" #include "sconconmlhandler.h" +#include "sconimsireader.h" +#include "sconoviaccounthandler.h" +#include "sconfolderlister.h" +#include "sconbtengine.h" #include "debug.h" #ifdef DEBUG_XML @@ -33,6 +39,15 @@ #endif _LIT( KSCONGetMetadataRequest, "METADATA:" ); +_LIT8( KSCONSyncRequest, "SYNC:" ); +_LIT( KSCONReadImsi, "READIMSI"); +_LIT( KSCONReadNetworkInfo, "READNETWORKINFO"); +_LIT( KSCONReadOviAccount, "READOVIACCOUNT"); +_LIT( KSCONListPath, "LISTP:"); +_LIT( KSCONReadBtInfo, "READBTINFO" ); +_LIT( KSCONSetBtPower, "SETBTPOWER:" ); +_LIT( KSCONSetBtName, "SETBTNAME:" ); +_LIT( KSCONSetBtAuthorized, "SETBTAUTHORIZED:" ); //------------------------------------------------------------ // Global functions @@ -129,7 +144,13 @@ if ( clientId != KSConPCConnClientSecureId ) { LOGGER_WRITE( "CSConPCConnServer::NewSessionL() : Secure ID does not match" ); +#ifndef __WINS__ + LOGGER_WRITE( "Leave KErrAccessDenied"); User::Leave( KErrAccessDenied ); +#else + // does not leave on WINS environment. Easier to run module tests. + LOGGER_WRITE( "Not leaving on WINS environment" ); +#endif } TRACE_FUNC_EXIT; @@ -272,7 +293,12 @@ } iChunk.Close(); - + delete iFolderLister; + + iFs.Close(); + + delete iBtEngine; + TRACE_FUNC_EXIT; } @@ -304,21 +330,18 @@ TInt ret ( KErrNone ); iResult = KErrNone; + User::LeaveIfError( iFs.Connect() ); + #ifdef DEBUG_XML // create log file - RFs fs; - User::LeaveIfError( fs.Connect () ); - CleanupClosePushL( fs ); RFile file; - TInt err = file.Create ( fs, KSConConMLDebugFile, EFileWrite ); + TInt err = file.Create ( iFs, KSConConMLDebugFile, EFileWrite ); if( err == KErrNone ) { // file created, close it file.Close(); - } - - CleanupStack::PopAndDestroy( &fs ); + } #endif // initialize buffer @@ -355,7 +378,9 @@ User::Leave ( ret ); } } - + + iFolderLister = CSconFolderLister::NewL( iFs ); + TRACE_FUNC_EXIT; } @@ -457,9 +482,14 @@ iBuffer->Reset(); length = buf.ReadInt32L(); - HBufC8* name = HBufC8::NewLC( length ); - TPtr8 namePtr = name->Des(); - buf.ReadL( namePtr, length); + HBufC8* name8 = HBufC8::NewLC( length ); + TPtr8 namePtr8 = name8->Des(); + buf.ReadL( namePtr8, length); + + const TUint8* ptr8 = namePtr8.Ptr(); + const TUint16* ptr16 = reinterpret_cast( ptr8 ); + TPtrC namePtr; + namePtr.Set( ptr16, length/2 ); length = buf.ReadInt32L(); HBufC8* type = HBufC8::NewLC( length ); @@ -478,12 +508,9 @@ buf.Close(); #ifdef DEBUG_XML - RFs fs; - User::LeaveIfError( fs.Connect() ); - CleanupClosePushL( fs ); RFile file; - if ( file.Open( fs, KSConConMLDebugFile, EFileWrite ) == KErrNone ) + if ( file.Open( iFs, KSConConMLDebugFile, EFileWrite ) == KErrNone ) { RFileWriteStream fws; TInt fileSize; @@ -507,11 +534,25 @@ CleanupStack::PopAndDestroy( &fws ); } - file.Close(); - CleanupStack::PopAndDestroy( &fs ); + file.Close(); #endif - - if ( ( typePtr.Compare( KSConPCDWBXMLObjectType ) == KErrNone) || + if ( ( ( typePtr.CompareC( KSConPCDWBXMLObjectType)== KErrNone ) || + ( typePtr.CompareC( KSConPCDWBXMLObjectType2 )== KErrNone ) ) + && namePtr8.Find(KSCONSyncRequest) == 0 ) + { + LOGGER_WRITE_1("Sync request: %S", &namePtr); + RBufReadStream stream( *iBuffer ); + + CleanupClosePushL( stream ); + TRAP( ret, iPCDHandler->HandlePutSyncRequestL( namePtr8, stream )); + if ( ret ) + { + LOGGER_WRITE_1("HandlePutSyncRequestL() Leaved with %d", ret); + } + + CleanupStack::PopAndDestroy( &stream ); + } + else if ( ( typePtr.Compare( KSConPCDWBXMLObjectType ) == KErrNone) || ( typePtr.Compare( KSConPCDWBXMLObjectType2 )== KErrNone) ) { LOGGER_WRITE( "CSConPCConnSession::HandlePutMessageL() : Object type PCD " ); @@ -533,7 +574,7 @@ } CleanupStack::PopAndDestroy( data ); CleanupStack::PopAndDestroy( type ); - CleanupStack::PopAndDestroy( name ); + CleanupStack::PopAndDestroy( name8 ); LOGGER_WRITE_1( "CSConPCConnSession::HandlePutMessageL() end : Heap count : %d", User::Heap().Count() ); LOGGER_WRITE_1( "CSConPCConnSession::HandlePutMessageL() : returned %d", ret ); return ret; @@ -587,12 +628,9 @@ ret = iCSCHandler->CapabilityObject( *iBuffer ); #ifdef DEBUG_XML - RFs fs; - User::LeaveIfError(fs.Connect()); - CleanupClosePushL(fs); - + RFile file; - if ( file.Open(fs, KSConConMLDebugFile, EFileWrite ) == KErrNone ) + if ( file.Open(iFs, KSConConMLDebugFile, EFileWrite ) == KErrNone ) { RFileWriteStream fws; TInt fileSize; @@ -616,13 +654,218 @@ CleanupStack::PopAndDestroy( &fws ); } file.Close(); - CleanupStack::PopAndDestroy( &fs ); #endif } else if ( typePtr.CompareC( KSConPCDWBXMLObjectType) == KErrNone ) { - ret = HandleWBXMLGetRequestL( namePtr ); + if ( namePtr8.Find(KSCONSyncRequest) == 0 ) // 8-bit search + { + LOGGER_WRITE("Sync request"); + + RBufWriteStream stream( *iBuffer ); + + CleanupClosePushL( stream ); + + TRAP( ret, iPCDHandler->HandleGetSyncRequestL( namePtr8, stream, iChunk.MaxSize() - sizeof(TInt32) )); + if ( ret ) + { + LOGGER_WRITE_1("HandleGetSyncRequestL() Leaved with %d", ret); + } + stream.CommitL(); + CleanupStack::PopAndDestroy( &stream ); + + LOGGER_WRITE_1("iBuffer size: %d", iBuffer->Size()); + + } + else if ( namePtr.Find(KSCONReadImsi) == 0 ) // 16-bit search + { + LOGGER_WRITE("Read IMSI"); + TBuf imsi; + ret = CSconImsiReader::GetImsiL( imsi ); + + if ( ret == KErrNone ) + { + TBuf8 imsi8; + User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8(imsi8,imsi) ); + + iBuffer->ResizeL( imsi8.Length() ); + iBuffer->Write( 0, imsi8 ); + } + else + { + // Change error code more generic + ret = KErrNotFound; + } + } + else if ( namePtr.Find(KSCONReadNetworkInfo) == 0 ) // 16-bit search + { + LOGGER_WRITE("Read NetworkInfo"); + CTelephony::TRegistrationStatus regStatus; + ret = CSconImsiReader::GetNetworkStatusL( regStatus ); + + if ( ret == KErrNone ) + { + RBufWriteStream stream( *iBuffer ); + CleanupClosePushL( stream ); + stream.WriteInt8L( regStatus ); + stream.CommitL(); + CleanupStack::PopAndDestroy( &stream ); + } + else + { + // Change error code more generic + ret = KErrNotFound; + } + } + else if ( namePtr.Find(KSCONReadOviAccount) == 0 ) + { + LOGGER_WRITE("Read Ovi account"); + RBufWriteStream stream( *iBuffer ); + CleanupClosePushL( stream ); + + ret = ReadOviAccountInfoL( stream ); + stream.CommitL(); + CleanupStack::PopAndDestroy( &stream ); + + } + else if ( namePtr.Find(KSCONListPath) == 0 ) + { + LOGGER_WRITE("List path"); + // LISTP:0:pathname + if ( namePtr.Length() > KSCONListPath().Length()+2) + { + TPtrC pathname = namePtr.Mid( KSCONListPath().Length()+2 ); + + const TUint16 levelsChar = namePtr[ KSCONListPath().Length() ]; + TInt level(KErrNotFound); + if ( levelsChar >= TChar('0') ) + { + level = levelsChar - TChar('0'); + } + + RBufWriteStream stream( *iBuffer ); + CleanupClosePushL( stream ); + TRAP( ret, iFolderLister->GenerateFolderListL( stream, pathname, level )); + LOGGER_WRITE_1("GenerateFolderListL leaved with err: %d", ret); + stream.CommitL(); + CleanupStack::PopAndDestroy( &stream ); + } + else + { + ret = KErrArgument; + } + + } + else if ( namePtr.Find(KSCONReadBtInfo) == 0 ) + { + LOGGER_WRITE( "Read BT info"); + if ( !iBtEngine ) + { + iBtEngine = CSconBtEngine::NewL(); + } + RBufWriteStream stream( *iBuffer ); + CleanupClosePushL( stream ); + TRAP( ret, iBtEngine->ReadBTInfoL( stream ) ); + LOGGER_WRITE_1("ReadBTInfoL leaved with err: %d", ret); + stream.CommitL(); + CleanupStack::PopAndDestroy( &stream ); + } + else if ( namePtr.Find(KSCONSetBtPower) == 0 ) + { + LOGGER_WRITE( "Change BT Power state"); + if ( namePtr.Length() == KSCONSetBtPower().Length()+1 ) + { + const TUint16 lastChar = namePtr[ KSCONSetBtPower().Length() ]; + TBool changeBtOn; + if ( lastChar == TChar('0') ) + { + changeBtOn = EFalse; + } + else if ( lastChar == TChar('1') ) + { + changeBtOn = ETrue; + } + else + { + ret = KErrArgument; + } + + if ( !ret ) + { + if ( !iBtEngine ) + { + iBtEngine = CSconBtEngine::NewL(); + } + TInt err = iBtEngine->SetBtPowerState( changeBtOn ); + + RBufWriteStream stream( *iBuffer ); + CleanupClosePushL( stream ); + stream.WriteInt32L( err ); + stream.CommitL(); + CleanupStack::PopAndDestroy( &stream ); + } + } + else + { + ret = KErrArgument; + } + } + else if ( namePtr.Find(KSCONSetBtName) == 0 ) + { + LOGGER_WRITE( "Set BT Name"); + TPtrC btName = namePtr.Mid( KSCONSetBtName().Length() ); + TInt err = iBtEngine->SetBtName( btName ); + + RBufWriteStream stream( *iBuffer ); + CleanupClosePushL( stream ); + stream.WriteInt32L( err ); + stream.CommitL(); + CleanupStack::PopAndDestroy( &stream ); + } + else if ( namePtr.Find(KSCONSetBtAuthorized) == 0 ) + { + LOGGER_WRITE( "Set BT Authorized"); + ret = KErrArgument; + // SETBTAUTHORIZED:0:00245f8d6a26 + // 1. param = auth. state ("0"=off, "1"=true) + // 2. param = bt address (hex string) + + if ( namePtr.Length() > KSCONSetBtAuthorized().Length()+2) + { + TPtrC btAddr = namePtr.Mid( KSCONSetBtAuthorized().Length()+2 ); + + const TUint16 authStateChar = namePtr[ KSCONSetBtAuthorized().Length() ]; + TBool authorize(EFalse); + if ( authStateChar == TChar('0') ) + { + authorize = EFalse; + ret = KErrNone; + } + else if ( authStateChar == TChar('1') ) + { + authorize = ETrue; + ret = KErrNone; + } + + if ( !iBtEngine ) + { + iBtEngine = CSconBtEngine::NewL(); + } + TRAPD(err, iBtEngine->SetBtAuthorizedL( btAddr, authorize ) ); + + RBufWriteStream stream( *iBuffer ); + CleanupClosePushL( stream ); + stream.WriteInt32L( err ); + stream.CommitL(); + CleanupStack::PopAndDestroy( &stream ); + } + + } + else + { + ret = HandleWBXMLGetRequestL( namePtr ); + } } else { @@ -760,6 +1003,59 @@ return ret; } + +// ----------------------------------------------------------------------------- +// CSConPCConnSession::ReadOviAccountInfoL() +// Reads ovi account information to stream +// ----------------------------------------------------------------------------- +// +TInt CSConPCConnSession::ReadOviAccountInfoL( RWriteStream& aAccountInfoStream ) + { + TRACE_FUNC_ENTRY; + RLibrary oviaccounthandlerLib; + CleanupClosePushL( oviaccounthandlerLib ); + // Dynamically load DLL + TInt err = oviaccounthandlerLib.Load( KSconOviAccountHandlerDllName ); + if ( err ) + { + LOGGER_WRITE_1("oviaccounthandlerLib.Load err: %d", err); + err = KErrNotSupported; + } + else if( oviaccounthandlerLib.Type()[1] != KSconOviAccountHandlerDllUid ) + { + LOGGER_WRITE_1( "KSconOviAccountHandlerDllUid incorrect... (0x%08X)",oviaccounthandlerLib.Type()[1].iUid ); + err = KErrNotSupported; + } + + if ( err == KErrNone ) + { + TSConCreateCSconOviAccountHandlerFunc CreateCSconOviAccountHandlerL = + (TSConCreateCSconOviAccountHandlerFunc)oviaccounthandlerLib.Lookup(1); + + CSconOviAccountHandler* oviAccountHandler = (CSconOviAccountHandler*)CreateCSconOviAccountHandlerL(); + + TRAP(err, oviAccountHandler->GetOviAccountDetailsL( aAccountInfoStream ) ); + LOGGER_WRITE_1("GetOviAccountDetailsL err: %d", err); + + delete oviAccountHandler; + oviAccountHandler = NULL; + + if ( err ) + { + // change error code + err = KErrNotFound; + } + } + else + { + err = KErrNotSupported; + } + + CleanupStack::PopAndDestroy( &oviaccounthandlerLib ); + TRACE_FUNC_EXIT; + return err; + } + // ----------------------------------------------------------------------------- // CSConPCConnSession::HandleResetMessage() // Resets the PCCS service @@ -878,12 +1174,8 @@ #ifdef DEBUG_XML iConMLHandler->GenerateDocument( aContent ); - RFs fs; - User::LeaveIfError(fs.Connect()); - CleanupClosePushL(fs); RFile file; - - if ( file.Open(fs, KSConConMLDebugFile, EFileWrite) == KErrNone ) + if ( file.Open(iFs, KSConConMLDebugFile, EFileWrite) == KErrNone ) { RFileWriteStream fws; TInt fileSize; @@ -910,7 +1202,6 @@ CleanupStack::PopAndDestroy( &fws ); } file.Close(); - CleanupStack::PopAndDestroy( &fs ); #endif @@ -1357,6 +1648,7 @@ p && p->data; p=p->next ) { CSConDataOwner* dataOwner = new (ELeave) CSConDataOwner(); + CleanupStack::PushL( dataOwner ); if ( p->data->type ) { dataOwner->iType = TSConDOType (DesToInt( @@ -1385,7 +1677,8 @@ TInt intValue = DesToInt( p->data->transferDataType->Data() ); dataOwner->iTransDataType = static_cast (intValue); } - task->iGetDataSizeParams->iDataOwners.Append( dataOwner ); + task->iGetDataSizeParams->iDataOwners.AppendL( dataOwner ); + CleanupStack::Pop( dataOwner ); } } ret = iPCDHandler->PutTaskL( task ); @@ -1540,7 +1833,7 @@ for ( ConML_SIDListPtr_t p = aContent->sid; p && p->data; p = p->next ) { CSConDataOwner* dataOwner = new (ELeave) CSConDataOwner(); - + CleanupStack::PushL( dataOwner ); if ( p->data->type ) { dataOwner->iType = TSConDOType ( DesToInt( @@ -1571,7 +1864,8 @@ dataOwner->iPackageName, p->data->packageInfo->name->Data()); } - task->iPubFilesParams->iDataOwners.Append( dataOwner ); + task->iPubFilesParams->iDataOwners.AppendL( dataOwner ); + CleanupStack::Pop( dataOwner ); } } ret = iPCDHandler->PutTaskL( task ); @@ -1667,6 +1961,7 @@ p && p->data; p=p->next ) { CSConDataOwner* dataOwner = new (ELeave) CSConDataOwner(); + CleanupStack::PushL( dataOwner ); if ( p->data->type ) { dataOwner->iType = TSConDOType (DesToInt( @@ -1686,7 +1981,8 @@ CleanupStack::PopAndDestroy(); //DesToHashLC() } } - task->iGetDataOwnerParams->iDataOwners.Append( dataOwner ); + task->iGetDataOwnerParams->iDataOwners.AppendL( dataOwner ); + CleanupStack::Pop( dataOwner ); } } ret = iPCDHandler->PutTaskL( task ); @@ -2020,9 +2316,9 @@ if ( aResult->iApps.Count() > 0 ) { - // 5 * KMaxFileName should be enought - // ( 4 items of TFileName and uid + type + size + 6* "#" ) - HBufC8* buf = HBufC8::NewLC( 5 * KMaxFileName ); + // 6 * KMaxFileName should be enought + // ( 5 items of TFileName and uid + type + size + 7* "#" ) + HBufC8* buf = HBufC8::NewLC( 6 * KMaxFileName ); TPtr8 ptrBuf = buf->Des(); aContent->applications = new ( ELeave ) ConML_Applications_t(); @@ -2040,7 +2336,7 @@ aResult->iApps[i]->iName)); CleanupStack::PopAndDestroy(); // BufToDesLC - // create uid: UID # Type # Size # Version # Vendor # Parent app. name # + // create uid: UID # Type # Size # Version # Vendor # Parent app. name # WidgetBundleId # LOGGER_WRITE( "CSConPCConnSession::AppendListInstalledAppsResultsL() : Create Uid" ); ptrBuf.Copy( UidToDesLC( aResult->iApps[i]->iUid ) ); @@ -2068,6 +2364,13 @@ CleanupStack::PopAndDestroy(); // BufToDesLC ptrBuf.Append( KSConAppInfoSeparator ); + if (aResult->iApps[i]->iWidgetBundleId) + { + ptrBuf.Append( BufToDesLC( *aResult->iApps[i]->iWidgetBundleId ) ); + CleanupStack::PopAndDestroy(); // BufToDesLC + } + + ptrBuf.Append( KSConAppInfoSeparator ); LOGGER_WRITE( "CSConPCConnSession::AppendListInstalledAppsResultsL() : set data" ); app->data->uid = new ( ELeave ) pcdata_t(); diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/group/bld.inf Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2009-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: Build information file for project SyncServer +* +*/ + + +PRJ_EXPORTS +../rom/sconsyncserver.iby CORE_APP_LAYER_IBY_EXPORT_PATH(sconsyncserver.iby) + +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +sconsyncserver.mmp + diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/group/sconsyncserver.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/group/sconsyncserver.mmp Thu Aug 19 10:44: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: sconsyncserver mmp file +* +*/ + + +#include +#include + + +TARGET sconsyncserver.exe +TARGETTYPE exe + +// Same capabilities than in DS Ui application +CAPABILITY LocalServices ReadUserData WriteUserData ReadDeviceData WriteDeviceData NetworkServices UserEnvironment ProtServ SwEvent NetworkControl Location + +UID 0x0 0x2001A964 +VENDORID VID_DEFAULT + +EPOCSTACKSIZE 0x2000 +EPOCHEAPSIZE 0x500 0x800000 // minimum and maximum heap sizes + +SOURCEPATH ../src +SOURCE sconsyncserver.cpp +SOURCE sconsyncsession.cpp +SOURCE sconsyncrelationship.cpp +SOURCE sconasynchandler.cpp +SOURCE cscontimeout.cpp + +// common components (dataproviderinfo) +SOURCEPATH ../../../clients/syncclient/src +USERINCLUDE ../../../clients/syncclient/inc +SOURCE scondataproviderinfo.cpp + +USERINCLUDE ..\inc + +// Default system include paths for middleware layer modules. +MW_LAYER_SYSTEMINCLUDE + +DEBUGLIBRARY flogger.lib +LIBRARY euser.lib +LIBRARY efsrv.lib +LIBRARY bafl.lib +LIBRARY ecom.lib +LIBRARY estor.lib // CDictionaryFileStore +LIBRARY smldataprovider.lib +LIBRARY nsmlchangefinder.lib +LIBRARY smlstoreformat.lib +LIBRARY charconv.lib diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/inc/cscontimeout.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/inc/cscontimeout.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CCSconTimeOut header file +* +*/ + + +#ifndef CSCONTIMEOUT_H +#define CSCONTIMEOUT_H + +#include // For CActive, link against: euser.lib +#include // For RTimer, link against: euser.lib + +class MTimeOutObserver + { +public: + virtual void TimeOut() = 0; + }; + +class CCSconTimeOut : public CActive + { +public: + // Cancel and destroy + ~CCSconTimeOut(); + + // Two-phased constructor. + static CCSconTimeOut* NewL( MTimeOutObserver& aTimeOutObserver ); + +public: + // New functions + // Function for making the timeout request + void Start(TTimeIntervalMicroSeconds32 aDelay); + +private: + // C++ constructor + CCSconTimeOut( MTimeOutObserver& aTimeOutObserver ); + + // Second-phase constructor + void ConstructL(); + +private: + // From CActive + // Handle completion + void RunL(); + + // How to cancel me + void DoCancel(); + + // Override to handle leaves from RunL(). Default implementation causes + // the active scheduler to panic. + TInt RunError(TInt aError); + +private: + enum TCSconTimeOutState + { + EUninitialized, // Uninitialized + EInitialized, // Initalized + EError + // Error condition + }; + +private: + TInt iState; // State of the active object + RTimer iTimer; // Provides async timing service + MTimeOutObserver& iTimeOutObserver; + }; + +#endif // CSCONTIMEOUT_H diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/inc/debug.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,130 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Debug utility for SyncServer +* +*/ + + +#ifndef _SECON_DEBUG_H +#define _SECON_DEBUG_H + +#ifdef _DEBUG + + // File logging + #define __FLOGGING__ + + #include + #ifdef __FLOGGING__ + #include + #include + #endif + + NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { + public: + void Overflow(TDes16& /*aDes*/) {} + }; + + NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { + public: + void Overflow(TDes8& /*aDes*/) {} + }; + + _LIT( KLogDir, "SECON" ); + _LIT( KLogFile, "SeconDebug.txt" ); + + _LIT(KTracePrefix16, "[SeConSync] "); + _LIT8(KTracePrefix8, "[SeConSync] "); + _LIT8(KFuncEntryFormat8, "%S : Begin"); + _LIT8(KFuncExitFormat8, "%S : End"); + _LIT8(KFuncFormat8, "><%S"); + + const TInt KMaxLogLineLength = 512; + + // old function loggin macros + #define FLOG(a) {FPrint(a);} + #define FLOG_1(a,b) {FPrint(a,b);} + #define FLOG_2(a,b,c) {FPrint(a,b,c);} + #define FTRACE(a) {a;} + #define LOGGER_ENTERFN( name ) {TRACE_FUNC_ENTRY;} + #define LOGGER_LEAVEFN( name ) {TRACE_FUNC_EXIT;} + + #define LOGGER_WRITE( text ) {_LIT( KTemp, text ); FPrint( KTemp );} + #define LOGGER_WRITE_1( text,par1 ) {_LIT( KTemp, text ); FPrint( KTemp, par1 );} + #define LOGGER_WRITE8_1( text,par1 ) {_LIT8( KTemp, text ); FPrint( KTemp, par1 );} + #define LOGGER_WRITE_2( text,par1,par2 ) {_LIT( KTemp, text ); FPrint( KTemp, par1, par2 );} + #define LOGGER_WRITE_3( text,par1,par2,par3 ) {_LIT( KTemp, text ); FPrint( KTemp, par1, par2, par3 );} + + // New function logging macros + #define TRACE_FUNC_ENTRY {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncEntryFormat8, &ptr8);} + #define TRACE_FUNC_EXIT {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncExitFormat8, &ptr8);} + #define TRACE_FUNC {TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); FPrint(KFuncFormat8, &ptr8);} + + // Declare the FPrint function + inline void FPrint( TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); + #ifdef __FLOGGING__ + RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list ); + #endif + TBuf16 theFinalString; + theFinalString.Append(KTracePrefix16); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList(aFmt,list,&overflow); + RDebug::Print(theFinalString); + } + + // Declare the FPrint function + inline void FPrint(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); + #ifdef __FLOGGING__ + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); + #endif + TOverflowTruncate8 overflow; + TBuf8 buf8; + buf8.Append(KTracePrefix8); + buf8.AppendFormatList(aFmt, list, &overflow); + TBuf16 buf16(buf8.Length()); + buf16.Copy(buf8); + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); + } +#else + + // No loggings --> reduced code size + #define FLOG(a) + #define FLOG_1(a,b) + #define FLOG_2(a,b,c) + #define FTRACE(a) + #define LOGGER_ENTERFN( name ) + #define LOGGER_LEAVEFN( name ) + #define LOGGER_WRITE( text ) + #define LOGGER_WRITE_1( text, par1 ) + #define LOGGER_WRITE8_1( text, par1 ) + #define LOGGER_WRITE_2( text, par1, par2 ) + #define LOGGER_WRITE_3( text, par1, par2, par3 ) + #define TRACE_FUNC_ENTRY + #define TRACE_FUNC_EXIT + #define TRACE_FUNC + +#endif //_DEBUG + +#endif // SECON_DEBUG_H + +// End of file + diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/inc/logdatastoreformat.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/inc/logdatastoreformat.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,98 @@ +/* +* 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: Simple class for tracing datastore format +* +*/ + +#ifndef LOGDATASTOREFORMAT_H_ +#define LOGDATASTOREFORMAT_H_ + +// +#include "debug.h" + +NONSHARABLE_CLASS(TLogDataStoreFormat) + { + public: +#ifndef _DEBUG +// does nothing on release version +static void TLogDataStoreFormat::LogDataStoreFormatL( const TDesC& /*aLogInfo*/, const CSmlDataStoreFormat& /*aDataStoreFormat*/ ) + { + } +#else +static void TLogDataStoreFormat::LogDataStoreFormatL( const TDesC& aLogInfo, const CSmlDataStoreFormat& aDataStoreFormat ) + { + LOGGER_WRITE_1("LogDataStoreFormatL, aLogInfo: %S", &aLogInfo); + LOGGER_WRITE_1("DisplayName: %S", &aDataStoreFormat.DisplayName()); + TBool hasMaxSize = aDataStoreFormat.IsSupported( CSmlDataStoreFormat::EOptionHasMaxSize ); + TBool hasMaxItems = aDataStoreFormat.IsSupported( CSmlDataStoreFormat::EOptionHasMaxItems ); + TBool hierarcial = aDataStoreFormat.IsSupported( CSmlDataStoreFormat::EOptionHierarchial ); + LOGGER_WRITE_1("hasMaxSize: %d", (TInt)hasMaxSize); + LOGGER_WRITE_1("hasMaxItems: %d", (TInt)hasMaxItems); + LOGGER_WRITE_1("hierarcial: %d", (TInt)hierarcial); + LOGGER_WRITE_1("MimeFormatCount: %d", aDataStoreFormat.MimeFormatCount()); + for ( TInt i = 0; i < aDataStoreFormat.MimeFormatCount(); i++) + { + LOGGER_WRITE_1(" MimeFormat(%d)",i); + const CSmlMimeFormat& mimeformat = aDataStoreFormat.MimeFormat(i); + LOGGER_WRITE8_1(" MimeType: %S", &mimeformat.MimeType().DesC()); + LOGGER_WRITE8_1(" MimeVersion: %S", &mimeformat.MimeVersion().DesC()); + LOGGER_WRITE_1( " FieldLevel, bool: %d", (TInt) mimeformat.FieldLevel()); + LOGGER_WRITE_1( " PropertyCount: %d", mimeformat.PropertyCount()); + for ( TInt j=0; j +#include + +#include +#include + +#include "cscontimeout.h" + +class CSmlDataStore; +class CSconSyncRelationship; +class CSmlDataProvider; +class CNSmlDataItemUidSet; +class CSmlDataStoreFormat; + +NONSHARABLE_CLASS ( CSconAsyncHandler ): public CActive, MTimeOutObserver +{ +public: + static CSconAsyncHandler* NewL(); + ~CSconAsyncHandler(); + void HandleServiceL( const RMessage2& aMessage ); + +private: // From CActive + void RunL(); + TInt RunError(TInt aError); + void DoCancel(); + +private: // From MTimeOutObserver + void TimeOut(); + +private: + + CSconAsyncHandler(); + void ConstructL(); + + void HandleChunkMessage(); + void ListAllImplementationsL(); + void OpenStoreL(); + + void OpenItemL(); + void OpenItemCompletedL( TInt aError ); + + void CreateItemL(); + void CreateItemCompletedL( TInt aError ); + void ReplaceItemL(); + void ReplaceItemCompletedL( TInt aError ); + void MoveItemL(); + void DeleteItemL(); + void SoftDeleteItemL(); + void DeleteAllItemsL(); + void ReadParentL(); + void ReadParentCompletedL( TInt aError ); + + void HasHistoryL(); + void AddedItemsL(); + void DeletedItemsL(); + void SoftDeletedItemsL(); + void ModifiedItemsL(); + void MovedItemsL(); + //void ListChangesL(); + void ResetChangeInfoL(); + void CommitChangeInfoL(); + void CloseStore(); + + void SetSyncTimeStampL(); + void GetSyncTimeStampL(); + + void ExportStoreFormatL(); + void SetRemoteStoreFormatL(); + + void LeaveIfNoInstanceL(); + + void DoCloseStore(); + + void CleanOldStoresL(); + void CompleteRequest( TInt aError ); +private: + RChunk iChunk; + + RStringPool iStringPool; + CSmlDataStoreFormat* iStoreFormat; + CSmlDataProvider* iDataProvider; + CSmlDataStore* iDataStore; + CSconSyncRelationship* iContext; + RFs iFs; + RMessage2 iMessage; + + // for committing changes + CNSmlDataItemUidSet* iItems; + + // for opening item + TBool iFieldChange; + TInt iSize; + TInt iParent; + TBuf8<64> iMimeType; + TBuf8<64> iMimeVer; + + // for creating item + TSmlDbItemUid iNewItem; + HBufC8* iWriteData; + TBool iCommitInProgress; + + CCSconTimeOut* iTimeOut; + TBool iForceCancel; +}; + +#endif /*SCONASYNCHANDLER_H_*/ diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/inc/sconsyncclientserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/inc/sconsyncclientserver.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,64 @@ +/* +* 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: Sync Client-Server header +* +*/ + + +#ifndef SCONSYNCCLIENTSERVER_H +#define SCONSYNCCLIENTSERVER_H + +#include + +_LIT(KSconSyncServerName, "sconsyncserver"); +_LIT(KSconSyncServerExe, "sconsyncserver.exe"); + + +enum TService +{ + ESendChunkHandle, + ECancelRequest, + EListImplementations, + + EOpenStore, + EOpenItem, + ECreateItem, + EReplaceItem, + EMoveItem, + EDeleteItem, + ESoftDeleteItem, + EDeleteAllItems, + EReadParent, + + EHasHistory, + EAddedItems, + EDeletedItems, + ESoftDeletedItems, + EModifiedItems, + EMovedItems, + + //EListChanges, + EResetChangeInfo, + ECommitChangeInfo, + + ECloseStore, + ESetSyncTimeStamp, + EGetSyncTimeStamp, + EExportStoreFormat, + ESetRemoteStoreFormat, + + EMaxService // Not an actual service +}; + +#endif // SCONSYNCCLIENTSERVER_H diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/inc/sconsyncrelationship.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/inc/sconsyncrelationship.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSconSyncRelationship header +* +*/ + + +#ifndef SCONSYNCRELATIONSHIP_H_ +#define SCONSYNCRELATIONSHIP_H_ + +#include +#include +#include +#include +#include + +class CDictionaryFileStore; + +NONSHARABLE_CLASS ( CSconSyncRelationship ) : public CBase, public MSmlSyncRelationship + { +public: + /** + * Creates CSconSyncRelationship object. + * @param aFs reference to open RFs connection + * @param aRelationUid uniqueID for each server-client pair + * @return new CSconSyncRelationship object + */ + static CSconSyncRelationship* NewL( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aProviderId ); + ~CSconSyncRelationship(); + + static void SetTimeStampL( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aId ); + static void GetTimeStampL( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aId, TDateTime& aTimeStamp ); + +public: // From MSmlSyncRelationship + + /** + * Returns the unique identifier for the synchronisation relationship. + * + * @return A unique identifier for the sync relationship. + */ + TSmlSyncTaskKey SyncTaskKey() const; + + /** + * Opens a specified stream for reading, and places an item on the cleanup stack to close it. + * + * @param aReadStream On return, an open read stream + * @param aStreamUid The UID of the stream to open for reading. + */ + void OpenReadStreamLC(RReadStream& aReadStream, TUid aStreamUid); + + /** + * Opens the specified stream, or creates a new one if it does not exist, and places an item on the cleanup stack to close it. + * + * @param aWriteStream On return, an open write stream + * @param aStreamUid The UID of the stream to open or create + */ + void OpenWriteStreamLC(RWriteStream& aWriteStream, TUid aStreamUid); + + /** + * Tests if the specified stream identified exists in the store. + * + * @param aStreamUid The stream UID + * @return Non-zero if the stream exists, otherwise EFalse. + */ + TBool IsStreamPresentL(TUid aStreamUid) const; + +private: + CSconSyncRelationship( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aProviderId ); + void ConstructL(); + +private: + + CDictionaryFileStore* iDictionaryStore; + RFs& iFs; + TUid iID; + TSmlDataProviderId iProviderId; + }; + +#endif /*SCONSYNCRELATIONSHIP_H_*/ diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/inc/sconsyncserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/inc/sconsyncserver.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSconSyncServer header +* +*/ + + +#ifndef __SCONSYNCSERVER_H__ +#define __SCONSYNCSERVER_H__ + +#include + +class CSconSyncServer : public CPolicyServer +{ +public: + static CSconSyncServer* NewL(); + static CSconSyncServer* NewLC(); + virtual ~CSconSyncServer(); + + void AddSession(); + void RemoveSession(); + +private: + CSconSyncServer(); + void ConstructL(); + + CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; + TInt RunError(TInt aError); + +private: + TInt iSessionCount; + +}; + +#endif // __SCONSYNCSERVER_H__ \ No newline at end of file diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/inc/sconsyncsession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/inc/sconsyncsession.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSconSyncSession header +* +*/ + + +#ifndef __SCONSYNCSESSION_H__ +#define __SCONSYNCSESSION_H__ + +#include + + +class CSconSyncServer; +class CSconAsyncHandler; + +class CSconSyncSession : public CSession2 + { +public: + static CSconSyncSession* NewL(); + + void CreateL(); + +private: + CSconSyncSession(); + ~CSconSyncSession(); + void ConstructL(); + + CSconSyncServer& Server(); + void ServiceL(const RMessage2& aMessage); + +private: + CSconAsyncHandler* iAsyncHandler; + }; + +#endif // __SCONSYNCSESSION_H__ diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/rom/sconsyncserver.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/rom/sconsyncserver.iby Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,26 @@ +/* +* 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: IBY file for SconSyncServer +* +*/ + +#ifndef _SCONSYNCSERVER_IBY_ +#define _SCONSYNCSERVER_IBY_ + +#include + +//file content +file=ABI_DIR\BUILD_DIR\sconsyncserver.exe PROGRAMS_DIR\sconsyncserver.exe + +#endif diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/src/cscontimeout.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/src/cscontimeout.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,85 @@ +/* +* 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: CCSconTimeOut implementation +* +*/ + +#include "cscontimeout.h" + +CCSconTimeOut::CCSconTimeOut( MTimeOutObserver& aTimeOutObserver ) : + CActive(EPriorityStandard), // Standard priority + iTimeOutObserver(aTimeOutObserver) + { + } + + +CCSconTimeOut* CCSconTimeOut::NewL( MTimeOutObserver& aTimeOutObserver ) + { + CCSconTimeOut* self = new (ELeave) CCSconTimeOut( aTimeOutObserver ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +void CCSconTimeOut::ConstructL() + { + User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer + CActiveScheduler::Add(this); // Add to scheduler + } + +CCSconTimeOut::~CCSconTimeOut() + { + Cancel(); // Cancel any request, if outstanding + iTimer.Close(); // Destroy the RTimer object + // Delete instance variables if any + } + +void CCSconTimeOut::DoCancel() + { + iTimer.Cancel(); + } + +void CCSconTimeOut::Start(TTimeIntervalMicroSeconds32 aDelay) + { + Cancel(); // Cancel any request, just to be sure + iState = EUninitialized; + iTimer.After(iStatus, aDelay); // Set for later + SetActive(); // Tell scheduler a request is active + } + +void CCSconTimeOut::RunL() + { + /*if (iState == EUninitialized) + { + // Do something the first time RunL() is called + iState = EInitialized; + } + else if (iState != EError) + { + // Do something + } + iTimer.After(iStatus, 1000000); // Set for 1 sec later + SetActive(); // Tell scheduler a request is active*/ + if ( iState == KErrNone ) + { + iTimeOutObserver.TimeOut(); + } + + } + +TInt CCSconTimeOut::RunError(TInt aError) + { + return aError; + } diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/src/sconasynchandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/src/sconasynchandler.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,1179 @@ +/* +* 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: CSconAsyncHandler implementation +* +*/ + + +#include "sconasynchandler.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "sconsyncclientserver.h" +#include "sconsyncrelationship.h" +#include "scondataproviderinfo.h" +#include "debug.h" +#include "logdatastoreformat.h" + +// Data Store interface implementation Uid. +// Load all plugins with this uid. +const TUid KDSEcomIFUid = {0x101F4D3A}; + +const TInt KDefaultExpandSize = 1024; + +// one store per computer, max store count. +const TInt KMaxStoresCount = 10; + +const TInt KDefaultTimeOutInMicroSeconds = 30 * 1000000; // 30 seconds +const TInt KDeleteAllTimeOutInMicroSeconds = 300 * 1000000; // 5 minutes +const TInt KOpenStoreTimeOutInMicroSeconds = 180 * 1000000; // 180 seconds + +CSconAsyncHandler::~CSconAsyncHandler() + { + TRACE_FUNC_ENTRY; + Cancel(); + DoCloseStore(); + delete iItems; + delete iWriteData; + delete iDataStore; + delete iDataProvider; + delete iContext; + delete iStoreFormat; + iStringPool.Close(); + iFs.Close(); + REComSession::FinalClose(); + iChunk.Close(); + delete iTimeOut; + TRACE_FUNC_EXIT; + } + +CSconAsyncHandler::CSconAsyncHandler(): CActive( EPriorityStandard ) + { + TRACE_FUNC; + CActiveScheduler::Add( this ); + } + +CSconAsyncHandler* CSconAsyncHandler::NewL() + { + TRACE_FUNC; + CSconAsyncHandler* self = new(ELeave) CSconAsyncHandler(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +void CSconAsyncHandler::ConstructL() + { + TRACE_FUNC; + User::LeaveIfError( iFs.Connect() ); + TInt err = iFs.CreatePrivatePath( EDriveC ); + LOGGER_WRITE_1("CreatePrivatePath err: %d", err); + iStringPool.OpenL(); + iTimeOut = CCSconTimeOut::NewL( *this ); + } + +// ----------------------------------------------------------------------------- +// CSconAsyncHandler::HandleServiceL() +// Handles the client request +// ----------------------------------------------------------------------------- +// +void CSconAsyncHandler::HandleServiceL( const RMessage2& aMessage ) + { + TRACE_FUNC_ENTRY; + if ( aMessage.Function() == ECancelRequest ) + { + LOGGER_WRITE("ECancelRequest"); + if ( IsActive() ) + { + Cancel(); + LOGGER_WRITE("iMessage.Complete( KErrCancel )"); + CompleteRequest( KErrCancel ); + } + + LOGGER_WRITE("aMessage.Complete( KErrNone )"); + aMessage.Complete( KErrNone ); + TRACE_FUNC_EXIT; + return; + } + + iTimeOut->Start( KDefaultTimeOutInMicroSeconds ); + + iMessage = aMessage; + switch ( aMessage.Function() ) + { + case ESendChunkHandle: + LOGGER_WRITE( "CSconSyncSession::ServiceL() : ESendChunkHandle" ); + HandleChunkMessage(); + break; + + case EListImplementations: + LOGGER_WRITE( "CSconSyncSession::ServiceL() : EListImplementations" ); + ListAllImplementationsL(); + break; + + case EOpenStore: + LOGGER_WRITE( "CSconSyncSession::ServiceL() : EOpenStore" ); + iTimeOut->Start( KOpenStoreTimeOutInMicroSeconds ); + OpenStoreL(); + break; + + case EOpenItem: + OpenItemL(); + break; + case ECreateItem: + CreateItemL(); + break; + case EReplaceItem: + ReplaceItemL(); + break; + case EMoveItem: + MoveItemL(); + break; + case EDeleteItem: + DeleteItemL(); + break; + case ESoftDeleteItem: + SoftDeleteItemL(); + break; + case EDeleteAllItems: + iTimeOut->Start( KDeleteAllTimeOutInMicroSeconds ); + DeleteAllItemsL(); + break; + case EReadParent: + ReadParentL(); + break; + + case EHasHistory: + HasHistoryL(); + break; + case EAddedItems: + AddedItemsL(); + break; + case EDeletedItems: + DeletedItemsL(); + break; + case ESoftDeletedItems: + SoftDeletedItemsL(); + break; + case EModifiedItems: + ModifiedItemsL(); + break; + case EMovedItems: + MovedItemsL(); + break; + case EResetChangeInfo: + ResetChangeInfoL(); + break; + case ECommitChangeInfo: + CommitChangeInfoL(); + break; + case ECloseStore: + CloseStore(); + break; + case ESetSyncTimeStamp: + SetSyncTimeStampL(); + break; + case EGetSyncTimeStamp: + GetSyncTimeStampL(); + break; + case EExportStoreFormat: + ExportStoreFormatL(); + break; + case ESetRemoteStoreFormat: + SetRemoteStoreFormatL(); + break; + + default: + aMessage.Complete(KErrNotSupported); + break; + } + TRACE_FUNC_EXIT; + } + + +void CSconAsyncHandler::RunL() + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("iStatus.Int(): %d", iStatus.Int()); + switch ( iMessage.Function() ) + { + case EOpenStore: + LOGGER_WRITE( "CSconAsyncHandler::RunL() : EOpenStore" ); + CompleteRequest( iStatus.Int() ); + break; + + case EOpenItem: + LOGGER_WRITE( "CSconAsyncHandler::RunL() : EOpenItem" ); + OpenItemCompletedL( iStatus.Int() ); + break; + + case ECreateItem: + LOGGER_WRITE( "CSconAsyncHandler::RunL() : ECreateItem" ); + if (!iCommitInProgress) + { + // Write data to item + CreateItemCompletedL( iStatus.Int() ); + } + else + { + // commit is done, all ready + LOGGER_WRITE( "CSconAsyncHandler::RunL() : ECreateItem, commit done" ); + TPckg pckg(iNewItem); + iMessage.WriteL( 0, pckg, 0); + CompleteRequest( iStatus.Int() ); + } + break; + + case EReplaceItem: + LOGGER_WRITE( "CSconAsyncHandler::RunL() : EReplaceItem" ); + if (!iCommitInProgress) + { + // Write data to item + ReplaceItemCompletedL( iStatus.Int() ); + } + else + { + // commit is done, all ready + LOGGER_WRITE( "CSconAsyncHandler::RunL() : EReplaceItem, commit done" ); + CompleteRequest( iStatus.Int() ); + } + break; + + case EMoveItem: + LOGGER_WRITE( "CSconAsyncHandler::RunL() : EMoveItem" ); + CompleteRequest( iStatus.Int() ); + break; + + case EDeleteItem: + LOGGER_WRITE( "CSconAsyncHandler::RunL() : EDeleteItem" ); + CompleteRequest( iStatus.Int() ); + break; + + case ESoftDeleteItem: + LOGGER_WRITE( "CSconAsyncHandler::RunL() : ESoftDeleteItem" ); + CompleteRequest( iStatus.Int() ); + break; + + case EDeleteAllItems: + LOGGER_WRITE( "CSconAsyncHandler::RunL() : EDeleteAllItems" ); + CompleteRequest( iStatus.Int() ); + break; + + case EReadParent: + LOGGER_WRITE( "CSconAsyncHandler::RunL() : EReadParent" ); + ReadParentCompletedL( iStatus.Int() ); + break; + + case EResetChangeInfo: + LOGGER_WRITE( "CSconAsyncHandler::RunL() : EResetChangeInfo" ); + CompleteRequest( iStatus.Int() ); + break; + + case ECommitChangeInfo: + LOGGER_WRITE( "CSconAsyncHandler::RunL() : ECommitChangeInfo" ); + delete iItems; + iItems = NULL; + CompleteRequest( iStatus.Int() ); + break; + + default: + LOGGER_WRITE("Not asynchronous function") + CompleteRequest( KErrNotSupported ); + break; + } + TRACE_FUNC_EXIT; + } + +TInt CSconAsyncHandler::RunError(TInt aError) + { + LOGGER_WRITE_1("CSconAsyncHandler::RunError() aError: %d", aError); + delete iItems; + iItems = NULL; + delete iWriteData; + iWriteData = NULL; + + if ( IsActive() ) + { + LOGGER_WRITE("IsActive"); + //iDataStore->CancelRequest(); + Cancel(); + } + + if ( iDataStore && iMessage.Function() == EOpenItem ) + { + LOGGER_WRITE( "CSconAsyncHandler::RunError() : EOpenItem" ); + iDataStore->CloseItem(); + } + + CompleteRequest( aError ); + aError = KErrNone; + LOGGER_WRITE_1("CSconAsyncHandler::RunError() : Return %d", aError); + return aError; + //return KErrNone;//aError; + } + +void CSconAsyncHandler::DoCancel() + { + TRACE_FUNC_ENTRY; + iDataStore->CancelRequest(); + iTimeOut->Cancel(); + + if ( iStatus == KRequestPending ) + { + LOGGER_WRITE( "iStatus == KRequestPending" ); + } + + if ( iDataStore && iMessage.Function() == EOpenItem ) + { + LOGGER_WRITE( "CSconAsyncHandler::RunError() : EOpenItem" ); + iDataStore->CloseItem(); + } + + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::TimeOut() + { + TRACE_FUNC_ENTRY; + if ( IsActive() ) + { + Cancel(); + CompleteRequest( KErrCancel ); + } + TRACE_FUNC_EXIT; + } + + +void CSconAsyncHandler::HandleChunkMessage() + { + TRACE_FUNC_ENTRY; + TInt ret ( KErrNone ); + + ret = iChunk.Open( iMessage, 0, EFalse ); + + LOGGER_WRITE_1( "CSconAsyncHandler::HandleChunkMessageL() : ret %d", ret ); + CompleteRequest( ret ); + } + + + +void CSconAsyncHandler::ListAllImplementationsL() + { + TRACE_FUNC_ENTRY; + + RImplInfoPtrArray implInfoArray; + CleanupResetAndDestroyPushL( implInfoArray ); + REComSession::ListImplementationsL( KDSEcomIFUid, implInfoArray ); + + const TInt KDataproviderInfoSize = 250; // 250 bytes should be enought + TInt requiredSize = implInfoArray.Count() * KDataproviderInfoSize; + if ( iChunk.Size() < requiredSize ) + { + User::LeaveIfError( iChunk.Adjust( requiredSize ) ); + } + + RMemWriteStream stream ( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( stream ); + + RSconDataProviderInfoArray dpInfoArray; + CleanupResetAndDestroyPushL( dpInfoArray ); + + // Collect information from dataproviders + for ( TInt i=0; i < implInfoArray.Count(); i++ ) + { + LOGGER_WRITE_1("implInfoArray: %d",i); + CImplementationInformation& implInfo = *implInfoArray[i]; + + CSmlDataProvider* dp(NULL); + TRAPD( err, dp = CSmlDataProvider::NewL( implInfo.ImplementationUid().iUid ) ); + LOGGER_WRITE_2("CSmlDataProvider::NewL, uid(0x%08x) err: %d",implInfo.ImplementationUid().iUid, err ); + if ( !err ) + { + CleanupStack::PushL( dp ); + + CSconDataproviderInfo *dpInfo = CSconDataproviderInfo::NewL(); + CleanupStack::PushL( dpInfo ); + + dpInfo->SetImplementationUid( implInfo.ImplementationUid() ); + LOGGER_WRITE_1("ImplementationUid: 0x%08x", implInfo.ImplementationUid().iUid ); + dpInfo->SetDisplayNameL( implInfo.DisplayName() ); + LOGGER_WRITE_1("DisplayName: %S", &implInfo.DisplayName() ); + + dpInfo->SetDefaultStoreL( dp->DefaultStoreL() ); + LOGGER_WRITE_1("DefaultStoreL: %S", &dp->DefaultStoreL() ); + CDesCArray* stores = dp->ListStoresLC(); + dpInfo->SetStoresL( *stores ); + CleanupStack::PopAndDestroy( stores ); + + dpInfoArray.AppendL( dpInfo ); + CleanupStack::Pop( dpInfo ); + + CleanupStack::PopAndDestroy( dp ); + } + } + + // Wrtie to stream + stream.WriteUint16L( dpInfoArray.Count() ); + for ( TInt i = 0; i < dpInfoArray.Count(); i++ ) + { + CSconDataproviderInfo& dpInfo = *dpInfoArray[i]; + dpInfo.ExternalizeL( stream ); + } + + stream.CommitL(); + + CleanupStack::PopAndDestroy( &dpInfoArray ); + CleanupStack::PopAndDestroy( &stream ); + CleanupStack::PopAndDestroy( &implInfoArray ); + + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::OpenStoreL() + { + TRACE_FUNC_ENTRY; + if ( iDataStore ) + { + LOGGER_WRITE("Warning: Previous DataStore was not closed properly."); + DoCloseStore(); + } + + // copy data from the chunk + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + + TSmlDataProviderId providerId = readStream.ReadUint32L(); + LOGGER_WRITE_1("providerId: 0x%08x", providerId); + + TInt len = readStream.ReadUint32L(); + HBufC* storeName = HBufC::NewLC(len); + TPtr storeNamePtr = storeName->Des(); + readStream.ReadL(storeNamePtr, len); + LOGGER_WRITE_1("storeName: %S", &storeNamePtr); + + TInt contextUid = readStream.ReadUint32L(); + + LOGGER_WRITE_1("contextIdentifier: 0x%08x", contextUid); + + LOGGER_WRITE("Open provider"); + delete iDataProvider; + iDataProvider = NULL; + iDataProvider = CSmlDataProvider::NewL( providerId ); + + delete iContext; + iContext = NULL; + + delete iStoreFormat; + iStoreFormat = NULL; + + LOGGER_WRITE("Create context"); + iContext = CSconSyncRelationship::NewL( iFs, TUid::Uid(contextUid), providerId ); + + + LOGGER_WRITE("Create NewStoreInstanceLC"); + iDataStore = iDataProvider->NewStoreInstanceLC(); + CleanupStack::Pop( iDataStore ); + + SetActive(); + iStatus = KRequestPending; + LOGGER_WRITE("OpenL"); + TRAPD(err, iDataStore->OpenL(storeNamePtr,*iContext, iStatus)); + if ( err ) + { + // we are on active state, call request completed (RunL) + LOGGER_WRITE_1("iDataStore->OpenL leaved with err: %d", err); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, err ); + } + + CleanupStack::PopAndDestroy( storeName ); + CleanupStack::PopAndDestroy( &readStream ); + + TRACE_FUNC_EXIT; + } + + +void CSconAsyncHandler::OpenItemL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + if ( IsActive() ) + { + LOGGER_WRITE("Was still in Active"); + Cancel(); + } + + TSmlDbItemUid itemUid = iMessage.Int0(); + LOGGER_WRITE_1("Open item: %d", itemUid); + + // set default values + iFieldChange = EFalse; + iSize = 0; + iParent = 0; + iMimeType.Copy(KNullDesC); + iMimeVer.Copy(KNullDesC); + + SetActive(); + LOGGER_WRITE("iDataStore->OpenItemL"); + iStatus = KRequestPending; + TRAPD( err, iDataStore->OpenItemL(itemUid,iFieldChange,iSize,iParent,iMimeType,iMimeVer,iStatus)); + if ( err ) + { + // we are on active state, call request completed (RunL) + LOGGER_WRITE_1("iDataStore->OpenItemL leaved with err: %d", err); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, err ); + } + + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::OpenItemCompletedL( TInt aError ) + { + TRACE_FUNC_ENTRY; + // item opened, now read it + if ( aError ) + { + CompleteRequest( aError ); + return; + } + LeaveIfNoInstanceL(); + + LOGGER_WRITE_1("item size: %d", iSize); + + TInt totalObjectSize( 0 ); + totalObjectSize+= sizeof(TInt32); // data length + totalObjectSize+= iSize; // data + totalObjectSize+= sizeof(TInt8); // iFieldChange + totalObjectSize+= sizeof(TInt32); // iParent + totalObjectSize+= sizeof(TInt32); // iMimeType + totalObjectSize+= iMimeType.Length(); // iMimeType + totalObjectSize+= sizeof(TInt32); // iMimeVer + totalObjectSize+= iMimeVer.Length(); // iMimeType + + LOGGER_WRITE_1("iChunk.Size(): %d", iChunk.Size()); + LOGGER_WRITE_1("iChunk.MaxSize(): %d", iChunk.MaxSize()); + LOGGER_WRITE_1("totalObjectSize: %d", totalObjectSize); + + if ( iChunk.Size() < totalObjectSize ) + { + LOGGER_WRITE("adjust chunk"); + TInt err = iChunk.Adjust( totalObjectSize ); + LOGGER_WRITE_1("Chunk.Adjust err: %d", err); + User::LeaveIfError( err ); + } + LOGGER_WRITE_1("new Chunk size: %d", iChunk.Size()); + LOGGER_WRITE_1("new ChunkMaxSize(): %d", iChunk.MaxSize()); + RMemWriteStream stream ( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( stream ); + + LOGGER_WRITE("ReadItemL"); + HBufC8* tempBuf = HBufC8::NewLC(iSize); + TPtr8 tempPtr = tempBuf->Des(); + + TUint8* ptr = (TUint8*) tempPtr.Ptr(); + + TPtr8 tempPtr2( ptr, 0, iSize ); + LOGGER_WRITE_1( "tempPtr2.Size(): %d", tempPtr2.Size()); + iDataStore->ReadItemL( tempPtr2 ); + LOGGER_WRITE("ReadItemL -ok"); + + LOGGER_WRITE_1("readed Length: %d", tempPtr2.Length() ); + LOGGER_WRITE_1("readed Size: %d", tempPtr2.Size() ); + + LOGGER_WRITE8_1("iMimeType: %S", &iMimeType ); + LOGGER_WRITE_1("iMimeType.Length(): %d", iMimeType.Length() ); + LOGGER_WRITE_1("iMimeType Size: %d", iMimeType.Size() ); + + LOGGER_WRITE8_1("iMimeVer: %S", &iMimeVer ); + LOGGER_WRITE_1("iMimeVer.Length(): %d", iMimeVer.Length() ); + LOGGER_WRITE_1("iMimeVer Size: %d", iMimeVer.Size() ); + + iDataStore->CloseItem(); + LOGGER_WRITE("Write to chunk"); + stream.WriteInt32L( tempPtr2.Length() ); + stream.WriteL( tempPtr2 ); + CleanupStack::PopAndDestroy( tempBuf ); + + stream.WriteInt8L( (TInt)iFieldChange ); + stream.WriteInt32L( iParent ); + stream.WriteInt32L( iMimeType.Length() ); + stream.WriteL( iMimeType ); + stream.WriteInt32L( iMimeVer.Length() ); + stream.WriteL( iMimeVer ); + + stream.CommitL(); + LOGGER_WRITE("Writed ok"); + CleanupStack::PopAndDestroy( &stream ); + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::CreateItemL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + iCommitInProgress = EFalse; + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + + TSmlDbItemUid parent = readStream.ReadUint32L(); + TInt len = readStream.ReadUint32L(); + readStream.ReadL(iMimeType, len); + len = readStream.ReadUint32L(); + readStream.ReadL(iMimeVer, len); + len = readStream.ReadUint32L(); + delete iWriteData; + iWriteData = NULL; + iWriteData = HBufC8::New(len); + TPtr8 dataPtr = iWriteData->Des(); + readStream.ReadL(dataPtr, len); + CleanupStack::PopAndDestroy( &readStream ); + SetActive(); + iStatus = KRequestPending; + TRAPD(err, iDataStore->CreateItemL( iNewItem, dataPtr.Size(), parent, iMimeType, iMimeVer, iStatus )); + if ( err ) + { + // we are on active state, call request completed (RunL) + LOGGER_WRITE_1("iDataStore->CreateItemL leaved with err: %d", err); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, err ); + } + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::CreateItemCompletedL( TInt aError ) + { + TRACE_FUNC_ENTRY; + User::LeaveIfError( aError ); + LeaveIfNoInstanceL(); + // CreateItem completed, now we must write the data to the created item and commit it. + + iDataStore->WriteItemL( iWriteData->Des() ); + delete iWriteData; + iWriteData = NULL; + SetActive(); + iStatus = KRequestPending; + TRAPD(err, iDataStore->CommitItemL( iStatus )); + if ( err ) + { + // we are on active state, call request completed (RunL) + LOGGER_WRITE_1("iDataStore->CommitItemL leaved with err: %d", err); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, err ); + } + iCommitInProgress = ETrue; + + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::ReplaceItemL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + + iCommitInProgress = EFalse; + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + + TSmlDbItemUid uid = readStream.ReadUint32L(); + TSmlDbItemUid parent = readStream.ReadUint32L(); + TBool fieldChange = readStream.ReadUint8L(); + TInt len = readStream.ReadUint32L(); + delete iWriteData; + iWriteData = NULL; + iWriteData = HBufC8::New(len); + TPtr8 dataPtr = iWriteData->Des(); + readStream.ReadL(dataPtr, len); + + CleanupStack::PopAndDestroy( &readStream ); + SetActive(); + iStatus = KRequestPending; + TRAPD(err,iDataStore->ReplaceItemL( uid,dataPtr.Size(),parent,fieldChange, iStatus )); + if ( err ) + { + // we are on active state, call request completed (RunL) + LOGGER_WRITE_1("iDataStore->CommitItemL leaved with err: %d", err); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, err ); + } + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::ReplaceItemCompletedL( TInt aError ) + { + TRACE_FUNC_ENTRY; + User::LeaveIfError( aError ); + LeaveIfNoInstanceL(); + // CreateItem completed, now we must write the data to the created item and commit it. + + iDataStore->WriteItemL( iWriteData->Des() ); + delete iWriteData; + iWriteData = NULL; + + SetActive(); + iStatus = KRequestPending; + TRAPD(err, iDataStore->CommitItemL( iStatus )); + if ( err ) + { + // we are on active state, call request completed (RunL) + LOGGER_WRITE_1("iDataStore->CommitItemL leaved with err: %d", err); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, err ); + } + iCommitInProgress = ETrue; + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::MoveItemL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + TSmlDbItemUid uid = iMessage.Int0(); + TSmlDbItemUid newParent = iMessage.Int1(); + LOGGER_WRITE_1( "uid: %d", uid ); + LOGGER_WRITE_1( "newParent: %d", newParent ); + + SetActive(); + iStatus = KRequestPending; + TRAPD(err, iDataStore->MoveItemL( uid, newParent, iStatus )); + if ( err ) + { + // we are on active state, call request completed (RunL) + LOGGER_WRITE_1("iDataStore->MoveItemL leaved with err: %d", err); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, err ); + } + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::DeleteItemL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + + TSmlDbItemUid uid = iMessage.Int0(); + LOGGER_WRITE_1( "uid: %d", uid ); + + SetActive(); + iStatus = KRequestPending; + TRAPD(err, iDataStore->DeleteItemL( uid, iStatus )); + if ( err ) + { + // we are on active state, call request completed (RunL) + LOGGER_WRITE_1("iDataStore->DeleteItemL leaved with err: %d", err); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, err ); + } + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::SoftDeleteItemL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + + TSmlDbItemUid uid = iMessage.Int0(); + LOGGER_WRITE_1( "uid: %d", uid ); + + SetActive(); + iStatus = KRequestPending; + TRAPD(err, iDataStore->SoftDeleteItemL( uid, iStatus )); + if ( err ) + { + // we are on active state, call request completed (RunL) + LOGGER_WRITE_1("iDataStore->SoftDeleteItemL leaved with err: %d", err); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, err ); + } + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::DeleteAllItemsL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + + SetActive(); + iStatus = KRequestPending; + TRAPD(err, iDataStore->DeleteAllItemsL( iStatus )); + if ( err ) + { + // we are on active state, call request completed (RunL) + LOGGER_WRITE_1("iDataStore->DeleteAllItemsL leaved with err: %d", err); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, err ); + } + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::ReadParentL() + { + TRACE_FUNC_ENTRY; + OpenItemL(); + + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::ReadParentCompletedL( TInt aError ) + { + TRACE_FUNC_ENTRY; + // item opened, now read it + if ( aError ) + { + CompleteRequest( aError ); + return; + } + LeaveIfNoInstanceL(); + + iDataStore->CloseItem(); + + TPckg pckg(iParent); + iMessage.WriteL( 1, pckg, 0); + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::HasHistoryL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + TBool hasHistory = iDataStore->HasSyncHistory(); + + TPckgC pckg(hasHistory); + iMessage.WriteL( 0, pckg, 0); + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::AddedItemsL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + const MSmlDataItemUidSet& items = iDataStore->AddedItems(); + + RMemWriteStream stream ( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( stream ); + items.ExternalizeL( stream ); + CleanupStack::PopAndDestroy( &stream ); + + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::DeletedItemsL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + const MSmlDataItemUidSet& items = iDataStore->DeletedItems(); + + RMemWriteStream stream ( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( stream ); + items.ExternalizeL( stream ); + CleanupStack::PopAndDestroy( &stream ); + + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::SoftDeletedItemsL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + const MSmlDataItemUidSet& items = iDataStore->SoftDeletedItems(); + + RMemWriteStream stream ( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( stream ); + items.ExternalizeL( stream ); + CleanupStack::PopAndDestroy( &stream ); + + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::ModifiedItemsL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + const MSmlDataItemUidSet& items = iDataStore->ModifiedItems(); + + RMemWriteStream stream ( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( stream ); + items.ExternalizeL( stream ); + CleanupStack::PopAndDestroy( &stream ); + + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::MovedItemsL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + const MSmlDataItemUidSet& items = iDataStore->MovedItems(); + + RMemWriteStream stream ( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( stream ); + items.ExternalizeL( stream ); + CleanupStack::PopAndDestroy( &stream ); + + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::ResetChangeInfoL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + SetActive(); + iStatus = KRequestPending; + TRAPD(err, iDataStore->ResetChangeInfoL( iStatus )); + if ( err ) + { + // we are on active state, call request completed (RunL) + LOGGER_WRITE_1("iDataStore->ResetChangeInfoL leaved with err: %d", err); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, err ); + } + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::CommitChangeInfoL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + + if ( iItems ) + { + delete iItems; + iItems = NULL; + } + iItems = new (ELeave) CNSmlDataItemUidSet(); + iItems->InternalizeL( readStream ); + + CleanupStack::PopAndDestroy( &readStream ); + + SetActive(); + iStatus = KRequestPending; + TRAPD(err, iDataStore->CommitChangeInfoL( iStatus, *iItems )); + if ( err ) + { + // we are on active state, call request completed (RunL) + LOGGER_WRITE_1("iDataStore->CommitChangeInfoL leaved with err: %d", err); + TRequestStatus* status = &iStatus; + User::RequestComplete( status, err ); + } + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::CloseStore() + { + TRACE_FUNC_ENTRY; + DoCloseStore(); + REComSession::FinalClose(); + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::SetSyncTimeStampL() + { + TRACE_FUNC_ENTRY; + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + TInt relationId = readStream.ReadInt32L(); + TInt providerId = readStream.ReadInt32L(); + CleanupStack::PopAndDestroy( &readStream ); + + CSconSyncRelationship::SetTimeStampL( iFs, TUid::Uid(relationId), providerId); + + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::GetSyncTimeStampL() + { + TRACE_FUNC_ENTRY; + TInt providerId = iMessage.Int0(); + TInt relationId = iMessage.Int1(); + + TDateTime time; + CSconSyncRelationship::GetTimeStampL( iFs, TUid::Uid(relationId), providerId, time); + + // write timestamp + TPckgC timeBuf(time); + iMessage.WriteL( 2, timeBuf, 0); + + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::ExportStoreFormatL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + if ( !iDataProvider ) + { + User::Leave( KErrNotReady ); + } + CBufFlat* buffer = CBufFlat::NewL( KDefaultExpandSize ); + CleanupStack::PushL( buffer ); + RBufWriteStream stream( *buffer ); + CleanupClosePushL( stream ); + + const CSmlDataStoreFormat& storeFormat = iDataProvider->StoreFormatL(); + TRAP_IGNORE( TLogDataStoreFormat::LogDataStoreFormatL( _L("iDataProvider->StoreFormatL()"), storeFormat )); + + storeFormat.ExternalizeL( stream ); + + stream.CommitL(); + CleanupStack::PopAndDestroy( &stream ); + buffer->Compress(); + + RMemWriteStream chunkStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( chunkStream ); + + chunkStream.WriteInt32L( buffer->Size() ); + chunkStream.WriteL( buffer->Ptr(0), buffer->Size()); + chunkStream.CommitL(); + CleanupStack::PopAndDestroy( &chunkStream ); + + CleanupStack::PopAndDestroy( buffer ); + + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::SetRemoteStoreFormatL() + { + TRACE_FUNC_ENTRY; + LeaveIfNoInstanceL(); + + RMemReadStream readStream( iChunk.Base(), iChunk.Size() ); + CleanupClosePushL( readStream ); + + if ( iStoreFormat ) + { + delete iStoreFormat; + iStoreFormat = NULL; + } + iStoreFormat = CSmlDataStoreFormat::NewLC( iStringPool, readStream); + CleanupStack::Pop( iStoreFormat ); + TRAP_IGNORE( TLogDataStoreFormat::LogDataStoreFormatL( _L("iDataProvider->SetRemoteStoreFormatL()"), *iStoreFormat )); + iDataStore->SetRemoteStoreFormatL( *iStoreFormat ); + + CleanupStack::PopAndDestroy( &readStream ); + + CompleteRequest( KErrNone ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::LeaveIfNoInstanceL() + { + if ( !iDataStore ) + { + LOGGER_WRITE("DataStore instance was not ready, leaving KErrNotReady"); + User::Leave( KErrNotReady ); + } + } + +void CSconAsyncHandler::DoCloseStore() + { + TRACE_FUNC_ENTRY; + delete iItems; + iItems = NULL; + delete iWriteData; + iWriteData = NULL; + if ( iDataProvider && iContext ) + { + TInt providerId = iDataProvider->Identifier(); + TInt contextId = iContext->SyncTaskKey(); + TRAP_IGNORE( CSconSyncRelationship::SetTimeStampL( iFs, TUid::Uid(contextId), providerId) ); + } + delete iDataStore; + iDataStore = NULL; + delete iDataProvider; + iDataProvider = NULL; + delete iContext; + iContext = NULL; + delete iStoreFormat; + iStoreFormat = NULL; + + CleanOldStoresL(); + + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::CleanOldStoresL() + { + TRACE_FUNC_ENTRY; + TFileName path; + User::LeaveIfError( iFs.PrivatePath( path ) ); + CDir* dir; + iFs.GetDir( path, KEntryAttNormal, ESortByDate, dir ); + CleanupStack::PushL( dir ); + TInt storesCount(0); + LOGGER_WRITE_1("count: %d", dir->Count() ); + for ( TInt i=dir->Count()-1; i >= 0; i-- ) + { + LOGGER_WRITE_1("dir[%d]", i); + TEntry entry = (*dir)[i]; + LOGGER_WRITE_1("file: %S", &entry.iName); + _LIT(KContextStoreName, "contextstore"); + _LIT(KTimeStoreName, "timestore"); + if ( entry.iName.Find(KContextStoreName) == 0 ) + { + storesCount++; + LOGGER_WRITE_1("storeNro: %d", storesCount); +#ifdef _DEBUG + TTime time = entry.iModified; + TDateTime dt = time.DateTime(); + _LIT(KFormat, "%d.%d %02d:%02d"); + TFileName mod; + mod.Format(KFormat, dt.Day()+1, dt.Month()+1, dt.Hour()+1,dt.Minute() ); + LOGGER_WRITE_1("time: %S", &mod); +#endif + if ( storesCount > KMaxStoresCount ) + { + LOGGER_WRITE_1("delete contextstore: '%S'", &entry.iName ); + iFs.Delete( entry.iName ); + TFileName timeStoreFile; + timeStoreFile = entry.iName.Right(15); + timeStoreFile.Insert(0, KTimeStoreName); + LOGGER_WRITE_1("delete timeStoreFile: %S", &timeStoreFile); + iFs.Delete( timeStoreFile ); + } + } + + } + CleanupStack::PopAndDestroy( dir ); + TRACE_FUNC_EXIT; + } + +void CSconAsyncHandler::CompleteRequest( TInt aError ) + { + TRACE_FUNC; + iTimeOut->Cancel(); + LOGGER_WRITE_1("iMessage.Complete( %d )", aError); + iMessage.Complete( aError ); + } diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/src/sconsyncrelationship.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/src/sconsyncrelationship.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,181 @@ +/* +* 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: CSconSyncRelationship implementation +* +*/ + + +#include "sconsyncrelationship.h" +#include +#include + +#include "debug.h" + +_LIT(KContextStore, "contextstore_0x%08x.dat"); +_LIT(KTimeStore, "timestore_0x%08x.dat"); + +CSconSyncRelationship::~CSconSyncRelationship() + { + TRACE_FUNC_ENTRY; + if ( iDictionaryStore ) + { + iDictionaryStore->Commit(); + delete iDictionaryStore; + } + TRACE_FUNC_EXIT; + } + +CSconSyncRelationship::CSconSyncRelationship( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aProviderId ) + : iFs(aFs), iID(aRelationUid), iProviderId(aProviderId) + { + TRACE_FUNC; + + } + +CSconSyncRelationship* CSconSyncRelationship::NewL( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aProviderId ) + { + TRACE_FUNC_ENTRY; + CSconSyncRelationship* self = new (ELeave) CSconSyncRelationship( aFs, aRelationUid, aProviderId ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + TRACE_FUNC_EXIT; + return self; + } + +void CSconSyncRelationship::SetTimeStampL( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aId ) + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("aRelationUid: 0x%08x", aRelationUid.iUid ); + LOGGER_WRITE_1("aId: 0x%08x", aId ); + aFs.SetSessionToPrivate( EDriveC ); + TFileName file; + file.Format(KTimeStore, aRelationUid.iUid); + CDictionaryFileStore* dictionaryStore = CDictionaryFileStore::OpenLC(aFs, file, TUid::Uid(0x0001)); + + RDictionaryWriteStream stream; + stream.AssignLC( *dictionaryStore, TUid::Uid(aId) ); + + TTime time; + time.UniversalTime(); + + TDateTime dateTime = time.DateTime(); + TPckgBuf timeBuf(dateTime); + + stream.WriteL( timeBuf ); + stream.CommitL(); + + CleanupStack::PopAndDestroy( &stream ); //AssingLC + dictionaryStore->Commit(); + CleanupStack::PopAndDestroy( dictionaryStore ); + TRACE_FUNC_EXIT; + } + +void CSconSyncRelationship::GetTimeStampL( RFs& aFs, TUid aRelationUid, TSmlDataProviderId aId, TDateTime& aTimeStamp ) + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("aRelationUid: 0x%08x", aRelationUid.iUid ); + LOGGER_WRITE_1("aId: 0x%08x", aId ); + User::LeaveIfError( aFs.SetSessionToPrivate( EDriveC ) ); + TFileName file; + file.Format(KTimeStore, aRelationUid.iUid); + CDictionaryFileStore* dictionaryStore = CDictionaryFileStore::OpenLC(aFs, file, TUid::Uid(0x0001)); + TBool present = dictionaryStore->IsPresentL( TUid::Uid(aId) ); + if ( !present ) + { + LOGGER_WRITE("Stream was not present"); + User::Leave(KErrNotFound); + } + RDictionaryReadStream stream; + stream.OpenLC( *dictionaryStore, TUid::Uid(aId) ); + TPckgBuf timeBuf; + stream.ReadL( timeBuf ); + aTimeStamp = timeBuf(); + CleanupStack::PopAndDestroy(); //OpenLC + CleanupStack::PopAndDestroy( dictionaryStore ); + + TRACE_FUNC_EXIT; + } + +void CSconSyncRelationship::ConstructL() + { + TRACE_FUNC_ENTRY; + iFs.SetSessionToPrivate( EDriveC ); + TFileName file; + file.Format(KContextStore, iID.iUid); + iDictionaryStore = CDictionaryFileStore::OpenL( + iFs, file, TUid::Uid(0x0001)); + + TRACE_FUNC_EXIT; + } + + +TSmlSyncTaskKey CSconSyncRelationship::SyncTaskKey() const + { + TRACE_FUNC; + return static_cast(iID.iUid); + } + +void CSconSyncRelationship::OpenReadStreamLC(RReadStream& aReadStream, TUid aStreamUid) + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("aStreamUid: 0x%08x", aStreamUid); + TUid streamUid(aStreamUid); + if ( aStreamUid.iUid == KNSmlDefaultSnapshotStreamUID ) + { + LOGGER_WRITE_1(" Default stream uid was used, use provider uid (0x%08x) as stream uid", iProviderId); + streamUid.iUid = iProviderId; + } + if ( !IsStreamPresentL( streamUid ) ) + { + LOGGER_WRITE("Stream was not present"); + User::Leave(KErrNotFound); + } + + + static_cast(aReadStream).OpenLC( + *iDictionaryStore, streamUid ); + TRACE_FUNC_EXIT; + } + +void CSconSyncRelationship::OpenWriteStreamLC(RWriteStream& aWriteStream, TUid aStreamUid) + { + TRACE_FUNC_ENTRY; + + LOGGER_WRITE_1("aStreamUid: 0x%08x", aStreamUid); + TUid streamUid(aStreamUid); + if ( aStreamUid.iUid == KNSmlDefaultSnapshotStreamUID ) + { + LOGGER_WRITE_1(" Default stream uid was used, use provider uid (0x%08x) as stream uid", iProviderId); + streamUid.iUid = iProviderId; + } + static_cast(aWriteStream).AssignLC( + *iDictionaryStore, streamUid ); + TRACE_FUNC_EXIT; + } + +TBool CSconSyncRelationship::IsStreamPresentL(TUid aStreamUid) const + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("aStreamUid: 0x%08x", aStreamUid.iUid ); + TUid streamUid(aStreamUid); + if ( aStreamUid.iUid == KNSmlDefaultSnapshotStreamUID ) + { + LOGGER_WRITE_1(" Default stream uid was used, use provider uid (0x%08x) as stream uid", iProviderId); + streamUid.iUid = iProviderId; + } + TBool present = iDictionaryStore->IsPresentL( streamUid ); + LOGGER_WRITE_1("CSconSyncRelationship::IsStreamPresentL() return: %d",(TInt)present); + return present; + } diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/src/sconsyncserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/src/sconsyncserver.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,177 @@ +/* +* 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: CSconSyncServer implementation +* +*/ + + +#include "sconsyncserver.h" +#include "sconsyncclientserver.h" + +#include "sconsyncsession.h" +#include "debug.h" + +const TInt KSConPCConnServerUid = 0x101F99F6; + +// Security policy +const TUint KServerPolicyRangeCount = 2; + +const TInt KServerPolicyRanges[KServerPolicyRangeCount] = + { + 0, // range is 0 inclusive + EMaxService // range is 1-KMaxTInt inclusive + }; + +const TUint8 KServerPolicyElementsIndex[KServerPolicyRangeCount] = + { + 0, // applies to 0th range + CPolicyServer::ENotSupported // applies to 1st range + }; + +const CPolicyServer::TPolicyElement KServerPolicyElements[] = + { + { _INIT_SECURITY_POLICY_S0(KSConPCConnServerUid) /*_INIT_SECURITY_POLICY_C1(ECapabilityReadDeviceData)*/, CPolicyServer::EFailClient } + }; + +const CPolicyServer::TPolicy KServerPolicy = + { + 0 /*CPolicyServer::EAlwaysPass*/, // specifies all connect attempts should pass + KServerPolicyRangeCount, + KServerPolicyRanges, + KServerPolicyElementsIndex, + KServerPolicyElements + }; + + +CSconSyncServer* CSconSyncServer::NewL() + { + CSconSyncServer* self = NewLC(); + CleanupStack::Pop(self); + return self; + } + +CSconSyncServer* CSconSyncServer::NewLC() + { + CSconSyncServer* self = new(ELeave) CSconSyncServer(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CSconSyncServer::CSconSyncServer() : + CPolicyServer(EPriorityStandard, KServerPolicy, ESharableSessions) + { + } + +void CSconSyncServer::ConstructL() + { + TRACE_FUNC_ENTRY; + TInt error = Start(KSconSyncServerName); + + if (error != KErrNone) + { + User::Panic(KSconSyncServerName, error); + } + TRACE_FUNC_EXIT; + } + +CSconSyncServer::~CSconSyncServer() + { + TRACE_FUNC; + } + +CSession2* CSconSyncServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const + { + TRACE_FUNC; + TVersion v(1,0,0); + if ( !User::QueryVersionSupported(v,aVersion) ) + { + TVersionName vname = aVersion.Name(); + LOGGER_WRITE_1("Client has wrong version: %S", &vname); + User::Leave( KErrNotSupported ); + } + + return CSconSyncSession::NewL(); + } + +TInt CSconSyncServer::RunError(TInt aError) + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("aError: %d", aError); + // Bad descriptor implies bad client + if (aError == KErrBadDescriptor) + { + Message().Panic(KSconSyncServerName, aError); + } + else + { + Message().Complete(aError); + } + + // Continue handling requests + ReStart(); + TRACE_FUNC_EXIT; + return KErrNone; + } + +void CSconSyncServer::AddSession() + { + ++iSessionCount; + LOGGER_WRITE_1("CSconSyncServer::AddSession(), iSessionCount: %d", iSessionCount); + } + +void CSconSyncServer::RemoveSession() + { + --iSessionCount; + LOGGER_WRITE_1("CSconSyncServer::RemoveSession(), iSessionCount: %d", iSessionCount); + if (iSessionCount == 0) + { + CActiveScheduler::Stop(); + } + } + +LOCAL_C void ExeMainL() + { + TRACE_FUNC_ENTRY; + // Install active scheduler + CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; + CleanupStack::PushL(scheduler); + CActiveScheduler::Install(scheduler); + + CSconSyncServer::NewLC(); + + User::LeaveIfError(User::RenameThread(KSconSyncServerName)); + RProcess::Rendezvous(KErrNone); + + CActiveScheduler::Start(); + + CleanupStack::PopAndDestroy(); // CSconSyncServer + CleanupStack::PopAndDestroy(); // CActiveScheduler + TRACE_FUNC_EXIT; + } + +GLDEF_C TInt E32Main() + { + TRACE_FUNC_ENTRY; + __UHEAP_MARK; + CTrapCleanup* cleanup = CTrapCleanup::New(); + + TRAPD(error, ExeMainL()); + __ASSERT_ALWAYS(!error, User::Panic(KSconSyncServerName, error)); + + delete cleanup; + __UHEAP_MARKEND; + TRACE_FUNC_EXIT; + return 0; + } diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/servers/syncserver/src/sconsyncsession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/servers/syncserver/src/sconsyncsession.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,96 @@ +/* +* 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: CSconSyncSession implementation +* +*/ + + +#include "sconsyncsession.h" + +#include "sconsyncserver.h" +#include "sconsyncclientserver.h" +#include "sconasynchandler.h" +#include "debug.h" + + +CSconSyncSession::CSconSyncSession() + { + TRACE_FUNC; + } + +CSconSyncSession* CSconSyncSession::NewL() + { + TRACE_FUNC; + CSconSyncSession* self = new(ELeave) CSconSyncSession(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +void CSconSyncSession::ConstructL() + { + TRACE_FUNC_ENTRY; + iAsyncHandler = CSconAsyncHandler::NewL(); + TRACE_FUNC_EXIT; + } + +void CSconSyncSession::CreateL() + { + TRACE_FUNC; + Server().AddSession(); + } + +CSconSyncSession::~CSconSyncSession() + { + TRACE_FUNC_ENTRY; + delete iAsyncHandler; + + Server().RemoveSession(); + + TRACE_FUNC_EXIT; + } + +CSconSyncServer& CSconSyncSession::Server() + { + return *static_cast(const_cast(CSession2::Server())); + } + + +// ----------------------------------------------------------------------------- +// CSconSyncSession::ServiceL() +// Handles the client request +// ----------------------------------------------------------------------------- +// +void CSconSyncSession::ServiceL(const RMessage2& aMessage) + { + TRACE_FUNC_ENTRY; + + TRAPD( err, iAsyncHandler->HandleServiceL( aMessage )); + if ( err ) + { + LOGGER_WRITE_1("iAsyncHandler->HandleServiceL leaved: %d", err); + if ( iAsyncHandler->IsActive() ) + { + LOGGER_WRITE(" and it was active -> Cancel it"); + iAsyncHandler->Cancel(); + } + // do server error processing + User::Leave( err ); + } + + TRACE_FUNC_EXIT; + } + + diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/csc/bld/101F99F6.xml Binary file connectivitymodules/SeCon/services/csc/bld/101F99F6.xml has changed diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/csc/bld/bld.inf --- a/connectivitymodules/SeCon/services/csc/bld/bld.inf Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/services/csc/bld/bld.inf Thu Aug 19 10:44:03 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-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" @@ -22,17 +22,9 @@ DEFAULT PRJ_EXPORTS -./101F9698.xml /epoc32/data/Z/private/101F99F6/capability/101F9698.xml -./fwdcomp.xml /epoc32/data/Z/private/101F99F6/capability/fwdcomp.xml -./101F99F6.xml /epoc32/data/Z/private/101F99F6/capability/101F99F6.xml - -./101F9698.xml /epoc32/RELEASE/winscw/udeb/Z/private/101F99F6/capability/101F9698.xml -./fwdcomp.xml /epoc32/RELEASE/winscw/udeb/Z/private/101F99F6/capability/fwdcomp.xml -./101F99F6.xml /epoc32/RELEASE/winscw/udeb/Z/private/101F99F6/capability/101F99F6.xml - +./101F9698.xml Z:/private/101F99F6/capability/101F9698.xml +./fwdcomp.xml Z:/private/101F99F6/capability/fwdcomp.xml +./101F99F6.xml Z:/private/101F99F6/capability/101F99F6.xml PRJ_MMPFILES - sconcsc.mmp - - diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/oviaccounthandler/inc/sconoviaccounthandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/services/oviaccounthandler/inc/sconoviaccounthandler.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSconOviAccountHandler header file +* +*/ + + +#ifndef _SCONOVIACCOUNTHANDLER_H_ +#define _SCONOVIACCOUNTHANDLER_H_ + +#include +#include + +_LIT(KSconOviAccountHandlerDllName, "sconoviaccounthandler.dll"); +const TUid KSconOviAccountHandlerDllUid={0x10009D8D}; + +class CWSOviAccountManager; + +/** + * CSconOviAccountHandler provides Ovi account information. + * Dynamically loadable dll. + */ +class CSconOviAccountHandler : public CBase +{ + public: + static CSconOviAccountHandler* NewL(); + ~CSconOviAccountHandler(); + + /** + * Reads account information from device + * @param aAccountInfoStream stream where to export account details. + * @leave KErrNotFound if account information does not exist. + */ + virtual void GetOviAccountDetailsL( RWriteStream& aAccountInfoStream ); + + private: + void ConstructL(); + + private: // Data + CWSOviAccountManager* iOviAccountManager; + +}; + +IMPORT_C CSconOviAccountHandler* CreateCSconOviAccountHandlerL(); +typedef CSconOviAccountHandler* (*TSConCreateCSconOviAccountHandlerFunc) (); + +#endif // _SCONOVIACCOUNTHANDLER_H_ diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/pcd/bld/bld.inf --- a/connectivitymodules/SeCon/services/pcd/bld/bld.inf Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/services/pcd/bld/bld.inf Thu Aug 19 10:44:03 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2002-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" @@ -23,7 +23,7 @@ DEFAULT PRJ_EXPORTS -./sbeconfig.xml /epoc32/data/Z/private/10202D56/sbeconfig.xml +./sbeconfig.xml Z:/private/10202D56/sbeconfig.xml PRJ_MMPFILES sconpcd.mmp diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/pcd/bld/sconpcd.mmp --- a/connectivitymodules/SeCon/services/pcd/bld/sconpcd.mmp Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/services/pcd/bld/sconpcd.mmp Thu Aug 19 10:44:03 2010 +0300 @@ -51,6 +51,7 @@ SOURCE sconpcdutility.cpp SOURCE sconmetadata.cpp SOURCE sconvideoparser.cpp +SOURCE sconsynchandler.cpp SOURCE cscontimeout.cpp SOURCEPATH ../../../common/conmltask/src @@ -59,6 +60,7 @@ USERINCLUDE ../inc USERINCLUDE ../../../inc USERINCLUDE ../../../common/conmltask/inc +USERINCLUDE ../../../clients/syncclient/inc // Default system include paths APP_LAYER_SYSTEMINCLUDE @@ -84,5 +86,10 @@ LIBRARY ImageConversion.lib // for CImageEncoder LIBRARY MMFControllerFramework.lib // for CMMFMetaDataEntry LIBRARY bafl.lib // for BaflUtils +LIBRARY ecom.lib +LIBRARY estor.lib // CDictionaryFileStore +LIBRARY sconsyncclient.lib +LIBRARY smlstoreformat.lib +LIBRARY centralrepository.lib DEBUGLIBRARY flogger.lib // End of file diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/pcd/inc/sconmetadatafielddefs.h --- a/connectivitymodules/SeCon/services/pcd/inc/sconmetadatafielddefs.h Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/services/pcd/inc/sconmetadatafielddefs.h Thu Aug 19 10:44:03 2010 +0300 @@ -46,6 +46,8 @@ const TUint8 KSconAudioUniqueFileIdentifier( 0x11 ); const TUint8 KSconAudioDuration ( 0x12 ); const TUint8 KSconAudioDate ( 0x13 ); +const TUint8 KSconAudioUnsyncLyrics ( 0x14 ); +const TUint8 KSconAudioProtected ( 0x15 ); // fields for exif const TUint8 KSconExifThumbnail ( 0x01 ); diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/pcd/inc/sconpcd.h --- a/connectivitymodules/SeCon/services/pcd/inc/sconpcd.h Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/services/pcd/inc/sconpcd.h Thu Aug 19 10:44:03 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-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" @@ -23,11 +23,13 @@ #include #include +#include #include "sconconmltask.h" class CSConInstallerQueue; class CSConBackupRestoreQueue; +class CSconSyncHandler; enum TSConLastConMLOperation { @@ -68,6 +70,9 @@ * @return none */ virtual void ResetPCD(); + + virtual void HandleGetSyncRequestL( const TDesC8& aRequest, RWriteStream& aResult, TInt aMaxObjectSize ); + virtual void HandlePutSyncRequestL( const TDesC8& aRequest, RReadStream& aResult ); private: /** @@ -153,6 +158,7 @@ TInt iMaxObjectSize; TSConLastConMLOperation iLastOperation; RFs iFs; + CSconSyncHandler* iSyncHandler; }; IMPORT_C CSConPCD* CreateCSConPCDL(); diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/pcd/inc/sconsbeclient.h --- a/connectivitymodules/SeCon/services/pcd/inc/sconsbeclient.h Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/services/pcd/inc/sconsbeclient.h Thu Aug 19 10:44:03 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-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" @@ -138,7 +138,12 @@ * @return KErrNone if no erros. Else system wide error codes. */ TInt ProcessRequestDataL(); - /** + /** + * Request data to iDataBuffer + * @return none + */ + void RequestDataL( CSBGenericTransferType& aGenericTransferType ); + /** * Executes GetDataOwnerStatus task * @return none */ @@ -209,25 +214,20 @@ * @param TDriveList drives to include * @return dataowner data size in specified drives */ - TUint JavaDataSizeL( const TDesC& aJavaHash, const TDriveList& aDriveList ) const; - - private: - CSBEClient* iSBEClient; - TRequestStatus* iCallerStatus; - TBool iProcessComplete; - TInt iProcessIndex; - TInt iMaxObjectSize; - - CSConTask* iCurrentTask; - TInt iDataPos; - TBool iDataLeft; - TPtrC8 iDataPtr; - TBool iLastChunk; - TBool iBURModeNormal; - TBool iRestoreMode; - RFs& iFs; - TBool iAllSnapshotsSuppliedCalled; - }; + TUint JavaDataSizeL( const TDesC& aJavaHash, const TDriveList& aDriveList ) const; + + private: + CSBEClient* iSBEClient; + TRequestStatus* iCallerStatus; + CSConTask* iCurrentTask; + TBool iBURModeNormal; + TBool iRestoreMode; + RFs& iFs; + TBool iAllSnapshotsSuppliedCalled; + TBool iLastChunk; + CBufFlat* iDataBuffer; + TInt iDataBufferSize; + }; #endif diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/pcd/inc/sconsynchandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/services/pcd/inc/sconsynchandler.h Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,138 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSconSyncHandler header +* +*/ + + +#ifndef SCONSYNCHANDLER_H_ +#define SCONSYNCHANDLER_H_ + +#include +#include +#include "sconsyncclient.h" + +class RFs; +class RWriteStream; +class RReadStream; +class RFileReadStream; + +NONSHARABLE_CLASS( TCreatedItem ) + { +public: + TInt iTemporaryId; + TInt iErrorCode; + TSmlDbItemUid iNewUid; + }; + +NONSHARABLE_CLASS( TReplacedItem ) + { +public: + TSmlDbItemUid iItemUid; + TInt iErrorCode; + }; + +NONSHARABLE_CLASS( CSconSyncHandler ) : public CActive +{ +public: + static CSconSyncHandler* NewL( RFs& aFs ); + ~CSconSyncHandler(); + + void HandleGetSyncRequestL( const TDesC8& aRequest, RWriteStream& aResult, TInt aMaxObjectSize ); + void HandlePutSyncRequestL( const TDesC8& aRequest, RReadStream& aData ); +private: + CSconSyncHandler( RFs& aFs ); + void ConstructL(); + + void ListStoresL( RWriteStream& aResult ); + void OpenStoreL( const TDesC8& aParams, RWriteStream& aResult ); + void CloseStoreL( RWriteStream& aResult ); + + void ListChangesL( RWriteStream& aResult ); + void ResetChangeInfoL( RWriteStream& aResult ); + void CommitChangesL( const TDesC8& aParams, RWriteStream& aResult ); + void ReadItemsL( const TDesC8& aParams, RWriteStream& aResult ); + void GetParentsL( const TDesC8& aParams, RWriteStream& aResult ); + void CreateItemsL( RReadStream& aData ); + void GetCreateItemsResponseL( const TDesC8& aParams, RWriteStream& aResult ); + void ReplaceItemsL( RReadStream& aData ); + void GetReplaceItemsResponseL( const TDesC8& aParams, RWriteStream& aResult ); + void MoveItemsL( const TDesC8& aParams, RWriteStream& aResult ); + void DeleteItemsL( const TDesC8& aParams, RWriteStream& aResult ); + void SoftDeleteItemsL( const TDesC8& aParams, RWriteStream& aResult ); + void DeleteAllItemsL( RWriteStream& aResult ); + void GetDeleteAllItemsStatusL( RWriteStream& aResult ); + void GetStoreFormatL( RWriteStream& aResult ); + void SetRemoteStoreFormatL( RReadStream& aData ); + + void CreateNextItemOnStreamL(); + void ReplaceNextItemOnStreamL(); + + void ReadNextDataBlockL( RWriteStream& aResult ); + void ReadItemL( TSmlDbItemUid aUid, CBufFlat& aItemData ); + + void LoadRemoteStoreFormatL( TInt aContextId, TInt aProviderId ); + void SaveRemoteStoreFormatL( CSmlDataStoreFormat& aStoreFormat, TInt aContextId, TInt aProviderId ); + + void CancelOperationsL( RWriteStream& aResult ); + + void Reset(); + + void SetCalendarCenrepL( TInt aProfileId, const TDesC& aServerId ); + void ClearCalendarCenrepL(); + +private: // from CActive + void DoCancel(); + void RunL(); + TInt RunError( TInt aError ); + +private: + RFs& iFs; // Not owned + RSconSyncSession iSyncSession; + TBool iConnected; + + TInt iCurrentDataProviderUid; + TInt iCurrentContextUid; + + CBufFlat* iResponseData; + + enum TSyncStatus + { + EReady, + ECreatingItemsFromFile, + EItemsCreated, + EReplacingItemsFromFile, + EItemsReplaced, + EDeletingAllItems + }; + TSyncStatus iSyncStatus; + + TInt iMaxObjectSize; + TInt iBytesWrited; + TBool iHasFileStream; + RFileReadStream iFileStream; + TSmlDbItemUid iCreatedItemUid; + TPckg iCreatedItemUidPckg; + TSmlDbItemUid iTemporaryItemUid; + TInt iItemsLeftInStream; + TInt iItemInProgress; // =1 if item is in progress + RArray iCreatedItems; + RArray iReplacedItems; + RArray iItemsToRead; + TReplacedItem iReplacedItem; + TFileName iFileInProgress; + TBool iCalendarCenrepUsed; +}; + +#endif /*SCONSYNCHANDLER_H_*/ diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/pcd/src/sconbackuprestore.cpp --- a/connectivitymodules/SeCon/services/pcd/src/sconbackuprestore.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/services/pcd/src/sconbackuprestore.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -38,12 +38,10 @@ CSConBackupRestore* CSConBackupRestore::NewL( CSConBackupRestoreQueue* aQueue, const TInt aMaxObjectSize, RFs& aFs ) { - TRACE_FUNC_ENTRY; CSConBackupRestore* self = new (ELeave) CSConBackupRestore( aQueue, aFs ); CleanupStack::PushL( self ); self->ConstructL( aMaxObjectSize ); CleanupStack::Pop( self ); - TRACE_FUNC_EXIT; return self; } @@ -76,18 +74,12 @@ // CSConBackupRestore::~CSConBackupRestore() { - TRACE_FUNC_ENTRY; if( iSBEClient ) { - if( iSBEClient->IsActive() ) - { - iSBEClient->Cancel(); - } - + iSBEClient->Cancel(); delete iSBEClient; iSBEClient = NULL; } - TRACE_FUNC_EXIT; } // ----------------------------------------------------------------------------- @@ -166,11 +158,7 @@ TRACE_FUNC_ENTRY; if( iSBEClient ) { - if( iSBEClient->IsActive() ) - { - iSBEClient->Cancel(); - } - + iSBEClient->Cancel(); delete iSBEClient; iSBEClient = NULL; } @@ -212,11 +200,9 @@ // void CSConBackupRestore::RunL() { - TRACE_FUNC_ENTRY; - + TRACE_FUNC; iQueue->CompleteTask( iCurrentTask, iStatus.Int() ); iBackupRestoreActive = EFalse; - TRACE_FUNC_EXIT; } // End of file diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/pcd/src/sconmetadata.cpp --- a/connectivitymodules/SeCon/services/pcd/src/sconmetadata.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/services/pcd/src/sconmetadata.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -210,8 +210,8 @@ // get field id fields.FieldIdAt( i , fieldId ); LOGGER_WRITE_2( "AudioFieldId( %d ): 0x%02x", i, fieldId ); - - if ( fieldId == EMetaDataJpeg ) + TUint8 sconFieldId = AudioFieldId( fieldId ); + if ( sconFieldId == KSconAudioJpeg ) { TPtrC8 field8( fields.Field8( fieldId ) ); AppendByteDataFieldL( @@ -219,13 +219,16 @@ field8, AudioFieldId( fieldId ) ); } - else + else if ( sconFieldId > 0 ) { // get field data and add UTF-8 formatted text to buffer fieldData.Set( fields.At( i , fieldId ) ); - AppendUtf8DataFieldL( buffer, fieldData, AudioFieldId( fieldId ) ); + AppendUtf8DataFieldL( buffer, fieldData, sconFieldId ); } - + else + { + LOGGER_WRITE("Unknown field skipped"); + } } if ( buffer->Size() > 0 ) @@ -426,6 +429,12 @@ case EMetaDataDate : ret = KSconAudioDate; break; + case EMetaDataUnsyncLyrics: + ret = KSconAudioUnsyncLyrics; + break; + case EMetaDataProtected: + ret = KSconAudioProtected; + break; default : LOGGER_WRITE( "SConMetadata::AudioFieldId : ERR field not defined!" ); break; diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/pcd/src/sconpcd.cpp --- a/connectivitymodules/SeCon/services/pcd/src/sconpcd.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/services/pcd/src/sconpcd.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -23,6 +23,7 @@ #include "sconinstqueue.h" #include "sconbrqueue.h" #include "sconmetadata.h" +#include "sconsynchandler.h" #include "debug.h" // ============================= MEMBER FUNCTIONS =============================== @@ -88,6 +89,7 @@ } CActiveScheduler::Add( iInstallerQueue ); CActiveScheduler::Add( iBackupRestoreQueue ); + iSyncHandler = CSconSyncHandler::NewL( iFs ); TRACE_FUNC_EXIT; } @@ -119,6 +121,12 @@ iLatestReply = NULL; } + if ( iSyncHandler ) + { + iSyncHandler->Cancel(); + delete iSyncHandler; + iSyncHandler = NULL; + } iFs.Close(); TRACE_FUNC_EXIT; } @@ -260,6 +268,32 @@ } // ----------------------------------------------------------------------------- +// CSConPCD::HandleGetSyncRequestL() +// +// ----------------------------------------------------------------------------- +// +void CSConPCD::HandleGetSyncRequestL( const TDesC8& aRequest, RWriteStream& aResult, TInt aMaxObjectSize ) + { + TRACE_FUNC_ENTRY; + iSyncHandler->HandleGetSyncRequestL( aRequest, aResult, aMaxObjectSize ); + + TRACE_FUNC_EXIT; + } + +// ----------------------------------------------------------------------------- +// CSConPCD::HandlePutSyncRequestL() +// +// ----------------------------------------------------------------------------- +// +void CSConPCD::HandlePutSyncRequestL( const TDesC8& aRequest, RReadStream& aResult ) + { + TRACE_FUNC_ENTRY; + iSyncHandler->HandlePutSyncRequestL( aRequest, aResult ); + + TRACE_FUNC_EXIT; + } + +// ----------------------------------------------------------------------------- // CSConPCD::SupportedInstTaskL( CSConTask* aTask ) // Fills a reply with predefined supported task -information // ----------------------------------------------------------------------------- @@ -421,16 +455,22 @@ for ( TInt i = 0; i < installerReply->iTasks.Count(); i++ ) { - mergeReply->iTasks.Append( installerReply->iTasks[i]->CopyAndFreeL() ); + CSConTaskReply* temp = installerReply->iTasks[i]->CopyAndFreeL(); + CleanupStack::PushL( temp ); + mergeReply->iTasks.AppendL( temp ); + CleanupStack::Pop( temp ); } // installer replys are copied to mergereply, delete installerReply CleanupStack::PopAndDestroy( installerReply ); // do same for br reply - for ( TInt j = 0; j < brReply->iTasks.Count(); j++ ) + for ( TInt i = 0; i < brReply->iTasks.Count(); i++ ) { - mergeReply->iTasks.Append( brReply->iTasks[j]->CopyAndFreeL() ); + CSConTaskReply* temp = brReply->iTasks[i]->CopyAndFreeL(); + CleanupStack::PushL( temp ); + mergeReply->iTasks.AppendL( temp ); + CleanupStack::Pop( temp ); } CleanupStack::PopAndDestroy( brReply ); diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/pcd/src/sconpcdutility.cpp --- a/connectivitymodules/SeCon/services/pcd/src/sconpcdutility.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/services/pcd/src/sconpcdutility.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-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" @@ -217,7 +217,7 @@ CJavaRegistry* javaRegistry = CJavaRegistry::NewLC( ); RArray packageUids; CleanupClosePushL( packageUids ); - javaRegistry->GetRegistryEntryUidsL( /*EGeneralPackage,*/ packageUids ); + javaRegistry->GetRegistryEntryUidsL( packageUids ); LOGGER_WRITE_1("packageUids.Count(): %d", packageUids.Count()); for (TInt i=0; iiUid, bundleId ); + app->iWidgetBundleId = bundleId.AllocL(); User::LeaveIfError( aListInstApps.iApps.Append( app ) ); CleanupStack::Pop( app ); // ownership transferred, do not delete diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/pcd/src/sconsbeclient.cpp --- a/connectivitymodules/SeCon/services/pcd/src/sconsbeclient.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/connectivitymodules/SeCon/services/pcd/src/sconsbeclient.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-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" @@ -24,7 +24,8 @@ #include "sconsbeclient.h" #include "debug.h" - +const TInt KDataBufExpandSize( 1024 ); +const TInt KMaxObjectSize( 1048576 - 1024 ); // Max chunk size is 1MB, but give some space for ConML wbxml _LIT( KSConNoDrive, "\x0" ); _LIT( KSConDriveExists, "\x1" ); // ============================= MEMBER FUNCTIONS ============================== @@ -46,13 +47,10 @@ // Constructor // ----------------------------------------------------------------------------- // -CSConSBEClient::CSConSBEClient( const TInt aMaxObjectSize, RFs& aFs ) : - CActive( EPriorityStandard ), iSBEClient(NULL), - iProcessComplete(EFalse), iProcessIndex( 0 ), iDataPos( 0 ), - iDataLeft( EFalse ), iBURModeNormal( ETrue ), - iRestoreMode( EFalse ), iFs( aFs ) +CSConSBEClient::CSConSBEClient( const TInt /*aMaxObjectSize*/, RFs& aFs ) : + CActive( EPriorityStandard ), iBURModeNormal( ETrue ), iFs( aFs ) { - iMaxObjectSize = aMaxObjectSize; + } // ----------------------------------------------------------------------------- @@ -89,6 +87,8 @@ delete iSBEClient; iSBEClient = NULL; } + + delete iDataBuffer; TRACE_FUNC_EXIT; } @@ -263,67 +263,52 @@ LOGGER_WRITE( "CSConSBEClient::RunL() : ESetBURMode" ); TRAP( err, ProcessSetBURModeL() ); LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessSetBURModeL() : returned %d", err ); - HandleSBEErrorL( err ); - User::RequestComplete( iCallerStatus, err ); break; case EListPublicFiles : LOGGER_WRITE( "CSConSBEClient::RunL() : EListPublicFiles" ); TRAP( err, ProcessListPublicFilesL() ); LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessListPublicFilesL() : returned %d", err ); - HandleSBEErrorL( err ); - User::RequestComplete( iCallerStatus, err ); break; case EListDataOwners : LOGGER_WRITE( "CSConSBEClient::RunL() : EListDataOwners" ); TRAP( err, ProcessListDataOwnersL() ); LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessListDataOwnersL() : returned %d", err ); - HandleSBEErrorL( err ); - User::RequestComplete( iCallerStatus, err ); break; case EGetDataSize : LOGGER_WRITE( "CSConSBEClient::RunL() : EGetDataSize" ); TRAP( err, ProcessGetDataSizeL() ); LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessGetDataSizeL() : returned %d", err ); - HandleSBEErrorL( err ); - User::RequestComplete( iCallerStatus, err ); break; case ERequestData : LOGGER_WRITE( "CSConSBEClient::RunL() : ERequestData" ); TRAP( err, ret = ProcessRequestDataL() ); LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessRequestDataL() : returned %d", err ); - HandleSBEErrorL( err ); - - if( err == KErrNone ) - { - err = ret; - } - - User::RequestComplete( iCallerStatus, err ); break; case EGetDataOwnerStatus : LOGGER_WRITE( "CSConSBEClient::RunL() : EGetDataOwnerStatus" ); TRAP( err, ProcessGetDataOwnerStatusL() ); LOGGER_WRITE_1( "CSConSBEClient::RunL() : ProcessGetDataOwnerStatusL() : returned %d", err ); - HandleSBEErrorL( err ); - User::RequestComplete( iCallerStatus, err ); break; case ESupplyData : LOGGER_WRITE( "CSConSBEClient::RunL() : ESupplyData" ); TRAP( err, ret = ProcessSupplyDataL() ); LOGGER_WRITE_1( "CSConSBEClient::RunL() : SupplyDataL() : returned %d", err ); - HandleSBEErrorL( err ); - - if( err == KErrNone ) - { - err = ret; - } - - User::RequestComplete( iCallerStatus, err ); break; default : + err = KErrNotSupported; LOGGER_WRITE( "CSConSBEClient::RunL() : ERROR! Unknown!" ); break; } + + if ( err ) + { + HandleSBEErrorL( err ); + } + else + { + err = ret; + } + User::RequestComplete( iCallerStatus, err ); TRACE_FUNC_EXIT; } @@ -338,6 +323,7 @@ TRACE_FUNC_ENTRY; iAllSnapshotsSuppliedCalled = EFalse; + iLastChunk = EFalse; TDriveList driveList = iCurrentTask->iBURModeParams->iDriveList; @@ -368,6 +354,21 @@ break; } + if ( partialType == EBURBackupFull || partialType == ESConBurBackupPartial ) + { + // initialize buffer + if ( !iDataBuffer ) + iDataBuffer = CBufFlat::NewL( KDataBufExpandSize ); + else + iDataBuffer->Reset(); + iDataBufferSize=0; + } + else + { + delete iDataBuffer; + iDataBuffer = 0; + } + TBackupIncType incType = ENoBackup; switch( iCurrentTask->iBURModeParams->iIncType ) @@ -521,6 +522,7 @@ { LOGGER_WRITE_2("handling do: %d, count: %d", i, dataOwners.Count()); CSConDataOwner* dataOwner = new (ELeave) CSConDataOwner(); + CleanupStack::PushL( dataOwner ); // default values TSecureId sid( 0 ); includeToList = ETrue; @@ -704,24 +706,27 @@ if( includeToList ) { LOGGER_WRITE_1( "Appending to list, uid: 0x%08x", dataOwner->iUid.iUid ); - iCurrentTask->iListDataOwnersParams->iDataOwners.Append( dataOwner ); + iCurrentTask->iListDataOwnersParams->iDataOwners.AppendL( dataOwner ); + CleanupStack::Pop( dataOwner ); } if( sid ) { LOGGER_WRITE_1( "Appending package sid to list, sid: 0x%08x", sid.iId ); CSConDataOwner* packageDataOwner = dataOwner->CopyL(); + CleanupStack::PushL( packageDataOwner ); //Clear package name packageDataOwner->iPackageName = KNullDesC(); //Add sid packageDataOwner->iUid.iUid = sid.iId; - iCurrentTask->iListDataOwnersParams->iDataOwners.Append( packageDataOwner ); + iCurrentTask->iListDataOwnersParams->iDataOwners.AppendL( packageDataOwner ); + CleanupStack::Pop( packageDataOwner ); } if( !includeToList ) { //Not included to list => delete memory allocation - delete dataOwner; + CleanupStack::PopAndDestroy( dataOwner ); } } @@ -838,11 +843,6 @@ { TRACE_FUNC_ENTRY; TInt ret( KErrNone ); - - if( iMaxObjectSize <= 1 ) - { - User::Leave( KErrGeneral ); - } TBool packageData = EFalse; TTransferDataType transferDataType( ERegistrationData ); @@ -917,95 +917,42 @@ sid = iCurrentTask->iRequestDataParams->iDataOwner->iUid; LOGGER_WRITE_1("CSConSBEClient::ProcessRequestDataL() sid: 0x%08x", sid.iId); } - - CSBPackageTransferType* ptt( NULL ); - CSBSIDTransferType* stt( NULL ); - CSBJavaTransferType* jtt( NULL ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \ - Begin - Data left: %d", iDataLeft ); + LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \ Begin - Package data: %d", packageData ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \ - Begin - iDataPos: %d", iDataPos ); + + LOGGER_WRITE_1("iLastChunk: %d", (TInt) iLastChunk ); + LOGGER_WRITE_1("iDataBufferSize: %d", iDataBufferSize ); - //Are there old data left to be transfered? - if( !iDataLeft ) + // if was't last chunk and there are free space left on our packet + if( !iLastChunk && iDataBufferSize < KMaxObjectSize ) { //No data left, request more from the server if( packageData && !iCurrentTask->iRequestDataParams->iDataOwner->iJavaHash ) { - ptt = CSBPackageTransferType::NewL( uid, driveNumber, - packageDataType ); + CSBPackageTransferType* ptt = CSBPackageTransferType::NewL( + uid, driveNumber, packageDataType ); CleanupStack::PushL( ptt ); - LOGGER_WRITE( "iSBEClient->RequestDataL( ptt ) : start" ); - TRequestStatus status; - iSBEClient->RequestDataL( *ptt, status ); - User::WaitForRequest( status ); - LOGGER_WRITE( "iSBEClint->RequestDataL( ptt ) : stop" ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : status.Int() %d", status.Int() ); - User::LeaveIfError( status.Int() ); - - //Get the data and store the handle - CSBGenericTransferType* gtt = NULL; - LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : start" ); - iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iLastChunk ) ); - LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : stop" ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\ - Received data size %d", iDataPtr.Length() ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\ - Received from DO 0x%08x", uid ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\ - Is last chunk %d", iLastChunk ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\ - Transfertype %d", iCurrentTask->iRequestDataParams->iDataOwner->iTransDataType ); - - if( gtt ) - { - delete gtt; - } - + RequestDataL( *ptt ); + CleanupStack::PopAndDestroy( ptt ); } else if( !iCurrentTask->iRequestDataParams->iDataOwner->iJavaHash ) { - stt = CSBSIDTransferType::NewL( sid, driveNumber, transferDataType ); + CSBSIDTransferType* stt = CSBSIDTransferType::NewL( + sid, driveNumber, transferDataType ); CleanupStack::PushL( stt ); - LOGGER_WRITE( "iSBEClient->RequestDataL( stt ) : start" ); - TRequestStatus status; - iSBEClient->RequestDataL( *stt, status ); - User::WaitForRequest( status ); - LOGGER_WRITE( "iSBEClient->RequestDataL( stt ) : stop" ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\ - status.Int() %d", status.Int() ); - User::LeaveIfError( status.Int() ); - - //Get the data and store the handle - CSBGenericTransferType* gtt = NULL; - LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : start" ); - iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iLastChunk ) ); - LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : stop" ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\ - Received data size %d", iDataPtr.Length() ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\ - Is last chunk %d", iLastChunk ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\ - Transfertype %d", - iCurrentTask->iRequestDataParams->iDataOwner->iTransDataType ); - - if( gtt ) - { - delete gtt; - } - + RequestDataL( *stt ); + CleanupStack::PopAndDestroy( stt ); } else { TPtr javaHashPtr = iCurrentTask->iRequestDataParams->iDataOwner->iJavaHash->Des(); - + CSBJavaTransferType* jtt( NULL ); //When ESystemData is requested, request EJavaMIDlet if( packageDataType == ESystemData ) { @@ -1020,52 +967,25 @@ if( packageDataType == ESystemData || transferDataType == EPassiveBaseData ) { CleanupStack::PushL( jtt ); - LOGGER_WRITE( "iSBEClient->RequestDataL( jtt ) : start" ); - TRequestStatus status; - iSBEClient->RequestDataL( *jtt, status ); - User::WaitForRequest( status ); - LOGGER_WRITE( "iSBEClient->RequestDataL( jtt ) : stop" ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\ - status.Int() %d", status.Int() ); - User::LeaveIfError( status.Int() ); - - //Get the data and store the handle - CSBGenericTransferType* gtt = NULL; - LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ) : start" ); - iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iLastChunk ) ); - LOGGER_WRITE( "iDataPtr.Set( iSBEClient->TransferDataInfoL( gtt, iSBEDataLeft ): stop" ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\ - Received data size %d", iDataPtr.Length() ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\ - Is last chunk %d", iLastChunk ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() :\ - Transfertype %d", - iCurrentTask->iRequestDataParams->iDataOwner->iTransDataType ); - - if( gtt ) - { - delete gtt; - } - + RequestDataL( *jtt ); + CleanupStack::PopAndDestroy( jtt ); } else { //No data - iDataPtr.Set( KNullDesC8 ); + iDataBuffer->Reset(); + iDataBufferSize = 0; iLastChunk = ETrue; } } - } + } + + LOGGER_WRITE_1("readed iLastChunk: %d", (TInt) iLastChunk ); + LOGGER_WRITE_1("readed iDataBufferSize: %d", iDataBufferSize ); - TInt dataBufLength = iDataPtr.Length(); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \ - Data received: %d", dataBufLength ); - TInt maxLength = iMaxObjectSize - 1024; - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \ - Max length: %d", maxLength ); if( iCurrentTask->iRequestDataParams->iBackupData ) { @@ -1073,57 +993,71 @@ iCurrentTask->iRequestDataParams->iBackupData = NULL; } + TInt dataToRead = KMaxObjectSize; + if ( dataToRead > iDataBufferSize ) + dataToRead = iDataBufferSize; + //Initialize the task data buffer - iCurrentTask->iRequestDataParams->iBackupData = HBufC8::NewL( maxLength ); + iCurrentTask->iRequestDataParams->iBackupData = HBufC8::NewL( dataToRead ); //Get descriptor task's buffer TPtr8 backupDataPtr = iCurrentTask->iRequestDataParams->iBackupData->Des(); - TInt copyPos = 0; - //Copy data to task buffer - for( ; iDataPos < dataBufLength && copyPos < maxLength; - iDataPos++ ) + iDataBuffer->Read(0, backupDataPtr, dataToRead ); + iDataBuffer->Delete(0, dataToRead); + iDataBufferSize -= dataToRead; + + if ( !iLastChunk || iDataBufferSize>0 ) { - backupDataPtr.Append( iDataPtr[iDataPos] ); - copyPos++; - } - - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \ - End - copyPos: %d", copyPos ); - LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : \ - End - iDataPos: %d", iDataPos ); - - //Are there more data left in the buffer - if( iDataPos < dataBufLength ) - { - LOGGER_WRITE( "iSBEClient->RequestDataL( stt ) : There is more data in buffer" ); - iDataLeft = ETrue; + LOGGER_WRITE( "CSConSBEClient::ProcessRequestDataL() : There are more data available" ); iCurrentTask->iRequestDataParams->iMoreData = ETrue; //Another task is needed to transfer the data to the client ret = KErrCompletion; } else { - //Check if the backup server has more data from the dataowner - if( !iLastChunk ) - { - iCurrentTask->iRequestDataParams->iMoreData = ETrue; - //Another task is needed to transfer the data to the client - ret = KErrCompletion; - LOGGER_WRITE( "iSBEClient->RequestDataL( stt ) : There are more data available from SBE" ); - } - else - { - iCurrentTask->iRequestDataParams->iMoreData = EFalse; - } - - iDataPos = 0; - iDataLeft = EFalse; + LOGGER_WRITE( "CSConSBEClient::ProcessRequestDataL() : All data readed" ); + iDataBuffer->Reset(); + iDataBufferSize = 0; + // task will be completed, initialize iLastChunk value for next operation + iLastChunk = EFalse; } + LOGGER_WRITE_1( "CSConSBEClient::ProcessRequestDataL() : returned %d", ret ); return ret; } + +void CSConSBEClient::RequestDataL( CSBGenericTransferType& aGenericTransferType ) + { + TRACE_FUNC_ENTRY; + if ( !iDataBuffer ) + User::Leave( KErrArgument ); + + do + { + LOGGER_WRITE( "iSBEClient->RequestDataL() : start" ); + TRequestStatus status; + iSBEClient->RequestDataL( aGenericTransferType, status ); + User::WaitForRequest( status ); + LOGGER_WRITE_1( "iSBEClient->RequestDataL() : status.Int() %d", status.Int() ); + User::LeaveIfError( status.Int() ); + + //Get the data and store the handle + CSBGenericTransferType* gtt = NULL; + const TPtrC8& dataPtr = iSBEClient->TransferDataInfoL( gtt, iLastChunk ); + LOGGER_WRITE_1("data size: %d", dataPtr.Length()); + delete gtt; + iDataBuffer->ExpandL( iDataBufferSize, dataPtr.Length() ); + iDataBuffer->Write(iDataBufferSize, dataPtr); + iDataBufferSize += dataPtr.Length(); + LOGGER_WRITE_1("total buffer size: %d", iDataBufferSize); + } + // Continue if there are more data, and our packet is not full + while ( !iLastChunk && iDataBufferSize < KMaxObjectSize ); + + TRACE_FUNC_EXIT; + } // ----------------------------------------------------------------------------- // CSConSBEClient::ProcessGetDataOwnerStatusL() @@ -1556,6 +1490,15 @@ iSBEClient = NULL; iSBEClient = CSBEClient::NewL(); } + else if ( aErr ) // error + { + if ( iDataBuffer ) + { + iDataBuffer->Reset(); + iDataBufferSize = 0; + } + iLastChunk = EFalse; + } TRACE_FUNC_EXIT; } diff -r dbd1c5e08735 -r 453dfc402455 connectivitymodules/SeCon/services/pcd/src/sconsynchandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connectivitymodules/SeCon/services/pcd/src/sconsynchandler.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -0,0 +1,1460 @@ +/* +* 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: CSconSyncHandler implementation +* +*/ + + +#include "sconsynchandler.h" +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" + +// versions up to 5 must be backward compatible +const TUint16 KFormatVersionNumber ( 1 ); + +_LIT8(KCommandListStores, "SYNC: ListStores"); +_LIT8(KCommandOpenStore, "SYNC: OpenStore: "); +_LIT8(KCommandCloseStore, "SYNC: CloseStore"); +_LIT8(KCommandListChanges, "SYNC: ListChanges"); +_LIT8(KCommandResetChangeInfo, "SYNC: ResetChangeInfo"); +_LIT8(KCommandCommitChanges, "SYNC: CommitChanges: "); +_LIT8(KCommandReadItems, "SYNC: ReadItems: "); +_LIT8(KCommandGetParents, "SYNC: GetParents: "); +_LIT8(KCommandCreateItems, "SYNC: CreateItems"); +_LIT8(KCommandGetCreateItemsResponse, "SYNC: GetCreateItemsResponse"); +_LIT8(KCommandGetCreateItems, "SYNC: GetCreateItems: "); +_LIT8(KCommandReplaceItems, "SYNC: ReplaceItems"); +_LIT8(KCommandGetReplaceItemsResponse, "SYNC: GetReplaceItemsResponse"); +_LIT8(KCommandGetReplaceItems, "SYNC: GetReplaceItems: "); +_LIT8(KCommandMoveItems, "SYNC: MoveItems"); +_LIT8(KCommandDeleteItems, "SYNC: DeleteItems: "); +_LIT8(KCommandSoftDeleteItems, "SYNC: SoftDeleteItems: "); +_LIT8(KCommandDeleteAllItems, "SYNC: DeleteAllItems"); +_LIT8(KCommandDeleteAllItemsStatus, "SYNC: GetDeleteAllItemsStatus"); +_LIT8(KCommandGetStoreFormat, "SYNC: GetStoreFormat"); +_LIT8(KCommandSetRemoteStoreFormat, "SYNC: SetRemoteStoreFormat"); +_LIT8(KCommandGetRestOfData, "SYNC: GetRestOfData"); +_LIT8(KCommandCancel, "SYNC: Cancel"); + + +_LIT(KRemoteFormatStore, "remoteformatstore_0x%08x.dat"); +_LIT(KDataFileExtension, ".tmp"); + +const TInt KTimeStampLength = 16; +_LIT8(KTimeStampFormat, "%02d%02d%04dT%02d%02d%02dZ"); + +const TInt KDefaultExpandSize = 1024; + +// Calendar sync specific constants +const TInt KCalendarDsUid = 0x101F6DDE; + +CSconSyncHandler::~CSconSyncHandler() + { + TRACE_FUNC_ENTRY; + Cancel(); + iSyncSession.Close(); + delete iResponseData; + iFileStream.Close(); + iCreatedItems.Close(); + iReplacedItems.Close(); + iItemsToRead.Close(); + iFs.Delete( iFileInProgress ); + ClearCalendarCenrepL(); + TRACE_FUNC_EXIT; + } + +CSconSyncHandler::CSconSyncHandler( RFs& aFs ) + : CActive( EPriorityStandard ), iFs(aFs), iCreatedItemUidPckg(iCreatedItemUid) + { + CActiveScheduler::Add( this ); + } + +CSconSyncHandler* CSconSyncHandler::NewL( RFs& aFs) + { + TRACE_FUNC_ENTRY; + CSconSyncHandler* self = new (ELeave) CSconSyncHandler(aFs); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + TRACE_FUNC_EXIT; + return self; + } + +void CSconSyncHandler::ConstructL() + { + TInt err = iFs.CreatePrivatePath( EDriveC ); + LOGGER_WRITE_1("CreatePrivatePath err: %d", err); + iFs.SetSessionToPrivate( EDriveC ); + } + +void CSconSyncHandler::HandleGetSyncRequestL( const TDesC8& aRequest, RWriteStream& aResult, TInt aMaxObjectSize ) + { + TRACE_FUNC_ENTRY; + iMaxObjectSize = aMaxObjectSize; + iBytesWrited = 0; + LOGGER_WRITE_1("iMaxObjectSize: %d", iMaxObjectSize); + if ( !iConnected ) + { + LOGGER_WRITE("Try to connect") + User::LeaveIfError( iSyncSession.Connect() ); + iConnected = ETrue; + } + + if ( aRequest.Compare( KCommandListStores ) == KErrNone ) + { + ListStoresL( aResult ); + } + else if ( aRequest.Find( KCommandOpenStore ) == 0 ) + { + TPtrC8 params = aRequest.Mid( KCommandOpenStore().Length() ); + OpenStoreL( params, aResult ); + } + else if ( aRequest.Find( KCommandCloseStore ) == 0 ) + { + CloseStoreL( aResult ); + } + else if ( aRequest.Find( KCommandListChanges ) == 0 ) + { + ListChangesL( aResult ); + } + else if ( aRequest.Find( KCommandResetChangeInfo ) == 0 ) + { + ResetChangeInfoL( aResult ); + } + else if ( aRequest.Find( KCommandCommitChanges ) == 0 ) + { + TPtrC8 params = aRequest.Mid( KCommandCommitChanges().Length() ); + CommitChangesL( params, aResult ); + } + else if ( aRequest.Find( KCommandReadItems ) == 0 ) + { + TPtrC8 params = aRequest.Mid( KCommandReadItems().Length() ); + ReadItemsL( params, aResult ); + } + else if ( aRequest.Find( KCommandGetParents ) == 0 ) + { + TPtrC8 params = aRequest.Mid( KCommandGetParents().Length() ); + GetParentsL( params, aResult ); + } + else if ( aRequest.Find( KCommandGetRestOfData ) == 0 ) + { + // Get rest of data + ReadNextDataBlockL( aResult ); + } + else if ( aRequest.Find( KCommandGetCreateItemsResponse ) == 0 ) + { + GetCreateItemsResponseL( KNullDesC8(), aResult ); + } + else if ( aRequest.Find( KCommandGetCreateItems ) == 0 ) + { + TPtrC8 params = aRequest.Mid( KCommandGetCreateItems().Length() ); + GetCreateItemsResponseL( params, aResult ); + } + else if ( aRequest.Find( KCommandGetReplaceItemsResponse ) == 0 ) + { + TPtrC8 params = aRequest.Mid( KCommandGetReplaceItemsResponse().Length() ); + GetReplaceItemsResponseL( KNullDesC8(), aResult ); + } + else if ( aRequest.Find( KCommandGetReplaceItems ) == 0 ) + { + TPtrC8 params = aRequest.Mid( KCommandGetReplaceItems().Length() ); + GetReplaceItemsResponseL( params, aResult ); + } + else if ( aRequest.Find( KCommandMoveItems ) == 0 ) + { + TPtrC8 params = aRequest.Mid( KCommandMoveItems().Length() ); + MoveItemsL( params, aResult ); + } + else if ( aRequest.Find( KCommandDeleteItems ) == 0 ) + { + TPtrC8 params = aRequest.Mid( KCommandDeleteItems().Length() ); + DeleteItemsL( params, aResult ); + } + else if ( aRequest.Find( KCommandSoftDeleteItems ) == 0 ) + { + TPtrC8 params = aRequest.Mid( KCommandSoftDeleteItems().Length() ); + SoftDeleteItemsL( params, aResult ); + } + else if ( aRequest.Find( KCommandDeleteAllItems ) == 0 ) + { + DeleteAllItemsL( aResult ); + } + else if ( aRequest.Find( KCommandDeleteAllItemsStatus ) == 0 ) + { + GetDeleteAllItemsStatusL( aResult ); + } + else if ( aRequest.Find( KCommandGetStoreFormat ) == 0 ) + { + GetStoreFormatL( aResult ); + } + else if ( aRequest.Find( KCommandCancel ) == 0 ) + { + CancelOperationsL( aResult ); + } + else + { + LOGGER_WRITE("Unknown command"); + User::Leave( KErrNotSupported ); + } + TRACE_FUNC_EXIT; + } + + +void CSconSyncHandler::HandlePutSyncRequestL( const TDesC8& aRequest, RReadStream& aData ) + { + TRACE_FUNC_ENTRY; + if ( !iConnected ) + { + LOGGER_WRITE("Try to connect") + User::LeaveIfError( iSyncSession.Connect() ); + iConnected = ETrue; + } + if ( aRequest.Find( KCommandCreateItems ) == KErrNone ) + { + CreateItemsL( aData ); + } + else if ( aRequest.Find( KCommandReplaceItems ) == 0 ) + { + ReplaceItemsL( aData ); + } + else if ( aRequest.Find( KCommandSetRemoteStoreFormat ) == 0 ) + { + SetRemoteStoreFormatL( aData ); + } + else + { + LOGGER_WRITE("Unknown command"); + User::Leave( KErrNotSupported ); + } + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::ListStoresL( RWriteStream& aResult ) + { + TRACE_FUNC_ENTRY; + RSconDataProviderInfoArray infoArray(5); + CleanupResetAndDestroyPushL( infoArray ); + iSyncSession.ListAllImplementationsL( infoArray ); + LOGGER_WRITE_1("infoArray.Count(): %d", infoArray.Count()); + aResult.WriteInt32L( infoArray.Count() ); + for (TInt i=0; iDes(); + stream.ReadL( bufPtr8, len ); + + LOGGER_WRITE8_1("storeName8: %S", &bufPtr8); + + // and convert it to unicode + HBufC* storeName = CnvUtfConverter::ConvertToUnicodeFromUtf8L( bufPtr8 ); + CleanupStack::PopAndDestroy( buf8 ); + CleanupStack::PushL( storeName ); + + TPtr storeNamePtr = storeName->Des(); + LOGGER_WRITE_1("storeName: %S", &storeNamePtr); + + if ( providerId == KCalendarDsUid && aParams.Size() > + sizeof(TInt32) // providerId + + sizeof(TInt32) // contextId + + sizeof(TUint16)// storeName len + + len ) // storeName + { + TInt profileId = stream.ReadInt32L(); + len = stream.ReadUint16L(); + HBufC8* buffer = HBufC8::NewLC( len ); + TPtr8 bufferPtr8 = buffer->Des(); + stream.ReadL( bufferPtr8, len ); + HBufC* serverId = CnvUtfConverter::ConvertToUnicodeFromUtf8L( bufferPtr8 ); + CleanupStack::PopAndDestroy( buffer ); + CleanupStack::PushL( serverId ); + SetCalendarCenrepL( profileId, serverId->Des() ); + CleanupStack::PopAndDestroy(serverId); + } + + aResult.WriteUint16L( KFormatVersionNumber ); + TRAPD( err, iSyncSession.OpenDataStoreL( providerId, storeName->Des(), contextId)); + if ( err == KErrServerTerminated ) + { + // server terminated, try to reconnect + iConnected = EFalse; + LOGGER_WRITE("Try to re-connect"); + err = iSyncSession.Connect(); + LOGGER_WRITE_1("iSyncSession.Connect() err: %d", err); + if ( !err ) + { + iConnected = ETrue; + TRAP( err, iSyncSession.OpenDataStoreL( providerId, storeName->Des(), contextId)); + } + } + + CleanupStack::PopAndDestroy( storeName ); + CleanupStack::PopAndDestroy( &stream ); + + aResult.WriteInt32L( err ); + + if ( err ) + { + LOGGER_WRITE_1("Error: %d", err); + LOGGER_WRITE("iSyncSession.CloseDataStore()"); + iSyncSession.CloseDataStore(); + ClearCalendarCenrepL(); + return; + } + iCurrentDataProviderUid = providerId; + iCurrentContextUid = contextId; + + + // Now the store is opened + TRAP(err, LoadRemoteStoreFormatL( contextId, providerId )); + if ( err ) + { + aResult.WriteUint8L( 1 ); // Remote store format needed + } + else + { + aResult.WriteUint8L( 0 ); // Remote store format not needed + } + + // return last sync timestamp, if has synced before. + TBool hasHistory = iSyncSession.HasSyncHistoryL(); + TUint8 historyFlag(0); + if ( hasHistory ) + { + historyFlag = 1; + } + aResult.WriteUint8L( historyFlag ); + + if ( hasHistory ) + { + TDateTime timeStamp; + TInt err(KErrNone); + TRAP(err, iSyncSession.GetSyncTimeStampL( providerId, contextId, timeStamp)); + LOGGER_WRITE_1("GetSyncTimeStampL err: %d", err); + + TBuf8 timeStampBuf; + + timeStampBuf.Format( KTimeStampFormat, + timeStamp.Day()+1,timeStamp.Month()+1, timeStamp.Year(), + timeStamp.Hour(), timeStamp.Minute(), timeStamp.Second() ); + LOGGER_WRITE8_1("timeStamp: %S", &timeStampBuf); + aResult.WriteL( timeStampBuf ); + } + + + // for testin purposes only + /* + if (!remoteStoreSetted) + { + RStringPool pool; + pool.OpenL(); + CleanupClosePushL( pool ); + CSmlDataStoreFormat* storeFormat(NULL); + TRAPD( err, storeFormat = iSyncSession.StoreFormatL( pool ) ); + CleanupStack::PushL( storeFormat ); + + iSyncSession.SetRemoteStoreFormatL( *storeFormat ); + SaveRemoteStoreFormatL( *storeFormat, contextId, providerId ); + + CleanupStack::PopAndDestroy( storeFormat ); + CleanupStack::PopAndDestroy( &pool ); + } + */ + + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::LoadRemoteStoreFormatL( TInt aContextId, TInt aProviderId ) + { + TRACE_FUNC_ENTRY; + TFileName remoteFormatStore; + iFs.SetSessionToPrivate( EDriveC ); + remoteFormatStore.Format( KRemoteFormatStore, aContextId ); + + CDictionaryFileStore* dictionaryStore = + CDictionaryFileStore::OpenLC(iFs, remoteFormatStore, TUid::Uid(0x0001)); + TBool present = dictionaryStore->IsPresentL( TUid::Uid(aProviderId) ); + if ( !present ) + { + LOGGER_WRITE("Remote store was not saved"); + User::Leave( KErrNotFound ); + } + else + { + RDictionaryReadStream stream; + stream.OpenLC( *dictionaryStore, TUid::Uid(aProviderId) ); + RStringPool stringPool; + stringPool.OpenL(); + CleanupClosePushL( stringPool ); + CSmlDataStoreFormat* storeFormat = CSmlDataStoreFormat::NewLC(stringPool, stream); + iSyncSession.SetRemoteStoreFormatL( *storeFormat ); + CleanupStack::PopAndDestroy( storeFormat ); + CleanupStack::PopAndDestroy( &stringPool ); + CleanupStack::PopAndDestroy(); //OpenLC + } + CleanupStack::PopAndDestroy( dictionaryStore ); + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::SaveRemoteStoreFormatL( CSmlDataStoreFormat& aStoreFormat, TInt aContextId, TInt aProviderId) + { + TRACE_FUNC_ENTRY; + iFs.SetSessionToPrivate( EDriveC ); + TFileName remoteFormatStore; + remoteFormatStore.Format( KRemoteFormatStore, aContextId ); + CDictionaryFileStore* dictionaryStore = + CDictionaryFileStore::OpenLC(iFs, remoteFormatStore, TUid::Uid(0x0001)); + + RDictionaryWriteStream stream; + stream.AssignLC( *dictionaryStore, TUid::Uid(aProviderId) ); + + aStoreFormat.ExternalizeL( stream ); + stream.CommitL(); + CleanupStack::PopAndDestroy(); //AssignLC + dictionaryStore->CommitL(); + + CleanupStack::PopAndDestroy( dictionaryStore ); + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::CloseStoreL( RWriteStream& aResult ) + { + TRACE_FUNC_ENTRY; + iSyncSession.CloseDataStore(); + ClearCalendarCenrepL(); + + // Get last used timestamp if provider was open + if ( iCurrentDataProviderUid != 0 ) + { + TDateTime timeStamp; + iSyncSession.GetSyncTimeStampL(iCurrentDataProviderUid, iCurrentContextUid, timeStamp ); + + iCurrentDataProviderUid = 0; + iCurrentContextUid = 0; + + const TInt KTimeStampLength = 16; + TBuf8 timeStampBuf; + + + timeStampBuf.Format( KTimeStampFormat, + timeStamp.Day()+1,timeStamp.Month()+1, timeStamp.Year(), + timeStamp.Hour(), timeStamp.Minute(), timeStamp.Second() ); + aResult.WriteL( timeStampBuf ); + } + + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::ListChangesL( RWriteStream& aResult ) + { + TRACE_FUNC_ENTRY; + RArray items; + CleanupClosePushL( items ); + + iSyncSession.AddedItemsL( items ); + LOGGER_WRITE_1("Added items count: %d", items.Count()); + aResult.WriteInt32L( items.Count() ); + for (TInt i=0; i items; + CleanupClosePushL( items ); + for ( TInt i=0; i 0 ) + { + iSyncSession.CommitChangeInfoL( items ); + } + + CleanupStack::PopAndDestroy( &items ); + CleanupStack::PopAndDestroy( &stream ); + + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::ReadItemsL( const TDesC8& aParams, RWriteStream& aResult ) + { + TRACE_FUNC_ENTRY; + iItemsToRead.Reset(); + LOGGER_WRITE_1("aParams length: %d", aParams.Length()); + + const TUint8* ptr = aParams.Ptr(); + RMemReadStream stream( ptr , aParams.Size() ); + CleanupClosePushL( stream ); + + // Read item uids from parameter + TInt itemCount = stream.ReadInt32L(); + LOGGER_WRITE_1("Item count: %d", itemCount); + for ( TInt i=0; iSize() == 0 ) && iItemsToRead.Count() == 0 ) + { + // no data + LOGGER_WRITE("no more data or items"); + User::Leave(KErrEof); + } + + if ( iResponseData ) + { + // write data from tempbuffer to response buffer + TInt writeLength = iResponseData->Size(); + if ( writeLength > iMaxObjectSize-iBytesWrited ) + { + writeLength = iMaxObjectSize-iBytesWrited; + } + aResult.WriteL( iResponseData->Ptr(0), writeLength ); + iBytesWrited += writeLength; + + if ( iResponseData->Size() > writeLength ) + { + iResponseData->Delete(0, writeLength); + } + else + { + iResponseData->Reset(); + } + } + if ( iBytesWrited == iMaxObjectSize ) + { + // responce buffer is full, return it. + LOGGER_WRITE("Stream is full, return it"); + return; + } + + TBool streamIsFull( EFalse ); + // Read items from server + CBufFlat* dataBuffer = CBufFlat::NewL(KDefaultExpandSize); + CleanupStack::PushL( dataBuffer ); + while ( iItemsToRead.Count() > 0 && !streamIsFull ) + { + if ( iMaxObjectSize-iBytesWrited < sizeof(TUint32) ) + { + streamIsFull = ETrue; + LOGGER_WRITE("Stream is full, don't read next item"); + continue; + } + ReadItemL( iItemsToRead[0], *dataBuffer ); + aResult.WriteUint32L( dataBuffer->Size() ); + iBytesWrited += sizeof( TUint32 ); + + TInt writeLength = dataBuffer->Size(); + if ( writeLength > iMaxObjectSize-iBytesWrited ) + { + writeLength = iMaxObjectSize-iBytesWrited; + LOGGER_WRITE_1("Write only %d bytes", writeLength); + } + aResult.WriteL( dataBuffer->Ptr(0), writeLength ); + iBytesWrited += writeLength; + + if ( dataBuffer->Size() > writeLength ) + { + // write rest to next data block + if ( !iResponseData ) + { + iResponseData = CBufFlat::NewL(KDefaultExpandSize); + } + iResponseData->Reset(); + LOGGER_WRITE_1("Save %d bytes for next request", dataBuffer->Size() - writeLength); + iResponseData->ResizeL( dataBuffer->Size() - writeLength ); + iResponseData->Write(0, dataBuffer->Ptr( writeLength )); + streamIsFull = ETrue; + } + + iItemsToRead.Remove(0); + + if ( iBytesWrited == iMaxObjectSize ) + { + // writestream is full + LOGGER_WRITE("Stream is full"); + streamIsFull = ETrue; + } + + } + aResult.CommitL(); + + CleanupStack::PopAndDestroy( dataBuffer ); + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::ReadItemL( TSmlDbItemUid aUid, CBufFlat& aItemData ) + { + TRACE_FUNC_ENTRY; + aItemData.Reset(); + CBufFlat* dataBuffer = CBufFlat::NewL(KDefaultExpandSize); + CleanupStack::PushL( dataBuffer ); + TSmlDbItemUid parent(-1); + TBool fieldChange(EFalse); + + TBuf8<256> mimeType; + TBuf8<100> mimeVer; + TRAPD( err, iSyncSession.OpenItemL( aUid, fieldChange, + parent, mimeType, mimeVer, *dataBuffer )); + if ( err ) + { + LOGGER_WRITE_1("Could not read item %d", aUid); + // only item uid and errorcode will be writed + aItemData.ResizeL( + sizeof(TInt32) + + sizeof(TInt32)); + + } + else + { + // reserve memory for all fields + aItemData.ResizeL( + sizeof(TInt32) + + sizeof(TInt32) + + sizeof(TUint8) + + sizeof(TInt32) + + sizeof(TUint16) + + mimeType.Length() + + sizeof(TUint16) + + mimeVer.Length() + + sizeof(TInt32) + + dataBuffer->Size() + ); + } + + RBufWriteStream tempStream( aItemData ); + CleanupClosePushL( tempStream ); + tempStream.WriteInt32L( aUid ); + tempStream.WriteInt32L( err ); + if ( !err ) + { + tempStream.WriteUint8L( fieldChange ); + tempStream.WriteInt32L( parent ); + tempStream.WriteUint16L( mimeType.Length() ); + tempStream.WriteL( mimeType ); + tempStream.WriteUint16L( mimeVer.Length() ); + tempStream.WriteL( mimeVer ); + tempStream.WriteInt32L( dataBuffer->Size() ); + tempStream.WriteL( dataBuffer->Ptr(0), dataBuffer->Size() ); + } + tempStream.CommitL(); + CleanupStack::PopAndDestroy( &tempStream ); + CleanupStack::PopAndDestroy( dataBuffer ); + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::CreateItemsL( RReadStream& aData ) + { + TRACE_FUNC_ENTRY; + delete iResponseData; + iResponseData = NULL; + iResponseData = CBufFlat::NewL(KDefaultExpandSize); + RBufWriteStream responseStream( *iResponseData ); + CleanupClosePushL( responseStream ); + // Read item uids from parameter + TInt itemCount = aData.ReadInt32L(); + LOGGER_WRITE_1("itemCount: %d", itemCount); + responseStream.WriteInt32L( itemCount ); + for ( TInt i=0; iDes(); + aData.ReadL(mimeTypePtr, len); + + len = aData.ReadUint16L(); + HBufC8* mimeVerBuf = HBufC8::NewLC( len ); + TPtr8 mimeVerPtr = mimeVerBuf->Des(); + aData.ReadL(mimeVerPtr, len); + + len = aData.ReadInt32L(); + HBufC8* dataBuf = HBufC8::NewLC( len ); + TPtr8 dataPtr = dataBuf->Des(); + aData.ReadL( dataPtr, len ); + + TSmlDbItemUid newUid(-1); + LOGGER_WRITE("read from aData stream -readed ok"); + TRAPD( err, iSyncSession.CreateItemL(newUid, + parent, mimeTypePtr, + mimeVerPtr, dataPtr)); + + CleanupStack::PopAndDestroy( dataBuf ); + CleanupStack::PopAndDestroy( mimeVerBuf ); + CleanupStack::PopAndDestroy( mimeTypeBuf ); + LOGGER_WRITE("Write to responseStream"); + responseStream.WriteInt32L( tempUid ); + responseStream.WriteInt32L( err ); + if ( !err ) + { + responseStream.WriteInt32L( newUid ); + } + LOGGER_WRITE("Write to responseStream -writed ok"); + } + + responseStream.CommitL(); + CleanupStack::PopAndDestroy( &responseStream ); + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::GetCreateItemsResponseL( const TDesC8& aParams, RWriteStream& aResult ) + { + TRACE_FUNC_ENTRY; + if ( aParams.Length() > 0 ) + { + LOGGER_WRITE_1("params length: %d", aParams.Length()); + + //LOGGER_WRITE8_1("aParams: %S", &aParams); + if ( iSyncStatus == EReady ) + { + LOGGER_WRITE("Start creating items from file"); + iCreatedItems.Reset(); + const TUint8* ptr = aParams.Ptr(); + RMemReadStream stream( ptr , aParams.Size() ); + CleanupClosePushL( stream ); + TInt filenameLength = stream.ReadInt32L(); + LOGGER_WRITE_1("filename length: %d", filenameLength ); + HBufC8* filenameBuf8 = HBufC8::NewLC( /*stream,*/ filenameLength ); // filename + TPtr8 filenamePtr = filenameBuf8->Des(); + stream.ReadL( filenamePtr, filenameLength); + LOGGER_WRITE("filename ok"); + TInt err = CnvUtfConverter::ConvertToUnicodeFromUtf8(iFileInProgress, filenamePtr ); + LOGGER_WRITE_1("ConvertToUnicodeFromUtf8 err: %d", err); + User::LeaveIfError( err ); + LOGGER_WRITE_1("iFileInProgress: %S", &iFileInProgress); + + if ( iFileInProgress.RightTPtr(KDataFileExtension().Length()).CompareF(KDataFileExtension) != 0 ) + { + iFileInProgress = KNullDesC(); + LOGGER_WRITE("File extendion was not correct"); + User::Leave( KErrAccessDenied ); + } + + CleanupStack::PopAndDestroy( filenameBuf8 ); + + LOGGER_WRITE("open file"); + err = iFileStream.Open(iFs,iFileInProgress, EFileShareReadersOnly); + LOGGER_WRITE_1("iFileStream.Open err: %d", err); + User::LeaveIfError( err ); + + CleanupStack::PopAndDestroy( &stream ); + + iSyncStatus = ECreatingItemsFromFile; + iItemsLeftInStream = iFileStream.ReadInt32L(); + LOGGER_WRITE_1("iItemsLeftInStream: %d", iItemsLeftInStream); + aResult.WriteInt32L( iItemsLeftInStream ); + aResult.WriteInt32L( 0 ); // completed items since last sync + CreateNextItemOnStreamL(); + iItemsLeftInStream--; + } + else if ( iSyncStatus == ECreatingItemsFromFile || iSyncStatus == EItemsCreated ) + { + LOGGER_WRITE("Read status"); + TInt temp = 0; + if ( iSyncStatus == ECreatingItemsFromFile ) + { + // one item is on progress, add it to to "left" items. + temp = 1; + } + LOGGER_WRITE_1("left items: %d", iItemsLeftInStream + temp); + LOGGER_WRITE_1("completed items: %d", iCreatedItems.Count()); + aResult.WriteInt32L( iItemsLeftInStream + temp ); // items in progress + aResult.WriteInt32L( iCreatedItems.Count() ); // completed items since last get + + while ( iCreatedItems.Count() > 0 ) + { + aResult.WriteInt32L( iCreatedItems[0].iTemporaryId ); + aResult.WriteInt32L( iCreatedItems[0].iErrorCode ); + if ( !iCreatedItems[0].iErrorCode ) + { + aResult.WriteInt32L( iCreatedItems[0].iNewUid ); + } + iCreatedItems.Remove(0); + } + if ( iSyncStatus == EItemsCreated ) + { + // all done + iSyncStatus = EReady; + LOGGER_WRITE("iSyncStatus = EReady"); + } + } + else + { + LOGGER_WRITE_1("Wrong sync status: %d", iSyncStatus); + User::Leave( KErrInUse ); + } + } + else + { + LOGGER_WRITE("Read response"); + if ( !iResponseData ) + { + User::Leave( KErrNotReady ); + } + aResult.WriteL( iResponseData->Ptr(0), iResponseData->Size() ); + delete iResponseData; + iResponseData = NULL; + } + aResult.CommitL(); + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::ReplaceItemsL( RReadStream& aData ) + { + TRACE_FUNC_ENTRY; + delete iResponseData; + iResponseData = NULL; + iResponseData = CBufFlat::NewL(KDefaultExpandSize); + RBufWriteStream responseStream( *iResponseData ); + CleanupClosePushL( responseStream ); + // Read item uids from parameter + TInt itemCount = aData.ReadInt32L(); + + responseStream.WriteInt32L( itemCount ); + for ( TInt i=0; iDes(); + aData.ReadL( dataPtr, len ); + + TRAPD( err, iSyncSession.ReplaceItemL(uid, + parent, + fieldChange, dataPtr)); + CleanupStack::PopAndDestroy( dataBuf ); + + responseStream.WriteInt32L( uid ); + responseStream.WriteInt32L( err ); + } + responseStream.CommitL(); + CleanupStack::PopAndDestroy( &responseStream ); + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::GetReplaceItemsResponseL( const TDesC8& aParams, RWriteStream& aResult ) + { + TRACE_FUNC_ENTRY; + if ( aParams.Length() > 0 ) + { + LOGGER_WRITE8_1("aParams: %S", &aParams); + if ( iSyncStatus == EReady ) + { + LOGGER_WRITE("Start replacing items from file"); + iReplacedItems.Reset(); + + // create parameter stream reader + const TUint8* ptr = aParams.Ptr(); + RMemReadStream stream( ptr , aParams.Size() ); + CleanupClosePushL( stream ); + + // read filename + TInt filenameLength = stream.ReadInt32L(); + LOGGER_WRITE_1("filename length: %d", filenameLength ); + HBufC8* filenameBuf8 = HBufC8::NewLC( filenameLength ); // filename + TPtr8 filenamePtr = filenameBuf8->Des(); + stream.ReadL( filenamePtr, filenameLength); + LOGGER_WRITE("filename ok"); + + TInt err = CnvUtfConverter::ConvertToUnicodeFromUtf8(iFileInProgress, filenameBuf8->Des() ); + LOGGER_WRITE_1("ConvertToUnicodeFromUtf8 err: %d", err); + User::LeaveIfError( err ); + if ( iFileInProgress.RightTPtr(KDataFileExtension().Length()).CompareF(KDataFileExtension) != 0 ) + { + iFileInProgress = KNullDesC(); + LOGGER_WRITE("File extendion was not correct"); + User::Leave( KErrAccessDenied ); + } + + // open file + err = iFileStream.Open(iFs, iFileInProgress, EFileShareReadersOnly); + LOGGER_WRITE_1("iFileStream.Open err: %d", err); + User::LeaveIfError( err ); + + CleanupStack::PopAndDestroy( filenameBuf8 ); + CleanupStack::PopAndDestroy( &stream ); + + iSyncStatus = EReplacingItemsFromFile; + iItemsLeftInStream = iFileStream.ReadInt32L(); + LOGGER_WRITE_1("iItemsLeftInStream: %d", iItemsLeftInStream); + // write results to return stream + aResult.WriteInt32L( iItemsLeftInStream ); + aResult.WriteInt32L( 0 ); // completed items since last sync + ReplaceNextItemOnStreamL(); + iItemsLeftInStream--; + } + else if ( iSyncStatus == EReplacingItemsFromFile || iSyncStatus == EItemsReplaced ) + { + LOGGER_WRITE("Read status"); + TInt temp = 0; + if ( iSyncStatus == EReplacingItemsFromFile ) + { + // one item is on progress, add it to to "left" items. + temp = 1; + } + LOGGER_WRITE_1("left items: %d", iItemsLeftInStream + temp); + LOGGER_WRITE_1("completed items: %d", iReplacedItems.Count()); + aResult.WriteInt32L( iItemsLeftInStream + temp ); // items in progress + aResult.WriteInt32L( iReplacedItems.Count() ); // completed items since last get + //for (TInt i=0; i 0 ) + { + aResult.WriteInt32L( iReplacedItems[0].iItemUid ); + aResult.WriteInt32L( iReplacedItems[0].iErrorCode ); + iReplacedItems.Remove(0); + } + if ( iSyncStatus == EItemsReplaced ) + { + // all done + iSyncStatus = EReady; + LOGGER_WRITE("iSyncStatus = EReady"); + } + } + } + else + { + if ( !iResponseData ) + { + LOGGER_WRITE("No response data, leave KErrNotReady"); + User::Leave( KErrNotReady ); + } + aResult.WriteL( iResponseData->Ptr(0), iResponseData->Size() ); + aResult.CommitL(); + delete iResponseData; + iResponseData = NULL; + } + aResult.CommitL(); + + + + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::MoveItemsL( const TDesC8& aParams, RWriteStream& aResult ) + { + TRACE_FUNC_ENTRY; + const TUint8* ptr = aParams.Ptr(); + RMemReadStream stream( ptr , aParams.Size() ); + CleanupClosePushL( stream ); + + // Read item uids from parameter + TInt itemCount = stream.ReadInt32L(); + aResult.WriteInt32L( itemCount ); + for ( TInt i=0; iExternalizeL( aResult ); + } + CleanupStack::PopAndDestroy( storeFormat ); + CleanupStack::PopAndDestroy( &pool ); + TRACE_FUNC_EXIT; + } + + +void CSconSyncHandler::SetRemoteStoreFormatL( RReadStream& aData ) + { + TRACE_FUNC_ENTRY; + RStringPool pool; + pool.OpenL(); + CleanupClosePushL( pool ); + CSmlDataStoreFormat* serverDataStoreFormat = CSmlDataStoreFormat::NewLC( pool, aData ); + iSyncSession.SetRemoteStoreFormatL( *serverDataStoreFormat ); + // Save format for later use + TRAPD(err, SaveRemoteStoreFormatL( *serverDataStoreFormat, iCurrentContextUid, iCurrentDataProviderUid )); + if ( err ) + { + LOGGER_WRITE_1("SaveRemoteStoreFormatL err: %d", err); + } + CleanupStack::PopAndDestroy( serverDataStoreFormat ); + CleanupStack::PopAndDestroy( &pool ); + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::CreateNextItemOnStreamL() + { + TRACE_FUNC_ENTRY; + if ( IsActive() ) + { + LOGGER_WRITE("Warning: Was on active state!"); + Cancel(); + } + iTemporaryItemUid = iFileStream.ReadInt32L(); + TSmlDbItemUid parent = iFileStream.ReadInt32L(); + + TInt len = iFileStream.ReadUint16L(); + HBufC8* mimeTypeBuf = HBufC8::NewLC( len ); + TPtr8 mimeTypePtr = mimeTypeBuf->Des(); + iFileStream.ReadL(mimeTypePtr, len); + + len = iFileStream.ReadUint16L(); + HBufC8* mimeVerBuf = HBufC8::NewLC( len ); + TPtr8 mimeVerPtr = mimeVerBuf->Des(); + iFileStream.ReadL(mimeVerPtr, len); + + len = iFileStream.ReadInt32L(); + HBufC8* dataBuf = HBufC8::NewLC( len ); + TPtr8 dataPtr = dataBuf->Des(); + iFileStream.ReadL( dataPtr, len ); + + SetActive(); + iStatus = KRequestPending; + iSyncSession.CreateItemL(iCreatedItemUidPckg, + parent, mimeTypePtr, + mimeVerPtr, dataPtr, iStatus); + + CleanupStack::PopAndDestroy( dataBuf ); + CleanupStack::PopAndDestroy( mimeVerBuf ); + CleanupStack::PopAndDestroy( mimeTypeBuf ); + + + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::ReplaceNextItemOnStreamL() + { + TRACE_FUNC_ENTRY; + if ( IsActive() ) + { + LOGGER_WRITE("Warning: Was on active state!"); + Cancel(); + } + TSmlDbItemUid uid = iFileStream.ReadInt32L(); + TSmlDbItemUid parent = iFileStream.ReadInt32L(); + TBool fieldChange = iFileStream.ReadUint8L(); + TInt len = iFileStream.ReadInt32L(); + HBufC8* dataBuf = HBufC8::NewLC( len ); + TPtr8 dataPtr = dataBuf->Des(); + iFileStream.ReadL( dataPtr, len ); + + iReplacedItem.iItemUid = uid; + + SetActive(); + iStatus = KRequestPending; + + iSyncSession.ReplaceItemL(uid, + parent, + fieldChange, dataPtr, iStatus); + + CleanupStack::PopAndDestroy( dataBuf ); + + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::CancelOperationsL( RWriteStream& aResult ) + { + TRACE_FUNC_ENTRY; + Cancel(); + // all done + iFileStream.Close(); + iTemporaryItemUid = -1; + iCreatedItemUid = -1; + iSyncStatus = EItemsCreated; + iFs.Delete( iFileInProgress ); + iFileInProgress = KNullDesC(); + iItemsLeftInStream = 0; + _LIT8(KDummyParam, "Cancel"); + if ( iSyncStatus == EItemsCreated ) + { + GetCreateItemsResponseL( KDummyParam, aResult ); + } + else if ( iSyncStatus == EItemsReplaced ) + { + GetReplaceItemsResponseL( KDummyParam, aResult ); + } + + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::DoCancel() + { + TRACE_FUNC_ENTRY; + iSyncSession.CancelRequest(); + Reset(); + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::RunL() + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("iSyncStatus: %d", iSyncStatus); + LOGGER_WRITE_1("iStatus: %d", iStatus.Int()); + if ( iSyncStatus == ECreatingItemsFromFile ) + { + LOGGER_WRITE_1("iTemporaryItemUid: %d", iTemporaryItemUid); + LOGGER_WRITE_1("iCreatedItemUid: %d", iCreatedItemUid); + TCreatedItem item; + item.iTemporaryId = iTemporaryItemUid; + item.iErrorCode = iStatus.Int(); + item.iNewUid = iCreatedItemUid; + iCreatedItems.Append( item ); + if ( iItemsLeftInStream > 0 ) + { + CreateNextItemOnStreamL(); + iItemsLeftInStream--; + LOGGER_WRITE_1("iItemsLeftInStream: %d", iItemsLeftInStream); + } + else + { + // all done + LOGGER_WRITE("All items added."); + iFileStream.Close(); + iTemporaryItemUid = -1; + iCreatedItemUid = -1; + iSyncStatus = EItemsCreated; + TInt err = iFs.Delete( iFileInProgress ); + LOGGER_WRITE_2("iFs.Delete( '%S' ) ret: %d", &iFileInProgress, err); + iFileInProgress = KNullDesC(); + } + } + else if ( iSyncStatus == EReplacingItemsFromFile ) + { + iReplacedItem.iErrorCode = iStatus.Int(); + iReplacedItems.Append( iReplacedItem ); + if ( iItemsLeftInStream > 0 ) + { + ReplaceNextItemOnStreamL(); + iItemsLeftInStream--; + LOGGER_WRITE_1("iItemsLeftInStream: %d", iItemsLeftInStream); + } + else + { + // all done + LOGGER_WRITE("All items replaced."); + iFileStream.Close(); + iSyncStatus = EItemsReplaced; + TInt err = iFs.Delete( iFileInProgress ); + LOGGER_WRITE_2("iFs.Delete( '%S' ) ret: %d", &iFileInProgress, err); + iFileInProgress = KNullDesC(); + } + } + else if ( iSyncStatus == EDeletingAllItems ) + { + iSyncStatus = EReady; + } + TRACE_FUNC_EXIT; + } + +TInt CSconSyncHandler::RunError( TInt aError ) + { + TRACE_FUNC_ENTRY; + LOGGER_WRITE_1("aError: %d", aError); + LOGGER_WRITE_1("iSyncStatus: %d", iSyncStatus); + TInt err( aError ); + if ( iSyncStatus == ECreatingItemsFromFile ) + { + iSyncStatus = EItemsCreated; + iItemsLeftInStream = 0; + iFileStream.Close(); + err = iFs.Delete( iFileInProgress ); + LOGGER_WRITE_2("iFs.Delete( '%S' ) ret: %d", &iFileInProgress, err); + iFileInProgress = KNullDesC(); + err = KErrNone; + } + else if ( iSyncStatus == EReplacingItemsFromFile ) + { + iSyncStatus = EItemsReplaced; + iItemsLeftInStream = 0; + iFileStream.Close(); + err = iFs.Delete( iFileInProgress ); + LOGGER_WRITE_2("iFs.Delete( '%S' ) ret: %d", &iFileInProgress, err); + iFileInProgress = KNullDesC(); + err = KErrNone; + } + else if ( iSyncStatus == EDeletingAllItems ) + { + iSyncStatus = EReady; + } + + TRACE_FUNC_EXIT; + return err; + } + +void CSconSyncHandler::Reset() + { + TRACE_FUNC_ENTRY; + iFileStream.Close(); + TInt err = iFs.Delete( iFileInProgress ); + LOGGER_WRITE_2("iFs.Delete( '%S' ) ret: %d", &iFileInProgress, err); + iFileInProgress = KNullDesC(); + iSyncStatus = EReady; + TRACE_FUNC_EXIT; + } + +void CSconSyncHandler::SetCalendarCenrepL( TInt aProfileId, const TDesC& aServerId ) + { + LOGGER_WRITE(" Write cenrep values"); + CRepository* rep = CRepository::NewLC(KNsmlDsSessionInfoKey); + User::LeaveIfError( rep->Set(EDSSessionProfileId, aProfileId) ); + User::LeaveIfError( rep->Set(EDSSessionProfileName, KNullDesC) ); + User::LeaveIfError( rep->Set(EDSSessionServerId, aServerId) ); + CleanupStack::PopAndDestroy(rep); + iCalendarCenrepUsed = ETrue; + } + +void CSconSyncHandler::ClearCalendarCenrepL() + { + if ( iCalendarCenrepUsed ) + { + LOGGER_WRITE("Calendar sync, clear cenrep values"); + + CRepository* rep = CRepository::NewLC(KNsmlDsSessionInfoKey); + rep->Set(EDSSessionProfileId, KErrNotFound); + rep->Set(EDSSessionProfileName, KNullDesC); + rep->Set(EDSSessionServerId, KNullDesC); + CleanupStack::PopAndDestroy(rep); + iCalendarCenrepUsed = EFalse; + } + } + diff -r dbd1c5e08735 -r 453dfc402455 mtpdataproviders/mtpimagedp/inc/cmtpimagedp.h --- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedp.h Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedp.h Thu Aug 19 10:44:03 2010 +0300 @@ -67,6 +67,7 @@ void HandleDeleteObjectsArray(); void IncreaseNewPictures(TInt aCount); void DecreaseNewPictures(TInt aCount); + void ResetNewPictures(); void HandleMdeSessionCompleteL(TInt aError); public: // From CMTPDataProviderPlugin @@ -129,6 +130,7 @@ TBool iEnumerationNotified; RPointerArray iDeleteObjectsArray; + RArray iNewPicHandles; }; #endif // CMTPIMAGEDP_H diff -r dbd1c5e08735 -r 453dfc402455 mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobject.h --- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobject.h Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobject.h Thu Aug 19 10:44:03 2010 +0300 @@ -42,6 +42,7 @@ void ServiceL(); TBool DoHandleCompletingPhaseL(); + TMTPResponseCode CheckRequestL(); private: diff -r dbd1c5e08735 -r 453dfc402455 mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp --- a/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -120,8 +120,10 @@ } //Define RProperty of new pictures for status data provider + RProcess process; + TUid tSid = process.SecureId(); _LIT_SECURITY_POLICY_PASS(KAllowReadAll); - TInt error = RProperty::Define(TUid::Uid(KMTPServerUID), KMTPNewPicKey, RProperty::EInt, KAllowReadAll, KAllowReadAll); + TInt error = RProperty::Define(tSid, KMTPNewPicKey, RProperty::EInt, KAllowReadAll, KAllowReadAll); if (error != KErrNone && error != KErrAlreadyExists) { __FLOG_1(_L8("CMTPImageDataProvider::ConstructL - RProperty define error:%d"), error); @@ -165,6 +167,7 @@ //Try to delete objects in array HandleDeleteObjectsArray(); iDeleteObjectsArray.ResetAndDestroy(); + iNewPicHandles.Reset(); __FLOG(_L8("<< ~CMTPImageDataProvider")); __FLOG_CLOSE; @@ -610,8 +613,7 @@ /** * Get image object count from framework and calculate the new pictures */ - TUint newPictures = QueryImageObjectCountL(); - RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, newPictures); + TUint newPictures = QueryImageObjectCountL(); iNewPicNotifier->SetNewPictures(newPictures); __FLOG_1(_L16("CMTPImageDpEnumerator::CompleteEnumeration - New Pics: %d"), newPictures); iEnumerated = EFalse; @@ -693,6 +695,8 @@ CleanupClosePushL(context); CleanupClosePushL(handles); + iNewPicHandles.Reset(); + do { /* @@ -712,6 +716,7 @@ if (MTPImageDpUtilits::IsNewPicture(*objMetadata)) { ++newPictures; + iNewPicHandles.Append(handles[i]); } } @@ -765,6 +770,32 @@ __FLOG(_L8("<< DecreaseNewPictures ")); } +void CMTPImageDataProvider::ResetNewPictures() + { + __FLOG(_L8(">> ResetNewPictures ")); + + iNewPicNotifier->SetNewPictures(0); + + TInt count = iNewPicHandles.Count(); + if (!count) + { + return; + } + + CMTPObjectMetaData* objMetadata = CMTPObjectMetaData::NewLC(); + + for (TInt i(0); i> HandleMdeSessionComplete")); diff -r dbd1c5e08735 -r 453dfc402455 mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobject.cpp --- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobject.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobject.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -93,7 +93,22 @@ __FLOG(_L8(">> CMTPImageDpGetObject::ConstructL")); __FLOG(_L8("<< CMTPImageDpGetObject::ConstructL")); } - +TMTPResponseCode CMTPImageDpGetObject::CheckRequestL() + { + __FLOG(_L8(">> CMTPImageDpGetObject::CheckRequestL")); + TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL(); + + TUint32 handle(Request().Uint32(TMTPTypeRequest::ERequestParameter1)); + if ( handle != KMTPHandleAll ) + { + CMTPObjectMetaData* ObjectMeta = CMTPObjectMetaData::NewL(); + responseCode = MTPImageDpUtilits::VerifyObjectHandleL( + iFramework, handle, *ObjectMeta); + delete ObjectMeta; + } + __FLOG(_L8("<< CMTPImageDpGetObject::CheckRequestL")); + return responseCode; + } /** GetObject request handler */ @@ -140,7 +155,7 @@ { //update new picture status MTPImageDpUtilits::UpdateObjectStatusToOldL(iFramework, *objectInfo); - iDataProvider.DecreaseNewPictures(1); + iDataProvider.ResetNewPictures(); } } diff -r dbd1c5e08735 -r 453dfc402455 mtpdataproviders/mtpimagedp/src/cmtpimagedpnewpicturesnotifier.cpp --- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpnewpicturesnotifier.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpnewpicturesnotifier.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -44,6 +44,7 @@ void CMTPImageDpNewPicturesNotifier::SetNewPictures(TInt aValue) { iNewPictures = aValue; + RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, iNewPictures); } void CMTPImageDpNewPicturesNotifier::IncreaseCount(TInt aValue) diff -r dbd1c5e08735 -r 453dfc402455 mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp --- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -68,7 +68,9 @@ CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache* CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::NewL() { CMTPImagePropertiesCache* self = new(ELeave) CMTPImagePropertiesCache(KElements, ENumProperties); + CleanupStack::PushL(self); self->ConstructL(); + CleanupStack::Pop(self); return self; } diff -r dbd1c5e08735 -r 453dfc402455 mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpsendobjectinfo.cpp --- a/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpsendobjectinfo.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpsendobjectinfo.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -659,7 +659,16 @@ //with folder creation. - iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObjectP); + TRAPD(err, iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObjectP)); + __FLOG_VA((_L8(" Entry error %d"),err)); + if( KErrAlreadyExists == err ) + { + iReceivedObjectP->SetUint(CMTPObjectMetaData::EHandle, iFramework.ObjectMgr().HandleL(iFullPath)); + } + else + { + User::LeaveIfError(err); + } SendResponseL(EMTPRespCodeOK); } __FLOG(_L8("<< CMTPPictGetObjectPropDesc::DoHandleSendObjectCompleteL")); diff -r dbd1c5e08735 -r 453dfc402455 mtpdataproviders/mtppictbridgedp/src/cmtppictbridgeusbconnection.cpp --- a/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgeusbconnection.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgeusbconnection.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -78,13 +78,19 @@ // void CMTPPictBridgeUsbConnection::Listen() { - iProperty.Subscribe(iStatus); - SetActive(); - if(ConnectionClosed()) // we listen to the disconnection only if connected to the printer + __FLOG(_L8(">> CMTPPictBridgeUsbConnection::Listen")); + if(!IsActive()) { - iPrinter.ConnectionClosed(); - Cancel(); + __FLOG(_L8(" CMTPPictBridgeUsbConnection AO is NOT active and run AO")); + iProperty.Subscribe(iStatus); + SetActive(); + if(ConnectionClosed()) // we listen to the disconnection only if connected to the printer + { + iPrinter.ConnectionClosed(); + Cancel(); + } } + __FLOG(_L8("<< CMTPPictBridgeUsbConnection::Listen")); } // -------------------------------------------------------------------------- @@ -97,12 +103,14 @@ TInt ret = RProperty::Get(KPSUidUsbWatcher, KUsbWatcherSelectedPersonality, personality); __FLOG_VA((_L8("CMTPPictBridgeUsbConnection::ConnectionClosed() current personality = %d, previous personality = %d"), personality, iPreviousPersonality)); - if ((ret == KErrNone && - (personality == KUsbPersonalityIdMS || personality == KUsbPersonalityIdPTP)) + if ((ret == KErrNone && personality == KUsbPersonalityIdMS) || (iPreviousPersonality != KNotAssigned && personality != iPreviousPersonality)) - { - __FLOG_VA((_L8("****WARNING!!! PTP server detects the USB connection closed!"))); - return ETrue; + { + if((personality != KUsbPersonalityIdPCSuiteMTP)&&(personality != KUsbPersonalityIdMTP)) + { + __FLOG_VA((_L8("****WARNING!!! PTP server detects the USB connection closed!"))); + return ETrue; + } } iPreviousPersonality = personality; diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetnumobjects.h --- a/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetnumobjects.h Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetnumobjects.h Thu Aug 19 10:44:03 2010 +0300 @@ -49,10 +49,12 @@ CMTPGetNumObjects(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection); void ConstructL(); + void HandleObjectHandlesUnderMacL(CMTPTypeArray &aObjectHandles); private: TBool IsSupportedFormatL(TUint32 aFormatCode); + void GetObjectHandlesByFormatCodeL(TUint32 aFormatCode, CMTPTypeArray &aObjectHandles); protected: /** diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedp.cpp --- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedp.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedp.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -388,7 +388,9 @@ if(extnpluginMap ) { + CleanupStack::PushL(extnpluginMap); iExtnPluginMapArray.AppendL(extnpluginMap); + CleanupStack::Pop(extnpluginMap); } } diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetnumobjects.cpp --- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetnumobjects.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetnumobjects.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -13,6 +13,7 @@ // Description: // + #include #include #include @@ -153,18 +154,11 @@ if(iDevDpSingletons.DeviceDataStore().IsConnectMac() &&(KMTPFormatsAll == Request().Uint32(TMTPTypeRequest::ERequestParameter2))) { - //get folder count - TMTPObjectMgrQueryParams paramsFolder(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeAssociation, Request().Uint32(TMTPTypeRequest::ERequestParameter3)); - TUint32 count = iFramework.ObjectMgr().CountL(paramsFolder); - __FLOG_VA((_L8("ConnectMac and Fetch all, folder count = %d"), count)); - - //get script count - TMTPObjectMgrQueryParams paramsScript(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeScript, Request().Uint32(TMTPTypeRequest::ERequestParameter3)); - count += iFramework.ObjectMgr().CountL(paramsScript); - - //get Image file count - TMTPObjectMgrQueryParams paramsImage(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeEXIFJPEG, Request().Uint32(TMTPTypeRequest::ERequestParameter3)); - count += iFramework.ObjectMgr().CountL(paramsImage); + TUint32 count(0); + CMTPTypeArray *handles = CMTPTypeArray::NewLC(EMTPTypeAUINT32); + HandleObjectHandlesUnderMacL(*handles); + count = handles->NumElements(); + CleanupStack::PopAndDestroy(handles); __FLOG_VA((_L8("ConnectMac and Fetch all, total count = %d"), count)); SendResponseL(EMTPRespCodeOK, 1, &count); } @@ -201,26 +195,106 @@ } - - - - - - - - - - +/** +Handle special case under Mac. +Only expose the Folder, Image File and Viedo, Script under Drive:\Images, Drive\Viedos +*/ +void CMTPGetNumObjects::HandleObjectHandlesUnderMacL(CMTPTypeArray &aObjectHandles) + { + __FLOG(_L8("HandleObjectHandlesUnderMacL - Entry")); + + CMTPTypeArray* totalHandles = CMTPTypeArray::NewLC(EMTPTypeAUINT32); + + //get folder object handles + GetObjectHandlesByFormatCodeL(EMTPFormatCodeAssociation,*totalHandles); + + //get image/jpeg object handles + GetObjectHandlesByFormatCodeL(EMTPFormatCodeEXIFJPEG,*totalHandles); + //get image/bmp object handles + GetObjectHandlesByFormatCodeL(EMTPFormatCodeBMP,*totalHandles); + //get image/jif object handles + GetObjectHandlesByFormatCodeL(EMTPFormatCodeGIF,*totalHandles); + //get image/jpeg object handles + GetObjectHandlesByFormatCodeL(EMTPFormatCodePNG,*totalHandles); + + //get video/mp4 object handles + GetObjectHandlesByFormatCodeL(EMTPFormatCodeMP4Container,*totalHandles); + //get video/3gp object handles + GetObjectHandlesByFormatCodeL(EMTPFormatCode3GPContainer,*totalHandles); + //get video/wmv object handles + GetObjectHandlesByFormatCodeL(EMTPFormatCodeWMV,*totalHandles); + //get video/asf object handles + GetObjectHandlesByFormatCodeL(EMTPFormatCodeASF,*totalHandles); + + //Filer the folder list, ?:\\Images\\* and ?:\\Videos\\* + _LIT(KImagesFolderPre, "?:\\Images\\*"); + _LIT(KViedosFolderPre, "?:\\Videos\\*"); + + const TUint KCount(totalHandles->NumElements()); + + for (TUint i(0); (i < KCount); i++)//handles loop + { + CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC()); + iFramework.ObjectMgr().ObjectL(totalHandles->ElementUint(i),*object); + const TDesC& suid(object->DesC(CMTPObjectMetaData::ESuid)); + +#ifdef __FLOG_ACTIVE + TBuf8 tmp; + tmp.Copy(suid); + __FLOG_VA((_L8("HandleObjectHandlesUnderMacL - suid: %S"), &tmp)); +#endif // __FLOG_ACTIVE + if((KErrNotFound != suid.MatchF(KImagesFolderPre)) || + (KErrNotFound != suid.MatchF(KViedosFolderPre))) + { + _LIT(KComma,","); + _LIT(KLineation,"-"); + _LIT(KUnderline,"_"); + _LIT(Ksemicolon ,";"); + if((KErrNotFound != suid.Find(KComma))|| + (KErrNotFound != suid.Find(KLineation))|| + (KErrNotFound != suid.Find(KUnderline))|| + (KErrNotFound != suid.Find(Ksemicolon))) + { + __FLOG(_L8("HandleObjectHandlesUnderMacL - Skip handle")); + } + else + { + __FLOG_VA((_L8("HandleObjectHandlesUnderMacL - Add handle: %x"), totalHandles->ElementUint(i))); + RArray tmphandles; + CleanupClosePushL(tmphandles); + tmphandles.AppendL(totalHandles->ElementUint(i)); + aObjectHandles.AppendL(tmphandles); + CleanupStack::PopAndDestroy(&tmphandles); + } + } + CleanupStack::PopAndDestroy(object); + } + + CleanupStack::PopAndDestroy(totalHandles); + //get script object handles + GetObjectHandlesByFormatCodeL(EMTPFormatCodeScript,aObjectHandles); + + __FLOG(_L8("HandleObjectHandlesUnderMacL - Exit")); + } +/** +Get Object Handles by format code +*/ +void CMTPGetNumObjects::GetObjectHandlesByFormatCodeL(TUint32 aFormatCode, CMTPTypeArray &aObjectHandles) + { + __FLOG_VA((_L8("GetObjectHandlesByFormatCodeL - Entry FormatCode: %x"), aFormatCode)); + RMTPObjectMgrQueryContext context; + RArray handles; + CleanupClosePushL(context); + CleanupClosePushL(handles); + TMTPObjectMgrQueryParams paramsFolder(Request().Uint32(TMTPTypeRequest::ERequestParameter1), aFormatCode, Request().Uint32(TMTPTypeRequest::ERequestParameter3)); + do + { + iFramework.ObjectMgr().GetObjectHandlesL(paramsFolder, context, handles); + aObjectHandles.AppendL(handles); + } + while (!context.QueryComplete()); + CleanupStack::PopAndDestroy(&context); + CleanupStack::PopAndDestroy(&handles); + __FLOG(_L8("GetObjectHandlesByFormatCode - Exit")); + } - - - - - - - - - - - - diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetobjecthandles.cpp --- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetobjecthandles.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetobjecthandles.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -107,10 +107,6 @@ iTimeoutCount = 0; - RMTPObjectMgrQueryContext context; - RArray handles; - CleanupClosePushL(context); - CleanupClosePushL(handles); delete iHandles; iHandles = CMTPTypeArray::NewL(EMTPTypeAUINT32); @@ -119,47 +115,14 @@ &&(KMTPFormatsAll == Request().Uint32(TMTPTypeRequest::ERequestParameter2))) { __FLOG(_L8("ConnectMac and Fetch all.")); - //get folder object handles - TMTPObjectMgrQueryParams paramsFolder(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeAssociation, Request().Uint32(TMTPTypeRequest::ERequestParameter3)); - do - { - iFramework.ObjectMgr().GetObjectHandlesL(paramsFolder, context, handles); - iHandles->AppendL(handles); - } - while (!context.QueryComplete()); - - //get script object handles - RMTPObjectMgrQueryContext contextScript; - RArray handlesScript; - CleanupClosePushL(contextScript); - CleanupClosePushL(handlesScript); - TMTPObjectMgrQueryParams paramsScript(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeScript, Request().Uint32(TMTPTypeRequest::ERequestParameter3)); - do - { - iFramework.ObjectMgr().GetObjectHandlesL(paramsScript, contextScript, handlesScript); - iHandles->AppendL(handlesScript); - } - while (!contextScript.QueryComplete()); - CleanupStack::PopAndDestroy(&contextScript); - CleanupStack::PopAndDestroy(&handlesScript); - - //get image object handles - RMTPObjectMgrQueryContext contextImage; - RArray handlesImage; - CleanupClosePushL(contextImage); - CleanupClosePushL(handlesImage); - TMTPObjectMgrQueryParams paramsImage(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeEXIFJPEG, Request().Uint32(TMTPTypeRequest::ERequestParameter3)); - do - { - iFramework.ObjectMgr().GetObjectHandlesL(paramsImage, contextImage, handlesImage); - iHandles->AppendL(handlesImage); - } - while (!contextImage.QueryComplete()); - CleanupStack::PopAndDestroy(&contextImage); - CleanupStack::PopAndDestroy(&handlesImage); + HandleObjectHandlesUnderMacL(*iHandles); } else { + RMTPObjectMgrQueryContext context; + RArray handles; + CleanupClosePushL(context); + CleanupClosePushL(handles); TMTPObjectMgrQueryParams params(Request().Uint32(TMTPTypeRequest::ERequestParameter1), Request().Uint32(TMTPTypeRequest::ERequestParameter2), Request().Uint32(TMTPTypeRequest::ERequestParameter3)); do { @@ -194,13 +157,11 @@ } iHandles->AppendL(handles); } - while (!context.QueryComplete()); + while (!context.QueryComplete()); + CleanupStack::PopAndDestroy(&handles); + CleanupStack::PopAndDestroy(&context); } - - - - CleanupStack::PopAndDestroy(&handles); - CleanupStack::PopAndDestroy(&context); + SendDataL(*iHandles); __FLOG(_L8("ServiceL - Exit")); } diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp --- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -196,7 +196,7 @@ { //E: is set as logically removable after eMMC image updated //So here we need to deal with this case to set it as FixedRam - if(iDriveInfo.iDriveAtt & KDriveAttInternal) + if(iDriveInfo.iDriveAtt & KDriveAttLogicallyRemovable) { __FLOG(_L8("removable but internal drive, set as Fixed RAM")); storageType = EMTPStorageFixedRAM; diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/dataproviders/devdp/src/cmtptypedeviceinfo.cpp --- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtptypedeviceinfo.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtptypedeviceinfo.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -130,7 +130,9 @@ } __ASSERT_DEBUG(chunk, User::Invariant()); + CleanupStack::PushL(chunk); ChunkAppendL(*chunk); + CleanupStack::Pop(chunk); } } } diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp --- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -396,18 +396,27 @@ TInt CMTPFSEnumerator::RunError(TInt aError) { __FLOG_VA((_L8("RunError - entry with error %d"), aError)); - if(!iFramework.StorageMgr().ValidStorageId(iStorages[iScanPos])) - { - __FLOG_VA((_L8("Invalid StorageID = %d"),iStorages[iScanPos] )); - if (iStorages.Count()>1) - { - //Not necessary to process any entry on the storage, since the storage removed. - //Then need to start from root dir of next storage if there is. - //So, the dir stack is popped to bottom. - iDirStack.Reset(); - } - iSkipCurrentStorage = ETrue; - } + + // avoid to access overflow of iStorages + if (iScanPos < iStorages.Count()) + { + if(!iFramework.StorageMgr().ValidStorageId(iStorages[iScanPos])) + { + __FLOG_VA((_L8("Invalid StorageID = %d"),iStorages[iScanPos] )); + if (iStorages.Count()>1) + { + //Not necessary to process any entry on the storage, since the storage removed. + //Then need to start from root dir of next storage if there is. + //So, the dir stack is popped to bottom. + iDirStack.Reset(); + } + iSkipCurrentStorage = ETrue; + } + } + else + { + iSkipCurrentStorage = ETrue; + } // Reschedule ourselves TRequestStatus* status = &iStatus; @@ -548,10 +557,16 @@ __FLOG_VA((_L("mime %S"), mime)); DpId = iDpSingletons.MTPUtility().GetDpIdL(parse.Ext().Mid(1),*mime); __FLOG_VA((_L("DpId find %d"), DpId)); + + format = iDpSingletons.MTPUtility().GetFormatCodeByMimeTypeL(parse.Ext().Mid(1),*mime); + AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos], + iParentHandle, iDpSingletons.MTPUtility().GetSubFormatCodeL(parse.Ext().Mid(1),*mime)); } - format = iDpSingletons.MTPUtility().GetFormatCodeByMimeTypeL(parse.Ext().Mid(1),*mime); - AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos], - iParentHandle, iDpSingletons.MTPUtility().GetSubFormatCodeL(parse.Ext().Mid(1),*mime)); + else + { + AddEntryL(iCurrentPath, handle, EMTPFormatCodeUndefined, iDpID, entry, iStorages[iScanPos], iParentHandle); + } + CleanupStack::PopAndDestroy(mime); } else diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetformatcapabilities.cpp --- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetformatcapabilities.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetformatcapabilities.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -95,44 +95,71 @@ CMTPTypeFormatCapability* frmCap = CMTPTypeFormatCapability::NewLC( EMTPFormatCodeAssociation ,interDesc ); //EMTPObjectPropCodeStorageID - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeStorageID) ); + CMTPTypeObjectPropDesc* storageId = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeStorageID); + frmCap->AppendL(storageId); + CleanupStack::Pop(storageId); //EMTPObjectPropCodeObjectFormat - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFormat) ); + CMTPTypeObjectPropDesc* objFormat = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeObjectFormat); + frmCap->AppendL(objFormat); + CleanupStack::Pop(objFormat); //EMTPObjectPropCodeProtectionStatus - frmCap->AppendL( ServiceProtectionStatusL() ); + CMTPTypeObjectPropDesc* protectionStatus = ServiceProtectionStatusL(); + CleanupStack::PushL(protectionStatus); + frmCap->AppendL(protectionStatus); + CleanupStack::Pop(protectionStatus); //EMTPObjectPropCodeAssociationType - frmCap->AppendL( ServiceAssociationTypeL() ); + CMTPTypeObjectPropDesc* associationType = ServiceAssociationTypeL(); + CleanupStack::PushL(associationType); + frmCap->AppendL(associationType); + CleanupStack::Pop(associationType); //EMTPObjectPropCodeAssociationDesc - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeAssociationDesc) ); + CMTPTypeObjectPropDesc* associationDesc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeAssociationDesc); + frmCap->AppendL(associationDesc); + CleanupStack::Pop(associationDesc); //EMTPObjectPropCodeObjectSize - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectSize) ); + CMTPTypeObjectPropDesc* objSize = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeObjectSize); + frmCap->AppendL(objSize); + CleanupStack::Pop(objSize); //EMTPObjectPropCodeObjectFileName _LIT(KMtpObjDescObjFileName, "[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 7}\\.[[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 2}]?"); - CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName ); - frmCap->AppendL(CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeObjectFileName, - CMTPTypeObjectPropDesc::ERegularExpressionForm, form)); + CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName ); + CMTPTypeObjectPropDesc* objFileName = CMTPTypeObjectPropDesc::NewLC( EMTPObjectPropCodeObjectFileName, + CMTPTypeObjectPropDesc::ERegularExpressionForm, form); + frmCap->AppendL(objFileName); + CleanupStack::Pop(objFileName); CleanupStack::PopAndDestroy(form ); //EMTPObjectPropCodeDateModified - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeDateModified) ); + CMTPTypeObjectPropDesc* dateModified = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeDateModified); + frmCap->AppendL(dateModified); + CleanupStack::Pop(dateModified); //EMTPObjectPropCodeParentObject - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeParentObject) ); + CMTPTypeObjectPropDesc* parentobj = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeParentObject); + frmCap->AppendL(parentobj); + CleanupStack::Pop(parentobj); //EMTPObjectPropCodePersistentUniqueObjectIdentifier - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodePersistentUniqueObjectIdentifier) ); + CMTPTypeObjectPropDesc* objectIdentifier = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodePersistentUniqueObjectIdentifier); + frmCap->AppendL(objectIdentifier); + CleanupStack::Pop(objectIdentifier); //EMTPObjectPropCodeName - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeName)); + CMTPTypeObjectPropDesc* name = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeName); + frmCap->AppendL(name); + CleanupStack::Pop(name); //EMTPObjectPropCodeNonConsumable - frmCap->AppendL(ServiceNonConsumableL() ); + CMTPTypeObjectPropDesc* nonConsumable = ServiceNonConsumableL(); + CleanupStack::PushL(nonConsumable); + frmCap->AppendL(nonConsumable); + CleanupStack::Pop(nonConsumable); iCapabilityList->AppendL(frmCap); CleanupStack::Pop(frmCap); @@ -146,38 +173,60 @@ CMTPTypeFormatCapability* frmCap = CMTPTypeFormatCapability::NewLC( aFormatCode ,interDesc ); //EMTPObjectPropCodeStorageID - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeStorageID) ); + CMTPTypeObjectPropDesc* storageID = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeStorageID); + frmCap->AppendL(storageID); + CleanupStack::Pop(storageID); //EMTPObjectPropCodeObjectFormat - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectFormat) ); + CMTPTypeObjectPropDesc* objectFormat = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeObjectFormat); + frmCap->AppendL(objectFormat); + CleanupStack::Pop(objectFormat); //EMTPObjectPropCodeProtectionStatus - frmCap->AppendL( ServiceProtectionStatusL() ); + CMTPTypeObjectPropDesc* protectionStatus = ServiceProtectionStatusL(); + CleanupStack::PushL(protectionStatus); + frmCap->AppendL(protectionStatus); + CleanupStack::Pop(protectionStatus); //EMTPObjectPropCodeObjectSize - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeObjectSize) ); + CMTPTypeObjectPropDesc* objSize = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeObjectSize); + frmCap->AppendL(objSize); + CleanupStack::Pop(objSize); //EMTPObjectPropCodeObjectFileName _LIT(KMtpObjDescObjFileName, "[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 7}\\.[[a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~][a-zA-Z!#\\$%&'\\(\\)\\-0-9@\\^_\\`\\{\\}\\~ ]{0, 2}]?"); - CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName ); - frmCap->AppendL(CMTPTypeObjectPropDesc::NewL( EMTPObjectPropCodeObjectFileName, - CMTPTypeObjectPropDesc::ERegularExpressionForm, form)); + CMTPTypeString* form = CMTPTypeString::NewLC( KMtpObjDescObjFileName ); + CMTPTypeObjectPropDesc* objFileName = CMTPTypeObjectPropDesc::NewLC( EMTPObjectPropCodeObjectFileName, + CMTPTypeObjectPropDesc::ERegularExpressionForm, form); + frmCap->AppendL(objFileName); + CleanupStack::Pop(objFileName); CleanupStack::PopAndDestroy(form ); //EMTPObjectPropCodeDateModified - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeDateModified) ); + CMTPTypeObjectPropDesc* dateModified = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeDateModified); + frmCap->AppendL(dateModified); + CleanupStack::Pop(dateModified); //EMTPObjectPropCodeParentObject - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeParentObject) ); + CMTPTypeObjectPropDesc* parentObject = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeParentObject); + frmCap->AppendL(parentObject); + CleanupStack::Pop(parentObject); //EMTPObjectPropCodePersistentUniqueObjectIdentifier - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodePersistentUniqueObjectIdentifier) ); + CMTPTypeObjectPropDesc* objectIdentifier = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodePersistentUniqueObjectIdentifier); + frmCap->AppendL(objectIdentifier); + CleanupStack::Pop(objectIdentifier); //EMTPObjectPropCodeName - frmCap->AppendL( CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeName)); + CMTPTypeObjectPropDesc* name = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeName); + frmCap->AppendL(name); + CleanupStack::Pop(name); //EMTPObjectPropCodeNonConsumable - frmCap->AppendL(ServiceNonConsumableL() ); + CMTPTypeObjectPropDesc* nonConsumable = ServiceNonConsumableL(); + CleanupStack::PushL(nonConsumable); + frmCap->AppendL(nonConsumable); + CleanupStack::Pop(nonConsumable); iCapabilityList->AppendL(frmCap); CleanupStack::Pop(frmCap); diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/datatypes/interface/mtpprotocolconstants.h --- a/mtpfws/mtpfw/datatypes/interface/mtpprotocolconstants.h Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/datatypes/interface/mtpprotocolconstants.h Thu Aug 19 10:44:03 2010 +0300 @@ -368,7 +368,7 @@ EMTPRespCodeCaptureAlreadyTerminated = 0x2018, EMTPRespCodeDeviceBusy = 0x2019, EMTPRespCodeInvalidParentObject = 0x201A, - EMTPRespCodeInvalidDeviEMTPRespCodecePropFormat = 0x201B, + EMTPRespCodeInvalidDevicePropFormat = 0x201B, EMTPRespCodeInvalidDevicePropValue = 0x201C, EMTPRespCodeInvalidParameter = 0x201D, EMTPRespCodeSessionAlreadyOpen = 0x201E, diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/datatypes/src/cmtptypeobjectinfo.cpp --- a/mtpfws/mtpfw/datatypes/src/cmtptypeobjectinfo.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/datatypes/src/cmtptypeobjectinfo.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -128,7 +128,9 @@ } __ASSERT_DEBUG(chunk, User::Invariant()); + CleanupStack::PushL(chunk); ChunkAppendL(*chunk); + CleanupStack::Pop(chunk); } } } diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/datatypes/src/cmtptypestorageinfo.cpp --- a/mtpfws/mtpfw/datatypes/src/cmtptypestorageinfo.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/datatypes/src/cmtptypestorageinfo.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -115,7 +115,9 @@ break; } __ASSERT_DEBUG(chunk, User::Invariant()); + CleanupStack::PushL(chunk); ChunkAppendL(*chunk); + CleanupStack::Pop(chunk); } } } diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/src/cmtpconnection.cpp --- a/mtpfws/mtpfw/src/cmtpconnection.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/src/cmtpconnection.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -94,6 +94,12 @@ } iSessions.ResetAndDestroy(); + + if (iTransportConnection != NULL) + { + iTransportConnection->Unbind(*this); + } + //close the property iProperty.Close(); // delete the ‘name?property @@ -357,7 +363,7 @@ CompleteCloseConnection(); ret = ETrue; } - + SetState(EStateShutdown); PublishConnState(EDisconnectedFromHost); } @@ -372,10 +378,6 @@ CloseAllSessions(); iSessions.Reset(); - if (iTransportConnection != NULL) - { - iTransportConnection->Unbind(*this); - } //notify ConnectionMgr and corresponding transports of completion of connection close iSingletons.ConnectionMgr().ConnectionCloseComplete(iConnectionId); @@ -405,8 +407,12 @@ */ SessionOpenedL(KMTPSessionNone); + if (iTransportConnection != NULL) + { + iTransportConnection->Unbind(*this); + } iTransportConnection = &aTransportConnection; - iTransportConnection->BindL(*this); + iTransportConnection->BindL(*this); SetState(EStateOpen); } @@ -707,7 +713,7 @@ iEventQ(_FOFF(CMTPEventLink, iLink)), iTransportConnection(&aTransportConnection) { - + iTransportConnection->BindL(*this); } /** diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/src/cmtpconnectionmgr.cpp --- a/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -13,8 +13,6 @@ // Description: // -#include -#include #include "cmtpconnectionmgr.h" #include "cmtpconnection.h" @@ -115,33 +113,6 @@ EXPORT_C void CMTPConnectionMgr::StartTransportL(TUid aTransport) { __FLOG(_L8("StartTransportL - Entry")); - - RUsb usb; - User::LeaveIfError(usb.Connect()); - __FLOG(_L8("after connect, and before call get currentpersonalityid")); - TInt usbMode; - TUsbServiceState usbStat; - TInt err = usb.GetCurrentPersonalityId(usbMode); - __FLOG_1(_L8("The return value of GetCurrentPersonalityId is %d"), err); - - err = usb.GetServiceState(usbStat); - __FLOG_1(_L8("The return value of GetServiceState is %d"), err); - - usb.Close(); - - __FLOG_1(_L8("The current usb mode is %d"), usbMode); - __FLOG_1(_L8("The current usb service state is %d"), usbStat); - - TInt massStorageMode = 0x02; - - if(usbMode == massStorageMode && usbStat != EUsbServiceIdle) - { - __FLOG(_L8("StartTransportL without parameter!")); - StartTransportL( aTransport, NULL ); - return; - } - - //When USB plug out, BT will start Master mode to reconnect remote device. Else BT will start slave mode to listen connection. if(aTransport.iUid == KMTPBTTransportUid && iRemoteDevice.iDeviceAddr != 0 && aTransport != iTransportUid) diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp --- a/mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -484,7 +484,7 @@ Cancel(); //clean the root level snapshot - iSingletons.ObjectMgr().ObjectStore().CleanDBSnapshotL(ETrue); + TRAP_IGNORE(iSingletons.ObjectMgr().ObjectStore().CleanDBSnapshotL(ETrue)); //Schedule again to scan subdir iEnumerationState = EEnumeratingSubDirFiles; @@ -500,9 +500,7 @@ { Cancel(); iEnumerationState = EEnumeratingCleanDBSnapshot; - iSingletons.ObjectMgr().ObjectStore().CleanDBSnapshotL(EFalse); - - + TRAP_IGNORE(iSingletons.ObjectMgr().ObjectStore().CleanDBSnapshotL(EFalse)); } else { diff -r dbd1c5e08735 -r 453dfc402455 mtpfws/mtpfw/src/cmtpframeworkconfig.cpp --- a/mtpfws/mtpfw/src/cmtpframeworkconfig.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtpfws/mtpfw/src/cmtpframeworkconfig.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -174,9 +174,9 @@ const TInt KStartupInitValue = 1; iAbnormalDownValue = 0; TInt err(iRepository->Get(EAbnormalDown, iAbnormalDownValue)); - if ((KErrNone != err ) && (KErrNotFound != err)) + if ( KErrNone != err ) { - User::Leave(err); + iAbnormalDownValue = 0; } //Save the AbnormalDown state to ETrue diff -r dbd1c5e08735 -r 453dfc402455 mtptransports/mtpcontroller/src/cmtpbearermonitor.cpp --- a/mtptransports/mtpcontroller/src/cmtpbearermonitor.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtptransports/mtpcontroller/src/cmtpbearermonitor.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -80,7 +80,9 @@ __FLOG( _L8("+ConstructL") ); CMTPBluetoothController* btController = CMTPBluetoothController::NewL( *this ); + CleanupStack::PushL(btController); iMTPControllers.AppendL( btController ); + CleanupStack::Pop(btController); __FLOG( _L8("-ConstructL") ); } diff -r dbd1c5e08735 -r 453dfc402455 mtptransports/mtpcontroller/src/cmtpcontrollertimer.cpp --- a/mtptransports/mtpcontroller/src/cmtpcontrollertimer.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtptransports/mtpcontroller/src/cmtpcontrollertimer.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -89,7 +89,7 @@ { __FLOG( _L8("Start transport to launch mtp server") ); - iMTPClient.Connect(); + User::LeaveIfError(iMTPClient.Connect()); iMTPClient.StartTransport(KMTPBtTransportUid); iStopTransport = EFalse; iMTPOperator->SubscribeConnState(); diff -r dbd1c5e08735 -r 453dfc402455 mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbase.h --- a/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbase.h Thu Jul 15 19:35:12 2010 +0300 +++ b/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbase.h Thu Aug 19 10:44:03 2010 +0300 @@ -55,6 +55,7 @@ void FlushRxDataL(); void FlushBufferedRxDataL(); + void FlushOnePacketL(); protected: diff -r dbd1c5e08735 -r 453dfc402455 mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp --- a/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -131,7 +131,7 @@ __FLOG(_L8("CloseConnection - Exit")); } -void CMTPUsbConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest) +void CMTPUsbConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& /*aRequest*/) { __FLOG(_L8("ReceiveDataL - Entry")); @@ -636,7 +636,11 @@ { __FLOG(_L8("SendInterruptDataCompleteL - Entry")); iEventPending = EFalse; + + if ( NULL != iProtocolLayer) + { BoundProtocolLayer().SendEventCompleteL(aError, iMTPEvent); + } __FLOG(_L8("SendInterruptDataCompleteL - Exit")); } @@ -1254,7 +1258,7 @@ @param aRequest The USB SIC class specific request setup data. @leave One of the system wide error codes, if a processing failure occurs. */ -void CMTPUsbConnection::ProcessControlRequestDeviceStatusL(const TMTPUsbControlRequestSetup& aRequest) +void CMTPUsbConnection::ProcessControlRequestDeviceStatusL(const TMTPUsbControlRequestSetup& /*aRequest*/) { __FLOG(_L8("ProcessControlRequestDeviceStatusL - Entry")); iUsbControlRequestDeviceStatus.Reset(); @@ -1358,7 +1362,17 @@ { // Invalid bulk transaction state, close the connection. __FLOG_VA((_L8("Expected bulk transaction state = %d"), aExpectedTransactionState)); + + //if transaction is in request phase, while the container type of data we received is other transaction phase, + //just ignore the data and initiate another request receiving. + if (ERequestPhase == iBulkTransactionState) + { + InitiateBulkRequestSequenceL(); + } + else + { CloseConnection(); + } } __FLOG(_L8("BulkRequestTransactionStateValid - Exit")); return valid; @@ -1503,6 +1517,7 @@ __FLOG(_L8("BulkEndpointsStallL - Entry")); EndpointStallL(EMTPUsbEpBulkIn); EndpointStallL(EMTPUsbEpBulkOut); + SetDeviceStatus(EMTPUsbDeviceStatusTransactionCancelled); __FLOG(_L8("BulkEndpointsStallL - Exit")); } @@ -1669,6 +1684,7 @@ SetBulkTransactionState(EUndefined); SetConnectionState(EIdle); SetSuspendState(ENotSuspended); + iMTPSessionId = KMTPSessionNone; } __FLOG(_L8("StopConnection - Exit")); diff -r dbd1c5e08735 -r 453dfc402455 mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp --- a/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp Thu Jul 15 19:35:12 2010 +0300 +++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp Thu Aug 19 10:44:03 2010 +0300 @@ -596,19 +596,11 @@ // USB Header validation if (!ValidateUSBHeaderL()) { - //trash data, continue to flush. - TRequestStatus status; - RBuf8 readBuf; - readBuf.CreateL(KMaxPacketTypeBulkHS); - Connection().Ldd().ReadPacket(status, EndpointNumber(), readBuf, KMaxPacketTypeBulkHS); - User::WaitForRequest(status); - RDebug::Print(_L("CMTPUsbEpBase::ProcessFirstReceivedChunkL(), trash data length = %d"), readBuf.Length()); - readBuf.Close(); + //trash data, continue to flush by one packet. + FlushOnePacketL(); InitiateFirstChunkReceiveL(); return; - - } if ((iDataLength - KUSBHeaderSize) == 0) @@ -617,7 +609,14 @@ SetStreamState(EReceiveComplete); } } - else if (iReceiveChunkData.MaxLength() == iReceiveChunkData.Length()) + else if (iReceiveChunkData.MaxLength() == KUSBHeaderSize + && iReceiveChunkData.Length() < KUSBHeaderSize) + { + //trash data received, just diacard it and initiate next receiving + InitiateFirstChunkReceiveL(); + return; + } + else if (iReceiveChunkData.MaxLength() == iReceiveChunkData.Length()) { // USB Control request setup or data packet is received from Control EP. // All the desired data should be received. @@ -692,7 +691,7 @@ // 1. MTP file receiving: MTP type file never returns KMTPChunkSequenceCompletion,It can be received // one part after another. Also it can be commited mutiple times. // 2. Other MTP datatype receiving during the middle of data stream - __FLOG(_L8("Commiting write data chunk")); + __FLOG(_L8("Commiting write data chunk - 1")); needCommit = iReceiveDataSink->CommitChunkL(iReceiveChunkData); lastChunkCommited = ETrue; } @@ -702,7 +701,7 @@ { // It should be the end of MTP type file receiving since it never returns KMTPChunkSequenceCompletion. // it can be commited mutiple times. - __FLOG(_L8("Commiting write data chunk")); + __FLOG(_L8("Commiting write data chunk - 2")); needCommit = iReceiveDataSink->CommitChunkL(iReceiveChunkData); } else if ((iChunkStatus == KMTPChunkSequenceCompletion) @@ -711,9 +710,22 @@ { // The last chunk data which type is any other MTP data type than MTP file type. // It will not be commited until all the chunk data is received. - __FLOG(_L8("Commiting write data chunk")); + __FLOG(_L8("Commiting write data chunk - 3")); needCommit = iReceiveDataSink->CommitChunkL(iReceiveChunkData); - } + } + else if ((iChunkStatus == KMTPChunkSequenceCompletion) + && !endStream + && (iReceiveChunkData.Length() == iReceiveChunkData.MaxLength())) + { + // The last chunk data is received and chunk has been filled up: + // just flush one packet and set endStream true and commit received data. + // This condition tries to make MTP more robust if DP forgets to handle data-out phase. + __FLOG(_L8("Commiting write data chunk - 4")); + + FlushOnePacketL(); + endStream = ETrue; + needCommit = iReceiveDataSink->CommitChunkL(iReceiveChunkData); + } } // Fetch the next read data chunk. @@ -1110,3 +1122,15 @@ readBuf.Close(); } } + +void CMTPUsbEpBase::FlushOnePacketL() + { + //trash data, continue to flush. + TRequestStatus status; + RBuf8 readBuf; + readBuf.CreateL(KMaxPacketTypeBulkHS); + Connection().Ldd().ReadPacket(status, EndpointNumber(), readBuf, KMaxPacketTypeBulkHS); + User::WaitForRequest(status); + RDebug::Print(_L("CMTPUsbEpBase::ProcessFirstReceivedChunkL(), trash data length = %d"), readBuf.Length()); + readBuf.Close(); + }