From e58823d961a630eb62e60d2ccb443761ba5f1704 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 14 Jun 2012 15:51:34 +0000 Subject: - all MS_CLIST_ADD*ITEM services replaced with Menu_Add*Item stubs. - massive cleanup of the menu-related code git-svn-id: http://svn.miranda-ng.org/main/trunk@410 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/utils/openurl.cpp | 82 +++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'src/modules/utils/openurl.cpp') diff --git a/src/modules/utils/openurl.cpp b/src/modules/utils/openurl.cpp index fb10c5f43c..46e95f954e 100644 --- a/src/modules/utils/openurl.cpp +++ b/src/modules/utils/openurl.cpp @@ -11,7 +11,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -27,24 +27,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define WNDCLASS_DDEMSGWINDOW _T("MirandaDdeMsgWindow") struct DdeMsgWindowData { - int fAcked,fData; + int fAcked, fData; HWND hwndDde; }; -static LRESULT CALLBACK DdeMessageWindow(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +static LRESULT CALLBACK DdeMessageWindow(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { struct DdeMsgWindowData *dat; ATOM hSzItem; HGLOBAL hDdeData; - dat=(struct DdeMsgWindowData*)GetWindowLongPtr(hwnd,0); + dat=(struct DdeMsgWindowData*)GetWindowLongPtr(hwnd, 0); switch(msg) { case WM_DDE_ACK: dat->fAcked=1; dat->hwndDde=(HWND)wParam; return 0; case WM_DDE_DATA: - UnpackDDElParam(msg,lParam,(PUINT_PTR)&hDdeData,(PUINT_PTR)&hSzItem); + UnpackDDElParam(msg, lParam, (PUINT_PTR)&hDdeData, (PUINT_PTR)&hSzItem); dat->fData=1; if (hDdeData) { DDEDATA *data; @@ -52,7 +52,7 @@ static LRESULT CALLBACK DdeMessageWindow(HWND hwnd,UINT msg,WPARAM wParam,LPARAM data=(DDEDATA*)GlobalLock(hDdeData); if (data->fAckReq) { DDEACK ack={0}; - PostMessage((HWND)wParam,WM_DDE_ACK,(WPARAM)hwnd,PackDDElParam(WM_DDE_ACK,*(PUINT)&ack,(UINT)hSzItem)); + PostMessage((HWND)wParam, WM_DDE_ACK, (WPARAM)hwnd, PackDDElParam(WM_DDE_ACK, *(PUINT)&ack, (UINT)hSzItem)); } else GlobalDeleteAtom(hSzItem); release=data->fRelease; @@ -62,32 +62,32 @@ static LRESULT CALLBACK DdeMessageWindow(HWND hwnd,UINT msg,WPARAM wParam,LPARAM else GlobalDeleteAtom(hSzItem); return 0; } - return DefWindowProc(hwnd,msg,wParam,lParam); + return DefWindowProc(hwnd, msg, wParam, lParam); } -static int DoDdeRequest(const char *szItemName,HWND hwndDdeMsg) +static int DoDdeRequest(const char *szItemName, HWND hwndDdeMsg) { ATOM hSzItemName; - DWORD timeoutTick,thisTick; + DWORD timeoutTick, thisTick; MSG msg; - struct DdeMsgWindowData *dat=(struct DdeMsgWindowData*)GetWindowLongPtr(hwndDdeMsg,0); + struct DdeMsgWindowData *dat=(struct DdeMsgWindowData*)GetWindowLongPtr(hwndDdeMsg, 0); hSzItemName=GlobalAddAtomA(szItemName); - if (!PostMessage(dat->hwndDde,WM_DDE_REQUEST,(WPARAM)hwndDdeMsg,MAKELPARAM(CF_TEXT,hSzItemName))) { + if (!PostMessage(dat->hwndDde, WM_DDE_REQUEST, (WPARAM)hwndDdeMsg, MAKELPARAM(CF_TEXT, hSzItemName))) { GlobalDeleteAtom(hSzItemName); return 1; } timeoutTick=GetTickCount()+5000; dat->fData=0; dat->fAcked=0; do { - if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { + if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (dat->fData || dat->fAcked) break; thisTick=GetTickCount(); if (thisTick>timeoutTick) break; - } while (MsgWaitForMultipleObjects(0,NULL,FALSE,timeoutTick-thisTick,QS_ALLINPUT) == WAIT_OBJECT_0); + } while (MsgWaitForMultipleObjects(0, NULL, FALSE, timeoutTick-thisTick, QS_ALLINPUT) == WAIT_OBJECT_0); if (!dat->fData) { GlobalDeleteAtom(hSzItemName); @@ -97,31 +97,31 @@ static int DoDdeRequest(const char *szItemName,HWND hwndDdeMsg) } //see Q160957 and http://developer.netscape.com/docs/manuals/communicator/DDE/index.htm -static int DdeOpenUrl(const char *szBrowser,char *szUrl,int newWindow,HWND hwndDdeMsg) +static int DdeOpenUrl(const char *szBrowser, char *szUrl, int newWindow, HWND hwndDdeMsg) { - ATOM hSzBrowser,hSzTopic; + ATOM hSzBrowser, hSzTopic; DWORD_PTR dwResult; char *szItemName; - struct DdeMsgWindowData *dat=(struct DdeMsgWindowData*)GetWindowLongPtr(hwndDdeMsg,0); + struct DdeMsgWindowData *dat=(struct DdeMsgWindowData*)GetWindowLongPtr(hwndDdeMsg, 0); hSzBrowser=GlobalAddAtomA(szBrowser); hSzTopic=GlobalAddAtomA("WWW_OpenURL"); dat->fAcked=0; - if (!SendMessageTimeout(HWND_BROADCAST,WM_DDE_INITIATE,(WPARAM)hwndDdeMsg,MAKELPARAM(hSzBrowser,hSzTopic),SMTO_ABORTIFHUNG|SMTO_NORMAL,DDEMESSAGETIMEOUT,&dwResult) + if (!SendMessageTimeout(HWND_BROADCAST, WM_DDE_INITIATE, (WPARAM)hwndDdeMsg, MAKELPARAM(hSzBrowser, hSzTopic), SMTO_ABORTIFHUNG|SMTO_NORMAL, DDEMESSAGETIMEOUT, &dwResult) || !dat->fAcked) { GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); return 1; } szItemName=(char*)mir_alloc(lstrlenA(szUrl)+7); - wsprintfA(szItemName,"\"%s\",,%d",szUrl,newWindow?0:-1); - if (DoDdeRequest(szItemName,hwndDdeMsg)) { + wsprintfA(szItemName, "\"%s\", , %d", szUrl, newWindow?0:-1); + if (DoDdeRequest(szItemName, hwndDdeMsg)) { mir_free(szItemName); GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); return 1; } - PostMessage(dat->hwndDde,WM_DDE_TERMINATE,(WPARAM)hwndDdeMsg,0); + PostMessage(dat->hwndDde, WM_DDE_TERMINATE, (WPARAM)hwndDdeMsg, 0); GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); mir_free(szItemName); @@ -147,25 +147,25 @@ static void OpenURLThread(void *arg) int success=0; if (!hUrlInfo->szUrl) return; - hwndDdeMsg=CreateWindow(WNDCLASS_DDEMSGWINDOW,_T(""),0,0,0,0,0,NULL,NULL,hMirandaInst,NULL); - SetWindowLongPtr(hwndDdeMsg,0,(LONG_PTR)&msgWndData); + hwndDdeMsg=CreateWindow(WNDCLASS_DDEMSGWINDOW, _T(""), 0, 0, 0, 0, 0, NULL, NULL, hMirandaInst, NULL); + SetWindowLongPtr(hwndDdeMsg, 0, (LONG_PTR)&msgWndData); - if (!_strnicmp(hUrlInfo->szUrl,"ftp:",4) || !_strnicmp(hUrlInfo->szUrl,"ftp.",4)) pszProtocol="ftp"; - if (!_strnicmp(hUrlInfo->szUrl,"mailto:",7)) pszProtocol="mailto"; - if (!_strnicmp(hUrlInfo->szUrl,"news:",5)) pszProtocol="news"; + if (!_strnicmp(hUrlInfo->szUrl, "ftp:", 4) || !_strnicmp(hUrlInfo->szUrl, "ftp.", 4)) pszProtocol="ftp"; + if (!_strnicmp(hUrlInfo->szUrl, "mailto:", 7)) pszProtocol="mailto"; + if (!_strnicmp(hUrlInfo->szUrl, "news:", 5)) pszProtocol="news"; else pszProtocol="http"; - wsprintfA(szSubkey,"%s\\shell\\open\\command",pszProtocol); - if (RegOpenKeyExA(HKEY_CURRENT_USER,szSubkey,0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS - || RegOpenKeyExA(HKEY_CLASSES_ROOT,szSubkey,0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) { + wsprintfA(szSubkey, "%s\\shell\\open\\command", pszProtocol); + if (RegOpenKeyExA(HKEY_CURRENT_USER, szSubkey, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS + || RegOpenKeyExA(HKEY_CLASSES_ROOT, szSubkey, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { dataLength=SIZEOF(szCommandName); - if (RegQueryValueEx(hKey,NULL,NULL,NULL,(PBYTE)szCommandName,&dataLength) == ERROR_SUCCESS) { + if (RegQueryValueEx(hKey, NULL, NULL, NULL, (PBYTE)szCommandName, &dataLength) == ERROR_SUCCESS) { _strlwr(szCommandName); - if (strstr(szCommandName,"mozilla") || strstr(szCommandName,"netscape")) - success=(DdeOpenUrl("mozilla",hUrlInfo->szUrl,hUrlInfo->newWindow,hwndDdeMsg) == 0 || DdeOpenUrl("netscape",hUrlInfo->szUrl,hUrlInfo->newWindow,hwndDdeMsg) == 0); - else if (strstr(szCommandName,"iexplore") || strstr(szCommandName,"msimn")) - success=0 == DdeOpenUrl("iexplore",hUrlInfo->szUrl,hUrlInfo->newWindow,hwndDdeMsg); - else if (strstr(szCommandName,"opera")) - success=0 == DdeOpenUrl("opera",hUrlInfo->szUrl,hUrlInfo->newWindow,hwndDdeMsg); + if (strstr(szCommandName, "mozilla") || strstr(szCommandName, "netscape")) + success=(DdeOpenUrl("mozilla", hUrlInfo->szUrl, hUrlInfo->newWindow, hwndDdeMsg) == 0 || DdeOpenUrl("netscape", hUrlInfo->szUrl, hUrlInfo->newWindow, hwndDdeMsg) == 0); + else if (strstr(szCommandName, "iexplore") || strstr(szCommandName, "msimn")) + success=0 == DdeOpenUrl("iexplore", hUrlInfo->szUrl, hUrlInfo->newWindow, hwndDdeMsg); + else if (strstr(szCommandName, "opera")) + success=0 == DdeOpenUrl("opera", hUrlInfo->szUrl, hUrlInfo->newWindow, hwndDdeMsg); //opera's the default anyway } RegCloseKey(hKey); @@ -177,20 +177,20 @@ static void OpenURLThread(void *arg) //wack a protocol on it if ((isalpha(hUrlInfo->szUrl[0]) && hUrlInfo->szUrl[1] == ':') || hUrlInfo->szUrl[0] == '\\') { szResult=(char*)mir_alloc(lstrlenA(hUrlInfo->szUrl)+9); - wsprintfA(szResult,"file:///%s",hUrlInfo->szUrl); + wsprintfA(szResult, "file:///%s", hUrlInfo->szUrl); } else { int i; for (i=0;isalpha(hUrlInfo->szUrl[i]);i++); if (hUrlInfo->szUrl[i] == ':') szResult=mir_strdup(hUrlInfo->szUrl); else { - if (!_strnicmp(hUrlInfo->szUrl,"ftp.",4)) { + if (!_strnicmp(hUrlInfo->szUrl, "ftp.", 4)) { szResult=(char*)mir_alloc(lstrlenA(hUrlInfo->szUrl)+7); - wsprintfA(szResult,"ftp://%s",hUrlInfo->szUrl); + wsprintfA(szResult, "ftp://%s", hUrlInfo->szUrl); } else { szResult=(char*)mir_alloc(lstrlenA(hUrlInfo->szUrl)+8); - wsprintfA(szResult,"http://%s",hUrlInfo->szUrl); + wsprintfA(szResult, "http://%s", hUrlInfo->szUrl); } } } @@ -201,7 +201,7 @@ static void OpenURLThread(void *arg) return; } -static INT_PTR OpenURL(WPARAM wParam,LPARAM lParam) { +static INT_PTR OpenURL(WPARAM wParam, LPARAM lParam) { TOpenUrlInfo *hUrlInfo = (TOpenUrlInfo*)mir_alloc(sizeof(TOpenUrlInfo)); hUrlInfo->szUrl = (char*)lParam?mir_strdup((char*)lParam):NULL; hUrlInfo->newWindow = (int)wParam; @@ -223,6 +223,6 @@ int InitOpenUrl(void) wcl.lpszMenuName=NULL; wcl.style=0; RegisterClass(&wcl); - CreateServiceFunction(MS_UTILS_OPENURL,OpenURL); + CreateServiceFunction(MS_UTILS_OPENURL, OpenURL); return 0; } -- cgit v1.2.3