summaryrefslogtreecommitdiff
path: root/plugins/GmailNotifier/src/check.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/GmailNotifier/src/check.cpp')
-rw-r--r--plugins/GmailNotifier/src/check.cpp132
1 files changed, 64 insertions, 68 deletions
diff --git a/plugins/GmailNotifier/src/check.cpp b/plugins/GmailNotifier/src/check.cpp
index b3821cb7cf..dafed2dcc8 100644
--- a/plugins/GmailNotifier/src/check.cpp
+++ b/plugins/GmailNotifier/src/check.cpp
@@ -9,12 +9,12 @@ void CheckMailInbox(Account *curAcc)
HINTERNET hHTTPRequest; // internet request hadle
DBVARIANT dbv;
- static char *contentType = "Content-Type: application/x-www-form-urlencoded";
- char requestBuffer[256] = "continue=https%3A%2F%2Fmail.google.com%2Fa%2F";
- char fileBuffer[_MAX_DOWN_BUFFER] = "";
- char *tail;
- char str[64];
- char temp[_MAX_DOWN_BUFFER] = "";
+ static TCHAR *contentType = _T("Content-Type: application/x-www-form-urlencoded");
+ TCHAR requestBuffer[256] = _T("continue=https%3A%2F%2Fmail.google.com%2Fa%2F");
+ TCHAR fileBuffer[_MAX_DOWN_BUFFER] = _T("");
+ TCHAR *tail;
+ TCHAR str[64];
+ TCHAR temp[_MAX_DOWN_BUFFER] = _T("");
unsigned long bufferLength;
if (curAcc->IsChecking)
@@ -22,30 +22,30 @@ void CheckMailInbox(Account *curAcc)
curAcc->IsChecking = TRUE;
- if (!db_get_s(curAcc->hContact, "CList", "MyHandle", &dbv)) {
- lstrcpyA(curAcc->results.content, dbv.pszVal);
+ if (!db_get_ts(curAcc->hContact, "CList", "MyHandle", &dbv)) {
+ lstrcpy(curAcc->results.content, dbv.ptszVal);
db_free(&dbv);
}
- else lstrcpyA(curAcc->results.content, curAcc->name);
+ else lstrcpy(curAcc->results.content, curAcc->name);
- tail = strstr(curAcc->results.content, " [");
+ tail = _tcsstr(curAcc->results.content, _T(" ["));
if (tail) *tail = '\0';
- lstrcatA(curAcc->results.content, " [");
+ lstrcat(curAcc->results.content, _T(" ["));
- lstrcpyA(str, curAcc->results.content);
- lstrcatA(str, Translate("Checking..."));
- lstrcatA(str, "]");
+ lstrcpy(str, curAcc->results.content);
+ lstrcat(str, TranslateT("Checking..."));
+ lstrcat(str, _T("]"));
- db_set_s(curAcc->hContact, "CList", "MyHandle", str);
- hHTTPOpen = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, "", "", 0);
+ db_set_ts(curAcc->hContact, "CList", "MyHandle", str);
+ hHTTPOpen = InternetOpen(_T(""), INTERNET_OPEN_TYPE_PRECONFIG, _T(""), _T(""), 0);
if (!hHTTPOpen) {
- lstrcatA(curAcc->results.content, Translate("Can't open Internet!"));
+ lstrcat(curAcc->results.content, TranslateT("Can't open Internet!"));
goto error_handle;
}
if (curAcc->hosted[0]) {
- hHTTPConnection = InternetConnectA(hHTTPOpen,
- "www.google.com",
+ hHTTPConnection = InternetConnect(hHTTPOpen,
+ _T("www.google.com"),
INTERNET_DEFAULT_HTTPS_PORT,
NULL,
NULL,
@@ -54,22 +54,22 @@ void CheckMailInbox(Account *curAcc)
0);
if (!hHTTPConnection) {
- lstrcatA(curAcc->results.content, Translate("Can't reach server!"));
+ lstrcat(curAcc->results.content, TranslateT("Can't reach server!"));
goto error_handle;
}
- lstrcpyA(str, "/a/");
- lstrcatA(str, curAcc->hosted);
- lstrcatA(str, "/LoginAction");
- hHTTPRequest = HttpOpenRequestA(hHTTPConnection, "POST", str, HTTP_VERSIONA, NULL, NULL, INTERNET_FLAG_SECURE, 0);
- lstrcatA(requestBuffer, curAcc->hosted);
- lstrcatA(requestBuffer, "%2Ffeed%2Fatom&service=mail&userName=");
- lstrcatA(requestBuffer, curAcc->name);
- tail = strchr(requestBuffer, '@');
+ lstrcpy(str, _T("/a/"));
+ lstrcat(str, curAcc->hosted);
+ lstrcat(str, _T("/LoginAction"));
+ hHTTPRequest = HttpOpenRequest(hHTTPConnection, _T("POST"), str, HTTP_VERSION, NULL, NULL, INTERNET_FLAG_SECURE, 0);
+ lstrcat(requestBuffer, curAcc->hosted);
+ lstrcat(requestBuffer, _T("%2Ffeed%2Fatom&service=mail&userName="));
+ lstrcat(requestBuffer, curAcc->name);
+ tail = _tcschr(requestBuffer, '@');
*tail = '\0';
- lstrcatA(requestBuffer, "&password=");
- lstrcatA(requestBuffer, curAcc->pass);
- if (!HttpSendRequestA(hHTTPRequest, contentType, (int)strlen(contentType) + 1, requestBuffer, (int)strlen(requestBuffer) + 1)) {
- lstrcpyA(curAcc->results.content, Translate("Can't send account data!"));
+ lstrcat(requestBuffer, _T("&password="));
+ lstrcat(requestBuffer, curAcc->pass);
+ if (!HttpSendRequest(hHTTPRequest, contentType, (int)_tcslen(contentType) + 1, requestBuffer, (int)_tcslen(requestBuffer) + 1)) {
+ lstrcpy(curAcc->results.content, TranslateT("Can't send account data!"));
goto error_handle;
}
@@ -77,42 +77,42 @@ void CheckMailInbox(Account *curAcc)
InternetCloseHandle(hHTTPRequest);
}
- hHTTPConnection = InternetConnectA(hHTTPOpen, "mail.google.com", INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ hHTTPConnection = InternetConnect(hHTTPOpen, _T("mail.google.com"), INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
if (!hHTTPConnection) {
- lstrcatA(curAcc->results.content, Translate("Can't reach server!"));
+ lstrcat(curAcc->results.content, TranslateT("Can't reach server!"));
goto error_handle;
}
if (curAcc->hosted[0]) {
- lstrcpyA(str, "/a/");
- lstrcatA(str, curAcc->hosted);
- lstrcatA(str, "/feed/atom");
+ lstrcpy(str, _T("/a/"));
+ lstrcat(str, curAcc->hosted);
+ lstrcat(str, _T("/feed/atom"));
}
- else lstrcpyA(str, "/mail/feed/atom");
+ else lstrcpy(str, _T("/mail/feed/atom"));
- hHTTPRequest = HttpOpenRequest(hHTTPConnection, _T("GET"), _A2T(str), NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD, 0);
- InternetSetOption(hHTTPRequest, INTERNET_OPTION_USERNAME, _A2T(curAcc->name), (int)strlen(curAcc->name) + 1);
- InternetSetOption(hHTTPRequest, INTERNET_OPTION_PASSWORD, _A2T(curAcc->pass), (int)strlen(curAcc->pass) + 1);
+ hHTTPRequest = HttpOpenRequest(hHTTPConnection, _T("GET"), str, NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD, 0);
+ InternetSetOption(hHTTPRequest, INTERNET_OPTION_USERNAME, curAcc->name, (int)_tcslen(curAcc->name) + 1);
+ InternetSetOption(hHTTPRequest, INTERNET_OPTION_PASSWORD, curAcc->pass, (int)_tcslen(curAcc->pass) + 1);
if (!HttpSendRequest(hHTTPRequest, NULL, 0, NULL, 0)) {
- lstrcatA(curAcc->results.content, Translate("Can't get RSS feed!"));
+ lstrcat(curAcc->results.content, TranslateT("Can't get RSS feed!"));
goto error_handle;
}
while (InternetReadFile(hHTTPRequest, temp, _MAX_DOWN_BUFFER, &bufferLength) && bufferLength > 0) {
temp[bufferLength] = '\0';
- lstrcatA(fileBuffer, temp);
+ lstrcat(fileBuffer, temp);
}
fileBuffer[_MAX_DOWN_BUFFER - 1] = '\0';
curAcc->results_num = ParsePage(fileBuffer, &curAcc->results);
if (curAcc->results_num == -1) {
- lstrcatA(curAcc->results.content, Translate("Wrong name or password!"));
+ lstrcat(curAcc->results.content, TranslateT("Wrong name or password!"));
goto error_handle;
}
InternetCloseHandle(hHTTPOpen);
InternetCloseHandle(hHTTPConnection);
InternetCloseHandle(hHTTPRequest);
- lstrcatA(curAcc->results.content, _itoa(curAcc->results_num, str, 10));
- lstrcatA(curAcc->results.content, "]");
+ lstrcat(curAcc->results.content, _itot(curAcc->results_num, str, 10));
+ lstrcat(curAcc->results.content, _T("]"));
curAcc->IsChecking = FALSE;
return;
@@ -123,14 +123,14 @@ error_handle:
InternetCloseHandle(hHTTPConnection);
InternetCloseHandle(hHTTPRequest);
- lstrcatA(curAcc->results.content, "]");
+ lstrcat(curAcc->results.content, _T("]"));
curAcc->IsChecking = FALSE;
}
void __cdecl Check_ThreadFunc(void *lpParam)
{
- InternetSetCookieA("https://mail.google.com/mail/", "GX", "");
+ InternetSetCookie(_T("https://mail.google.com/mail/"), _T("GX"), _T(""));
if (lpParam) {
CheckMailInbox((Account *)lpParam);
NotifyUser((Account *)lpParam);
@@ -143,41 +143,37 @@ void __cdecl Check_ThreadFunc(void *lpParam)
}
}
-int ParsePage(char *page, resultLink *prst)
+int ParsePage(TCHAR *page, resultLink *prst)
{
- char *str_head;
- char *str_tail;
- char name[64], title[64];
+ TCHAR *str_head, *str_tail;
+ TCHAR name[64], title[64];
int num = 0;
- wchar_t str[64];
prst->next = NULL;
- if (strstr(page, "Unauthorized"))
+ if (_tcsstr(page, _T("Unauthorized")))
return -1;
- if (!(str_head = strstr(page, "<entry>")))
+ if (!(str_head = _tcsstr(page, _T("<entry>"))))
return 0;
- while (str_head = strstr(str_head, "<title>")) {
+ while (str_head = _tcsstr(str_head, _T("<title>"))) {
prst = prst->next = (resultLink *)malloc(sizeof(resultLink));
str_head += 7;
- str_tail = strstr(str_head, "</title>");
+ str_tail = _tcsstr(str_head, _T("</title>"));
*str_tail = '\0';
- lstrcpynA(title, str_head, 41);
- if (lstrlenA(title) == 40)
- lstrcatA(title, "...");
+ lstrcpyn(title, str_head, 41);
+ if (lstrlen(title) == 40)
+ lstrcat(title, _T("..."));
*str_tail = ' ';
- str_head = strstr(str_head, "<name>") + 6;
- str_tail = strstr(str_head, "</name>");
+ str_head = _tcsstr(str_head, _T("<name>")) + 6;
+ str_tail = _tcsstr(str_head, _T("</name>"));
*str_tail = '\0';
- lstrcpynA(name, str_head, 11);
- lstrcatA(name, ": ");
+ lstrcpyn(name, str_head, 11);
+ lstrcat(name, _T(": "));
*str_tail = ' ';
- lstrcpyA(prst->content, name);
- lstrcatA(prst->content, title);
- MultiByteToWideChar(CP_UTF8, 0, prst->content, -1, str, 64);
- WideCharToMultiByte(CP_ACP, 0, str, -1, prst->content, 64, NULL, NULL);
+ lstrcpy(prst->content, name);
+ lstrcat(prst->content, title);
num++;
}
prst->next = NULL;