diff options
author | George Hazan <george.hazan@gmail.com> | 2013-03-24 19:50:44 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-03-24 19:50:44 +0000 |
commit | f6de1e36aeeeb662a04e3287b3929a07384bf510 (patch) | |
tree | de89ca1a736fe457d805d36062513427088bbf7a /protocols/GTalkExt | |
parent | 3fed56c332215dd3a753d2fc0b31616c1b270a51 (diff) |
- IJabberNetInterface::GetHandle() method added to retrieve a network handle;
- another major clutch removed from GTalkExt;
- version.rc added;
- bunch of crap removed;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@4177 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/GTalkExt')
-rw-r--r-- | protocols/GTalkExt/GTalkExt_10.vcxproj | 1 | ||||
-rw-r--r-- | protocols/GTalkExt/GTalkExt_10.vcxproj.filters | 3 | ||||
-rw-r--r-- | protocols/GTalkExt/GTalkExt_11.vcxproj | 1 | ||||
-rw-r--r-- | protocols/GTalkExt/GTalkExt_11.vcxproj.filters | 3 | ||||
-rw-r--r-- | protocols/GTalkExt/res/Version.rc | 38 | ||||
-rw-r--r-- | protocols/GTalkExt/res/settings.rc | 36 | ||||
-rw-r--r-- | protocols/GTalkExt/src/GTalkExt.cpp | 21 | ||||
-rw-r--r-- | protocols/GTalkExt/src/Version.h | 14 | ||||
-rw-r--r-- | protocols/GTalkExt/src/db.cpp | 2 | ||||
-rw-r--r-- | protocols/GTalkExt/src/inbox.cpp | 137 | ||||
-rw-r--r-- | protocols/GTalkExt/src/notifications.cpp | 57 | ||||
-rw-r--r-- | protocols/GTalkExt/src/options.cpp | 180 | ||||
-rw-r--r-- | protocols/GTalkExt/src/options.h | 3 | ||||
-rw-r--r-- | protocols/GTalkExt/src/resources.h | 7 | ||||
-rw-r--r-- | protocols/GTalkExt/src/stdafx.h | 1 | ||||
-rw-r--r-- | protocols/GTalkExt/src/tipper_items.cpp | 6 |
16 files changed, 230 insertions, 280 deletions
diff --git a/protocols/GTalkExt/GTalkExt_10.vcxproj b/protocols/GTalkExt/GTalkExt_10.vcxproj index b5d0f625cf..0972d8f3e7 100644 --- a/protocols/GTalkExt/GTalkExt_10.vcxproj +++ b/protocols/GTalkExt/GTalkExt_10.vcxproj @@ -206,6 +206,7 @@ </ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\settings.rc" />
+ <ResourceCompile Include="res\Version.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/protocols/GTalkExt/GTalkExt_10.vcxproj.filters b/protocols/GTalkExt/GTalkExt_10.vcxproj.filters index d30ac9881f..c4669a5f90 100644 --- a/protocols/GTalkExt/GTalkExt_10.vcxproj.filters +++ b/protocols/GTalkExt/GTalkExt_10.vcxproj.filters @@ -88,5 +88,8 @@ <ResourceCompile Include="res\settings.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
+ <ResourceCompile Include="res\Version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
</ItemGroup>
</Project>
\ No newline at end of file diff --git a/protocols/GTalkExt/GTalkExt_11.vcxproj b/protocols/GTalkExt/GTalkExt_11.vcxproj index 3cb0f6aaf4..935e6d1b69 100644 --- a/protocols/GTalkExt/GTalkExt_11.vcxproj +++ b/protocols/GTalkExt/GTalkExt_11.vcxproj @@ -210,6 +210,7 @@ </ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\settings.rc" />
+ <ResourceCompile Include="res\Version.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/protocols/GTalkExt/GTalkExt_11.vcxproj.filters b/protocols/GTalkExt/GTalkExt_11.vcxproj.filters index d30ac9881f..c4669a5f90 100644 --- a/protocols/GTalkExt/GTalkExt_11.vcxproj.filters +++ b/protocols/GTalkExt/GTalkExt_11.vcxproj.filters @@ -88,5 +88,8 @@ <ResourceCompile Include="res\settings.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
+ <ResourceCompile Include="res\Version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
</ItemGroup>
</Project>
\ No newline at end of file diff --git a/protocols/GTalkExt/res/Version.rc b/protocols/GTalkExt/res/Version.rc new file mode 100644 index 0000000000..5bfbab4754 --- /dev/null +++ b/protocols/GTalkExt/res/Version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script.
+//
+#ifdef APSTUDIO_INVOKED
+#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+#include "afxres.h"
+#include "..\src\version.h"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x0L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "FileDescription", __DESCRIPTION
+ VALUE "InternalName", __PLUGIN_NAME
+ VALUE "LegalCopyright", __COPYRIGHT
+ VALUE "OriginalFilename", __FILENAME
+ VALUE "ProductName", __PLUGIN_NAME
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
diff --git a/protocols/GTalkExt/res/settings.rc b/protocols/GTalkExt/res/settings.rc index 533eceaa59..0e7dbee2a6 100644 --- a/protocols/GTalkExt/res/settings.rc +++ b/protocols/GTalkExt/res/settings.rc @@ -42,41 +42,5 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1 LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
-
-
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION PLUGIN_FILE_VERSION
- PRODUCTVERSION PLUGIN_FILE_VERSION
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x40004L
- FILETYPE 0x2L
- FILESUBTYPE 0x0L
-{
- BLOCK "StringFileInfo"
- {
- BLOCK "040904b0"
- {
- VALUE "FileDescription", PLUGIN_DESCRIPTION
- VALUE "FileVersion", PLUGIN_VERSION_STRING
- VALUE "InternalName", SHORT_PLUGIN_NAME
- VALUE "LegalCopyright", COPYRIGHT_STRING
- VALUE "OriginalFilename", SHORT_PLUGIN_NAME ".dll"
- VALUE "PrivateBuild", "Yes"
- VALUE "ProductName", PLUGIN_DESCRIPTION
- VALUE "ProductVersion", PLUGIN_VERSION_STRING
- }
- }
- BLOCK "VarFileInfo"
- {
- VALUE "Translation", 0x409, 1200
- }
-}
-
IDI_POPUP ICON "PopupIcon.ico"
IDI_PSEUDOAVA PNG "pseudoava.png"
\ No newline at end of file diff --git a/protocols/GTalkExt/src/GTalkExt.cpp b/protocols/GTalkExt/src/GTalkExt.cpp index a449435cb3..e2eeb754ee 100644 --- a/protocols/GTalkExt/src/GTalkExt.cpp +++ b/protocols/GTalkExt/src/GTalkExt.cpp @@ -28,6 +28,7 @@ #include "tipper_items.h"
#include "avatar.h"
#include "menu.h"
+#include "Version.h"
int hLangpack;
HICON g_hPopupIcon = 0;
@@ -35,15 +36,16 @@ HICON g_hPopupIcon = 0; PLUGININFOEX pluginInfo =
{
sizeof(PLUGININFOEX),
- PLUGIN_DESCRIPTION,
- PLUGIN_VERSION_DWORD,
- "GTalk mail notification extensions for Jabber protocol.",
- "bems",
- "bems@vingrad.ru",
- COPYRIGHT_STRING,
- "http://miranda-ng.org/",
- UNICODE_AWARE, //doesn't replace anything built-in
- {0x08B86253, 0xEC6E, 0x4d09, { 0xB7, 0xA9, 0x64, 0xAC, 0xDF, 0x06, 0x27, 0xB8 }} //{08B86253-EC6E-4d09-B7A9-64ACDF0627B8}
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ //{08B86253-EC6E-4d09-B7A9-64ACDF0627B8}
+ {0x08B86253, 0xEC6E, 0x4d09, { 0xB7, 0xA9, 0x64, 0xAC, 0xDF, 0x06, 0x27, 0xB8 }}
};
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
@@ -100,7 +102,6 @@ extern "C" int __declspec(dllexport) Load(void) extern "C" int __declspec(dllexport) Unload(void)
{
- UnhookOptionsInitialization();
InitMenus(FALSE);
InitAvaUnit(FALSE);
return 0;
diff --git a/protocols/GTalkExt/src/Version.h b/protocols/GTalkExt/src/Version.h new file mode 100644 index 0000000000..10e6a7aa79 --- /dev/null +++ b/protocols/GTalkExt/src/Version.h @@ -0,0 +1,14 @@ +#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 0
+#define __RELEASE_NUM 1
+#define __BUILD_NUM 1
+
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+
+#define __PLUGIN_NAME "GTalk Extension"
+#define __FILENAME "GTalkExt.dll"
+#define __DESCRIPTION "GTalk extensions for Jabber protocol"
+#define __AUTHOR "bems"
+#define __AUTHOREMAIL "bems@vingrad.ru"
+#define __AUTHORWEB "http://miranda-ng.org/"
+#define __COPYRIGHT "© 2010-11 bems"
diff --git a/protocols/GTalkExt/src/db.cpp b/protocols/GTalkExt/src/db.cpp index dcdde85451..bab22c21ed 100644 --- a/protocols/GTalkExt/src/db.cpp +++ b/protocols/GTalkExt/src/db.cpp @@ -72,7 +72,7 @@ void WriteJidSetting(LPCSTR name, LPCTSTR jid, LPCTSTR setting) {
char *ansiJid = WtoA(jid);
__try {
- DBWriteContactSettingTString(0, name, ansiJid, setting);
+ db_set_ts(0, name, ansiJid, setting);
}
__finally {
free(ansiJid);
diff --git a/protocols/GTalkExt/src/inbox.cpp b/protocols/GTalkExt/src/inbox.cpp index b1c8531b9d..cff579bb4c 100644 --- a/protocols/GTalkExt/src/inbox.cpp +++ b/protocols/GTalkExt/src/inbox.cpp @@ -25,39 +25,39 @@ #include "db.h"
#include "options.h"
-static const LPTSTR COMMON_GMAIL_HOST1 = _T("gmail.com");
-static const LPTSTR COMMON_GMAIL_HOST2 = _T("googlemail.com");
+const LPTSTR COMMON_GMAIL_HOST1 = _T("gmail.com");
+const LPTSTR COMMON_GMAIL_HOST2 = _T("googlemail.com");
-static const LPSTR AUTH_REQUEST_URL = "https://www.google.com/accounts/ClientAuth";
-static const LPSTR AUTH_REQUEST_PARAMS = "Email=%s&Passwd=%s&"
+const LPSTR AUTH_REQUEST_URL = "https://www.google.com/accounts/ClientAuth";
+const LPSTR AUTH_REQUEST_PARAMS = "Email=%s&Passwd=%s&"
"accountType=HOSTED_OR_GOOGLE&"
"skipvpage=true&"
"PersistentCookie=false";
-static const LPSTR ISSUE_TOKEN_REQUEST_URL = "https://www.google.com/accounts/IssueAuthToken";
-static const LPSTR ISSUE_TOKEN_REQUEST_PARAMS = "SID=%s&LSID=%s&"
+const LPSTR ISSUE_TOKEN_REQUEST_URL = "https://www.google.com/accounts/IssueAuthToken";
+const LPSTR ISSUE_TOKEN_REQUEST_PARAMS = "SID=%s&LSID=%s&"
"Session=true&"
"skipvpage=true&"
"service=gaia";
-static const LPSTR TOKEN_AUTH_URL = "https://www.google.com/accounts/TokenAuth?"\
+const LPSTR TOKEN_AUTH_URL = "https://www.google.com/accounts/TokenAuth?"\
"auth=%s&"
"service=mail&"
"continue=%s&"
"source=googletalk";
-static const NETLIBHTTPHEADER HEADER_URL_ENCODED = {"Content-Type", "application/x-www-form-urlencoded"};
-static const int HTTP_OK = 200;
+const NETLIBHTTPHEADER HEADER_URL_ENCODED = {"Content-Type", "application/x-www-form-urlencoded"};
+const int HTTP_OK = 200;
-static const LPSTR SID_KEY_NAME = "SID=";
-static const LPSTR LSID_KEY_NAME = "LSID=";
+const LPSTR SID_KEY_NAME = "SID=";
+const LPSTR LSID_KEY_NAME = "LSID=";
-static const LPSTR LOGIN_PASS_SETTING_NAME = "LoginPassword";
+const LPSTR LOGIN_PASS_SETTING_NAME = "LoginPassword";
-static const LPTSTR INBOX_URL_FORMAT = _T("https://mail.google.com/%s%s/#inbox");
+const LPTSTR INBOX_URL_FORMAT = _T("https://mail.google.com/%s%s/#inbox");
-static const DWORD SIZE_OF_JABBER_OPTIONS = 243 * sizeof(DWORD);
+const DWORD SIZE_OF_JABBER_OPTIONS = 243 * sizeof(DWORD);
// 3 lines from netlib.h
#define GetNetlibHandleType(h) (h?*(int*)h:NLH_INVALID)
@@ -211,47 +211,24 @@ struct OPEN_URL_HEADER { HANDLE FindNetUserHandle(LPCSTR acc)
{
IJabberInterface *ji = getJabberApi(acc);
- if (!ji) return NULL;
+ if (!ji)
+ return NULL;
- PBYTE m_psProto = *(PBYTE*)((PBYTE)ji + sizeof(*ji)); // see CJabberInterface in jabber_proto.h
-
- PHANDLE pResult = (PHANDLE)(m_psProto + // see CJabberProto in jabber_proto.h
- sizeof(PVOID) + // skip vtable ptr
- sizeof(PVOID) + // skip m_ThreadInfo
- SIZE_OF_JABBER_OPTIONS); // skip m_options
-
- for (int i=0; i < 100; i++) {
- __try {
- if (GetNetlibHandleType(*pResult) == NLH_USER)
- break;
- }
- __except (EXCEPTION_EXECUTE_HANDLER){
- }
- pResult++;
- }
-
- assert(GetNetlibHandleType(*pResult) == NLH_USER);
- return *pResult;
+ return ji->Net()->GetHandle();
}
void OpenUrlThread(void *param)
{
OPEN_URL_HEADER* data = (OPEN_URL_HEADER*)param;
- __try {
- HANDLE hUser = FindNetUserHandle(data->acc);
- if (!hUser || !AuthAndOpen(hUser, data->url, data->mailbox, data->pwd))
- ShellExecuteA(0, NULL, data->url, NULL, NULL, SW_SHOW);
- }
- __finally {
- free(data);
- }
+ HANDLE hUser = FindNetUserHandle(data->acc);
+ if (!hUser || !AuthAndOpen(hUser, data->url, data->mailbox, data->pwd))
+ CallService(MS_UTILS_OPENURL, 0, (LPARAM)data->url);
}
void __forceinline DecryptString(LPSTR str, int len)
{
- for (--len; len >= 0; len--)
- {
+ for (--len; len >= 0; len--) {
const char c = str[len] ^ 0xc3;
if (c) str[len] = c;
}
@@ -312,7 +289,8 @@ BOOL OpenUrlWithAuth(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url) }
data->pwd = data->mailbox + mailboxLen;
- if (!GetMailboxPwd(acc, mailbox, &data->pwd, pwdLen)) return FALSE;
+ if (!GetMailboxPwd(acc, mailbox, &data->pwd, pwdLen))
+ return FALSE;
data->acc = acc;
@@ -328,63 +306,38 @@ BOOL OpenUrlWithAuth(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url) static void ShellExecuteThread(PVOID param)
{
- __try {
- ShellExecute(0, NULL, (LPTSTR)param, NULL, NULL, SW_SHOW);
- }
- __finally {
- free(param);
- }
-}
-
-void StartShellExecuteThread(LPCTSTR url)
-{
- mir_forkthread(ShellExecuteThread, _tcsdup(url));
+ CallService(MS_UTILS_OPENURL, OUF_TCHAR, (LPARAM)param);
+ mir_free(param);
}
void OpenUrl(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url)
{
extern DWORD itlsSettings;
- if (!ReadCheckbox(0, IDC_AUTHONMAILBOX, (DWORD)TlsGetValue(itlsSettings)) ||
- !OpenUrlWithAuth(acc, mailbox, url))
- StartShellExecuteThread(url);
-}
-
-LPTSTR CraftInboxUrl(LPTSTR jid)
-{
- LPTSTR host = _tcsstr(jid, _T("@")) + 1;
-
- LPTSTR result = (LPTSTR)malloc((lstrlen(INBOX_URL_FORMAT) + 1 + lstrlen(jid)) * sizeof(TCHAR));
- __try {
- if (lstrcmpi(host, COMMON_GMAIL_HOST1) && lstrcmpi(host, COMMON_GMAIL_HOST2))
- wsprintf(result, INBOX_URL_FORMAT, _T("a/"), host); // hosted
- else
- wsprintf(result, INBOX_URL_FORMAT, NULL, _T("mail")); // common
- }
- __except (
- free(result),
- EXCEPTION_CONTINUE_SEARCH
- ) {}
-
- return result;
+ if (!ReadCheckbox(0, IDC_AUTHONMAILBOX, (DWORD)TlsGetValue(itlsSettings)) || !OpenUrlWithAuth(acc, mailbox, url))
+ mir_forkthread(ShellExecuteThread, mir_tstrdup(url));
}
void OpenContactInbox(HANDLE hContact)
{
LPSTR acc = GetContactProto(hContact);
- if (!acc) return;
+ if (!acc)
+ return;
DBVARIANT dbv;
- if (!DBGetContactSettingTString(0, acc, "jid", &dbv))
- __try {
- LPTSTR url = CraftInboxUrl(dbv.ptszVal);
- __try {
- OpenUrl(acc, dbv.ptszVal, url);
- }
- __finally {
- free(url);
- }
- }
- __finally {
- DBFreeVariant(&dbv);
- }
+ if ( DBGetContactSettingTString(0, acc, "jid", &dbv))
+ return;
+
+ LPTSTR host = _tcschr(dbv.ptszVal, '@');
+ if (!host)
+ return;
+ *host++ = 0;
+
+ TCHAR buf[1024];
+ if (lstrcmpi(host, COMMON_GMAIL_HOST1) && lstrcmpi(host, COMMON_GMAIL_HOST2))
+ 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);
+
+ DBFreeVariant(&dbv);
}
diff --git a/protocols/GTalkExt/src/notifications.cpp b/protocols/GTalkExt/src/notifications.cpp index ba9b9b14de..d4c75ca665 100644 --- a/protocols/GTalkExt/src/notifications.cpp +++ b/protocols/GTalkExt/src/notifications.cpp @@ -120,18 +120,13 @@ LRESULT CALLBACK PopupProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) UnhookEvent(hHook);
}
- __try {
- 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);
- }
- }
- __finally {
- RemoveProp(wnd, PLUGIN_DATA_PROP_NAME);
- free(ppdh);
+ 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;
case WM_LBUTTONUP:
@@ -158,20 +153,18 @@ static bool DoAddPopup(POPUPDATAT *data) {
bool result = false;
HWND handle = 0;
- __try {
- if (ReadCheckbox(0, IDC_POPUPSINFULLSCREEN, (DWORD)TlsGetValue(itlsSettings))) {
- handle = CreateWindowEx(WS_EX_TOOLWINDOW, TEMP_WINDOW_CLASS_NAME, NULL, WS_OVERLAPPED | WS_VISIBLE,
+
+ if (ReadCheckbox(0, IDC_POPUPSINFULLSCREEN, (DWORD)TlsGetValue(itlsSettings))) {
+ handle = CreateWindowEx(WS_EX_TOOLWINDOW, TEMP_WINDOW_CLASS_NAME, NULL, WS_OVERLAPPED | WS_VISIBLE,
-100, -100, 10, 10, NULL, NULL, NULL, NULL);
- if (handle) {
- ShowWindow(handle, SW_MINIMIZE);
- ShowWindow(handle, SW_RESTORE);
- }
+ if (handle) {
+ ShowWindow(handle, SW_MINIMIZE);
+ ShowWindow(handle, SW_RESTORE);
}
- result = PUAddPopUpT(data) == 0;
- }
- __finally {
- if (handle) DestroyWindow(handle);
}
+ result = PUAddPopUpT(data) == 0;
+
+ if (handle) DestroyWindow(handle);
return result;
}
@@ -196,21 +189,15 @@ HANDLE SetupPseudocontact(LPCTSTR jid, LPCTSTR unreadCount, LPCSTR acc, LPCTSTR SetAvatar(result);
- BOOL allocateName = !displayName;
- __try {
- if (allocateName) {
- displayName = (LPCTSTR)malloc((lstrlen(jid) + lstrlen(unreadCount) + 3 + 1) * sizeof(TCHAR));
- FormatPseudocontactDisplayName((LPTSTR)displayName, jid, unreadCount);
- }
-
- DBWriteContactSettingTString(result, CLIST_MODULE_NAME, CONTACT_DISPLAY_NAME_SETTING, displayName);
- }
- __finally {
- if (allocateName) free((PVOID)displayName);
+ 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);
- DBWriteContactSettingTString(result, CLIST_MODULE_NAME, STATUS_MSG_SETTING, TranslateTS(MAIL_NOTIFICATIONS));
- DBWriteContactSettingTString(result, SHORT_PLUGIN_NAME, UNREAD_THREADS_SETTING, unreadCount);
+ 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;
}
diff --git a/protocols/GTalkExt/src/options.cpp b/protocols/GTalkExt/src/options.cpp index 810dead8ec..07b533c0a2 100644 --- a/protocols/GTalkExt/src/options.cpp +++ b/protocols/GTalkExt/src/options.cpp @@ -40,7 +40,6 @@ static const LPTSTR TEST_LETTER_SNIP = LPGENT("* No metaprogramming except preprocessor macros\n")
LPGENT("* No exceptions");
-HANDLE hOptionsHook = 0;
extern HINSTANCE g_hInst;
void CheckControlsEnabled(HWND wnd)
@@ -111,41 +110,41 @@ void SaveControls(HWND wnd, LPCSTR mod) INT_PTR CALLBACK AccOptionsDlgProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
- case WM_INITDIALOG:
- SetProp(wnd, ACCOUNT_PROP_NAME, (HANDLE)lParam);
- TranslateDialogDefault(wnd);
- ReadCheckboxes(wnd, (LPCSTR)lParam);
- CheckControlsEnabled(wnd);
- break;
-
- case WM_CTLCOLORSTATIC:
- if (GetDlgItem(wnd, IDC_WARNBAR) == (HWND)lParam)
- return (INT_PTR)CreateSolidBrush(0x55AAFF); // orange
- break;
-
- 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:
- case IDC_STANDARDVIEW:
- case IDC_HTMLVIEW:
- if (HIWORD(wParam) == BN_CLICKED) PropSheet_Changed(GetParent(wnd), wnd);
- }
- break;
-
- case WM_NOTIFY:
- if (!((LPNMHDR)lParam)->idFrom && ((LPNMHDR)lParam)->code == PSN_APPLY)
- SaveControls(wnd, (LPCSTR)GetProp(wnd, ACCOUNT_PROP_NAME));
- break;
+ case WM_INITDIALOG:
+ SetProp(wnd, ACCOUNT_PROP_NAME, (HANDLE)lParam);
+ TranslateDialogDefault(wnd);
+ ReadCheckboxes(wnd, (LPCSTR)lParam);
+ CheckControlsEnabled(wnd);
+ break;
+
+ case WM_CTLCOLORSTATIC:
+ if (GetDlgItem(wnd, IDC_WARNBAR) == (HWND)lParam)
+ return (INT_PTR)CreateSolidBrush(0x55AAFF); // orange
+ break;
+
+ 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:
+ case IDC_STANDARDVIEW:
+ case IDC_HTMLVIEW:
+ if (HIWORD(wParam) == BN_CLICKED) PropSheet_Changed(GetParent(wnd), wnd);
+ }
+ break;
+
+ case WM_NOTIFY:
+ if (!((LPNMHDR)lParam)->idFrom && ((LPNMHDR)lParam)->code == PSN_APPLY)
+ SaveControls(wnd, (LPCSTR)GetProp(wnd, ACCOUNT_PROP_NAME));
+ break;
}
return 0;
}
@@ -181,58 +180,59 @@ void ShowTestPopup(HWND wnd) INT_PTR CALLBACK PopupsOptionsDlgProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(wnd);
- SendMessage(GetDlgItem(wnd, IDC_BACKCOLORPICKER), CPM_SETCOLOUR, 0,
- (LPARAM)DBGetContactSettingDword(0, SHORT_PLUGIN_NAME, BACK_COLOR_SETTING, 0));
- SendMessage(GetDlgItem(wnd, IDC_TEXTCOLORPICKER), CPM_SETCOLOUR, 0,
- (LPARAM)DBGetContactSettingDword(0, SHORT_PLUGIN_NAME, TEXT_COLOR_SETTING, 0));
-
- {LPTSTR timeout = (LPTSTR)malloc(11 * sizeof(TCHAR));
+ case WM_INITDIALOG:
+ TranslateDialogDefault(wnd);
+ SendMessage(GetDlgItem(wnd, IDC_BACKCOLORPICKER), CPM_SETCOLOUR, 0,
+ (LPARAM)DBGetContactSettingDword(0, SHORT_PLUGIN_NAME, BACK_COLOR_SETTING, 0));
+ SendMessage(GetDlgItem(wnd, IDC_TEXTCOLORPICKER), CPM_SETCOLOUR, 0,
+ (LPARAM)DBGetContactSettingDword(0, SHORT_PLUGIN_NAME, TEXT_COLOR_SETTING, 0));
+ {
+ LPTSTR timeout = (LPTSTR)malloc(11 * sizeof(TCHAR));
__try {
wsprintf(timeout, _T("%d"), DBGetContactSettingDword(0, SHORT_PLUGIN_NAME, TIMEOUT_SETTING, 0));
SendMessage(GetDlgItem(wnd, IDC_TIMEOUTEDIT), WM_SETTEXT, 0, (LPARAM)timeout);
}
__finally {
free(timeout);
- }}
-
- SetProp(wnd, DIALOG_INITIALIZED_PROP_NAME, (HANDLE)TRUE);
- break;
-
- case WM_COMMAND:
- if (LOWORD(wParam) == IDC_TESTBUTTON && HIWORD(wParam) == BN_CLICKED)
- ShowTestPopup(wnd);
-
- if (GetProp(wnd, DIALOG_INITIALIZED_PROP_NAME))
- switch (LOWORD(wParam)) {
- case IDC_BACKCOLORPICKER:
- case IDC_TEXTCOLORPICKER:
- if (HIWORD(wParam) == CPN_COLOURCHANGED) PropSheet_Changed(GetParent(wnd), wnd);
- break;
-
- case IDC_TIMEOUTEDIT:
- if (HIWORD(wParam) == EN_CHANGE) PropSheet_Changed(GetParent(wnd), wnd);
- }
- break;
-
- case WM_NOTIFY:
- if (!((LPNMHDR)lParam)->idFrom && ((LPNMHDR)lParam)->code == PSN_APPLY)
- DBWriteContactSettingDword(0, SHORT_PLUGIN_NAME, BACK_COLOR_SETTING,
- (DWORD)SendMessage(GetDlgItem(wnd, IDC_BACKCOLORPICKER), CPM_GETCOLOUR, 0, 0));
- DBWriteContactSettingDword(0, SHORT_PLUGIN_NAME, TEXT_COLOR_SETTING,
- (DWORD)SendMessage(GetDlgItem(wnd, IDC_TEXTCOLORPICKER), CPM_GETCOLOUR, 0, 0));
-
- int len = SendMessage(GetDlgItem(wnd, IDC_TIMEOUTEDIT), WM_GETTEXTLENGTH, 0, 0) + 1;
- LPTSTR timeout = (LPTSTR)malloc(len * sizeof(TCHAR));
- __try {
- SendMessage(GetDlgItem(wnd, IDC_TIMEOUTEDIT), WM_GETTEXT, len, (LPARAM)timeout);
- DBWriteContactSettingDword(0, SHORT_PLUGIN_NAME, TIMEOUT_SETTING, _ttoi(timeout));
- }
- __finally {
- free(timeout);
}
- break;
+ }
+
+ SetProp(wnd, DIALOG_INITIALIZED_PROP_NAME, (HANDLE)TRUE);
+ break;
+
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDC_TESTBUTTON && HIWORD(wParam) == BN_CLICKED)
+ ShowTestPopup(wnd);
+
+ if (GetProp(wnd, DIALOG_INITIALIZED_PROP_NAME))
+ switch (LOWORD(wParam)) {
+ case IDC_BACKCOLORPICKER:
+ case IDC_TEXTCOLORPICKER:
+ if (HIWORD(wParam) == CPN_COLOURCHANGED) PropSheet_Changed(GetParent(wnd), wnd);
+ break;
+
+ case IDC_TIMEOUTEDIT:
+ if (HIWORD(wParam) == EN_CHANGE) PropSheet_Changed(GetParent(wnd), wnd);
+ }
+ break;
+
+ case WM_NOTIFY:
+ if (!((LPNMHDR)lParam)->idFrom && ((LPNMHDR)lParam)->code == PSN_APPLY)
+ DBWriteContactSettingDword(0, SHORT_PLUGIN_NAME, BACK_COLOR_SETTING,
+ (DWORD)SendMessage(GetDlgItem(wnd, IDC_BACKCOLORPICKER), CPM_GETCOLOUR, 0, 0));
+ DBWriteContactSettingDword(0, SHORT_PLUGIN_NAME, TEXT_COLOR_SETTING,
+ (DWORD)SendMessage(GetDlgItem(wnd, IDC_TEXTCOLORPICKER), CPM_GETCOLOUR, 0, 0));
+
+ int len = SendMessage(GetDlgItem(wnd, IDC_TIMEOUTEDIT), WM_GETTEXTLENGTH, 0, 0) + 1;
+ LPTSTR timeout = (LPTSTR)malloc(len * sizeof(TCHAR));
+ __try {
+ SendMessage(GetDlgItem(wnd, IDC_TIMEOUTEDIT), WM_GETTEXT, len, (LPARAM)timeout);
+ DBWriteContactSettingDword(0, SHORT_PLUGIN_NAME, TIMEOUT_SETTING, _ttoi(timeout));
+ }
+ __finally {
+ free(timeout);
+ }
+ break;
}
return 0;
}
@@ -253,8 +253,7 @@ void AddPopupsPage(WPARAM wParam) void AddAccPage(LPTSTR acc, LPCSTR mod, WPARAM wParam)
{
- OPTIONSDIALOGPAGE odp = {0};
- odp.cbSize = sizeof(odp);
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.ptszTitle = acc;
odp.pfnDlgProc = AccOptionsDlgProc;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_MAILSETTINGS);
@@ -273,21 +272,14 @@ int OptionsInitialization(WPARAM wParam, LPARAM lParam) PROTOACCOUNT **accs;
CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&count, (LPARAM)&accs);
for (int i = 0; i < count; i++)
- if (getJabberApi(accs[i]->szModuleName)) AddAccPage(accs[i]->tszAccountName, accs[i]->szModuleName, wParam);
+ if ( getJabberApi(accs[i]->szModuleName))
+ AddAccPage(accs[i]->tszAccountName, accs[i]->szModuleName, wParam);
if (ServiceExists(MS_POPUP_ADDPOPUPT)) AddPopupsPage(wParam);
return FALSE;
}
-BOOL HookOptionsInitialization()
+void HookOptionsInitialization()
{
- return (hOptionsHook = HookEvent(ME_OPT_INITIALISE, OptionsInitialization)) != 0;
+ HookEvent(ME_OPT_INITIALISE, OptionsInitialization);
}
-
-void UnhookOptionsInitialization()
-{
- if (hOptionsHook) {
- UnhookEvent(hOptionsHook);
- hOptionsHook = 0;
- }
-}
\ No newline at end of file diff --git a/protocols/GTalkExt/src/options.h b/protocols/GTalkExt/src/options.h index 2b0c215dd3..ff9c2327e2 100644 --- a/protocols/GTalkExt/src/options.h +++ b/protocols/GTalkExt/src/options.h @@ -33,7 +33,6 @@ static const LPSTR BACK_COLOR_SETTING = "BackColor"; static const LPSTR TEXT_COLOR_SETTING = "TextColor";
static const LPSTR TIMEOUT_SETTING = "Timeout";
-BOOL HookOptionsInitialization();
-void UnhookOptionsInitialization();
+void HookOptionsInitialization();
DWORD ReadCheckboxes(HWND wnd, LPCSTR mod);
BOOL ReadCheckbox(HWND wnd, int id, DWORD controls);
\ No newline at end of file diff --git a/protocols/GTalkExt/src/resources.h b/protocols/GTalkExt/src/resources.h index 547a3c7ee2..1b63b3c9e4 100644 --- a/protocols/GTalkExt/src/resources.h +++ b/protocols/GTalkExt/src/resources.h @@ -57,10 +57,3 @@ #define IDI_POPUP 3001
#define IDI_PSEUDOAVA 3002
-
-#define PLUGIN_VERSION_STRING "0.0.0.20 BETA"
-#define PLUGIN_FILE_VERSION 0, 0, 0, 20
-#define PLUGIN_VERSION_DWORD PLUGIN_MAKE_VERSION(0, 0, 0, 20)
-
-#define PLUGIN_DESCRIPTION "GTalk extensions for Jabber protocol"
-#define COPYRIGHT_STRING "2010, 11 bems"
diff --git a/protocols/GTalkExt/src/stdafx.h b/protocols/GTalkExt/src/stdafx.h index 7e272e900f..d89c4d59e7 100644 --- a/protocols/GTalkExt/src/stdafx.h +++ b/protocols/GTalkExt/src/stdafx.h @@ -61,6 +61,7 @@ #include <m_clist.h>
#include <m_avatars.h>
#include <m_netlib.h>
+#include <win2k.h>
#pragma warning(pop)
#if _MSC_VER < 1400
diff --git a/protocols/GTalkExt/src/tipper_items.cpp b/protocols/GTalkExt/src/tipper_items.cpp index 5483f82aa3..cacdf5878e 100644 --- a/protocols/GTalkExt/src/tipper_items.cpp +++ b/protocols/GTalkExt/src/tipper_items.cpp @@ -87,8 +87,8 @@ void SetLabelProp(int index, LPSTR setting) __try {
if (!lstrcmp(dbv1.ptszVal, dbv2.ptszVal)) {
LPTSTR label = TranslateTS(UNREAD_THREADS_LABEL);
- DBWriteContactSettingTString(0, SHORT_PLUGIN_NAME, LAST_WRITTEN_LABEL_SETTING, label);
- DBWriteContactSettingTString(0, TIPPER_ITEMS_MOD_NAME, setting, label);
+ db_set_ts(0, SHORT_PLUGIN_NAME, LAST_WRITTEN_LABEL_SETTING, label);
+ db_set_ts(0, TIPPER_ITEMS_MOD_NAME, setting, label);
}
}
__finally {
@@ -137,7 +137,7 @@ void AddTipperItem() LPTSTR label = TranslateTS(UNREAD_THREADS_LABEL);
- DBWriteContactSettingTString(0, SHORT_PLUGIN_NAME, LAST_WRITTEN_LABEL_SETTING, label);
+ db_set_ts(0, SHORT_PLUGIN_NAME, LAST_WRITTEN_LABEL_SETTING, label);
WRITE_TIPPER_PROP(TString, 0, label);
WRITE_TIPPER_PROP(Byte, 1, 0);
|