-const char w32log_rcs[] = "$Id: w32log.c,v 1.34 2009/05/16 13:27:20 fabiankeil Exp $";
+const char w32log_rcs[] = "$Id: w32log.c,v 1.45 2012/05/24 15:05:17 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/w32log.c,v $
* Written by and Copyright (C) 1999 Adam Lock
* <locka@iol.ie>
*
- * 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
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 */
{ "Crunch: Connection failure", STYLE_HIGHLIGHT },
{ "Crunch: Out of memory", STYLE_HIGHLIGHT },
{ "Connect: Found reusable socket", STYLE_HIGHLIGHT },
+ { "Connect: Reusing server socket", STYLE_HIGHLIGHT },
{ "Connect: Created new connection to", STYLE_HIGHLIGHT },
+ { "hung up on us", STYLE_HIGHLIGHT },
+ { "Crunching Referer:", STYLE_HIGHLIGHT },
/* what are all the possible error strings?? */
{ "Error:", STYLE_HIGHLIGHT },
/* http headers */
}
-/*********************************************************************
- *
- * Function : LogGetURLUnderCursor
- *
- * Description : Returns the URL from under the cursor (remember to free it!).
- *
- * Parameters : None
- *
- * Returns : NULL or a pointer to an URL string.
- *
- *********************************************************************/
-char *LogGetURLUnderCursor(void)
-{
- char *szResult = NULL;
- regex_t re;
- POINT ptCursor;
- POINTL ptl;
- DWORD nPos;
- DWORD nWordStart = 0;
- DWORD nWordEnd = 0;
-
- regcomp(&re, RE_URL, REG_ICASE);
-
- /* Get the position of the cursor over the text window */
- GetCursorPos(&ptCursor);
- ScreenToClient(g_hwndLogBox, &ptCursor);
- ptl.x = ptCursor.x;
- ptl.y = ptCursor.y;
-
- /* Search backwards and fowards to obtain the word that is highlighted */
- nPos = LOWORD(SendMessage(g_hwndLogBox, EM_CHARFROMPOS, 0, (LPARAM) &ptl));
- nWordStart = SendMessage(g_hwndLogBox, EM_FINDWORDBREAK, WB_LEFT, nPos);
- nWordEnd = SendMessage(g_hwndLogBox, EM_FINDWORDBREAK, WB_RIGHTBREAK, nPos);
-
- /* Compare the string to the pattern */
- if (nWordEnd > nWordStart)
- {
- TEXTRANGE range;
- regmatch_t match;
-
- range.chrg.cpMin = nWordStart;
- range.chrg.cpMax = nWordEnd;
- range.lpstrText = (LPSTR)zalloc(nWordEnd - nWordStart + 1);
- SendMessage(g_hwndLogBox, EM_GETTEXTRANGE, 0, (LPARAM) &range);
-
- if (regexec(&re, range.lpstrText, 1, &match, 0) == 0)
- {
- szResult = range.lpstrText;
- }
- else
- {
- free(range.lpstrText);
- }
-
- regfree(&re);
- }
- return szResult;
-
-}
-
-
/*********************************************************************
*
* Function : LogPutString
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;
}
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);
-
+
}
-}
+}
/*********************************************************************
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;
{
SetForegroundWindow(g_hwndLogFrame);
SetWindowPos(g_hwndLogFrame, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
-
+
}
else if (g_bShowOnTaskBar)
{
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 */
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
/* 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 */
if (!global_toggle_state)
{
TraySetIcon(g_hwndTray, 1, g_hiconOff);
- /* log_error(LOG_LEVEL_INFO, "Privoxy OFF icon selected."); */
}
else
#endif /* def FEATURE_TOGGLE */
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;