Lots of bug fixing, and 4.7 merges
[SCSI2SD-V6.git] / src / scsi2sd-util6 / TargetPanel.cc
1 //      Copyright (C) 2014 Michael McMaster <michael@codesrc.com>
2 //
3 //      This file is part of SCSI2SD.
4 //
5 //      SCSI2SD is free software: you can redistribute it and/or modify
6 //      it under the terms of the GNU General Public License as published by
7 //      the Free Software Foundation, either version 3 of the License, or
8 //      (at your option) any later version.
9 //
10 //      SCSI2SD is distributed in the hope that it will be useful,
11 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //      GNU General Public License for more details.
14 //
15 //      You should have received a copy of the GNU General Public License
16 //      along with SCSI2SD.  If not, see <http://www.gnu.org/licenses/>.
17
18 // For compilers that support precompilation, includes "wx/wx.h".
19 #include <wx/wxprec.h>
20 #ifndef WX_PRECOMP
21 #include <wx/wx.h>
22 #endif
23
24 #include <wx/wrapsizer.h>
25
26 #include "ConfigUtil.hh"
27 #include "TargetPanel.hh"
28
29 #include <limits>
30 #include <sstream>
31
32 #include <math.h>
33 #include <string.h>
34
35 using namespace SCSI2SD;
36
37 wxDEFINE_EVENT(SCSI2SD::ConfigChangedEvent, wxCommandEvent);
38
39 namespace
40 {
41         template<typename IntType, class WXCTRL> std::pair<IntType, bool>
42         CtrlGetValue(WXCTRL* ctrl)
43         {
44                 IntType value;
45                 std::stringstream conv;
46                 conv << ctrl->GetValue();
47                 conv >> value;
48                 return std::make_pair(value, static_cast<bool>(conv));
49         }
50
51         void CtrlGetFixedString(wxTextEntry* ctrl, char* dest, size_t len)
52         {
53                 memset(dest, ' ', len);
54                 std::string str(ctrl->GetValue().ToAscii());
55                 // Don't use strncpy - we need to avoid NULL's
56                 memcpy(dest, str.c_str(), std::min(len, str.size()));
57         }
58
59         bool CtrlIsAscii(wxTextEntry* ctrl)
60         {
61                 return ctrl->GetValue().IsAscii();
62         }
63
64 }
65
66 TargetPanel::TargetPanel(wxWindow* parent, const S2S_TargetCfg& initialConfig) :
67         wxPanel(parent),
68         myParent(parent),
69         myAutoStartSector(0),
70         myStartSDSectorValidator(new wxIntegerValidator<uint32_t>),
71         mySectorSizeValidator(new wxIntegerValidator<uint16_t>),
72         myNumSectorValidator(new wxIntegerValidator<uint32_t>),
73         mySizeValidator(new wxFloatingPointValidator<float>(2))
74 {
75         wxFlexGridSizer *fgs = new wxFlexGridSizer(11, 3, 9, 25);
76
77         fgs->Add(new wxStaticText(this, wxID_ANY, wxT("")));
78         myEnableCtrl =
79                 new wxCheckBox(
80                         this,
81                         ID_enableCtrl,
82                         _("Enable SCSI Target"));
83         fgs->Add(myEnableCtrl);
84         // Set a non-visible string to leave room in the column for future messages
85         fgs->Add(new wxStaticText(this, wxID_ANY, wxT("                                        ")));
86         Bind(wxEVT_CHECKBOX, &TargetPanel::onInput<wxCommandEvent>, this, ID_enableCtrl);
87
88
89         fgs->Add(new wxStaticText(this, wxID_ANY, _("SCSI ID")));
90         myScsiIdCtrl =
91                 new wxSpinCtrl
92                         (this,
93                         ID_scsiIdCtrl,
94                         wxEmptyString,
95                         wxDefaultPosition,
96                         wxDefaultSize,
97                         wxSP_WRAP | wxSP_ARROW_KEYS,
98                         0,
99                         7,
100                         0);
101         fgs->Add(myScsiIdCtrl);
102         myScsiIdMsg = new wxStaticText(this, wxID_ANY, wxT(""));
103         fgs->Add(myScsiIdMsg);
104         Bind(wxEVT_SPINCTRL, &TargetPanel::onInput<wxSpinEvent>, this, ID_scsiIdCtrl);
105
106         fgs->Add(new wxStaticText(this, wxID_ANY, _("Device Type")));
107         wxString deviceTypes[] =
108         {
109                 _("Hard Drive"),
110                 _("Removable"),
111                 _("CDROM"),
112                 _("3.5\" Floppy"),
113                 _("Magneto optical")
114         };
115         myDeviceTypeCtrl =
116                 new wxChoice(
117                         this,
118                         ID_deviceTypeCtrl,
119                         wxDefaultPosition,
120                         wxDefaultSize,
121                         sizeof(deviceTypes) / sizeof(wxString),
122                         deviceTypes
123                         );
124         myDeviceTypeCtrl->SetSelection(0);
125         fgs->Add(myDeviceTypeCtrl);
126         fgs->Add(new wxStaticText(this, wxID_ANY, wxT("")));
127         Bind(wxEVT_CHOICE, &TargetPanel::onInput<wxCommandEvent>, this, ID_deviceTypeCtrl);
128
129         fgs->Add(new wxStaticText(this, wxID_ANY, wxT("SD card start sector")));
130         wxWrapSizer* startContainer = new wxWrapSizer();
131         myStartSDSectorCtrl =
132                 new wxTextCtrl(
133                         this,
134                         ID_startSDSectorCtrl,
135                         "0",
136                         wxDefaultPosition,
137                         wxDefaultSize,
138                         0,
139                         *myStartSDSectorValidator);
140         myStartSDSectorCtrl->SetToolTip(wxT("Supports multiple SCSI targets "
141                 "on a single memory card. In units of 512-byte sectors."));
142         startContainer->Add(myStartSDSectorCtrl);
143         myAutoStartSectorCtrl =
144                 new wxCheckBox(
145                         this,
146                         ID_autoStartSectorCtrl,
147                         wxT("Auto"));
148         startContainer->Add(myAutoStartSectorCtrl);
149         Bind(wxEVT_CHECKBOX, &TargetPanel::onInput<wxCommandEvent>, this, ID_autoStartSectorCtrl);
150         fgs->Add(startContainer);
151         myStartSDSectorMsg = new wxStaticText(this, wxID_ANY, wxT(""));
152         fgs->Add(myStartSDSectorMsg);
153         Bind(wxEVT_TEXT, &TargetPanel::onInput<wxCommandEvent>, this, ID_startSDSectorCtrl);
154
155
156         fgs->Add(new wxStaticText(this, wxID_ANY, wxT("Sector size (bytes)")));
157         mySectorSizeCtrl =
158                 new wxTextCtrl(
159                         this,
160                         ID_sectorSizeCtrl,
161                         "512",
162                         wxDefaultPosition,
163                         wxDefaultSize,
164                         0,
165                         *mySectorSizeValidator);
166         mySectorSizeCtrl->SetToolTip(wxT("Between 64 and 8192. Default of 512 is suitable in most cases."));
167         fgs->Add(mySectorSizeCtrl);
168         mySectorSizeMsg = new wxStaticText(this, wxID_ANY, wxT(""));
169         fgs->Add(mySectorSizeMsg);
170         Bind(wxEVT_TEXT, &TargetPanel::onSizeInput, this, ID_sectorSizeCtrl);
171
172
173         fgs->Add(new wxStaticText(this, wxID_ANY, wxT("Sector count")));
174         myNumSectorCtrl =
175                 new wxTextCtrl(
176                         this,
177                         ID_numSectorCtrl,
178                         "",
179                         wxDefaultPosition,
180                         wxDefaultSize,
181                         0,
182                         *myNumSectorValidator);
183         myNumSectorCtrl->SetToolTip(wxT("Number of sectors (device size)"));
184         fgs->Add(myNumSectorCtrl);
185         myNumSectorMsg = new wxStaticText(this, wxID_ANY, wxT(""));
186         fgs->Add(myNumSectorMsg);
187         Bind(wxEVT_TEXT, &TargetPanel::onSizeInput, this, ID_numSectorCtrl);
188
189
190         fgs->Add(new wxStaticText(this, wxID_ANY, wxT("Device size")));
191         wxWrapSizer* sizeContainer = new wxWrapSizer();
192         mySizeCtrl =
193                 new wxTextCtrl(
194                         this,
195                         ID_sizeCtrl,
196                         "",
197                         wxDefaultPosition,
198                         wxDefaultSize,
199                         0,
200                         *mySizeValidator);
201         mySizeCtrl->SetToolTip(wxT("Device size"));
202         sizeContainer->Add(mySizeCtrl);
203         wxString units[] = {wxT("KB"), wxT("MB"), wxT("GB")};
204         mySizeUnitCtrl =
205                 new wxChoice(
206                         this,
207                         ID_sizeUnitCtrl,
208                         wxDefaultPosition,
209                         wxDefaultSize,
210                         sizeof(units) / sizeof(wxString),
211                         units
212                         );
213         sizeContainer->Add(mySizeUnitCtrl);
214         fgs->Add(sizeContainer);
215         fgs->Add(new wxStaticText(this, wxID_ANY, wxT("")));
216         Bind(wxEVT_TEXT, &TargetPanel::onSizeInput, this, ID_sizeCtrl);
217         Bind(wxEVT_CHOICE, &TargetPanel::onSizeInput, this, ID_sizeUnitCtrl);
218
219         fgs->Add(new wxStaticText(this, wxID_ANY, wxT("Vendor")));
220         myVendorCtrl =
221                 new wxTextCtrl(
222                         this,
223                         ID_vendorCtrl,
224                         wxEmptyString,
225                         wxDefaultPosition,
226                         wxSize(GetCharWidth() * 10, -1));
227         myVendorCtrl->SetMaxLength(8);
228         myVendorCtrl->SetToolTip(wxT("SCSI Vendor string. eg. ' codesrc'"));
229         fgs->Add(myVendorCtrl);
230         myVendorMsg = new wxStaticText(this, wxID_ANY, wxT(""));
231         fgs->Add(myVendorMsg);
232         Bind(wxEVT_TEXT, &TargetPanel::onInput<wxCommandEvent>, this, ID_vendorCtrl);
233
234         fgs->Add(new wxStaticText(this, wxID_ANY, wxT("Product ID")));
235         myProductCtrl =
236                 new wxTextCtrl(
237                         this,
238                         ID_productCtrl,
239                         wxEmptyString,
240                         wxDefaultPosition,
241                         wxSize(GetCharWidth() * 17, -1));
242         myProductCtrl->SetMaxLength(18);
243         myProductCtrl->SetToolTip(wxT("SCSI Product ID string. eg. 'SCSI2SD'"));
244         fgs->Add(myProductCtrl);
245         myProductMsg = new wxStaticText(this, wxID_ANY, wxT(""));
246         fgs->Add(myProductMsg);
247         Bind(wxEVT_TEXT, &TargetPanel::onInput<wxCommandEvent>, this, ID_productCtrl);
248
249         fgs->Add(new wxStaticText(this, wxID_ANY, wxT("Revision")));
250         myRevisionCtrl =
251                 new wxTextCtrl(
252                         this,
253                         ID_revisionCtrl,
254                         wxEmptyString,
255                         wxDefaultPosition,
256                         wxSize(GetCharWidth() * 6, -1));
257         myRevisionCtrl->SetMaxLength(4);
258         myRevisionCtrl->SetToolTip(wxT("SCSI device revision string. eg. '3.5a'"));
259         fgs->Add(myRevisionCtrl);
260         myRevisionMsg = new wxStaticText(this, wxID_ANY, wxT(""));
261         fgs->Add(myRevisionMsg);
262         Bind(wxEVT_TEXT, &TargetPanel::onInput<wxCommandEvent>, this, ID_revisionCtrl);
263
264         fgs->Add(new wxStaticText(this, wxID_ANY, wxT("Serial number")));
265         mySerialCtrl =
266                 new wxTextCtrl(
267                         this,
268                         ID_serialCtrl,
269                         wxEmptyString,
270                         wxDefaultPosition,
271                         wxSize(GetCharWidth() * 18, -1));
272         mySerialCtrl->SetMaxLength(16);
273         mySerialCtrl->SetToolTip(wxT("SCSI serial number. eg. '13eab5632a'"));
274         fgs->Add(mySerialCtrl);
275         mySerialMsg = new wxStaticText(this, wxID_ANY, wxT(""));
276         fgs->Add(mySerialMsg);
277         Bind(wxEVT_TEXT, &TargetPanel::onInput<wxCommandEvent>, this, ID_serialCtrl);
278
279         wxBoxSizer* hbox = new wxBoxSizer(wxHORIZONTAL);
280         hbox->Add(fgs, 1, wxALL | wxEXPAND, 15);
281         this->SetSizer(hbox);
282         Centre();
283
284
285         setConfig(initialConfig);
286         evaluate();
287 }
288
289 bool
290 TargetPanel::evaluate()
291 {
292         bool valid = true;
293         std::stringstream conv;
294
295         bool enabled = myEnableCtrl->IsChecked();
296         {
297                 myScsiIdCtrl->Enable(enabled);
298                 myDeviceTypeCtrl->Enable(enabled);
299                 myStartSDSectorCtrl->Enable(enabled && !myAutoStartSectorCtrl->IsChecked());
300                 myAutoStartSectorCtrl->Enable(enabled);
301                 mySectorSizeCtrl->Enable(enabled);
302                 myNumSectorCtrl->Enable(enabled);
303                 mySizeCtrl->Enable(enabled);
304                 mySizeUnitCtrl->Enable(enabled);
305                 myVendorCtrl->Enable(enabled);
306                 myProductCtrl->Enable(enabled);
307                 myRevisionCtrl->Enable(enabled);
308                 mySerialCtrl->Enable(enabled);
309         }
310
311         switch (myDeviceTypeCtrl->GetSelection())
312         {
313         case S2S_CFG_OPTICAL:
314                 mySectorSizeCtrl->ChangeValue("2048");
315                 mySectorSizeCtrl->Enable(true); // Enable override
316                 break;
317         case S2S_CFG_FLOPPY_14MB:
318                 mySectorSizeCtrl->ChangeValue("512");
319                 mySectorSizeCtrl->Enable(false);
320                 myNumSectorCtrl->ChangeValue("2880");
321                 myNumSectorCtrl->Enable(false);
322                 mySizeUnitCtrl->Enable(false);
323                 mySizeCtrl->Enable(false);
324                 break;
325         };
326         evaluateSize();
327
328         if (myAutoStartSectorCtrl->IsChecked())
329         {
330                 std::stringstream ss; ss << myAutoStartSector;
331                 myStartSDSectorCtrl->ChangeValue(ss.str());
332         }
333
334         uint32_t startSDsector;
335         {
336                 conv << myStartSDSectorCtrl->GetValue();
337                 conv >> startSDsector;
338         }
339
340         if (!conv)
341                 // TODO check if it is beyond the current SD card.
342         {
343                 myStartSDSectorMsg->SetLabelMarkup(wxT("<span foreground='red' weight='bold'>Number &gt;= 0</span>"));
344                 valid = false;
345         }
346         else
347         {
348                 myStartSDSectorMsg->SetLabelMarkup("");
349         }
350         conv.str(std::string()); conv.clear();
351
352         uint16_t sectorSize(CtrlGetValue<uint16_t>(mySectorSizeCtrl).first);
353         if (sectorSize < 64 || sectorSize > 8192)
354         {
355                 mySectorSizeMsg->SetLabelMarkup(wxT("<span foreground='red' weight='bold'>Must be between 64 and 8192</span>"));
356                 valid = false;
357         }
358         else
359         {
360                 mySectorSizeMsg->SetLabelMarkup("");
361         }
362         conv.str(std::string()); conv.clear();
363
364         std::pair<uint32_t, bool> numSectors(CtrlGetValue<uint32_t>(myNumSectorCtrl));
365         if (!numSectors.second ||
366                 numSectors.first == 0 ||
367                 !convertUnitsToSectors().second)
368         {
369                 myNumSectorMsg->SetLabelMarkup(wxT("<span foreground='red' weight='bold'>Invalid size</span>"));
370                 valid = false;
371         }
372         else
373         {
374                 myNumSectorMsg->SetLabelMarkup("");
375         }
376
377         if (!CtrlIsAscii(myVendorCtrl))
378         {
379                 myVendorMsg->SetLabelMarkup(wxT("<span foreground='red' weight='bold'>Invalid characters</span>"));
380                 valid = false;
381         }
382         else
383         {
384                 myVendorMsg->SetLabelMarkup("");
385         }
386
387         if (!CtrlIsAscii(myProductCtrl))
388         {
389                 myProductMsg->SetLabelMarkup(wxT("<span foreground='red' weight='bold'>Invalid characters</span>"));
390                 valid = false;
391         }
392         else
393         {
394                 myProductMsg->SetLabelMarkup("");
395         }
396
397         if (!CtrlIsAscii(myRevisionCtrl))
398         {
399                 myRevisionMsg->SetLabelMarkup(wxT("<span foreground='red' weight='bold'>Invalid characters</span>"));
400                 valid = false;
401         }
402         else
403         {
404                 myRevisionMsg->SetLabelMarkup("");
405         }
406
407         if (!CtrlIsAscii(mySerialCtrl))
408         {
409                 mySerialMsg->SetLabelMarkup(wxT("<span foreground='red' weight='bold'>Invalid characters</span>"));
410                 valid = false;
411         }
412         else
413         {
414                 mySerialMsg->SetLabelMarkup("");
415         }
416
417         return valid || !enabled;
418 }
419
420 template<typename EvtType> void
421 TargetPanel::onInput(EvtType& event)
422 {
423         wxCommandEvent changeEvent(ConfigChangedEvent);
424         wxPostEvent(myParent, changeEvent);
425 }
426
427 void
428 TargetPanel::onSizeInput(wxCommandEvent& event)
429 {
430         if (event.GetId() != ID_numSectorCtrl)
431         {
432                 std::stringstream ss;
433                 ss << convertUnitsToSectors().first;
434                 myNumSectorCtrl->ChangeValue(ss.str());
435         }
436         evaluateSize();
437         onInput(event); // propagate
438 }
439
440 void
441 TargetPanel::evaluateSize()
442 {
443         uint32_t numSectors;
444         std::stringstream conv;
445         conv << myNumSectorCtrl->GetValue();
446         conv >> numSectors;
447
448         conv.str(""); conv.clear();
449
450         if (conv)
451         {
452                 uint64_t bytes =
453                         uint64_t(numSectors) *
454                                 CtrlGetValue<uint16_t>(mySectorSizeCtrl).first;
455
456                 if (bytes >= 1024 * 1024 * 1024)
457                 {
458                         conv << (bytes / (1024.0 * 1024 * 1024));
459                         mySizeUnitCtrl->SetSelection(UNIT_GB);
460                 }
461                 else if (bytes >= 1024 * 1024)
462                 {
463                         conv << (bytes / (1024.0 * 1024));
464                         mySizeUnitCtrl->SetSelection(UNIT_MB);
465                 }
466                 else
467                 {
468                         conv << (bytes / 1024.0);
469                         mySizeUnitCtrl->SetSelection(UNIT_KB);
470                 }
471                 mySizeCtrl->ChangeValue(conv.str());
472         }
473 }
474
475 std::pair<uint32_t, bool>
476 TargetPanel::convertUnitsToSectors() const
477 {
478         bool valid = true;
479
480         uint64_t multiplier(0);
481         switch (mySizeUnitCtrl->GetSelection())
482         {
483                 case UNIT_KB: multiplier = 1024; break;
484                 case UNIT_MB: multiplier = 1024 * 1024; break;
485                 case UNIT_GB: multiplier = 1024 * 1024 * 1024; break;
486                 default: valid = false;
487         }
488
489         double size;
490         std::stringstream conv;
491         conv << mySizeCtrl->GetValue();
492         conv >> size;
493         valid = valid && conv;
494
495         uint16_t sectorSize = CtrlGetValue<uint16_t>(mySectorSizeCtrl).first;
496         uint64_t sectors = ceil(multiplier * size / sectorSize);
497
498         if (sectors > std::numeric_limits<uint32_t>::max())
499         {
500                 sectors = std::numeric_limits<uint32_t>::max();
501                 valid = false;
502         }
503
504         return std::make_pair(static_cast<uint32_t>(sectors), valid);
505 }
506
507
508 S2S_TargetCfg
509 TargetPanel::getConfig() const
510 {
511         S2S_TargetCfg config;
512
513         // Try and keep unknown/unused fields as-is to support newer firmware
514         // versions.
515         memcpy(&config, &myConfig, sizeof(config));
516
517         bool valid = true;
518
519         auto scsiId = CtrlGetValue<uint8_t>(myScsiIdCtrl);
520         config.scsiId = scsiId.first & S2S_CFG_TARGET_ID_BITS;
521         valid = valid && scsiId.second;
522         if (myEnableCtrl->IsChecked())
523         {
524                 config.scsiId = config.scsiId | S2S_CFG_TARGET_ENABLED;
525         }
526
527         config.deviceType = myDeviceTypeCtrl->GetSelection();
528
529         auto startSDSector = CtrlGetValue<uint32_t>(myStartSDSectorCtrl);
530         config.sdSectorStart = startSDSector.first;
531         valid = valid && startSDSector.second;
532
533         auto numSectors = CtrlGetValue<uint32_t>(myNumSectorCtrl);
534         config.scsiSectors = numSectors.first;
535         valid = valid && numSectors.second;
536
537         auto sectorSize = CtrlGetValue<uint16_t>(mySectorSizeCtrl);
538         config.bytesPerSector = sectorSize.first;
539         valid = valid && sectorSize.second;
540
541         CtrlGetFixedString(myVendorCtrl, config.vendor, sizeof(config.vendor));
542         CtrlGetFixedString(myProductCtrl, config.prodId, sizeof(config.prodId));
543         CtrlGetFixedString(myRevisionCtrl, config.revision, sizeof(config.revision));
544         CtrlGetFixedString(mySerialCtrl, config.serial, sizeof(config.serial));
545
546         return config;
547 }
548
549 void
550 TargetPanel::setConfig(const S2S_TargetCfg& config)
551 {
552         memcpy(&myConfig, &config, sizeof(config));
553
554         myScsiIdCtrl->SetValue(config.scsiId & S2S_CFG_TARGET_ID_BITS);
555         myEnableCtrl->SetValue(config.scsiId & S2S_CFG_TARGET_ENABLED);
556
557         myDeviceTypeCtrl->SetSelection(config.deviceType);
558
559         {
560                 std::stringstream ss; ss << config.sdSectorStart;
561                 myStartSDSectorCtrl->ChangeValue(ss.str());
562                 myAutoStartSectorCtrl->SetValue(0);
563         }
564
565         {
566                 std::stringstream ss; ss << config.scsiSectors;
567                 myNumSectorCtrl->ChangeValue(ss.str());
568         }
569
570         {
571                 std::stringstream ss; ss << config.bytesPerSector;
572                 mySectorSizeCtrl->ChangeValue(ss.str());
573         }
574
575         myVendorCtrl->ChangeValue(std::string(config.vendor, sizeof(config.vendor)));
576         myProductCtrl->ChangeValue(std::string(config.prodId, sizeof(config.prodId)));
577         myRevisionCtrl->ChangeValue(std::string(config.revision, sizeof(config.revision)));
578         mySerialCtrl->ChangeValue(std::string(config.serial, sizeof(config.serial)));
579
580         // Set the size fields based on sector size, and evaluate inputs.
581         wxCommandEvent fakeEvent(wxEVT_NULL, ID_numSectorCtrl);
582         onSizeInput(fakeEvent);
583 }
584
585 bool
586 TargetPanel::isEnabled() const
587 {
588         return myEnableCtrl->IsChecked();
589 }
590
591 uint8_t
592 TargetPanel::getSCSIId() const
593 {
594         return CtrlGetValue<uint8_t>(myScsiIdCtrl).first & S2S_CFG_TARGET_ID_BITS;
595 }
596
597 std::pair<uint32_t, uint64_t>
598 TargetPanel::getSDSectorRange() const
599 {
600         std::pair<uint32_t, uint64_t> result;
601         result.first = CtrlGetValue<uint32_t>(myStartSDSectorCtrl).first;
602
603         uint32_t numSCSISectors = CtrlGetValue<uint32_t>(myNumSectorCtrl).first;
604         uint16_t scsiSectorSize = CtrlGetValue<uint16_t>(mySectorSizeCtrl).first;
605
606         const int sdSector = 512; // Always 512 for SDHC/SDXC
607         result.second = result.first +
608                 (
609                         ((uint64_t(numSCSISectors) * scsiSectorSize) + (sdSector - 1))
610                                 / sdSector
611                 );
612         return result;
613 }
614
615 void
616 TargetPanel::setDuplicateID(bool duplicate)
617 {
618         if (duplicate)
619         {
620                 myScsiIdMsg->SetLabelMarkup(wxT("<span foreground='red' weight='bold'>Duplicate ID</span>"));
621         }
622         else
623         {
624                 myScsiIdMsg->SetLabelMarkup("");
625         }
626 }
627
628 void
629 TargetPanel::setSDSectorOverlap(bool overlap)
630 {
631         if (overlap)
632         {
633                 myStartSDSectorMsg->SetLabelMarkup(wxT("<span foreground='red' weight='bold'>Overlapping data</span>"));
634         }
635         else
636         {
637                 myStartSDSectorMsg->SetLabelMarkup("");
638         }
639 }
640
641 void
642 TargetPanel::setAutoStartSector(uint32_t start)
643 {
644         myAutoStartSector = start;
645 }
646