Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added comments to describe functions in frmContactEditorTelephone
[xestiaab/.git] / source / contacteditor / frmContactEditor-Sound.cpp
index b82d0b9..f6b6643 100644 (file)
@@ -1,6 +1,6 @@
 // frmContactEditor-Sound.cpp - frmContactEditor Sound tab subroutines.
 //
-// (c) 2012-2015 Xestia Software Development.
+// (c) 2012-2016 Xestia Software Development.
 //
 // This file is part of Xestia Address Book.
 //
@@ -28,16 +28,16 @@ void frmContactEditor::AddSound( wxCommandEvent& event )
     
     frmContactEditorSound *frameCESound = new frmContactEditorSound ( this );
     frameCESound->SetEditorMode(FALSE);
-    intResult = GetLastInt(&SoundsList);
-    frameCESound->SetupPointers(&SoundsList,
-                                &SoundsListAltID,
-                                &SoundsListPID,
-                                &SoundsListType,
-                                &SoundsListAudioType,
-                                &SoundsListAudioEncType,
-                                &SoundsListTokens,
-                                &SoundsListMediatype,
-                                &SoundsListPref,
+    intResult = GetLastInt(&ContactEditorData.SoundsList);
+    frameCESound->SetupPointers(&ContactEditorData.SoundsList,
+                                &ContactEditorData.SoundsListAltID,
+                                &ContactEditorData.SoundsListPID,
+                                &ContactEditorData.SoundsListType,
+                                &ContactEditorData.SoundsListAudioType,
+                                &ContactEditorData.SoundsListAudioEncType,
+                                &ContactEditorData.SoundsListTokens,
+                                &ContactEditorData.SoundsListMediatype,
+                                &ContactEditorData.SoundsListPref,
                                 lboSounds,
                                 (intValueSeek));
     frameCESound->ShowModal();
@@ -57,15 +57,15 @@ void frmContactEditor::ModifySound( wxCommandEvent& event )
     }
     
     frmContactEditorSound *frameCESound = new frmContactEditorSound ( this );
-    frameCESound->SetupPointers(&SoundsList,
-                                &SoundsListAltID,
-                                &SoundsListPID,
-                                &SoundsListType,
-                                &SoundsListAudioType,
-                                &SoundsListAudioEncType,
-                                &SoundsListTokens,
-                                &SoundsListMediatype,
-                                &SoundsListPref,
+    frameCESound->SetupPointers(&ContactEditorData.SoundsList,
+                                &ContactEditorData.SoundsListAltID,
+                                &ContactEditorData.SoundsListPID,
+                                &ContactEditorData.SoundsListType,
+                                &ContactEditorData.SoundsListAudioType,
+                                &ContactEditorData.SoundsListAudioEncType,
+                                &ContactEditorData.SoundsListTokens,
+                                &ContactEditorData.SoundsListMediatype,
+                                &ContactEditorData.SoundsListPref,
                                 lboSounds,
                                 intSelectedData);
     frameCESound->SetEditorMode(TRUE);
@@ -87,10 +87,10 @@ void frmContactEditor::DeleteSound( wxCommandEvent& event )
     
     lboSounds->DeleteItem(longSelected);
     
-    DeleteMapData(intSelectedData, &SoundsList, &SoundsListAltID,
-                  &SoundsListPID, &SoundsListType, &SoundsListAudioType,
-                  &SoundsListAudioEncType, &SoundsListTokens, &SoundsListMediatype,
-                  &SoundsListPref);
+    DeleteMapData(intSelectedData, &ContactEditorData.SoundsList, &ContactEditorData.SoundsListAltID,
+                  &ContactEditorData.SoundsListPID, &ContactEditorData.SoundsListType, &ContactEditorData.SoundsListAudioType,
+                  &ContactEditorData.SoundsListAudioEncType, &ContactEditorData.SoundsListTokens, &ContactEditorData.SoundsListMediatype,
+                  &ContactEditorData.SoundsListPref);
     
 }
 
@@ -171,7 +171,7 @@ void frmContactEditor::PlaySound( wxCommandEvent& event )
     
     std::map<int, std::string>::iterator initier;
     
-    initier = SoundsList.find(intSelectedData);
+    initier = ContactEditorData.SoundsList.find(intSelectedData);
     
     base64dec = base64_decode(initier->second);
     base64declen = base64dec.size();
@@ -198,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<int,std::string>::iterator initier;
+       std::map<int,wxString>::iterator soundtypeiter;
+    
+       initier = ContactEditorData.SoundsList.find(intSelectedData);
+       soundtypeiter = ContactEditorData.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 = ContactEditorData.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
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy