diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2014-04-07 11:28:04 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2014-05-01 19:34:18 +0200 |
commit | 4356666101e0e7985e65a19f86bc4a74519e93f9 (patch) | |
tree | bf8de8057d93d0fab0a30cae92a90f5a4edc79dc /utils/regtools/qeditor/backend.cpp | |
parent | 3754624edc48539c5cc5acbf426ce909477e87d8 (diff) | |
download | rockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.tar.gz rockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.zip |
regtools: completely rework qeditor, improve soc desc library and tools
The graphical editor can now display and editor description files.
The library has been improved to provide more useful function.
The XML format has been slightly changed: only one soc is allowed per file
(this is was already de facto the case since <soc> was the root tag).
Also introduce a DTD to validate the files.
Change-Id: If70ba35b6dc0242bdb87411cf4baee9597798aac
Diffstat (limited to 'utils/regtools/qeditor/backend.cpp')
-rw-r--r-- | utils/regtools/qeditor/backend.cpp | 67 |
1 files changed, 48 insertions, 19 deletions
diff --git a/utils/regtools/qeditor/backend.cpp b/utils/regtools/qeditor/backend.cpp index eebda31989..204c160054 100644 --- a/utils/regtools/qeditor/backend.cpp +++ b/utils/regtools/qeditor/backend.cpp | |||
@@ -5,6 +5,36 @@ | |||
5 | #include "backend.h" | 5 | #include "backend.h" |
6 | 6 | ||
7 | /** | 7 | /** |
8 | * SocFile | ||
9 | */ | ||
10 | SocFile::SocFile() | ||
11 | :m_valid(false) | ||
12 | { | ||
13 | } | ||
14 | |||
15 | SocFile::SocFile(const QString& filename) | ||
16 | :m_filename(filename) | ||
17 | { | ||
18 | m_valid = soc_desc_parse_xml(filename.toStdString(), m_soc); | ||
19 | soc_desc_normalize(m_soc); | ||
20 | } | ||
21 | |||
22 | bool SocFile::IsValid() | ||
23 | { | ||
24 | return m_valid; | ||
25 | } | ||
26 | |||
27 | SocRef SocFile::GetSocRef() | ||
28 | { | ||
29 | return SocRef(this); | ||
30 | } | ||
31 | |||
32 | QString SocFile::GetFilename() | ||
33 | { | ||
34 | return m_filename; | ||
35 | } | ||
36 | |||
37 | /** | ||
8 | * Backend | 38 | * Backend |
9 | */ | 39 | */ |
10 | 40 | ||
@@ -12,33 +42,31 @@ Backend::Backend() | |||
12 | { | 42 | { |
13 | } | 43 | } |
14 | 44 | ||
15 | QStringList Backend::GetSocNameList() | 45 | |
46 | QList< SocFileRef > Backend::GetSocFileList() | ||
16 | { | 47 | { |
17 | QStringList sl; | 48 | QList< SocFileRef > list; |
18 | foreach(const soc_t& soc, m_socs) | 49 | for(std::list< SocFile >::iterator it = m_socs.begin(); it != m_socs.end(); ++it) |
19 | sl.append(QString(soc.name.c_str())); | 50 | list.append(SocFileRef(&(*it))); |
20 | return sl; | 51 | return list; |
21 | } | 52 | } |
22 | 53 | ||
23 | bool Backend::GetSocByName(const QString& name, SocRef& s) | 54 | QList< SocRef > Backend::GetSocList() |
24 | { | 55 | { |
25 | for(std::list< soc_t >::iterator it = m_socs.begin(); it != m_socs.end(); ++it) | 56 | QList< SocRef > list; |
26 | if(it->name == name.toStdString()) | 57 | for(std::list< SocFile >::iterator it = m_socs.begin(); it != m_socs.end(); ++it) |
27 | { | 58 | list.append(it->GetSocRef()); |
28 | s = SocRef(&(*it)); | 59 | return list; |
29 | return true; | ||
30 | } | ||
31 | return false; | ||
32 | } | 60 | } |
33 | 61 | ||
34 | bool Backend::LoadSocDesc(const QString& filename) | 62 | bool Backend::LoadSocDesc(const QString& filename) |
35 | { | 63 | { |
36 | std::vector< soc_t > new_socs; | 64 | SocFile f(filename); |
37 | bool ret = soc_desc_parse_xml(filename.toStdString(), new_socs); | 65 | if(!f.IsValid()) |
38 | for(size_t i = 0; i < new_socs.size(); i++) | 66 | return false; |
39 | m_socs.push_back(new_socs[i]); | 67 | m_socs.push_back(f); |
40 | emit OnSocListChanged(); | 68 | emit OnSocListChanged(); |
41 | return ret; | 69 | return true; |
42 | } | 70 | } |
43 | 71 | ||
44 | IoBackend *Backend::CreateFileIoBackend(const QString& filename) | 72 | IoBackend *Backend::CreateFileIoBackend(const QString& filename) |
@@ -321,7 +349,7 @@ HWStubBackendHelper::HWStubBackendHelper() | |||
321 | if(m_hotplug) | 349 | if(m_hotplug) |
322 | { | 350 | { |
323 | m_hotplug = LIBUSB_SUCCESS == libusb_hotplug_register_callback( | 351 | m_hotplug = LIBUSB_SUCCESS == libusb_hotplug_register_callback( |
324 | NULL, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT, | 352 | NULL, (libusb_hotplug_event)(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT), |
325 | LIBUSB_HOTPLUG_ENUMERATE, HWSTUB_USB_VID, HWSTUB_USB_PID, HWSTUB_CLASS, | 353 | LIBUSB_HOTPLUG_ENUMERATE, HWSTUB_USB_VID, HWSTUB_USB_PID, HWSTUB_CLASS, |
326 | &HWStubBackendHelper::HotPlugCallback, reinterpret_cast< void* >(this), &m_hotplug_handle); | 354 | &HWStubBackendHelper::HotPlugCallback, reinterpret_cast< void* >(this), &m_hotplug_handle); |
327 | } | 355 | } |
@@ -364,6 +392,7 @@ void HWStubBackendHelper::OnHotPlug(bool arrived, struct libusb_device *dev) | |||
364 | int HWStubBackendHelper::HotPlugCallback(struct libusb_context *ctx, struct libusb_device *dev, | 392 | int HWStubBackendHelper::HotPlugCallback(struct libusb_context *ctx, struct libusb_device *dev, |
365 | libusb_hotplug_event event, void *user_data) | 393 | libusb_hotplug_event event, void *user_data) |
366 | { | 394 | { |
395 | Q_UNUSED(ctx); | ||
367 | HWStubBackendHelper *helper = reinterpret_cast< HWStubBackendHelper* >(user_data); | 396 | HWStubBackendHelper *helper = reinterpret_cast< HWStubBackendHelper* >(user_data); |
368 | switch(event) | 397 | switch(event) |
369 | { | 398 | { |