void WmdmLister::DoUpdateDriveFreeSpace(const QString& id) { { QMutexLocker l(&mutex_); if (!devices_.contains(id)) return; UpdateFreeSpace(&devices_[id]); } emit DeviceChanged(id); }
void DirectoriesPrefs::OnChooseTempDir(wxCommandEvent &event) { wxDirDialog dlog(this, _("Choose a location to place the " "temporary directory"), ""); dlog.ShowModal(); if (dlog.GetPath() != "") { mTempDirText->SetValue(dlog.GetPath() + wxFILE_SEP_PATH + ".audacity_temp"); UpdateFreeSpace(event); } }
/// Creates the dialog and its contents. void DirectoriesPrefs::Populate() { //------------------------- Main section -------------------- // Now construct the GUI itself. // Use 'eIsCreatingFromPrefs' so that the GUI is // initialised with values from gPrefs. ShuttleGui S(this, eIsCreatingFromPrefs); PopulateOrExchange(S); // ----------------------- End of main section -------------- wxCommandEvent e; UpdateFreeSpace(e); }
void DirectoriesPrefs::OnChooseTempDir(wxCommandEvent & e) { wxDirDialog dlog(this, _("Choose a location to place the temporary directory"), gPrefs->Read(wxT("/Directories/TempDir"), wxGetApp().defaultTempDir)); dlog.ShowModal(); if (dlog.GetPath() != wxT("")) { wxFileName tmpDirPath; tmpDirPath.AssignDir(dlog.GetPath()); #if defined(__WXMSW__) || defined(__WXMAC__) tmpDirPath.AppendDir(wxT("audacity_temp")); #else tmpDirPath.AppendDir(wxT(".audacity_temp")); #endif mTempDir->SetValue(tmpDirPath.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR)); UpdateFreeSpace(e); } }
void DirectoriesPrefs::OnChooseTempDir(wxCommandEvent & e) { wxDirDialog dlog(this, _("Choose a location to place the temporary directory"), gPrefs->Read(wxT("/Directories/TempDir"), wxGetApp().defaultTempDir)); int retval = dlog.ShowModal(); if (retval != wxID_CANCEL && dlog.GetPath() != wxT("")) { wxFileName tmpDirPath; tmpDirPath.AssignDir(dlog.GetPath()); // Append an "audacity_temp" directory to this path if necessary (the // default, the existing pref (as stored in the control), and any path // ending in a directory with the same name as what we'd add should be OK // already) wxString newDirName; #if defined(__WXMSW__) || defined(__WXMAC__) newDirName = wxT("audacity_temp"); #else newDirName = wxT(".audacity_temp"); #endif wxArrayString dirsInPath = tmpDirPath.GetDirs(); // If the default temp dir or user's pref dir don't end in '/' they cause // wxFileName's == operator to construct a wxFileName representing a file // (that doesn't exist) -- hence the constructor calls if (tmpDirPath != wxFileName(wxGetApp().defaultTempDir, wxT("")) && tmpDirPath != wxFileName(mTempDir->GetValue(), wxT("")) && (dirsInPath.GetCount() == 0 || dirsInPath[dirsInPath.GetCount()-1] != newDirName)) { tmpDirPath.AppendDir(newDirName); } mTempDir->SetValue(tmpDirPath.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR)); UpdateFreeSpace(e); } }
WmdmLister::DeviceInfo WmdmLister::ReadDeviceInfo(IWMDMDevice2* device) { qLog(Debug) << "Reading device info"; DeviceInfo ret; ret.device_ = device; // Get text strings const int max_size = 512; wchar_t buf[max_size]; device->GetName(buf, max_size); ret.name_ = QString::fromWCharArray(buf).trimmed(); device->GetManufacturer(buf, max_size); ret.manufacturer_ = QString::fromWCharArray(buf).trimmed(); device->GetCanonicalName(buf, max_size); ret.canonical_name_ = QString::fromWCharArray(buf).toLower(); qLog(Debug) << "Read device strings:" << ret.name_ << ret.manufacturer_ << ret.canonical_name_; // Upgrade to a device3 IWMDMDevice3* device3 = NULL; device->QueryInterface(IID_IWMDMDevice3, (void**)&device3); // Get the device protocol so we can figure out whether the device is MSC PROPVARIANT protocol; if (device3) { device3->GetProperty(g_wszWMDMDeviceProtocol, &protocol); device3->Release(); } // Get the type and check whether it has storage DWORD type = 0; device->GetType(&type); if (type & WMDM_DEVICE_TYPE_STORAGE) ret.is_suitable_ = true; // Get the icon HICON icon; if (device->GetDeviceIcon((ULONG*)&icon) == S_OK) { // Extra check for whether the icon is valid (see issue 1417) ICONINFO iconinfo; if (GetIconInfo(icon, &iconinfo)) { ret.icon_ = QPixmap::fromWinHICON(icon); DestroyIcon(icon); } } // Get the main (first) storage for the device IWMDMEnumStorage* storage_it = NULL; if (device->EnumStorage(&storage_it) == S_OK && storage_it) { ULONG storage_fetched = 0; IWMDMStorage* storage; if (storage_it->Next(1, &storage, &storage_fetched) == S_OK) { if (storage->QueryInterface(IID_IWMDMStorage2, (void**)&ret.storage_)) { qLog(Warning) << "Error getting IWMDMStorage2 from storage"; } else { // Get free space information UpdateFreeSpace(&ret); } storage->Release(); } storage_it->Release(); } // There doesn't seem to be a way to get the drive letter of MSC devices, so // try parsing the device's name to extract it. if (!device3 || QUuid(*protocol.puuid) == kDeviceProtocolMsc) GuessDriveLetter(&ret); return ret; }