summaryrefslogtreecommitdiff
path: root/protocols/GTalkExt
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-09-24 19:22:39 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-09-24 19:22:39 +0000
commit19ab68c3d146d0d0dc24e9c8153e90d218395209 (patch)
tree0e5a8d34a25dafa1d1fb71cddd9e5d7528c116e1 /protocols/GTalkExt
parentfb190494fe8550288e5c8741bebec9ab0f58284e (diff)
GTalkExt: contact list contact restored
git-svn-id: http://svn.miranda-ng.org/main/trunk@6214 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/GTalkExt')
-rw-r--r--protocols/GTalkExt/GTalkExt_10.vcxproj6
-rw-r--r--protocols/GTalkExt/GTalkExt_10.vcxproj.filters14
-rw-r--r--protocols/GTalkExt/GTalkExt_11.vcxproj1
-rw-r--r--protocols/GTalkExt/GTalkExt_11.vcxproj.filters3
-rw-r--r--protocols/GTalkExt/res/settings.rc99
-rw-r--r--protocols/GTalkExt/src/GTalkExt.cpp6
-rw-r--r--protocols/GTalkExt/src/Version.h4
-rw-r--r--protocols/GTalkExt/src/db.cpp18
-rw-r--r--protocols/GTalkExt/src/db.h2
-rw-r--r--protocols/GTalkExt/src/handlers.cpp7
-rw-r--r--protocols/GTalkExt/src/handlers.h2
-rw-r--r--protocols/GTalkExt/src/inbox.cpp19
-rw-r--r--protocols/GTalkExt/src/inbox.h4
-rw-r--r--protocols/GTalkExt/src/menu.cpp72
-rw-r--r--protocols/GTalkExt/src/notifications.cpp111
-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
-rw-r--r--protocols/GTalkExt/src/stdafx.h3
20 files changed, 338 insertions, 64 deletions
diff --git a/protocols/GTalkExt/GTalkExt_10.vcxproj b/protocols/GTalkExt/GTalkExt_10.vcxproj
index 2f6ea4714c..50326e60e2 100644
--- a/protocols/GTalkExt/GTalkExt_10.vcxproj
+++ b/protocols/GTalkExt/GTalkExt_10.vcxproj
@@ -173,6 +173,7 @@
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="src\avatar.cpp" />
<ClCompile Include="src\db.cpp" />
<ClCompile Include="src\dllmain.cpp" />
<ClCompile Include="src\GTalkExt.cpp" />
@@ -187,6 +188,7 @@
<ClCompile Include="src\tipper_items.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="res\resource.h" />
<ClInclude Include="src\db.h" />
<ClInclude Include="src\handlers.h" />
<ClInclude Include="src\inbox.h" />
@@ -201,6 +203,10 @@
<ResourceCompile Include="res\settings.rc" />
<ResourceCompile Include="res\Version.rc" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="res\PopupIcon.ico" />
+ <None Include="res\pseudoava.png" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/protocols/GTalkExt/GTalkExt_10.vcxproj.filters b/protocols/GTalkExt/GTalkExt_10.vcxproj.filters
index 5438faccd9..89acc256a7 100644
--- a/protocols/GTalkExt/GTalkExt_10.vcxproj.filters
+++ b/protocols/GTalkExt/GTalkExt_10.vcxproj.filters
@@ -45,6 +45,9 @@
<ClCompile Include="src\tipper_items.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\avatar.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\db.h">
@@ -74,6 +77,9 @@
<ClInclude Include="src\tipper_items.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="res\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\settings.rc">
@@ -83,4 +89,12 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
+ <ItemGroup>
+ <None Include="res\PopupIcon.ico">
+ <Filter>Resource Files</Filter>
+ </None>
+ <None Include="res\pseudoava.png">
+ <Filter>Resource Files</Filter>
+ </None>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/protocols/GTalkExt/GTalkExt_11.vcxproj b/protocols/GTalkExt/GTalkExt_11.vcxproj
index 8f6e7a4358..2a33628c33 100644
--- a/protocols/GTalkExt/GTalkExt_11.vcxproj
+++ b/protocols/GTalkExt/GTalkExt_11.vcxproj
@@ -176,6 +176,7 @@
</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 5438faccd9..61a6512dfe 100644
--- a/protocols/GTalkExt/GTalkExt_11.vcxproj.filters
+++ b/protocols/GTalkExt/GTalkExt_11.vcxproj.filters
@@ -45,6 +45,9 @@
<ClCompile Include="src\tipper_items.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\avatar.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\db.h">
diff --git a/protocols/GTalkExt/res/settings.rc b/protocols/GTalkExt/res/settings.rc
index da441af224..5c1866f211 100644
--- a/protocols/GTalkExt/res/settings.rc
+++ b/protocols/GTalkExt/res/settings.rc
@@ -1,44 +1,89 @@
-#include "..\src\resources.h"
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
#include "winres.h"
-IDD_MAILSETTINGS DIALOGEX 0, 0, 304, 196
+/////////////////////////////////////////////////////////////////////////////
+// English (United States) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_MAILSETTINGS DIALOGEX 0, 0, 304, 204
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
CONTROL "Popup notifications (needs popup plugin)",IDC_POPUPSENABLED,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,271,14
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,8,271,14
CONTROL "Notify in fullscreen mode too",IDC_POPUPSINFULLSCREEN,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,22,267,14
LTEXT "Use this if your popup plugin does not correctly detect fullscreen mode. It will take away your keyboard focus",IDC_POPUPSINFULLSCREENLABEL,34,38,234,27,NOT WS_GROUP
- CONTROL "Add message snip to notification",IDC_ADDSNIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,69,282,15
+ CONTROL "Notify in contact list",IDC_PSEUDOCONTACTENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,60,271,14
+ CONTROL "Clear pseudocontact history before adding new events",IDC_CLEARPSEUDOCONTACTLOG,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,74,254,15
+ CONTROL "Mark history event read when popup closed",IDC_MARKEVENTREAD,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,88,284,15
+ CONTROL "Add message snip to notification",IDC_ADDSNIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,102,282,15
CONTROL "Try to login before open mailbox",IDC_AUTHONMAILBOX,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,87,279,15
- LTEXT "This works only if password is saved in the database. Has no effect on links in pseudocontact message log",IDC_AUTHONMAILBOXLABEL,19,101,269,26,NOT WS_GROUP
- LTEXT "Choose GMail view you use in web interface",IDC_MAILBOXVIEWLABEL,7,128,280,9,NOT WS_GROUP
- CONTROL "I don't know",IDC_UNKNOWNVIEW,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,141,153,8
- CONTROL "Standard view",IDC_STANDARDVIEW,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,152,157,8
- CONTROL "Basic HTML",IDC_HTMLVIEW,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,163,158,8
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,116,279,15
+ LTEXT "This works only if password is saved in the database. Has no effect on links in pseudocontact message log",IDC_AUTHONMAILBOXLABEL,19,130,269,26,NOT WS_GROUP
+ LTEXT "Choose GMail view you use in web interface",IDC_MAILBOXVIEWLABEL,7,154,280,9,NOT WS_GROUP
+ CONTROL "I don't know",IDC_UNKNOWNVIEW,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,167,153,8
+ CONTROL "Standard view",IDC_STANDARDVIEW,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,178,157,8
+ CONTROL "Basic HTML",IDC_HTMLVIEW,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,189,158,8
END
IDD_POPUPSETTINGS DIALOGEX 0, 0, 304, 65
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
-{
- GROUPBOX "", IDC_GROUP, 0, 0, 304, 65
- CONTROL "Background color", IDC_BACKCOLORLABEL, STATIC, SS_LEFT, 10, 10, 60, 15
- CONTROL "", IDC_BACKCOLORPICKER, "ColourPicker", WS_TABSTOP, 70, 10, 39, 10
- CONTROL "Text color", IDC_TEXTCOLORLABEL, STATIC, SS_LEFT, 10, 25, 50, 15
- CONTROL "", IDC_TEXTCOLORPICKER, "ColourPicker", WS_TABSTOP, 70, 25, 39, 10
- CONTROL "Timeout", IDC_TIMEOUTLABEL, STATIC, SS_LEFT, 10, 40, 50, 13
- CONTROL "", IDC_TIMEOUTEDIT, EDIT, WS_TABSTOP | WS_BORDER, 70, 40, 39, 10
- CONTROL "If both colors set to the same value, default colors will be used", IDC_DEFCOLORSLABEL, STATIC, SS_LEFT, 120, 10, 120, 25
- CONTROL "0 means default timeout,\n-1 means no timeout", IDC_DEFTIMEOUTLABEL, STATIC, SS_LEFT, 120, 40, 120, 20
- CONTROL "Test", IDC_TESTBUTTON, BUTTON, WS_TABSTOP, 245, 17, 50, 25
-}
-
-LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
-
-IDI_POPUP ICON "PopupIcon.ico"
-IDI_PSEUDOAVA PNG "pseudoava.png" \ No newline at end of file
+BEGIN
+ GROUPBOX "",IDC_GROUP,0,0,304,65
+ LTEXT "Background color",IDC_BACKCOLORLABEL,10,10,60,15,NOT WS_GROUP
+ CONTROL "",IDC_BACKCOLORPICKER,"ColourPicker",WS_TABSTOP,70,10,39,10
+ LTEXT "Text color",IDC_TEXTCOLORLABEL,10,25,50,15,NOT WS_GROUP
+ CONTROL "",IDC_TEXTCOLORPICKER,"ColourPicker",WS_TABSTOP,70,25,39,10
+ LTEXT "Timeout",IDC_TIMEOUTLABEL,10,40,50,13,NOT WS_GROUP
+ EDITTEXT IDC_TIMEOUTEDIT,70,40,39,10
+ LTEXT "If both colors set to the same value, default colors will be used",IDC_DEFCOLORSLABEL,120,10,120,25,NOT WS_GROUP
+ LTEXT "0 means default timeout,\n-1 means no timeout",IDC_DEFTIMEOUTLABEL,120,40,120,20,NOT WS_GROUP
+ PUSHBUTTON "Test",IDC_TESTBUTTON,245,17,50,25
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_POPUP ICON "PopupIcon.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// PNG
+//
+
+IDI_PSEUDOAVA PNG "pseudoava.png"
+#endif // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/protocols/GTalkExt/src/GTalkExt.cpp b/protocols/GTalkExt/src/GTalkExt.cpp
index 845c990d71..64d860f77d 100644
--- a/protocols/GTalkExt/src/GTalkExt.cpp
+++ b/protocols/GTalkExt/src/GTalkExt.cpp
@@ -27,6 +27,7 @@
#include "handlers.h"
#include "tipper_items.h"
#include "Version.h"
+#include "inbox.h"
int hLangpack;
HICON g_hPopupIcon = 0;
@@ -86,6 +87,9 @@ 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);
@@ -97,5 +101,7 @@ extern "C" int __declspec(dllexport) Load(void)
extern "C" int __declspec(dllexport) Unload(void)
{
+ InitAvaUnit(FALSE);
+ InitMenus(FALSE);
return 0;
}
diff --git a/protocols/GTalkExt/src/Version.h b/protocols/GTalkExt/src/Version.h
index 24c00cd0fd..bed7bb9a3f 100644
--- a/protocols/GTalkExt/src/Version.h
+++ b/protocols/GTalkExt/src/Version.h
@@ -1,6 +1,6 @@
#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 0
-#define __RELEASE_NUM 1
+#define __MINOR_VERSION 1
+#define __RELEASE_NUM 0
#define __BUILD_NUM 1
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
diff --git a/protocols/GTalkExt/src/db.cpp b/protocols/GTalkExt/src/db.cpp
index 691e065bc3..a652babe49 100644
--- a/protocols/GTalkExt/src/db.cpp
+++ b/protocols/GTalkExt/src/db.cpp
@@ -31,3 +31,21 @@ void WriteJidSetting(LPCSTR name, LPCTSTR jid, LPCTSTR setting)
{
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
+ }
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (db_get_b(hContact, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0)) {
+ LPCSTR proto = (LPCSTR)GetContactProto(hContact);
+ db_set_dw(NULL, proto, PSEUDOCONTACT_LINK, (DWORD)hContact);
+ }
+ }
+}
diff --git a/protocols/GTalkExt/src/db.h b/protocols/GTalkExt/src/db.h
index 2a688dcad0..92a01c6500 100644
--- a/protocols/GTalkExt/src/db.h
+++ b/protocols/GTalkExt/src/db.h
@@ -29,3 +29,5 @@ LPTSTR ReadJidSetting(LPCSTR name, LPCTSTR jid);
void WriteJidSetting(LPCSTR name, LPCTSTR jid, LPCTSTR setting);
IJabberInterface* IsGoogleAccount(LPCSTR szModuleName);
+
+void RenewPseudocontactHandles();
diff --git a/protocols/GTalkExt/src/handlers.cpp b/protocols/GTalkExt/src/handlers.cpp
index 91974a914b..9f8ff03aff 100644
--- a/protocols/GTalkExt/src/handlers.cpp
+++ b/protocols/GTalkExt/src/handlers.cpp
@@ -134,8 +134,10 @@ BOOL InternalListHandler(IJabberInterface *ji, HXML node, LPCTSTR jid, LPCTSTR m
if (!acc)
return FALSE;
- if (!unreadCount)
+ if (!unreadCount) {
+ SetupPseudocontact(jid, xi.getAttrValue(node, ATTRNAME_TOTAL_MATCHED), acc);
return TRUE;
+ }
DWORD settings = ReadNotificationSettings(acc);
@@ -380,6 +382,8 @@ int AccListChanged(WPARAM wParam, LPARAM lParam)
int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
+ RenewPseudocontactHandles();
+
int count;
PROTOACCOUNT **protos;
ProtoEnumAccounts(&count, &protos);
@@ -389,7 +393,6 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam)
ji->Net()->AddSendHandler(SendHandler);
}
- HookEvent(ME_JABBER_MENUINIT, InitMenus);
HookOptionsInitialization();
return 0;
}
diff --git a/protocols/GTalkExt/src/handlers.h b/protocols/GTalkExt/src/handlers.h
index 10ffa8cb81..c9d7dd120d 100644
--- a/protocols/GTalkExt/src/handlers.h
+++ b/protocols/GTalkExt/src/handlers.h
@@ -24,4 +24,4 @@
extern HANDLE hModulesLoaded;
int ModulesLoaded(WPARAM wParam, LPARAM lParam);
-int AccListChanged(WPARAM wParam, LPARAM lParam); \ No newline at end of file
+int AccListChanged(WPARAM wParam, LPARAM lParam);
diff --git a/protocols/GTalkExt/src/inbox.cpp b/protocols/GTalkExt/src/inbox.cpp
index 471431a185..4343ae6fe2 100644
--- a/protocols/GTalkExt/src/inbox.cpp
+++ b/protocols/GTalkExt/src/inbox.cpp
@@ -66,8 +66,7 @@ const DWORD SIZE_OF_JABBER_OPTIONS = 243 * sizeof(DWORD);
LPSTR HttpPost(HANDLE hUser, LPSTR reqUrl, LPSTR reqParams)
{
- NETLIBHTTPREQUEST nlhr = {0};
- nlhr.cbSize = sizeof(nlhr);
+ NETLIBHTTPREQUEST nlhr = { sizeof(nlhr) };
nlhr.requestType = REQUEST_POST;
nlhr.flags = NLHRF_GENERATEHOST | NLHRF_SMARTAUTHHEADER | NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP | NLHRF_NODUMPHEADERS;
nlhr.szUrl = reqUrl;
@@ -240,13 +239,17 @@ void OpenUrl(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url)
mir_forkthread(ShellExecuteThread, mir_tstrdup(url));
}
-void OpenContactInbox(LPCSTR acc)
+void OpenContactInbox(HANDLE hContact)
{
- DBVARIANT dbv;
- if ( db_get_ts(0, acc, "jid", &dbv))
+ LPSTR acc = GetContactProto(hContact);
+ if (!acc)
+ return;
+
+ ptrT tszJid( db_get_tsa(0, acc, "jid"));
+ if (tszJid == NULL)
return;
- LPTSTR host = _tcschr(dbv.ptszVal, '@');
+ LPTSTR host = _tcschr(tszJid, '@');
if (!host)
return;
*host++ = 0;
@@ -256,7 +259,5 @@ void OpenContactInbox(LPCSTR acc)
mir_sntprintf(buf, SIZEOF(buf), INBOX_URL_FORMAT, _T("a/"), host); // hosted
else
mir_sntprintf(buf, SIZEOF(buf), INBOX_URL_FORMAT, _T(""), _T("mail")); // common
- OpenUrl(acc, dbv.ptszVal, buf);
-
- db_free(&dbv);
+ OpenUrl(acc, tszJid, buf);
}
diff --git a/protocols/GTalkExt/src/inbox.h b/protocols/GTalkExt/src/inbox.h
index 2b26a074ca..54c3686155 100644
--- a/protocols/GTalkExt/src/inbox.h
+++ b/protocols/GTalkExt/src/inbox.h
@@ -22,6 +22,6 @@
#pragma once
void OpenUrl(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url);
-void OpenContactInbox(LPCSTR acc);
+void OpenContactInbox(HANDLE hContact);
-int InitMenus(WPARAM wParam, LPARAM lParam);
+BOOL InitMenus(BOOL init); \ No newline at end of file
diff --git a/protocols/GTalkExt/src/menu.cpp b/protocols/GTalkExt/src/menu.cpp
index 31aa364710..6cbe2f2209 100644
--- a/protocols/GTalkExt/src/menu.cpp
+++ b/protocols/GTalkExt/src/menu.cpp
@@ -26,32 +26,72 @@
#include "inbox.h"
static const LPSTR MS_GTALKEXT_OPENMAILBOX = SHORT_PLUGIN_NAME "/OpenMailbox";
+static const LPTSTR _T(OPEN_MAILBOX_ITEM_CAPTION) = LPGENT("Open mailbox");
extern HICON g_hPopupIcon;
-INT_PTR OpenMailboxMenuHandler(WPARAM wParam, LPARAM lParam, LPARAM param)
+HANDLE hOpenMailboxService = 0;
+HANDLE hOnPrebuildMenu = 0;
+
+HGENMENU hOpenMailboxMenuItem = 0;
+
+INT_PTR OpenMailboxMenuHandler(WPARAM wParam, LPARAM lParam)
+{
+ HANDLE hContact = (HANDLE)wParam;
+ if (db_get_b(hContact, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0))
+ OpenContactInbox(hContact);
+ return 0;
+}
+
+int OnPrebuildMenu(WPARAM wParam, LPARAM lParam)
{
- OpenContactInbox((LPCSTR)param);
+ CLISTMENUITEM cmi = { sizeof(cmi) };
+ cmi.flags = CMIM_FLAGS;
+ if (!db_get_b((HANDLE)wParam, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0))
+ cmi.flags |= CMIF_HIDDEN;
+ Menu_ModifyItem(hOpenMailboxMenuItem, &cmi);
return 0;
}
-int InitMenus(WPARAM wParam, LPARAM lParam)
+BOOL InitMenus(BOOL init)
{
- IJabberInterface *ji = (IJabberInterface*)lParam;
- LPCSTR szModuleName = ji->Sys()->GetModuleName();
- if ( IsGoogleAccount(szModuleName)) {
- char szServiceName[100];
- mir_snprintf(szServiceName, SIZEOF(szServiceName), "%s/%s", szModuleName, MS_GTALKEXT_OPENMAILBOX);
- CreateServiceFunctionParam(szServiceName, OpenMailboxMenuHandler, (LPARAM)szModuleName);
+ if (init) {
+ hOpenMailboxService = (HANDLE)CreateServiceFunction(MS_GTALKEXT_OPENMAILBOX, OpenMailboxMenuHandler);
+ if (!hOpenMailboxService) {
+ InitMenus(FALSE);
+ return FALSE;
+ }
+
+ extern HICON g_hPopupIcon;
CLISTMENUITEM cmi = { sizeof(cmi) };
- cmi.flags = CMIF_CHILDPOPUP;
- cmi.hParentMenu = HGENMENU(wParam);
+ cmi.flags = CMIF_TCHAR;
cmi.hIcon = g_hPopupIcon;
- cmi.position = 200101;
- cmi.pszName = LPGEN("Open mailbox");
- cmi.pszService = szServiceName;
- Menu_AddProtoMenuItem(&cmi);
+ 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;
+ }
}
- return 0;
+ else {
+ if (hOnPrebuildMenu) {
+ UnhookEvent(hOnPrebuildMenu);
+ hOnPrebuildMenu = 0;
+ }
+ if (hOpenMailboxService) {
+ DestroyServiceFunction(hOpenMailboxService);
+ hOpenMailboxService = 0;
+ }
+ }
+
+ return TRUE;
}
diff --git a/protocols/GTalkExt/src/notifications.cpp b/protocols/GTalkExt/src/notifications.cpp
index b1d52d0d51..373ca1cbba 100644
--- a/protocols/GTalkExt/src/notifications.cpp
+++ b/protocols/GTalkExt/src/notifications.cpp
@@ -28,7 +28,9 @@
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";
@@ -38,6 +40,9 @@ const LPSTR UNREAD_THREADS_SETTING = "UnreadThreads";
struct POPUP_DATA_HEADER
{
+ BOOL MarkRead;
+ HANDLE hDbEvent;
+ HANDLE hContact;
LPTSTR jid;
LPTSTR url;
};
@@ -64,20 +69,61 @@ 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) &&
+ db_event_markRead(hCnt, hEvt) != -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 (MESSAGE_CLOSEPOPUP == msg)
+ if (EVENT_DELETED_MSG == msg) {
+ if ((HANDLE)lParam == ppdh->hDbEvent)
+ ppdh->hDbEvent = NULL;
+ return 0;
+ }
+
+ if (MESSAGE_CLOSEPOPUP == msg) {
+ ppdh->MarkRead = TRUE;
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;
@@ -130,6 +176,47 @@ 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)db_get_dw(NULL, 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);
+ db_set_b(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 db_event_add(hContact, &dbei);
+}
+
BOOL UsePopups()
{
return ServiceExists(MS_POPUP_QUERY) &&
@@ -139,6 +226,10 @@ 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;
@@ -157,6 +248,9 @@ 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);
@@ -201,6 +295,15 @@ 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)db_get_dw(NULL, acc, PSEUDOCONTACT_LINK, 0);
+ if (hContact && db_get_b(hContact, SHORT_PLUGIN_NAME, PSEUDOCONTACT_FLAG, 0))
+ while ((hEvent = db_event_last(hContact)) && !db_event_delete(hContact, hEvent))
+ ;
+}
+
DWORD ReadNotificationSettings(LPCSTR acc)
{
DWORD result = ReadCheckboxes(0, acc);
@@ -233,6 +336,12 @@ 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 76f164ce4b..02780ae2b0 100644
--- a/protocols/GTalkExt/src/notifications.h
+++ b/protocols/GTalkExt/src/notifications.h
@@ -40,4 +40,5 @@ 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 e463c0d2a6..7cf97347b8 100644
--- a/protocols/GTalkExt/src/options.cpp
+++ b/protocols/GTalkExt/src/options.cpp
@@ -43,7 +43,17 @@ void CheckControlsEnabled(HWND wnd)
BOOL PopupsEnabled = (SendDlgItemMessage(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);
@@ -63,7 +73,10 @@ DWORD ReadCheckboxes(HWND wnd, LPCSTR mod)
{
DWORD controls = db_get_dw(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);
@@ -81,9 +94,11 @@ DWORD GetCheckboxSaveValue(HWND wnd, int id)
void SaveControls(HWND wnd, LPCSTR mod)
{
- DWORD controls =
+ DWORD controls = GetCheckboxSaveValue(wnd, IDC_CLEARPSEUDOCONTACTLOG) |
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) |
@@ -111,10 +126,13 @@ 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:
@@ -217,8 +235,7 @@ INT_PTR CALLBACK PopupsOptionsDlgProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM
void AddPopupsPage(WPARAM wParam)
{
- OPTIONSDIALOGPAGE odp = {0};
- odp.cbSize = sizeof(odp);
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.ptszTitle = MAIL_NOTIFICATIONS;
odp.pfnDlgProc = PopupsOptionsDlgProc;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUPSETTINGS);
diff --git a/protocols/GTalkExt/src/options.h b/protocols/GTalkExt/src/options.h
index 2b9507b84e..ff9c2327e2 100644
--- a/protocols/GTalkExt/src/options.h
+++ b/protocols/GTalkExt/src/options.h
@@ -27,6 +27,8 @@ 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 7a5a10e63d..1b63b3c9e4 100644
--- a/protocols/GTalkExt/src/resources.h
+++ b/protocols/GTalkExt/src/resources.h
@@ -27,7 +27,10 @@
#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
diff --git a/protocols/GTalkExt/src/stdafx.h b/protocols/GTalkExt/src/stdafx.h
index 76fcb5ee0d..0a4dd456ee 100644
--- a/protocols/GTalkExt/src/stdafx.h
+++ b/protocols/GTalkExt/src/stdafx.h
@@ -65,3 +65,6 @@
#pragma warning(pop)
extern HINSTANCE g_hInst;
+
+void SetAvatar(HANDLE hContact);
+BOOL InitAvaUnit(BOOL init);