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 |
122 |
/* string message = string("Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)\n") |
83 |
|
|
+ "From: Fred Foobar <foobar@Blurdybloop.COM>\n" |
84 |
|
|
+ "Subject: afternoon meeting\n" |
85 |
|
|
+ "To: mooch@owatagu.siam.edu\n" |
86 |
|
|
+ "Message-Id: <B27397-0100000@Blurdybloop.COM>\n" |
87 |
douglas |
114 |
+ "MIME-Version: 1.0\r\n" |
88 |
douglas |
122 |
+ "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII\n\n" |
89 |
|
|
+ "Hello Joe, do you think we can meet at 3:30 tomorrow?\n"; |
90 |
douglas |
114 |
|
91 |
douglas |
122 |
char length[4]; |
92 |
|
|
sprintf(length, "%u", message.length()); |
93 |
douglas |
114 |
|
94 |
douglas |
122 |
tester.append("Test {" + string(length) + "}", message);*/ |
95 |
douglas |
115 |
// tester.select("\"Program Testing\""); |
96 |
|
|
// tester.noop(); |
97 |
douglas |
113 |
tester.logout(); |
98 |
|
|
|
99 |
douglas |
108 |
return 0; |
100 |
|
|
} |