Skip to content

Commit

Permalink
Show MediaMonitor's errors via notification centre
Browse files Browse the repository at this point in the history
Update Mac OS eject to use diskutil (disktool is deprecated and removed in 10.9)
  • Loading branch information
jyavenard committed Jul 7, 2013
1 parent d0ecc8e commit 88c491a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
28 changes: 17 additions & 11 deletions mythtv/libs/libmyth/mythmediamonitor.cpp
Expand Up @@ -33,6 +33,9 @@ using namespace std;
#else
#include "mediamonitor-unix.h"
#endif
#include "mythuinotificationcenter.h"

static const QString _Location = QObject::tr("Media Monitor");

MediaMonitor *MediaMonitor::c_monitor = NULL;

Expand Down Expand Up @@ -231,7 +234,7 @@ void MediaMonitor::ChooseAndEjectMedia(void)

if (!selected)
{
ShowOkPopup(tr("No devices to eject"));
ShowNotification(tr("No devices to eject"), _Location);
return;
}

Expand All @@ -249,12 +252,12 @@ void MediaMonitor::AttemptEject(MythMediaDevice *device)

if (device->eject(false) != MEDIAERR_OK)
{
QString msg = QObject::tr(
"Unable to open or close the empty drive %1.\n\n"
"You may have to use the eject button under its tray.");
ShowOkPopup(msg.arg(dev));
QString msg =
QObject::tr("Unable to open or close the empty drive %1");
QString extra =
QObject::tr("You may have to use the eject button under its tray");
ShowNotificationError(msg.arg(dev), _Location, extra);
}

return;
}

Expand All @@ -264,11 +267,14 @@ void MediaMonitor::AttemptEject(MythMediaDevice *device)
QString("Disk %1 is mounted? Unmounting").arg(dev));
device->unmount();

#if !CONFIG_DARWIN
if (device->isMounted())
{
ShowOkPopup(tr("Failed to unmount %1").arg(dev));
ShowNotificationError(tr("Failed to unmount %1").arg(dev),
_Location);
return;
}
#endif
}

LOG(VB_MEDIA, LOG_INFO,
Expand All @@ -281,11 +287,11 @@ void MediaMonitor::AttemptEject(MythMediaDevice *device)
{
// Physical ejection isn't possible (there is no tray or slot),
// but logically the device is now ejected (ignored by the OS).
ShowOkPopup(tr("You may safely remove %1").arg(dev));
ShowNotification(tr("You may safely remove %1").arg(dev), _Location);
}
else if (err == MEDIAERR_FAILED)
{
ShowOkPopup(tr("Failed to eject %1").arg(dev));
ShowNotificationError(tr("Failed to eject %1").arg(dev), _Location);
}
}

Expand Down Expand Up @@ -930,8 +936,8 @@ void MediaMonitor::ejectOpticalDisc()
myth_system("eject -T");
#elif CONFIG_DARWIN
QString def = DEFAULT_CD;
LOG(VB_MEDIA, LOG_INFO, "Trying 'disktool -e " + def);
myth_system("disktool -e " + def);
LOG(VB_MEDIA, LOG_INFO, "Trying 'diskutil eject " + def);
myth_system("diskutil eject " + def);
#endif
}
}
Expand Down
9 changes: 2 additions & 7 deletions mythtv/libs/libmythbase/mythmedia.cpp
Expand Up @@ -294,14 +294,9 @@ MythMediaError MythMediaDevice::eject(bool open_close)
(void) open_close;

#if CONFIG_DARWIN
// Backgrounding this is a bit naughty, but it can take up to five
// seconds to execute, and freezing the frontend for that long is bad

QString command = "disktool -e " + m_DevicePath + " &";

if (myth_system(command, kMSRunBackground) != GENERIC_EXIT_OK)
return MEDIAERR_FAILED;
QString command = "diskutil eject " + m_DevicePath;

int ret = myth_system(command, kMSRunBackground);
return MEDIAERR_OK;
#endif

Expand Down

0 comments on commit 88c491a

Please sign in to comment.