Well there should be a dbus command/event that occurs when a phone call is made or received, and a dbus command/event when that call is ended. Maybe listening in on the dbus and then calling somebody and hanging up, then finding out what command/event occurred when the phone call starts and ends