summaryrefslogtreecommitdiffstats
path: root/src/progs/base/prog_config.cpp
blob: 9802fbad4a785ccb475e53f160f229f58236bd0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/***************************************************************************
 *   Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org>             *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/
#include "prog_config.h"

//----------------------------------------------------------------------------
PortType Programmer::GroupConfig::portType(const Group &group)
{
  GenericConfig config(group.name());
  PortType ctype = config.readEnumEntry<PortType>("port_group");
  if ( group.isPortSupported(ctype) ) return ctype;
  FOR_EACH(PortType, type) if ( group.isPortSupported(type) ) return type;
  return PortType::Nb_Types;
}
void Programmer::GroupConfig::writePortType(const Group &group, PortType type)
{
  if ( type==PortType::Nb_Types ) return;
  GenericConfig config(group.name());
  config.writeEnumEntry<PortType>("port_group", type);
}

TQString Programmer::GroupConfig::portDevice(const Group &group, PortType portType)
{
  GenericConfig config(group.name());
  TQString device = config.readEntry(TQString(portType.key()) + "_port_device" , TQString());
  if ( device.isNull() ) {
    TQStringList list = Port::probedDeviceList(portType);
    if ( list.isEmpty() ) return TQString();
    return list[0];
  }
  return device;
}
void Programmer::GroupConfig::writePortDevice(const Group &group, PortType type, const TQString &device)
{
  if ( type==PortType::Nb_Types ) return;
  GenericConfig config(group.name());
  config.writeEntry(TQString(type.key()) + "_port_device", device);
}

Port::Description Programmer::GroupConfig::portDescription(const Group &group)
{
  PortType type = portType(group);
  return Port::Description(type, portDevice(group, type));
}
void Programmer::GroupConfig::writePortDescription(const Group &group, const Port::Description &dp)
{
  writePortType(group, dp.type);
  writePortDevice(group, dp.type, dp.device);
}

TQString Programmer::GroupConfig::firmwareDirectory(const Group &group)
{
  GenericConfig config(group.name());
  return config.readEntry("firmware_directory", TQString());
}
void Programmer::GroupConfig::writeFirmwareDirectory(const Group &group, const TQString &path)
{
  GenericConfig config(group.name());
  config.writeEntry("firmware_directory", path);
}

//----------------------------------------------------------------------------
const Programmer::Config::Data Programmer::Config::DATA[Nb_Types] = {
  { "only_program_non_tqmask", I18N_NOOP("Only program what is needed (faster)."), TQVariant(true, 0) },
  { "verify_after_program", I18N_NOOP("Verify device memory after programming."), TQVariant(true, 0) },
  { "only_verify_programmed", I18N_NOOP("Only verify programmed words in code memory (faster)."), TQVariant(true, 0) },
  { "power_down_after_programming", I18N_NOOP("Power down target after programming."), TQVariant(true, 0) },
  { "target_self_powered", I18N_NOOP("Target is self-powered (when possible)."), TQVariant(true, 0) },
  { "blank_check_after_erase", I18N_NOOP("Blank check after erase."), TQVariant(false, 0) },
  { "preserve_eeprom", I18N_NOOP("Preserve data EEPROM when programming."), TQVariant(false, 0) },
  { "program_eeprom", I18N_NOOP("Program data EEPROM."), TQVariant(true, 0) },
  { "run_after_program", I18N_NOOP("Run device after successful programming."), TQVariant(false, 0) }
};