messagingfw/msgsrvnstore/server/src/TMsvServerStoreManager.cpp
author hgs
Wed, 03 Nov 2010 22:41:46 +0530
changeset 62 db3f5fa34ec7
permissions -rw-r--r--
201044_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
     1
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
     2
// All rights reserved.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
     3
// This component and the accompanying materials are made available
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
     5
// which accompanies this distribution, and is available
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
     7
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
     8
// Initial Contributors:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    10
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    11
// Contributors:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    12
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    13
// Description:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    14
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    15
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    16
#include <e32wins.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    17
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    18
#include "TMsvServerStoreManager.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    19
#include "MSVUTILS.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    20
#include "MSVSERV.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    21
#include "MSVPANIC.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    22
#include "MSVAPI.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    23
#include "msvindexadapter.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    24
#include "msvpreferreddrivelist.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    25
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    26
TMsvServerStoreManager::TMsvServerStoreManager() : iMsvServer(NULL),iFs(NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    27
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    28
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    29
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    30
void TMsvServerStoreManager::SetMsvServerAndFileSession(CMsvServer& aMsvServer,RFs& aFs)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    31
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    32
	iMsvServer = &aMsvServer;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    33
	iFs = &aFs;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    34
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    35
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    36
/** Gets the filepath for the storage of binary files associated with the context
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    37
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    38
If the directory specified in the context does not exist, it is created.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    39
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    40
@param aEntryId index id of the entry whose filepath is requested
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    41
@param aDirectory On return, contains the binary file directory path
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    42
@return KErrNone - success;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    43
@return The server was unable to create the directory.- failure */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    44
TInt TMsvServerStoreManager::GetFilePath(TMsvId aEntryId, TFileName& aDirectory) const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    45
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    46
	__ASSERT_ALWAYS(iMsvServer != NULL, PanicServer(EMsvServerNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    47
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    48
	TMsvId owningService = KMsvNullIndexEntryId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    49
	GetOwningServiceAndFilePath(aEntryId,aDirectory,owningService);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    50
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    51
	MsvUtils::ConstructEntryName(owningService, aEntryId, aDirectory, MsvUtils::EFolder);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    52
	TInt error = iMsvServer->FileSession().MkDirAll(aDirectory);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    53
	return (error==KErrAlreadyExists ? KErrNone : error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    54
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    55
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    56
/** Gets the filestore name associated with the context
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    57
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    58
@param aEntryId Index id of the entry whose store filename is requested
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    59
@param aFileName On return, contains the store file name for the context
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    60
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    61
void TMsvServerStoreManager::GetStoreFileName(TMsvId aEntryId, TFileName& aFileName) const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    62
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    63
	__ASSERT_ALWAYS(iMsvServer != NULL, PanicServer(EMsvServerNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    64
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    65
	TMsvId owningService = KMsvNullIndexEntryId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    66
	GetOwningServiceAndFilePath(aEntryId,aFileName,owningService);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    67
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    68
	MsvUtils::ConstructEntryName(owningService, aEntryId, aFileName, MsvUtils::EStore);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    69
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    70
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    71
void TMsvServerStoreManager::GetOwningServiceAndFilePath(TMsvId aEntryId,TDes& aFilePath,TMsvId& aOwningService) const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    72
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    73
	__ASSERT_ALWAYS(iMsvServer != NULL, PanicServer(EMsvServerNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    74
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    75
#if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    76
	//TUint driveId = MsvUtils::GetDriveId(aEntryId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    77
	TUint driveId = GetDriveId(aEntryId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    78
	TDriveNumber driveNum = EDriveC;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    79
	CMsvPreferredDriveList::GetDriveList()->GetDriveNumber(driveId, driveNum);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    80
	aFilePath.Zero();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    81
	aFilePath.Append(TDriveUnit(driveNum).Name());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    82
	TParse parse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    83
	parse.Set(iMsvServer->Context().MessageFolder(), NULL, NULL);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    84
	aFilePath.Append(parse.Path());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    85
#else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    86
	aFilePath = iMsvServer->Context().MessageFolder();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    87
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    88
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    89
	iMsvServer->IndexAdapter().OwningService(aEntryId, aOwningService);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    90
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    91
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    92
/** Checks if the filename length is greater than KMaxFileName(256)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    93
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    94
If the filename is greater than KMaxFileName then it truncates the filename
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    95
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    96
@param aFilePath file path where the file is being created.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    97
@param aFileName name of the file whose length if being checked.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    98
@return ETrue if the filename is changed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    99
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   100
TBool TMsvServerStoreManager::CheckFileNameLengthAndTrimL(const TDesC& aFilePath,TDes& aFileName)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   101
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   102
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   103
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   104
 	TParsePtrC filenamePPtr(aFileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   105
 	TPtrC fileExtension(filenamePPtr.Ext());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   106
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   107
#ifdef __WINS__
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   108
	TFileName winsFileName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   109
	TFileName mailStoreDrive;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   110
	TDriveUnit drive(MessageServer::CurrentDriveL(*iFs));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   111
	mailStoreDrive.Append(drive.Name());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   112
	mailStoreDrive.Append(KPathDelimiter);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   113
	MapEmulatedFileName(winsFileName, mailStoreDrive); // Ignoring return value
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   114
	TInt KEpocBasePathLen = winsFileName.Length();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   115
	TInt maxFilenameLength = KMaxFileName-(aFilePath).Length()-fileExtension.Length()-KEpocBasePathLen;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   116
#else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   117
	TInt maxFilenameLength = KMaxFileName-(aFilePath).Length()-fileExtension.Length();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   118
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   119
	TBool fileNameChanged = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   120
	// Truncate filename if too long.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   121
	if (maxFilenameLength < aFileName.Length())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   122
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   123
		aFileName.SetLength(maxFilenameLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   124
		aFileName.Append(fileExtension);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   125
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   126
		fileNameChanged = ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   127
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   128
	return fileNameChanged;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   129
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   130
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   131
TBool TMsvServerStoreManager::GenerateFileNameIfExistsL(TDes& aFileName)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   132
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   133
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   134
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   135
	TParse fileParser;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   136
	User::LeaveIfError(fileParser.Set(aFileName, NULL, NULL));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   137
	TInt fileNameGenerator = 1;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   138
	TBool fileNameChanged = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   139
	CDir* dir;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   140
	TInt error =  iFs->GetDir(fileParser.DriveAndPath(), KEntryAttNormal, ESortNone, dir);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   141
	if (error==KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   142
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   143
		CleanupStack::PushL(dir);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   144
		TInt fileCount=dir->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   145
		while(fileCount--)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   146
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   147
			TBool open;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   148
			TFileName filePath(aFileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   149
			TInt error = iFs->IsFileOpen(aFileName, open);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   150
			// file exists
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   151
			if (error==KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   152
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   153
				TFileName tempFileName(fileParser.DriveAndPath());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   154
				tempFileName.Append(fileParser.Name());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   155
				tempFileName.AppendNum(fileNameGenerator++);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   156
				tempFileName.Append(fileParser.Ext());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   157
				aFileName = tempFileName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   158
				fileNameChanged = ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   159
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   160
			else if (error==KErrNotFound)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   161
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   162
				break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   163
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   164
			else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   165
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   166
				User::Leave(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   167
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   168
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   169
		CleanupStack::PopAndDestroy(dir);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   170
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   171
	return fileNameChanged;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   172
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   173
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   174
// from MMsvStoreManager
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   175
TBool TMsvServerStoreManager::CreateAttachmentForWriteL(TMsvId aEntryId, TDes& aFilename, RFile& aFile)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   176
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   177
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   178
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   179
	return CreateAttachmentL(aEntryId, aFilename, aFile, *iFs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   180
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   181
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   182
TBool TMsvServerStoreManager::CreateShareProtectedAttachmentForWriteL(TMsvId aEntryId, TDes& aFilename, RFile& aFile)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   183
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   184
	RFs fs;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   185
	User::LeaveIfError(fs.Connect());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   186
	User::LeaveIfError(fs.ShareProtected());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   187
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   188
	return CreateAttachmentL(aEntryId, aFilename, aFile, fs, ETrue);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   189
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   190
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   191
TBool TMsvServerStoreManager::CreateAttachmentL(TMsvId aEntryId, TDes& aFilename, RFile& aFile, RFs& aFs,TBool aSharedAccess)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   192
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   193
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   194
	GetFilePath(aEntryId,filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   195
	TBool fileNameChanged = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   196
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   197
	if(CheckFileNameLengthAndTrimL(filePath,(TDes&)aFilename))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   198
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   199
		fileNameChanged = ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   200
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   201
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   202
	//for handling TBuf desc overflow
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   203
	RBuf newFilePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   204
	TInt error = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   205
 	newFilePath.CreateL(KMaxPath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   206
	newFilePath.CleanupClosePushL(); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   207
	newFilePath.Copy(filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   208
	if(aFilename.Length()+filePath.Length()>KMaxFileName)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   209
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   210
	newFilePath.ReAllocL(aFilename.Length()+filePath.Length());	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   211
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   212
	newFilePath.Append(aFilename);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   213
	if (aSharedAccess)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   214
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   215
		//Shared access for reading and writing
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   216
		error = aFile.Create(aFs,newFilePath,EFileShareAny|EFileWrite);		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   217
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   218
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   219
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   220
		error = aFile.Create(aFs,newFilePath,EFileWrite);	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   221
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   222
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   223
	if(error == KErrAlreadyExists)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   224
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   225
		if(GenerateFileNameIfExistsL(newFilePath))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   226
			{			
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   227
			fileNameChanged = ETrue;	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   228
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   229
			if (aSharedAccess)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   230
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   231
				//Shared access for reading and writing
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   232
				User::LeaveIfError(aFile.Create(aFs,newFilePath, EFileShareAny|EFileWrite)); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   233
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   234
			else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   235
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   236
			 	User::LeaveIfError(aFile.Create(aFs,newFilePath,EFileWrite));		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   237
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   238
			
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   239
			aFilename.Copy(newFilePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   240
				
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   241
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   242
	else 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   243
	   	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   244
		User::LeaveIfError(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   245
		// return if error = KErrNone
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   246
		aFilename.Copy(newFilePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   247
		}	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   248
	CleanupStack::PopAndDestroy(&newFilePath);//newFilePath destroy 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   249
	return fileNameChanged;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   250
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   251
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   252
void TMsvServerStoreManager::ReplaceAttachmentForWriteL(TMsvId aEntryId, TDes& aFilename, RFile& aFile)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   253
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   254
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   255
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   256
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   257
	GetFilePath(aEntryId, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   258
	TParsePtrC fileName(aFilename);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   259
	filePath.Append(fileName.NameAndExt());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   260
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   261
	User::LeaveIfError(aFile.Replace(*iFs, filePath, EFileWrite));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   262
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   263
	aFilename = filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   264
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   265
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   266
void TMsvServerStoreManager::OpenAttachmentL(TMsvId aEntryId, const TDesC& aFilePath, RFile& aFile)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   267
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   268
	__ASSERT_ALWAYS(iFs != NULL,PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   269
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   270
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   271
	GetFilePath(aEntryId,filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   272
	TParsePtrC fileName(aFilePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   273
	filePath.Append(fileName.NameAndExt());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   274
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   275
	User::LeaveIfError(aFile.Open(*iFs,filePath,EFileRead|EFileShareReadersOnly));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   276
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   277
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   278
void TMsvServerStoreManager::OpenAttachmentForWriteL(TMsvId aEntryId, const TDesC& aFilePath, RFile& aFile)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   279
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   280
	__ASSERT_ALWAYS(iFs != NULL,PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   281
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   282
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   283
	GetFilePath(aEntryId,filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   284
	TParsePtrC fileName(aFilePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   285
	filePath.Append(fileName.NameAndExt());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   286
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   287
	User::LeaveIfError(aFile.Open(*iFs,filePath,EFileWrite));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   288
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   289
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   290
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   291
TInt TMsvServerStoreManager::DeleteAttachment(TMsvId aEntryId, const TDesC& aFilePath)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   292
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   293
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   294
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   295
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   296
	GetFilePath(aEntryId,filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   297
	TParsePtrC fileName(aFilePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   298
	filePath.Append(fileName.NameAndExt());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   299
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   300
	TInt error = iFs->Delete(filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   301
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   302
	if(error == KErrNotFound || error == KErrPathNotFound)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   303
		return KErrNotFound;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   304
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   305
	return error;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   306
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   307
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   308
TInt TMsvServerStoreManager::RenameAttachment(TMsvId aEntryId, const TDesC& aOldFilePath, const TDesC& aNewName)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   309
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   310
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   311
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   312
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   313
	TInt err = GetFilePath(aEntryId, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   314
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   315
	TParsePtrC fileToRename(aOldFilePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   316
	if(err==KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   317
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   318
		filePath.Append(fileToRename.NameAndExt());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   319
		TParse newPath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   320
		err = newPath.Set(aNewName, &fileToRename.FullName(), NULL);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   321
		if( err==KErrNone )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   322
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   323
			err = iFs->Rename(filePath, newPath.FullName());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   324
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   325
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   326
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   327
	return err;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   328
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   329
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   330
TBool TMsvServerStoreManager::FileExistsL(const TDesC& aFilePath)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   331
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   332
	// Use the Att method to check if file exists as it does change the
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   333
	// file and is a light-weight call
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   334
	TUint attValue = 0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   335
	TInt err = iFs->Att(aFilePath, attValue);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   336
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   337
	TBool fileExists = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   338
	if (err == KErrNotFound || err == KErrPathNotFound)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   339
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   340
		fileExists = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   341
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   342
	else if (err == KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   343
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   344
		fileExists = ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   345
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   346
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   347
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   348
		User::Leave(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   349
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   350
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   351
	return fileExists;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   352
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   353
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   354
void TMsvServerStoreManager::AttachmentFilePathL(TMsvId aEntryId, TDes& aFilePath)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   355
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   356
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   357
	User::LeaveIfError(GetFilePath(aEntryId, filePath));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   358
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   359
	aFilePath = filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   360
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   361
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   362
TInt TMsvServerStoreManager::OpenFileStoreForRead(TMsvId aEntryId, RFile& aFile)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   363
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   364
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   365
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   366
	TFileName filePathAndName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   367
	GetStoreFileName(aEntryId,filePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   368
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   369
	TInt error = aFile.Open(*iFs,filePathAndName,EFileRead|EFileShareAny);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   370
	if(error == KErrNotFound || error == KErrPathNotFound)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   371
		return KErrNotFound;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   372
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   373
	return error;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   374
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   375
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   376
void TMsvServerStoreManager::OpenTempStoreFileL(TMsvId aEntryId, RFile& aFile)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   377
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   378
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   379
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   380
	TFileName tempFilePathAndName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   381
	GetStoreFileName(aEntryId,tempFilePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   382
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   383
	tempFilePathAndName.Append(KMsvUtilsNewExtension);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   384
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   385
	TInt error= aFile.Replace(*iFs,tempFilePathAndName,EFileShareExclusive|EFileWrite);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   386
	if (error==KErrPathNotFound)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   387
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   388
        //only create directory if not found
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   389
        error=iFs->MkDirAll(tempFilePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   390
        if (error==KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   391
            error=aFile.Replace(*iFs,tempFilePathAndName,EFileShareExclusive|EFileWrite);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   392
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   393
	User::LeaveIfError(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   394
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   395
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   396
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   397
void TMsvServerStoreManager::ReplaceFileStoreL(TMsvId aEntryId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   398
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   399
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   400
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   401
	TFileName filePathAndName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   402
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   403
	GetStoreFileName(aEntryId,filePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   404
	TFileName tempFilePathAndName(filePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   405
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   406
	tempFilePathAndName.Append(KMsvUtilsNewExtension);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   407
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   408
	TInt error = iFs->Replace(tempFilePathAndName,filePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   409
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   410
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   411
	if(error !=KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   412
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   413
		iFs->Delete(tempFilePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   414
		User::Leave(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   415
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   416
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   417
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   418
void TMsvServerStoreManager::DeleteFileStoreL(TMsvId aEntryId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   419
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   420
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   421
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   422
	TFileName filePathAndName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   423
	GetStoreFileName(aEntryId,filePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   424
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   425
	TInt error = iFs->Delete(filePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   426
	if(error != KErrNone && error != KErrNotFound && error != KErrPathNotFound)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   427
		User::Leave(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   428
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   429
	// Delete the temporary store file if it exists
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   430
	filePathAndName.Append(KMsvUtilsNewExtension);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   431
	error = iFs->Delete(filePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   432
	if(error != KErrNone && error != KErrNotFound && error != KErrPathNotFound)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   433
		User::Leave(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   434
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   435
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   436
TBool TMsvServerStoreManager::FileStoreExistsL(TMsvId aEntryId) const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   437
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   438
	__ASSERT_ALWAYS(iMsvServer != NULL, PanicServer(EMsvServerNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   439
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   440
	TMsvId owningService = KMsvNullIndexEntryId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   441
	TFileName filePathAndName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   442
	GetOwningServiceAndFilePath(aEntryId,filePathAndName,owningService);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   443
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   444
	return User::LeaveIfError(MsvUtils::HasStore(iMsvServer->FileSession(),filePathAndName,owningService, aEntryId));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   445
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   446
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   447
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   448
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   449
Gets the path for the file in message store for which the message Id is passed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   450
@param aBodyTextId The Id of the body text for which the path is required.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   451
@param aFilepath The output parameter which contains filepath.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   452
@return none.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   453
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   454
void TMsvServerStoreManager::BodyTextFilePathL(TMsvId aBodyTextId, TDes& aFilePath)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   455
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   456
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   457
	User::LeaveIfError(GetFilePath(aBodyTextId, filePath));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   458
	aFilePath = filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   459
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   460
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   461
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   462
Opens the RFile for which the aFilepath is passed in read mode.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   463
@param RFile   		Reference to RFile that needs to be opened.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   464
@param aBodyTextId 	The Id of the bodytext.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   465
@param aFilepath 	The path of the file to be opened.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   466
@return none.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   467
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   468
void TMsvServerStoreManager::OpenBodyTextFileForReadL(RFile& aFile, TMsvId /*aBodyTextId*/, const TDesC& aFilePath)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   469
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   470
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   471
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   472
	User::LeaveIfError(aFile.Open(*iFs, aFilePath, EFileRead));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   473
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   474
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   475
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   476
Creates the RFile in the aFilepath is passed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   477
@param RFile     	Reference to RFile that will be created.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   478
@param aBodyTextId 	The Id of the bodytext.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   479
@return none.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   480
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   481
void TMsvServerStoreManager::CreatePlainTextFileL(RFile& aFile, TMsvId aBodyTextId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   482
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   483
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   484
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   485
	TFileName filePathAndName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   486
	GetFilePath(aBodyTextId, filePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   487
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   488
	TBuf<KFileNameFixedWidth> fileName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   489
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   490
	fileName.NumFixedWidth(aBodyTextId, EHex, KFileNameFixedWidth);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   491
	filePathAndName.Append(fileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   492
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   493
	TFileName tempFilePathAndName((filePathAndName));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   494
	tempFilePathAndName.Append(KMsvUtilsNewExtension);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   495
	User::LeaveIfError(aFile.Replace(*iFs, tempFilePathAndName, EFileShareExclusive|EFileWrite));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   496
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   497
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   498
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   499
Deletes the RFile in the aFilepath passed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   500
@param aBodyTextId  The Id of the bodytext.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   501
@return none.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   502
*/	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   503
void TMsvServerStoreManager::DeletePlainTextFileL(TMsvId aBodyTextId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   504
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   505
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   506
	TFileName filePathAndName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   507
	GetFilePath(aBodyTextId, filePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   508
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   509
	TBuf<KFileNameFixedWidth> fileName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   510
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   511
	fileName.NumFixedWidth(aBodyTextId, EHex, KFileNameFixedWidth);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   512
	filePathAndName.Append(fileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   513
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   514
	TFileName tempFilePathAndName((filePathAndName));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   515
	tempFilePathAndName.Append(KMsvUtilsNewExtension);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   516
	// Remove the temporary file if it is there.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   517
	TInt err = iFs->Delete(tempFilePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   518
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   519
	if (err != KErrNone && err != KErrNotFound)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   520
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   521
		User::Leave(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   522
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   523
	// There is no temporary file, delete the body text file.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   524
	if (err == KErrNotFound)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   525
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   526
		TInt error = iFs->Delete(filePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   527
		if (error != KErrNone && error != KErrNotFound && error != KErrPathNotFound)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   528
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   529
			User::Leave(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   530
			}		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   531
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   532
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   533
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   534
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   535
Replaces a temporary RFile with a new RFile.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   536
@param aBodyTextId  The Id of the bodytext.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   537
@return none.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   538
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   539
void TMsvServerStoreManager::ReplacePlainTextFileL(TMsvId aBodyTextId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   540
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   541
	__ASSERT_ALWAYS(iFs != NULL, PanicServer(EMsvFileSessionNotValid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   542
	TFileName filePathAndName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   543
	GetFilePath(aBodyTextId, filePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   544
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   545
	TBuf<KFileNameFixedWidth> fileName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   546
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   547
	fileName.NumFixedWidth(aBodyTextId, EHex, KFileNameFixedWidth);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   548
	filePathAndName.Append(fileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   549
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   550
	TFileName tempFilePathAndName((filePathAndName));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   551
	tempFilePathAndName.Append(KMsvUtilsNewExtension);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   552
	TInt err = iFs->Replace(tempFilePathAndName,filePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   553
	if(err != KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   554
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   555
		iFs->Delete(tempFilePathAndName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   556
		User::Leave(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   557
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   558
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   559
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   560
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   561
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   562
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   563
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   564
#if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   565
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   566
 * LoadHeaderL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   567
 * 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   568
 * @param aMtmId : a MTM id.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   569
 * @param aEntryId: Metadata entry Id of the message body.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   570
 * @param iFieldPairList: Array of header fields.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   571
 */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   572
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   573
void TMsvServerStoreManager::LoadHeaderEntryL(const TUid& aMtmId, TMsvId aEntryId, RPointerArray<CHeaderFields>& aFieldPairList)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   574
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   575
	iMsvServer->MessageDBAdapter().LoadHeaderEntryL(aMtmId,aEntryId,aFieldPairList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   576
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   577
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   578
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   579
 * DeleteHeaderL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   580
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   581
 * 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   582
 * @param aMtmId : a MTM id.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   583
 * @param aEntryId: Metadata entry Id of the message body.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   584
 */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   585
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   586
void TMsvServerStoreManager::DeleteHeaderEntryL(const TUid& aMtmId, TMsvId aEntryId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   587
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   588
	iMsvServer->MessageDBAdapter().DeleteHeaderEntryL(aMtmId,aEntryId);	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   589
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   590
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   591
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   592
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   593
 * UpdateHeaderL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   594
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   595
 * 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   596
 * @param aMtmId : a MTM id.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   597
 * @param aEntryId: Metadata entry Id of the message body.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   598
 * @param iFieldPairList: Array of header fields.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   599
 */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   600
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   601
void TMsvServerStoreManager::UpdateHeaderEntryL(const TUid& aMtmId, TMsvId aEntryId, const RPointerArray<CHeaderFields>& aFieldPairList)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   602
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   603
	iMsvServer->MessageDBAdapter().UpdateHeaderEntryL(aMtmId,aEntryId,aFieldPairList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   604
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   605
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   606
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   607
 * CreateHeaderEntryL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   608
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   609
 * 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   610
 * @param aMtmId : a MTM id.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   611
 * @param aEntryId: Metadata entry Id of the message body.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   612
 * @param iFieldPairList: Array of header fields.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   613
 */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   614
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   615
void TMsvServerStoreManager::CreateHeaderEntryL(const TUid& aMtmId, TMsvId aEntryId, const RPointerArray<CHeaderFields>& aFieldPairList)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   616
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   617
	iMsvServer->MessageDBAdapter().CreateHeaderEntryL(aMtmId,aEntryId,aFieldPairList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   618
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   619
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   620
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   621
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   622
TBool TMsvServerStoreManager::DoesAnyStoreExists(TMsvId aId, TUid aMtmId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   623
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   624
	TBool isStoreExists = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   625
	TRAPD(err, isStoreExists = iMsvServer->MessageDBAdapter().DoesAnyStoreExistsL(aId, aMtmId));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   626
	if(err)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   627
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   628
		return EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   629
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   630
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   631
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   632
		return isStoreExists;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   633
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   634
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   635
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   636
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   637
TBool TMsvServerStoreManager::DoesHeaderTableExist(const TUid& aMtmId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   638
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   639
	TBool doesTableExists = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   640
	TRAPD(err, doesTableExists = iMsvServer->MessageDBAdapter().IsHeaderTableExistsL(aMtmId));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   641
	if(err)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   642
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   643
		return EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   644
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   645
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   646
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   647
		return doesTableExists;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   648
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   649
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   650
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   651
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   652
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   653
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   654
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   655
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   656
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   657
#endif			// #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)