Index: branches/2.5/zpush/backend/expresso/providers/calendarProvider.php
===================================================================
--- branches/2.5/zpush/backend/expresso/providers/calendarProvider.php	(revision 7687)
+++ branches/2.5/zpush/backend/expresso/providers/calendarProvider.php	(revision 8032)
@@ -30,16 +30,49 @@
     {
         $return = array();
-        $sigs = Controller::find(array('concept' => 'calendarSignature'), array( 'id','calendar' ), array( 'filter' => array( '=' , 'user' , $this->_uidnumber )));
-
-        foreach($sigs as $sig)
-        {
-            $calendar =  Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] ));
-            if($calendar['type'] != 0 ) continue; //ecluir grupo de tarefas
-
-            $tmpSig = array();
-            $tmpSig["id"] = 'calendar'.$sig['id'];
-            $tmpSig["parent"] = 0;
-            $tmpSig["mod"] = $calendar['name'];
-            $return[] = $tmpSig;
+        $criteria = CALENDAR_SYNC_SIGNED_CALENDARS ? array( 'filter' => array( 'AND' , array( '=' , 'type' , '0' ) , array( '=' , 'user' , $this->_uidnumber ))) : array( 'filter' => array ( 'AND'  ,array( '=' , 'isOwner' , '1' ),array( '=' , 'type' , '0' ) , array( '=' , 'user' , $this->_uidnumber ))); 
+        $sigs = Controller::find(array('concept' => 'calendarSignature'), array( 'id','calendar' ), $criteria); 
+ 
+        if(Request::GetDeviceType()  == 'iPhone' || Request::GetDeviceType()  == 'iPad') 
+        { 
+            foreach($sigs as $sig) 
+            { 
+                $calendar =  Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] )); 
+                $tmpSig = array(); 
+                $tmpSig["id"] = 'calendar'.$sig['id']; 
+                $tmpSig["parent"] = 0; 
+                $tmpSig["mod"] = $calendar['name']; 
+                $return[] = $tmpSig; 
+            } 
+        } 
+        else 
+        { 
+            $defaultCalendar = Controller::find(array('concept' => 'modulePreference'), array('value','id') , array('filter' => array( 'and' , array('=' , 'name' , 'defaultCalendar') , array('=' , 'module' , 'expressoCalendar') , array('=' , 'user' , $this->_uidnumber )  )) ); 
+ 
+            if(isset($defaultCalendar[0])) //Prioriza agenda default de importaÃÂ§ÃÂ£o pois o android so sincroniza a primeira agenda. 
+            { 
+                foreach($sigs as $i => $sig) 
+                { 
+                    if($sig['calendar'] == $defaultCalendar[0]['value']) 
+                    { 
+                        $calendar =  Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] )); 
+                        $tmpSig = array(); 
+                        $tmpSig["id"] = 'calendar'.$sig['id']; 
+                        $tmpSig["parent"] = 0; 
+                        $tmpSig["mod"] = $calendar['name']; 
+                        $return[] = $tmpSig; 
+                    } 
+                } 
+            } 
+            else 
+            { 
+                $sig = $sigs[0]; 
+                $calendar =  Controller::read( array( 'concept' => 'calendar' , 'id' => $sig['calendar'] )); 
+                $tmpSig = array(); 
+                $tmpSig["id"] = 'calendar'.$sig['id']; 
+                $tmpSig["parent"] = 0; 
+                $tmpSig["mod"] = $calendar['name']; 
+                $return[] = $tmpSig; 
+ 
+            } 
         }
 
@@ -525,4 +558,15 @@
         $schedulable['timezone'] = $calendar['timezone'];
 
+ 
+        $sv  = new DateTime('@'.($message->starttime + $GMT_CEL), $calendarSignatureTimezone); 
+ 
+        if($sv->format('I') == 0) 
+            $schedulable['startTime'] = $schedulable['startTime'] - 3600000; 
+ 
+        $ev  = new DateTime('@'.($message->endtime + $GMT_CEL), $calendarSignatureTimezone); 
+ 
+        if($ev->format('I') == 0) 
+            $schedulable['endTime'] = $schedulable['endTime'] - 3600000; 
+ 
         $schedulable['allDay'] = $message->alldayevent;
         $schedulable['description'] = $message->body;
@@ -735,6 +779,16 @@
         $schedulable['startTime'] = (($message->starttime + $GMT_CEL) + ($calendarSignatureTimezone->getOffset(new DateTime('@'.($message->starttime + $GMT_CEL), new DateTimeZone('UTC'))) * -1) ) *1000; //$message->starttime  * 1000;
         $schedulable['endTime'] = (($message->endtime + $GMT_CEL) + ($calendarSignatureTimezone->getOffset(new DateTime('@'.($message->endtime + $GMT_CEL), new DateTimeZone('UTC')))* -1)) *1000;//$message->endtime  * 1000;
+ 
+        $sv  = new DateTime('@'.($message->starttime + $GMT_CEL), $calendarSignatureTimezone); 
+ 
+        if($sv->format('I') == 0) 
+            $schedulable['startTime'] = $schedulable['startTime'] - 3600000; 
+ 
+        $ev  = new DateTime('@'.($message->endtime + $GMT_CEL), $calendarSignatureTimezone); 
+ 
+        if($ev->format('I') == 0) 
+            $schedulable['endTime'] = $schedulable['endTime'] - 3600000; 
+ 
         $schedulable['timezone'] = $calendar['timezone'];
-
 
 
@@ -749,4 +803,5 @@
         $participant['isOrganizer'] = '1';
         $participant['acl'] = 'rowi';
+        $participant['status'] = '1'; 
 
         if($message->organizeremail)
@@ -1033,15 +1088,15 @@
 
         //Inicia Variaveis de para API expresso
-            if(!isset($_SESSION))
-                session_start();
-
-            $userWallet = array();
-            $userWallet['uidNumber'] = $entries[0]['uidnumber'][0];
-            $userWallet['uid'] = $entries[0]['uid'][0];
-            $userWallet['mail'] = $entries[0]['mail'][0];
-
-            $_SESSION['wallet'] = array();
-            $_SESSION['wallet']['user'] = $userWallet;
-            $_SESSION['flags']['currentapp'] = 'expressoCalendar';
+        if(!isset($_SESSION))
+            session_start();
+
+        $userWallet = array();
+        $userWallet['uidNumber'] = $entries[0]['uidnumber'][0];
+        $userWallet['uid'] = $entries[0]['uid'][0];
+        $userWallet['mail'] = $entries[0]['mail'][0];
+
+        $_SESSION['wallet'] = array();
+        $_SESSION['wallet']['user'] = $userWallet;
+        $_SESSION['flags']['currentapp'] = 'expressoCalendar';
 
         //----------------------------------------------------------------------------------------//
Index: branches/2.5/zpush/config.php
===================================================================
--- branches/2.5/zpush/config.php	(revision 7706)
+++ branches/2.5/zpush/config.php	(revision 8032)
@@ -311,4 +311,5 @@
     define('IMAP_USE_IMAPMAIL', true);
 
+    define('CALENDAR_SYNC_SIGNED_CALENDARS', false); 
 
     $rs = pg_query( $GLOBALS['connections']['db'], 'SELECT app_id FROM phpgw_applications WHERE app_name = \'zpush\'' );
