From 1042cf12dbcf9c8a6d413326e81d821715538938 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 21 Mar 2013 08:55:26 +0000 Subject: plugin unicoded git-svn-id: http://svn.miranda-ng.org/main/trunk@4136 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/BuddyPounce/src/dialog.cpp | 218 ++++++++++++++++++------------------- plugins/BuddyPounce/src/headers.h | 19 ++-- plugins/BuddyPounce/src/main.cpp | 71 ++++++------ plugins/BuddyPounce/src/resource.h | 4 +- 4 files changed, 155 insertions(+), 157 deletions(-) (limited to 'plugins/BuddyPounce/src') diff --git a/plugins/BuddyPounce/src/dialog.cpp b/plugins/BuddyPounce/src/dialog.cpp index 76cb17a37c..332d46fe74 100644 --- a/plugins/BuddyPounce/src/dialog.cpp +++ b/plugins/BuddyPounce/src/dialog.cpp @@ -2,12 +2,12 @@ void populateSettingsList(HWND hwnd2List) { - SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)Translate("Send If My Status Is...")); - SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)Translate("Send If They Change Status to...")); - SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)"----------------------------"); - SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)Translate("Reuse Pounce")); - SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)Translate("Give Up delay")); - SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)Translate("Confirmation Window")); + SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)TranslateT("Send If My Status Is...")); + SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)TranslateT("Send If They Change Status to...")); + SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)_T("----------------------------")); + SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)TranslateT("Reuse Pounce")); + SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)TranslateT("Give Up delay")); + SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)TranslateT("Confirmation Window")); // SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)"----------------------------")); // SendMessage(hwnd2List, LB_ADDSTRING, 0, (LPARAM)Translate("Send a File")); } @@ -34,7 +34,7 @@ void populateContacts(HANDLE BPhContact,HWND hwnd2CB) void saveLastSetting(HANDLE hContact, HWND hwnd) { - char number[8], string[1024]; + TCHAR number[8], string[1024]; switch (DBGetContactSettingByte(hContact, modname, "LastSetting", 2)) // nothing to do { case 0: // Send If My Status Is... @@ -46,24 +46,24 @@ void saveLastSetting(HANDLE hContact, HWND hwnd) break; case 3: // Reuse Pounce GetDlgItemText(hwnd, IDC_SETTINGNUMBER, number, 8); - DBWriteContactSettingByte(hContact, modname, "Reuse", (BYTE)atoi(number)); + DBWriteContactSettingByte(hContact, modname, "Reuse", (BYTE)_ttoi(number)); break; case 4: // Give Up delay GetDlgItemText(hwnd, IDC_SETTINGNUMBER, number, 8); - DBWriteContactSettingByte(hContact, modname, "GiveUpDays", (BYTE)atoi(number)); + DBWriteContactSettingByte(hContact, modname, "GiveUpDays", (BYTE)_ttoi(number)); { time_t today = time(NULL); - DBWriteContactSettingDword(hContact, modname, "GiveUpDate", (DWORD)(atoi(number)*SECONDSINADAY)); + DBWriteContactSettingDword(hContact, modname, "GiveUpDate", (DWORD)(_ttoi(number)*SECONDSINADAY)); } break; case 5: // confirm window GetDlgItemText(hwnd, IDC_SETTINGNUMBER, number, 8); - DBWriteContactSettingByte(hContact, modname, "ConfirmTimeout", (BYTE)atoi(number)); + DBWriteContactSettingByte(hContact, modname, "ConfirmTimeout", (BYTE)_ttoi(number)); break; case 7: // send a file GetDlgItemText(hwnd, IDC_SETTINGTEXT, string, 1024); - DBWriteContactSettingString(hContact, modname, "FileToSend", string); + DBWriteContactSettingTString(hContact, modname, "FileToSend", string); break; } } @@ -81,10 +81,10 @@ void hideAll(HWND hwnd) void getDefaultMessage(HWND hwnd, UINT control, HANDLE hContact) { DBVARIANT dbv; - if (!DBGetContactSetting(hContact,modname, "PounceMsg", &dbv)) - SetDlgItemText(hwnd, control, dbv.pszVal); - else if (!DBGetContactSetting(NULL,modname, "PounceMsg", &dbv)) - SetDlgItemText(hwnd, control, dbv.pszVal); + if (!DBGetContactSettingTString(hContact, modname, "PounceMsg", &dbv)) + SetDlgItemText(hwnd, control, dbv.ptszVal); + else if (!DBGetContactSettingTString(NULL, modname, "PounceMsg", &dbv)) + SetDlgItemText(hwnd, control, dbv.ptszVal); DBFreeVariant(&dbv); } INT_PTR CALLBACK StatusModesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -106,7 +106,7 @@ INT_PTR CALLBACK StatusModesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l case IDCANCEL: { struct windowInfo *wi = (struct windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - char type[32]; + TCHAR type[32]; int flag = 0; GetDlgItemText(hwnd, IDC_CHECK1, type, 32); flag = (IsDlgButtonChecked(hwnd, IDC_CHECK1)) @@ -119,7 +119,7 @@ INT_PTR CALLBACK StatusModesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l |(IsDlgButtonChecked(hwnd, IDC_CHECK8)<<7) |(IsDlgButtonChecked(hwnd, IDC_CHECK9)<<8) |(IsDlgButtonChecked(hwnd, IDC_CHECK10)<<9); - if (!strcmp(type, "Any")) + if (!_tcscmp(type, _T("Any"))) { if (LOWORD(wParam) == IDOK) DBWriteContactSettingWord(wi->hContact, modname, "SendIfMyStatusIsFLAG", (WORD)flag); @@ -151,17 +151,17 @@ void statusModes(struct windowInfo *wi, int myStatusMode) // myStatusMode=1 send { hwnd = wi->SendIfMy = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_STATUSMODES), 0, StatusModesDlgProc, (LPARAM)wi); statusFlag = DBGetContactSettingWord(wi->hContact, modname, "SendIfMyStatusIsFLAG", 0); - SetWindowText(hwnd, Translate("Send If My Status Is")); - SetDlgItemText(hwnd, IDC_CHECK1, Translate("Any")); - SetDlgItemText(hwnd, IDC_CHECK2, Translate("Online")); - SetDlgItemText(hwnd, IDC_CHECK3, Translate("Away")); - SetDlgItemText(hwnd, IDC_CHECK4, Translate("NA")); - SetDlgItemText(hwnd, IDC_CHECK5, Translate("Occupied")); - SetDlgItemText(hwnd, IDC_CHECK6, Translate("DND")); - SetDlgItemText(hwnd, IDC_CHECK7, Translate("Free For Chat")); - SetDlgItemText(hwnd, IDC_CHECK8, Translate("Invisible")); - SetDlgItemText(hwnd, IDC_CHECK9, Translate("On The Phone")); - SetDlgItemText(hwnd, IDC_CHECK10, Translate("Out To Lunch")); + SetWindowText(hwnd, TranslateT("Send If My Status Is")); + SetDlgItemText(hwnd, IDC_CHECK1, TranslateT("Any")); + SetDlgItemText(hwnd, IDC_CHECK2, TranslateT("Online")); + SetDlgItemText(hwnd, IDC_CHECK3, TranslateT("Away")); + SetDlgItemText(hwnd, IDC_CHECK4, TranslateT("NA")); + SetDlgItemText(hwnd, IDC_CHECK5, TranslateT("Occupied")); + SetDlgItemText(hwnd, IDC_CHECK6, TranslateT("DND")); + SetDlgItemText(hwnd, IDC_CHECK7, TranslateT("Free For Chat")); + SetDlgItemText(hwnd, IDC_CHECK8, TranslateT("Invisible")); + SetDlgItemText(hwnd, IDC_CHECK9, TranslateT("On The Phone")); + SetDlgItemText(hwnd, IDC_CHECK10, TranslateT("Out To Lunch")); } } else @@ -171,17 +171,17 @@ void statusModes(struct windowInfo *wi, int myStatusMode) // myStatusMode=1 send { hwnd = wi->SendWhenThey = CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_STATUSMODES),0,StatusModesDlgProc, (LPARAM)wi); statusFlag = DBGetContactSettingWord(wi->hContact, modname, "SendIfTheirStatusIsFLAG", 0); - SetWindowText(hwnd, Translate("Send If Their Status changes")); - SetDlgItemText(hwnd, IDC_CHECK1, Translate("From Offline")); - SetDlgItemText(hwnd, IDC_CHECK2, Translate("To Online")); - SetDlgItemText(hwnd, IDC_CHECK3, Translate("To Away")); - SetDlgItemText(hwnd, IDC_CHECK4, Translate("To NA")); - SetDlgItemText(hwnd, IDC_CHECK5, Translate("To Occupied")); - SetDlgItemText(hwnd, IDC_CHECK6, Translate("To DND")); - SetDlgItemText(hwnd, IDC_CHECK7, Translate("To Free For Chat")); - SetDlgItemText(hwnd, IDC_CHECK8, Translate("To Invisible")); - SetDlgItemText(hwnd, IDC_CHECK9, Translate("To On The Phone")); - SetDlgItemText(hwnd, IDC_CHECK10, Translate("To Out To Lunch")); + SetWindowText(hwnd, TranslateT("Send If Their Status changes")); + SetDlgItemText(hwnd, IDC_CHECK1, TranslateT("From Offline")); + SetDlgItemText(hwnd, IDC_CHECK2, TranslateT("To Online")); + SetDlgItemText(hwnd, IDC_CHECK3, TranslateT("To Away")); + SetDlgItemText(hwnd, IDC_CHECK4, TranslateT("To NA")); + SetDlgItemText(hwnd, IDC_CHECK5, TranslateT("To Occupied")); + SetDlgItemText(hwnd, IDC_CHECK6, TranslateT("To DND")); + SetDlgItemText(hwnd, IDC_CHECK7, TranslateT("To Free For Chat")); + SetDlgItemText(hwnd, IDC_CHECK8, TranslateT("To Invisible")); + SetDlgItemText(hwnd, IDC_CHECK9, TranslateT("To On The Phone")); + SetDlgItemText(hwnd, IDC_CHECK10, TranslateT("To Out To Lunch")); } } CheckDlgButton(hwnd, IDC_CHECK1, statusFlag&ANY); @@ -215,12 +215,12 @@ INT_PTR CALLBACK BuddyPounceSimpleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LP case WM_INITDIALOG: { HANDLE hContact = (HANDLE)lParam; - char msg[1024]; + TCHAR msg[1024]; TranslateDialogDefault(hwnd); SetWindowLongPtr(hwnd, GWLP_USERDATA, (LPARAM)lParam); getDefaultMessage(hwnd, IDC_MESSAGE, hContact); - _snprintf(msg, 1024, Translate("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); SetDlgItemText(hwnd, GRP_MSG, msg); } @@ -233,9 +233,9 @@ INT_PTR CALLBACK BuddyPounceSimpleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LP if (HIWORD(wParam) == EN_CHANGE) { int length; - char msg[1024]; + TCHAR msg[1024]; length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)); - _snprintf(msg, 1024, Translate("The Message (%d Characters)"), length); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("The Message (%d Characters)"), length); SetDlgItemText(hwnd, GRP_MSG, msg); } } @@ -244,13 +244,13 @@ INT_PTR CALLBACK BuddyPounceSimpleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LP // fall through case IDOK: { - char *text; + TCHAR *text; HANDLE hContact = (HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA); - int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))+1; + int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)) + 1; if (length>1) { - text = (char*)malloc(length); - if (!text) { msg("Couldnt Allocate enough memory",""); break; } + text = (TCHAR*)malloc(length*sizeof(TCHAR)); + if (!text) { msg(TranslateT("Couldnt Allocate enough memory"), _T("")); break; } GetDlgItemText(hwnd, IDC_MESSAGE, text, length); } @@ -275,15 +275,15 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l case WM_INITDIALOG: { struct windowInfo *wi = (struct windowInfo *)malloc(sizeof(struct windowInfo)); - char msg[1024]; - if (!wi) { msg("error......","Buddy Pounce"); DestroyWindow(hwnd); } + TCHAR msg[1024]; + if (!wi) { msg(TranslateT("error......"), TranslateT("Buddy Pounce")); DestroyWindow(hwnd); } TranslateDialogDefault(hwnd); wi->hContact = (HANDLE)lParam; wi->SendIfMy = 0; wi->SendWhenThey = 0; SetWindowLongPtr(hwnd, GWLP_USERDATA, (LPARAM)wi); getDefaultMessage(hwnd, IDC_MESSAGE, wi->hContact); - _snprintf(msg, 1024, Translate("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); SetDlgItemText(hwnd, GRP_MSG, msg); populateSettingsList(GetDlgItem(hwnd, IDC_SETTINGS)); populateContacts(wi->hContact, GetDlgItem(hwnd,IDC_CONTACTS)); @@ -299,9 +299,9 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l if (HIWORD(wParam) == EN_CHANGE) { int length; - char msg[1024]; + TCHAR msg[1024]; length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)); - _snprintf(msg, 1024, Translate("The Message (%d Characters)"), length); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("The Message (%d Characters)"), length); SetDlgItemText(hwnd, GRP_MSG, msg); } } @@ -309,15 +309,15 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l case IDC_SIMPLE: case IDOK: { - char *text; + TCHAR *text; HANDLE hContact = (HANDLE)SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETITEMDATA, SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETCURSEL,0,0),0); int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))+1; if (length>1) { - text = (char*)malloc(length); - if (!text) { msg("Couldnt Allocate enough memory",""); break; } + text = (TCHAR*)malloc(length*sizeof(TCHAR)); + if (!text) { msg(TranslateT("Couldnt Allocate enough memory"), _T("")); break; } GetDlgItemText(hwnd, IDC_MESSAGE, text, length); - DBWriteContactSettingString(hContact, modname, "PounceMsg", text); + DBWriteContactSettingTString(hContact, modname, "PounceMsg", text); free(text); } else DBDeleteContactSetting(hContact, modname, "PounceMsg"); @@ -339,20 +339,20 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l { HANDLE hContact = ((struct windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA))->hContact; deletePounce(hContact); - SetDlgItemText(hwnd, IDC_MESSAGE, ""); - SetDlgItemText(hwnd, GRP_MSG, "The Message (0 Characters)"); + SetDlgItemText(hwnd, IDC_MESSAGE, _T("")); + SetDlgItemText(hwnd, GRP_MSG, TranslateT("The Message (0 Characters)")); } break; case IDC_DEFAULT: { HANDLE hContact = ((struct windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA))->hContact; - char msg[1024]; + TCHAR msg[1024]; getDefaultMessage(hwnd, IDC_MESSAGE, hContact); - _snprintf(msg, 1024, Translate("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); SetDlgItemText(hwnd, GRP_MSG, msg); - DBWriteContactSettingWord(hContact,modname, "SendIfMyStatusIsFLAG", (WORD)DBGetContactSettingWord(NULL, modname, "SendIfMyStatusIsFLAG",0)); - DBWriteContactSettingWord(hContact,modname, "SendIfTheirStatusIsFLAG", (WORD)DBGetContactSettingWord(NULL, modname, "SendIfTheirStatusIsFLAG",0)); - DBWriteContactSettingByte(hContact,modname, "Reuse",(BYTE)DBGetContactSettingByte(NULL, modname, "Reuse",0)); + DBWriteContactSettingWord(hContact, modname, "SendIfMyStatusIsFLAG", (WORD)DBGetContactSettingWord(NULL, modname, "SendIfMyStatusIsFLAG",0)); + DBWriteContactSettingWord(hContact, modname, "SendIfTheirStatusIsFLAG", (WORD)DBGetContactSettingWord(NULL, modname, "SendIfTheirStatusIsFLAG",0)); + DBWriteContactSettingByte(hContact, modname, "Reuse",(BYTE)DBGetContactSettingByte(NULL, modname, "Reuse",0)); DBWriteContactSettingByte(hContact, modname, "GiveUpDays", (BYTE)DBGetContactSettingByte(NULL, modname, "GiveUpDays",0)); DBWriteContactSettingDword(hContact, modname, "GiveUpDate", (DWORD)DBGetContactSettingDword(NULL, modname, "GiveUpDate",0)); DBWriteContactSettingByte(hContact, modname, "ConfirmTimeout", (BYTE)DBGetContactSettingByte(NULL, modname, "ConfirmTimeout",0)); @@ -363,7 +363,7 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l { struct windowInfo *wi = (struct windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA); int item = SendMessage(GetDlgItem(hwnd, IDC_SETTINGS), LB_GETCURSEL, 0, 0); - char temp[5]; + TCHAR temp[5]; saveLastSetting(wi->hContact, hwnd); hideAll(hwnd); switch (item) @@ -376,27 +376,27 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l break; case 3: // Reuse Pounce ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG, "Reuse this message? (0 to use it once)"); + SetDlgItemText(hwnd, IDC_SETTINGMSG, TranslateT("Reuse this message? (0 to use it once)")); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG2), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG2, "Times"); + SetDlgItemText(hwnd, IDC_SETTINGMSG2, TranslateT("Times")); SetDlgItemText(hwnd, IDC_SETTINGNUMBER, _itot(DBGetContactSettingByte(wi->hContact, modname, "Reuse", 0), temp, 10)); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGNUMBER), SW_SHOW); ShowWindow(GetDlgItem(hwnd, IDC_SPIN), SW_SHOW); break; case 4: // Give Up delay ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG, "Giveup after.. (0 to not giveup)"); + SetDlgItemText(hwnd, IDC_SETTINGMSG, TranslateT("Giveup after.. (0 to not giveup)")); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG2), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG2, "Days"); + SetDlgItemText(hwnd, IDC_SETTINGMSG2, TranslateT("Days")); SetDlgItemText(hwnd, IDC_SETTINGNUMBER, _itot(DBGetContactSettingByte(wi->hContact, modname, "GiveUpDays", 0), temp, 10)); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGNUMBER), SW_SHOW); ShowWindow(GetDlgItem(hwnd, IDC_SPIN), SW_SHOW); break; case 5: // confirm window ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG, "Show confirmation window? (0 to not Show)"); + SetDlgItemText(hwnd, IDC_SETTINGMSG, TranslateT("Show confirmation window? (0 to not Show)")); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG2), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG2, "Seconds to wait before sending"); + SetDlgItemText(hwnd, IDC_SETTINGMSG2, TranslateT("Seconds to wait before sending")); SetDlgItemText(hwnd, IDC_SETTINGNUMBER, _itot(DBGetContactSettingByte(wi->hContact, modname, "ConfirmTimeout", 0), temp, 10)); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGNUMBER), SW_SHOW); ShowWindow(GetDlgItem(hwnd, IDC_SPIN), SW_SHOW); @@ -404,7 +404,7 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l case 7: // send a file ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG, "Send a file"); + SetDlgItemText(hwnd, IDC_SETTINGMSG, TranslateT("Send a file")); ShowWindow(GetDlgItem(hwnd, IDC_BUTTON), SW_SHOW); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGTEXT), SW_SHOW); break; @@ -425,7 +425,7 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, L case WM_INITDIALOG: { struct windowInfo *wi = (struct windowInfo *)malloc(sizeof(struct windowInfo)); - char msg[1024]; + TCHAR msg[1024]; TranslateDialogDefault(hwnd); wi->hContact = 0; wi->SendIfMy = 0; @@ -433,7 +433,7 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, L SetWindowLongPtr(hwnd, GWLP_USERDATA, (LPARAM)wi); getDefaultMessage(hwnd, IDC_MESSAGE, wi->hContact); - _snprintf(msg, 1024, Translate("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))); SetDlgItemText(hwnd, GRP_MSG, msg); populateSettingsList(GetDlgItem(hwnd, IDC_SETTINGS)); SendMessage(GetDlgItem(hwnd,IDC_SPIN), UDM_SETRANGE, 0, (LPARAM) MAKELONG ((short) 1024, (short) 0)); @@ -449,16 +449,16 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, L { case PSN_APPLY: { - char *text; + TCHAR *text; struct windowInfo *wi = (struct windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA); HANDLE hContact = ((struct windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA))->hContact; int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))+1; - if (length>1) + if (length > 1) { - text = (char*)malloc(length); - if (!text) { msg("Couldnt Allocate enough memory",""); break; } + text = (TCHAR*)malloc(length*sizeof(TCHAR)); + if (!text) { msg(TranslateT("Couldnt Allocate enough memory"), _T("")); break; } GetDlgItemText(hwnd, IDC_MESSAGE, text, length); - DBWriteContactSettingString(hContact, modname, "PounceMsg", text); + DBWriteContactSettingTString(hContact, modname, "PounceMsg", text); free(text); } else DBDeleteContactSetting(hContact, modname, "PounceMsg"); @@ -481,9 +481,9 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, L if (HIWORD(wParam) == EN_CHANGE) { int length; - char msg[1024]; + TCHAR msg[1024]; length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)); - _snprintf(msg, 1024, Translate("The Message (%d Characters)"), length); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("The Message (%d Characters)"), length); SetDlgItemText(hwnd, GRP_MSG, msg); SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); } @@ -498,7 +498,7 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, L { struct windowInfo *wi = (struct windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA); int item = SendMessage(GetDlgItem(hwnd, IDC_SETTINGS), LB_GETCURSEL, 0, 0); - char temp[5]; + TCHAR temp[5]; SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); saveLastSetting(wi->hContact, hwnd); hideAll(hwnd); @@ -512,27 +512,27 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, L break; case 3: // Reuse Pounce ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG, "Reuse this message? (0 to use it once)"); + SetDlgItemText(hwnd, IDC_SETTINGMSG, TranslateT("Reuse this message? (0 to use it once)")); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG2), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG2, "Times"); + SetDlgItemText(hwnd, IDC_SETTINGMSG2, TranslateT("Times")); SetDlgItemText(hwnd, IDC_SETTINGNUMBER, _itot(DBGetContactSettingByte(wi->hContact, modname, "Reuse", 0), temp, 10)); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGNUMBER), SW_SHOW); ShowWindow(GetDlgItem(hwnd, IDC_SPIN), SW_SHOW); break; case 4: // Give Up delay ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG, "Giveup after.. (0 to not giveup)"); + SetDlgItemText(hwnd, IDC_SETTINGMSG, TranslateT("Giveup after.. (0 to not giveup)")); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG2), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG2, "Days"); + SetDlgItemText(hwnd, IDC_SETTINGMSG2, TranslateT("Days")); SetDlgItemText(hwnd, IDC_SETTINGNUMBER, _itot(DBGetContactSettingByte(wi->hContact, modname, "GiveUpDays", 0), temp, 10)); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGNUMBER), SW_SHOW); ShowWindow(GetDlgItem(hwnd, IDC_SPIN), SW_SHOW); break; case 5: // confirm window ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG, "Show confirmation window? (0 to not Show)"); + SetDlgItemText(hwnd, IDC_SETTINGMSG, TranslateT("Show confirmation window? (0 to not Show)")); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG2), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG2, "Seconds to wait before sending"); + SetDlgItemText(hwnd, IDC_SETTINGMSG2, TranslateT("Seconds to wait before sending")); SetDlgItemText(hwnd, IDC_SETTINGNUMBER, _itot(DBGetContactSettingByte(wi->hContact, modname, "ConfirmTimeout", 0), temp, 10)); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGNUMBER), SW_SHOW); ShowWindow(GetDlgItem(hwnd, IDC_SPIN), SW_SHOW); @@ -540,7 +540,7 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, L case 7: // send a file ShowWindow(GetDlgItem(hwnd, IDC_SETTINGMSG), SW_SHOW); - SetDlgItemText(hwnd, IDC_SETTINGMSG, "Send a file"); + SetDlgItemText(hwnd, IDC_SETTINGMSG, TranslateT("Send a file")); ShowWindow(GetDlgItem(hwnd, IDC_BUTTON), SW_SHOW); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGTEXT), SW_SHOW); break; @@ -567,8 +567,8 @@ INT_PTR CALLBACK SendPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP TranslateDialogDefault(hwnd); spdps->timer = DBGetContactSettingByte(spdps->hContact, modname, "ConfirmTimeout", 0); SetWindowLongPtr(hwnd, GWLP_USERDATA, (WPARAM)spdps); - if (DBGetContactSetting(spdps->hContact,modname,"PounceMsg",&dbv)) DestroyWindow(hwnd); - SetDlgItemText(hwnd,IDC_MESSAGE,dbv.pszVal); + if (DBGetContactSettingTString(spdps->hContact, modname, "PounceMsg", &dbv)) DestroyWindow(hwnd); + SetDlgItemText(hwnd,IDC_MESSAGE, dbv.ptszVal); DBFreeVariant(&dbv); SetTimer(hwnd,1,1000,NULL); SendMessage(hwnd,WM_TIMER,0,0); @@ -577,9 +577,9 @@ INT_PTR CALLBACK SendPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP case WM_TIMER: { struct SendPounceDlgProcStruct *spdps = (struct SendPounceDlgProcStruct *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - char message[1024]; - _snprintf(message,sizeof(message),Translate("Pounce being sent to %s in %d seconds"),CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)spdps->hContact, 0),spdps->timer); - SetDlgItemText(hwnd,LBL_CONTACT ,message); + TCHAR message[1024]; + mir_sntprintf(message, SIZEOF(message), TranslateT("Pounce being sent to %s in %d seconds"), CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)spdps->hContact, GCDNF_TCHAR), spdps->timer); + SetDlgItemText(hwnd, LBL_CONTACT, message); spdps->timer--; if (spdps->timer == -1) @@ -620,8 +620,8 @@ INT_PTR CALLBACK PounceSentDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP SetWindowLongPtr(hwnd, GWLP_USERDATA, (WPARAM)lParam); TranslateDialogDefault(hwnd); hContact = (HANDLE)lParam; - if (DBGetContactSetting(hContact,modname,"PounceMsg",&dbv)) DestroyWindow(hwnd); - SetDlgItemText(hwnd,IDC_MESSAGE,dbv.pszVal); + if (DBGetContactSettingTString(hContact, modname, "PounceMsg", &dbv)) DestroyWindow(hwnd); + SetDlgItemText(hwnd, IDC_MESSAGE, dbv.ptszVal); DBFreeVariant(&dbv); } break; @@ -629,12 +629,12 @@ INT_PTR CALLBACK PounceSentDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP switch(LOWORD(wParam)) { case IDOK: { - char text[2048]; - GetWindowText(GetDlgItem(hwnd,IDOK),text,16); - if (!strcmp(text,Translate("Retry"))) + TCHAR text[2048]; + GetWindowText(GetDlgItem(hwnd, IDOK), text, 16); + if (!_tcscmp(text, TranslateT("Retry"))) { - GetWindowText(GetDlgItem(hwnd,IDC_MESSAGE),text,2048); - SendPounce(text,hContact); + GetWindowText(GetDlgItem(hwnd,IDC_MESSAGE), text, 2048); + SendPounce(text, hContact); } } // fall through @@ -649,18 +649,18 @@ INT_PTR CALLBACK PounceSentDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP void CreateMessageAcknowlegedWindow(HANDLE hContact, int SentSuccess) { HWND hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONFIRMSEND), 0, PounceSentDlgProc, (LPARAM)hContact); - char msg[256]; + TCHAR msg[256]; if (SentSuccess) { - _snprintf(msg,256,Translate("Message successfully sent to %s"),CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0) ); - SetWindowText(GetDlgItem(hwnd,IDOK),"OK"); - ShowWindow(GetDlgItem(hwnd,IDCANCEL),0); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("Message successfully sent to %s"), CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)); + SetWindowText(GetDlgItem(hwnd, IDOK), TranslateT("OK")); + ShowWindow(GetDlgItem(hwnd, IDCANCEL), 0); } else { - _snprintf(msg,256,Translate("Message failed to send to %s"),CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0)); - SetWindowText(GetDlgItem(hwnd,IDOK),"Retry"); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("Message failed to send to %s"), CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)); + SetWindowText(GetDlgItem(hwnd, IDOK), TranslateT("Retry")); } - SetWindowText(GetDlgItem(hwnd,LBL_CONTACT),msg); - SetWindowText(hwnd,modFullname); + SetWindowText(GetDlgItem(hwnd, LBL_CONTACT), msg); + SetWindowText(hwnd, TranslateT(modFullname)); } \ No newline at end of file diff --git a/plugins/BuddyPounce/src/headers.h b/plugins/BuddyPounce/src/headers.h index a2c3399063..de87db585b 100644 --- a/plugins/BuddyPounce/src/headers.h +++ b/plugins/BuddyPounce/src/headers.h @@ -8,13 +8,14 @@ #include #include -#include "newpluginapi.h" -#include "m_clist.h" -#include "m_langpack.h" -#include "m_database.h" -#include "m_protocols.h" -#include "m_options.h" -#include "m_protosvc.h" +#include +#include +#include +#include +#include +#include +#include +#include #include "resource.h" #include "Version.h" @@ -53,7 +54,7 @@ struct windowInfo { struct SendPounceDlgProcStruct { HANDLE hContact; int timer; - char *message; + TCHAR *message; }; extern HINSTANCE hInst; @@ -63,7 +64,7 @@ extern HINSTANCE hInst; //======================================================= // main.c -void SendPounce(char* text, HANDLE hContact); +void SendPounce(TCHAR* text, HANDLE hContact); //dialog.c INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); diff --git a/plugins/BuddyPounce/src/main.cpp b/plugins/BuddyPounce/src/main.cpp index 712bcd8a8e..693bfd1106 100644 --- a/plugins/BuddyPounce/src/main.cpp +++ b/plugins/BuddyPounce/src/main.cpp @@ -72,25 +72,26 @@ int MsgAck(WPARAM wParam, LPARAM lParam) DBEVENTINFO dbei = { 0 }; DBVARIANT dbv; int reuse = DBGetContactSettingByte(ack->hContact,modname, "Reuse", 0); - if (!DBGetContactSetting(ack->hContact, modname, "PounceMsg", &dbv) && (dbv.pszVal[0] != '\0')) + if (!DBGetContactSettingTString(ack->hContact, modname, "PounceMsg", &dbv) && (dbv.ptszVal[0] != '\0')) { - + char* pszUtf = mir_utf8encodeT(dbv.ptszVal); dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_MESSAGE; - dbei.flags = DBEF_SENT; + dbei.flags = DBEF_UTF | DBEF_SENT; dbei.szModule = (char*)ack->szModule; dbei.timestamp = time(NULL); - dbei.cbBlob = lstrlenA(dbv.pszVal) + 1; - dbei.pBlob = (PBYTE) dbv.pszVal; - CallService(MS_DB_EVENT_ADD, (WPARAM) ack->hContact, (LPARAM) & dbei); + dbei.cbBlob = lstrlenA(pszUtf) + 1; + dbei.pBlob = (PBYTE)pszUtf; + CallService(MS_DB_EVENT_ADD, (WPARAM)ack->hContact, (LPARAM)&dbei); + mir_free(pszUtf); } // check to reuse - if (reuse >1) - DBWriteContactSettingByte(ack->hContact,modname, "Reuse", (BYTE)(reuse-1)); + if (reuse > 1) + DBWriteContactSettingByte(ack->hContact, modname, "Reuse", (BYTE)(reuse-1)); else { DBWriteContactSettingByte(ack->hContact,modname, "Reuse", 0); - DBWriteContactSettingString(ack->hContact,modname, "PounceMsg",""); + DBWriteContactSettingTString(ack->hContact, modname, "PounceMsg", _T("")); } } WindowList_Remove(hWindowList,(HWND)ack->hProcess); @@ -104,7 +105,7 @@ int BuddyPounceOptInit(WPARAM wParam, LPARAM lParam) odp.cbSize = sizeof(odp); odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR; odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCE(IDD_OPTIONS); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); odp.ptszGroup = LPGENT("Plugins"); odp.ptszTitle = LPGENT("Buddy Pounce"); odp.pfnDlgProc = BuddyPounceOptionsDlgProc; @@ -151,11 +152,12 @@ int CheckDate(HANDLE hContact) return 0; } -void SendPounce(char* text, HANDLE hContact) +void SendPounce(TCHAR *text, HANDLE hContact) { - HANDLE hSendId; - if (hSendId = (HANDLE)CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)text)) - WindowList_Add(hWindowList,(HWND)hSendId,hContact); + char* pszUtf = mir_utf8encodeT(text); + if (HANDLE hSendId = (HANDLE)CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)text)) + WindowList_Add(hWindowList, (HWND)hSendId, hContact); + } int UserOnlineSettingChanged(WPARAM wParam,LPARAM lParam) @@ -164,18 +166,18 @@ int UserOnlineSettingChanged(WPARAM wParam,LPARAM lParam) int newStatus,oldStatus; DBVARIANT dbv; HANDLE hContact; - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)wParam,0); - char* message; - if((HANDLE)wParam==NULL || strcmp(cws->szSetting,"Status")) return 0; + char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)wParam, 0); + TCHAR* message; + if((HANDLE)wParam == NULL || strcmp(cws->szSetting,"Status")) return 0; if (szProto && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM)) { - newStatus=cws->value.wVal; - oldStatus=DBGetContactSettingWord((HANDLE)wParam,"UserOnline","OldStatus",ID_STATUS_OFFLINE); + newStatus = cws->value.wVal; + oldStatus = DBGetContactSettingWord((HANDLE)wParam,"UserOnline","OldStatus",ID_STATUS_OFFLINE); if ( ( newStatus != oldStatus ) && ( (HANDLE)wParam != NULL) && ( newStatus != ID_STATUS_OFFLINE) ) { - hContact=(HANDLE)wParam; - if (!DBGetContactSetting(hContact, modname, "PounceMsg", &dbv) && (dbv.pszVal[0] != '\0')) + hContact = (HANDLE)wParam; + if (!DBGetContactSettingTString(hContact, modname, "PounceMsg", &dbv) && (dbv.ptszVal[0] != '\0')) { // check my status if (statusCheck(DBGetContactSettingWord(hContact, modname, "SendIfMyStatusIsFLAG", 0), CallProtoService(szProto, PS_GETSTATUS,0,0)) @@ -189,14 +191,15 @@ int UserOnlineSettingChanged(WPARAM wParam,LPARAM lParam) if (DBGetContactSettingByte(hContact, modname, "ConfirmTimeout", 0)) { struct SendPounceDlgProcStruct *spdps = (struct SendPounceDlgProcStruct *)malloc(sizeof(struct SendPounceDlgProcStruct)); - message = mir_tstrdup(dbv.pszVal); // will get free()ed in the send confirm window proc + message = mir_tstrdup(dbv.ptszVal); // will get free()ed in the send confirm window proc spdps->hContact = hContact; spdps->message = message; CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONFIRMSEND), 0, SendPounceDlgProc, (LPARAM)spdps); // set the confirmation window to send the msg when the timeout is done mir_free(message); } - else SendPounce(dbv.pszVal, hContact); + else + SendPounce(dbv.ptszVal, hContact); } } } @@ -218,9 +221,9 @@ INT_PTR BuddyPounceMenuCommand(WPARAM wParam, LPARAM lParam) INT_PTR AddSimpleMessage(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; - char* message = (char*)lParam; + TCHAR* message = (TCHAR*)lParam; time_t today = time(NULL); - DBWriteContactSettingString(hContact, modname, "PounceMsg", message); + DBWriteContactSettingTString(hContact, modname, "PounceMsg", message); DBWriteContactSettingWord(hContact, modname, "SendIfMyStatusIsFLAG", (WORD)DBGetContactSettingWord(NULL, modname, "SendIfMyStatusIsFLAG",1)); DBWriteContactSettingWord(hContact, modname, "SendIfTheirStatusIsFLAG", (WORD)DBGetContactSettingWord(NULL, modname, "SendIfTheirStatusIsFLAG",1)); DBWriteContactSettingByte(hContact, modname, "Reuse", (BYTE)DBGetContactSettingByte(NULL, modname, "Reuse",0)); @@ -232,15 +235,15 @@ INT_PTR AddSimpleMessage(WPARAM wParam, LPARAM lParam) INT_PTR AddToPounce(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; - char* message = (char*)lParam; + TCHAR* message = (TCHAR*)lParam; DBVARIANT dbv; - if (!DBGetContactSetting(hContact, modname, "PounceMsg",&dbv)) + if (!DBGetContactSettingTString(hContact, modname, "PounceMsg",&dbv)) { - char* newPounce = (char*)malloc(strlen(dbv.pszVal) + strlen(message) + 1); + TCHAR* newPounce = (TCHAR*)malloc(lstrlen(dbv.ptszVal) + lstrlen(message) + 1); if (!newPounce) return 1; - strcpy(newPounce, dbv.pszVal); - strcat(newPounce, message); - DBWriteContactSettingString(hContact, modname, "PounceMsg", newPounce); + _tcscpy(newPounce, dbv.ptszVal); + _tcscat(newPounce, message); + DBWriteContactSettingTString(hContact, modname, "PounceMsg", newPounce); free(newPounce); DBFreeVariant(&dbv); } @@ -266,12 +269,6 @@ extern "C" __declspec(dllexport) int Load(void) CreateServiceFunction("BuddyPounce/AddToPounce", AddToPounce); // add to the exsisitng pounce, if there isnt 1 then add a new simple pounce. /* ******************************************************** */ - { // known modules list - DBVARIANT dbv; - if (DBGetContactSetting(NULL,"KnownModules","Buddy Pounce", &dbv)) - DBWriteContactSettingString(NULL,"KnownModules","Buddy Pounce",modname); - DBFreeVariant(&dbv); - } return 0; } diff --git a/plugins/BuddyPounce/src/resource.h b/plugins/BuddyPounce/src/resource.h index 6ff38b88cc..6d9de9b857 100644 --- a/plugins/BuddyPounce/src/resource.h +++ b/plugins/BuddyPounce/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} -// Включаемый файл, созданный в Microsoft Visual C++. -// Используется D:\MNG_orig\plugins\BuddyPounce\res\resource.rc +// Microsoft Visual C++ generated include file. +// Used by C:\Temp\Myranda\plugins\BuddyPounce\res\resource.rc // #define IDC_DELETE 5 #define IDC_DEFAULT 6 -- cgit v1.2.3