summaryrefslogtreecommitdiff
path: root/protocols/AimOscar/src/connection.cpp
diff options
context:
space:
mode:
authorAlexander Gluzsky <sss123next@list.ru>2016-04-03 17:11:21 +0000
committerAlexander Gluzsky <sss123next@list.ru>2016-04-03 17:11:21 +0000
commitc3d5068e1d3f07a0959aaa366fee11a552245c1a (patch)
tree0aa956a0a8cb69a1b6c6e1b17220043ab92a8f93 /protocols/AimOscar/src/connection.cpp
parentb2ca0aa7399c74e8ee11f7dcc0404a1407272477 (diff)
aim protocol:
started "clienlogin" implementation skeleton is somehow done, just actual work implementation left to be done) git-svn-id: http://svn.miranda-ng.org/main/trunk@16581 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/AimOscar/src/connection.cpp')
-rwxr-xr-x[-rw-r--r--]protocols/AimOscar/src/connection.cpp101
1 files changed, 101 insertions, 0 deletions
diff --git a/protocols/AimOscar/src/connection.cpp b/protocols/AimOscar/src/connection.cpp
index 0a09c6d86c..ed0ae25292 100644..100755
--- a/protocols/AimOscar/src/connection.cpp
+++ b/protocols/AimOscar/src/connection.cpp
@@ -140,6 +140,107 @@ void CAimProto::aim_connection_authorization(void)
debugLogA("Connection Authorization Thread Ending: End of Thread");
}
+void fill_post_request(char *buf)
+{
+ //TODO: fill post data
+ /*
+ devId=dev_key&f=xml&pwd=urlencoded_password&s=urlencoded_screenname
+ */
+ //mir_urlEncode()
+}
+
+bool parse_clientlogin_response(char *buf, size_t len, char *token, char *secret, time_t &hosttime)
+{
+ //TODO: validate response
+ //TODO: return false on errors
+ //TODO: extract token, secret, hosttime from response
+ return true;
+}
+
+void fill_login_url(char *buf, char *token, char *secret, time_t &hosttime)
+{
+ //TODO: construct url for get request
+ /*
+ a=urlencoded_token&distId=0x00000611&f=xml&k=dev_key&ts=hosttime&useTLS=bool_encryption
+ */
+
+}
+
+bool parse_start_socar_session_response(char *response, size_t response_len, char *bos_host, unsigned short bos_port, char *cookie, char *tls_cert_name)
+{
+ //TODO: extract bos_host, bos_port, cookie, tls_cert_name
+ return true;
+}
+
+void CAimProto::aim_connection_clientlogin(void)
+{
+ NETLIBHTTPREQUEST req = {0};
+ req.cbSize = sizeof(req);
+ req.flags = NLHRF_SSL;
+ req.requestType = REQUEST_POST;
+ req.szUrl = AIM_LOGIN_URL;
+ char buf[1024];
+ fill_post_request(buf);
+ req.pData = buf;
+ req.dataLength = (int)strlen(buf);
+
+ NETLIBHTTPREQUEST *resp = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ if(!resp)
+ {
+ //TODO: handle error
+ return;
+ }
+ if(!resp->dataLength)
+ {
+ //TODO: handle error
+ return;
+ }
+ char token[512], secret[512]; //TODO: find efficient buf size
+ time_t hosttime;
+ if(!parse_clientlogin_response(resp->pData, resp->dataLength, token, secret, hosttime))
+ {
+ //TODO: handle error
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, (WPARAM)0, (LPARAM)&resp);
+ return;
+ }
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, (WPARAM)0, (LPARAM)&resp);
+ //reuse NETLIBHTTPREQUEST
+ req.requestType = REQUEST_GET;
+ req.pData = NULL;
+ req.dataLength = 0;
+ char url[1024];
+ fill_login_url(url, token, secret, hosttime);
+ req.szUrl = url;
+ resp = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ if(!resp)
+ {
+ //TODO: handle error
+ return;
+ }
+ if(!resp->dataLength)
+ {
+ //TODO: handle error
+ return;
+ }
+ char bos_host[128], cookie[1024], tls_cert_name[128]; //TODO: find efficient buf size
+ unsigned short bos_port = 0;
+ if(!parse_start_socar_session_response(resp->pData, resp->dataLength, bos_host, bos_port, cookie, tls_cert_name))
+ {
+ //TODO: handle error
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, (WPARAM)0, (LPARAM)&resp);
+ return;
+ }
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, (WPARAM)0, (LPARAM)&resp);
+
+ mir_free(COOKIE);
+ COOKIE = mir_strdup(cookie); //TODO: check if it's null terminated
+ COOKIE_LENGTH = (int)mir_strlen(cookie);
+
+ //TODO: connect to bos server
+
+
+}
+
void __cdecl CAimProto::aim_protocol_negotiation(void*)
{
HANDLE hServerPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)m_hServerConn, 2048 * 8);