ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/IMAPHandler/Tester.cpp
Revision: 115
Committed: 2003-04-01T00:03:03-08:00 (22 years, 2 months ago) by douglas
Original Path: trunk/IMAPHandler/Tester.cpp
File size: 2026 byte(s)
Log Message:
Done.

File Contents

# User Rev Content
1 douglas 108 // IMAP Handler
2     //
3     // Douglas Thrift
4     //
5     // Tester.cpp
6    
7     #include "IMAPHandler.h"
8    
9     string program;
10 douglas 115 bool debug = false;
11 douglas 108
12     int main(int argc, char* argv[])
13     {
14     program = argv[0];
15    
16 douglas 115 bool tls = false;
17 douglas 108
18 douglas 115 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 douglas 114 // tester.noop();
58 douglas 113
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 douglas 115 // tester.create("FRED");
77     // tester.rename("FRED MARTHA");
78     // tester.delete_("MARTHA");
79     // tester.status_("INBOX (MESSAGES UNSEEN)");
80     // tester.examine("INBOX");
81 douglas 113
82 douglas 115 /* string message = string("Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)\r\n")
83 douglas 114 + "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 douglas 115 + "Hello Joe, do you think we can meet at 3:30 tomorrow?\r\n";*/
90 douglas 114
91 douglas 115 // char length[4];
92     // sprintf(length, "%u", message.length());
93 douglas 114
94 douglas 115 // tester.append("INBOX {" + string(length) + "}", message);
95     // tester.select("\"Program Testing\"");
96     // tester.noop();
97 douglas 113 tester.logout();
98    
99 douglas 108 return 0;
100     }