Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added code so that OSX is now supported.
[xestiaab/.git] / source / common / defaults.cpp
index e23f9e7..8f3dc7c 100644 (file)
 #include <wx/ffile.h>
 
 void SetupDefaultAddressBook(){
-
-       // Check if the 'Default.local' directory exists.
-
-       wxString DefaultLocalDir;
-
+    
+    // Check if the 'Default.local' directory exists.
+    
+    wxString DefaultLocalDir;
+    
 #if defined(__HAIKU__)
     
     //preffilename = wxT("noo");
-
+    
 #elif defined(__WIN32__)
-
-       DefaultLocalDir.Clear();
-       DefaultLocalDir.Append(wxString::FromUTF8(getenv("APPDATA")));
-       DefaultLocalDir.Append(wxT("\\Xestia\\Address Book\\accounts\\"));
-       DefaultLocalDir.Append(wxT("Default.local"));
-
+    
+    DefaultLocalDir.Clear();
+    DefaultLocalDir.Append(wxString::FromUTF8(getenv("APPDATA")));
+    DefaultLocalDir.Append(wxT("\\Xestia\\Address Book\\accounts\\"));
+    DefaultLocalDir.Append(wxT("Default.local"));
+    
+#elif defined(__APPLE__)
+    
+    DefaultLocalDir.Clear();
+    DefaultLocalDir.Append(wxString::FromUTF8(getenv("HOME")));
+    DefaultLocalDir.Append(wxT("/Library/Preferences/Xestia/Address Book/accounts/"));
+    DefaultLocalDir.Append(wxT("Default.local"));
+    
 #else
-
-       DefaultLocalDir.Clear();
-       DefaultLocalDir.Append(wxString::FromUTF8(getenv("HOME")));
-       DefaultLocalDir.Append(wxT("/.xestiaab/accounts/"));
-       DefaultLocalDir.Append(wxT("Default.local"));
-
+    
+    DefaultLocalDir.Clear();
+    DefaultLocalDir.Append(wxString::FromUTF8(getenv("HOME")));
+    DefaultLocalDir.Append(wxT("/.xestiaab/accounts/"));
+    DefaultLocalDir.Append(wxT("Default.local"));
+    
 #endif
-
-       if (wxDirExists(DefaultLocalDir) == FALSE){
-       
-               if (wxMkdir(DefaultLocalDir, 0740) == TRUE){            
-                                       
-               }
-       
-       }
-
+    
+    if (wxDirExists(DefaultLocalDir) == FALSE){
+        
+        if (wxMkdir(DefaultLocalDir, 0740) == TRUE){
+            
+        }
+        
+    }
+    
 }
 
 void SetupDefaultSettings(){
-
-       // Setup default (non account) settings if they don't exist.
-       
-       wxString DefaultPrefDir;
-
+    
+    // Setup default (non account) settings if they don't exist.
+    
+    wxString DefaultPrefDir;
+    
 #if defined(__HAIKU__)
-
-       //preffilename = wxT("noo");
-
+    
+    //preffilename = wxT("noo");
+    
 #elif defined(__WIN32__)
-
-       DefaultPrefDir.Clear();
-       DefaultPrefDir.Append(wxString::FromUTF8(getenv("APPDATA")));
-       DefaultPrefDir.Append(wxT("\\Xestia\\Address Book\\preferences\\"));
-
+    
+    DefaultPrefDir.Clear();
+    DefaultPrefDir.Append(wxString::FromUTF8(getenv("APPDATA")));
+    DefaultPrefDir.Append(wxT("\\Xestia\\Address Book\\preferences\\"));
+    
+#elif defined(__APPLE__)
+    
+    DefaultPrefDir.Clear();
+    DefaultPrefDir.Append(wxString::FromUTF8(getenv("HOME")));
+    DefaultPrefDir.Append(wxT("/Library/Preferences/Xestia/Address Book/preferences"));
+    
 #else
-
-       DefaultPrefDir.Clear();
-       DefaultPrefDir.Append(wxString::FromUTF8(getenv("HOME")));
-       DefaultPrefDir.Append(wxT("/.xestiaab/preferences/"));
-
+    
+    DefaultPrefDir.Clear();
+    DefaultPrefDir.Append(wxString::FromUTF8(getenv("HOME")));
+    DefaultPrefDir.Append(wxT("/.xestiaab/preferences/"));
+    
 #endif
-       
-       // Create the accounts file if it doesn't exist.
-       
-       if (wxFileExists(DefaultPrefDir + wxT("accounts")) == FALSE){
-       
-               wxString AccountsFilename;
-               wxFFile AccountsFile;
-
-               AccountsFilename = DefaultPrefDir;
-               AccountsFilename.Append(wxT("accounts"));
-
+    
+    // Create the accounts file if it doesn't exist.
+    
+    if (wxFileExists(DefaultPrefDir + wxT("accounts")) == FALSE){
+        
+        wxString AccountsFilename;
+        wxFFile AccountsFile;
+        
+        AccountsFilename = DefaultPrefDir;
+        AccountsFilename.Append(wxT("accounts"));
+        
 #if wxABI_VERSION < 20900
-               AccountsFile.Open(AccountsFilename.c_str(), wxT("w"));
+        AccountsFile.Open(AccountsFilename.c_str(), wxT("w"));
 #else
-               AccountsFile.Open(AccountsFilename, wxT("w"));
-#endif 
-       
-               AccountsFile.Write(wxT(""));
-       
-       }
-       
-       // Create the preferences file if it doesn't exist.
-
-       if (wxFileExists(DefaultPrefDir + wxT("settings")) == FALSE){
-
-               wxString PrefsFilename;
-               wxFFile PrefsFile;
-
-               PrefsFilename = DefaultPrefDir;
-               PrefsFilename.Append(wxT("settings"));
-       
+        AccountsFile.Open(AccountsFilename, wxT("w"));
+#endif
+        
+        AccountsFile.Write(wxT(""));
+        
+    }
+    
+    // Create the preferences file if it doesn't exist.
+    
+    if (wxFileExists(DefaultPrefDir + wxT("settings")) == FALSE){
+        
+        wxString PrefsFilename;
+        wxFFile PrefsFile;
+        
+        PrefsFilename = DefaultPrefDir;
+        PrefsFilename.Append(wxT("settings"));
+        
 #if wxABI_VERSION < 20900
-               PrefsFile.Open(PrefsFilename.c_str(), wxT("w"));
+        PrefsFile.Open(PrefsFilename.c_str(), wxT("w"));
 #else
-               PrefsFile.Open(PrefsFilename, wxT("w"));
-#endif 
-       
-               PrefsFile.Write(wxT("HideLocalAddressBooks=false\nSaveWindowPosition=true\n"));
-       
-       }
-
+        PrefsFile.Open(PrefsFilename, wxT("w"));
+#endif
+        
+        PrefsFile.Write(wxT("HideLocalAddressBooks=false\nSaveWindowPosition=true\n"));
+        
+    }
+    
 }
 
 void SetupDirectories(){
-
-       // Create the directories if they don't exist.
-
-       wxString DefaultSettingsDir;
-
+    
+    // Create the directories if they don't exist.
+    
+    wxString DefaultSettingsDir;
+    
 #if defined(__HAIKU__)
-
-       //preffilename = wxT("noo");
-
+    
+    //preffilename = wxT("noo");
+    
 #elif defined(__WIN32__)
-
-       DefaultSettingsDir.Clear();
-       DefaultSettingsDir.Append(wxString::FromUTF8(getenv("APPDATA")));
-       DefaultSettingsDir.Append(wxT("\\Xestia\\"));
-
-       if (wxDirExists(DefaultSettingsDir) == FALSE){
-
-               // Create the directory.
-
-               if (wxMkdir(DefaultSettingsDir, 0740) == TRUE){         
-
-               }
-
-       }
-
-       // TODO: APPEND 'Address Book' to the directory.
-
-       DefaultSettingsDir.Append(wxT("\\Address Book\\"));
-
+    
+    DefaultSettingsDir.Clear();
+    DefaultSettingsDir.Append(wxString::FromUTF8(getenv("APPDATA")));
+    DefaultSettingsDir.Append(wxT("\\Xestia\\"));
+    
+    if (wxDirExists(DefaultSettingsDir) == FALSE){
+        
+        // Create the directory.
+        
+        if (wxMkdir(DefaultSettingsDir, 0740) == TRUE){
+            
+        }
+        
+    }
+    
+    // TODO: APPEND 'Address Book' to the directory.
+    
+    DefaultSettingsDir.Append(wxT("\\Address Book\\"));
+    
+#elif defined(__APPLE__)
+    
+    DefaultSettingsDir.Clear();
+    DefaultSettingsDir.Append(wxString::FromUTF8(getenv("HOME")));
+    DefaultSettingsDir.Append(wxT("/Library/Preferences/Xestia/"));
+    
+    if (wxDirExists(DefaultSettingsDir) == FALSE){
+        
+        // Create the directory.
+        
+        if (wxMkdir(DefaultSettingsDir, 0740) == TRUE){
+            
+        }
+        
+    }
+    
+    // TODO: APPEND 'Address Book' to the directory.
+    
+    DefaultSettingsDir.Append(wxT("/Address Book/"));
+    
 #else
-
-       DefaultSettingsDir.Clear();
-       DefaultSettingsDir.Append(wxString::FromUTF8(getenv("HOME")));
-       DefaultSettingsDir.Append(wxT("/.xestiaab/"));
-
+    
+    DefaultSettingsDir.Clear();
+    DefaultSettingsDir.Append(wxString::FromUTF8(getenv("HOME")));
+    DefaultSettingsDir.Append(wxT("/.xestiaab/"));
+    
 #endif
-
-       // Check if the directory exists.
-
-       if (wxDirExists(DefaultSettingsDir) == FALSE){
-       
-               // Create the directory.
-               
-               if (wxMkdir(DefaultSettingsDir, 0740) == TRUE){         
-                                       
-               }
-       
-       }
-
-       if (wxDirExists(DefaultSettingsDir + wxT("accounts")) == FALSE){
-       
-               if (wxMkdir(DefaultSettingsDir + wxT("accounts"), 0740) == TRUE){               
-                                       
-               }
-       
-       }
-       
-       if (wxDirExists(DefaultSettingsDir + wxT("preferences")) == FALSE){
-       
-               if (wxMkdir(DefaultSettingsDir + wxT("preferences"), 0740) == TRUE){            
-               
-               }
-       
-       }
-
+    
+    // Check if the directory exists.
+    
+    if (wxDirExists(DefaultSettingsDir) == FALSE){
+        
+        // Create the directory.
+        
+        if (wxMkdir(DefaultSettingsDir, 0740) == TRUE){                
+            
+        }
+        
+    }
+    
+    if (wxDirExists(DefaultSettingsDir + wxT("accounts")) == FALSE){
+        
+        if (wxMkdir(DefaultSettingsDir + wxT("accounts"), 0740) == TRUE){              
+            
+        }
+        
+    }
+    
+    if (wxDirExists(DefaultSettingsDir + wxT("preferences")) == FALSE){
+        
+        if (wxMkdir(DefaultSettingsDir + wxT("preferences"), 0740) == TRUE){           
+            
+        }
+        
+    }
+    
 }
\ 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