Source

vlocity-vinstall-gambas / Vlocity / .svn / text-base / Conf5.class.svn-base

' Gambas class file
'    This file is part of vinstall-ng

'    vinstall-ng is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 2 of the License, or
'    (at your option) any later version.

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

'    You should have received a copy of the GNU General Public License
'    along with vinstall-ng.  If not, see <http://www.gnu.org/licenses/>.

' ==================== services configuration settings =================
PRIVATE picStatus AS Picture
PUBLIC SUB Form_Open()

  MdlMain.ADVANCE_STATUS_TREE("Step9", "Step10")
  WITH ME
    .tlbanner.Text = "<h2>" & tlbanner.Text & "</h2>"
  END WITH 
  ME.Prepare_Grid()
  ME.lIST_SERVICES()
  
END
PUBLIC FUNCTION GetNext() AS String
  

  RETURN "FDone"
  
END
PUBLIC SUB StartUp()
  
  
  
END
PUBLIC SUB OnExit()
  
  MdlMain.Set_App_Status(("Saving system services configuration"))
  ME.SAVE_SERVICES_LIST()
  MdlMain.ADVANCE_STATUS_TREE("Step10", "Step11")
  
  
END


PUBLIC SUB Form_Resize()

  WITH ME
    .gvSvcList.Height = .ClientH - (.gvSvcList.Top + 12)
    .gvSvcList.Columns[2].Width = .gvSvcList.Width - (.gvSvcList.Columns[2].Left + 12)
  END WITH 

END
PUBLIC SUB Prepare_Grid()
  DIM i AS Integer
  WITH ME
    .gvSvcList.Rows.Count = 3
    .gvSvcList.columns.Count = 4
    .gvheader.rows.Count = 1
    .gvheader.Columns.Count = 3
    .gvheader[0, 2].Text = UCase(("Service"))
      FOR i = 0 TO gvheader.columns.Count - 1
        .gvheader[0, i].BackColor = Color.SelectedBackground
        .gvheader[0, i].Alignment = Align.Center
      NEXT 
    .gvSvcList.columns[0].Width = 24
    .gvheader.Columns[0].Width = 24
    .gvSvcList.Columns[1].Width = 64
    .gvheader.Columns[1].Width = 64
    .gvSvcList.Columns[3].Width = 1
  END WITH 
    
  
END


PUBLIC SUB lIST_SERVICES()
  
  DIM irow AS Integer
  DIM sService, sDesc AS String
  DIM sPic AS Picture
  DIM sLogo AS Image
  DIM sSvcPath AS String = Main.Install.TargetMount &/ "/etc/rc.d/init.d" 'ClsGlobal.sTargetPath &/ "etc" &/ "rc.d" &/ "init.d"
  
  IF Exist("images/16px-check.png") THEN picStatus = Picture.Load("images/16px-check.png")
  
  FOR EACH sService IN Dir(sSvcPath, "*", gb.File)
      SELECT CASE sService
        CASE "cron"
          sDesc = ("System task scheduler")
          sPic = picStatus
        CASE "bluetooth"
          sDesc = ("Bluetooth device manager")
          sPic = ""
        CASE "sshd"
          sDesc = ("Secure Shell remote access")
          sPic = ""
        CASE "gslaptd"
          sDesc = ("Software update notifications")
          sPic = picStatus
        CASE "wifi-radar"
          sDesc = ("Wireless network scanner")
          sPic = ""
        CASE "cups"
          sDesc = ("Printing service")
          sPic = picStatus
        CASE "fuse"
          sDesc = ("File in userspace daemon")
          sPic = ""
        CASE "inetd"
          sDesc = ("Internet Super Server")
          sPic = ""
        CASE "portmap"
          sDesc = ("RPC Port Mapper")
          sPic = ""
        CASE "samba"
          sDesc = ("Windows networking service")
          sPic = ""
        CASE "vmware"
          sDesc = ("VMWare modules")
          sPic = ""
        CASE "wicd"
          sDesc = ("Network interface manager")
          sPic = picStatus
        CASE "firewall"
          sDesc = ("Enhanced network security")
          sPic = ""
        CASE "gpm"
          sDesc = ("Mouse driver for Text Mode interface")
          sPic = ""
        CASE ELSE 
          sDesc = sService & Space(1) & ("service")
          sPic = ""
      END SELECT 
      IF Exist("images" &/ sService & ".png") THEN 
        sLogo = Image.Load("images" &/ sService & ".png")
      ELSE 
        sLogo = Image.Load("images" &/ "service.png")
      END IF
      
      DEBUG "Listing service " & sService
          
    IF sDesc THEN 
      IF (sPic) THEN ME.gvSvcList[irow, 0].Picture = sPic
        IF sLogo THEN 
           ME.gvSvcList[irow, 1].Picture = sLogo.Picture
            ME.gvSvcList[irow, 1].Alignment = Align.Center
        END IF
      ME.gvSvcList.rows[irow].Height = 64 'sLogo.Height
      ME.gvSvcList[irow, 0].Alignment = Align.Center
      ME.gvSvcList[irow, 2].Text = UCase(sService) & gb.NewLine & gb.NewLine & sDesc
      ME.gvSvcList[irow, 3].Text = sService
      INC irow
      INC gvSvcList.Rows.Count
    END IF
  NEXT 
    
    DEC gvSvcList.Rows.Count
    DEC gvSvcList.Rows.Count
    DEC gvSvcList.Rows.Count
  
  
END


PUBLIC SUB gvSvcList_Click()

  IF LAST.column > 1 THEN RETURN 
  IF gvSvcList[LAST.row, 0].Picture = picStatus THEN 
    gvSvcList[LAST.row, 0].Picture = ""
  ELSE 
    gvSvcList[LAST.row, 0].Picture = picStatus
  END IF
  
  gvSvcList.Refresh()

END
PUBLIC SUB SAVE_SERVICES_LIST()
  
  DIM irow AS Integer
  DIM sSVc AS String
  
  ' We will default to runlevel 4 (GUI Mode) for services.
  FOR irow = 0 TO ME.gvSvcList.Rows.Count - 1
      sSVc = gvSvcList[irow, 3].Text
      IF gvSvcList[irow, 0].Picture = picStatus THEN 
        PRINT " \\__ Setting up services" & gb.NewLine 
        PRINT "   \\- " & sSVc
          SHELL "chroot " & Main.Install.TargetMount & " /sbin/service -s " & sSVc & " 4" WAIT ' add this service to GUI boot mode.
      ELSE 
          SHELL "chroot " & Main.Install.TargetMount & " /sbin/service -r " & sSVc & " 4" WAIT ' Service is un-wanted... remove it
          
      END IF
          
  NEXT 
  
END