#!/usr/bin/python3
# -*- coding: utf-8 -*-

# MyConnector
# Copyright (C) 2014-2024 Evgeniy Korneechev <ek@myconnector.ru>

# This program is free software; you can redistribute it and/or
# modify it under the terms of the version 2 of the GNU General
# Public License as published by the Free Software Foundation.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.

from subprocess import check_output
from os import system
from sys import ( argv,
                  exit )
import gettext
import locale

APP         = "myconnector"
MO_FOLDER   = "/usr/share/locale"

locale.bindtextdomain(  APP, MO_FOLDER )
gettext.bindtextdomain( APP, MO_FOLDER )
gettext.textdomain( APP )
_ = gettext.gettext

def main():
    currentVersion = check_output( "curl https://raw.githubusercontent.com/MyConnector/MyConnector/master/VERSION 2>/dev/null; exit 0",
                                   shell=True, universal_newlines=True ).strip()
    if currentVersion and currentVersion != argv[1]:
        system( "zenity --notification --window-icon=myconnector --text='%s MyConnector\n%s!\n%s: %s\n%s: %s'" %
              ( _("Program"), _("Your version is outdated"), _("Installed"), argv[1], _("Actual"), currentVersion ) )
    exit(0)

if __name__ == "__main__":
    main()
