26 |
|
|
27 |
|
load(); |
28 |
|
|
29 |
< |
// |
29 |
> |
ballots(); |
30 |
> |
approvals(); |
31 |
|
|
32 |
< |
// save(); |
32 |
> |
save(); |
33 |
|
} |
34 |
|
|
35 |
|
void Poller::load() |
236 |
|
|
237 |
|
fout.close(); |
238 |
|
} |
239 |
+ |
|
240 |
+ |
void Poller::ballots() |
241 |
+ |
{ |
242 |
+ |
session->select('\"' + account.getMailbox() + '\"'); |
243 |
+ |
|
244 |
+ |
stringstream search; |
245 |
+ |
search << session->search(string("ALL HEADER X-Mailer \"WinXPFAQPoll 1.0 ") |
246 |
+ |
+ "(Perl)\" SUBJECT \"Windows XP FAQ | Poll Ballot\" UNDELETED FROM \"" |
247 |
+ |
+ "Windows XP FAQ | Poll\" HEADER \"X-WinXPFAQPoll-Post-Host\" * HEADE" |
248 |
+ |
+ "R \"X-WinXPFAQPoll-Post-Agent\" *"); |
249 |
+ |
|
250 |
+ |
string junk; |
251 |
+ |
|
252 |
+ |
getline(search, junk, ' '); |
253 |
+ |
getline(search, junk, ' '); |
254 |
+ |
|
255 |
+ |
while (search.good()) |
256 |
+ |
{ |
257 |
+ |
unsigned message; |
258 |
+ |
search >> message; |
259 |
+ |
search.get(); |
260 |
+ |
|
261 |
+ |
if (debug) cerr << "message = " << message << "\n"; |
262 |
+ |
messages.push(message); |
263 |
+ |
} |
264 |
+ |
|
265 |
+ |
if (!messages.empty()) |
266 |
+ |
{ |
267 |
+ |
unsigned message = messages.front(); |
268 |
+ |
messages.pop(); |
269 |
+ |
|
270 |
+ |
ballot(message); |
271 |
+ |
} |
272 |
+ |
|
273 |
+ |
if (!nodelete) |
274 |
+ |
{ |
275 |
+ |
session->expunge(); |
276 |
+ |
} |
277 |
+ |
} |
278 |
+ |
|
279 |
+ |
void Poller::ballot(unsigned message) |
280 |
+ |
{ |
281 |
+ |
cout << "Checking message: " << message << "..." << flush; |
282 |
+ |
|
283 |
+ |
char number[32 + 1]; |
284 |
+ |
sprintf(number, "%u", message); |
285 |
+ |
|
286 |
+ |
stringstream buffer; |
287 |
+ |
|
288 |
+ |
buffer << session->fetch(string(number) + " BODY.PEEK[2]"); |
289 |
+ |
|
290 |
+ |
if (session->successful()) |
291 |
+ |
{ |
292 |
+ |
bool approved = session->fetch(string(number) + " FLAGS").find("\\Flag" |
293 |
+ |
+ string("ged")) != string::npos; |
294 |
+ |
|
295 |
+ |
do |
296 |
+ |
{ |
297 |
+ |
enum { FIND, HELP, IMPROVE } type; |
298 |
+ |
string vote; |
299 |
+ |
|
300 |
+ |
getline(buffer, vote); |
301 |
+ |
if (debug) cerr << "vote = " << vote << "\n"; |
302 |
+ |
|
303 |
+ |
if (vote == "_find_") |
304 |
+ |
{ |
305 |
+ |
type = FIND; |
306 |
+ |
continue; |
307 |
+ |
} |
308 |
+ |
else if (vote == "_help_") |
309 |
+ |
{ |
310 |
+ |
type = HELP; |
311 |
+ |
continue; |
312 |
+ |
} |
313 |
+ |
else if (vote == "_improve_") |
314 |
+ |
{ |
315 |
+ |
type = IMPROVE; |
316 |
+ |
continue; |
317 |
+ |
} |
318 |
+ |
|
319 |
+ |
switch (type) |
320 |
+ |
{ |
321 |
+ |
case FIND: |
322 |
+ |
if (vote == "reply") |
323 |
+ |
{ |
324 |
+ |
find.reply++; |
325 |
+ |
} |
326 |
+ |
else if (vote == "news") |
327 |
+ |
{ |
328 |
+ |
find.news++; |
329 |
+ |
} |
330 |
+ |
else if (vote == "sig") |
331 |
+ |
{ |
332 |
+ |
find.sig++; |
333 |
+ |
} |
334 |
+ |
else if (vote == "search") |
335 |
+ |
{ |
336 |
+ |
find.search++; |
337 |
+ |
} |
338 |
+ |
else if (vote == "link") |
339 |
+ |
{ |
340 |
+ |
find.link++; |
341 |
+ |
} |
342 |
+ |
else if (vote == "browse") |
343 |
+ |
{ |
344 |
+ |
find.browse++; |
345 |
+ |
} |
346 |
+ |
else if (vote == "other") |
347 |
+ |
{ |
348 |
+ |
find.other++; |
349 |
+ |
|
350 |
+ |
// |
351 |
+ |
} |
352 |
+ |
break; |
353 |
+ |
case HELP: |
354 |
+ |
if (vote == "solved") |
355 |
+ |
{ |
356 |
+ |
help.solved++; |
357 |
+ |
} |
358 |
+ |
else if (vote == "note") |
359 |
+ |
{ |
360 |
+ |
help.note++; |
361 |
+ |
} |
362 |
+ |
else if (vote == "link") |
363 |
+ |
{ |
364 |
+ |
help.link++; |
365 |
+ |
} |
366 |
+ |
else if (vote == "news") |
367 |
+ |
{ |
368 |
+ |
help.news++; |
369 |
+ |
} |
370 |
+ |
else if (vote == "lazy") |
371 |
+ |
{ |
372 |
+ |
help.lazy++; |
373 |
+ |
} |
374 |
+ |
break; |
375 |
+ |
case IMPROVE: |
376 |
+ |
if (vote == "nothing") |
377 |
+ |
{ |
378 |
+ |
improve.nothing++; |
379 |
+ |
} |
380 |
+ |
else if (vote == "links") |
381 |
+ |
{ |
382 |
+ |
improve.links++; |
383 |
+ |
} |
384 |
+ |
else if (vote == "suggest") |
385 |
+ |
{ |
386 |
+ |
improve.suggest++; |
387 |
+ |
|
388 |
+ |
// |
389 |
+ |
} |
390 |
+ |
break; |
391 |
+ |
} |
392 |
+ |
} |
393 |
+ |
while (buffer.good()); |
394 |
+ |
|
395 |
+ |
cout << "done.\n"; |
396 |
+ |
} |
397 |
+ |
else |
398 |
+ |
{ |
399 |
+ |
cout << "cancelled.\n"; |
400 |
+ |
} |
401 |
+ |
|
402 |
+ |
if (!messages.empty()) |
403 |
+ |
{ |
404 |
+ |
unsigned message = messages.front(); |
405 |
+ |
messages.pop(); |
406 |
+ |
|
407 |
+ |
ballot(message); |
408 |
+ |
} |
409 |
+ |
} |
410 |
+ |
|
411 |
+ |
void Poller::approvals() |
412 |
+ |
{ |
413 |
+ |
// |
414 |
+ |
|
415 |
+ |
if (!nodelete) |
416 |
+ |
{ |
417 |
+ |
session->expunge(); |
418 |
+ |
} |
419 |
+ |
} |