From 9266f20959d58859070111cafe2a054de906fbb0 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Thu, 5 Feb 2015 18:32:01 +0000 Subject: ShlExt: -translation fixes -Minor bugfixes git-svn-id: http://svn.miranda-ng.org/main/trunk@12010 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/ShellExt/src/main.cpp | 12 +++--- plugins/ShellExt/src/options.cpp | 24 ++++------- plugins/ShellExt/src/shlcom.cpp | 88 ++++++++++++++++++---------------------- plugins/ShellExt/src/shlext.cpp | 20 ++++----- plugins/ShellExt/src/shlipc.cpp | 2 +- 5 files changed, 63 insertions(+), 83 deletions(-) (limited to 'plugins/ShellExt/src') diff --git a/plugins/ShellExt/src/main.cpp b/plugins/ShellExt/src/main.cpp index 24e1cdc736..12a09506a4 100644 --- a/plugins/ShellExt/src/main.cpp +++ b/plugins/ShellExt/src/main.cpp @@ -82,8 +82,8 @@ STDAPI DllCanUnloadNow() struct HRegKey { - HRegKey(HKEY hRoot, const char *ptszKey) : m_key(NULL) - { RegCreateKeyExA(hRoot, ptszKey, 0, 0, 0, KEY_SET_VALUE | KEY_CREATE_SUB_KEY, 0, &m_key, 0); + HRegKey(HKEY hRoot, const TCHAR *ptszKey) : m_key(NULL) + { RegCreateKeyEx(hRoot, ptszKey, 0, 0, 0, KEY_SET_VALUE | KEY_CREATE_SUB_KEY, 0, &m_key, 0); } ~HRegKey() { if (m_key) RegCloseKey(m_key); } @@ -101,7 +101,7 @@ char str4[] = "Apartment"; STDAPI DllRegisterServer() { - HRegKey k1(HKEY_CLASSES_ROOT, "miranda.shlext"); + HRegKey k1(HKEY_CLASSES_ROOT, _T("miranda.shlext")); if (k1 == NULL) return E_FAIL; @@ -113,7 +113,7 @@ STDAPI DllRegisterServer() ////////////////////////////////////////////////////////////////////////////////////// - HRegKey kClsid(HKEY_CLASSES_ROOT, "CLSID\\{72013A26-A94C-11d6-8540-A5E62932711D}"); + HRegKey kClsid(HKEY_CLASSES_ROOT, _T("CLSID\\{72013A26-A94C-11d6-8540-A5E62932711D}")); if (kClsid == NULL) return E_FAIL; @@ -122,7 +122,7 @@ STDAPI DllRegisterServer() if ( RegSetValueA(kClsid, "ProgID", REG_SZ, str3, sizeof(str3))) return E_FAIL; - HRegKey kInprocServer(kClsid, "InprocServer32"); + HRegKey kInprocServer(kClsid, _T("InprocServer32")); if (kInprocServer == NULL) return E_FAIL; @@ -142,7 +142,7 @@ STDAPI DllRegisterServer() ////////////////////////////////////////////////////////////////////////////////////// - HRegKey k2(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"); + HRegKey k2(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved")); if (k2 == NULL) return E_FAIL; if ( RegSetValueExA(k2, str2, 0, REG_SZ, (PBYTE)str1, str1len)) diff --git a/plugins/ShellExt/src/options.cpp b/plugins/ShellExt/src/options.cpp index d2b5f1cf7d..b3402a65f1 100644 --- a/plugins/ShellExt/src/options.cpp +++ b/plugins/ShellExt/src/options.cpp @@ -47,18 +47,12 @@ static INT_PTR CALLBACK OptDialogProc(HWND hwndDlg, UINT wMsg, WPARAM wParam, LP iCheck = db_get_b(0, SHLExt_Name, SHLExt_UseGroups, BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_USEGROUPS, iCheck ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_CLISTGROUPS), iCheck = BST_CHECKED); - CheckDlgButton(hwndDlg, IDC_CLISTGROUPS, - db_get_b(0, SHLExt_Name, SHLExt_UseCListSetting, BST_UNCHECKED)); - CheckDlgButton(hwndDlg, IDC_NOPROF, - db_get_b(0, SHLExt_Name, SHLExt_ShowNoProfile, BST_UNCHECKED)); - CheckDlgButton(hwndDlg, IDC_SHOWFULL, - db_get_b(0, SHLExt_Name, SHLExt_UseHITContacts, BST_UNCHECKED)); - CheckDlgButton(hwndDlg, IDC_SHOWINVISIBLES, - db_get_b(0, SHLExt_Name, SHLExt_UseHIT2Contacts, BST_UNCHECKED)); - CheckDlgButton(hwndDlg, IDC_USEOWNERDRAW, - db_get_b(0, SHLExt_Name, SHLExt_ShowNoIcons, BST_UNCHECKED)); - CheckDlgButton(hwndDlg, IDC_HIDEOFFLINE, - db_get_b(0, SHLExt_Name, SHLExt_ShowNoOffline, BST_UNCHECKED)); + CheckDlgButton(hwndDlg, IDC_CLISTGROUPS, db_get_b(0, SHLExt_Name, SHLExt_UseCListSetting, BST_UNCHECKED)); + CheckDlgButton(hwndDlg, IDC_NOPROF, db_get_b(0, SHLExt_Name, SHLExt_ShowNoProfile, BST_UNCHECKED)); + CheckDlgButton(hwndDlg, IDC_SHOWFULL, db_get_b(0, SHLExt_Name, SHLExt_UseHITContacts, BST_UNCHECKED)); + CheckDlgButton(hwndDlg, IDC_SHOWINVISIBLES, db_get_b(0, SHLExt_Name, SHLExt_UseHIT2Contacts, BST_UNCHECKED)); + CheckDlgButton(hwndDlg, IDC_USEOWNERDRAW, db_get_b(0, SHLExt_Name, SHLExt_ShowNoIcons, BST_UNCHECKED)); + CheckDlgButton(hwndDlg, IDC_HIDEOFFLINE, db_get_b(0, SHLExt_Name, SHLExt_ShowNoOffline, BST_UNCHECKED)); // give the Remove button a Vista icon SendDlgItemMessage(hwndDlg, IDC_REMOVE, BCM_SETSHIELD, 0, 1); return TRUE; @@ -106,13 +100,13 @@ static INT_PTR CALLBACK OptDialogProc(HWND hwndDlg, UINT wMsg, WPARAM wParam, LP return 0; } -int OnOptionsInit(WPARAM wParam, LPARAM lParam) +int OnOptionsInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE opt = { sizeof(opt) }; opt.flags = ODPF_BOLDGROUPS; - opt.pszGroup = "Services"; + opt.pszGroup = LPGEN("Services"); opt.position = -1066; - opt.pszTitle = "Shell context menus"; + opt.pszTitle = LPGEN("Shell context menus"); opt.pszTemplate = MAKEINTRESOURCEA(IDD_SHLOPTS); opt.hInstance = hInst; opt.pfnDlgProc = OptDialogProc; diff --git a/plugins/ShellExt/src/shlcom.cpp b/plugins/ShellExt/src/shlcom.cpp index 45cd72b88c..a4442d1460 100644 --- a/plugins/ShellExt/src/shlcom.cpp +++ b/plugins/ShellExt/src/shlcom.cpp @@ -27,14 +27,14 @@ int IsCOMRegistered() int res = 0; // these arent the BEST checks in the world - if ( !RegOpenKeyExA(HKEY_CLASSES_ROOT, "miranda.shlext", 0, KEY_READ, &hRegKey)) { + if (!RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("miranda.shlext"), 0, KEY_READ, &hRegKey)) { res += COMREG_OK; RegCloseKey(hRegKey); } - if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", 0, KEY_READ, &hRegKey)) { + if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"), 0, KEY_READ, &hRegKey)) { DWORD lpType = REG_SZ; - if ( !RegQueryValueExA(hRegKey, "{72013A26-A94C-11d6-8540-A5E62932711D}", NULL, &lpType, 0, 0)) + if (!RegQueryValueEx(hRegKey, _T("{72013A26-A94C-11d6-8540-A5E62932711D}"), NULL, &lpType, 0, 0)) res += COMREG_APPROVED; RegCloseKey(hRegKey); } @@ -82,8 +82,7 @@ BOOL AddToList(TAddArgList& args) lstrcpyA(szBuf, args.szFile); args.files = (LPSTR*)mir_realloc(args.files, (args.count + 1) * sizeof(LPSTR)); char *p = mir_strdup(szBuf); - args.files[args.count] = p; - args.count++; + args.files[args.count++] = p; // tack on ending search token lstrcatA(szBuf, "\\*"); @@ -91,9 +90,7 @@ BOOL AddToList(TAddArgList& args) HANDLE hFind = FindFirstFileA(szBuf, &fd); while (true) { if (fd.cFileName[0] != '.') { - lstrcpyA(szBuf, args.szFile); - lstrcatA(szBuf, "\\"); - lstrcatA(szBuf, fd.cFileName); + mir_snprintf(szBuf, SIZEOF(szBuf),"%s\\%s", args.szFile, fd.cFileName); // keep a copy of the current thing being processed szThis = args.szFile; args.szFile = szBuf; @@ -104,8 +101,10 @@ BOOL AddToList(TAddArgList& args) // restore args.szFile = szThis; args.cch = cchThis; - if (Result) + if (Result) { + FindClose(hFind); return true; + } } if (!FindNextFileA(hFind, &fd)) break; @@ -115,8 +114,7 @@ BOOL AddToList(TAddArgList& args) else { // add the file args.files = (LPSTR*)mir_realloc(args.files, (args.count + 1) * sizeof(LPSTR)); - args.files[args.count] = mir_strdup(args.szFile); - args.count++; + args.files[args.count++] = mir_strdup(args.szFile); } } return false; @@ -157,8 +155,7 @@ void __cdecl IssueTransferThread(void *param) if (args.files != NULL) { args.files = (LPSTR*)mir_realloc(args.files, (args.count + 1) * sizeof(LPSTR)); - args.files[args.count] = NULL; - args.count++; + args.files[args.count++] = NULL; if (!bQuit) { args.hEvent = CreateEvent(NULL, true, false, NULL); QueueUserAPC(MainThreadIssueTransfer, hMainThread, UINT_PTR(&args)); @@ -196,7 +193,7 @@ void ipcGetSkinIcons(THeaderIPC *ipch) int protoCount; PROTOACCOUNT **pp; - if ( CallService(MS_PROTO_ENUMACCOUNTS, WPARAM(&protoCount), LPARAM(&pp)) == 0 && protoCount != 0) { + if (ProtoEnumAccounts(&protoCount,&pp) == 0 && protoCount != 0) { spi.pid = GetCurrentProcessId(); while (protoCount > 0) { PROTOACCOUNT *pa = *pp; @@ -237,9 +234,6 @@ void ipcGetSkinIcons(THeaderIPC *ipch) bool ipcGetSortedContacts(THeaderIPC *ipch, int *pSlot, bool bGroupMode) { - DBVARIANT dbv; - int n, rc; - bool Result = false; // hide offliners? bool bHideOffline = db_get_b(0, "CList", "HideOffline", 0) == 1; @@ -292,8 +286,7 @@ bool ipcGetSortedContacts(THeaderIPC *ipch, int *pSlot, bool bGroupMode) // store pContacts[i].hContact = hContact; pContacts[i].dwStatus = dwStatus; - pContacts[i].hProto = murmur_hash(szProto); - i++; + pContacts[i++].hProto = murmur_hash(szProto); } } @@ -305,7 +298,9 @@ bool ipcGetSortedContacts(THeaderIPC *ipch, int *pSlot, bool bGroupMode) dwContacts = i; qsort(pContacts, dwContacts, sizeof(TSlotInfo), SortContact); - + + DBVARIANT dbv; + int n, rc; // create an IPC slot for each contact and store display name, etc for (i=0; i < dwContacts; i++) { char *szContact = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)pContacts[i].hContact, 0); @@ -518,40 +513,39 @@ void InvokeThreadServer() } // helper functions - HRESULT RemoveCOMRegistryEntries() { HKEY hRootKey; - if ( !RegOpenKeyExA(HKEY_CLASSES_ROOT, "miranda.shlext", 0, KEY_READ, &hRootKey)) { + if (!RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("miranda.shlext"), 0, KEY_READ, &hRootKey)) { // need to delete the subkey before the parent key is deleted under NT/2000/XP - RegDeleteKeyA(hRootKey, "CLSID"); + RegDeleteKey(hRootKey, _T("CLSID")); // close the key RegCloseKey(hRootKey); // delete it - if ( RegDeleteKeyA(HKEY_CLASSES_ROOT, "miranda.shlext") != ERROR_SUCCESS) - MessageBoxA(0, - "Unable to delete registry key for 'shlext COM', this key may already be deleted or you may need admin rights.", - "Problem", MB_ICONERROR); + if (RegDeleteKey(HKEY_CLASSES_ROOT, _T("miranda.shlext")) != ERROR_SUCCESS) + MessageBox(0, + TranslateT("Unable to delete registry key for 'shlext COM', this key may already be deleted or you may need admin rights."), + TranslateT("Problem"), MB_ICONERROR); } - if ( !RegOpenKeyExA(HKEY_CLASSES_ROOT, "\\*\\shellex\\ContextMenuHandlers", 0, KEY_ALL_ACCESS, &hRootKey)) { - if ( RegDeleteKeyA(hRootKey, "miranda.shlext") != ERROR_SUCCESS) - MessageBoxA(0, - "Unable to delete registry key for 'File context menu handlers', this key may already be deleted or you may need admin rights.", - "Problem", MB_ICONERROR); + if (!RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("\\*\\shellex\\ContextMenuHandlers"), 0, KEY_ALL_ACCESS, &hRootKey)) { + if (RegDeleteKey(hRootKey, _T("miranda.shlext")) != ERROR_SUCCESS) + MessageBox(0, + TranslateT("Unable to delete registry key for 'File context menu handlers', this key may already be deleted or you may need admin rights."), + TranslateT("Problem"), MB_ICONERROR); RegCloseKey(hRootKey); } - if ( !RegOpenKeyExA(HKEY_CLASSES_ROOT, "Directory\\shellex\\ContextMenuHandlers", 0, KEY_ALL_ACCESS, &hRootKey)) { - if ( RegDeleteKeyA(hRootKey, "miranda.shlext") != ERROR_SUCCESS) - MessageBoxA(0, - "Unable to delete registry key for 'Directory context menu handlers', this key may already be deleted or you may need admin rights.", - "Problem", MB_ICONERROR); + if (!RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("Directory\\shellex\\ContextMenuHandlers"), 0, KEY_ALL_ACCESS, &hRootKey)) { + if (RegDeleteKey(hRootKey, _T("miranda.shlext")) != ERROR_SUCCESS) + MessageBox(0, + TranslateT("Unable to delete registry key for 'Directory context menu handlers', this key may already be deleted or you may need admin rights."), + TranslateT("Problem"), MB_ICONERROR); RegCloseKey(hRootKey); } - if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", 0, KEY_ALL_ACCESS, &hRootKey)) { - if ( RegDeleteValueA(hRootKey, "{72013A26-A94C-11d6-8540-A5E62932711D}") != ERROR_SUCCESS) { - MessageBoxA(0, - "Unable to delete registry entry for 'Approved context menu handlers', this key may already be deleted or you may need admin rights.", - "Problem", MB_ICONERROR); + if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"), 0, KEY_ALL_ACCESS, &hRootKey)) { + if (RegDeleteValue(hRootKey, _T("{72013A26-A94C-11d6-8540-A5E62932711D}")) != ERROR_SUCCESS) { + MessageBox(0, + TranslateT("Unable to delete registry entry for 'Approved context menu handlers', this key may already be deleted or you may need admin rights."), + TranslateT("Problem"), MB_ICONERROR); } RegCloseKey(hRootKey); } @@ -559,7 +553,6 @@ HRESULT RemoveCOMRegistryEntries() } // called by the options code to remove COM entries, and before that, get permission, if required. - void CheckUnregisterServer() { if (bIsVistaPlus) { @@ -582,18 +575,17 @@ void CheckUnregisterServer() // Wow, I can't believe there isn't a direct API for this - 'runas' will invoke the UAC and ask // for permission before installing the shell extension. note the filepath arg has to be quoted } - void CheckRegisterServer() { TCHAR szFileName[MAX_PATH], szBuf[MAX_PATH * 2]; HKEY hRegKey; - if ( !RegOpenKeyExA(HKEY_CLASSES_ROOT, "miranda.shlext", 0, KEY_READ, &hRegKey)) + if (!RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("miranda.shlext"), 0, KEY_READ, &hRegKey)) RegCloseKey(hRegKey); else if (bIsVistaPlus) { - MessageBoxA(0, - "Shell context menus requires your permission to register with Windows Explorer (one time only).", - "Miranda NG - Shell context menus (shellext.dll)", MB_OK | MB_ICONINFORMATION); + MessageBox(0, + TranslateT("Shell context menus requires your permission to register with Windows Explorer (one time only)."), + TranslateT("Miranda NG - Shell context menus (shellext.dll)"), MB_OK | MB_ICONINFORMATION); // /s = silent GetModuleFileName(hInst, szFileName, SIZEOF(szFileName)); mir_sntprintf(szBuf, SIZEOF(szBuf), _T("/s \"%s\""), szFileName); diff --git a/plugins/ShellExt/src/shlext.cpp b/plugins/ShellExt/src/shlext.cpp index ff8ba3d906..977232ba19 100644 --- a/plugins/ShellExt/src/shlext.cpp +++ b/plugins/ShellExt/src/shlext.cpp @@ -223,7 +223,6 @@ void DecideMenuItemInfo(TSlotIPC *pct, TGroupNode *pg, MENUITEMINFOA &mii, TEnum // this callback is triggered by the menu code and IPC is already taking place, // just the transfer type+data needs to be setup - int __stdcall ClearMRUIPC( THeaderIPC *pipch, // IPC header info, already mapped HANDLE hWorkThreadEvent, // event object being waited on on miranda thread @@ -339,13 +338,9 @@ static void BuildMenuGroupTree(TGroupNode *p, TEnumData *lParam, HMENU hLastMenu static void BuildMenus(TEnumData *lParam) { - HMENU hGroupMenu; LPSTR Token; TMenuDrawInfo *psd; - UINT c; - TSlotProtoIcons *pp; - MENUITEMINFOA mii = { 0 }; HANDLE hDllHeap = lParam->Self->hDllHeap; HMENU hBaseMenu = lParam->Self->hRootMenu; @@ -389,7 +384,7 @@ static void BuildMenus(TEnumData *lParam) // build the menus inserting into hGroupMenu which will be a submenu of // the instance menu item. e.g. Miranda -> [Groups ->] contacts - hGroupMenu = CreatePopupMenu(); + HMENU hGroupMenu = CreatePopupMenu(); // allocate MRU menu, this will be associated with the higher up menu // so doesn't need to be freed (unless theres no MRUs items attached) @@ -402,7 +397,8 @@ static void BuildMenus(TEnumData *lParam) // add contacts that have a group somewhere BuildContactTree(j.First, lParam); } - + + MENUITEMINFOA mii = { 0 }; mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_DATA; // add all the contacts that have no group (which maybe all of them) @@ -503,8 +499,8 @@ static void BuildMenus(TEnumData *lParam) psd->hContact = 0; // get Miranda's icon or bitmap - c = lParam->Self->ProtoIconsCount; - pp = lParam->Self->ProtoIcons; + UINT c = lParam->Self->ProtoIconsCount; + TSlotProtoIcons *pp = lParam->Self->ProtoIcons; while (c > 0) { c--; if (pp[c].pid == lParam->pid && pp[c].hProto == 0) { @@ -570,8 +566,6 @@ static void BuildSkinIcons(TEnumData *lParam) BOOL __stdcall ProcessRequest(HWND hwnd, LPARAM param) { - HANDLE hMirandaWorkEvent; - int replyBits; char szBuf[MAX_PATH]; TEnumData *lParam = (TEnumData*)param; @@ -582,7 +576,7 @@ BOOL __stdcall ProcessRequest(HWND hwnd, LPARAM param) // and try to OpenEvent() a event object name to it (prefixed with a string) // this was fine for most Oses (not the best way) but now actually compares // the class string (a bit slower) but should get rid of those bugs finally. - hMirandaWorkEvent = OpenEventA(EVENT_ALL_ACCESS, false, CreateProcessUID(pid, szBuf, sizeof(szBuf))); + HANDLE hMirandaWorkEvent = OpenEventA(EVENT_ALL_ACCESS, false, CreateProcessUID(pid, szBuf, sizeof(szBuf))); if (hMirandaWorkEvent != 0) { GetClassNameA(hwnd, szBuf, sizeof(szBuf)); if ( lstrcmpA(szBuf, MIRANDACLASS) != 0) { @@ -600,7 +594,7 @@ BOOL __stdcall ProcessRequest(HWND hwnd, LPARAM param) // slots will be in the order of icon data, groups contacts, the first // slot will contain the profile name - replyBits = ipcSendRequest(hMirandaWorkEvent, lParam->hWaitFor, lParam->ipch, 1000); + DWORD replyBits = ipcSendRequest(hMirandaWorkEvent, lParam->hWaitFor, lParam->ipch, 1000); // replyBits will be REPLY_FAIL if the wait timed out, or it'll be the request // bits as sent or a series of *_NOTIMPL bits where the request bit were, if there are no diff --git a/plugins/ShellExt/src/shlipc.cpp b/plugins/ShellExt/src/shlipc.cpp index a58dd76055..eda0729a7a 100644 --- a/plugins/ShellExt/src/shlipc.cpp +++ b/plugins/ShellExt/src/shlipc.cpp @@ -65,7 +65,7 @@ void ipcPrepareRequests(int ipcPacketSize, THeaderIPC *pipch, DWORD fRequests) pipch->DataPtrEnd = (TSlotIPC*)(LPSTR(pipch->DataPtr) + pipch->DataSize); pipch->DataFramePtr = pipch->DataPtr; // fill the data area - memset(pipch->DataPtr, pipch->DataSize, 0); + memset(pipch->DataPtr,0 , pipch->DataSize); } DWORD ipcSendRequest(HANDLE hSignal, HANDLE hWaitFor, THeaderIPC *pipch, DWORD dwTimeoutMsecs) -- cgit v1.2.3