failed to send mms

Login to reply to this topic.
Wed, 2007-12-05 15:21
Joined: 2007-11-02
Forum posts: 37

Hi,
I have written the following code to send mms.But it does not work.
Also no error is there in emulator while the application is running.When closed, it shows panic KERN EXEC 3

In the phone-> the application crashes on the line
iMtm->CreateAttachment2L(
*store,
atch,
mimeType,
*mimeHeaders,
attaInfo,
aAttaId );
The code is------------------

xxxEngine.h
------------
class xxxEngine : public CBase, public MMsvSessionObserver
{
------
---------

private:
CMsvSession* iSession;
CClientMtmRegistry* iReg;
CMsvEntrySelection* iSelection;

}

xxxEngine.cpp
------------------------

void xxxEngine::HandleSessionEventL(TMsvSessionEvent aEvent,TAny* aArg1,TAny* aArg2,TAny* aArg3)
{
switch(aEvent)
{
case EMsvServerReady:
{

ServerReadyL();

TakeSnapsL();
}
break;
case EMsvEntriesCreated:
{
}
break;
case EMsvEntriesChanged:
{

}
break;
default:
{

}
break;
}
}

void xxxEngine::ServerReadyL()
{
TMsvId serviceId(KUidMsgTypeSMS.iUid);
TBuf8<20> progress;//progres is created on the stack.
iSession->ServiceProgress(serviceId,progress);
_LIT8(KCompare,"KErrNone");
if(progress.Compare(KCompare))
{
HBufC* buf=StringLoader::LoadLC(R_SMS_SERVER_SESSION);
CAknInformationNote* info=new (ELeave)CAknInformationNote;
info->ExecuteLD(*buf);
CleanupStack::PopAndDestroy(buf);
if(!iReg)
{
iReg=CClientMtmRegistry::NewL(*iSession);
((xxxAppUi*)CCoeEnv::Static()->AppUi())->setMtmRegistry(iReg);

}
}
else
{
HBufC* buf=StringLoader::LoadLC(R_SMS_SESSION_ERROR);
CAknInformationNote* info=new (ELeave)CAknInformationNote;
info->ExecuteLD(*buf);
CleanupStack::PopAndDestroy(buf);
}
}

void xxxEngine::TakeSnapsL()
{
((xxxAppUi*)CCoeEnv::Static()->AppUi())->setSnapTaker(xxxSnapTaker::NewL());
}

xxxSnaptaker.cpp
------------------------------
purpose is to take image
this class works fine and takes image
saves image in xxxFileEncoder

xxxFileEncoder.cpp
------------------------------
is an active object
saves image
works fine
inside its RUNL()----à
void xxxFileEncoder::RunL()
{
((xxxAppUi*)(CCoeEnv::Static()->AppUi()))->setMMS(xxxMMSSender::NewL());
}

xxxMMSSender.h
CMsvSession* iSession;
CClientMtmRegistry* iReg;
CMsvEntrySelection* iSelection;
CMsvOperation* iOp;

CMmsClientMtm* iMtm;
TBuf16<20> iNumber;
TBuf16<50> iFile;

xxxMMSSender.cpp
#include "xxxMMSSender.h"
#include "xxxAppUi.h"
#include
//#include
#include
#include
#include

class xxxAppUi;
_LIT(KNumber,"9886010928");
_LIT(KFile,"file.jpg");
_LIT(KMessageSubject, "MMS Example");

#define KPhoneRootPath PathInfo::PhoneMemoryRootPath()
#define KImagesPath PathInfo::ImagesPath()

xxxMMSSender::xxxMMSSender() : CActive( EPriorityStandard ), // Standard priority
iReg(((xxxAppUi*)(CCoeEnv::Static()->AppUi()))->getMtmRegistry()),
iNumber(KNumber),
iFile(KPhoneRootPath)

{
iFile.Append(KImagesPath);
iFile.Append(KFile);
}

xxxMMSSender* xxxMMSSender::NewLC()
{
xxxMMSSender* self = new ( ELeave ) xxxMMSSender();
CleanupStack::PushL( self );
self->ConstructL();
return self;
}

xxxMMSSender* xxxMMSSender::NewL()
{
xxxMMSSender* self = xxxMMSSender::NewLC();
CleanupStack::Pop(); // self;
return self;
}

void xxxMMSSender::ConstructL()
{

TMsvAttachmentId aAttaId;
iMtm=STATIC_CAST(CMmsClientMtm*,iReg->NewMtmL(KUidMsgTypeMultimedia));
iMtm->SwitchCurrentEntryL(KMsvDraftEntryId);
iMtm->CreateMessageL(iMtm->DefaultServiceL());

iMtm->AddAddresseeL(iNumber);
iMtm->SetSubjectL(KMessageSubject);

iMtm->SetMessagePriority(EMmsPriorityHigh);
//Save the changes
iMtm->SaveMessageL();

CMsvStore* store = iMtm->Entry().EditStoreL();
CleanupStack::PushL(store);

TFileName afl(iFile);
RFile atch;
TInt err=atch.Open(CCoeEnv::Static()->FsSession(),afl,EFileShareReadersOnly|EFileRead);
CleanupClosePushL(atch);

if(err != KErrNone)
{
//_LIT(KFileNotFound, "Attachment file not found!");

atch.Close();
CleanupStack::PopAndDestroy(&atch);
CleanupStack::PopAndDestroy(store);
//return EFalse;
}
else
{

// Mime header
CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
CleanupStack::PushL(mimeHeaders);
mimeHeaders->SetSuggestedFilenameL(iFile);

// Represents a single attachment and information about the attachment
CMsvAttachment* attaInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
CleanupStack::PushL(attaInfo);

// Mime Type
_LIT8(KMimeType, "image/jpeg");
TBufC8<10> mimeType(KMimeType);

// Attachment file must be in a public folder (e.g. c:\Data\images)
iMtm->CreateAttachment2L(
*store,
atch,
mimeType,
*mimeHeaders,
attaInfo,
aAttaId );
_LIT(KMsg,"inside MMS Sender");//PROGRAM CRASHES HERE
-
-
-
-
-
-
CConsoleBase* gConsole=Console::NewL(KMsg,TSize(80,80));
CleanupStack::PushL(gConsole);
gConsole->ClearScreen();
gConsole->Printf(KMsg);
gConsole->Getch();
CleanupStack::PopAndDestroy(gConsole);
CleanupStack::Pop(attaInfo); // attaInfo
CleanupStack::PopAndDestroy(mimeHeaders); // mimeHeaders

// If a SMIL file is attached for presentation layout purposes
// then it should be done here before the
// the changes are committed

// Commit the changes and perform the appropriate cleanup
store->CommitL();
atch.Close();

CleanupStack::PopAndDestroy(&atch);
CleanupStack::PopAndDestroy(store);

// Save the changes
iMtm->SaveMessageL();

}

TMsvEntry ent=iMtm->Entry().Entry();
ent.SetInPreparation(EFalse);
ent.SetVisible(ETrue);
iMtm->Entry().ChangeL(ent);
iMtm->SaveMessageL();

iOp=iMtm->SendL(iStatus);
SetActive();

}

xxxMMSSender::~CCameraControlMMSSender()
{
Cancel(); // Cancel any request, if outstanding
// Destroy the RTimer object
// Delete instance variables if any
if(iMtm)
{
delete iMtm;
iMtm=NULL;
}
if(iOp)
{
delete iOp;
iOp=NULL;
}
}

void xxxMMSSender:oCancel()
{

}

void xxxMMSSender::RunL()
{

}

TInt xxxMMSSender::RunError( TInt aError )
{
return aError;
}


Wed, 2007-12-05 18:02
Joined: 2007-11-02
Forum posts: 37
Re: failed to send mms

I Think The variable
TMsvAttachmentId aAttaId
is not properly initialised.
Can someone write wahat would be the most appropriate value to initialise this to??

  • Login to reply to this topic.