X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcommon%2Fdefaults.cpp;h=57a8ad57b0363b14cbd0d5933d4f3deb58b805ef;hb=3ea1eb0f68896a1269eaea72873eaa744503897a;hp=e23f9e75f767cef3810d985311e92e3036492500;hpb=45729fca56479bd9158486e0cda0c4a94b4dd1dc;p=xestiaab%2F.git diff --git a/source/common/defaults.cpp b/source/common/defaults.cpp index e23f9e7..57a8ad5 100644 --- a/source/common/defaults.cpp +++ b/source/common/defaults.cpp @@ -1,172 +1,222 @@ +// defaults.cpp - Default settings 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 #include void SetupDefaultAddressBook(){ - + + // Setup the default address book if there are none. + // Check if the 'Default.local' directory exists. - + wxString DefaultLocalDir; - -#if defined(__HAIKU__) - //preffilename = wxT("noo"); - +#if defined(__HAIKU__) + #elif defined(__WIN32__) - + 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")); - + #endif - + if (wxDirExists(DefaultLocalDir) == FALSE){ - - if (wxMkdir(DefaultLocalDir, 0740) == TRUE){ - + + if (wxMkdir(DefaultLocalDir, 0740) == TRUE){ + } - + } - + } void SetupDefaultSettings(){ - + + // Setup the default settings if they don't exist. + // Setup default (non account) settings if they don't exist. - + wxString DefaultPrefDir; - + #if defined(__HAIKU__) - - //preffilename = wxT("noo"); - + + #elif defined(__WIN32__) - + 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/")); - + #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")); - + #if wxABI_VERSION < 20900 AccountsFile.Open(AccountsFilename.c_str(), wxT("w")); #else AccountsFile.Open(AccountsFilename, wxT("w")); -#endif - +#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")); #else PrefsFile.Open(PrefsFilename, wxT("w")); -#endif - +#endif + PrefsFile.Write(wxT("HideLocalAddressBooks=false\nSaveWindowPosition=true\n")); - + } - + } void SetupDirectories(){ - + // Create the directories if they don't exist. - + wxString DefaultSettingsDir; #if defined(__HAIKU__) - - //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){ - + + if (wxMkdir(DefaultSettingsDir, 0740) == TRUE){ + } - + } - - // TODO: APPEND 'Address Book' to the directory. - + + // '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){ + + } + + } + + // Append 'Address Book' to the directory. + + DefaultSettingsDir.Append(wxT("/Address Book/")); + #else - + 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){ - + } - + } - + } \ No newline at end of file