<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1700" Guid="{BD692227-0BBA-4897-B77D-71EC06CAFCD2}" Time="1443113426.37">
    <Passwords>
        ebZfmF37ioz2vTMDZv+E+fmN0b++ENjrEV5lTbsG+fPwGJxGS97qQQzI2iyQr385y+vt0eZ+1+O5
        o4fcjK1rPpV7GZVr6+Dw/TPso89UTnZmdAObc+l5Y2jSwLSuq2lWTs0TIX9ODCNCAzufm4IlwWnn
        NpKtcTkW0TIIQ4bKfH4=
    </Passwords>
    <Autostart Name="Autostart" Expanded="True">
        <Plugin Identifier="PushBullet" Guid="{C92AD47A-B959-44D5-A849-9FCCCAAC9572}" File="PushBullet">
            gAIoWAsAAABFRy1CVE1PQklMRXEAY2VnLkNsYXNzZXMuUGFzc3dvcmQKUGFzc3dvcmQKcQEpgXECfXEDVQRndWlkcQRVJns1MkRGN0FGMy00MDZBLTQzMzktODRFOS0zRjYzRDc0MEE5MTF9cQVzYlgWAAAAdWp6YktubndKc3lzakFuQmRKQTB5R3EGWAoAAABQdXNoQnVsbGV0cQdLAVgjAAAAQzpcVXNlcnNcYmhlbmRpblxBcHBEYXRhXExvY2FsXFRlbXBxCEsFS7RLD11xCYlYAAAAAHEKiFUNMTQ0MzExMzQxNS40NnELiUv/S/9L/4dxDEsBSwBLAEsAhnENXXEOXXEPXXEQaAEpgXERfXESVQRndWlkcRNVJntBOTczRDM4Ny0yQUZDLTQwMzYtQkVCNC1EQzlDQTRCRDcyMTV9cRRzYoiIdHEVLg==
        </Plugin>
        <Plugin Identifier="XBMC2" Guid="{8C8B850C-773F-4583-AAD9-A568262B7933}" File="XBMCRepeat">
            gAJ9cQAoVQlCcm9hZGNhc3RxAX1xAihVBmVuYWJsZXEDiVUEcG9ydHEETVYgdVULRXZlbnRTZXJ2ZXJxBX1xBihoA4hoBE0xJnVVDGxvZ1Jhd0V2ZW50c3EHiVUHSlNPTlJQQ3EIfXEJKGgDiWgETYIjdVUEWEJNQ3EKfXELKFUIdXNlcm5hbWVxDFgAAAAAcQ1VAmlwcQ5YCQAAADEyNy4wLjAuMXEPVQhwYXNzd29yZHEQaA1oBEtQdXWIhnERLg==
        </Plugin>
        <Plugin Identifier="Timer" Guid="{6149CA99-1FCD-4450-9160-7543BC20CFD3}" File="Timer">
            gAIpLg==
        </Plugin>
        <Plugin Identifier="Keyboard" Guid="{59CBD10F-C1D8-4ADB-999B-9B76BA360F1F}" File="Keyboard">
            gAKIhXEALg==
        </Plugin>
    </Autostart>
    <Folder Name="PushBullet Notifications" Expanded="True">
        <Macro Name="PushBullet Notifications" id="8" Expanded="True">
            <Event Name="PushBullet.Mirror.*" />
            <Action>
                EventGhost.PythonScript(u'import time\n\n# This function is needed to determine the current state of playing video and to deal with no discrete Play/Pause in XBMC/Kodi\ndef getVideoPlaying():\n    videoPlaying = 0\n    activePlayer = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False)\n    if activePlayer:\n        if activePlayer[0]["type"] == "video":\n            mediaSpeed = eg.plugins.XBMC2.JSONRPC(u\'Player.GetProperties\', u\'1,["speed"]\', False)["speed"]\n            if mediaSpeed &gt; 0:\n                videoPlaying = 1\n    return videoPlaying\n\n# Get all variables\neventName=eg.event.payload[0]\ndeviceName=eg.event.payload[1]\npushDict = eg.event.payload[3]\nfor items in pushDict:\n    if items == "package_name":\n        packageName = pushDict[items]\nfor items in pushDict:\n    if items == "title":\n        eventTitle = pushDict[items]        \ngetStartedVideoState=getVideoPlaying()\n\n# Print to EG for debugging\nprint "deviceName: " + deviceName\nprint "packageName: " + packageName\nprint "eventTitle: " + str(eventTitle)\nprint "eventName: " + eventName.replace(\'\\n\', \' \')\nprint "getVideoPlaying: " + str(getVideoPlaying())\n\n# Set friendly names\nif deviceName == "HTC One M8":\n    deviceName = "Joe"\nelse:\n    deviceName = "Jane"\n\nif packageName == "com.pushbullet.android":\n    if eventTitle == "Test notification":\n        notificationString=u\'"\' + deviceName + ": " + eventTitle + \'","\' + eventTitle +\'","http://www.boemagroup.com/images/call.png",15000\'\n        eg.plugins.XBMC2.JSONRPC(u\'GUI.ShowNotification\', notificationString, False)\n        eg.plugins.PushBullet.SendDismiss()\n        \nif packageName == "com.google.android.talk":\n    textBody = eventName.replace(\'\\n\', \' \')\n    textBody = textBody.replace(\'myemail@place.com\',\'\') # parse my e-mail out of message.\n    bodyLength = len(textBody)\n    toastDelay = (bodyLength * 160) + 3000\n    strToastDelay = str(toastDelay)\n    \n    if getVideoPlaying():\n        eg.plugins.XBMC2.Pause()\n    \n    notificationString=u\'"Hangouts: \' + eventTitle + \'","\' + textBody +\'","https://xtraweb.files.wordpress.com/2013/11/hangouts-1024x1024.png",\' + strToastDelay\n    eg.plugins.XBMC2.JSONRPC(u\'GUI.ShowNotification\', notificationString, False)\n    eg.plugins.PushBullet.SendDismiss()\n    time.sleep(toastDelay/1000)\n    \n    if getStartedVideoState:\n        eg.plugins.XBMC2.Play()\n\nif eventName == "Incoming call":\n    if getVideoPlaying(): eg.plugins.XBMC2.Pause()\n    notificationString=u\'"\' + deviceName + ": " + eventName + \'","\' + eventTitle +\'","http://www.boemagroup.com/images/call.png",15000\'\n    eg.plugins.XBMC2.JSONRPC(u\'GUI.ShowNotification\', notificationString, False)\n')
            </Action>
        </Macro>
        <Folder Name="Toggle PushBullet Notifications" Expanded="True">
            <Macro Name="Item: PushBullet Notifications" Expanded="True">
                <Event Name="Keyboard.Ctrl+B" />
                <Action>
                    EventGhost.GetItemState(XmlIdLink(8))
                </Action>
                <Action>
                    EventGhost.JumpIfElse(XmlIdLink(20), 0, False, XmlIdLink(16), False)
                </Action>
            </Macro>
            <Macro Name="Enable: PushBullet Notifications" id="16" Expanded="True">
                <Action>
                    EventGhost.EnableItem(XmlIdLink(8))
                </Action>
                <Action>
                    EventGhost.ShowOSD(u'DISMISS NOTIFICATIONS:\nON', u'0;-24;0;0;0;700;0;0;0;1;0;0;2;32;Arial', (0, 255, 0), (0, 0, 0), 1, (0, 0), 0, 3.0, True)
                </Action>
                <Action>
                    Timer.TimerAction(u'PushBullet.Notification.Timer', 0, 1, 7200.0, u'PushBullet.Notification.Disable', False, True, 1, u'00:00:00')
                </Action>
            </Macro>
            <Macro Name="Disable: Enable: PushBullet Notifications" id="20" Expanded="True">
                <Event Name="Timer.PushBullet.Notification.Disable" />
                <Action>
                    EventGhost.ShowOSD(u'DISMISS NOTIFICATIONS:\nOFF', u'0;-24;0;0;0;700;0;0;0;1;0;0;2;32;Arial', (255, 0, 0), (0, 0, 0), 1, (0, 0), 0, 3.0, True)
                </Action>
                <Action>
                    EventGhost.DisableItem(XmlIdLink(8))
                </Action>
            </Macro>
        </Folder>
    </Folder>
</EventGhost>
