gui/hdd_menu.cpp: rework HDD menu, add device mount/umount,

add support for mmc and DVD/BD devices, make easy to add other filesystems mkfs/fsck,
parts based on code (C) martii
This commit is contained in:
[CST] Focus
2014-04-14 14:13:20 +04:00
parent 49177a18f8
commit 37fb9ddc87
2 changed files with 620 additions and 362 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2,12 +2,14 @@
Neutrino-GUI - DBoxII-Project Neutrino-GUI - DBoxII-Project
License: GPL Copyright (C) 2009-2014 CoolStream International Ltd
Copyright (C) 2013-2014 martii
License: GPLv2
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; version 2 of the License.
(at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -28,11 +30,14 @@
using namespace std; using namespace std;
enum { struct devtool_s {
fs_ext3, std::string fmt;
fs_ext4, std::string fsck;
std::string fsck_options;
fs_max std::string mkfs;
std::string mkfs_options;
bool fsck_supported;
bool mkfs_supported;
}; };
class CHDDDestExec : public CMenuTarget class CHDDDestExec : public CMenuTarget
@@ -40,21 +45,50 @@ class CHDDDestExec : public CMenuTarget
public: public:
int exec(CMenuTarget* parent, const std::string&); int exec(CMenuTarget* parent, const std::string&);
}; };
class CHDDFmtExec : public CMenuTarget
{
public:
int exec(CMenuTarget* parent, const std::string&);
};
class CHDDChkExec : public CMenuTarget
{
public:
int exec(CMenuTarget* parent, const std::string&);
};
class CHDDMenuHandler : public CMenuTarget class CHDDMenuHandler : public CMenuTarget
{ {
private: private:
int width; int width;
std::string mount;
std::string umount;
bool show_menu;
std::map<std::string, std::string> devtitle;
struct hdd_s {
std::string devname;
std::string fmt;
std::string desc;
CMenuForwarder *cmf;
bool mounted;
};
std::vector<hdd_s> hdd_list;
struct cmp_hdd_by_name: public binary_function <const struct hdd_s, const struct hdd_s, bool>
{
bool operator() (const struct hdd_s c1, const struct hdd_s c2)
{
return std::lexicographical_compare(c1.devname.begin(), c1.devname.end(), c2.devname.begin(), c2.devname.end());
};
};
static devtool_s devtools[];
bool is_mounted(const char *dev);
void getBlkIds();
std::string getFmtType(std::string name, std::string part = "");
std::string getDefaultPart(std::string dev);
bool mount_dev(std::string name);
bool umount_dev(std::string name);
bool umount_all(std::string dev);
bool add_dev(std::string dev, std::string part);
bool waitfordev(std::string dev, int maxwait);
void check_dev_tools();
devtool_s * get_dev_tool(std::string fmt);
int showDeviceMenu(std::string dev);
int checkDevice(std::string dev);
int formatDevice(std::string dev);
void showError(neutrino_locale_t err);
public: public:
CHDDMenuHandler(); CHDDMenuHandler();
~CHDDMenuHandler(); ~CHDDMenuHandler();
@@ -63,4 +97,3 @@ class CHDDMenuHandler : public CMenuTarget
}; };
#endif #endif