Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User rahul_tiwari's Avatar
    Join Date
    Oct 2009
    Posts
    4
    Hi guys I am trying to write a script which makes a call on click of any button or any other event and as soon as call finish reports the duration of that call to a server.

    I am facing the problem in stopping the listener to the call logs. the alert for last call duration comes in recursive manner.

    following is the code I am trying for listening the logs

    Code:
    var so = null;
    var noItemsErrorCode = 1012; 
    
    function init() {
        StartListiningLogs(); 
    }
    function StartListiningLogs() {
    
        try {
            so = device.getServiceObject("Service.Logging", "IDataSource");
        } catch (err) {
            alert("error receiving Logging service handle");
            return;
        }
    
    
        var filter = new Object();
        filter.DelayTime = 2000000;
    
        var criteria = new Object();
        criteria.Type = 'Log';
        criteria.Filter = filter;
    
    
        try {
            so.IDataSource.RequestNotification(criteria, ListnerCallback);
        } catch (err) {
            alert("error listining log");
        }
     
    }
    
    function ListnerCallback(transId, eventCode, result) {
    
         var criteria = new Object();
        criteria.Type = "Log";
        criteria.Filter = new Object();
        criteria.Filter.RecentList = 2;//outgoing calls
       
    
    
        try {
              so.IDataSource.GetList(criteria, GetRecordCallback);
        } catch (err) {
            alert("error receiving log items");
        }
        
    }
    
    
    function GetRecordCallback(transId, eventCode, result) {
        if (result.ErrorCode != 0) {
            // if error code is not "no suitable items" -- 
            // show alert otherwise leave the function
            if (result.ErrorCode != noItemsErrorCode) {
                alert(result.ErrorMessage);
            }
            return;
        } else {
       
            var item; // pointer to item in received list
            var temp = " ";
            for (var i = 0; (item = result.ReturnValue.getNext()) != undefined; i++) {
    
                if (i == 0) {
                    if (item['PhoneNumber'] != undefined) {
                        temp += item['PhoneNumber'];
                    }
                    temp += " ";
                    if (item['EventDuration'] != undefined) {
                        temp += item['EventDuration'];
                    }
                }
            }
            alert(temp);
            try {
                var criteria = new Object();
                criteria.TransactionID = result.TransactionID;
                var result2 = so.IDataSource.Cancel(criteria);
            } catch (e) {
                alert("cancelRequestNotification: " + e);
            }
        } 
    }

    here in above code I am getting the value of result.TransactionID as undefined in function GetRecordCallback.
    I wrote this code 2 months back at that time it worked fine for me. and now I am not able to figure out where
    is the problem.

    Thanks

  2. #2
    Super Contributor RB_Sahu's Avatar
    Join Date
    Jan 2007
    Location
    Bhubaneswar, India
    Posts
    1,189
    -------------------------------------
    Thanks & Regards
    Ram
    Symbian OS 9.2/9.3,S60 3rd FP1/FP2,Carbide.c++v2.0

  3. #3
    Registered User rahul_tiwari's Avatar
    Join Date
    Oct 2009
    Posts
    4
    Quote Originally Posted by RB_Sahu View Post

    You have provided the Symbian URL.
    My code is for Nokia WRT(javascript).

  4. #4
    Nokia Developer Moderator isalento's Avatar
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    831
    Why do you want to cancel asynchronous function in it's own callback?

    If you wish to stop receiving notifications try to cancel RequestNotification instead.
    Code:
     var transaction =so.IDataSource.RequestNotification(criteria, ListnerCallback);
    -Ilkka

  5. #5
    Registered User rahul_tiwari's Avatar
    Join Date
    Oct 2009
    Posts
    4
    Quote Originally Posted by isalento View Post
    Why do you want to cancel asynchronous function in it's own callback?

    If you wish to stop receiving notifications try to cancel RequestNotification instead.
    Code:
     var transaction =so.IDataSource.RequestNotification(criteria, ListnerCallback);
    -Ilkka
    Thanks for response.

    yes I want to stop receiving notifications. I thought it will stop notifying if I will cancel the function.
    how exactly I can cancel RequestNotification in my case(after first notification).

    somehow I got it working by assigning the RequestNotification call to a global variable and canceling the transactionID from that variable. I want some more sophisticated way for doing this.

    and I also want to know is there any way to receive notification related to specific event (in my case outgoing call).

  6. #6
    Nokia Developer Moderator isalento's Avatar
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    831
    It seems that request notification does not support filtering by event type.

    You will have to cancel RequestNotification if you don't wish to have more that one notification (see the code below). However if you want it to fire only once, why not to call just GetList(phoneCallLogCriteria, GetRecordCallback)?

    It is good to note, that when using request notification, it will fire once when call is made and second time when call is completed. The phone call log item is already created at the first pass and it will have all other data expect duration. In the second time, the very same log item is updated to have correct duration. Another thing to note is, that when calling to same number multiple times, the log will only hold the latest call information.

    Code:
    var logNotificationCriteria = {
        Type : "Log",
        Filter : {DelayTime: 2000000 }    
    }
    
    var logNotificationTransaction = null;
    
    logNotificationTransaction = so.IDataSource.RequestNotification(logNotificationCriteria, ListnerCallback);		
    
    function CancelNotifications(){
    	
    	if(logNotificationTransaction){
    		var res = so.IDataSource.Cancel(logNotificationTransaction);
    		
    		if(res.ErrorCode !=0){
    			alert("Error in canceling transaction " +logNotificationTransaction.TransactionID + " "+ res.ErrorMessage);
    		}else{
    			logNotificationTransaction = null;
    		}
    	}		
    }


    -Ilkka
    Last edited by isalento; 2009-12-17 at 07:42. Reason: code changes

  7. #7
    Registered User rahul_tiwari's Avatar
    Join Date
    Oct 2009
    Posts
    4
    This is a great help.
    I had observed the behavior u described.

    so where I have to call CancelNotifications ?
    in callback after processing the first received log?

Similar Threads

  1. More than one call in CTelephony gives problem
    By sid_diu in forum Symbian C++
    Replies: 2
    Last Post: 2009-10-22, 07:13
  2. Problem in creating answering machine for incoming call...
    By amol_benare604 in forum Symbian C++
    Replies: 8
    Last Post: 2009-08-28, 05:16
  3. Replies: 5
    Last Post: 2009-08-26, 09:36
  4. Problem cancelling a new call on some phones
    By eduijs in forum Symbian C++
    Replies: 0
    Last Post: 2009-02-19, 21:05
  5. Call duration counter??
    By patrick772goh in forum Symbian C++
    Replies: 0
    Last Post: 2007-10-08, 09:13

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved