summaryrefslogtreecommitdiff
path: root/plugins/GmailNotifier/src/notify.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/GmailNotifier/src/notify.cpp')
-rw-r--r--plugins/GmailNotifier/src/notify.cpp149
1 files changed, 75 insertions, 74 deletions
diff --git a/plugins/GmailNotifier/src/notify.cpp b/plugins/GmailNotifier/src/notify.cpp
index ee1bbc04e4..8222d5c4cf 100644
--- a/plugins/GmailNotifier/src/notify.cpp
+++ b/plugins/GmailNotifier/src/notify.cpp
@@ -1,5 +1,76 @@
#include "stdafx.h"
+static void __cdecl Login_ThreadFunc(Account *curAcc)
+{
+ if (curAcc == nullptr)
+ return;
+
+ HANDLE hTempFile;
+ DWORD dwBytesWritten, dwBufSize = 1024;
+ char szTempName[MAX_PATH];
+ char buffer[1024];
+ char *str_temp;
+ char lpPathBuffer[1024];
+
+ if (GetBrowser(lpPathBuffer)) {
+ if (opt.AutoLogin == 0) {
+ if (curAcc->hosted[0]) {
+ mir_strcat(lpPathBuffer, "https://mail.google.com/a/");
+ mir_strcat(lpPathBuffer, curAcc->hosted);
+ mir_strcat(lpPathBuffer, "/?logout");
+ }
+ else {
+ mir_strcat(lpPathBuffer, "https://mail.google.com/mail/?logout");
+ }
+ }
+ else {
+ if (curAcc->hosted[0]) {
+ GetTempPathA(dwBufSize, buffer);
+ GetTempFileNameA(buffer, "gmail", 0, szTempName);
+
+ hTempFile = CreateFileA(szTempName, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
+ mir_strcpy(buffer, FORMDATA1);
+ mir_strcat(buffer, curAcc->hosted);
+ mir_strcat(buffer, FORMDATA2);
+ mir_strcat(buffer, curAcc->hosted);
+ mir_strcat(buffer, FORMDATA3);
+ mir_strcat(buffer, "<input type=hidden name=userName value=");
+ mir_strcat(buffer, curAcc->name);
+ if ((str_temp = strstr(buffer, "@")) != nullptr)
+ *str_temp = '\0';
+ mir_strcat(buffer, "><input type=hidden name=password value=");
+ mir_strcat(buffer, curAcc->pass);
+ mir_strcat(buffer, "></form></body>");
+ WriteFile(hTempFile, buffer, (DWORD)mir_strlen(buffer), &dwBytesWritten, nullptr);
+ CloseHandle(hTempFile);
+ mir_strcat(lpPathBuffer, szTempName);
+ }
+ else {
+ char *szEncodedURL = mir_urlEncode(curAcc->name);
+ mir_strcat(lpPathBuffer, LINK);
+ mir_strcat(lpPathBuffer, szEncodedURL);
+ //mir_strcat(lpPathBuffer, "&Passwd=");
+ //mir_strcat(lpPathBuffer, mir_urlEncode(curAcc->pass));
+ if (opt.AutoLogin == 1)
+ mir_strcat(lpPathBuffer, "&PersistentCookie=yes");
+ mir_free(szEncodedURL);
+ }
+ }
+ }
+
+ STARTUPINFOA suInfo = { 0 };
+ PROCESS_INFORMATION procInfo;
+ suInfo.cb = sizeof(suInfo);
+ suInfo.wShowWindow = SW_MAXIMIZE;
+ if (CreateProcessA(nullptr, lpPathBuffer, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &suInfo, &procInfo))
+ CloseHandle(procInfo.hProcess);
+
+ if (curAcc->hosted[0]) {
+ Sleep(30000);
+ DeleteFileA(szTempName);
+ }
+}
+
int OpenBrowser(WPARAM hContact, LPARAM)
{
char *proto = GetContactProto(hContact);
@@ -16,7 +87,7 @@ int OpenBrowser(WPARAM hContact, LPARAM)
DeleteResults(curAcc->results.next);
curAcc->results.next = nullptr;
}
- mir_forkthread(Login_ThreadFunc, curAcc);
+ mir_forkThread<Account>(Login_ThreadFunc, curAcc);
}
return FALSE;
}
@@ -27,6 +98,8 @@ INT_PTR Notifying(WPARAM, LPARAM lParam)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
MCONTACT hContact = PUGetContact(hWnd);
@@ -76,7 +149,7 @@ void NotifyUser(Account *curAcc)
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.flags = DBEF_READ;
dbei.szModule = MODULE_NAME;
- dbei.timestamp = time(nullptr);
+ dbei.timestamp = time(0);
resultLink *prst = curAcc->results.next;
for (int i = 0; i < newMails; i++) {
@@ -135,75 +208,3 @@ void DeleteResults(resultLink *prst)
free(prst);
}
}
-
-void __cdecl Login_ThreadFunc(void *lpParam)
-{
- if (lpParam == nullptr)
- return;
-
- HANDLE hTempFile;
- DWORD dwBytesWritten, dwBufSize = 1024;
- char szTempName[MAX_PATH];
- char buffer[1024];
- char *str_temp;
- char lpPathBuffer[1024];
- Account *curAcc = (Account *)lpParam;
-
- if (GetBrowser(lpPathBuffer)) {
- if (opt.AutoLogin == 0) {
- if (curAcc->hosted[0]) {
- mir_strcat(lpPathBuffer, "https://mail.google.com/a/");
- mir_strcat(lpPathBuffer, curAcc->hosted);
- mir_strcat(lpPathBuffer, "/?logout");
- }
- else {
- mir_strcat(lpPathBuffer, "https://mail.google.com/mail/?logout");
- }
- }
- else {
- if (curAcc->hosted[0]) {
- GetTempPathA(dwBufSize, buffer);
- GetTempFileNameA(buffer, "gmail", 0, szTempName);
-
- hTempFile = CreateFileA(szTempName, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
- mir_strcpy(buffer, FORMDATA1);
- mir_strcat(buffer, curAcc->hosted);
- mir_strcat(buffer, FORMDATA2);
- mir_strcat(buffer, curAcc->hosted);
- mir_strcat(buffer, FORMDATA3);
- mir_strcat(buffer, "<input type=hidden name=userName value=");
- mir_strcat(buffer, curAcc->name);
- if ((str_temp = strstr(buffer, "@")) != nullptr)
- *str_temp = '\0';
- mir_strcat(buffer, "><input type=hidden name=password value=");
- mir_strcat(buffer, curAcc->pass);
- mir_strcat(buffer, "></form></body>");
- WriteFile(hTempFile, buffer, (DWORD)mir_strlen(buffer), &dwBytesWritten, nullptr);
- CloseHandle(hTempFile);
- mir_strcat(lpPathBuffer, szTempName);
- }
- else {
- char *szEncodedURL = mir_urlEncode(curAcc->name);
- mir_strcat(lpPathBuffer, LINK);
- mir_strcat(lpPathBuffer, szEncodedURL);
- //mir_strcat(lpPathBuffer, "&Passwd=");
- //mir_strcat(lpPathBuffer, mir_urlEncode(curAcc->pass));
- if (opt.AutoLogin == 1)
- mir_strcat(lpPathBuffer, "&PersistentCookie=yes");
- mir_free(szEncodedURL);
- }
- }
- }
-
- STARTUPINFOA suInfo = { 0 };
- PROCESS_INFORMATION procInfo;
- suInfo.cb = sizeof(suInfo);
- suInfo.wShowWindow = SW_MAXIMIZE;
- if (CreateProcessA(nullptr, lpPathBuffer, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &suInfo, &procInfo))
- CloseHandle(procInfo.hProcess);
-
- if (curAcc->hosted[0]) {
- Sleep(30000);
- DeleteFileA(szTempName);
- }
-}