Index: branches/2.2/calendar/inc/class.boicalendar.inc.php
===================================================================
--- branches/2.2/calendar/inc/class.boicalendar.inc.php	(revision 678)
+++ branches/2.2/calendar/inc/class.boicalendar.inc.php	(revision 3018)
@@ -1275,5 +1275,6 @@
 			if($this->line < count($ical_text))
 			{
-				$str = str_replace("\r\n",'',$ical_text[$this->line]);
+				$str = str_replace(array("\r\n","\r","\n"), '', $ical_text[$this->line]);
+
 				$this->line = $this->line + 1;
 				while(ereg("^[[:space:]]",$ical_text[$this->line]))
@@ -1282,4 +1283,6 @@
 					$this->line = $this->line + 1;
 				}
+				// Corrige a codificacao dos caracteres
+				$str = utf8_decode ( trim ($str) );
 				$this->debug("LINE : ".$str);
 				return $str;
@@ -1405,4 +1408,5 @@
 		function parse_parameters(&$event,$majortype,$value)
 		{
+			$this->debug ('value: '.$value);
 			if(!ereg('[\=\;]',$value))
 			{
@@ -1451,4 +1455,6 @@
 				}
 			}
+
+			$this->debug('parse_parameters array return_value: '._debug_array($return_value,False));
 
 			for($i=0;$i<count($return_value);$i++)
@@ -1528,5 +1534,5 @@
 			if($this->property[$majortype][$mode]['multiples'])
 			{
-				$this->debug(_debug_array($var,False));
+				$this->debug('parse_value var array: '._debug_array($var,False));
 				$event[$majortype][] = $var;
 			}
@@ -1540,10 +1546,13 @@
 					$t_var = $var[$majortype];
 					unset($var[$majortype]);
-					reset($t_var);
-					while(list($key,$val) = each($t_var))
-					{
-						$var[$key] = $val;
-					}
-					$this->debug($majortype.' : '._debug_array($var,False));
+					if ( $t_var )
+					{
+						reset($t_var);
+						while(list($key,$val) = each($t_var))
+						{
+							$var[$key] = $val;
+						}
+						$this->debug($majortype.' : '._debug_array($var,False));
+					}
 				}
 				$this->set_var($event,$majortype,$var);
@@ -2260,7 +2269,5 @@
 		function switch_partstat($var)
 		{
-//			$this->debug_str = True;
 			$this->debug('PARTSTAT = '.$var);
-//			$this->debug_str = False;
 			if(is_string($var))
 			{
@@ -2567,4 +2574,5 @@
 
 				ereg($property_regexp,$text,$temp);
+				$this->debug ('Majortype dump: '._debug_array($temp, false) );
 				$majortype = str_replace('-','_',strtolower($temp[1]));
 				$value = chop($temp[2]);
@@ -2767,5 +2775,5 @@
 				elseif($state == 'optional' || $state == 'required')
 				{
-					$this->debug('Mode : '.$mode.' Majortype : '.$majortype);
+					$this->debug('Mode : '.$mode.' Majortype : '.$majortype . ' Type : '.$type);
 					if($do_to_text)
 					{
@@ -3016,4 +3024,5 @@
 					break;
 			}
+			$this->debug ('ical parse result: ' . _debug_array ($ical, false));
 			$c_events = count($ical['event']);
 			for($i=0;$i<$c_events;$i++)
@@ -3056,4 +3065,24 @@
 						$so_event->set_ex_participants($ical['event'][$i]['ex_participants']['value']);
 					}
+					// Compatibilidade com agendamentos vindos do outlook/exchange
+					if ( isset ($ical['event'][$i]['attendee']) )
+					{
+						$c_attendees = count($ical['event'][$i]['attendee']);
+						$all_attendees = '';
+						for ( $a=0; $a < $c_attendees; $a++ )
+						{
+							$cname = '"'. $ical['event'][$i]['attendee'][$a]['cn'] .'"';
+							$email = $ical['event'][$i]['attendee'][$a]['mailto']['user'];
+							if ( $email )
+								$email = '<'. $email .'@'. $ical['event'][$i]['attendee'][$a]['mailto']['host'] .'>';
+							else
+								$email = '';
+							
+							$all_attendees .= $cname . $email .', ';
+						}
+						$this->debug ('All attendees: ' . $all_attendees);
+						$so_event->set_ex_participants($all_attendees);
+					}
+
 					if($ical['event'][$i]['location']['value'])
 					{
@@ -3296,5 +3325,5 @@
 					else
 					{
-//owner
+						$so_event->add_attribute('participants','A',(int)$GLOBALS['phpgw_info']['user']['account_id']);
 					}
 
@@ -3585,5 +3614,8 @@
 			if($this->debug_str)
 			{
-				echo $str."<br>\n";
+				//echo $str."<br>\n";
+				$log = fopen('/tmp/calendar.log', 'a') or die("nao foi possivel abrir o arquivo /tmp/calendar.log");
+				fwrite($log, $str . "\n");
+				fclose($log);
 			}
 		}
