mobilemessaging/smsmtm/clientmtm/src/SMSCLNT.CPP
changeset 23 238255e8b033
parent 0 72b543305e3a
child 47 5b14749788d7
--- a/mobilemessaging/smsmtm/clientmtm/src/SMSCLNT.CPP	Tue Feb 02 00:08:43 2010 +0200
+++ b/mobilemessaging/smsmtm/clientmtm/src/SMSCLNT.CPP	Fri Apr 16 14:56:15 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1999-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -238,8 +238,18 @@
 			{
 			User::Leave(err);
 			}
-
-		iServiceId = 0;
+		TMsvEntry entry;
+		entry.iMtm = KUidMsgTypeSMS;
+	    entry.iType = KUidMsvServiceEntry;
+	    entry.SetReadOnly(EFalse);
+	    entry.SetVisible(EFalse);
+	    entry.iDate.UniversalTime();
+	    entry.iDetails.Set(_L("Default SMS Message"));
+    
+    	CMsvEntry* root = Session().GetEntryL(KMsvRootIndexEntryId);
+	    root->CreateL(entry);
+	   	iServiceId = entry.Id();
+	   	delete root;
 		}
 
 	//Initialise iRealAddressOpen and iRealAddressClose from the SMS resouce file
@@ -819,20 +829,13 @@
 	{
 	__ASSERT_DEBUG(iMsvEntry,Panic(ESmscEntryNotSet));
 
-	RestoreServiceAndSettingsL();
-
-	ResetHeader();
-	Body().Reset();
 	CMsvStore* msvstore=iMsvEntry->ReadStoreL();
 	CleanupStack::PushL(msvstore);
 	switch (iMsvEntry->Entry().iType.iUid)
 		{
 		case KUidMsvServiceEntryValue:
 			{
-			CSmsAccount* account = CSmsAccount::NewLC();
-			// just v2
-			account->LoadSettingsL(*iServiceSettings);
-			CleanupStack::PopAndDestroy(account);    
+			RestoreServiceAndSettingsL();
 			break;
 			}
 		case KUidMsvFolderEntryValue:
@@ -841,6 +844,9 @@
 			}
 		case KUidMsvMessageEntryValue:
 			{
+			ResetHeader();
+			Body().Reset();
+			
 			CSmsHeader* smsheader=CSmsHeader::NewL(CSmsPDU::ESmsSubmit,Body());
 			CleanupStack::PushL(smsheader);
 			smsheader->RestoreL(*msvstore);
@@ -1539,6 +1545,45 @@
 		}
  	}
 
+
+
+/** 
+Creates a new outgoing SMS message entry as a child of the current context.
+Used by CSendAs::CreateMessageL to create an outgoing SMS message.
+
+@param	
+The entry with the required fields set.
+
+*/
+EXPORT_C void CSmsClientMtm::CreateMessageL(TMsvEntry& aEntry)
+	{
+	RestoreServiceAndSettingsL();
+
+ 	aEntry.SetVisible(EFalse);
+ 	aEntry.SetInPreparation(ETrue);
+ 	aEntry.iDate.UniversalTime();
+ 	
+ 	// store entry in folder
+ 	iMsvEntry->CreateL(aEntry);
+ 	SwitchCurrentEntryL(aEntry.Id());
+ 	// End of fix
+
+	delete iSmsHeader;
+	iSmsHeader=NULL;
+	iSmsHeader=CSmsHeader::NewL(CSmsPDU::ESmsSubmit,Body());
+	iSmsHeader->SetSmsSettingsL(*iServiceSettings);
+
+	// service centre was not being set 
+	TInt defaultSC = iServiceSettings->DefaultServiceCenter();
+	if(defaultSC > -1)
+		{
+		if (iServiceSettings->ServiceCenterCount() > defaultSC )
+			{
+			iSmsHeader->SetServiceCenterAddressL( iServiceSettings->GetServiceCenter(defaultSC).Address() );	
+			}
+		}
+ 	}
+
 /**
 Resets the current SMS message.