From a881be4206c532a8d7dd1d65fbeed1e1a89e84d2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 25 Mar 2013 08:26:09 +0000 Subject: last portion of cleaning before removing GtalkExt's contact git-svn-id: http://svn.miranda-ng.org/main/trunk@4184 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/GTalkExt/src/db.cpp | 6 ++-- protocols/GTalkExt/src/handlers.cpp | 7 ++-- protocols/GTalkExt/src/notifications.cpp | 61 ++++++++++++-------------------- protocols/GTalkExt/src/options.cpp | 8 ++--- 4 files changed, 34 insertions(+), 48 deletions(-) (limited to 'protocols/GTalkExt/src') diff --git a/protocols/GTalkExt/src/db.cpp b/protocols/GTalkExt/src/db.cpp index bab22c21ed..5b55a9a688 100644 --- a/protocols/GTalkExt/src/db.cpp +++ b/protocols/GTalkExt/src/db.cpp @@ -85,15 +85,15 @@ void RenewPseudocontactHandles() PROTOACCOUNT **protos; ProtoEnumAccounts(&count, &protos); for (int i = 0; i < count; i++) { - DBDeleteContactSetting(0, protos[i]->szModuleName, PSEUDOCONTACT_LINK); - DBDeleteContactSetting(0, protos[i]->szModuleName, "GMailExtNotifyContact"); // remove this + 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); - DBWriteContactSettingDword(0, proto, PSEUDOCONTACT_LINK, (DWORD)hContact); + db_set_dw(0, proto, PSEUDOCONTACT_LINK, (DWORD)hContact); } hContact = db_find_next(hContact); }; diff --git a/protocols/GTalkExt/src/handlers.cpp b/protocols/GTalkExt/src/handlers.cpp index e72a940d3e..422f627973 100644 --- a/protocols/GTalkExt/src/handlers.cpp +++ b/protocols/GTalkExt/src/handlers.cpp @@ -407,7 +407,8 @@ int AccListChanged(WPARAM wParam, LPARAM lParam) { if (PRAC_ADDED == wParam) { IJabberInterface *japi = getJabberApi(((PROTOACCOUNT*)lParam)->szModuleName); - if (japi) japi->Net()->AddSendHandler(SendHandler); + if (japi) + japi->Net()->AddSendHandler(SendHandler); } return 0; } @@ -421,10 +422,10 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) ProtoEnumAccounts(&count, &protos); for (int i = 0; i < count; i++) { IJabberInterface *japi = getJabberApi(protos[i]->szModuleName); - if (japi) japi->Net()->AddSendHandler(SendHandler); + if (japi) + japi->Net()->AddSendHandler(SendHandler); } HookOptionsInitialization(); - return 0; } \ No newline at end of file diff --git a/protocols/GTalkExt/src/notifications.cpp b/protocols/GTalkExt/src/notifications.cpp index d4c75ca665..45acc87ba8 100644 --- a/protocols/GTalkExt/src/notifications.cpp +++ b/protocols/GTalkExt/src/notifications.cpp @@ -182,7 +182,7 @@ HANDLE SetupPseudocontact(LPCTSTR jid, LPCTSTR unreadCount, LPCSTR acc, LPCTSTR 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); - DBWriteContactSettingDword(0, acc, PSEUDOCONTACT_LINK, (DWORD)result); + 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); } @@ -204,31 +204,18 @@ HANDLE SetupPseudocontact(LPCTSTR jid, LPCTSTR unreadCount, LPCSTR acc, LPCTSTR HANDLE AddCListNotification(HANDLE hContact, LPCSTR acc, POPUPDATAT *data, LPCTSTR jid, LPCTSTR url, LPCTSTR unreadCount) { - int lurl = (lstrlen(url) + 1) * sizeof(WCHAR); - LPSTR utf8 = (LPSTR)malloc(sizeof(data->lptzText) + sizeof(WCHAR) * 2 + lurl); - __try { - DBEVENTINFO dbei = {0}; - - dbei.cbBlob = WideCharToMultiByte(CP_UTF8, 0, &data->lptzText[0], -1, utf8, sizeof(data->lptzText), NULL, NULL) - 1; - - if (utf8[dbei.cbBlob - 1] != 10) { - utf8[dbei.cbBlob++] = 13; - utf8[dbei.cbBlob++] = 10; - } - - dbei.cbBlob += WideCharToMultiByte(CP_UTF8, 0, url, -1, utf8 + dbei.cbBlob, lurl, NULL, NULL); - - dbei.pBlob = (PBYTE)utf8; - dbei.cbSize = sizeof(dbei); - dbei.szModule = (LPSTR)acc; - dbei.timestamp = time(NULL); - dbei.flags = DBEF_UTF; - dbei.eventType = EVENTTYPE_MESSAGE; - return (HANDLE)CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei); - } - __finally { - free(utf8); - } + mir_ptr 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() @@ -293,21 +280,19 @@ void UnreadThreadNotification(LPCSTR acc, LPCTSTR jid, LPCTSTR url, LPCTSTR unre FormatPseudocontactDisplayName(&data.lptzContactName[0], jid, unreadCount); LPTSTR senders = (LPTSTR)malloc(SENDER_COUNT * 100 * sizeof(TCHAR)); LPTSTR currSender = senders; - __try { - for (int i = 0; i < SENDER_COUNT && mtn->senders[i].addr; i++) { - wsprintf(currSender, _T(" %s <%s>\n"), mtn->senders[i].name, mtn->senders[i].addr); - currSender += lstrlen(currSender); - } - if (ReadCheckbox(0, IDC_ADDSNIP, (DWORD)TlsGetValue(itlsSettings))) - wsprintf(&data.lptzText[0], TranslateTS(FULL_NOTIFICATION_FORMAT), mtn->subj, senders, mtn->snip); - else - wsprintf(&data.lptzText[0], TranslateTS(SHORT_NOTIFICATION_FORMAT), mtn->subj, senders); - } - __finally { - free(senders); + for (int i = 0; i < SENDER_COUNT && mtn->senders[i].addr; i++) { + wsprintf(currSender, _T(" %s <%s>\n"), mtn->senders[i].name, mtn->senders[i].addr); + currSender += lstrlen(currSender); } + if (ReadCheckbox(0, IDC_ADDSNIP, (DWORD)TlsGetValue(itlsSettings))) + wsprintf(&data.lptzText[0], TranslateTS(FULL_NOTIFICATION_FORMAT), mtn->subj, senders, mtn->snip); + else + wsprintf(&data.lptzText[0], TranslateTS(SHORT_NOTIFICATION_FORMAT), mtn->subj, senders); + + free(senders); + ShowNotification(acc, &data, jid, url, unreadCount); } diff --git a/protocols/GTalkExt/src/options.cpp b/protocols/GTalkExt/src/options.cpp index 07b533c0a2..792bc9f45c 100644 --- a/protocols/GTalkExt/src/options.cpp +++ b/protocols/GTalkExt/src/options.cpp @@ -104,7 +104,7 @@ void SaveControls(HWND wnd, LPCSTR mod) GetCheckboxSaveValue(wnd, IDC_STANDARDVIEW) | GetCheckboxSaveValue(wnd, IDC_HTMLVIEW); - DBWriteContactSettingDword(0, NOTIFY_SETTINGS_FROM_MOD_NAME, mod, controls); + db_set_dw(0, NOTIFY_SETTINGS_FROM_MOD_NAME, mod, controls); } INT_PTR CALLBACK AccOptionsDlgProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -218,16 +218,16 @@ INT_PTR CALLBACK PopupsOptionsDlgProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM case WM_NOTIFY: if (!((LPNMHDR)lParam)->idFrom && ((LPNMHDR)lParam)->code == PSN_APPLY) - DBWriteContactSettingDword(0, SHORT_PLUGIN_NAME, BACK_COLOR_SETTING, + db_set_dw(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, + db_set_dw(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)); + db_set_dw(0, SHORT_PLUGIN_NAME, TIMEOUT_SETTING, _ttoi(timeout)); } __finally { free(timeout); -- cgit v1.2.3