ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/IMAPHandler/Tester.cpp
Revision: 368
Committed: 2008-08-23T02:44:00-07:00 (14 years, 1 month ago) by douglas
File size: 2005 byte(s)
Log Message:
Rearranged everything else.

File Contents

# Content
1 // IMAP Handler
2 //
3 // Douglas Thrift
4 //
5 // Tester.cpp
6
7 #include "IMAPHandler.h"
8
9 string program;
10 bool debug = false;
11
12 int main(int argc, char* argv[])
13 {
14 program = argv[0];
15
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)\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 + "MIME-Version: 1.0\n"
88 + "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII\n\n"
89 + "Hello Joe, do you think we can meet at 3:30 tomorrow?\n";
90
91 char length[4];
92 sprintf(length, "%u", message.length() + 8);
93
94 tester.append("Test {" + string(length) + "}", message);*/
95 // tester.select("\"Program Testing\"");
96 // tester.noop();
97 tester.logout();
98
99 return 0;
100 }