summaryrefslogtreecommitdiff
authoralwin <alwin>2004-02-18 22:36:26 (UTC)
committer alwin <alwin>2004-02-18 22:36:26 (UTC)
commitcfd235730a4619ae9181f0d78d78a7f9360ea49e (patch) (unidiff)
tree6044d8213b5b794ef6d99c60667df17445d86b2d
parent71b6aa6d19ed2e4690cd98ecdb7dbfe40f857653 (diff)
downloadopie-cfd235730a4619ae9181f0d78d78a7f9360ea49e.zip
opie-cfd235730a4619ae9181f0d78d78a7f9360ea49e.tar.gz
opie-cfd235730a4619ae9181f0d78d78a7f9360ea49e.tar.bz2
forgot member variable initializer
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/settings.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp
index 3279f39..65ca387 100644
--- a/noncore/net/mail/libmailwrapper/settings.cpp
+++ b/noncore/net/mail/libmailwrapper/settings.cpp
@@ -1,239 +1,240 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <qdir.h> 2#include <qdir.h>
3 3
4#include <qpe/config.h> 4#include <qpe/config.h>
5 5
6#include "settings.h" 6#include "settings.h"
7//#include "defines.h" 7//#include "defines.h"
8 8
9#define IMAP_PORT "143" 9#define IMAP_PORT "143"
10#define IMAP_SSL_PORT "993" 10#define IMAP_SSL_PORT "993"
11#define SMTP_PORT "25" 11#define SMTP_PORT "25"
12#define SMTP_SSL_PORT "465" 12#define SMTP_SSL_PORT "465"
13#define POP3_PORT "110" 13#define POP3_PORT "110"
14#define POP3_SSL_PORT "995" 14#define POP3_SSL_PORT "995"
15#define NNTP_PORT "119" 15#define NNTP_PORT "119"
16#define NNTP_SSL_PORT "563" 16#define NNTP_SSL_PORT "563"
17 17
18 18
19Settings::Settings() 19Settings::Settings()
20 : QObject() 20 : QObject()
21{ 21{
22 updateAccounts(); 22 updateAccounts();
23} 23}
24 24
25void Settings::checkDirectory() 25void Settings::checkDirectory()
26{ 26{
27 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { 27 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) {
28 system( "mkdir -p $HOME/Applications/opiemail" ); 28 system( "mkdir -p $HOME/Applications/opiemail" );
29 qDebug( "$HOME/Applications/opiemail created" ); 29 qDebug( "$HOME/Applications/opiemail created" );
30 } 30 }
31} 31}
32 32
33QList<Account> Settings::getAccounts() 33QList<Account> Settings::getAccounts()
34{ 34{
35 return accounts; 35 return accounts;
36} 36}
37 37
38void Settings::addAccount( Account *account ) 38void Settings::addAccount( Account *account )
39{ 39{
40 accounts.append( account ); 40 accounts.append( account );
41} 41}
42 42
43void Settings::delAccount( Account *account ) 43void Settings::delAccount( Account *account )
44{ 44{
45 accounts.remove( account ); 45 accounts.remove( account );
46 account->remove(); 46 account->remove();
47} 47}
48 48
49void Settings::updateAccounts() 49void Settings::updateAccounts()
50{ 50{
51 accounts.clear(); 51 accounts.clear();
52 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 52 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
53 QStringList::Iterator it; 53 QStringList::Iterator it;
54 54
55 QStringList imap = dir.entryList( "imap-*" ); 55 QStringList imap = dir.entryList( "imap-*" );
56 for ( it = imap.begin(); it != imap.end(); it++ ) { 56 for ( it = imap.begin(); it != imap.end(); it++ ) {
57 qDebug( "Added IMAP account" ); 57 qDebug( "Added IMAP account" );
58 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); 58 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") );
59 accounts.append( account ); 59 accounts.append( account );
60 } 60 }
61 61
62 QStringList pop3 = dir.entryList( "pop3-*" ); 62 QStringList pop3 = dir.entryList( "pop3-*" );
63 for ( it = pop3.begin(); it != pop3.end(); it++ ) { 63 for ( it = pop3.begin(); it != pop3.end(); it++ ) {
64 qDebug( "Added POP account" ); 64 qDebug( "Added POP account" );
65 POP3account *account = new POP3account( (*it).replace(0, 5, "") ); 65 POP3account *account = new POP3account( (*it).replace(0, 5, "") );
66 accounts.append( account ); 66 accounts.append( account );
67 } 67 }
68 68
69 QStringList smtp = dir.entryList( "smtp-*" ); 69 QStringList smtp = dir.entryList( "smtp-*" );
70 for ( it = smtp.begin(); it != smtp.end(); it++ ) { 70 for ( it = smtp.begin(); it != smtp.end(); it++ ) {
71 qDebug( "Added SMTP account" ); 71 qDebug( "Added SMTP account" );
72 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); 72 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") );
73 accounts.append( account ); 73 accounts.append( account );
74 } 74 }
75 75
76 QStringList nntp = dir.entryList( "nntp-*" ); 76 QStringList nntp = dir.entryList( "nntp-*" );
77 for ( it = nntp.begin(); it != nntp.end(); it++ ) { 77 for ( it = nntp.begin(); it != nntp.end(); it++ ) {
78 qDebug( "Added NNTP account" ); 78 qDebug( "Added NNTP account" );
79 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); 79 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") );
80 accounts.append( account ); 80 accounts.append( account );
81 } 81 }
82 82
83 readAccounts(); 83 readAccounts();
84} 84}
85 85
86void Settings::saveAccounts() 86void Settings::saveAccounts()
87{ 87{
88 checkDirectory(); 88 checkDirectory();
89 Account *it; 89 Account *it;
90 90
91 for ( it = accounts.first(); it; it = accounts.next() ) { 91 for ( it = accounts.first(); it; it = accounts.next() ) {
92 it->save(); 92 it->save();
93 } 93 }
94} 94}
95 95
96void Settings::readAccounts() 96void Settings::readAccounts()
97{ 97{
98 checkDirectory(); 98 checkDirectory();
99 Account *it; 99 Account *it;
100 100
101 for ( it = accounts.first(); it; it = accounts.next() ) { 101 for ( it = accounts.first(); it; it = accounts.next() ) {
102 it->read(); 102 it->read();
103 } 103 }
104} 104}
105 105
106Account::Account() 106Account::Account()
107{ 107{
108 accountName = "changeMe"; 108 accountName = "changeMe";
109 type = "changeMe"; 109 type = "changeMe";
110 ssl = false; 110 ssl = false;
111 connectionType = 1; 111 connectionType = 1;
112 offline = false;
112} 113}
113 114
114void Account::remove() 115void Account::remove()
115{ 116{
116 QFile file( getFileName() ); 117 QFile file( getFileName() );
117 file.remove(); 118 file.remove();
118} 119}
119 120
120IMAPaccount::IMAPaccount() 121IMAPaccount::IMAPaccount()
121 : Account() 122 : Account()
122{ 123{
123 file = IMAPaccount::getUniqueFileName(); 124 file = IMAPaccount::getUniqueFileName();
124 accountName = "New IMAP Account"; 125 accountName = "New IMAP Account";
125 ssl = false; 126 ssl = false;
126 connectionType = 1; 127 connectionType = 1;
127 type = "IMAP"; 128 type = "IMAP";
128 port = IMAP_PORT; 129 port = IMAP_PORT;
129} 130}
130 131
131IMAPaccount::IMAPaccount( QString filename ) 132IMAPaccount::IMAPaccount( QString filename )
132 : Account() 133 : Account()
133{ 134{
134 file = filename; 135 file = filename;
135 accountName = "New IMAP Account"; 136 accountName = "New IMAP Account";
136 ssl = false; 137 ssl = false;
137 connectionType = 1; 138 connectionType = 1;
138 type = "IMAP"; 139 type = "IMAP";
139 port = IMAP_PORT; 140 port = IMAP_PORT;
140} 141}
141 142
142QString IMAPaccount::getUniqueFileName() 143QString IMAPaccount::getUniqueFileName()
143{ 144{
144 int num = 0; 145 int num = 0;
145 QString unique; 146 QString unique;
146 147
147 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 148 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
148 149
149 QStringList imap = dir.entryList( "imap-*" ); 150 QStringList imap = dir.entryList( "imap-*" );
150 do { 151 do {
151 unique.setNum( num++ ); 152 unique.setNum( num++ );
152 } while ( imap.contains( "imap-" + unique ) > 0 ); 153 } while ( imap.contains( "imap-" + unique ) > 0 );
153 154
154 return unique; 155 return unique;
155} 156}
156 157
157void IMAPaccount::read() 158void IMAPaccount::read()
158{ 159{
159 Config *conf = new Config( getFileName(), Config::File ); 160 Config *conf = new Config( getFileName(), Config::File );
160 conf->setGroup( "IMAP Account" ); 161 conf->setGroup( "IMAP Account" );
161 accountName = conf->readEntry( "Account","" ); 162 accountName = conf->readEntry( "Account","" );
162 if (accountName.isNull()) accountName = ""; 163 if (accountName.isNull()) accountName = "";
163 server = conf->readEntry( "Server","" ); 164 server = conf->readEntry( "Server","" );
164 if (server.isNull()) server=""; 165 if (server.isNull()) server="";
165 port = conf->readEntry( "Port","" ); 166 port = conf->readEntry( "Port","" );
166 if (port.isNull()) port="143"; 167 if (port.isNull()) port="143";
167 connectionType = conf->readNumEntry( "ConnectionType" ); 168 connectionType = conf->readNumEntry( "ConnectionType" );
168 ssl = conf->readBoolEntry( "SSL",false ); 169 ssl = conf->readBoolEntry( "SSL",false );
169 user = conf->readEntry( "User","" ); 170 user = conf->readEntry( "User","" );
170 if (user.isNull()) user = ""; 171 if (user.isNull()) user = "";
171 password = conf->readEntryCrypt( "Password","" ); 172 password = conf->readEntryCrypt( "Password","" );
172 if (password.isNull()) password = ""; 173 if (password.isNull()) password = "";
173 prefix = conf->readEntry("MailPrefix",""); 174 prefix = conf->readEntry("MailPrefix","");
174 if (prefix.isNull()) prefix = ""; 175 if (prefix.isNull()) prefix = "";
175 offline = conf->readBoolEntry("Offline",false); 176 offline = conf->readBoolEntry("Offline",false);
176 delete conf; 177 delete conf;
177} 178}
178 179
179void IMAPaccount::save() 180void IMAPaccount::save()
180{ 181{
181 qDebug( "saving " + getFileName() ); 182 qDebug( "saving " + getFileName() );
182 Settings::checkDirectory(); 183 Settings::checkDirectory();
183 184
184 Config *conf = new Config( getFileName(), Config::File ); 185 Config *conf = new Config( getFileName(), Config::File );
185 conf->setGroup( "IMAP Account" ); 186 conf->setGroup( "IMAP Account" );
186 conf->writeEntry( "Account", accountName ); 187 conf->writeEntry( "Account", accountName );
187 conf->writeEntry( "Server", server ); 188 conf->writeEntry( "Server", server );
188 conf->writeEntry( "Port", port ); 189 conf->writeEntry( "Port", port );
189 conf->writeEntry( "SSL", ssl ); 190 conf->writeEntry( "SSL", ssl );
190 conf->writeEntry( "ConnectionType", connectionType ); 191 conf->writeEntry( "ConnectionType", connectionType );
191 conf->writeEntry( "User", user ); 192 conf->writeEntry( "User", user );
192 conf->writeEntryCrypt( "Password", password ); 193 conf->writeEntryCrypt( "Password", password );
193 conf->writeEntry( "MailPrefix",prefix); 194 conf->writeEntry( "MailPrefix",prefix);
194 conf->writeEntry( "Offline",offline); 195 conf->writeEntry( "Offline",offline);
195 conf->write(); 196 conf->write();
196 delete conf; 197 delete conf;
197} 198}
198 199
199 200
200QString IMAPaccount::getFileName() 201QString IMAPaccount::getFileName()
201{ 202{
202 return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; 203 return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file;
203} 204}
204 205
205POP3account::POP3account() 206POP3account::POP3account()
206 : Account() 207 : Account()
207{ 208{
208 file = POP3account::getUniqueFileName(); 209 file = POP3account::getUniqueFileName();
209 accountName = "New POP3 Account"; 210 accountName = "New POP3 Account";
210 ssl = false; 211 ssl = false;
211 connectionType = 1; 212 connectionType = 1;
212 type = "POP3"; 213 type = "POP3";
213 port = POP3_PORT; 214 port = POP3_PORT;
214} 215}
215 216
216POP3account::POP3account( QString filename ) 217POP3account::POP3account( QString filename )
217 : Account() 218 : Account()
218{ 219{
219 file = filename; 220 file = filename;
220 accountName = "New POP3 Account"; 221 accountName = "New POP3 Account";
221 ssl = false; 222 ssl = false;
222 connectionType = 1; 223 connectionType = 1;
223 type = "POP3"; 224 type = "POP3";
224 port = POP3_PORT; 225 port = POP3_PORT;
225} 226}
226 227
227QString POP3account::getUniqueFileName() 228QString POP3account::getUniqueFileName()
228{ 229{
229 int num = 0; 230 int num = 0;
230 QString unique; 231 QString unique;
231 232
232 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 233 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
233 234
234 QStringList imap = dir.entryList( "pop3-*" ); 235 QStringList imap = dir.entryList( "pop3-*" );
235 do { 236 do {
236 unique.setNum( num++ ); 237 unique.setNum( num++ );
237 } while ( imap.contains( "pop3-" + unique ) > 0 ); 238 } while ( imap.contains( "pop3-" + unique ) > 0 );
238 239
239 return unique; 240 return unique;