mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-14 08:39:31 +02:00
Merge pull request #8 from tryphon/replace-getenv-by-rdconf
Replace getenv by rdconf functions We really should retire RDTempFile() altogether, as it is arguably broken. Merged in origin master. Thanks!
This commit is contained in:
commit
f54385c881
1
lib/rd.h
1
lib/rd.h
@ -354,7 +354,6 @@
|
||||
* Ripper Settings
|
||||
*/
|
||||
#define RIPPER_BAR_INTERVAL 500
|
||||
#define RIPPER_TEMP_DIR "/tmp"
|
||||
#define RIPPER_TEMP_WAV "rdlibrary_rip.wav"
|
||||
#define RIPPER_TEMP_PEAK "rdlibrary_rip.dat"
|
||||
#define RIPPER_CDDB_USER "rdlibrary"
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <rd.h>
|
||||
#include <rdaudioconvert.h>
|
||||
#include <rdlibrary_conf.h>
|
||||
#include <rdconf.h>
|
||||
|
||||
#define STAGE2_XFER_SIZE 2048
|
||||
#define STAGE2_BUFFER_SIZE 49152
|
||||
@ -152,10 +153,7 @@ RDAudioConvert::ErrorCode RDAudioConvert::convert()
|
||||
//
|
||||
// Generate Temporary Filenames
|
||||
//
|
||||
strcpy(tmpdir,"/tmp");
|
||||
if(getenv("TEMP")!=NULL) {
|
||||
strncpy(tmpdir,getenv("TEMP"),PATH_MAX-20);
|
||||
}
|
||||
strcpy(tmpdir,RDTempDir());
|
||||
strcat(tmpdir,"/rdaudioconvertXXXXXX");
|
||||
if(mkdtemp(tmpdir)==NULL) {
|
||||
return RDAudioConvert::ErrorInternal;
|
||||
|
@ -905,14 +905,29 @@ QString RDCartDialog::GetSearchFilter(const QString &filter,
|
||||
return search;
|
||||
}
|
||||
|
||||
QString RDCartDialog::StateFile() {
|
||||
bool home_found = false;
|
||||
QString home = RDGetHomeDir(&home_found);
|
||||
if (home_found) {
|
||||
return QString().sprintf("%s/.rdcartdialog",(const char *)home);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void RDCartDialog::LoadState()
|
||||
{
|
||||
if(getenv("HOME")==NULL) {
|
||||
QString state_file = StateFile();
|
||||
if (state_file == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
RDProfile *p=new RDProfile();
|
||||
p->setSource(QString().sprintf("%s/.rdcartdialog",getenv("HOME")));
|
||||
p->setSource(state_file);
|
||||
|
||||
bool value_read = false;
|
||||
cart_limit_box->setChecked(p->boolValue("RDCartDialog", "LimitSearch", true, &value_read));
|
||||
|
||||
delete p;
|
||||
}
|
||||
|
||||
@ -921,11 +936,12 @@ void RDCartDialog::SaveState()
|
||||
{
|
||||
FILE *f=NULL;
|
||||
|
||||
if(getenv("HOME")==NULL) {
|
||||
QString state_file = StateFile();
|
||||
if (state_file == NULL) {
|
||||
return;
|
||||
}
|
||||
if((f=fopen(QString().sprintf("%s/.rdcartdialog",getenv("HOME")),"w"))==
|
||||
NULL) {
|
||||
|
||||
if((f=fopen(state_file,"w"))==NULL) {
|
||||
return;
|
||||
}
|
||||
fprintf(f,"[RDCartDialog]\n");
|
||||
|
@ -84,6 +84,7 @@ class RDCartDialog : public QDialog
|
||||
void BuildGroupList();
|
||||
QString GetSearchFilter(const QString &filter,const QString &group,
|
||||
const QString &schedcode);
|
||||
QString StateFile();
|
||||
void LoadState();
|
||||
void SaveState();
|
||||
int *cart_cartnum;
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include <rdadd_cart.h>
|
||||
#include <rdprofile.h>
|
||||
#include <rddb.h>
|
||||
#include <rdconf.h>
|
||||
|
||||
|
||||
//
|
||||
// Icons
|
||||
@ -641,14 +643,29 @@ void RDCutDialog::BuildGroupList()
|
||||
}
|
||||
}
|
||||
|
||||
QString RDCutDialog::StateFile() {
|
||||
bool home_found = false;
|
||||
QString home = RDGetHomeDir(&home_found);
|
||||
if (home_found) {
|
||||
return QString().sprintf("%s/.rdcartdialog",(const char *)home);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void RDCutDialog::LoadState()
|
||||
{
|
||||
if(getenv("HOME")==NULL) {
|
||||
QString state_file = StateFile();
|
||||
if (state_file == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
RDProfile *p=new RDProfile();
|
||||
p->setSource(QString().sprintf("%s/.rdcartdialog",getenv("HOME")));
|
||||
p->setSource(state_file);
|
||||
|
||||
bool value_read = false;
|
||||
cart_limit_box->setChecked(p->boolValue("RDCartDialog", "LimitSearch", true, &value_read));
|
||||
|
||||
delete p;
|
||||
}
|
||||
|
||||
@ -657,11 +674,12 @@ void RDCutDialog::SaveState()
|
||||
{
|
||||
FILE *f=NULL;
|
||||
|
||||
if(getenv("HOME")==NULL) {
|
||||
QString state_file = StateFile();
|
||||
if (state_file == NULL) {
|
||||
return;
|
||||
}
|
||||
if((f=fopen(QString().sprintf("%s/.rdcartdialog",getenv("HOME")),"w"))==
|
||||
NULL) {
|
||||
|
||||
if((f=fopen(state_file,"w"))==NULL) {
|
||||
return;
|
||||
}
|
||||
fprintf(f,"[RDCartDialog]\n");
|
||||
|
@ -74,6 +74,7 @@ class RDCutDialog : public QDialog
|
||||
void RefreshCuts();
|
||||
void SelectCut(QString cutname);
|
||||
void BuildGroupList();
|
||||
QString StateFile();
|
||||
void LoadState();
|
||||
void SaveState();
|
||||
RDListView *cut_cart_list;
|
||||
|
@ -71,12 +71,7 @@ RDFormPost::RDFormPost(RDFormPost::Encoding encoding,unsigned maxsize,
|
||||
//
|
||||
// Initialize Temp Directory Path
|
||||
//
|
||||
if(getenv("TMPDIR")!=NULL) {
|
||||
strcpy(tempdir,getenv("TMPDIR"));
|
||||
}
|
||||
else {
|
||||
strcpy(tempdir,"/tmp");
|
||||
}
|
||||
strcpy(tempdir,RDTempDir());
|
||||
strcat(tempdir,"/rivendellXXXXXX");
|
||||
post_tempdir=mkdtemp(tempdir);
|
||||
if(post_tempdir.isNull()) {
|
||||
|
@ -28,13 +28,17 @@
|
||||
#include <rdprofile.h>
|
||||
|
||||
#include <rdmonitor_config.h>
|
||||
#include <rdconf.h>
|
||||
|
||||
RDMonitorConfig::RDMonitorConfig()
|
||||
{
|
||||
clear();
|
||||
mon_filename="/.rdmonitorrc";
|
||||
if(getenv("HOME")!=NULL) {
|
||||
mon_filename=QString(getenv("HOME"))+mon_filename;
|
||||
|
||||
bool home_found = false;
|
||||
QString home = RDGetHomeDir(&home_found);
|
||||
if (home_found) {
|
||||
mon_filename=home+mon_filename;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ bool RDTextFile(const QString &data)
|
||||
proc->launch("");
|
||||
delete proc;
|
||||
#else
|
||||
strcpy(tmpfile,"/tmp/rdreportXXXXXX");
|
||||
strcpy(tmpfile,RDTempDir()+"/rdreportXXXXXX");
|
||||
int fd=mkstemp(tmpfile);
|
||||
if(fd<0) {
|
||||
QMessageBox::warning(NULL,"File Error","Unable to create temporary file");
|
||||
|
@ -783,13 +783,7 @@ bool RDParsePost(std::map<QString,QString> *vars)
|
||||
//
|
||||
// Initialize Temp Directory Path
|
||||
//
|
||||
if(getenv("TMPDIR")!=NULL) {
|
||||
tempdir=getenv("TMPDIR");
|
||||
}
|
||||
else {
|
||||
tempdir="/tmp";
|
||||
}
|
||||
tempdir+="/rivendellXXXXXX";
|
||||
tempdir = RDTempDir() + "/rivendellXXXXXX";
|
||||
|
||||
//
|
||||
// Get message part separator
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "rdconfig.h"
|
||||
#include <createdb.h>
|
||||
#include <globals.h>
|
||||
#include <rdconf.h>
|
||||
|
||||
//
|
||||
// NOTE TO MAINTAINERS:
|
||||
@ -2729,11 +2730,10 @@ int UpdateDb(int ver)
|
||||
//
|
||||
if(!admin_skip_backup) {
|
||||
if(admin_backup_filename.isEmpty()) {
|
||||
if(getenv("HOME")==NULL) {
|
||||
admin_backup_filename="/tmp";
|
||||
}
|
||||
else {
|
||||
admin_backup_filename=getenv("HOME");
|
||||
bool home_found = false;
|
||||
admin_backup_filename = RDGetHomeDir(&home_found);
|
||||
if (!home_found) {
|
||||
admin_backup_filename = RDTempDir();
|
||||
}
|
||||
admin_backup_filename+=
|
||||
QString().sprintf("/rdbackup-%s-%d.sql.gz",
|
||||
|
@ -2513,15 +2513,24 @@ int MainWidget::GetConnection(QString station,unsigned chan)
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString MainWidget::GeometryFile() {
|
||||
bool home_found = false;
|
||||
QString home = RDGetHomeDir(&home_found);
|
||||
if (home_found) {
|
||||
return home + "/" + RDCATCH_GEOMETRY_FILE;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::LoadGeometry()
|
||||
{
|
||||
if(getenv("HOME")==NULL) {
|
||||
QString geometry_file = GeometryFile();
|
||||
if(geometry_file==NULL) {
|
||||
return;
|
||||
}
|
||||
RDProfile *profile=new RDProfile();
|
||||
profile->
|
||||
setSource(QString().sprintf("%s/%s",getenv("HOME"),RDCATCH_GEOMETRY_FILE));
|
||||
profile->setSource(geometry_file);
|
||||
resize(profile->intValue("RDCatch","Width",sizeHint().width()),
|
||||
profile->intValue("RDCatch","Height",sizeHint().height()));
|
||||
|
||||
@ -2531,12 +2540,11 @@ void MainWidget::LoadGeometry()
|
||||
|
||||
void MainWidget::SaveGeometry()
|
||||
{
|
||||
if(getenv("HOME")==NULL) {
|
||||
QString geometry_file = GeometryFile();
|
||||
if(geometry_file==NULL) {
|
||||
return;
|
||||
}
|
||||
FILE *file=fopen((const char *)QString().
|
||||
sprintf("%s/%s",getenv("HOME"),RDCATCH_GEOMETRY_FILE),
|
||||
"w");
|
||||
FILE *file=fopen(geometry_file,"w");
|
||||
if(file==NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -126,6 +126,7 @@ class MainWidget : public QWidget
|
||||
RDListViewItem *GetItem(int id);
|
||||
int GetMonitor(int serial,int chan);
|
||||
int GetConnection(QString station,unsigned chan=0);
|
||||
QString GeometryFile();
|
||||
void LoadGeometry();
|
||||
void SaveGeometry();
|
||||
std::vector<CatchMonitor *> catch_monitor;
|
||||
|
@ -84,7 +84,7 @@ CdRipper::CdRipper(QString cutname,RDCddbRecord *rec,RDLibraryConf *conf,
|
||||
// Create Temporary Directory
|
||||
//
|
||||
char path[PATH_MAX];
|
||||
strncpy(path,RIPPER_TEMP_DIR,PATH_MAX);
|
||||
strncpy(path,RDTempDir(),PATH_MAX);
|
||||
strcat(path,"/XXXXXX");
|
||||
if(mkdtemp(path)==NULL) {
|
||||
QMessageBox::warning(this,"RDLibrary - "+tr("Ripper Error"),
|
||||
|
@ -86,7 +86,7 @@ DiskRipper::DiskRipper(QString *filter,QString *group,QString *schedcode,
|
||||
// Create Temporary Directory
|
||||
//
|
||||
char path[PATH_MAX];
|
||||
strncpy(path,RIPPER_TEMP_DIR,PATH_MAX);
|
||||
strncpy(path,RDTempDir(),PATH_MAX);
|
||||
strcat(path,"/XXXXXX");
|
||||
if(mkdtemp(path)==NULL) {
|
||||
QMessageBox::warning(this,"RDLibrary - "+tr("Ripper Error"),
|
||||
|
@ -1405,16 +1405,24 @@ QString MainWidget::GetTypeFilter()
|
||||
return type_filter;
|
||||
}
|
||||
|
||||
QString MainWidget::GeometryFile() {
|
||||
bool home_found = false;
|
||||
QString home = RDGetHomeDir(&home_found);
|
||||
if (home_found) {
|
||||
return home + "/" + RDLIBRARY_GEOMETRY_FILE;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::LoadGeometry()
|
||||
{
|
||||
if(getenv("HOME")==NULL) {
|
||||
QString geometry_file = GeometryFile();
|
||||
if(geometry_file==NULL) {
|
||||
return;
|
||||
}
|
||||
RDProfile *profile=new RDProfile();
|
||||
profile->
|
||||
setSource(QString().sprintf("%s/%s",getenv("HOME"),
|
||||
RDLIBRARY_GEOMETRY_FILE));
|
||||
profile->setSource(geometry_file);
|
||||
resize(profile->intValue("RDLibrary","Width",sizeHint().width()),
|
||||
profile->intValue("RDLibrary","Height",sizeHint().height()));
|
||||
lib_shownotes_box->
|
||||
@ -1426,12 +1434,11 @@ void MainWidget::LoadGeometry()
|
||||
|
||||
void MainWidget::SaveGeometry()
|
||||
{
|
||||
if(getenv("HOME")==NULL) {
|
||||
QString geometry_file = GeometryFile();
|
||||
if(geometry_file==NULL) {
|
||||
return;
|
||||
}
|
||||
FILE *file=fopen((const char *)QString().
|
||||
sprintf("%s/%s",getenv("HOME"),RDLIBRARY_GEOMETRY_FILE),
|
||||
"w");
|
||||
FILE *file=fopen(geometry_file,"w");
|
||||
if(file==NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ class MainWidget : public QWidget
|
||||
const QDateTime ¤t_datetime);
|
||||
void SetCaption(QString user);
|
||||
QString GetTypeFilter();
|
||||
QString GeometryFile();
|
||||
void LoadGeometry();
|
||||
void SaveGeometry();
|
||||
void LockUser();
|
||||
|
@ -249,7 +249,7 @@ void MainWidget::loadWaveFile()
|
||||
wave_name=QFileDialog::getOpenFileName(wave_path,RD_AUDIO_FILE_FILTER,this);
|
||||
if(wave_name.isEmpty()) {
|
||||
wave_loaded=false;
|
||||
wave_path=getenv("HOME");
|
||||
wave_path=RDHomeDir();
|
||||
wave_base=tr("RHPIPlay");
|
||||
update();
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user