Index » Empathy Jukebox : Blob f40fd1 / ripper / prefs.pas
unit prefs;
{*
 * EMPRIP - Preferences Dialog
 * Windows CD Audio extraction and MP3 Encoder
 * (C) 2003 Matthew J. Smith, Librarysmith Software
 * Based on AKRIP (http://akrip.sourceforge.net) cddb and audio extraction library
 * and the LAME projects (http://wwww.mp3dev.org) LAME_ENC.DLL.
 *
 * This program 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.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls,filectrl,registry, ComCtrls,comobj, Buttons,global,shellapi;

type
  Tpreferences = class(TForm)
    OK: TButton;
    cancel: TButton;
    uninstall: TButton;
    Help: TButton;
    PageControl1: TPageControl;
    genral: TTabSheet;
    Internet: TTabSheet;
    bitrategroup: TGroupBox;
    Label4: TLabel;
    bitrate: TComboBox;
    GroupBox1: TGroupBox;
    path: TEdit;
    browse: TButton;
    GroupBox3: TGroupBox;
    Label2: TLabel;
    Label3: TLabel;
    Label1: TLabel;
    cgi: TEdit;
    email: TEdit;
    GroupBox2: TGroupBox;
    search: TEdit;
    server: TComboBox;
    procedure OKClick(Sender: TObject);
    procedure cancelClick(Sender: TObject);
    procedure browseClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure showexplorer(URL : string);
    procedure helpClick(Sender: TObject);
    procedure uninstallClick(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

function showprefs(firstrun : boolean) : integer; export;


var
  preferences: Tpreferences;
  resp : integer;
  url : string;
implementation


{$R *.DFM}

function showprefs(firstrun : boolean) : integer; export;
begin

preferences := Tpreferences.Create(Application);


 url:='http://www.librarysmith.co.uk/empathy/navigation.php?sec=emprip';
 try
    preferences.ShowModal;
      finally
      result:=resp;
      preferences.Free;
  end;
end;
procedure Tpreferences.OKClick(Sender: TObject);
var
reg : tregistry;
begin
reg:=Tregistry.create();
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('SOFTWARE\ID Consultants\EmpRip',false);
config.pathtocd:=path.text;
if config.pathtocd='' then config.pathtocd:='C:\';
if config.pathtocd[length(config.pathtocd)]<>'\' then config.pathtocd:=config.pathtocd+'\';
case bitrate.itemindex of
0 : config.bitrate:=32;
1 : config.bitrate:=40;
2 : config.bitrate:=48;
3 : config.bitrate:=56;
4 : config.bitrate:=64;
5 : config.bitrate:=80;
6 : config.bitrate:=96;
7 : config.bitrate:=112;
8 : config.bitrate:=128;
9 : config.bitrate:=160;
10 : config.bitrate:=192;
11 : config.bitrate:=224;
12 : config.bitrate:=256;
13 : config.bitrate:=320;
end;

config.cddbserver:=server.text;
config.cddbcgi:=cgi.text;
config.email:=email.text;
config.imagesearch:=search.text;
reg.WriteString('Path',config.pathtocd);
reg.WriteInteger('Bitrate',config.bitrate);
reg.WriteString('CDDBServer',config.cddbserver);
reg.WriteString('CDDBcgi',config.cddbcgi);
reg.WriteString('email',config.email);
reg.WriteString('Inetsearch',config.imagesearch);

reg.Closekey;

resp:=0;
preferences.close;
end;

procedure Tpreferences.cancelClick(Sender: TObject);
begin
resp:=-1;
preferences.close;
end;

procedure Tpreferences.browseClick(Sender: TObject);
var
dir : string;
begin
try
dir:=path.text;
if SelectDirectory(dir,[],0)=true then begin
path.text:=dir;
end;
except
end;
end;



procedure Tpreferences.FormActivate(Sender: TObject);
begin
  path.text:=config.pathtocd;
  server.text:=config.cddbserver;
  cgi.text:=config.cddbcgi;
  email.text:=config.email;
  search.text:=config.imagesearch;
case config.bitrate of
32 : bitrate.itemindex:=0;
40 : bitrate.itemindex:=1;
48 : bitrate.itemindex:=2;
56 : bitrate.itemindex:=3;
64 : bitrate.itemindex:=4;
80 : bitrate.itemindex:=5;
96 : bitrate.itemindex:=6;
112 : bitrate.itemindex:=7;
128 : bitrate.itemindex:=8;
160 : bitrate.itemindex:=9;
192 : bitrate.itemindex:=10;
224 : bitrate.itemindex:=11;
256 : bitrate.itemindex:=12;
320 : bitrate.itemindex:=13;
end;
end;

procedure Tpreferences.showexplorer(URL : string);
begin
ShellExecute (0, nil, pchar(url), nil, nil, SW_SHOWNORMAL);
end;

procedure Tpreferences.helpClick(Sender: TObject);
begin
showexplorer(url);
end;

procedure Tpreferences.uninstallClick(Sender: TObject);
var
reg : Tregistry;
begin
if messagedlg('Uninstall Emprip. This will remove all registry entries for this program. Are you sure you want to do this? After completion the the program file will remain ('+paramstr(0)+#'), you may delete this if required.',mtConfirmation,[mbYes,MbNo],0)=mrYes then begin
reg:=Tregistry.create();
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.deletekey('SOFTWARE\ID Consultants\EmpRip\Path');
reg.deletekey('SOFTWARE\ID Consultants\EmpRip\CDDBServer');
reg.deletekey('SOFTWARE\ID Consultants\EmpRip\CDDBcgi');
reg.deletekey('SOFTWARE\ID Consultants\EmpRip\email');
reg.deletekey('SOFTWARE\ID Consultants\EmpRip\bitrate');
reg.deletekey('SOFTWARE\ID Consultants\EmpRip');
reg.Closekey;
halt(0);
end;

end;

end.