[eGroupWare-svn] r55995 - in /trunk: egroupware/api/src/Etemplate/ egroupware/doc/ mail/inc/ mail/setup/ phpgwapi/inc/

[email protected] Tue, 03 May 2016 19:17:44 -0000
Newsgroups gmane.comp.web.egroupware.cvs
Message-ID <[email protected]>
Author: ralfbecker
Date: Tue May  3 21:17:44 2016
New Revision: 55995

URL: http://svn.stylite.de/viewvc/egroupware?rev=55995&view=rev
Log:
using new api for mail app

Added:
    trunk/egroupware/api/src/Etemplate/KeyManager.php
      - copied, changed from r55990, trunk/phpgwapi/inc/class.egw_keymanager.inc.php
Modified:
    trunk/egroupware/doc/fix_api.php
    trunk/mail/inc/class.mail_acl.inc.php
    trunk/mail/inc/class.mail_compose.inc.php
    trunk/mail/inc/class.mail_hooks.inc.php
    trunk/mail/inc/class.mail_integration.inc.php
    trunk/mail/inc/class.mail_sieve.inc.php
    trunk/mail/inc/class.mail_tree.inc.php
    trunk/mail/inc/class.mail_ui.inc.php
    trunk/mail/inc/class.mail_wizard.inc.php
    trunk/mail/inc/class.mail_zpush.inc.php
    trunk/mail/setup/default_records.inc.php
    trunk/mail/setup/setup.inc.php
    trunk/phpgwapi/inc/class.egw_keymanager.inc.php

Copied: trunk/egroupware/api/src/Etemplate/KeyManager.php (from r55990, trunk/phpgwapi/inc/class.egw_keymanager.inc.php)
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/src/Etemplate/KeyManager.php?p2=trunk/egroupware/api/src/Etemplate/KeyManager.php&p1=trunk/phpgwapi/inc/class.egw_keymanager.inc.php&r1=55990&r2=55995&rev=55995&view=diff
==============================================================================
--- trunk/phpgwapi/inc/class.egw_keymanager.inc.php (original)
+++ trunk/egroupware/api/src/Etemplate/KeyManager.php Tue May  3 21:17:44 2016
@@ -1,17 +1,19 @@
 <?php
 /**
- * eGroupWare API: contains classes and key constants for generating shortcuts
+ * EGroupware API: contains classes and key constants for generating shortcuts
  *
  * @link http://www.egroupware.org
  * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
  * @package api
- * @subpackage egw action grid
+ * @subpackage etemplate
  * @author Andreas Stöckel
  * @copyright (c) 2011 Stylite
  * @version $Id$
  */
 
-class egw_keymanager
+namespace EGroupware\Api\Etemplate;
+
+class KeyManager
 {
 	const BACKSPACE = 8;
 	const TAB = 9;

Modified: trunk/egroupware/doc/fix_api.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/doc/fix_api.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/egroupware/doc/fix_api.php (original)
+++ trunk/egroupware/doc/fix_api.php Tue May  3 21:17:44 2016
@@ -44,7 +44,7 @@
 	"#\\\$GLOBALS\['egw'\]->preferences->change#" => '$GLOBALS[\'egw\']->preferences->add',
 );
 // enclose class-names and static methods with some syntax check
-$class_start = '#(?<!function)([\[\s,;().!])';
+$class_start = '#(?<!function)([\[\s,;().!=])';
 $class_end = '(::|\\(|\\)|;|\?|:|\\s|,|$)#';
 foreach(array(
 	'accounts' => 'Api\\Accounts',
@@ -158,6 +158,7 @@
 	'etemplate_request' => 'Api\\Etemplate\\Request',
 	'nextmatch_widget::category_action' => 'Api\\Etemplate\\Widget\\Nextmatch::category_action',
 	'nextmatch_widget::DEFAULT_MAX_MENU_LENGTH' => 'Api\\Etemplate\\Widget\\Nextmatch::DEFAULT_MAX_MENU_LENGTH',
+	'egw_keymanager' => 'Api\\Etemplate\\KeyManager',
 	// so_sql and friends
 	'so_sql' => 'Api\\Storage\\Base',
 	'so_sql_cf' => 'Api\\Storage',
@@ -167,6 +168,7 @@
 	// addressbook backend
 	'addressbook_bo' => 'Api\\Contacts',
 	'addressbook_so' => 'Api\\Contacts\\Storage',
+	'addressbook_merge' => 'Api\\Contacts\\Merge',
 ) as $from => $to)
 {
 	$replace[$class_start.$from.$class_end] = '$1'.$to.'$2';

Modified: trunk/mail/inc/class.mail_acl.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/mail/inc/class.mail_acl.inc.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/mail/inc/class.mail_acl.inc.php (original)
+++ trunk/mail/inc/class.mail_acl.inc.php Tue May  3 21:17:44 2016
@@ -11,6 +11,8 @@
  */
 
 use EGroupware\Api;
+use EGroupware\Api\Framework;
+use EGroupware\Api\Etemplate;
 use EGroupware\Api\Mail;
 
 class mail_acl
@@ -61,13 +63,13 @@
 	 */
 	function edit(array $content=null ,$msg='')
 	{
-		$tmpl = new Api\Etemplate('mail.acl');
+		$tmpl = new Etemplate('mail.acl');
 		if (!is_array($content))
 		{
 			$acc_id = $_GET['acc_id']?$_GET['acc_id']:$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
 			if (isset($_GET['account_id']) && !isset($GLOBALS['egw_info']['user']['apps']['admin']))
 			{
-				egw_framework::window_close(lang('Permission denied'));
+				Framework::window_close(lang('Permission denied'));
 			}
 			$account_id = $_GET['account_id'];
 		}
@@ -175,12 +177,12 @@
 						$msg .= "\n".lang("Error: Could not save ACL").' '.lang("reason!");
 					}
 					//Send message
-					egw_framework::message($msg);
+					Framework::message($msg);
 					if ($button == "apply") break;
 
 				//Fall through
 				case 'cancel':
-					egw_framework::window_close();
+					Framework::window_close();
 					exit;
 
 				case 'delete':
@@ -193,7 +195,7 @@
 					{
 						error_log(__METHOD__.__LINE__. "()" . "The remove_acl suppose to return an array back, something is wrong there");
 					}
-					egw_framework::message($msg);
+					Framework::message($msg);
 			}
 		}
 		$readonlys = $sel_options = array();
@@ -239,13 +241,13 @@
 	/**
 	 * Autocomplete for folder taglist
 	 *
-	 * @throws egw_exception_no_permission_admin
+	 * @throws Api\Exception\NoPermission\Admin
 	 */
 	public static function ajax_folders()
 	{
 		if (!empty($_GET['account_id']) && !$GLOBALS['egw_info']['user']['apps']['admin'])
 		{
-			throw new egw_exception_no_permission_admin;
+			throw new Api\Exception\NoPermission\Admin;
 		}
 		$account = Mail\Account::read($_GET['acc_id'], $_GET['account_id']);
 		$imap = $account->imapServer(!empty($_GET['account_id']) ? (int)$_GET['account_id'] : false);
@@ -263,7 +265,7 @@
 			}
 		}
 		// switch regular JSON response handling off
-		egw_json_request::isJSONRequest(false);
+		Api\Json\Request::isJSONRequest(false);
 
 		header('Content-Type: application/json; charset=utf-8');
 		echo json_encode($folders);

Modified: trunk/mail/inc/class.mail_compose.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/mail/inc/class.mail_compose.inc.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/mail/inc/class.mail_compose.inc.php (original)
+++ trunk/mail/inc/class.mail_compose.inc.php Tue May  3 21:17:44 2016
@@ -11,6 +11,11 @@
  */
 
 use EGroupware\Api;
+use EGroupware\Api\Link;
+use EGroupware\Api\Framework;
+use EGroupware\Api\Egw;
+use EGroupware\Api\Acl;
+use EGroupware\Api\Etemplate;
 use EGroupware\Api\Vfs;
 use EGroupware\Api\Mail;
 
@@ -65,7 +70,7 @@
 
 	function __construct()
 	{
-		$this->displayCharset   = translation::charset();
+		$this->displayCharset   = Api\Translation::charset();
 
 		$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
 		$this->mail_bo	= Mail::getInstance(true,$profileID);
@@ -232,7 +237,7 @@
 		{
 			$actions['prty']['children'][$content['priority']]['default'] = true;
 		}
-		if (html::$ua_mobile)
+		if (Api\Header\UserAgent::mobile())
 		{
 			foreach (array_keys($actions) as $key)
 			{
@@ -256,7 +261,7 @@
 	 */
 	function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false)
 	{
-		if ($msg) egw_framework::message($msg);
+		if ($msg) Framework::message($msg);
 
 		if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']))
 		{
@@ -350,16 +355,16 @@
 				{
 					$upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false);
 				}
-				catch (egw_exception_wrong_userinput $e)
-				{
-					egw_framework::message($e->getMessage(), 'error');
+				catch (Api\Exception\WrongUserinput $e)
+				{
+					Framework::message($e->getMessage(), 'error');
 					unset($_content['uploadForCompose'][$i]);
 					continue;
 				}
 				if (is_dir($upload['file']) && (!$_content['filemode'] || $_content['filemode'] == Vfs\Sharing::ATTACH))
 				{
 					$_content['filemode'] = Vfs\Sharing::READONLY;
-					egw_framework::message(lang('Directories have to be shared.'), 'info');
+					Framework::message(lang('Directories have to be shared.'), 'info');
 				}
 			}
 		}
@@ -449,7 +454,7 @@
 						$GLOBALS['egw']->preferences->save_repository(true);
 					}
 				}
-				catch (egw_exception_wrong_userinput $e)
+				catch (Api\Exception\WrongUserinput $e)
 				{
 					$sendOK = false;
 					$message = $e->getMessage();
@@ -494,7 +499,7 @@
 					$rhA = mail_ui::splitRowID($_content['processedmail_id']);
 					$idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false);
 				}
-				$response = egw_json_response::get();
+				$response = Api\Json\Response::get();
 				if ($activeProfile != $composeProfile)
 				{
 					// we need a message only, when account ids (composeProfile vs. activeProfile) differ
@@ -518,12 +523,12 @@
 					$response->call('opener.egw_message',lang('Message send successfully.'));
 				}
 				//egw_framework::refresh_opener(lang('Message send successfully.'),'mail');
-				egw_framework::window_close();
+				Framework::window_close();
 			}
 			if ($sendOK == false)
 			{
-				$response = egw_json_response::get();
-				egw_framework::message(lang('Message send failed: %1',$message),'error');// maybe error is more appropriate
+				$response = Api\Json\Response::get();
+				Framework::message(lang('Message send failed: %1',$message),'error');// maybe error is more appropriate
 				$response->call('app.mail.clearIntevals');
 			}
 		}
@@ -552,7 +557,7 @@
 			$suppressSigOnTop = true;
 			if (stripos($content['mail_htmltext'],'<pre>')!==false)
 			{
-				$contentArr = translation::splithtmlByPRE($content['mail_htmltext']);
+				$contentArr = Api\Mail\Html::splithtmlByPRE($content['mail_htmltext']);
 				if (is_array($contentArr))
 				{
 					foreach ($contentArr as $k =>&$elem)
@@ -563,7 +568,7 @@
 				}
 			}
 			$content['mail_htmltext'] = $this->_getCleanHTML($content['mail_htmltext']);
-			$content['mail_htmltext'] = translation::convertHTMLToText($content['mail_htmltext'],$charset=false,false,true);
+			$content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'],$charset=false,false,true);
 
 			$content['body'] = $content['mail_htmltext'];
 			unset($content['mail_htmltext']);
@@ -665,7 +670,7 @@
 				{
 					$content['body'] = str_replace("\n",'\n',$content['body']);	// dont know why, but \n screws up preg_replace
 					$styles = Mail::getStyles(array(array('body'=>$content['body'])));
-					if (stripos($content['body'],'style')!==false) translation::replaceTagsCompletley($content['body'],'style',$endtag='',true); // clean out empty or pagewide style definitions / left over tags
+					if (stripos($content['body'],'style')!==false) Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true); // clean out empty or pagewide style definitions / left over tags
 				}
 				$content['body'] = str_replace(array("\r","\t","<br />\n",": "),array("","","<br />",":"),($_currentMode == 'html'?html::purify($content['body'],Mail::$htmLawed_config,array(),true):$content['body']));
 				Mail::$htmLawed_config = $_htmlConfig;
@@ -747,7 +752,7 @@
 				$mt = $_REQUEST['method'];
 				$id = $_REQUEST['id'];
 				// passed method MUST be registered
-				$method = egw_link::get_registry($app,$mt);
+				$method = Link::get_registry($app,$mt);
 				//error_log(__METHOD__.__LINE__.array2string($method));
 				if ($method)
 				{
@@ -905,13 +910,13 @@
 							// special handling for attaching vCard of iCal --> use their link-title as name
 							if (substr($path,-7) != '/.entry' ||
 								!(list($app,$id) = array_slice(explode('/',$path),-3)) ||
-								!($name = egw_link::title($app, $id)))
+								!($name = Link::title($app, $id)))
 							{
 								$name = Vfs::decodePath(Vfs::basename($path));
 							}
 							else
 							{
-								$name .= '.'.mime_magic::mime2ext($type);
+								$name .= '.'.Api\MimeMagic::mime2ext($type);
 							}
 							// use type specified by caller, if Vfs reports only default, or contains specified type (eg. "text/vcard; charset=utf-8")
 							if (!empty($types[$k]) && ($type == 'application/octet-stream' || stripos($types[$k], $type) === 0))
@@ -928,14 +933,14 @@
 							if ($formData['type'] == Vfs::DIR_MIME_TYPE && $content['filemode'] == Vfs\Sharing::ATTACH)
 							{
 								$content['filemode'] = Vfs\Sharing::READONLY;
-								egw_framework::message(lang('Directories have to be shared.'), 'info');
+								Framework::message(lang('Directories have to be shared.'), 'info');
 							}
 						}
 						elseif(is_readable($path))
 						{
 							$formData = array(
 								'name' => isset($names[$k]) ? $names[$k] : basename($path),
-								'type' => isset($types[$k]) ? $types[$k] : (function_exists('mime_content_type') ? mime_content_type($path) : mime_magic::filename2mime($path)),
+								'type' => isset($types[$k]) ? $types[$k] : (function_exists('mime_content_type') ? mime_content_type($path) : Api\MimeMagic::filename2mime($path)),
 								'file' => $path,
 								'size' => filesize($path),
 							);
@@ -991,8 +996,8 @@
 						$content['to'] = $email;
 					}
 				}
-				if (strpos($content['to'],'%40')!== false) $content['to'] = html::purify(str_replace('%40','@',$content['to']));
-				$rarr = array(html::purify($rest));
+				if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to']));
+				$rarr = array(Api\Html::purify($rest));
 				if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest);
 				//error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr));
 				$karr = array();
@@ -1011,7 +1016,7 @@
 				{
 					if ($karr[$name]) $content[$name] = $karr[$name];
 				}
-				if (!empty($_REQUEST['subject'])) $content['subject'] = html::purify(trim(html_entity_decode($_REQUEST['subject'])));
+				if (!empty($_REQUEST['subject'])) $content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject'])));
 			}
 		}
 		//error_log(__METHOD__.__LINE__.array2string($content));
@@ -1054,7 +1059,7 @@
 			}
 		}
 
-		if ($content['mimeType'] == 'html' && html::htmlarea_availible()===false)
+		if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible()===false)
 		{
 			$_content['mimeType'] = $content['mimeType'] = 'plain';
 			$content['body'] = $this->convertHTMLToText($content['body']);
@@ -1152,7 +1157,7 @@
 
 		// prepare body
 		// in a way, this tests if we are having real utf-8 (the displayCharset) by now; we should if charsets reported (or detected) are correct
-		$content['body'] = translation::convert_jsonsafe($content['body'],'utf-8');
+		$content['body'] = Api\Translation::convert_jsonsafe($content['body'],'utf-8');
 		//error_log(__METHOD__.__LINE__.array2string($content));
 
 		// get identities of all accounts as "$acc_id:$ident_id" => $identity
@@ -1254,7 +1259,7 @@
 		$sel_options['filemode'] = Vfs\Sharing::$modes;
 		if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3;
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
-		$etpl = new Api\Etemplate('mail.compose');
+		$etpl = new Etemplate('mail.compose');
 
 		$etpl->setElementAttribute('composeToolbar', 'actions', $this->getToolbarActions($_content));
 		if ($content['mimeType']=='html')
@@ -1404,7 +1409,7 @@
 			 * Use ajax_merge to merge & send multiple
 			 */
 			// Merge selected ID (in mailtocontactbyid or $mail_id) into given document
-			$merge_class = preg_match('/^([a-z_-]+_merge)$/', $_REQUEST['merge']) ? $_REQUEST['merge'] : 'addressbook_merge';
+			$merge_class = preg_match('/^([a-z_-]+_merge)$/', $_REQUEST['merge']) ? $_REQUEST['merge'] : 'EGroupware\\Api\\Contacts\\Merge';
 			$document_merge = new $merge_class();
 			$this->mail_bo->openConnection();
 			$merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id;
@@ -1439,11 +1444,11 @@
 				{
 					$success = implode(', ',$results['success']);
 					$fail = implode(', ', $results['failed']);
-					if($success) egw_framework::message($success, 'success');
-					egw_framework::window_close($fail);
-				}
-			}
-			catch (egw_exception_wrong_userinput $e)
+					if($success) Framework::message($success, 'success');
+					Framework::window_close($fail);
+				}
+			}
+			catch (Api\Exception\WrongUserinput $e)
 			{
 				// if this returns with an exeption, something failed big time
 				$content['msg'] = $e->getMessage();
@@ -1463,7 +1468,7 @@
 	static function replaceEmailAdresses(&$text)
 	{
 		// replace emailaddresses eclosed in <> (eg.: <[email protected]>) with the emailaddress only (e.g: [email protected])
-		translation::replaceEmailAdresses($text);
+		Api\Mail\Html::replaceEmailAdresses($text);
 		return 1;
 	}
 
@@ -1472,7 +1477,7 @@
 		$stripalltags = true;
 		// third param is stripalltags, we may not need that, if the source is already in ascii
 		if (!$sourceishtml) $stripalltags=false;
-		return translation::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags);
+		return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags);
 	}
 
 	function generateRFC822Address($_addressObject)
@@ -1644,7 +1649,7 @@
 					$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
 				}
 				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
-				$bodyParts[$i]['body'] = translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
+				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
 				#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
 				$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
 			}
@@ -1658,7 +1663,7 @@
 					$this->sessionData['body'] .= "<hr>";
 				}
 				if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']);
-				$bodyParts[$i]['body'] = translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
+				$bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
 				#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
 				$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
 			}
@@ -1779,11 +1784,11 @@
 		{
 			$tmpFileName = Mail::checkFileBasics($_formData,$this->composeID,false);
 		}
-		catch (egw_exception_wrong_userinput $e)
+		catch (Api\Exception\WrongUserinput $e)
 		{
 			$attachfailed = true;
 			$alert_msg = $e->getMessage();
-			egw_framework::message($e->getMessage(), 'error');
+			Framework::message($e->getMessage(), 'error');
 		}
 		//error_log(__METHOD__.__LINE__.array2string($tmpFileName));
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
@@ -1832,7 +1837,7 @@
 	function getAttachment()
 	{
 		// read attachment data from etemplate request, use tmpname only to identify it
-		if (($request = etemplate_request::read($_GET['etemplate_exec_id'])))
+		if (($request = Etemplate\Request::read($_GET['etemplate_exec_id'])))
 		{
 			foreach($request->preserv['attachments'] as $attachment)
 			{
@@ -1871,7 +1876,7 @@
 				$buff = explode('.',$attachment['tmp_name']);
 				$suffix = '';
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
-				if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix);
+				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
 				$attachment['type'] = $sfxMimeType;
 				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
 			}
@@ -1926,10 +1931,10 @@
 			}
 		}
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
-		html::safe_content_header($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save");
+		Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save");
 		echo $attachment['attachment'];
 
-		common::egw_exit();
+		exit();
 	}
 
 	/**
@@ -2111,7 +2116,7 @@
 				$_htmlConfig = Mail::$htmLawed_config;
 				Mail::$htmLawed_config['comment'] = 2;
 				Mail::$htmLawed_config['transform_anchor'] = false;
-				$this->sessionData['body'] .= "<br>".self::_getCleanHTML(translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']));
+				$this->sessionData['body'] .= "<br>".self::_getCleanHTML(Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']));
 				Mail::$htmLawed_config = $_htmlConfig;
 				#error_log( "GetReplyData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
 			}
@@ -2134,7 +2139,7 @@
 				}
 
 				// add line breaks to $bodyParts
-				$newBody2 = translation::convert_jsonsafe($bodyParts[$i]['body'],$bodyParts[$i]['charSet']);
+				$newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'],$bodyParts[$i]['charSet']);
 				#error_log( "GetReplyData (Plain) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
 				$newBody = mail_ui::resolve_inline_images($newBody2, $_folder, $_uid, $_partID, 'plain');
 				$this->sessionData['body'] .= "\r\n";
@@ -2211,12 +2216,12 @@
 	/**
 	 * Create a message from given data and identity
 	 *
-	 * @param egw_mailer $_mailObject
+	 * @param Api\Mailer $_mailObject
 	 * @param array $_formData
 	 * @param array $_identity
 	 * @param boolean $_autosaving =false true: autosaving, false: save-as-draft or send
 	 */
-	function createMessage(egw_mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false)
+	function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false)
 	{
 		if (substr($_formData['body'], 0, 27) == '-----BEGIN PGP MESSAGE-----')
 		{
@@ -2496,7 +2501,7 @@
 
 			if ($html)
 			{
-				$links[] = html::a_href($name, $link).' '.
+				$links[] = Api\Html::a_href($name, $link).' '.
 					(is_dir($path) ? lang('Directory') : Vfs::hsize($attachment['size']));
 			}
 			else
@@ -2525,7 +2530,7 @@
 	public function ajax_saveAsDraft ($content, $action='button[saveAsDraft]')
 	{
 		//error_log(__METHOD__.__LINE__.array2string($content)."(, action=$action)");
-		$response = egw_json_response::get();
+		$response = Api\Json\Response::get();
 		$success = true;
 
 		// check if default account is changed then we need to change profile
@@ -2573,7 +2578,7 @@
 							{
 								$this->mail_bo->deleteMessages($duid,$dmailbox,'remove_immediately');
 							}
-							catch (egw_exception $e)
+							catch (Api\Exception $e)
 							{
 								$msg = str_replace('"',"'",$e->getMessage());
 								$success = false;
@@ -2591,10 +2596,10 @@
 			}
 			else
 			{
-				throw new egw_exception_wrong_userinput(lang("Error: Could not save Message as Draft"));
-			}
-		}
-		catch (egw_exception_wrong_userinput $e)
+				throw new Api\Exception\WrongUserinput(lang("Error: Could not save Message as Draft"));
+			}
+		}
+		catch (Api\Exception\WrongUserinput $e)
 		{
 			$msg = str_replace('"',"'",$e->getMessage());
 			error_log(__METHOD__.__LINE__.$msg);
@@ -2658,7 +2663,7 @@
 	{
 		//error_log(__METHOD__."(..., $savingDestination, action=$action)");
 		$mail_bo	= $this->mail_bo;
-		$mail		= new egw_mailer($this->mail_bo->profileID);
+		$mail		= new Api\Mailer($this->mail_bo->profileID);
 
 		// preserve the bcc and if possible the save to folder information
 		$this->sessionData['folder']    = $_formData['folder'];
@@ -2716,7 +2721,7 @@
 			{
 				$messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags);
 			}
-			catch (egw_exception_wrong_userinput $e)
+			catch (Api\Exception\WrongUserinput $e)
 			{
 				error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",__METHOD__,$savingDestination,$e->getMessage()));
 				return false;
@@ -2733,7 +2738,7 @@
 	function send($_formData)
 	{
 		$mail_bo	= $this->mail_bo;
-		$mail 		= new egw_mailer($mail_bo->profileID);
+		$mail 		= new Api\Mailer($mail_bo->profileID);
 		$messageIsDraft	=  false;
 
 		$this->sessionData['mailaccount']	= $_formData['mailaccount'];
@@ -3001,7 +3006,7 @@
 						//error_log(__METHOD__.__LINE__.array2string($folderName));
 						$mail_bo->appendMessage($folderName, $mail->getRaw(), null, $flags);
 					}
-					catch (egw_exception_wrong_userinput $e)
+					catch (Api\Exception\WrongUserinput $e)
 					{
 						error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$this->sessionData['subject'],$folderName,$e->getMessage()));
 					}
@@ -3035,7 +3040,7 @@
 						//error_log(__METHOD__.__LINE__.array2string($folderName));
 						$this->mail_bo->appendMessage($folderName, $mail->getRaw(), null, $flags);
 					}
-					catch (egw_exception_wrong_userinput $e)
+					catch (Api\Exception\WrongUserinput $e)
 					{
 						error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$this->sessionData['subject'],$folderName,$e->getMessage()));
 					}
@@ -3076,7 +3081,7 @@
 					$mail_bo->deleteMessages($lastDrafted['uid'],$lastDrafted['folder'],'remove_immediately');
 				}
 			}
-			catch (egw_exception $e)
+			catch (Api\Exception $e)
 			{
 				//error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage()));
 				unset($e);
@@ -3103,7 +3108,7 @@
 						$mail_bo->deleteMessages(array($this->sessionData['uid']),$this->sessionData['messageFolder']);
 					}
 				}
-				catch (egw_exception $e)
+				catch (Api\Exception $e)
 				{
 					//error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage()));
 					unset($e);
@@ -3118,7 +3123,7 @@
 						//error_log(__METHOD__.__LINE__.':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']);
 						$mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'],$this->sessionData['sourceFolder']);
 					}
-					catch (egw_exception $e)
+					catch (Api\Exception $e)
 					{
 						//error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage()));
 						unset($e);
@@ -3152,7 +3157,7 @@
 				{
 					$app_name = substr($app_key,3);
 					// Get registered hook data of the app called for integration
-					$hook = $GLOBALS['egw']->hooks->single(array('location'=> 'mail_import'),$app_name);
+					$hook = Api\Hooks::single(array('location'=> 'mail_import'),$app_name);
 
 					// store mail / eml in temp. file to not have to download it from mail-server again
 					$eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'mail_integrate');
@@ -3163,9 +3168,9 @@
 					// Open the app called for integration in a popup
 					// and store the mail raw data as egw_data, in order to
 					// be stored from registered app method later
-					egw_framework::popup(egw::link('/index.php', array(
+					Framework::popup(Egw::link('/index.php', array(
 						'menuaction' => $hook['menuaction'],
-						'egw_data' => egw_link::set_data(null,'mail_integration::integrate',array(
+						'egw_data' => Link::set_data(null,'mail_integration::integrate',array(
 							$mailaddresses,
 							$this->sessionData['subject'],
 							$this->convertHTMLToText($this->sessionData['body']),
@@ -3281,7 +3286,7 @@
 			{
 				$useCacheIfPossible = true;
 			}
-			$searchString = translation::convert($_searchString, Mail::$displayCharset,'UTF7-IMAP');
+			$searchString = Api\Translation::convert($_searchString, Mail::$displayCharset,'UTF7-IMAP');
 			foreach ($folderObjects as $k =>$fA)
 			{
 				//error_log(__METHOD__.__LINE__.$_searchString.'/'.$searchString.' in '.$k.'->'.$fA->displayName);
@@ -3317,12 +3322,12 @@
 			return $rL;
 		}
 		// switch regular JSON response handling off
-		egw_json_request::isJSONRequest(false);
+		Api\Json\Request::isJSONRequest(false);
 
 		header('Content-Type: application/json; charset=utf-8');
 		//error_log(__METHOD__.__LINE__);
 		echo json_encode($results);
-		common::egw_exit();
+		exit();
 	}
 
 	public static function ajax_searchAddress($_searchStringLength=2) {
@@ -3432,7 +3437,7 @@
 		if($include_lists)
 		{
 			$lists = array_filter(
-				$contacts_obj->get_lists(EGW_ACL_READ),
+				$contacts_obj->get_lists(Acl::READ),
 				function($element) use($_searchString) {
 					return (stripos($element, $_searchString) !== false);
 				}
@@ -3452,12 +3457,12 @@
 			}
 		}
 		 // switch regular JSON response handling off
-		egw_json_request::isJSONRequest(false);
+		Api\Json\Request::isJSONRequest(false);
 
 		//error_log(__METHOD__.__LINE__.array2string($jsArray));
 		header('Content-Type: application/json; charset=utf-8');
 		echo json_encode($results);
-		common::egw_exit();
+		exit();
 	}
 
 	/**
@@ -3468,14 +3473,14 @@
 	 */
 	public function ajax_merge($contact_id)
 	{
-		$response = egw_json_response::get();
-		if(class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'],'bo_merge'))
+		$response = Api\Json\Response::get();
+		if(class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge'))
 		{
 			$document_merge = new $_REQUEST['merge']();
 		}
 		else
 		{
-			$document_merge = new addressbook_merge();
+			$document_merge = new Api\Contacts\Merge();
 		}
 		$this->mail_bo->openConnection();
 

Modified: trunk/mail/inc/class.mail_hooks.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/mail/inc/class.mail_hooks.inc.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/mail/inc/class.mail_hooks.inc.php (original)
+++ trunk/mail/inc/class.mail_hooks.inc.php Tue May  3 21:17:44 2016
@@ -11,6 +11,7 @@
  */
 
 use EGroupware\Api;
+use EGroupware\Api\Egw;
 use EGroupware\Api\Mail;
 
 /**
@@ -31,7 +32,7 @@
 		if (Mail\Account::is_multiple($account) && $account['acc_imap_admin_username'] ||
 			$account['acc_imap_type'] == 'managementserver_imap')
 		{
-			translation::add_app('mail');
+			Api\Translation::add_app('mail');
 
 			if (true /* ToDo check ACL available */ || $account['acc_imap_type'] == 'managementserver_imap')
 			{
@@ -40,7 +41,7 @@
 					'caption' => 'Folder ACL',
 					'icon' => 'lock',
 					'popup' => '750x420',
-					'url' => egw::link('/index.php', array(
+					'url' => Egw::link('/index.php', array(
 						'menuaction' => 'mail.mail_acl.edit',
 						'acc_id' => $data['acc_id'],
 						'account_id' => $data['account_id'],
@@ -55,7 +56,7 @@
 					'caption' => 'Vacation notice',
 					'icon' => 'mail/navbar',
 					'popup' => '750x420',
-					'url' => egw::link('/index.php', array(
+					'url' => Egw::link('/index.php', array(
 						'menuaction' => 'mail.mail_sieve.editVacation',
 						'acc_id' => $data['acc_id'],
 						'account_id' => $data['account_id'],
@@ -70,11 +71,13 @@
 	/**
      * Hook called by link-class to include mail in the appregistry of the linkage
      *
-     * @param array/string $location location and other parameters (not used)
+     * @param array|string $location location and other parameters (not used)
      * @return array with method-names
      */
     static function search_link($location)
     {
+		unset($location);	// not used, but required by function signature
+
         return array(
 			'view'  => array(
 				'menuaction' => 'mail.mail_ui.displayMessage',
@@ -122,22 +125,7 @@
 			$profileID = 0;
 			if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']))
 				$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
-
-			$mailConfig = config::read('mail');
-		}
-
-		$connectionTimeout = array(
-			'0' => lang('use default timeout (20 seconds)'),
-			'10' => '10', // timeout used in SIEVE
-			'20' => '20',
-			'30' => '30',
-			'40' => '40',
-			'50' => '50',
-			'60' => '60',
-			'70' => '70',
-			'80' => '80',
-			'90' => '90',
-		);
+		}
 
 		$no_yes = array(
 			'0' => lang('no'),
@@ -145,35 +133,13 @@
 		);
 		$no_yes_copy = array_merge($no_yes,array('2'=>lang('yes, offer copy option')));
 
- 		$prefAllowManageFolders = $no_yes;
-
 		$forwardOptions = array(
 			'asmail' => lang('forward as attachment'),
 			'inline' => lang('forward inline'),
 		);
-		$sortOrder = array(
-			'0' => lang('date(newest first)'),
-			'1' => lang('date(oldest first)'),
-			'3' => lang('from(A->Z)'),
-			'2' => lang('from(Z->A)'),
-			'5' => lang('subject(A->Z)'),
-			'4' => lang('subject(Z->A)'),
-			'7' => lang('size(0->...)'),
-			'6' => lang('size(...->0)')
-		);
-
 		$trustServersUnseenOptions = array_merge(
 			$no_yes,
 			array('2' => lang('yes') . ' - ' . lang('but check shared folders'))
-		);
-
-		$selectOptions = array_merge(
-			$no_yes,
-			array('2' => lang('yes') . ' - ' . lang('small view'))
- 		);
-		$newWindowOptions = array(
-			'1' => lang('only one window'),
-			'2' => lang('allways a new window'),
 		);
 
 		$deleteOptions = array(
@@ -208,45 +174,9 @@
 			'only_if_no_text'	=> lang('display only when no plain text is available'),
 			'always_display'	=> lang('always show html emails'),
 		);
-		$toggle = false;
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode'] == 'EGW_SELECTMODE_TOGGLE') $toggle=true;
-		$rowOrderStyle = array(
-			'mail'	=> lang('mail'),
-			'outlook'	=> 'Outlook',
-			'mail_wCB' => lang('mail').' '.($toggle?lang('(select mails by clicking on the line, like a checkbox)'):lang('(with checkbox enforced)')),
-			'outlook_wCB'	=> 'Outlook'.' '.($toggle?lang('(select mails by clicking on the line, like a checkbox)'):lang('(with checkbox enforced)')),
-		);
 
 		// otherwise we get warnings during setup
 		if (!is_array($folderList)) $folderList = array();
-
-		$trashOptions = array_merge(
-			array(
-				'none' => lang("Don't use Trash")
-			),
-			$folderList
-		);
-
-		$sentOptions = array_merge(
-			array(
-				'none' => lang("Don't use Sent")
-			),
-			$folderList
-		);
-
-		$draftOptions = array_merge(
-			array(
-				'none' => lang("Don't use draft folder")
-			),
-			$folderList
-		);
-
-		$templateOptions = array_merge(
-		    array(
-		        'none' => lang("Don't use template folder")
-		    ),
-		    $folderList
-		);
 
 		// modify folderlist, add a none entry, to be able to force the regarding settings, if no folders apply
 		$folderList['none'] = lang('no folders');
@@ -434,6 +364,8 @@
 	 */
 	static function admin($hook_data)
 	{
+		unset($hook_data);	// not used, but required by function signature
+
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
 		// Only Modify the $file and $title variables.....
 		$title = $appname = 'mail';
@@ -442,7 +374,7 @@
 			$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
 
 		$file = Array(
-			'Site Configuration' => egw::link('/index.php',array('menuaction'=>'admin.uiconfig.index','appname'=>'mail')),
+			'Site Configuration' => Egw::link('/index.php',array('menuaction'=>'admin.uiconfig.index','appname'=>'mail')),
 		);
 		display_section($appname,$title,$file);
 	}
@@ -454,6 +386,8 @@
 	 */
 	static function sidebox_menu($hook_data)
 	{
+		unset($hook_data);	// not used, but required by function signature
+
 		//error_log(__METHOD__);
 		// always show the side bar
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
@@ -513,7 +447,7 @@
 		);
 
 		$file += array(
-			'import message' => "javascript:egw_openWindowCentered2('".egw::link('/index.php', $linkData,false)."','importMessageDialog',600,100,'no','$appname');",
+			'import message' => "javascript:egw_openWindowCentered2('".Egw::link('/index.php', $linkData,false)."','importMessageDialog',600,100,'no','$appname');",
 		);
 
 
@@ -522,21 +456,21 @@
 		{
 			$file += array(
 				'create new account' => "javascript:egw_openWindowCentered2('" .
-					egw::link('/index.php', array('menuaction' => 'mail.mail_wizard.add'), '').
+					Egw::link('/index.php', array('menuaction' => 'mail.mail_wizard.add'), '').
 					"','_blank',640,480,'yes')",
 			);
 		}
 		// display them all
 		display_sidebox($appname,$menu_title,$file);
 
-		if ($GLOBALS['egw_info']['user']['apps']['admin'] && !html::$ua_mobile)
+		if ($GLOBALS['egw_info']['user']['apps']['admin'] && !Api\Header\UserAgent::mobile())
 		{
 			$file = Array(
-				'Site Configuration' => egw::link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname),
+				'Site Configuration' => Egw::link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname),
 			);
 			display_sidebox($appname,lang('Admin'),$file);
 		}
-		hooks::pgp_encryption_menu('mail');
+		Api\Hooks::pgp_encryption_menu('mail');
 
 	}
 
@@ -555,7 +489,7 @@
 			//error_log(__METHOD__.__LINE__." Job should not run too often; we limit this to once every 3 Minutes :". ($currentTime-$lastRun). " Seconds to go!");
 			return true;
 		}
-		$accountsToSearchObj = Mail\Account::search($only_current_user=true, $just_name=true);
+		$accountsToSearchObj = Mail\Account::search(true, true);
 
 		foreach($accountsToSearchObj as $acc_id => $identity_name)
 		{
@@ -614,8 +548,7 @@
 						$notified_mail_uidsCache[$activeProfile][$notify_folder] = array();
 					}
 					$folder_status[$notify_folder] = $bomail->getFolderStatus($notify_folder);
-					$cutoffdate = time();
-					$cutoffdate = $cutoffdate - (60*60*24*14); // last 14 days
+					$cutoffdate = time() - (60*60*24*14); // last 14 days
 					$_filter = array('status'=>array('UNSEEN','UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate));
 					//error_log(__METHOD__.__LINE__.' (user: '.$currentRecipient->account_lid.') Mailbox:'.$notify_folder.' filter:'.array2string($_filter));
 					// $_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true
@@ -695,7 +628,7 @@
 		{
 			return true;	// allways give admins or emailadmins all rights, even if they are in a denied group
 		}
-		if (!isset($config)) $config = (array)config::read('mail');
+		if (!isset($config)) $config = (array)Api\Config::read('mail');
 		//error_log(__METHOD__.__LINE__.' '.$feature.':'.array2string($config['deny_'.$feature]));
 		if (!empty($config['deny_'.$feature]))
 		{

Modified: trunk/mail/inc/class.mail_integration.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/mail/inc/class.mail_integration.inc.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/mail/inc/class.mail_integration.inc.php (original)
+++ trunk/mail/inc/class.mail_integration.inc.php Tue May  3 21:17:44 2016
@@ -9,6 +9,9 @@
  * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
  * @version $Id:$
  */
+
+use EGroupware\Api;
+use EGroupware\Api\Link;
 
 /**
  * Class cotains methods and functions
@@ -60,7 +63,7 @@
 	 * @param string $_date
 	 * @param string $_rawMail path to file with raw mail
 	 * @param int $_icServerID mail profile id
-	 * @throws egw_exception_assertion_failed
+	 * @throws Api\Exception\AssertionFailed
 	 */
 	public static function integrate ($_to_emailAddress=false,$_subject=false,$_body=false,$_attachments=false,$_date=false,$_rawMail=null,$_icServerID=null)
 	{
@@ -74,7 +77,7 @@
 		if (!$_date)
 		{
 			$time = time();
-			$_date = egw_time::server2user($time->now,'ts');
+			$_date = Api\DateTime::server2user($time->now,'ts');
 		}
 
 		// For dealing with multiple files of the same name
@@ -91,10 +94,10 @@
 			if (!($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='text_only')&&is_array($_attachments))
 			{
 				// initialize mail open connection requirements
-				if (!isset($_icServerID)) $_icServerID =& egw_cache::getSession($sessionLocation,'activeProfileID');
+				if (!isset($_icServerID)) $_icServerID =& Api\Cache::getSession($sessionLocation,'activeProfileID');
 				$mo = mail_bo::getInstance(true,$_icServerID);
 				$mo->openConnection();
-				$messageUID = $messagePartId = $messageFolder = null;
+				$messagePartId = $messageFolder = null;
 				foreach ($_attachments as $attachment)
 				{
 					//error_log(__METHOD__.__LINE__.array2string($attachment));
@@ -165,7 +168,7 @@
 					{
 						$mo->deleteMessages(array($messageUid),$messageFolder);
 					}
-					catch (egw_exception $e)
+					catch (Api\Exception $e)
 					{
 						//error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage()));
 						unset($e);
@@ -222,14 +225,14 @@
 			$hA = mail_ui::splitRowID($_GET['rowid']);
 			$sessionLocation = $hA['app']; // THIS is part of the row ID, we may use this for validation
 			// Check the mail app
-			if ($sessionLocation != 'mail') throw new egw_exception_assertion_failed(lang('Application mail expected but got: %1',$sessionLocation));
+			if ($sessionLocation != 'mail') throw new Api\Exception\AssertionFailed(lang('Application mail expected but got: %1',$sessionLocation));
 			$uid = $hA['msgUID'];
 			$mailbox = $hA['folder'];
 			$icServerID = $hA['profileID'];
 
 			if ($uid && $mailbox)
 			{
-				if (!isset($icServerID)) $icServerID =& egw_cache::getSession($sessionLocation,'activeProfileID');
+				if (!isset($icServerID)) $icServerID =& Api\Cache::getSession($sessionLocation,'activeProfileID');
 				$mo	= mail_bo::getInstance(true,$icServerID);
 				$mo->openConnection();
 				$mo->reopen($mailbox);
@@ -292,7 +295,7 @@
 				);
 				if ($uid && !$mailcontent['attachments'][$key]['add_raw'])
 				{
-					$data_attachments[$key]['egw_data'] = egw_link::set_data($mailcontent['attachments'][$key]['mimeType'],
+					$data_attachments[$key]['egw_data'] = Link::set_data($mailcontent['attachments'][$key]['mimeType'],
 						'EGroupware\\Api\\Mail::getAttachmentAccount',array($icServerID, $mailbox, $uid, $attachment['partID'], $is_winmail, true),true);
 				}
 				unset($mailcontent['attachments'][$key]['add_raw']);
@@ -300,21 +303,18 @@
 		}
 
 		// Check if the hook is registered
-		if ($GLOBALS['egw']->hooks->hook_exists('mail_import',$app) == 0)
+		if (Api\Hooks::exists('mail_import',$app) == 0)
 		{
 			// Try to register hook
-			if(!$GLOBALS['egw']->hooks->register_single_app_hook($app,'mail_import'))
-			{
-				throw new egw_exception_assertion_failed('Hook import_mail registration faild for '.$app.' app! Please, contact your system admin in order to clear cache and register hooks.');
-			}
+			Api\Hooks::read(true);
 		}
 
 		// Get the registered hook method of requested app for integration
-		$hook = $GLOBALS['egw']->hooks->single(array('location' => 'mail_import'),$app);
-
-		// Load translation for the app since the original URL
-		// is from mail integration and only loads mail translation
-		translation::add_app($app);
+		$hook = Api\Hooks::single(array('location' => 'mail_import'),$app);
+
+		// Load Api\Translation for the app since the original URL
+		// is from mail integration and only loads mail Api\Translation
+		Api\Translation::add_app($app);
 
 		// Execute import mail with provided content
 		ExecMethod($hook['menuaction'],array (

Modified: trunk/mail/inc/class.mail_sieve.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/mail/inc/class.mail_sieve.inc.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/mail/inc/class.mail_sieve.inc.php (original)
+++ trunk/mail/inc/class.mail_sieve.inc.php Tue May  3 21:17:44 2016
@@ -11,6 +11,8 @@
  */
 
 use EGroupware\Api;
+use EGroupware\Api\Framework;
+use EGroupware\Api\Etemplate;
 use EGroupware\Api\Mail;
 
 class mail_sieve
@@ -91,8 +93,8 @@
 		{
 			Api\Cache::setSession(__CLASS__, 'acc_id', $this->account->acc_id);
 		}
-		//Instantiate an Api\Etemplate object
-		$tmpl = new Api\Etemplate('mail.sieve.index');
+		//Instantiate an eTemplate object
+		$tmpl = new Etemplate('mail.sieve.index');
 
 		if ($msg)
 		{
@@ -131,8 +133,8 @@
 	 */
 	function editEmailNotification($content=null, $msg='')
 	{
-		//Instantiate an Api\Etemplate object, representing sieve.emailNotification
-		$eNotitmpl = new Api\Etemplate('mail.sieve.emailNotification');
+		//Instantiate an eTemplate object, representing sieve.emailNotification
+		$eNotitmpl = new Etemplate('mail.sieve.emailNotification');
 
 		if ($this->account->acc_sieve_enabled)
 		{
@@ -186,14 +188,14 @@
 							$msg .= lang('email notification update failed! You need to set an email address!');
 							break;
 						}
-						egw_framework::refresh_opener($msg, 'mail');
+						Framework::refresh_opener($msg, 'mail');
 						if ($button === 'apply')
 						{
 							break;
 						}
 
 					case 'cancel':
-						egw_framework::window_close();
+						Framework::window_close();
 						exit;
 				}
 				$this->saveSessionData();
@@ -226,8 +228,8 @@
 	 */
 	function edit ($content=null)
 	{
-		//Instantiate an Api\Etemplate object, representing sieve.edit template
-		$etmpl = new Api\Etemplate('mail.sieve.edit');
+		//Instantiate an eTemplate object, representing sieve.edit template
+		$etmpl = new Etemplate('mail.sieve.edit');
 		$etmpl->setElementAttribute('action_folder_text','autocomplete_params', array('noPrefixId'=> true));
 		if (!is_array($content))
 		{
@@ -333,7 +335,7 @@
 						$msg .= "\n".lang("Error: Could not save rule").' '.lang("No action defined!");
 						$error++;
 					}
-					egw_framework::refresh_opener($msg, 'mail', 'sieve');
+					Framework::refresh_opener($msg, 'mail', 'sieve');
 					if ($button == "apply")
 					{
 						break;
@@ -356,10 +358,10 @@
 						$this->rules = array_values($this->rules);
 						$this->updateScript();
 					}
-					egw_framework::refresh_opener($msg, 'mail', 'sieve');
+					Framework::refresh_opener($msg, 'mail', 'sieve');
 
 				case 'cancel':
-					egw_framework::window_close();
+					Framework::window_close();
 					exit;
 			}
 		}
@@ -397,7 +399,7 @@
 	{
 		if(!(empty($this->mailConfig['prefpreventnotificationformailviaemail']) || $this->mailConfig['prefpreventnotificationformailviaemail'] == 0))
 		{
-			throw new egw_exception_no_permission();
+			throw new Api\Exception\NoPermission();
 		}
 
 		try {
@@ -421,7 +423,7 @@
 	{
 		if(!(empty($this->mailConfig['prefpreventabsentnotice']) || $this->mailConfig['prefpreventabsentnotice'] == 0))
 		{
-			throw new egw_exception_no_permission();
+			throw new Api\Exception\NoPermission();
 		}
 		try {
 			if ($this->is_admin_vac)
@@ -438,11 +440,11 @@
 		}
 		catch(Exception $e)
 		{
-			egw_framework::window_close(lang($e->getMessage()));
+			Framework::window_close(lang($e->getMessage()));
 		}
 		if (is_null($accountID)) $accountID = $GLOBALS['egw_info']['user']['account_id'];
 
-		$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(accounts::id2name($accountID));
+		$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID));
 		$allAliases = array($this->account->ident_email);
 		foreach ($accAllIdentities as &$arrVal)
 		{
@@ -466,8 +468,8 @@
 	 */
 	function editVacation($content=null, $msg='')
 	{
-		//Instantiate an Api\Etemplate object, representing the sieve.vacation template
-		$vtmpl = new Api\Etemplate('mail.sieve.vacation');
+		//Instantiate an eTemplate object, representing the sieve.vacation template
+		$vtmpl = new Etemplate('mail.sieve.vacation');
 		$vacation = array();
 
 		if (isset($_GET['account_id'])) $account_id = $preserv['account_id'] = $_GET['account_id'];
@@ -557,7 +559,7 @@
 					if (strlen(trim($content['text']))==0)
 					{
 						$content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.');
-						egw_framework::refresh_opener($msg, 'mail');
+						Framework::refresh_opener($msg, 'mail');
 					}
 					//Set default value for days new entry
 					if (empty($content['days']))
@@ -639,7 +641,7 @@
 										//Reset vacationNotice cache which is used in mail_ui get_rows
 										if (isset($account_id) && $this->mail_admin)
 										{
-											$account_lid = accounts::id2name($account_id,'account_lid');
+											$account_lid = Api\Accounts::id2name($account_id,'account_lid');
 											$cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid);
 											//error_log(__METHOD__.__LINE__.' Setting Cache for '.$account_lid.':'.array2string($cachedVacations));
 											Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$account_lid, $cachedVacations);
@@ -658,9 +660,9 @@
 									$msg .= implode("\n",$this->errorStack);
 								}
 								// refresh vacationNotice on index
-								$response = egw_json_response::get();
+								$response = Api\Json\Response::get();
 								$response->call('app.mail.mail_callRefreshVacationNotice',$icServer->ImapServerId);
-								egw_framework::refresh_opener($msg, 'mail');
+								Framework::refresh_opener($msg, 'mail');
 								if ($button === 'apply' || $icServer->error !=="")
 								{
 									break;
@@ -668,7 +670,7 @@
 							}
 
 						case 'cancel':
-							egw_framework::window_close();
+							Framework::window_close();
 					}
 				}
 
@@ -739,10 +741,10 @@
 	{
 		if (!($_vacation['acc_id'] > 0))
 		{
-			throw new egw_exception_wrong_parameter('No acc_id given!');
+			throw new Api\Exception\WrongParameter('No acc_id given!');
 		}
 		// setting up an async job to enable/disable the vacation message
-		$async = new asyncservice();
+		$async = new Api\AsyncService();
 		if (empty($_vacation['account_id'])) $_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id'];
 		$async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id'];
 		$async->delete($async_id);
@@ -771,7 +773,7 @@
 	 * Callback for the async job to enable/disable the vacation message
 	 *
 	 * @param array $_vacation
-	 * @throws egw_exception_not_found if mail account is not found
+	 * @throws Api\Exception\NotFound if mail account is not found
 	 */
 	static function async_vacation(array $_vacation)
 	{
@@ -788,7 +790,7 @@
 			self::setAsyncJob($_vacation);
 		}
 		// if mail account no longer exists --> remove async job
-		catch (egw_exception_not_found $e)
+		catch (Api\Exception\NotFound $e)
 		{
 			$_vacation['status'] = 'off';
 			self::setAsyncJob($_vacation);
@@ -899,7 +901,7 @@
 		$this->saveSessionData();
 
 		//Calling to referesh after move action
-		$response = egw_json_response::get();
+		$response = Api\Json\Response::get();
 		$response->call('app.mail.sieve_refresh');
 	}
 
@@ -945,7 +947,7 @@
 		ob_start();
 		$result = $this->updateScript();
 
-		$response = egw_json_response::get();
+		$response = Api\Json\Response::get();
 
 		if($result)
 		{

Modified: trunk/mail/inc/class.mail_tree.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/mail/inc/class.mail_tree.inc.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/mail/inc/class.mail_tree.inc.php (original)
+++ trunk/mail/inc/class.mail_tree.inc.php Tue May  3 21:17:44 2016
@@ -5,11 +5,12 @@
  * @link http://www.egroupware.org
  * @package mail
  * @author Hadi Nategh [[email protected]]
- * @copyright (c) 2015 by Stylite AG <info-AT-stylite.de>
+ * @copyright (c) 2015-16 by Stylite AG <info-AT-stylite.de>
  * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
  * @version $Id:$
  */
 
+use EGroupware\Api;
 use EGroupware\Api\Mail;
 use EGroupware\Api\Etemplate\Widget\Tree;
 
@@ -375,7 +376,7 @@
 				}
 				else
 				{
-					throw new egw_exception_assertion_failed(__METHOD__.':'.__LINE__.": id=$data[id]: Parent '$parent' '$component' not found!");
+					throw new Api\Exception\AssertionFailed(__METHOD__.':'.__LINE__.": id=$data[id]: Parent '$parent' '$component' not found!");
 				}
 			}
 			$parents[] = $component;

Modified: trunk/mail/inc/class.mail_ui.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/mail/inc/class.mail_ui.inc.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/mail/inc/class.mail_ui.inc.php (original)
+++ trunk/mail/inc/class.mail_ui.inc.php Tue May  3 21:17:44 2016
@@ -11,6 +11,12 @@
  */
 
 use EGroupware\Api;
+use EGroupware\Api\Link;
+use EGroupware\Api\Framework;
+use EGroupware\Api\Egw;
+use EGroupware\Api\Vfs;
+use EGroupware\Api\Etemplate;
+use EGroupware\Api\Etemplate\KeyManager;
 use EGroupware\Api\Mail;
 
 /**
@@ -145,7 +151,7 @@
 
 			// RegEx to minimize extra openConnection
 			$needle = '/^(?!mail)/';
-			if (!preg_match($needle,$_GET['menuaction']) && !egw_json_request::isJSONRequest())
+			if (!preg_match($needle,$_GET['menuaction']) && !Api\Json\Request::isJSONRequest())
 			{
 				//error_log(__METHOD__.__LINE__.' Fetched IC Server openConnection:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
 				//openConnection gathers SpecialUseFolderInformation and Delimiter Info
@@ -164,7 +170,7 @@
 	 * callWizard
 	 *
 	 * @param string $message
-	 * @param boolean $exit If true, will call common::egw_exit() after opening the wizardpopup
+	 * @param boolean $exit If true, will call exit() after opening the wizardpopup
 	 * @param string $msg_type = 'success' message type
 	 */
 	static function callWizard($message, $exit=true, $msg_type='success')
@@ -180,28 +186,28 @@
 				'msg_type' => $msg_type
 			);
 
-		if (egw_json_response::isJSONResponse())
-		{
-			$response = egw_json_response::get();
+		if (Api\Json\Response::isJSONResponse())
+		{
+			$response = Api\Json\Response::get();
 			$windowName = "editMailAccount".self::$icServerID;
-			$response->call("egw.open_link", egw::link('/index.php', $linkData), $windowName, "600x480",null,true);
-			egw_framework::message($message, 'error');
+			$response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480",null,true);
+			Framework::message($message, 'error');
 			if ($_GET['menuaction'] == 'mail.mail_ui.index')
 			{
 				$response->call('framework.setSidebox','mail',array(),'md5');
 			}
 			if ($exit)
 			{
-				common::egw_exit();
+				exit();
 			}
 		}
 		else	// regular GET request eg. in idots template
 		{
-			egw_framework::popup(egw_framework::link('/index.php',$linkData));
+			Framework::popup(Framework::link('/index.php',$linkData));
 			$GLOBALS['egw']->framework->render($message,'',true);
 			if ($exit)
 			{
-				common::egw_exit();
+				exit();
 			}
 		}
 	}
@@ -212,7 +218,7 @@
 	 * @param int $_icServerID
 	 * @param boolean $unsetCache
 	 *
-	 * @throws egw_exception
+	 * @throws Api\Exception
 	 */
 	function changeProfile($_icServerID,$unsetCache=false)
 	{
@@ -230,16 +236,16 @@
 		if (!isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
 		{
 			self::$icServerID = $_icServerID;
-			throw new egw_exception('Profile change failed!');
+			throw new Api\Exception('Profile change failed!');
 		}
 
 		// save session varchar
-		$oldicServerID =& egw_cache::getSession('mail','activeProfileID');
+		$oldicServerID =& Api\Cache::getSession('mail','activeProfileID');
 		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
-		$oldicServerID = self::$icServerID;
+		if (true) $oldicServerID = self::$icServerID;
 		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
 		{
-			throw new egw_exception(__METHOD__." failed to change Profile to $_icServerID");
+			throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID");
 		}
 
 		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
@@ -252,7 +258,7 @@
 	{
 		$mail_ui = new mail_ui();
 		$id = $_id ? $_id : $_GET['id'];
-		Api\Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,false));
+		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,false));
 	}
 
 	/**
@@ -263,7 +269,7 @@
 	 */
 	function subscription(array $content=null ,$msg=null)
 	{
-		$stmpl = new etemplate_new('mail.subscribe');
+		$stmpl = new Etemplate('mail.subscribe');
 
 		if(is_array($content))
 		{
@@ -271,7 +277,7 @@
 		}
 		elseif (!($profileId = (int)$_GET['acc_id']))
 		{
-			egw_framework::window_close('Missing acc_id!');
+			Framework::window_close('Missing acc_id!');
 		}
 		// Initial tree's options, the rest would be loaded dynamicaly by autoloading,
 		// triggered from client-side. Also, we keep this here as
@@ -284,7 +290,7 @@
 		try {
 			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
 		} catch (Exception $ex) {
-			egw_framework::message($ex->getMessage());
+			Framework::message($ex->getMessage());
 		}
 
 		if (!is_array($content))
@@ -367,7 +373,7 @@
 					$refreshData = array(
 						$profileId => lang($parentFolder),
 					);
-					$response = egw_json_response::get();
+					$response = Api\Json\Response::get();
 					foreach($refreshData as $folder => &$name)
 					{
 						$name = $this->mail_tree->getTree($folder, $profileId,1,true,true,true);
@@ -376,16 +382,16 @@
 					//$response->call('opener.app.mail.subscription_refresh',$refreshData);
 					$response->call('opener.app.mail.mail_reloadNode',$refreshData);
 
-					egw_framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type);
+					Framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type);
 					if ($button == 'apply')
 					{
-						egw_framework::message($msg, $msg_type);
+						Framework::message($msg, $msg_type);
 						break;
 					}
 				}
 				case 'cancel':
 				{
-					egw_framework::window_close();
+					Framework::window_close();
 				}
 			}
 		}
@@ -423,7 +429,7 @@
 				if (!is_array($content))
 				{
 					$content = array(
-						self::$nm_index => egw_session::appsession('index','mail'),
+						self::$nm_index => Api\Cache::getSession('mail', 'index'),
 					);
 					if (!is_array($content[self::$nm_index]))
 					{
@@ -437,7 +443,7 @@
 							'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
 						);
 					}
-					if (html::$ua_mobile) $content[self::$nm_index]['header_row'] = 'mail.index.header_right';
+					if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right';
 				}
 
 				// These must always be set, even if $content is an array
@@ -480,7 +486,7 @@
 					{
 						$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/;
 						$content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = lang('Vacation notice is active');
-						$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status']=='by_date'? common::show_date($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.common::show_date($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
+						$content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
 					}
 				}
 				if ($vacation==false)
@@ -520,7 +526,7 @@
 
 				if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
 				{
-					Mail::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
+					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
 					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
 				}
 				if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
@@ -536,7 +542,7 @@
 				$sel_options['filter2'] = array(''=>lang('No details'),1=>lang('Details'));
 				$content[self::$nm_index]['filter2'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails'];
 
-				$etpl = new etemplate_new('mail.index');
+				$etpl = new Etemplate('mail.index');
 				//apply infolog_filter_change javascript method (hide/show of date filter form) over onchange filter
 				$content[self::$nm_index]['cat_id_onchange'] = "app.mail.mail_searchtype_change()";
 				// Start at 2 so auto-added copy+paste actions show up as second group
@@ -734,7 +740,7 @@
 				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
 
 				// We need to send toolbar actions to client-side because view template needs them
-				if (html::$ua_mobile) $sel_options['toolbar'] = $this->get_toolbar_actions();
+				if (Api\Header\UserAgent::mobile()) $sel_options['toolbar'] = $this->get_toolbar_actions();
 
 				//we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....)
 				if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search']))
@@ -806,7 +812,7 @@
 			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
 		}
 		if (!is_null($_nodeID)) return $data;
-		Api\Etemplate\Widget\Tree::send_quote_json($data);
+		Etemplate\Widget\Tree::send_quote_json($data);
 	}
 
 	/**
@@ -854,8 +860,7 @@
 		$lastFolderUsedForMove = null;
 		$moveactions = array();
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
-		$currentArchiveActionKey = 'move_'.$this->mail_bo->profileID.self::$delimiter.$archiveFolder;
-		$lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
+		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
 		//error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont));
 		//error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]));
 		if (is_null($accArray))
@@ -873,7 +878,7 @@
 			}
 		}
 		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
-		foreach ($lastFoldersUsedForMoveCont as $pid => $info)
+		foreach (array_keys($lastFoldersUsedForMoveCont) as $pid)
 		{
 			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
 			{
@@ -924,14 +929,14 @@
 				}
 			}
 		}
-		egw_cache::setCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
+		Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
 		$group = 0;
 		$actions =  array(
 			'open' => array(
 				'caption' => lang('Open'),
 				'icon' => 'view',
 				'group' => ++$group,
-				'onExecute' => html::$ua_mobile?'javaScript:app.mail.mobileView':'javaScript:app.mail.mail_open',
+				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.mail.mobileView':'javaScript:app.mail.mail_open',
 				'allowOnMultiple' => false,
 				'default' => true,
 				'mobileViewTemplate' => 'view'
@@ -1008,247 +1013,240 @@
 				$pID = $lastFolderUsedForMove['profileID'];
 				$macounter++;
 			}
-			$actions = array_merge($actions,array('moveto' =>
-				array(
-					'caption' => lang('Move selected to'),
-					'icon' => 'move',
-					'group' => $group,
-					'children' => $children,
-					)
-				)
+			$actions['moveto'] =	array(
+				'caption' => lang('Move selected to'),
+				'icon' => 'move',
+				'group' => $group,
+				'children' => $children,
 			);
 
 		} else {
 			$group++;
 		}
-		
+
 		//error_log(__METHOD__.__LINE__.$archiveFolder);
-		$actions = array_merge($actions,
-			array(
-				'move2'.$this->mail_bo->profileID.self::$delimiter.$archiveFolder => array( //toarchive
-					'caption' => 'Move to archive',
-					'hint' => 'move selected mails to archive',
-					'icon' => 'move',
-					'group' => $group++,
-					'enabled' => 'javaScript:app.mail.archivefolder_enabled',
-					//'hideOnDisabled' => true, // does not work as expected on message-list
-					'onExecute' => 'javaScript:app.mail.mail_move2folder',
-					'shortcut' => egw_keymanager::shortcut(egw_keymanager::V, true, true),
-					'allowOnMultiple' => true,
-					'toolbarDefault' => false
-				)));
-
-		$actions = array_merge($actions,
-			array(
-				'infolog' => array(
-					'caption' => 'InfoLog',
-					'hint' => 'Save as InfoLog',
-					'icon' => 'infolog/navbar',
-					'group' => ++$group,
-					'onExecute' => 'javaScript:app.mail.mail_integrate',
-					'popup' => egw_link::get_registry('infolog', 'add_popup'),
-					'allowOnMultiple' => false,
-					'toolbarDefault' => true
+		$actions['move2'.$this->mail_bo->profileID.self::$delimiter.$archiveFolder] = array( //toarchive
+			'caption' => 'Move to archive',
+			'hint' => 'move selected mails to archive',
+			'icon' => 'move',
+			'group' => $group++,
+			'enabled' => 'javaScript:app.mail.archivefolder_enabled',
+			//'hideOnDisabled' => true, // does not work as expected on message-list
+			'onExecute' => 'javaScript:app.mail.mail_move2folder',
+			'shortcut' => KeyManager::shortcut(KeyManager::V, true, true),
+			'allowOnMultiple' => true,
+			'toolbarDefault' => false
+		);
+
+		$actions += array(
+			'infolog' => array(
+				'caption' => 'InfoLog',
+				'hint' => 'Save as InfoLog',
+				'icon' => 'infolog/navbar',
+				'group' => ++$group,
+				'onExecute' => 'javaScript:app.mail.mail_integrate',
+				'popup' => Link::get_registry('infolog', 'add_popup'),
+				'allowOnMultiple' => false,
+				'toolbarDefault' => true
+			),
+			'tracker' => array(
+				'caption' => 'Tracker',
+				'hint' => 'Save as ticket',
+				'group' => $group,
+				'icon' => 'tracker/navbar',
+				'onExecute' => 'javaScript:app.mail.mail_integrate',
+				'popup' => Link::get_registry('tracker', 'add_popup'),
+				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'),
+				'allowOnMultiple' => false,
+			),
+			'calendar' => array(
+				'caption' => 'Calendar',
+				'hint' => 'Save as Calendar',
+				'icon' => 'calendar/navbar',
+				'group' => $group,
+				'onExecute' => 'javaScript:app.mail.mail_integrate',
+				'popup' => Link::get_registry('calendar', 'add_popup'),
+				'allowOnMultiple' => false,
+				'toolbarDefault' => true
+			),
+			'print' => array(
+				'caption' => 'Print',
+				'group' => ++$group,
+				'onExecute' => 'javaScript:app.mail.mail_print',
+				'allowOnMultiple' => false,
+				'hideOnMobile' => true
+			),
+			'save' => array(
+				'caption' => 'Save',
+				'group' => $group,
+				'icon' => 'fileexport',
+				'children' => array(
+					'save2disk' => array(
+						'caption' => 'Save to disk',
+						'hint' => 'Save message to disk',
+						'group' => $group,
+						'icon' => 'fileexport',
+						'onExecute' => 'javaScript:app.mail.mail_save',
+						'allowOnMultiple' => false,
+						'hideOnMobile' => true
+					),
+					'save2filemanager' => array(
+						'caption' => 'Filemanager',
+						'hint' => 'Save message to filemanager',
+						'group' => $group,
+						'icon' => 'filemanager/navbar',
+						'onExecute' => 'javaScript:app.mail.mail_save2fm',
+						'allowOnMultiple' => false,
+					),
 				),
-				'tracker' => array(
-					'caption' => 'Tracker',
-					'hint' => 'Save as ticket',
-					'group' => $group,
-					'icon' => 'tracker/navbar',
-					'onExecute' => 'javaScript:app.mail.mail_integrate',
-					'popup' => egw_link::get_registry('tracker', 'add_popup'),
-					'mail_import' => $GLOBALS['egw']->hooks->single(array('location' => 'mail_import'),'tracker'),
-					'allowOnMultiple' => false,
+				'hideOnMobile' => true
+			),
+			'view' => array(
+				'caption' => 'View',
+				'group' => $group,
+				'icon' => 'kmmsgread',
+				'children' => array(
+					'header' => array(
+						'caption' => 'Header',
+						'hint' => 'View header lines',
+						'group' => $group,
+						'icon' => 'kmmsgread',
+						'onExecute' => 'javaScript:app.mail.mail_header',
+						'allowOnMultiple' => false,
+					),
+					'mailsource' => array(
+						'caption' => 'Source',
+						'hint' => 'View full Mail Source',
+						'group' => $group,
+						'icon' => 'source',
+						'onExecute' => 'javaScript:app.mail.mail_mailsource',
+						'allowOnMultiple' => false,
+					),
+					'openastext' => array(
+						'caption' => lang('Text mode'),
+						'hint' => 'Open in Text mode',
+						'group' => ++$group,
+						'icon' => 'textmode',
+						'onExecute' => 'javaScript:app.mail.mail_openAsText',
+						'allowOnMultiple' => false,
+					),
+					'openashtml' => array(
+						'caption' => lang('HTML mode'),
+						'hint' => 'Open in HTML mode',
+						'group' => $group,
+						'icon' => 'htmlmode',
+						'onExecute' => 'javaScript:app.mail.mail_openAsHtml',
+						'allowOnMultiple' => false,
+					),
 				),
-				'calendar' => array(
-					'caption' => 'Calendar',
-					'hint' => 'Save as Calendar',
-					'icon' => 'calendar/navbar',
-					'group' => $group,
-					'onExecute' => 'javaScript:app.mail.mail_integrate',
-					'popup' => egw_link::get_registry('calendar', 'add_popup'),
-					'allowOnMultiple' => false,
-					'toolbarDefault' => true
-				),
-				'print' => array(
-					'caption' => 'Print',
-					'group' => ++$group,
-					'onExecute' => 'javaScript:app.mail.mail_print',
-					'allowOnMultiple' => false,
-					'hideOnMobile' => true
-				),
-				'save' => array(
-					'caption' => 'Save',
-					'group' => $group,
-					'icon' => 'fileexport',
-					'children' => array(
-						'save2disk' => array(
-							'caption' => 'Save to disk',
-							'hint' => 'Save message to disk',
-							'group' => $group,
-							'icon' => 'fileexport',
-							'onExecute' => 'javaScript:app.mail.mail_save',
-							'allowOnMultiple' => false,
-							'hideOnMobile' => true
-						),
-						'save2filemanager' => array(
-							'caption' => 'Filemanager',
-							'hint' => 'Save message to filemanager',
-							'group' => $group,
-							'icon' => 'filemanager/navbar',
-							'onExecute' => 'javaScript:app.mail.mail_save2fm',
-							'allowOnMultiple' => false,
+				'hideOnMobile' => true
+			),
+			'mark' => array(
+				'caption' => 'Set / Remove Flags',
+				'icon' => 'read_small',
+				'group' => ++$group,
+				'children' => array(
+					// icons used from http://creativecommons.org/licenses/by-sa/3.0/
+					// Artist: Led24
+					// Iconset Homepage: http://led24.de/iconset
+					// License: CC Attribution 3.0
+					'setLabel' => array(
+						'caption' => 'Set / Remove Labels',
+						'icon' => 'tag_message',
+						'group' => ++$group,
+						// note this one is NOT a real CAPABILITY reported by the server, but added by selectMailbox
+						'enabled' => $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'),
+						'hideOnDisabled' => true,
+						'children' => array(
+							'unlabel' => array(
+								'group' => ++$group,
+								'caption' => "<font color='#ff0000'>".lang('remove all')."</font>",
+								'icon' => 'mail_label',
+								'onExecute' => 'javaScript:app.mail.mail_flag',
+								'shortcut' => KeyManager::shortcut(KeyManager::_0, true, true),
+							),
+							'label1' => array(
+								'group' => ++$group,
+								'caption' => "<font color='#ff0000'>".lang('important')."</font>",
+								'icon' => 'mail_label1',
+								'onExecute' => 'javaScript:app.mail.mail_flag',
+								'shortcut' => KeyManager::shortcut(KeyManager::_1, true, true),
+							),
+							'label2' => array(
+								'group' => $group,
+								'caption' => "<font color='#ff8000'>".lang('job')."</font>",
+								'icon' => 'mail_label2',
+								'onExecute' => 'javaScript:app.mail.mail_flag',
+								'shortcut' => KeyManager::shortcut(KeyManager::_2, true, true),
+							),
+							'label3' => array(
+								'group' => $group,
+								'caption' => "<font color='#008000'>".lang('personal')."</font>",
+								'icon' => 'mail_label3',
+								'onExecute' => 'javaScript:app.mail.mail_flag',
+								'shortcut' => KeyManager::shortcut(KeyManager::_3, true, true),
+							),
+							'label4' => array(
+								'group' => $group,
+								'caption' => "<font color='#0000ff'>".lang('to do')."</font>",
+								'icon' => 'mail_label4',
+								'onExecute' => 'javaScript:app.mail.mail_flag',
+								'shortcut' => KeyManager::shortcut(KeyManager::_4, true, true),
+							),
+							'label5' => array(
+								'group' => $group,
+								'caption' => "<font color='#8000ff'>".lang('later')."</font>",
+								'icon' => 'mail_label5',
+								'onExecute' => 'javaScript:app.mail.mail_flag',
+								'shortcut' => KeyManager::shortcut(KeyManager::_5, true, true),
+							),
 						),
 					),
-					'hideOnMobile' => true
-				),
-				'view' => array(
-					'caption' => 'View',
-					'group' => $group,
-					'icon' => 'kmmsgread',
-					'children' => array(
-						'header' => array(
-							'caption' => 'Header',
-							'hint' => 'View header lines',
-							'group' => $group,
-							'icon' => 'kmmsgread',
-							'onExecute' => 'javaScript:app.mail.mail_header',
-							'allowOnMultiple' => false,
-						),
-						'mailsource' => array(
-							'caption' => 'Source',
-							'hint' => 'View full Mail Source',
-							'group' => $group,
-							'icon' => 'source',
-							'onExecute' => 'javaScript:app.mail.mail_mailsource',
-							'allowOnMultiple' => false,
-						),
-						'openastext' => array(
-							'caption' => lang('Text mode'),
-							'hint' => 'Open in Text mode',
-							'group' => ++$group,
-							'icon' => 'textmode',
-							'onExecute' => 'javaScript:app.mail.mail_openAsText',
-							'allowOnMultiple' => false,
-						),
-						'openashtml' => array(
-							'caption' => lang('HTML mode'),
-							'hint' => 'Open in HTML mode',
-							'group' => $group,
-							'icon' => 'htmlmode',
-							'onExecute' => 'javaScript:app.mail.mail_openAsHtml',
-							'allowOnMultiple' => false,
-						),
+					// modified icons from http://creativecommons.org/licenses/by-sa/3.0/
+					'flagged' => array(
+						'group' => ++$group,
+						'caption' => 'Flag / Unflag',
+						'icon' => 'unread_flagged_small',
+						'onExecute' => 'javaScript:app.mail.mail_flag',
+						'hint' => 'Flag or Unflag a mail',
+						'shortcut' => KeyManager::shortcut(KeyManager::F, true, true),
+						'toolbarDefault' => true
 					),
-					'hideOnMobile' => true
-				),
-				'mark' => array(
-					'caption' => 'Set / Remove Flags',
-					'icon' => 'read_small',
-					'group' => ++$group,
-					'children' => array(
-						// icons used from http://creativecommons.org/licenses/by-sa/3.0/
-						// Artist: Led24
-						// Iconset Homepage: http://led24.de/iconset
-						// License: CC Attribution 3.0
-						'setLabel' => array(
-							'caption' => 'Set / Remove Labels',
-							'icon' => 'tag_message',
-							'group' => ++$group,
-							// note this one is NOT a real CAPABILITY reported by the server, but added by selectMailbox
-							'enabled' => $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'),
-							'hideOnDisabled' => true,
-							'children' => array(
-								'unlabel' => array(
-									'group' => ++$group,
-									'caption' => "<font color='#ff0000'>".lang('remove all')."</font>",
-									'icon' => 'mail_label',
-									'onExecute' => 'javaScript:app.mail.mail_flag',
-									'shortcut' => egw_keymanager::shortcut(egw_keymanager::_0, true, true),
-								),
-								'label1' => array(
-									'group' => ++$group,
-									'caption' => "<font color='#ff0000'>".lang('important')."</font>",
-									'icon' => 'mail_label1',
-									'onExecute' => 'javaScript:app.mail.mail_flag',
-									'shortcut' => egw_keymanager::shortcut(egw_keymanager::_1, true, true),
-								),
-								'label2' => array(
-									'group' => $group,
-									'caption' => "<font color='#ff8000'>".lang('job')."</font>",
-									'icon' => 'mail_label2',
-									'onExecute' => 'javaScript:app.mail.mail_flag',
-									'shortcut' => egw_keymanager::shortcut(egw_keymanager::_2, true, true),
-								),
-								'label3' => array(
-									'group' => $group,
-									'caption' => "<font color='#008000'>".lang('personal')."</font>",
-									'icon' => 'mail_label3',
-									'onExecute' => 'javaScript:app.mail.mail_flag',
-									'shortcut' => egw_keymanager::shortcut(egw_keymanager::_3, true, true),
-								),
-								'label4' => array(
-									'group' => $group,
-									'caption' => "<font color='#0000ff'>".lang('to do')."</font>",
-									'icon' => 'mail_label4',
-									'onExecute' => 'javaScript:app.mail.mail_flag',
-									'shortcut' => egw_keymanager::shortcut(egw_keymanager::_4, true, true),
-								),
-								'label5' => array(
-									'group' => $group,
-									'caption' => "<font color='#8000ff'>".lang('later')."</font>",
-									'icon' => 'mail_label5',
-									'onExecute' => 'javaScript:app.mail.mail_flag',
-									'shortcut' => egw_keymanager::shortcut(egw_keymanager::_5, true, true),
-								),
-							),
-						),
-						// modified icons from http://creativecommons.org/licenses/by-sa/3.0/
-						'flagged' => array(
-							'group' => ++$group,
-							'caption' => 'Flag / Unflag',
-							'icon' => 'unread_flagged_small',
-							'onExecute' => 'javaScript:app.mail.mail_flag',
-							'hint' => 'Flag or Unflag a mail',
-							'shortcut' => egw_keymanager::shortcut(egw_keymanager::F, true, true),
-							'toolbarDefault' => true
-						),
-						'read' => array(
-							'group' => $group,
-							'caption' => 'Read / Unread',
-							'icon' => 'read_small',
-							'onExecute' => 'javaScript:app.mail.mail_flag',
-							'shortcut' => egw_keymanager::shortcut(egw_keymanager::U, true, true),
-
-						),
-						'readall' => array(
-							'group' => ++$group,
-							'caption' => "<font color='#ff0000'>".lang('mark all as read')."</font>",
-							'icon' => 'read_small',
-							'onExecute' => 'javaScript:app.mail.mail_flag',
-							'hint' => 'mark all messages in folder as read',
-							'toolbarDefault' => false
-						),
-						'undelete' => array(
-							'group' => $group,
-							'caption' => 'Undelete',
-							'icon' => 'revert',
-							'onExecute' => 'javaScript:app.mail.mail_flag',
-						),
+					'read' => array(
+						'group' => $group,
+						'caption' => 'Read / Unread',
+						'icon' => 'read_small',
+						'onExecute' => 'javaScript:app.mail.mail_flag',
+						'shortcut' => KeyManager::shortcut(KeyManager::U, true, true),
+
+					),
+					'readall' => array(
+						'group' => ++$group,
+						'caption' => "<font color='#ff0000'>".lang('mark all as read')."</font>",
+						'icon' => 'read_small',
+						'onExecute' => 'javaScript:app.mail.mail_flag',
+						'hint' => 'mark all messages in folder as read',
+						'toolbarDefault' => false
+					),
+					'undelete' => array(
+						'group' => $group,
+						'caption' => 'Undelete',
+						'icon' => 'revert',
+						'onExecute' => 'javaScript:app.mail.mail_flag',
 					),
 				),
-				'delete' => array(
-					'caption' => 'Delete',
-					'hint' => $deleteOptions[$this->mail_bo->mailPreferences['deleteOptions']],
-					'group' => ++$group,
-					'onExecute' => 'javaScript:app.mail.mail_delete',
-					'toolbarDefault' => true
-				),
-				'drag_mail' => array(
-					'dragType' => array('mail'),
-					'type' => 'drag',
-					//'onExecute' => 'javaScript:app.mail.mail_dragStart',
-				)
+			),
+			'delete' => array(
+				'caption' => 'Delete',
+				'hint' => $deleteOptions[$this->mail_bo->mailPreferences['deleteOptions']],
+				'group' => ++$group,
+				'onExecute' => 'javaScript:app.mail.mail_delete',
+				'toolbarDefault' => true
+			),
+			'drag_mail' => array(
+				'dragType' => array('mail'),
+				'type' => 'drag',
+				//'onExecute' => 'javaScript:app.mail.mail_dragStart',
 			)
 		);
 		//error_log(__METHOD__.__LINE__.array2string(array_keys($actions)));
@@ -1279,6 +1277,8 @@
 	 */
 	public static function get_rows(&$query,&$rows,&$readonlys)
 	{
+		unset($readonlys);	// not used, but required by function signature
+
 		// handle possible profile change in get_rows
 		if (!empty($query['selectedFolder']))
 		{
@@ -1345,7 +1345,7 @@
 		{
 			if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
 			{
-				Mail::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
+				Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
 				if (!isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
 				{
 					Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]=true;
@@ -1353,8 +1353,8 @@
 			}
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
 			$cutoffdate = $cutoffdate2 = null;
-			if ($query['startdate']) $cutoffdate = egw_time::to($query['startdate'],'ts');//SINCE, enddate
-			if ($query['enddate']) $cutoffdate2 = egw_time::to($query['enddate'],'ts');//BEFORE, startdate
+			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
+			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
 			$filter = array(
 				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -1403,8 +1403,8 @@
 		}
 		//error_log(__METHOD__.__LINE__.' maxMessages:'.$maxMessages.' Offset:'.$offset.' Filter:'.array2string($mail_ui->sessionData['messageFilter']));
 /*
-$cutoffdate = egw_time::to('now','ts')-(3600*24*6);//SINCE, enddate
-$cutoffdate2 = egw_time::to('now','ts')-(3600*24*3);//BEFORE, startdate
+$cutoffdate = Api\DateTime::to('now','ts')-(3600*24*6);//SINCE, enddate
+$cutoffdate2 = Api\DateTime::to('now','ts')-(3600*24*3);//BEFORE, startdate
 $filter['range'] = "BETWEEN";// we support SINCE, BEFORE, BETWEEN and ON
 $filter['since'] = date("d-M-Y", $cutoffdate);
 $filter['before']= date("d-M-Y", $cutoffdate2);
@@ -1421,10 +1421,10 @@
 					$rByUid=true
 				);
 				$rowsFetched['messages'] = $_sR['count'];
-				$sR = $_sR['match']->ids;
+				$ids = $_sR['match']->ids;
 				// if $sR is false, something failed fundamentally
-				if($reverse === true) $sR = ($sR===false?array():array_reverse((array)$sR));
-				$sR = array_slice((array)$sR,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
+				if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids));
+				$sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
 				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
 				$maxMessages = 75;
@@ -1471,7 +1471,7 @@
 			$sR=array();
 			self::callWizard($e->getMessage(), false, 'error');
 		}
-		$response = egw_json_response::get();
+		$response = Api\Json\Response::get();
 		// unlock immediately after fetching the rows
 		if (stripos($_GET['menuaction'],'ajax_get_rows')!==false)
 		{
@@ -1737,7 +1737,7 @@
 					substr($header['mimetype'],0,5) == 'video' ||
 					$header['mimetype'] == 'multipart/alternative')
 				{
-					$image = html::image('mail','attach');
+					$image = Api\Html::image('mail','attach');
 					$imageHTMLBlock = '';
 					$datarowid = $this->createRowID($_folderName,$message_uid,true);
 					$attachments = $header['attachments'];
@@ -1748,12 +1748,12 @@
 					if (count($attachments)==1)
 					{
 						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
-						$image = html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':''));
+						$image = Api\Html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':''));
 					}
 					if (count($attachments)>1)
 					{
 						$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
-						$image = html::image('mail','attach',lang('%1 attachments',count($attachments)));
+						$image = Api\Html::image('mail','attach',lang('%1 attachments',count($attachments)));
 					}
 
 					$attachmentFlag = $image;
@@ -1762,9 +1762,9 @@
 				}
 				// show priority flag
 				if ($header['priority'] < 3) {
-					 $image = html::image('mail','prio_high');
+					 $image = Api\Html::image('mail','prio_high');
 				} elseif ($header['priority'] > 3) {
-					$image = html::image('mail','prio_low');
+					$image = Api\Html::image('mail','prio_low');
 				} else {
 					$image = '';
 				}
@@ -1772,7 +1772,7 @@
 				$imageflagged ='';
 				if ($header['flagged'])
 				{
-					$imageflagged = html::image('mail','unread_flagged_small');
+					$imageflagged = Api\Html::image('mail','unread_flagged_small');
 				}
 				$data["attachments"] = $image.$attachmentFlag.$imageflagged; // icon for attachments available
 			}
@@ -1839,7 +1839,7 @@
 		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
 
 		// ToDo: call this ONLY if labels change
-		etemplate_widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
+		Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
 
 		return $rv;
 	}
@@ -1866,10 +1866,10 @@
 		}
 
 		$this->mail_bo->reopen($mailbox);
-		$rawheaders	= $this->mail_bo->getMessageRawHeader($uid, $partID);
+		$headers_in	= $this->mail_bo->getMessageRawHeader($uid, $partID);
 
 		// add line breaks to $rawheaders
-		$newRawHeaders = explode("\n",$rawheaders);
+		$newRawHeaders = explode("\n",$headers_in);
 		reset($newRawHeaders);
 
 		// reset $rawheaders
@@ -1923,12 +1923,12 @@
 		//error_log(__METHOD__.__LINE__.array2string($hA));
 		if (($this->mail_bo->isDraftFolder($mailbox)) && $_requesteddata['mode'] == 'print')
 		{
-			$response = egw_json_response::get();
+			$response = Api\Json\Response::get();
 			$response->call('app.mail.print_for_compose', $rowID);
 		}
 		if (!$preventRedirect && ($this->mail_bo->isDraftFolder($mailbox) || $this->mail_bo->isTemplateFolder($mailbox)))
 		{
-			egw::redirect_link('/index.php',array('menuaction'=>'mail.mail_compose.compose','id'=>$rowID,'from'=>'composefromdraft'));
+			Egw::redirect_link('/index.php',array('menuaction'=>'mail.mail_compose.compose','id'=>$rowID,'from'=>'composefromdraft'));
 		}
 		$this->mail_bo->reopen($mailbox);
 		// retrieve the flags of the message, before touching it.
@@ -1936,11 +1936,11 @@
 		{
 			$headers	= $this->mail_bo->getMessageHeader($uid, $partID,true,true,$mailbox);
 		}
-		catch (egw_exception $e)
+		catch (Api\Exception $e)
 		{
 			$error_msg[] = lang("ERROR: Message could not be displayed.");
 			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
-			egw_framework::message($e->getMessage(), 'error');
+			Framework::message($e->getMessage(), 'error');
 		}
 		if (!empty($uid)) $this->mail_bo->getFlags($uid);
 		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
@@ -1961,11 +1961,12 @@
 		//error_log(__METHOD__.__LINE__.$mailBody);
 		$this->mail_bo->closeConnection();
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
-		$etpl = new etemplate_new('mail.display');
+		$etpl = new Etemplate('mail.display');
 		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
 
 		// Set up data for taglist widget(s)
 		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
+		$sel_options = array();
 		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
 		{
 			if (!isset($envelope[$field])) continue;
@@ -1995,7 +1996,7 @@
 		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID);
 		if (!empty($partID)) $linkData['_partID']=$partID;
 		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions;
-		$content['mailDisplayBodySrc'] = egw::link('/index.php',$linkData);
+		$content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData);
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
 		$content['mail_id']=$rowID;
 		$content['mailDisplayContainerClass']=(count($attachments)?"mailDisplayContainer mailDisplayContainerFixedHeight":"mailDisplayContainer mailDisplayContainerFullHeight");
@@ -2042,14 +2043,13 @@
 
 		$compose = $actions['composeasnew'];
 		unset($actions['composeasnew']);
-		$actions = array_reverse($actions,true);
-		$actions['composeasnew']= $compose;
-		$actions = array_reverse($actions,true);
-		return $actions;
-	}
-
-	/**
-	 * createAttachmentBlock
+
+		$actions2 = array_reverse($actions,true);
+		$actions2['composeasnew']= $compose;
+		return array_reverse($actions2,true);
+	}
+
+	/**
 	 * helper function to create the attachment block/table
 	 *
 	 * @param array $attachments array with the attachments information
@@ -2057,34 +2057,34 @@
 	 * @param int $uid uid of the message
 	 * @param string $mailbox mailbox identifier
 	 * @param boolean $_returnFullHTML flag wether to return HTML or data array
-	 * @return mixed array/string data array or html or empty string
+	 * @return array|string data array or html or empty string
 	 */
 	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox,$_returnFullHTML=false)
 	{
 		$attachmentHTMLBlock='';
 		$attachmentHTML = array();
 		if (is_array($attachments) && count($attachments) > 0) {
-			$url_img_vfs = html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
-			$url_img_vfs_save_all = html::image('mail','save_all', lang('Save all'));
+			$url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"');
+			$url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all'));
 
 			foreach ($attachments as $key => $value)
 			{
 				$attachmentHTML[$key]['filename']= ($value['name'] ? ( $value['filename'] ? $value['filename'] : $value['name'] ) : lang('(no subject)'));
-				$attachmentHTML[$key]['filename'] = translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
+				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
 				//error_log(array2string($value));
-				//error_log(strtoupper($value['mimeType']) .'<->'. mime_magic::filename2mime($attachmentHTML[$key]['filename']));
-				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = mime_magic::filename2mime($attachmentHTML[$key]['filename']);
+				//error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']));
+				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
 				$attachmentHTML[$key]['type']=$value['mimeType'];
-				$attachmentHTML[$key]['mimetype']=mime_magic::mime2label($value['mimeType']);
+				$attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']);
 				$hA = self::splitRowID($rowID);
 				$uid = $hA['msgUID'];
 				$mailbox = $hA['folder'];
 				$acc_id = $hA['profileID'];
 
-				$attachmentHTML[$key]['mime_data'] = egw_link::set_data($value['mimeType'], 'EGroupware\\Api\\Mail::getAttachmentAccount', array(
+				$attachmentHTML[$key]['mime_data'] = Link::set_data($value['mimeType'], 'EGroupware\\Api\\Mail::getAttachmentAccount', array(
 					$acc_id, $mailbox, $uid, $value['partID'], $value['is_winmail'], true
 				));
-				$attachmentHTML[$key]['size']=egw_vfs::hsize($value['size']);
+				$attachmentHTML[$key]['size']=Vfs::hsize($value['size']);
 				$attachmentHTML[$key]['attachment_number']=$key;
 				$attachmentHTML[$key]['partID']=$value['partID'];
 				$attachmentHTML[$key]['mail_id'] = $rowID;
@@ -2103,7 +2103,7 @@
 							'is_winmail'    => $value['is_winmail']
 						);
 						$windowName = 'displayMessage_'. $rowID.'_'.$value['partID'];
-						$linkView = "egw_openWindowCentered('".egw::link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());";
+						$linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());";
 						break;
 					case 'IMAGE/JPEG':
 					case 'IMAGE/PNG':
@@ -2117,7 +2117,7 @@
 						$buff = explode('.',$value['name']);
 						$suffix = '';
 						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
-						if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix);
+						if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
 						if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
 						{
 							$attachments[$key]['mimeType'] = $sfxMimeType;
@@ -2141,18 +2141,18 @@
 						if (strtoupper($value['mimeType'])=='TEXT/CALENDAR')
 						{
 							$windowName = 'displayEvent_'. $rowID;
-							$reg2 = egw_link::get_registry('calendar','view_popup');
+							$reg2 = Link::get_registry('calendar','view_popup');
 							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
 						}
 						if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD')
 						{
 							$windowName = 'displayContact_'. $rowID;
-							$reg2 = egw_link::get_registry('addressbook','add_popup');
+							$reg2 = Link::get_registry('addressbook','add_popup');
 							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
 						}
 						// apply to action
 						list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg));
-						$linkView = "egw_openWindowCentered('".egw::link('/index.php',$linkData)."','$windowName',$width,$height);";
+						$linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',$width,$height);";
 						break;
 					default:
 						$linkData = array
@@ -2163,13 +2163,13 @@
 							'is_winmail'    => $value['is_winmail'],
 							'mailbox'   => base64_encode($mailbox),
 						);
-						$linkView = "window.location.href = '".egw::link('/index.php',$linkData)."';";
+						$linkView = "window.location.href = '".Egw::link('/index.php',$linkData)."';";
 						break;
 				}
 				// we either use mime_data for server-side supported mime-types or mime_url for client-side or download
 				if (empty($attachmentHTML[$key]['mime_data']))
 				{
-					$attachmentHTML[$key]['mime_url'] = egw::link('/index.php',$linkData);
+					$attachmentHTML[$key]['mime_url'] = Egw::link('/index.php',$linkData);
 					unset($attachmentHTML[$key]['mime_data']);
 				}
 				$attachmentHTML[$key]['windowName'] = $windowName;
@@ -2188,11 +2188,11 @@
 					'is_winmail'    => $value['is_winmail'],
 					'mailbox'   => base64_encode($mailbox),
 				);
-				$attachmentHTML[$key]['link_save'] ="<a href='".egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".html::image('mail','fileexport')."</a>";
+				$attachmentHTML[$key]['link_save'] ="<a href='".Egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail','fileexport')."</a>";
 
 				if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
 				{
-					$link_vfs_save = egw::link('/index.php',array(
+					$link_vfs_save = Egw::link('/index.php',array(
 						'menuaction' => 'filemanager.filemanager_select.select',
 						'mode' => 'saveas',
 						'name' => $value['name'],
@@ -2211,7 +2211,7 @@
 							//$rowID
 							$ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name'];
 						}
-						$link_vfs_save = egw::link('/index.php',array(
+						$link_vfs_save = Egw::link('/index.php',array(
 							'menuaction' => 'filemanager.filemanager_select.select',
 							'mode' => 'select-dir',
 							'method' => 'mail.mail_ui.vfsSaveAttachment',
@@ -2265,7 +2265,7 @@
 
 				$cachedVacations = array($sieveServer->acc_id => $vacation) + (array)$cachedVacations;
 				// Set vacation to the instance cache for particular account with expiration of one day
-				egw_cache::setCache(egw_cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60*60*24);
+				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60*60*24);
 			}
 			catch (PEAR_Exception $ex)
 			{
@@ -2277,8 +2277,8 @@
 	}
 
 	/**
-	 * quotaDisplay
 	 * gather Info on how to display the quota info
+	 *
 	 * @param $_usage int
 	 * @param $_limit int
 	 * @return array - info used for quota array(class=>string,text=>string,$percent=>string)
@@ -2348,7 +2348,7 @@
 			// the next headers are for IE and SSL
 			//header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
 			//header("Pragma: public");
-			egw_session::cache_control(true);
+			Api\Session::cache_control(true);
 			echo $attachment->getContents();
 		}
 		else
@@ -2356,7 +2356,7 @@
 			// send a 404 Not found
 			header("HTTP/1.1 404 Not found");
 		}
-		common::egw_exit();
+		exit();
 	}
 
 	function getAttachment()
@@ -2395,7 +2395,7 @@
 				$buff = explode('.',$attachment['filename']);
 				$suffix = '';
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
-				if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix);
+				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
 				$attachment['type'] = $sfxMimeType;
 				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
 			}
@@ -2415,7 +2415,7 @@
 						'menuaction'      => 'calendar.calendar_uiforms.edit',
 						'cal_id'      => $event,
 					);
-					egw::redirect_link('../index.php',$vars);
+					Egw::redirect_link('../index.php',$vars);
 				}
 				//Import failed, download content anyway
 			}
@@ -2444,17 +2444,17 @@
 						'menuaction'	=> 'addressbook.addressbook_ui.edit',
 						'contact_id'	=> $contact,
 					);
-					egw::redirect_link('../index.php',$vars);
+					Egw::redirect_link('../index.php',$vars);
 				}
 				//Import failed, download content anyway
 			}
 		}
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
 		$filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part));
-		html::safe_content_header($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save");
+		Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save");
 		echo $attachment['attachment'];
 
-		common::egw_exit();
+		exit();
 	}
 
 
@@ -2497,12 +2497,12 @@
 		{
 			$headers = Horde_Mime_Headers::parseHeaders($message);
 			$subject = str_replace('$$','__',Mail::decode_header($headers['SUBJECT']));
-			html::safe_content_header($message, $subject.".eml", $mime='message/rfc822', $size=0, true, true);
+			Api\Header\Content::safe($message, $subject.".eml", $mime='message/rfc822', $size=0, true, true);
 			echo $message;
 		}
 		else
 		{
-			html::safe_content_header($message, $subject.".eml", $mime='text/html', $size=0, true, false);
+			Api\Header\Content::safe($message, $subject.".eml", $mime='text/html', $size=0, true, false);
 			print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8') .'</pre>';
 		}
 	}
@@ -2511,7 +2511,7 @@
 	 * Save an Message in the vfs
 	 *
 	 * @param string|array $ids use splitRowID, to separate values
-	 * @param string $path path in vfs (no egw_vfs::PREFIX!), only directory for multiple id's ($ids is an array)
+	 * @param string $path path in vfs (no Vfs::PREFIX!), only directory for multiple id's ($ids is an array)
 	 * @param boolean $close Return javascript to close the window
 	 * @return string|boolean javascript eg. to close the selector window if $close is true, or success/fail if $close is false
 	 */
@@ -2519,11 +2519,11 @@
 	{
 		//error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path);
 
-		if (is_array($ids) && !egw_vfs::is_writable($path) || !is_array($ids) && !egw_vfs::is_writable(dirname($path)))
-		{
-			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); egw(window).close();';
-		}
-		translation::add_app('mail');
+		if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path)))
+		{
+			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();';
+		}
+		Api\Translation::add_app('mail');
 
 		$rememberServerID = $this->mail_bo->profileID;
 		foreach((array)$ids as $id)
@@ -2539,7 +2539,7 @@
 			}
 			$message = $this->mail_bo->getMessageRawBody($uid, $partID='', $mailbox);
 			$err=null;
-			if(egw_vfs::is_dir($path))
+			if(Vfs::is_dir($path))
 			{
 				$headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox);
 				$file = $path . '/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/',"_",$headers['SUBJECT']).'.eml';
@@ -2548,7 +2548,7 @@
 			{
 				$file = $path;
 			}
-			if (!($fp = egw_vfs::fopen($file,'wb')) || !fwrite($fp,$message))
+			if (!($fp = Vfs::fopen($file,'wb')) || !fwrite($fp,$message))
 			{
 				$err .= lang('Error saving %1!',$file);
 				$succeeded = false;
@@ -2563,7 +2563,7 @@
 				unset($headers['SUBJECT']);//already in filename
 				$infoSection = Mail::createHeaderInfoSection($headers, 'SUPPRESS', false);
 				$props = array(array('name' => 'comment','val' => $infoSection));
-				egw_vfs::proppatch($file,$props);
+				Vfs::proppatch($file,$props);
 			}
 		}
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -2574,7 +2574,7 @@
 
 		if($close)
 		{
-			egw_framework::window_close(($err?$err:null));
+			Framework::window_close(($err?$err:null));
 		}
 		else
 		{
@@ -2586,16 +2586,16 @@
 	 * Save an attachment in the vfs
 	 *
 	 * @param string|array $ids '::' delimited mailbox::uid::part-id::is_winmail::name (::name for multiple id's)
-	 * @param string $path path in vfs (no egw_vfs::PREFIX!), only directory for multiple id's ($ids is an array)
+	 * @param string $path path in vfs (no Vfs::PREFIX!), only directory for multiple id's ($ids is an array)
 	 * @return string javascript eg. to close the selector window
 	 */
 	function vfsSaveAttachment($ids,$path)
 	{
 		//error_log(__METHOD__.__LINE__.'("'.array2string($ids).'","'.$path."\")');");
 
-		if (is_array($ids) && !egw_vfs::is_writable($path) || !is_array($ids) && !egw_vfs::is_writable(dirname($path)))
-		{
-			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); egw(window).close();';
+		if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path)))
+		{
+			return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();';
 		}
 		$err=null;
 		$dupe_count = array();
@@ -2666,7 +2666,7 @@
 
 			$file = $params['name'];
 			// when $isMultipleDownload the path holds no filename
-			while(egw_vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : '')))
+			while(Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : '')))
 			{
 				$dupe_count[$params['name']]++;
 				$file = pathinfo($params['name'], PATHINFO_FILENAME) .
@@ -2676,7 +2676,7 @@
 			$params['name'] = $file;
 			//error_log(__METHOD__.__LINE__.array2string($attachment));
 			// when $isMultipleDownload the path holds no filename
-			if (!($fp = egw_vfs::fopen($file=$path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''),'wb')) ||
+			if (!($fp = Vfs::fopen($file=$path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''),'wb')) ||
 				!fwrite($fp,$attachment['attachment']))
 			{
 				$err .= lang('Error saving %1!',$file);
@@ -2692,7 +2692,7 @@
 			//error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID);
 			$this->changeProfile($rememberServerID);
 		}
-		egw_framework::window_close(($err?$err:null));
+		Framework::window_close(($err?$err:null));
 	}
 
 	/**
@@ -2729,14 +2729,14 @@
 		$header = $this->mail_bo->getMessageHeader($message_id,'',true,false,$mailbox);
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
-		$temp_path = $homedir/*egw_vfs::get_home_dir()*/ . "/.mail_$message_id";
-		if(egw_vfs::is_dir($temp_path)) egw_vfs::remove ($temp_path);
+		$temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id";
+		if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path);
 
 		// Add subject to path, so it gets used as the file name
-		$path = $temp_path . '/' . ($header['SUBJECT'] ? egw_vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/';
-		if(!egw_vfs::mkdir($path, 0700, true))
-		{
-			egw_framework::message("Unable to open temp directory $path",'error');
+		$path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/';
+		if(!Vfs::mkdir($path, 0700, true))
+		{
+			Framework::message("Unable to open temp directory $path",'error');
 			return;
 		}
 
@@ -2771,11 +2771,11 @@
 					' ('.($dupe_count[$path.$file['filename']] + 1).')' . '.' .
 					pathinfo($file['filename'], PATHINFO_EXTENSION);
 			}
-			if (!($fp = egw_vfs::fopen($path.$file['filename'],'wb')) ||
+			if (!($fp = Vfs::fopen($path.$file['filename'],'wb')) ||
 				!(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp)))
 			{
 				$success=false;
-				egw_framework::message("Unable to zip {$file['filename']}",'error');
+				Framework::message("Unable to zip {$file['filename']}",'error');
 			}
 			if ($success) $file_list[] = $path.$file['filename'];
 			if ($fp) fclose($fp);
@@ -2788,12 +2788,12 @@
 		}
 
 		// Zip it up
-		egw_vfs::download_zip($file_list);
+		Vfs::download_zip($file_list);
 
 		// Clean up
-		egw_vfs::remove($temp_path);
-
-		common::egw_exit();
+		Vfs::remove($temp_path);
+
+		exit();
 	}
 
 	function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null)
@@ -2823,14 +2823,14 @@
 				($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'],$attach['is_winmail'],(strtolower($attach['mimeType']) == 'text/calendar'?false:true))))
 			{
 				//error_log(__METHOD__.__LINE__.array2string($attachment));
-				egw_cache::setSession('calendar', 'ical', array(
+				Api\Cache::setSession('calendar', 'ical', array(
 					'charset' => $attach['charset'] ? $attach['charset'] : 'utf-8',
 					'attachment' => $attachment['attachment'],
 					'method' => $attach['method'],
 					'sender' => $mailbox,
 				));
 				$this->mail_bo->htmlOptions = $bufferHtmlOptions;
-				translation::add_app('calendar');
+				Api\Translation::add_app('calendar');
 				return ExecMethod( 'calendar.calendar_uiforms.meeting',
 					array('event'=>null,'msg'=>'','useSession'=>true)
 				);
@@ -2854,10 +2854,10 @@
 		$GLOBALS['egw_info']['flags']['nofooter']=true;
 		$GLOBALS['egw_info']['flags']['nonavbar']=true;
 		// do NOT include any default CSS
-		egw_framework::includeCSS('mail', 'preview', true, true);
+		Framework::includeCSS('mail', 'preview', true, true);
 
 		// load preview.js to activate mailto links
-		egw_framework::validate_file('/mail/js/preview.js');
+		Framework::includeJS('/mail/js/preview.js');
 
 		// send CSP and content-type header
 		return $GLOBALS['egw']->framework->header();
@@ -2932,7 +2932,7 @@
 				$singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']);
 			}
 			//error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']);
-			$singleBodyPart['body'] = translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']);
+			$singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']);
 			//error_log(__METHOD__.__LINE__.array2string($singleBodyPart));
 			if($singleBodyPart['mimeType'] == 'text/plain')
 			{
@@ -2948,7 +2948,7 @@
 				// http://www.php.net/manual/en/function.preg-replace.php
 
 				// create links for websites
-				if ($modifyURI) $newBody = html::activate_links($newBody);
+				if ($modifyURI) $newBody = Api\Html::activate_links($newBody);
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
 				// redirect links for websites if you use no cookies
 				#if (!($GLOBALS['egw_info']['server']['usecookies']))
@@ -2990,9 +2990,9 @@
 					{
 						$newBody = $cleaned;
 					}
-					if (!$preserveHTML)
-					{
-						// filter only the 'body', as we only want that part, if we throw away the html
+					if (!$preserveHTML)	// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
+					{
+						// filter only the 'body', as we only want that part, if we throw away the Api\Html
 						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
 						if ($matches[2])
 						{
@@ -3151,9 +3151,9 @@
 					'cid'		=> base64_encode($CID),
 					'partID'	=> $_partID,
 				);
-				$imageURL = egw::link('/index.php', $linkData);
+				$imageURL = Egw::link('/index.php', $linkData);
 				// to test without data uris, comment the if close incl. it's body
-				if (html::$user_agent != 'msie' || html::$ua_version >= 8)
+				if (Api\Header\UserAgent::type() != 'msie' || Api\Header\UserAgent::version() >= 8)
 				{
 					if (!isset($cache[$imageURL]))
 					{
@@ -3225,10 +3225,10 @@
 			if ($content['vfsfile'])
 			{
 				$file = $content['vfsfile'] = array(
-					'name' => egw_vfs::basename($content['vfsfile']),
-					'type' => egw_vfs::mime_content_type($content['vfsfile']),
-					'file' => egw_vfs::PREFIX.$content['vfsfile'],
-					'size' => filesize(egw_vfs::PREFIX.$content['vfsfile']),
+					'name' => Vfs::basename($content['vfsfile']),
+					'type' => Vfs::mime_content_type($content['vfsfile']),
+					'file' => Vfs::PREFIX.$content['vfsfile'],
+					'size' => filesize(Vfs::PREFIX.$content['vfsfile']),
 				);
 			}
 			else
@@ -3254,15 +3254,15 @@
 					'id' => $this->createRowID($destination, $messageUid, true),
 			    );
 			}
-			catch (egw_exception_wrong_userinput $e)
+			catch (Api\Exception\WrongUserinput $e)
 			{
 					$importFailed=true;
 					$content['msg']		= $e->getMessage();
 			}
 			if (!$importFailed)
 			{
-				list($width, $height) = explode('x', egw_link::get_registry('mail', 'add_popup'));
-				if ($width > 0 && $height > 0) egw_json_response::get()->call('resizeTo', $width, $height);
+				list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup'));
+				if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height);
 				ExecMethod2('mail.mail_ui.displayMessage',$linkData);
 				return;
 			}
@@ -3271,7 +3271,7 @@
 		if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
 		if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true);
 
-		$etpl = new etemplate_new('mail.importMessage');
+		$etpl = new Etemplate('mail.importMessage');
 		$etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport');
 		$etpl->exec('mail.mail_ui.importMessage',$content,$sel_options,array(),array(),2);
 	}
@@ -3295,7 +3295,7 @@
 		{
 			$tmpFileName = Mail::checkFileBasics($_formData,$importID);
 		}
-		catch (egw_exception_wrong_userinput $e)
+		catch (Api\Exception\WrongUserinput $e)
 		{
 			$importfailed = true;
 			$alert_msg .= $e->getMessage();
@@ -3303,12 +3303,12 @@
 		// -----------------------------------------------------------------------
 		if ($importfailed === false)
 		{
-			$mailObject = new egw_mailer();
+			$mailObject = new Api\Mailer();
 			try
 			{
 				$this->mail_bo->parseFileIntoMailObject($mailObject, $tmpFileName);
 			}
-			catch (egw_exception_assertion_failed $e)
+			catch (Api\Exception\AssertionFailed $e)
 			{
 				$importfailed = true;
 				$alert_msg .= $e->getMessage();
@@ -3330,7 +3330,7 @@
 							$mailObject->getRaw(),
 							null,'\\Seen');
 					}
-					catch (egw_exception_wrong_userinput $e)
+					catch (Api\Exception\WrongUserinput $e)
 					{
 						$importfailed = true;
 						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$_formData['name'],$_folder,$e->getMessage());
@@ -3346,7 +3346,7 @@
 		// set the url to open when refreshing
 		if ($importfailed == true)
 		{
-			throw new egw_exception_wrong_userinput($alert_msg);
+			throw new Api\Exception\WrongUserinput($alert_msg);
 		}
 		else
 		{
@@ -3406,7 +3406,7 @@
 			$buff = explode('.',$formData['file']);
 			$suffix = '';
 			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
-			if (!empty($suffix)) $formData['type'] = mime_magic::ext2mime($suffix);
+			if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix);
 		}
 		// size should be set to meet the requirements of checkFileBasics
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
@@ -3431,11 +3431,11 @@
 			{
 				$linkData['mode']=$mode;
 			}
-			egw::redirect_link('/index.php',$linkData);
-		}
-		catch (egw_exception_wrong_userinput $e)
-		{
-			egw_framework::window_close($e->getMessage());
+			Egw::redirect_link('/index.php',$linkData);
+		}
+		catch (Api\Exception\WrongUserinput $e)
+		{
+			Framework::window_close($e->getMessage());
 		}
 	}
 
@@ -3467,7 +3467,7 @@
 		}
 
 		$bodyResponse = $this->get_load_email_data($messageID,$_partID,$folder,$_htmloptions);
-		egw_session::cache_control(true);
+		Api\Session::cache_control(true);
 		//error_log(array2string($bodyResponse));
 		echo $bodyResponse;
 
@@ -3481,7 +3481,7 @@
 	 */
 	function ajax_setFolderStatus($_folder)
 	{
-		translation::add_app('mail');
+		Api\Translation::add_app('mail');
 		//error_log(__METHOD__.__LINE__.array2string($_folder));
 		if ($_folder)
 		{
@@ -3512,7 +3512,7 @@
 			//error_log(__METHOD__.__LINE__.array2string($oA));
 			if ($oA)
 			{
-				$response = egw_json_response::get();
+				$response = Api\Json\Response::get();
 				$response->call('app.mail.mail_setFolderStatus',$oA);
 			}
 		}
@@ -3606,7 +3606,7 @@
 			if ($created===true)
 			{
 				$this->mail_bo->resetFolderObjectCache($profileID);
-				$response = egw_json_response::get();
+				$response = Api\Json\Response::get();
 				if ( $oldFolderInfo['shortDisplayName'])
 				{
 					$nodeInfo = array($_parentFolderName=>$oldFolderInfo['shortDisplayName']);
@@ -3621,7 +3621,7 @@
 			{
 				if ($errorMessage)
 				{
-					$response = egw_json_response::get();
+					$response = Api\Json\Response::get();
 					$response->call('egw.message',$errorMessage);
 				}
 			}
@@ -3639,7 +3639,7 @@
 		if (Mail::$debug) error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
 		if ($_folderName)
 		{
-			translation::add_app('mail');
+			Api\Translation::add_app('mail');
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
 			$_newName = $this->mail_bo->decodeEntityFolderName($_newName);
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
@@ -3690,8 +3690,8 @@
 						{
 							$this->mail_bo->resetFolderObjectCache($profileID);
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
-							$rv = $this->mail_bo->icServer->subscribeMailbox($newFolderName, true);
-							$rv = $this->mail_bo->icServer->subscribeMailbox($folderName, false);
+							$this->mail_bo->icServer->subscribeMailbox($newFolderName, true);
+							$this->mail_bo->icServer->subscribeMailbox($folderName, false);
 							$success = true;
 						}
 					}
@@ -3756,7 +3756,7 @@
 				$this->mail_bo->saveSessionData();
 			}
 			//error_log(__METHOD__.__LINE__.array2string($oA));
-			$response = egw_json_response::get();
+			$response = Api\Json\Response::get();
 			if ($oA && $success)
 			{
 				$response->call('app.mail.mail_setLeaf',$oA);
@@ -3777,7 +3777,7 @@
 	 */
 	function ajax_reloadNode($_folderName,$_subscribedOnly=true)
 	{
-		translation::add_app('mail');
+		Api\Translation::add_app('mail');
 		$oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'];
 
 		// prefs are plain prefs; we discussed an approach to have user only prefs, and
@@ -3814,7 +3814,7 @@
 			);
 		}
 		// Send full info back in the response
-		$response = egw_json_response::get();
+		$response = Api\Json\Response::get();
 		foreach($refreshData as $folder => &$name)
 		{
 			$name = $this->mail_tree->getTree($folder,$profileID,1,false, $_subscribedOnly,true);
@@ -3837,7 +3837,7 @@
 	 */
 	function ajax_resolveWinmail ($_rowid)
 	{
-		$response = egw_json_response::get();
+		$response = Api\Json\Response::get();
 
 		$idParts = self::splitRowID($_rowid);
 		$uid = $idParts['msgUID'];
@@ -3869,10 +3869,10 @@
 		if ($_folderName)
 		{
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
-			$_newLocation = $this->mail_bo->decodeEntityFolderName($_target);
+			$_newLocation2 = $this->mail_bo->decodeEntityFolderName($_target);
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
 			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
-			list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation,2);
+			list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation2,2);
 			$hasChildren = false;
 			if (is_numeric($profileID))
 			{
@@ -3923,8 +3923,8 @@
 						{
 							$this->mail_bo->resetFolderObjectCache($profileID);
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
-							$rv = $this->mail_bo->icServer->subscribeMailbox($newFolderName, true);
-							$rv = $this->mail_bo->icServer->subscribeMailbox($folderName, false);
+							$this->mail_bo->icServer->subscribeMailbox($newFolderName, true);
+							$this->mail_bo->icServer->subscribeMailbox($folderName, false);
 							$this->mail_bo->resetFolderObjectCache($profileID);
 							$success = true;
 						}
@@ -3962,10 +3962,10 @@
 				$this->mail_bo->saveSessionData();
 			}
 			//error_log(__METHOD__.__LINE__.array2string($oA));
-			$response = egw_json_response::get();
+			$response = Api\Json\Response::get();
 			if ($success)
 			{
-				translation::add_app('mail');
+				Api\Translation::add_app('mail');
 
 				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder,false,false,false);
 				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
@@ -4038,7 +4038,7 @@
 						//we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree
 						foreach($ftD as $k => $lc)//collection per level
 						{
-							foreach($lc as $i => $f)//folders contained in that level
+							foreach($lc as $f)//folders contained in that level
 							{
 								try
 								{
@@ -4076,7 +4076,7 @@
 				}
 			}
 			if ($_return) return $success;
-			$response = egw_json_response::get();
+			$response = Api\Json\Response::get();
 			if ($success)
 			{
 				//error_log(__METHOD__.__LINE__.array2string($oA));
@@ -4100,7 +4100,7 @@
 	 */
 	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id=null)
 	{
-		$response = egw_json_response::get();
+		$response = Api\Json\Response::get();
 
 		$previous_id = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
 
@@ -4133,7 +4133,7 @@
 		// Send full info back in the response
 		if($getFolders)
 		{
-			translation::add_app('mail');
+			Api\Translation::add_app('mail');
 
 			$refreshData = array(
 				$icServerID => $mail_ui->mail_tree->getTree(null,$icServerID,1,false,!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'])
@@ -4152,7 +4152,7 @@
 	public static function ajax_refreshVacationNotice($icServerID=null)
 	{
 		//Get vacation from cache if it's available
-		$cachedVacations = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
+		$cachedVacations = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
 		$vacation = $cachedVacations[$icServerID];
 
 		if (!$vacation)
@@ -4171,7 +4171,7 @@
 			{
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
-				$refreshData['vacationrange'] = ($vacation['status']=='by_date'? common::show_date($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.common::show_date($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
+				$refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
 				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = '';
 			}
 		}
@@ -4180,7 +4180,7 @@
 			$refreshData['vacationnotice'] =  '';
 			$refreshData['vacationrange'] =  '';
 		}
-		$response = egw_json_response::get();
+		$response = Api\Json\Response::get();
 		$response->call('app.mail.mail_refreshVacationNotice',$refreshData);
 	}
 
@@ -4197,7 +4197,7 @@
 		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
 		if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
 		{
-			Mail::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
+			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
 			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
 		}
 		if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
@@ -4224,7 +4224,7 @@
 			}
 		}
 
-		$response = egw_json_response::get();
+		$response = Api\Json\Response::get();
 		$response->call('app.mail.mail_refreshCatIdOptions',$this->searchTypes);
 		$response->call('app.mail.mail_refreshFilterOptions',$this->statusTypes);
 		$response->call('app.mail.mail_refreshFilter2Options',array(''=>lang('No details'),1=>lang('Details')));
@@ -4239,7 +4239,7 @@
 	function ajax_refreshQuotaDisplay($icServerID=null)
 	{
 		//error_log(__METHOD__.__LINE__.array2string($icServerID));
-		translation::add_app('mail');
+		Api\Translation::add_app('mail');
 		if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID;
 		$rememberServerID = $this->mail_bo->profileID;
 		if ($icServerID && $icServerID != $this->mail_bo->profileID)
@@ -4271,7 +4271,7 @@
 			//error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID);
 			$this->changeProfile($rememberServerID);
 		}
-		$response = egw_json_response::get();
+		$response = Api\Json\Response::get();
 		$response->call('app.mail.mail_setQuotaDisplay',array('data'=>$content));
 	}
 
@@ -4285,8 +4285,8 @@
 	function ajax_emptySpam($icServerID, $selectedFolder)
 	{
 		//error_log(__METHOD__.__LINE__.' '.$icServerID);
-		translation::add_app('mail');
-		$response = egw_json_response::get();
+		Api\Translation::add_app('mail');
+		$response = Api\Json\Response::get();
 		$rememberServerID = $this->mail_bo->profileID;
 		if ($icServerID && $icServerID != $this->mail_bo->profileID)
 		{
@@ -4335,8 +4335,8 @@
 	function ajax_emptyTrash($icServerID, $selectedFolder)
 	{
 		//error_log(__METHOD__.__LINE__.' '.$icServerID);
-		translation::add_app('mail');
-		$response = egw_json_response::get();
+		Api\Translation::add_app('mail');
+		$response = Api\Json\Response::get();
 		$rememberServerID = $this->mail_bo->profileID;
 		if ($icServerID && $icServerID != $this->mail_bo->profileID)
 		{
@@ -4384,7 +4384,7 @@
 	function ajax_compressFolder($_folderName)
 	{
 		//error_log(__METHOD__.__LINE__.' '.$_folderName);
-		translation::add_app('mail');
+		Api\Translation::add_app('mail');
 
 		$this->mail_bo->restoreSessionData();
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
@@ -4407,7 +4407,7 @@
 				//error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID);
 				$this->changeProfile($rememberServerID);
 			}
-			$response = egw_json_response::get();
+			$response = Api\Json\Response::get();
 			$response->call('egw.refresh',lang('compress folder').': '.$folderName,'mail');
 		}
 	}
@@ -4439,7 +4439,7 @@
 	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
 	{
 		if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
-		translation::add_app('mail');
+		Api\Translation::add_app('mail');
 		$alreadyFlagged=false;
 		$flag2check='';
 		$filter2toggle = $query = array();
@@ -4458,13 +4458,13 @@
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
 						{
-							Mail::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
 							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
 						}
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
 						$cutoffdate = $cutoffdate2 = null;
-						if ($query['startdate']) $cutoffdate = egw_time::to($query['startdate'],'ts');//SINCE, enddate
-						if ($query['enddate']) $cutoffdate2 = egw_time::to($query['enddate'],'ts');//BEFORE, startdate
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
 						$filter = array(
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4603,7 +4603,7 @@
 				'label4'	=> 'to do',	//lang('to do'),
 				'label5'	=> 'later',	//lang('later'),
 			);
-			$response = egw_json_response::get();
+			$response = Api\Json\Response::get();
 			if (isset($_messageList['msg']) && $_messageList['popup'])
 			{
 				$response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',$_messageList['msg'],lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail', $_messageList['msg'], 'update');
@@ -4646,13 +4646,13 @@
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
 						{
-							Mail::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
 							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
 						}
 						$filtered =  true;
 						$cutoffdate = $cutoffdate2 = null;
-						if ($query['startdate']) $cutoffdate = egw_time::to($query['startdate'],'ts');//SINCE, enddate
-						if ($query['enddate']) $cutoffdate2 = egw_time::to($query['enddate'],'ts');//BEFORE, startdate
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
 						$filter = array(
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4677,7 +4677,6 @@
 					{
 						$filter = array();
 					}
-					$messageList = array();
 					//error_log(__METHOD__.__LINE__."->".print_r($filter,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
 					$reverse = 1;
 					$rByUid = true;
@@ -4700,7 +4699,7 @@
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
 					$this->mail_bo->deleteMessages(($messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
 				}
-				catch (egw_exception $e)
+				catch (Api\Exception $e)
 				{
 					$error = str_replace('"',"'",$e->getMessage());
 				}
@@ -4719,12 +4718,12 @@
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
 					$this->mail_bo->deleteMessages($messageList,$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
 				}
-				catch (egw_exception $e)
+				catch (Api\Exception $e)
 				{
 					$error = str_replace('"',"'",$e->getMessage());
 				}
 			}
-			$response = egw_json_response::get();
+			$response = Api\Json\Response::get();
 			if (empty($error))
 			{
 				$response->call('app.mail.mail_deleteMessagesShowResult',array('egw_message'=>lang('deleted %1 messages in %2',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($_messageList['msg'])),$folder),'msg'=>$_messageList['msg']));
@@ -4754,11 +4753,11 @@
 	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_')
 	{
 		if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
-		translation::add_app('mail');
-		$_folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
+		Api\Translation::add_app('mail');
+		$folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
 		// only copy or move are supported as method
 		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
-		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$_folderName,2);
+		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2);
 		// check if move2archive was called with the correct archiveFolder
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
 		if ($_move2ArchiveMarker=='2' && $targetFolder != $archiveFolder)
@@ -4768,7 +4767,7 @@
 			$targetFolder = $archiveFolder;
 			error_log(__METHOD__.__LINE__."#Fixed ArchiveFolder:"."$targetProfileID,$targetFolder");
 		}
-		$lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
+		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
 		$changeFolderActions = false;
 		//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder");
 		//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
@@ -4786,7 +4785,7 @@
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
 			}
 			//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder = $_folderName");
-			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$_folderName;
+			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$folderName;
 			$changeFolderActions = true;
 		}
 		$filtered = false;
@@ -4807,13 +4806,13 @@
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
 						{
-							Mail::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
 							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
 						}
 						$filtered = true;
 						$cutoffdate = $cutoffdate2 = null;
-						if ($query['startdate']) $cutoffdate = egw_time::to($query['startdate'],'ts');//SINCE, enddate
-						if ($query['enddate']) $cutoffdate2 = egw_time::to($query['enddate'],'ts');//BEFORE, startdate
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
 						$filter = array(
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4838,7 +4837,6 @@
 					{
 						$filter = array();
 					}
-					$messageList = array();
 					$reverse = 1;
 					$rByUid = true;
 					$_sR = $this->mail_bo->getSortedList(
@@ -4855,7 +4853,7 @@
 						//error_log(__METHOD__.__LINE__.$uID);
 						if ($_copyOrMove=='move')
 						{
-							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $_folderName, $uID, $_prependApp=false);
+							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp=false);
 						}
 					}
 				}
@@ -4868,7 +4866,7 @@
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
 					$this->mail_bo->moveMessages($targetFolder,$messageList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
 				}
-				catch (egw_exception $e)
+				catch (Api\Exception $e)
 				{
 					$error = str_replace('"',"'",$e->getMessage());
 				}
@@ -4904,14 +4902,14 @@
 						//error_log(__METHOD__.__LINE__."->".print_r($moveList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
 						$this->mail_bo->moveMessages($targetFolder,$moveList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
 					}
-					catch (egw_exception $e)
+					catch (Api\Exception $e)
 					{
 						$error = str_replace('"',"'",$e->getMessage());
 					}
 				}
 			}
 
-			$response = egw_json_response::get();
+			$response = Api\Json\Response::get();
 			if ($error)
 			{
 				if ($changeFolderActions == false)
@@ -4935,9 +4933,8 @@
 			if ($changeFolderActions == true)
 			{
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
-				egw_cache::setCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
-				$actionsnew = self::get_actions();
-				$actionsnew = etemplate_widget_nextmatch::egw_actions($actionsnew);
+				Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
+				$actionsnew = Etemplate\Widget\Nextmatch::egw_actions(self::get_actions());
 				$response->call('app.mail.mail_rebuildActionsOnList',$actionsnew);
 			}
 		}
@@ -4956,8 +4953,8 @@
 	function ajax_folderMgmtTree_autoloading ($_id = null)
 	{
 		$mail_ui = new mail_ui();
-		$_id = $_id? $_id:$_GET['id'];
-		Api\Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($_id,'',1,true,false,false,false));
+		$id = $_id? $_id : $_GET['id'];
+		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,true,false,false,false));
 	}
 
 	/**
@@ -4967,7 +4964,7 @@
 	 */
 	function folderManagement (array $content = null)
 	{
-		$dtmpl = new etemplate_new('mail.folder_management');
+		$dtmpl = new Etemplate('mail.folder_management');
 		$profileID = $_GET['acc_id']? $_GET['acc_id']: $content['acc_id'];
 		$sel_options['tree'] = $this->mail_tree->getTree(null,$profileID, 1, true, false, false);
 
@@ -4996,7 +4993,7 @@
 		if ($_folderName)
 		{
 			$success = $this->ajax_deleteFolder($_folderName,true);
-			$response = egw_json_response::get();
+			$response = Api\Json\Response::get();
 			list(,$folderName) = explode(self::$delimiter, $_folderName);
 			if ($success)
 			{

Modified: trunk/mail/inc/class.mail_wizard.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/mail/inc/class.mail_wizard.inc.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/mail/inc/class.mail_wizard.inc.php (original)
+++ trunk/mail/inc/class.mail_wizard.inc.php Tue May  3 21:17:44 2016
@@ -9,8 +9,11 @@
  * @version $Id$
  */
 
+use EGroupware\Api;
+use EGroupware\Api\Framework;
+
 /**
- * Wizard to create mail accounts
+ * Wizard to create mail Api\Accounts
  *
  * Extends admin_mail to allow non-admins to use it.
  */
@@ -29,11 +32,11 @@
 		parent::__construct();
 
 		// need emailadmin's app.css file
-		egw_framework::includeCSS('admin','app');
+		Framework::includeCSS('admin','app');
 
 		// and translations
-		translation::add_app('admin');
+		Api\Translation::add_app('admin');
 
-		egw_framework::validate_file('/admin/js/app.js');
+		Framework::includeJS('/admin/js/app.js');
 	}
 }

Modified: trunk/mail/inc/class.mail_zpush.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/mail/inc/class.mail_zpush.inc.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/mail/inc/class.mail_zpush.inc.php (original)
+++ trunk/mail/inc/class.mail_zpush.inc.php Tue May  3 21:17:44 2016
@@ -12,6 +12,7 @@
  * @version $Id$
  */
 
+use EGroupware\Api;
 use EGroupware\Api\Mail;
 
 /**
@@ -97,7 +98,7 @@
 		if (is_null(self::$profileID))
 		{
 			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' self::ProfileID isNUll:'.array2string(self::$profileID));
-			self::$profileID =& egw_cache::getSession('mail','activeSyncProfileID');
+			self::$profileID =& Api\Cache::getSession('mail','activeSyncProfileID');
 			if ($this->debugLevel>1) error_log(__METHOD__.__LINE__.' ActiveProfileID (after reading Cache):'.array2string(self::$profileID));
 		}
 		if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID']))
@@ -188,8 +189,8 @@
 		if (isset($hook_data['prefs']['mail-ActiveSyncProfileID']) || $hook_data['type'] == 'user')
 		{
 			// eSync and eMail translations are not (yet) loaded
-			translation::add_app('activesync');
-			translation::add_app('mail');
+			Api\Translation::add_app('activesync');
+			Api\Translation::add_app('mail');
 
 			// inject preference to verify and call constructor
 			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-ActiveSyncProfileID'] =
@@ -362,8 +363,8 @@
 
 		ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.")".' ProfileID:'.self::$profileID.' ActiveMailProfile:'.array2string($activeMailProfile));
 
-		// initialize the new egw_mailer object for sending
-		$mailObject = new egw_mailer(self::$profileID);
+		// initialize the new Api\Mailer object for sending
+		$mailObject = new Api\Mailer(self::$profileID);
 		$this->mail->parseRawMessageIntoMailObject($mailObject,$smartdata->mime);
 		// Horde SMTP Class uses utf-8 by default. as we set charset always to utf-8
 		$mailObject->Sender  = $activeMailProfile['ident_email'];
@@ -437,7 +438,7 @@
 			else
 			{
 				$AltBody = $body;
-				$Body =  trim(translation::convertHTMLToText($body));
+				$Body =  trim(Api\Mail\Html::convertHTMLToText($body));
 				ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") fetched Body as :". $simpleBodyType.'=> Created Body');
 			}
 		}
@@ -531,7 +532,7 @@
 		$signature = $_signature['ident_signature'];
 		if ((isset($preferencesArray['disableRulerForSignatureSeparation']) &&
 			$preferencesArray['disableRulerForSignatureSeparation']) ||
-			empty($signature) || trim(translation::convertHTMLToText($signature)) =='')
+			empty($signature) || trim(Api\Mail\Html::convertHTMLToText($signature)) =='')
 		{
 			$disableRuler = true;
 		}
@@ -541,7 +542,7 @@
 		$sigText = Mail::merge($signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
 		if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Signature to use:'.$sigText);
 		$sigTextHtml = $beforeHtml.$sigText;
-		$sigTextPlain = $beforePlain.translation::convertHTMLToText($sigText);
+		$sigTextPlain = $beforePlain.Api\Mail\Html::convertHTMLToText($sigText);
 		$isreply = $isforward = false;
 		// reply ---------------------------------------------------------------------------
 		if ($smartdata_task == 'reply' && isset($smartdata->source->itemid) &&
@@ -578,7 +579,7 @@
 			{
 				$isreply = true;
 				$AltBody = $AltBody."</br><pre>".nl2br($bodyBUFF).'</pre>'.$sigTextHtml;
-				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no html Body found use modified plaintext body for txt/html: ".$AltBody);
+				if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." no Api\Html Body found use modified plaintext body for txt/html: ".$AltBody);
 			}
 		}
 
@@ -611,7 +612,6 @@
 			// build a new mime message, forward entire old mail as file
 			if ($preferencesArray['message_forwarding'] == 'asmail')
 			{
-				$rawHeader='';
 				$rawHeader      = $this->mail->getMessageRawHeader($smartdata->source->itemid, $_partID,$folder);
 				$rawBody        = $this->mail->getMessageRawBody($smartdata->source->itemid, $_partID,$folder);
 				$mailObject->AddStringAttachment($rawHeader.$rawBody, $headers['SUBJECT'].'.eml', 'message/rfc822');
@@ -664,7 +664,6 @@
 					{
 						if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' Key:'.$key.'->'.array2string($attachment));
 						$attachmentNames .= $attachment['name']."\n";
-						$attachmentData = '';
 						$attachmentData	= $this->mail->getAttachment($uid, $attachment['partID'],0,false,false,$folder);
 						/*$x =*/ $mailObject->AddStringAttachment($attachmentData['attachment'], $mailObject->EncodeHeader($attachment['name']), $attachment['mimeType']);
 						ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' added part with number:'.$x);
@@ -773,7 +772,7 @@
 							$this->mail->appendMessage($folderName,$mailObject->getRaw(), null,
 									$flags);
 						}
-						catch (egw_exception_wrong_userinput $e)
+						catch (Api\Exception\WrongUserinput $e)
 						{
 							//$asf = false;
 							ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$mailObject->getHeader('Subject'),$folderName,$e->getMessage()));
@@ -920,7 +919,7 @@
 					$bodyStructplain = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text');
 					if(isset($bodyStructplain[0])&&isset($bodyStructplain[0]['error'])&&$bodyStructplain[0]['error']==1)
 					{
-						$plainBody = translation::convertHTMLToText($body); // always display with preserved HTML
+						$plainBody = Api\Mail\Html::convertHTMLToText($body); // always display with preserved HTML
 					}
 					else
 					{
@@ -939,8 +938,8 @@
 					//SYNC_BODYPREFERENCE_MIME
 					ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." bodypreference 4 requested");
 					$output->asbody->type = SYNC_BODYPREFERENCE_MIME;//4;
-					// use egw_mailer::convert to convert charset of all text parts to utf-8, which is a z-push or AS requirement!
-					$Body = egw_mailer::convert($this->mail->getMessageRawBody($id, '', $_folderName));
+					// use Api\Mailer::convert to convert charset of all text parts to utf-8, which is a z-push or AS requirement!
+					$Body = Api\Mailer::convert($this->mail->getMessageRawBody($id, '', $_folderName));
 					if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__." Setting Mailobjectcontent to output:".$Body);
 					$output->asbody->data = $Body;
 				}
@@ -1342,7 +1341,7 @@
 		debugLog (__METHOD__.' for Folder:'.$folderid.' SINCE:'.$cutdate.'/'.date("d-M-Y", $cutdate));
 		if (empty($cutdate))
 		{
-			$cutdate = egw_time::to('now','ts')-(3600*24*28*3);
+			$cutdate = Api\DateTime::to('now','ts')-(3600*24*28*3);
 			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using 12 weeks.'.date("d-M-Y", $cutdate));
 		}
 		return $this->fetchMessages($folderid, $cutdate);
@@ -1504,7 +1503,7 @@
 		// other types may be possible - we support quicksearch first (freeText in subject and from (or TO in Sent Folder))
 		if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[self::$profileID]))
 		{
-			Mail::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10);
+			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10);
 			if (!isset(Mail::$supportsORinQuery[self::$profileID])) Mail::$supportsORinQuery[self::$profileID]=true;
 		}
 */
@@ -1539,8 +1538,8 @@
 			$_filter['range'] = "BETWEEN";
 			list($sincedate,$crap) = explode('T',$searchquery['searchvaluegreater']);
 			list($beforedate,$crap) = explode('T',$searchquery['searchvalueless']);
-			$_filter['before'] = date("d-M-Y", egw_time::to($beforedate,'ts'));
-			$_filter['since'] = date("d-M-Y", egw_time::to($sincedate,'ts'));
+			$_filter['before'] = date("d-M-Y", Api\DateTime::to($beforedate,'ts'));
+			$_filter['since'] = date("d-M-Y", Api\DateTime::to($sincedate,'ts'));
 		}
 		//$_filter[] = array('type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate));
 		if ($this->debugLevel>1) debugLog (__METHOD__.' for Folder:'.$_folderName.' Filter:'.array2string($_filter));
@@ -1773,7 +1772,7 @@
 		{
 			$rv = $this->mail->deleteMessages($_messageUID, $folder);
 		}
-		catch (egw_exception $e)
+		catch (Api\Exception $e)
 		{
 			$error = $e->getMessage();
 			ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__." $_messageUID, $folder ->".$error);
@@ -1885,7 +1884,7 @@
 	 * @param string $folder
 	 * @param int $id =0
 	 * @return string
-	 * @throws egw_exception_wrong_parameter
+	 * @throws Api\Exception\WrongParameter
 	 */
 	private function createID($account,$folder,$id=0)
 	{
@@ -1909,7 +1908,7 @@
 	 * @param int &$account mail account id
 	 * @param string &$folder
 	 * @param int &$id=null
-	 * @throws egw_exception_wrong_parameter
+	 * @throws Api\Exception\WrongParameter
 	 */
 	private function splitID($str,&$account,&$folder,&$id=null)
 	{
@@ -2007,13 +2006,13 @@
 	 * On request this function also returns, but never creates (!), old z-push 1 directory.
 	 *
 	 * @param boolean $old =false true: return old / pre-15 hash-file
-	 * @throws egw_exception_assertion_failed
+	 * @throws Api\Exception\AssertionFailed
 	 */
 	private function hashFile($old=false)
 	{
 		if (!($dev_id=Request::GetDeviceID()))
 		{
-			throw new egw_exception_assertion_failed(__METHOD__."() no DeviceID set!");
+			throw new Api\Exception\AssertionFailed(__METHOD__."() no DeviceID set!");
 		}
 		if ($old)
 		{

Modified: trunk/mail/setup/default_records.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/mail/setup/default_records.inc.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/mail/setup/default_records.inc.php (original)
+++ trunk/mail/setup/default_records.inc.php Tue May  3 21:17:44 2016
@@ -6,10 +6,12 @@
  * @package mail
  * @subpackage setup
  * @author Stylite AG [[email protected]]
- * @copyright (c) 2014 by Stylite AG <info-AT-stylite.de>
+ * @copyright (c) 2014-16 by Stylite AG <info-AT-stylite.de>
  * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
  * @version $Id$
  */
+
+use EGroupware\Api;
 
 // change felamimail run rights to new mail app
 $GLOBALS['egw_setup']->db->update('egw_acl', array(
@@ -27,10 +29,10 @@
 }
 
 // change common/default_app pref to mail, if it was felamimail
-preferences::change_preference('common', 'default_app', 'mail', 'felamimail');
+Api\Preferences::change_preference('common', 'default_app', 'mail', 'felamimail');
 
-// copy felamimail preferences to new mail app, if they still exist there
-preferences::copy_preferences('felamimail', 'mail', array(
+// copy felamimail Api\Preferences to new mail app, if they still exist there
+Api\Preferences::copy_preferences('felamimail', 'mail', array(
 	'htmlOptions',
 	'allowExternalIMGs',
 	'message_forwarding',

Modified: trunk/mail/setup/setup.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/mail/setup/setup.inc.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/mail/setup/setup.inc.php (original)
+++ trunk/mail/setup/setup.inc.php Tue May  3 21:17:44 2016
@@ -6,14 +6,14 @@
  * @package mail
  * @subpackage setup
  * @author Stylite AG [[email protected]]
- * @copyright (c) 2013-14 by Stylite AG <info-AT-stylite.de>
+ * @copyright (c) 2013-16 by Stylite AG <info-AT-stylite.de>
  * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
  * @version $Id$
  */
 
 $setup_info['mail']['name']      	= 'mail';
 $setup_info['mail']['title']     	= 'mail';
-$setup_info['mail']['version']     	= '14.1';
+$setup_info['mail']['version']     	= '16.1';
 $setup_info['mail']['app_order'] 	= 2;
 $setup_info['mail']['enable']    	= 1;
 $setup_info['mail']['index']    	= 'mail.mail_ui.index&ajax=true';
@@ -40,10 +40,6 @@
 
 /* Dependencies for this app to work */
 $setup_info['mail']['depends'][] = array(
-	'appname'  => 'phpgwapi',
-	'versions' => Array('14.1')
-);
-$setup_info['mail']['depends'][] = array(
 	'appname'  => 'api',
 	'versions' => Array('16.1')
 );

Modified: trunk/phpgwapi/inc/class.egw_keymanager.inc.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/phpgwapi/inc/class.egw_keymanager.inc.php?rev=55995&r1=55994&r2=55995&view=diff
==============================================================================
--- trunk/phpgwapi/inc/class.egw_keymanager.inc.php (original)
+++ trunk/phpgwapi/inc/class.egw_keymanager.inc.php Tue May  3 21:17:44 2016
@@ -5,159 +5,12 @@
  * @link http://www.egroupware.org
  * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
  * @package api
- * @subpackage egw action grid
+ * @subpackage etemplate
  * @author Andreas Stöckel
  * @copyright (c) 2011 Stylite
  * @version $Id$
  */
 
-class egw_keymanager
-{
-	const BACKSPACE = 8;
-	const TAB = 9;
-	const ENTER = 13;
-	const ESCAPE = 27;
-	const DELETE = 46;
+use EGroupware\Api\Etemplate\KeyManager;
 
-	const SPACE = 32;
-
-	const PAGE_UP = 33;
-	const PAGE_DOWN = 34;
-
-	const ARROW_LEFT = 37;
-	const ARROW_UP = 38;
-	const ARROW_RIGHT = 39;
-	const ARROW_DOWN = 40;
-
-	const _0 = 48;
-	const _1 = 49;
-	const _2 = 50;
-	const _3 = 51;
-	const _4 = 52;
-	const _5 = 53;
-	const _6 = 54;
-	const _7 = 55;
-	const _8 = 56;
-	const _9 = 57;
-
-	const A = 65;
-	const B = 66;
-	const C = 67;
-	const D = 68;
-	const E = 69;
-	const F = 70;
-	const G = 71;
-	const H = 72;
-	const I = 73;
-	const J = 74;
-	const K = 75;
-	const L = 76;
-	const M = 77;
-	const N = 78;
-	const O = 79;
-	const P = 80;
-	const Q = 81;
-	const R = 82;
-	const S = 83;
-	const T = 84;
-	const U = 85;
-	const V = 86;
-	const W = 87;
-	const X = 88;
-	const Y = 89;
-	const Z = 90;
-
-	const F1 = 112;
-	const F2 = 113;
-	const F3 = 114;
-	const F4 = 115;
-	const F5 = 116;
-	const F6 = 117;
-	const F7 = 118;
-	const F8 = 119;
-	const F9 = 120;
-	const F10 = 121;
-	const F11 = 122;
-	const F12 = 123;
-
-	/**
-	 * Converts the given key codes into translated key names.
-	 */
-	public static function key_name($keyCode)
-	{
-		// Keys which can be directly translated into ASCII chars
-		if (($keyCode >= self::_0 && $keyCode <= self::_9) ||
-			($keyCode >= self::A && $keyCode <= self::Z))
-		{
-			return chr($keyCode);
-		}
-
-		// Function keys
-		if ($keyCode >= self::F1 && $keyCode <= self::F12)
-		{
-			return "F".($keyCode - EGW_KEY_F1 + 1);
-		}
-
-		// Special keys
-		switch ($keyCode) {
-			case self::BACKSPACE:
-				return lang("Back");
-			case self::TAB:
-				return lang("Tab");
-			case self::DELETE:
-				return lang("Del");
-			case self::SPACE:
-				return lang("Space");
-			case self::PAGE_UP:
-				return lang("Pg up");
-			case self::PAGE_DOWN:
-				return lang("Pg down");
-		}
-
-		return "";
-	}
-
-	/**
-	 * Generates the caption of the given shortcut and returns it
-	 */
-	public static function shortcut_caption($keyCode, $shift = false, $ctrl = false, $alt = false)
-	{
-		$elems = array();
-
-		if ($shift)
-		{
-			$elems[] = lang("Shift");
-		}
-
-		if ($ctrl)
-		{
-			$elems[] = lang("Ctrl");
-		}
-
-		if ($alt)
-		{
-			$elems[] = lang("Alt");
-		}
-
-		$elems[] = self::key_name($keyCode);
-
-		return implode(" + ", $elems);
-	}
-
-	/**
-	 * Generates a shortcut structure which can be JSON encoded and send to the
-	 * egw action system. This function and class could later be used to provide
-	 * user defined shortcuts.
-	 */
-	public static function shortcut($keyCode, $shift = false, $ctrl = false, $alt = false)
-	{
-		return array(
-			"keyCode" => $keyCode,
-			"shift" => (boolean)$shift,
-			"ctrl" => (boolean)$ctrl,
-			"alt" => (boolean)$alt,
-			"caption" => self::shortcut_caption($keyCode, $shift, $ctrl, $alt)
-		);
-	}
-}
-
+class egw_keymanager extends KeyManager{}


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
eGroupWare-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs