messagingfw/msgsrvnstore/server/src/MTCLBASE.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
// MTCLBASE.CPP
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    15
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    16
#include <e32std.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    17
#include <txtrich.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    18
#include <txtfmlyr.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    19
#include <mtmuids.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    20
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    21
#include "MSVIDS.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    22
#include "MSVAPI.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    23
#include "MTCLBASE.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    24
#include "MTCLREG.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    25
#include "MSVPANIC.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    26
#include "MSVUIDS.H"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    27
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    28
#include <mmsvattachmentmanager.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    29
#include "CMsvAttachmentWaiter.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    30
#include <cmsvmimeheaders.h>
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    31
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    32
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS  
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    33
#include "msvconsts.h"
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    34
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    35
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    36
#if defined(_DEBUG)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    37
_LIT(KMtclPanicString, "MSGS");
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    38
#endif
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    39
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    40
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    41
EXPORT_C CBaseMtm::CBaseMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aSession)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    42
: iRegisteredMtmDll(aRegisteredMtmDll), iSession(aSession)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    43
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    44
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    45
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    46
/** Creates a CBaseMtm with member variables initialised from the passed arguments. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    47
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    48
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    49
Client applications do not use this function. It is relevant only to implementers 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    50
of derived classes.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    51
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    52
The value of aSession can be accessed through Session().
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    53
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    54
Derived classes can implement a constructor to perform any additional MTM-specific 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    55
setup that can be safely carried out in a constructor. Such constructors must 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    56
call the base class constructor function.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    57
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    58
Derived classes also implement two-phase construction functions (NewL(), ConstructL()) 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    59
to create a new instance of the object, in which any dynamic allocation should 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    60
be performed. Client-side MTMs also implement a factory function by which 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    61
a MTM registry can request an instance of the class.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    62
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    63
@param aRegisteredMtmDll Registration data for the MTM DLL. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    64
@param aSession The CMsvSession of the client requesting the object */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    65
	{}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    66
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    67
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    68
EXPORT_C CBaseMtm::~CBaseMtm()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    69
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    70
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    71
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    72
/** Cleans up the base class. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    73
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    74
CBaseMtm -derived objects must be deleted by client applications when they 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    75
are no longer required. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    76
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    77
Derived classes can implement a destructor to do any additional clean up tasks 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    78
that they require. */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    79
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    80
	DeleteEntry();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    81
	delete iAddresseeList;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    82
	delete iRichTextBody;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    83
	delete iCharFormatLayer;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    84
	delete iParaFormatLayer;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    85
	iRegisteredMtmDll.ReleaseLibrary();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    86
	delete iAttachmentWaiter;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    87
	delete iExtensionData;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    88
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    89
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    90
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    91
EXPORT_C TUid CBaseMtm::Type() const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    92
/** Gets the Type UID of the message type associated with the Client-side MTM.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    93
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    94
@return UID of the message type associated with the MTM */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    95
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    96
	return iRegisteredMtmDll.MtmTypeUid();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    97
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    98
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
    99
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   100
EXPORT_C TInt CBaseMtm::QueryCapability(TUid /*aCapability*/, TInt& /*aResponse*/)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   101
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   102
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   103
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   104
	/** Queries if the MTM supports a particular capability, specified by a UID. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   105
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   106
	For MTM-specific UIDs, see the documentation for the relevant MTM.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   107
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   108
	Requirements:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   109
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   110
	Implementations should check aCapability for the standard capability values, 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   111
	plus any MTM-specific capabilities, and if recognised, return a suitable response 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   112
	in aResponse. If aCapability is unknown, return KErrNotSupported.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   113
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   114
	The default implementation returns KErrNotSupported. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   115
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   116
	@param aCapability UID of capability to be queried 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   117
	@param aResponse Response value. The format of the response varies according 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   118
	to the capability. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   119
	@return KErrNone: aCapability is a recognised value and a response is returned 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   120
	KErrNotSupported: aCapability is not a recognised value */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   121
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   122
	return KErrNotSupported;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   123
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   124
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   125
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   126
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   127
EXPORT_C void CBaseMtm::SwitchCurrentEntryL(TMsvId aId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   128
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   129
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   130
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   131
/** Changes the entry on which later actions are performed to the entry with the 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   132
specified TMsvId. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   133
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   134
@param aId The ID of the entry upon which all following actions will be performed 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   135
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   136
@leave KErrNoMemory Insufficient memory 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   137
@leave KErrNotFound The requested entry does not exist */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   138
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   139
	// create the new CMsvEntry
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   140
	CMsvEntry* newEntry = Session().GetEntryL(aId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   141
	SetCurrentEntryL(newEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   142
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   143
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   144
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   145
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   146
EXPORT_C void CBaseMtm::SetCurrentEntryL(CMsvEntry* aEntry)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   147
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   148
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   149
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   150
/** Sets the entry on which later actions are performed to the specified CMsvEntry. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   151
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   152
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   153
@param aEntry The entry on which all following actions will be performed 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   154
@leave KErrNoMemory Insufficient memory */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   155
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   156
	CleanupStack::PushL(aEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   157
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   158
	if (iAddresseeList==NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   159
		iAddresseeList = CMsvRecipientList::NewL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   160
	if (iParaFormatLayer==NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   161
		iParaFormatLayer = CParaFormatLayer::NewL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   162
	if (iCharFormatLayer==NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   163
		iCharFormatLayer = CCharFormatLayer::NewL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   164
	if (iRichTextBody==NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   165
		iRichTextBody = CRichText::NewL(iParaFormatLayer, iCharFormatLayer);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   166
	else
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   167
		iRichTextBody->Reset();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   168
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   169
	aEntry->AddObserverL(*this);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   170
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   171
	CleanupStack::Pop(); // aEntry
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   172
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   173
	// swap the old and new context
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   174
	DeleteEntry();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   175
	iMsvEntry = aEntry;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   176
	iEntryId = iMsvEntry->EntryId();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   177
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   178
	// If waiting for attachment additons to be commited, delete without commiting
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   179
	// the changed
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   180
	delete iAttachmentWaiter;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   181
	iAttachmentWaiter = NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   182
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   183
	// inform concrete implementation that the context has switched (or set in the first case)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   184
	ContextEntrySwitched();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   185
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   186
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   187
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   188
EXPORT_C CMsvEntry& CBaseMtm::Entry() const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   189
/** Gets a CMsvEntry for the current context. The message client application can 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   190
then use this to manipulate the entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   191
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   192
Implementers should note that this function returns the value of the protected 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   193
data member iMsvEntry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   194
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   195
@return CMsvEntry for the current context */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   196
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   197
	__ASSERT_DEBUG(iMsvEntry!=NULL, User::Panic(KMtclPanicString, 275));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   198
	return *iMsvEntry;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   199
	};
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   200
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   201
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   202
EXPORT_C TBool CBaseMtm::HasContext() const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   203
/** Tests if an MTM context has been set.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   204
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   205
A Client-side MTM has no context until one is set through SwitchCurrentEntryL() 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   206
or SetCurrentEntryL() . 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   207
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   208
@return ETrue: context has been set EFalse: context has not been set */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   209
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   210
	return (iMsvEntry!=NULL);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   211
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   212
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   213
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   214
void CBaseMtm::DeleteEntry()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   215
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   216
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   217
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   218
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   219
	if (iMsvEntry!=NULL)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   220
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   221
		iMsvEntry->RemoveObserver(*this);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   222
		delete iMsvEntry;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   223
		iMsvEntry=NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   224
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   225
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   226
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   227
EXPORT_C void CBaseMtm::StoreBodyL(CMsvStore& aStore)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   228
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   229
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   230
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   231
/** Stores and commits the current cached CRichText body text to the appropriate 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   232
stream in the specified message store. Client applications do not use this 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   233
function. It is relevant only to implementers of derived classes.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   234
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   235
The function overwrites any existing data in that stream. The implementation 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   236
must have write access to aStore. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   237
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   238
A typical use of this function is from SaveMessageL().
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   239
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   240
@param aStore Message store in which to store the body text 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   241
@leave KErrAccessDenied The store was opened for read only 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   242
@leave Other Standard stream-related leave codes */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   243
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   244
	__ASSERT_ALWAYS(iMsvEntry!=NULL, PanicServer(EMtclMsvEntryNotSet));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   245
	__ASSERT_ALWAYS(iMsvEntry->EntryId()==iEntryId, PanicServer(EMtclContextChangedByOwner));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   246
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   247
	aStore.StoreBodyTextL(*iRichTextBody);	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   248
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   249
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   250
EXPORT_C void CBaseMtm::RestoreBodyL(CMsvStore& aStore)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   251
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   252
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   253
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   254
/** Gets the current cached CRichText from the appropriate stream in the specified 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   255
message store. Client applications do not use this function. It is relevant 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   256
only to implementers of derived classes.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   257
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   258
A typical use of this function is from LoadMessageL().
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   259
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   260
@param aStore Message store from which to read the body text */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   261
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   262
	__ASSERT_ALWAYS(iMsvEntry!=NULL, PanicServer(EMtclMsvEntryNotSet));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   263
	__ASSERT_ALWAYS(iMsvEntry->EntryId()==iEntryId, PanicServer(EMtclContextChangedByOwner));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   264
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   265
	aStore.RestoreBodyTextL(*iRichTextBody);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   266
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   267
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   268
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   269
EXPORT_C CRichText& CBaseMtm::Body()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   270
/** Gets the body text of the context, that must be a message. For non-message 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   271
contexts, an empty CRichText is returned. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   272
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   273
@return Body text of the context 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   274
@see StoreBodyL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   275
@see RestoreBodyL() */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   276
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   277
	__ASSERT_DEBUG(iMsvEntry!=NULL, User::Panic(KMtclPanicString, 275)); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   278
	return *iRichTextBody;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   279
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   280
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   281
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   282
EXPORT_C const CRichText& CBaseMtm::Body() const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   283
/** Gets the read-only body text of the context, that must be a message. For non-message 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   284
contexts, an empty CRichText is returned. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   285
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   286
@return Read-only body text of the context 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   287
@see StoreBodyL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   288
@see RestoreBodyL() */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   289
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   290
	__ASSERT_DEBUG(iMsvEntry!=NULL, User::Panic(KMtclPanicString, 275));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   291
	return *iRichTextBody;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   292
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   293
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   294
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   295
EXPORT_C void CBaseMtm::SetSubjectL(const TDesC& /*aSubject*/)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   296
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   297
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   298
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   299
	/** Sets the subject text of the context, which must be a message. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   300
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   301
	Some Client-side MTMs may not support subject text, in which case the function 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   302
	leaves with KErrNotSupported.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   303
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   304
	Requirements:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   305
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   306
	If the message protocol supports subject text, implementations should maintain 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   307
	a private buffer to store this information, settable through this function.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   308
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   309
	Implementations should save the subject text to the appropriate place in the 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   310
	message store when the message is stored.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   311
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   312
	The default implementation leaves with KErrNotSupported.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   313
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   314
	@param aSubject Message subject text 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   315
	@leave KErrNotSupported The Client-side MTMs does not support subject text 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   316
	@see StoreBodyL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   317
	@see RestoreBodyL() */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   318
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   319
	User::Leave(KErrNotSupported);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   320
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   321
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   322
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   323
/** Gets the list of intended recipients for the current context, which must be 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   324
a message. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   325
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   326
In the case of protocols that allow different classes of recipient (such as 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   327
To, Cc and Bcc), the list returned is whatever the protocol defines as the 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   328
default recipient list. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   329
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   330
Requirements:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   331
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   332
The default implementation simply returns the value of the protected data 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   333
member iAddresseeList. As a consequence, Client-side MTM implementations should 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   334
update this member whenever the address list is modified.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   335
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   336
@return Array of recipients
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   337
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   338
EXPORT_C const CMsvRecipientList& CBaseMtm::AddresseeList() const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   339
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   340
	__ASSERT_DEBUG(iMsvEntry!=NULL, User::Panic(KMtclPanicString, 275));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   341
	return *iAddresseeList;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   342
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   343
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   344
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   345
/** Adds addressee to list.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   346
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   347
The default implementation treats To: and Cc: type addressees as if the addressee
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   348
had no type.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   349
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   350
The default implementation does not support Bcc type addressees.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   351
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   352
@param	aType
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   353
The addressee type.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   354
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   355
@param	aRealAddress
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   356
The addressee address.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   357
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   358
@leave	KErrNotSupprted
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   359
The addressee type was Bcc which is not supported in the default implementation.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   360
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   361
EXPORT_C void CBaseMtm::AddAddresseeL(TMsvRecipientType aType, const TDesC& aRealAddress)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   362
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   363
	if (aType == EMsvRecipientBcc)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   364
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   365
		User::Leave(KErrNotSupported);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   366
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   367
	AddAddresseeL(aRealAddress);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   368
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   369
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   370
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   371
/** Adds addressee to list.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   372
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   373
The default implementation treats To: and Cc: type addressees as if the addressee
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   374
had no type.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   375
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   376
The default implementation does not support Bcc type addressees.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   377
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   378
@param	aType
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   379
The addressee type.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   380
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   381
@param	aRealAddress
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   382
The addressee address.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   383
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   384
@param	aAlias
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   385
The alias for the addressee.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   386
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   387
@leave	KErrNotSupprted
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   388
The addressee type was Bcc which is not supported in the default implementation.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   389
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   390
EXPORT_C void CBaseMtm::AddAddresseeL(TMsvRecipientType aType, const TDesC& aRealAddress, const TDesC& aAlias)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   391
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   392
	if (aType == EMsvRecipientBcc)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   393
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   394
		User::Leave(KErrNotSupported);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   395
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   396
	AddAddresseeL(aRealAddress, aAlias);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   397
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   398
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   399
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   400
EXPORT_C const TPtrC CBaseMtm::SubjectL() const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   401
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   402
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   403
//
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   404
/** Gets the subject text of the context, which must be a message. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   405
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   406
Some Client-side MTMs may not support subject text, in which case the function 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   407
leaves with KErrNotSupported.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   408
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   409
Requirements:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   410
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   411
If the message protocol supports subject text, implementations should maintain 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   412
a private buffer to store this information, gettable through this function.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   413
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   414
The default implementation leaves with KErrNotSupported.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   415
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   416
@leave KErrNotSupported The Client-side MTMs does not support subject text 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   417
@return Message subject text */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   418
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   419
	User::Leave(KErrNotSupported);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   420
	return TPtrC();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   421
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   422
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   423
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   424
EXPORT_C void CBaseMtm::HandleEntryEventL(TMsvEntryEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   425
/** Indicates that an event has occurred. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   426
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   427
Client applications do not use this function. It is relevant only to implementers of derived classes.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   428
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   429
The Client-side MTM object is automatically set as an observer, through CMsvEntry::AddObserverL(), 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   430
for the context whenever the context changes (by SetCurrentEntryL() or SwitchCurrentEntryL()).
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   431
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   432
The default implementation is defined to do nothing.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   433
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   434
Requirements:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   435
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   436
Implementations can override this function to handle events concerning the current context. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   437
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   438
@param aEvent Indicates the event type 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   439
@param aArg1 Event specific argument value 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   440
@param aArg2 Event specific argument value
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   441
@param aArg3 Event specific argument value
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   442
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   443
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   444
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   445
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   446
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   447
EXPORT_C CMsvSession& CBaseMtm::Session()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   448
/** Gets a reference to the session object passed by the creator of the Client-side 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   449
MTM.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   450
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   451
@return Session object used by the Client-side MTM */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   452
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   453
	return iSession;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   454
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   455
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   456
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   457
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   458
Adds a file attachment to the current message entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   459
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   460
The attachment is referenced by its file path and is copied into the message store.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   461
Only one asynchronous operation can be run at any one time.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   462
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   463
@param aFilePath The full path specification of the attachment file.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   464
@param aMimeType The mime type of the attachment file.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   465
@param aCharset The mime charset. The value is a standard IANA value. The value 0 indicates
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   466
	   that no charset is provided.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   467
@param aStatus The request status to complete when request has completed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   468
@leave System-wide error codes.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   469
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   470
EXPORT_C void CBaseMtm::AddAttachmentL(const TDesC& aFilePath, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   471
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   472
	AddFilePathAttachmentL(aFilePath, aMimeType, aCharset, CMsvAttachment::EMsvFile, aStatus);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   473
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   474
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   475
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   476
Adds a file attachment to the current message entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   477
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   478
The attachment is referenced by an open file handle and is copied into the message store. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   479
Only one asynchronous operation can be run at any one time.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   480
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   481
@param aFile An open file handle for the file attachment.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   482
@param aMimeType The mime type of the attachment file.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   483
@param aCharset The mime charset. The value is a standard IANA value. The value 0 indicates
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   484
	   that no charset is provided.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   485
@param aStatus The request status to complete when request has completed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   486
@leave System-wide error codes.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   487
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   488
EXPORT_C void CBaseMtm::AddAttachmentL(RFile& aFile, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   489
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   490
	if( iAttachmentWaiter == NULL )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   491
		iAttachmentWaiter = CMsvAttachmentWaiter::NewL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   492
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   493
	CMsvStore* store = iMsvEntry->EditStoreL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   494
	CleanupStack::PushL(store);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   495
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   496
	CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   497
	CleanupStack::PushL(attachment);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   498
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   499
	// set the size
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   500
	TInt size = 0;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   501
	User::LeaveIfError(aFile.Size(size));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   502
	attachment->SetSize(size);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   503
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   504
	// set the mime-type if provided
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   505
	if( aMimeType.Length() > 0 )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   506
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   507
		attachment->SetMimeTypeL(aMimeType);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   508
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   509
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   510
	TFileName fileName;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   511
	User::LeaveIfError(aFile.Name(fileName));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   512
	attachment->SetAttachmentNameL(fileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   513
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   514
	if( aCharset!=0 )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   515
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   516
		CMsvMimeHeaders* headers = CMsvMimeHeaders::NewLC();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   517
		headers->SetMimeCharset(aCharset);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   518
		headers->StoreL(*attachment);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   519
		CleanupStack::PopAndDestroy(headers);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   520
		}	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   521
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   522
	// attachment is initialised, pass to the attachment manager
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   523
	MMsvAttachmentManager& manager = store->AttachmentManagerL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   524
	manager.AddAttachmentL(aFile, attachment, iAttachmentWaiter->iStatus); 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   525
	CleanupStack::Pop(attachment); // ownership passed to manager
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   526
	iAttachmentWaiter->StartWaitingL(aStatus, store, &manager);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   527
	CleanupStack::Pop(store);      // ownership passed
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   528
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   529
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   530
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   531
Adds a file attachment to the current message entry as a linked file.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   532
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   533
The attachment is referenced by its file path and is not copied into the message store. The attachment file is always used from
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   534
its original location on disk indicated by the aFilePath parameter. Only one asynchronous operation can be run at any one time.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   535
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   536
@param aFilePath The full path specification of the attachment file.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   537
@param aMimeType The mime type of the attachment file.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   538
@param aCharset The mime charset. The value is a standard IANA value. The value 0 indicates
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   539
	   that no charset is provided.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   540
@param aStatus The request status to complete when request has completed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   541
@leave System-wide error codes.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   542
*/	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   543
EXPORT_C void CBaseMtm::AddLinkedAttachmentL(const TDesC& aFilePath, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   544
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   545
	AddFilePathAttachmentL(aFilePath, aMimeType, aCharset, CMsvAttachment::EMsvLinkedFile, aStatus);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   546
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   547
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   548
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   549
Creates a new empty file attachment to the current message entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   550
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   551
An empty file attachment is created with the suggested given name and if
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   552
completed successfully, the aAttachmentFile will be open on the new file.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   553
Only one asynchronous operation can be run at any one time.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   554
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   555
@param aFileName The suggested file name for the new attachment file.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   556
@param aAttachmentFile If successful, this will be set to the open new file.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   557
@param aMimeType The mime type of the attachment file.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   558
@param aCharset The mime charset. The value is a standard IANA value. The value 0 indicates
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   559
	   that no charset is provided.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   560
@param aStatus The request status to complete when request has completed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   561
@leave System-wide error codes.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   562
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   563
EXPORT_C void CBaseMtm::CreateAttachmentL(const TDesC& aFileName, RFile& aAttachmentFile, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   564
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   565
	if( iAttachmentWaiter == NULL )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   566
		iAttachmentWaiter = CMsvAttachmentWaiter::NewL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   567
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   568
	CMsvStore* store = iMsvEntry->EditStoreL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   569
	CleanupStack::PushL(store);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   570
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   571
	CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   572
	CleanupStack::PushL(attachmentInfo);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   573
	attachmentInfo->SetAttachmentNameL(aFileName);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   574
	attachmentInfo->SetMimeTypeL(aMimeType);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   575
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   576
	if( aCharset!=0 )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   577
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   578
		CMsvMimeHeaders* headers = CMsvMimeHeaders::NewLC();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   579
		headers->SetMimeCharset(aCharset);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   580
		headers->StoreL(*attachmentInfo);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   581
		CleanupStack::PopAndDestroy(headers);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   582
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   583
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   584
	MMsvAttachmentManager& manager = store->AttachmentManagerL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   585
	manager.CreateAttachmentL(aFileName, aAttachmentFile, attachmentInfo, iAttachmentWaiter->iStatus);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   586
	CleanupStack::Pop(attachmentInfo); // ownership passed to manager
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   587
	iAttachmentWaiter->StartWaitingL(aStatus, store, &manager);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   588
	CleanupStack::Pop(store); // ownership passed
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   589
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   590
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   591
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   592
Adds a message entry as an attachment to the current message entry.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   593
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   594
This method simply registers an existing message entry as an attachment to the current entry. Only one asynchronous
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   595
operation can be run at any one time.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   596
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   597
@param aAttachmentId The message Id of the message entry to add as an attachment.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   598
@param aStatus The request status to complete when request has completed.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   599
@leave System-wide error codes.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   600
*/	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   601
EXPORT_C void CBaseMtm::AddEntryAsAttachmentL(TMsvId aAttachmentId, TRequestStatus& aStatus)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   602
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   603
	// Get the size of the message entry
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   604
	CMsvEntry* attachEntry = iSession.GetEntryL(aAttachmentId);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   605
	TInt attachSize = attachEntry->Entry().iSize;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   606
	delete attachEntry;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   607
	attachEntry = NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   608
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   609
	if( iAttachmentWaiter == NULL )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   610
		iAttachmentWaiter = CMsvAttachmentWaiter::NewL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   611
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   612
	CMsvStore* store = iMsvEntry->EditStoreL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   613
	CleanupStack::PushL(store);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   614
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   615
	CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvMessageEntry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   616
	CleanupStack::PushL(attachment);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   617
	attachment->SetSize(attachSize);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   618
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   619
	// Register entry as attachment
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   620
	MMsvAttachmentManager& manager = store->AttachmentManagerL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   621
	manager.AddEntryAsAttachmentL(aAttachmentId, attachment, iAttachmentWaiter->iStatus);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   622
	CleanupStack::Pop(attachment); // ownership passed to manager
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   623
	iAttachmentWaiter->StartWaitingL(aStatus, store, &manager);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   624
	CleanupStack::Pop(store); // ownership passed
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   625
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   626
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   627
void CBaseMtm::AddFilePathAttachmentL(const TDesC& aFilePath, const TDesC8& aMimeType, TUint aCharset, CMsvAttachment::TMsvAttachmentType aType, TRequestStatus& aStatus)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   628
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   629
	__ASSERT_DEBUG(aType != CMsvAttachment::EMsvMessageEntry, User::Invariant());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   630
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   631
	if( iAttachmentWaiter == NULL )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   632
		iAttachmentWaiter = CMsvAttachmentWaiter::NewL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   633
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   634
	CMsvStore* store = iMsvEntry->EditStoreL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   635
	CleanupStack::PushL(store);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   636
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   637
	CMsvAttachment* attachment = CMsvAttachment::NewL(aType);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   638
	CleanupStack::PushL(attachment);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   639
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   640
	// set the size
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   641
	TEntry fileEntry;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   642
	RFs& fs = iSession.FileSession();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   643
	User::LeaveIfError(fs.Entry(aFilePath, fileEntry));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   644
	attachment->SetSize(fileEntry.iSize);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   645
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   646
	// set the mime-type, if provided
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   647
	if( aMimeType.Length() > 0 )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   648
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   649
		attachment->SetMimeTypeL(aMimeType);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   650
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   651
		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   652
	// set attachment name
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   653
	TParse fileNameParser;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   654
	User::LeaveIfError(fileNameParser.Set(aFilePath, NULL, NULL));
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   655
	attachment->SetAttachmentNameL(fileNameParser.NameAndExt());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   656
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   657
	if( aCharset!=0 )
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   658
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   659
		CMsvMimeHeaders* headers = CMsvMimeHeaders::NewLC();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   660
		headers->SetMimeCharset(aCharset);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   661
		headers->StoreL(*attachment);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   662
		CleanupStack::PopAndDestroy(headers);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   663
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   664
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   665
	// attachment is initialised, pass to the attachment manager
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   666
	MMsvAttachmentManager& manager = store->AttachmentManagerL();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   667
	switch(aType)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   668
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   669
		case CMsvAttachment::EMsvFile:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   670
			manager.AddAttachmentL(aFilePath, attachment, iAttachmentWaiter->iStatus);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   671
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   672
		case CMsvAttachment::EMsvLinkedFile:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   673
			manager.AddLinkedAttachmentL(aFilePath, attachment, iAttachmentWaiter->iStatus);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   674
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   675
		default:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   676
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   677
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   678
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   679
	CleanupStack::Pop(attachment); // ownership passed to manager
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   680
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   681
	iAttachmentWaiter->StartWaitingL(aStatus, store, &manager);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   682
	CleanupStack::Pop(store); // ownership passed
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   683
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   684
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   685
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   686
Cancels the current attachment operation.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   687
*/	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   688
EXPORT_C void CBaseMtm::CancelAttachmentOperation()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   689
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   690
	if(iAttachmentWaiter)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   691
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   692
		iAttachmentWaiter->Cancel();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   693
		delete iAttachmentWaiter;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   694
		iAttachmentWaiter = NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   695
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   696
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   697
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   698
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   699
// virtual
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   700
EXPORT_C void CBaseMtm::CreateMessageL(TMsvId aServiceId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   701
/** Creates a new message entry as a child of the current context.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   702
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   703
The default implementation creates an empty entry with its visible flag set 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   704
to false and its in-preparation flag set to true.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   705
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   706
@param aServiceId ID of the service to own the entry. */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   707
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   708
	// create an invisible blank entry 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   709
	TMsvEntry entry;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   710
	entry.iType = KUidMsvMessageEntry;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   711
	entry.iServiceId = aServiceId;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   712
	entry.iMtm = Type();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   713
	entry.SetVisible(EFalse);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   714
	entry.SetInPreparation(ETrue);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   715
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   716
	// store entry in folder
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   717
	iMsvEntry->CreateL(entry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   718
	iMsvEntry->SetEntryL(entry.Id());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   719
	iEntryId = entry.Id();
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   720
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   721
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   722
EXPORT_C void CBaseMtm::BioTypeChangedL(TUid /*aBioTypeUid*/)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   723
	/** Informs client-side MTM that the context's BIO field is being changed as a 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   724
	result of a call to CSendAs::SetBioTypeL().
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   725
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   726
	CSendAs::SetBioTypeL() calls this function before setting the BIO field in 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   727
	the context's index entry. This allows a client-side MTM to perform MTM specific 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   728
	actions when the BIO type changes. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   729
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   730
	CSendAs will not change the BIO type if this function leaves.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   731
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   732
	The default implementation is to do nothing. 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   733
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   734
	@param aBioTypeUid New value for the BIO field
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   735
	@see CSendAs::SetBioTypeL() */
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   736
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   737
	//The default implementation is to do nothing.
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
Gets the default MTM service.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   742
 	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   743
The default implementation is to assume the MTM only supports one service so finds the
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   744
first service associated with this MTM and returns that.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   745
 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   746
@return
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   747
The default service
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   748
 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   749
@leave 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   750
KErrNotFound If no service has been created.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   751
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   752
EXPORT_C TMsvId CBaseMtm::DefaultServiceL() const
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   753
 	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   754
    // Create a new entry, showing invisible entries (because the service entry may be invisible)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   755
    TMsvSelectionOrdering ordering(KMsvNoGrouping, EMsvSortByNone, ETrue);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   756
    CMsvEntry* entry = CMsvEntry::NewL(iSession, KMsvRootIndexEntryId, ordering);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   757
    CleanupStack::PushL(entry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   758
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   759
 	CMsvEntrySelection *sel=entry->ChildrenWithMtmL(iRegisteredMtmDll.MtmTypeUid());
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   760
	CleanupStack::PushL(sel);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   761
	if(sel->Count() == 0)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   762
	    {
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   763
	    User::Leave(KErrNotFound);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   764
	    } 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   765
	TMsvId service=sel->At(0);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   766
 	CleanupStack::PopAndDestroy(2,entry);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   767
	return service;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   768
 	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   769
 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   770
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   771
Removes the default service setting. The default implementation of this function assumes
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   772
that the MTM only supports one service and therefore this does nothing.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   773
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   774
EXPORT_C void CBaseMtm::RemoveDefaultServiceL()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   775
 	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   776
 	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   777
 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   778
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   779
Sets the default MTM service. The default implementation of this function assumes that
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   780
the MTM only supports one service and therefore this does nothing.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   781
 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   782
@param	aService
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   783
The default service
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   784
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   785
EXPORT_C void CBaseMtm::ChangeDefaultServiceL(const TMsvId& /*aService*/)
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
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   790
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   791
Returns a pointer to the interface with the specified Uid.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   792
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   793
This method is the first part of an extension pattern to allow for 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   794
more functionality to be supported without adding virtual methods 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   795
to this base class.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   796
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   797
The default implementation returns a NULL pointer.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   798
 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   799
@param	aUid  
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   800
Uid of the extension interface
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   801
@return
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   802
Pointer to the extension interface
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   803
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   804
EXPORT_C TAny* CBaseMtm::GetInterface(TUid /*aUid*/)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   805
 	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   806
	return NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   807
 	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   808
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   809
/** 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   810
Sets the character encoding value. The character encoding value options are 7-bit,
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   811
8-bit and 16-Bit Unicode. By default the character set encoding is 7 bit encoding.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   812
@param	aCharSet	Character encoding value may be 7-bit/8-bit/16-bit Unicode.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   813
@return KErrNone	If charset is changed successfully in SMS settings.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   814
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   815
   
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   816
EXPORT_C TInt CBaseMtm::SetMessageCharacterSet(TUint aCharSet)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   817
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   818
	TAny* ptrNull=NULL;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   819
	return Extension_(KUIDCharacterSet,ptrNull,&aCharSet);		
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   820
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   821
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   822
/**
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   823
The default Extension service. The default implementation of this function assumes that
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   824
the new service for setting the charset encoding value for a SMS message is not 
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   825
supported. TAny* is equivalent to void*.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   826
@param	a0				 			The collective parameters of TAny*
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   827
@param	a1				 			The collective parameters of TAny*,Charset encoding value is actually extracted from a1.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   828
@param aExtensionId 	 			Uid of the extension interface
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   829
@return KErrExtensionNotSupported 	If the message is other than SMS.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   830
@return Other 			 			Standard system-wide error codes.
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   831
*/
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   832
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   833
EXPORT_C TInt CBaseMtm::Extension_(TUint aExtensionId, TAny *&a0, TAny *a1)	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   834
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   835
	TInt ret = KErrNone;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   836
	switch(aExtensionId)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   837
		{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   838
		case KUIDCharacterSet:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   839
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   840
			ret = KErrExtensionNotSupported;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   841
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   842
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   843
		default:
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   844
			{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   845
			// Chain to base class
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   846
			ret = CBase::Extension_(aExtensionId,a0,a1);
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   847
			}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   848
			break;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   849
		}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   850
	return ret;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   851
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   852
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   853
//if passed value is NULL, its as good as reset extention data
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   854
EXPORT_C void CBaseMtm::SetExtensionData(TAny* aSortData)
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   855
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   856
	iExtensionData=aSortData;	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   857
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   858
	
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   859
EXPORT_C TAny* CBaseMtm::GetExtensionData()
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   860
	{
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   861
	return iExtensionData;
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   862
	}
db3f5fa34ec7 201044_02
hgs
parents:
diff changeset
   863