<?php
/***********************************************
* File      :   config.php
* Descr     :   Main configuration file
*
* Original by Zarafa Deutschland GmbH released under GPLv2.
* Modifications by Atmail published under GPLv2
* Consult LICENSE file for details
************************************************/

define('SERIALIZE_TO_DB', true);
// Turn off for production
define('DEBUGGING', false);
define('PING_INTERVAL', 30);
define('TAR_PIT', 0);
define('TAR_PIT_MULTIPLIER', 1);

include_once("debug.php");

if( function_exists('mb_internal_encoding') )
{
	mb_internal_encoding('UTF-8');
	mb_regex_encoding('UTF-8');
}

if(function_exists("iconv_set_encoding"))
{
	iconv_set_encoding("internal_encoding", "UTF-8");
	iconv_set_encoding("input_encoding", "UTF-8");
	iconv_set_encoding("output_encoding", "UTF-8");
}


// Defines the default time zone
if (function_exists("date_default_timezone_set"))
{
	date_default_timezone_set("Australia/Brisbane");
}

// Defines the base path on the server, terminated by a slash
define('BASE_PATH', dirname($_SERVER['SCRIPT_FILENAME']) . "/");

// Define the include paths
ini_set('include_path',
					BASE_PATH. "include/" . PATH_SEPARATOR .
					BASE_PATH. PATH_SEPARATOR .
					ini_get('include_path') . PATH_SEPARATOR .
					"/usr/share/php/" . PATH_SEPARATOR .
					"/usr/share/php5/" . PATH_SEPARATOR .
					"/usr/share/pear/");

define('STATE_DIR', 'state');

// Try to set unlimited timeout
define('SCRIPT_TIMEOUT', 0);

//Max size of attachments to display inline. Default is 1MB
define('MAX_EMBEDDED_SIZE', 1048576);

// Device Provisioning
define('PROVISIONING', false);

// This option allows the 'loose enforcement' of the provisioning policies for older
// devices which don't support provisioning (like WM 5 and HTC Android Mail) - dw2412 contribution
// false (default) - Enforce provisioning for all devices
// true - allow older devices, but enforce policies on devices which support it
define('LOOSE_PROVISIONING', true);

// The data providers that we are using (see configuration below)
//$BACKEND_PROVIDER = "BackendICS";
//$BACKEND_PROVIDER = "BackendIMAP";
//$BACKEND_PROVIDER = "BackendAtmailAbook";
$BACKEND_PROVIDER = "BackendCombined";
//$BACKEND_PROVIDER = "BackendSerialize";

// ************************
//  BackendICS settings
// ************************

// Defines the server to which we want to connect
define('MAPI_SERVER', '');


// ************************
//  BackendIMAP settings
// ************************

// Defines the server to which we want to connect
// recommended to use local servers only
define('IMAP_SERVER', 'localhost');
// connecting to default port (143)
define('IMAP_PORT', 143);
// best cross-platform compatibility (see http://php.net/imap_open for options)
//define('IMAP_OPTIONS', '/notls/norsh');
define('IMAP_OPTIONS', '/norsh/notls/novalidate-cert');
// overwrite the "from" header if it isn't set when sending emails
// options: 'username'    - the username will be set (usefull if your login is equal to your emailaddress)
//        'domain'    - the value of the "domain" field is used
//        '@mydomain.com' - the username is used and the given string will be appended
define('IMAP_DEFAULTFROM', 'username');
// copy outgoing mail to this folder. If not set atmail will try the default folders
define('IMAP_SENTFOLDER', '');


// ************************
//  BackendMaildir settings
// ************************
define('MAILDIR_BASE', '/tmp');
define('MAILDIR_SUBDIR', 'Maildir');

// **********************
//  BackendVCDir settings
// **********************
define('VCARDDIR_DIR', '/home/%u/.kde/share/apps/kabc/stdvcf');

$BackendIMAP_config = '';
$BackendAtmailAbook_config = '';

$BackendCalendar_config = array(
	//'SERIALIZE_DIR' => '/usr/local/atmail/webmail/push/serialize/%u/',
	'SERIALIZE_DIR' => '/usr/local/atmail/webmail/push/serialize',
	'SERIALIZE_DELIMITER' => '/',
	//set which folders should have specific type
	'SERIALIZE_FOLDERS' => array(
	SYNC_FOLDER_TYPE_TASK => array('tasks'),
	SYNC_FOLDER_TYPE_APPOINTMENT => array('calendar')
	),
);

$BackendSerialize_config = array(
	//'SERIALIZE_DIR' => '/usr/local/atmail/webmail/push/serialize/%u/',
	'SERIALIZE_DIR' => '/usr/local/atmail/webmail/push/serialize',
	'SERIALIZE_DELIMITER' => '/',
	//set which folders should have specific type
	'SERIALIZE_FOLDERS' => array(
	SYNC_FOLDER_TYPE_CONTACT => array('contacts'),
	SYNC_FOLDER_TYPE_APPOINTMENT => array('calendar')
	),
);

$BackendCombined_config = array(
	//the order in which the backends are loaded.
	//login only succeeds if all backend return true on login
	//when sending mail: the mail is send with first backend that is able to send the mail
	'backends' => array(

		'i' => array(
			'name' => 'BackendIMAP',
			'config' => $BackendIMAP_config,
		),
		's' => array(
			'name' => 'BackendAtmailCalendar',
			'config' => $BackendCalendar_config,
		),
		'v' => array(
			'name' => 'BackendAtmailAbook',
			'config' => $BackendAtmailAbook_config,
		),
		//'v' => array(
		//	'name' => 'BackendSerialize',
		//	'config' => $BackendSerialize_config,
		//)
	),

	'delimiter' => '/',
	//force one type of folder to one backend
	'folderbackend' => array(
		SYNC_FOLDER_TYPE_INBOX => 'i',
		SYNC_FOLDER_TYPE_DRAFTS => 'i',
		SYNC_FOLDER_TYPE_WASTEBASKET => 'i',
		SYNC_FOLDER_TYPE_SENTMAIL => 'i',
		SYNC_FOLDER_TYPE_OUTBOX => 'i',
		SYNC_FOLDER_TYPE_CONTACT => 'v',
		SYNC_FOLDER_TYPE_TASK => 's',
		SYNC_FOLDER_TYPE_APPOINTMENT => 's'
	),

	//creating a new folder in the root folder should create a folder in one backend
	'rootcreatefolderbackend' => 'i'
);

$BACKEND_CONFIG = ${$BACKEND_PROVIDER."_config"};
