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

Comparing trunk/IMAPHandler/Tester.cpp (file contents):
Revision 112 by douglas, 2003-03-31T21:08:59-08:00 vs.
Revision 115 by douglas, 2003-04-01T00:03:03-08:00

# Line 7 | Line 7
7   #include "IMAPHandler.h"
8  
9   string program;
10 < bool debug = true;
10 > bool debug = false;
11  
12   int main(int argc, char* argv[])
13   {
14          program = argv[0];
15  
16 <        IMAPHandler tester("imap.myrealbox.com", true);
16 >        bool tls = false;
17 >
18 >        for (unsigned index = 1; index < argc; index++)
19 >        {
20 >                string arg = argv[index];
21 >
22 >                if (arg == "-D")
23 >                {
24 >                        debug = true;
25 >                }
26 >                else if (arg == "-tls")
27 >                {
28 >                        tls = true;
29 >                }
30 >        }
31 >
32 >        IMAPHandler tester("imap.myrealbox.com", tls);
33 >
34 >        string abilities = tester.capability();
35 >
36 >        if (abilities.find(" LOGINDISABLED") != string::npos)
37 >        {
38 >                if (abilities.find(" STARTTLS") != string::npos)
39 >                {
40 >                        tester.starttls();
41 >
42 >                        if (!tester.successful())
43 >                        {
44 >                                cerr << program << ": Starting TLS didn't work.\n";
45 >                                return 1;
46 >                        }
47 >
48 >                        tester.capability();
49 >                }
50 >                else
51 >                {
52 >                        cerr << program << ": Login disabled and TLS not available.\n";
53 >                        return 1;
54 >                }
55 >        }
56 >
57 > //      tester.noop();
58 >
59 >        char* login = new char[32 + 1];
60 >        char* password = new char[32 + 1];
61 >
62 >        cout << "login: " << flush;
63 >        cin.getline(login, 32);
64 >        cout << "password: " << flush;
65 >        cin.getline(password, 32);
66 >
67 >        tester.login(string(login) + ' ' + password);
68 >
69 >        memset(login, 0, strlen(login));
70 >        memset(password, 0, strlen(password));
71 >
72 >        delete [] login;
73 >        delete [] password;
74 >
75 >        cout << tester.list("\"\" *");
76 > //      tester.create("FRED");
77 > //      tester.rename("FRED MARTHA");
78 > //      tester.delete_("MARTHA");
79 > //      tester.status_("INBOX (MESSAGES UNSEEN)");
80 > //      tester.examine("INBOX");
81 >
82 > /*      string message = string("Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)\r\n")
83 >                + "From: Fred Foobar <foobar@Blurdybloop.COM>\r\n"
84 >                + "Subject: afternoon meeting\r\n"
85 >                + "To: mooch@owatagu.siam.edu\r\n"
86 >                + "Message-Id: <B27397-0100000@Blurdybloop.COM>\r\n"
87 >                + "MIME-Version: 1.0\r\n"
88 >                + "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII\r\n\r\n"
89 >                + "Hello Joe, do you think we can meet at 3:30 tomorrow?\r\n";*/
90 >
91 > //      char length[4];
92 > //      sprintf(length, "%u", message.length());
93 >
94 > //      tester.append("INBOX {" + string(length) + "}", message);
95 > //      tester.select("\"Program Testing\"");
96 > //      tester.noop();
97 >        tester.logout();
98  
99          return 0;
100   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines