×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    27

    [moved] Empty SMS message obtained

    Hi,

    I got any empty SMS message when i tried sending out the parsed .xml output as SMS. The .xml is in UTF8. I tried detecting the length of the message, but it returns a 0. Pls help. I've no idea where went wrong. Thks.

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Empty SMS message obtained

    Sorry but Can you be more specific, from your post can't make out what is your problem.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    27

    Re: Empty SMS message obtained

    Hi Skumar_rao

    Sorry for the vague description. My problem is:

    I'm using the HTTP get request source code from S60 nokia forum. The get request returns a .xml document as the uri is in the format of .xml. With this .xml document, i tried finding the length of the entire .xml message by using Length().

    With the length returned as TInt position = aMsg.Length(); where aMsg stores the entire .xml message, i did the following:

    TBuf<900> iconvert;
    iconvert.AppendNum(position);
    SendsmsL(iconvert); SMS was successfully sent out, but a length of 0 is sent.

    I'm not sure where went wrong as the length of the .xml message should not be 0. Hope this is clearer.

  4. #4
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Empty SMS message obtained

    looks like your file handler (RFs) is not working properly. can you show use how you used your RFs

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    27

    Re: Empty SMS message obtained

    Hi Skumar_rao,

    Here is my ClientEngine.cpp code. The get request commences once the user presses the get command from the keypad.

    void CClientEngine::IssueHTTPGetL(const TDesC8& aUri)
    {
    // Parse string to URI (as defined in RFC2396)
    TUriParser8 uri;
    uri.Parse(aUri);
    TBuf8<KDefaultBufferSize> storeuri;
    storeuri.Copy(KGetUri);

    // Create HTTP connection
    TRAPD(err, SetupConnectionL());
    // User didn't select an IAP
    if (err == KErrNotReady) {
    HBufC* resTxCancelled = StringLoader::LoadLC(R_HTTP_TX_CANCELLED);
    iObserver.ClientEvent(*resTxCancelled);
    CleanupStack::PopAndDestroy(resTxCancelled);
    return;
    }

    // Get request method string for HTTP GET
    RStringF method = iSession.StringPool().StringF(HTTP::EGET,
    RHTTPSession::GetTable());

    // Open transaction with previous method and parsed uri. This class will
    // receive transaction events in MHFRunL and MHFRunError.
    icount = 0;
    iTransaction = iSession.OpenTransactionL(uri, *this, method);

    // Set headers for request; user agent and accepted content type
    RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
    SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
    SetHeaderL(hdr, HTTP::EAccept, KAccept);

    // Submit the transaction. After this the framework will give transaction
    // events via MHFRunL and MHFRunError.
    iTransaction.SubmitL();

    iRunning = ETrue;
    HBufC* resConnecting = StringLoader::LoadLC(R_HTTP_CONNECTING);
    iObserver.ClientEvent(*resConnecting);
    CleanupStack::PopAndDestroy(resConnecting);

    }

    void CClientEngine::MHFRunL(RHTTPTransaction aTransaction,
    const THTTPEvent& aEvent)
    {

    switch (aEvent.iStatus)
    {
    case THTTPEvent::EGotResponseHeaders:
    {
    // HTTP response headers have been received. Use
    // aTransaction.Response() to get the response. However, it's not
    // necessary to do anything with the response when this event occurs.

    // Get HTTP status code from header (e.g. 200)
    RHTTPResponse resp = aTransaction.Response();
    TInt status = resp.StatusCode();

    // Get status text (e.g. "OK")
    TBuf<KStatustextBufferSize> statusText;
    statusText.Copy(resp.StatusText().DesC());

    HBufC* resHeaderReceived = StringLoader::LoadLC(R_HTTP_HEADER_RECEIVED, statusText, status);
    iObserver.ClientEvent(*resHeaderReceived);
    CleanupStack::PopAndDestroy(resHeaderReceived);
    }
    break;

    case THTTPEvent::EGotResponseBodyData:
    {
    // Part (or all) of response's body data received. Use
    // aTransaction.Response().Body()->GetNextDataPart() to get the actual
    // body data.

    // Get the body data supplier
    MHTTPDataSupplier* body = aTransaction.Response().Body();
    TPtrC8 dataChunk;
    // Convert 8-bit aText to 16-bit and append it to end of output window
    HBufC* tempBuf1 = HBufC::NewL(dataChunk.Length());
    CleanupStack::PushL(tempBuf1);
    tempBuf1->Des().Copy(dataChunk);

    TPtrC ptr = *tempBuf1;
    //iMessage = ptr;
    imsg.Append(ptr);

    CleanupStack::PopAndDestroy();


    // GetNextDataPart() returns ETrue, if the received part is the last
    // one.
    TBool isLast = body->GetNextDataPart(dataChunk);
    iObserver.ClientBodyReceived(dataChunk);

    HBufC* resBytesReceived = StringLoader::LoadLC(R_HTTP_BYTES_RECEIVED, dataChunk.Length());
    iObserver.ClientEvent(*resBytesReceived);
    CleanupStack::PopAndDestroy(resBytesReceived);

    // NOTE: isLast may not be ETrue even if last data part received.
    // (e.g. multipart response without content length field)
    // Use EResponseComplete to reliably determine when body is completely
    // received.
    if (isLast)
    {

    HBufC* resBodyReceived = StringLoader::LoadLC(R_HTTP_BODY_RECEIVED);
    iObserver.ClientEvent(*resBodyReceived);
    CleanupStack::PopAndDestroy(resBodyReceived);

    }

    // Always remember to release the body data.
    body->ReleaseData();

    }
    break;

    case THTTPEvent::EResponseComplete:
    {
    // Indicates that header & body of response is completely received.
    // No further action here needed.
    HBufC* resTxComplete = StringLoader::LoadLC(R_HTTP_TX_COMPLETE);
    iObserver.ClientEvent(*resTxComplete);
    CleanupStack::PopAndDestroy(resTxComplete);
    }
    break;

    case THTTPEvent::ESucceeded:
    {
    // Indicates that transaction succeeded.
    HBufC* resTxSuccessful = StringLoader::LoadLC(R_HTTP_TX_SUCCESSFUL);
    iObserver.ClientEvent(*resTxSuccessful);
    CleanupStack::PopAndDestroy(resTxSuccessful);

    CheckL1(imsg);

    // Transaction can be closed now. It's not needed anymore.
    aTransaction.Close();
    iRunning = EFalse;



    }
    break;

    case THTTPEvent::EFailed:
    {
    // Transaction completed with failure.
    HBufC* resTxFailed = StringLoader::LoadLC(R_HTTP_TX_FAILED);
    iObserver.ClientEvent(*resTxFailed);
    CleanupStack::PopAndDestroy(resTxFailed);
    aTransaction.Close();
    iRunning = EFalse;

    }
    break;

    default:
    // There are more events in THTTPEvent, but they are not usually
    // needed. However, event status smaller than zero should be handled
    // correctly since it's error.
    {
    if (aEvent.iStatus < 0)
    {
    HBufC* resNoInternetConnection = StringLoader::LoadLC(
    R_HTTP_NO_INTERNET_CONNECTION, aEvent.iStatus);
    iObserver.ClientEvent(*resNoInternetConnection);
    CleanupStack::PopAndDestroy(resNoInternetConnection);

    // Close the transaction on errors
    aTransaction.Close();
    iRunning = EFalse;

    }
    else
    {
    // Other events are not errors (e.g. permanent and temporary
    // redirections)
    HBufC* resUnrecognisedEvent = StringLoader::LoadLC(
    R_HTTP_UNRECOGNISED_EVENT, aEvent.iStatus);
    iObserver.ClientEvent(*resUnrecognisedEvent);
    CleanupStack::PopAndDestroy(resUnrecognisedEvent);

    }
    }
    break;
    }
    }


    void CClientEngine::CheckL1(const TDesC& aMsg)
    {
    ilength1 = aMsg.Length();
    TBuf<500> icopy1;
    icopy1.AppendNum(ilength1);
    SendmessageL(icopy1);
    }

    void CClientEngine::SendmessageL(const TDesC& aMsg)
    {
    TBuf<500> itext;
    TBuf<500> iNum;
    iNum.Copy(_L("+1234456"));
    itext.Copy(aMsg);
    iSMS->SendSmsL(iNum, itext);
    }


    // ----------------------------------------------------------------------------
    // CClientEngine::MHFRunError()
    //
    // Inherited from MHTTPTransactionCallback
    // Called by framework when *leave* occurs in handling of transaction event.
    // These errors must be handled, or otherwise HTTP-CORE 6 panic is thrown.
    // ----------------------------------------------------------------------------
    TInt CClientEngine::MHFRunError(TInt aError,
    RHTTPTransaction /*aTransaction*/,
    const THTTPEvent& /*aEvent*/)
    {
    // Just notify about the error and return KErrNone.
    HBufC* resMHFRunError = StringLoader::LoadLC(R_HTTP_MHFRUN_ERROR, aError);
    iObserver.ClientEvent(*resMHFRunError);
    CleanupStack::PopAndDestroy(resMHFRunError);
    return KErrNone;
    }


    // ----------------------------------------------------------------------------
    // CClientEngine::GetNextDataPart()
    //
    // Inherited from MHTTPDataSupplier
    // Called by framework when next part of the body is needed. In this
    // this provides data for HTTP post.
    // ----------------------------------------------------------------------------
    TBool CClientEngine::GetNextDataPart(TPtrC8& aDataPart)
    {
    if(iPostData)
    {
    // Provide pointer to next chunk of data (return ETrue, if last chunk)
    // Usually only one chunk is needed, but sending big file could require
    // loading the file in small parts.
    aDataPart.Set(iPostData->Des());
    }
    return ETrue;
    }


    // ----------------------------------------------------------------------------
    // CClientEngine::ReleaseData()
    //
    // Inherited from MHTTPDataSupplier
    // Called by framework. Allows us to release resources needed for previous
    // chunk. (e.g. free buffers)
    // ----------------------------------------------------------------------------
    void CClientEngine::ReleaseData()
    {
    // It's safe to delete iPostData now.
    delete iPostData;
    iPostData = NULL;
    }

    // ----------------------------------------------------------------------------
    // CClientEngine::Reset()
    //
    // Inherited from MHTTPDataSupplier
    // Called by framework to reset the data supplier. Indicates to the data
    // supplier that it should return to the first part of the data.
    // In practise an error has occured while sending data, and framework needs to
    // resend data.
    // ----------------------------------------------------------------------------
    TInt CClientEngine::Reset()
    {
    // Nothing needed since iPostData still exists and contains all the data.
    // (If a file is used and read in small parts we should seek to beginning
    // of file and provide the first chunk again in GetNextDataPart() )
    return KErrNone;
    }

Similar Threads

  1. NSM EMS (SMS with picture) not working in Nokia E Series (E50)
    By tulio.duarte in forum General Messaging
    Replies: 0
    Last Post: 2008-03-25, 19:35
  2. Sms porting problem
    By Ikhtys in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2007-12-05, 10:05
  3. Replies: 4
    Last Post: 2005-08-03, 11:21
  4. Replies: 3
    Last Post: 2005-07-22, 02:35
  5. Identification of SMS (Service Message)
    By engrsanjiv in forum Symbian
    Replies: 0
    Last Post: 2003-05-19, 07:22

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×