author | conber <conber> | 2002-06-16 16:26:27 (UTC) |
---|---|---|
committer | conber <conber> | 2002-06-16 16:26:27 (UTC) |
commit | 23c2d100ed9070d82f956cdcb7364f5627aa0600 (patch) (unidiff) | |
tree | 721a3fe17def3d0425026a3ebb2f7105bb44d425 | |
parent | ea69cfbbde29fef2f792d1eab702699aada088bf (diff) | |
download | opie-23c2d100ed9070d82f956cdcb7364f5627aa0600.zip opie-23c2d100ed9070d82f956cdcb7364f5627aa0600.tar.gz opie-23c2d100ed9070d82f956cdcb7364f5627aa0600.tar.bz2 |
small but important fix
-rw-r--r-- | noncore/unsupported/mail2/folderwidget.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/unsupported/mail2/folderwidget.cpp b/noncore/unsupported/mail2/folderwidget.cpp index ca2bb5a..6c36e92 100644 --- a/noncore/unsupported/mail2/folderwidget.cpp +++ b/noncore/unsupported/mail2/folderwidget.cpp | |||
@@ -1,314 +1,314 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qtextstream.h> | 2 | #include <qtextstream.h> |
3 | #include <qpopupmenu.h> | 3 | #include <qpopupmenu.h> |
4 | #include <qheader.h> | 4 | #include <qheader.h> |
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | 7 | ||
8 | #include <qpe/resource.h> | 8 | #include <qpe/resource.h> |
9 | 9 | ||
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | 11 | ||
12 | #include "folderwidget.h" | 12 | #include "folderwidget.h" |
13 | #include "imaphandler.h" | 13 | #include "imaphandler.h" |
14 | #include "imapbase.h" | 14 | #include "imapbase.h" |
15 | #include "rename.h" | 15 | #include "rename.h" |
16 | 16 | ||
17 | FolderWidgetItem::FolderWidgetItem(Folder &folder, QListView *parent) | 17 | FolderWidgetItem::FolderWidgetItem(Folder &folder, QListView *parent) |
18 | : QListViewItem(parent), _folder(folder) | 18 | : QListViewItem(parent), _folder(folder) |
19 | { | 19 | { |
20 | setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox"))); | 20 | setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox"))); |
21 | setText(0, _folder.topFolder().account().user() + " (" + _folder.topFolder().account().imapServer() + ")"); | 21 | setText(0, _folder.topFolder().account().user() + " (" + _folder.topFolder().account().imapServer() + ")"); |
22 | setOpen(true); | 22 | setOpen(true); |
23 | } | 23 | } |
24 | 24 | ||
25 | FolderWidgetItem::FolderWidgetItem(Folder &folder, FolderWidgetItem *parent) | 25 | FolderWidgetItem::FolderWidgetItem(Folder &folder, FolderWidgetItem *parent) |
26 | : QListViewItem(parent), _folder(folder) | 26 | : QListViewItem(parent), _folder(folder) |
27 | { | 27 | { |
28 | if (_folder.noCache()) { | 28 | if (_folder.noCache()) { |
29 | setText(0, QObject::tr("<Foldertree not known.>")); | 29 | setText(0, QObject::tr("<Foldertree not known.>")); |
30 | } else { | 30 | } else { |
31 | if (folder.fullName().upper() == "INBOX") { | 31 | if (folder.fullName().upper() == "INBOX") { |
32 | setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox"))); | 32 | setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox"))); |
33 | setText(0, QObject::tr("Inbox")); | 33 | setText(0, QObject::tr("Inbox")); |
34 | } else { | 34 | } else { |
35 | setPixmap(0, QPixmap(Resource::loadPixmap("mail/folder"))); | 35 | setPixmap(0, QPixmap(Resource::loadPixmap("mail/folder"))); |
36 | setText(0, folder.fullName()); | 36 | setText(0, folder.fullName()); |
37 | } | 37 | } |
38 | setOpen(true); | 38 | setOpen(true); |
39 | } | 39 | } |
40 | } | 40 | } |
41 | 41 | ||
42 | FolderWidget::FolderWidget(QWidget *parent, const char *name, WFlags fl) | 42 | FolderWidget::FolderWidget(QWidget *parent, const char *name, WFlags fl) |
43 | : ListViewPlus(parent, name, fl) | 43 | : ListViewPlus(parent, name, fl) |
44 | { | 44 | { |
45 | header()->hide(); | 45 | header()->hide(); |
46 | addColumn(""); | 46 | addColumn(""); |
47 | setSorting(-1); | 47 | setSorting(-1); |
48 | 48 | ||
49 | QPopupMenu *menu = new QPopupMenu(); | 49 | QPopupMenu *menu = new QPopupMenu(); |
50 | menu->insertItem(tr("Rename"), MENU_RENAME); | 50 | menu->insertItem(tr("Rename"), MENU_RENAME); |
51 | menu->insertItem(tr("Delete"), MENU_DELETE); | 51 | menu->insertItem(tr("Delete"), MENU_DELETE); |
52 | menu->insertItem(tr("Move"), MENU_MOVE); | 52 | menu->insertItem(tr("Move"), MENU_MOVE); |
53 | menu->insertItem(tr("Copy"), MENU_COPY); | 53 | menu->insertItem(tr("Copy"), MENU_COPY); |
54 | menu->insertSeparator(); | 54 | menu->insertSeparator(); |
55 | menu->insertItem(tr("Create folder"), MENU_CREATE); | 55 | menu->insertItem(tr("Create folder"), MENU_CREATE); |
56 | menu->insertSeparator(); | 56 | menu->insertSeparator(); |
57 | menu->insertItem(tr("Rescan folder list"), MENU_RESCAN); | 57 | menu->insertItem(tr("Rescan folder list"), MENU_RESCAN); |
58 | setPopup(menu); | 58 | setPopup(menu); |
59 | 59 | ||
60 | getAccounts(); | 60 | getAccounts(); |
61 | 61 | ||
62 | connect(menu, SIGNAL(activated(int)), SLOT(slotMenuActivated(int))); | 62 | connect(menu, SIGNAL(activated(int)), SLOT(slotMenuActivated(int))); |
63 | connect(this, SIGNAL(clicked(QListViewItem *)), SLOT(slotItemClicked(QListViewItem *))); | 63 | connect(this, SIGNAL(clicked(QListViewItem *)), SLOT(slotItemClicked(QListViewItem *))); |
64 | } | 64 | } |
65 | 65 | ||
66 | FolderWidget::~FolderWidget() | 66 | FolderWidget::~FolderWidget() |
67 | { | 67 | { |
68 | // TODO: Save folder tree. | 68 | // TODO: Save folder tree. |
69 | } | 69 | } |
70 | 70 | ||
71 | void FolderWidget::update() | 71 | void FolderWidget::update() |
72 | { | 72 | { |
73 | getAccounts(); | 73 | getAccounts(); |
74 | } | 74 | } |
75 | 75 | ||
76 | void FolderWidget::getAccounts() | 76 | void FolderWidget::getAccounts() |
77 | { | 77 | { |
78 | clear(); | 78 | clear(); |
79 | 79 | ||
80 | QValueList<Account> accounts = ConfigFile::getAccounts(); | 80 | QValueList<Account> accounts = ConfigFile::getAccounts(); |
81 | QValueList<Account>::Iterator it; | 81 | QValueList<Account>::Iterator it; |
82 | for (it = accounts.begin(); it != accounts.end(); it++) { | 82 | for (it = accounts.begin(); it != accounts.end(); it++) { |
83 | FolderWidgetItem *item = addAccount(*it); | 83 | FolderWidgetItem *item = addAccount(*it); |
84 | QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + (*it).accountName()); | 84 | QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + (*it).accountName()); |
85 | if (!f.open(IO_ReadOnly)) { | 85 | if (!f.open(IO_ReadOnly)) { |
86 | Folder folder; | 86 | Folder folder; |
87 | folder.setNoCache(true); | 87 | folder.setNoCache(true); |
88 | addFolder(folder, item); | 88 | addFolder(folder, item); |
89 | } else { | 89 | } else { |
90 | QTextStream t(&f); | 90 | QTextStream t(&f); |
91 | while (!t.atEnd()) { | 91 | while (!t.atEnd()) { |
92 | QString separator = t.readLine(); | 92 | QString separator = t.readLine(); |
93 | QString fullname = t.readLine(); | 93 | QString fullname = t.readLine(); |
94 | Folder folder; | 94 | Folder folder; |
95 | folder.setSeparator(separator); | 95 | folder.setSeparator(separator); |
96 | folder.setFullName(fullname); | 96 | folder.setFullName(fullname); |
97 | folder.setTopFolder(item->folder().topFolder()); | 97 | folder.setTopFolder(item->folder().topFolder()); |
98 | addFolder(folder, item); | 98 | addFolder(folder, item); |
99 | } | 99 | } |
100 | f.close(); | 100 | f.close(); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | FolderWidgetItem *FolderWidget::addAccount(Account &account) | 105 | FolderWidgetItem *FolderWidget::addAccount(Account &account) |
106 | { | 106 | { |
107 | TopFolder tf; | 107 | TopFolder tf; |
108 | tf.setAccount(account); | 108 | tf.setAccount(account); |
109 | 109 | ||
110 | // XXX This has to change!!! The folderwidget may not create an | 110 | // XXX This has to change!!! The folderwidget may not create an |
111 | // XXX IMAPHandler!!!! Do this in IMAPHandler! | 111 | // XXX IMAPHandler!!!! Do this in IMAPHandler! |
112 | tf.setIMAPHandler(new IMAPHandler(account)); | 112 | tf.setIMAPHandler(new IMAPHandler(account)); |
113 | 113 | ||
114 | Folder folder; | 114 | Folder folder; |
115 | folder.setTopFolder(tf); | 115 | folder.setTopFolder(tf); |
116 | 116 | ||
117 | connect(tf.handler(), SIGNAL(IMAPLookingUpHost()), SLOT(slotIMAPLookingUpHost())); | 117 | connect(tf.handler(), SIGNAL(IMAPLookingUpHost()), SLOT(slotIMAPLookingUpHost())); |
118 | connect(tf.handler(), SIGNAL(IMAPHostFound()), SLOT(slotIMAPHostFound())); | 118 | connect(tf.handler(), SIGNAL(IMAPHostFound()), SLOT(slotIMAPHostFound())); |
119 | connect(tf.handler(), SIGNAL(IMAPConnected()), SLOT(slotIMAPConnected())); | 119 | connect(tf.handler(), SIGNAL(IMAPConnected()), SLOT(slotIMAPConnected())); |
120 | connect(tf.handler(), SIGNAL(IMAPDisconnected()), SLOT(slotIMAPDisconnected())); | 120 | connect(tf.handler(), SIGNAL(IMAPDisconnected()), SLOT(slotIMAPDisconnected())); |
121 | connect(tf.handler(), SIGNAL(IMAPError(int)), SLOT(slotIMAPError(int))); | 121 | connect(tf.handler(), SIGNAL(IMAPError(int)), SLOT(slotIMAPError(int))); |
122 | 122 | ||
123 | return new FolderWidgetItem(folder, this); | 123 | return new FolderWidgetItem(folder, this); |
124 | } | 124 | } |
125 | 125 | ||
126 | FolderWidgetItem *FolderWidget::addFolder(Folder &folder, FolderWidgetItem *folderWidgetItem) | 126 | FolderWidgetItem *FolderWidget::addFolder(Folder &folder, FolderWidgetItem *folderWidgetItem) |
127 | { | 127 | { |
128 | return new FolderWidgetItem(folder, folderWidgetItem); | 128 | return new FolderWidgetItem(folder, folderWidgetItem); |
129 | } | 129 | } |
130 | 130 | ||
131 | void FolderWidget::slotMenuActivated(int itemid) | 131 | void FolderWidget::slotMenuActivated(int itemid) |
132 | { | 132 | { |
133 | if (currentItem() == NULL) { | 133 | if (currentItem() == NULL) { |
134 | QMessageBox::information(this, tr("Error"), tr("<p>Please select an item first.</p>"), tr("Ok")); | 134 | QMessageBox::information(this, tr("Error"), tr("<p>Please select an item first.</p>"), tr("Ok")); |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | 137 | ||
138 | if (itemid == MENU_RENAME) { | 138 | if (itemid == MENU_RENAME) { |
139 | if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return; | 139 | if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return; |
140 | 140 | ||
141 | Folder folder = ((FolderWidgetItem *)currentItem())->folder(); | 141 | Folder folder = ((FolderWidgetItem *)currentItem())->folder(); |
142 | QString newName = Rename::rename(folder.fullName(), this); | 142 | QString newName = Rename::rename(folder.fullName(), this); |
143 | if (newName.isNull()) return; | 143 | if (newName.isNull()) return; |
144 | 144 | ||
145 | folder.topFolder().handler()->iRename(folder.fullName(), newName); | 145 | folder.topFolder().handler()->iRename(folder.fullName(), newName); |
146 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPRename(IMAPResponse &))); | 146 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPRename(IMAPResponse &))); |
147 | } else if (itemid == MENU_DELETE) { | 147 | } else if (itemid == MENU_DELETE) { |
148 | if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return; | 148 | if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return; |
149 | 149 | ||
150 | Folder folder = ((FolderWidgetItem *)currentItem())->folder(); | 150 | Folder folder = ((FolderWidgetItem *)currentItem())->folder(); |
151 | 151 | ||
152 | int ret = QMessageBox::information(this, tr("Question"), tr("<p>Do you really want to delete <pre>%1</pre>?").arg(folder.fullName()), tr("Yes"), tr("No")); | 152 | int ret = QMessageBox::information(this, tr("Question"), tr("<p>Do you really want to delete <pre>%1</pre>?").arg(folder.fullName()), tr("Yes"), tr("No")); |
153 | if (ret == 1) return; | 153 | if (ret == 1) return; |
154 | 154 | ||
155 | _createFolder = folder; | 155 | _createFolder = folder; |
156 | 156 | ||
157 | folder.topFolder().handler()->iDelete(folder.fullName()); | 157 | folder.topFolder().handler()->iDelete(folder.fullName()); |
158 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPDelete(IMAPResponse &))); | 158 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPDelete(IMAPResponse &))); |
159 | } else if (itemid == MENU_MOVE) { | 159 | } else if (itemid == MENU_MOVE) { |
160 | 160 | ||
161 | } else if (itemid == MENU_COPY) { | 161 | } else if (itemid == MENU_COPY) { |
162 | 162 | ||
163 | } else if (itemid == MENU_CREATE) { | 163 | } else if (itemid == MENU_CREATE) { |
164 | Folder folder = (((FolderWidgetItem *)currentItem())->folder()); | 164 | Folder folder = (((FolderWidgetItem *)currentItem())->folder()); |
165 | _createFolder = folder; | 165 | _createFolder = folder; |
166 | 166 | ||
167 | QString folderName = Rename::getText(tr("Foldername"), tr("<p>Please enter the name of the new folder.</p>"), this); | 167 | QString folderName = Rename::getText(tr("Foldername"), tr("<p>Please enter the name of the new folder.</p>"), this); |
168 | if (folderName.isNull()) return; | 168 | if (folderName.isNull()) return; |
169 | 169 | ||
170 | folder.topFolder().handler()->iCreate(folder.fullName() + folder.separator() + folderName); | 170 | folder.topFolder().handler()->iCreate(folder.fullName() + folder.separator() + folderName); |
171 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPCreate(IMAPResponse &))); | 171 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPCreate(IMAPResponse &))); |
172 | } else if (itemid == MENU_RESCAN) { | 172 | } else if (itemid == MENU_RESCAN) { |
173 | Folder folder = (((FolderWidgetItem *)currentItem())->folder()); | 173 | Folder folder = (((FolderWidgetItem *)currentItem())->folder()); |
174 | _rescanAccount = folder.topFolder().account(); | 174 | _rescanAccount = folder.topFolder().account(); |
175 | 175 | ||
176 | folder.topFolder().handler()->iList(".", "*"); | 176 | folder.topFolder().handler()->iList("", "*"); |
177 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &))); | 177 | connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &))); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | ||
181 | void FolderWidget::slotItemClicked(QListViewItem *item) | 181 | void FolderWidget::slotItemClicked(QListViewItem *item) |
182 | { | 182 | { |
183 | if (item == NULL) return; | 183 | if (item == NULL) return; |
184 | Folder folder = ((FolderWidgetItem *)item)->folder(); | 184 | Folder folder = ((FolderWidgetItem *)item)->folder(); |
185 | if (folder.fullName().isEmpty()) return; | 185 | if (folder.fullName().isEmpty()) return; |
186 | 186 | ||
187 | emit folderSelected(folder); | 187 | emit folderSelected(folder); |
188 | } | 188 | } |
189 | 189 | ||
190 | void FolderWidget::slotIMAPLookingUpHost() | 190 | void FolderWidget::slotIMAPLookingUpHost() |
191 | { | 191 | { |
192 | emit status(tr("Looking up host...")); | 192 | emit status(tr("Looking up host...")); |
193 | emit connecting(); | 193 | emit connecting(); |
194 | } | 194 | } |
195 | 195 | ||
196 | void FolderWidget::slotIMAPHostFound() | 196 | void FolderWidget::slotIMAPHostFound() |
197 | { | 197 | { |
198 | emit status(tr("Host found.")); | 198 | emit status(tr("Host found.")); |
199 | } | 199 | } |
200 | 200 | ||
201 | void FolderWidget::slotIMAPConnected() | 201 | void FolderWidget::slotIMAPConnected() |
202 | { | 202 | { |
203 | emit status(tr("Connected to host.")); | 203 | emit status(tr("Connected to host.")); |
204 | emit connected(); | 204 | emit connected(); |
205 | } | 205 | } |
206 | 206 | ||
207 | void FolderWidget::slotIMAPError(int error) | 207 | void FolderWidget::slotIMAPError(int error) |
208 | { | 208 | { |
209 | if (error == IMAPBase::IMAPErrConnectionRefused) { | 209 | if (error == IMAPBase::IMAPErrConnectionRefused) { |
210 | QMessageBox::warning(this, tr("Error"), tr("<p>The IMAP connection was refused.</p>"), tr("Ok")); | 210 | QMessageBox::warning(this, tr("Error"), tr("<p>The IMAP connection was refused.</p>"), tr("Ok")); |
211 | } else if (error == IMAPBase::IMAPErrHostNotFound) { | 211 | } else if (error == IMAPBase::IMAPErrHostNotFound) { |
212 | QMessageBox::warning(this, tr("Error"), tr("<p>The host was not found.</p>"), tr("Ok")); | 212 | QMessageBox::warning(this, tr("Error"), tr("<p>The host was not found.</p>"), tr("Ok")); |
213 | } else if (error == IMAPBase::IMAPErrSocketRead) { | 213 | } else if (error == IMAPBase::IMAPErrSocketRead) { |
214 | QMessageBox::warning(this, tr("Error"), tr("<p>There was an error while reading from the socket.</p>"), tr("Ok")); | 214 | QMessageBox::warning(this, tr("Error"), tr("<p>There was an error while reading from the socket.</p>"), tr("Ok")); |
215 | } else if (error == IMAPBase::IMAPErrLoginFailed) { | 215 | } else if (error == IMAPBase::IMAPErrLoginFailed) { |
216 | QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Check your password/username.</p>"), tr("Ok")); | 216 | QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Check your password/username.</p>"), tr("Ok")); |
217 | } else { | 217 | } else { |
218 | QMessageBox::warning(this, tr("Error"), tr("<p>An unknown error was encountered.</p>"), tr("Ok")); | 218 | QMessageBox::warning(this, tr("Error"), tr("<p>An unknown error was encountered.</p>"), tr("Ok")); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | void FolderWidget::slotIMAPDisconnected() | 222 | void FolderWidget::slotIMAPDisconnected() |
223 | { | 223 | { |
224 | emit status(tr("Disconnected.")); | 224 | emit status(tr("Disconnected.")); |
225 | emit disconnected(); | 225 | emit disconnected(); |
226 | } | 226 | } |
227 | 227 | ||
228 | void FolderWidget::slotIMAPLogin(IMAPResponse &response) | 228 | void FolderWidget::slotIMAPLogin(IMAPResponse &response) |
229 | { | 229 | { |
230 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPLogin(IMAPResponse &))); | 230 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPLogin(IMAPResponse &))); |
231 | 231 | ||
232 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 232 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
233 | emit status(tr("Login successfull!")); | 233 | emit status(tr("Login successfull!")); |
234 | } else { | 234 | } else { |
235 | QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Go away.</p>"), tr("Ok")); | 235 | QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Go away.</p>"), tr("Ok")); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | void FolderWidget::slotIMAPRename(IMAPResponse &response) | 239 | void FolderWidget::slotIMAPRename(IMAPResponse &response) |
240 | { | 240 | { |
241 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPRename(IMAPResponse &))); | 241 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPRename(IMAPResponse &))); |
242 | 242 | ||
243 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 243 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
244 | emit status(tr("Renaming successfull!")); | 244 | emit status(tr("Renaming successfull!")); |
245 | } else { | 245 | } else { |
246 | QMessageBox::warning(this, tr("Error"), tr("<p>Renaming failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); | 246 | QMessageBox::warning(this, tr("Error"), tr("<p>Renaming failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | void FolderWidget::slotIMAPDelete(IMAPResponse &response) | 250 | void FolderWidget::slotIMAPDelete(IMAPResponse &response) |
251 | { | 251 | { |
252 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPDelete(IMAPResponse &))); | 252 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPDelete(IMAPResponse &))); |
253 | 253 | ||
254 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 254 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
255 | emit status(tr("Deletion successfull!")); | 255 | emit status(tr("Deletion successfull!")); |
256 | 256 | ||
257 | _rescanAccount = _createFolder.topFolder().account(); | 257 | _rescanAccount = _createFolder.topFolder().account(); |
258 | 258 | ||
259 | _createFolder.topFolder().handler()->iList(".", "*"); | 259 | _createFolder.topFolder().handler()->iList(".", "*"); |
260 | connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &))); | 260 | connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &))); |
261 | } else { | 261 | } else { |
262 | QMessageBox::warning(this, tr("Error"), tr("<p>Delete failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); | 262 | QMessageBox::warning(this, tr("Error"), tr("<p>Delete failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | void FolderWidget::slotIMAPCreate(IMAPResponse &response) | 266 | void FolderWidget::slotIMAPCreate(IMAPResponse &response) |
267 | { | 267 | { |
268 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPCreate(IMAPResponse &))); | 268 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPCreate(IMAPResponse &))); |
269 | 269 | ||
270 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 270 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
271 | emit status(tr("Folder created. Rescanning...")); | 271 | emit status(tr("Folder created. Rescanning...")); |
272 | 272 | ||
273 | _rescanAccount = _createFolder.topFolder().account(); | 273 | _rescanAccount = _createFolder.topFolder().account(); |
274 | 274 | ||
275 | _createFolder.topFolder().handler()->iList(".", "*"); | 275 | _createFolder.topFolder().handler()->iList(".", "*"); |
276 | connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &))); | 276 | connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &))); |
277 | } else { | 277 | } else { |
278 | QMessageBox::warning(this, tr("Error"), tr("<p>The folder could not be created. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); | 278 | QMessageBox::warning(this, tr("Error"), tr("<p>The folder could not be created. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | void FolderWidget::slotIMAPList(IMAPResponse &response) | 282 | void FolderWidget::slotIMAPList(IMAPResponse &response) |
283 | { | 283 | { |
284 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPList(IMAPResponse &))); | 284 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPList(IMAPResponse &))); |
285 | 285 | ||
286 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 286 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
287 | QDir d((QString) getenv("HOME") + "/Applications/mail/foldercache"); | 287 | QDir d((QString) getenv("HOME") + "/Applications/mail/foldercache"); |
288 | if (!d.exists()) { | 288 | if (!d.exists()) { |
289 | system("mkdir -p $HOME/Applications/mail/foldercache"); | 289 | system("mkdir -p $HOME/Applications/mail/foldercache"); |
290 | qWarning("Created $HOME/Applications/mail/foldercache."); | 290 | qWarning("Created $HOME/Applications/mail/foldercache."); |
291 | } | 291 | } |
292 | QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + _rescanAccount.accountName()); | 292 | QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + _rescanAccount.accountName()); |
293 | if (!f.open(IO_WriteOnly)) { | 293 | if (!f.open(IO_WriteOnly)) { |
294 | QMessageBox::critical(this, tr("Error"), tr("<p>Couldn't open folder cache file for writing!</p>"), tr("Ok")); | 294 | QMessageBox::critical(this, tr("Error"), tr("<p>Couldn't open folder cache file for writing!</p>"), tr("Ok")); |
295 | return; | 295 | return; |
296 | } | 296 | } |
297 | QTextStream t(&f); | 297 | QTextStream t(&f); |
298 | 298 | ||
299 | QValueList<IMAPResponseLIST>::Iterator it; | 299 | QValueList<IMAPResponseLIST>::Iterator it; |
300 | QValueList<IMAPResponseLIST> lists = response.LIST(); | 300 | QValueList<IMAPResponseLIST> lists = response.LIST(); |
301 | for (it = lists.begin(); it != lists.end(); it++) { | 301 | for (it = lists.begin(); it != lists.end(); it++) { |
302 | t << (*it).folderSeparator() << "\n"; | 302 | t << (*it).folderSeparator() << "\n"; |
303 | t << (*it).folder() << "\n"; | 303 | t << (*it).folder() << "\n"; |
304 | } | 304 | } |
305 | 305 | ||
306 | f.close(); | 306 | f.close(); |
307 | 307 | ||
308 | emit status(tr("Got folder list.")); | 308 | emit status(tr("Got folder list.")); |
309 | getAccounts(); | 309 | getAccounts(); |
310 | } else { | 310 | } else { |
311 | QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't retrieve the folder list. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); | 311 | QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't retrieve the folder list. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); |
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||