<?php


class activesyncHeaders
{
    public static $supportedASServerVersions =
        //array('6.5.7638.1');
        //array( 1.0,2.0,2.1,2.5,'6.5.7638.1');
        array(1.0, 2.0, 2.1, 2.5, '6.5.7638.1', /*12.0,*/ 12.1); //,14.0 );
        //array( 1.0,2.0,2.1,2.5,'6.5.7638.1',12.0,12.1,14.0 );
    public static $supportedASProtocolVersions =
        //array(1.0,2.0,2.1,2.5);
        array(1.0, 2.0, 2.1, 2.5, /*12.0,*/ 12.1);
        //array( 1.0,2.0,2.1,2.5,12.0,12.1,14.0 );
    public static $supportedASProtocolCommands = array(
        0 => array( // proto ver <=6.5.7638.1
            "Sync",
            "SendMail",
            "SmartForward",
            "SmartReply",
            "GetAttachment",
            "GetHierarchy",
            "CreateCollection",
            "DeleteCollection",
            "MoveCollection",
            "FolderSync",
            "FolderCreate",
            "FolderDelete",
            "FolderUpdate",
            "MoveItems",
            "GetItemEstimate",
            "MeetingResponse",
            "ResolveRecipients",
            "ValidateCert",
            "Provision",
            "Search",
            "Ping"
        ),
        1 => array( // proto ver >=12
            "Sync",
            "SendMail",
            "SmartForward",
            "SmartReply",
            "GetAttachment",
            "GetHierarchy",
            "CreateCollection",
            "DeleteCollection",
            "MoveCollection",
            "FolderSync",
            "FolderCreate",
            "FolderDelete",
            "FolderUpdate",
            "MoveItems",
            "GetItemEstimate",
            "MeetingResponse",
            "ResolveRecipients",
            "ValidateCert",
            "Provision",
            "Search",
            "Ping",
            "Settings"));


    public static function getBestASServerVersion()
    {
        return self::$supportedASServerVersions[count(self::$supportedASServerVersions) - 1];
    }

    public static function getServerHeader()
    {
        return "MS-Server-ActiveSync: " . self::getBestASServerVersion();
    }

    public static function getProtocolVersionHeader()
    {
        return "MS-ASProtocolVersions: " . rtrim(implode(',', self::$supportedASProtocolVersions), ',');
    }

    public static function getProtocolCommandsHeader()
    {
        return "MS-ASProtocolCommands: " . rtrim(implode(',', self::$supportedASProtocolCommands[(self::getBestASServerVersion() >= 12 ? 1 : 0)]), ',');
    }
}