X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FfrmContactEditor-Sound.cpp;h=c19b947a89291d8c2175c7cec3bb7cd94e203fcf;hb=43a294d863a3cbcd825889adaa702f3a79dd7aa2;hp=094a7cb6be7dbb0ab0ac692a224efb432d4c24ad;hpb=5b2b2bcea1ab1dfd2b74589573cd16ee9326c4b9;p=xestiaab%2F.git diff --git a/source/contacteditor/frmContactEditor-Sound.cpp b/source/contacteditor/frmContactEditor-Sound.cpp index 094a7cb..c19b947 100644 --- a/source/contacteditor/frmContactEditor-Sound.cpp +++ b/source/contacteditor/frmContactEditor-Sound.cpp @@ -1,3 +1,21 @@ +// frmContactEditor-Sound.cpp - frmContactEditor Sound tab subroutines. +// +// (c) 2012-2015 Xestia Software Development. +// +// This file is part of Xestia Address Book. +// +// Xestia Address Book is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by the +// Free Software Foundation, version 3 of the license. +// +// Xestia Address Book is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with Xestia Address Book. If not, see + #include "frmContactEditor.h" #include "frmContactEditorSound.h" #include "../common/base64.h" @@ -180,3 +198,61 @@ 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; + + } + +} \ No newline at end of file