Skip to content

Commit

Permalink
Do not start on DBus error.
Browse files Browse the repository at this point in the history
  • Loading branch information
limansky committed Dec 9, 2014
1 parent 0df1214 commit 4b3f74f
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 56 deletions.
5 changes: 3 additions & 2 deletions src/diskmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace {
}

DiskManager::DiskManager(QObject *parent) :
QObject(parent)
QObject(parent), ready(false)
{
udisks = new UDisksInterface(UDISKS_SERVICE,
UDISKS_PATH,
Expand All @@ -102,10 +102,11 @@ DiskManager::DiskManager(QObject *parent) :

if (devs.isError())
{
qDebug() << devs.error();
qCritical() << devs.error();
}
else
{
ready = true;
foreach(const QDBusObjectPath& d, devs.value())
{
DeviceInfoPtr info = deviceForPath(d);
Expand Down
3 changes: 3 additions & 0 deletions src/diskmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class DiskManager : public QObject

explicit DiskManager(QObject *parent = 0);

bool isReady() const { return ready; }

typedef QList<DeviceInfoPtr> Devices;
typedef QMap<QString, DeviceInfoPtr> DeviceMap;

Expand Down Expand Up @@ -101,6 +103,7 @@ private slots:
private:
UDisksInterface* udisks;
DeviceMap deviceCache;
bool ready;
};

#endif // DISKMANAGER_H
8 changes: 7 additions & 1 deletion src/tinymounttray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ TinyMountTray::~TinyMountTray()

void TinyMountTray::reloadDevices()
{
if (!manager->isReady()) {
QMessageBox::critical(0, tr("TinyMount statup error"),
tr("TinyMount cannot be started. Possible DBus daemon is not running or UDisks is not installed."));
QApplication::quit();
}

trayMenu->clear();

bool showSystem = SettingsManager::instance().getSettings().showSystemDisks;
Expand Down Expand Up @@ -286,7 +292,7 @@ void TinyMountTray::onUnmountDone(const DeviceInfo &device, int status)
void TinyMountTray::showAbout()
{
QMessageBox::about(0, tr("TinyMount, version %1").arg(TINYMOUNT_VERSION),
tr("Copyright (c) 2012 Mike Limansky\n\n"
tr("Copyright (c) 2012-2014 Mike Limansky\n\n"
"Use and redistribute under terms of the GNU General Public License Version 2."));
}

Expand Down
69 changes: 42 additions & 27 deletions src/translations/tinymount_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<message>
<location filename="../tinymounttray.cpp" line="78"/>
<source>DBus error</source>
<translation type="unfinished">Ошибка DBus</translation>
<translation>Ошибка DBus</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="81"/>
Expand Down Expand Up @@ -143,6 +143,11 @@ p, li { white-space: pre-wrap; }
<source>Detach devices after unmount</source>
<translation>Отключать устройство</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="124"/>
<source>Force unmount if device is busy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settingsdialog.cpp" line="19"/>
<source>Use system notifications</source>
Expand All @@ -152,94 +157,104 @@ p, li { white-space: pre-wrap; }
<context>
<name>TinyMountTray</name>
<message>
<location filename="../main.cpp" line="156"/>
<location filename="../tinymounttray.cpp" line="282"/>
<location filename="../main.cpp" line="158"/>
<location filename="../tinymounttray.cpp" line="294"/>
<source>TinyMount, version %1</source>
<translation>TinyMount, версия %1</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="184"/>
<location filename="../tinymounttray.cpp" line="190"/>
<source>About...</source>
<translation>О программе...</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="185"/>
<location filename="../tinymounttray.cpp" line="191"/>
<source>Quit</source>
<translation>Выход</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="195"/>
<location filename="../tinymounttray.cpp" line="201"/>
<source>Device is added</source>
<translation>Устройство добавлено</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="196"/>
<location filename="../tinymounttray.cpp" line="202"/>
<source>Device %1 is added</source>
<translation>Добавлено устройство %1</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="210"/>
<location filename="../tinymounttray.cpp" line="216"/>
<source>Device is removed</source>
<translation>Устройство удалено</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="211"/>
<location filename="../tinymounttray.cpp" line="217"/>
<source>Device %1 is removed</source>
<translation>Устройство %1 удалено</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="244"/>
<location filename="../tinymounttray.cpp" line="250"/>
<source>Device is mounted</source>
<translation>Устройство смонтировано</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="245"/>
<location filename="../tinymounttray.cpp" line="251"/>
<source>%1 is mounted to %2.</source>
<translation>%1 смонтирован в %2.</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="251"/>
<location filename="../tinymounttray.cpp" line="257"/>
<source>%1 mounting error. %2.</source>
<translation>Не могу смонтировать %1. %2.</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="265"/>
<location filename="../tinymounttray.cpp" line="272"/>
<source>%1 is unmounted successfuly.</source>
<translation>%1 успешно отмонтирован.</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="275"/>
<location filename="../tinymounttray.cpp" line="287"/>
<source>Failed to unmount %1. %2.</source>
<translation>Не могу отмонтировать %1. %2.</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="250"/>
<location filename="../tinymounttray.cpp" line="295"/>
<source>Copyright (c) 2012-2014 Mike Limansky

Use and redistribute under terms of the GNU General Public License Version 2.</source>
<translation>Copyright (c) 2012-2014 Mike Limansky

Использование и распространение на условиях GNU General Public License версия 2.</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="256"/>
<source>Mount failed</source>
<translation>Ошибка монтирования</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="183"/>
<location filename="../tinymounttray.cpp" line="142"/>
<source>TinyMount statup error</source>
<translation>Ошибка запуска TinyMount</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="143"/>
<source>TinyMount cannot be started. Possible DBus daemon is not running or UDisks is not installed.</source>
<translation>TinyMount не может быть запущен. Возможно, не запущен демон DBus или не установлен сервис UDisks.</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="189"/>
<source>Settings</source>
<translation>Настройки</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="264"/>
<location filename="../tinymounttray.cpp" line="271"/>
<source>Device is unmounted</source>
<translation>Устройство отмонтировано</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="274"/>
<location filename="../tinymounttray.cpp" line="286"/>
<source>Unmount failed</source>
<translation>Ошибка размонтирования</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="283"/>
<source>Copyright (c) 2012 Mike Limansky

Use and redistribute under terms of the GNU General Public License Version 2.</source>
<translation>Copyright (c) 2012 Mike Limansky

Использование и распространение на условиях GNU General Public License версия 2.</translation>
</message>
</context>
</TS>
67 changes: 41 additions & 26 deletions src/translations/tinymount_uk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ p, li { white-space: pre-wrap; }
<source>Detach devices after unmount</source>
<translation>Відключити пристрій</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="124"/>
<source>Force unmount if device is busy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settingsdialog.cpp" line="19"/>
<source>Use system notifications</source>
Expand All @@ -152,94 +157,104 @@ p, li { white-space: pre-wrap; }
<context>
<name>TinyMountTray</name>
<message>
<location filename="../main.cpp" line="156"/>
<location filename="../tinymounttray.cpp" line="282"/>
<location filename="../main.cpp" line="158"/>
<location filename="../tinymounttray.cpp" line="294"/>
<source>TinyMount, version %1</source>
<translation>TinyMount, версія %1</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="184"/>
<location filename="../tinymounttray.cpp" line="190"/>
<source>About...</source>
<translation>Про програму...</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="185"/>
<location filename="../tinymounttray.cpp" line="191"/>
<source>Quit</source>
<translation>Вийти</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="195"/>
<location filename="../tinymounttray.cpp" line="201"/>
<source>Device is added</source>
<translation>Пристрій додано</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="196"/>
<location filename="../tinymounttray.cpp" line="202"/>
<source>Device %1 is added</source>
<translation>Додано пристрій %1</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="210"/>
<location filename="../tinymounttray.cpp" line="216"/>
<source>Device is removed</source>
<translation>Пристрій видалено</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="211"/>
<location filename="../tinymounttray.cpp" line="217"/>
<source>Device %1 is removed</source>
<translation>Пристрій %1 видалено</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="244"/>
<location filename="../tinymounttray.cpp" line="250"/>
<source>Device is mounted</source>
<translation>Пристрій змонтовано</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="245"/>
<location filename="../tinymounttray.cpp" line="251"/>
<source>%1 is mounted to %2.</source>
<translation>%1 змонтовано в %2.</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="251"/>
<location filename="../tinymounttray.cpp" line="257"/>
<source>%1 mounting error. %2.</source>
<translation>Не вдається змонтувати %1. %2.</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="265"/>
<location filename="../tinymounttray.cpp" line="272"/>
<source>%1 is unmounted successfuly.</source>
<translation>%1 вдало відмонтовано.</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="275"/>
<location filename="../tinymounttray.cpp" line="287"/>
<source>Failed to unmount %1. %2.</source>
<translation>Не вдається відмонтувати %1. %2.</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="250"/>
<location filename="../tinymounttray.cpp" line="295"/>
<source>Copyright (c) 2012-2014 Mike Limansky

Use and redistribute under terms of the GNU General Public License Version 2.</source>
<translation type="unfinished">Copyright (c) 2012-2014 Mike Limansky

Використання та розповсюдження на умовах GNU General Public License версия 2.</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="256"/>
<source>Mount failed</source>
<translation>Помилка монтування</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="183"/>
<location filename="../tinymounttray.cpp" line="142"/>
<source>TinyMount statup error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="143"/>
<source>TinyMount cannot be started. Possible DBus daemon is not running or UDisks is not installed.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="189"/>
<source>Settings</source>
<translation>Налаштування</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="264"/>
<location filename="../tinymounttray.cpp" line="271"/>
<source>Device is unmounted</source>
<translation>Пристрій відмонтовано</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="274"/>
<location filename="../tinymounttray.cpp" line="286"/>
<source>Unmount failed</source>
<translation>Помилка відмонтування</translation>
</message>
<message>
<location filename="../tinymounttray.cpp" line="283"/>
<source>Copyright (c) 2012 Mike Limansky

Use and redistribute under terms of the GNU General Public License Version 2.</source>
<translation>Copyright (c) 2012 Mike Limansky

Використання та розповсюдження на умовах GNU General Public License версия 2.</translation>
</message>
</context>
</TS>

0 comments on commit 4b3f74f

Please sign in to comment.