rockbox/rbutil/rbutilqt/base/autodetection.h
Dominik Riebeling b943c59f35 Rework autodetection to better handle ambiguous cases.
The old detection code simply assumed only one player to be connected and threw
all information it could find together, causing wrong results in various cases.
Rewrite it to better handle this.

- Don't expect only a single player to be attached. Return a list of players
  found instead. The configuration dialog can then show the user a list to
  select from. This is not implemented yet, the configuration dialog will only
  show the devices found and tell the user to disconnect all but one.

- Handle ambiguous cases better. A player found that is ambiguous is treated as
  such, and if refining the result didn't lead to a single match for each
  possible player a single entry is created that indicates it being ambiguous.

The current code needs a bit of additional cleanup (the result exposes internal
data to the caller it shouldn't) to be done later.

Change-Id: I22dc2f73cdd6a9d90c34f3a0703aa9e0a2d2087a
2013-09-18 23:37:39 +02:00

71 lines
1.9 KiB
C++

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2007 by Dominik Wenger
*
* 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.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef AUTODETECTION_H_
#define AUTODETECTION_H_
#include <QObject>
#include <QString>
#include <QList>
#include <QStringList>
class Autodetection :public QObject
{
Q_OBJECT
public:
Autodetection(QObject* parent=0);
enum PlayerStatus {
PlayerOk,
PlayerIncompatible,
PlayerMtpMode,
PlayerWrongFilesystem,
PlayerError,
PlayerAmbiguous,
};
struct Detected {
QString device;
QStringList usbdevices;
QString mountpoint;
enum PlayerStatus status;
};
bool detect();
QList<struct Detected> detected(void) { return m_detected; }
private:
QString resolveMountPoint(QString);
void detectUsb(void);
void mergeMounted(void);
void mergePatcher(void);
QString detectAjbrec(QString);
int findDetectedDevice(QString device);
QList<struct Detected> m_detected;
QList<int> m_usbconid;
};
#endif /*AUTODETECTION_H_*/