X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FfrmContactEditor-Sound.cpp;h=c19b947a89291d8c2175c7cec3bb7cd94e203fcf;hb=d06d0b1d631e7a48c34738397e98651f541d4000;hp=162662657e7f7f92d9d3af28e6f14937d00aae11;hpb=d541e55be1061c81b88936a22365804e7b13d2cf;p=xestiaab%2F.git diff --git a/source/contacteditor/frmContactEditor-Sound.cpp b/source/contacteditor/frmContactEditor-Sound.cpp index 1626626..c19b947 100644 --- a/source/contacteditor/frmContactEditor-Sound.cpp +++ b/source/contacteditor/frmContactEditor-Sound.cpp @@ -200,7 +200,59 @@ void frmContactEditor::StopSound( wxCommandEvent& event ) void frmContactEditor::SaveSound( wxCommandEvent &event ) { + + long longSelected = -1; + int intSelectedData = 0; + + if (!GetSelectedItem(lboSounds, + &longSelected, + &intSelectedData)){ + + return; + + } + + wxString FileTypes; + + wxString FinalFilename; + + std::map::iterator initier; + std::map::iterator soundtypeiter; + + initier = SoundsList.find(intSelectedData); + soundtypeiter = SoundsListAudioType.find(intSelectedData); + + // Open up the dialog to save the picture. + + wxFileDialog ExportDlg(this, wxT("Save Sound"), wxT(""), wxT(""), + FileTypes, wxFD_SAVE|wxFD_OVERWRITE_PROMPT); + + if (ExportDlg.ShowModal() == wxID_CANCEL){ + + return; + + } + + // Write out the picture to the file. + + wxFile SoundFile; + + if (SoundFile.Open(ExportDlg.GetPath(), wxFile::write)){ + + std::string base64dec; + + initier = SoundsList.find(intSelectedData); + base64dec = base64_decode(initier->second); + + SoundFile.Write(base64dec.c_str(), (size_t)base64dec.size()); + + SoundFile.Close(); + + } else { + + wxMessageBox(_("An error occured whilst saving the sound. Check that you have free space and permissions to write the picture at this location."), _("Sound save error"), wxOK, this); + return; - return; + } } \ No newline at end of file