Index: branches/2.5/zpush/setup/setup.inc.php
===================================================================
--- branches/2.5/zpush/setup/setup.inc.php	(revision 7589)
+++ branches/2.5/zpush/setup/setup.inc.php	(revision 8232)
@@ -13,5 +13,5 @@
 	$setup_info['zpush']['title']     	= 'Z-Push' ;
 	/* Ao incrementar versão, não esquecer de declarar função do tables_update.inc.php*/
-	$setup_info['zpush']['version']   	= '2.5.0';
+	$setup_info['zpush']['version']   	= '2.5.1';
 	$setup_info['zpush']['app_order']	= 10;
 
Index: branches/2.5/zpush/lib/utils/utils.php
===================================================================
--- branches/2.5/zpush/lib/utils/utils.php	(revision 7589)
+++ branches/2.5/zpush/lib/utils/utils.php	(revision 8232)
@@ -446,5 +446,5 @@
     static public function IsSystemFolder($foldertype) {
         return ($foldertype == SYNC_FOLDER_TYPE_INBOX || $foldertype == SYNC_FOLDER_TYPE_DRAFTS || $foldertype == SYNC_FOLDER_TYPE_WASTEBASKET || $foldertype == SYNC_FOLDER_TYPE_SENTMAIL ||
-                $foldertype == SYNC_FOLDER_TYPE_OUTBOX || $foldertype == SYNC_FOLDER_TYPE_TASK || $foldertype == SYNC_FOLDER_TYPE_APPOINTMENT || $foldertype == SYNC_FOLDER_TYPE_CONTACT ||
+                $foldertype == SYNC_FOLDER_TYPE_OUTBOX || $foldertype == SYNC_FOLDER_TYPE_TASK /*|| $foldertype == SYNC_FOLDER_TYPE_APPOINTMENT */|| $foldertype == SYNC_FOLDER_TYPE_CONTACT ||
                 $foldertype == SYNC_FOLDER_TYPE_NOTE || $foldertype == SYNC_FOLDER_TYPE_JOURNAL) ? true:false;
     }
Index: branches/2.5/zpush/backend/expresso/providers/imapProvider.php
===================================================================
--- branches/2.5/zpush/backend/expresso/providers/imapProvider.php	(revision 8169)
+++ branches/2.5/zpush/backend/expresso/providers/imapProvider.php	(revision 8232)
@@ -497,9 +497,9 @@
             if (!empty($bccaddr)) $headers .= "\nBcc: $bccaddr";
             // changed by mku ZP-330
- 
-            require_once(__DIR__."/../../../../library/Mail/Mail.php"); 
-            $mail_object =& Mail::factory("smtp", $GLOBALS['config']['SMTP']); 
-            $send = $mail_object->send($toaddr, $message->headers , $body); 
-          //  $send =  @mail ( $toaddr, $message->headers["subject"], $body, $headers, $envelopefrom ); 
+
+	    require_once(__DIR__."/../../../../library/Mail/Mail.php");
+            $mail_object =& Mail::factory("smtp", $GLOBALS['config']['SMTP']);
+            $send = $mail_object->send($toaddr, $message->headers , $body);
+          //  $send =  @mail ( $toaddr, $message->headers["subject"], $body, $headers, $envelopefrom );
         }
 
@@ -904,20 +904,13 @@
 
         // build name for new mailboxBackendMaildir
-        $displayname = Utils::Utf7_iconv_encode(Utils::Utf8_to_utf7($displayname));
-        $newname = $this->server . $folderid . $this->serverdelimiter . $displayname;
-
+        $displayname = Utils::Utf7_iconv_encode(Utils::Utf8_to_utf7($displayname));;
+        $new = $this->server . $this->getImapIdFromFolderId($folderid) . $this->serverdelimiter.  $displayname;
         $csts = false;
-        // if $id is set => rename mailbox, otherwise create
-        if ($oldid) {
-            // rename doesn't work properly with IMAP
-            // the activesync client doesn't support a 'changing ID'
-            // TODO this would be solved by implementing hex ids (Mantis #459)
-            //$csts = imap_renamemailbox($this->mbox, $this->server . imap_utf7_encode(str_replace(".", $this->serverdelimiter, $oldid)), $newname);
-        }
-        else {
-            $csts = @imap_createmailbox($this->mbox, $newname);
-        }
+
+        $csts = ($oldid) ? imap_renamemailbox($this->mbox,  $this->server .$this->getImapIdFromFolderId($oldid) , $new) : imap_createmailbox($this->mbox, $new);
+
         if ($csts) {
-            return $this->StatFolder($folderid . $this->serverdelimiter . $displayname);
+           $newId =  $this->convertImapId($new);
+           return $this->StatFolder($newId);
         }
         else
@@ -936,7 +929,9 @@
      *
      */
-    public function DeleteFolder($id, $parentid){
-        // TODO implement
-        return false;
+    public function DeleteFolder($id, $parentid)
+    {
+        $ret = imap_deletemailbox($this->mbox , $this->server .$this->getImapIdFromFolderId($id) );
+        imap_expunge( $this->mbox );
+        return $ret;
     }
 
Index: branches/2.5/zpush/backend/expresso/providers/calendarProvider.php
===================================================================
--- branches/2.5/zpush/backend/expresso/providers/calendarProvider.php	(revision 8032)
+++ branches/2.5/zpush/backend/expresso/providers/calendarProvider.php	(revision 8232)
@@ -30,49 +30,49 @@
     {
         $return = array();
-        $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; 
- 
-            } 
+        $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;
+
+            }
         }
 
@@ -154,5 +154,51 @@
     public function ChangeFolder($folderid, $oldid, $displayname, $type)
     {
-       return false;
+        if($oldid)
+        {
+            $idNumber = (int)str_replace('calendar' , '' , $oldid);
+            $calendarSignature =  Controller::read( array( 'concept' => 'calendarSignature' , 'id' => $idNumber ));
+
+            Controller::update( array('concept' => 'calendar' , 'id' => $calendarSignature['calendar']), array( 'name' => $displayname) );
+
+            return $this->StatFolder($oldid);
+        }
+        else
+        {
+             $cal = array('name' => $displayname,
+                'timezone' => 'America/Sao_Paulo',
+                'type' => '0'
+            );
+
+            $calCreated = Controller::create(array('concept' => 'calendar'), $cal);
+
+            if(!$calCreated){
+                return false;
+            }
+
+            $sig = array('user' => $_SESSION['wallet']['user']['uidNumber'],
+                'calendar' => $calCreated['id'],
+                'isOwner' => '1',
+                'dtstamp' => time() . '000',
+                'fontColor' => 'FFFFFF',
+                'backgroundColor' => '3366CC',
+                'borderColor' => '3366CC',
+            );
+
+            $sigCreated = Controller::create(array('concept' => 'calendarSignature'), $sig);
+
+            if(!$sigCreated){
+                return false;
+            }
+            else
+            {
+                $return = array();
+                $return["id"] = 'calendar'.$calCreated;
+                $return["parent"] = 0;
+                $return["mod"] = $displayname;
+                return $return;
+            }
+        }
+
+        return false;
 
     }
@@ -168,7 +214,17 @@
      * @throws StatusException              could throw specific SYNC_FSSTATUS_* exceptions
      */
-    public function DeleteFolder($id, $parentid)
-    {
-        return false;
+    public function DeleteFolder($id, $parent)
+    {
+        $interation = array();
+        $idNumber = (int)str_replace('calendar' , '' , $id);
+        $calendarSignature =  Controller::read( array( 'concept' => 'calendarSignature' , 'id' => $idNumber ));
+
+        $interation['calendar://' . $calendarSignature['calendar']] = false;
+        ob_start();
+        $args = $interation;
+        include EXPRESSO_PATH.'/prototype/Sync.php';
+        ob_end_clean();
+
+        return true;
     }
 
@@ -302,5 +358,5 @@
                                 break;
                             case 'd':
-                                $mult = 3600;
+                                $mult = 1440;
                                 break;
                             default:
@@ -316,5 +372,5 @@
                         case STATUS_ACCEPTED:
                             $message->busystatus = 2;
-                           break;
+                            break;
                         case STATUS_TENTATIVE:
                             $message->busystatus = 1;
@@ -333,7 +389,7 @@
         //------------------------------------------------------------------------------------------------------------//
 
-       /*
-       * SincronizaÃ§Ã£o de RecorrÃªncia
-       */
+        /*
+        * SincronizaÃ§Ã£o de RecorrÃªncia
+        */
         $repeats = Controller::find(array('concept' => 'repeat'), null , array( 'filter' => array( 'and' , array( '=' , 'schedulable' , $schedulable['id'] ),array( '!=' , 'frequency' , 'none' )  ) ));
         if(is_array($repeats) && count($repeats) > 0)
@@ -359,5 +415,5 @@
 
             if($repeat['endTime'])
-               $recur->until =  (int) substr($repeat['endTime'], 0, -3);
+                $recur->until =  (int) substr($repeat['endTime'], 0, -3);
 
             $recur->interval = $repeat['interval'] ? $repeat['interval'] : 1;
@@ -558,15 +614,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; 
- 
+
+        $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;
@@ -741,5 +797,5 @@
             if($v['user']['id'] == $this->_uidnumber )
             {
-               $schedulable['participants'][$i]['status'] = $this->formatBusy($message->busystatus);
+                $schedulable['participants'][$i]['status'] = $this->formatBusy($message->busystatus);
             }
         }
@@ -779,15 +835,15 @@
         $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; 
- 
+
+        $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'];
 
@@ -803,5 +859,5 @@
         $participant['isOrganizer'] = '1';
         $participant['acl'] = 'rowi';
-        $participant['status'] = '1'; 
+        $participant['status'] = '1';
 
         if($message->organizeremail)
@@ -1021,5 +1077,5 @@
             if($v['user']['id'] == $this->_uidnumber && $v['user']['isOrganizer']  == '1')
             {
-              $delete = true;
+                $delete = true;
             }
         }
@@ -1262,5 +1318,5 @@
                 break;
             case 0:
-               return STATUS_UNANSWERED;
+                return STATUS_UNANSWERED;
                 break;
         }
Index: branches/2.5/zpush/backend/expresso/expresso.php
===================================================================
--- branches/2.5/zpush/backend/expresso/expresso.php	(revision 7671)
+++ branches/2.5/zpush/backend/expresso/expresso.php	(revision 8232)
@@ -24,4 +24,6 @@
     private function getProvider( $folderId )
     {
+
+
         foreach($this->providers as $provider)
         {
@@ -109,5 +111,5 @@
     public function ChangeFolder($folderid, $oldid, $displayname, $type)
     {
-        // TODO: Implement ChangeFolder() method.
+        return $this->getProvider($oldid ? $oldid: $folderid)->ChangeFolder($folderid, $oldid, $displayname, $type);
     }
 
@@ -124,5 +126,5 @@
     public function DeleteFolder($id, $parentid)
     {
-        // TODO: Implement DeleteFolder() method.
+        return $this->getProvider($id)->DeleteFolder($id, $parentid);
     }
 
Index: branches/2.5/zpush/config.php
===================================================================
--- branches/2.5/zpush/config.php	(revision 8169)
+++ branches/2.5/zpush/config.php	(revision 8232)
@@ -284,7 +284,7 @@
     $row = pg_fetch_assoc( $rs );
 
-    $smtpConfig = parse_ini_file(EXPRESSO_PATH . '/prototype/config/SMTP.srv' , true ); 
-    $GLOBALS['config']['SMTP'] = $smtpConfig['config']; 
- 
+    $smtpConfig = parse_ini_file(EXPRESSO_PATH . '/prototype/config/SMTP.srv' , true );
+    $GLOBALS['config']['SMTP'] = $smtpConfig['config'];
+
     // ************************
     //  BackendIMAP settings
@@ -314,5 +314,5 @@
     define('IMAP_USE_IMAPMAIL', false);
 
-    define('CALENDAR_SYNC_SIGNED_CALENDARS', false); 
+    define('CALENDAR_SYNC_SIGNED_CALENDARS', false);
 
     $rs = pg_query( $GLOBALS['connections']['db'], 'SELECT app_id FROM phpgw_applications WHERE app_name = \'zpush\'' );
