Ejemplo n.º 1
0
void ListCasts::RefreshList()
{
  QString sql;
  RDSqlQuery *q;
  RDListViewItem *item;

  list_casts_view->clear();
  sql=QString().sprintf("select ID from PODCASTS %s \
                         order by ORIGIN_DATETIME",
       (const char *)RDCastSearch(list_feed_id,list_filter_edit->text(),
				  list_unexpired_check->isChecked(),
				  list_active_check->isChecked()));
  q=new RDSqlQuery(sql);
  while (q->next()) {
    item=new RDListViewItem(list_casts_view);
    item->setId(q->value(0).toInt());
    RefreshItem(item);
  }
  delete q;
}
void MainWidget::RefreshItem(RDListViewItem *item)
{
  RDSqlQuery *q;
  RDSqlQuery *q1;
  QString sql;
  int active=0;
  int total=0;

  sql=QString().sprintf("select CHANNEL_TITLE,CHANNEL_DESCRIPTION,ID \
                         from FEEDS where KEY_NAME=\"%s\"",
			(const char *)item->text(1));
  q=new RDSqlQuery(sql);
  while(q->next()) {
    sql=QString().sprintf("select STATUS from PODCASTS where FEED_ID=%u",
			  q->value(2).toUInt());
    q1=new RDSqlQuery(sql);
    while(q1->next()) {
      total++;
      switch((RDPodcast::Status)q1->value(0).toUInt()) {
	case RDPodcast::StatusActive:
	case RDPodcast::StatusExpired:
	  active++;
	  break;

	case RDPodcast::StatusPending:
	  break;
      }
    }
    delete q1;
    if(active==total) {
      item->setPixmap(0,*cast_greencheckmark_map);
    }
    else {
      item->setPixmap(0,*cast_redx_map);
    }
    item->setText(2,q->value(0).toString());
    item->setText(3,q->value(1).toString());
    item->setText(4,QString().sprintf("%d / %d",active,total));
  }
  delete q;
}
Ejemplo n.º 3
0
void MainWidget::RefreshEventsList()
{
  QString sql;
  RDSqlQuery *q;

  sql=QString("select EVENT_DATETIME,NUMBER,EDGE from GPIO_EVENTS where ")+
    "(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
    QString().sprintf("(MATRIX=%d)&&",gpi_matrix_box->currentItem())+
    QString().sprintf("(TYPE=%d)&&",gpi_type_box->currentItem())+
    "(EVENT_DATETIME>=\""+gpi_events_date_edit->date().toString("yyyy-MM-dd")+
    " 00:00:00\")&&"+
    "(EVENT_DATETIME<\""+gpi_events_date_edit->date().addDays(1).
    toString("yyyy-MM-dd")+" 00:00:00\")";
  if(gpi_events_state_box->currentItem()==0) {
    sql+="&&(EDGE=1)";
  }
  if(gpi_events_state_box->currentItem()==1) {
    sql+="&&(EDGE=0)";
  }
  q=new RDSqlQuery(sql);
  gpi_events_list->clear();
  RDListViewItem *item=NULL;
  while(q->next()) {
    item=new RDListViewItem(gpi_events_list);
    item->setText(0,q->value(0).toDateTime().toString("hh:mm:ss"));
    item->setText(1,QString().sprintf("%d",q->value(1).toInt()));
    if(q->value(2).toInt()==0) {
      item->setText(2,tr("Off"));
      item->setTextColor(Qt::darkRed);
    }
    else {
      item->setText(2,tr("On"));
      item->setTextColor(Qt::darkGreen);
    }
  }
  if(gpi_scroll_mode&&(item!=NULL)) {
    gpi_events_list->ensureItemVisible(item);
  }
  delete q;
}
Ejemplo n.º 4
0
void ListReplicatorCarts::RefreshList()
{
  QString sql;
  RDSqlQuery *q;
  RDListViewItem *item;

  list_view->clear();
  sql=QString("select ")+
    "REPL_CART_STATE.ID,"+
    "CART.TYPE,"+
    "REPL_CART_STATE.CART_NUMBER,"+
    "CART.TITLE,"+
    "REPL_CART_STATE.ITEM_DATETIME,"+
    "REPL_CART_STATE.POSTED_FILENAME "+
    "from REPL_CART_STATE left join CART "+
    "on REPL_CART_STATE.CART_NUMBER=CART.NUMBER where "+
    "REPLICATOR_NAME=\""+RDEscapeString(list_replicator_name)+"\"";
  q=new RDSqlQuery(sql);
  while (q->next()) {
    item=new RDListViewItem(list_view);
    item->setId(q->value(0).toInt());
    item->setText(1,QString().sprintf("%06u",q->value(2).toUInt()));
    switch((RDCart::Type)q->value(1).toInt()) {
    case RDCart::Audio:
      item->setPixmap(0,*list_playout_map);
      break;

    case RDCart::Macro:
      item->setPixmap(0,*list_macro_map);
      break;

    case RDCart::All:
      break;
    }
    item->setText(2,q->value(3).toString());
    item->setText(3,q->value(4).toDateTime().toString("hh:mm:ss dd/MM/yyyy"));
    item->setText(4,q->value(5).toString());
  }
  delete q;
}
Ejemplo n.º 5
0
void RDCutDialog::RefreshCuts()

{
  QString sql;
  RDSqlQuery *q;
  Q3ListViewItem *l;
  Q3ListViewItem *cart_item=cut_cart_list->selectedItem();

  cut_cut_list->clear();
  if(cart_item==NULL) {
    return;
  }
  sql=QString().sprintf("select DESCRIPTION,CUT_NAME from CUTS where \
                         CART_NUMBER=%s",(const char *)cart_item->text(1));
  q=new RDSqlQuery(sql);
  while(q->next()) {
    l=new Q3ListViewItem(cut_cut_list);
    l->setText(0,q->value(0).toString());     // Description
    l->setText(1,QString().sprintf("%03u",    // Cut Number
				   q->value(1).toString().right(3).toUInt()));
  }
  delete q;
}
Ejemplo n.º 6
0
void ListUsers::RefreshList()
{
  QString sql;
  RDSqlQuery *q;
  RDListViewItem *item;

  list_users_view->clear();
  sql="select ADMIN_CONFIG_PRIV,LOGIN_NAME,FULL_NAME,DESCRIPTION from USERS";
  q=new RDSqlQuery(sql);
  while (q->next()) {
    item=new RDListViewItem(list_users_view);
    if(q->value(0).toString()=="Y") {
      item->setPixmap(0,*list_admin_map);
    }
    else {
      item->setPixmap(0,*list_user_map);
    }
    item->setText(1,q->value(1).toString());
    item->setText(2,q->value(2).toString());
    item->setText(3,q->value(3).toString());
  }
  delete q;
}
Ejemplo n.º 7
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)&&",edit_swmatrix_box->currentData().toInt())+
    "(NAME!=\"\")";
  q=new RDSqlQuery(sql);
  while(q->next()) {
    edit_swoutput_box->insertItem(q->value(0).toString());
  }
  delete q;
}
Ejemplo n.º 8
0
void EditClock::RefreshNames()
{
  QString sql;
  RDSqlQuery *q;
  RDEventLine *eventline=NULL;
  RDListViewItem *item=(RDListViewItem *)edit_clocks_list->firstChild();
  while(item!=NULL) {
    if(!item->text(4).isEmpty()) {
      if((eventline=edit_clock->eventLine(item->text(4).toInt()))!=NULL) {
	sql=QString().sprintf("select PROPERTIES from EVENTS\
                               where NAME=\"%s\"",
			      (const char *)RDEscapeString(eventline->name()));
	q=new RDSqlQuery(sql);
	if(q->next()) {
	  item->
	    setText(2,QString().sprintf("%s [%s]",
					(const char *)eventline->name(),
					(const char *)q->value(0).toString()));
	}
	delete q;
      }
    }
    item=(RDListViewItem *)item->nextSibling();
  }
void ListReplicatorCarts::refreshTimeoutData()
{
  QString sql;
  RDSqlQuery *q;
  RDListViewItem *item;

  sql=QString().sprintf("select ID,ITEM_DATETIME from REPL_CART_STATE \
                         where REPLICATOR_NAME=\"%s\"",
			(const char *)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);
}
Ejemplo n.º 10
0
void RDCutDialog::RefreshCarts()
{
  QString sql;
  RDSqlQuery *q;
  RDListViewItem *l;
  QString group=cut_group_box->currentText();

  if(!cut_cutname->isEmpty()) {
  }
  cut_cart_list->clear();
  if(group==QString(tr("ALL"))) {
    group="";
  }
  QString schedcode="";
  if(cut_schedcode_box->currentText()!=tr("ALL")) {
    schedcode=cut_schedcode_box->currentText();
  }
  sql=QString().sprintf("select CART.NUMBER,CART.TITLE,CART.GROUP_NAME,\
                         GROUPS.COLOR,CART.TYPE from CART left join GROUPS \
                         on CART.GROUP_NAME=GROUPS.NAME \
                         %s&&(CART.TYPE=%u)",
			(const char *)RDCartSearchText(cut_filter_edit->text(),
						       group,schedcode.utf8(),
						       false),
			RDCart::Audio);
  if(cut_exclude_tracks) {
    sql+="&&(CART.OWNER is null)";
  }
  if(cart_limit_box->isChecked()) {
    sql+=QString().sprintf(" limit %d",RD_LIMITED_CART_SEARCH_QUANTITY);
  }
  q=new RDSqlQuery(sql);
  int step=0;
  int count=0;
  cut_progress_dialog->setTotalSteps(q->size()/RDCUT_DIALOG_STEP_SIZE);
  cut_progress_dialog->setProgress(0);
  while(q->next()) {
    l=new RDListViewItem(cut_cart_list);
    switch((RDCart::Type)q->value(4).toUInt()) {
    case RDCart::Audio:
      l->setPixmap(0,*cut_playout_map);
      break;

    case RDCart::All:
    case RDCart::Macro:
      break;
    }
    l->setText(1,QString().sprintf("%06u",q->value(0).toUInt()));   // Number

    l->setText(2,q->value(1).toString());     // Title
    l->setText(3,q->value(2).toString());     // Group
    l->setTextColor(3,q->value(3).toString(),QFont::Bold);
    if(count++>RDCUT_DIALOG_STEP_SIZE) {
      cut_progress_dialog->setProgress(++step);
      count=0;
      qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
    }
  }
  cut_progress_dialog->reset();
  delete q;
  cut_search_button->setDisabled(true);
}
Ejemplo n.º 11
0
MainWidget::MainWidget(QWidget *parent,const char *name)
  :QWidget(parent,name)
{
  login_user_width=160;

  QString str;
  QString sql;
  RDSqlQuery *q;

  //
  // HACK: Disable the Broken Custom SuSE Dialogs
  //
  setenv("QT_NO_KDE_INTEGRATION","1",1);

  //
  // Read Command Options
  //
  RDCmdSwitch *cmd=new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdlogin","\n");
  delete cmd;

  //
  // Fix the Window Size
  //
  setMinimumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());
  setMaximumHeight(sizeHint().height());

  //
  // Generate Fonts
  //
  QFont default_font("Helvetica",12,QFont::Normal);
  default_font.setPixelSize(12);
  qApp->setFont(default_font);
  QFont button_font=QFont("Helvetica",12,QFont::Bold);
  button_font.setPixelSize(12);
  QFont label_font=QFont("Helvetica",16,QFont::Bold);
  label_font.setPixelSize(12);
  QFont small_label_font=QFont("Helvetica",12,QFont::Bold);
  small_label_font.setPixelSize(12);
  QFont line_edit_font=QFont("Helvetica",12,QFont::Normal);
  line_edit_font.setPixelSize(12);

  //
  // Create And Set Icon
  //
  login_rivendell_map=new QPixmap(rivendell_xpm);
  setIcon(*login_rivendell_map);

  //
  // Text Validator
  //
  RDTextValidator *validator=new RDTextValidator(this,"validator");

  //
  // Ensure that the system daemons are running
  //
  RDInitializeDaemons();

  //
  // Load Configs
  //
  login_config=new RDConfig();
  login_config->load();

  str=QString(tr("RDLogin - Station:"));
  setCaption(QString().sprintf("%s %s",(const char *)str,
			       (const char *)login_config->stationName()));

  //
  // Open Database
  //
  QString err(tr("rdlogin : "******"Can't Connect"),err);
    exit(0);
  }
  //
  // RIPC Connection
  //
  login_ripc=new RDRipc(login_config->stationName());
  connect(login_ripc,SIGNAL(connected(bool)),this,SLOT(connectedData(bool)));
  connect(login_ripc,SIGNAL(userChanged()),this,SLOT(userData()));
  login_ripc->connectHost("localhost",RIPCD_TCP_PORT,
			  login_config->password());

  //
  // Station
  //
  login_station=new RDStation(login_config->stationName());

  //
  // User Label
  //
  login_label=new QLabel(this,"login_label");
  login_label->setFont(label_font);
  login_label->setAlignment(AlignCenter);
  login_label->setText(tr("Current User: unknown"));

  //
  // User Name
  //
  login_username_box=new QComboBox(this,"login_username_box");
  login_username_box->setFont(line_edit_font);
  login_username_box->setFocus();
  QFontMetrics fm(line_edit_font);
  sql="select LOGIN_NAME from USERS where ADMIN_CONFIG_PRIV=\"N\"\
       order by LOGIN_NAME";
  q=new RDSqlQuery(sql);
  while(q->next()) {
    login_username_box->insertItem(q->value(0).toString());
    if(fm.width(q->value(0).toString())>login_user_width) {
      login_user_width=fm.width(q->value(0).toString());
    }
  }
  delete q;
  if(login_user_width>900) {
    login_user_width=900;
  }
  login_username_label=new QLabel(login_username_box,tr("&Username:"******"login_username_label");
  login_username_label->setFont(small_label_font);
  login_username_label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);

  //
  // Password
  //
  login_password_edit=new QLineEdit(this,"login_password_edit");
  login_password_edit->setFont(line_edit_font);
  login_password_edit->setMaxLength(16);
  login_password_edit->setValidator(validator);
  login_password_edit->setEchoMode(QLineEdit::Password);
  login_password_label=new QLabel(login_password_edit,tr("&Password:"******"login_password_label");
  login_password_label->setFont(small_label_font);
  login_password_label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(login_password_edit,SIGNAL(returnPressed()),this,SLOT(loginData()));

  //
  // Login Button
  //
  login_button=new QPushButton(this,"login_button");
  login_button->setFont(button_font);
  login_button->setText(tr("&Set User"));
  connect(login_button,SIGNAL(clicked()),this,SLOT(loginData()));

  //
  // Logout Button
  //
  logout_button=new QPushButton(this,"logout_button");
  logout_button->setFont(button_font);
  logout_button->setText(tr("&Default\nUser"));
  connect(logout_button,SIGNAL(clicked()),this,SLOT(logoutData()));

  //
  // Cancel Button
  //
  cancel_button=new QPushButton(this,"cancel_button");
  cancel_button->setFont(button_font);
  cancel_button->setText(tr("&Cancel"));
  connect(cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));

  resizeEvent(NULL);
}
Ejemplo n.º 12
0
SchedRulesList::SchedRulesList(QString clockname)
{
  QString sql;
  RDSqlQuery *q;
  RDSqlQuery *q1;

  sql=QString().sprintf("create table if not exists `%s_RULES` (\
      CODE varchar(10) not null primary key,\
      MAX_ROW int unsigned,\
      MIN_WAIT int unsigned,\
      NOT_AFTER varchar(10),\
      OR_AFTER varchar(10),\
      OR_AFTER_II varchar(10))",(const char*)clockname.replace(" ","_")); 

  q=new RDSqlQuery(sql);
  if(!q->isActive()) {
    printf("SQL: %s\n",(const char *)sql);
    printf("SQL Error: %s\n",(const char *)q->lastError().databaseText());
  }
  delete q;

  sql=QString().sprintf("select CODE,DESCRIPTION from SCHED_CODES order by `CODE` asc"); 

  q=new RDSqlQuery(sql);

  itemcounter=q->size();  
  sched_code = new QString[itemcounter];
  max_row = new int[itemcounter];
  min_wait = new int[itemcounter];
  not_after = new QString[itemcounter];
  or_after = new QString[itemcounter];
  or_after_II = new QString[itemcounter];
  description = new QString[itemcounter];
    
  for (int i=0; i<itemcounter; i++){
    q->next();
    sched_code[i] = q->value(0).toString();
    description[i] = q->value(1).toString();
    sql=QString().sprintf("select MAX_ROW,MIN_WAIT,NOT_AFTER,OR_AFTER,OR_AFTER_II from %s_RULES where CODE=\"%s\"",
	(const char *)clockname.replace(" ","_"),(const char *)sched_code[i]);
    q1=new RDSqlQuery(sql);
    if(q1->first())
      {
      max_row[i] = q1->value(0).toInt();
      min_wait[i] = q1->value(1).toInt();
      not_after[i] = q1->value(2).toString();
      or_after[i] = q1->value(3).toString();
      or_after_II[i] = q1->value(3).toString();
      }
    else
      {
      max_row[i] = 1;
      min_wait[i] = 0;
      not_after[i] = "";
      or_after[i] = "";
      or_after_II[i] = "";
      }
    delete q1;
    }
  delete q;
}
Ejemplo n.º 13
0
EditGroup::EditGroup(QString group,QWidget *parent,const char *name)
  : QDialog(parent,name,true)
{
  QString sql;
  RDSqlQuery *q;

  //
  // Fix the Window Size
  //
  setMinimumWidth(sizeHint().width());
  setMaximumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());
  setMaximumHeight(sizeHint().height());

  group_group=new RDGroup(group);

  setCaption(tr("Group: ")+group);

  //
  // Create Fonts
  //
  QFont font=QFont("Helvetica",12,QFont::Bold);
  font.setPixelSize(12);

  //
  // Text Validator
  //
  RDTextValidator *validator=new RDTextValidator(this,"validator");

  //
  // Group Name
  //
  group_name_edit=new QLineEdit(this,"group_name_edit");
  group_name_edit->setGeometry(165,11,100,19);
  group_name_edit->setMaxLength(10);
  group_name_edit->setReadOnly(true);
  QLabel *group_name_label=new QLabel(group_name_edit,tr("&Group Name:"),this,
				       "group_name_label");
  group_name_label->setGeometry(10,11,150,19);
  group_name_label->setFont(font);
  group_name_label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);

  //
  // Group Description
  //
  group_description_edit=new QLineEdit(this,"group_description_edit");
  group_description_edit->setGeometry(165,32,sizeHint().width()-175,19);
  group_description_edit->setMaxLength(255);
  group_description_edit->setValidator(validator);
  QLabel *group_description_label=new QLabel(group_description_edit,
					     tr("Group &Description:"),this,
					     "group_description_label");
  group_description_label->setGeometry(10,32,150,19);
  group_description_label->setFont(font);
  group_description_label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);

  //
  // Default Title
  //
  group_title_edit=new QLineEdit(this,"group_title_edit");
  group_title_edit->setGeometry(165,53,sizeHint().width()-175,19);
  group_title_edit->setMaxLength(255);
  group_title_edit->setValidator(validator);
  QLabel *group_title_label=new QLabel(group_title_edit,
					     tr("Default Import &Title:"),this,
					     "group_title_label");
  group_title_label->setGeometry(10,53,150,19);
  group_title_label->setFont(font);
  group_title_label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);

  //
  // Default Cart Type
  //
  group_carttype_box=new QComboBox(this,"group_carttype_box");
  group_carttype_box->setGeometry(165,74,100,19);
  group_carttype_box->insertItem(tr("Audio"));
  group_carttype_box->insertItem(tr("Macro"));
  QLabel *group_carttype_label=new QLabel(group_carttype_box,
					     tr("Default Cart &Type:"),this,
					     "group_carttype_label");
  group_carttype_label->setGeometry(10,74,150,19);
  group_carttype_label->setFont(font);
  group_carttype_label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);

  //
  // Default Cart Numbers
  //
  group_lowcart_box=new QSpinBox(this,"group_lowcart_box");
  group_lowcart_box->setGeometry(165,95,70,19);
  group_lowcart_box->setRange(0,999999);
  group_lowcart_box->setSpecialValueText(tr("None"));
  QLabel *label=new QLabel(group_lowcart_box,
			   tr("Default Cart Number:"),this,
			   "group_lowcart_label");
  label->setGeometry(10,95,150,19);
  label->setFont(font);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  group_highcart_box=new QSpinBox(this,"group_highcart_box");
  group_highcart_box->setGeometry(265,95,70,19);
  group_highcart_box->setRange(1,999999);
  group_highcart_label=new QLabel(group_highcart_box,
				  tr("to"),this,
				  "group_highcart_label");
  group_highcart_label->setGeometry(240,95,20,19);
  group_highcart_label->setFont(font);
  group_highcart_label->setAlignment(AlignCenter|ShowPrefix);
  connect(group_lowcart_box,SIGNAL(valueChanged(int)),
	  this,SLOT(lowCartChangedData(int)));

  //
  // Enforce Cart Range Checkbox
  //
  group_enforcerange_box=new QCheckBox(this,"group_enforcerange_box");
  group_enforcerange_box->setGeometry(20,118,15,15);
  group_enforcerange_label=
    new QLabel(group_enforcerange_box,tr("Enforce Cart Range"),
	       this,"group_enforcerange_label");
  group_enforcerange_label->setGeometry(40,118,sizeHint().width()-50,19);
  group_enforcerange_label->setFont(font);
  group_enforcerange_label->setAlignment(AlignLeft|AlignVCenter|ShowPrefix);

  //
  // Traffic Report Checkbox
  //
  group_traffic_box=new QCheckBox(this,"group_traffic_box");
  group_traffic_box->setGeometry(20,145,15,15);
  label=
    new QLabel(group_traffic_box,tr("Include this group in Traffic reports"),
	       this,"group_traffic_label");
  label->setGeometry(40,143,sizeHint().width()-50,19);
  label->setFont(font);
  label->setAlignment(AlignLeft|AlignVCenter|ShowPrefix);

  //
  // Music Report Checkbox
  //
  group_music_box=new QCheckBox(this,"group_music_box");
  group_music_box->setGeometry(20,166,15,15);
  label=new QLabel(group_music_box,tr("Include this group in Music reports"),
		   this,"group_music_label");
  label->setGeometry(40,164,sizeHint().width()-50,19);
  label->setFont(font);
  label->setAlignment(AlignLeft|AlignVCenter|ShowPrefix);

  //
  // Cut Autopurging
  //
  group_shelflife_box=new QCheckBox(this,"group_shelflife_box");
  group_shelflife_box->setGeometry(20,193,15,15);
  connect(group_shelflife_box,SIGNAL(toggled(bool)),
	  this,SLOT(purgeEnabledData(bool)));
  group_shelflife_spin=new QSpinBox(this,"group_shelflife_spin");
  group_shelflife_spin->setGeometry(200,191,40,19);
  group_shelflife_spin->setRange(0,30);
  group_shelflife_label=
    new QLabel(group_shelflife_box,tr("Purge expired cuts after"),
	       this,"group_shelflife_label");
  group_shelflife_label->setGeometry(40,193,160,19);
  group_shelflife_label->setFont(font);
  group_shelflife_label->setAlignment(AlignLeft|AlignVCenter|ShowPrefix);
  group_shelflife_unit=
    new QLabel(group_shelflife_box,tr("days"),this,"group_shelflife_unit");
  group_shelflife_unit->setGeometry(250,193,50,19);
  group_shelflife_unit->setFont(font);
  group_shelflife_unit->setAlignment(AlignLeft|AlignVCenter|ShowPrefix);

  //
  // Now & Next Data Checkbox
  //
  group_nownext_box=new QCheckBox(this,"group_nownext_box");
  group_nownext_box->setGeometry(20,220,15,15);
  label=new QLabel(group_nownext_box,tr("Transmit Now && Next data"),
		   this,"group_nownext_label");
  label->setGeometry(40,219,sizeHint().width()-50,19);
  label->setFont(font);
  label->setAlignment(AlignLeft|AlignVCenter|ShowPrefix);

  //
  // Services Selector
  //
  group_svcs_sel=new RDListSelector(this,"group_svcs_sel");
  group_svcs_sel->setGeometry(10,239,380,130);

  //
  //  Color Button
  //
  group_color_button=new QPushButton(this,"group_colorbutton");
  group_color_button->setGeometry(10,sizeHint().height()-60,80,50);
  group_color_button->setFont(font);
  group_color_button->setText(tr("C&olor"));
  connect(group_color_button,SIGNAL(clicked()),this,SLOT(colorData()));

  //
  //  Ok Button
  //
  QPushButton *ok_button=new QPushButton(this,"ok_button");
  ok_button->setGeometry(sizeHint().width()-180,sizeHint().height()-60,80,50);
  ok_button->setDefault(true);
  ok_button->setFont(font);
  ok_button->setText(tr("&OK"));
  connect(ok_button,SIGNAL(clicked()),this,SLOT(okData()));

  //
  //  Cancel Button
  //
  QPushButton *cancel_button=new QPushButton(this,"cancel_button");
  cancel_button->setGeometry(sizeHint().width()-90,sizeHint().height()-60,
			     80,50);
  cancel_button->setFont(font);
  cancel_button->setText(tr("&Cancel"));
  connect(cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));

  //
  // Populate Fields
  //
  group_name_edit->setText(group_group->name());
  group_description_edit->setText(group_group->description());
  group_title_edit->setText(group_group->defaultTitle());
  group_carttype_box->setCurrentItem(group_group->defaultCartType()-1);
  group_lowcart_box->setValue(group_group->defaultLowCart());
  group_highcart_box->setValue(group_group->defaultHighCart());
  lowCartChangedData(group_group->defaultLowCart());
  group_enforcerange_box->setChecked(group_group->enforceCartRange());
  group_traffic_box->setChecked(group_group->exportReport(RDGroup::Traffic));
  group_music_box->setChecked(group_group->exportReport(RDGroup::Music));
  if(group_group->cutShelflife()>=0) {
    group_shelflife_spin->setValue(group_group->cutShelflife());
    group_shelflife_box->setChecked(true);
  }
  purgeEnabledData(group_shelflife_box->isChecked());
  group_nownext_box->setChecked(group_group->enableNowNext());
  sql=QString().sprintf("select SERVICE_NAME from AUDIO_PERMS \
                         where GROUP_NAME=\"%s\"",
			(const char *)group_group->name());
  q=new RDSqlQuery(sql);
  while(q->next()) {
    group_svcs_sel->destInsertItem(q->value(0).toString());
  }
  delete q;

  sql=QString().sprintf("select NAME from SERVICES");
  q=new RDSqlQuery(sql);
  while(q->next()) {
    if(group_svcs_sel->destFindItem(q->value(0).toString())==0) {
      group_svcs_sel->sourceInsertItem(q->value(0).toString());
    }
  }
  delete q;
  SetButtonColor(group_group->color());
}
Ejemplo n.º 14
0
void Xport::ListCarts()
{
  QString sql;
  RDSqlQuery *q;
  QString where="";
  RDCart *cart;
  QString group_name;
  QString filter;
  int include_cuts;
  RDCart::Type cart_type=RDCart::All;
  QString type;

  //
  // Verify Post
  //
  xport_post->getValue("GROUP_NAME",&group_name);
  xport_post->getValue("FILTER",&filter);
  xport_post->getValue("INCLUDE_CUTS",&include_cuts);
  xport_post->getValue("TYPE",&type);
  if(type.lower()=="audio") {
    cart_type=RDCart::Audio;
  }
  if(type.lower()=="macro") {
    cart_type=RDCart::Macro;
  }

  //
  // Generate Cart List
  //
  if(group_name.isEmpty()||(group_name==tr("ALL"))) {
    where=RDAllCartSearchText(filter,"",rda->user()->name(),false);
  }
  else {
    sql=QString("select GROUP_NAME from USER_PERMS where ")+
      "(GROUP_NAME=\""+RDEscapeString(group_name)+"\")&&"+
      "(USER_NAME=\""+RDEscapeString(rda->user()->name())+"\")";
    q=new RDSqlQuery(sql);
    if(!q->first()) {
      delete q;
      XmlExit("No such group",404);
    }
    where=RDCartSearchText(filter,group_name,"",false);
  }
  if(cart_type!=RDCart::All) {
    where+=QString().sprintf("&&(TYPE=%u)",cart_type);
  }
  sql="select NUMBER from CART where "+where+"order by NUMBER";
  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("<cartList>\n");
  while(q->next()) {
    cart=new RDCart(q->value(0).toUInt());
    printf("%s",(const char *)cart->xml(include_cuts,true));
    delete cart;
  }
  printf("</cartList>\n");
  
  delete q;
  Exit(0);
}
Ejemplo n.º 15
0
void ListReports::GenerateCartReport(QString *report)
{
  QString sql;
  RDSqlQuery *q;
  QString schedcode="";

  if(list_schedcode!=tr("ALL")) {
    schedcode=list_schedcode;
  }

  //
  // Generate Header
  //
  QString filter=list_filter;
  if(list_filter.isEmpty()) {
    filter="[none]";
  }
  *report="                                                        Rivendell Cart Report\n";
  *report+=QString().
    sprintf("Generated: %s     Group: %-10s      Filter: %s\n",
	    (const char *)QDateTime(QDate::currentDate(),QTime::currentTime()).
	    toString("MM/dd/yyyy - hh:mm:ss"),
	    (const char *)list_group.utf8(),(const char *)filter.utf8());
  *report+="\n";
  *report+="Type -Cart- -Group---- -Len- -Title------------------------- -Artist----------------------- Cuts Rot Enf -LenDev -Owner--------------\n";

  //
  // Generate Rows
  //
  if(list_type_filter.isEmpty()) {
    return;
  }
  sql=QString("select CART.TYPE,CART.NUMBER,CART.GROUP_NAME,")+
    "CART.FORCED_LENGTH,CART.TITLE,CART.ARTIST,CART.CUT_QUANTITY,"+
    "CART.PLAY_ORDER,CART.ENFORCE_LENGTH,CART.LENGTH_DEVIATION,CART.OWNER "+
    "from CART left join CUTS on CART.NUMBER=CUTS.CART_NUMBER";
  if(list_group==QString("ALL")) {
    sql+=QString(" where ")+
      RDAllCartSearchText(list_filter,schedcode,lib_user->name(),true)+" && "+
      list_type_filter+" order by NUMBER";
  }
  else {
    sql+=QString(" where ")+
      RDCartSearchText(list_filter,list_group,schedcode,true)+" && "+
      list_type_filter+" order by NUMBER";
  }
  q=new RDSqlQuery(sql);
  while(q->next()) {
    //
    // Cart Type
    //
    switch((RDCart::Type)q->value(0).toInt()) {
	case RDCart::Audio:
	  *report+="  A  ";
	  break;

	case RDCart::Macro:
	  *report+="  M  ";
	  break;

	default:
	  *report+="  ?  ";
	  break;
    }

    //
    // Cart Number
    //
    *report+=QString().sprintf("%06u ",q->value(1).toUInt());

    //
    // Group
    //
    *report+=
      QString().sprintf("%-10s ",(const char *)q->value(2).toString().utf8());

    //
    // Length
    //
    *report+=
      QString().sprintf("%5s ",
	       (const char *)RDGetTimeLength(q->value(3).toInt(),false,false));

    //
    // Title
    //
    *report+=QString().sprintf("%-31s ",(const char *)q->value(4).toString().
			       utf8().left(31));

    //
    // Artist
    //
    *report+=QString().sprintf("%-30s ",(const char *)q->value(5).toString().
			       utf8().left(30));

    //
    // Cut Quantity
    //
    *report+=QString().sprintf("%4d ",q->value(6).toInt());

    //
    // Play Order
    //
    switch((RDCart::PlayOrder)q->value(7).toInt()) {
	case RDCart::Sequence:
	  *report+="SEQ ";
	  break;

	case RDCart::Random:
	  *report+="RND ";
	  break;

	default:
	  *report+="???";
	  break;
    }

    //
    // Enforce Length
    //
    if(q->value(8).toString()=="Y") {
      *report+="Yes ";
    }
    else {
      *report+="No  ";
    }

    //
    // Length Deviation
    //
    *report+=
      QString().sprintf("%7s ",
	       (const char *)RDGetTimeLength(q->value(9).toInt(),false,true));

    //
    // Owner
    //
    if(q->value(10).toString().isEmpty()) {
      *report+="[none]";
    }
    else {
      *report+=QString().sprintf("%s",(const char *)q->value(10).toString().
				 utf8().left(20));
    }

    //
    // End of Line
    //
    *report+="\n";
  }
  delete q;
}
Ejemplo n.º 16
0
void ListReports::GenerateCartDumpFixed(QString *report,bool prepend_names)
{
  QString sql;
  RDSqlQuery *q;
  QString schedcode="";

  if(list_schedcode!=tr("ALL")) {
    schedcode=list_schedcode;
  }

  //
  // Prepend Field Names
  //
  if(prepend_names) {
    *report="CART  |";
    *report+="CUT|";
    *report+="GROUP_NAME|";
    *report+="TITLE                                                                                                                                                                                                                                                          |";
    *report+="ARTIST                                                                                                                                                                                                                                                         |";
    *report+="ALBUM                                                                                                                                                                                                                                                          |";
    *report+="YEAR|";
    *report+="ISRC        |";
    *report+="LABEL                                                           |";
    *report+="CLIENT                                                          |";
    *report+="AGENCY                                                          |";
    *report+="PUBLISHER                                                       |";
    *report+="COMPOSER                                                        |";
    *report+="USER_DEFINED                                                                                                                                                                                                                                                   |";
    *report+="LENGTH   |\n";
  }

  //
  // Generate Rows
  //
  if(list_type_filter.isEmpty()) {
    return;
  }
  sql="select CUTS.CUT_NAME,CART.GROUP_NAME,CART.TITLE,CART.ARTIST,CART.ALBUM,\
       CART.YEAR,CUTS.ISRC,CART.LABEL,CART.CLIENT,CART.AGENCY,CART.PUBLISHER,\
       CART.COMPOSER,CART.USER_DEFINED,CUTS.LENGTH from CART \
       join CUTS on CART.NUMBER=CUTS.CART_NUMBER";
  if(list_group==QString("ALL")) {
    sql+=QString(" where ")+
      RDAllCartSearchText(list_filter,schedcode,lib_user->name(),true)+" && "+
      list_type_filter+" order by CUTS.CUT_NAME";
  }
  else {
    sql+=QString(" where ")+
      RDCartSearchText(list_filter,list_group,schedcode,true)+" && "+
      list_type_filter+" order by CUTS.CUT_NAME";
  }
  q=new RDSqlQuery(sql);
  while(q->next()) {
    //
    // Cart Number
    //
    *report+=QString().sprintf("%-6s|",(const char *)q->value(0).toString().
			       utf8().left(6));

    //
    // Cut Number
    //
    *report+=
      QString().sprintf("%-3s|",(const char *)q->value(0).toString().right(3));

    //
    // Group Name
    //
    *report+=QString().sprintf("%-10s|",(const char *)q->value(1).toString().
			       utf8());

    //
    // Title
    //
    *report+=QString().sprintf("%-255s|",(const char *)q->value(2).toString().
			       utf8());

    //
    // Artist
    //
    *report+=QString().sprintf("%-255s|",(const char *)q->value(3).toString().
			       utf8());

    //
    // Album
    //
    *report+=QString().sprintf("%-255s|",(const char *)q->value(4).toString().
			       utf8());

    //
    // Year
    //
    if(q->value(5).toDate().isNull()) {
      *report+="    |";
    }
    else {
      *report+=QString().sprintf("%4d|",q->value(5).toDate().year());
    }

    //
    // ISRC
    //
    *report+=QString().sprintf("%-12s|",(const char *)q->value(6).toString().
			       utf8());

    //
    // Label
    //
    *report+=QString().sprintf("%-64s|",(const char *)q->value(7).toString().
			       utf8());

    //
    // Client
    //
    *report+=QString().sprintf("%-64s|",(const char *)q->value(8).toString().
			       utf8());

    //
    // Agency
    //
    *report+=QString().sprintf("%-64s|",(const char *)q->value(9).toString().
			       utf8());

    //
    // Publisher
    //
    *report+=QString().sprintf("%-64s|",(const char *)q->value(10).toString().
			       utf8());

    //
    // Composer
    //
    *report+=QString().sprintf("%-64s|",(const char *)q->value(11).toString().
			       utf8());

    //
    // User Defined
    //
    *report+=QString().sprintf("%-255s|",(const char *)q->value(12).toString().
			       utf8());

    //
    // Length
    //
    *report+=QString().sprintf("%9s|",
	     (const char *)RDGetTimeLength(q->value(13).toInt(),true,true));

    //
    // End of Line
    //
    *report+="\n";
  }

  delete q;
}
Ejemplo n.º 17
0
bool RDReport::ExportRadioTraffic(const QDate &startdate,const QDate &enddate,
				  const QString &mixtable)
{
  QString sql;
  RDSqlQuery *q;
  FILE *f;
  QString air_fmt;

#ifdef WIN32
  QString filename=RDDateDecode(exportPath(RDReport::Windows),startdate);
#else
  QString filename=RDDateDecode(exportPath(RDReport::Linux),startdate);
#endif

  QFile file(filename);
  if((f=fopen((const char *)filename,"w"))==NULL) {
    report_error_code=RDReport::ErrorCantOpen;
    return false;
  }

  if(useLeadingZeros()) {
    air_fmt=QString().sprintf("%%0%uu ",cartDigits());
  }
  else {
    air_fmt=QString().sprintf("%%%-uu ",cartDigits());
  }
  sql=QString().sprintf("select `%s_SRT`.LENGTH,`%s_SRT`.CART_NUMBER,\
                         `%s_SRT`.EVENT_DATETIME,`%s_SRT`.EVENT_TYPE,\
                         `%s_SRT`.EXT_START_TIME,`%s_SRT`.EXT_LENGTH,\
                         `%s_SRT`.EXT_DATA,`%s_SRT`.EXT_EVENT_ID,\
                         `%s_SRT`.EXT_ANNC_TYPE,`%s_SRT`.TITLE,\
                         `%s_SRT`.EXT_CART_NAME from `%s_SRT` \
                         left join CART on\
                         `%s_SRT`.CART_NUMBER=CART.NUMBER\
                         order by EVENT_DATETIME",
			(const char *)mixtable,
			(const char *)mixtable,
			(const char *)mixtable,
			(const char *)mixtable,
			(const char *)mixtable,
			(const char *)mixtable,
			(const char *)mixtable,
			(const char *)mixtable,
			(const char *)mixtable,
			(const char *)mixtable,
			(const char *)mixtable,
			(const char *)mixtable,
			(const char *)mixtable);

  q=new RDSqlQuery(sql);

  //
  // Write Data Rows
  //
  while(q->next()) {
    fprintf(f,"%s ",(const char *)q->value(4).toTime().toString("hh:mm:ss"));
    fprintf(f,"%s ",(const char *)q->value(2).toDateTime().
	    toString("hh:mm:ss"));
    if(q->value(5).toInt()>0) {
      fprintf(f,"0%s ",(const char *)RDGetTimeLength(q->value(5).toInt(),
						     true,false));
    }
    else {
      fprintf(f,"00:00:00 ");
    }
    if(q->value(0).toInt()>0) {
      fprintf(f,"0%s ",(const char *)RDGetTimeLength(q->value(0).toInt(),
						     true,false));
    }
    else {
      fprintf(f,"00:00:00 ");
    }
    fprintf(f,air_fmt,q->value(1).toUInt());
    fprintf(f,"%-34s ",(const char *)q->value(9).toString().left(34));
    if(q->value(6).toString().isEmpty()) {
      fprintf(f,"                                ");
    }
    else {
      fprintf(f,"%-32s",(const char *)q->value(6).toString().left(32).
	      stripWhiteSpace());
    }
    fprintf(f,"\r\n");
  }

  delete q;
  fclose(f);
  report_error_code=RDReport::ErrorOk;

  return true;
}
Ejemplo n.º 18
0
EditUserPerms::EditUserPerms(RDUser *user,QWidget *parent)
  : QDialog(parent)
{
  QString sql;
  RDSqlQuery *q;

  user_user=user;

  //
  // Fix the Window Size
  //
  setMinimumSize(sizeHint());
  setMaximumSize(sizeHint());

  setWindowTitle("RDAdmin - "+tr("User: "******"Helvetica",12,QFont::Bold);
  font.setPixelSize(12);

  //
  // Groups Selector
  //
  user_host_sel=new RDListSelector(this);
  user_host_sel->sourceSetLabel(tr("Available Groups"));
  user_host_sel->destSetLabel(tr("Enabled Groups"));
  user_host_sel->setGeometry(10,10,380,130);

  //
  //  Ok Button
  //
  QPushButton *ok_button=new QPushButton(this);
  ok_button->setGeometry(sizeHint().width()-180,sizeHint().height()-60,80,50);
  ok_button->setDefault(true);
  ok_button->setFont(font);
  ok_button->setText(tr("&OK"));
  connect(ok_button,SIGNAL(clicked()),this,SLOT(okData()));

  //
  //  Cancel Button
  //
  QPushButton *cancel_button=new QPushButton(this);
  cancel_button->setGeometry(sizeHint().width()-90,sizeHint().height()-60,
			     80,50);
  cancel_button->setFont(font);
  cancel_button->setText(tr("&Cancel"));
  connect(cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));

  //
  // Populate Fields
  //
  sql=QString("select GROUP_NAME from USER_PERMS where ")+
    "USER_NAME=\""+RDEscapeString(user_user->name())+"\"";
  q=new RDSqlQuery(sql);
  while(q->next()) {
    user_host_sel->destInsertItem(q->value(0).toString());
  }
  delete q;

  sql=QString().sprintf("select NAME from GROUPS");
  q=new RDSqlQuery(sql);
  while(q->next()) {
    if(user_host_sel->destFindItem(q->value(0).toString())==0) {
      user_host_sel->sourceInsertItem(q->value(0).toString());
    }
  }
  delete q;
}
Ejemplo n.º 19
0
MainObject::MainObject(QObject *parent,const char *name)
  : QObject(parent,name)
{
  bool found=false;
  QString src_hostname;
  QString dest_hostname;
  QString src_station;
  QString dest_station;
  QString sql;
  RDSqlQuery *q;
  RDSqlQuery *q1;

  //
  // Read Command Options
  //
  RDCmdSwitch *cmd=
    new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdcatch_copy",
		    RDCATCH_COPY_USAGE);
  delete cmd;

  rd_config=new RDConfig(RD_CONF_FILE);
  rd_config->load();

  //
  // Read Switches
  //
  for(int i=1;i<qApp->argc();i+=2) {
    found=false;
    if(QString(qApp->argv()[i])=="-h") {  // Source mySQL Hostname
      if((i+1)==qApp->argc()) {
	fprintf(stderr,"rdcatch_copy: invalid argument\n");
	exit(256);
      }
      src_hostname=qApp->argv()[i+1];
      found=true;
    }
    if(QString(qApp->argv()[i])=="-s") {  // Source Rivendell Host
      if((i+1)==qApp->argc()) {
	fprintf(stderr,"rdcatch_copy: invalid argument\n");
	exit(256);
      }
      src_station=qApp->argv()[i+1];
      found=true;
    }
    if(QString(qApp->argv()[i])=="-H") {  // Source mySQL Hostname
      if((i+1)==qApp->argc()) {
	fprintf(stderr,"rdcatch_copy: invalid argument\n");
	exit(256);
      }
      dest_hostname=qApp->argv()[i+1];
      found=true;
    }
    if(QString(qApp->argv()[i])=="-S") {  // Source Rivendell Host
      if((i+1)==qApp->argc()) {
	fprintf(stderr,"rdcatch_copy: invalid argument\n");
	exit(256);
      }
      dest_station=qApp->argv()[i+1];
      found=true;
    }
    if(!found) {
      fprintf(stderr,"rdcatch_copy: invalid argument\n");
      exit(256);
    }
  }

  if(src_hostname.isEmpty()) {
    fprintf(stderr,"rdcatch_copy: invalid source mySQL hostname\n");
    exit(256);
  }
  if(src_station.isEmpty()) {
    fprintf(stderr,"rdcatch_copy: invalid source Rivendell host\n");
    exit(256);
  }
  if(dest_hostname.isEmpty()) {
    fprintf(stderr,"rdcatch_copy: invalid destination mySQL hostname\n");
    exit(256);
  }
  if(dest_station.isEmpty()) {
    fprintf(stderr,"rdcatch_copy: invalid destination Rivendell host\n");
    exit(256);
  }

  //
  // Open Databases
  //
  src_db=QSqlDatabase::addDatabase("QMYSQL3");
  if(!src_db) {
    fprintf(stderr,"rdcatch_copy: can't open source mySQL database\n");
    exit(1);
  }
  src_db->setDatabaseName(rd_config->mysqlDbname());
  src_db->setUserName(rd_config->mysqlUsername());
  src_db->setPassword(rd_config->mysqlPassword());
  src_db->setHostName(src_hostname);
  if(!src_db->open()) {
    fprintf(stderr,"rdcatch_copy: unable to connect to source mySQL server\n");
    src_db->removeDatabase(rd_config->mysqlDbname());
    exit(256);
  }

  if(src_hostname==dest_hostname) {
    if(src_station==dest_station) {
      fprintf(stderr,"rdcatch_copy: cannot copy a host configuration onto itself\n");
      exit(256);
    }
    else {
      dest_db=src_db;
    }
  }
  else {
    dest_db=QSqlDatabase::addDatabase("QMYSQL3");
    if(!dest_db) {
      fprintf(stderr,"rdcatch_copy: can't open destination mySQL database\n");
      exit(1);
    }
    dest_db->setDatabaseName(rd_config->mysqlDbname());
    dest_db->setUserName(rd_config->mysqlUsername());
    dest_db->setPassword(rd_config->mysqlPassword());
    dest_db->setHostName(dest_hostname);
    if(!dest_db->open()) {
      fprintf(stderr,
	      "rdcatch_copy: unable to connect to destination mySQL server\n");
      dest_db->removeDatabase(rd_config->mysqlDbname());
      exit(256);
    }
  }

  //
  // Check Database Versions
  //
  sql="select DB from VERSION";
  q=new RDSqlQuery(sql,src_db);
  if(!q->first()) {
    fprintf(stderr,
	    "rdcatch_copy: unable to read source database version\n");
    exit(256);
  }
  if(q->value(0).toInt()!=RD_VERSION_DATABASE) {
    fprintf(stderr,"rdcatch_copy: source database version mismatch\n");
    exit(256);
  }
  delete q;

  q=new RDSqlQuery(sql,dest_db);
  if(!q->first()) {
    fprintf(stderr,
	    "rdcatch_copy: unable to read destination database version\n");
    exit(256);
  }
  if(q->value(0).toInt()!=RD_VERSION_DATABASE) {
    fprintf(stderr,"rdcatch_copy: destination database version mismatch\n");
    exit(256);
  }
  delete q;

  //
  // Check Rivendell Hosts
  //
  sql=QString().sprintf("select NAME from STATIONS where NAME=\"%s\"",
			(const char *)src_station);
  q=new RDSqlQuery(sql,src_db);
  if(!q->first()) {
    fprintf(stderr,
	    "rdcatch_copy: source Rivendell host doesn't exist\n");
    exit(256);
  }
  delete q;

  sql=QString().sprintf("select NAME from STATIONS where NAME=\"%s\"",
			(const char *)dest_station);
  q=new RDSqlQuery(sql,dest_db);
  if(!q->first()) {
    fprintf(stderr,
	    "rdcatch_copy: destination Rivendell host doesn't exist\n");
    exit(256);
  }
  delete q;

  //
  // Confirmation Prompt
  //
  printf("\n");
  printf("****** WARNING ******\n");
  printf(" This operation will OVERWRITE ALL RDCATCH EVENTS on the destination Host!");
  printf(" Press RETURN to continue, or CNTL-C to abort.");
  printf("\n");
  while(getchar()!=10);
  printf("Copying events...");
  fflush(stdout);

  //
  // Delete current destination entries
  //
  sql=QString().sprintf("delete from RECORDINGS where STATION_NAME\"%s\"",
			(const char *)dest_station);
  q=new RDSqlQuery(sql,dest_db);
  delete q;

  //
  // Copy Entries
  //
  sql=QString().sprintf("select IS_ACTIVE,TYPE,CHANNEL,CUT_NAME,SUN,MON,TUE,\
                         WED,THU,FRI,SAT,DESCRIPTION,START_TYPE,START_TIME,\
                         START_LENGTH,START_MATRIX,START_LINE,START_OFFSET,\
                         END_TYPE,END_TIME,END_LENGTH,END_MATRIX,END_LINE,\
                         LENGTH,TRIM_THRESHOLD,NORMALIZE_LEVEL,\
                         STARTDATE_OFFSET,ENDDATE_OFFSET,FORMAT,CHANNELS,\
                         SAMPRATE,BITRATE,QUALITY,MACRO_CART,SWITCH_INPUT,\
                         SWITCH_OUTPUT,EXIT_CODE,ONE_SHOT,URL,URL_USERNAME,\
                         URL_PASSWORD from RECORDINGS\
                         where STATION_NAME=\"%s\"",
			(const char *)src_station);
  q=new RDSqlQuery(sql,src_db);
  while(q->next()) {
    sql=QString().sprintf("insert into RECORDINGS set IS_ACTIVE=\"%s\",\
                           TYPE=%d,CHANNEL=%u,CUT_NAME=\"%s\",SUN=\"%s\",\
                           MON=\"%s\",TUE=\"%s\",WED=\"%s\",THU=\"%s\",\
                           FRI=\"%s\",SAT=\"%s\",DESCRIPTION=\"%s\",\
                           START_TYPE=%d,START_TIME=\"%s\",START_LENGTH=%d,\
                           START_MATRIX=%d,START_LINE=%d,START_OFFSET=%d,\
                           END_TYPE=%d,END_TIME=\"%s\",END_LENGTH=%d,\
                           END_MATRIX=%d,END_LINE=%d,LENGTH=%u,\
                           TRIM_THRESHOLD=%d,NORMALIZE_LEVEL=%d,\
                           STARTDATE_OFFSET=%u,ENDDATE_OFFSET=%u,FORMAT=%d,\
                           CHANNELS=%d,SAMPRATE=%d,BITRATE=%d,QUALITY=%d,\
                           MACRO_CART=%d,SWITCH_INPUT=%d,SWITCH_OUTPUT=%d,\
                           EXIT_CODE=%d,ONE_SHOT=\"%s\",URL=\"%s\",\
                           URL_USERNAME=\"%s\",URL_PASSWORD=\"%s\",\
                           STATION_NAME=\"%s\"",
			  (const char *)q->value(0).toString(),

			  q->value(1).toInt(),q->value(2).toUInt(),
			  (const char *)q->value(3).toString(),
			  (const char *)q->value(4).toString(),

			  (const char *)q->value(5).toString(),
			  (const char *)q->value(6).toString(),
			  (const char *)q->value(7).toString(),
			  (const char *)q->value(8).toString(),
			  
			  (const char *)q->value(9).toString(),
			  (const char *)q->value(10).toString(),
			  (const char *)q->value(11).toString(),

			  q->value(12).toInt(),
			  (const char *)q->value(13).toString(),
			  q->value(14).toInt(),

			  q->value(15).toInt(),
			  q->value(16).toInt(),
			  q->value(17).toInt(),

			  q->value(18).toInt(),
			  (const char *)q->value(19).toString(),
			  q->value(20).toInt(),

			  q->value(21).toInt(),
			  q->value(22).toInt(),
			  q->value(23).toUInt(),

			  q->value(24).toInt(),
			  q->value(25).toInt(),

			  q->value(26).toUInt(),
			  q->value(27).toUInt(),
			  q->value(28).toInt(),

			  q->value(29).toInt(),
			  q->value(30).toInt(),
			  q->value(31).toInt(),
			  q->value(32).toInt(),

			  q->value(33).toInt(),
			  q->value(34).toInt(),
			  q->value(35).toInt(),

			  q->value(36).toInt(),
			  (const char *)q->value(37).toString(),
			  (const char *)q->value(38).toString(),

			  (const char *)q->value(39).toString(),
			  (const char *)q->value(40).toString(),
			  (const char *)dest_station);
    q1=new RDSqlQuery(sql,dest_db);
    delete q1;
  }
  delete q;

  printf("done.\n");
  exit(0);
}
Ejemplo n.º 20
0
EditSvc::EditSvc(QString svc,QWidget *parent)
  : QDialog(parent,"",true)
{
  QString sql;
  RDSqlQuery *q;
  QString group;
  QString autospot;

  //
  // Fix the Window Size
  //
  setMinimumWidth(sizeHint().width());
  setMaximumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());
  setMaximumHeight(sizeHint().height());

  svc_svc=new RDSvc(svc);

  setCaption(tr("Edit Service"));

  //
  // Create Fonts
  //
  QFont font=QFont("Helvetica",12,QFont::Bold);
  font.setPixelSize(12);
  QFont section_font=QFont("Helvetica",14,QFont::Bold);
  section_font.setPixelSize(14);

  //
  // Text Validators
  //
  RDTextValidator *validator=new RDTextValidator(this);
  RDIdValidator *log_validator=new RDIdValidator(this);
  log_validator->addBannedChar(' ');

  //
  // General Section
  //
  QLabel *label=new QLabel("General",this);
  label->setGeometry(10,10,120,24);
  label->setFont(section_font);
  label->setAlignment(AlignLeft);

  //
  // Service Name
  //
  svc_name_edit=new QLineEdit(this);
  svc_name_edit->setGeometry(185,31,80,19);
  svc_name_edit->setMaxLength(10);
  svc_name_edit->setReadOnly(true);
  label=new QLabel(svc_name_edit,tr("&Service Name:"),this);
  label->setGeometry(10,33,170,19);
  label->setAlignment(AlignRight|ShowPrefix);

  //
  // Service Description
  //
  svc_description_edit=new QLineEdit(this);
  svc_description_edit->setGeometry(185,52,240,19);
  svc_description_edit->setMaxLength(255);
  svc_description_edit->setValidator(validator);
  label=new QLabel(svc_description_edit,tr("Service &Description:"),this);
  label->setGeometry(10,54,170,19);
  label->setAlignment(AlignRight|ShowPrefix);

  //
  // Service Program Code
  //
  svc_program_code_edit=new QLineEdit(this);
  svc_program_code_edit->setGeometry(185,73,240,19);
  svc_program_code_edit->setMaxLength(255);
  svc_program_code_edit->setValidator(validator);
  label=new QLabel(svc_program_code_edit,tr("&Program Code:"),this);
  label->setGeometry(10,73,170,19);
  label->setAlignment(AlignRight|ShowPrefix);

  //
  // Log Name Template
  //
  svc_name_template_edit=new QLineEdit(this);
  svc_name_template_edit->setGeometry(185,94,240,19);
  svc_name_template_edit->setMaxLength(255);
  svc_name_template_edit->setValidator(log_validator);
  label=new QLabel(svc_name_template_edit,
		   tr("Log Name &Template:"),this);
  label->setGeometry(10,94,170,19);
  label->setAlignment(AlignRight|ShowPrefix);

  //
  // Log Description Template
  //
  svc_description_template_edit=new QLineEdit(this);
  svc_description_template_edit->setGeometry(185,115,240,19);
  svc_description_template_edit->setMaxLength(255);
  label=new QLabel(svc_description_template_edit,
		   tr("Log &Description Template:"),this);
  label->setGeometry(10,115,170,19);
  label->setAlignment(AlignRight|ShowPrefix);

  //
  // Voicetracking Group
  //
  svc_voice_group_box=new QComboBox(this);
  svc_voice_group_box->setGeometry(185,136,240,19);
  svc_voice_group_box->insertItem(tr("[none]"));
  label=new QLabel(svc_voice_group_box,tr("Voicetrack Group:"),this);
  label->setGeometry(10,136,170,19);
  label->setAlignment(AlignRight|ShowPrefix);

  //
  // Autospot Group
  //
  svc_autospot_group_box=new QComboBox(this);
  svc_autospot_group_box->setGeometry(185,157,240,19);
  svc_autospot_group_box->insertItem(tr("[none]"));
  label=new QLabel(svc_autospot_group_box,tr("AutoSpot Group:"),this);
  label->setGeometry(10,157,170,19);
  label->setAlignment(AlignRight|ShowPrefix);

  //
  // Chain Log
  //
  svc_chain_box=new QCheckBox(this);
  svc_chain_box->setGeometry(30,180,15,15);
  label=new QLabel(svc_chain_box,tr("Insert CHAIN TO at log end"),this);
  label->setGeometry(50,180,170,19);
  label->setAlignment(AlignLeft|ShowPrefix);

  //
  // Default Auto Refresh
  //
  svc_autorefresh_box=new QCheckBox(this);
  svc_autorefresh_box->setGeometry(230,180,15,15);
  label=
    new QLabel(svc_autorefresh_box,tr("Enable AutoRefresh By Default"),this);
  label->setGeometry(250,180,200,19);
  label->setAlignment(AlignLeft|ShowPrefix);

  //
  // Autofill Button
  //
  QPushButton *button=new QPushButton(this);
  button->setGeometry(455,31,150,50);
  button->setFont(font);
  button->setText(tr("Configure \n&Autofill Carts"));
  connect(button,SIGNAL(clicked()),this,SLOT(autofillData()));

  //
  // Purge Expired Logs
  //
  svc_loglife_box=new QCheckBox(this);
  svc_loglife_box->setGeometry(460,95,15,15);
  label=new QLabel(svc_loglife_box,tr("Purge Logs after"),this);
  label->setGeometry(480,95,200,19);
  label->setAlignment(AlignLeft|ShowPrefix);
  svc_loglife_spin=new QSpinBox(this);
  svc_loglife_spin->setGeometry(585,93,50,19);
  svc_loglife_spin->setRange(0,365);
  connect(svc_loglife_box,SIGNAL(toggled(bool)),
	  svc_loglife_spin,SLOT(setEnabled(bool)));
  label=new QLabel(svc_loglife_box,tr("days"),
		   this,"svc_loglife_unit");
  label->setGeometry(645,95,40,19);
  label->setAlignment(AlignLeft|ShowPrefix);

  //
  // Purge Expired ELR Data
  //
  svc_shelflife_box=new QCheckBox(this);
  svc_shelflife_box->setGeometry(460,117,15,15);
  label=new QLabel(svc_shelflife_box,tr("Purge ELR Data after"),this);
  label->setGeometry(480,117,200,19);
  label->setAlignment(AlignLeft|ShowPrefix);
  svc_shelflife_spin=new QSpinBox(this);
  svc_shelflife_spin->setGeometry(610,115,50,19);
  svc_shelflife_spin->setRange(0,365);
  connect(svc_shelflife_box,SIGNAL(toggled(bool)),
	  svc_shelflife_spin,SLOT(setEnabled(bool)));
  label=new QLabel(svc_shelflife_box,tr("days"),this);
  label->setGeometry(670,117,40,19);
  label->setAlignment(AlignLeft|ShowPrefix);

  //
  // Enable Hosts Button
  //
  button=new QPushButton(this);
  button->setGeometry(625,31,150,50);
  button->setFont(font);
  button->setText(tr("Enable &Hosts"));
  connect(button,SIGNAL(clicked()),this,SLOT(enableHostsData()));



  //
  // Traffic Import Section
  //
  label=new QLabel(tr("Traffic Data Import"),this);
  label->setGeometry(10,213,160,24);
  label->setFont(section_font);
  label->setAlignment(AlignLeft);

  //
  // Linux Traffic Import Path
  //
  svc_tfc_path_edit=new QLineEdit(this);
  svc_tfc_path_edit->setGeometry(185,234,240,19);
  svc_tfc_path_edit->setMaxLength(255);
  svc_tfc_path_edit->setValidator(validator);
  label=new QLabel(svc_tfc_path_edit,tr("Linux Import Path:"),this);
  label->setGeometry(10,234,170,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_tfc_path_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Linux Traffic Preimport Command
  //
  svc_tfc_preimport_cmd_edit=new QLineEdit(this);
  svc_tfc_preimport_cmd_edit->setGeometry(185,255,240,19);
  svc_tfc_preimport_cmd_edit->setValidator(validator);
  label=
    new QLabel(svc_tfc_preimport_cmd_edit,tr("Linux Preimport Command:"),this);
  label->setGeometry(10,255,170,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_tfc_preimport_cmd_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Windows Traffic Import Path
  //
  svc_tfc_win_path_edit=new QLineEdit(this);
  svc_tfc_win_path_edit->setGeometry(185,276,240,19);
  svc_tfc_win_path_edit->setMaxLength(255);
  label=new QLabel(svc_tfc_win_path_edit,tr("Windows Import Path:"),this);
  label->setGeometry(10,276,170,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_tfc_win_path_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Linux Traffic Preimport Command
  //
  svc_tfc_win_preimport_cmd_edit=new QLineEdit(this);
  svc_tfc_win_preimport_cmd_edit->setGeometry(185,297,240,19);
  label=new QLabel(svc_tfc_win_preimport_cmd_edit,
		   tr("Windows Preimport Command:"),this);
  label->setGeometry(10,297,170,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_tfc_win_preimport_cmd_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Note Cart
  //
  svc_tfc_label_cart_edit=new QLineEdit(this);
  svc_tfc_label_cart_edit->setGeometry(185,318,240,19);
  svc_tfc_label_cart_edit->setMaxLength(32);
  label=new QLabel(svc_tfc_label_cart_edit,tr("Note Cart String:"),this);
  label->setGeometry(10,318,170,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_tfc_label_cart_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Track String
  //
  svc_tfc_track_edit=new QLineEdit(this);
  svc_tfc_track_edit->setGeometry(185,339,240,19);
  svc_tfc_track_edit->setMaxLength(32);
  label=new QLabel(svc_tfc_track_edit,tr("Insert Voice Track String:"),this);
  label->setGeometry(10,339,170,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_tfc_track_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Traffic Import Template
  //
  svc_tfc_import_template_box=new QComboBox(this);
  svc_tfc_import_template_box->setGeometry(185,360,240,19);
  label=new QLabel(svc_tfc_import_template_box,tr("Import Template:"),this);
  label->setGeometry(10,360,170,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_tfc_import_template_box,SIGNAL(activated(int)),
	  this,SLOT(tfcTemplateActivatedData(int)));

  //
  // Traffic Parser Settings
  //
  svc_tfc_fields=new ImportFields(this);
  svc_tfc_fields->setGeometry(10,381,svc_tfc_fields->sizeHint().width(),
			      svc_tfc_fields->sizeHint().height());

  //
  //  Traffic Test Button
  //
  button=new QPushButton(this);
  button->setGeometry(360,381,60,40);
  button->setFont(font);
  button->setText(tr("Test \n&Traffic"));
  connect(button,SIGNAL(clicked()),this,SLOT(trafficData()));

  //
  // Music Import Section
  //
  label=new QLabel(tr("Music Data Import"),this);
  label->setGeometry(445,213,160,24);
  label->setFont(section_font);
  label->setAlignment(AlignLeft);

  //
  // Linux Music Import Path
  //
  svc_mus_path_edit=new QLineEdit(this);
  svc_mus_path_edit->setGeometry(620,234,240,19);
  svc_mus_path_edit->setMaxLength(255);
  svc_mus_path_edit->setValidator(validator);
  label=new QLabel(svc_mus_path_edit,tr("Linux Import Path:"),this);
  label->setGeometry(450,234,165,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_mus_path_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Linux Music Preimport Command
  //
  svc_mus_preimport_cmd_edit=new QLineEdit(this);
  svc_mus_preimport_cmd_edit->setGeometry(620,255,240,19);
  svc_mus_preimport_cmd_edit->setValidator(validator);
  label=
    new QLabel(svc_mus_preimport_cmd_edit,tr("Linux Preimport Command:"),this);
  label->setGeometry(450,255,170,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_mus_preimport_cmd_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Windows Music Import Path
  //
  svc_mus_win_path_edit=new QLineEdit(this);
  svc_mus_win_path_edit->setGeometry(620,276,240,19);
  svc_mus_win_path_edit->setMaxLength(255);
  label=new QLabel(svc_mus_win_path_edit,tr("Windows Import Path:"),this);
  label->setGeometry(450,276,165,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_mus_win_path_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Windows Music Preimport Command
  //
  svc_mus_win_preimport_cmd_edit=new QLineEdit(this);
  svc_mus_win_preimport_cmd_edit->setGeometry(620,297,240,19);
  label=new QLabel(svc_mus_win_preimport_cmd_edit,
		   tr("Windows Preimport Command:"),this);
  label->setGeometry(450,297,170,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_mus_win_preimport_cmd_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Label Cart
  //
  svc_mus_label_cart_edit=new QLineEdit(this);
  svc_mus_label_cart_edit->setGeometry(620,318,240,19);
  svc_mus_label_cart_edit->setMaxLength(32);
  label=new QLabel(svc_mus_label_cart_edit,tr("Note Cart String:"),this);
  label->setGeometry(450,318,170,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_mus_label_cart_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Insert Voice Track String
  //
  svc_mus_track_edit=new QLineEdit(this);
  svc_mus_track_edit->setGeometry(620,339,240,19);
  svc_mus_track_edit->setMaxLength(255);
  label=new QLabel(svc_mus_track_edit,tr("Insert Voice Track String:"),this);
  label->setGeometry(450,339,165,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_mus_track_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Insert Spot Break String
  //
  svc_mus_break_edit=new QLineEdit(this);
  svc_mus_break_edit->setGeometry(620,360,240,19);
  svc_mus_break_edit->setMaxLength(255);
  label=new QLabel(svc_mus_break_edit,tr("Insert Traffic Break String:"),this);
  label->setGeometry(450,360,165,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_mus_break_edit,SIGNAL(textChanged(const QString &)),
	  this,SLOT(textChangedData(const QString &)));

  //
  // Music Import Template
  //
  svc_mus_import_template_box=new QComboBox(this);
  svc_mus_import_template_box->setGeometry(620,381,240,19);
  label=new QLabel(svc_mus_import_template_box,tr("Import Template:"),this);
  label->setGeometry(450,381,170,19);
  label->setAlignment(AlignRight|AlignVCenter|ShowPrefix);
  connect(svc_mus_import_template_box,SIGNAL(activated(int)),
	  this,SLOT(musTemplateActivatedData(int)));

  //
  // Music Parser Settings
  //
  svc_mus_fields=new ImportFields(this);
  svc_mus_fields->setGeometry(445,402,svc_mus_fields->sizeHint().width(),
			      svc_mus_fields->sizeHint().height());

  //
  // Music Test Button
  //
  button=new QPushButton(this);
  button->setGeometry(795,402,60,40);
  button->setFont(font);
  button->setText(tr("Test \n&Music"));
  connect(button,SIGNAL(clicked()),this,SLOT(musicData()));

  //
  //  Ok Button
  //
  button=new QPushButton(this);
  button->setGeometry(sizeHint().width()-180,sizeHint().height()-60,80,50);
  button->setDefault(true);
  button->setFont(font);
  button->setText(tr("&OK"));
  connect(button,SIGNAL(clicked()),this,SLOT(okData()));

  //
  //  Cancel Button
  //
  button=new QPushButton(this);
  button->setGeometry(sizeHint().width()-90,sizeHint().height()-60,
			     80,50);
  button->setFont(font);
  button->setText(tr("&Cancel"));
  connect(button,SIGNAL(clicked()),this,SLOT(cancelData()));

  //
  // Load Group Lists
  //
  group=svc_svc->trackGroup();
  autospot=svc_svc->autospotGroup();
  sql="select NAME from GROUPS order by NAME";
  q=new RDSqlQuery(sql);
  while(q->next()) {
    svc_voice_group_box->insertItem(q->value(0).toString());
    if(q->value(0).toString()==group) {
      svc_voice_group_box->setCurrentItem(svc_voice_group_box->count()-1);
    }
    svc_autospot_group_box->insertItem(q->value(0).toString());
    if(q->value(0).toString()==autospot) {
      svc_autospot_group_box->setCurrentItem(svc_autospot_group_box->count()-1);
    }
  }
  delete q;

  //
  // Populate Fields
  //
  svc_name_edit->setText(svc_svc->name());
  svc_description_edit->setText(svc_svc->description());
  svc_program_code_edit->setText(svc_svc->programCode());
  svc_name_template_edit->setText(svc_svc->nameTemplate());
  svc_description_template_edit->setText(svc_svc->descriptionTemplate());
  svc_chain_box->setChecked(svc_svc->chainto());
  svc_autorefresh_box->setChecked(svc_svc->autoRefresh());
  if(svc_svc->defaultLogShelflife()>=0) {
    svc_loglife_box->setChecked(true);
    svc_loglife_spin->setValue(svc_svc->defaultLogShelflife());
  }
  else {
    svc_loglife_spin->setDisabled(true);
  }
  if(svc_svc->elrShelflife()>=0) {
    svc_shelflife_box->setChecked(true);
    svc_shelflife_spin->setValue(svc_svc->elrShelflife());
  }
  else {
    svc_shelflife_spin->setDisabled(true);
  }
  svc_tfc_path_edit->setText(svc_svc->importPath(RDSvc::Traffic,RDSvc::Linux));
  svc_tfc_preimport_cmd_edit->
    setText(svc_svc->preimportCommand(RDSvc::Traffic,RDSvc::Linux));
  svc_tfc_win_path_edit->
    setText(svc_svc->importPath(RDSvc::Traffic,RDSvc::Windows));  
  svc_tfc_win_preimport_cmd_edit->
    setText(svc_svc->preimportCommand(RDSvc::Traffic,RDSvc::Windows));  

  svc_tfc_import_template_box->insertItem(tr("[custom]"));
  svc_mus_import_template_box->insertItem(tr("[custom]"));
  sql="select NAME from PARSER_TEMPLATES order by NAME";
  QString templ="";
  q=new RDSqlQuery(sql);
  while(q->next()) {
    if(q->value(0).toString()!=templ) {
      svc_tfc_import_template_box->insertItem(q->value(0).toString());
      if(q->value(0).toString()==svc_svc->importTemplate(RDSvc::Traffic)) {
	svc_tfc_import_template_box->
	  setCurrentItem(svc_tfc_import_template_box->count()-1);
      }
      svc_mus_import_template_box->insertItem(q->value(0).toString());
      if(q->value(0).toString()==svc_svc->importTemplate(RDSvc::Music)) {
	svc_mus_import_template_box->
	  setCurrentItem(svc_mus_import_template_box->count()-1);
      }
      templ=q->value(0).toString();
    }
  }
  delete q;
  svc_tfc_label_cart_edit->setText(svc_svc->labelCart(RDSvc::Traffic));
  svc_tfc_track_edit->setText(svc_svc->trackString(RDSvc::Traffic));
  svc_mus_path_edit->setText(svc_svc->importPath(RDSvc::Music,RDSvc::Linux));
  svc_mus_preimport_cmd_edit->
    setText(svc_svc->preimportCommand(RDSvc::Music,RDSvc::Linux));
  svc_mus_win_path_edit->
    setText(svc_svc->importPath(RDSvc::Music,RDSvc::Windows));  
  svc_mus_win_preimport_cmd_edit->
    setText(svc_svc->preimportCommand(RDSvc::Music,RDSvc::Windows));  
  svc_mus_label_cart_edit->setText(svc_svc->labelCart(RDSvc::Music));
  svc_mus_break_edit->
    setText(svc_svc->breakString());
  svc_mus_track_edit->
    setText(svc_svc->trackString(RDSvc::Music));
  svc_tfc_fields->setFields(svc_svc,RDSvc::Traffic);
  tfcTemplateActivatedData(svc_tfc_import_template_box->currentItem());
  musTemplateActivatedData(svc_mus_import_template_box->currentItem());
  svc_mus_fields->setFields(svc_svc,RDSvc::Music);
  import_changed=false;
}
Ejemplo n.º 21
0
void ListReports::GenerateCartDumpCsv(QString *report,bool prepend_names)
{
  QString sql;
  RDSqlQuery *q;
  QString schedcode="";
  QStringList f0;
  int code_quan=0;

  if(list_schedcode!=tr("ALL")) {
    schedcode=list_schedcode;
  }

  //
  // Generate Rows
  //
  if(list_type_filter.isEmpty()) {
    return;
  }
  sql=QString("select CART.NUMBER,CART.TYPE,CUTS.CUT_NAME,CART.GROUP_NAME,CART.TITLE,CART.ARTIST,")+
    "CART.ALBUM,CART.YEAR,CUTS.ISRC,CUTS.ISCI,CART.LABEL,CART.CLIENT,"+
    "CART.AGENCY,CART.PUBLISHER,CART.COMPOSER,CART.CONDUCTOR,CART.SONG_ID,"+
    "CART.USER_DEFINED,CUTS.DESCRIPTION,CUTS.OUTCUE,"+
    "CUTS.LENGTH,"+
    "CUTS.START_POINT,CUTS.END_POINT,"+
    "CUTS.SEGUE_START_POINT,CUTS.SEGUE_END_POINT,"+
    "CUTS.HOOK_START_POINT,CUTS.HOOK_END_POINT,"+
    "CUTS.TALK_START_POINT,CUTS.TALK_END_POINT,"+
    "CUTS.FADEUP_POINT,CUTS.FADEDOWN_POINT,"+
    "SCHED_CODES from CART "+
    "left join CUTS on CART.NUMBER=CUTS.CART_NUMBER";
  if(list_group==QString("ALL")) {
    sql+=QString(" where ")+
      RDAllCartSearchText(list_filter,schedcode,lib_user->name(),true)+" && "+
      list_type_filter+" order by CART.NUMBER,CUTS.CUT_NAME";
  }
  else {
    sql+=QString(" where ")+
      RDCartSearchText(list_filter,list_group,schedcode,true)+" && "+
      list_type_filter+" order by CART.NUMBER,CUTS.CUT_NAME";
  }
  q=new RDSqlQuery(sql);

  //
  // Get max number of scheduler codes
  //
  while(q->next()) {
    f0=f0.split(" ",q->value(17).toString());
    if((int)f0.size()>code_quan) {
      code_quan=f0.size();
    }
  }
  code_quan--;

  //
  // Prepend Field Names
  //
  if(prepend_names) {
    *report="CART,CUT,TYPE,GROUP_NAME,TITLE,ARTIST,ALBUM,YEAR,ISRC,ISCI,LABEL,";
    *report+="CLIENT,AGENCY,PUBLISHER,COMPOSER,CONDUCTOR,SONG_ID,USER_DEFINED,";
    *report+="DESCRIPTION,OUTCUE,";
    *report+="FILENAME,LENGTH,";
    *report+="START_POINT,END_POINT,";
    *report+="SEGUE_START_POINT,SEGUE_END_POINT,";
    *report+="HOOK_START_POINT,HOOK_END_POINT,";
    *report+="TALK_START_POINT,TALK_END_POINT,";
    *report+="FADEUP_POINT,FADEDOWN_POINT,";
    for(int i=0;i<code_quan;i++) {
      *report+=QString().sprintf("SCHED_CODE%u,",i+1);
    } 
    *report=report->left(report->length()-1);
    *report+="\n";
  }

  //
  // Generate Rows
  //
  q->seek(-1);
  while(q->next()) {
    RDCart::Type type=(RDCart::Type)q->value(1).toInt();
    *report+=QString().sprintf("%u,",q->value(0).toUInt());
    if(type==RDCart::Macro) {
      *report+="0,\"macro\",";
    }
    else {
      *report+=QString().sprintf("%u,",RDCut::cutNumber(q->value(2).toString()));
      *report+="\"audio\",";
    }
    *report+="\""+q->value(3).toString()+"\",";
    *report+="\""+q->value(4).toString()+"\",";
    *report+="\""+q->value(5).toString()+"\",";
    *report+="\""+q->value(6).toString()+"\",";
    *report+="\""+q->value(7).toDate().toString("yyyy")+"\",";
    *report+="\""+q->value(8).toString()+"\",";
    *report+="\""+q->value(9).toString()+"\",";
    *report+="\""+q->value(10).toString()+"\",";
    *report+="\""+q->value(11).toString()+"\",";
    *report+="\""+q->value(12).toString()+"\",";
    *report+="\""+q->value(13).toString()+"\",";
    *report+="\""+q->value(14).toString()+"\",";
    *report+="\""+q->value(15).toString()+"\",";
    *report+="\""+q->value(16).toString()+"\",";
    *report+="\""+q->value(17).toString()+"\",";
    *report+="\""+q->value(18).toString()+"\",";
    *report+="\""+q->value(19).toString()+"\",";
    if(type==RDCart::Macro) {
      *report+="\"\",";
    }
    else {
      *report+="\""+q->value(2).toString()+".wav\",";
    }
    *report+="\""+
      RDGetTimeLength(q->value(20).toInt(),false,false).stripWhiteSpace()+"\",";
    if(type==RDCart::Macro) {
      *report+="-1,";
      *report+="-1,";
      *report+="-1,";
      *report+="-1,";
      *report+="-1,";
      *report+="-1,";
      *report+="-1,";
      *report+="-1,";
      *report+="-1,";
      *report+="-1,";
    }
    else {
      *report+=QString().sprintf("%d,",q->value(21).toInt());
      *report+=QString().sprintf("%d,",q->value(22).toInt());
      *report+=QString().sprintf("%d,",q->value(23).toInt());
      *report+=QString().sprintf("%d,",q->value(24).toInt());
      *report+=QString().sprintf("%d,",q->value(25).toInt());
      *report+=QString().sprintf("%d,",q->value(26).toInt());
      *report+=QString().sprintf("%d,",q->value(27).toInt());
      *report+=QString().sprintf("%d,",q->value(28).toInt());
      *report+=QString().sprintf("%d,",q->value(29).toInt());
      *report+=QString().sprintf("%d,",q->value(30).toInt());
    }

    f0=f0.split(" ",q->value(31).toString());
    for(int i=0;i<code_quan;i++) {
      if(((int)f0.size()>i)&&(f0[i]!=".")) {
	*report+="\""+f0[i].stripWhiteSpace()+"\",";
      }
      else {
	*report+="\"\",";
      }
    }
    *report=report->left(report->length()-1);
    *report+="\n";
  }
}
Ejemplo n.º 22
0
EditSvcPerms::EditSvcPerms(RDSvc *svc,QWidget *parent,const char *name)
  : QDialog(parent,name,true)
{
  QString sql;
  RDSqlQuery *q;

  svc_svc=svc;

  //
  // Fix the Window Size
  //
  setMinimumWidth(sizeHint().width());
  setMaximumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());
  setMaximumHeight(sizeHint().height());

  setCaption(tr("Service: ")+svc_svc->name());

  //
  // Create Fonts
  //
  QFont font=QFont("Helvetica",12,QFont::Bold);
  font.setPixelSize(12);

  //
  // Services Selector
  //
  svc_host_sel=new RDListSelector(this,"svc_host_sel");
  svc_host_sel->sourceSetLabel(tr("Available Hosts"));
  svc_host_sel->destSetLabel(tr("Enabled Hosts"));
  svc_host_sel->setGeometry(10,10,380,130);

  //
  //  Ok Button
  //
  QPushButton *ok_button=new QPushButton(this,"ok_button");
  ok_button->setGeometry(sizeHint().width()-180,sizeHint().height()-60,80,50);
  ok_button->setDefault(true);
  ok_button->setFont(font);
  ok_button->setText(tr("&OK"));
  connect(ok_button,SIGNAL(clicked()),this,SLOT(okData()));

  //
  //  Cancel Button
  //
  QPushButton *cancel_button=new QPushButton(this,"cancel_button");
  cancel_button->setGeometry(sizeHint().width()-90,sizeHint().height()-60,
			     80,50);
  cancel_button->setFont(font);
  cancel_button->setText(tr("&Cancel"));
  connect(cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));

  //
  // Populate Fields
  sql=QString().sprintf("select STATION_NAME from SERVICE_PERMS \
                         where SERVICE_NAME=\"%s\"",
			(const char *)svc_svc->name());
  q=new RDSqlQuery(sql);
  while(q->next()) {
    svc_host_sel->destInsertItem(q->value(0).toString());
  }
  delete q;

  sql=QString().sprintf("select NAME from STATIONS");
  q=new RDSqlQuery(sql);
  while(q->next()) {
    if(svc_host_sel->destFindItem(q->value(0).toString())==0) {
      svc_host_sel->sourceInsertItem(q->value(0).toString());
    }
  }
  delete q;
}
Ejemplo n.º 23
0
bool RDReport::ExportTechnical(const QString &filename,const QDate &startdate,
			       const QDate &enddate,bool incl_hdr,bool incl_crs,
			       const QString &mixtable)
{
  QString sql;
  RDSqlQuery *q;
  QString cut;
  QString str;
  QString cart_fmt;
  QString cart_num;
  char eol[3]="\n";

  if(incl_crs) {
    strcpy(eol,"\r\n");
  }

  QFile *file=new QFile(filename);
  if(!file->open(QIODevice::WriteOnly|QIODevice::Truncate)) {
    report_error_code=RDReport::ErrorCantOpen;
    delete file;
    return false;
  }
  Q3TextStream *strm=new Q3TextStream(file);
  strm->setEncoding(Q3TextStream::UnicodeUTF8);
  if(useLeadingZeros()) {
    cart_fmt=QString().sprintf("%%0%uu",cartDigits());
  }
  else {
    cart_fmt="%6u";
  }
  sql=QString("select ")+
    "ELR_LINES.LENGTH,"+          // 00
    "ELR_LINES.CART_NUMBER,"+     // 01
    "ELR_LINES.EVENT_DATETIME,"+  // 02
    "ELR_LINES.EVENT_TYPE,"+      // 03
    "ELR_LINES.EXT_START_TIME,"+  // 04
    "ELR_LINES.EXT_LENGTH,"+      // 05
    "ELR_LINES.EXT_DATA,"+        // 06
    "ELR_LINES.EXT_EVENT_ID,"+    // 07
    "ELR_LINES.TITLE,"+           // 08
    "CART.FORCED_LENGTH,"+        // 09
    "ELR_LINES.STATION_NAME,"+    // 10
    "ELR_LINES.PLAY_SOURCE,"+     // 11
    "ELR_LINES.CUT_NUMBER,"+      // 12
    "ELR_LINES.START_SOURCE,"+    // 13
    "ELR_LINES.ONAIR_FLAG "+      // 14
    "from ELR_LINES left join CART "+
    "on ELR_LINES.CART_NUMBER=CART.NUMBER where "+
    "SERVICE_NAME=\""+RDEscapeString(mixtable)+"\" "+
    "order by EVENT_DATETIME";
  q=new RDSqlQuery(sql);

  //
  // Write File Header
  //
  if(incl_hdr) {
    if(startdate==enddate) {
      *strm << RDReport::center("Rivendell RDAirPlay Technical Playout Report for "+
				 startdate.toString("MM/dd/yyyy"),96);
      *strm << eol;
    }
    else {
      *strm << RDReport::center("Rivendell RDAirPlay Technical Playout Report for "+
		      startdate.toString("MM/dd/yyyy")+" - "+
		      enddate.toString("MM/dd/yyyy"),96);
      *strm << eol;
    }
    *strm << RDReport::center(name()+" -- "+description(),96);
    *strm << eol;
    *strm << "--Time--  -Cart-  Cut  --Title----------------  A-Len  N-Len  --Host----  Srce  StartedBy  OnAir";
    *strm << eol;
  }

  //
  // Write Data Rows
  //
  while(q->next()) {
    if(q->value(12).toInt()>0) {
      cut=QString().sprintf("%03d",q->value(12).toInt());
    }
    else {
      if((RDAirPlayConf::TrafficAction)q->value(3).toInt()==
	 RDAirPlayConf::TrafficMacro) {
	cut="rml";
      }
      else {
	cut="   ";
      }
    }
    cart_num=QString().sprintf(cart_fmt,q->value(1).toUInt());
    *strm << q->value(2).toTime().toString("hh:mm:ss")+"  ";
    *strm << cart_num+"  ";
    *strm << cut+"  ";
    *strm << RDReport::leftJustify(q->value(8).toString(),23)+"  ";
    *strm << RDGetTimeLength(q->value(0).toInt(),true,false).right(5)+"  ";
    *strm << RDGetTimeLength(q->value(9).toInt(),true,false).right(5)+"  ";
    *strm << RDReport::leftJustify(q->value(10).toString(),10)+"  ";
    switch((RDLogLine::PlaySource)q->value(11).toInt()) {
    case RDLogLine::MainLog:
      *strm << "Main   ";
      break;

    case RDLogLine::AuxLog1:
      *strm << "Aux1   ";
      break;

    case RDLogLine::AuxLog2:
      *strm << "Aux2   ";
      break;

    case RDLogLine::SoundPanel:
      *strm << "SPnl    ";
      break;

    case RDLogLine::CartSlot:
      *strm << "Slot   ";
      break;

    default:
      *strm << "       ";
      break;
    }
    *strm << RDReport::leftJustify(RDLogLine::startSourceText((RDLogLine::StartSource)q->value(13).toInt()),7)+"  ";
    if(q->value(14).toString()=="Y") {
      *strm << "  Yes ";
    }
    else {
      *strm << "  No  ";
    }
    *strm << eol;
  }
  delete q;

  delete strm;
  delete file;
  report_error_code=RDReport::ErrorOk;
  return true;
}
Ejemplo n.º 24
0
void ListReports::GenerateCutReport(QString *report)
{
  QString sql;
  RDSqlQuery *q;
  unsigned current_cart=0;
  QString schedcode="";

  if(list_schedcode!=tr("ALL")) {
    schedcode=list_schedcode;
  }

  //
  // Generate Header
  //
  QString filter=list_filter;
  if(list_filter.isEmpty()) {
    filter="[none]";
  }
  *report="                                                        Rivendell Cut Report\n";
  *report+=QString().
    sprintf("Generated: %s     Group: %-10s      Filter: %s\n",
	    (const char *)QDateTime(QDate::currentDate(),QTime::currentTime()).
	    toString("MM/dd/yyyy - hh:mm:ss"),
	    (const char *)list_group.utf8(),(const char *)filter.utf8());
  *report+="\n";
  *report+="-Cart- Cut Wht -Cart Title-------------- -Description--- -Len- Last Play Plays Start Date End Date -Days of Week- -Daypart-----------\n";

  //
  // Generate Rows
  //
  if(list_type_filter.isEmpty()) {
    return;
  }
  sql="select CART.NUMBER,CUTS.CUT_NAME,CUTS.WEIGHT,CART.TITLE,\
       CUTS.DESCRIPTION,CUTS.LENGTH,CUTS.LAST_PLAY_DATETIME,CUTS.PLAY_COUNTER,\
       CUTS.START_DATETIME,CUTS.END_DATETIME,SUN,MON,TUE,WED,THU,FRI,SAT,\
       CUTS.START_DAYPART,CUTS.END_DAYPART from CART join CUTS \
       on CART.NUMBER=CUTS.CART_NUMBER";
  if(list_group==QString("ALL")) {
    sql+=QString(" where ")+
      RDAllCartSearchText(list_filter,schedcode,lib_user->name(),true)+" && "+
      list_type_filter+" order by CART.NUMBER";
  }
  else {
    sql+=QString(" where ")+
      RDCartSearchText(list_filter,list_group,schedcode,true)+" && "+
      list_type_filter+" order by CART.NUMBER";
  }
  q=new RDSqlQuery(sql);
  while(q->next()) {
    //
    // Cart Number
    //
    if(q->value(0).toUInt()!=current_cart) {
      *report+=QString().sprintf("%06u ",q->value(0).toUInt());
    }
    else {
      *report+="       ";
    }

    //
    // Cut Number
    //
    *report+=
      QString().sprintf("%03d ",q->value(1).toString().right(3).toInt());

    //
    // Weight
    //
    *report+=QString().sprintf("%3d ",q->value(2).toInt());

    //
    // Title
    //
    if(q->value(0).toUInt()!=current_cart) {
      *report+=QString().sprintf("%-25s ",(const char *)q->value(3).toString().
				 utf8().left(25));
    }
    else {
      *report+="                          ";
    }

    //
    // Description
    //
    *report+=QString().sprintf("%-15s ",(const char *)q->value(4).toString().
			       utf8().left(15));

    //
    // Length
    //
    *report+=
      QString().sprintf("%5s ",
	       (const char *)RDGetTimeLength(q->value(5).toInt(),false,false));

    //
    // Last Play
    //
    if(q->value(6).toDateTime().isNull()) {
      *report+="  [none]   ";
    }
    else {
      *report+=QString().sprintf(" %8s  ",
		    (const char *)q->value(6).toDate().toString("MM/dd/yy"));
    }

    //
    // Plays
    //
    *report+=QString().sprintf("%4d ",q->value(7).toInt());

    //
    // Start Date
    //
    if(q->value(8).toDateTime().isNull()) {
      *report+="  [none]  ";
    }
    else {
      *report+=QString().sprintf(" %8s ",
	       (const char *)q->value(8).toDateTime().toString("MM/dd/yy"));
    }

    //
    // End Date
    //
    if(q->value(9).toDateTime().isNull()) {
      *report+="   TFN    ";
    }
    else {
      *report+=QString().sprintf(" %8s ",
		(const char *)q->value(9).toDateTime().toString("MM/dd/yy"));
    }

    //
    // Days of the Week
    //
    if(q->value(10).toString()=="Y") {
      *report+="Su";
    }
    else {
      *report+="  ";
    }
    if(q->value(11).toString()=="Y") {
      *report+="Mo";
    }
    else {
      *report+="  ";
    }
    if(q->value(12).toString()=="Y") {
      *report+="Tu";
    }
    else {
      *report+="  ";
    }
    if(q->value(13).toString()=="Y") {
      *report+="We";
    }
    else {
      *report+="  ";
    }
    if(q->value(14).toString()=="Y") {
      *report+="Th";
    }
    else {
      *report+="  ";
    }
    if(q->value(15).toString()=="Y") {
      *report+="Fr";
    }
    else {
      *report+="  ";
    }
    if(q->value(16).toString()=="Y") {
      *report+="Sa ";
    }
    else {
      *report+="   ";
    }

    //
    // Dayparts
    //
    if(q->value(18).toTime().isNull()) {
      *report+="[none]";
    }
    else {
      *report+=QString().sprintf("%8s - %8s",
	       (const char *)q->value(17).toTime().toString("hh:mm:ss"),
	       (const char *)q->value(18).toTime().toString("hh:mm:ss"));
    }

    //
    // End of Line
    //
    *report+="\n";

    current_cart=q->value(0).toUInt();
  }
  delete q;
}
Ejemplo n.º 25
0
void MainObject::ProcessCarts()
{
  QString sql;
  RDSqlQuery *q;
  RDSqlQuery *q1;
  RDSqlQuery *q2;
  QString repl_name;
  QString where;
  bool stale;

  for(unsigned i=0;i<repl_replicators.size();i++) {
    where="";
    repl_name=repl_replicators[i]->config()->name();
    sql=QString().
      sprintf("select GROUP_NAME from REPLICATOR_MAP \
                           where REPLICATOR_NAME=\"%s\"",
	      (const char *)RDEscapeString(repl_name));
    q=new RDSqlQuery(sql);
    while(q->next()) {
      where+=QString().
	sprintf("(GROUP_NAME=\"%s\")||",
		(const char *)RDEscapeString(q->value(0).toString()));
    }
    delete q;
    where=where.left(where.length()-2);
    sql=QString().sprintf("select NUMBER,TYPE,METADATA_DATETIME \
                           from CART where %s",
			  (const char *)where);
    q=new RDSqlQuery(sql);
    while(q->next()) {
      sql=QString().sprintf("select ID,ITEM_DATETIME from REPL_CART_STATE \
                             where (REPLICATOR_NAME=\"%s\")&&\
                             (CART_NUMBER=%u)",
			    (const char *)RDEscapeString(repl_name),
			    q->value(0).toUInt());
      q1=new RDSqlQuery(sql);
      if(q1->first()) {
	stale=q->value(2).toDateTime()>q1->value(1).toDateTime();
      }
      else {
	stale=true;
      }
      if(stale) {
	if(repl_replicators[i]->processCart(q->value(0).toUInt())) {
	  if(q1->isValid()) {
	    sql=QString().sprintf("update REPL_CART_STATE set \
                                   ITEM_DATETIME=now() where ID=%u",
				  q1->value(0).toUInt());
	  }
	  else {
	    sql=QString().sprintf("insert into REPL_CART_STATE set \
                                   REPLICATOR_NAME=\"%s\",\
                                   CART_NUMBER=%u,\
                                   ITEM_DATETIME=now()",
				  (const char *)RDEscapeString(repl_name),
				  q->value(0).toUInt());
	  }
	  q2=new RDSqlQuery(sql);
	  delete q2;
	}
      }
      delete q1;
    }
Ejemplo n.º 26
0
void EditDecks::ReadRecord(int chan)
{
  QString sql;
  RDSqlQuery *q;

  if(chan==0) {  // Audition Deck
    if(edit_audition_deck==NULL) {
      edit_audition_deck=new RDDeck(edit_station->name(),0,true);
    }
  }
  if((chan>128)&&(chan<(MAX_DECKS+129))) {  // Play Deck
    if(edit_play_deck!=NULL) {
      delete edit_play_deck;
    }
    edit_play_deck=new RDDeck(edit_station->name(),edit_play_channel,true);
    edit_play_selector->setCard(edit_play_deck->cardNumber());
    edit_play_selector->setPort(edit_play_deck->portNumber());
  }
  if((chan>0)&&(chan<(MAX_DECKS+1))) {       // Record Deck
    if(edit_record_deck!=NULL) {
      delete edit_record_deck;
    }
    edit_record_deck=new RDDeck(edit_station->name(),edit_record_channel,true);
    edit_record_selector->setCard(edit_record_deck->cardNumber());
    edit_record_selector->setPort(edit_record_deck->portNumber());
    edit_monitor_box->setValue(edit_record_deck->monitorPortNumber());
    if(edit_record_deck->defaultMonitorOn()) {
      edit_default_on_box->setCurrentItem(1);
    }
    else {
      edit_default_on_box->setCurrentItem(0);
    }
    switch(edit_record_deck->defaultFormat()) {
	case RDSettings::Pcm16:
	  edit_format_box->setCurrentItem(0);
	  edit_bitrate_box->setDisabled(true);
	  break;

	case RDSettings::Pcm24:
	  edit_format_box->setCurrentItem(1);
	  edit_bitrate_box->setDisabled(true);
	  break;

	case RDSettings::MpegL2:
	case RDSettings::MpegL2Wav:
	  edit_format_box->setCurrentItem(2);
	  edit_bitrate_box->setEnabled(true);
	  break;

	case RDSettings::MpegL1:
	case RDSettings::MpegL3:
	case RDSettings::Flac:
	case RDSettings::OggVorbis:
	  break;
    }
    edit_channels_box->setCurrentItem(edit_record_deck->defaultChannels()-1);
    switch(edit_record_deck->defaultBitrate()) {
	case 32000:
	  edit_bitrate_box->setCurrentItem(0);
	  break;
	case 48000:
	  edit_bitrate_box->setCurrentItem(1);
	  break;
	case 56000:
	  edit_bitrate_box->setCurrentItem(2);
	  break;
	case 64000:
	  edit_bitrate_box->setCurrentItem(3);
	  break;
	case 80000:
	  edit_bitrate_box->setCurrentItem(4);
	  break;
	case 96000:
	  edit_bitrate_box->setCurrentItem(5);
	  break;
	case 112000:
	  edit_bitrate_box->setCurrentItem(6);
	  break;
	case 128000:
	  edit_bitrate_box->setCurrentItem(7);
	  break;
	case 160000:
	  edit_bitrate_box->setCurrentItem(8);
	  break;
	case 192000:
	  edit_bitrate_box->setCurrentItem(9);
	  break;
	case 224000:
	  edit_bitrate_box->setCurrentItem(10);
	  break;
	case 256000:
	  edit_bitrate_box->setCurrentItem(11);
	  break;
	case 320000:
	  edit_bitrate_box->setCurrentItem(12);
	  break;
	case 384000:
	  edit_bitrate_box->setCurrentItem(13);
	  break;
	default:
	  edit_bitrate_box->setCurrentItem(7);    // 128 kbps/chan
	  break;
    }
    for(int i=0;i<edit_swstation_box->count();i++) {
      if(edit_record_deck->switchStation()==edit_swstation_box->text(i)) {
	edit_swstation_box->setCurrentItem(i);
	stationActivatedData(edit_swstation_box->currentText());
      }
    }
    QString matrix_name=edit_record_deck->switchMatrixName();
    for(int i=0;i<edit_swmatrix_box->count();i++) {
      if(edit_swmatrix_box->text(i)==matrix_name) {
	edit_swmatrix_box->setCurrentItem(i);
	matrixActivatedData(edit_swmatrix_box->currentText());
      }
    }
    QString output_name=edit_record_deck->switchOutputName();
    for(int i=0;i<edit_swoutput_box->count();i++) {
      if(edit_swoutput_box->text(i)==output_name) {
	edit_swoutput_box->setCurrentItem(i);
      }
    }
    edit_swdelay_box->setValue(edit_record_deck->switchDelay()/100);
    edit_threshold_box->setValue(-edit_record_deck->defaultThreshold()/100);
  }

  if(chan>128) {
    sql=QString("select NUMBER,CART_NUMBER from DECK_EVENTS where ")+
      "(STATION_NAME=\""+RDEscapeString(edit_station->name())+"\")&&"+
      QString().sprintf("(CHANNEL=%d)",chan);
    q=new RDSqlQuery(sql);
    while(q->next()) {
      if((q->value(0).toInt()-1)<RD_CUT_EVENT_ID_QUAN) {
	if(q->value(1).toUInt()==0) {
	  edit_event_edits[q->value(0).toInt()-1]->setText("");
	}
	else {
	  edit_event_edits[q->value(0).toInt()-1]->
	    setText(QString().sprintf("%06u",q->value(1).toUInt()));
	}
      }
    }
    playSettingsChangedData(0,edit_play_selector->card(),
			    edit_play_selector->port());
  }
}
Ejemplo n.º 27
0
void AddStation::okData()
{
  RDSqlQuery *q;
  RDSqlQuery *q1;
  QString sql;

  if(add_name_edit->text().isEmpty()) {
    QMessageBox::warning(this,tr("Invalid Name"),
			 tr("You must give the host a name!"));
    return;
  }

  if(add_exemplar_box->currentItem()==0) {  // Create Blank Host Config
    sql=QString().sprintf("insert into STATIONS set NAME=\"%s\",\
                           DESCRIPTION=\"Workstation %s\",USER_NAME=\"user\",\
                           DEFAULT_NAME=\"user\"",
			  (const char *)add_name_edit->text(),
			  (const char *)add_name_edit->text());
    q=new RDSqlQuery(sql);
    if(!q->isActive()) {
      QMessageBox::warning(this,tr("Host Exists"),tr("Host Already Exists!"),
			   1,0,0);
      delete q;
      return;
    }
    delete q;

    //
    // Create Service Perms
    //
    sql="select NAME from SERVICES";
    q=new RDSqlQuery(sql);
    while(q->next()) {
      sql=QString().sprintf("insert into SERVICE_PERMS set\
                           SERVICE_NAME=\"%s\",STATION_NAME=\"%s\"",
			    (const char *)q->value(0).toString(),
			    (const char *)add_name_edit->text());
      q1=new RDSqlQuery(sql);
      delete q1;
    }
    delete q;

    //
    // RDAirPlay/RDPanel Channel Data
    //
    for(unsigned i=0;i<10;i++) {
      sql=QString("insert into RDAIRPLAY_CHANNELS set ")+
	"STATION_NAME=\""+RDEscapeString(add_name_edit->text())+"\","+
	QString().sprintf("INSTANCE=%u",i);
      q=new RDSqlQuery(sql);
      delete q;

      sql=QString("insert into RDPANEL_CHANNELS set ")+
	"STATION_NAME=\""+RDEscapeString(add_name_edit->text())+"\","+
	QString().sprintf("INSTANCE=%u",i);
      q=new RDSqlQuery(sql);
      delete q;
    }
    for(unsigned i=0;i<RD_CUT_EVENT_ID_QUAN;i++) {
      for(unsigned j=0;j<MAX_DECKS;j++) {
	sql=QString("insert into DECK_EVENTS set ")+
	  "STATION_NAME=\""+RDEscapeString(add_name_edit->text())+"\","+
	  QString().sprintf("CHANNEL=%u,",j+129)+
	  QString().sprintf("NUMBER=%u",i+1);
	q=new RDSqlQuery(sql);
	delete q;
      }
    }
  }
Ejemplo n.º 28
0
QStringList EditDecks::GetActiveOutputMatrices()
{
  QStringList ret;
  QString sql;
  RDSqlQuery *q;
  RDSqlQuery *q1;
  
  //  edit_matrix_ids.clear();
  sql=QString("select TYPE,NAME,OUTPUTS,MATRIX from MATRICES where ")+
    "STATION_NAME=\""+RDEscapeString(edit_station->name())+"\"";
  q=new RDSqlQuery(sql);
  while(q->next()) {
    switch((RDMatrix::Type)q->value(0).toInt()) {
    case RDMatrix::LiveWireLwrpAudio:
      sql=QString("select HOSTNAME,PASSWORD,TCP_PORT,BASE_OUTPUT ")+
	"from SWITCHER_NODES "+
	"where (STATION_NAME=\""+RDEscapeString(edit_station->name())+"\")&& "+
	QString().sprintf("(MATRIX=%d) ",q->value(3).toInt())+
	"order by BASE_OUTPUT desc";
      q1=new RDSqlQuery(sql);
      if(q1->first()) {
	RDLiveWire *lw=new RDLiveWire(0,this);
	if(!lw->loadSettings(q1->value(0).toString(),q1->value(2).toUInt(),
			     q1->value(1).toString(),q1->value(3).toInt())) {
	  QMessageBox::warning(this,tr("RDAdmin - "+tr("Connection Error")),
			       tr("Unable to connect to node at")+" \""+
			       q1->value(0).toString()+"\"."+
			    tr("Check that the unit is online and try again."));
	  delete lw;
	  return ret;
	}
	edit_swmatrix_box->
	  insertItem(q->value(1).toString()+" ["+
		 RDMatrix::typeString((RDMatrix::Type)q->value(0).toInt())+"]",
		     false,q->value(3));
	//	ret.push_back(q->value(1).toString()+
	//	   " ["+RDMatrix::typeString((RDMatrix::Type)q->value(0).toInt())+"]");
	delete lw;
	//	edit_matrix_ids.push_back(q->value(3).toInt());
      }
      delete q1;
      break;

    default:
      if(q->value(2).toInt()>0) {
	edit_swmatrix_box->
	  insertItem(q->value(1).toString()+
	    " ["+RDMatrix::typeString((RDMatrix::Type)q->value(0).toInt())+"]",
		     false,q->value(3));
	/*
	ret.push_back(q->value(1).toString()+
	   " ["+RDMatrix::typeString((RDMatrix::Type)q->value(0).toInt())+"]");
	edit_matrix_ids.push_back(q->value(3).toInt());
	*/
      }
      break;
    }
  }
  delete q;

  return ret;
}
Ejemplo n.º 29
0
bool RDReport::ExportMusicPlayout(const QDate &startdate,const QDate &enddate,
				  const QString &mixtable)
{
  QString sql;
  RDSqlQuery *q;
  FILE *f;
  QString cut;
  QString str;
  QString cart_fmt;
  QString cart_num;

#ifdef WIN32
  QString filename=RDDateDecode(exportPath(RDReport::Windows),startdate);
#else
  QString filename=RDDateDecode(exportPath(RDReport::Linux),startdate);
#endif

  QFile file(filename);
  if((f=fopen((const char *)filename,"w"))==NULL) {
    report_error_code=RDReport::ErrorCantOpen;
    return false;
  }
  if(useLeadingZeros()) {
    cart_fmt=QString().sprintf("%%0%uu",cartDigits());
  }
  else {
    cart_fmt="%6u";
  }
  sql=QString("select ")+
    "`"+mixtable+"_SRT`.LENGTH,"+            // 00
    "`"+mixtable+"_SRT`.CART_NUMBER,"+       // 01
    "`"+mixtable+"%s_SRT`.EVENT_DATETIME,"+  // 02
    "`"+mixtable+"_SRT`.EXT_EVENT_ID,"+      // 03
    "`"+mixtable+"_SRT`.TITLE,"+             // 04
    "`"+mixtable+"_SRT`.CUT_NUMBER,"+        // 05
    "`"+mixtable+"_SRT`.ARTIST,"+            // 06
    "`"+mixtable+"_SRT`.ALBUM,"+             // 07
    "`"+mixtable+"_SRT`.LABEL "+             // 08
    "from `"+mixtable+"_SRT` left join CART "+
    "on `"+mixtable+"_SRT`.CART_NUMBER=CART.NUMBER "+
    "order by EVENT_DATETIME";
  q=new RDSqlQuery(sql);

  //
  // Write File Header
  //
  if(startdate==enddate) {
    fprintf(f,"                                                             Rivendell RDAirPlay Music Playout Report for %s\n",
	    (const char *)startdate.toString("MM/dd/yyyy"));
  }
  else {
    fprintf(f,"                                              Rivendell RDAirPlay Music Playout Report for %s - %s\n",
	    (const char *)startdate.toString("MM/dd/yyyy"),
	    (const char *)enddate.toString("MM/dd/yyyy"));
  }
  str=QString().sprintf("%s -- %s\n",(const char *)name(),
			(const char *)description());
  for(int i=0;i<(180-str.length())/2;i++) {
    fprintf(f," ");
  }
  fprintf(f,"%s\n",(const char *)str);
  fprintf(f,"--Time--  -Cart-  Cut  A-Len  --Title-----------------------   --Artist----------------------   --Album------------------   --Label-------------\n");

  //
  // Write Data Rows
  //
  while(q->next()) {
    if(q->value(5).toInt()>0) {
      cut=QString().sprintf("%03d",q->value(5).toInt());
    }
    else {
      if((RDAirPlayConf::TrafficAction)q->value(6).toInt()==
	 RDAirPlayConf::TrafficMacro) {
	cut="rml";
      }
      else {
	cut="   ";
      }
    }
    cart_num=QString().sprintf(cart_fmt,q->value(1).toUInt());
    fprintf(f,"%8s  %6s  %3s  %5s  %-30s   %-30s   %-25s   %-20s\n",
	    (const char *)q->value(2).toDateTime().time().toString("hh:mm:ss"),
	    (const char *)cart_num,
	    (const char *)cut,
	    (const char *)RDGetTimeLength(q->value(0).toInt(),true,false).
	    right(5),
	    (const char *)StringField(q->value(4).toString().left(30)),
	    (const char *)StringField(q->value(6).toString().left(30)),
	    (const char *)StringField(q->value(7).toString().left(25)),
	    (const char *)StringField(q->value(8).toString().left(20)));
  }
  delete q;
  fclose(f);
  report_error_code=RDReport::ErrorOk;

  return true;
}
Ejemplo n.º 30
0
void ListUsers::deleteData()
{
  RDListViewItem *item=(RDListViewItem *)list_users_view->selectedItem();
  if(item==NULL) {
    return;
  }

  if(list_admin_name==item->text(1)) {
    QMessageBox::warning(this,tr("Delete User"),
			 tr("You cannot delete yourself!"));
    return;
  }

  QString sql;
  RDSqlQuery *q;
  QString warning;
  QString str;

  QString username=RDEscapeString(item->text(1));

  //
  // Check for default user assignments
  //
  sql=QString().sprintf("select NAME from STATIONS where DEFAULT_NAME=\"%s\"",
			(const char *)username);
  q=new RDSqlQuery(sql);
  if(q->size()>0) {
    str=tr("This user is set as the default user for the following hosts:\n\n");
    while(q->next()) {
      str+=("     "+q->value(0).toString()+"\n");
    }
    str+="\n";
    str+=tr("You must change this before deleting the user.");
    delete q;
    QMessageBox::warning(this,tr("Delete User"),str);
    return;
  }
  delete q;

  str=QString(tr("Are you sure you want to delete user"));
  warning+=QString().sprintf("%s \"%s\"?",(const char *)str,
			     (const char *)item->text(1));
  switch(QMessageBox::warning(this,tr("Delete User"),warning,
			      QMessageBox::Yes,QMessageBox::No)) {
      case QMessageBox::No:
      case QMessageBox::NoButton:
	return;

      default:
	break;
  }

  //
  // Delete RSS Feed Perms
  //
  sql=QString().sprintf("delete from FEED_PERMS where USER_NAME=\"%s\"",
			(const char *)username);
  q=new RDSqlQuery(sql);
  delete q;
  
  //
  // Delete Member User Perms
  //
  sql=QString().sprintf("delete from USER_PERMS where USER_NAME=\"%s\"",
			(const char *)username);
  q=new RDSqlQuery(sql);
  delete q;
  
  //
  // Delete from User List
  //
  sql=QString().sprintf("delete from USERS where LOGIN_NAME=\"%s\"",
			(const char *)username);
  q=new RDSqlQuery(sql);
  delete q;

  //
  // Delete from Cached Web Connections
  //
  sql=QString().sprintf("delete from WEB_CONNECTIONS where LOGIN_NAME=\"%s\"",
			(const char *)username);
  q=new RDSqlQuery(sql);
  delete q;

  item->setSelected(false);
  delete item;
}