Example #1
0
void EditSvcPerms::okData()
{
  RDSqlQuery *q;
  QString sql;

  //
  // Add New Hosts
  //
  for(unsigned i=0;i<svc_host_sel->destCount();i++) {
    sql=QString().sprintf("select STATION_NAME from SERVICE_PERMS \
                           where SERVICE_NAME=\"%s\" && STATION_NAME=\"%s\"",
			  (const char *)svc_svc->name(),
			  (const char *)svc_host_sel->destText(i));
    q=new RDSqlQuery(sql);
    if(q->size()==0) {
      delete q;
      sql=QString().
	sprintf("insert into SERVICE_PERMS (SERVICE_NAME,STATION_NAME) \
                 values (\"%s\",\"%s\")",
		(const char *)svc_svc->name(),
		(const char *)svc_host_sel->destText(i));
      q=new RDSqlQuery(sql);
    }
    delete q;
  }
Example #2
0
void Xport::ListGroups()
{
  QString sql;
  RDSqlQuery *q;
  RDGroup *group;

  //
  // Generate Group List
  //
  sql=QString().sprintf("select GROUP_NAME from USER_PERMS \
                         where USER_NAME=\"%s\" order by GROUP_NAME",
			(const char *)RDEscapeString(rdcgi->user()->name()));
  q=new RDSqlQuery(sql);

  //
  // Process Request
  //
  printf("Content-type: application/xml\n");
  printf("Status: 200\n\n");
  printf("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
  printf("<groupList>\n");
  while(q->next()) {
    group=new RDGroup(q->value(0).toString());
    printf("%s",(const char *)group->xml());
    delete group;
  }
  printf("</groupList>\n");

  delete q;
  Exit(0);
}
Example #3
0
void ListReplicatorCarts::refreshTimeoutData()
{
  QString sql;
  RDSqlQuery *q;
  RDListViewItem *item;

  sql=QString("select ")+
    "ID,"+
    "ITEM_DATETIME "+
    "from REPL_CART_STATE where "+
    "REPLICATOR_NAME=\""+RDEscapeString(list_replicator_name)+"\"";
  q=new RDSqlQuery(sql);
  while(q->next()) {
    item=(RDListViewItem *)list_view->firstChild();
    while(item!=NULL) {
      if(item->id()==q->value(0).toInt()) {
	item->setText(3,q->value(1).
		      toDateTime().toString("hh:mm:ss dd/MM/yyyy"));
	break;
      }
      item=(RDListViewItem *)item->nextSibling();
    }
  }
  delete q;
  list_refresh_timer->start(5000,true);
}
Example #4
0
void EditDecks::matrixActivatedData(const QString &str)
{
  QString sql;
  RDSqlQuery *q;

  if(str.isEmpty()) {
    edit_swoutput_label->setDisabled(true);
    edit_swoutput_box->setDisabled(true);
    edit_swdelay_label->setDisabled(true);
    edit_swdelay_unit->setDisabled(true);
    edit_swdelay_box->setDisabled(true);
    return;
  }
  edit_swoutput_label->setEnabled(true);
  edit_swoutput_box->setEnabled(true);
  edit_swdelay_label->setEnabled(true);
  edit_swdelay_unit->setEnabled(true);
  edit_swdelay_box->setEnabled(true);

  edit_swoutput_box->clear();
  if(edit_swmatrix_box->currentItem()>=(int)edit_matrix_ids.size()) {
    return;
  }
  int matrix=edit_matrix_ids[edit_swmatrix_box->currentItem()];
  sql=QString("select NAME from OUTPUTS where ")+
    "(STATION_NAME=\""+RDEscapeString(edit_swstation_box->currentText())+
    "\")&&"+
    QString().sprintf("(MATRIX=%d)&&",matrix)+
    "(NAME!=\"\")";
  q=new RDSqlQuery(sql);
  while(q->next()) {
    edit_swoutput_box->insertItem(q->value(0).toString());
  }
  delete q;
}
Example #5
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 #6
0
void EditUserPerms::okData()
{
  RDSqlQuery *q;
  QString sql;

  //
  // Add New Groups
  //
  for(unsigned i=0;i<user_host_sel->destCount();i++) {
    sql=QString().sprintf("select GROUP_NAME from USER_PERMS \
                           where USER_NAME=\"%s\" && GROUP_NAME=\"%s\"",
			  (const char *)user_user->name(),
			  (const char *)user_host_sel->destText(i));
    q=new RDSqlQuery(sql);
    if(q->size()==0) {
      delete q;
      sql=QString().
	sprintf("insert into USER_PERMS (USER_NAME,GROUP_NAME) \
                 values (\"%s\",\"%s\")",
		(const char *)user_user->name(),
		(const char *)user_host_sel->destText(i));
      q=new RDSqlQuery(sql);
    }
    delete q;
  }
Example #7
0
void Xport::ListSchedCodes()
{
  QString sql;
  RDSqlQuery *q;
  RDSchedCode *schedcode;

  //
  // Generate Scheduler Code List
  //
  sql=QString("select CODE from SCHED_CODES order by CODE");
  q=new RDSqlQuery(sql);

  //
  // Process Request
  //
  printf("Content-type: application/xml\n");
  printf("Status: 200\n\n");
  printf("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
  printf("<schedCodeList>\n");
  while(q->next()) {
    schedcode=new RDSchedCode(q->value(0).toString());
    printf("%s",(const char *)schedcode->xml().utf8());
    delete schedcode;
  }
  printf("</schedCodeList>\n");

  delete q;
  Exit(0);
}
Example #8
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");
  }
}
Example #9
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 #10
0
void EditPerms::okData()
{
  RDSqlQuery *q;
  QString sql;

  //
  // Add New Objects
  //
  for(unsigned i=0;i<svc_object_sel->destCount();i++) {
    sql=QString().sprintf("select %s_NAME from %s_PERMS \
                           where SERVICE_NAME=\"%s\" && %s_NAME=\"%s\"",
			  (const char *)object_type,
			  (const char *)object_type,
			  (const char *)svc_object_sel->destText(i),
			  (const char *)object_type,
			  (const char *)sel_name);
    q=new RDSqlQuery(sql);
    if(q->size()==0) {
      delete q;
      sql=QString().
	sprintf("insert into %s_PERMS (SERVICE_NAME,%s_NAME) \
                 values (\"%s\",\"%s\")",
		(const char *)object_type,
		(const char *)object_type,
		(const char *)svc_object_sel->destText(i),
		(const char *)sel_name);
      q=new RDSqlQuery(sql);
    }
    delete q;
  }
Example #11
0
void MainWidget::RefreshList()
{
  RDSqlQuery *q;
  QString sql;
  ListListViewItem *item;

  log_log_list->clear(); // Note: clear here, in case user has no perms.

  sql=QString("select NAME from LOGS where ")+
    "(TYPE=0)&&"+
    "(LOG_EXISTS=\"Y\")";

  if(log_service_box->currentItem()!=0) {
    sql+="&&(SERVICE=\""+RDEscapeString(log_service_box->currentText())+"\")";
  }
  QString filter=log_filter_edit->text();
  if(!filter.isEmpty()) {
    sql+="&&((NAME like \"%%"+RDEscapeString(filter)+"%%\")||";
    sql+="(DESCRIPTION like \"%%"+RDEscapeString(filter)+"%%\")||";
    sql+="(SERVICE like \"%%"+RDEscapeString(filter)+"%%\"))";
  }
  if(log_recent_check->isChecked()) {
    sql+=QString().sprintf("order by ORIGIN_DATETIME desc limit %d",
			   RDLOGEDIT_LIMIT_QUAN);
  }
  q=new RDSqlQuery(sql);
  while(q->next()) {
    item=new ListListViewItem(log_log_list);
    item->setText(1,q->value(0).toString());
    RefreshItem(item);
  }
  delete q;
}
Example #12
0
QStringList RDUser::services() const
{
  RDSqlQuery *q;
  QString sql;
  QStringList services_list;

  if (adminConfig()) {
    sql=QString().sprintf("SELECT NAME FROM SERVICES" );
  } 
  else {
    sql=QString().sprintf("select distinct AUDIO_PERMS.SERVICE_NAME \
                           from USER_PERMS left join AUDIO_PERMS \
                           on USER_PERMS.GROUP_NAME=AUDIO_PERMS.GROUP_NAME \
                           where USER_PERMS.USER_NAME=\"%s\"",
			  (const char *)RDEscapeString(user_name));
  }
  
  q=new RDSqlQuery(sql);
  while (q->next() ) {
    services_list.append( q->value(0).toString() );
  }
  delete q;

  return services_list;
}
unsigned RDCartSlot::SelectCart(const QString &svcname,unsigned msecs)
{
  QString sql;
  RDSqlQuery *q;
  unsigned cartnum=0;
  int diff=1000000;

  sql=QString("select AUTOFILLS.CART_NUMBER,CART.FORCED_LENGTH from ")+
    "AUTOFILLS left join CART on AUTOFILLS.CART_NUMBER=CART.NUMBER"+
    QString().
    sprintf(" where (CART.FORCED_LENGTH>%u)&&(CART.FORCED_LENGTH<%u)&&",
	    (unsigned)((double)msecs*RD_TIMESCALE_MIN),
	    (unsigned)((double)msecs*RD_TIMESCALE_MAX))+
    "(SERVICE=\""+RDEscapeString(svcname)+"\")";
  q=new RDSqlQuery(sql);
  while(q->next()) {
    int cur_diff = msecs-q->value(1).toInt();
    if(::abs(cur_diff)<diff) {
      cartnum=q->value(0).toUInt();
      diff=::abs(cur_diff);
    }
  }
  delete q;
  return cartnum;
}
Example #14
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);
}
Example #15
0
QString RDCartDialog::GetSearchFilter(const QString &filter,
				      const QString &group,
				      const QString &schedcode)
{
  QString sql;
  RDSqlQuery *q;
  QString sched="";
  
  if(schedcode!=tr("ALL")) {
    sched=schedcode;
  }
  QString search=RDCartSearchText(filter,group,sched,false).utf8();

  //
  // Excluded Groups
  //
  sql=QString().sprintf("select NAME from GROUPS where ");
  for(int i=1;i<cart_group_box->count();i++) {
    sql+=QString("(NAME!=\"")+RDEscapeString(cart_group_box->text(i))+"\")&&";
  }
  sql=sql.left(sql.length()-2);
  q=new RDSqlQuery(sql);
  while(q->next()) {
    search+=QString("&&(GROUP_NAME!=\"")+
      RDEscapeString(q->value(0).toString())+"\")";
  }
  delete q;
  return search;
}
Example #16
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 #17
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 #18
0
int RDLog::removeTracks(RDStation *station,RDUser *user,RDConfig *config) const
{
  QString sql;
  RDSqlQuery *q;
  int count=0;
  RDCart *cart;

  QString owner=log_name;
  owner.replace(" ","_");
  sql=QString().sprintf("select NUMBER from CART where OWNER=\"%s\"",
			(const char *)owner);
  q=new RDSqlQuery(sql);
  while(q->next()) {
    cart=new RDCart(q->value(0).toUInt());
    if(!cart->remove(station,user,config)) {
      delete cart;
      return -1;
    }
    delete cart;
    count++;
  }
  delete q;

  return count;
}
Example #19
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 #20
0
//
// Global Classes
//
RDLog::RDLog(const QString &name,bool create)
{
  RDSqlQuery *q;
  QString sql;

  log_name=name;

  if(create) {
    sql=QString().sprintf("select NAME from LOGS where \
(NAME=\"%s\")",(const char *)RDEscapeString(log_name));
    q=new RDSqlQuery(sql);
    if(q->size()!=1) {
      delete q;
      sql=QString().
        sprintf("INSERT INTO LOGS SET NAME=\"%s\",ORIGIN_DATETIME=NOW(),\
                 LINK_DATETIME=NOW(),MODIFIED_DATETIME=now()",
		(const char *)RDEscapeString(log_name));
      q=new RDSqlQuery(sql);
      delete q;
    }
    else {
      delete q;
    }
  }
}
Example #21
0
void RDLog::updateTracks()
{
  QString sql;
  RDSqlQuery *q;
  unsigned scheduled=0;
  unsigned completed=0;

  sql=QString().sprintf("select NUMBER from CART where OWNER=\"%s\"",
			(const char *)RDEscapeString(log_name));
  q=new RDSqlQuery(sql);
  completed=q->size();
  delete q;

  sql=QString("select ID from `")+RDLog::tableName(log_name)+
    "` where "+QString().sprintf("TYPE=%d",RDLogLine::Track);
  q=new RDSqlQuery(sql);
  scheduled=q->size()+completed;
  delete q;

  sql=QString().sprintf("update LOGS set SCHEDULED_TRACKS=%d,\
                         COMPLETED_TRACKS=%u where NAME=\"%s\"",
			scheduled,completed,
			(const char *)RDEscapeString(log_name));
  q=new RDSqlQuery(sql);
  delete q;
}
Example #22
0
//
// Global Classes
//
RDTty::RDTty(const QString &station,unsigned port_id,bool create)
{
  RDSqlQuery *q;
  QString sql;

  tty_station=station;
  tty_id=port_id;

  if(create) {
    sql=QString("select ID from TTYS where ")+
      "(STATION_NAME=\""+RDEscapeString(tty_station)+"\")&&"+
      QString().sprintf("(PORT_ID=%d)",tty_id);
    q=new RDSqlQuery(sql);
    if(q->size()!=1) {
      delete q;
      sql=QString().sprintf("insert into TTYS set ")+
	"STATION_NAME=\""+RDEscapeString(tty_station)+"\","+
	QString().sprintf("PORT_ID=%d",tty_id);
      q=new RDSqlQuery(sql);
      delete q;
    }
    else {
      delete q;
    }
  }
}
Example #23
0
void RDLog::updateLinkQuantity(RDLog::Source src) const
{
  QString sql;
  RDSqlQuery *q;
  switch(src) {
      case RDLog::SourceMusic:
	sql=QString("select ID from `")+RDLog::tableName(log_name)+
	  "` where "+QString().sprintf("TYPE=%d",RDLogLine::MusicLink);
	q=new RDSqlQuery(sql);
	sql=QString("update LOGS set ")+
	  QString().sprintf("MUSIC_LINKS=%d ",q->size())+
	  "where NAME=\""+RDEscapeString(log_name)+"\"";
	break;

      case RDLog::SourceTraffic:
	sql=QString("select ID from `")+RDLog::tableName(log_name)+
	  "` where "+QString().sprintf("TYPE=%d",RDLogLine::TrafficLink);
	q=new RDSqlQuery(sql);

	sql=QString("update LOGS set ")+
	  QString().sprintf("TRAFFIC_LINKS=%d ",q->size())+
	  "where NAME=\""+RDEscapeString(log_name)+"\"";
	break;

      default:
	return;
  }
  delete q;
  q=new RDSqlQuery(sql);
  delete q;
}
Example #24
0
//
// Global Classes
//
RDDeck::RDDeck(QString station,unsigned channel,bool create)
{
  RDSqlQuery *q;
  QString sql;

  deck_station=station;
  deck_channel=channel;

  if(create) {
    sql=QString("select ID from DECKS where ")+
      "(STATION_NAME=\""+RDEscapeString(deck_station)+"\")&&"+
      QString().sprintf("(CHANNEL=%d)",deck_channel);
    q=new RDSqlQuery(sql);
    if(q->size()!=1) {
      delete q;
      sql=QString().
        sprintf("insert into DECKS set ")+
	"STATION_NAME=\""+RDEscapeString(deck_station)+"\","+
	QString().sprintf("CHANNEL=%d",deck_channel);
      q=new RDSqlQuery(sql);
      delete q;
    }
    else {
      delete q;
    }
  }
}
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 #26
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"));
  }
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 #28
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 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 {
void ListLog::loadButtonData()
{
    QString name=list_log->logName().left(list_log->logName().length()-4);
    QString svcname=list_log->serviceName();

    RDLog *edit_log;
    QString sql;
    RDSqlQuery *q;

    switch(list_logs_dialog->exec(&name,&svcname)) {
    case 0:
        list_log->setLogName(RDLog::tableName(name));
        list_log->load();
        break;

    case 2:
        list_log->save();
        edit_log=new RDLog(list_log->logName().
                           left(list_log->logName().length()-4));
        delete edit_log;
        break;

    case 3:
        sql=QString().sprintf("insert into LOGS set \
                                       NAME=\"%s\",TYPE=0,\
                                       DESCRIPTION=\"%s log\",\
                                       ORIGIN_USER=\"%s\",\
                                       ORIGIN_DATETIME=NOW(),\
                                       LINK_DATETIME=NOW(),\
                                       MODIFIED_DATETIME=NOW(),\
                                       SERVICE=\"%s\"",
                              (const char *)name,
                              (const char *)name,
                              (const char *)rda->ripc()->user(),
                              (const char *)svcname);
        q=new RDSqlQuery(sql);
        if(!q->isActive()) {
            QMessageBox::warning(this,tr("Log Exists"),
                                 tr("Log Already Exists!"));
            delete q;
            return;
        }
        delete q;
        edit_log=new RDLog(name,true);
        RDCreateLogTable(RDLog::tableName(name));
        list_log->setServiceName(svcname);
        list_log->setLogName(RDLog::tableName(name));
        list_log->save();
        edit_log->setModifiedDatetime(QDateTime(QDate::currentDate(),
                                                QTime::currentTime()));
        delete edit_log;
        break;

    case -1:
        list_log->clear();
        break;
    }
}