2
0
Эх сурвалжийг харах

Update TurboBird from internet
modified: TurboBird.lpr
modified: about.lfm
modified: about.lrs
modified: about.pas
modified: main.lfm
modified: main.lrs
modified: main.pas
new file: update.lfm
new file: update.lrs
new file: update.pas

motaz 12 жил өмнө
parent
commit
02f447f4f5
10 өөрчлөгдсөн 1471 нэмэгдсэн , 819 устгасан
  1. 11 4
      TurboBird.lpr
  2. 13 1
      about.lfm
  3. 5 2
      about.lrs
  4. 10 1
      about.pas
  5. 19 5
      main.lfm
  6. 808 806
      main.lrs
  7. 29 0
      main.pas
  8. 201 0
      update.lfm
  9. 51 0
      update.lrs
  10. 324 0
      update.pas

+ 11 - 4
TurboBird.lpr

@@ -22,10 +22,13 @@ uses
   NewDomain, SysTables, NewConstraint, NewEditField, Calen, Scriptdb,
   NewDomain, SysTables, NewConstraint, NewEditField, Calen, Scriptdb,
   UserPermissions, TableManage, BackupRestore, CreateUser, ChangePass,
   UserPermissions, TableManage, BackupRestore, CreateUser, ChangePass,
   PermissionManage, SQLHistory, CopyTable, dynlibs, ibase60dyn, dbInfo,
   PermissionManage, SQLHistory, CopyTable, dynlibs, ibase60dyn, dbInfo,
-  sysutils, Comparison;
+  sysutils, Comparison, Update;
 
 
 const
 const
-  Version = '0.9.10';
+  Major = 0;
+  Minor = 9;
+  Release = 10;
+
   VersionDate = '2010 - Apr 2013';
   VersionDate = '2010 - Apr 2013';
 {$IFDEF Unix}
 {$IFDEF Unix}
 {$DEFINE extdecl:=cdecl}
 {$DEFINE extdecl:=cdecl}
@@ -64,6 +67,12 @@ begin
   Application.ProcessMessages;
   Application.ProcessMessages;
   SAbout.Update;
   SAbout.Update;
   Application.CreateForm(TfmMain, fmMain);
   Application.CreateForm(TfmMain, fmMain);
+  fmMain.Version:= Format('%d.%d.%d', [Major, Minor, Release]);
+  fmMain.StatusBar1.Panels[1].Text:= 'Version: ' + fmMain.Version;
+  fmMain.VersionDate:= VersionDate;
+  fmMain.Major:= Major;
+  fmMain.Minor:= Minor;
+  fmMain.ReleaseVersion:= Release;
   Application.CreateForm(TfmCreateDB, fmCreateDB);
   Application.CreateForm(TfmCreateDB, fmCreateDB);
   Application.CreateForm(TfmReg, fmReg);
   Application.CreateForm(TfmReg, fmReg);
   Application.CreateForm(TfmNewGen, fmNewGen);
   Application.CreateForm(TfmNewGen, fmNewGen);
@@ -81,8 +90,6 @@ begin
   Application.CreateForm(TfmChangePass, fmChangePass);
   Application.CreateForm(TfmChangePass, fmChangePass);
   Application.CreateForm(TfmSQLHistory, fmSQLHistory);
   Application.CreateForm(TfmSQLHistory, fmSQLHistory);
   Application.CreateForm(TfmCopyTable, fmCopyTable);
   Application.CreateForm(TfmCopyTable, fmCopyTable);
-  fmMain.Version:= Version;
-  fmMain.VersionDate:= VersionDate;
   SAbout.Free;
   SAbout.Free;
   InitialiseIBase60;
   InitialiseIBase60;
   Application.Run;
   Application.Run;

+ 13 - 1
about.lfm

@@ -12,7 +12,7 @@ object fmAbout: TfmAbout
   Color = 15792364
   Color = 15792364
   OnClose = FormClose
   OnClose = FormClose
   Position = poScreenCenter
   Position = poScreenCenter
-  LCLVersion = '1.0.4.0'
+  LCLVersion = '1.0.8.0'
   object Shape1: TShape
   object Shape1: TShape
     Left = 9
     Left = 9
     Height = 294
     Height = 294
@@ -224,4 +224,16 @@ object fmAbout: TfmAbout
     ParentColor = False
     ParentColor = False
     ParentFont = False
     ParentFont = False
   end
   end
+  object laUpdate: TLabel
+    Cursor = crHandPoint
+    Left = 240
+    Height = 18
+    Top = 88
+    Width = 116
+    Caption = 'Check for update'
+    Font.Color = clBlack
+    ParentColor = False
+    ParentFont = False
+    OnClick = laUpdateClick
+  end
 end
 end

+ 5 - 2
about.lrs

@@ -5,7 +5,7 @@ LazarusResources.Add('TfmAbout','FORMDATA',[
   +#5'Width'#3#144#1#13'ActiveControl'#7#7'BitBtn1'#11'BorderIcons'#11#0#11'Bor'
   +#5'Width'#3#144#1#13'ActiveControl'#7#7'BitBtn1'#11'BorderIcons'#11#0#11'Bor'
   +'derStyle'#7#8'bsDialog'#7'Caption'#6#15'About TurboBird'#12'ClientHeight'#3
   +'derStyle'#7#8'bsDialog'#7'Caption'#6#15'About TurboBird'#12'ClientHeight'#3
   +'n'#1#11'ClientWidth'#3#144#1#5'Color'#4#236#248#240#0#7'OnClose'#7#9'FormCl'
   +'n'#1#11'ClientWidth'#3#144#1#5'Color'#4#236#248#240#0#7'OnClose'#7#9'FormCl'
-  +'ose'#8'Position'#7#14'poScreenCenter'#10'LCLVersion'#6#7'1.0.4.0'#0#6'TShap'
+  +'ose'#8'Position'#7#14'poScreenCenter'#10'LCLVersion'#6#7'1.0.8.0'#0#6'TShap'
   +'e'#6'Shape1'#4'Left'#2#9#6'Height'#3'&'#1#3'Top'#2#5#5'Width'#3#128#1#11'Br'
   +'e'#6'Shape1'#4'Left'#2#9#6'Height'#3'&'#1#3'Top'#2#5#5'Width'#3#128#1#11'Br'
   +'ush.Color'#7#7'clCream'#11'Brush.Style'#7#11'bsDiagCross'#9'Pen.Color'#7#12
   +'ush.Color'#7#7'clCream'#11'Brush.Style'#7#11'bsDiagCross'#9'Pen.Color'#7#12
   +'clMoneyGreen'#13'Pen.JoinStyle'#7#8'pjsMiter'#0#0#6'TLabel'#6'Label2'#4'Lef'
   +'clMoneyGreen'#13'Pen.JoinStyle'#7#8'pjsMiter'#0#0#6'TLabel'#6'Label2'#4'Lef'
@@ -157,5 +157,8 @@ LazarusResources.Add('TfmAbout','FORMDATA',[
   +' LGPL'#10'Font.Color'#4'555'#0#11'ParentColor'#8#10'ParentFont'#8#0#0#6'TLa'
   +' LGPL'#10'Font.Color'#4'555'#0#11'ParentColor'#8#10'ParentFont'#8#0#0#6'TLa'
   +'bel'#8'laTarget'#4'Left'#2#24#6'Height'#2#18#3'Top'#3#16#1#5'Width'#2#127#8
   +'bel'#8'laTarget'#4'Left'#2#24#6'Height'#2#18#3'Top'#3#16#1#5'Width'#2#127#8
   +'AutoSize'#8#7'Caption'#6#9'Target OS'#10'Font.Color'#4'555'#0#11'ParentColo'
   +'AutoSize'#8#7'Caption'#6#9'Target OS'#10'Font.Color'#4'555'#0#11'ParentColo'
-  +'r'#8#10'ParentFont'#8#0#0#0
+  +'r'#8#10'ParentFont'#8#0#0#6'TLabel'#8'laUpdate'#6'Cursor'#7#11'crHandPoint'
+  +#4'Left'#3#240#0#6'Height'#2#18#3'Top'#2'X'#5'Width'#2't'#7'Caption'#6#16'Ch'
+  +'eck for update'#10'Font.Color'#7#7'clBlack'#11'ParentColor'#8#10'ParentFont'
+  +#8#7'OnClick'#7#13'laUpdateClick'#0#0#0
 ]);
 ]);

+ 10 - 1
about.pas

@@ -48,10 +48,12 @@ type
     laWebSite: TLabel;
     laWebSite: TLabel;
     Label6: TLabel;
     Label6: TLabel;
     laVersionDate: TLabel;
     laVersionDate: TLabel;
+    laUpdate: TLabel;
     Shape1: TShape;
     Shape1: TShape;
     procedure BitBtn1Click(Sender: TObject);
     procedure BitBtn1Click(Sender: TObject);
     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     procedure Label6Click(Sender: TObject);
     procedure Label6Click(Sender: TObject);
+    procedure laUpdateClick(Sender: TObject);
     procedure laWebSiteClick(Sender: TObject);
     procedure laWebSiteClick(Sender: TObject);
   private
   private
     { private declarations }
     { private declarations }
@@ -67,7 +69,7 @@ implementation
 
 
 { TfmAbout }
 { TfmAbout }
 
 
-uses Main;
+uses Main, Update;
 
 
 procedure TfmAbout.laWebSiteClick(Sender: TObject);
 procedure TfmAbout.laWebSiteClick(Sender: TObject);
 begin
 begin
@@ -86,6 +88,13 @@ begin
   OpenURL('http://lazarus.freepascal.org');
   OpenURL('http://lazarus.freepascal.org');
 end;
 end;
 
 
+procedure TfmAbout.laUpdateClick(Sender: TObject);
+begin
+  fmUpdate:= TfmUpdate.Create(nil);
+  fmUpdate.Init(fmMain.Major, fmMain.Minor, fmMain.ReleaseVersion);
+  fmUpdate.Show;
+end;
+
 procedure TfmAbout.FormClose(Sender: TObject; var CloseAction: TCloseAction);
 procedure TfmAbout.FormClose(Sender: TObject; var CloseAction: TCloseAction);
 begin
 begin
   CloseAction:= caFree;
   CloseAction:= caFree;

+ 19 - 5
main.lfm

@@ -14,10 +14,10 @@ object fmMain: TfmMain
   OnClose = FormClose
   OnClose = FormClose
   OnCreate = FormCreate
   OnCreate = FormCreate
   Position = poScreenCenter
   Position = poScreenCenter
-  LCLVersion = '1.0.6.0'
+  LCLVersion = '1.0.8.0'
   object tvMain: TTreeView
   object tvMain: TTreeView
     Left = 0
     Left = 0
-    Height = 617
+    Height = 596
     Top = 0
     Top = 0
     Width = 360
     Width = 360
     Align = alLeft
     Align = alLeft
@@ -37,14 +37,14 @@ object fmMain: TfmMain
   end
   end
   object Splitter1: TSplitter
   object Splitter1: TSplitter
     Left = 360
     Left = 360
-    Height = 617
+    Height = 596
     Top = 0
     Top = 0
     Width = 14
     Width = 14
     Beveled = True
     Beveled = True
   end
   end
   object PageControl1: TPageControl
   object PageControl1: TPageControl
     Left = 377
     Left = 377
-    Height = 610
+    Height = 589
     Top = 3
     Top = 3
     Width = 644
     Width = 644
     ActivePage = TabSheet1
     ActivePage = TabSheet1
@@ -64,7 +64,7 @@ object fmMain: TfmMain
     object TabSheet1: TTabSheet
     object TabSheet1: TTabSheet
       BorderWidth = 1
       BorderWidth = 1
       Caption = 'Main'
       Caption = 'Main'
-      ClientHeight = 580
+      ClientHeight = 559
       ClientWidth = 640
       ClientWidth = 640
       Font.Color = clNavy
       Font.Color = clNavy
       Font.Name = 'Arial'
       Font.Name = 'Arial'
@@ -503,6 +503,20 @@ object fmMain: TfmMain
       end
       end
     end
     end
   end
   end
+  object StatusBar1: TStatusBar
+    Left = 0
+    Height = 21
+    Top = 596
+    Width = 1024
+    Panels = <    
+      item
+        Width = 250
+      end    
+      item
+        Width = 200
+      end>
+    SimplePanel = False
+  end
   object MainMenu1: TMainMenu
   object MainMenu1: TMainMenu
     left = 63
     left = 63
     top = 113
     top = 113

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 808 - 806
main.lrs


+ 29 - 0
main.pas

@@ -9,6 +9,32 @@ uses
   Controls, Graphics, Dialogs, Menus, ComCtrls, Reg, QueryWindow, Grids,
   Controls, Graphics, Dialogs, Menus, ComCtrls, Reg, QueryWindow, Grids,
   ExtCtrls, Buttons, StdCtrls, TableManage;
   ExtCtrls, Buttons, StdCtrls, TableManage;
 
 
+const
+  {$IFDEF LINUX}
+   Target = 'Linux';
+  {$ENDIF}
+
+  {$IFDEF WINDOWS}
+   Target = 'Win';
+  {$ENDIF}
+
+  {$IFDEF MAC}
+   Target = 'Mac';
+  {$ENDIF}
+
+  {$IFDEF BSD}
+   Target = 'BSD';
+  {$ENDIF}
+
+  {$ifDEF CPU32}
+   Arch = '32';
+  {$ENDIF}
+
+  {$ifDEF CPU64}
+   Arch = '64';
+  {$ENDIF}
+
+
 type
 type
 
 
   TDatabaseRec = record
   TDatabaseRec = record
@@ -102,6 +128,7 @@ type
     pmDatabase: TPopupMenu;
     pmDatabase: TPopupMenu;
     Splitter1: TSplitter;
     Splitter1: TSplitter;
     SQLQuery1: TSQLQuery;
     SQLQuery1: TSQLQuery;
+    StatusBar1: TStatusBar;
     TabSheet1: TTabSheet;
     TabSheet1: TTabSheet;
     tvMain: TTreeView;
     tvMain: TTreeView;
     procedure FormActivate(Sender: TObject);
     procedure FormActivate(Sender: TObject);
@@ -194,6 +221,7 @@ type
     RegisteredDatabases: array of TDatabaseRec;
     RegisteredDatabases: array of TDatabaseRec;
     Version: string;
     Version: string;
     VersionDate: string;
     VersionDate: string;
+    Major, Minor, ReleaseVersion: word;
     function GetServerName(DBName: string): string;
     function GetServerName(DBName: string): string;
     function RetreiveInputParamFromSP(Body: string): string;
     function RetreiveInputParamFromSP(Body: string): string;
     function LoadRegisteredDatabases: Boolean;
     function LoadRegisteredDatabases: Boolean;
@@ -250,6 +278,7 @@ begin
   Application.OnException:= @GlobalException;
   Application.OnException:= @GlobalException;
   fActivated:= False;
   fActivated:= False;
   LoadRegisteredDatabases;
   LoadRegisteredDatabases;
+  StatusBar1.Panels[0].Text:= 'TurboBird for ' + Target + '-' + Arch;
 end;
 end;
 
 
 (*****************  Add New user  ***********************)
 (*****************  Add New user  ***********************)

+ 201 - 0
update.lfm

@@ -0,0 +1,201 @@
+object fmUpdate: TfmUpdate
+  Left = 587
+  Height = 314
+  Top = 265
+  Width = 501
+  BorderStyle = bsDialog
+  Caption = 'Version update'
+  ClientHeight = 314
+  ClientWidth = 501
+  OnActivate = FormActivate
+  OnClose = FormClose
+  Position = poScreenCenter
+  LCLVersion = '1.0.8.0'
+  object Label1: TLabel
+    Left = 8
+    Height = 18
+    Top = 32
+    Width = 104
+    BidiMode = bdRightToLeft
+    Caption = 'Current version'
+    ParentBidiMode = False
+    ParentColor = False
+  end
+  object stVersion: TStaticText
+    Left = 152
+    Height = 19
+    Top = 32
+    Width = 148
+    Caption = 'stVersion'
+    Color = clWhite
+    ParentColor = False
+    TabOrder = 0
+    Transparent = False
+  end
+  object bbSearch: TBitBtn
+    Left = 8
+    Height = 30
+    Top = 72
+    Width = 75
+    Caption = 'Check'
+    OnClick = bbSearchClick
+    TabOrder = 1
+  end
+  object stNewVersion: TStaticText
+    Left = 152
+    Height = 23
+    Top = 72
+    Width = 196
+    Caption = '-'
+    Color = clWhite
+    ParentColor = False
+    TabOrder = 2
+    Transparent = False
+  end
+  object bbDownload: TBitBtn
+    Left = 8
+    Height = 30
+    Top = 112
+    Width = 148
+    Caption = 'Install Update'
+    OnClick = bbDownloadClick
+    TabOrder = 3
+    Visible = False
+  end
+  object cxProxy: TCheckBox
+    Left = 16
+    Height = 24
+    Top = 176
+    Width = 177
+    Caption = 'connect through proxy'
+    OnChange = cxProxyChange
+    ParentBidiMode = False
+    TabOrder = 4
+  end
+  object GroupBox1: TGroupBox
+    Left = 15
+    Height = 108
+    Top = 198
+    Width = 472
+    ClientHeight = 104
+    ClientWidth = 468
+    TabOrder = 5
+    Visible = False
+    object Label2: TLabel
+      Left = 6
+      Height = 18
+      Top = 11
+      Width = 85
+      Alignment = taRightJustify
+      Caption = 'Proxy server'
+      ParentColor = False
+    end
+    object edProxy: TEdit
+      Left = 103
+      Height = 27
+      Top = 8
+      Width = 112
+      TabOrder = 0
+    end
+    object Label3: TLabel
+      Left = 7
+      Height = 18
+      Top = 41
+      Width = 73
+      Alignment = taRightJustify
+      Caption = 'Proxy port'
+      ParentColor = False
+    end
+    object edPort: TEdit
+      Left = 103
+      Height = 27
+      Top = 40
+      Width = 69
+      TabOrder = 1
+      Text = '8080'
+    end
+    object Label4: TLabel
+      Left = 6
+      Height = 18
+      Top = 80
+      Width = 32
+      Alignment = taRightJustify
+      Caption = 'User'
+      ParentColor = False
+    end
+    object edUser: TEdit
+      Left = 335
+      Height = 27
+      Top = 71
+      Width = 112
+      TabOrder = 2
+    end
+    object Label5: TLabel
+      Left = 247
+      Height = 18
+      Top = 80
+      Width = 67
+      Alignment = taRightJustify
+      Caption = 'Password'
+      ParentColor = False
+    end
+    object edPassword: TEdit
+      Left = 103
+      Height = 27
+      Top = 71
+      Width = 112
+      EchoMode = emPassword
+      PasswordChar = '*'
+      TabOrder = 3
+    end
+  end
+  object stStatus: TStaticText
+    Left = 8
+    Height = 28
+    Top = 146
+    Width = 479
+    Alignment = taCenter
+    Caption = '-'
+    Color = clWhite
+    ParentColor = False
+    TabOrder = 6
+    Transparent = False
+  end
+  object laTime: TLabel
+    Left = 408
+    Height = 27
+    Top = 104
+    Width = 66
+    Caption = '00:00'
+    Color = clCream
+    Font.Color = clRed
+    Font.Height = -21
+    Font.Name = 'Courier 10 Pitch'
+    ParentColor = False
+    ParentFont = False
+    Transparent = False
+    Visible = False
+  end
+  object Process1: TProcess
+    Active = False
+    Options = []
+    Priority = ppNormal
+    StartupOptions = []
+    ShowWindow = swoNone
+    WindowColumns = 0
+    WindowHeight = 0
+    WindowLeft = 0
+    WindowRows = 0
+    WindowTop = 0
+    WindowWidth = 0
+    FillAttribute = 0
+    left = 416
+    top = 16
+  end
+  object Timer1: TTimer
+    Enabled = False
+    OnTimer = Timer1Timer
+    left = 320
+    top = 88
+  end
+end

+ 51 - 0
update.lrs

@@ -0,0 +1,51 @@
+{ This is an automatically generated lazarus resource file }
+
+LazarusResources.Add('TfmUpdate','FORMDATA',[
+  'TPF0'#9'TfmUpdate'#8'fmUpdate'#4'Left'#3'K'#2#6'Height'#3':'#1#3'Top'#3#9#1#5
+  +'Width'#3#245#1#11'BorderStyle'#7#8'bsDialog'#7'Caption'#6#14'Version update'
+  +#12'ClientHeight'#3':'#1#11'ClientWidth'#3#245#1#10'OnActivate'#7#12'FormAct'
+  +'ivate'#7'OnClose'#7#9'FormClose'#8'Position'#7#14'poScreenCenter'#10'LCLVer'
+  +'sion'#6#7'1.0.8.0'#0#6'TLabel'#6'Label1'#4'Left'#2#8#6'Height'#2#18#3'Top'#2
+  +' '#5'Width'#2'h'#8'BidiMode'#7#13'bdRightToLeft'#7'Caption'#6#15'Current ve'
+  +'rsion'#14'ParentBidiMode'#8#11'ParentColor'#8#0#0#11'TStaticText'#9'stVersi'
+  +'on'#4'Left'#3#152#0#6'Height'#2#19#3'Top'#2' '#5'Width'#3#148#0#7'Caption'#6
+  +#9'stVersion'#5'Color'#7#7'clWhite'#11'ParentColor'#8#8'TabOrder'#2#0#11'Tra'
+  +'nsparent'#8#0#0#7'TBitBtn'#8'bbSearch'#4'Left'#2#8#6'Height'#2#30#3'Top'#2
+  +'H'#5'Width'#2'K'#7'Caption'#6#5'Check'#7'OnClick'#7#13'bbSearchClick'#8'Tab'
+  +'Order'#2#1#0#0#11'TStaticText'#12'stNewVersion'#4'Left'#3#152#0#6'Height'#2
+  +#23#3'Top'#2'H'#5'Width'#3#196#0#7'Caption'#6#1'-'#5'Color'#7#7'clWhite'#11
+  +'ParentColor'#8#8'TabOrder'#2#2#11'Transparent'#8#0#0#7'TBitBtn'#10'bbDownlo'
+  +'ad'#4'Left'#2#8#6'Height'#2#30#3'Top'#2'p'#5'Width'#3#148#0#7'Caption'#6#14
+  +'Install Update'#7'OnClick'#7#15'bbDownloadClick'#8'TabOrder'#2#3#7'Visible'
+  +#8#0#0#9'TCheckBox'#7'cxProxy'#4'Left'#2#16#6'Height'#2#24#3'Top'#3#176#0#5
+  +'Width'#3#177#0#7'Caption'#6#21'connect through proxy'#8'OnChange'#7#13'cxPr'
+  +'oxyChange'#14'ParentBidiMode'#8#8'TabOrder'#2#4#0#0#9'TGroupBox'#9'GroupBox'
+  +'1'#4'Left'#2#15#6'Height'#2'l'#3'Top'#3#198#0#5'Width'#3#216#1#12'ClientHei'
+  +'ght'#2'h'#11'ClientWidth'#3#212#1#8'TabOrder'#2#5#7'Visible'#8#0#6'TLabel'#6
+  +'Label2'#4'Left'#2#6#6'Height'#2#18#3'Top'#2#11#5'Width'#2'U'#9'Alignment'#7
+  +#14'taRightJustify'#7'Caption'#6#12'Proxy server'#11'ParentColor'#8#0#0#5'TE'
+  +'dit'#7'edProxy'#4'Left'#2'g'#6'Height'#2#27#3'Top'#2#8#5'Width'#2'p'#8'TabO'
+  +'rder'#2#0#0#0#6'TLabel'#6'Label3'#4'Left'#2#7#6'Height'#2#18#3'Top'#2')'#5
+  +'Width'#2'I'#9'Alignment'#7#14'taRightJustify'#7'Caption'#6#10'Proxy port'#11
+  +'ParentColor'#8#0#0#5'TEdit'#6'edPort'#4'Left'#2'g'#6'Height'#2#27#3'Top'#2
+  +'('#5'Width'#2'E'#8'TabOrder'#2#1#4'Text'#6#4'8080'#0#0#6'TLabel'#6'Label4'#4
+  +'Left'#2#6#6'Height'#2#18#3'Top'#2'P'#5'Width'#2' '#9'Alignment'#7#14'taRigh'
+  +'tJustify'#7'Caption'#6#4'User'#11'ParentColor'#8#0#0#5'TEdit'#6'edUser'#4'L'
+  +'eft'#3'O'#1#6'Height'#2#27#3'Top'#2'G'#5'Width'#2'p'#8'TabOrder'#2#2#0#0#6
+  +'TLabel'#6'Label5'#4'Left'#3#247#0#6'Height'#2#18#3'Top'#2'P'#5'Width'#2'C'#9
+  +'Alignment'#7#14'taRightJustify'#7'Caption'#6#8'Password'#11'ParentColor'#8#0
+  +#0#5'TEdit'#10'edPassword'#4'Left'#2'g'#6'Height'#2#27#3'Top'#2'G'#5'Width'#2
+  +'p'#8'EchoMode'#7#10'emPassword'#12'PasswordChar'#6#1'*'#8'TabOrder'#2#3#0#0
+  +#0#11'TStaticText'#8'stStatus'#4'Left'#2#8#6'Height'#2#28#3'Top'#3#146#0#5'W'
+  +'idth'#3#223#1#9'Alignment'#7#8'taCenter'#7'Caption'#6#1'-'#5'Color'#7#7'clW'
+  +'hite'#11'ParentColor'#8#8'TabOrder'#2#6#11'Transparent'#8#0#0#6'TLabel'#6'l'
+  +'aTime'#4'Left'#3#152#1#6'Height'#2#27#3'Top'#2'h'#5'Width'#2'B'#7'Caption'#6
+  +#5'00:00'#5'Color'#7#7'clCream'#10'Font.Color'#7#5'clRed'#11'Font.Height'#2
+  +#235#9'Font.Name'#6#16'Courier 10 Pitch'#11'ParentColor'#8#10'ParentFont'#8
+  +#11'Transparent'#8#7'Visible'#8#0#0#8'TProcess'#8'Process1'#6'Active'#8#7'Op'
+  +'tions'#11#0#8'Priority'#7#8'ppNormal'#14'StartupOptions'#11#0#10'ShowWindow'
+  +#7#7'swoNone'#13'WindowColumns'#2#0#12'WindowHeight'#2#0#10'WindowLeft'#2#0
+  +#10'WindowRows'#2#0#9'WindowTop'#2#0#11'WindowWidth'#2#0#13'FillAttribute'#2
+  +#0#4'left'#3#160#1#3'top'#2#16#0#0#6'TTimer'#6'Timer1'#7'Enabled'#8#7'OnTime'
+  +'r'#7#11'Timer1Timer'#4'left'#3'@'#1#3'top'#2'X'#0#0#0
+]);

+ 324 - 0
update.pas

@@ -0,0 +1,324 @@
+unit Update;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
+  StdCtrls, Buttons, ExtCtrls, httpsend, Process;
+
+const
+  {$IFDEF LINUX}
+   Target = 'Linux';
+  {$ENDIF}
+
+  {$IFDEF WINDOWS}
+   Target = 'Win';
+  {$ENDIF}
+
+  {$IFDEF MAC}
+   Target = 'Mac';
+  {$ENDIF}
+
+  {$IFDEF BSD}
+   Target = 'BSD';
+  {$ENDIF}
+
+  {$ifDEF CPU32}
+   Arch = '32';
+  {$ENDIF}
+
+  {$ifDEF CPU64}
+   Arch = '64';
+  {$ENDIF}
+
+type
+
+
+  { THTTPDownload }
+
+  THTTPDownload = class(TThread)
+    private
+      fURL: string;
+      fFileName: string;
+      fSuccess: Boolean;
+      fErrorMessage: string;
+    public
+      constructor Create(URL, FileName: string);
+      procedure Execute; override;
+  end;
+
+
+  { TfmUpdate }
+  TfmUpdate = class(TForm)
+    bbSearch: TBitBtn;
+    bbDownload: TBitBtn;
+    cxProxy: TCheckBox;
+    edProxy: TEdit;
+    edPort: TEdit;
+    edUser: TEdit;
+    edPassword: TEdit;
+    GroupBox1: TGroupBox;
+    Label1: TLabel;
+    Label2: TLabel;
+    Label3: TLabel;
+    Label4: TLabel;
+    Label5: TLabel;
+    laTime: TLabel;
+    Process1: TProcess;
+    stStatus: TStaticText;
+    stVersion: TStaticText;
+    stNewVersion: TStaticText;
+    Timer1: TTimer;
+    procedure bbDownloadClick(Sender: TObject);
+    procedure bbSearchClick(Sender: TObject);
+    procedure cxProxyChange(Sender: TObject);
+    procedure FormActivate(Sender: TObject);
+    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
+    procedure Timer1Timer(Sender: TObject);
+  private
+    fNewFileName: string;
+    downloadThread: THTTPDownload;
+    { private declarations }
+    procedure DownloadTerminated(Sender: TObject);
+  public
+    Major, Minor, ReleaseVersion: Word;
+    Started: TDateTime;
+    function GetNewVersion(var AFileName, Version, ResMsg: string; var NewVersion: Boolean): Boolean;
+    function DownloadNewVersion: Boolean;
+    procedure Init(aMajor, aMinor, aReleaseVersion: Word);
+    { public declarations }
+  end;
+
+var
+  fmUpdate: TfmUpdate;
+
+implementation
+
+uses Main;
+{ TfmUpdate }
+
+
+{ THTTPDownload }
+
+constructor THTTPDownload.Create(URL, FileName: string);
+begin
+  inherited Create(True);
+  fURL:= URL;
+  fFileName:= FileName;
+end;
+
+procedure THTTPDownload.Execute;
+var
+  http: THTTPSend;
+  List: TStringList;
+begin
+  try
+    http:= THTTPSend.Create;
+
+    with fmUpdate do
+    if cxProxy.Checked then
+    begin
+      http.ProxyHost:= edProxy.Text;
+      http.ProxyPort:= edPort.Text;
+      http.ProxyUser:= edUser.Text;
+      http.ProxyPass:= edPassword.Text;
+    end;
+
+    fSuccess:= http.HTTPMethod('GET', fURL);
+    if fSuccess then
+    if http.Document.Size > 10000 then  // Actual file has been downloaded
+      http.Document.SaveToFile(ExtractFilePath(ParamStr(0)) + fFileName)
+    else
+    begin // Error HTML response
+      List:= TStringList.Create;
+      List.LoadFromStream(http.Document);
+      fSuccess:= False;
+      fErrorMessage:= List.Text;
+      List.Free;
+    end;
+
+    http.Free
+
+  except
+  on e: exception do
+  begin
+    fSuccess:= False;
+    fErrorMessage:= e.Message;
+  end;
+  end;
+
+end;
+
+procedure TfmUpdate.bbSearchClick(Sender: TObject);
+var
+  Version: string;
+  ResMsg: string;
+  ThereIsaNewVersion: Boolean;
+begin
+  if GetNewVersion(fNewFileName, Version, ResMsg, ThereisaNewVersion) then
+  begin
+    if ThereisaNewVersion then
+    begin
+      stNewVersion.Caption:= Version;
+      stNewVersion.Font.Color:= clGreen;
+      stNewVersion.Font.Style:= [fsBold];
+      bbDownload.Visible:= True;
+    end
+    else
+    begin
+      stNewVersion.Caption:= 'There is no new version';
+      stNewVersion.Font.Color:= clBlue;
+      bbDownload.Visible:= False;
+    end;
+  end
+  else
+  if pos('not found', LowerCase(ResMsg)) > 0 then
+  begin
+    stNewVersion.Caption:= 'Error while fetching new version';
+    stNewVersion.Font.Color:= clMaroon;
+    bbDownload.Visible:= False;
+  end
+  else
+    ShowMessage('Internet connection error');
+
+end;
+
+procedure TfmUpdate.bbDownloadClick(Sender: TObject);
+begin
+  stStatus.Caption:= 'Downloading.. please wait';
+  bbDownload.Enabled:= False;
+  bbSearch.Enabled:= False;
+  cxProxy.Enabled:= False;
+  laTime.Visible:= True;
+  Started:= Now;
+  Timer1.Enabled:= True;
+  DownloadNewVersion;
+end;
+
+procedure TfmUpdate.cxProxyChange(Sender: TObject);
+begin
+  GroupBox1.Visible:= cxProxy.Checked;
+end;
+
+procedure TfmUpdate.FormActivate(Sender: TObject);
+begin
+  stVersion.Caption:= Format('%d.%d.%d', [Major, Minor, ReleaseVersion]);
+end;
+
+procedure TfmUpdate.FormClose(Sender: TObject; var CloseAction: TCloseAction);
+begin
+  CloseAction:= caFree;
+end;
+
+procedure TfmUpdate.Timer1Timer(Sender: TObject);
+begin
+  laTime.Caption:= FormatDateTime('nn:ss', Now - Started);
+end;
+
+procedure TfmUpdate.DownloadTerminated(Sender: TObject);
+var
+  AppName: string;
+  ResMsg: string;
+begin
+  {$IFDEF LINUX}
+  AppName:= 'CodeUpdater';
+  {$ENDIF}
+
+  {$IFDEF MSWINDOWS}
+  AppName:= 'CodeUpdater.exe';
+  {$ENDIF}
+  bbDownload.Enabled:= True;
+  bbSearch.Enabled:= True;
+  cxProxy.Enabled:= True;
+  ResMsg:= downloadThread.fErrorMessage;
+
+  if downloadThread.fSuccess then
+  begin
+    stStatus.Caption:= 'Update completed';
+    SetCurrentDir(ExtractFileDir(ParamStr(0)));
+    Process1.CommandLine:= AppName + ' ' + fNewFileName + ' ' + ExtractFileName(ParamStr(0));
+    Process1.Execute;
+    Close;
+    fmMain.Close;
+  end
+  else
+  begin
+    if Pos('not found', LowerCase(ResMsg)) > 0 then
+      ShowMessage('There is no new version, please try again later')
+    else
+      ShowMessage('Error while getting the new version');
+    stStatus.Caption:= 'Error';
+  end;
+end;
+
+function TfmUpdate.GetNewVersion(var AFileName, Version, ResMsg: string; var NewVersion: Boolean): Boolean;
+var
+  http: THTTPSend;
+  OS: string;
+  List: TStringList;
+  ServerRelease: Word;
+  ServerMinor: Word;
+  VerStr: string;
+begin
+  List:= TStringList.Create;
+
+  OS:= Target + Arch + '-';
+  try
+    http:= THTTPSend.Create;
+
+    if cxProxy.Checked then
+    begin
+      http.ProxyHost:= edProxy.Text;
+      http.ProxyPort:= edPort.Text;
+      http.ProxyUser:= edUser.Text;
+      http.ProxyPass:= edPassword.Text;
+    end;
+
+    http.HTTPMethod('GET', 'http://code-sd.com/turbobird/releases/' + OS + IntToStr(Major));
+    // Linux64-0
+    List.LoadFromStream(http.Document);
+    VerStr:= Trim(List.Text);
+    ServerMinor:= StrToInt(Copy(VerStr, 1, Pos('.', VerStr) - 1));
+    Delete(VerStr, 1, Pos('.', VerStr));
+    ServerRelease:= StrToInt(VerStr);
+    NewVersion:= (Minor < ServerMinor) or (ServerRelease > ReleaseVersion);
+
+    Version:= IntToStr(Major) + '.' + IntToStr(ServerMinor) + '.' + IntToStr(ServerRelease);
+    AFileName:= 'TurboBird-' + OS + IntToStr(Major) + '.zip';
+    // TurboBird-Linux32-1.zip
+    Result:= True;
+    List.Free;
+    http.Free
+
+  except
+  on e: exception do
+  begin
+    Result:= False;
+    ResMsg:= e.Message;
+  end;
+  end;
+
+end;
+
+function TfmUpdate.DownloadNewVersion: Boolean;
+begin
+  downloadThread:= THTTPDownload.Create('http://code-sd.com/turbobird/releases/' + fNewFileName, fNewFileName);
+  downloadThread.OnTerminate:= @DownloadTerminated;
+  downloadThread.FreeOnTerminate:= False;
+  downloadThread.Resume;
+end;
+
+procedure TfmUpdate.Init(aMajor, aMinor, aReleaseVersion: Word);
+begin
+  Major:= aMajor;
+  Minor:= aMinor;
+  ReleaseVersion:= aReleaseVersion;
+end;
+
+initialization
+  {$I update.lrs}
+
+end.
+

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно