Ejemplo n.º 1
0
void
ManagedFileListWidget::RefreshList()
{
  items.clear();

  bool download_active = false;
  for (auto i = repository.begin(), end = repository.end(); i != end; ++i) {
    const auto &remote_file = *i;
    DownloadStatus download_status;
    const bool is_downloading = IsDownloading(remote_file, download_status);

    TCHAR path[MAX_PATH];
    if (LocalPath(path, remote_file) &&
        (is_downloading || File::Exists(path))) {
      download_active |= is_downloading;
      items.append().Set(BaseName(path),
                         is_downloading ? &download_status : NULL,
                         HasFailed(remote_file));
    }
  }

  ListControl &list = GetList();
  list.SetLength(items.size());
  list.Invalidate();

#ifdef HAVE_DOWNLOAD_MANAGER
  if (download_active && !Timer::IsActive())
    Timer::Schedule(1000);
#endif
}
Ejemplo n.º 2
0
  int AppendMode(const TCHAR *name) {
    if (modes.full())
      return -1;

    modes.append() = name;
    return modes.size() - 1;
  }
Ejemplo n.º 3
0
void
ManagedFileListWidget::RefreshList()
{
  items.clear();

  bool download_active = false;
  for (auto i = repository.begin(), end = repository.end(); i != end; ++i) {
    const auto &remote_file = *i;
    DownloadStatus download_status;
    const bool is_downloading = IsDownloading(remote_file, download_status);

    const auto path = LocalPath(remote_file);
    if (!path.IsNull() &&
        (is_downloading || File::Exists(path))) {
      download_active |= is_downloading;

      const Path base = path.GetBase();
      if (base.IsNull())
        continue;

      items.append().Set(base.c_str(),
                         is_downloading ? &download_status : nullptr,
                         HasFailed(remote_file));
    }
  }

  ListControl &list = GetList();
  list.SetLength(items.size());
  list.Invalidate();

#ifdef HAVE_DOWNLOAD_MANAGER
  if (download_active && !Timer::IsActive())
    Timer::Schedule(1000);
#endif
}
Ejemplo n.º 4
0
inline void
WifiListWidget::Append(const WifiConfiguredNetworkInfo &src)
{
  auto &dest = networks.append();
  dest.bssid = src.bssid;
  dest.ssid = src.ssid;
  dest.id = src.id;
  dest.signal_level = -1;
  dest.old_configured = false;
}
Ejemplo n.º 5
0
bool
KRT2Device::DataReceived(const void *_data, size_t length,
                         struct NMEAInfo &info)
{
  assert(length > 0);

  const char *data = static_cast<const char *>(_data);
  const char *end = data + length;
  bool result = false;

  unsigned expected_size = 0;
  do {
    if (!input_buffer.empty()) {
      input_buffer.append(*data);
      if (!expected_size)
        expected_size = FrameSize(input_buffer[1]);

      if (input_buffer.size() == expected_size) {
        // frame complete
        result |= ParseFrame(info);
        input_buffer.clear();
      } else if (input_buffer.full()) {
        // too much data (will never happen when buffer >= max(expected_size))
        input_buffer.clear();
      }
    } else if (*data == SYNC) {
      // reply to SYNC from radio
      port.Write(SYNC_ACK);
    } else if (*data == STX) {
      // found start of new frame
      input_buffer.append(*data);
      expected_size = 0;
    } else if (*data == ACK) {
      // previous command accepted
    } else if (*data == NAK) {
      // previous command rejected
    }
  } while (++data != end);

  return result;
}
Ejemplo n.º 6
0
  unsigned AppendEvent(pt2Event handler, const TCHAR *misc,
                       unsigned next) {
    if (events.full())
      return 0;

    Event &event = events.append();
    event.event = handler;
    event.misc = misc;
    event.next = next;

    return events.size() - 1;
  }
Ejemplo n.º 7
0
inline void
WifiListWidget::MergeList(const WifiVisibleNetwork *p, unsigned n)
{
  for (unsigned i = 0; i < unsigned(n); ++i) {
    const auto &found = p[i];

    auto info = FindByBSSID(found.bssid);
    if (info == nullptr) {
      info = &networks.append();
      info->bssid = found.bssid;
      info->id = -1;
    }

    info->ssid = found.ssid;
    info->signal_level = found.signal_level;
    info->security = found.security;
    info->old_visible = false;
  }
}
Ejemplo n.º 8
0
 /**
  * Allocates a new FLARM_TRAFFIC object from the array.
  *
  * @return the FLARM_TRAFFIC pointer, NULL if the array is full
  */
 FlarmTraffic *AllocateTraffic() {
   return list.full()
     ? NULL
     : &list.append();
 }
Ejemplo n.º 9
0
void
dlgQuickMenuShowModal(SingleWindow &parent)
{
  const Menu *menu = InputEvents::GetMenu(_T("RemoteStick"));
  if (menu == NULL)
    return;

  const DialogLook &dialog_look = UIGlobals::GetDialogLook();

  WindowStyle dialogStyle;
  dialogStyle.Hide();
  dialogStyle.ControlParent();

  wf = new WndForm(parent, dialog_look, parent.get_client_rect(),
                   _T("Quick Menu"), dialogStyle);

  ContainerWindow &client_area = wf->GetClientAreaWindow();

  PixelRect r = client_area.get_client_rect();

  WindowStyle grid_view_style;
  grid_view_style.ControlParent();

  grid_view = new GridView(client_area,
                           r.left, r.top,
                           r.right - r.left, r.bottom - r.top,
                           dialog_look, grid_view_style);

  WindowStyle buttonStyle;
  buttonStyle.TabStop();

  for (unsigned i = 0; i < menu->MAX_ITEMS; ++i) {
    if (buttons.full())
      continue;

    const MenuItem &menuItem = (*menu)[i];
    if (!menuItem.IsDefined())
      continue;

    TCHAR buffer[100];
    ButtonLabel::Expanded expanded =
      ButtonLabel::Expand(menuItem.label, buffer, ARRAY_SIZE(buffer));
    if (!expanded.visible)
      continue;

    PixelRect button_rc;
    button_rc.left = 0;
    button_rc.top = 0;
    button_rc.right = 80;
    button_rc.bottom = 30;
    WndButton *button =
      new WndCustomButton(*grid_view, dialog_look, expanded.text,
                          button_rc, buttonStyle, OnButtonClicked);
    button->set_enabled(expanded.enabled);

    buttons.append(button);
    events.append(menuItem.event);
  }

  grid_view->SetItems(buttons);
  SetFormDefaultFocus();
  SetFormCaption();

  wf->SetKeyDownNotify(FormKeyDown);

  wf->ShowModal();

  for (auto it = buttons.begin(), end = buttons.end(); it != end; ++it)
    delete *it;

  buttons.clear();
  events.clear();

  delete wf;
  delete grid_view;
}