Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added source code, headers and unit testing code for the CALURI vCard Property for...
[xestiaab/.git] / source / contacteditor / frmContactEditor-Save.cpp
index dd3851c..9cb3c71 100644 (file)
@@ -1,3 +1,21 @@
+// frmContactEditor-Save.cpp - frmContactEditor save contact 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 <http://www.gnu.org/licenses/>
+
 #include "frmContactEditor.h"
 #include "../enums.h"
 #include "../version.h"
@@ -29,54 +47,60 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
     wxString FilenameFinal;
     bool ReplaceContact = FALSE;
     
-    if (cmbType->GetCurrentSelection() == 1 ||
-        cmbType->GetCurrentSelection() == 3 ||
-        cmbType->GetCurrentSelection() == 4){
+    if (StartupEditMode == TRUE){
+    
+       if (cmbType->GetCurrentSelection() == 1 ||
+           cmbType->GetCurrentSelection() == 3 ||
+            cmbType->GetCurrentSelection() == 4){
         
-        if (IsGroup == TRUE){
+           if (IsGroup == TRUE){
             
-            // Mark contact for replacing.
+               // Mark contact for replacing.
             
-            ReplaceContact = TRUE;
-            
-        }
+               ReplaceContact = TRUE;
+               IsGroup = FALSE;
+           
+           }
         
-    } else if (cmbType->GetCurrentSelection() == 2){
+       } else if (cmbType->GetCurrentSelection() == 2){
         
-        if (IsGroup == TRUE){
+               if (IsGroup == FALSE){
             
-            // Mark contact for replacing.
+               // Mark contact for replacing.
             
-            ReplaceContact = TRUE;
-            
-        }
+               ReplaceContact = TRUE;
+               IsGroup = TRUE;
+           
+            }
         
-    }
+       }
     
-    if (ReplaceContact == TRUE){
+       if (ReplaceContact == TRUE){
         
-        wxString wxDelSplitFilename;
-        wxString wxDelFinalFilename;
-        wxString wxSDelDataURL;
-        wxStringTokenizer wSTDelFilename(wxSContactFilename, wxT("/"));
-        while(wSTDelFilename.HasMoreTokens()){
+            wxString wxDelSplitFilename;
+            wxString wxDelFinalFilename;
+            wxString wxSDelDataURL;
+            wxStringTokenizer wSTDelFilename(wxSContactFilename, wxT("/"));
+            while(wSTDelFilename.HasMoreTokens()){
             
-            wxDelSplitFilename = wSTDelFilename.GetNextToken();
+                wxDelSplitFilename = wSTDelFilename.GetNextToken();
             
-        }
+            }
         
-        wxSDelDataURL = wxDelSplitFilename;
+            wxSDelDataURL = wxDelSplitFilename;
         
-        // Delete the contact from the server as it will be useless in certain
-        // address book clients.
+            // Delete the contact from the server as it will be useless in certain
+            // address book clients.
         
-        ActMgrPtr->AddTask(2, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDelDataURL, wxDelSplitFilename, wxSContactFilename, wxT(""));
+            ActMgrPtr->AddTask(2, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDelDataURL, wxDelSplitFilename, wxSContactFilename, wxT(""));
         
-        // Clear the filename so the trigger to recreate the UID is done.
+            // Clear the filename so the trigger to recreate the UID is done.
         
-        wxSContactFilename.Clear();
-        EditMode = FALSE;
+           wxSContactFilename.Clear();
+           EditMode = FALSE;
         
+       }
+    
     }
     
     if (wxSContactFilename.IsEmpty()){
@@ -117,10 +141,6 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
             // UID Token is empty. (Shouldn't be).
             // Generate a new UID Token.
             
-            /*boost::uuids::uuid ContactUUID = boost::uuids::random_generator()();
-             std::string sstContactUUID = boost::uuids::to_string(ContactUUID);
-             wxString strContactUUID(sstContactUUID.c_str(), wxConvUTF8);
-             UIDToken = strContactUUID;*/
             UIDToken = GenerateUUID();
             UIDToken = UIDToken.MakeUpper();
             
@@ -2301,4 +2321,8 @@ void frmContactEditor::SaveCloseContact( wxCommandEvent& event )
     
     // Save the updated contact data and close the form.
     
+    wxCommandEvent NullEvent;
+    this->SaveContact(NullEvent);
+    this->Close();
+    
 }
\ 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