summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-25 09:06:37 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-25 09:06:37 +0000
commit8aa669fbc78ce229f45105df09ac25a2df8b8eff (patch)
tree14ea6da3b83456da5f0c421d3b7691415b68093f
parenta881be4206c532a8d7dd1d65fbeed1e1a89e84d2 (diff)
Google contact removed from clist
git-svn-id: http://svn.miranda-ng.org/main/trunk@4185 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/GTalkExt/GTalkExt_10.vcxproj1
-rw-r--r--protocols/GTalkExt/GTalkExt_10.vcxproj.filters3
-rw-r--r--protocols/GTalkExt/GTalkExt_11.vcxproj1
-rw-r--r--protocols/GTalkExt/GTalkExt_11.vcxproj.filters3
-rw-r--r--protocols/GTalkExt/res/settings.rc3
-rw-r--r--protocols/GTalkExt/src/GTalkExt.cpp7
-rw-r--r--protocols/GTalkExt/src/avatar.cpp212
-rw-r--r--protocols/GTalkExt/src/avatar.h25
-rw-r--r--protocols/GTalkExt/src/db.cpp75
-rw-r--r--protocols/GTalkExt/src/db.h2
-rw-r--r--protocols/GTalkExt/src/handlers.cpp11
-rw-r--r--protocols/GTalkExt/src/inbox.cpp43
-rw-r--r--protocols/GTalkExt/src/menu.cpp59
-rw-r--r--protocols/GTalkExt/src/menu.h24
-rw-r--r--protocols/GTalkExt/src/notifications.cpp123
-rw-r--r--protocols/GTalkExt/src/notifications.h1
-rw-r--r--protocols/GTalkExt/src/options.cpp25
-rw-r--r--protocols/GTalkExt/src/options.h2
-rw-r--r--protocols/GTalkExt/src/resources.h3
19 files changed, 44 insertions, 579 deletions
diff --git a/protocols/GTalkExt/GTalkExt_10.vcxproj b/protocols/GTalkExt/GTalkExt_10.vcxproj
index 0972d8f3e7..e7257201e3 100644
--- a/protocols/GTalkExt/GTalkExt_10.vcxproj
+++ b/protocols/GTalkExt/GTalkExt_10.vcxproj
@@ -177,7 +177,6 @@
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="src\avatar.cpp" />
<ClCompile Include="src\db.cpp" />
<ClCompile Include="src\dllmain.cpp" />
<ClCompile Include="src\GTalkExt.cpp" />
diff --git a/protocols/GTalkExt/GTalkExt_10.vcxproj.filters b/protocols/GTalkExt/GTalkExt_10.vcxproj.filters
index c4669a5f90..3bcde2ac93 100644
--- a/protocols/GTalkExt/GTalkExt_10.vcxproj.filters
+++ b/protocols/GTalkExt/GTalkExt_10.vcxproj.filters
@@ -15,9 +15,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="src\avatar.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\db.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/protocols/GTalkExt/GTalkExt_11.vcxproj b/protocols/GTalkExt/GTalkExt_11.vcxproj
index 935e6d1b69..66833e07ca 100644
--- a/protocols/GTalkExt/GTalkExt_11.vcxproj
+++ b/protocols/GTalkExt/GTalkExt_11.vcxproj
@@ -181,7 +181,6 @@
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="src\avatar.cpp" />
<ClCompile Include="src\db.cpp" />
<ClCompile Include="src\dllmain.cpp" />
<ClCompile Include="src\GTalkExt.cpp" />
diff --git a/protocols/GTalkExt/GTalkExt_11.vcxproj.filters b/protocols/GTalkExt/GTalkExt_11.vcxproj.filters
index c4669a5f90..3bcde2ac93 100644
--- a/protocols/GTalkExt/GTalkExt_11.vcxproj.filters
+++ b/protocols/GTalkExt/GTalkExt_11.vcxproj.filters
@@ -15,9 +15,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="src\avatar.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\db.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/protocols/GTalkExt/res/settings.rc b/protocols/GTalkExt/res/settings.rc
index 0e7dbee2a6..94d7e356d2 100644
--- a/protocols/GTalkExt/res/settings.rc
+++ b/protocols/GTalkExt/res/settings.rc
@@ -11,9 +11,6 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1
CONTROL "Popup notifications (needs popup plugin)", IDC_POPUPSENABLED, BUTTON, BS_AUTOCHECKBOX | WS_TABSTOP, 3, 36, 271, 14
CONTROL "Notify in fullscreen mode too", IDC_POPUPSINFULLSCREEN, BUTTON, BS_AUTOCHECKBOX | WS_TABSTOP, 17, 51, 254, 15
CONTROL "Use this if your popup plugin does not correctly detect fullscreen mode. It will take away your keyboard focus", IDC_POPUPSINFULLSCREENLABEL, STATIC, SS_LEFT, 30, 65, 270, 22
- CONTROL "Notify in contact list", IDC_PSEUDOCONTACTENABLED, BUTTON, BS_AUTOCHECKBOX | WS_TABSTOP, 3, 83, 271, 14
- CONTROL "Clear pseudocontact history before adding new events", IDC_CLEARPSEUDOCONTACTLOG, BUTTON, BS_AUTOCHECKBOX | WS_TABSTOP, 17, 97, 254, 15
- CONTROL "Mark history event read when popup closed", IDC_MARKEVENTREAD, BUTTON, BS_AUTOCHECKBOX | WS_TABSTOP, 3, 128, 300, 15
CONTROL "Add message snip to notification", IDC_ADDSNIP, BUTTON, BS_AUTOCHECKBOX | WS_TABSTOP, 3, 146, 300, 15
CONTROL "Try to login before open mailbox", IDC_AUTHONMAILBOX, BUTTON, BS_AUTOCHECKBOX | WS_TABSTOP, 3, 164, 300, 15
CONTROL "This works only if password is saved in the database. Has no effect on links in pseudocontact message log", IDC_AUTHONMAILBOXLABEL, STATIC, SS_LEFT, 15, 178, 280, 26
diff --git a/protocols/GTalkExt/src/GTalkExt.cpp b/protocols/GTalkExt/src/GTalkExt.cpp
index e2eeb754ee..845c990d71 100644
--- a/protocols/GTalkExt/src/GTalkExt.cpp
+++ b/protocols/GTalkExt/src/GTalkExt.cpp
@@ -26,8 +26,6 @@
#include "notifications.h"
#include "handlers.h"
#include "tipper_items.h"
-#include "avatar.h"
-#include "menu.h"
#include "Version.h"
int hLangpack;
@@ -88,9 +86,6 @@ extern "C" int __declspec(dllexport) Load(void)
g_hPopupIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_POPUP));
- InitAvaUnit(TRUE);
- InitMenus(TRUE);
-
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
HookEvent(ME_PROTO_ACCLISTCHANGED, AccListChanged);
@@ -102,7 +97,5 @@ extern "C" int __declspec(dllexport) Load(void)
extern "C" int __declspec(dllexport) Unload(void)
{
- InitMenus(FALSE);
- InitAvaUnit(FALSE);
return 0;
}
diff --git a/protocols/GTalkExt/src/avatar.cpp b/protocols/GTalkExt/src/avatar.cpp
deleted file mode 100644
index 42bf059dae..0000000000
--- a/protocols/GTalkExt/src/avatar.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-//***************************************************************************************
-//
-// Google Extension plugin for the Miranda IM's Jabber protocol
-// Copyright (c) 2011 bems@jabber.org, George Hazan (ghazan@jabber.ru)
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
-//***************************************************************************************
-
-#include "stdafx.h"
-#include "avatar.h"
-#include "resources.h"
-#include "options.h"
-
-static const LPSTR AVA_FILE_NAME_FORMAT = "%s\\%s\\AvatarCache\\Jabber\\" SHORT_PLUGIN_NAME ".pseudoava.png";
-static const LPTSTR AVA_RES_TYPE = _T("PNG");
-static const LPSTR SRMM_MODULE_NAME = "SRMM";
-static const LPSTR SRMM_AVATAR_SETTING_NAME = "Avatar";
-
-static const int SET_AVATAR_INTERVAL = 2000;
-
-void ForceDir(LPSTR dir, int len)
-{
- if (GetFileAttributesA(dir) != INVALID_FILE_ATTRIBUTES) return;
- for (int i = len - 1; i >= 0; i--)
- if ('\\' == dir[i]) {
- dir[i] = 0;
- __try {
- ForceDir(dir, i);
- }
- __finally {
- dir[i] = '\\';
- }
- CreateDirectoryA(dir, NULL);
- }
-}
-
-void ForceFileDir(LPSTR file)
-{
- for (int i = lstrlenA(file) - 1; i >= 0; i--)
- if ('\\' == file[i]) {
- file[i] = 0;
- __try {
- ForceDir(file, i);
- }
- __finally {
- file[i] = '\\';
- }
- break;
- }
-}
-
-LPSTR CreateAvaFile(HANDLE *hFile)
-{
- char name[MAX_PATH + 2];
- char path[MAX_PATH + 2];
- char full[MAX_PATH + 2];
-
- if (CallService(MS_DB_GETPROFILENAME, (WPARAM)sizeof(name), (LPARAM)&name))
- return NULL;
- for (int i = lstrlenA(name); i >= 0; i--)
- if ('.' == name[i]) {
- name[i] = 0;
- break;
- }
-
- if (CallService(MS_DB_GETPROFILEPATH, (WPARAM)sizeof(path), (LPARAM)&path))
- return NULL;
- sprintf(&full[0], AVA_FILE_NAME_FORMAT, path, name);
-
- ForceFileDir(&full[0]);
-
- HANDLE h = 0;
- __try {
- h = CreateFileA(&full[0], GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
- if (INVALID_HANDLE_VALUE == h) return NULL;
-
- if (hFile) *hFile = h; else CloseHandle(h);
- h = 0;
- return _strdup(&full[0]);
- }
- __finally {
- CloseHandle(h);
- }
-}
-
-extern HINSTANCE g_hInst;
-
-BOOL SaveAvatar(HANDLE hFile)
-{
- HRSRC hres = FindResource(g_hInst, MAKEINTRESOURCE(IDI_PSEUDOAVA), AVA_RES_TYPE);
- if (!hres) return FALSE;
-
- HGLOBAL hglob = LoadResource(g_hInst, hres);
- if (!hglob) return FALSE;
-
- PVOID p = LockResource(hglob);
- if (!p) return FALSE;
-
- DWORD l = SizeofResource(g_hInst, hres);
- if (!l) return FALSE;
-
- DWORD written;
- if (!WriteFile(hFile, p, l, &written, NULL)) return FALSE;
- return written == l;
-}
-
-struct AVACHANGED {
- HANDLE hTimer;
- HANDLE hContact;
-};
-
-VOID CALLBACK CallSetAvatar(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
-{
- Thread_Push(0);
- __try {
- AVACHANGED *ach = (AVACHANGED*)lpParameter;
- __try {
- SetAvatar(ach->hContact);
- DeleteTimerQueueTimer(NULL, ach->hTimer, NULL);
- }
- __finally {
- free(ach);
- }
- }
- __finally {
- Thread_Pop();
- }
-}
-
-int AvaChanged(WPARAM wParam, LPARAM lParam)
-{
- if (!lParam && db_get_b((HANDLE)wParam, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0)) {
- BOOL enqueued = FALSE;
- AVACHANGED *ach = (AVACHANGED*)malloc(sizeof(AVACHANGED));
- __try {
- ach->hContact = (HANDLE)wParam;
- enqueued = CreateTimerQueueTimer(&ach->hTimer, NULL, CallSetAvatar, ach, SET_AVATAR_INTERVAL, 0, WT_EXECUTEONLYONCE);
- }
- __finally {
- if (!enqueued) free(ach);
- }
- }
- return 0;
-}
-
-CRITICAL_SECTION g_csSetAvatar;
-HANDLE hAvaChanged = 0;
-BOOL initialized = FALSE;
-
-BOOL InitAvaUnit(BOOL init)
-{
- if (init) {
- hAvaChanged = HookEvent(ME_AV_AVATARCHANGED, AvaChanged);
- InitializeCriticalSection(&g_csSetAvatar);
- initialized = TRUE;
- return hAvaChanged != 0;
- }
- else {
- if (initialized) {
- initialized = FALSE;
- DeleteCriticalSection(&g_csSetAvatar);
- }
- if (hAvaChanged) {
- UnhookEvent(hAvaChanged);
- hAvaChanged = 0;
- }
- return TRUE;
- }
-}
-
-void SetAvatar(HANDLE hContact)
-{
- EnterCriticalSection(&g_csSetAvatar);
- __try {
- avatarCacheEntry *ava = (avatarCacheEntry*)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)hContact, 0);
- if (ava && GetFileAttributes(&ava->szFilename[0]) != INVALID_FILE_ATTRIBUTES)
- return;
-
- HANDLE hFile;
- LPSTR avaFile = CreateAvaFile(&hFile);
- if (avaFile)
- __try {
- BOOL saved = SaveAvatar(hFile);
- CloseHandle(hFile); hFile = 0;
- if (saved){
- if (ava) CallService(MS_AV_SETAVATAR, (WPARAM)hContact, (LPARAM)"");
- CallService(MS_AV_SETAVATAR, (WPARAM)hContact, (LPARAM)avaFile);
- DBWriteContactSettingString(hContact, SRMM_MODULE_NAME, SRMM_AVATAR_SETTING_NAME, avaFile);
- }
- }
- __finally {
- free(avaFile);
- CloseHandle(hFile);
- }
- }
- __finally {
- LeaveCriticalSection(&g_csSetAvatar);
- }
-} \ No newline at end of file
diff --git a/protocols/GTalkExt/src/avatar.h b/protocols/GTalkExt/src/avatar.h
deleted file mode 100644
index f07631deff..0000000000
--- a/protocols/GTalkExt/src/avatar.h
+++ /dev/null
@@ -1,25 +0,0 @@
-//***************************************************************************************
-//
-// Google Extension plugin for the Miranda IM's Jabber protocol
-// Copyright (c) 2011 bems@jabber.org, George Hazan (ghazan@jabber.ru)
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
-//***************************************************************************************
-
-#pragma once
-
-void SetAvatar(HANDLE hContact);
-BOOL InitAvaUnit(BOOL init); \ No newline at end of file
diff --git a/protocols/GTalkExt/src/db.cpp b/protocols/GTalkExt/src/db.cpp
index 5b55a9a688..d5e8e6edbc 100644
--- a/protocols/GTalkExt/src/db.cpp
+++ b/protocols/GTalkExt/src/db.cpp
@@ -22,79 +22,18 @@
#include "StdAfx.h"
#include "options.h"
-char *WtoA(LPCTSTR W)
-{
- char* result = (char*)malloc(lstrlen(W) + 1);
- __try {
- int i;
- for (i = 0; W[i]; i++) {
- result[i] = W[i];
- }
-
- result[i] = 0;
- }
- __except(
- free(result),
- EXCEPTION_CONTINUE_SEARCH
- ) {}
- return result;
-}
-
LPTSTR ReadJidSetting(LPCSTR name, LPCTSTR jid)
{
- char *ansiJid = WtoA(jid);
- __try {
- DBVARIANT dbv = {0};
- __try {
- if (DBGetContactSettingTString(0, name, ansiJid, &dbv))
- {
- LPTSTR result = (LPTSTR)malloc(2 * sizeof(TCHAR));
- result[0] = '0';
- result[1] = NULL;
- return result;
- }
+ DBVARIANT dbv;
+ if ( DBGetContactSettingTString(0, name, _T2A(jid), &dbv))
+ return (LPTSTR)calloc(2, sizeof(TCHAR));
- return _tcsdup(dbv.ptszVal);
- }
- __finally {
- DBFreeVariant(&dbv);
- }
- }
- __finally {
- free(ansiJid);
- }
-
- assert(false);
- return NULL; // relax compiler
+ TCHAR *result = _tcsdup(dbv.ptszVal);
+ db_free(&dbv);
+ return result;
}
void WriteJidSetting(LPCSTR name, LPCTSTR jid, LPCTSTR setting)
{
- char *ansiJid = WtoA(jid);
- __try {
- db_set_ts(0, name, ansiJid, setting);
- }
- __finally {
- free(ansiJid);
- }
+ db_set_ts(0, name, _T2A(jid), setting);
}
-
-void RenewPseudocontactHandles()
-{
- int count = 0;
- PROTOACCOUNT **protos;
- ProtoEnumAccounts(&count, &protos);
- for (int i = 0; i < count; i++) {
- db_unset(0, protos[i]->szModuleName, PSEUDOCONTACT_LINK);
- db_unset(0, protos[i]->szModuleName, "GMailExtNotifyContact"); // remove this
- }
-
- HANDLE hContact = db_find_first();
- while (hContact) {
- if (db_get_b(hContact, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0)) {
- LPCSTR proto = (LPCSTR)GetContactProto(hContact);
- db_set_dw(0, proto, PSEUDOCONTACT_LINK, (DWORD)hContact);
- }
- hContact = db_find_next(hContact);
- };
-} \ No newline at end of file
diff --git a/protocols/GTalkExt/src/db.h b/protocols/GTalkExt/src/db.h
index 9db6cc94ce..cb8c3f3f4c 100644
--- a/protocols/GTalkExt/src/db.h
+++ b/protocols/GTalkExt/src/db.h
@@ -27,5 +27,3 @@ static const LPSTR LAST_THREAD_ID_FROM_JID = SHORT_PLUGIN_NAME ".LastThreadIdFro
LPTSTR ReadJidSetting(LPCSTR name, LPCTSTR jid);
void WriteJidSetting(LPCSTR name, LPCTSTR jid, LPCTSTR setting);
-char *WtoA(LPCTSTR W);
-void RenewPseudocontactHandles();
diff --git a/protocols/GTalkExt/src/handlers.cpp b/protocols/GTalkExt/src/handlers.cpp
index 422f627973..3b48137b3c 100644
--- a/protocols/GTalkExt/src/handlers.cpp
+++ b/protocols/GTalkExt/src/handlers.cpp
@@ -136,12 +136,11 @@ BOOL InternalListHandler(IJabberInterface *ji, HXML node, LPCTSTR jid, LPCTSTR m
}
LPCSTR acc = GetJidAcc(jid);
- if (!acc) return FALSE;
+ if (!acc)
+ return FALSE;
- if (!unreadCount) {
- SetupPseudocontact(jid, xi.getAttrValue(node, ATTRNAME_TOTAL_MATCHED), acc);
+ if (!unreadCount)
return TRUE;
- }
DWORD settings = ReadNotificationSettings(acc);
@@ -415,8 +414,6 @@ int AccListChanged(WPARAM wParam, LPARAM lParam)
int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
- RenewPseudocontactHandles();
-
int count;
PROTOACCOUNT **protos;
ProtoEnumAccounts(&count, &protos);
@@ -428,4 +425,4 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam)
HookOptionsInitialization();
return 0;
-} \ No newline at end of file
+}
diff --git a/protocols/GTalkExt/src/inbox.cpp b/protocols/GTalkExt/src/inbox.cpp
index 3e0bd96932..4faf247172 100644
--- a/protocols/GTalkExt/src/inbox.cpp
+++ b/protocols/GTalkExt/src/inbox.cpp
@@ -164,6 +164,7 @@ void OpenUrlThread(void *param)
HANDLE hUser = FindNetUserHandle(data->acc);
if (!hUser || !AuthAndOpen(hUser, data->url, data->mailbox, data->pwd))
CallService(MS_UTILS_OPENURL, 0, (LPARAM)data->url);
+ free(data);
}
void __forceinline DecryptString(LPSTR str, int len)
@@ -209,38 +210,18 @@ BOOL OpenUrlWithAuth(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url)
int mailboxLen = lstrlen(mailbox) + 1;
OPEN_URL_HEADER *data = (OPEN_URL_HEADER*)malloc(sizeof(OPEN_URL_HEADER) + urlLen + mailboxLen + pwdLen);
- __try {
- data->url = (LPSTR)data + sizeof(OPEN_URL_HEADER);
- LPSTR ansi = WtoA(url);
- __try {
- memcpy(data->url, ansi, urlLen);
- }
- __finally {
- free(ansi);
- }
-
- data->mailbox = data->url + urlLen;
- ansi = WtoA(mailbox);
- __try {
- memcpy(data->mailbox, ansi, mailboxLen);
- }
- __finally {
- free(ansi);
- }
-
- data->pwd = data->mailbox + mailboxLen;
- if (!GetMailboxPwd(acc, mailbox, &data->pwd, pwdLen))
- return FALSE;
-
- data->acc = acc;
-
- mir_forkthread(OpenUrlThread, data);
- data = NULL;
- }
- __finally {
- free(data);
- }
+ data->url = (LPSTR)data + sizeof(OPEN_URL_HEADER);
+ memcpy(data->url, _T2A(url), urlLen);
+
+ data->mailbox = data->url + urlLen;
+ memcpy(data->mailbox, _T2A(mailbox), mailboxLen);
+
+ data->pwd = data->mailbox + mailboxLen;
+ if (!GetMailboxPwd(acc, mailbox, &data->pwd, pwdLen))
+ return FALSE;
+ data->acc = acc;
+ mir_forkthread(OpenUrlThread, data);
return TRUE;
}
diff --git a/protocols/GTalkExt/src/menu.cpp b/protocols/GTalkExt/src/menu.cpp
index 23e571c206..377b776091 100644
--- a/protocols/GTalkExt/src/menu.cpp
+++ b/protocols/GTalkExt/src/menu.cpp
@@ -20,7 +20,6 @@
//***************************************************************************************
#include "stdafx.h"
-#include "menu.h"
#include "resources.h"
#include "options.h"
#include "inbox.h"
@@ -28,66 +27,24 @@
static const LPSTR MS_GTALKEXT_OPENMAILBOX = SHORT_PLUGIN_NAME "/OpenMailbox";
static const LPTSTR _T(OPEN_MAILBOX_ITEM_CAPTION) = LPGENT("Open mailbox");
-HANDLE hOpenMailboxService = 0;
-HANDLE hOpenMailboxMenuItem = 0;
+extern HICON g_hPopupIcon;
+
HANDLE hOnPrebuildMenu = 0;
INT_PTR OpenMailboxMenuHandler(WPARAM wParam, LPARAM lParam)
{
- if (db_get_b((HANDLE)wParam, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0))
- OpenContactInbox((HANDLE)wParam);
- return 0;
-}
-
-int OnPrebuildMenu(WPARAM wParam, LPARAM lParam)
-{
- CLISTMENUITEM cmi = { sizeof(cmi) };
- cmi.flags = CMIM_FLAGS;
- if (!db_get_b((HANDLE)wParam, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0))
- cmi.flags |= CMIF_HIDDEN;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hOpenMailboxMenuItem, (LPARAM)&cmi);
+ OpenContactInbox((HANDLE)wParam);
return 0;
}
-BOOL InitMenus(BOOL init)
+void InitMenus()
{
- if (init) {
- hOpenMailboxService = (HANDLE)CreateServiceFunction(MS_GTALKEXT_OPENMAILBOX, OpenMailboxMenuHandler);
- if (!hOpenMailboxService) {
- InitMenus(FALSE);
- return FALSE;
- }
-
- extern HICON g_hPopupIcon;
-
+ CreateServiceFunction(MS_GTALKEXT_OPENMAILBOX, OpenMailboxMenuHandler);
+/*!!!!!!!!!!!!!!!!!!!!!
CLISTMENUITEM cmi = { sizeof(cmi) };
cmi.flags = CMIF_TCHAR;
cmi.hIcon = g_hPopupIcon;
cmi.ptszName = _T(OPEN_MAILBOX_ITEM_CAPTION);
cmi.pszService = MS_GTALKEXT_OPENMAILBOX;
- hOpenMailboxMenuItem = Menu_AddContactMenuItem(&cmi);
-
- if (!hOpenMailboxMenuItem) {
- InitMenus(FALSE);
- return FALSE;
- }
-
- hOnPrebuildMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPrebuildMenu);
- if (!hOnPrebuildMenu) {
- InitMenus(FALSE);
- return FALSE;
- }
- }
- else {
- if (hOnPrebuildMenu) {
- UnhookEvent(hOnPrebuildMenu);
- hOnPrebuildMenu = 0;
- }
- if (hOpenMailboxService) {
- DestroyServiceFunction(hOpenMailboxService);
- hOpenMailboxService = 0;
- }
- }
-
- return TRUE;
-} \ No newline at end of file
+ Menu_AddContactMenuItem(&cmi); */
+}
diff --git a/protocols/GTalkExt/src/menu.h b/protocols/GTalkExt/src/menu.h
deleted file mode 100644
index c06457672a..0000000000
--- a/protocols/GTalkExt/src/menu.h
+++ /dev/null
@@ -1,24 +0,0 @@
-//***************************************************************************************
-//
-// Google Extension plugin for the Miranda IM's Jabber protocol
-// Copyright (c) 2011 bems@jabber.org, George Hazan (ghazan@jabber.ru)
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
-//***************************************************************************************
-
-#pragma once
-
-BOOL InitMenus(BOOL init); \ No newline at end of file
diff --git a/protocols/GTalkExt/src/notifications.cpp b/protocols/GTalkExt/src/notifications.cpp
index 45acc87ba8..995848e0e4 100644
--- a/protocols/GTalkExt/src/notifications.cpp
+++ b/protocols/GTalkExt/src/notifications.cpp
@@ -23,15 +23,12 @@
#include "notifications.h"
#include "db.h"
#include "options.h"
-#include "avatar.h"
#include "inbox.h"
const LPTSTR _T(NUMBER_EMAILS_MESSAGE) = LPGENT("You've received an e-mail\n%s unread threads");
const LPTSTR PLUGIN_DATA_PROP_NAME = _T("{DB5CE833-C3AC-4851-831C-DDEBD9FA0508}");
-const LPTSTR EVT_DELETED_HOOK_PROP_NAME = _T("{87CBD2BC-8806-413C-8FD5-1D61ABCA4AF8}");
-#define EVENT_DELETED_MSG RegisterWindowMessage(_T("{B9B00536-86A0-4BCE-B2FE-4ABD409C22AE}"))
#define MESSAGE_CLOSEPOPUP RegisterWindowMessage(_T("{7A60EA87-3E77-41DF-8A69-59B147F0C9C6}"))
const LPSTR CLIST_MODULE_NAME = "CList";
@@ -41,9 +38,6 @@ const LPSTR UNREAD_THREADS_SETTING = "UnreadThreads";
struct POPUP_DATA_HEADER
{
- BOOL MarkRead;
- HANDLE hDbEvent;
- HANDLE hContact;
LPTSTR jid;
LPTSTR url;
};
@@ -70,61 +64,20 @@ LPCSTR GetJidAcc(LPCTSTR jid)
return NULL;
}
-void MarkEventRead(HANDLE hCnt, HANDLE hEvt)
-{
- DWORD settings = (DWORD)TlsGetValue(itlsSettings);
- if (ReadCheckbox(0, IDC_POPUPSENABLED, settings) &&
- ReadCheckbox(0, IDC_PSEUDOCONTACTENABLED, settings) &&
- ReadCheckbox(0, IDC_MARKEVENTREAD, settings) &&
- (CallService(MS_DB_EVENT_MARKREAD, (WPARAM)hCnt, (LPARAM)hEvt) != (INT_PTR)-1))
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hCnt, (LPARAM)hEvt);
-}
-
-int OnEventDeleted(WPARAM hContact, LPARAM hDbEvent, LPARAM wnd)
-{
- if (db_get_b((HANDLE)hContact, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0)) {
- CallService(MS_CLIST_REMOVEEVENT, hContact, hDbEvent);
- PostMessage((HWND)wnd, EVENT_DELETED_MSG, hContact, hDbEvent);
- }
-
- return 0;
-}
-
LRESULT CALLBACK PopupProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
POPUP_DATA_HEADER *ppdh = (POPUP_DATA_HEADER*)PUGetPluginData(wnd);
LPCSTR acc;
- if (EVENT_DELETED_MSG == msg) {
- if ((HANDLE)lParam == ppdh->hDbEvent)
- ppdh->hDbEvent = NULL;
- return 0;
- }
-
- if (MESSAGE_CLOSEPOPUP == msg) {
- ppdh->MarkRead = TRUE;
+ if (MESSAGE_CLOSEPOPUP == msg)
PUDeletePopUp(wnd);
- }
switch (msg) {
case UM_INITPOPUP:
SetProp(wnd, PLUGIN_DATA_PROP_NAME, (HANDLE)ppdh);
- SetProp(wnd, EVT_DELETED_HOOK_PROP_NAME,
- HookEventParam(ME_DB_EVENT_DELETED, OnEventDeleted, (LPARAM)wnd));
return 0;
case UM_FREEPLUGINDATA:
- {
- HANDLE hHook = GetProp(wnd, EVT_DELETED_HOOK_PROP_NAME);
- RemoveProp(wnd, EVT_DELETED_HOOK_PROP_NAME);
- UnhookEvent(hHook);
- }
-
- if (ppdh->MarkRead && ppdh->hDbEvent && (acc = GetJidAcc(ppdh->jid))) {
- ReadNotificationSettings(acc);
- MarkEventRead(ppdh->hContact, ppdh->hDbEvent);
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)ppdh->hContact, (LPARAM)ppdh->hDbEvent);
- }
RemoveProp(wnd, PLUGIN_DATA_PROP_NAME);
free(ppdh);
return 0;
@@ -177,47 +130,6 @@ void FormatPseudocontactDisplayName(LPTSTR buff, LPCTSTR jid, LPCTSTR unreadCoun
wsprintf(buff, _T("%s"), jid);
}
-HANDLE SetupPseudocontact(LPCTSTR jid, LPCTSTR unreadCount, LPCSTR acc, LPCTSTR displayName)
-{
- HANDLE result = (HANDLE)DBGetContactSettingDword(0, acc, PSEUDOCONTACT_LINK, 0);
- if (!result || !db_get_b(result, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0)) {
- result = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
- db_set_dw(0, acc, PSEUDOCONTACT_LINK, (DWORD)result);
- DBWriteContactSettingByte(result, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 1);
- CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)result, (LPARAM)acc);
- }
-
- SetAvatar(result);
-
- if (displayName == NULL) {
- TCHAR *tszTemp = (TCHAR*)alloca((lstrlen(jid) + lstrlen(unreadCount) + 3 + 1) * sizeof(TCHAR));
- FormatPseudocontactDisplayName(tszTemp, jid, unreadCount);
- db_set_ts(result, CLIST_MODULE_NAME, CONTACT_DISPLAY_NAME_SETTING, tszTemp);
- }
- else db_set_ts(result, CLIST_MODULE_NAME, CONTACT_DISPLAY_NAME_SETTING, displayName);
-
- db_set_ts(result, CLIST_MODULE_NAME, STATUS_MSG_SETTING, TranslateTS(MAIL_NOTIFICATIONS));
- db_set_ts(result, SHORT_PLUGIN_NAME, UNREAD_THREADS_SETTING, unreadCount);
-
- return result;
-}
-
-HANDLE AddCListNotification(HANDLE hContact, LPCSTR acc, POPUPDATAT *data, LPCTSTR jid, LPCTSTR url, LPCTSTR unreadCount)
-{
- mir_ptr<char> szUrl( mir_utf8encodeT(url)), szText( mir_utf8encodeT(data->lptzText));
-
- DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.szModule = (LPSTR)acc;
- dbei.timestamp = time(NULL);
- dbei.flags = DBEF_UTF;
- dbei.eventType = EVENTTYPE_MESSAGE;
-
- char szEventText[4096];
- dbei.cbBlob = mir_snprintf(szEventText, SIZEOF(szEventText), "%s\r\n%s", szUrl, szText);
- dbei.pBlob = (PBYTE)szEventText;
- return (HANDLE)CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
-}
-
BOOL UsePopups()
{
return ServiceExists(MS_POPUP_QUERY) &&
@@ -227,11 +139,8 @@ BOOL UsePopups()
void ShowNotification(LPCSTR acc, POPUPDATAT *data, LPCTSTR jid, LPCTSTR url, LPCTSTR unreadCount)
{
- HANDLE hCnt = SetupPseudocontact(jid, unreadCount, acc, &data->lptzContactName[0]);
- HANDLE hEvt = ReadCheckbox(0, IDC_PSEUDOCONTACTENABLED, (DWORD)TlsGetValue(itlsSettings))
- ? AddCListNotification(hCnt, acc, data, jid, url, unreadCount) : NULL;
-
- if (!UsePopups()) return;
+ if (!UsePopups())
+ return;
extern HICON g_hPopupIcon;
data->lchIcon = g_hPopupIcon;
@@ -248,10 +157,6 @@ void ShowNotification(LPCSTR acc, POPUPDATAT *data, LPCTSTR jid, LPCTSTR url, LP
int ljid = (lstrlen(jid) + 1) * sizeof(TCHAR);
POPUP_DATA_HEADER *ppdh = (POPUP_DATA_HEADER*)malloc(sizeof(POPUP_DATA_HEADER) + lurl + ljid);
- ppdh->MarkRead = FALSE;
- ppdh->hContact = hCnt;
- ppdh->hDbEvent = hEvt;
-
ppdh->jid = (LPTSTR)((PBYTE)ppdh + sizeof(*ppdh));
memcpy(ppdh->jid, jid, ljid);
@@ -296,15 +201,6 @@ void UnreadThreadNotification(LPCSTR acc, LPCTSTR jid, LPCTSTR url, LPCTSTR unre
ShowNotification(acc, &data, jid, url, unreadCount);
}
-void ClearNotificationContactHistory(LPCSTR acc)
-{
- HANDLE hEvent = 0;
- HANDLE hContact = (HANDLE)DBGetContactSettingDword(0, acc, PSEUDOCONTACT_LINK, 0);
- if (hContact && db_get_b(hContact, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0))
- while ((hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0)) &&
- !CallService(MS_DB_EVENT_DELETE, (WPARAM)hContact, (LPARAM)hEvent)) {};
-}
-
DWORD ReadNotificationSettings(LPCSTR acc)
{
DWORD result = ReadCheckboxes(0, acc);
@@ -321,11 +217,13 @@ BOOL CALLBACK ClosePopupFunc(__in HWND hwnd, __in LPARAM lParam)
{
DWORD pid = 0;
GetWindowThreadProcessId(hwnd, &pid);
- if (pid != GetCurrentProcessId()) return TRUE;
+ if (pid != GetCurrentProcessId())
+ return TRUE;
POPUP_IDENT_STRINGS *ppis = (POPUP_IDENT_STRINGS*)lParam;
POPUP_DATA_HEADER *ppdh = (POPUP_DATA_HEADER*)GetProp(hwnd, PLUGIN_DATA_PROP_NAME);
- if (!ppdh) return TRUE;
+ if (!ppdh)
+ return TRUE;
if (!lstrcmpi(ppis->url, ppdh->url) && !lstrcmpi(ppis->jid, ppdh->jid))
SendMessage(hwnd, MESSAGE_CLOSEPOPUP, 0, 0);
@@ -335,13 +233,6 @@ BOOL CALLBACK ClosePopupFunc(__in HWND hwnd, __in LPARAM lParam)
void CloseNotifications(LPCSTR acc, LPCTSTR url, LPCTSTR jid, BOOL PopupsOnly)
{
- DWORD settings = (DWORD)TlsGetValue(itlsSettings);
- if (acc &&
- !PopupsOnly &&
- ReadCheckbox(0, IDC_PSEUDOCONTACTENABLED, settings) &&
- ReadCheckbox(0, IDC_CLEARPSEUDOCONTACTLOG, settings))
- ClearNotificationContactHistory(acc);
-
POPUP_IDENT_STRINGS pis = {url, jid};
EnumWindows(ClosePopupFunc, (LPARAM)&pis);
}
diff --git a/protocols/GTalkExt/src/notifications.h b/protocols/GTalkExt/src/notifications.h
index 02780ae2b0..76f164ce4b 100644
--- a/protocols/GTalkExt/src/notifications.h
+++ b/protocols/GTalkExt/src/notifications.h
@@ -40,5 +40,4 @@ void UnreadMailNotification(LPCSTR acc, LPCTSTR jid, LPCTSTR url, LPCTSTR unread
void UnreadThreadNotification(LPCSTR acc, LPCTSTR jid, LPCTSTR url, LPCTSTR unreadCount, const MAIL_THREAD_NOTIFICATION *mtn);
void CloseNotifications(LPCSTR acc, LPCTSTR url, LPCTSTR jid, BOOL PopupsOnly);
DWORD ReadNotificationSettings(LPCSTR acc);
-HANDLE SetupPseudocontact(LPCTSTR jid, LPCTSTR unreadCount, LPCSTR acc, LPCTSTR displayName = NULL);
LPCSTR GetJidAcc(LPCTSTR jid); \ No newline at end of file
diff --git a/protocols/GTalkExt/src/options.cpp b/protocols/GTalkExt/src/options.cpp
index 792bc9f45c..7df8c2c7d3 100644
--- a/protocols/GTalkExt/src/options.cpp
+++ b/protocols/GTalkExt/src/options.cpp
@@ -47,17 +47,12 @@ void CheckControlsEnabled(HWND wnd)
BOOL PopupsEnabled = (SendMessage(GetDlgItem(wnd, IDC_POPUPSENABLED), BM_GETSTATE, 0, 0) & BST_CHECKED) == BST_CHECKED;
EnableWindow(GetDlgItem(wnd, IDC_POPUPSINFULLSCREEN), PopupsEnabled);
EnableWindow(GetDlgItem(wnd, IDC_POPUPSINFULLSCREENLABEL), PopupsEnabled);
+ EnableWindow(GetDlgItem(wnd, IDC_ADDSNIP), PopupsEnabled);
- BOOL CListEnabled = (SendMessage(GetDlgItem(wnd, IDC_PSEUDOCONTACTENABLED), BM_GETSTATE, 0, 0) & BST_CHECKED) == BST_CHECKED;
- EnableWindow(GetDlgItem(wnd, IDC_CLEARPSEUDOCONTACTLOG), CListEnabled);
-
- EnableWindow(GetDlgItem(wnd, IDC_MARKEVENTREAD), PopupsEnabled && CListEnabled);
- EnableWindow(GetDlgItem(wnd, IDC_ADDSNIP), PopupsEnabled || CListEnabled);
-
- EnableWindow(GetDlgItem(wnd, IDC_MAILBOXVIEWLABEL), PopupsEnabled || CListEnabled);
- EnableWindow(GetDlgItem(wnd, IDC_UNKNOWNVIEW), PopupsEnabled || CListEnabled);
- EnableWindow(GetDlgItem(wnd, IDC_STANDARDVIEW), PopupsEnabled || CListEnabled);
- EnableWindow(GetDlgItem(wnd, IDC_HTMLVIEW), PopupsEnabled || CListEnabled);
+ EnableWindow(GetDlgItem(wnd, IDC_MAILBOXVIEWLABEL), PopupsEnabled);
+ EnableWindow(GetDlgItem(wnd, IDC_UNKNOWNVIEW), PopupsEnabled);
+ EnableWindow(GetDlgItem(wnd, IDC_STANDARDVIEW), PopupsEnabled);
+ EnableWindow(GetDlgItem(wnd, IDC_HTMLVIEW), PopupsEnabled);
}
BOOL ReadCheckbox(HWND wnd, int id, DWORD controls)
@@ -72,10 +67,7 @@ DWORD ReadCheckboxes(HWND wnd, LPCSTR mod)
{
DWORD controls = DBGetContactSettingDword(0, NOTIFY_SETTINGS_FROM_MOD_NAME, mod, 0);
ReadCheckbox(wnd, IDC_POPUPSENABLED, controls);
- ReadCheckbox(wnd, IDC_PSEUDOCONTACTENABLED, controls);
- ReadCheckbox(wnd, IDC_CLEARPSEUDOCONTACTLOG, controls);
ReadCheckbox(wnd, IDC_POPUPSINFULLSCREEN, controls);
- ReadCheckbox(wnd, IDC_MARKEVENTREAD, controls);
ReadCheckbox(wnd, IDC_AUTHONMAILBOX, controls);
ReadCheckbox(wnd, IDC_ADDSNIP, controls);
ReadCheckbox(wnd, IDC_UNKNOWNVIEW, controls);
@@ -93,11 +85,9 @@ DWORD GetCheckboxSaveValue(HWND wnd, int id)
void SaveControls(HWND wnd, LPCSTR mod)
{
- DWORD controls = GetCheckboxSaveValue(wnd, IDC_CLEARPSEUDOCONTACTLOG) |
+ DWORD controls =
GetCheckboxSaveValue(wnd, IDC_POPUPSINFULLSCREEN) |
GetCheckboxSaveValue(wnd, IDC_POPUPSENABLED) |
- GetCheckboxSaveValue(wnd, IDC_PSEUDOCONTACTENABLED) |
- GetCheckboxSaveValue(wnd, IDC_MARKEVENTREAD) |
GetCheckboxSaveValue(wnd, IDC_AUTHONMAILBOX) |
GetCheckboxSaveValue(wnd, IDC_ADDSNIP) |
GetCheckboxSaveValue(wnd, IDC_UNKNOWNVIEW) |
@@ -125,13 +115,10 @@ INT_PTR CALLBACK AccOptionsDlgProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lPa
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_POPUPSENABLED:
- case IDC_PSEUDOCONTACTENABLED:
if (HIWORD(wParam) == BN_CLICKED) CheckControlsEnabled(wnd);
// no break
- case IDC_CLEARPSEUDOCONTACTLOG:
case IDC_POPUPSINFULLSCREEN:
- case IDC_MARKEVENTREAD:
case IDC_AUTHONMAILBOX:
case IDC_ADDSNIP:
case IDC_UNKNOWNVIEW:
diff --git a/protocols/GTalkExt/src/options.h b/protocols/GTalkExt/src/options.h
index ff9c2327e2..2b9507b84e 100644
--- a/protocols/GTalkExt/src/options.h
+++ b/protocols/GTalkExt/src/options.h
@@ -27,8 +27,6 @@ static const LPTSTR MAIL_NOTIFICATIONS = LPGENT("GMail notifications");
static const LPTSTR FULL_NOTIFICATION_FORMAT = LPGENT("subject\n %s\nfrom\n%s\n%s\n");
static const LPTSTR SHORT_NOTIFICATION_FORMAT = LPGENT("subject\n %s\nfrom\n%s");
-static const LPSTR PSEUDOCONTACT_LINK = "GTalkExtNotifyContact";
-static const LPSTR PSEUDOCONTACT_FLAG = "IsNotifyContact";
static const LPSTR BACK_COLOR_SETTING = "BackColor";
static const LPSTR TEXT_COLOR_SETTING = "TextColor";
static const LPSTR TIMEOUT_SETTING = "Timeout";
diff --git a/protocols/GTalkExt/src/resources.h b/protocols/GTalkExt/src/resources.h
index 1b63b3c9e4..7a5a10e63d 100644
--- a/protocols/GTalkExt/src/resources.h
+++ b/protocols/GTalkExt/src/resources.h
@@ -27,10 +27,7 @@
#define IDC_BASE 1001
#define IDC_POPUPSENABLED IDC_BASE + 0
-#define IDC_PSEUDOCONTACTENABLED IDC_BASE + 1
-#define IDC_CLEARPSEUDOCONTACTLOG IDC_BASE + 2
#define IDC_POPUPSINFULLSCREEN IDC_BASE + 3
-#define IDC_MARKEVENTREAD IDC_BASE + 5
#define IDC_AUTHONMAILBOX IDC_BASE + 6
#define IDC_ADDSNIP IDC_BASE + 7
#define IDC_UNKNOWNVIEW IDC_BASE + 8