Example #1
0
//
// Global Classes
//
RDLibraryConf::RDLibraryConf(const QString &station,unsigned instance)
{
  RDSqlQuery *q;
  QString sql;

  lib_station=station;
  lib_instance=instance;

  sql=QString().sprintf("select ID from RDLIBRARY where STATION=\"%s\" && INSTANCE=%d",
			(const char *)lib_station,
			lib_instance);
  q=new RDSqlQuery(sql);
  if(!q->first()) {
    delete q;
    sql=QString().sprintf("insert into RDLIBRARY set STATION=\"%s\",INSTANCE=%d",
			  (const char *)lib_station,
			  lib_instance);
    q=new RDSqlQuery(sql);
    delete q;
    sql=QString().sprintf("select ID from RDLIBRARY where STATION=\"%s\" && INSTANCE=%d",
			  (const char *)lib_station,
			  lib_instance);
    q=new RDSqlQuery(sql);
    q->first();
  }
  lib_id=q->value(0).toUInt();
  delete q;
}
Example #2
0
void ListCasts::GetEncoderId()
{
  QString sql;
  RDSqlQuery *q;

  list_encoder_id=-1;
  RDFeed *feed=new RDFeed(list_feed_id);
  int format=feed->uploadFormat();
  delete feed;
  if((format>0)&&(format<100)) {  // Built-in format
    list_encoder_id=format;
    return;
  }
  sql=QString().sprintf("select NAME from ENCODERS where ID=%d",format);
  q=new RDSqlQuery(sql);
  if(q->first()) {
    sql=QString().sprintf("select ID from ENCODERS \
                           where (NAME=\"%s\")&&(STATION_NAME=\"%s\")",
			  (const char *)RDEscapeString(q->value(0).toString()),
			  (const char *)RDEscapeString(rdstation_conf->name()));
    delete q;
    q=new RDSqlQuery(sql);
    if(q->first()) {
      list_encoder_id=q->value(0).toInt();
    }
  }
Example #3
0
void EditNode::okData()
{
  QString sql;
  RDSqlQuery *q;

  if(edit_password_changed) {
    edit_password=edit_password_edit->text();
  }

  if((*edit_id)<0) {
    sql=QString("select ID from SWITCHER_NODES where ")+
      "(STATION_NAME=\""+RDEscapeString(edit_matrix->station())+"\") && "+
      QString().sprintf("(MATRIX=%d) && ",edit_matrix->matrix())+
      "(HOSTNAME=\""+RDEscapeString(edit_hostname_edit->text())+"\") && "+
      QString().sprintf("(TCP_PORT=%d)",edit_tcpport_spin->value());
    q=new RDSqlQuery(sql);
    if(q->first()) {
      delete q;
      QMessageBox::warning(this,tr("Duplicate Node"),
			   tr("That node is already listed for this matrix!"));
      return;
    }
    delete q;

    sql="select ID from SWITCHER_NODES order by ID desc";
    q=new RDSqlQuery(sql);
    if(q->first()) {
      *edit_id=q->value(0).toInt()+1;
    }
    else {
      *edit_id=1;
    }
    delete q;
    sql=QString("insert into SWITCHER_NODES set ")+
      QString().sprintf("ID=%d,",*edit_id)+
      "STATION_NAME=\""+RDEscapeString(edit_matrix->station())+"\","+
      QString().sprintf("MATRIX=%d,",edit_matrix->matrix())+
      "HOSTNAME=\""+RDEscapeString(edit_hostname_edit->text())+"\","+
      QString().sprintf("TCP_PORT=%d,",edit_tcpport_spin->value())+
      "DESCRIPTION=\""+RDEscapeString(edit_description_edit->text())+"\""+
      QString().sprintf("BASE_OUTPUT=%d,",edit_output_spin->value())+
      "PASSWORD=\""+RDEscapeString(edit_password)+"\"";
    q=new RDSqlQuery(sql);
    delete q;
  }
  else {
    sql=QString("update SWITCHER_NODES set ")+
      "HOSTNAME=\""+RDEscapeString(edit_hostname_edit->text())+"\","+
      QString().sprintf("TCP_PORT=%d,",edit_tcpport_spin->value())+
      "DESCRIPTION=\""+RDEscapeString(edit_description_edit->text())+"\","+
      QString().sprintf("BASE_OUTPUT=%d,",edit_output_spin->value())+
      "PASSWORD=\""+RDEscapeString(edit_password)+"\" where "+
      QString().sprintf("ID=%d",*edit_id);
    q=new RDSqlQuery(sql);
    delete q;
  }

  done(0);
}
void EditNode::okData()
{
  QString sql;
  RDSqlQuery *q;

  if(edit_password_changed) {
    edit_password=edit_password_edit->text();
  }

  if((*edit_id)<0) {
    sql=QString().sprintf("select ID from SWITCHER_NODES \
                           where (STATION_NAME=\"%s\")&&\
                           (MATRIX=%d)&&\
                           (HOSTNAME=\"%s\")&&\
                           (TCP_PORT=%d)",
			  (const char *)edit_matrix->station(),
			  edit_matrix->matrix(),
			  (const char *)edit_hostname_edit->text(),
			  edit_tcpport_spin->value());
    q=new RDSqlQuery(sql);
    if(q->first()) {
      delete q;
      QMessageBox::warning(this,tr("Duplicate Node"),
			   tr("That node is already listed for this matrix!"));
      return;
    }
    delete q;

    sql="select ID from SWITCHER_NODES order by ID desc";
    q=new RDSqlQuery(sql);
    if(q->first()) {
      *edit_id=q->value(0).toInt()+1;
    }
    else {
      *edit_id=1;
    }
    delete q;
    sql=QString().sprintf("insert into SWITCHER_NODES set \
                           ID=%d,\
                           STATION_NAME=\"%s\",\
                           MATRIX=%d,\
                           HOSTNAME=\"%s\",\
                           TCP_PORT=%d,\
                           DESCRIPTION=\"%s\",\
                           BASE_OUTPUT=%d,\
                           PASSWORD=\"%s\"",
			  *edit_id,
			  (const char *)edit_matrix->station(),
			  edit_matrix->matrix(),
			  (const char *)edit_hostname_edit->text(),
			  edit_tcpport_spin->value(),
			  (const char *)edit_description_edit->text(),
			  edit_output_spin->value(),
			  (const char *)RDEscapeString(edit_password));
    q=new RDSqlQuery(sql);
    delete q;
  }
Example #5
0
void AddFeed::okData()
{
  QString sql;
  RDSqlQuery *q;
  RDSqlQuery *q1;

  sql=QString("select KEY_NAME from FEEDS where ")+
    "KEY_NAME=\""+RDEscapeString(feed_keyname_edit->text())+"\"";
  q=new RDSqlQuery(sql);
  if(q->first()) {
    QMessageBox::warning(this,tr("Add Feed Error"),
			 tr("A feed with that key name already exists!"));
    delete q;
    return;
  }
  delete q;

  //
  // Create Default Feed Perms
  //
  if(feed_users_box->isChecked()) {
    sql=QString("select LOGIN_NAME from USERS where ")+
      "(ADMIN_USERS_PRIV='N')&&(ADMIN_CONFIG_PRIV='N')";
    q=new RDSqlQuery(sql);
    while(q->next()) {
      sql=QString("insert into FEED_PERMS set ")+
	"USER_NAME=\""+RDEscapeString(q->value(0).toString())+"\","+
	"KEY_NAME=\""+RDEscapeString(feed_keyname_edit->text())+"\"";
      q1=new RDSqlQuery(sql);
      delete q1;
    }
    delete q;
  }

  //
  // Create Feed
  //
  sql=QString("insert into FEEDS set ")+
    "KEY_NAME=\""+RDEscapeString(feed_keyname_edit->text())+"\","+
    "ORIGIN_DATETIME=now(),"+
    "HEADER_XML=\""+RDEscapeString(DEFAULT_HEADER_XML)+"\","+
    "CHANNEL_XML=\""+RDEscapeString(DEFAULT_CHANNEL_XML)+"\","+
    "ITEM_XML=\""+RDEscapeString(DEFAULT_ITEM_XML)+"\"";
  q=new RDSqlQuery(sql);
  delete q;
  sql=QString("select ID from FEEDS where ")+
    "KEY_NAME=\""+RDEscapeString(feed_keyname_edit->text())+"\"";
  q=new RDSqlQuery(sql);
  if(q->first()) {
    *feed_id=q->value(0).toUInt();
  }
  delete q;
  *feed_keyname=feed_keyname_edit->text();
  done(0);
}
void ListEncoders::addData()
{
  QString name;
  QString sql;
  RDSqlQuery *q;
  RDSqlQuery *q1;

  AddEncoder *ad=new AddEncoder(&name,list_stationname,this);
  if(ad->exec()==0) {
    sql=QString().sprintf("select ID from ENCODERS \
                           where (NAME=\"%s\")&&(STATION_NAME=\"%s\")",
			  (const char *)RDEscapeString(name),
			  (const char *)RDEscapeString(list_stationname));
    q=new RDSqlQuery(sql);
    if(q->first()) {
      EditEncoder *ee=new EditEncoder(q->value(0).toInt());
      if(ee->exec()==0) {
	RDListViewItem *item=new RDListViewItem(list_list_view);
	item->setId(q->value(0).toInt());
	item->setText(0,name);
	RefreshItem(item);
	list_list_view->ensureItemVisible(item);
      }
      else {
	sql=QString().sprintf("delete from ENCODERS \
                              where (NAME=\"%s\")&&(STATION_NAME=\"%s\")",
			      (const char *)RDEscapeString(name),
			      (const char *)RDEscapeString(list_stationname));
	q1=new RDSqlQuery(sql);
	delete q1;
      }
      delete ee;
    }
Example #7
0
void RDIncrementCastCount(QString keyname,unsigned cast_id)
{
  QString sql;
  RDSqlQuery *q;
  QDate current_date=QDate::currentDate();

  keyname.replace(" ","_");
/*
  FIXME: Table locking kills updates.  Why?

  sql=QString().sprintf("lock tables %s_FLG read",(const char *)keyname);
  q=new RDSqlQuery(sql);
  delete q;
*/
  sql=QString().sprintf("select ACCESS_COUNT from %s_FLG where \
                         (CAST_ID=%u)&&(ACCESS_DATE=\"%s\")",
			(const char *)keyname,
			cast_id,
			(const char *)current_date.toString("yyyy-MM-dd"));
  q=new RDSqlQuery(sql);
  if(q->first()) {
    sql=QString().sprintf("update %s_FLG set ACCESS_COUNT=%u where \
                         (CAST_ID=%u)&&(ACCESS_DATE=\"%s\")",
			  (const char *)keyname,
			  q->value(0).toUInt()+1,cast_id,
			  (const char *)current_date.toString("yyyy-MM-dd"));
  }
Example #8
0
void RDLibraryConf::getSettings(RDSettings *s) const
{
  QString sql;
  RDSqlQuery *q;

  sql=QString().sprintf("select DEFAULT_CHANNELS,DEFAULT_SAMPRATE,\
                         DEFAULT_FORMAT,DEFAULT_BITRATE,RIPPER_LEVEL,\
                         TRIM_THRESHOLD from RDLIBRARY \
                         where STATION=\"%s\" && INSTANCE=%d",
			(const char *)lib_station,lib_instance);
  q=new RDSqlQuery(sql);
  s->clear();
  if(q->first()) {
    s->setChannels(q->value(0).toUInt());
    s->setSampleRate(q->value(1).toUInt());
    switch(q->value(2).toInt()) {
	case 0:
	  s->setFormat(RDSettings::Pcm16);
	  break;

	case 1:
	  s->setFormat(RDSettings::MpegL2);
	  break;
    }
    s->setBitRate(q->value(3).toUInt());
    s->setNormalizationLevel(q->value(4).toUInt());
    s->setAutotrimLevel(q->value(5).toUInt());
  }
  delete q;
}
Example #9
0
QVariant RDGetSqlValue(const QString &table,
		       const QString &name1,const QString &test1,
		       const QString &name2,const QString &test2,
                       const QString &name3,const QString &test3,
		       const QString &param,QSqlDatabase *db,bool *valid)
{
  RDSqlQuery *q;
  QString sql;
  QVariant v;

  sql="select `"+param+"` from `"+table+"` where "+
    "(`"+name1+"`=\""+RDEscapeString(test1)+"\")&&"+
    "(`"+name2+"`=\""+RDEscapeString(test1)+"\")&&"+
    "(`"+name3+"`=\""+RDEscapeString(test1)+"\")";
  q=new RDSqlQuery(sql,db);
  if(q->isActive()) {
    q->first();
    v=q->value(0);
    if(valid!=NULL) {
      *valid=!q->isNull(0);
    }
    delete q;
    return v;
  }
  delete q;
  return QVariant();
}
Example #10
0
RDLogLine::RDLogLine(unsigned cartnum)
{
  QString sql;
  RDSqlQuery *q;

  clear();
  log_cart_number=cartnum;
  sql=QString().sprintf("select GROUP_NAME,TITLE,ARTIST,ALBUM,YEAR,LABEL,\
                         CLIENT,AGENCY,COMPOSER,PUBLISHER,USER_DEFINED,NOTES \
                         from CART where NUMBER=%u",log_cart_number);
  q=new RDSqlQuery(sql);
  if(q->first()) {
    log_group_name=q->value(0).toString();
    log_title=q->value(1).toString();
    log_artist=q->value(2).toString();
    log_album=q->value(3).toString();
    log_year=QDate(q->value(4).toInt(),1,1);
    log_label=q->value(5).toString();
    log_client=q->value(6).toString();
    log_agency=q->value(7).toString();
    log_composer=q->value(8).toString();
    log_publisher=q->value(9).toString();
    log_user_defined=q->value(10).toString();
    log_cart_notes=q->value(11).toString();
  }
  delete q;
}
Example #11
0
void RDLogeditConf::getSettings(RDSettings *s) const
{
  QString sql;
  RDSqlQuery *q;

  sql=QString("select ")+
    "DEFAULT_CHANNELS,"+
    "SAMPRATE,"+
    "FORMAT,"+
    "BITRATE,"+
    "RIPPER_LEVEL,"+
    "TRIM_THRESHOLD "+
    "from RDLOGEDIT where "+
    "STATION=\""+RDEscapeString(lib_station)+"\"";
  q=new RDSqlQuery(sql);
  s->clear();
  if(q->first()) {
    s->setChannels(q->value(0).toUInt());
    s->setSampleRate(q->value(1).toUInt());
    switch(q->value(2).toInt()) {
	case 0:
	  s->setFormat(RDSettings::Pcm16);
	  break;

	case 1:
	  s->setFormat(RDSettings::MpegL2);
	  break;
    }
    s->setBitRate(q->value(3).toUInt());
    s->setNormalizationLevel(q->value(4).toUInt());
    s->setAutotrimLevel(q->value(5).toUInt());
  }
  delete q;
}
Example #12
0
void ListAuxFields::deleteData()
{
  QString sql;
  RDSqlQuery *q;

  RDListViewItem *item=(RDListViewItem *)list_list_view->selectedItem();
  if(item==NULL) {
    return;
  }

  if(QMessageBox::question(this,tr("Warning"),
			   tr("This will delete all data associated with this field!\nAre you sure you want to continue?"),QMessageBox::Yes,QMessageBox::No)==QMessageBox::No) {
    return;
  }

  sql=QString().sprintf("select KEY_NAME from FEEDS where ID=%d",list_feed_id);
  q=new RDSqlQuery(sql);
  if(q->first()) {
    QString keyname=q->value(0).toString();
    delete q;
    keyname.replace(" ","_");
    QString varname=item->text(0).mid(1,item->text(0).length()-2);
    sql=QString().sprintf("alter table %s_FIELDS drop column %s",
			  (const char *)keyname,(const char *)varname);
    q=new RDSqlQuery(sql);
  }
  delete q;

  sql=QString().sprintf("delete from AUX_METADATA where ID=%d",item->id());
  q=new RDSqlQuery(sql);
  delete q;
  delete item;
}
Example #13
0
void MainObject::Deletelog(QString logname)
{
  QString sql;
  RDSqlQuery *q;

  //
  // Normalize log name case
  //
  // FIXME: This should really be handled by use of collations in the
  //        where clause.
  //
  sql=QString("select NAME from LOGS where ")+
    "NAME=\""+RDEscapeString(logname)+"\"";
  q=new RDSqlQuery(sql);
  if(q->first()) {
    logname=q->value(0).toString();
  }
  delete q;

  if((edit_log==NULL)||(edit_log->name()!=logname)) {
    RDLog *log=new RDLog(logname);
    if(log->exists()) {
      if(!log->remove(rda->station(),rda->user(),rda->config())) {
	fprintf(stderr,"deletelog: audio deletion error, log not deleted\n");
      }
    }
    else {
      fprintf(stderr,"deletelog: no such log\n");
    }
    delete log;
  }
  else {
    fprintf(stderr,"deletelog: log currently loaded (try \"unload\" first)\n");
  }
}
Example #14
0
void MainObject::New(const QString &logname)
{
  QString sql;
  RDSqlQuery *q;

  if(edit_log!=NULL) {
    delete edit_log;
  }
  if(edit_log_event!=NULL) {
    delete edit_log_event;
  }
  edit_log=new RDLog(logname);
  if(!edit_log->exists()) {
    edit_log_event=new RDLogEvent(RDLog::tableName(logname));
    edit_description=logname+" log";
    sql=QString("select NAME from SERVICES");
    q=new RDSqlQuery(sql);
    if(q->first()) {
      edit_service=q->value(0).toString();
    }
    delete q;
    edit_start_date=QDate();
    edit_end_date=QDate();
    edit_purge_date=QDate();
    edit_auto_refresh=false;
    edit_new_log=true;
    edit_modified=false;
  }
  else {
    fprintf(stderr,"new: log already exists\n");
  }
}
void EditJack::addData()
{
  QString sql;
  RDSqlQuery *q;
  RDSqlQuery *q1;
  RDListViewItem *item=NULL;

  sql=QString("insert into JACK_CLIENTS set ")+
    "STATION_NAME=\""+RDEscapeString(edit_station->name())+"\","+
    "DESCRIPTION=\"\",COMMAND_LINE=\"\"";
  q=new RDSqlQuery(sql);
  delete q;
  sql="select last_insert_id() from JACK_CLIENTS";
  q=new RDSqlQuery(sql);
  if(q->first()) {
    item=new RDListViewItem(edit_jack_client_view);
    item->setId(q->value(0).toInt());
    QString desc=tr("[New Client]");
    QString cmd="";
    EditJackClient *d=new EditJackClient(edit_station,this);
    if(d->exec(&desc,&cmd)==0) {
      item->setText(0,desc);
      item->setText(1,cmd);
    }
    else {
      sql=QString().sprintf("delete from JACK_CLIENTS where ID=%d",item->id());
      q1=new RDSqlQuery(sql);
      delete q1;
      delete item;
    }
  }
  delete q;
}
Example #16
0
void RDLogLine::refreshPointers()
{
  if(log_cut_name.isEmpty()) {
    return;
  }
  QString sql;
  RDSqlQuery *q;

  sql=QString().sprintf("select START_POINT,END_POINT,\
                         SEGUE_START_POINT,SEGUE_END_POINT,\
                         TALK_START_POINT,TALK_END_POINT,\
                         FADEUP_POINT,FADEDOWN_POINT,\
                         HOOK_START_POINT,HOOK_END_POINT from CUTS\
                         where CUT_NAME=\"%s\"",
			(const char *)log_cut_name);
  q=new RDSqlQuery(sql);
  if(q->first()) {
    log_start_point[RDLogLine::CartPointer]=q->value(0).toInt();
    log_end_point[RDLogLine::CartPointer]=q->value(1).toInt();
    log_segue_start_point[RDLogLine::CartPointer]=q->value(2).toInt();
    log_segue_end_point[RDLogLine::CartPointer]=q->value(3).toInt();
    log_talk_start=q->value(4).toInt();
    log_talk_end=q->value(5).toInt();
    log_talk_length=log_talk_end-log_talk_start;
    log_fadeup_point[RDLogLine::CartPointer]=q->value(6).toInt();
    log_fadedown_point[RDLogLine::CartPointer]=q->value(7).toInt();
    log_hook_start=q->value(8).toInt();
    log_hook_end=q->value(9).toInt();
  }
  delete q;
}
Example #17
0
void AddEncoder::okData()
{
  QString sql;
  RDSqlQuery *q;

  sql=QString().sprintf("select NAME from ENCODERS \
                         where (NAME=\"%s\")&&(STATION_NAME=\"%s\")",
			(const char *)RDEscapeString(encoder_name_edit->text()),
			(const char *)RDEscapeString(encoder_stationname));
  q=new RDSqlQuery(sql);
  if(q->first()) {
    QMessageBox::warning(this,tr("Add Encoder Error"),
			 tr("A encoder with that name already exists!"));
    delete q;
    return;
  }
  delete q;

  //
  // Create Encoder
  //
  sql=QString().sprintf("insert into ENCODERS set NAME=\"%s\",\
                         STATION_NAME=\"%s\"",
			(const char *)RDEscapeString(encoder_name_edit->text()),
			(const char *)RDEscapeString(encoder_stationname));
  q=new RDSqlQuery(sql);
  delete q;
  *encoder_name=encoder_name_edit->text();

  done(0);
}
void ListVguestResources::okData()
{
  QString sql;
  RDSqlQuery *q;
  int engine_num=-1;
  int device_num=-1;
  int surface_num=-1;
  int relay_num=-1;

  QListViewItem *item=list_list_view->firstChild();
  while(item!=NULL) {
    engine_num=-1;
    device_num=-1;
    surface_num=-1;
    relay_num=-1;
    if(!item->text(1).isEmpty()) {
      engine_num=item->text(1).toInt(NULL,16);
    }
    if(!item->text(2).isEmpty()) {
      device_num=item->text(2).toInt(NULL,16);
    }
    if(!item->text(3).isEmpty()) {
      surface_num=item->text(3).toInt(NULL,16);
    }
    switch(list_type) {
	case RDMatrix::VguestTypeRelay:
	  if(!item->text(4).isEmpty()) {
	    relay_num=item->text(4).toInt(NULL,16);
	  }
	  break;

	case RDMatrix::VguestTypeDisplay:
	  break;
    }
    sql=QString().sprintf("select ID from VGUEST_RESOURCES where\
                           (STATION_NAME=\"%s\")&&\
                           (MATRIX_NUM=%d)&&\
                           (VGUEST_TYPE=%d)&&\
                           (NUMBER=%d)",
			  (const char *)list_matrix->station(),
			  list_matrix->matrix(),list_type,
			  item->text(0).toInt());
    q=new RDSqlQuery(sql);
    if(q->first()) {
      sql=QString().sprintf("update VGUEST_RESOURCES set\
                             ENGINE_NUM=%d,DEVICE_NUM=%d,\
                             SURFACE_NUM=%d,RELAY_NUM=%d\
                             where\
                             (STATION_NAME=\"%s\")&&\
                             (MATRIX_NUM=%d)&&\
                             (VGUEST_TYPE=%d)&&\
                             (NUMBER=%d)",
			    engine_num,device_num,surface_num,
			    relay_num,
			    (const char *)list_matrix->station(),
			    list_matrix->matrix(),
			    list_type,item->text(0).toInt());
    }
    else {
Example #19
0
void RDCartDialog::editorData()
{
#ifndef WIN32
  RDListViewItem *item=(RDListViewItem *)cart_cart_list->currentItem();
  if(item==NULL) {
    return;
  }

  QString sql;
  RDSqlQuery *q;

  sql=QString("select ")+
    "CUTS.CUT_NAME,"+      // 00
    "CUTS.LENGTH,"+        // 01
    "CART.GROUP_NAME,"+    // 02
    "CART.TITLE,"+         // 03
    "CART.ARTIST,"+        // 04
    "CART.ALBUM,"+         // 05
    "CART.YEAR,"+          // 06
    "CART.LABEL,"+         // 07
    "CART.CLIENT,"+        // 08
    "CART.AGENCY,"+        // 09
    "CART.COMPOSER,"+      // 10
    "CART.PUBLISHER,"+     // 11
    "CART.USER_DEFINED "+  // 12
    "from CUTS left join CART "+
    "on CUTS.CART_NUMBER=CART.NUMBER where "+
    QString().sprintf("(CUTS.CART_NUMBER=%u)&&",item->text(1).toUInt())+
    "(CUTS.LENGTH>0)";
  q=new RDSqlQuery(sql);
  if(!q->first()) {
    delete q;
    return;
  }
  QString cmd=rda->station()->editorPath();
  cmd.replace("%f",RDCut::pathName(q->value(0).toString()));
  cmd.replace("%n",QString().sprintf("%06u",item->text(1).toUInt()));
  cmd.replace("%h",QString().sprintf("%d",q->value(1).toInt()));
  cmd.replace("%g",q->value(2).toString());
  cmd.replace("%t",q->value(3).toString());
  cmd.replace("%a",q->value(4).toString());
  cmd.replace("%l",q->value(5).toString());
  cmd.replace("%y",q->value(6).toString());
  cmd.replace("%b",q->value(7).toString());
  cmd.replace("%c",q->value(8).toString());
  cmd.replace("%e",q->value(9).toString());
  cmd.replace("%m",q->value(10).toString());
  cmd.replace("%p",q->value(11).toString());
  cmd.replace("%u",q->value(12).toString());
  delete q;

  if(fork()==0) {
    system(cmd+" &");
    exit(0);
  }
#endif
}
Example #20
0
void RDDeleteCastCount(unsigned feed_id,unsigned cast_id)
{
  QString sql;
  RDSqlQuery *q;

  sql=QString().sprintf("select KEY_NAME from FEEDS where ID=%u",feed_id);
  q=new RDSqlQuery(sql);
  if(q->first()) {
    RDDeleteCastCount(q->value(0).toString(),cast_id);
  }
  delete q;
}
Example #21
0
bool EditUpload::CheckFormat()
{
  bool res=false;

  RDStation *station=new RDStation(edit_station_box->currentText());
  switch(edit_settings.format()) {
      case RDSettings::Pcm16:
      case RDSettings::MpegL2:
      case RDSettings::MpegL2Wav:
	res=true;
	break;

      case RDSettings::MpegL1:
	res=false;
	break;

      case RDSettings::MpegL3:
	if(station->haveCapability(RDStation::HaveLame)) {
	  res=true;
	}
	break;
	
      case RDSettings::Flac:
	if(station->haveCapability(RDStation::HaveFlac)) {
	  res=true;
	}
	break;
	
      case RDSettings::OggVorbis:
	if(station->haveCapability(RDStation::HaveOggenc)) {
	  res=true;
	}
	break;
  }
  delete station;

  QString sql;
  RDSqlQuery *q;
  sql=QString().sprintf("select STATION_NAME from ENCODERS \
                         where (NAME=\"%s\")&&(STATION_NAME=\"%s\")",
			(const char *)RDEscapeString(edit_settings.
						     formatName()),
			(const char *)RDEscapeString(edit_station_box->
						     currentText()));
  q=new RDSqlQuery(sql);
  if(q->first()) {
    res=true;
  }
  delete q;

  return res;
}
Example #22
0
void ListEvents::addData()
{
  QString logname;
  RDEvent *event;
  RDSqlQuery *q;
  RDSqlQuery *q1;
  std::vector<QString> new_events;

  AddEvent *add_dialog=new AddEvent(&logname,this,"add_dialog");
  if(add_dialog->exec()<0) {
    delete add_dialog;
    return;
  }
  delete add_dialog;
  QString sql=QString().sprintf("select NAME from EVENTS where NAME=\"%s\"",
				(const char *)logname);
  q=new RDSqlQuery(sql);
  if(q->first()) {
    QMessageBox::
      information(this,tr("Event Exists"),
		  tr("An event with that name already exists!"));
    delete q;
    return;
  }
  delete q;
  event=new RDEvent(logname,true);
  delete event;
  EditEvent *event_dialog=new EditEvent(logname,true,&new_events,
					this,"event_dialog");
  if(event_dialog->exec()<-1) {
    sql=QString().sprintf("delete from EVENTS where NAME=\"%s\"",
			  (const char *)logname);
    q=new RDSqlQuery(sql);
    delete q;
    return;
  }
  else {
    if(edit_filter_box->currentItem()==0) {
      sql="select NAME from SERVICES";
      q=new RDSqlQuery(sql);
      while(q->next()) {
	sql=QString().sprintf("insert into EVENT_PERMS set\
                               EVENT_NAME=\"%s\",SERVICE_NAME=\"%s\"",
			      (const char *)logname,
			      (const char *)q->value(0).toString());
	q1=new RDSqlQuery(sql);
	delete q1;
      }
      delete q;
    }
    else {
Example #23
0
void ListAuxFields::RefreshItem(RDListViewItem *item)
{
  QString sql;
  RDSqlQuery *q;

  sql=QString().sprintf("select VAR_NAME,CAPTION from AUX_METADATA \
                         where ID=%d",item->id());
  q=new RDSqlQuery(sql);
  if(q->first()) {
    item->setText(0,q->value(0).toString());
    item->setText(1,q->value(1).toString());
  }
  delete q;
}
Example #24
0
bool RDSystem::showUserList() const
{
  bool ret=false;
  QString sql;
  RDSqlQuery *q;

  sql="select SHOW_USER_LIST from SYSTEM";
  q=new RDSqlQuery(sql);
  if(q->first()) {
    ret=RDBool(q->value(0).toString());
  }
  delete q;
  return ret;
}
Example #25
0
bool RDSystem::allowDuplicateCartTitles() const
{
  bool ret=false;
  QString sql;
  RDSqlQuery *q;

  sql="select DUP_CART_TITLES from SYSTEM";
  q=new RDSqlQuery(sql);
  if(q->first()) {
    ret=RDBool(q->value(0).toString());
  }
  delete q;
  return ret;
}
Example #26
0
bool RDUser::groupAuthorized(const QString &group_name)
{
  QString sql;
  RDSqlQuery *q;
  bool ret=false;

  sql=QString().
    sprintf("select GROUP_NAME from USER_PERMS where USER_NAME=\"%s\"",
	    (const char *)RDEscapeString(user_name));
  q=new RDSqlQuery(sql);
  ret=q->first();
  delete q;
  return ret;
}
Example #27
0
bool RDLog::exists(const QString &name)
{
  QString sql;
  RDSqlQuery *q;
  bool ret=false;

  sql=QString("select NAME from LOGS where NAME=\"")+
    RDEscapeString(name)+"\"";
  q=new RDSqlQuery(sql);
  ret=q->first();
  delete q;

  return ret;
}
Example #28
0
RDFeed::RDFeed(unsigned id,QObject *parent,const char *name)
  : QObject(parent,name)
{
  RDSqlQuery *q;
  QString sql;

  feed_id=id;

  sql=QString().sprintf("select KEY_NAME from FEEDS where ID=%u",id);
  q=new RDSqlQuery(sql);
  if(q->first()) {
    feed_keyname=q->value(0).toString();
  }
  delete q;
}
Example #29
0
void DeckMon::SetCutInfo(int id,const QString &cutname)
{
  QString sql;
  RDSqlQuery *q;
  RDSqlQuery *q1;

  if(id<0) {
    mon_cut_label->setText(tr("[multiple events]"));
    return;
  }
  if(id==0) {
    mon_cut_label->setText("");
    return;
  }
  sql=QString().sprintf("select DESCRIPTION from RECORDINGS where ID=%d",id);
  q=new RDSqlQuery(sql);
  if(!q->first()) {
    if(cutname.isEmpty()) {
      mon_cut_label->setText(tr("[unknown cut]"));
    }
    else {
      sql=QString("select ")+
	"CART.TITLE,"+
	"CUTS.DESCRIPTION "+
	"from CART left join CUTS "+
	"on CART.NUMBER=CUTS.CART_NUMBER where "+
	"CUTS.CUT_NAME=\""+RDEscapeString(cutname)+"\"";
      q1=new RDSqlQuery(sql);
      if(q1->first()) {
	mon_cut_label->
	  setText(q1->value(0).toString()+"->"+q1->value(1).toString());
      }
      else {
	mon_cut_label->setText(tr("[unknown cut]"));
      }
      delete q1;
    }
    delete q;
    return;
  }
  if(q->value(0).toString().isEmpty()) {
    mon_cut_label->setText(tr("[no description]"));
    delete q;
    return;
  }
  mon_cut_label->setText(q->value(0).toString());
  delete q;
}
Example #30
0
bool RDDoesRowExist(const QString &table,const QString &name,
		    const QString &test,QSqlDatabase *db)
{
  RDSqlQuery *q;
  QString sql;

  sql="select `"+name+"` from `"+table+"` where `"+name+"`="+
    "\""+RDEscapeString(test)+"\"";
  q=new RDSqlQuery(sql,db);
  if(q->first()) {
    delete q;
    return true;
  }
  delete q;
  return false;
}