messagingfw/msgsrvnstore/server/src/MSVSESS.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) 1998-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
#ifdef _DEBUG
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    17
#undef _NO_SERVER_LOGGING_
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    18
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    19
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    20
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    21
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    22
#include <e32std.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    23
#include <s32mem.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    24
#include <tmsvsystemprogress.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    25
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    26
#include "MSVSTD.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    27
#include "MSVIPC.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    28
#include "MSVREG.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    29
#include "MSVREGIP.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    30
#include "MSVIDS.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    31
#include "MSVUIDS.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    32
#include "MSVENTRY.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    33
#include "MSERVER.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    34
#include "MSVSERV.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    35
#include "MSVLOPS.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    36
#include "MSVROPS.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    37
#include "MSVUTILS.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    38
#include "MTSR.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    39
#include "MSVPANIC.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    40
#include "CMsvChangeBuffer.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    41
#include "MsvSecurityCapabilitySet.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    42
#include "cmsvcopystoreoperation.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    43
#include "cmsvdeletestoreoperation.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    44
#include "MSVAPI.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    45
#include "msvindexadapter.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    46
#include "msvcacheentry.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    47
#include "msvsearchsortcacheentry.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    48
#include "msvsearchsortcachemanager.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    49
#include "msvsearchsortdeltacache.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    50
#include <msvsearchsortquery.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    51
#include <msvsearchsortoperation.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    52
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    53
#if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    54
#include <u32std.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    55
#include "cmsvconverterwaiter.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    56
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    57
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    58
const TInt KMsvOperationIndexGranularity=8;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    59
const TInt KMsvOperationDataArrayGranularity=4;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    60
const TInt KMsvMtmRefCountArrayGranularity=4;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    61
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    62
_LIT(KMsvClientPanicString, "MSGS Client");
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    63
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    64
//**********************************
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    65
// TMtmGroupRefCount
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    66
//**********************************
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    67
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    68
TMtmGroupRefCount::TMtmGroupRefCount(TUid aMtmTypeUid)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    69
: iMtmTypeUid(aMtmTypeUid), iRefCount(0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    70
	{}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    71
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    72
//**********************************
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    73
// CMsvOperationData
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    74
//**********************************
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    75
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    76
CMsvOperationData::CMsvOperationData(TMsvOp aOpId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    77
: iOpId(aOpId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    78
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    79
	__DECLARE_NAME(_S("CMsvOperationData"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    80
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    81
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    82
CMsvOperationData::~CMsvOperationData()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    83
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    84
	delete iBuffer;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    85
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    86
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    87
//**********************************
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    88
// CMsvServerSession
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    89
//**********************************
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    90
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    91
CMsvServerSession::CMsvServerSession(CMsvServer& aServer)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    92
:   CSession2(),
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    93
	iMsvServer(aServer),
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    94
	iOperations(KMsvOperationIndexGranularity),
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    95
	iMtmGroupRefCountArray(KMsvMtmRefCountArrayGranularity),
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    96
	iOperationDataArray(KMsvOperationDataArrayGranularity),
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    97
	iReceiveEntryEvents(ETrue)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    98
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    99
	__DECLARE_NAME(_S("CMsvServerSession"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   100
	iSessionId = iMsvServer.SessionId();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   101
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   102
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   103
CMsvServerSession* CMsvServerSession::NewL(CMsvServer& aServer, const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   104
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   105
	CMsvServerSession* self = new(ELeave) CMsvServerSession(aServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   106
	CleanupStack::PushL(self);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   107
	self->ConstructL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   108
	CleanupStack::Pop();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   109
	return self;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   110
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   111
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   112
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   113
void CMsvServerSession::ConstructL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   114
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   115
	iChangeBuffer = CMsvChangeBuffer::NewL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   116
	iBuffer = HBufC8::NewL(KMsvSessionBufferLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   117
	iChildrenSelection = new(ELeave) CArrayPtrSeg<const TMsvEntry>(16);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   118
	iChildrenSelectionIds = new(ELeave) CMsvEntrySelection;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   119
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   120
	// if the index is already loaded, tell the client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   121
	if (iMsvServer.HasContext() && iMsvServer.Context().State()==TMsvIndexLoadProgress::EIndexComplete)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   122
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   123
		TMsvNotifBuffer buffer;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   124
		TMsvPackedChangeNotification package(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   125
		package.Pack(EMsvIndexLoaded, 0, 0, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   126
		NotifyChangedL(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   127
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   128
		// Send disk status notifications
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   129
		if (iMsvServer.StartupState() != EMsvNullNotification)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   130
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   131
			package.Pack(iMsvServer.StartupState(), KMsvNullIndexEntryId, iMsvServer.Context().Config().iDrive, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   132
			NotifyChangedL(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   133
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   134
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   135
	#if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   136
			// if we have unsupported drives, notify the client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   137
		if(FoundUnSupportedDrives())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   138
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   139
			package.Pack(EMsvMessageStoreNotSupported, 0, 0, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   140
			NotifyChangedL(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   141
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   142
	#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   143
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   144
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   145
	RThread thread;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   146
	aMessage.Client(thread);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   147
	iProcessName = thread.Name();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   148
	thread.Close();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   149
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   150
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   151
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   152
CMsvServerSession::~CMsvServerSession()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   153
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   154
	// releasing locks
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   155
	__ASSERT_DEBUG(iLockedStores.Count()==0, PanicClient(iQueuedMessage, EMsvLockedStoresOnExit));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   156
	TInt count = iLockedStores.Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   157
	while (count--)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   158
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   159
		iMsvServer.IndexAdapter().ReleaseStore(iLockedStores.At(count)); // ignore any errors
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   160
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   161
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   162
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   163
	// deleting outstanding operations
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   164
	__ASSERT_DEBUG(iOperations.Count()==0, PanicClient(iQueuedMessage, EMsvOutstandingOperationsOnExit));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   165
	count=iOperations.Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   166
	while (count--)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   167
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   168
		delete iOperations.At(count); // operation are deleted last in first out order
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   169
		iOperations.Delete(count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   170
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   171
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   172
	iOperationDataArray.ResetAndDestroy();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   173
	iMtmGroupRefCountArray.Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   174
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   175
	// Set request queued flag to false so we're not notified to close the session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   176
	iRequestQueued = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   177
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   178
	iMsvServer.ClosingSession(iSessionId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   179
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   180
	delete iChildrenSelection;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   181
	delete iChildrenSelectionIds;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   182
	if(iChangeBuffer != NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   183
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   184
		delete iChangeBuffer;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   185
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   186
	if(iBuffer != NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   187
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   188
		delete iBuffer;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   189
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   190
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   191
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   192
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   193
void CMsvServerSession::ServiceL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   194
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   195
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   196
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   197
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   198
	if ((!iMsvServer.HasContext() || iMsvServer.Context().State()!=TMsvIndexLoadProgress::EIndexComplete) && aMessage.Function()!=EMsvNotifySessionEvent && aMessage.Function()!=EMsvCancelSessionEventNotification)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   199
		aMessage.Complete(KErrNotReady);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   200
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   201
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   202
		TRAPD(error, DoServiceL(aMessage));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   203
		if (error)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   204
			aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   205
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   206
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   207
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   208
void CMsvServerSession::DoServiceL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   209
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   210
// service a client request; test the opcode and then do appropriate servicing
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   211
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   212
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   213
	// all functions called should ensure that all synchronous messages have been completed
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   214
	switch (aMessage.Function())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   215
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   216
		case EMsvNotifySessionEvent:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   217
			QueueSessionEventRequestL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   218
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   219
		case EMsvCancelSessionEventNotification:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   220
			CancelSessionEventRequest(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   221
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   222
		case EMsvOperationData:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   223
			CopyOperationDataL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   224
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   225
		case EMsvCommandData:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   226
			CopyCommandDataL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   227
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   228
		case EMsvCreateEntry:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   229
			CreateEntryL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   230
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   231
		case EMsvGetEntry:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   232
			GetEntryL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   233
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   234
		case EMsvChangeEntry:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   235
			ChangeEntryL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   236
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   237
		case EMsvGetChildren:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   238
			GetChildrenL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   239
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   240
		case EMsvGetRemainingChildren:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   241
			GetRemainingChildrenL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   242
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   243
		case EMsvDeleteEntries:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   244
			DeleteEntriesL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   245
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   246
		case EMsvLockEntry:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   247
			LockEntryL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   248
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   249
		case EMsvReleaseEntry:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   250
			ReleaseEntryL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   251
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   252
		case EMsvReadStore:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   253
			ReadStoreL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   254
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   255
		case EMsvLockStore:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   256
			LockStoreL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   257
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   258
		case EMsvReleaseStore:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   259
			ReleaseStoreL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   260
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   261
		case EMsvCancelOperation:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   262
			CancelOperationL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   263
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   264
		case EMsvOperationCompletion:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   265
			OperationCompletionL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   266
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   267
		case EMsvOperationProgress:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   268
			OperationProgressL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   269
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   270
		case EMsvOperationSystemProgress:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   271
			OperationSystemProgressL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   272
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   273
		case EMsvOperationMtm:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   274
			OperationMtmL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   275
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   276
		case EMsvMoveEntries:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   277
			MoveEntriesL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   278
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   279
		case EMsvCopyEntries:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   280
			CopyEntriesL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   281
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   282
		case EMsvMtmCommand:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   283
			TransferCommandL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   284
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   285
		case EMsvFillRegisteredMtmDllArray:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   286
			FillRegisteredMtmDllArray(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   287
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   288
		case EMsvInstallMtmGroup:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   289
			MtmGroupL(aMessage, ETrue);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   290
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   291
		case EMsvDeInstallMtmGroup:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   292
			MtmGroupL(aMessage, EFalse);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   293
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   294
		case EMsvUseMtmGroup:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   295
			UseMtmGroup(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   296
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   297
		case EMsvReleaseMtmGroup:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   298
			ReleaseMtmGroup(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   299
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   300
		case EMsvGetMtmGroupData:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   301
			GetMtmGroupDataL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   302
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   303
		case EMsvGetMtmRequiredCapabilities:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   304
			GetMtmRequiredCapabilitiesL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   305
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   306
		case EMsvCloseServer:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   307
			iMsvServer.CloseServer(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   308
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   309
		case EMsvStopService:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   310
			iMsvServer.StopServiceL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   311
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   312
		case EMsvServiceActive:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   313
			iMsvServer.ServiceActive(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   314
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   315
		case EMsvServiceProgress:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   316
			ServiceProgressL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   317
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   318
		case EMsvRemoveEntry:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   319
			RemoveEntry(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   320
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   321
		case EMsvGetMessageDirectory:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   322
			MessageFolderL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   323
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   324
		case EMsvSlotAvailable:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   325
			if (iOperations.Count()<KMsvMaxSlotsAvailable)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   326
				aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   327
			else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   328
				aMessage.Complete(KErrServerBusy);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   329
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   330
		case EMsvSetSessionAsObserver:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   331
			iObserverOnly=ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   332
			aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   333
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   334
		case EMsvSetFailure:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   335
			iMsvServer.SetFailure((TMsvFailure)aMessage.Int0(), aMessage.Int1(), aMessage.Int2(), aMessage.Int3());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   336
			aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   337
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   338
		case EMsvChangeAttributes:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   339
			ChangeAttributesL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   340
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   341
		case EMsvGetChildIds:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   342
			GetChildIdsL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   343
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   344
		case EMsvChangeDrive:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   345
			ChangeDriveL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   346
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   347
		case EMsvOutstandingOperations:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   348
			OutstandingOperationsL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   349
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   350
		case EMsvGetNotifySequence:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   351
			GetNotifySequenceL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   352
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   353
		case EMsvSetReceiveEntyEvents:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   354
			SetReceiveEntryEvents(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   355
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   356
		case EMsvDecStoreReaderCount:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   357
			DecStoreReaderCountL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   358
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   359
		case EMsvGetMessageDrive:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   360
#if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   361
			MessageDrive(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   362
#else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   363
			aMessage.Complete(iMsvServer.Context().Config().iDrive);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   364
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   365
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   366
		case EMsvCreateAttachmentForWrite:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   367
			CreateAttachmentForWriteL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   368
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   369
		case EMsvReplaceAttachmentForWrite:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   370
			ReplaceAttachmentForWriteL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   371
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   372
		case EMsvOpenAttachment:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   373
			OpenAttachmentL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   374
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   375
		case EMsvOpenAttachmentForWrite:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   376
			OpenAttachmentForWriteL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   377
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   378
		case EMsvDeleteAttachment:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   379
			DeleteAttachmentL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   380
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   381
		case EMsvRenameAttachment:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   382
			RenameAttachmentL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   383
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   384
		case EMsvFileExists :
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   385
			FileExistsL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   386
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   387
		case EMsvGetAttachmentFilePath:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   388
			GetAttachmentFilePathL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   389
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   390
		case EMsvOpenFileStoreForRead:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   391
			OpenFileStoreForReadL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   392
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   393
		case EMsvOpenTempStoreFile:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   394
			OpenTempStoreFileL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   395
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   396
		case EMsvReplaceFileStore:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   397
			ReplaceFileStoreL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   398
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   399
		case EMsvDeleteFileStore:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   400
			DeleteFileStoreL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   401
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   402
		case EMsvFileStoreExists:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   403
			FileStoreExistsL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   404
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   405
		case EMsvGetAndClearIndexCorruptFlag:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   406
			aMessage.Complete(iMsvServer.Context().GetAndClearIndexCorruptFlagL());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   407
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   408
		case EMsvCopyStore:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   409
			CopyStoreL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   410
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   411
		case EMsvDeleteStore:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   412
			DeleteStoreL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   413
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   414
		case EMsvDriveContainsStore:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   415
			aMessage.Complete(MessageServer::DriveContainsStore(iMsvServer.FileSession(),aMessage.Int0()));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   416
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   417
		case EMsvMessageStoreDrivePresent:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   418
			aMessage.Complete(MessageServer::IsMessageStoreDrivePresentL(iMsvServer.FileSession()));			
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   419
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   420
		case EMsvGetBodyTextFilePath:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   421
			 BodyTextFilePathL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   422
			 break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   423
		case EMsvOpenTextFileForRead:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   424
			 OpenPlainTextFileL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   425
			 break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   426
		case EMsvCreatePlainTextFile:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   427
			 CreatePlainTextFileL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   428
			 break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   429
		case EMsvDeletePlainTextFile:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   430
			DeletePlainTextFileL(aMessage); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   431
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   432
		case EMsvReplacePlainTextFile:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   433
			ReplacePlainTextFileL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   434
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   435
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   436
		case EMsvGetNonOperationMtmData:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   437
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   438
			GetNonOperationMtmDataL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   439
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   440
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   441
		case EMsvSearchSortOperation: // On HEADER AND BODY
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   442
			SearchSortOnHeaderAndBodytMsgL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   443
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   444
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   445
		case EMsvSearchSortOnIndexEntry: //On INDEX ENTRY.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   446
			SearchSortOnIndexEntryL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   447
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   448
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   449
		case EMsvGetResult ://Index entry result.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   450
			SendSearchSortIndexEntryResultL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   451
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   452
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   453
		case EMsvGetIdsOrResult://header result.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   454
			SendResultOrIdsToSearchL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   455
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   456
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   457
		case EMsvGetResultCount:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   458
			GetSearchSortResultCountL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   459
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   460
			
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   461
		case EMsvGetNextId:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   462
			GetResultInIteratorL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   463
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   464
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   465
		case EMsvGetNextEntry:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   466
			GetNextEntryInIteratorL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   467
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   468
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   469
		case EMsvGetQueryId:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   470
			GetQueryIDL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   471
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   472
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   473
		case EMsvUnmarQueryId:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   474
			QueryUnMarkedL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   475
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   476
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   477
		case EMsvIdWithSortFiled:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   478
			UpdateSearchSortCacheWithSortFiledL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   479
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   480
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   481
		case EMsvSearchSortQueryId:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   482
			GetResultForQueryIDL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   483
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   484
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   485
		case EMsvQueryData:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   486
			CopyQueryDataL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   487
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   488
			
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   489
		case EMsvGetSearchSortProgress:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   490
			GetSearchSortProgressInfoL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   491
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   492
			
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   493
		case EMsvCancelSearchSortOp:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   494
			SearchSortOperationCancelL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   495
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   496
			
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   497
		case EMsvUpdateAndSort:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   498
			UpdateSearchSortResultsAndSortByEntryL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   499
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   500
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   501
// Code changes for PREQ 557.	   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   502
#if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   503
		case EMsvGetChildrenALL:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   504
			GetChildrenAllL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   505
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   506
		case EMsvGetChildIdsALL:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   507
			GetChildIdsAllL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   508
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   509
		case EMsvGetCurrentDriveInfo:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   510
			CurrentDriveInfoL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   511
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   512
		case EMsvGetDriveList:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   513
			DriveListL(aMessage);	   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   514
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   515
		case EMsvGetAvailableDriveList:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   516
			AvailableDriveListL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   517
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   518
		case EMsvAddDriveToDriveList:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   519
			AddDriveL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   520
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   521
		case EMsvRemoveDriveFromDriveList:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   522
			RemoveDriveL(aMessage); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   523
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   524
		case EMsvUpdateDrivePriority:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   525
			UpdateDrivePriorityL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   526
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   527
#if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   528
		case EMsvResetRepository:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   529
			ResetRepositoryL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   530
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   531
		case EMsvPrintCache:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   532
			PrintCache(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   533
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   534
#endif	  // #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   535
#endif	  // #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   536
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   537
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   538
#if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   539
		case EMsvCreateStore:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   540
			CreateHeaderTableL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   541
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   542
		case EMsvCheckStoreExists:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   543
			DoesStoreExistsL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   544
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   545
		case EMsvLastErrorMessage:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   546
			LastErrorMessageL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   547
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   548
		case EMsvCreateHeaderEntry:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   549
			CreateHeaderEntryL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   550
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   551
		case EMsvLoadHeaderEntry:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   552
			LoadHeaderEntryL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   553
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   554
		case EMsvUpdateHeaderEntry:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   555
			UpdateHeaderEntryL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   556
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   557
		case EMsvDeleteHeaderEntry:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   558
			DeleteHeaderEntryL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   559
			break;							  
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   560
		case EMsvCheckAnyStoreExists:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   561
			DoesAnyStoreExists(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   562
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   563
		case EMsvCheckHeaderTableExist:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   564
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   565
			DoesHeaderTableExist(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   566
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   567
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   568
		case EMsvGetConvertibleDriveList:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   569
			GetConvertibleDriveListL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   570
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   571
		case EMsvConvertMessageStore:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   572
			ConvertMessageStoreL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   573
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   574
		case EMsvGetConversionStatus:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   575
			GetConversionStatus(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   576
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   577
		case EMsvCancelConversionRequest:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   578
			CancelConversionRequestL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   579
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   580
#endif	  // #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   581
		case EMsvChangeEntries:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   582
		     ChangeEntriesL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   583
		     break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   584
		default:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   585
			PanicClient(aMessage, EMsvBadRequest);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   586
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   587
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   588
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   589
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   590
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   591
void CMsvServerSession::QueueSessionEventRequestL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   592
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   593
// The client is requesting notifcation of any changes
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   594
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   595
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   596
	if (iRequestQueued)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   597
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   598
		PanicClient(aMessage, EMsvDuplicatedChangeRequest);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   599
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   600
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   601
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   602
	if (iChangeBuffer->IsEmpty())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   603
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   604
		// queue this request until a change occurs
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   605
		iQueuedMessage = aMessage;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   606
		iRequestQueued = ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   607
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   608
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   609
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   610
		// inform client of change which has been queued
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   611
		SendNotificationL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   612
		}
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 CMsvServerSession::SendNotificationL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   616
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   617
	// inform client of change which has been queued
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   618
	TPckgBuf<TUint32> sequence;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   619
	aMessage.WriteL(0, iChangeBuffer->Next(sequence()));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   620
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   621
	// Tell the client the notification sequence number
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   622
	aMessage.WriteL(1, sequence);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   623
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   624
#ifndef _NO_SERVER_LOGGING_
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   625
	iMsvServer.Log(_L("Sending notification sequence %d"), sequence());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   626
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   627
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   628
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   629
	iChangeBuffer->Out();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   630
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   631
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   632
void CMsvServerSession::CancelSessionEventRequest(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   633
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   634
// The client is cancelling the outstanding request
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   635
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   636
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   637
	if (iRequestQueued)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   638
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   639
		iQueuedMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   640
		iRequestQueued = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   641
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   642
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   643
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   644
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   645
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   646
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   647
void CMsvServerSession::ReadBufferL(const RMessage2& aMessage, TInt aParam, HBufC8*& aBuffer)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   648
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   649
// Copies a buffer from the client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   650
// Only fails if there is not enough memory to increase the buffer size (if needed)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   651
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   652
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   653
	TInt desLen = aMessage.GetDesLength(aParam);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   654
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   655
	if(desLen >= 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   656
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   657
		TBool alloced=EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   658
		HBufC8* localBuffer=NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   659
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   660
		if (aBuffer==NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   661
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   662
			localBuffer = HBufC8::NewLC(desLen);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   663
			alloced=ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   664
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   665
		else if (desLen > aBuffer->Des().MaxLength())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   666
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   667
			// we have to increase the size of iBuffer
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   668
			aBuffer->Des().SetLength(0); // to avoid copying the contents
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   669
			localBuffer = aBuffer->ReAlloc(desLen);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   670
			if (localBuffer==NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   671
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   672
				User::Leave(KErrNoMemory); // unable to create buffer large enough
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   673
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   674
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   675
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   676
		if(localBuffer)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   677
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   678
			TPtr8 desPtr = localBuffer->Des();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   679
			aMessage.ReadL(aParam, desPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   680
				
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   681
			if (alloced)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   682
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   683
				CleanupStack::Pop(); // localBuffer
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   684
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   685
			
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   686
			aBuffer = localBuffer;  
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   687
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   688
		//use aBuffer
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   689
		else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   690
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   691
			TPtr8 desPtr = aBuffer->Des();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   692
			aMessage.ReadL(aParam, desPtr); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   693
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   694
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   695
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   696
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   697
		// desLen is negative leave with an error.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   698
		User::Leave(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   699
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   700
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   701
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   702
void CMsvServerSession::WriteBufferL(const RMessage2& aMessage, TInt aParam)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   703
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   704
// Copies the packed entry buffer from the client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   705
// Only fails if the client buffer is not large enough
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   706
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   707
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   708
	TInt desLen = aMessage.GetDesMaxLength(aParam);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   709
	if (desLen < iBuffer->Des().Length())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   710
		User::Leave(KErrOverflow);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   711
	aMessage.WriteL(aParam, iBuffer->Des());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   712
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   713
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   714
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   715
void CMsvServerSession::WriteL(const RMessage2& aMessage, TInt aParam, const TDesC8& aDes)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   716
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   717
// Write a descriptor to the client thread; if unsuccessful,leave so that client can handle it.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   718
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   719
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   720
	TInt error = aMessage.Write(aParam, aDes);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   721
	if (error)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   722
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   723
		User::Leave(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   724
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   725
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   726
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   727
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   728
void CMsvServerSession::ReadL(const RMessage2& aMessage, TInt aParam, TDes8& aDes)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   729
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   730
// Reads a descriptor from the client thread; if unsuccessful,leave so that client can handle it
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   731
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   732
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   733
	TInt error = aMessage.Read(aParam, aDes);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   734
	if (error)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   735
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   736
		User::Leave(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   737
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   738
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   739
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   740
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   741
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   742
void CMsvServerSession::CopyOperationDataL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   743
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   744
// Copies operation data from the client and stores for the asynchronous operation request
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   745
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   746
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   747
	TMsvOp operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   748
	CMsvOperationData* opData = new (ELeave) CMsvOperationData(operationId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   749
	CleanupStack::PushL(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   750
	ReadBufferL(aMessage, 1, opData->iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   751
	iOperationDataArray.AppendL(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   752
	CleanupStack::Pop(); // opData
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   753
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   754
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   755
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   756
void CMsvServerSession::CopyCommandDataL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   757
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   758
// Copies operation data from the client and stores for the asynchronous operation request
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   759
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   760
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   761
	TMsvOp operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   762
	// operation data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   763
	CMsvOperationData* opData = new (ELeave) CMsvOperationData(operationId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   764
	CleanupStack::PushL(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   765
	ReadBufferL(aMessage, 1, opData->iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   766
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   767
	// This is to check if the buffer is a valid , before it is added to 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   768
	// the operationData array
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   769
	TMsvPackedOperation packedOperation(opData->iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   770
	CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   771
	CleanupStack::PushL(selection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   772
	TInt command, temp;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   773
	packedOperation.UnpackL(*selection, command, temp);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   774
	CleanupStack::PopAndDestroy(selection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   775
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   776
	iOperationDataArray.AppendL(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   777
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   778
	// additional parameter
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   779
	CMsvOperationData* opParam = new (ELeave) CMsvOperationData(operationId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   780
	CleanupStack::PushL(opParam);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   781
	ReadBufferL(aMessage, 2, opParam->iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   782
	iOperationDataArray.AppendL(opParam);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   783
	CleanupStack::Pop(2, opData); // opParam, opData
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   784
	//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   785
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   786
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   787
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   788
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   789
HBufC8* CMsvServerSession::RecoverOperationData(TMsvOp aOpId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   790
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   791
// Returns the operation data previously copied from the client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   792
// NOTE the calling function is responsible for deleting the returned HBufC
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   793
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   794
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   795
	// find the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   796
	TInt count = 0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   797
	TInt totalCount=iOperationDataArray.Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   798
	for (; count<totalCount; count++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   799
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   800
		if (iOperationDataArray.At(count)->OperationId()==aOpId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   801
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   802
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   803
	// Panic during debug if cannot find data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   804
	__ASSERT_DEBUG(count<iOperationDataArray.Count(), PanicServer(EMsvEntryDataNotFound));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   805
	// At runtime, return NULL.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   806
	if(count >= iOperationDataArray.Count())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   807
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   808
		return NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   809
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   810
	// return the data to the caller, and delete the container object
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   811
	HBufC8* opData = iOperationDataArray.At(count)->iBuffer;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   812
	iOperationDataArray.At(count)->iBuffer = NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   813
	delete iOperationDataArray.At(count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   814
	iOperationDataArray.Delete(count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   815
	return opData;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   816
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   817
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   818
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   819
void CMsvServerSession::CreateEntryL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   820
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   821
// Create a entry in the index
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   822
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   823
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   824
	// Recover the operation data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   825
	TMsvOp operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   826
	HBufC8* opData = RecoverOperationData(operationId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   827
	// Check for NULL data entry to be changed, must have been given incorrect id for argument.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   828
	if(opData == NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   829
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   830
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   831
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   832
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   833
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   834
	CleanupStack::PushL(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   835
	// Unpack the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   836
	TMsvPackedEntry packedEntry(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   837
	TMsvEntry entry;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   838
	packedEntry.UnpackEntry(entry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   839
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   840
	// Check the content of the entry are conforming to policy
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   841
	if (!MsvUtils::ValidEntry(entry, ETrue))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   842
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   843
		PanicClient(aMessage, EMsvIncorrectEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   844
		User::Leave(KErrNotSupported);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   845
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   846
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   847
	// Check if the entry is local or the entry is a service
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   848
	TBool local=ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   849
	// Police request - client must be able to create the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   850
	iMsvServer.PoliceCreateEntryL(aMessage, entry, local, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::CreateEntryL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   851
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   852
	// For purpose of creating a service entry, it is considered local as an MTM
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   853
	// is not required to do the work.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   854
	if( entry.iType == KUidMsvServiceEntry )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   855
		local = ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   856
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   857
	// start the change for local or remote entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   858
	if (local)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   859
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   860
		TSecureId ownerId = aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   861
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   862
		DoCreateLocalEntryL(entry, operationId, aMessage, ownerId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   863
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   864
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   865
		DoCreateRemoteEntryL(entry, operationId, aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   866
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   867
	CleanupStack::PopAndDestroy(); // opData
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   868
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   869
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   870
void CMsvServerSession::DoCreateLocalEntryL(const TMsvEntry& aEntry, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   871
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   872
// Create a local entry in the index
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   873
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   874
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   875
	CMsvLocalCreateOperation* operation = new(ELeave) CMsvLocalCreateOperation(aMessage, aOpId, aEntry, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   876
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   877
	iOperations.AppendL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   878
	CleanupStack::Pop(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   879
	operation->Start(aOwnerId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   880
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   881
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   882
void CMsvServerSession::DoCreateRemoteEntryL(const TMsvEntry& aEntry, TMsvOp aOpId, const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   883
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   884
// Create a remote entry in the index
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   885
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   886
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   887
	// make sure that the operation can be added to the list
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   888
	iOperations.SetReserveL(iOperations.Count()+1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   889
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   890
	// create the operation and pass it to the server for starting/queuing
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   891
	CMsvMtmOperation* operation = CMsvMtmOperation::NewL(aMessage, aOpId, aEntry.iMtm, aEntry.iServiceId, iSessionId, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   892
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   893
	operation->CreateL(aEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   894
	iMsvServer.StartOperationL(*operation, iSessionId, aMessage, ETrue);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   895
	iOperations.AppendL(operation); // will not fail - see start of function
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   896
	CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   897
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   898
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   899
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   900
void CMsvServerSession::ChangeEntryL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   901
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   902
// Changes the entry
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   903
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   904
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   905
	// Recover the operation data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   906
	TMsvOp operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   907
	HBufC8* opData = RecoverOperationData(operationId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   908
	// Check for NULL data entry to be changed, must have been given incorrect id for argument.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   909
	if(opData == NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   910
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   911
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   912
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   913
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   914
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   915
	CleanupStack::PushL(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   916
	// Unpack the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   917
	TMsvPackedEntry packedEntry(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   918
	TMsvEntry entry;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   919
	packedEntry.UnpackEntry(entry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   920
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   921
	// Check the content of the entry are conforming to policy
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   922
	__ASSERT_DEBUG(MsvUtils::ValidEntry(entry), PanicClient(aMessage, EMsvIncorrectEntry));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   923
	if (!MsvUtils::ValidEntry(entry))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   924
		User::Leave(KErrNotSupported);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   925
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   926
	// Check if the entry is local or the entry is a service
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   927
	TBool local=ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   928
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   929
	iMsvServer.PoliceModifyEntryL(aMessage, entry, local, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::ChangeEntryL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   930
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   931
	// For purpose of changing a service entry, it is considered local as an MTM
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   932
	// is not required to do the work.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   933
	if( entry.iType == KUidMsvServiceEntry )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   934
		local = ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   935
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   936
	// start the change for local or remote entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   937
	if (local)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   938
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   939
		// Extract the owner ID from the message.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   940
		TSecureId ownerId = aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   941
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   942
		DoChangeLocalEntryL(entry, operationId, aMessage, ownerId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   943
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   944
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   945
		DoChangeRemoteEntryL(entry, operationId, aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   946
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   947
	CleanupStack::PopAndDestroy(); // opData
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   948
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   949
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   950
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   951
// Changes the selection of id.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   952
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   953
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   954
void CMsvServerSession::ChangeEntriesL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   955
    {
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   956
     // Recover the operation data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   957
     TMsvOp operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   958
     HBufC8* opData = RecoverOperationData(operationId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   959
     // Check for NULL data entry to be changed, must have been given incorrect id for argument.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   960
     if(opData == NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   961
         {
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   962
         aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   963
         return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   964
         }
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   965
     CleanupStack::PushL(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   966
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   967
     // unpack the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   968
     TMsvPackedOperation packedOperation(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   969
     
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   970
     CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   971
     CleanupStack::PushL(selection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   972
     TInt target,temp;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   973
     packedOperation.UnpackL(*selection, target, temp);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   974
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   975
     if (selection->Count() == 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   976
         {
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   977
         PanicClient(aMessage, EMsvNoEntriesInChangeSelection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   978
         aMessage.Complete(KErrNotFound);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   979
         return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   980
         }
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   981
     // Find the first entry in the selection which exists
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   982
     TInt count=selection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   983
     while (count--)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   984
         {
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   985
         TBool entryExsists = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   986
         entryExsists = iMsvServer.IndexAdapter().EntryExists(selection->At(count));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   987
         if (entryExsists)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   988
             break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   989
         }
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   990
 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   991
       // Check if the entry is local or the entry is a service
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   992
      TBool local=ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   993
      TMsvEntry* entry=NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   994
      User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(selection->At(0), entry));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   995
     
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   996
      // Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   997
      iMsvServer.PoliceModifyEntryL(aMessage, *entry, local, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::ChangeEntryL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   998
             
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   999
      // For purpose of changing a service entry, it is considered local as an MTM
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1000
      // is not required to do the work.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1001
      if( entry->iType == KUidMsvServiceEntry )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1002
          local = ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1003
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1004
      // start the change for local or remote entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1005
      if (local)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1006
          {
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1007
          // Extract the owner ID from the message.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1008
          TSecureId ownerId = aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1009
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1010
          DoChangeLocalEntriesL(selection, operationId, aMessage, ownerId, target);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1011
          }
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1012
      else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1013
          DoChangeRemoteEntriesL(selection, operationId, aMessage,target);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1014
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1015
      CleanupStack::PopAndDestroy(); // opData
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1016
    }
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1017
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1018
void CMsvServerSession::DoChangeLocalEntriesL(CMsvEntrySelection*& aSelection, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId, TInt mark)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1019
    {
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1020
    CMsvLocalChangeEntriesOperation* operation = new(ELeave) CMsvLocalChangeEntriesOperation(aMessage, aOpId, aSelection, iMsvServer,mark);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1021
    CleanupStack::Pop(); // selection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1022
    CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1023
   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1024
    TBool forcedUpdate = (aOwnerId != aMessage.SecureId());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1025
    operation->StartL(aOwnerId, forcedUpdate);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1026
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1027
    iOperations.AppendL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1028
    CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1029
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1030
    
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1031
    }
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1032
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1033
void CMsvServerSession::DoChangeRemoteEntriesL(CMsvEntrySelection*& aSelection, TMsvOp aOpId, const RMessage2 &aMessage,TInt mark)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1034
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1035
// Change a selection of entry under a remote service
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1036
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1037
    {
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1038
     // make sure that the operation can be added to the list
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1039
     iOperations.SetReserveL(iOperations.Count()+1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1040
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1041
     TMsvEntry* entry=NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1042
     User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(aSelection->At(0), entry));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1043
 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1044
     // create the operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1045
     CMsvMtmOperation* operation = CMsvMtmOperation::NewL(aMessage, aOpId, entry->iMtm, entry->iServiceId, iSessionId, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1046
     CleanupStack::Pop(); // aSelection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1047
     CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1048
     operation->ChangeEntriesL(aSelection,mark);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1049
     
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1050
     iMsvServer.StartOperationL(*operation, iSessionId, aMessage, ETrue);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1051
     iOperations.AppendL(operation); // will not fail - see start of function
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1052
     CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1053
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1054
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1055
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1056
void CMsvServerSession::DoChangeLocalEntryL(const TMsvEntry& aEntry, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1057
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1058
// Create a local entry in the index
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1059
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1060
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1061
	CMsvLocalChangeOperation* operation = new(ELeave) CMsvLocalChangeOperation(aMessage, aOpId, aEntry, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1062
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1063
	// Check the given owner ID - if NULL then this is not a forced update, but
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1064
	// need to set the ID to that of the requesting process.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1065
	TBool forcedUpdate = (aOwnerId != aMessage.SecureId());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1066
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1067
	operation->StartL(aOwnerId, forcedUpdate);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1068
	iOperations.AppendL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1069
	CleanupStack::Pop(); //operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1070
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1071
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1072
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1073
void CMsvServerSession::DoChangeRemoteEntryL(const TMsvEntry& aEntry, TMsvOp aOpId, const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1074
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1075
// Change a entry under a remote service
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1076
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1077
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1078
	// make sure that the operation can be added to the list
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1079
	iOperations.SetReserveL(iOperations.Count()+1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1080
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1081
	// create the operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1082
	CMsvMtmOperation* operation = CMsvMtmOperation::NewL(aMessage, aOpId, aEntry.iMtm, aEntry.iServiceId, iSessionId, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1083
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1084
	operation->ChangeL(aEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1085
	iMsvServer.StartOperationL(*operation, iSessionId, aMessage, ETrue);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1086
	iOperations.AppendL(operation); // will not fail - see start of function
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1087
	CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1088
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1089
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1090
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1091
void CMsvServerSession::PackEntryAndWriteBufferL(const RMessage2 &aMessage, const TInt aParam, const TMsvEntry& aEntry, const TMsvId& aServiceId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1092
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1093
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1094
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1095
	// package the entry and service id in same buffer
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1096
	TMsvPackedEntry packedEntry(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1097
	TInt error = packedEntry.PackEntryAndService(aEntry, aServiceId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1098
	while(error!=KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1099
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1100
		// increase the size of the buffer and try again
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1101
		iBuffer->Des().SetLength(0); // to avoid copying contents
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1102
		iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1103
		error = packedEntry.PackEntryAndService(aEntry, aServiceId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1104
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1105
	// max destination length is passed from client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1106
	TInt maxDesLen = aMessage.Int2();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1107
    if (maxDesLen < iBuffer->Des().Length())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1108
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1109
        User::Leave(KErrOverflow);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1110
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1111
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1112
    aMessage.WriteL(aParam, iBuffer->Des());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1113
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1114
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1115
void CMsvServerSession::GetEntryL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1116
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1117
// Returns the index entry for the given id
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1118
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1119
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1120
	// copy across the entry id to get
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1121
	TMsvId id = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1122
	TMsvEntry* entryPtr;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1123
	TSecureId ownerId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1124
	TInt error = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1125
	error = iMsvServer.IndexAdapter().GetEntry(id, entryPtr, ownerId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1126
	if (error==KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1127
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1128
		// Police request - client must be able to read the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1129
		iMsvServer.PoliceReadEntryL(aMessage, ownerId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetEntryL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1130
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1131
		// get the owning service and write that back
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1132
		TMsvId service;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1133
		if (id == KMsvRootIndexEntryId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1134
			service = KMsvRootIndexEntryId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1135
		else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1136
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1137
			iMsvServer.IndexAdapter().OwningService(id, service); // error ignore as the entry exists
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1138
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1139
		// write the entry back
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1140
		PackEntryAndWriteBufferL(aMessage, 1, *entryPtr, service);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1141
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1142
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1143
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1144
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1145
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1146
void CMsvServerSession::OutstandingOperationsL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1147
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1148
	TPckgBuf<TInt> outstanding;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1149
	outstanding() = iMsvServer.OutstandingOperations() > 0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1150
	WriteL(aMessage, 0, outstanding);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1151
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1152
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1153
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1154
void CMsvServerSession::GetNotifySequenceL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1155
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1156
	TPckgBuf<TUint32> sequence;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1157
	sequence() = iChangeBuffer->NotifySequence();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1158
	WriteL(aMessage, 0, sequence);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1159
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1160
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1161
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1162
void CMsvServerSession::GetChildrenL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1163
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1164
// Gets the children of an entry
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1165
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1166
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1167
	// reset
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1168
	iChildrenSelection->Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1169
	iChildrenSelectionIds->Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1170
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1171
	// copy across the children details structure
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1172
	TPckgBuf<TMsvChildrenDetails> children;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1173
	aMessage.ReadL(0, children);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1174
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1175
	// Check that the children details arguments are empty. Panic in debug mode but try to handle it gracefully in
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1176
	// release code.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1177
	__ASSERT_DEBUG( children().iTotalNumberChildren==0 &&
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1178
					children().iNumberChildrenInArray==0, PanicServer(EMsvChildrenDetailsNotEmpty2));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1179
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1180
	if( children().iTotalNumberChildren != 0 || children().iNumberChildrenInArray != 0 )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1181
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1182
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1183
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1184
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1185
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1186
#if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1187
	// Return error, if the passed parent-id 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1188
	// is a non-current standard id.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1189
	if( (IsStandardId(children().iParentId)) &&
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1190
		(KCurrentDriveId != GetDriveId(children().iParentId))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1191
	  )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1192
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1193
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1194
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1195
		}	   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1196
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1197
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1198
	// copy across the sort order
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1199
	TPckgBuf<TMsvSelectionOrdering> order;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1200
	aMessage.ReadL(1, order);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1201
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1202
	// get the children as a selection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1203
	// Need to filter the list via the client secure ID if the client is not
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1204
	// trusted with Read User Data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1205
	TBool filterByOwnerId = !aMessage.HasCapability(ECapabilityReadUserData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1206
	iMsvServer.IndexAdapter().GetChildrenL(children().iParentId, *iChildrenSelection, order(), KUidMsvNullEntry, filterByOwnerId, aMessage.SecureId());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1207
	// return number of children
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1208
	children().iTotalNumberChildren = iChildrenSelection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1209
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1210
	// package up the entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1211
	iBuffer->Des().SetMax();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1212
	TMsvPackedEntryArray packedEntryArray(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1213
	TInt count=0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1214
	TInt error=KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1215
	TInt totalCount=iChildrenSelection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1216
	for (; count<totalCount; count++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1217
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1218
		error = packedEntryArray.PackEntry(*iChildrenSelection->At(count));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1219
		if (error)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1220
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1221
			children().iLastEntryInArray = count;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1222
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1223
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1224
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1225
	// return number of children in the array
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1226
	children().iNumberChildrenInArray = count;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1227
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1228
	// Try to write the buffer to the client (if any entries are in the array)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1229
    if (children().iNumberChildrenInArray)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1230
    	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1231
        TRAPD(bufferError, WriteL(aMessage, 2, iBuffer->Des()));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1232
        if(bufferError!=KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1233
        	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1234
        	// Writing data into client buffer is failed, we should not send incorrect count to client.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1235
			error = bufferError;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1236
        	children().iNumberChildrenInArray = 0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1237
        	children().iLastEntryInArray = 0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1238
        	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1239
        }
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1240
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1241
	// write the children to client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1242
	WriteL(aMessage, 0, children);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1243
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1244
	if (error==KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1245
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1246
		// reset the member data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1247
		iChildrenSelection->Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1248
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1249
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1250
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1251
		// keep an list of the ids separatelyin case they are deleted by another client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1252
		TInt totalCount=iChildrenSelection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1253
		for (count=0; count<totalCount; count++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1254
			iChildrenSelectionIds->AppendL(iChildrenSelection->At(count)->Id());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1255
		iChildrenDetails = children();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1256
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1257
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1258
	// signal the client and finished with selection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1259
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1260
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1261
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1262
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1263
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1264
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1265
void CMsvServerSession::GetRemainingChildrenL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1266
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1267
// Gets the remaining children of an entry when the buffer is to small
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1268
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1269
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1270
	// Check the arguments. Panic in debug mode but try to handle it gracefully in
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1271
	// release code.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1272
	__ASSERT_DEBUG(iChildrenSelection->Count()!=0, PanicServer(EMsvChildrenSelectionNull));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1273
	__ASSERT_DEBUG(iChildrenSelection->Count() == iChildrenSelectionIds->Count(), PanicServer(EMsvChildrenSelectionCountsMismatch));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1274
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1275
	if( (iChildrenSelection->Count()==0) || (iChildrenSelection->Count() != iChildrenSelectionIds->Count()) )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1276
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1277
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1278
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1279
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1280
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1281
	// copy across the children details structure
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1282
	TPckgBuf<TMsvChildrenDetails> pDetails;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1283
	aMessage.ReadL(0, pDetails);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1284
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1285
	// Check the arguments. Panic in debug mode but try to handle it gracefully in
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1286
	// release code.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1287
	__ASSERT_DEBUG( iChildrenDetails.iParentId == pDetails().iParentId &&
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1288
					iChildrenDetails.iTotalNumberChildren == pDetails().iTotalNumberChildren &&
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1289
					iChildrenDetails.iNumberChildrenInArray == pDetails().iNumberChildrenInArray, PanicServer(EMsvChildrenDetailsNotEmpty1));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1290
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1291
	if( iChildrenDetails.iParentId != pDetails().iParentId ||
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1292
		iChildrenDetails.iTotalNumberChildren != pDetails().iTotalNumberChildren ||
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1293
		iChildrenDetails.iNumberChildrenInArray != pDetails().iNumberChildrenInArray )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1294
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1295
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1296
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1297
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1298
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1299
	iChildrenDetails=pDetails();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1300
	// Make a local copy of details, this needs to be used when the client buffer is not sufficient enough to
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1301
	// pack data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1302
	TMsvChildrenDetails localCopy = pDetails();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1303
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1304
	// package up the entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1305
	iBuffer->Des().SetMax();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1306
	TMsvPackedEntryArray packedEntryArray(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1307
	TInt error=KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1308
	TInt count=iChildrenDetails.iLastEntryInArray;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1309
	iChildrenDetails.iLastEntryInArray=-1;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1310
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1311
	TInt childCount=iChildrenSelection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1312
	TInt missingCount = 0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1313
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1314
	for (; count<childCount; count++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1315
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1316
		// The iChildrenSelection contains pointers to TMsvEntry objects. If one of those
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1317
		// objects has been deleted then the pointer will no longer be valid so we need
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1318
		// to get the entry again using the ID from iChildrenSelectionIds.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1319
		TMsvEntry* entryPtr;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1320
		TInt err = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1321
		err = iMsvServer.IndexAdapter().GetEntry(iChildrenSelectionIds->At(count), entryPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1322
		if (err != KErrNotFound)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1323
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1324
#ifndef _NO_SERVER_LOGGING_
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1325
			if (entryPtr != iChildrenSelection->At(count))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1326
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1327
				iMsvServer.Log(_L("GetRemainingChildrenL() - Ptr mismatch for id %d (%x %x)"), iChildrenSelectionIds->At(count), iChildrenSelection->At(count), entryPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1328
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1329
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1330
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1331
			error = packedEntryArray.PackEntry(*entryPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1332
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1333
			if (error)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1334
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1335
				// the buffer is not large enough to pack all the entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1336
				iChildrenDetails.iLastEntryInArray = count;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1337
				if ((count - missingCount - pDetails().iLastEntryInArray) == 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1338
					{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1339
					// Couldn't fit entry in buffer
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1340
					// Increase size of buffer - client will do this as well
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1341
					iBuffer->Des().SetLength(0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1342
					iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1343
					}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1344
				break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1345
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1346
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1347
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1348
		else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1349
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1350
#ifndef _NO_SERVER_LOGGING_
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1351
			iMsvServer.Log(_L("GetRemainingChildrenL() - Ignore missing id %d"), iChildrenSelectionIds->At(count));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1352
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1353
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1354
			++missingCount;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1355
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1356
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1357
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1358
	// return number of children in the array
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1359
	iChildrenDetails.iNumberChildrenInArray = count - missingCount - pDetails().iLastEntryInArray;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1360
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1361
	// write the array to the client (if any entries are in the array)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1362
	TRAPD(err, WriteBufferL(aMessage, 2));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1363
	if(err)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1364
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1365
		if(err == KErrOverflow)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1366
		 {
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1367
		 localCopy.iNumberChildrenInArray = 0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1368
		 iChildrenDetails = localCopy;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1369
		 pDetails() = iChildrenDetails;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1370
		 WriteL(aMessage, 0, pDetails);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1371
		 User::Leave(KErrOverflow);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1372
		 }
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1373
	 else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1374
		 {
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1375
		 User::Leave(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1376
		 }   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1377
	 }   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1378
			 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1379
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1380
	// write the details to client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1381
	pDetails() = iChildrenDetails;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1382
	WriteL(aMessage, 0, pDetails);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1383
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1384
	if (error==KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1385
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1386
		// reset the member data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1387
		iChildrenDetails = TMsvChildrenDetails();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1388
		iChildrenSelection->Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1389
		iChildrenSelectionIds->Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1390
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1391
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1392
	// signal the client and finished with selection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1393
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1394
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1395
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1396
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1397
void CMsvServerSession::DeleteEntriesL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1398
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1399
// Deleting entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1400
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1401
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1402
	// Recover the operation data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1403
	TMsvOp operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1404
	HBufC8* opData = RecoverOperationData(operationId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1405
	// Check for NULL data entry to be changed, must have been given incorrect id for argument.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1406
	if(opData == NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1407
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1408
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1409
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1410
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1411
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1412
	CleanupStack::PushL(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1413
	// unpack the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1414
	TMsvPackedOperation packedOperation(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1415
	CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1416
	CleanupStack::PushL(selection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1417
	TInt temp1, temp2;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1418
	packedOperation.UnpackL(*selection, temp1, temp2);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1419
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1420
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1421
Added code to begin transaction for bulk deletion.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1422
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1423
	iMsvServer.IndexAdapter().GetDbAdapter()->BeginTransactionL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1424
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1425
	if (selection->Count())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1426
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1427
		// Check if the entries are local (inc services) or remote
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1428
		TBool local;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1429
		TMsvEntry* entry=NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1430
		User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(selection->At(0), entry));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1431
		// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1432
		iMsvServer.PoliceModifyEntryL(aMessage, *entry, local, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::DeleteEntriesL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1433
		// start the move for local or remote messages
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1434
		if (local || entry->iType==KUidMsvServiceEntry)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1435
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1436
			DoDeleteLocalEntriesL(selection, operationId, aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1437
			TMsgType aType(EDeletedMsg);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1438
			if(CMSvSearchSortCacheManager::Instance()->iManagerEntry != NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1439
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1440
				if(CMSvSearchSortCacheManager::Instance()->iManagerEntry->Count()>0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1441
					{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1442
					TInt count=selection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1443
					TInt i=0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1444
					while(i < count)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1445
						{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1446
						CMsvSearchSortDeltaCache::Instance()->EntryInDeltaCache(selection->At(i),aType);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1447
						i++;	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1448
						}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1449
					}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1450
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1451
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1452
		else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1453
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1454
			DoDeleteRemoteEntriesL(selection, operationId, aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1455
			TMsgType aType(EDeletedMsg);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1456
			if(CMSvSearchSortCacheManager::Instance()->iManagerEntry != NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1457
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1458
				if(CMSvSearchSortCacheManager::Instance()->iManagerEntry->Count()>0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1459
					{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1460
					TInt count=selection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1461
					TInt i=0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1462
					while(i < count)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1463
						{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1464
						CMsvSearchSortDeltaCache::Instance()->EntryInDeltaCache(selection->At(i),aType);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1465
						i++;	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1466
						}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1467
					}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1468
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1469
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1470
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1471
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1472
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1473
		PanicClient(aMessage, EMsvNoEntriesInDeleteSelection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1474
		aMessage.Complete(KErrNotFound);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1475
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1476
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1477
	CleanupStack::PopAndDestroy(); // opData
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1478
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1479
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1480
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1481
void CMsvServerSession::DoDeleteLocalEntriesL(CMsvEntrySelection*& aSelection, TMsvOp aOpId, const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1482
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1483
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1484
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1485
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1486
	CMsvLocalDeleteOperation* operation = new(ELeave) CMsvLocalDeleteOperation(aMessage, aOpId, aSelection, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1487
	CleanupStack::Pop(); // selection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1488
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1489
	operation->StartL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1490
	iOperations.AppendL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1491
	CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1492
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1493
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1494
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1495
void CMsvServerSession::DoDeleteRemoteEntriesL(CMsvEntrySelection*& aSelection, TMsvOp aOpId, const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1496
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1497
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1498
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1499
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1500
	// make sure that the operation can be added to the list
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1501
	iOperations.SetReserveL(iOperations.Count()+1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1502
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1503
	// find the first entry being acted on
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1504
	TMsvEntry* entry=NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1505
	User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(aSelection->At(0), entry));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1506
	// create the operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1507
	CMsvMtmOperation* operation = CMsvMtmOperation::NewL(aMessage, aOpId, entry->iMtm, entry->iServiceId, iSessionId, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1508
	CleanupStack::Pop();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1509
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1510
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1511
	// set up the operation type and pass the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1512
	operation->DeleteAll(aSelection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1513
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1514
	// either start the operation or queue it
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1515
	iMsvServer.StartOperationL(*operation, iSessionId, aMessage, ETrue);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1516
	iOperations.AppendL(operation); // will not fail - see start of function
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1517
	CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1518
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1519
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1520
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1521
void CMsvServerSession::LockEntryL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1522
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1523
// Locks an entry in the index
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1524
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1525
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1526
	TMsvId id = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1527
	aMessage.Complete(iMsvServer.IndexAdapter().LockEntry(id));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1528
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1529
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1530
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1531
void CMsvServerSession::ReleaseEntryL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1532
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1533
// Releases the lock on an entry in the index
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1534
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1535
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1536
	TMsvId id = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1537
	aMessage.Complete(iMsvServer.IndexAdapter().ReleaseEntry(id));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1538
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1539
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1540
void CMsvServerSession::ReadStoreL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1541
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1542
// Can only read from a store that has nnot been locked
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1543
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1544
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1545
	// Fail now if the index says it's not available
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1546
	User::LeaveIfError(iMsvServer.IndexAdapter().ErrorState());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1547
	TMsvId id = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1548
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1549
	// Police request - client must be able to read the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1550
	iMsvServer.PoliceReadEntryL(aMessage, id, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::ReadStoreL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1551
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1552
	TBool locked;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1553
	TInt error = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1554
	error = iMsvServer.IndexAdapter().IsStoreLocked(id, locked);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1555
	if (error==KErrNone && locked)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1556
		error = KErrAccessDenied;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1557
	if(error==KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1558
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1559
		iMsvServer.IndexAdapter().IncStoreReaderCount(id);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1560
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1561
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1562
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1563
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1564
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1565
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1566
void CMsvServerSession::LockStoreL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1567
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1568
// Tries to locks the store
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1569
// Adds the id to the list of locked entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1570
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1571
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1572
	// Fail now if the index says it's not available
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1573
	User::LeaveIfError(iMsvServer.IndexAdapter().ErrorState());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1574
	TMsvId id = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1575
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1576
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1577
	iMsvServer.PoliceModifyEntryL(aMessage, id, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::LockStoreL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1578
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1579
	iLockedStores.AppendL(id); // ensure that the entry cannot be locked but not added to the list
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1580
	TInt error = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1581
	error = iMsvServer.IndexAdapter().LockStore(id);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1582
	if (error)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1583
		iLockedStores.Delete(iLockedStores.Count()-1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1584
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1585
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1586
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1587
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1588
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1589
void CMsvServerSession::ReleaseStoreL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1590
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1591
// Releases the lock on a store
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1592
// Removes the id from the list of locked entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1593
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1594
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1595
	TMsvId id = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1596
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1597
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1598
	iMsvServer.PoliceModifyEntryL(aMessage, id, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::ReleaseStoreL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1599
	TInt error = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1600
	error = iMsvServer.IndexAdapter().ReleaseStore(id);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1601
	TInt count = iLockedStores.Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1602
	while (count--)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1603
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1604
		if (iLockedStores.At(count)==id)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1605
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1606
			iLockedStores.Delete(count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1607
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1608
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1609
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1610
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1611
	__ASSERT_DEBUG(count>=0, PanicClient(aMessage, EMsvReleasingUnknownStore));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1612
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1613
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1614
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1615
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1616
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1617
void CMsvServerSession::DecStoreReaderCountL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1618
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1619
// Decrements the reader count on a store
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1620
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1621
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1622
	TMsvId id = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1623
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1624
	// Police request - client must be able to read the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1625
	iMsvServer.PoliceReadEntryL(aMessage, id, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::DecStoreReaderCountL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1626
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1627
	TInt error = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1628
	error = iMsvServer.IndexAdapter().DecStoreReaderCount(id);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1629
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1630
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1631
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1632
void CMsvServerSession::NotifyChangedL(TMsvNotifBuffer& aChange, TBool aQueue)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1633
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1634
// This session is being informed that a change has occured
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1635
// Will only leave if a write to a client fails
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1636
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1637
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1638
	// queue the change in FIFO buffer
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1639
	iChangeBuffer->InL(aChange);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1640
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1641
#ifndef _NO_SERVER_LOGGING_
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1642
	iMsvServer.Log(_L("Queued notification sequence %d"), iChangeBuffer->NotifySequence());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1643
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1644
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1645
	// Only actually send the notification when we have a context
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1646
	if (iRequestQueued && !aQueue &&  iQueuedMessage.Handle())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1647
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1648
		// inform client of change
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1649
		SendNotificationL(iQueuedMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1650
		iRequestQueued = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1651
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1652
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1653
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1654
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1655
TBool CMsvServerSession::IsInUse(TUid aMtmTypeUid)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1656
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1657
	TBool isinuse=EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1658
	TInt index=0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1659
	TInt count=iMtmGroupRefCountArray.Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1660
	for (; (index<count) && !isinuse; index++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1661
		if (iMtmGroupRefCountArray[index].iMtmTypeUid==aMtmTypeUid)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1662
			isinuse=ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1663
	return isinuse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1664
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1665
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1666
void CMsvServerSession::CancelOperationL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1667
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1668
// Cancels an operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1669
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1670
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1671
	TMsvOp op = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1672
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1673
	TInt error=KErrNotFound;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1674
	for (TInt count=0; count<iOperations.Count(); count++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1675
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1676
		if (iOperations.At(count)->Id()==op)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1677
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1678
			error=KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1679
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1680
			iOperations.At(count)->Cancel();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1681
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1682
			if (iOperations.At(count)->State()!=EMsvOperationQueued)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1683
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1684
				TPtrC8 desPtr = iOperations.At(count)->Progress();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1685
				if (desPtr.Length() > KMsvProgressBufferLength)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1686
					{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1687
					PanicClient(aMessage, EMsvProgressBufferExceeds256);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1688
					error = KErrOverflow;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1689
					}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1690
				else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1691
					{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1692
					WriteL(aMessage, 1, desPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1693
					error = desPtr.Length();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1694
					}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1695
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1696
			else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1697
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1698
				error=KErrNotReady;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1699
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1700
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1701
			delete iOperations.At(count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1702
			iOperations.Delete(count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1703
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1704
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1705
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1706
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1707
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1708
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1709
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1710
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1711
void CMsvServerSession::OperationCompletionL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1712
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1713
// Gets the final progress of an operation and deletes all objects
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1714
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1715
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1716
	TMsvOp op = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1717
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1718
	TInt error=KErrNotFound;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1719
	for (TInt count=0; count<iOperations.Count(); count++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1720
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1721
		if (iOperations.At(count)->Id()==op)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1722
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1723
			__ASSERT_DEBUG(iOperations.At(count)->State() == EMsvOperationCompleted || iOperations.At(count)->State() == EMsvOperationFailed, PanicServer(EMsvOperationNotCompleted));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1724
			if (iOperations.At(count)->State() == EMsvOperationFailed)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1725
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1726
				// there will be no progress available
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1727
				error=KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1728
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1729
			else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1730
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1731
				TPtrC8 desPtr = iOperations.At(count)->Progress();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1732
				if (desPtr.Length() > KMsvProgressBufferLength)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1733
					{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1734
					PanicClient(aMessage, EMsvProgressBufferExceeds256);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1735
					error = KErrOverflow;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1736
					}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1737
				else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1738
					{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1739
					WriteL(aMessage, 1, desPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1740
					error = desPtr.Length();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1741
					}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1742
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1743
			delete iOperations.At(count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1744
			iOperations.Delete(count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1745
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1746
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1747
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1748
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1749
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1750
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1751
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1752
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1753
void CMsvServerSession::OperationProgressL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1754
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1755
// Gets the progress of an operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1756
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1757
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1758
	TMsvOp op = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1759
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1760
	TInt error=KErrNotFound;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1761
	for (TInt count=0; count<iOperations.Count(); count++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1762
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1763
		if (iOperations.At(count)->Id()==op)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1764
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1765
			if (iOperations.At(count)->State() == EMsvOperationQueued)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1766
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1767
				// the operation has not started
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1768
				error = KErrNotReady;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1769
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1770
			else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1771
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1772
				// get the progress from the running operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1773
				TPtrC8 desPtr = iOperations.At(count)->Progress();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1774
				if (desPtr.Length() > KMsvProgressBufferLength)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1775
					{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1776
					PanicClient(aMessage, EMsvProgressBufferExceeds256);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1777
					error = KErrOverflow;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1778
					}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1779
				else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1780
					{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1781
					WriteL(aMessage, 1, desPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1782
					error = desPtr.Length();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1783
					}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1784
				break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1785
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1786
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1787
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1788
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1789
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1790
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1791
void CMsvServerSession::OperationSystemProgressL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1792
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1793
// Get the progress of a system operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1794
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1795
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1796
	TMsvOp op = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1797
	TInt error=KErrNotFound;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1798
	for (TInt count=0; count<iOperations.Count(); count++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1799
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1800
		if (iOperations.At(count)->Id()==op)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1801
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1802
			if (iOperations.At(count)->State() == EMsvOperationQueued)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1803
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1804
				// the operation has not started
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1805
				error = KErrNotReady;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1806
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1807
			else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1808
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1809
				// get the progress from the running operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1810
				TPckgBuf<TMsvSystemProgress> systemProgress;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1811
				error = iOperations.At(count)->SystemProgress(systemProgress());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1812
				WriteL(aMessage, 1, systemProgress);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1813
				break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1814
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1815
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1816
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1817
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1818
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1819
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1820
void CMsvServerSession::OperationMtmL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1821
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1822
// Returns the MTM which will perform the operation using the two entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1823
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1824
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1825
	// read the two ids
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1826
	TMsvId id1 = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1827
	TMsvId id2 = aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1828
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1829
	// the uid to be writen back
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1830
	TPckgBuf<TUid> uid;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1831
	TPckgBuf<TMsvId> service;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1832
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1833
	// get the first entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1834
	TBool local1;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1835
	TMsvEntry* entry1=NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1836
	User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(id1, entry1));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1837
	User::LeaveIfError(iMsvServer.IndexAdapter().IsLocal(id1, local1));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1838
	if (id1==id2)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1839
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1840
		// single entry either under local or a remote service
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1841
		if (local1)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1842
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1843
			uid() = KUidMsvLocalServiceMtm;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1844
			service() = KMsvLocalServiceIndexEntryId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1845
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1846
		else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1847
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1848
			uid() = entry1->iMtm;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1849
			service() = entry1->iServiceId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1850
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1851
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1852
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1853
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1854
		// get the second entry
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1855
		TBool local2;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1856
		TMsvEntry* entry2=NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1857
		User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(id2, entry2));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1858
		User::LeaveIfError(iMsvServer.IndexAdapter().IsLocal(id2, local2));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1859
		// work out the responsible MTM
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1860
		if (local1 && local2)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1861
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1862
			// both entries under the local service
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1863
			uid() = KUidMsvLocalServiceMtm;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1864
			service() = KMsvLocalServiceIndexEntryId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1865
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1866
		else if (entry1->iMtm == entry2->iMtm)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1867
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1868
			__ASSERT_DEBUG(entry1->iMtm!=KUidMsvLocalServiceMtm, PanicServer(EMsvOperationMtm3));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1869
			// both entries use the same MTM
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1870
			uid() = entry1->iMtm;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1871
			service() = entry1->iServiceId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1872
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1873
		else if (entry1->iMtm == KUidMsvLocalServiceMtm)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1874
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1875
			__ASSERT_DEBUG(entry2->iMtm!=KUidMsvLocalServiceMtm, PanicServer(EMsvOperationMtm1));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1876
			// entry1 is a local entry - hence entry 2 must be MTM dependent
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1877
			uid() = entry2->iMtm;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1878
			service() = entry2->iServiceId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1879
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1880
		else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1881
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1882
#ifdef _DEBUG
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1883
			if (entry2->iMtm != KUidMsvLocalServiceMtm)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1884
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1885
				// Neither entry belongs to local mtm, check they have the same technology type
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1886
				__ASSERT_DEBUG(iMsvServer.Registry().TechnologyTypeUid(entry1->iMtm) == iMsvServer.Registry().TechnologyTypeUid(entry2->iMtm), PanicServer(EMsvOperationMtm2));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1887
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1888
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1889
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1890
			// entry1 is not a local entry - assume entry 2 is local
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1891
			uid() = entry1->iMtm;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1892
			service() = entry1->iServiceId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1893
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1894
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1895
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1896
	WriteL(aMessage, 2, uid);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1897
	WriteL(aMessage, 3, service);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1898
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1899
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1900
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1901
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1902
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1903
void CMsvServerSession::MoveEntriesL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1904
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1905
// Moving entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1906
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1907
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1908
	// Recover the operation data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1909
	TMsvOp operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1910
	HBufC8* opData = RecoverOperationData(operationId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1911
	// Check for NULL data entry to be changed, must have been given incorrect id for argument.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1912
	if(opData == NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1913
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1914
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1915
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1916
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1917
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1918
	CleanupStack::PushL(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1919
	// unpack the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1920
	TMsvPackedOperation packedOperation(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1921
	CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1922
	CleanupStack::PushL(selection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1923
	TInt target, temp;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1924
	packedOperation.UnpackL(*selection, target, temp);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1925
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1926
	TInt count = selection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1927
	if ( count == 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1928
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1929
		PanicClient(aMessage, EMsvNoEntriesInMoveSelection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1930
		aMessage.Complete(KErrNotFound);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1931
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1932
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1933
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1934
	// Find the first entry in the selection which exists
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1935
	TInt pos=-1;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1936
	TMsvId source = KMsvNullIndexEntryIdValue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1937
	while (++pos<count)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1938
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1939
		TMsvEntry* entryPtr;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1940
		TInt error = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1941
		error = iMsvServer.IndexAdapter().GetEntry(selection->At(pos), entryPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1942
		if( error == KErrNone )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1943
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1944
			source = entryPtr->Parent();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1945
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1946
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1947
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1948
	if (pos==count)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1949
		pos = 0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1950
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1951
	// Check if the target and source are local or remote
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1952
	TBool targetLocal=EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1953
	TBool sourceLocal=EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1954
	TBool hasCapability=EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1955
	// Police request - client must be able to move the entries.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1956
#if (defined SYMBIAN_USER_PROMPT_SERVICE)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1957
	TRAPD(err, iMsvServer.PoliceMoveEntriesL(aMessage, *selection, target, source, targetLocal, sourceLocal, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::MoveEntriesL")));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1958
	if(err == KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1959
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1960
		hasCapability = ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1961
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1962
	else if((err != KErrNone) && (targetLocal && sourceLocal))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1963
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1964
		User::LeaveIfError(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1965
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1966
#else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1967
	iMsvServer.PoliceMoveEntriesL(aMessage, *selection, target, source, targetLocal, sourceLocal, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::MoveEntriesL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1968
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1969
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1970
	// start the move for local or remote messages
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1971
	if (targetLocal && sourceLocal)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1972
		DoMoveLocalEntriesL(selection, target, operationId, aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1973
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1974
		DoMoveRemoteEntriesL(selection, target, operationId, aMessage, sourceLocal, targetLocal, hasCapability);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1975
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1976
	CleanupStack::PopAndDestroy(); // opData
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1977
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1978
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1979
void CMsvServerSession::DoMoveLocalEntriesL(CMsvEntrySelection*& aSelection, TMsvId aTarget, TMsvOp aOpId, const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1980
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1981
// NOTE aSelection is the top item on the cleanupstack when the function is called
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1982
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1983
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1984
	CMsvLocalMoveOperation* operation = new(ELeave) CMsvLocalMoveOperation(aMessage, aOpId, aSelection, aTarget, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1985
	CleanupStack::Pop(); // selection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1986
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1987
	operation->StartL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1988
	iOperations.AppendL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1989
	CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1990
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1991
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1992
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1993
void CMsvServerSession::DoMoveRemoteEntriesL(CMsvEntrySelection*& aSelection, TMsvId aTarget, TMsvOp aOpId, const RMessage2 &aMessage, TBool aSourceLocal, TBool aTargetLocal, TBool aHasCapability)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1994
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1995
// NOTE aSelection is the top item on the cleanupstack when the function is called
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1996
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1997
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1998
	// make sure that the operation can be added to the list
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  1999
	iOperations.SetReserveL(iOperations.Count()+1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2000
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2001
	TMsvEntry* entry=NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2002
	if (!aTargetLocal)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2003
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2004
		User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(aTarget, entry));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2005
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2006
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2007
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2008
		User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(aSelection->At(0), entry));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2009
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2010
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2011
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2012
	// create the operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2013
	CMsvMtmOperation* operation = CMsvMtmOperation::NewL(aMessage, aOpId, entry->iMtm, entry->iServiceId, iSessionId, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2014
	CleanupStack::Pop();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2015
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2016
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2017
	// set up the operation type and pass the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2018
	if (!(aSourceLocal || aTargetLocal))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2019
		operation->MoveWithinService(aSelection, aTarget);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2020
	else if (aSourceLocal)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2021
		operation->MoveFromLocal(aSelection, aTarget);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2022
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2023
		operation->MoveToLocal(aSelection, aTarget);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2024
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2025
	// either start the operation or queue it
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2026
	iMsvServer.StartOperationL(*operation, iSessionId, aMessage, aHasCapability);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2027
	iOperations.AppendL(operation); // will not fail - see start of function
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2028
	CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2029
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2030
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2031
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2032
void CMsvServerSession::CopyEntriesL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2033
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2034
// Moving entries
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2035
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2036
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2037
	// Recover the operation data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2038
	TMsvOp operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2039
	HBufC8* opData = RecoverOperationData(operationId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2040
	// Check for NULL data entry to be changed, must have been given incorrect id for argument.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2041
	if(opData == NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2042
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2043
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2044
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2045
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2046
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2047
	CleanupStack::PushL(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2048
	// unpack the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2049
	TMsvPackedOperation packedOperation(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2050
	CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2051
	CleanupStack::PushL(selection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2052
	TInt target,temp;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2053
	packedOperation.UnpackL(*selection, target, temp);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2054
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2055
	if (selection->Count() == 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2056
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2057
		PanicClient(aMessage, EMsvNoEntriesInCopySelection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2058
		aMessage.Complete(KErrNotFound);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2059
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2060
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2061
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2062
	// Find the first entry in the selection which exists
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2063
	TInt pos=-1;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2064
	TInt count=selection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2065
	while (++pos<count)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2066
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2067
		TBool entryExsists = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2068
		entryExsists = iMsvServer.IndexAdapter().EntryExists(selection->At(pos));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2069
		if (entryExsists)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2070
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2071
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2072
	if (pos==count)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2073
		pos = 0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2074
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2075
	// Check if the target and source are local or remote
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2076
	TBool targetLocal=EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2077
	TBool sourceLocal=EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2078
	TBool hasCapability = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2079
#if (defined SYMBIAN_USER_PROMPT_SERVICE)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2080
	// Police request - client must be able to copy the entries.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2081
	TRAPD(err, iMsvServer.PoliceCopyEntriesL(aMessage, *selection, target, targetLocal, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::CopyEntriesL")));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2082
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2083
	if(err == KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2084
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2085
		hasCapability = ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2086
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2087
#else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2088
	iMsvServer.PoliceCopyEntriesL(aMessage, *selection, target, targetLocal, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::CopyEntriesL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2089
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2090
	TInt error = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2091
	// what happens about the rest? Inconsistent behaviour
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2092
	error = iMsvServer.IndexAdapter().IsLocal(selection->At(pos), sourceLocal);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2093
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2094
#if (defined SYMBIAN_USER_PROMPT_SERVICE)   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2095
	if((err != KErrNone) && (targetLocal && sourceLocal))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2096
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2097
		User::LeaveIfError(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2098
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2099
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2100
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2101
	if (error)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2102
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2103
		CleanupStack::PopAndDestroy(2); // selection & opData
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2104
		aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2105
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2106
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2107
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2108
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2109
	// start the move for local or remote messages
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2110
	if (targetLocal && sourceLocal)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2111
		DoCopyLocalEntriesL(selection, target, operationId, aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2112
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2113
		DoCopyRemoteEntriesL(selection, target, operationId, aMessage, sourceLocal, targetLocal, hasCapability);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2114
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2115
	CleanupStack::PopAndDestroy(); // opData
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2116
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2117
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2118
void CMsvServerSession::DoCopyLocalEntriesL(CMsvEntrySelection*& aSelection, TMsvId aTarget, TMsvOp aOpId, const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2119
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2120
// NOTE aSelection is the top item on the cleanupstack when the function is called
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2121
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2122
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2123
	CMsvLocalCopyOperation* operation = new(ELeave) CMsvLocalCopyOperation(aMessage, aOpId, aSelection, aTarget, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2124
	CleanupStack::Pop(); // selection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2125
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2126
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2127
	operation->StartL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2128
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2129
	iOperations.AppendL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2130
	CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2131
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2132
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2133
void CMsvServerSession::DoCopyRemoteEntriesL(CMsvEntrySelection*& aSelection, TMsvId aTarget, TMsvOp aOpId, const RMessage2 &aMessage, TBool aSourceLocal, TBool aTargetLocal, TBool aHasCapability)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2134
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2135
// NOTE aSelection is the top item on the cleanupstack when the function is called
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2136
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2137
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2138
	// make sure that the operation can be added to the list
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2139
	iOperations.SetReserveL(iOperations.Count()+1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2140
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2141
	TMsvEntry* entry=NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2142
	if (!aTargetLocal)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2143
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2144
		User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(aTarget, entry));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2145
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2146
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2147
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2148
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2149
		User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(aSelection->At(0), entry));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2150
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2151
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2152
	// create the operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2153
	CMsvMtmOperation* operation = CMsvMtmOperation::NewL(aMessage, aOpId, entry->iMtm, entry->iServiceId, iSessionId, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2154
	CleanupStack::Pop(); // aSelection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2155
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2156
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2157
	// set up the operation type and pass the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2158
	if (!(aSourceLocal || aTargetLocal))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2159
		operation->CopyWithinService(aSelection, aTarget);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2160
	else if (aSourceLocal)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2161
		operation->CopyFromLocal(aSelection, aTarget);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2162
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2163
		operation->CopyToLocal(aSelection, aTarget);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2164
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2165
	// either start the operation or queue it
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2166
	iMsvServer.StartOperationL(*operation, iSessionId, aMessage, aHasCapability);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2167
	iOperations.AppendL(operation); // will not fail - see start of function
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2168
	CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2169
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2170
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2171
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2172
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2173
void CMsvServerSession::TransferCommandL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2174
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2175
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2176
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2177
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2178
	// Recover the operation data and parameter
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2179
	TMsvOp operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2180
	HBufC8* opData = RecoverOperationData(operationId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2181
	// Check for NULL data entry to be changed, must have been given incorrect id for argument.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2182
	if(opData == NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2183
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2184
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2185
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2186
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2187
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2188
	HBufC8* opParam = RecoverOperationData(operationId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2189
	// Check for NULL data entry to be changed, must have been given incorrect id for argument.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2190
	if(opParam == NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2191
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2192
		delete opData;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2193
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2194
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2195
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2196
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2197
	CleanupStack::PushL(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2198
	CleanupStack::PushL(opParam);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2199
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2200
	// Unpack the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2201
	TMsvPackedOperation packedOperation(opData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2202
	CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2203
	CleanupStack::PushL(selection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2204
	TInt command, temp;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2205
	packedOperation.UnpackL(*selection, command, temp);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2206
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2207
	// make sure that the operation can be added to the list
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2208
	iOperations.SetReserveL(iOperations.Count()+1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2209
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2210
	// find the first entry being acted on
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2211
	TMsvEntry* entry=NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2212
	User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(selection->At(0), entry));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2213
	TBool hasCapability = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2214
	// Police request - client must be able to access the MTM functionality.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2215
#if (defined SYMBIAN_USER_PROMPT_SERVICE)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2216
	TRAPD(err, iMsvServer.PoliceMtmTransferCommandL(aMessage, entry->iMtm, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::TransferCommandL")));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2217
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2218
	if(err == KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2219
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2220
		hasCapability = ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2221
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2222
	else if(err != KErrPermissionDenied)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2223
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2224
		User::LeaveIfError(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2225
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2226
#else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2227
	iMsvServer.PoliceMtmTransferCommandL(aMessage, entry->iMtm, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::TransferCommandL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2228
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2229
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2230
	// create the operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2231
	CMsvMtmOperation* operation = CMsvMtmOperation::NewL(aMessage, operationId, entry->iMtm, entry->iServiceId, iSessionId, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2232
	CleanupStack::Pop(); // selection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2233
	CleanupStack::Pop(); // opParam
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2234
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2235
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2236
	// set up the operation type and pass the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2237
	operation->StartCommand(selection, command, opParam);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2238
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2239
	// either start the operation or queue it
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2240
	iMsvServer.StartOperationL(*operation, iSessionId, aMessage, hasCapability);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2241
	iOperations.AppendL(operation); // will not fail - see start of function
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2242
	CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2243
	CleanupStack::PopAndDestroy(); // opParam
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2244
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2245
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2246
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2247
void CMsvServerSession::FillRegisteredMtmDllArray(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2248
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2249
	TRAPD(error,DoFillRegisteredMtmDllArrayL(aMessage));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2250
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2251
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2252
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2253
void CMsvServerSession::DoFillRegisteredMtmDllArrayL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2254
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2255
	CRegisteredMtmDllArray* registeredMtmDllArray = new(ELeave) CRegisteredMtmDllArray;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2256
	CleanupStack::PushL(registeredMtmDllArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2257
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2258
	TUid mtmdlltypeuid = {aMessage.Int0()};
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2259
	TInt error=iMsvServer.FillRegisteredMtmDllArray(mtmdlltypeuid,*registeredMtmDllArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2260
	User::LeaveIfError(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2261
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2262
	TPtr8 bufferPtr = iBuffer->Des();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2263
	bufferPtr.Zero();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2264
	RDesWriteStream writeStream(bufferPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2265
	TMsvPackedRegisteredMtmDllArray::PackRegisteredMtmDllArrayL(writeStream, *registeredMtmDllArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2266
	writeStream.CommitL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2267
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2268
	WriteBufferL(aMessage, 1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2269
	CleanupStack::PopAndDestroy(); // registeredMtmDllArray
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2270
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2271
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2272
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2273
void CMsvServerSession::MtmGroupL(const RMessage2 &aMessage, TBool aInstall)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2274
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2275
	TFullName fullname;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2276
	TInt  desLen = aMessage.GetDesLengthL(0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2277
	fullname.SetLength(desLen);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2278
	TInt error = aMessage.Read(0,fullname);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2279
	if (error)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2280
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2281
		PanicClient(aMessage, EMsvBadDescriptorRead);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2282
		User::Leave(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2283
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2284
	TUid mtmtypeuid=KNullUid;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2285
	if (aInstall)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2286
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2287
		User::LeaveIfError(iMsvServer.InstallMtmGroup(fullname,mtmtypeuid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2288
		iMsvServer.NotifyChanged(EMsvMtmGroupInstalled,mtmtypeuid);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2289
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2290
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2291
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2292
		User::LeaveIfError(iMsvServer.DeInstallMtmGroup(fullname,mtmtypeuid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2293
		iMsvServer.NotifyChanged(EMsvMtmGroupDeInstalled,mtmtypeuid);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2294
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2295
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2296
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2297
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2298
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2299
void CMsvServerSession::UseMtmGroup(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2300
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2301
	TUid mtmtypeuid = {aMessage.Int0()};
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2302
	TInt index=0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2303
	TInt count=iMtmGroupRefCountArray.Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2304
	for (; (index<count) && (mtmtypeuid!=iMtmGroupRefCountArray[index].iMtmTypeUid); index++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2305
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2306
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2307
	TInt error=KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2308
	if (index==count)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2309
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2310
		TMtmGroupRefCount mtmgrouprefcount(mtmtypeuid);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2311
		TRAP(error,iMtmGroupRefCountArray.AppendL(mtmgrouprefcount));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2312
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2313
	if (error==KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2314
		iMtmGroupRefCountArray[index].iRefCount++;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2315
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2316
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2317
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2318
void CMsvServerSession::ReleaseMtmGroup(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2319
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2320
	TUid mtmtypeuid = {aMessage.Int0()};
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2321
	TInt index=0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2322
	TInt count=iMtmGroupRefCountArray.Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2323
	for (; (index<count) && (mtmtypeuid!=iMtmGroupRefCountArray[index].iMtmTypeUid); index++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2324
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2325
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2326
	TInt error=KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2327
	if (index==count)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2328
		error=KErrNotFound;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2329
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2330
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2331
		iMtmGroupRefCountArray[index].iRefCount--;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2332
		if (iMtmGroupRefCountArray[index].iRefCount==0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2333
			iMtmGroupRefCountArray.Delete(index);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2334
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2335
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2336
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2337
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2338
void CMsvServerSession::GetMtmGroupDataL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2339
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2340
	TUid mtmtypeuid = {aMessage.Int0()};
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2341
	CMtmGroupData* mtmgroupdata=iMsvServer.GetMtmGroupDataL(mtmtypeuid);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2342
	CleanupStack::PushL(mtmgroupdata);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2343
	TPtr8 bufferPtr = iBuffer->Des();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2344
	bufferPtr.Zero();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2345
	RDesWriteStream writeStream(bufferPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2346
	writeStream << *mtmgroupdata;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2347
	writeStream.CommitL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2348
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2349
	WriteBufferL(aMessage, 1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2350
	CleanupStack::PopAndDestroy();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2351
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2352
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2353
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2354
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2355
void CMsvServerSession::GetMtmRequiredCapabilitiesL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2356
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2357
	TUid mtmTypeUid = TUid::Uid(aMessage.Int0());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2358
	TCapabilitySet mtmRequiredCaps;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2359
	iMsvServer.GetMtmRequiredCapabilitiesL(mtmTypeUid,mtmRequiredCaps);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2360
	TPtr8 ptr = iBuffer->Des();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2361
	ptr.Zero();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2362
	RDesWriteStream writeStream(ptr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2363
	MsvSecurityCapabilitySetUtils::ExternalizeL(writeStream,mtmRequiredCaps);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2364
	writeStream.CommitL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2365
	WriteBufferL(aMessage, 1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2366
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2367
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2368
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2369
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2370
void CMsvServerSession::PanicClient(const RMessage2& aMessage, TMsvClientPanic aPanic) const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2371
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2372
// Panic the client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2373
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2374
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2375
	aMessage.Panic(KMsvClientPanicString, aPanic);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2376
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2377
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2378
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2379
void CMsvServerSession::StopOperations(TMsvId aServiceId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2380
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2381
// Cancels all operations which use the service (the service is being stopped)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2382
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2383
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2384
	TInt count=iOperations.Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2385
	while (count--)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2386
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2387
		if (iOperations.At(count)->ServiceId() == aServiceId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2388
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2389
			delete iOperations.At(count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2390
			iOperations.Delete(count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2391
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2392
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2393
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2394
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2395
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2396
void CMsvServerSession::ServiceProgressL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2397
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2398
// Returns the progress from the server MTM
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2399
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2400
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2401
	TPtrC8 desPtr = iMsvServer.ServiceProgressL(aMessage.Int0());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2402
	TInt desLength = aMessage.GetDesMaxLength(1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2403
	if (desLength < desPtr.Length())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2404
		aMessage.Complete(KErrOverflow);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2405
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2406
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2407
		WriteL(aMessage, 1, desPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2408
		aMessage.Complete(desPtr.Length());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2409
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2410
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2411
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2412
void CMsvServerSession::RemoveEntry(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2413
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2414
// Removes the entry from the index. Client not interested in result.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2415
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2416
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2417
	TMsvId id = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2418
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2419
	TBool local;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2420
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2421
	TRAPD(error, iMsvServer.PoliceModifyEntryL(aMessage, id, local, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::RemoveEntry")));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2422
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2423
	if( error == KErrPermissionDenied )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2424
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2425
		// The request was denied - complete with this error code.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2426
		aMessage.Complete(KErrPermissionDenied);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2427
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2428
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2429
	else if( error == KErrNone )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2430
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2431
		if (local)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2432
			iMsvServer.RemoveEntry(id);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2433
		else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2434
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2435
			TMsvId service;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2436
			iMsvServer.IndexAdapter().OwningService(id, service); // error ignored
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2437
			if (service==id)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2438
				iMsvServer.RemoveEntry(id);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2439
			else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2440
				PanicClient(aMessage, EMsvRemovingNonLocalEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2441
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2442
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2443
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2444
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2445
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2446
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2447
void CMsvServerSession::MessageFolderL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2448
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2449
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2450
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2451
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2452
	aMessage.WriteL(0, iMsvServer.Context().MessageFolder());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2453
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2454
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2455
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2456
void CMsvServerSession::ChangeAttributesL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2457
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2458
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2459
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2460
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2461
	HBufC8* buffer = NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2462
	ReadBufferL(aMessage, 0, buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2463
	CleanupStack::PushL(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2464
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2465
	TMsvPackedOperation packedOperation(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2466
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2467
	CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2468
	CleanupStack::PushL(selection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2469
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2470
	TInt setAttributes, clearAttributes;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2471
	packedOperation.UnpackL(*selection, setAttributes, clearAttributes);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2472
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2473
	if (selection->Count() == 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2474
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2475
		PanicClient(aMessage, EMsvNoEntriesInChangeAttributesSelection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2476
		aMessage.Complete(KErrNotFound);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2477
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2478
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2479
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2480
	// get a copy of the selection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2481
	CMsvEntrySelection* changedEntries = selection->CopyL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2482
	CleanupStack::PushL(changedEntries);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2483
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2484
	// create a selection for the later notification
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2485
	CMsvEntrySelection* notify = new(ELeave)CMsvEntrySelection;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2486
	CleanupStack::PushL(notify);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2487
	notify->SetReserveL(selection->Count());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2488
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2489
	TInt error = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2490
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2491
	// lock all the selection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2492
	TInt count1 = selection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2493
	while (count1--)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2494
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2495
		error = iMsvServer.IndexAdapter().LockEntry(selection->At(count1));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2496
		if (error)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2497
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2498
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2499
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2500
	// change the attributes if all were locked
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2501
	if (error == KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2502
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2503
		error = iMsvServer.IndexAdapter().ChangeAttributes(*changedEntries, setAttributes, clearAttributes);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2504
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2505
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2506
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2507
	// release all that were locked
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2508
	TInt count2 = selection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2509
	while (--count2 > count1)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2510
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2511
		iMsvServer.IndexAdapter().ReleaseEntry(selection->At(count2));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2512
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2513
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2514
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2515
	if (error == KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2516
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2517
		// Note: Code in the following loop shouldn't leave
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2518
		while(changedEntries->Count())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2519
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2520
			TMsvId id = changedEntries->At(0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2521
			changedEntries->Delete(0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2522
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2523
			// Get the index entry associated with this entry - Shouldn't fail
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2524
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2525
			TInt err = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2526
			CMsvCacheEntry* entry = NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2527
			err = iMsvServer.IndexAdapter().GetInternalEntry(id, entry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2528
			if (err != KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2529
				continue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2530
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2531
			// Get the parent of this entry. It will be notified that its children have changed
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2532
			TMsvId parent = entry->Entry().Parent();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2533
			notify->AppendL(id);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2534
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2535
			// Find other entries that have the same parent
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2536
			TInt count = changedEntries->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2537
			while(count--)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2538
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2539
				iMsvServer.IndexAdapter().GetInternalEntry(changedEntries->At(count), entry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2540
				if (entry && entry->Entry().Parent() == parent)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2541
					{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2542
					// Add entry to list - Shouldn't fail as we've already reserved space
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2543
					notify->AppendL(changedEntries->At(count));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2544
					changedEntries->Delete(count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2545
					}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2546
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2547
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2548
			// Do the notification
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2549
			iMsvServer.NotifyChanged(EMsvEntriesChanged, *notify, parent);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2550
			notify->Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2551
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2552
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2553
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2554
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2555
	CleanupStack::PopAndDestroy(4); // notify, changedEntries, selection, buffer
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2556
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2557
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2558
void CMsvServerSession::GetChildIdsL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2559
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2560
	TMsvId id = aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2561
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2562
#if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2563
	// Return error, if the passed parent-id 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2564
	// is a non-current standard id.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2565
	if( (IsStandardId(id)) &&
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2566
		(KCurrentDriveId != GetDriveId(id))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2567
	  )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2568
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2569
		aMessage.Complete(KErrArgument);		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2570
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2571
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2572
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2573
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2574
	CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2575
	CleanupStack::PushL(selection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2576
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2577
	HBufC8* buffer = NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2578
	ReadBufferL(aMessage, 0, buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2579
	CleanupStack::PushL(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2580
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2581
	CMsvEntryFilter* filter = CMsvEntryFilter::NewLC();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2582
	TMsvPackedEntryFilter package(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2583
	package.UnpackFilter(*filter);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2584
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2585
	// Need to filter the list via the client secure ID if the client is not
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2586
	// trusted with Read User Data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2587
	TBool filterByOwnerId = !aMessage.HasCapability(ECapabilityReadUserData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2588
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2589
	iMsvServer.IndexAdapter().GetChildrenId(id, *filter, *selection, filterByOwnerId, aMessage.SecureId());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2590
	TMsvPackedOperation op(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2591
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2592
	TInt error = op.Pack(*selection, 0, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2593
	while (error != KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2594
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2595
		// increase the size of the buffer and try again
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2596
		iBuffer->Des().SetLength(0); // to avoid copying contents
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2597
		iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2598
		error = op.Pack(*selection, 0, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2599
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2600
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2601
	WriteBufferL(aMessage, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2602
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2603
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2604
	CleanupStack::PopAndDestroy(3); // selection, buffer, filter
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2605
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2606
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2607
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2608
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2609
void CMsvServerSession::ChangeDriveL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2610
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2611
// Change the drive containing the Message Store
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2612
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2613
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2614
	// Not allowed to do this if operations are outstanding
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2615
	if (iMsvServer.OutstandingOperations() > 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2616
		User::Leave(KErrServerBusy);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2617
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2618
	// make sure that the operation can be added to the list
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2619
	iOperations.SetReserveL(iOperations.Count()+1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2620
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2621
	// Start the operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2622
	CMsvChangeDriveOperation* operation = new(ELeave)CMsvChangeDriveOperation(aMessage, aMessage.Int0(), aMessage.Int1(), iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2623
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2624
	User::LeaveIfError(operation->Start());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2625
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2626
	iOperations.AppendL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2627
	CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2628
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2629
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2630
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2631
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2632
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2633
void CMsvServerSession::CopyStoreL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2634
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2635
// Copy the Message Store to another location
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2636
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2637
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2638
	// Not allowed to do this if operations are outstanding
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2639
	if (iMsvServer.OutstandingOperations() > 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2640
		User::Leave(KErrServerBusy);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2641
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2642
	// make sure that the operation can be added to the list
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2643
	iOperations.SetReserveL(iOperations.Count()+1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2644
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2645
	// Start the operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2646
	CMsvCopyStoreOperation* operation = CMsvCopyStoreOperation::NewL(aMessage, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2647
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2648
	operation->StartL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2649
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2650
	iOperations.AppendL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2651
	CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2652
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2653
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2654
void CMsvServerSession::DeleteStoreL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2655
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2656
// Delete the Message Store from the specified location
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2657
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2658
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2659
	// Not allowed to do this if operations are outstanding
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2660
	if (iMsvServer.OutstandingOperations() > 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2661
		User::Leave(KErrServerBusy);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2662
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2663
	// make sure that the operation can be added to the list
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2664
	iOperations.SetReserveL(iOperations.Count()+1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2665
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2666
	// Start the operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2667
	CMsvDeleteStoreOperation* operation = new(ELeave)CMsvDeleteStoreOperation(aMessage, iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2668
	CleanupStack::PushL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2669
	operation->StartL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2670
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2671
	iOperations.AppendL(operation);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2672
	CleanupStack::Pop(); // operation
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2673
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2674
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2675
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2676
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2677
void CMsvServerSession::SetReceiveEntryEvents(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2678
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2679
// Request/UnRequest Entry Events
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2680
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2681
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2682
	iReceiveEntryEvents=aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2683
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2684
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2685
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2686
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2687
void CMsvServerSession::CreateAttachmentForWriteL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2688
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2689
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2690
	TMsvId msgId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2691
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2692
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2693
	TBool local;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2694
	iMsvServer.PoliceModifyEntryL(aMessage, msgId, local, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::CreateAttachmentForWriteL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2695
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2696
	if( local )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2697
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2698
		// Update the owner ID of the entry. NOTE - doesn't matter if actually
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2699
		// attachment creation fails after this - safer that owner ID is updated
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2700
		// at very least.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2701
		UpdateOwnerIdL(msgId, aMessage.SecureId());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2702
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2703
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2704
	// Get the file name from slot 1
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2705
	TFileName fileName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2706
	aMessage.ReadL(1, fileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2707
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2708
	RFs fs;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2709
	ConnectAndShareFileSessionLC(fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2710
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2711
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2712
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2713
	storemanager.SetMsvServerAndFileSession(iMsvServer,fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2714
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2715
	RFile file;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2716
	TBool fileNameChanged = storemanager.CreateAttachmentForWriteL(msgId, fileName, file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2717
	CleanupClosePushL(file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2718
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2719
	// Write the sub session handle (RFile) in slot 2
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2720
	TPckg<TInt> pckgSubSessionHandle(file.SubSessionHandle());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2721
	aMessage.WriteL(2,pckgSubSessionHandle);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2722
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2723
	// Write the file changed status in slot 3
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2724
	TPckg<TBool> pckgFileNameChanged(fileNameChanged);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2725
	aMessage.WriteL(3,pckgFileNameChanged);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2726
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2727
	// Write back the file path to the client.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2728
	TInt desLen = aMessage.GetDesMaxLength(1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2729
	if( desLen < fileName.Length() )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2730
		User::Leave(KErrOverflow);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2731
	aMessage.WriteL(1, fileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2732
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2733
	// Takes care of completing with session (RFs),
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2734
	// SendReceieve returns session handle at client side
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2735
	User::LeaveIfError(file.TransferToClient(aMessage,2));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2736
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2737
	CleanupStack::PopAndDestroy(2, &fs); // fs , file
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2738
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2739
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2740
void CMsvServerSession::ReplaceAttachmentForWriteL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2741
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2742
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2743
	TMsvId msgId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2744
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2745
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2746
	iMsvServer.PoliceModifyEntryL(aMessage, msgId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::ReplaceAttachmentForWriteL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2747
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2748
	// Get the file name from slot 1
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2749
	TFileName fileName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2750
	aMessage.ReadL(1, fileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2751
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2752
	RFs fs;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2753
	ConnectAndShareFileSessionLC(fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2754
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2755
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2756
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2757
	storemanager.SetMsvServerAndFileSession(iMsvServer,fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2758
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2759
	RFile file;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2760
	storemanager.ReplaceAttachmentForWriteL(msgId, fileName, file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2761
	CleanupClosePushL(file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2762
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2763
	// Write the sub session handle (RFile) in slot 2
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2764
	TPckg<TInt> pckgSubSessionHandle(file.SubSessionHandle());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2765
	aMessage.WriteL(2,pckgSubSessionHandle);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2766
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2767
	// Write back the file path to the client.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2768
	TInt desLen = aMessage.GetDesMaxLength(1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2769
	if( desLen < fileName.Length() )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2770
		User::Leave(KErrOverflow);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2771
	aMessage.WriteL(1, fileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2772
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2773
	// Takes care of completing with session (RFs),
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2774
	// SendReceieve returns session handle at client side
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2775
	User::LeaveIfError(file.TransferToClient(aMessage,2));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2776
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2777
	CleanupStack::PopAndDestroy(2, &fs); // fs , file
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2778
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2779
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2780
void CMsvServerSession::OpenAttachmentL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2781
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2782
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2783
	TMsvId msgId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2784
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2785
	// Police request - client must be able to read the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2786
	iMsvServer.PoliceReadEntryL(aMessage, msgId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::OpenAttachmentL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2787
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2788
	// Get the file name from slot 1
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2789
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2790
	aMessage.ReadL(1, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2791
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2792
	RFs fs;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2793
	ConnectAndShareFileSessionLC(fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2794
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2795
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2796
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2797
	storemanager.SetMsvServerAndFileSession(iMsvServer,fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2798
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2799
	RFile file;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2800
	storemanager.OpenAttachmentL(msgId, filePath, file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2801
	CleanupClosePushL(file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2802
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2803
	// Write the sub session handle (RFile) in slot 2
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2804
	TPckg<TInt> pckgSubSessionHandle(file.SubSessionHandle());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2805
	aMessage.WriteL(2,pckgSubSessionHandle);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2806
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2807
	// Takes care of completing with session (RFs),
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2808
	// SendReceieve returns session handle at client side
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2809
	User::LeaveIfError(file.TransferToClient(aMessage,2));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2810
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2811
	CleanupStack::PopAndDestroy(2,&fs); // fs, file
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2812
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2813
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2814
void CMsvServerSession::OpenAttachmentForWriteL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2815
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2816
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2817
	TMsvId msgId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2818
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2819
	// Police request - client must be able to read the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2820
	iMsvServer.PoliceModifyEntryL(aMessage, msgId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::OpenAttachmentForWriteL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2821
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2822
	// Get the file name from slot 1
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2823
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2824
	aMessage.ReadL(1, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2825
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2826
	RFs fs;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2827
	ConnectAndShareFileSessionLC(fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2828
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2829
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2830
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2831
	storemanager.SetMsvServerAndFileSession(iMsvServer,fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2832
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2833
	RFile file;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2834
	storemanager.OpenAttachmentForWriteL(msgId, filePath, file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2835
	CleanupClosePushL(file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2836
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2837
	// Write the sub session handle (RFile) in slot 2
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2838
	TPckg<TInt> pckgSubSessionHandle(file.SubSessionHandle());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2839
	aMessage.WriteL(2,pckgSubSessionHandle);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2840
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2841
	// Takes care of completing with session (RFs),
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2842
	// SendReceieve returns session handle at client side
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2843
	User::LeaveIfError(file.TransferToClient(aMessage,2));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2844
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2845
	CleanupStack::PopAndDestroy(2,&fs); // fs, file
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2846
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2847
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2848
void CMsvServerSession::DeleteAttachmentL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2849
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2850
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2851
	TMsvId msgId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2852
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2853
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2854
	iMsvServer.PoliceModifyEntryL(aMessage, msgId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::DeleteAttachmentL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2855
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2856
	// Get the file name from slot 1
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2857
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2858
	aMessage.ReadL(1, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2859
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2860
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2861
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2862
	storemanager.SetMsvServerAndFileSession(iMsvServer,iMsvServer.FileSession());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2863
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2864
	TInt error = storemanager.DeleteAttachment(msgId, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2865
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2866
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2867
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2868
void CMsvServerSession::RenameAttachmentL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2869
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2870
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2871
	TMsvId msgId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2872
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2873
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2874
	iMsvServer.PoliceModifyEntryL(aMessage, msgId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::RenameAttachmentL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2875
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2876
	// Get the old file name from slot 1
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2877
	TFileName oldFileName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2878
	aMessage.ReadL(1, oldFileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2879
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2880
	// Get the new file name from slot 2
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2881
	TFileName newFileName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2882
	aMessage.ReadL(2, newFileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2883
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2884
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2885
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2886
	storemanager.SetMsvServerAndFileSession(iMsvServer,iMsvServer.FileSession());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2887
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2888
	TInt error = storemanager.RenameAttachment(msgId, oldFileName, newFileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2889
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2890
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2891
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2892
void CMsvServerSession::FileExistsL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2893
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2894
	// Get the file name from slot 10
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2895
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2896
	aMessage.ReadL(0, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2897
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2898
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2899
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2900
	storemanager.SetMsvServerAndFileSession(iMsvServer, iMsvServer.FileSession());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2901
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2902
	TInt err = KErrNotFound;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2903
	if( storemanager.FileExistsL(filePath) )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2904
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2905
		err = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2906
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2907
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2908
	aMessage.Complete(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2909
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2910
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2911
void CMsvServerSession::GetAttachmentFilePathL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2912
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2913
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2914
	TMsvId msgId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2915
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2916
	// Get the file path buffer from slot 1
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2917
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2918
	aMessage.ReadL(1, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2919
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2920
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2921
	TMsvServerStoreManager storeManager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2922
	storeManager.SetMsvServerAndFileSession(iMsvServer,iMsvServer.FileSession());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2923
	storeManager.AttachmentFilePathL(msgId, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2924
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2925
	// Write the attachment file path back to slot 1
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2926
	TInt desLen = aMessage.GetDesMaxLength(1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2927
	if( desLen < filePath.Length() )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2928
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2929
		User::Leave(KErrOverflow);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2930
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2931
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2932
	aMessage.WriteL(1, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2933
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2934
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2935
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2936
void CMsvServerSession::OpenFileStoreForReadL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2937
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2938
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2939
	TMsvId msgId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2940
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2941
	// Police request - client must be able to read the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2942
	iMsvServer.PoliceReadEntryL(aMessage, msgId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::OpenFileStoreForReadL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2943
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2944
	RFs fs;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2945
	ConnectAndShareFileSessionLC(fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2946
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2947
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2948
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2949
	storemanager.SetMsvServerAndFileSession(iMsvServer,fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2950
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2951
	RFile file;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2952
	User::LeaveIfError( storemanager.OpenFileStoreForRead(msgId,file));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2953
	CleanupClosePushL(file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2954
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2955
	// Write the sub session handle (RFile) in slot 1
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2956
	TPckg<TInt> pckgSubSessionHandle(file.SubSessionHandle());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2957
	aMessage.WriteL(1,pckgSubSessionHandle);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2958
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2959
	// Takes care of completing with session (RFs),
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2960
	// SendReceieve returns session handle at client side
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2961
	User::LeaveIfError(file.TransferToClient(aMessage,1));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2962
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2963
	CleanupStack::PopAndDestroy(2,&fs); // fs, file
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2964
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2965
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2966
void CMsvServerSession::OpenTempStoreFileL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2967
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2968
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2969
	TMsvId msgId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2970
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2971
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2972
	iMsvServer.PoliceModifyEntryL(aMessage, msgId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::OpenTempStoreFileL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2973
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2974
	RFs fs;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2975
	ConnectAndShareFileSessionLC(fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2976
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2977
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2978
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2979
	storemanager.SetMsvServerAndFileSession(iMsvServer,fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2980
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2981
	RFile file;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2982
	storemanager.OpenTempStoreFileL(msgId,file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2983
	CleanupClosePushL(file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2984
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2985
	// Write the sub session handle (RFile) in slot 1
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2986
	TPckg<TInt> pckgSubSessionHandle(file.SubSessionHandle());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2987
	aMessage.WriteL(1,pckgSubSessionHandle);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2988
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2989
	// Takes care of completing with session (RFs),
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2990
	// SendReceieve returns session handle at client side
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2991
	User::LeaveIfError(file.TransferToClient(aMessage,1));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2992
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2993
	CleanupStack::PopAndDestroy(2,&fs); // fs, file
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2994
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2995
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2996
void CMsvServerSession::ReplaceFileStoreL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2997
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2998
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  2999
	TMsvId msgId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3000
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3001
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3002
	TBool local;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3003
	iMsvServer.PoliceModifyEntryL(aMessage, msgId, local, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::ReplaceFileStoreL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3004
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3005
	if( local )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3006
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3007
		// Update the owner ID of the entry. NOTE - doesn't matter if actually
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3008
		// attachment creation fails after this - safer that owner ID is updated
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3009
		// at very least.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3010
		UpdateOwnerIdL(msgId, aMessage.SecureId());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3011
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3012
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3013
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3014
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3015
	storemanager.SetMsvServerAndFileSession(iMsvServer,iMsvServer.FileSession());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3016
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3017
	storemanager.ReplaceFileStoreL(msgId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3018
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3019
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3020
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3021
void CMsvServerSession::DeleteFileStoreL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3022
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3023
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3024
	TMsvId msgId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3025
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3026
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3027
	iMsvServer.PoliceModifyEntryL(aMessage, msgId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::DeleteFileStoreL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3028
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3029
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3030
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3031
	storemanager.SetMsvServerAndFileSession(iMsvServer,iMsvServer.FileSession());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3032
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3033
	storemanager.DeleteFileStoreL(msgId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3034
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3035
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3036
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3037
void CMsvServerSession::FileStoreExistsL(const RMessage2 &aMessage) const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3038
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3039
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3040
	TMsvId msgId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3041
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3042
	// Set the CMsvServer and file session
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3043
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3044
	storemanager.SetMsvServerAndFileSession(iMsvServer,iMsvServer.FileSession());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3045
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3046
	TInt storeExists = storemanager.FileStoreExistsL(msgId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3047
	aMessage.Complete(storeExists);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3048
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3049
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3050
void CMsvServerSession::ConnectAndShareFileSessionLC(RFs& aFs )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3051
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3052
	User::LeaveIfError(aFs.Connect());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3053
	CleanupClosePushL(aFs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3054
	User::LeaveIfError(aFs.ShareProtected());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3055
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3056
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3057
void CMsvServerSession::UpdateOwnerIdL(TMsvId aId, TSecureId aOwnerId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3058
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3059
	User::LeaveIfError(iMsvServer.IndexAdapter().LockEntry(aId));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3060
	TMsvEntry* entry;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3061
	iMsvServer.IndexAdapter().GetEntry(aId, entry); // error ignored
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3062
	User::LeaveIfError(iMsvServer.IndexAdapter().ChangeEntry(*entry, aOwnerId, ETrue));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3063
	iMsvServer.IndexAdapter().ReleaseEntry(aId);		// error ignored
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3064
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3065
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3066
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3067
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3068
Gets the path for the file in message store for which the message Id is passed in RMessage2.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3069
@param aMessage RMessage2 encapsulating client request and data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3070
@return none.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3071
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3072
void CMsvServerSession::BodyTextFilePathL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3073
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3074
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3075
	TMsvId bodyTextId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3076
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3077
	// Get the file name from slot 1
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3078
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3079
	aMessage.ReadL(1, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3080
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3081
	// Set the CMsvServer and file session 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3082
	TMsvServerStoreManager storemanager; 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3083
	storemanager.SetMsvServerAndFileSession(iMsvServer, iMsvServer.FileSession());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3084
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3085
	storemanager.BodyTextFilePathL(bodyTextId, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3086
	aMessage.WriteL(1, filePath);   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3087
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3088
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3089
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3090
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3091
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3092
Open the RFile located in filepath encapsulted in RMessage2 in Read mode.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3093
@param aMessage RMessage2 encapsulating client request and data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3094
@return none.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3095
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3096
void CMsvServerSession::OpenPlainTextFileL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3097
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3098
	TMsvId bodyTextId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3099
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3100
	TFileName filePath;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3101
	aMessage.ReadL(1, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3102
	iMsvServer.PoliceReadEntryL(aMessage, bodyTextId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::OpenPlainTextFileL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3103
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3104
	RFs fs;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3105
	ConnectAndShareFileSessionLC(fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3106
	RFile file;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3107
	CleanupClosePushL(file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3108
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3109
	// Set the CMsvServer and file session 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3110
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3111
	storemanager.SetMsvServerAndFileSession(iMsvServer, fs); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3112
	storemanager.OpenBodyTextFileForReadL(file, bodyTextId, filePath);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3113
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3114
	TPckg<TInt> pckgSubSessionHandle(file.SubSessionHandle()); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3115
	aMessage.WriteL(2,pckgSubSessionHandle);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3116
	User::LeaveIfError(file.TransferToClient(aMessage, 2));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3117
	CleanupStack::PopAndDestroy(2, &fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3118
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3119
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3120
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3121
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3122
Creates the RFile in location specified by filepath encapsulted in RMessage2.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3123
@param aMessage RMessage2 encapsulating client request and data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3124
@return none.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3125
*/  
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3126
void CMsvServerSession::CreatePlainTextFileL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3127
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3128
	TMsvId bodyTextId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3129
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3130
	iMsvServer.PoliceModifyEntryL(aMessage, bodyTextId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::CreatePlainTextFileL")); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3131
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3132
	RFs fs;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3133
	ConnectAndShareFileSessionLC(fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3134
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3135
	RFile file;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3136
	CleanupClosePushL(file);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3137
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3138
	// Set the CMsvServer and file session 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3139
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3140
	storemanager.SetMsvServerAndFileSession(iMsvServer, fs); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3141
	storemanager.CreatePlainTextFileL(file, bodyTextId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3142
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3143
	TPckg<TInt> pckgSubSessionHandle(file.SubSessionHandle()); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3144
	aMessage.WriteL(1,pckgSubSessionHandle);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3145
	User::LeaveIfError(file.TransferToClient(aMessage,1));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3146
	CleanupStack::PopAndDestroy(2, &fs);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3147
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3148
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3149
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3150
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3151
Deletes the RFile located in filepath encapsulted in RMessage2
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3152
@param aMessage RMessage2 encapsulating client request and data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3153
@return none.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3154
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3155
void CMsvServerSession::DeletePlainTextFileL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3156
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3157
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3158
	storemanager.SetMsvServerAndFileSession(iMsvServer, iMsvServer.FileSession()); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3159
	TMsvId bodyTextId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3160
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3161
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3162
	iMsvServer.PoliceModifyEntryL(aMessage, bodyTextId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::DeletePlainTextFileL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3163
	storemanager.DeletePlainTextFileL(bodyTextId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3164
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3165
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3166
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3167
Replace the RFile for the message Id encapsulted in RMessage2.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3168
@param aMessage RMessage2 encapsulating client request and data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3169
@return none.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3170
*/  
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3171
void CMsvServerSession::ReplacePlainTextFileL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3172
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3173
	// Get the Message Id from slot 0
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3174
	TMsvId bodyTextId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3175
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3176
	// Police request - client must be able to modify the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3177
	TBool local;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3178
	iMsvServer.PoliceModifyEntryL(aMessage, bodyTextId, local, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::ReplacePlainTextFileL")); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3179
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3180
	if( local )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3181
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3182
		// Update the owner ID of the entry. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3183
		UpdateOwnerIdL(bodyTextId, aMessage.SecureId());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3184
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3185
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3186
	// Set the CMsvServer and file session 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3187
	TMsvServerStoreManager storemanager;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3188
	storemanager.SetMsvServerAndFileSession(iMsvServer,iMsvServer.FileSession()); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3189
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3190
	storemanager.ReplacePlainTextFileL(bodyTextId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3191
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3192
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3193
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3194
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3195
Gets data from a server MTM that is not related to any operation being performed on
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3196
that MTM.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3197
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3198
@param aMessage Received message
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3199
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3200
void CMsvServerSession::GetNonOperationMtmDataL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3201
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3202
	TPtrC8 desPtr;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3203
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3204
	iMsvServer.GetNonOperationMtmDataL(static_cast<TMsvId>(aMessage.Int0()), static_cast<TNonOperationMtmDataType>(aMessage.Int1()), desPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3205
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3206
	TInt desLength = aMessage.GetDesMaxLength(2);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3207
	if (desLength < desPtr.Length())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3208
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3209
		aMessage.Complete(KErrOverflow);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3210
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3211
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3212
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3213
		WriteL(aMessage, 2, desPtr);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3214
		aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3215
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3216
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3217
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3218
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3219
/*****************************************
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3220
 * SearchSortOnHeaderAndBodytMsgL() :
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3221
 * Get the Query data from  client to make Search-Sort on HEADER abd BODY
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3222
 * in meassage server.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3223
 * 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3224
 * @param aMessage Received message
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3225
 ****************************************/ 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3226
void CMsvServerSession::SearchSortOnHeaderAndBodytMsgL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3227
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3228
	//For Simultaneously query
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3229
	if(CMSvSearchSortCacheManager::Instance()->OutstandingSOSOperations() > 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3230
       		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3231
			if(CMSvSearchSortCacheManager::Instance()->iProgress != KMsvSearchSortOpCompleted)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3232
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3233
				User::Leave(KErrServerBusy); // One is SOS request is under proress.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3234
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3235
       		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3236
	CMSvSearchSortCacheManager::Instance()->AddOutstandingSOSOperation();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3237
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3238
	//Header and body.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3239
	TMsvOp operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3240
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3241
	HBufC8* buffer = NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3242
	ReadBufferL(aMessage, 1, buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3243
	CleanupStack::PushL(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3244
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3245
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::SearchSortOnHeaderAndBodytMsgL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3246
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3247
	CMsvSearchSortQuery* query= CMsvSearchSortQuery::NewL() ;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3248
	CleanupStack::PushL(query);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3249
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3250
	TMsvPackQuery packedQuery(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3251
	packedQuery.UnpackQuery(query);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3252
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3253
	TBool markQuery = aMessage.Int2();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3254
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3255
	CMsvSearchSortCacheEntry *aEntry = CMsvSearchSortCacheEntry::CreateQueryEntryL(query, markQuery);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3256
	CleanupStack::PushL(aEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3257
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3258
	TInt indexCount =CMSvSearchSortCacheManager::Instance()->QueryExists(*aEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3259
	//Check the query is exist or not.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3260
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3261
	if(CMSvSearchSortCacheManager::Instance()->QueryExists(*aEntry)<0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3262
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3263
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3264
		//NEW Query
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3265
		if(!aEntry->IsSortQuery())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3266
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3267
			CMSvSearchSortCacheManager::Instance()->TypeOfSearchQuery(*aEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3268
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3269
		else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3270
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3271
			CMSvSearchSortCacheManager::Instance()->TypeOfSortQuery(*aEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3272
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3273
		//Do process query.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3274
		CMSvSearchSortCacheManager::Instance()->DoProcessQueryL(*aEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3275
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3276
	else 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3277
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3278
		//Existing Query
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3279
		CMSvSearchSortCacheManager::Instance()->DoProcessQueryL(indexCount);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3280
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3281
	CleanupStack::Pop();//  aEntry
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3282
	CleanupStack::PopAndDestroy(2); //  query, buffer
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3283
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3284
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3285
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3286
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3287
/*****************************************
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3288
 * SearchSortOnIndexEntry() :
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3289
 * Get the Query data from  client to make Search-Sort on INDEX ENTRY
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3290
 * in meassage server.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3291
 * 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3292
 * @param aMessage Received message
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3293
 ****************************************/ 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3294
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3295
void CMsvServerSession::SearchSortOnIndexEntryL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3296
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3297
  	//For Simultaneously query
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3298
   	if(CMSvSearchSortCacheManager::Instance()->OutstandingSOSOperations() > 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3299
       	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3300
       	if(CMSvSearchSortCacheManager::Instance()->iProgress != KMsvSearchSortOpCompleted)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3301
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3302
            User::Leave(KErrServerBusy); // One is SOS request is under proress.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3303
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3304
       	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3305
 	CMSvSearchSortCacheManager::Instance()->AddOutstandingSOSOperation();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3306
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3307
	//Search sort on index entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3308
	// Recover the operation data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3309
	TMsvOp operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3310
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3311
	HBufC8* buffer = NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3312
	ReadBufferL(aMessage, 1, buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3313
	CleanupStack::PushL(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3314
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3315
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::SearchSortOnIndexEntryL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3316
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3317
	CMsvSearchSortQuery* query= CMsvSearchSortQuery::NewL() ;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3318
	CleanupStack::PushL(query);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3319
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3320
	TMsvPackQuery packedQuery(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3321
	packedQuery.UnpackQuery(query);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3322
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3323
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3324
	TBool markQuery = aMessage.Int2();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3325
	TInt  iteratorCount = aMessage.Int3();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3326
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3327
	CMsvSearchSortCacheEntry *aEntry = CMsvSearchSortCacheEntry::CreateQueryEntryL(query, markQuery,iteratorCount);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3328
	CleanupStack::PushL(aEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3329
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3330
	TInt indexCount =CMSvSearchSortCacheManager::Instance()->QueryExists(*aEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3331
	//Query Exist or not
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3332
	if(CMSvSearchSortCacheManager::Instance()->QueryExists(*aEntry)<0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3333
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3334
		//NEW Query
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3335
		if(!aEntry->IsSortQuery())
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3336
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3337
			CMSvSearchSortCacheManager::Instance()->TypeOfSearchQuery(*aEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3338
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3339
		else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3340
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3341
			CMSvSearchSortCacheManager::Instance()->TypeOfSortQuery(*aEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3342
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3343
		//Do process query.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3344
		CMSvSearchSortCacheManager::Instance()->DoProcessQueryL(*aEntry,iteratorCount);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3345
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3346
	else 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3347
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3348
		//Existing Query
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3349
		CMSvSearchSortCacheManager::Instance()->DoProcessQueryL(indexCount);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3350
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3351
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3352
	CleanupStack::Pop();		// aEntry
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3353
	CleanupStack::PopAndDestroy(2, buffer); // buffer, CmsvSearchSortQuery
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3354
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3355
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3356
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3357
void CMsvServerSession::SendSearchSortIndexEntryResultL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3358
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3359
	TBool resultType = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3360
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3361
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::SendSearchSortIndexEntryResultL"));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3362
	//id's
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3363
	if(resultType) // EResultAsTMsvID
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3364
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3365
		TMsvPackedIdOperation op(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3366
		TInt error = op.Pack(CMSvSearchSortCacheManager::Instance()->iFinalResultAsIdArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3367
		while (error != KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3368
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3369
			// increase the size of the buffer and try again
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3370
			iBuffer->Des().SetLength(0); // to avoid copying contents
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3371
			iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3372
			error = op.Pack(CMSvSearchSortCacheManager::Instance()->iFinalResultAsIdArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3373
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3374
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3375
	else  // EResultAsTMsvEntry
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3376
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3377
		//As of now it takes TMsvId.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3378
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3379
	WriteBufferL(aMessage, 1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3380
	CMSvSearchSortCacheManager::Instance()->iFinalResultAsIdArray.Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3381
	CMSvSearchSortCacheManager::Instance()->iToFindResultAsIdArray.Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3382
	CMSvSearchSortCacheManager::Instance()->iMsvIdWithSortFieldArray.Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3383
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3384
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3385
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3386
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3387
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3388
//sending resultas
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3389
void CMsvServerSession::SendResultOrIdsToSearchL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3390
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3391
	// result type (is it a Final result, Partial Result or New query)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3392
	TPckgBuf<TInt> resultType;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3393
	TInt errorMem = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3394
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::SendResultOrIdsToSearchL"));   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3395
	//resuttype
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3396
	resultType = CMSvSearchSortCacheManager::Instance()->iReturnResultType;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3397
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3398
	if(CMSvSearchSortCacheManager::Instance()->iReturnResultType == KMsvSearchSortQueryIdNotFound)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3399
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3400
		WriteL(aMessage, 1, resultType);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3401
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3402
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3403
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3404
		// need to send data to client according resultType 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3405
		// result type is KFinalResult, KNewQuery or KPartilaResult
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3406
		TInt error = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3407
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3408
		TMsvPackedIdOperation op(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3409
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3410
#if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3411
		error = op.Pack(CMSvSearchSortCacheManager::Instance()->iFinalResultAsIdArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3412
		while (error != KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3413
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3414
			// increase the size of the buffer and try again
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3415
			iBuffer->Des().SetLength(0); // to avoid copying contents
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3416
			iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3417
			error = op.Pack(CMSvSearchSortCacheManager::Instance()->iFinalResultAsIdArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3418
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3419
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3420
#else   // else SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3421
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3422
		if(CMSvSearchSortCacheManager::Instance()->iReturnResultType == KFinalResult)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3423
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3424
			CMSvSearchSortCacheManager::Instance()->iSearchSortDeltaCache->iIsHeaderSearchEnabled = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3425
			error = op.Pack(CMSvSearchSortCacheManager::Instance()->iFinalResultAsIdArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3426
			
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3427
			while (error != KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3428
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3429
				// increase the size of the buffer and try again
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3430
				iBuffer->Des().SetLength(0); // to avoid copying contents
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3431
				iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3432
				error = op.Pack(CMSvSearchSortCacheManager::Instance()->iFinalResultAsIdArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3433
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3434
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3435
		else if(CMSvSearchSortCacheManager::Instance()->iReturnResultType == KNewQuery)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3436
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3437
			error = op.Pack(CMSvSearchSortCacheManager::Instance()->iToFindResultAsIdArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3438
			while (error != KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3439
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3440
				// increase the size of the buffer and try again
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3441
				iBuffer->Des().SetLength(0); // to avoid copying contents
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3442
				iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3443
				error = op.Pack(CMSvSearchSortCacheManager::Instance()->iToFindResultAsIdArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3444
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3445
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3446
		else // for KPartialResult
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3447
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3448
			error = op.Pack(CMSvSearchSortCacheManager::Instance()->iDeltaCacheIdArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3449
			while (error != KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3450
				{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3451
				// increase the size of the buffer and try again
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3452
				iBuffer->Des().SetLength(0); // to avoid copying contents
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3453
				iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3454
				error = op.Pack(CMSvSearchSortCacheManager::Instance()->iDeltaCacheIdArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3455
				}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3456
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3457
#endif // SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3458
			
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3459
		// send Id's in buffer
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3460
		TRAP(errorMem,WriteBufferL(aMessage,0));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3461
			
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3462
		//send resultType to client, whether it's final result, partial result or newQuery.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3463
		WriteL(aMessage,1,resultType);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3464
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3465
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3466
	//needs to reset RArray
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3467
	if(errorMem==KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3468
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3469
		CMSvSearchSortCacheManager::Instance()->iFinalResultAsIdArray.Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3470
		CMSvSearchSortCacheManager::Instance()->iToFindResultAsIdArray.Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3471
		CMSvSearchSortCacheManager::Instance()->iMsvIdWithSortFieldArray.Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3472
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3473
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3474
	aMessage.Complete(errorMem);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3475
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3476
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3477
void CMsvServerSession::GetSearchSortResultCountL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3478
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3479
	TPckgBuf<TInt> resultCount;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3480
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3481
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetSearchSortResultCountL"));  
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3482
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3483
	TInt  index = CMSvSearchSortCacheManager::Instance()->iManagerEntry->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3484
	CMSvSearchSortCacheManager::Instance()->ResultCountL(index-1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3485
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3486
	resultCount() = CMSvSearchSortCacheManager::Instance()->iFinalResultCount;//Contain the result.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3487
	WriteL(aMessage, 0, resultCount);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3488
	CMSvSearchSortCacheManager::Instance()->iFinalResultCount = 0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3489
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3490
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3491
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3492
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3493
void CMsvServerSession::GetResultInIteratorL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3494
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3495
	TPckgBuf<TMsvId> messageId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3496
	TPckgBuf<TInt> count;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3497
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3498
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetResultInIteratorL"));   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3499
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3500
	TInt  index = CMSvSearchSortCacheManager::Instance()->iManagerEntry->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3501
	CMSvSearchSortCacheManager::Instance()->NextResultForInteraratorL(index-1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3502
	messageId() = CMSvSearchSortCacheManager::Instance()->iIteratorId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3503
	count() = CMSvSearchSortCacheManager::Instance()->iIteratorRemainingResultCount;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3504
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3505
	//result as TMsvId
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3506
	WriteL(aMessage, 0, messageId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3507
	//for remaing count
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3508
	WriteL(aMessage, 1, count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3509
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3510
	CMSvSearchSortCacheManager::Instance()->iIteratorId = 0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3511
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3512
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3513
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3514
void CMsvServerSession::GetNextEntryInIteratorL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3515
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3516
	//need this varible to send remaining count to client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3517
	TPckgBuf<TInt> count;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3518
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3519
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetNextEntryInIteratorL"));	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3520
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3521
	TInt  index = CMSvSearchSortCacheManager::Instance()->iManagerEntry->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3522
	CMSvSearchSortCacheManager::Instance()->NextResultForInteraratorL(index-1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3523
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3524
	// package the entry
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3525
	TMsvPackedEntry packedEntry(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3526
	TInt error = packedEntry.PackEntry(CMSvSearchSortCacheManager::Instance()->iIteratorEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3527
	while(error!=KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3528
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3529
		// increase the size of the buffer and try again
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3530
		iBuffer->Des().SetLength(0); // to avoid copying contents
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3531
		iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3532
		error = packedEntry.PackEntry(CMSvSearchSortCacheManager::Instance()->iIteratorEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3533
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3534
	//needs fill the remaing count
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3535
	count() =  CMSvSearchSortCacheManager::Instance()->iIteratorRemainingResultCount;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3536
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3537
	//result as TMsvEntry
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3538
	WriteBufferL(aMessage, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3539
	//for remaing count
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3540
	WriteL(aMessage, 1, count);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3541
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3542
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3543
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3544
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3545
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3546
void CMsvServerSession::GetQueryIDL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3547
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3548
	TPckgBuf<TInt> queryId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3549
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3550
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetQueryIDL"));	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3551
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3552
	queryId() = CMSvSearchSortCacheManager::Instance()->QueryID();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3553
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3554
	WriteL(aMessage, 0, queryId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3555
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3556
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3557
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3558
void CMsvServerSession::UpdateSearchSortCacheWithSortFiledL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3559
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3560
	TInt  index = CMSvSearchSortCacheManager::Instance()->iManagerEntry->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3561
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3562
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::UpdateSearchSortCacheWithSortFiledL"));	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3563
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3564
	// get the length
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3565
	TInt desLen = aMessage.GetDesLength(1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3566
	if(desLen == 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3567
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3568
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3569
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3570
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3571
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3572
	// allocate buffer copy the data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3573
	CBufFlat* buffer = CBufFlat::NewL(desLen);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3574
	CleanupStack::PushL(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3575
	buffer->ExpandL(0, desLen);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3576
	RBufReadStream readStream(*buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3577
	CleanupClosePushL (readStream);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3578
	TPtr8 desPtr = buffer->Ptr(0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3579
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3580
	TRAPD(err,  aMessage.ReadL(1, desPtr));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3581
	User::LeaveIfError(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3582
	// object of TMsvPackedIdAndMessagePart 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3583
	TMsvPackedIdAndMessagePart packIdAndMessagePart;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3584
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3585
	//extract TMsvId with Sort field
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3586
	packIdAndMessagePart.InternalizeL(readStream, CMSvSearchSortCacheManager::Instance()->iMsvIdWithSortFieldArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3587
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3588
	//Manager class update the Db.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3589
	CMSvSearchSortCacheManager::Instance()->StoreSortResultL(index,CMSvSearchSortCacheManager::Instance()->iMsvIdWithSortFieldArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3590
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3591
	CleanupStack::PopAndDestroy(2, buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3592
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3593
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3594
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3595
void CMsvServerSession::QueryUnMarkedL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3596
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3597
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3598
	TInt  queryID = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3599
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3600
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::PoliceSearchSortQueryReadRequestL"));  
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3601
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3602
	TInt index =  CMSvSearchSortCacheManager::Instance()->QueryExists(queryID);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3603
	if(index>0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3604
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3605
		CMSvSearchSortCacheManager::Instance()->UnMarkedQuery(index);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3606
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3607
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3608
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3609
		aMessage.Complete(KErrNotFound);	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3610
		}   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3611
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3612
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3613
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3614
void CMsvServerSession::GetResultForQueryIDL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3615
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3616
    //For Simultaneously query
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3617
    if(CMSvSearchSortCacheManager::Instance()->OutstandingSOSOperations() > 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3618
        {
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3619
		if(CMSvSearchSortCacheManager::Instance()->iProgress != KMsvSearchSortOpCompleted )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3620
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3621
			User::Leave(KErrServerBusy); // One is SOS request is under proress.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3622
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3623
         }
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3624
    CMSvSearchSortCacheManager::Instance()->AddOutstandingSOSOperation();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3625
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3626
	TInt operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3627
	TInt queryID = aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3628
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3629
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetResultForQueryIDL"));   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3630
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3631
	TInt index =  CMSvSearchSortCacheManager::Instance()->QueryExists(queryID);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3632
	if(index>=0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3633
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3634
		CMSvSearchSortCacheManager::Instance()->DoProcessQueryL(index);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3635
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3636
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3637
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3638
		//Invalid query id.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3639
		CMSvSearchSortCacheManager::Instance()->iReturnResultType = KMsvSearchSortQueryIdNotFound;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3640
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3641
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3642
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3643
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3644
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3645
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3646
void CMsvServerSession::GetSearchSortProgressInfoL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3647
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3648
	TInt operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3649
	TPckg<TInt> progress(KMsvSearchSortOpNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3650
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3651
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetSearchSortProgressInfoL")); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3652
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3653
	progress() = CMSvSearchSortCacheManager::Instance()->ReturnProgressInfo();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3654
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3655
	WriteL(aMessage, 1, progress);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3656
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3657
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3658
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3659
void CMsvServerSession::SearchSortOperationCancelL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3660
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3661
	TInt operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3662
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3663
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::SearchSortOperationCancel"));  
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3664
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3665
	CMSvSearchSortCacheManager::Instance()->CancelSearchSortOperation();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3666
	//cancel the current oeration and delete the query and correspnding entry from DB.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3667
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3668
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3669
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3670
//Update search sort results to DB, and sort by TMsvEntry fields invalid id's
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3671
void CMsvServerSession::UpdateSearchSortResultsAndSortByEntryL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3672
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3673
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3674
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::UpdateSearchSortResultsAndSortByEntryL")); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3675
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3676
	TInt  index = CMSvSearchSortCacheManager::Instance()->iManagerEntry->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3677
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3678
	HBufC8* buffer = NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3679
	ReadBufferL(aMessage, 1, buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3680
	CleanupStack::PushL(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3681
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3682
	// Unpack the entries from the buffer
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3683
	TMsvPackedIdOperation packedIdOperation(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3684
	packedIdOperation.UnpackL(CMSvSearchSortCacheManager::Instance()->iUpdateIdsToCacheArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3685
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3686
	// Update DB and sort by TMsvEnty field with existing partil query
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3687
	// Invalid ID need to delete.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3688
	CMSvSearchSortCacheManager::Instance()->StoreResultL(index,CMSvSearchSortCacheManager::Instance()->iUpdateIdsToCacheArray);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3689
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3690
	CleanupStack::PopAndDestroy(buffer); // buffer
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3691
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3692
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3693
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3694
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3695
void CMsvServerSession::CopyQueryDataL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3696
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3697
	TInt operationId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3698
	TInt queryId = aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3699
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3700
	iMsvServer.PoliceSearchSortQueryReadRequestL(aMessage,__PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::CopyQueryDataL")); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3701
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3702
	CMsvSearchSortQuery* searchSortQuery= CMsvSearchSortQuery::NewL() ;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3703
	CleanupStack::PushL(searchSortQuery);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3704
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3705
	TInt index =  CMSvSearchSortCacheManager::Instance()->QueryExists(queryId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3706
	if(index>=0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3707
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3708
		//This below function will return  TMsvSearchSortQuery object .
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3709
		CMSvSearchSortCacheManager::Instance()->RetrunQuery(index, searchSortQuery);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3710
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3711
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3712
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3713
		//Query id not found.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3714
		CleanupStack::PopAndDestroy(searchSortQuery); // searchSortQuery
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3715
		aMessage.Complete(KErrNotFound);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3716
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3717
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3718
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3719
	TMsvPackQuery packedQuery(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3720
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3721
	TInt error = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3722
	error = packedQuery.PackQuery(searchSortQuery);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3723
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3724
	WriteBufferL(aMessage, 2);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3725
	CleanupStack::PopAndDestroy(searchSortQuery); // searchSortQuery
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3726
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3727
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3728
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3729
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3730
#if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3731
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3732
 * GetChildrenAllL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3733
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3734
 * @param RMessage2.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3735
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3736
 * Code changes for PREQ 557.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3737
 * Service request EMsvGetChildrenALL.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3738
 * If the parent id is a standard folder the function fetches
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3739
 * the child entries from all drives in the preferred drive list
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3740
 * as maintained by server.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3741
 */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3742
 void CMsvServerSession::GetChildrenAllL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3743
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3744
	// Reset internal datastructure.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3745
	iChildrenSelection->Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3746
	iChildrenSelectionIds->Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3747
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3748
	// Copy across the children details structure.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3749
	TPckgBuf<TMsvChildrenDetails> children;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3750
	aMessage.ReadL(0, children);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3751
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3752
	// Check that the children details arguments are empty. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3753
	// Panic in debug mode but try to handle it gracefully 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3754
	// in release code.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3755
	__ASSERT_DEBUG( children().iTotalNumberChildren==0 &&
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3756
					children().iNumberChildrenInArray==0, PanicServer(EMsvChildrenDetailsNotEmpty2));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3757
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3758
	if( children().iTotalNumberChildren != 0 || children().iNumberChildrenInArray != 0 )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3759
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3760
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3761
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3762
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3763
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3764
	// The function is allowed only for following standard 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3765
	// folders of current drive:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3766
	// Inbox, Outbox, Draft, Sent and Deleted.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3767
	if( (KCurrentDriveId != GetDriveId(children().iParentId)) ||
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3768
		( KMsvLocalServiceIndexEntryId >= UnmaskTMsvId(children().iParentId) ||
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3769
		  KMsvUnknownServiceIndexEntryId <= UnmaskTMsvId(children().iParentId) )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3770
	  )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3771
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3772
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3773
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3774
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3775
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3776
	// Copy across the sort order.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3777
	TPckgBuf<TMsvSelectionOrdering> order;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3778
	aMessage.ReadL(1, order);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3779
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3780
	// Get the children as a selection. Need to 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3781
	// filter the list via the client secure ID 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3782
	// if the client is not trusted with Read User Data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3783
	TBool filterByOwnerId = !aMessage.HasCapability(ECapabilityReadUserData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3784
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3785
	iMsvServer.IndexAdapter().GetChildrenAllL(children().iParentId, *iChildrenSelection, order(), KUidMsvNullEntry, filterByOwnerId, aMessage.SecureId());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3786
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3787
	// Return number of children.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3788
	children().iTotalNumberChildren = iChildrenSelection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3789
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3790
	// Package up the entries.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3791
	iBuffer->Des().SetMax();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3792
	TMsvPackedEntryArray packedEntryArray(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3793
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3794
	TInt count=0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3795
	TInt error=KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3796
	TInt totalCount=iChildrenSelection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3797
	for (; count<totalCount; count++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3798
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3799
		error = packedEntryArray.PackEntry(*iChildrenSelection->At(count));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3800
		if (error)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3801
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3802
			children().iLastEntryInArray = count;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3803
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3804
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3805
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3806
	// return number of children in the array
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3807
	children().iNumberChildrenInArray = count;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3808
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3809
	// write the children to client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3810
	WriteL(aMessage, 0, children);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3811
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3812
	// write the array to the client (if any entries are in the array)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3813
	if (children().iNumberChildrenInArray)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3814
		WriteL(aMessage, 2, iBuffer->Des());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3815
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3816
	if (error==KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3817
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3818
		// reset the member data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3819
		iChildrenSelection->Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3820
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3821
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3822
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3823
		// keep an list of the ids separatelyin case they are deleted by another client
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3824
		TInt totalCount=iChildrenSelection->Count();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3825
		for (count=0; count<totalCount; count++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3826
			iChildrenSelectionIds->AppendL(iChildrenSelection->At(count)->Id());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3827
		iChildrenDetails = children();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3828
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3829
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3830
	// signal the client and finished with selection
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3831
	aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3832
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3833
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3834
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3835
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3836
/** 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3837
 * GetChildIdsAll()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3838
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3839
 * Gets the children of a parent entry specified as first argument.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3840
 * If the passed parent is a standard folder the function will fetch 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3841
 * entries from all drives currently present in the preferred drive list.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3842
 */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3843
void CMsvServerSession::GetChildIdsAllL(const RMessage2& aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3844
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3845
	TMsvId id = aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3846
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3847
	// The function is allowed only for following standard 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3848
	// folders of current drive:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3849
	// Inbox, Outbox, Draft, Sent and Deleted.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3850
	if( (KCurrentDriveId != GetDriveId(id)) ||
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3851
		(KMsvLocalServiceIndexEntryId >= UnmaskTMsvId(id)) ||
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3852
		(KMsvUnknownServiceIndexEntryId <= UnmaskTMsvId(id))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3853
	  )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3854
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3855
		aMessage.Complete(KErrArgument);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3856
		return;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3857
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3858
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3859
	CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3860
	CleanupStack::PushL(selection);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3861
	HBufC8* buffer = NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3862
	ReadBufferL(aMessage, 0, buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3863
	CleanupStack::PushL(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3864
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3865
	CMsvEntryFilter* filter = CMsvEntryFilter::NewLC();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3866
	TMsvPackedEntryFilter package(buffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3867
	package.UnpackFilter(*filter);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3868
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3869
	// Need to filter the list via the client secure ID if the client is not
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3870
	// trusted with Read User Data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3871
	TBool filterByOwnerId = !aMessage.HasCapability(ECapabilityReadUserData);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3872
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3873
	TInt error = iMsvServer.IndexAdapter().GetChildrenIdAll(id, *filter, *selection, filterByOwnerId, aMessage.SecureId());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3874
	if(KErrNone != error)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3875
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3876
		aMessage.Complete(error);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3877
		CleanupStack::PopAndDestroy(3); // selection, buffer, filter
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3878
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3879
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3880
	TMsvPackedOperation op(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3881
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3882
	error = op.Pack(*selection, 0, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3883
	while (error != KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3884
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3885
		// increase the size of the buffer and try again
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3886
		iBuffer->Des().SetLength(0); // to avoid copying contents
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3887
		iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3888
		error = op.Pack(*selection, 0, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3889
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3890
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3891
	WriteBufferL(aMessage, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3892
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3893
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3894
	CleanupStack::PopAndDestroy(3); // selection, buffer, filter
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3895
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3896
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3897
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3898
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3899
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3900
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3901
 * MessageDrive()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3902
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3903
 * @param RMessage2.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3904
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3905
 * Code changes for PREQ 557.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3906
 * Service request EMsvGetMessageDrive.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3907
 */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3908
void CMsvServerSession::MessageDrive(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3909
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3910
	aMessage.Complete(CMsvPreferredDriveList::GetDriveList()->CurrentDriveNumber());		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3911
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3912
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3913
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3914
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3915
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3916
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3917
 * CurrentDriveInfoL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3918
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3919
 * @param RMessage2.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3920
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3921
 * Code changes for PREQ 557.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3922
 * Service request EMsvGetCurrentDriveInfo.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3923
 */	 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3924
void CMsvServerSession::CurrentDriveInfoL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3925
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3926
	TMsvPreferredDrive driveInfo;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3927
	TUint currentDriveIndex = CMsvPreferredDriveList::GetDriveList()->CurrentDriveIndex();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3928
	TRAPD(err, CMsvPreferredDriveList::GetDriveList()->DriveInfoL(currentDriveIndex, driveInfo));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3929
	if(KErrNone == err)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3930
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3931
		TPckgBuf<TDriveNumber> driveNum;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3932
		TPckgBuf<TUint> priority;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3933
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3934
		driveNum() = driveInfo.driveNum;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3935
		priority() = currentDriveIndex + 1;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3936
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3937
		WriteL(aMessage, 0, driveNum);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3938
		WriteL(aMessage, 1, priority);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3939
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3940
	aMessage.Complete(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3941
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3942
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3943
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3944
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3945
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3946
 * DriveListL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3947
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3948
 * @param RMessage2.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3949
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3950
 * Code changes for PREQ 557.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3951
 * Service request EMsvGetDriveList.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3952
 */	 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3953
void CMsvServerSession::DriveListL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3954
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3955
	CMsvPreferredDriveList *driveList = CMsvPreferredDriveList::GetDriveList();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3956
	RArray<TDriveNumber> driveNumList;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3957
	CleanupClosePushL(driveNumList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3958
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3959
	for(TInt index=0; index<driveList->Count(); index++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3960
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3961
		driveNumList.AppendL((*driveList)[index].driveNum);	 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3962
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3963
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3964
	TMsvPackedDriveIdOperation driveOp(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3965
	User::LeaveIfError(driveOp.Pack(driveNumList));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3966
	WriteBufferL(aMessage, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3967
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3968
	CleanupStack::PopAndDestroy();	  // driveNumList
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3969
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3970
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3971
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3972
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3973
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3974
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3975
 * AvailableDriveListL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3976
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3977
 * @param RMessage2.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3978
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3979
 * Code changes for PREQ 557.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3980
 * Service request EMsvGetAvailableDriveList.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3981
 */ 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3982
void CMsvServerSession::AvailableDriveListL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3983
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3984
	CMsvPreferredDriveList *driveList = CMsvPreferredDriveList::GetDriveList();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3985
	RArray<TDriveNumber> driveNumList;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3986
	CleanupClosePushL(driveNumList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3987
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3988
	for(TInt index=0; index<driveList->Count(); index++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3989
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3990
		if(EMsvMessageStoreAvailableStatus == (*driveList)[index].status)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3991
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3992
			driveNumList.AppendL((*driveList)[index].driveNum);	 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3993
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3994
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3995
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3996
	TMsvPackedDriveIdOperation driveOp(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3997
	User::LeaveIfError(driveOp.Pack(driveNumList));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3998
	WriteBufferL(aMessage, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  3999
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4000
	CleanupStack::PopAndDestroy();	  // driveNumList
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4001
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4002
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4003
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4004
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4005
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4006
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4007
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4008
 * AddDriveL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4009
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4010
 * @param RMessage2.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4011
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4012
 * Code changes for PREQ 557.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4013
 * Service request EMsvAddDriveToDriveList.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4014
 */	 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4015
void CMsvServerSession::AddDriveL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4016
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4017
	TDriveNumber driveNumber = (TDriveNumber) aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4018
	TUint priority = (TUint) aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4019
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4020
	TRAPD(err, iMsvServer.AddDriveToListL(driveNumber, priority, this));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4021
	if(KErrNone == err)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4022
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4023
		TPckgBuf<TUint> priorityBuf;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4024
		priorityBuf() = priority;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4025
		WriteL(aMessage, 2, priorityBuf);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4026
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4027
	aMessage.Complete(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4028
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4029
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4030
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4031
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4032
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4033
 * RemoveDriveL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4034
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4035
 * @param RMessage2.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4036
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4037
 * Code changes for PREQ 557.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4038
 * Service request EMsvRemoveDriveFromDriveList.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4039
 */ 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4040
void CMsvServerSession::RemoveDriveL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4041
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4042
	TDriveNumber driveNumber = (TDriveNumber) aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4043
	TRAPD(err, iMsvServer.RemoveDriveFromListL(driveNumber));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4044
	aMessage.Complete(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4045
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4046
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4047
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4048
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4049
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4050
 * UpdateDrivePriorityL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4051
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4052
 * @param RMessage2.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4053
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4054
 * Code changes for PREQ 557.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4055
 * Service request EMsvUpdateDrivePriority.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4056
 */	 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4057
void CMsvServerSession::UpdateDrivePriorityL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4058
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4059
	TDriveNumber driveNumber = (TDriveNumber) aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4060
	TUint priority = (TUint) aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4061
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4062
	TRAPD(err, iMsvServer.UpdateDrivePriorityL(driveNumber, priority));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4063
	if(KErrNone == err)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4064
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4065
		TPckgBuf<TUint> priorityBuf;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4066
		priorityBuf() = priority;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4067
		WriteL(aMessage, 2, priorityBuf);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4068
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4069
	aMessage.Complete(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4070
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4071
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4072
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4073
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4074
 * ResetRepositoryL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4075
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4076
 * @param RMessage2.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4077
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4078
 * Code changes for PREQ 557.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4079
 * Service request EMsvResetRepository.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4080
 */ 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4081
#if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4082
void CMsvServerSession::ResetRepositoryL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4083
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4084
	TRAPD(err, iMsvServer.ResetRepositoryL());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4085
	aMessage.Complete(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4086
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4087
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4088
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4089
void CMsvServerSession::PrintCache(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4090
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4091
	#ifdef _DEBUG
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4092
		iMsvServer.Context().IndexAdapter()->PrintL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4093
	#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4094
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4095
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4096
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4097
#endif	  // #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4098
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4099
#endif		  // #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4100
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4101
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4102
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4103
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4104
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4105
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4106
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4107
#if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4108
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4109
/*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4110
 * CreateHeaderTableL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4111
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4112
 * The function creates the header table in the message store.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4113
 */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4114
void CMsvServerSession::CreateHeaderTableL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4115
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4116
	// Check for capability.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4117
	if(!aMessage.HasCapability(ECapabilityWriteDeviceData))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4118
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4119
		// Client missing capabilities - emit diagnostics and leave...
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4120
		User::LeaveIfError(PlatSec::CapabilityCheckFail(aMessage, ECapabilityWriteDeviceData, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::CreateHeaderTableL")));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4121
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4122
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4123
	// Capability check is fine. Proceed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4124
	TUid mtmTypeUid = TUid::Uid(aMessage.Int0());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4125
	ReadBufferL(aMessage, 1, iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4126
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4127
	// Read the header structure from the buffer.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4128
	RPointerArray<CFieldPair> fieldDetails;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4129
	CleanupClosePushL(fieldDetails);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4130
	TMsvPackedHeaderStructure headerStruct(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4131
			
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4132
	headerStruct.UnpackL(fieldDetails);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4133
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4134
	// Create the header table and handle error.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4135
	TRAPD(err, iMsvServer.MessageDBAdapter().CreateHeaderTableL(mtmTypeUid, fieldDetails, iLastDBErrorMessage));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4136
	fieldDetails.ResetAndDestroy();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4137
	CleanupStack::PopAndDestroy();		  // fieldDetails
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4138
	aMessage.Complete(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4139
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4140
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4141
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4142
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4143
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4144
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4145
/*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4146
 * DoesStoreExistsL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4147
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4148
 * The function checks if a header table for a MTM Id already exists in message store.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4149
 */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4150
void CMsvServerSession::DoesStoreExistsL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4151
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4152
	// Check for capability.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4153
	if(!aMessage.HasCapability(ECapabilityReadDeviceData))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4154
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4155
		// Client missing capabilities - emit diagnostics and leave...
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4156
		User::LeaveIfError(PlatSec::CapabilityCheckFail(aMessage, ECapabilityReadDeviceData, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::DoesStoreExistsL")));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4157
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4158
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4159
	// Capability check is fine. Proceed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4160
	TUid mtmTypeUid = TUid::Uid(aMessage.Int0());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4161
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4162
	TBool isStoreExists = iMsvServer.MessageDBAdapter().IsHeaderTableExistsL(mtmTypeUid);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4163
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4164
	TPckgBuf<TBool> storeExists;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4165
	storeExists() = isStoreExists;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4166
	WriteL(aMessage, 1, storeExists);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4167
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4168
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4169
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4170
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4171
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4172
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4173
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4174
/*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4175
 * LastErrorMessageL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4176
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4177
 * This function is mainly used after the header table creation.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4178
 * The function returns the error message text, if the header table
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4179
 * creation fails.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4180
 */ 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4181
void CMsvServerSession::LastErrorMessageL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4182
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4183
	TInt desLen = iLastDBErrorMessage.Size();   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4184
	if (Align4(desLen+4) > aMessage.GetDesMaxLength(0))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4185
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4186
		User::Leave(KErrOverflow);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4187
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4188
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4189
	iBuffer->Des().SetLength(desLen+4);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4190
	TInt* ptr = (TInt*) CONST_CAST(TUint8*, iBuffer->Ptr());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4191
	*ptr++ = desLen;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4192
	Mem::Copy((void*)ptr, iLastDBErrorMessage.Ptr(), desLen);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4193
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4194
	WriteBufferL(aMessage, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4195
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4196
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4197
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4198
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4199
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4200
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4201
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4202
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4203
/*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4204
 * CreateHeaderEntryL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4205
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4206
 * This function creates a new header entry in the database.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4207
 */ 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4208
void CMsvServerSession::CreateHeaderEntryL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4209
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4210
	// Check for capability.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4211
	if(!aMessage.HasCapability(ECapabilityWriteUserData))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4212
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4213
		// Client missing capabilities - emit diagnostics and leave...
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4214
		User::LeaveIfError(PlatSec::CapabilityCheckFail(aMessage, ECapabilityWriteUserData, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::CreateHeaderEntryL")));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4215
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4216
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4217
	// Capability check is fine. Proceed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4218
	TUid mtmTypeUid = TUid::Uid(aMessage.Int0());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4219
	TMsvId entryId = aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4220
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4221
	ReadBufferL(aMessage, 2, iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4222
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4223
	RPointerArray<CHeaderFields> fieldPairList;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4224
	CleanupClosePushL(fieldPairList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4225
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4226
	TMsvPackedHeaderData headerData(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4227
	headerData.UnpackL(fieldPairList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4228
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4229
	TRAPD(err, iMsvServer.MessageDBAdapter().CreateHeaderEntryL(mtmTypeUid, entryId, fieldPairList));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4230
	fieldPairList.ResetAndDestroy();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4231
	CleanupStack::PopAndDestroy();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4232
	aMessage.Complete(err); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4233
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4234
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4235
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4236
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4237
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4238
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4239
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4240
/*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4241
 * LoadHeaderEntryL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4242
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4243
 * This function loads the header entry from the database
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4244
 * and returns to the client.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4245
 */ 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4246
void CMsvServerSession::LoadHeaderEntryL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4247
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4248
	// Check for capability.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4249
	if(!aMessage.HasCapability(ECapabilityReadUserData))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4250
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4251
		// Client missing capabilities - emit diagnostics and leave...
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4252
		User::LeaveIfError(PlatSec::CapabilityCheckFail(aMessage, ECapabilityReadUserData, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::LoadHeaderEntryL")));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4253
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4254
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4255
	// Capability check is fine. Proceed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4256
	TUid mtmTypeUid = TUid::Uid(aMessage.Int0());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4257
	TMsvId entryId = aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4258
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4259
	RPointerArray<CHeaderFields> fieldPairList;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4260
	CleanupClosePushL(fieldPairList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4261
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4262
	TRAPD(err, iMsvServer.MessageDBAdapter().LoadHeaderEntryL(mtmTypeUid, entryId, fieldPairList));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4263
	if(KErrNone == err)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4264
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4265
		TMsvPackedHeaderData headerData(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4266
		err = headerData.Pack(fieldPairList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4267
		while (err != KErrNone)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4268
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4269
			// increase the size of the buffer and try again
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4270
			iBuffer->Des().SetLength(0); // to avoid copying contents
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4271
			iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4272
			err = headerData.Pack(fieldPairList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4273
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4274
		WriteBufferL(aMessage, 2);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4275
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4276
	fieldPairList.ResetAndDestroy();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4277
	CleanupStack::PopAndDestroy();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4278
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4279
	aMessage.Complete(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4280
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4281
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4282
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4283
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4284
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4285
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4286
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4287
/*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4288
 * DeleteHeaderEntryL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4289
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4290
 * This function deletes the header entry from the database.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4291
 */	 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4292
void CMsvServerSession::DeleteHeaderEntryL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4293
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4294
	// Check for capability.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4295
	if(!aMessage.HasCapability(ECapabilityWriteUserData))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4296
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4297
		// Client missing capabilities - emit diagnostics and leave...
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4298
		User::LeaveIfError(PlatSec::CapabilityCheckFail(aMessage, ECapabilityWriteUserData, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::DeleteHeaderEntryL")));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4299
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4300
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4301
	TUid mtmTypeUid = TUid::Uid(aMessage.Int0());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4302
	TMsvId entryId = aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4303
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4304
	TRAPD(err, iMsvServer.MessageDBAdapter().DeleteHeaderEntryL(mtmTypeUid, entryId));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4305
	aMessage.Complete(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4306
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4307
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4308
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4309
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4310
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4311
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4312
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4313
/*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4314
 * UpdateHeaderEntryL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4315
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4316
 * This function udpates the header entry in the database.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4317
 */ 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4318
void CMsvServerSession::UpdateHeaderEntryL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4319
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4320
	// Check for capability.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4321
	if(!aMessage.HasCapability(ECapabilityWriteUserData))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4322
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4323
		// Client missing capabilities - emit diagnostics and leave...
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4324
		User::LeaveIfError(PlatSec::CapabilityCheckFail(aMessage, ECapabilityWriteUserData, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::UpdateHeaderEntryL")));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4325
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4326
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4327
	TUid mtmTypeUid = TUid::Uid(aMessage.Int0());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4328
	TMsvId entryId = aMessage.Int1();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4329
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4330
	ReadBufferL(aMessage, 2, iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4331
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4332
	RPointerArray<CHeaderFields> fieldPairList;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4333
	CleanupClosePushL(fieldPairList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4334
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4335
	TMsvPackedHeaderData headerData(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4336
	headerData.UnpackL(fieldPairList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4337
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4338
	TRAPD(err, iMsvServer.MessageDBAdapter().UpdateHeaderEntryL(mtmTypeUid, entryId, fieldPairList));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4339
	fieldPairList.ResetAndDestroy();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4340
	CleanupStack::PopAndDestroy();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4341
	aMessage.Complete(err);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4342
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4343
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4344
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4345
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4346
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4347
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4348
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4349
/*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4350
 * DoesAnyStoreExists()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4351
 *
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4352
 * This function checks if the store (header/body) exists 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4353
 * for a give metadata entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4354
 */ 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4355
void CMsvServerSession::DoesAnyStoreExists(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4356
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4357
	TMsvId entryId = aMessage.Int0();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4358
	TUid mtmTypeUid = TUid::Uid(aMessage.Int1());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4359
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4360
	TBool isStoreExists = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4361
	TRAPD(err, isStoreExists = iMsvServer.MessageDBAdapter().DoesAnyStoreExistsL(entryId, mtmTypeUid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4362
	if(err)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4363
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4364
		aMessage.Complete(EFalse);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4365
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4366
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4367
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4368
		aMessage.Complete(isStoreExists);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4369
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4370
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4371
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4372
void CMsvServerSession::DoesHeaderTableExist(const RMessage2 aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4373
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4374
	TUid mtmTypeUid = TUid::Uid(aMessage.Int0());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4375
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4376
	TBool doesHeaderExists = EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4377
	TRAPD(err, doesHeaderExists = iMsvServer.MessageDBAdapter().IsHeaderTableExistsL(mtmTypeUid));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4378
	if(err)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4379
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4380
		aMessage.Complete(EFalse);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4381
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4382
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4383
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4384
		aMessage.Complete(doesHeaderExists);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4385
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4386
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4387
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4388
/***************************************Converter API's***************************/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4389
/*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4390
 GetConvertibleDriveListL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4391
 Fetches a list of drives with message store unsupported	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4392
 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4393
 @param aMessage: RMessage2 representing client request and containing request data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4394
 @return None
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4395
 */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4396
void CMsvServerSession::GetConvertibleDriveListL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4397
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4398
	// capability check
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4399
	if(!aMessage.HasCapability(ECapabilityReadDeviceData))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4400
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4401
		// Client missing capabilities - emit diagnostics and leave...
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4402
		User::LeaveIfError(PlatSec::CapabilityCheckFail(aMessage, ECapabilityReadDeviceData, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetConvertibleDriveListL")));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4403
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4404
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4405
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4406
	CMsvPreferredDriveList *driveList = CMsvPreferredDriveList::GetDriveList();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4407
	RArray<TDriveNumber> driveNumList;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4408
	CleanupClosePushL(driveNumList);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4409
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4410
	for(TInt index=0; index<driveList->Count(); index++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4411
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4412
		if(EMsvMessageStoreNotSupportedStatus == (*driveList)[index].status)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4413
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4414
			driveNumList.AppendL((*driveList)[index].driveNum);	 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4415
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4416
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4417
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4418
	TMsvPackedDriveIdOperation driveOp(iBuffer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4419
	User::LeaveIfError(driveOp.Pack(driveNumList));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4420
	WriteBufferL(aMessage, 0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4421
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4422
	CleanupStack::PopAndDestroy();	  // driveNumList
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4423
	aMessage.Complete(KErrNone);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4424
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4425
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4426
/*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4427
 ConvertMessageStoreL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4428
 Initiates message store conversion on a drive. if the conversion is active on a drive
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4429
 than this request is queued and completed later.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4430
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4431
 @param aMessage: RMessage2 representing client request and containing request data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4432
 @return None
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4433
 */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4434
void CMsvServerSession::ConvertMessageStoreL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4435
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4436
	// capability check
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4437
	if(!aMessage.HasCapability(ECapabilityWriteDeviceData))
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4438
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4439
		// Client missing capabilities - emit diagnostics and leave...
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4440
		User::LeaveIfError(PlatSec::CapabilityCheckFail(aMessage, ECapabilityWriteDeviceData, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::ConvertMessageStoreL")));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4441
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4442
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4443
	/*Instantiate the converter waiter thread. If it is already active, than the existing instance is returned
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4444
	  Else a new instance is created and returned. Singleton Pattern   */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4445
	  
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4446
	iConverterWaiter=CMsvConverterWaiter::InstanceL(&iMsvServer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4447
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4448
	if(!iConverterWaiter->isRunningMessageStoreConverter()) 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4449
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4450
		iConverterWaiter->StartMessageStoreConversionL(aMessage,EFalse);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4451
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4452
	else 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4453
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4454
		// Queue the request if the drive is already not present
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4455
		iConverterWaiter->QueueConversionRequestL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4456
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4457
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4458
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4459
/*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4460
 CancelConversionRequestL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4461
 Cancels conversion request for a drive.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4462
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4463
 @param aMessage: RMessage2 representing client request and containing request data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4464
 @return None
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4465
 */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4466
void CMsvServerSession::CancelConversionRequestL(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4467
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4468
	if(iConverterWaiter)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4469
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4470
		iConverterWaiter->CancelConversionL(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4471
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4472
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4473
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4474
		aMessage.Complete(KErrNotFound);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4475
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4476
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4477
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4478
/*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4479
 GetConversionStatus()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4480
 Gets the conversion status for a drive.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4481
 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4482
 @param aMessage: RMessage2 representing client request and containing request data.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4483
 @return None
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4484
 */ 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4485
void CMsvServerSession::GetConversionStatus(const RMessage2 &aMessage)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4486
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4487
	if(iConverterWaiter)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4488
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4489
		iConverterWaiter->GetConversionStatus(aMessage);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4490
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4491
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4492
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4493
		aMessage.Complete(KErrNotFound);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4494
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4495
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4496
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4497
TBool CMsvServerSession::FoundUnSupportedDrives()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4498
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4499
	CMsvPreferredDriveList *driveList = CMsvPreferredDriveList::GetDriveList();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4500
	for(TInt index=0; index<driveList->Count(); index++)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4501
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4502
		if(EMsvMessageStoreNotSupportedStatus == (*driveList)[index].status)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4503
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4504
			return ETrue;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4505
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4506
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4507
	return EFalse;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4508
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4509
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4510
#endif	  // #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4511
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4512
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4513
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4514
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4515
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
  4516