const version="GammuGUI v. 0.3.34 ",
		STARTUP = 1,
		OPERATOR = 2


  Dim myGIStartup = new wxEmptyBitmap(0,0) 
  Dim myGIOperator = new wxEmptyBitmap(0,0) 

dim Debug[6]
dim DebugTypes[6]
DebugTypes[1]="nothing"
DebugTypes[2]="text"
DebugTypes[3]="textall"
DebugTypes[4]="errors"
DebugTypes[5]="binary"

dim Reset[8]
dim ResetTypes[8]
ResetTypes[1]="PHONE"
ResetTypes[2]="DEV"
ResetTypes[3]="UIF"
ResetTypes[4]="ALL"
ResetTypes[5]="FACTORY"
ResetTypes[6]="SOFT"
ResetTypes[7]="HARD"

dim SMSDurationRadio[7]
dim SMSDurationTypes[7]
SMSDurationTypes[1]="HOUR"
SMSDurationTypes[2]="6HOURS"
SMSDurationTypes[3]="DAY"
SMSDurationTypes[4]="3DAYS"
SMSDurationTypes[5]="WEEK"
SMSDurationTypes[6]="MAX"

Global DebugLevel="nothing"
Global ResetParamSettings, ResetParamPhone

Global SMSText$=" ", SMSClass0$=" ",SMSFax$=" ",SMSMail$=" ",SMSVoice$=" "
Global SMSRead$=" ",SMSSent$=" ",SMSVoid$=" ",SMSCSet$=" ",SMSCNumber$=" "
Global SMSLen$=" ",SMSAutoLen$=" ",SMSReply$=" ",SMSDuration$=" ",SMSFrom$=" ",SMSTo$=" "
Global SMSReport$=" ",SMSUnicode$=" ",SMSInputUnicode$=" "

Global TabSelected

Global bmpStartup, bmpOperator, bmpStartupDC, bmpOperatorDC

Global Result$, LogoType, LogoFileName="", LogoFileNameOp="", LogoFilePath="",LogoFilePathOp=""

Global CLI = "[nothing]" , OSVer , Slash ,CR

Global RingtoneSource, RingtonePath

	' Create main window
frame=New wxFrame(Null,-1,version+" loading...",wxPoint(10,10),wxSize(10,10),wxSYSTEM_MENU+wxCAPTION)
frame.SetSize(640,441) 	
frame.Center

		FormatDialog = new wxFrame(frame,-1,"File format",wxPoint(10,10),wxSize(200,150))
		FormatDialog.Centre()
		FormatPanel=new wxPanel(FormatDialog,-1,wxPoint(0,0),wxSize(200,150))
		nlmRadio = new wxRadioButton(FormatPanel,-1,"NLM (Nokia Logo Manager",wxPoint(20,20))
		bmpRadio = new wxRadioButton(FormatPanel,-1,"BMP (Windows BitMaP)",wxPoint(20,40))
		ASCIIRadio = new wxRadioButton(FormatPanel,-1,"ASCII (text format)",wxPoint(20,60))
		okButton=new wxButton(FormatPanel,-1,"Save",wxPoint(10,80))
		CancelButton=new wxButton(FormatPanel,-1,"Cancel",wxPoint(100,80))
		ASCIIRadio.SetValue(1)

' create a "File" menu and append an item
mFile = wxMenu.new()
mFile.Append( wxID_EXIT, "E&xit\tAlt-X", "Quit this program")

' create an "About" menu and append an item
mHelp = wxMenu.new()
mHelp.Append( wxID_ABOUT, "&About...", "Show about dialog")
mHelp.Append( wxID_HELP, "&Help...", "Show help")

' now append the freshly created menu to the menu bar...
menuBar = wxMenuBar.new()
menuBar.Append(mFile, "&File")
menuBar.Append(mHelp, "&Help")

' ... and attach this menu bar to the frame
frame.SetMenuBar(menuBar)

' create a status bar
GammuCli = frame.CreateStatusBar(1)
'frame.CreateStatusBar(1)
frame.SetStatusText("GAMMU command line:")


' callback for the Quit menu option
function OnQuit( event )
    ' TRUE is to force the frame to close
    frame.Close(True)
	end
end function
connect( frame, wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, "OnQuit" )


Function LoadGraphicStartup( filename, type ) 
    If !myGIStartup.LoadFile( filename, type ) Then 
    wxMessageBox( "Resource file " & filename & " is missing.", "Error", wxOK + wxICON_INFORMATION, frame ) 
    End 
  End If 
  Return myGIStartup 
End Function 

Function LoadGraphicOperator( filename, type ) 
    If !myGIOperator.LoadFile( filename, type ) Then 
    wxMessageBox( "Resource file " & filename & " is missing.", "Error", wxOK + wxICON_INFORMATION, frame ) 
    End 
  End If 
  Return myGIOperator 
End Function 


// callback for the About menu option
function OnAbout( event )
    msg = "GAMMU GUI by Luca Cassioli 2003 - BETA VERSION \n"
    msg=msg+"Written in wxBasic, portable to Windows, Linux,...\n"
    msg=msg+"If you are a BASIC programmer, you can help me developing \n"
    msg=msg+"this OPENSOURCE program: write me at cassioli@iol.it.\n\n"
    msg=msg+"Versions information:\n"
    msg=msg+"First number:   number of complete version (not beta)\n"
    msg=msg+"Second number:  number of released version\n"
    msg=msg+"Third number:   number of internal version (only on my hard disk)\n"
    msg=msg+"Example: if 0.0.3 is my latest internal versions,I'll release it\n"
    msg=msg+"as v. 0.1.3 if it isn't complete yet. If it is complete (all panels\n"
    msg=msg+"present and all commands implemented), I'll release it as v. 1.1.3;\n"
    msg=msg+"then, I'll work on 0.0.4, 0.0.5,... till next release.\n"
    wxMessageBox( msg, "About GammuGUI", wxOK + wxICON_INFORMATION, frame )
end function
connect( frame, wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, "OnAbout" )

// callback for the HELP menu option
function OnHelp( event )
    msg = "This program is a Graphical User Interface (GUI) for the\n"
    msg=msg+"program GAMMU (http://marcin-wiacek.fkn.pl/english/),\n"
    msg=msg+"which allows connecting a PC to a mobile phone (several\n"
    msg=msg+"brands supported: Nokia, Alacatel, Siemens...).\n"
    msg=msg+"\nFor more info about GAMMU, please visit the above site.\n"
    msg=msg+"\n If you want to contribute to the writing of this GUI,\n"
    msg=msg+"please contact me at cassioli@iol.it.\n"
    msg=msg+"\n\nThis program is written in wxBasic (http://wxbasic.sourceforge.net/),\n"
    msg=msg+"an opensource Basic implementation of wxWindows opensource \n"
    msg=msg+"libraries. (http://www.wxwindows.org).\n"
    wxMessageBox( msg, "GammuGUI HELP", wxOK + wxICON_INFORMATION, frame )
end function
connect( frame, wxID_HELP, wxEVT_COMMAND_MENU_SELECTED, "OnHelp" )


frame.Show(True)	

	' Add a panel to main window
panel=new wxPanel(frame,-1,wxPoint(0,0),wxSize(640,276))
	' Add several tabs	
Tabs = new wxNotebook( panel, -1, wxPoint(10,10), wxSize(620,250) ) 
	' Create new panel: it will contain generic GAMMU functions
tabMain = new wxPanel(Tabs, -1)	
	' Previously created panel is associated to first tab
Tabs.AddPage( tabMain, "Main" ) 
	' other tabs...
'tabKeyboard = new wxPanel(Tabs, -1)	
'Tabs.AddPage( tabKeyboard, "Phone keyboard" )

tabConfig = new wxPanel(Tabs, -1)	
Tabs.AddPage( tabConfig, "Phone config" )

tabSMS = new wxPanel(Tabs, -1)	
Tabs.AddPage( tabSMS, "SMS" )

tabLogo = new wxPanel(Tabs, -1)
Tabs.AddPage( tabLogo, "Logo" )

tabRingtones = new wxPanel(Tabs, -1)
Tabs.AddPage( tabRingtones, "Ringtones" )

tabBackup = new wxPanel(Tabs, -1)
Tabs.AddPage( tabBackup, "Backup phone data" )

tabAdvanced = new wxPanel(Tabs, -1)
Tabs.AddPage( tabAdvanced, "Advanced" )

	' Create a window for GAMMU output, and make it not-editable
OutputText = new wxTextCtrl(frame, -1, "", wxPoint(0,276),wxSize( 633, 100 ), wxTE_MULTILINE | wxVSCROLL )
OutputText.SetEditable(False) 
test= New wxStaticText(panel,-1,"GAMMU output",wxPoint(260,262),wxSize(85,15),1,"")
OutputSaveButton = new wxButton(panel,-1,"Save output",wxPoint(350,260),wxSize(80,20))
sub SaveOutput ( event )
	Open "gammu.tmp" For Input As #2
	Open "output.txt" For Output As #1
	While Not Eof( 2 )
	WriteByte( 1, ReadByte(2))
	End While
	Close
end sub
connect(OutputSaveButton,-1,wxEVT_COMMAND_BUTTON_CLICKED,"SaveOutput")


'**********************
'**** MAIN SECTION ****
'**********************
	' Create groupbox for containg Phone specs (--identify)
BoxPhoneSpecs=New wxStaticBox(tabMain,-1,"Phone specs",wxPoint(300,10),wxSize(300,150),1,"") ' Phone specs box
	' Button to start phone identifying
button= New wxButton(tabMain,-1,"Identify",wxPoint(415,165)) ' --identify

	' Create groupbox for containg DEBUG options
BoxDebug=New wxStaticBox(tabMain,-1,"Gammu debug level",wxPoint(10,10),wxSize(110,130),1,"") 
Debug[1]= new wxRadioButton( tabMain, -1, "Nothing",wxPoint(30,30) )
Debug[2]= new wxRadioButton( tabMain, -1, "text",wxPoint(30,50) )
Debug[3]= new wxRadioButton( tabMain, -1, "textall",wxPoint(30,70) )
Debug[4]= new wxRadioButton( tabMain, -1, "errors",wxPoint(30,90) )
Debug[5]= new wxRadioButton( tabMain, -1, "binary",wxPoint(30,110) )


'test=New wxRadioBox(tabMain,-1,"Debug level",wxPoint(130,10),wxSize(130,100),2,c[1],1)
'buttonHelp= New wxButton(tabMain,-1,"Gammu commands",wxPoint(10,170))




' Dialog used for Open/Save/Save As
    Common fileDialog = new wxFileDialog( frame )

function GammuShowOutput()
OutputText.Clear
if !FileExists("gammu.tmp") then
	wxMessageBox("Error in reading gammu's output: gammu.tmp not found!","Error")
	exit function
end if
 open "gammu.tmp" for input as #1
conta=0
 While (Not Eof( 1 )) And (conta<100)
  conta=conta+1
  Line Input #1,riga
 if !Instr(UCase$(OSVer),"LINUX") then
	  OutputText.AppendText(left$(riga,len(riga)-1)+CR)
	else
	  OutputText.AppendText(riga+CR)
   end if
 End While
 Close(1)
end function

' --IDENTIFY
function Identify(event)
	OutputText.Clear
	CLI="gammu "+DebugLevel+" --identify > gammu.tmp"
	frame.SetStatusText("GAMMU command line:  "+CLI)
	Shell(CLI)
	GammuShowOutput
end function
connect (button,wxEVT_COMMAND_BUTTON_CLICKED,"Identify")

'function help(event)
'	GammuShowOutput("--help")
'end function
'connect (buttonHelp,wxEVT_COMMAND_BUTTON_CLICKED,"help")


	' Create groupbox for SETTINGS RESET options
PanelReset=New wxPanel(tabMain,-1,wxPoint(135,10),wxSize(115,130))
BoxReset=New wxStaticBox(PanelReset,-1,"Reset phone settings",wxPoint(0,0),wxSize(115,130),1,"") 
Reset[1]= new wxRadioButton( PanelReset, -1, "PHONE",wxPoint(10,20) )
Reset[2]= new wxRadioButton( PanelReset, -1, "DEV",wxPoint(10,40) )
Reset[3]= new wxRadioButton( PanelReset, -1, "UIF",wxPoint(10,60) )
Reset[4]= new wxRadioButton( PanelReset, -1, "ALL",wxPoint(10,80) )
Reset[5]= new wxRadioButton( PanelReset, -1, "FACTORY",wxPoint(10,100) )
ResetSettingsButton = new wxButton( PanelReset, -1,"GO!",wxPoint(63,40),wxSize(40,40))

	' Create groupbox for PHONE RESET options
PanelResetPhone=New wxPanel(tabMain,-1,wxPoint(135,140),wxSize(115,130))
BoxReset=New wxStaticBox(PanelResetPhone, -1,"Phone reset",wxPoint(0,0),wxSize(115,60),1,"") 
Reset[6]= new wxRadioButton( PanelResetPhone, -1, "SOFT",wxPoint(10,15) )
Reset[7]= new wxRadioButton( PanelResetPhone, -1, "HARD",wxPoint(10,35) )
ResetPhoneButton = new wxButton( PanelResetPhone, -1,"GO!",wxPoint(70,17),wxSize(40,35))

Function DebugClicked( event )
 for x = 1 to 5
 	if Debug[x].GetValue()=1 then 
 		DebugLevel=DebugTypes[x]
 	end if
 next
End Function
Connect( Debug[1],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "DebugClicked" )
Connect( Debug[2],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "DebugClicked" )
Connect( Debug[3],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "DebugClicked" )
Connect( Debug[4],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "DebugClicked" )
Connect( Debug[5],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "DebugClicked" )

Function ResetSettingsClicked( event )
 for x= 1 to 5
	if Reset[x].GetValue()=1 then
		ResetParamSettings=ResetTypes[x]
	end if
 next
End Function
Connect( Reset[1],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "ResetSettingsClicked" )
Connect( Reset[2],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "ResetSettingsClicked" )
Connect( Reset[3],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "ResetSettingsClicked" )
Connect( Reset[4],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "ResetSettingsClicked" )
Connect( Reset[5],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "ResetSettingsClicked" )

Function ResetPhoneClicked( event )
 for x= 6 to 7
 	if Reset[x].GetValue()=1 then
 		ResetParamPhone=ResetTypes[x]
 	end if
 next
End Function
Connect( Reset[6],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "ResetPhoneClicked" )
Connect( Reset[7],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "ResetPhoneClicked" )

' --RESETPHONESETTINGS
function ResetSettings (event)
 OutputText.Clear
' CLI="gammu "+DebugLevel+" --resetphonesettings "+ResetParamSettings+ " > gammu.tmp"
' frame.SetStatusText("GAMMU command line:  "+CLI)
 test=wxMessageBox("WARNING! PHONE IS GOING TO BE RESET! ARE YOU SURE?","Phone reset warning", 255 ,frame) 
 if test=4 then
    CLI="gammu "+DebugLevel+" --resetphonesettings "+ResetParamSettings+ " > gammu.tmp"	
    frame.SetStatusText(CLI)
    shell(CLI)
    GammuShowOutput
 end if
end function
Connect( ResetSettingsButton, wxEVT_COMMAND_BUTTON_CLICKED, "ResetSettings" )

' --RESET
function ResetPhone (event)
 OutputText.Clear
' frame.SetStatusText("GAMMU command line:   gammu "+DebugLevel+" --reset "+ResetParamPhone+ " > gammu.tmp")
 test=wxMessageBox("WARNING! PHONE IS GOING TO BE RESET! ARE YOU SURE?","Phone reset warning", 255 ,frame) 
 if test=4 then
    CLI="gammu "+DebugLevel+" --reset "+ResetParamPhone+ " > gammu.tmp"
    frame.SetStatusText(CLI)
    shell(CLI)
    GammuShowOutput
 end if
end function
Connect( ResetPhoneButton, wxEVT_COMMAND_BUTTON_CLICKED, "ResetPhone" )

'********************************
'**** PHONE KEYBOARD SECTION ****
'********************************
'KeyboardPanel = new wxPanel(tabKeyboard,-1,wxPoint(20,2),wxSize(120,218))
'KeyboardBox = new wxStaticBox(KeyboardPanel,-1,"        Keyboard        ",wxPoint(0,0),wxSize(120,218))
'Button1=new wxButton(KeyboardBox,-1,"1",wxPoint(10,70),wxSize(30,30))
'Button2=new wxButton(KeyboardBox,-1,"2",wxPoint(45,70),wxSize(30,30))
'Button3=new wxButton(KeyboardBox,-1,"3",wxPoint(80,70),wxSize(30,30))
'Button4=new wxButton(KeyboardBox,-1,"4",wxPoint(10,105),wxSize(30,30))
'Button5=new wxButton(KeyboardBox,-1,"5",wxPoint(45,105),wxSize(30,30))
'Button6=new wxButton(KeyboardBox,-1,"6",wxPoint(80,105),wxSize(30,30))
'Button7=new wxButton(KeyboardBox,-1,"7",wxPoint(10,140),wxSize(30,30))
'Button8=new wxButton(KeyboardBox,-1,"8",wxPoint(45,140),wxSize(30,30))
'Button9=new wxButton(KeyboardBox,-1,"9",wxPoint(80,140),wxSize(30,30))
'ButtonAst=new wxButton(KeyboardBox,-1,"*",wxPoint(10,175),wxSize(30,15))
'Button0=new wxButton(KeyboardBox,-1,"0",wxPoint(45,175),wxSize(30,30))
'ButtonDiesis=new wxButton(KeyboardBox,-1,"#",wxPoint(80,175),wxSize(30,15))
'ButtonMenu=new wxButton(KeyboardBox,-1,"Menu",wxPoint(5,17),wxSize(40,15))
'ButtonNames=new wxButton(KeyboardBox,-1,"Names",wxPoint(75,17),wxSize(40,15))
'ButtonGreen=new wxButton(KeyboardBox,-1,"Green",wxPoint(5,35),wxSize(35,15))
'ButtonRed=new wxButton(KeyboardBox,-1,"Red",wxPoint(80,35),wxSize(35,15))
'ButtonMenu=new wxButton(KeyboardBox,-1,"P",wxPoint(5,53),wxSize(15,15))
'ButtonMenu=new wxButton(KeyboardBox,-1,"W",wxPoint(20,53),wxSize(15,15))
'ButtonNames=new wxButton(KeyboardBox,-1,"On",wxPoint(75,53),wxSize(40,15))
'ButtonUp= new wxButton(KeyboardBox,-1,"Up",wxPoint(48,20),wxSize(25,15))
'ButtonDown= new wxButton(KeyboardBox,-1,"Dn",wxPoint(48,40),wxSize(25,15))
'ButtonAst=new wxButton(KeyboardBox,-1,"+",wxPoint(10,190),wxSize(30,15))
'ButtonAst=new wxButton(KeyboardBox,-1,"-",wxPoint(80,190),wxSize(30,15))
'********************************
'**** PHONE SETTINGS SECTION ****
'********************************
GetDisplayButton = new wxButton(tabConfig,-1,"Get display status",wxPoint(10,10),wxSize(120,20))
GetProfileButton = new wxButton(tabConfig,-1,"Get profile",wxPoint(10,55))
	GetProfileLabels = new wxStaticText(tabConfig,-1,"From   to",wxPoint(105,40))
	GetProfileStartText = new wxTextCtrl(tabConfig,-1,"1",wxPoint(100,55),wxSize(30,20))
	GetProfileStopText = new wxTextCtrl(tabConfig,-1,"1",wxPoint(140,55),wxSize(30,20))

SetAutonetworkLoginButton = new wxButton(tabConfig,-1,"Set auto network login",wxPoint(10,100),wxSize(150,20))
GetSecurityStatusButton = new wxButton(tabConfig,-1,"Get security status",wxPoint(10,145),wxSize(120,20))
EnterSecurityCodeButton = new wxButton(tabConfig,-1,"Eneter security code",wxPoint(10,180),wxSize(130,20))
	EnterSecurityStatusText = new wxTextCtrl(tabConfig,-1,"1",wxPoint(140,180),wxSize(40,20))
	EnterSecurityRadioPIN = new wxRadioButton(tabConfig,-1,"PIN",wxPoint(10,200))
		EnterSecurityRadioPIN.SetValue(1)
	EnterSecurityRadioPIN2 = new wxRadioButton(tabConfig,-1,"PIN2",wxPoint(60,200))
	EnterSecurityRadioPUK = new wxRadioButton(tabConfig,-1,"PUK",wxPoint(110,200))
	EnterSecurityRadioPUK2 = new wxRadioButton(tabConfig,-1,"PUK2",wxPoint(160,200))

GetFMStationButton = new wxButton(tabConfig,-1,"Get FM station",wxPoint(200,10),wxSize(100,20))
	GetFMLabels = new wxStaticText(tabConfig,-1,"From   to",wxPoint(300,2))
	GetFMStartText = new wxTextCtrl(tabConfig,-1,"1",wxPoint(300,15),wxSize(30,20))
	GetFMStopText = new wxTextCtrl(tabConfig,-1,"1",wxPoint(330,15),wxSize(30,20))
GetDateTimeButton = new wxButton(tabConfig,-1,"Get phone date/time from phone",wxPoint(200,55),wxSize(190,20))
SetDateTimeButton = new wxButton(tabConfig,-1,"Set phone to PC date/time",wxPoint(200,100),wxSize(170,20))
GetAlarmButton = new wxButton(tabConfig,-1,"Get phone alarm",wxPoint(200,145),wxSize(120,20))
SetAlarmButton = new wxButton(tabConfig,-1,"Set phone alarm to ",wxPoint(200,180),wxSize(120,20))
	SetAlarmHourLabel = new wxStaticText(tabConfig,-1,"H",wxPoint(320,186))
	SetAlarmHourInput = new wxTextCtrl(tabConfig,-1,"00",wxPoint(330,183),wxSize(30,20))
	SetAlarmMinLabel = new wxStaticText(tabConfig,-1,"M",wxPoint(363,186))
	SetAlarmMinInput = new wxTextCtrl(tabConfig,-1,"00",wxPoint(373,183),wxSize(30,20))

sub GetDisplayStatus ( event ) 
 OutputText.Clear
 CLI="gammu "+DebugLevel+" --getdisplaystatus "+ " > gammu.tmp"
 frame.SetStatusText("GAMMU command line:   "+CLI)
 shell(CLI)
 GammuShowOutput
end sub
connect (GetDisplayButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetDisplayStatus")

sub GetProfile ( event ) 
 OutputText.Clear
 CLI="gammu "+DebugLevel+" --getprofile " + GetProfileStartText.GetLineText(0)
 CLI=CLI+ " " + GetProfileStopText.GetLineText(0)+" > gammu.tmp"
 frame.SetStatusText("GAMMU command line:   "+CLI)
 shell(CLI)
 GammuShowOutput
end sub
connect (GetProfileButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetProfile")

sub SetAutonetworkLogin ( event ) 
 OutputText.Clear
 CLI="gammu "+DebugLevel+" --setautonetworklogin "+ " > gammu.tmp"
 frame.SetStatusText("GAMMU command line:   "+CLI)
 shell(CLI)
 GammuShowOutput
end sub
connect (SetAutonetworkLoginButton, wxEVT_COMMAND_BUTTON_CLICKED, "SetAutonetworkLogin")

sub GetSecurityStatus ( event ) 
 OutputText.Clear
 CLI="gammu "+DebugLevel+" --getsecuritystatus "+ " > gammu.tmp"
 frame.SetStatusText("GAMMU command line:   "+CLI)
 shell(CLI)
 GammuShowOutput
end sub
connect (GetSecurityStatusButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetSecurityStatus")

sub EnterSecurityCode ( event ) 
 OutputText.Clear
 CLI="gammu "+DebugLevel+" --entersecuritycode "
 if EnterSecurityRadioPIN.GetValue()=1 then 
	add="PIN"
 end if
 if EnterSecurityRadioPIN2.GetValue()=1 then 
	add="PIN2"
 end if
 if EnterSecurityRadioPUK.GetValue()=1 then 
	add="PUK"
 end if
 if EnterSecurityRadioPUK2.GetValue()=1 then 
	add="PUK2"
 end if
 CLI=CLI+" "+add+" "+ EnterSecurityStatusText.GetLineText(0)+" > gammu.tmp"
 frame.SetStatusText("GAMMU command line:   "+CLI)
 shell(CLI)
 GammuShowOutput
end sub
connect (EnterSecurityCodeButton, wxEVT_COMMAND_BUTTON_CLICKED, "EnterSecurityCode")

sub GetFMStation ( event ) 
 OutputText.Clear
 CLI="gammu "+DebugLevel+" --getfmstation " + GetFMStartText.GetLineText(0)
 CLI=CLI+ " " + GetFMStopText.GetLineText(0)+" > gammu.tmp"
 frame.SetStatusText("GAMMU command line:   "+CLI)
 shell(CLI)
 GammuShowOutput
end sub
connect (GetFMStationButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetFMStation")

sub GetDateTime ( event ) 
 OutputText.Clear
 CLI="gammu "+DebugLevel+" --getdatetime "+ " > gammu.tmp"
 frame.SetStatusText("GAMMU command line:   "+CLI)
 shell(CLI)
 GammuShowOutput
end sub
connect (GetDateTimeButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetDateTime")

sub SetDateTime ( event ) 
 OutputText.Clear
 CLI="gammu "+DebugLevel+" --setdatetime "+ " > gammu.tmp"
 frame.SetStatusText("GAMMU command line:   "+CLI)
 shell(CLI)
 GammuShowOutput
end sub
connect (SetDateTimeButton, wxEVT_COMMAND_BUTTON_CLICKED, "SetDateTime")

sub GetAlarm ( event ) 
 OutputText.Clear
 CLI="gammu "+DebugLevel+" --getalarm "+ " > gammu.tmp"
 frame.SetStatusText("GAMMU command line:   "+CLI)
 shell(CLI)
 GammuShowOutput
end sub
connect (GetAlarmButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetAlarm")

sub SetAlarm ( event ) 
 OutputText.Clear
 CLI="gammu "+DebugLevel+" --setalarm " + SetAlarmHourInput.GetLineText(0)
 CLI=CLI+ " " + SetAlarmMinInput.GetLineText(0)+" > gammu.tmp"
 frame.SetStatusText("GAMMU command line:   "+CLI)
 shell(CLI)
 GammuShowOutput
end sub
connect (SetAlarmButton, wxEVT_COMMAND_BUTTON_CLICKED, "SetAlarm")



'***********************************
'*******BACKUP SECTION *****
'************************************
'GetAllSMSButton = New wxButton(tabSMS,-1,"Backup sms",wxPoint(500,10))

GetAllSMSButton2 = New wxButton(tabBackup,-1,"Backup sms",wxPoint(440,10))
RestoreSMSButton = New wxButton(tabBackup,-1,"Restore sms",wxPoint(520,10))
BackupButton = New wxButton(tabBackup,-1,"Backup phone settings",wxPoint(5,10),wxSize(140,25))
RestoreSettingsButton = New wxButton(tabBackup,-1,"Restore settings",wxPoint(145,10),wxSize(120,25))
GetToDoButton = new wxButton(tabBackup,-1,"Get ToDo",wxPoint(10,80))
GetToDoStart= new wxTextCtrl(tabBackup,-1,"1",wxPoint(95,80),wxSize(20,20))
GetToDoStop= new wxTextCtrl(tabBackup,-1,"1",wxPoint(120,80),wxSize(20,20))
GetCalendarButton = new wxButton(tabBackup,-1,"Get calendar",wxPoint(10,105),wxSize(120,20))
GetCategoryButton = new wxButton(tabBackup,-1,"Get category",wxPoint(10,130))
	GetCategoryStart= new wxTextCtrl(tabBackup,-1,"1",wxPoint(95,130),wxSize(20,20))
	GetCategoryStop= new wxTextCtrl(tabBackup,-1,"1",wxPoint(120,130),wxSize(20,20))
	GetCategoryPanel = new wxPanel(tabBackup,-1,wxPoint(140,120),wxSize(150,40))
	GetCategoryTodo = new wxRadioButton(GetCategoryPanel,-1,"ToDo",wxPoint(0,10))
	GetCategoryPhonebook = new wxRadioButton(GetCategoryPanel,-1,"Phonebook",wxPoint(50,12),wxSize(120,25))
GetAllCategoriesButton = new wxButton(tabBackup,-1,"Get all categories",wxPoint(10,155),wxSize(120,25))
	GetAllCategoriesPanel = new wxPanel(tabBackup,-1,wxPoint(140,155),wxSize(150,30))
	GetAllCategoriesTodo = new wxRadioButton(GetAllCategoriesPanel,-1,"ToDo",wxPoint(0,5))
	GetAllCategoriesPhonebook = new wxRadioButton(GetAllCategoriesPanel,-1,"Phonebook",wxPoint(50,7),wxSize(120,250))
GetMemoryPanel = new wxPanel(tabBackup,-1,wxPoint(275,25),wxSize(140,90))
	GetMemoryBox = new wxStaticBox(tabBackup,-1,"Get memory",wxPoint(270,10),wxSize(155,110))
	GetMemDC= new wxRadioButton(GetMemoryPanel,-1,"DC",wxPoint(10,5))
	GetMemMC= new wxRadioButton(GetMemoryPanel,-1,"MC",wxPoint(10,25))
	GetMemRC= new wxRadioButton(GetMemoryPanel,-1,"RC",wxPoint(10,45))
	GetMemON= new wxRadioButton(GetMemoryPanel,-1,"ON",wxPoint(10,65))
	GetMemVM= new wxRadioButton(GetMemoryPanel,-1,"VM",wxPoint(50,5))
	GetMemSM= new wxRadioButton(GetMemoryPanel,-1,"SM",wxPoint(50,25))
	GetMemME= new wxRadioButton(GetMemoryPanel,-1,"ME",wxPoint(50,45))
	GetMemoryStart=new wxTextCtrl(GetMemoryPanel,-1,"1",wxPoint(80,65),wxSize(20,20))
	GetMemoryStop=new wxTextCtrl(GetMemoryPanel,-1,"1",wxPoint(110,65),wxSize(20,20))
	GetMemoryButton = new wxButton(GetMemoryPanel,-1,"GET",wxPoint(100,15),wxSize(35,30))
GetSMSFoldersButton = new wxButton(tabBackup,-1,"Get SMS folders",wxPoint(470,40),wxSize(120,25))
GetSMSButton=new wxButton(tabBackup,-1,"Get SMS",wxPoint(430,70))
	GetSMSFolderName=new wxTextCtrl(tabBackup,-1,"folder",wxPoint(510,71),wxSize(50,20))
	GetSMSFolderStart=new wxTextCtrl(tabBackup,-1,"1",wxPoint(560,71),wxSize(20,20))
	GetSMSFolderStop=new wxTextCtrl(tabBackup,-1,"1",wxPoint(585,71),wxSize(20,20))
GetAllSMSButton = new wxButton(tabBackup,-1,"Get all SMS",wxPoint(430,95),wxSize(85,25))
GetEachSMSButton = new wxButton(tabBackup,-1,"Get each SMS",wxPoint(513,95),wxSize(105,25))
GetWapBookmarkButton = new wxButton(tabBackup,-1,"Get WAP bookmark",wxPoint(440,135),wxSize(120,25))
	GetWapBookmarkStart=new wxTextCtrl(tabBackup,-1,"1",wxPoint(560,135),wxSize(20,25))
	GetWapBookmarkStop=new wxTextCtrl(tabBackup,-1,"1",wxPoint(585,135),wxSize(20,25))
GetWapSettingsButton = new wxButton(tabBackup,-1,"Get WAP settings",wxPoint(440,160),wxSize(120,25))
	GetWapSettingsStart=new wxTextCtrl(tabBackup,-1,"1",wxPoint(560,160),wxSize(20,20))
	GetWapSettingsStop=new wxTextCtrl(tabBackup,-1,"1",wxPoint(585,160),wxSize(20,20))
GetRingtonesListButton= new wxButton(tabBackup,-1,"Get ringtones list",wxPoint(280,125),wxSize(120,25))
GetRingtoneButton= new wxButton(tabBackup,-1,"Get ringtone",wxPoint(280,150),wxSize(120,25))
	GetRingtoneLocation=new wxTextCtrl(tabBackup,-1,"1",wxPoint(410,152),wxSize(20,25))
GetPhoneRingtoneButton= new wxButton(tabBackup,-1,"Get phone ringtone",wxPoint(280,175),wxSize(120,25))
	GetPhoneRingtoneLocation=new wxTextCtrl(tabBackup,-1,"1",wxPoint(410,177),wxSize(20,20))
'**** Buttons in RINGTONES SECTION
GetRingtonesListButton2= new wxButton(tabRingtones,-1,"Get ringtones list",wxPoint(10,10),wxSize(120,25))
GetRingtoneButton2= new wxButton(tabRingtones,-1,"Get ringtone",wxPoint(10,35),wxSize(120,25))
GetRingtoneLocation2=new wxTextCtrl(tabRingtones,-1,"1",wxPoint(140,35),wxSize(20,20),wxSize(120,25))
GetPhoneRingtoneButton2= new wxButton(tabRingtones,-1,"Get phone ringtone",wxPoint(10,60),wxSize(120,25))
GetPhoneRingtoneLocation2=new wxTextCtrl(tabRingtones,-1,"1",wxPoint(140,60),wxSize(20,20),wxSize(120,25))

function BackupSMS ( event )
	OutputText.Clear
      CLI="gammu "+DebugLevel+" --backupsms smsback.txt > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end function
connect( GetAllSMSButton2, wxEVT_COMMAND_BUTTON_CLICKED, "BackupSMS")

function BackupSettings ( event )
	OutputText.Clear
      CLI="gammu "+DebugLevel+" --backup settback.txt > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end function
connect( BackupButton, wxEVT_COMMAND_BUTTON_CLICKED, "BackupSettings")

function RestoreSMS ( event )
	OutputText.Clear
      CLI="GAMMU command line:   gammu "+DebugLevel+" --restore smsback.txt > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end function
connect( RestoreSMSButton, wxEVT_COMMAND_BUTTON_CLICKED, "RestoreSMS")

function RestoreSettings ( event )
	OutputText.Clear
      CLI="gammu "+DebugLevel+" --restore backup.txt > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end function
connect( RestoreSettingsButton, wxEVT_COMMAND_BUTTON_CLICKED, "RestoreSettings")

sub GetToDo ( event)
	OutputText.Clear
     CLI="gammu "+DebugLevel+" --gettodo "+ GetToDoStart.GetLineText(0)+" "+GetToDoStop.GetLineText(0)+" > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetToDoButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetToDo")

sub GetCalendar ( event )
	OutputText.Clear
     CLI="gammu "+DebugLevel+" --getcalendarnotes  > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetCalendarButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetCalendar")

sub GetCategory ( event )
	OutputText.Clear
	if GetCategoryTodo.GetValue()=1 then
		add="TODO"
	else
		add="PHONEBOOK"
	end if
     CLI="gammu "+DebugLevel+" --getcategory "+ add + " "+ GetCategoryStart.GetLineText(0)+" "+GetCategoryStop.GetLineText(0)+" > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetCategoryButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetCategory")

sub GetAllCategories ( event)
	OutputText.Clear
    if GetAllCategoriesTodo.GetValue()=1 then
		add="TODO"
	else
		add="PHONEBOOK"
	end if
     CLI="gammu "+DebugLevel+" --getallcategories "+ add+" > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetAllCategoriesButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetAllCategories")

sub GetMemory ( event)
	OutputText.Clear
    if GetMemDC.GetValue()=1 then
		add="DC"
	end if
    if GetMemMC.GetValue()=1 then
		add="MC"
	end if
    if GetMemRC.GetValue()=1 then
		add="RC"
	end if
    if GetMemON.GetValue()=1 then
		add="ON"
	end if
    if GetMemVM.GetValue()=1 then
		add="VM"
	end if
    if GetMemSM.GetValue()=1 then
		add="SM"
	end if
    if GetMemME.GetValue()=1 then
		add="ME"
	end if
      CLI="gammu "+DebugLevel+" --getmemory "+ add+" "+ GetMemoryStart.GetLineText(0)+" "+GetMemoryStop.GetLineText(0)+" > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetMemoryButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetMemory")

sub GetSMSFolders ( event )
	OutputText.Clear
     CLI="gammu "+DebugLevel+" --getsmsfolders  > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetSMSFoldersButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetSMSFolders")

sub GetSMS ( event)
	OutputText.Clear
     CLI="gammu "+DebugLevel+" --getsms "+ GetSMSFolderName.GetLineText(0)+" "+GetSMSFolderStart.GetLineText(0)+" "+GetSMSFolderStop.GetLineText(0)+" > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetSMSButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetSMS")

sub GetAllSMS ( event )
	OutputText.Clear
     CLI="gammu "+DebugLevel+" --getallsms  > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetAllSMSButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetAllSMS")

sub GetEachSMS ( event )
	OutputText.Clear
     CLI="gammu "+DebugLevel+" --geteachsms  > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetEachSMSButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetEachSMS")

sub GetWapBookmark ( event )
	OutputText.Clear
     CLI="gammu "+DebugLevel+" --getwapbookmark "+ GetWapBookmarkStart.GetLineText(0)+" "+GetWapBookmarkStop.GetLineText(0)+"  > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetWapBookmarkButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetWapBookmark")

sub GetWapSettings ( event )
	OutputText.Clear
     CLI="gammu "+DebugLevel+" --getwapsettings "+  GetWapSettingsStart.GetLineText(0)+" "+GetWapSettingsStop.GetLineText(0)+"  > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetWapSettingsButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetWapSettings")

sub GetRingtonesList ( event )
	OutputText.Clear
     CLI="gammu "+DebugLevel+" --getringtoneslist  > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetRingtonesListButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetRingtonesList")
connect( GetRingtonesListButton2, wxEVT_COMMAND_BUTTON_CLICKED, "GetRingtonesList")

sub GetRingtone ( event )
	OutputText.Clear
     CLI="gammu "+DebugLevel+" --getringtone  "+ GetRingtoneLocation.GetLineText(0) +"  > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetRingtoneButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetRingtone")
connect( GetRingtoneButton2, wxEVT_COMMAND_BUTTON_CLICKED, "GetRingtone")

sub GetPhoneRingtone ( event )
	OutputText.Clear
     CLI="gammu "+DebugLevel+" --getphoneringtone  "+ GetPhoneRingtoneLocation.GetLineText(0) +"   > gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
end sub
connect( GetPhoneRingtoneButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetPhoneRingtone")
connect( GetPhoneRingtoneButton2, wxEVT_COMMAND_BUTTON_CLICKED, "GetPhoneRingtone")



'***********************
'***** SMS SECTION *****
'***********************
'

SMSTextLabel=new wxStaticText(tabSMS,-1,"Message text",wxPoint(42,7))
SMSText=New wxTextCtrl(tabSMS,-1,"",wxPoint(10,20),wxSize(140,90),wxTE_MULTILINE | wxVSCROLL)

'SMS options panel
SMSOptionBox=New wxStaticBox(tabSMS, -1,"Special options",wxPoint(5,110),wxSize(180,110),1,"") 
SMSClass0CheckBox = new wxCheckBox(tabSMS,-1,"Class 0 (blinking)",wxPoint(10,122))
SMSVoidCheckBox = new wxCheckBox(tabSMS,-1,"Void message",wxPoint(10,138))

SMSOptionsLabel=new wxStaticText(tabSMS,-1,"On  Off",wxPoint(130,152),wxSize(45,20))

SMSFaxCheckBoxPanel=new wxPanel(tabSMS,-1,wxPoint(10,165),wxSize(170,18))
SMSFaxCheckBox = new wxCheckBox(SMSFaxCheckBoxPanel,-1,"Fax indicator",wxPoint(0,0))
SMSFaxRadioOn=new wxRadioButton(SMSFaxCheckBoxPanel,-1,"",wxPoint(125,0))
SMSFaxRadioOff=new wxRadioButton(SMSFaxCheckBoxPanel,-1,"",wxPoint(145,00))

SMSMailCheckBoxPanel=new wxPanel(tabSMS,-1,wxPoint(10,183),wxSize(170,18))
SMSMailCheckBox = new wxCheckBox(SMSMailCheckBoxPanel,-1,"Mail indicator",wxPoint(0,0))
SMSMailRadioOn=new wxRadioButton(SMSMailCheckBoxPanel,-1,"",wxPoint(125,0))
SMSMailRadioOff=new wxRadioButton(SMSMailCheckBoxPanel,-1,"",wxPoint(145,0))

SMSVoiceCheckBoxPanel=new wxPanel(tabSMS,-1,wxPoint(10,201),wxSize(170,18))
SMSVoiceCheckBox = new wxCheckBox(SMSVoiceCheckBoxPanel,-1,"Voice indicator",wxPoint(0,0))
SMSVoiceRadioOn=new wxRadioButton(SMSVoiceCheckBoxPanel,-1,"",wxPoint(125,0))
SMSVoiceRadioOff=new wxRadioButton(SMSVoiceCheckBoxPanel,-1,"",wxPoint(145,0))

'SMS flags panel
SMSFlagBox=New wxStaticBox(tabSMS, -1,"Saved message flags",wxPoint(190,110),wxSize(120,110),1,"") 
SMSReadCheckBoxPanel=new wxPanel(tabSMS,-1,wxPoint(195,145),wxSize(100,20))
SMSReadCheckBox = new wxCheckBox(SMSReadCheckBoxPanel,-1,"Read",wxPoint(0,0))
SMSReadRadioOn   = new wxRadioButton(SMSReadCheckBoxPanel,-1,"",wxPoint(65,0))
SMSReadRadioOff   = new wxRadioButton(SMSReadCheckBoxPanel,-1,"",wxPoint(85,0))
SMSSentCheckBoxPanel=new wxPanel(tabSMS,-1,wxPoint(195,175),wxSize(100,20))
SMSSentCheckBox = new wxCheckBox(SMSSentCheckBoxPanel,-1,"Sent",wxPoint(0,0))
'SMSSentRadioOn=new wxRadioButton(SMSSentCheckBoxPanel,-1,"",wxPoint(65,0))
'SMSSentRadioOff=new wxRadioButton(SMSSentCheckBoxPanel,-1,"",wxPoint(85,0))



'Sender number
SMSFromLabel=new wxStaticText(tabSMS,-1,"From:",wxPoint(200,5))
SMSFromText=new wxTextCtrl(tabSMS,-1,"",wxPoint(195,20),wxSize(100,20), wxTE_MULTILINE )
SMSFromText.SetEditable(False)
SMSFromText.Enable(False)
'Destination number
SMSDestLabel=new wxStaticText(tabSMS,-1,"To:",wxPoint(320,5))
SMSRecipientText=new wxTextCtrl(tabSMS,-1,"",wxPoint(315,20),wxSize(100,20))

'SMS Center parameters
SMSCPanel=new wxPanel(tabSMS,-1,wxPoint(190,50),wxSize(260,60))
SMSCStaticBox=new wxStaticBox(SMSCPanel,-1,"SMSC settings",wxPoint(0,0),wxSize(260,60))
SMSCSetRadio=new wxRadioButton(SMSCPanel,-1,"SMSC n. from set: ",wxPoint(5,15))
SMSCSetText=new wxTextCtrl(SMSCPanel,-1,"",wxPoint(150,15),wxSize(80,20))
SMSCNumberRadio=new wxRadioButton(SMSCPanel,-1,"SMSC number: ",wxPoint(5,35))
SMSCNumberText=new wxTextCtrl(SMSCPanel,-1,"",wxPoint(150,35),wxSize(80,20))

'SMS other parameters
SMSOtherStaticBox=new wxStaticBox(tabSMS,-1,"Other settings",wxPoint(320,110),wxSize(130,110))
SMSLenRadio=new wxRadioButton(tabSMS,-1,"len: ",wxPoint(330,125))
SMSLenText=new wxTextCtrl(tabSMS,-1,"",wxPoint(400,125),wxSize(40,20))
SMSAutoLenRadio=new wxRadioButton(tabSMS,-1,"autolen: ",wxPoint(330,145))
SMSAutoLenText=new wxTextCtrl(tabSMS,-1,"",wxPoint(400,145),wxSize(40,20))
SMSReplyCheckBox = new wxCheckBox(tabSMS,-1,"Reply",wxPoint(340,170))
SMSReportCheckBox = new wxCheckBox(tabSMS,-1,"Delivery report",wxPoint(340,190))

'SMS duration panel
SMSDurationPanel=new wxPanel(tabSMS,-1,wxPoint(460,5),wxSize(130,80))
SMSDurationStaticBox=new wxStaticBox(SMSDurationPanel,-1,"SMS duration",wxPoint(0,0),wxSize(130,80))
SMSDurationRadio[1]=new wxRadioButton(SMSDurationPanel,-1,"1 hour",wxPoint(5,15))
SMSDurationRadio[2]=new wxRadioButton(SMSDurationPanel,-1,"6 hour",wxPoint(65,15))
SMSDurationRadio[3]=new wxRadioButton(SMSDurationPanel,-1,"1 day",wxPoint(5,35))
SMSDurationRadio[4]=new wxRadioButton(SMSDurationPanel,-1,"3 days",wxPoint(65,35))
SMSDurationRadio[5]=new wxRadioButton(SMSDurationPanel,-1,"1 week",wxPoint(5,55))
SMSDurationRadio[6]=new wxRadioButton(SMSDurationPanel,-1,"max",wxPoint(65,55))

SMSOther2StaticBox=new wxStaticBox(tabSMS,-1,"",wxPoint(460,85),wxSize(130,80))
SMSUnicodeCheckBox = new wxCheckBox(tabSMS,-1,"Unicode",wxPoint(470,100))
SMSInputUnicodeCheckBox = new wxCheckBox(tabSMS,-1,"Input unicode",wxPoint(470,135))

SMSSendButton = New wxButton(tabSMS,-1,"Send",wxPoint(470,170))
SMSSaveButton = New wxButton(tabSMS,-1,"Save to phone",wxPoint(465,200))
SMSOtherButton=New wxButton(tabSMS,-1,"Other...",wxPoint(555,170),wxSize(50,50))


function SendSMS ( event )
	SMSText.SaveFile("sms.txt")  ' Save message text to a file
	OutputText.Clear
	SMSFrom=SMSFromText.GetLineText(0)
	SMSTo=SMSRecipientText.GetLineText(0)
    if len(SMSLenText.GetLineText(0))>0  and (SMSLenRadio.GetValue()=1)then
		SMSLen$=" -len "+SMSLenText.GetLineText(0)
	else
		SMSLen$=" "
	end if
	if len(SMSAutoLenText.GetLineText(0))>0 and (SMSAutoLenRadio.GetValue()=1) then
		SMSAutoLen$=" -autolen "+SMSAutoLenText.GetLineText(0)
    else
		SMSAutoLen$=" "
	end if
	if len(SMSCSetText.GetLineText(0))>0  and (SMSCSetRadio.GetValue()=1) then 
		SMSCSet$=" -smscset "+SMSCSetText.GetLineText(0)
	else
		SMSCSet$=" "
	end if
	if len(SMSCNumberText.GetLineText(0))>0  and (SMSCNumberRadio.GetValue()=1) then
		SMSCNumber$="-smscnumber "+SMSCNumberText.GetLineText(0)
	else
		SMSCNumber$=" "
	end if
	param="gammu "+DebugLevel+" --sendsms TEXT "+SMSTo
	if len(SMSFrom)>0 then 
		param=param+" -sender "+SMSFrom
	end if
	if SMSUnicodeCheckBox.GetValue()=1 then
		SMSUnicode$=" -unicode "
	else
		SMSUnicode$=" "
	end if
	if SMSInputUnicodeCheckBox.GetValue()=1 then
		SMSInputUnicode$=" -inputunicode "
	else
		SMSInputUnicode$=" "
	end if
	param=param+SMSReply$+SMSClass0$+SMSFax$+SMSVoice$+SMSMail$+SMSReport$+SMSVoid$
	param=param+SMSUnicode$+SMSInputUnicode$
	param=param+SMSLen$+SMSAutoLen$+SMSCSet$+SMSCNumber$
	param=param+SMSUnicode$+SMSInputUnicode$
	param=param+" -validity "+SMSDuration$
	param=param+" < sms.txt"  ' Read SMS text from file
	wxMessageBox( param, "DEBUG", wxOK + wxICON_INFORMATION, frame )
	frame.SetStatusText("GAMMU command line:   "+param)
	shell(param+" > gammu.tmp")
	GammuShowOutput
end function
Connect( SMSSendButton,wxEVT_COMMAND_BUTTON_CLICKED, "SendSMS" )

Function SaveSMS ( event )
	SMSText.SaveFile("sms.txt")  ' Save message text to a file
	OutputText.Clear
	SMSFrom=SMSFromText.GetLineText(0)
	SMSTo=SMSRecipientText.GetLineText(0)
	param="gammu "+DebugLevel+" --sendsms TEXT "+SMSTo
	if len(SMSFrom)>0 then 
		param=param+" -sender "+SMSFrom
	end if
	param=param+SMSReply$+SMSClass0$+SMSFax$+SMSVoice$+SMSMail$+SMSReport$+SMSVoid$
	param=param+SMSUnicode$+SMSInputUnicode$+SMSRead$+SMSSent$
	'param=param+" -validity "+SMSDuration$
	param=param+" < sms.txt"  ' Read SMS text from file
	wxMessageBox( param, "DEBUG", wxOK + wxICON_INFORMATION, frame )
	frame.SetStatusText("GAMMU command line:   "+param)
	shell(param+" > gammu.tmp")
	GammuShowOutput
end function
Connect( SMSSaveButton,wxEVT_COMMAND_BUTTON_CLICKED, "SaveSMS" )

Function OtherSMSCommands ( event )
msg="Commands to be implemented:\n"
msg=msg+"gammu --deletesms folder start [stop]\n"
msg=msg+"gammu --deleteallsms folder\n"
msg=msg+"gammu --smsd FILES configfile\n"
 wxMessageBox( msg, "Developing...", wxOK + wxICON_INFORMATION, frame )
end function
Connect( SMSOtherButton,wxEVT_COMMAND_BUTTON_CLICKED, "OtherSMSCommands" )

Function SMSDurationClicked( event )
 for x= 1 to 6
 	if SMSDurationRadio[x].GetValue()=1 then
 		SMSDuration$=SMSDurationTypes[x]
 	end if
 next
End Function
Connect( SMSDurationRadio[1],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSDurationClicked" )
Connect( SMSDurationRadio[2],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSDurationClicked" )
Connect( SMSDurationRadio[3],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSDurationClicked" )
Connect( SMSDurationRadio[4],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSDurationClicked" )
Connect( SMSDurationRadio[5],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSDurationClicked" )
Connect( SMSDurationRadio[6],wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSDurationClicked" )

Function SMSClass0Checked ( event )
	if SMSClass0CheckBox.GetValue()=1 then
		SMSClass0$=" -flash "
	else
		SMSClass0$=" "
	end if
end function
connect (SMSClass0CheckBox,wxEVT_COMMAND_CHECKBOX_CLICKED, "SMSClass0Checked")

Function SMSFaxChecked ( event )
	if SMSFaxCheckBox.GetValue()=1 and SMSFaxRadioOn.GetValue()=1 then
			SMSFax$=" -enablefax "
	end if
	if SMSFaxCheckBox.GetValue()=1 and SMSFaxRadioOff.GetValue()=1 then
			SMSFax$=" -disablefax "
	end if
    if SMSFaxCheckBox.GetValue()=0 then
		SMSFax$="  "
	end if
end function
connect (SMSFaxCheckBox,wxEVT_COMMAND_CHECKBOX_CLICKED, "SMSFaxChecked")

Function SMSFaxRadio ( event )
	SMSFaxCheckBox.SetValue(1)
	SMSFaxChecked(-1)
end function
connect (SMSFaxRadioOn,wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSFaxRadio")
connect (SMSFaxRadioOff,wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSFaxRadio")

Function SMSMailChecked ( event )
	if SMSMailCheckBox.GetValue()=1 and SMSMailRadioOn.GetValue()=1 then
			SMSMail$=" -enableemail "
	end if
	if SMSMailCheckBox.GetValue()=1 and SMSMailRadioOff.GetValue()=1 then
			SMSMail$=" -disableemail "
	end if
    if SMSMailCheckBox.GetValue()=0 then
		SMSMail$="  "
	end if
end function
connect (SMSMailCheckBox,wxEVT_COMMAND_CHECKBOX_CLICKED, "SMSMailChecked")

Function SMSMailRadio ( event )
	SMSMailCheckBox.SetValue(1)
	SMSMailChecked(-1)
end function
connect (SMSMailRadioOn,wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSMailRadio")
connect (SMSMailRadioOff,wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSMailRadio")


Function SMSVoiceChecked ( event )
	if SMSVoiceCheckBox.GetValue()=1 and SMSVoiceRadioOn.GetValue()=1 then
			SMSVoice$=" -enablevoice "
	end if
	if SMSVoiceCheckBox.GetValue()=1 and SMSVoiceRadioOff.GetValue()=1 then
			SMSVoice$=" -disablevoice "
	end if
    if SMSVoiceCheckBox.GetValue()=0 then
		SMSVoice$="  "
	end if
end function
connect (SMSVoiceCheckBox,wxEVT_COMMAND_CHECKBOX_CLICKED, "SMSVoiceChecked")

Function SMSVoiceRadio ( event )
	SMSVoiceCheckBox.SetValue(1)
	SMSVoiceChecked(-1)
end function
connect (SMSVoiceRadioOn,wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSVoiceRadio")
connect (SMSVoiceRadioOff,wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSVoiceRadio")


Function SMSReadChecked ( event )
	if SMSReadCheckBox.GetValue()=1 and SMSReadRadioOn.GetValue()=1 then
			SMSRead$=" -read "
	end if
	if SMSReadCheckBox.GetValue()=1 and SMSReadRadioOff.GetValue()=1 then
			SMSRead$=" -unread "
	end if
    if SMSReadCheckBox.GetValue()=0 then
		SMSRead$="  "
	end if
end function
connect (SMSReadCheckBox,wxEVT_COMMAND_CHECKBOX_CLICKED, "SMSReadChecked")

Function SMSReadRadio ( event )
	SMSReadCheckBox.SetValue(1)
	SMSReadChecked(-1)
end function
connect (SMSReadRadioOn,wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSReadRadio")
connect (SMSReadRadioOff,wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSReadRadio")

Function SMSSentChecked ( event )
	if SMSSentCheckBox.GetValue()=1  then ' and SMSSentRadioOn.GetValue()=1
			SMSSent$=" -sent "
	end if
	if SMSSentCheckBox.GetValue()=1 then ' and SMSSentRadioOff.GetValue()=1
			SMSSent$=" -unsent "
	end if
    if SMSSentCheckBox.GetValue()=0 then
		SMSSent$="  "
	end if

end function
connect (SMSSentCheckBox,wxEVT_COMMAND_CHECKBOX_CLICKED, "SMSSentChecked")

Function SMSSentRadio ( event )
	SMSSentCheckBox.SetValue(1)
	SMSSentChecked(-1)
end function
'connect (SMSSentRadioOn,wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSSentRadio")
'connect (SMSSentRadioOff,wxEVT_COMMAND_RADIOBUTTON_SELECTED, "SMSSentRadio")


Function SMSReportChecked ( event )
	if SMSReportCheckBox.GetValue()=1 then
		SMSReport$=" -report "
	else
		SMSReport$=" -report "
	end if
end function
connect (SMSReportCheckBox,wxEVT_COMMAND_CHECKBOX_CLICKED, "SMSReportChecked")

Function SMSReplyChecked ( event )
	if SMSReplyCheckBox.GetValue()=1 then
		SMSReply$=" -reply "
	else
		SMSReply$=" -reply "
	end if
end function
connect (SMSReplyCheckBox,wxEVT_COMMAND_CHECKBOX_CLICKED, "SMSReplyChecked")

'***************************************
' ***** ADVANCED SECTION *****
'***************************************
NetMonitorButton = new wxButton(tabAdvanced, -1,"Start test",wxPoint(10,10),wxSize(60,40))
NetMonitorTestText =New wxTextCtrl(tabAdvanced,-1,"",wxPoint(80,20),wxSize(40,20))
NetMonitorResultText = New wxTextCtrl(tabAdvanced,-1,"",wxPoint(130,20),wxSize(80,80))
DEBUG= new wxStaticText(tabAdvanced,-1,"Results visualization not yet implemented, \nplease send me GAMMU output.",wxPoint(10,100))
NokiaBox=new wxStaticBox(tabAdvanced,-1,"Nokia",wxPoint(300,5),wxSize(300,210))
NokiaGetOperatorButton=new wxButton(tabAdvanced,-1,"Get operator name",wxPoint(310,20),wxSize(120,20))
NokiaSetOperatorButton=new wxButton(tabAdvanced,-1,"Set operator name",wxPoint(310,45),wxSize(120,20))
	NokiaSetOperatorName=new wxTextCtrl(tabAdvanced,-1,"",wxPoint(440,45),wxSize(60,20))
NokiaNetMonitor36Button=new wxButton(tabAdvanced,-1,"Netmonitor36",wxPoint(310,70),wxSize(120,20))
NokiaSetVibraLevelButton=new wxButton(tabAdvanced,-1,"Set vibra level",wxPoint(310,95),wxSize(120,20))
	NokiaSetVibraLevelValue=new wxTextCtrl(tabAdvanced,-1,"",wxPoint(440,95),wxSize(30,20))
NokiaGetVoiceRecordButton=new wxButton(tabAdvanced,-1,"Get voice record",wxPoint(310,120),wxSize(120,20))
	NokiaGetVoiceRecordName=new wxTextCtrl(tabAdvanced,-1,"",wxPoint(440,120),wxSize(60,20))
NokiaGetFileSystemButton=new wxButton(tabAdvanced,-1,"Get filesystem",wxPoint(310,145),wxSize(120,20))
NokiaTestsButton=new wxButton(tabAdvanced,-1,"Tests",wxPoint(310,170),wxSize(120,20))
NokiaSetPhoneMenusButton=new wxButton(tabAdvanced,-1,"Set phone menus",wxPoint(310,195),wxSize(120,20))
'SiemensNetMonitorButton=new wxButton(tabAdvanced,-1,"Get operator name",wxPoint(10,205),wxSize(120,20))
SendCommandLineButton=new wxButton(tabAdvanced,-1,"Send command line",wxPoint(70,160),wxSize(120,20))
	SendCommandLineText=new wxTextCtrl(tabAdvanced,-1,"",wxPoint(10,185),wxSize(280,20))

Function NetMonitor ( event )
	OutputText.Clear
    test=wxMessageBox("WARNING! This commandline will be executed:\n"+"gammu "+DebugLevel+" --nokianetmonitor "+NetMonitorTestText.GetLineText(0)+" > gammu.tmp\n"+" ARE YOU SURE?","Nokia netmonitor warning", 255 ,frame) 
	if test=16 then
		exit function
	end if
	CLI="gammu "+DebugLevel+" --nokianetmonitor "+NetMonitorTestText.GetLineText(0)+" > gammu.tmp"
	frame.SetStatusText(CLI)
	shell(CLI)
	 GammuShowOutput
end function
connect (NetMonitorButton,wxEVT_COMMAND_BUTTON_CLICKED, "NetMonitor")

Function NokiaGetOperator ( event )
	kill("gammu.tmp")
	OutputText.Clear
	CLI="gammu "+DebugLevel+" --nokiagetoperator  > gammu.tmp"
	frame.SetStatusText(CLI)
	shell(CLI)
	GammuShowOutput
end function
connect (NokiaGetOperatorButton,wxEVT_COMMAND_BUTTON_CLICKED, "NokiaGetOperator")

Function NokiaSetOperator ( event )
	kill("gammu.tmp")
	OutputText.Clear
	CLI="gammu "+DebugLevel+" --nokiasetoperator "+NokiaSetOperatorName.GetLineText(0)+" > gammu.tmp"
	frame.SetStatusText(CLI)
	shell(CLI)
	GammuShowOutput
end function
connect (NokiaSetOperatorButton,wxEVT_COMMAND_BUTTON_CLICKED, "NokiaSetOperator")

Function NokiaNetMonitor36 ( event )
	kill("gammu.tmp")
	OutputText.Clear
	CLI="gammu "+DebugLevel+" --nokianetmonitor36  > gammu.tmp"
	frame.SetStatusText(CLI)
	shell(CLI)
	GammuShowOutput
end function
connect (NokiaNetMonitor36Button, wxEVT_COMMAND_BUTTON_CLICKED, "NokiaNetMonitor36")

Function NokiaSetVibraLevel ( event )
	kill("gammu.tmp")
	OutputText.Clear
	CLI="gammu "+DebugLevel+" --nokiasetvibralevel "+NokiaSetVibraLevelValue.GetLineText(0)+" > gammu.tmp"
	frame.SetStatusText(CLI)
	shell(CLI)
	GammuShowOutput
end function
connect (NokiaSetVibraLevelButton, wxEVT_COMMAND_BUTTON_CLICKED, "NokiaSetVibraLevel")

Function GetVoiceRecord ( event )
	kill("gammu.tmp")
	OutputText.Clear
	CLI="gammu "+DebugLevel+" --nokiagetvoicerecord "+NokiaGetVoiceRecordName.GetLineText(0)+" > gammu.tmp"
	frame.SetStatusText(CLI)
	shell(CLI)
	GammuShowOutput
end function
connect (NokiaGetVoiceRecordButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetVoiceRecord")

Function GetFileSystem ( event )
	kill("gammu.tmp")
	OutputText.Clear
	CLI="gammu "+DebugLevel+" --nokiagetfilesystem  > gammu.tmp"
	frame.SetStatusText(CLI)
	shell(CLI)
	GammuShowOutput
end function
connect (NokiaGetFileSystemButton, wxEVT_COMMAND_BUTTON_CLICKED, "GetFileSystem")

Function NokiaTests ( event )
	kill("gammu.tmp")
	OutputText.Clear
	CLI="gammu "+DebugLevel+" --nokiatests  > gammu.tmp"
	frame.SetStatusText(CLI)
	shell(CLI)
	GammuShowOutput
end function
connect (NokiaTestsButton, wxEVT_COMMAND_BUTTON_CLICKED, "NokiaTests")

Function NokiaSetPhoneMenus ( event )
	kill("gammu.tmp")
	OutputText.Clear
	CLI="gammu "+DebugLevel+" --nokiasetphonemenus  > gammu.tmp"
	frame.SetStatusText(CLI)
	shell(CLI)
	GammuShowOutput
end function
connect (NokiaSetPhoneMenusButton, wxEVT_COMMAND_BUTTON_CLICKED, "NokiaSetPhoneMenus")

Function SendCommandLine ( event )
	kill("gammu.tmp")
	OutputText.Clear
	CLI="gammu "+DebugLevel+" --nokiasetphonemenus "+SendCommandLineText.GetLineText(0)+" > gammu.tmp"
	frame.SetStatusText(CLI)
	shell(CLI)
	GammuShowOutput
end function
connect (SendCommandLineButton, wxEVT_COMMAND_BUTTON_CLICKED, "SendCommandLine")





'****************************
'******* LOGO SECTION *******
'****************************

LogoStartupBox = new wxStaticBox(tabLogo,-1,"Startup logo",wxPoint(10,5),wxSize(225,116))
LogoStartupGetButton = new wxButton(tabLogo,-1,"Get",wxPoint(20,20),wxSize(40,20))
LogoStartupLoadButton=new wxButton(tabLogo,-1,"Load from file",wxPoint(15,95),wxSize(90,20))
LogoStartupSaveButton=new wxButton(tabLogo,-1,"Save/convert to file",wxPoint(110,95),wxSize(120,20))
LogoStartupSetButton = new wxButton(tabLogo,-1,"Set",wxPoint(180,20),wxSize(40,20))
LogoStartupNameLabel = new wxStaticText(tabLogo,-1,"File name: ",wxPoint(40,75))
LogoStartupNameText = new wxStaticText(tabLogo,-1,"xxxx",wxPoint(110,75))
StartupButton = new wxBitmapButton(tabLogo, -1, myGIStartup, wxPoint(72,19), wxSize(100,57)) 

LogoOperatorBox = new wxStaticBox(tabLogo,-1,"Operator logo",wxPoint(10,122),wxSize(225,100))
LogoOperatorGetButton = new wxButton(tabLogo,-1,"Get",wxPoint(20,137),wxSize(40,20))
LogoOperatorLoadButton=new wxButton(tabLogo,-1,"Load from file",wxPoint(15,192),wxSize(90,20))
LogoOperatorSaveButton=new wxButton(tabLogo,-1,"Save/convert to file",wxPoint(110,192),wxSize(120,20))
LogoOperatorSetButton = new wxButton(tabLogo,-1,"Set",wxPoint(180,137),wxSize(40,20))
LogoOperatorNameLabel = new wxStaticText(tabLogo,-1,"File name: ",wxPoint(40,162))
LogoOperatorNameText = new wxStaticText(tabLogo,-1,"xxxx",wxPoint(110,162))
LogoOperatorNetCodeLabel = new wxStaticText(tabLogo,-1,"NetCode",wxPoint(105,175),wxSize(60,20))
LogoOperatorNetCode = new wxTextCtrl(tabLogo,-1,"000 00",wxPoint(155,174),wxSize(60,20))
OperatorButton = new wxBitmapButton(tabLogo, -1, myGIOperator, wxPoint(76,137), wxSize(90,25)) 

LogoCallerGetButton = new wxButton(tabLogo,-1,"Get",wxPoint(330,20),wxSize(40,20))
LogoCallerSetButton = new wxButton(tabLogo,-1,"Set",wxPoint(490,20),wxSize(40,20))
PictureGetButton = new wxButton(tabLogo,-1,"Get",wxPoint(330,120),wxSize(40,20))
PictureSetButton = new wxButton(tabLogo,-1,"Set",wxPoint(490,120),wxSize(40,20))

sub StartupGetClick ( event )
	    kill("logos.bmp")
        results$=""
        '' Download logo from phone
        param$=" --getbitmap STARTUP logos.bmp "
		CLI="gammu "+DebugLevel+param$+" >gammu.tmp"
		frame.SetStatusText("GAMMU command line:   "+CLI)
		shell(CLI)
		GammuShowOutput
        '' If download is successful, GAMMU.TMP SHOULD BE (but it isn't!!!) empty
	if FileExists("gammu.tmp") then
		open "gammu.tmp" for input as #2
		if Lof(2)>1000 then 
			wxMessageBox( "Logo downloaded and saved to LOGOS.BMP", "Logo download", wxOK + wxICON_INFORMATION, frame )
		else
			wxMessageBox( "Logo downloading FAILED!", "Logo download", wxOK + wxERROR_INFORMATION, frame )
			close #2
			exit sub
		end if
		close #2
	end if
	OpenLogoStartup("logos.bmp") 'Display logo only if PREVIEW enabled
	LogoFileName="logos.bmp"
end sub
connect (LogoStartupGetButton,-1,wxEVT_COMMAND_BUTTON_CLICKED,"StartupGetClick")

sub OperatorGetClick ( event )
		kill("logoop.bmp")
        results$=""
        '' Download logo from phone
        param$=" --getbitmap OPERATOR logoop.bmp "
		CLI="gammu "+DebugLevel+param$+" >gammu.tmp"
		frame.SetStatusText("GAMMU command line:   "+CLI)
		shell(CLI)
		GammuShowOutput
        '' If download is successful, GAMMU.TMP SHOULD BE (but it isn't!!!) empty
	if FileExists("gammu.tmp") then
		open "gammu.tmp" for input as #2
		if Lof(2)>1000 then 
			wxMessageBox( "Logo downloaded and saved to LOGOOP.BMP", "Logo download", wxOK + wxICON_INFORMATION, frame )
			close #2
		else
			wxMessageBox( "Logo downloading FAILED!", "Logo download", wxOK + wxERROR_INFORMATION, frame )
			close #2
			exit sub
		end if
		close #2
	end if
	OpenLogoOperator("logoop.bmp") 'Display logo only if PREVIEW enabled
	LogoFileNameOp="logoop.bmp"
end sub
connect (LogoOperatorGetButton,-1,wxEVT_COMMAND_BUTTON_CLICKED,"OperatorGetClick")


sub StartupSetClick ( event )  
'test if logo is in memory (loaded or DOWNloaded)  
if len(LogoFileName)=0 then 
	wxMessageBox("No logo!", "Logo upload", wxOK + wxICON_INFORMATION, frame )
	exit sub
end if
' Upload logo to phone.
	kill("gammu.tmp")
	param$=" --setbitmap STARTUP "+LogoFilePath+LogoFileName
	CLI="gammu "+DebugLevel+param$+" >gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
' When uploading NLM file, if upload was successfull GAMMU.TMP is empty.
if FileExists("gammu.tmp") then
	open "gammu.tmp" for input as #1
	if lof(1)=0 then
		wxMessageBox( "Logo uploaded.", "Logo upload", wxOK + wxICON_INFORMATION, frame )
    else
		wxMessageBox( "Logo NOT uploaded.", "Logo upload", wxOK + wxICON_INFORMATION, frame )
		close #1
		exit sub
    end if
end if
close #1
end sub
connect (LogoStartupSetButton,-1,wxEVT_COMMAND_BUTTON_CLICKED,"StartupSetClick")

sub OperatorSetClick ( event ) 
'test if logo is in memory (loaded or DOWNloaded)   
if len(LogoFileNameOp)=0 then 
	wxMessageBox("No logo!", "Logo upload", wxOK + wxICON_INFORMATION, frame )
	exit sub
end if
' Upload logo to phone.
	kill("gammu.tmp")
	param$=" --setbitmap OPERATOR "+LogoFilePath+LogoFileNameOp+" "+LogoOperatorNetCode.GetLineText(0)
	CLI="gammu "+DebugLevel+param$+" >gammu.tmp"
	frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput
' When uploading NLM file, if upload was successfull GAMMU.TMP is empty.
if FileExists("gammu.tmp") then
	open "gammu.tmp" for input as #1
	if lof(1)=0 then
		wxMessageBox( "Logo uploaded.", "Logo upload", wxOK + wxICON_INFORMATION, frame )
		close #1
    else
		wxMessageBox( "Logo NOT uploaded.", "Logo upload", wxOK + wxICON_INFORMATION, frame )
		close #1
		exit sub
    end if
end if
end sub
connect (LogoOperatorSetButton,-1,wxEVT_COMMAND_BUTTON_CLICKED,"OperatorSetClick")

SUB OpenLogoStartup (LogoFile)
StartupButton.SetBitmapLabel(LoadGraphicStartup(LogoFile,wxBITMAP_TYPE_BMP))
StartupButton.Refresh(True)
end sub

function onFileOpenStartup( event ) 'Open and display startup logo
    fileDialog.SetMessage("Open File")
	fileDialog.SetWildcard("*.txt;*.bmp;*.nlm")
    fileDialog.SetStyle( wxOPEN )
    If fileDialog.ShowModal() = wxID_OK Then
		kill("logos.bmp")
		LogoFileName=fileDialog.GetFilename()
		LogoFilePath=fileDialog.GetDirectory()+Slash
		'Always convert logo to Bmp format
			shell("gammu "+DebugLevel+" --copybitmap "+LogoFilePath+LogoFileName+" logos.bmp >gammu.tmp")
			GammuShowOutput()
     	LogoStartupNameText.SetLabel(LogoFileName) ' Show logo filename
'		if !Instr(UCase$(OSVer),"LINUX") then 
			OpenLogoStartup("logos.bmp") 'Display logo only if PREVIEW enabled
'		end if
		kill("logos.bmp")
    End If
End function
Connect( LogoStartupLoadButton, -1, wxEVT_COMMAND_BUTTON_CLICKED, "onFileOpenStartup" )

SUB OpenLogoOperator (Logo)
OperatorButton.SetBitmapLabel(LoadGraphicOperator(Logo,wxBITMAP_TYPE_BMP))
OperatorButton.Refresh(True)
end sub

function onFileOpenOperator( event )
    fileDialog.SetMessage("Open File")
	fileDialog.SetWildcard("*.txt;*.bmp;*.nlm") 'Show only supported formats
    fileDialog.SetStyle( wxOPEN )
    If fileDialog.ShowModal() = wxID_OK Then
		kill("logoop.bmp")
        LogoFileNameOp = fileDialog.GetFilename()
		LogoFilePathOp= fileDialog.GetDirectory()+Slash
		'Always convert logo to BMP format
			shell("gammu "+DebugLevel+" --copybitmap "+LogoFilePathOp+LogoFileNameOp+" logoop.bmp >gammu.tmp")
			GammuShowOutput()
	LogoOperatorNameText.SetLabel(LogoFileNameOp)
'	if len(LogoFileNameOp)>0 and !Instr(UCase$(OSVer),"LINUX") then
		OpenLogoOperator("logoop.bmp")
		kill("logoop.bmp")
'	end if
    End If
End function
Connect( LogoOperatorLoadButton, -1, wxEVT_COMMAND_BUTTON_CLICKED, "onFileOpenOperator" )

sub OkClicked ( event )
	FormatDialog.Show(False) 'Turn off dialog window
	fileDialog.SetMessage("Save File As") 'Show "Save" dialog window
	fileDialog.SetFilename( "" )
	fileDialog.SetStyle( wxSAVE )
	fileDialog.SetWildcard("*.*")
	If fileDialog.ShowModal() = wxID_OK Then
		fileName = fileDialog.GetPath()  'Store selected filename
	End If
'Select extension of destination file
	if nlmRadio.GetValue()=1 then
		exten=".nlm"
	end if
	if bmpRadio.GetValue()=1 then
		exten=".bmp"
	end if
	if ASCIIRadio.GetValue()=1 then
		exten=".txt"
	end if
'Add extension if not already present
	if right$(fileName,4)<>exten then
		fileName=fileName+exten 'Destination file
	end if

'Use GAMMU to convert logo to desired format
if LogoType=OPERATOR then
	add="OPERATOR"
	CLI="gammu "+DebugLevel+" --copybitmap "+LogoFilePathOp+LogoFileNameOp+" "+fileName+" "+add
else
	add="STARTUP"
	CLI="gammu "+DebugLevel+" --copybitmap "+LogoFilePath+LogoFileName+" "+fileName+" "+add
end if
    frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput()
end sub
Connect( okButton, -1, wxEVT_COMMAND_BUTTON_CLICKED, "OkClicked" )


sub CancelClicked ( event )
	FormatDialog.Show(False)
end sub
Connect( CancelButton, -1, wxEVT_COMMAND_BUTTON_CLICKED, "CancelClicked" )

sub ShowSaveDialogStartup ( event )
	LogoType=STARTUP
	FormatDialog.Show(True)
end sub
Connect( LogoStartupSaveButton, -1, wxEVT_COMMAND_BUTTON_CLICKED, "ShowSaveDialogStartup" )

sub ShowSaveDialogOperator ( event )
'When "Save" button is clicked, the "Format dialog" is shown, and
'control passes to "OkClicked" sub, which saves the previously loaded (global variable "LogoFileName") logo
	LogoType=OPERATOR
	FormatDialog.Show(True)
end sub
Connect( LogoOperatorSaveButton, -1, wxEVT_COMMAND_BUTTON_CLICKED, "ShowSaveDialogOperator" )


'***************************************
'***** RINGTONES SECTION *****
'***************************************
RingtoneConvertFrame = new wxFrame(frame,-1,"File format",wxPoint(10,10),wxSize(200,150))
RingtoneFormatPanel=new wxPanel(RingtoneConvertFrame,-1,wxPoint(0,0),wxSize(200,150))
RTTLRadio = new wxRadioButton(RingtoneFormatPanel,-1,"RTTL",wxPoint(70,20))
BinaryRadio = new wxRadioButton(RingtoneFormatPanel,-1,"BInary",wxPoint(70,40))
okButtonRingtone=new wxButton(RingtoneFormatPanel,-1,"Save",wxPoint(10,80))
CancelButtonRingtone=new wxButton(RingtoneFormatPanel,-1,"Cancel",wxPoint(100,80))
RTTLRadio.SetValue(1)
RingtoneConvertFrame.Center()

LoadRingtoneButton= new wxButton(tabRingtones,-1,"Load ringtone",wxPoint(10,100),wxSize(110,20))
SetRingtoneButton= new wxButton(tabRingtones,-1,"Upload to phone",wxPoint(120,100),wxSize(120,20))
SetRingtoneMemoryLabel=new wxStaticText(tabRingtones,-1,"In memory:",wxPoint(35,130))
SetRingtoneMemory=new wxStaticText(tabRingtones,-1,"xxxxxx",wxPoint(35,150))
SetRingtoneName=new wxTextCtrl(tabRingtones,-1,"",wxPoint(120,140),wxSize(80,20))
SetRingtoneNameLabel=new wxStaticText(tabRingtones,-1,"Name (on phone):",wxPoint(120,125))
SetRingtoneLocation=new wxTextCtrl(tabRingtones,-1,"",wxPoint(120,170),wxSize(20,20))
SetRingtoneLocationLabel=new wxStaticText(tabRingtones,-1,"Location",wxPoint(150,170))
SetRingtoneScale=new wxTextCtrl(tabRingtones,-1,"",wxPoint(120,200),wxSize(20,20))
SetRingtoneScaleLabel=new wxStaticText(tabRingtones,-1,"Scale",wxPoint(150,200))
RingtoneConvertButton=new wxButton(tabRingtones,-1,"Convert ringtone",wxPoint(200,10),wxSize(120,20))
RingtoneComposerButton=new wxButton(tabRingtones,-1,"Nokia Composer",wxPoint(200,35),wxSize(120,20))

Sub onLoadRingtone( event ) 
    fileDialog.SetMessage("Select ringtone to be uploaded to phone")
	fileDialog.SetWildcard("*.txt")
    fileDialog.SetStyle( wxOPEN )
	fileDialog.SetFilename("")
    If fileDialog.ShowModal() = wxID_OK Then
		RingtoneSource=fileDialog.GetFilename()
		RingtonePath=fileDialog.GetDirectory()+Slash
		SetRingtoneName.SetLabel(RingtoneSource)
		SetRingtoneMemory.SetLabel(RingtoneSource)
    End If
End sub
Connect( LoadRingtoneButton, -1, wxEVT_COMMAND_BUTTON_CLICKED, "onLoadRingtone" )

Sub onSetRingtone( event ) 
	kill("gammu.tmp")
	if len(SetRingtoneLocation.GetLineText(0))>0 then
		location=" -location "+SetRingtoneLocation.GetLineText(0)
	else
		location=" "
	end if
	if len(SetRingtoneScale.GetLineText(0))>0 then
		scale=" -scale "+SetRingtoneScale.GetLineText(0)
	else
		scale=" "
	end if
	if len(SetRingtoneName.GetLineText(0))>0 then
		name=" -name "+SetRingtoneName.GetLineText(0)
	else
		name=" "
	end if
	CLI="gammu "+DebugLevel+" --setringtone "+RingtoneSource+" "+location+" "+scale+" "+name+" >gammu.tmp"
    frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput()
End sub
Connect( SetRingtoneButton, -1, wxEVT_COMMAND_BUTTON_CLICKED, "onSetRingtone" )


Sub onRingtoneConvert( event ) 
    fileDialog.SetMessage("Select ringtone to be converted")
	fileDialog.SetWildcard("*.txt")
    fileDialog.SetStyle( wxOPEN )
	fileDialog.SetFilename("")
    If fileDialog.ShowModal() = wxID_OK Then
		RingtoneSource=fileDialog.GetFilename()
		RingtonePath=fileDialog.GetDirectory()+Slash
		SetRingtoneName.SetLabel(RingtoneSource)
		SetRingtoneMemory.SetLabel(RingtoneSource)
		RingtoneConvertFrame.Show(True)
    End If
End sub
Connect( RingtoneConvertButton, -1, wxEVT_COMMAND_BUTTON_CLICKED, "onRingtoneConvert" )

sub okClickedRingtone ( event )
	RingtoneConvertFrame.Show(False) 'Turn off dialog window
	fileDialog.SetMessage("Save File As") 'Show "Save" dialog window
	fileDialog.SetFilename( "" )
	fileDialog.SetStyle( wxSAVE )
	fileDialog.SetWildcard("")
	If fileDialog.ShowModal() != wxID_OK Then
	  exit sub
	end if
		fileName = fileDialog.GetPath()  'Store selected filename
'Select extension of destination file
	if RTTLRadio.GetValue()=1 then
		exten=".rtt"
		add="RTTL"
	else
		exten=".bin"
		add="BINARY"
	end if
'Add extension if not already present
	if right$(fileName,4)<>exten then
		fileName=fileName+exten 'Destination file
	end if
'Use GAMMU to convert logo to desired format
	kill("gammu.tmp")
	CLI="gammu "+DebugLevel+" --copyringtone "+RingtoneSource+" "+fileName+" "+add+" >gammu.tmp"
    frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput()
end sub
Connect( okButtonRingtone, -1, wxEVT_COMMAND_BUTTON_CLICKED, "okClickedRingtone" )


sub CancelClickedRingtone ( event )
	RingtoneConvertFrame.Show(False)
end sub
Connect( CancelButtonRingtone, -1, wxEVT_COMMAND_BUTTON_CLICKED, "CancelClickedRingtone" )

Sub onRingtoneComposer( event ) 
    fileDialog.SetMessage("Select ringtone to be displayed in Nokia Composer format")
	fileDialog.SetWildcard("*.txt")
    fileDialog.SetStyle( wxOPEN )
	fileDialog.SetFilename("")
    If fileDialog.ShowModal() = wxID_OK Then
		RingtoneSource=fileDialog.GetFilename()
		SetRingtoneName.SetLabel(RingtoneSource)
		SetRingtoneMemory.SetLabel(RingtoneSource)
	kill("gammu.tmp")
	CLI="gammu "+DebugLevel+" --nokiacomposer "+RingtoneSource+" >gammu.tmp"
    frame.SetStatusText("GAMMU command line:   "+CLI)
	shell(CLI)
	GammuShowOutput()
    End If
End sub
Connect( RingtoneComposerButton, -1, wxEVT_COMMAND_BUTTON_CLICKED, "onRingtoneComposer" )



'*************************
' PROGRAM BODY
'*************************
'Write gammu's version into titlebar - give error if gammu is not found
kill("gammu.tmp")
shell("gammu --version > gammu.tmp")
if FileExists("gammu.tmp") then
	open "gammu.tmp" for input as #1
	if lof(1)=0 then
		wxMessageBox( "Error: GAMMU executable must be into\n GammuGUI folder or in your PATH!", "GAMMU not found!", wxOK + wxICON_INFORMATION, frame )
	    end
	end if		
	Line Input #1,riga
	close #1
    OSVer=wxGetOsDescription()
	if Instr(UCase$(OSVer),"LINUX") then
		Slash="/"
		CR=chr$(10)
	else
		Slash="\\"
		CR=chr$(13)+chr$(10)
	end if
	frame.SetTitle(version+"running on "+OSVer+" "+riga)
else 
		wxMessageBox( "Error: GAMMU executable must be into\n GammuGUI folder or in your PATH!", "GAMMU not found!", wxOK + wxICON_INFORMATION, frame )
	end
end if


'Initialize radio buttons
for x=1 to 5
  a=Debug[x].SetValue(0)
next
a=Debug[1].SetValue(1)
DebugLevel="nothing"

for x=1 to 7
  a=Reset[x].SetValue(0)
next
a=Reset[1].SetValue(1)
a=Reset[6].SetValue(1)
ResetParamSettings="PHONE"
ResetParamPhone="SOFT"

for x=1 to 6
  a=SMSDurationRadio[x].SetValue(0)
next
a=SMSDurationRadio[6].SetValue(1)
SMSDuration$="MAX"

a=SMSLenRadio.SetValue(1)
a=SMSLenText.SetValue(160)

a=SMSCSetRadio.SetValue(1)
a=SMSCSetText.SetValue(1)

a=GetCategoryTodo.SetValue(1)

a=GetAllCategoriesTodo.SetValue(1)

a=GetMemDC.SetValue(1)

a=RTTLRadio.SetValue(1)

frame.Show(True)

'Show gammu's last command line in a box, if status bar is clicked
sub OnClickStatus ( event )
if len(CLI)<2 then 
	CLI="[nothing]"
end if
wxMessageBox( "Last GAMMU command line:\n\n"+CLI, "Gammu command line", wxOK + wxICON_INFORMATION, frame )
end
end sub
connect( GammuCli, wxEVT_LEFT_UP, "OnClickStatus" )
connect( GammuCli, wxEVT_RIGHT_UP, "OnClickStatus" )

