X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcommon%2Fdefaults.cpp;h=2e47a27ba84701ef70de938c8629a86e763ad837;hb=4ecf020f6b1aab7c70d179826e620ad25b815810;hp=30455a76b7c5b9a9817c2b39166d419adac84ab9;hpb=a640cd5555cef0092393a0feacb3c9222e177fe4;p=xestiaab%2F.git
diff --git a/source/common/defaults.cpp b/source/common/defaults.cpp
index 30455a7..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(){
@@ -28,9 +29,7 @@ void SetupDefaultAddressBook(){
wxString DefaultLocalDir;
#if defined(__HAIKU__)
-
- //preffilename = wxT("noo");
-
+
#elif defined(__WIN32__)
DefaultLocalDir.Clear();
@@ -74,7 +73,6 @@ void SetupDefaultSettings(){
#if defined(__HAIKU__)
- //preffilename = wxT("noo");
#elif defined(__WIN32__)
@@ -86,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
@@ -135,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(){
@@ -143,11 +195,9 @@ void SetupDirectories(){
// Create the directories if they don't exist.
wxString DefaultSettingsDir;
-
+
#if defined(__HAIKU__)
- //preffilename = wxT("noo");
-
#elif defined(__WIN32__)
DefaultSettingsDir.Clear();