Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added code so that OSX is now supported.
[xestiaab/.git] / source / common / defaults.cpp
1 #include <wx/wx.h>
2 #include <wx/ffile.h>
4 void SetupDefaultAddressBook(){
5     
6     // Check if the 'Default.local' directory exists.
7     
8     wxString DefaultLocalDir;
9     
10 #if defined(__HAIKU__)
11     
12     //preffilename = wxT("noo");
13     
14 #elif defined(__WIN32__)
15     
16     DefaultLocalDir.Clear();
17     DefaultLocalDir.Append(wxString::FromUTF8(getenv("APPDATA")));
18     DefaultLocalDir.Append(wxT("\\Xestia\\Address Book\\accounts\\"));
19     DefaultLocalDir.Append(wxT("Default.local"));
20     
21 #elif defined(__APPLE__)
22     
23     DefaultLocalDir.Clear();
24     DefaultLocalDir.Append(wxString::FromUTF8(getenv("HOME")));
25     DefaultLocalDir.Append(wxT("/Library/Preferences/Xestia/Address Book/accounts/"));
26     DefaultLocalDir.Append(wxT("Default.local"));
27     
28 #else
29     
30     DefaultLocalDir.Clear();
31     DefaultLocalDir.Append(wxString::FromUTF8(getenv("HOME")));
32     DefaultLocalDir.Append(wxT("/.xestiaab/accounts/"));
33     DefaultLocalDir.Append(wxT("Default.local"));
34     
35 #endif
36     
37     if (wxDirExists(DefaultLocalDir) == FALSE){
38         
39         if (wxMkdir(DefaultLocalDir, 0740) == TRUE){
40             
41         }
42         
43     }
44     
45 }
47 void SetupDefaultSettings(){
48     
49     // Setup default (non account) settings if they don't exist.
50     
51     wxString DefaultPrefDir;
52     
53 #if defined(__HAIKU__)
54     
55     //preffilename = wxT("noo");
56     
57 #elif defined(__WIN32__)
58     
59     DefaultPrefDir.Clear();
60     DefaultPrefDir.Append(wxString::FromUTF8(getenv("APPDATA")));
61     DefaultPrefDir.Append(wxT("\\Xestia\\Address Book\\preferences\\"));
62     
63 #elif defined(__APPLE__)
64     
65     DefaultPrefDir.Clear();
66     DefaultPrefDir.Append(wxString::FromUTF8(getenv("HOME")));
67     DefaultPrefDir.Append(wxT("/Library/Preferences/Xestia/Address Book/preferences"));
68     
69 #else
70     
71     DefaultPrefDir.Clear();
72     DefaultPrefDir.Append(wxString::FromUTF8(getenv("HOME")));
73     DefaultPrefDir.Append(wxT("/.xestiaab/preferences/"));
74     
75 #endif
76     
77     // Create the accounts file if it doesn't exist.
78     
79     if (wxFileExists(DefaultPrefDir + wxT("accounts")) == FALSE){
80         
81         wxString AccountsFilename;
82         wxFFile AccountsFile;
83         
84         AccountsFilename = DefaultPrefDir;
85         AccountsFilename.Append(wxT("accounts"));
86         
87 #if wxABI_VERSION < 20900
88         AccountsFile.Open(AccountsFilename.c_str(), wxT("w"));
89 #else
90         AccountsFile.Open(AccountsFilename, wxT("w"));
91 #endif
92         
93         AccountsFile.Write(wxT(""));
94         
95     }
96     
97     // Create the preferences file if it doesn't exist.
98     
99     if (wxFileExists(DefaultPrefDir + wxT("settings")) == FALSE){
100         
101         wxString PrefsFilename;
102         wxFFile PrefsFile;
103         
104         PrefsFilename = DefaultPrefDir;
105         PrefsFilename.Append(wxT("settings"));
106         
107 #if wxABI_VERSION < 20900
108         PrefsFile.Open(PrefsFilename.c_str(), wxT("w"));
109 #else
110         PrefsFile.Open(PrefsFilename, wxT("w"));
111 #endif
112         
113         PrefsFile.Write(wxT("HideLocalAddressBooks=false\nSaveWindowPosition=true\n"));
114         
115     }
116     
119 void SetupDirectories(){
120     
121     // Create the directories if they don't exist.
122     
123     wxString DefaultSettingsDir;
124     
125 #if defined(__HAIKU__)
126     
127     //preffilename = wxT("noo");
128     
129 #elif defined(__WIN32__)
130     
131     DefaultSettingsDir.Clear();
132     DefaultSettingsDir.Append(wxString::FromUTF8(getenv("APPDATA")));
133     DefaultSettingsDir.Append(wxT("\\Xestia\\"));
134     
135     if (wxDirExists(DefaultSettingsDir) == FALSE){
136         
137         // Create the directory.
138         
139         if (wxMkdir(DefaultSettingsDir, 0740) == TRUE){
140             
141         }
142         
143     }
144     
145     // TODO: APPEND 'Address Book' to the directory.
146     
147     DefaultSettingsDir.Append(wxT("\\Address Book\\"));
148     
149 #elif defined(__APPLE__)
150     
151     DefaultSettingsDir.Clear();
152     DefaultSettingsDir.Append(wxString::FromUTF8(getenv("HOME")));
153     DefaultSettingsDir.Append(wxT("/Library/Preferences/Xestia/"));
154     
155     if (wxDirExists(DefaultSettingsDir) == FALSE){
156         
157         // Create the directory.
158         
159         if (wxMkdir(DefaultSettingsDir, 0740) == TRUE){
160             
161         }
162         
163     }
164     
165     // TODO: APPEND 'Address Book' to the directory.
166     
167     DefaultSettingsDir.Append(wxT("/Address Book/"));
168     
169 #else
170     
171     DefaultSettingsDir.Clear();
172     DefaultSettingsDir.Append(wxString::FromUTF8(getenv("HOME")));
173     DefaultSettingsDir.Append(wxT("/.xestiaab/"));
174     
175 #endif
176     
177     // Check if the directory exists.
178     
179     if (wxDirExists(DefaultSettingsDir) == FALSE){
180         
181         // Create the directory.
182         
183         if (wxMkdir(DefaultSettingsDir, 0740) == TRUE){         
184             
185         }
186         
187     }
188     
189     if (wxDirExists(DefaultSettingsDir + wxT("accounts")) == FALSE){
190         
191         if (wxMkdir(DefaultSettingsDir + wxT("accounts"), 0740) == TRUE){               
192             
193         }
194         
195     }
196     
197     if (wxDirExists(DefaultSettingsDir + wxT("preferences")) == FALSE){
198         
199         if (wxMkdir(DefaultSettingsDir + wxT("preferences"), 0740) == TRUE){            
200             
201         }
202         
203     }
204     
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