Push to talk !
Login to reply to this topic.
Mon, 2004-06-28 14:26
Joined: 2004-06-28
Forum posts: 2
Hi !

       i Hav developed a small MMS appln . This is locally storing the voice recorded in .wav format in the system at the location C:\symbian\7.0s\series60\epoc32\wins\c:\system\mail\00001000_s as an attachment . How do i retrieve this attachment to play . i am using the CMdaAudioRecorderUtility to record and play the voice .

Thu, 2004-07-01 10:38
Joined: 2004-06-28
Forum posts: 2
Hi Eric !
               plz reply to the query i sent , i am not able to get thru it. i want to retrieve the wav file sent as attachment n play it .

just look at the code :


CPoCReceiveHandler::CPoCReceiveHandler(CPoCAppUi& aAppUi):
    iAppUi(aAppUi)
    {
   // No implementation required
    }



CPoCReceiveHandler* CPoCReceiveHandler::NewL(CPoCAppUi& aAppUi)
    {
    CPoCReceiveHandler* self = CPoCReceiveHandler::NewLC(aAppUi);
    CleanupStack::Pop();
    return self;
    }


CPoCReceiveHandler* CPoCReceiveHandler::NewLC(CPoCAppUi& aAppUi)
    {
    CPoCReceiveHandler* self = new (ELeave) CPoCReceiveHandler(aAppUi);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }


void CPoCReceiveHandler::ConstructL()
{


    // Create CMsvSession
    iMsgSession = CMsvSession::OpenAsyncL(*this); // new session is opened asynchronously
                                               // CompleteConstructL() is called when async finishes
   

}



/*
-----------------------------------------------------------------------------

    CPoCExampleAppUi::CompleteConstructL()

    Creates client MTM registry when session is ready for use.
    This completes model construction and is called after 'server
    ready' event is received after async opening of CMsvSession.

-----------------------------------------------------------------------------
*/

void CPoCReceiveHandler::CompleteConstructL()
    {
    // We get a MtmClientRegistry from our session
    // this registry is used to instantiate new mtms.
    iMtmReg = CClientMtmRegistry::NewL(*iMsgSession);
    iMmsMtm = (CMmsClientMtm*) iMtmReg->NewMtmL( KUidMsgTypeMultimedia );

    // notify the user with a InfoWin (this will be shown in emulator only)
    // iEikonEnv->InfoMsg(_L("Server session opened."));
    }




CPoCReceiveHandler:: ~CPoCReceiveHandler()
{

}



/*
-------------------------------------------------------------------------------------------------
   Receives session events from observer and calls event handling functions.
    Note that if additional session event handlers are defined
    in the session, they are called before this function (as this is the
    main session observer).

    The type of event is indicated by the value of aEvent. The
    interpretation of the TAny arguments depends on this type. For most
    event types, the action that is taken, for example updating the
    display, is client-specific. All clients though should respond to
    EMsvCloseSession and EMsvServerTerminated events.
-------------------------------------------------------------------------------------------------
*/

 void CPoCReceiveHandler::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
    {
    switch (aEvent)
        {
            // This event tells us that the session has been opened
        case EMsvServerReady:
            CompleteConstructL();       // Construct the mtm registry & MMS mtm
            break;
        case EMsvEntriesCreated:
         {
         TMsvId* parentId;
         //parent id from the session event
          parentId = static_cast<TMsvId*>(aArg2);
        //new entry has been created in in outbox folder
            if(*parentId == KMsvGlobalOutBoxIndexEntryId)
      {   
            //we take the created entries into selection
            CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
         //entry pointer for making changes in the actual message contexts
         CMsvEntry* entry ;
          for (TInt i=0; i < entries->Count(); i++)
          {
             //this reserves memory for a new CMsvEntry
               entry = iMsgSession->GetEntryL( entries->At(i) );
               CleanupStack::PushL(entry);
                   //Manipulate the entry
               CleanupStack::PopAndDestroy(entry);
          }

         }
   
         }
            break;

         case EMsvEntriesChanged:        // A new entry has been created in the message server
            {
            // We are interested in messages that are created in Inbox
            TMsvId* entryId = static_cast<TMsvId*>(aArg2);          // entry id from the session event
           
            if (*entryId == KMsvGlobalOutBoxIndexEntryId)  // new entry has been created in Outbox folder
                {
                // We take the created entries into a selection
                CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);

                //Process each created entry, one at a time.
                for(TInt i = 0; i < entries->Count(); i++)
                    {
                    MessageReceivedL(entries->At(i)); // this checks the entry and handles it if it is targeted to SMS app                
                    }
                }
            }
            break;
      
      
      
      default:
            // All other events are ignored
            break;
        }

    }


void CPoCReceiveHandler::MessageReceivedL(TMsvId aEntryId)
    {
    // Load this entry to our mtm
     iMmsMtm->SwitchCurrentEntryL(aEntryId);
    iMmsMtm->LoadMessageL();

    TMsvEntry msvEntry = iMmsMtm->Entry().Entry();
 
   TMsvSelectionOrdering sort;
     sort.SetShowInvisibleEntries(ETrue);
    //take a handle to the folder entry
    CMsvEntry* parentEntry = CMsvEntry::NewL(*iMsgSession,KMsvGlobalOutBoxIndexEntryId,sort);
   
    CleanupStack::PushL(parentEntry);
 
     //A selection of all MMS entries

      CMsvEntrySelection* entries = parentEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
     
        //get presentation root attachment  
      TMsvId rootId = iMmsMtm->MessageRoot();
     
      //get attachment file path
      TFileName attachNamePath;
     
     TRAPD(error , iMmsMtm->GetAttachmentPathL(rootId,attachNamePath));
     
     
             
//       TDesC16& path = iMmsMtm->GetAttachmentPathByCidL(CID,attachNamePath);
     
//      KRecorderFile = path;


         iMdaAudioRecorderUtility->OpenFileL(KRecorderFile);
           iMdaAudioRecorderUtility->PlayL();  
     
         CleanupStack::PushL(entries);


    // go thru the selection and delete
/*
     for ( TInt i= 0 ; i < entries->Count(); i++)
    {

       parentEntry->DeleteL((*entries)[i]);

     }*/

    CleanupStack::PopAndDestroy(2);


}

copyright 2003-2009 NewLC SARL