In the "I would like to help ..." entry:
[privoxy.git] / w32log.c
index dc3f3ac..927796d 100644 (file)
--- a/w32log.c
+++ b/w32log.c
@@ -1,4 +1,4 @@
-const char w32log_rcs[] = "$Id: w32log.c,v 1.28 2008/11/02 14:37:47 ler762 Exp $";
+const char w32log_rcs[] = "$Id: w32log.c,v 1.32 2009/03/09 18:32:48 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/w32log.c,v $
@@ -6,7 +6,7 @@ const char w32log_rcs[] = "$Id: w32log.c,v 1.28 2008/11/02 14:37:47 ler762 Exp $
  * Purpose     :  Functions for creating and destroying the log window,
  *                ouputting strings, processing messages and so on.
  *
- * Copyright   :  Written by and Copyright (C) 2001-2002 members of
+ * Copyright   :  Written by and Copyright (C) 2001-2009 members of
  *                the Privoxy team.  http://www.privoxy.org/
  *
  *                Written by and Copyright (C) 1999 Adam Lock
@@ -32,6 +32,22 @@ const char w32log_rcs[] = "$Id: w32log.c,v 1.28 2008/11/02 14:37:47 ler762 Exp $
  *
  * Revisions   :
  *    $Log: w32log.c,v $
+ *    Revision 1.32  2009/03/09 18:32:48  fabiankeil
+ *    Use the Privoxy icon in the alt+tab window.
+ *    Patch submitted by Burberry in #2674342.
+ *
+ *    Revision 1.31  2009/03/07 17:58:02  fabiankeil
+ *    Fix two mingw32-only buffer overflows. Note that triggering
+ *    them requires control over the configuration file in which
+ *    case all bets are off anyway.
+ *
+ *    Revision 1.30  2009/01/01 15:09:23  ler762
+ *    Change the Windows taskbar icon when privoxy is toggled off.
+ *
+ *    Revision 1.29  2008/12/20 15:27:40  ler762
+ *    The crunch log message format changed, so update the strings to highlight
+ *    in the log window.
+ *
  *    Revision 1.28  2008/11/02 14:37:47  ler762
  *    commit the part of the patches I've been using that were written by torford and gjmurphy
  *      [ 1824315 ] Minor code cleanup
@@ -280,7 +296,7 @@ BOOL g_bLimitBufferSize = 1;
 int g_nMaxBufferLines = DEFAULT_MAX_BUFFER_LINES;
 
 /* Font to use */
-char g_szFontFaceName[255] = DEFAULT_LOG_FONT_NAME;
+char g_szFontFaceName[32] = DEFAULT_LOG_FONT_NAME;
 
 /* Size of font to use */
 int g_nFontSize = DEFAULT_LOG_FONT_SIZE;
@@ -367,6 +383,7 @@ static HWND g_hwndLogBox;
 static WNDPROC g_fnLogBox;
 static HICON g_hiconAnim[ANIM_FRAMES];
 static HICON g_hiconIdle;
+static HICON g_hiconOff;
 static int g_nAnimFrame;
 static BOOL g_bClipPending = FALSE;
 static int g_nRichEditVersion = 0;
@@ -384,6 +401,7 @@ static void LogClipBuffer(void);
 static void LogCreatePatternMatchingBuffers(void);
 static void LogDestroyPatternMatchingBuffers(void);
 static int LogPutStringNoMatch(const char *pszText, int style);
+static void SetIdleIcon(void);
 
 
 /*********************************************************************
@@ -403,6 +421,7 @@ BOOL InitLogWindow(void)
 
    /* Load the icons */
    g_hiconIdle = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_IDLE));
+   g_hiconOff  = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_OFF));
    for (i = 0; i < ANIM_FRAMES; i++)
    {
       g_hiconAnim[i] = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ANIMATED1 + i));
@@ -445,6 +464,7 @@ void TermLogWindow(void)
    TrayDeleteIcon(g_hwndTray, 1);
    DeleteObject(g_hiconApp);
    DeleteObject(g_hiconIdle);
+   DeleteObject(g_hiconOff);
    for (i = 0; i < ANIM_FRAMES; i++)
    {
       DeleteObject(g_hiconAnim[i]);
@@ -694,9 +714,11 @@ int LogPutStringNoMatch(const char *pszText, int style)
    /* Apply a formatting style */
    memset(&format, 0, sizeof(format));
    format.cbSize = sizeof(format);
-   format.dwMask = CFM_BOLD | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_ITALIC | CFM_COLOR | CFM_FACE | CFM_SIZE;
+   format.dwMask = CFM_BOLD | CFM_UNDERLINE | CFM_STRIKEOUT |
+      CFM_ITALIC | CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_CHARSET;
+   format.bCharSet = DEFAULT_CHARSET;
    format.yHeight = (g_nFontSize * 1440) / 72;
-   strcpy(format.szFaceName, g_szFontFaceName);
+   strlcpy(format.szFaceName, g_szFontFaceName, sizeof(format.szFaceName));
    if (style == STYLE_NONE)
    {
       /* DO NOTHING */
@@ -835,7 +857,7 @@ HWND CreateHiddenLogOwnerWindow(HINSTANCE hInstance)
    wc.cbClsExtra     = 0;
    wc.cbWndExtra     = 0;
    wc.hInstance      = hInstance;
-   wc.hIcon          = 0;
+   wc.hIcon          = g_hiconApp;
    wc.hCursor        = 0;
    wc.hbrBackground  = 0;
    wc.lpszMenuName   = 0;
@@ -1159,6 +1181,7 @@ void OnLogCommand(int nCommand)
          {
             log_error(LOG_LEVEL_INFO, "Now toggled OFF.");
          }
+         SetIdleIcon();
          break;
 #endif /* def FEATURE_TOGGLE */
 
@@ -1271,7 +1294,7 @@ void OnLogTimer(int nTimer)
 
       case TIMER_ANIMSTOP_ID:
          g_nAnimFrame = 0;
-         TraySetIcon(g_hwndTray, 1, g_hiconIdle);
+         SetIdleIcon();
          KillTimer(g_hwndLogFrame, TIMER_ANIM_ID);
          KillTimer(g_hwndLogFrame, TIMER_ANIMSTOP_ID);
          break;
@@ -1292,6 +1315,31 @@ void OnLogTimer(int nTimer)
 }
 
 
+/*********************************************************************
+ *
+ * Function    :  SetIdleIcon
+ *
+ * Description :  Sets the tray icon to either idle or off
+ *
+ * Parameters  :  none
+ *
+ * Returns     :  N/A
+ *
+ *********************************************************************/
+void SetIdleIcon()
+{
+#ifdef FEATURE_TOGGLE
+         if (!global_toggle_state)
+         {
+            TraySetIcon(g_hwndTray, 1, g_hiconOff);
+            /* log_error(LOG_LEVEL_INFO, "Privoxy OFF icon selected."); */
+         }
+         else
+#endif /* def FEATURE_TOGGLE */
+         TraySetIcon(g_hwndTray, 1, g_hiconIdle);
+}
+
+
 /*********************************************************************
  *
  * Function    :  LogRichEditProc