X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=w32log.c;h=b60eae782cafd238357838317b06c8efac683747;hp=8d5b3004537e0f0bd492febe1c803358de89fe97;hb=a473a2a85dbf5325b270a906e85785ba4b032503;hpb=ce775bd9934502af12b07085d4ea458630de066b diff --git a/w32log.c b/w32log.c index 8d5b3004..b60eae78 100644 --- a/w32log.c +++ b/w32log.c @@ -1,18 +1,17 @@ -const char w32log_rcs[] = "$Id: w32log.c,v 1.36 2009/11/08 18:09:52 ler762 Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/w32log.c,v $ * * Purpose : Functions for creating and destroying the log window, - * ouputting strings, processing messages and so on. + * outputting strings, processing messages and so on. * * Copyright : Written by and Copyright (C) 2001-2009 members of - * the Privoxy team. http://www.privoxy.org/ + * the Privoxy team. https://www.privoxy.org/ * * Written by and Copyright (C) 1999 Adam Lock * * - * This program is free software; you can redistribute it + * This program is free software; you can redistribute it * and/or 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 @@ -41,6 +40,7 @@ const char w32log_rcs[] = "$Id: w32log.c,v 1.36 2009/11/08 18:09:52 ler762 Exp $ #ifndef STRICT #define STRICT #endif +#include #include #include @@ -54,15 +54,6 @@ const char w32log_rcs[] = "$Id: w32log.c,v 1.36 2009/11/08 18:09:52 ler762 Exp $ #include "errlog.h" #include "loadcfg.h" -const char w32res_h_rcs[] = W32RES_H_VERSION; - -#ifdef __MINGW32__ -#include "cygwin.h" -const char cygwin_h_rcs[] = CYGWIN_H_VERSION; -#endif - -const char w32log_h_rcs[] = W32LOG_H_VERSION; - #ifndef _WIN_CONSOLE /* entire file */ /* @@ -135,7 +126,8 @@ int g_nFontSize = DEFAULT_LOG_FONT_SIZE; const char * g_default_actions_file = NULL; const char * g_user_actions_file = NULL; -const char * g_re_filterfile = NULL; +const char * g_default_filterfile = NULL; +const char * g_user_filterfile = NULL; #ifdef FEATURE_TRUST const char * g_trustfile = NULL; #endif /* def FEATURE_TRUST */ @@ -171,6 +163,9 @@ static struct _Pattern { "Connect: Reusing server socket", STYLE_HIGHLIGHT }, { "Connect: Created new connection to", STYLE_HIGHLIGHT }, { "hung up on us", STYLE_HIGHLIGHT }, + { "Info: Loading actions file:", STYLE_HIGHLIGHT }, + { "Info: Loading filter file:", STYLE_HIGHLIGHT }, + { "Info: Now toggled ", STYLE_HIGHLIGHT }, { "Crunching Referer:", STYLE_HIGHLIGHT }, /* what are all the possible error strings?? */ { "Error:", STYLE_HIGHLIGHT }, @@ -369,12 +364,12 @@ int LogPutString(const char *pszText) int i; int result = 0; - if (pszText == NULL || strlen(pszText) == 0) + if (!g_bLogMessages) { return 1; } - if (!g_bLogMessages) + if (pszText == NULL || strlen(pszText) == 0) { return 1; } @@ -597,13 +592,13 @@ void LogClipBuffer(void) range.cpMin = SendMessage (g_hwndLogBox, WM_GETTEXTLENGTH, 0, 0); range.cpMax = -1; SendMessage(g_hwndLogBox, EM_EXSETSEL, 0, (LPARAM) &range); - + /* restore vertical ScrollBar stuff (messed up by AUTOVSCROLL) */ SendMessage (g_hwndLogBox, EM_SCROLL, SB_LINEDOWN, 0); - + } -} +} /********************************************************************* @@ -640,7 +635,7 @@ HWND CreateHiddenLogOwnerWindow(HINSTANCE hInstance) hwnd = CreateWindow(szWndName, szWndName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); + CW_USEDEFAULT, NULL, NULL, hInstance, NULL); return hwnd; @@ -723,8 +718,8 @@ HWND CreateLogWindow(HINSTANCE hInstance, int nCmdShow) /* SendMessage(g_hwndLogBox, EM_SETWORDWRAPMODE, 0, 0); */ /* Subclass the control to catch certain messages */ - g_fnLogBox = (WNDPROC) GetWindowLong(g_hwndLogBox, GWL_WNDPROC); - SetWindowLong(g_hwndLogBox, GWL_WNDPROC, (LONG) LogRichEditProc); + g_fnLogBox = (WNDPROC) GetWindowLongPtr(g_hwndLogBox, GWLP_WNDPROC); + SetWindowLongPtr(g_hwndLogBox, GWLP_WNDPROC, (LONG_PTR) LogRichEditProc); /* Minimizing looks stupid when the log window is not on the task bar, so hide instead */ if (!g_bShowOnTaskBar && @@ -805,7 +800,7 @@ void ShowLogWindow(BOOL bShow) { SetForegroundWindow(g_hwndLogFrame); SetWindowPos(g_hwndLogFrame, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE); - + } else if (g_bShowOnTaskBar) { @@ -943,18 +938,17 @@ void OnLogCommand(int nCommand) break; #ifdef FEATURE_TOGGLE - /* by haroon - change toggle to its opposite value */ case ID_TOGGLE_ENABLED: global_toggle_state = !global_toggle_state; - if (global_toggle_state) - { - log_error(LOG_LEVEL_INFO, "Now toggled ON."); - } - else - { - log_error(LOG_LEVEL_INFO, "Now toggled OFF."); - } - SetIdleIcon(); + log_error(LOG_LEVEL_INFO, + "Now toggled %s", global_toggle_state ? "ON" : "OFF"); + /* + * Leverage TIMER_ANIMSTOP_ID to set the idle icon through the + * "application queue". According to MSDN, 10 milliseconds are + * the lowest value possible and seem to be close enough to + * "instantly". + */ + SetTimer(g_hwndLogFrame, TIMER_ANIMSTOP_ID, 10, NULL); break; #endif /* def FEATURE_TOGGLE */ @@ -970,8 +964,12 @@ void OnLogCommand(int nCommand) EditFile(g_user_actions_file); break; - case ID_TOOLS_EDITFILTERS: - EditFile(g_re_filterfile); + case ID_TOOLS_EDITDEFAULTFILTERS: + EditFile(g_default_filterfile); + break; + + case ID_TOOLS_EDITUSERFILTERS: + EditFile(g_user_filterfile); break; #ifdef FEATURE_TRUST @@ -1026,7 +1024,8 @@ void OnLogInitMenu(HMENU hmenu) /* Only enable editors if there is a file to edit */ EnableMenuItem(hmenu, ID_TOOLS_EDITDEFAULTACTIONS, MF_BYCOMMAND | (g_default_actions_file ? MF_ENABLED : MF_GRAYED)); EnableMenuItem(hmenu, ID_TOOLS_EDITUSERACTIONS, MF_BYCOMMAND | (g_user_actions_file ? MF_ENABLED : MF_GRAYED)); - EnableMenuItem(hmenu, ID_TOOLS_EDITFILTERS, MF_BYCOMMAND | (g_re_filterfile ? MF_ENABLED : MF_GRAYED)); + EnableMenuItem(hmenu, ID_TOOLS_EDITDEFAULTFILTERS, MF_BYCOMMAND | (g_default_filterfile ? MF_ENABLED : MF_GRAYED)); + EnableMenuItem(hmenu, ID_TOOLS_EDITUSERFILTERS, MF_BYCOMMAND | (g_user_filterfile ? MF_ENABLED : MF_GRAYED)); #ifdef FEATURE_TRUST EnableMenuItem(hmenu, ID_TOOLS_EDITTRUST, MF_BYCOMMAND | (g_trustfile ? MF_ENABLED : MF_GRAYED)); #endif /* def FEATURE_TRUST */ @@ -1105,7 +1104,6 @@ void SetIdleIcon() if (!global_toggle_state) { TraySetIcon(g_hwndTray, 1, g_hiconOff); - /* log_error(LOG_LEVEL_INFO, "Privoxy OFF icon selected."); */ } else #endif /* def FEATURE_TOGGLE */ @@ -1178,7 +1176,7 @@ LRESULT CALLBACK LogWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara return 0; case WM_CLOSE: - /* This is the end - beautiful friend - the end */ + /* This is the end - my only friend - the end */ DestroyWindow(g_hwndLogBox); DestroyWindow(g_hwndLogFrame); return 0;