×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 30
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    41

    How to obtain telephone number from call

    Hi,

    I've built an application that monitors incoming phone calls. I've built a CActive program that connects to the tel server, and waits for a status change on a line.
    This all works great. But when a phone call comes in, I want to pick up the incoming phone number.
    How do I do this ?

    thanks,

    Rich

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Philippines
    Posts
    208
    with the current telephony api you cannot get the mobile phone number,

    however, you can search in this forum, about using the log apis for a way around this,

    goodluck,

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    39
    Hi,

    The following code initializes the CLogViewRecent class:

    RFs iFs;
    CLogClient* iLogClient;
    CLogViewRecent* iRecentLogView;

    iFs.Connect();
    iLogClient = CLogClient::NewL(iFs);
    iRecentLogView = CLogViewRecent::NewL(*iLogClient);

    To get the latest log entry you use:

    iRecentLogView->SetRecentListL(KLogNullRecentList,iStatus);

    This is an asynchronous call and RunL is called once the call is over. In RunL you can read the latest event:

    const CLogEvent& event = iRecentLogView->Event();
    iTelNumber.Copy(event.Number());


    For answering incoming calls you have to derive your class from CActive and implement RunL. So when you you detect an incoming call you can call

    iRecentLogView->SetRecentListL(KLogNullRecentList,iStatus);

    to initialize the iRecentLogView with the latest events. The new one is the first one.

    Before that you can initialize the view in your ConstructL.

    Once SetRecentListL is complete RunL will be called again. At that time you can read the number in the first event.

    Hope this helps.

    Regards,
    Brijesh

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    41
    Thanks Brijesh for your prompt reply. I think I can manage to implement your code in my application.

    Best Regards,

    Rich

  5. #5
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Philippines
    Posts
    208
    Hello brijesh,

    do you know what RemoteParty() actually means? i'm thinking it will be filled up by the contact name if one is provided on the contacts database, but i am not sure.

    also, RemoteParty() is empty on SMS event? why?

    thanks,

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    39
    Hi Mickey,

    I have no clue what RemoteParty() returns. You could try it out and check whether it contains the name of the caller or not.

    Actually it would have been really great if RCall itself would tell you what the caller number is. I came across this issue of the date being changed to a previous date. After that a new call event would not be placed on Top, so when I read the event log for the latest one, I always get an older one. I guess one cant do much about this as the event log is always going to place events datewise. if a newer event has a date prior to an existing event then it is obviously going to be placed behind it.


    Thanks,
    Brijesh

  7. #7
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Philippines
    Posts
    208
    brijesh,

    RemotePArty contains the contact name from the contact database, if one is provided, otherwise it contains nothing.

    but i do not understand why on SMS event, it contains nothing even if the name is provided in the contact database.

    Also, CLogEvent::Id() always returns -1, calls or SMS,

    yes, i fixed the problem by storing the time when an event happens, (ie using Time::HomeTime() ) and then when the event is done, i used this time to browse on the log event for the first one which has the same time as the time i stored.

    I wish i could also check against the date but it's kinda not working,

  8. #8
    Regular Contributor
    Join Date
    Mar 2003
    Location
    India
    Posts
    63

    How to get the telephone number

    Hello Rich,

    Do you guys able to read the incoming telephone number? I want to read the incoming telephone number just after the call is terminated. This i want to read from logs.

    I am trying to identify the incoming call but always getting line status as 'Unknown'. Could you please send me the code to identify the incoming call, call termination and after terminating reading the recent log to find out the telephone number.

    Could any one of u guys send me the code?

    regards,
    rajasekhar

  9. #9
    Registered User
    Join Date
    Mar 2003
    Posts
    41
    Rajasekhar,

    Here's the code that I use in my application. I build the logViewer as a CActive object that gets constructed at application startup. Then whenever there's a phone call, my main thread makes a call to the function myLogViewer::GetLatest(). This causes the logViewer to start watching for the latest event. When the event occurs, it is the phone call event. The RunL function then opens the event log, and retrieves the phone information - this contains the phone number. Then the call back function in my main thread is called. Read about CActive and how to read and handle the event log. Its actually not too difficult to get to work.

    Best Regards,

    Rich

    #include <e32svr.h>
    #include <aknnotewrappers.h>
    #include "myLogViewer.h"
    #include "BS001appui.h"

    #if __WINS__
    #else


    myLogViewer* myLogViewer::NewL(MAsyncObserver& aObserver)
    {
    myLogViewer* self = NewLC(aObserver);
    CleanupStack::Pop();
    return(self) ;
    }

    myLogViewer* myLogViewer::NewLC(MAsyncObserver& aObserver)
    {
    myLogViewer* self = new (ELeave) myLogViewer(aObserver);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

    void myLogViewer::ConstructL()
    {
    CActiveScheduler::Add(this);

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

    myLogViewer::myLogViewer(MAsyncObserver& aObserver)
    : CActive(EPriorityStandard),iObserver(aObserver)
    {
    }

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


    void myLogViewer::CancelRequest()
    {
    CActive::Cancel(); // Causes call to DoCancel()
    }

    void myLogViewer::RunL()
    {
    /* We got a response back from the Log Server.
    * "event" now has the latest log listing. The newest will be the
    * first entry on the list.
    */
    if( iStatus == KErrNone)
    {
    TBuf<20> iTelNumber;
    const CLogEvent& event = iRecentLogView->Event();
    iTelNumber.Copy(event.Number());
    iObserver.HandlePhoneUpdate(eCallStart, iTelNumber );
    }

    }

    void myLogViewer:oCancel()
    {
    CActive::Cancel();

    // Cancel any outstanding requests.
    iRecentLogView->Cancel();
    }


    void myLogViewer::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();
    }

    }


    #endif // Only in NON WINS case

  10. #10
    Regular Contributor
    Join Date
    Mar 2003
    Location
    India
    Posts
    63

    E32USER-CBase 42

    Hi rich,

    Thanks for your response. Sorry for troubling you. i implemented your code in my helloworld application.

    This is my code:

    Header file:
    --------------
    #ifndef __GetCallerID_H
    #define __GetCallerID_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 CGetCallerId : public CActive
    {
    public:
    CLogViewRecent* iRecentLogView;
    RFs iFs;
    CLogClient* iLogClient;

    CGetCallerId();
    ~CGetCallerId();
    virtual void RunL();
    virtual void DoCancel();
    void GetLatest();

    };

    #endif
    --------------

    Cpp file
    ----------------------
    #include "GetCallerID.h"
    #include <aknnotewrappers.h>

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

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

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

    void CGetCallerId::GetLatest()
    {
    // Connect to the Log Server
    iFs.Connect();

    iLogClient = CLogClient::NewL(iFs);
    iRecentLogView = CLogViewRecent::NewL(*iLogClient);

    // 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();
    }
    ----------------------
    These two files i included in helloworld example and trying to execute it.

    I am calling the GetLatest() method from my Helloworldappui.cpp from hello event handling like this.

    CGetCallerId objCall;
    objCall.GetLatest();

    When i debugged the application on the emulator SetRecentListL() is failed and it is not calling SetActive() method.

    When i run the application on the device I am getting E32USER-CBase 42 means 'It is caused by an attempt to flag the active object as active when it is already active, i.e. a request is still outstanding'.

    i couldn't understand why i am getting this panic.

    When i commented SetActive() and run, i am getting KERN-EXEC 3.

    I am totally confused with this.

    Where am i doing mistake? Please guide me.

    Do you have any idea on how to read the size of incoming/outgoing GPRS data. i can see the values on device 'Logs->GPRS data counter'. i feel these values will be stored in the logs.

    but how do we read them from logs. Are there any api's or classes available to read those values.

    thanks for your patience.

    Regards,
    Rajasekhar

  11. #11
    Registered User
    Join Date
    Apr 2003
    Posts
    15

    detect incoming call failed

    Hi rbwilliams2

    I trying to detect the incoming call ,but it not getting the status from the runl method.can you please send me sample code.it will be grateful .thanks in advance.my id is (sajith@comcreation.biz).please do the needful.

    with regards,
    r.sajithali.

  12. #12
    Regular Contributor
    Join Date
    Mar 2003
    Location
    India
    Posts
    63

    I solved it on my own

    Hi Rich,

    Thanks for your code.

    I was able to find out the caller id.

    Regards,
    Rajasekhar
    Last edited by chavasekhar; 2003-05-10 at 09:09.

  13. #13
    Shaggy
    Guest
    I am new to C++, learning on the Symbian platform. After having some initial success at building a sample application, I got hungry to try more. I have tried implementing the code posted above in a sample application but I can't get it to work at all. I think it may have something to do with linking the source files, but I'm not sure.

    I have 2 questions:

    1. What INCLUDEs are required to implement the CLogView interface? Do I have to implement all those shown here or are some optional?

    2. If my current problem is simply a linking problem, can someone please provide a quick how-to for properly linking source files using CodeWarrior?

    Thanks..

  14. #14
    Registered User
    Join Date
    Nov 2003
    Posts
    4

    how did you solve it

    Hi Rajasekhar,

    I am facing the same problem with the panic after the SetActive Command. How did you manage to solve it? I am just about to throw my laptop out of the window ...
    ... so maybe you could give me a hint or mail me a code sample. This would really be a big help for me.

    BTW: is it possible to retrieve the caller id even before the call has been accepted using the log files? Or is has the call to be over to find the data in the files?

    I also heard that there would be an unrestricted API that offers functionality to retrieve the caller id directly.

    Thank you a lot for your help!

    Cheers
    Severin

  15. #15
    Registered User
    Join Date
    Jul 2003
    Posts
    2

    The same problem

    Hi Rajasekhar,

    I also met the problem you met before:

    When i run the application on the device I am getting E32USER-CBase 42 means 'It is caused by an attempt to flag the active object as active when it is already active, i.e. a request is still outstanding'.

    before using SetActive(), IsActive() is true.

    Would you let me know how you solve it ?

Posting Permissions

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