ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/WinXPFAQPoll/Poller.cpp
(Generate patch)

Comparing trunk/WinXPFAQPoll/Poller.cpp (file contents):
Revision 128 by douglas, 2003-04-03T20:59:00-08:00 vs.
Revision 230 by douglas, 2003-08-05T19:01:05-07:00

# Line 27 | Line 27 | Poller::~Poller()
27          }
28   }
29  
30 < void Poller::poll(bool nodelete, const string& file)
30 > void Poller::poll(bool nodelete, const string& file, bool approve)
31   {
32          this->nodelete = nodelete;
33          this->file = file;
34  
35          load();
36  
37 <        ballots();
38 <        approvals();
37 >        session->select('\"' + account.getMailbox() + '\"');
38 >
39 >        if (!approve)
40 >        {
41 >                ballots();
42 >        }
43 >        else
44 >        {
45 >                approvals();
46 >        }
47  
48          save();
49   }
# Line 108 | Line 116 | void Poller::load()
116                          fin.get();
117                  }
118  
119 <                fin.peek();
119 >                if (fin.peek() == EOF) fin.get();
120  
121                  switch (type)
122                  {
# Line 250 | Line 258 | void Poller::save()
258  
259   void Poller::ballots()
260   {
253        session->select('\"' + account.getMailbox() + '\"');
254
261          stringstream search;
262          search << session->search(string("ALL HEADER X-Mailer \"WinXPFAQPoll 1.0 ")
263                  + "(Perl)\" SUBJECT \"Windows XP FAQ | Poll Ballot\" FROM \"Windows XP"
264                  + " FAQ | Poll\"");
265  
266          search.ignore(9);
267 <        search.peek();
267 >
268 >        while (!isdigit(search.peek()) && search.good())
269 >        {
270 >                search.get();
271 >        }
272  
273          while (search.good())
274          {
# Line 269 | Line 279 | void Poller::ballots()
279                  messages.push(message);
280  
281                  search.get();
282 <                search.peek();
282 >
283 >                while (!isdigit(search.peek()) && search.good())
284 >                {
285 >                        search.get();
286 >                }
287          }
288  
289          if (!messages.empty())
# Line 303 | Line 317 | void Poller::ballot(unsigned message)
317          number << message;
318  
319          stringstream buffer;
320 +        string junk;
321  
322          buffer << session->fetch(number.str() + " BODY.PEEK[2]");
323  
324 +        if (session->successful() && buffer.str() == "* " + number.str() + " FETCH"
325 +                + " (BODY[2] \"\")\n")
326 +        {
327 +                do
328 +                {
329 +                        getline(buffer, junk);
330 +                }
331 +                while (buffer.good());
332 +
333 +                buffer.clear();
334 +
335 +                buffer << session->fetch(number.str() + " BODY.PEEK[TEXT]");
336 +
337 +                for (unsigned index = 0; index < 25; index++)
338 +                {
339 +                        getline(buffer, junk);
340 +                }
341 +        }
342 +
343          if (session->successful() && session->fetch(number.str() + " FLAGS").find(
344                  "\\Deleted") == string::npos)
345          {
346 <                buffer.ignore(string::npos, '\n');
346 >                getline(buffer, junk);
347  
348                  bool approved = session->fetch(number.str() + " FLAGS").find("\\Flagge"
349                          + string("d")) != string::npos;
# Line 500 | Line 534 | void Poller::submit(const string& type,
534  
535   void Poller::approvals()
536   {
503        unsigned index;
504
537          session->check();
538  
539 +        unsigned index;
540 +
541          for (index = find.approve.size(); index > 0; index--)
542          {
543                  cout << "Checking find: " << index << "..." << flush;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines