×

Discussion Board

Page 1 of 7 1234567 LastLast
Results 1 to 15 of 100
  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    26

    Retrieving caller number again. I'm going crazy!

    Hello everyone,
    I'm trying (and keep trying) to retrieve the caller number from incoming call. But I still can't do it. When incoming call arrive, it show blank information note then the application crash. I'm going crazy now. Could you help me please.... Here is my code, please guide me and show me where I'm doing wrong:

    ///////////////////////////////////////
    // ActiveIncomingCallObserver.cpp //
    ///////////////////////////////////////

    #ifndef __ACTIVEINCOMINGCALLOBSERVER__
    #define __ACTIVEINCOMINGCALLOBSERVER__

    #include <etel.h>
    #include <EIKENV.H>

    #include "IncomingCallObserverInterface.h"
    #include "IncomingCallObserver.h"

    #include <e32base.h>

    //tel num
    #include <logcli.h>
    #include <logview.h>
    #include <f32file.h>
    #include <logwrap.h>
    #include <e32svr.h>
    #include <aknnotewrappers.h>



    class CActiveIncomingCallObserver : public CActive
    {
    public:
    CActiveIncomingCallObserver(MIncomingCallObserverInterface* aObserver);
    ~CActiveIncomingCallObserver();
    void ConstructL();
    void StartObserver();

    public:
    CLogViewRecent* iRecentLogView;
    RFs iFs;
    CLogClient* iLogClient;
    //void GetLatest();

    private:
    virtual void DoCancel();
    virtual void RunL();

    private:
    TInt InitializePhone();
    void ReleasePhone();

    private:
    MIncomingCallObserverInterface* iObserver;

    RCall::TStatus iCallStatus;
    TName iName;

    TBool iLineInited;
    TBuf <40> iTsyName;
    RTelServer iTelServer;
    RPhone iPhone;
    RLine iLine;

    TBool iCallActive;
    RCall iCall;

    };
    #endif


    ////////////////////////////////////
    // ActiveIncomingCallObserver.cpp //
    ////////////////////////////////////

    #include "ActiveIncomingCallObserver.h"
    #include <apgtask.h>
    #include <aknnotewrappers.h>

    CActiveIncomingCallObserver::CActiveIncomingCallObserver(MIncomingCallObserverInterface* aObserver)
    : CActive(0)
    {
    iObserver = aObserver;
    iLineInited = EFalse;
    iCallActive = EFalse;
    }

    CActiveIncomingCallObserver::~CActiveIncomingCallObserver()
    {
    // Cancel any request, if outstanding
    if (IsActive())
    {
    Cancel();
    }
    else
    {
    ReleasePhone();
    }
    }

    void CActiveIncomingCallObserver::ConstructL()
    {
    CActiveScheduler::Add(this);
    }

    void CActiveIncomingCallObserver:oCancel()
    {
    ReleasePhone();
    //iRecentLogView->Cancel();
    }

    void CActiveIncomingCallObserver::RunL()
    {
    if (iStatus == KErrNone)
    {
    if (iCallActive)
    {
    // We are polling for the RCall status
    if (iCallStatus == RCall::EStatusHangingUp || iCallStatus == RCall::EStatusIdle || iCallStatus == RCall::EStatusUnknown)
    {
    iCallActive = EFalse;
    iCall.Close();
    iLine.NotifyIncomingCall(iStatus, iName);
    if (iObserver)
    {
    iObserver->IncomingCallObserverInterface_HandleItL();
    }
    }
    else
    {

    iCallActive = EFalse;
    iCall.NotifyStatusChange(iStatus, iCallStatus);
    User::WaitForRequest(iStatus);
    }
    //GetLatest();
    }
    else
    {
    // There's an incoming call!
    iCallActive = ETrue;
    iCall.OpenExistingCall(iLine, iName);

    // I add my function here to answer then hanging up
    iCall.AnswerIncomingCall (iStatus);
    User::WaitForRequest(iStatus);

    iCall.NotifyStatusChange(iStatus, iCallStatus);
    User::WaitForRequest(iStatus);
    iCall.HangUp(iStatus);
    User::WaitForRequest(iStatus);

    // Here I add codes for retrieving caller number
    iFs.Connect();
    iLogClient = CLogClient::NewL(iFs);
    iRecentLogView = CLogViewRecent::NewL(*iLogClient);
    iRecentLogView->SetRecentListL(KLogNullRecentList,iStatus);
    User::WaitForRequest(iStatus);
    TBuf<20> iTelNumber;
    const CLogEvent& event = iRecentLogView->Event();
    iTelNumber.Copy(event.Number());
    CAknInformationNote *notify=new (ELeave) CAknInformationNote;
    notify->ExecuteLD(iTelNumber);

    iCall.NotifyStatusChange(iStatus, iCallStatus);
    }
    // And we re-enable the polling
    SetActive();
    }
    }

    void CActiveIncomingCallObserver::StartObserver()
    {
    // Just in case - but we should not need it!
    Cancel();
    if (InitializePhone() == KErrNone)
    {
    // Tells scheduler a request is active
    SetActive();
    }
    }

    TInt CActiveIncomingCallObserver::InitializePhone()
    {
    TInt theError;
    if (iLineInited)
    {
    return KErrNone;
    }
    theError = iTelServer.Connect();
    if (theError)
    {
    return theError;
    }
    // Find the number of phones available from the tel server
    TInt numberPhones;
    theError = iTelServer.EnumeratePhones(numberPhones);
    if (theError)
    {
    iTelServer.Close();
    return theError;
    }
    // Check there are available phones
    if (numberPhones < 1)
    {
    iTelServer.Close();
    return KErrNotFound;
    }
    // Read the TSY module name
    theError = iTelServer.GetTsyName(0, iTsyName);
    if (theError != KErrNone)
    {
    iTelServer.Close();
    return theError;
    }
    // Load in the phone device driver
    theError = iTelServer.LoadPhoneModule(iTsyName);
    if (theError)
    {
    iTelServer.Close();
    return theError;
    }
    // Get info about the first available phone
    RTelServer::TPhoneInfo info;
    theError = iTelServer.GetPhoneInfo(0, info);
    if (theError)
    {
    iTelServer.UnloadPhoneModule(iTsyName);
    iTelServer.Close();
    return theError;
    }
    // Use this info to open a connection to the phone, the phone is identified by its name
    theError = iPhone.Open(iTelServer, info.iName);
    if (theError)
    {
    iTelServer.UnloadPhoneModule(iTsyName);
    iTelServer.Close();
    return theError;
    }
    // Get info about the first line from the phone
    RPhone::TLineInfo lineInfo;
    theError = iPhone.GetLineInfo(0, lineInfo);
    if (theError)
    {
    iPhone.Close();
    iTelServer.UnloadPhoneModule(iTsyName);
    iTelServer.Close();
    return theError;
    }
    // Use this to open a line
    theError = iLine.Open(iPhone, lineInfo.iName);
    if (theError)
    {
    iPhone.Close();
    iTelServer.UnloadPhoneModule(iTsyName);
    iTelServer.Close();
    return theError;
    }
    iLine.NotifyIncomingCall(iStatus, iName);
    iLineInited = ETrue;

    return KErrNone;
    }

    void CActiveIncomingCallObserver::ReleasePhone()
    {
    if (iLineInited)
    {
    if (iCallActive)
    {
    iCall.NotifyStatusChangeCancel();
    iCall.Close();
    }
    else
    {
    iLine.NotifyIncomingCallCancel();
    }
    iLine.Close();
    iPhone.Close();
    iTelServer.UnloadPhoneModule(iTsyName);
    iTelServer.Close();
    iLineInited = EFalse;
    }
    }


    Thank you very much...


    Eric

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,168
    hi

    I would get rid of all User::WaitForRequest() function and implement them in Active Object as well, maybe you also want to put the log reading into a different AO.

    The best would be that who ever owns the call monitoring AO is informed of the need to read the number and that same class would own the AO for log handling.

    Baiscally othervise you might end up having funny behaviour caused by some rase conditions and other timing issues.

    yucca

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    26
    Hello yucca,
    Many thanks for your reply. I tried to remove User::WaitForRequest(iStatus),
    but it made the application crash. So I added it again. But when I tried to find
    the error, it seems that function SetRecentListL make the application crash when try
    to open log engine. When I commented it, the application can show information note. But
    the information note did not contain phone number. It's blank.
    I tried another way by made the new class that derived from CActive (I try the code that chavasekhar give in this forum).
    But the application still crash when it tried to get caller id. So, what must I do. I'm very confuse.

    here is the code :

    GetCallerId.h
    =============
    #ifndef __GetCallerId_H
    #define __GetCallerId_H

    #include <e32base.h>
    #include <logcli.h>
    #include <logview.h>
    #include <f32file.h>
    #include <logwrap.h>
    #include <e32svr.h>
    #include <aknnotewrappers.h>

    class CGetCallerId : public CActive
    {
    public:
    CLogViewRecent* iRecentLogView;
    RFs iFs;
    CLogClient* iLogClient;
    TBuf<20> iCallerID;

    CGetCallerId();
    ~CGetCallerId();
    virtual void RunL();
    virtual void DoCancel();
    void ConstructL();
    void GetLatest();
    static CGetCallerId* NewL();
    static CGetCallerId* NewLC();

    CLogViewEvent* logViewEvent;
    CLogClient* logClient;
    CLogFilterList* filterList;

    };

    #endif


    GetCallerId.cpp
    ===============
    #include "GetCallerId.h"
    #include <aknnotewrappers.h>

    CGetCallerId::CGetCallerId(): CActive(EPriorityStandard)
    {
    CActiveScheduler::Add(this);
    }

    CGetCallerId::~CGetCallerId()
    {
    CActive::Cancel(); // Causes call to DoCancel()

    }

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

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


    void CGetCallerId::RunL()
    {
    if( iStatus == KErrNone)
    {
    TBuf<20> iTelNumber;
    const CLogEvent& event = iRecentLogView->Event();
    iTelNumber.Copy(event.Number());
    }
    }

    void CGetCallerId::ConstructL()
    {
    // Connect to the Log Server
    iFs.Connect();
    iLogClient = CLogClient::NewL(iFs);
    iRecentLogView = CLogViewRecent::NewL(*iLogClient);
    }

    void CGetCallerId::GetLatest()
    {
    // Cancel any outstanding requests.
    iRecentLogView->Cancel();
    // Make a call into the Log server to get the latest call event.
    if( iRecentLogView->SetRecentListL(KLogNullRecentList,iStatus))
    {
    // Notify the Log server that we're ready
    SetActive();
    }
    }

    void CGetCallerId:oCancel()
    {
    CActive::Cancel();
    // Cancel any outstanding requests.
    iRecentLogView->Cancel();
    }


    to get id, I use this:
    CGetCallerId myId;
    myId.ConstructL();
    myId.GetLatest();


    Thank you very much...
    Eric

  4. #4
    Registered User
    Join Date
    Apr 2004
    Posts
    26
    Hello yucca,
    I was able to get the caller number from log. Thanks for your guide. But, I need to get the caller number while the phone is still ringging. For example, while phone is ringing because of incoming call from someone, I want to take that caller number.
    Can it be done with log engine? when the phone is still ringing, does the phone has write the caller number to its log?

    Regards,
    Eric

  5. #5
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,168
    At least with the test i did with the log engine, it only gets the number after answer, so I don't think it's possible.

    For OS 6.1 phones, you could see the Etelbgsm.h header, it allows you to see the number before answering.

    yucca

  6. #6
    Registered User
    Join Date
    Apr 2004
    Posts
    26

    I have found the solution

    Hey yucca,
    I have found the solution. I could catch the caller number while phone is still ringing. I use RAdvGsmCall.
    Thank you very very much for your help

    Regards,
    Eric

  7. #7
    Regular Contributor
    Join Date
    Aug 2003
    Posts
    64
    Hi Eric,

    I m having the same problem as u have faced earlier, but am not able to figure out how to use RAdvGsmCall.
    Can u provide some hints on how to use it??? as there is no document which I can rely on....

    Thanks
    Raja

  8. #8
    Registered User
    Join Date
    Apr 2004
    Posts
    6

    Application crashes

    I tried EricDrew's code, but the application consistently crashes on the emulator. I've transfered the code to the phone. The application crashes after RetrieveCalls(). It never starts RunL(). What do I need to modify to retrieve the Caller ID?

    This is my CPP file:

    CCallChecker::CCallChecker():CActive(EPriorityStandard)
    {
    }

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

    }

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


    void CCallChecker::ConstructL()
    {
    CActiveScheduler::Add(this);
    }

    CCallChecker::~CCallChecker()
    {
    CActive::Cancel();
    }

    void CCallChecker::RunL()
    {
    const CLogEvent& event = iRecentLogView->Event();

    TBuf<20> iTelNumber;
    iTelNumber.Copy(event.Number());

    CAknInformationNote* notify = new (ELeave) CAknInformationNote;
    notify->ExecuteLD(iTelNumber);

    }


    void CCallChecker:oCancel()
    {
    CActive::Cancel();
    iRecentLogView->Cancel();
    iLogClient->Cancel();
    iFs.Close();
    }


    void CCallChecker::RetrieveCalls()
    {
    iFs.Connect();
    iLogClient = CLogClient::NewL(iFs);
    iRecentLogView = CLogViewRecent::NewL(*iLogClient);

    CLogFilter* afilter = CLogFilter::NewL();
    if (!IsActive())
    {
    if (iRecentLogView->SetRecentListL(KLogNullRecentList, iStatus))
    {
    SetActive();
    }

    }
    }
    Last edited by chenhui; 2004-05-12 at 20:43.

  9. #9
    Registered User
    Join Date
    Mar 2003
    Posts
    35
    I can't find etalagsm.h in any of my Symbian platforms.

    Can anyone upload a zip file with all headers, requierd for using RAdvGsmCall class.

    Thanks in advance
    Eran

  10. #10
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,168
    I would again like to remaind people that you are propably not allowed to distribute copyrighted material .

    and using non-public API's is not recommended. Also the functions provided by Etelagsm.h are not really working in OS 7.0s.

    yucca

  11. #11
    Registered User
    Join Date
    Mar 2003
    Posts
    35
    Thanks Yucca,

    Do you know other way to receive the Caller ID?

    Thanks
    Eran

  12. #12
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,168
    you could utilize logs. Thou it's not really an ideal solution, but only solution that will work also in 7.0s phones.

    yucca

  13. #13
    Regular Contributor
    Join Date
    May 2004
    Location
    NRW/ Germany
    Posts
    188
    Hi,

    I'm also using the code of chavasekhar to get the caller id from the logs.
    Sadly I do not really know where to put the GetLatest() method to get it to work.

    If I use a Menu Button to call the method before the call comes in I get the caller id as it should be, but if I use the GetLatest anywhere else in my code the buffer for the number remains empty. I tried to put the GetLatest in ConstructL of my app or in my phone monitor but it doesn't work.

    Would be nice if I can get a little help, where to put it. I think Eric already solved the problem?

    Greetz

    Arne

    Another problem occured:
    The phone number is only read out once. I've tried a SetActive() again in the RunL method, but that chrashes the phone.

    I really need your help.

    Thank you in advance
    Last edited by ArneH; 2004-08-03 at 14:47.

  14. #14
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,168
    you basically should read thye number after you have answered the call, then it should work in all times (thou if you clock is changed it will take the one with most latest time stamp).

    Anyway for active objects read this: http://www.symbian.com/developer/tec...cts/active.htm

    Basically before calling setactive you'll need to set one request active.

    yucca

  15. #15
    Regular Contributor
    Join Date
    May 2004
    Location
    NRW/ Germany
    Posts
    188
    Another day in germany and I'm trying to figure it out.

    Thanks for your answer symbianyucca. I've already read the paper by Mr. Tasker, but still got problems to handle the active object. Need more training, I think.

    I'll let you know when it works.

    Arne

Posting Permissions

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