Beispiel #1
0
bool Directory::stationCodeEq(const StationData& stn, string code, bool exact)
{
  if (exact)
  {
    return (stn.code() == code);
  }
  else
  {
    return (stn.code().find(code) == 0);
  }
} /* Directory::stationCodeEq  */
Beispiel #2
0
void ComDialog::dnsResultsReady(DnsLookup &)
{
  if (dns->addresses().empty())
  {
    MyMessageBox *mb = new MyMessageBox(trUtf8("Qtel Error"),
	trUtf8("Could not create connection to remote host") + " \"" +
	dns->label().c_str() + "\"");
    mb->show();
    connect(mb, SIGNAL(closed()), this, SLOT(close()));
    delete con;
    con = 0;
    return;
  }
  
  StationData *station = new StationData;
  station->setIp(dns->addresses()[0]);
  updateStationData(station);
  createConnection(station);  
  
  delete dns;
  dns = 0;
  
} /* ComDialog::dnsResultsReady */
Beispiel #3
0
void MainWindow::explorerViewClicked(QListViewItem* item)
{
  list<StationData> station_list;
  
  //stationView->setUpdatesEnabled(FALSE);
  
  if (item == 0)
  {
    //stationView->clear();
  }
  else if (item->text(0) == MainWindowBase::trUtf8("Bookmarks"))
  {
    //stationView->clear();
    QStringList bookmarks = Settings::instance()->bookmarks();
    QStringList::iterator it;
    for (it = bookmarks.begin(); it != bookmarks.end(); ++it)
    {
      const StationData *station = dir.findCall((*it).latin1());
      if (station != 0)
      {
	station_list.push_back(*station);
      }
      else
      {
	StationData stn;
	stn.setCallsign((*it).latin1());
	stn.setStatus(StationData::STAT_OFFLINE);
	stn.setIp(Async::IpAddress("0.0.0.0"));
	station_list.push_back(stn);
      }
    }
  }
  else if (item->text(0) == MainWindowBase::trUtf8("Links"))
  {
    station_list = dir.links();
  }
  else if (item->text(0) == MainWindowBase::trUtf8("Repeaters"))
  {
    station_list = dir.repeaters();
  }
  else if (item->text(0) == MainWindowBase::trUtf8("Conferences"))
  {
    station_list = dir.conferences();
  }
  else if (item->text(0) == MainWindowBase::trUtf8("Stations"))
  {
    station_list = dir.stations();
  }
  
  stationView->clear();
  list<StationData>::const_iterator iter;
  for (iter=station_list.begin(); iter!=station_list.end(); ++iter)
  {
    char id_str[256] = "";
    if (iter->id() != -1)
    {
      sprintf(id_str, "%d", iter->id());
    }
    new QListViewItem(stationView, iter->callsign().c_str(),
	      	      iter->description().c_str(), iter->statusStr().c_str(),
	      	      iter->time().c_str(), id_str);
  }
  
  if (stationView->firstChild() != 0)
  {
    QListViewItem *selected_item = stationView->findItem(select_map[item], 0);
    if (selected_item == 0)
    {
      selected_item = stationView->firstChild();
      select_map[item] = selected_item->text(0);
    }
    if (selected_item != 0)
    {
      stationView->setSelected(selected_item, true);
      stationView->ensureItemVisible(selected_item);
      QRect rect = stationView->itemRect(selected_item);
      int target_top = stationView->viewport()->height() / 2 -
	  selected_item->height() / 2;
      if (rect.top() > target_top)
      {
	stationView->scrollBy(0, rect.top() - target_top);
      }
    }
  }
  
  //stationView->setUpdatesEnabled(TRUE);
  //stationView->update();
  
} /* MainWindow::explorerViewClicked */
Beispiel #4
0
QsoImpl::QsoImpl(const StationData &station, ModuleEchoLink *module)
  : m_qso(station.ip()), module(module), event_handler(0), msg_handler(0),
    output_sel(0), init_ok(false), reject_qso(false), last_message(""),
    last_info_msg(""), idle_timer(0), disc_when_done(false), idle_timer_cnt(0),
    idle_timeout(0), destroy_timer(0), station(station), sink_handler(0)
{
  assert(module != 0);

  Config &cfg = module->cfg();
  const string &cfg_name = module->cfgName();
  
  string local_callsign;
  if (!cfg.getValue(cfg_name, "CALLSIGN", local_callsign))
  {
    cerr << "*** ERROR: Config variable " << cfg_name << "/CALLSIGN not set\n";
    return;
  }
  m_qso.setLocalCallsign(local_callsign);
  
  bool use_gsm_only = false;
  if (cfg.getValue(cfg_name, "USE_GSM_ONLY", use_gsm_only) && use_gsm_only)
  {
    cout << module->name() << ": Using GSM codec only\n";
    m_qso.setUseGsmOnly();
  }

  if (!cfg.getValue(cfg_name, "SYSOPNAME", sysop_name))
  {
    cerr << "*** ERROR: Config variable " << cfg_name
      	 << "/SYSOPNAME not set\n";
    return;
  }
  m_qso.setLocalName(sysop_name);
  
  string description;
  if (!cfg.getValue(cfg_name, "DESCRIPTION", description))
  {
    cerr << "*** ERROR: Config variable " << cfg_name
      	 << "/DESCRIPTION not set\n";
    return;
  }
  m_qso.setLocalInfo(description);
  
  string event_handler_script;
  if (!cfg.getValue(module->logicName(), "EVENT_HANDLER", event_handler_script))
  {
    cerr << "*** ERROR: Config variable " << module->logicName()
      	 << "/EVENT_HANDLER not set\n";
    return;
  }
  
  string idle_timeout_str;
  if (cfg.getValue(cfg_name, "LINK_IDLE_TIMEOUT", idle_timeout_str))
  {
    idle_timeout = atoi(idle_timeout_str.c_str());
    idle_timer = new Timer(1000, Timer::TYPE_PERIODIC);
    idle_timer->expired.connect(mem_fun(*this, &QsoImpl::idleTimeoutCheck));
  }
  
  sink_handler = new AudioPassthrough;
  AudioSink::setHandler(sink_handler);

  msg_handler = new MsgHandler(INTERNAL_SAMPLE_RATE);
  msg_handler->allMsgsWritten.connect(
      	  mem_fun(*this, &QsoImpl::allRemoteMsgsWritten));
	  
  AudioPacer *msg_pacer = new AudioPacer(INTERNAL_SAMPLE_RATE,
      	      	                         160*4*(INTERNAL_SAMPLE_RATE / 8000),
					 500);
  msg_handler->registerSink(msg_pacer, true);
  
  output_sel = new AudioSelector;
  output_sel->addSource(sink_handler);
  output_sel->enableAutoSelect(sink_handler, 0);
  output_sel->addSource(msg_pacer);
  output_sel->enableAutoSelect(msg_pacer, 10);
  AudioSource *prev_src = output_sel;

#if INTERNAL_SAMPLE_RATE == 16000
  AudioDecimator *down_sampler = new AudioDecimator(
          2, coeff_16_8, coeff_16_8_taps);
  prev_src->registerSink(down_sampler, true);
  prev_src = down_sampler;
#endif

  prev_src->registerSink(&m_qso);
  prev_src = 0;
  
  event_handler = new EventHandler(event_handler_script, 0);
  event_handler->playFile.connect(
      sigc::bind(mem_fun(*msg_handler, &MsgHandler::playFile), false));
  event_handler->playSilence.connect(
      sigc::bind(mem_fun(*msg_handler, &MsgHandler::playSilence), false));
  event_handler->playTone.connect(
      sigc::bind(mem_fun(*msg_handler, &MsgHandler::playTone), false));

    // Workaround: Need to set the ID config variable and "logic_name"
    // variable to load the TCL script.
  event_handler->processEvent("namespace eval EchoLink {}");
  event_handler->setVariable("EchoLink::CFG_ID", "0");
  event_handler->setVariable("logic_name", "Default");

  event_handler->processEvent("namespace eval Logic {}");
  string default_lang;
  if (cfg.getValue(cfg_name, "DEFAULT_LANG", default_lang))
  {
    event_handler->setVariable("Logic::CFG_DEFAULT_LANG", default_lang);
  }
  
  event_handler->initialize();
  
  m_qso.infoMsgReceived.connect(mem_fun(*this, &QsoImpl::onInfoMsgReceived));
  m_qso.chatMsgReceived.connect(mem_fun(*this, &QsoImpl::onChatMsgReceived));
  m_qso.stateChange.connect(mem_fun(*this, &QsoImpl::onStateChange));
  m_qso.isReceiving.connect(sigc::bind(isReceiving.make_slot(), this));
  m_qso.audioReceivedRaw.connect(
      sigc::bind(audioReceivedRaw.make_slot(), this));
  
  prev_src = &m_qso;
  
  AudioFifo *input_fifo = new AudioFifo(2048);
  input_fifo->setOverwrite(true);
  input_fifo->setPrebufSamples(1024);
  prev_src->registerSink(input_fifo, true);
  prev_src = input_fifo;
  
#if INTERNAL_SAMPLE_RATE == 16000
  AudioInterpolator *up_sampler = new AudioInterpolator(
          2, coeff_16_8, coeff_16_8_taps);
  prev_src->registerSink(up_sampler, true);
  prev_src = up_sampler;
#endif

  AudioSource::setHandler(prev_src);
  
  init_ok = true;
  
} /* QsoImpl::QsoImpl */