# Copyright (c) 2004-5 Marek Hnilica. All rights reserved. # Module that checks for new mBox version. # Distributed under GPL version 2, or (at your option) later import string,httplib import wx from version import mBoxVersion def Close(junk): window.Close() def check(parent,Show=1): global window window=wx.Dialog(parent,-1,'Information about latest version',size=(500,400)) panel=wx.Panel(window,-1,size=(500,400)) TextView=wx.TextCtrl(panel,-1,'',size=(500,350),style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_READONLY) OkayButton=wx.Button(panel,wx.ID_OK,pos=(200,360)) wx.EVT_BUTTON(OkayButton,OkayButton.GetId(),Close) window.CenterOnParent() connection=httplib.HTTPConnection("www.mbox.wz.cz") try: connection.request("GET",'/mbox-latest-version.txt') except: error=wx.MessageDialog(parent,'Unable to connect to homepage.\nAre you connected to the Internet?','File transfer failed',wx.OK|wx.ICON_WARNING) if Show: error.ShowModal() error.Destroy() else: parent.SetStatusText('Failed connecting to homepage. Version not checked.') return data=connection.getresponse() text=str(data.read()) TextList=string.split(text,'Version:') TextList.remove('') ToView=[] for i in TextList: if not i[:5]==mBoxVersion: ToView.append('Version:'+i+'\n') Show=1 else: break if ToView==[]: ToView.append('No new versions') if not Show: parent.SetStatusText('You\'re using the latest available version.') for i in ToView: TextView.WriteText(i) connection.close() if Show or ToView!=['No new versions']: window.ShowModal() window.Destroy() else: window.Close()