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

Comparing trunk/WinXPFAQPoll/IMAPHandler.h (file contents):
Revision 104 by douglas, 2003-03-31T20:18:26-08:00 vs.
Revision 116 by douglas, 2003-04-01T00:43:13-08:00

# Line 52 | Line 52
52   #ifndef _IMAPHandler_h_
53   #define _IMAPHandler_h_
54  
55 < #include "WinXPFAQPoll.h"
56 < #include <jni.h>
55 > #include <iostream>
56 > #include <string>
57 > #include <cstdlib>
58 > #include <cstdio>
59 >
60 > using namespace std;
61 >
62 > // Lovely C Sockets!
63 > #ifdef _WIN32
64 >
65 > // Windows Sockets
66 > #include <winsock2.h>
67 > #include <windows.h>
68 >
69 > #else
70 >
71 > // BSD Sockets
72 > #include <unistd.h>
73 > #include <sys/types.h>
74 > #include <sys/socket.h>
75 > #include <netinet/in.h>
76 > #include <netdb.h>
77 >
78 > #define INVALID_SOCKET -1
79 > #define SOCKET_ERROR -1
80 >
81 > typedef int SOCKET;
82 >
83 > inline int closesocket(SOCKET s) { return close(s); }
84 >
85 > #endif // _WIN32
86 >
87 > #include <openssl/ssl.h>
88 > #include <openssl/err.h>
89 > #include <openssl/rand.h>
90 >
91 > extern string program;
92 > extern bool debug;
93  
94   class IMAPHandler
95   {
96   private:
97 <        char* jarPath;
98 <        JavaVMOption options[1];
99 <        JNIEnv* env;
100 <        JavaVM* jvm;
101 <        JavaVMInitArgs vm_args;
102 <        long status;
103 <        jclass cls;
104 <        jmethodID mid;
105 <        jobject obj;
106 <        void setJarPath();
107 <        string imap(char* imap);
108 <        string imap(char* imap, const string& args);
109 <        string imap(char* imap, const string& args, const string& message);
97 > #ifdef _WIN32
98 >        WSADATA data;
99 > #endif // _WIN32
100 >        SOCKET sock;
101 >        SSL_CTX* ctx;
102 >        SSL* ssl;
103 >        bool tls;
104 >        char* buffer;
105 >        char letter;
106 >        unsigned number;
107 >        bool success;
108 >        string command();
109 >        string imap(const string& imap);
110 >        string imap(const string& imap, const string& args);
111 >        string imap(const string& imap, const string& args, const string& message);
112 >        void putline(const string line = "");
113 >        string getline();
114 >        void error(const string& prefix, bool host = false);
115 >        void error(const string& prefix, int code);
116   public:
117 <        IMAPHandler(const string& host, unsigned port);
117 >        IMAPHandler(const string& server, bool tls = false);
118          ~IMAPHandler();
119 <        string capability() { return imap("capability"); }
120 <        string noop() { return imap("noop"); }
121 <        string logout() { return imap("logout"); }
122 <        string login(const string& args) { return imap("login", args); }
123 <        string select(const string& args) { return imap("select", args); }
124 <        string examine(const string& args) { return imap("examine", args); }
125 <        string create(const string& args) { return imap("create", args); }
126 <        string delete_(const string& args) { return imap("delete", args); }
127 <        string rename(const string& args) { return imap("rename", args); }
128 <        string subscribe(const string& args) { return imap("subscribe", args); }
129 <        string unsubscribe(const string& args) { return imap("unsubscribe", args); }
130 <        string list(const string& args) { return imap("list", args); }
131 <        string lsub(const string& args) { return imap("lsub", args); }
132 <        string status_(const string& args) { return imap("status", args); }
119 >        string capability() { return imap("CAPABILITY"); }
120 >        string starttls();
121 >        string noop() { return imap("NOOP"); }
122 >        string logout() { return imap("LOGOUT"); }
123 >        string login(const string& args) { return imap("LOGIN", args); }
124 >        string select(const string& args) { return imap("SELECT", args); }
125 >        string examine(const string& args) { return imap("EXAMINE", args); }
126 >        string create(const string& args) { return imap("CREATE", args); }
127 >        string delete_(const string& args) { return imap("DELETE", args); }
128 >        string rename(const string& args) { return imap("RENAME", args); }
129 >        string subscribe(const string& args) { return imap("SUBSCRIBE", args); }
130 >        string unsubscribe(const string& args) { return imap("UNSUBSCRIBE", args); }
131 >        string list(const string& args) { return imap("LIST", args); }
132 >        string lsub(const string& args) { return imap("LSUB", args); }
133 >        string status_(const string& args) { return imap("STATUS", args); }
134          string append(const string& args, const string& message)
135          {
136 <                return imap("append", args, message);
136 >                return imap("APPEND", args, message);
137          }
138 <        string check() { return imap("check"); }
139 <        string close() { return imap("close"); }
140 <        string expunge() { return imap("expunge"); }
141 <        string search(const string& args) { return imap("search", args); }
142 <        string fetch(const string& args) { return imap("fetch", args); }
143 <        string store(const string& args) { return imap("store", args); }
144 <        string copy(const string& args) { return imap("copy", args); }
145 <        string uid(const string& args) { return imap("uid", args); }
146 <        bool successful();
138 >        string check() { return imap("CHECK"); }
139 >        string close() { return imap("CLOSE"); }
140 >        string expunge() { return imap("EXPUNGE"); }
141 >        string search(const string& args) { return imap("SEARCH", args); }
142 >        string fetch(const string& args) { return imap("FETCH", args); }
143 >        string store(const string& args) { return imap("STORE", args); }
144 >        string copy(const string& args) { return imap("COPY", args); }
145 >        string uid(const string& args) { return imap("UID", args); }
146 >        bool successful() { return success; }
147   };
148  
149   #endif // _IMAPHandler_h_

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines