/**
  * keeps track of the call history
  * 
  * the callId can be 3c3b966053be-phxdiv27t9gm or 7027a58643aeb25149e4861076f1b0a9@xxx.xxx.xxx.xxx
  * we strip everything after the @ character
  *
  * @param string $mac the mac address of the phone
  * @param string $event event can be connected, disconnected, incoming, outgoing, missed
  * @param string $callId the callid
  * @param string $local the username of the asterisk sip peer
  * @param string $remote the remote number
  * 
  * @todo add correct line_id
  */
 public function callHistory($mac, $event, $callId, $local, $remote)
 {
     // there is no need to start session for call history
     // it's a single shot request
     parent::_authenticate();
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Event: {$event} CallId: {$callId} Local: {$local} Remote: {$remote} ");
     }
     $phone = Voipmanager_Controller_Snom_Phone::getInstance()->getByMacAddress($mac);
     $controller = Phone_Controller::getInstance();
     $pos = strpos($callId, '@');
     if ($pos !== false) {
         $callId = substr($callId, 0, $pos);
     }
     $pos = strpos($local, '@');
     if ($pos !== false) {
         $local = substr($local, 0, $pos);
     }
     $pos = strpos($remote, '@');
     if ($pos !== false) {
         $remote = substr($remote, 0, $pos);
     }
     $call = new Phone_Model_Call(array('id' => substr($callId, 0, 40), 'phone_id' => $phone->getId(), 'line_id' => $local));
     switch ($event) {
         case 'outgoing':
             $call->source = $local;
             $call->destination = $remote;
             $call->direction = Phone_Model_Call::TYPE_OUTGOING;
             $controller->callStarted($call);
             break;
         case 'incoming':
             $call->source = $local;
             $call->destination = $remote;
             $call->direction = Phone_Model_Call::TYPE_INCOMING;
             $controller->callStarted($call);
             break;
         case 'connected':
             $controller->callConnected($call);
             break;
         case 'disconnected':
             $controller->callDisconnected($call);
             break;
     }
 }