X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcommon%2Fdefaults.cpp;h=2e47a27ba84701ef70de938c8629a86e763ad837;hb=d6023ac2bba9572d1bca7da3d5960f6c07082624;hp=e7e467afcc1afd0df0d76b6ba1371f1b84cfe650;hpb=3c2e78e6290082712464b13a433766955a044a46;p=xestiaab%2F.git
diff --git a/source/common/defaults.cpp b/source/common/defaults.cpp
index e7e467a..2e47a27 100644
--- a/source/common/defaults.cpp
+++ b/source/common/defaults.cpp
@@ -16,8 +16,9 @@
// You should have received a copy of the GNU General Public License along
// with Xestia Address Book. If not, see
-#include
-#include
+#include "defaults.h"
+
+using namespace std;
void SetupDefaultAddressBook(){
@@ -83,7 +84,7 @@ void SetupDefaultSettings(){
DefaultPrefDir.Clear();
DefaultPrefDir.Append(wxString::FromUTF8(getenv("HOME")));
- DefaultPrefDir.Append(wxT("/Library/Preferences/Xestia/Address Book/preferences"));
+ DefaultPrefDir.Append(wxT("/Library/Preferences/Xestia/Address Book/preferences/"));
#else
@@ -132,7 +133,61 @@ void SetupDefaultSettings(){
PrefsFile.Write(wxT("HideLocalAddressBooks=false\nSaveWindowPosition=true\n"));
}
-
+
+ // Check if the default account is in the accounts list.
+ // Add it if it isn't.
+
+ wxString accountsConfigFile = DefaultPrefDir;
+ accountsConfigFile.Append(wxT("accounts"));
+
+ wxFileConfig *accountConfigData = new wxFileConfig("", "", accountsConfigFile);
+
+ long itemIndex = 0;
+ wxString accountName;
+ wxString accountType;
+ wxString accountDirectory;
+ bool continueProcessing = false;
+ bool defaultCalendarExists = false;
+
+ continueProcessing = accountConfigData->GetFirstGroup(accountName, itemIndex);
+
+ while (continueProcessing){
+
+ accountConfigData->SetPath(accountName);
+ accountConfigData->Read(wxT("type"), &accountType);
+ accountConfigData->Read(wxT("accountdir"), &accountDirectory);
+
+ if (accountType == wxT("Local") && accountDirectory == wxT("Default")){
+
+ defaultCalendarExists = true;
+
+ }
+
+ continueProcessing = accountConfigData->GetNextGroup(accountName, itemIndex);
+
+ }
+
+ if (defaultCalendarExists == false){
+
+ // Create the account in the accounts file.
+
+ accountConfigData->SetPath(wxT("/Default"));
+ accountConfigData->Write(wxT("type"), wxT("Local"));
+ accountConfigData->Write(wxT("accountdir"), wxT("Default"));
+ accountConfigData->Write(wxT("prefix"), wxT(""));
+ accountConfigData->Write(wxT("address"), wxT(""));
+ accountConfigData->Write(wxT("port"), wxT(""));
+ accountConfigData->Write(wxT("ssl"), wxT("false"));
+ accountConfigData->Write(wxT("username"), wxT(""));
+ accountConfigData->Write(wxT("password"), wxT(""));
+ accountConfigData->Write(wxT("prefix"), wxT(""));
+ accountConfigData->Write(wxT("refresh"), wxT("1800"));
+
+ }
+
+ delete accountConfigData;
+ accountConfigData = nullptr;
+
}
void SetupDirectories(){
@@ -140,7 +195,7 @@ void SetupDirectories(){
// Create the directories if they don't exist.
wxString DefaultSettingsDir;
-
+
#if defined(__HAIKU__)
#elif defined(__WIN32__)