diff options
author | Rozhuk Ivan <rozhuk.im@gmail.com> | 2014-12-12 11:46:50 +0000 |
---|---|---|
committer | Rozhuk Ivan <rozhuk.im@gmail.com> | 2014-12-12 11:46:50 +0000 |
commit | 0af013506f236f576be1f1eb9dd9c02196e6ab70 (patch) | |
tree | add6205986a6e002a45ebd114469b58a3104cdcd /plugins/HistoryLinkListPlus | |
parent | 2d436102558cc745e951c596271b6fcec829851f (diff) |
HistoryLinkListPlus: multiple fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@11346 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/HistoryLinkListPlus')
-rw-r--r-- | plugins/HistoryLinkListPlus/res/linklist.rc | 6 | ||||
-rw-r--r-- | plugins/HistoryLinkListPlus/src/linklist.cpp | 79 | ||||
-rw-r--r-- | plugins/HistoryLinkListPlus/src/linklist.h | 30 | ||||
-rw-r--r-- | plugins/HistoryLinkListPlus/src/linklist_dlg.cpp | 847 | ||||
-rw-r--r-- | plugins/HistoryLinkListPlus/src/linklist_dlg.h | 4 | ||||
-rw-r--r-- | plugins/HistoryLinkListPlus/src/linklist_fct.cpp | 293 |
6 files changed, 549 insertions, 710 deletions
diff --git a/plugins/HistoryLinkListPlus/res/linklist.rc b/plugins/HistoryLinkListPlus/res/linklist.rc index 6fb41fecc6..d9624c4e24 100644 --- a/plugins/HistoryLinkListPlus/res/linklist.rc +++ b/plugins/HistoryLinkListPlus/res/linklist.rc @@ -81,9 +81,9 @@ EXSTYLE WS_EX_CONTROLPARENT MENU IDR_MENU1
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
- CONTROL "",IDC_MAIN,"RICHEDIT",TCS_HOTTRACK | TCS_VERTICAL | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,0,1,145,25
+ CONTROL "",IDC_MAIN,"RichEdit50W",TCS_HOTTRACK | TCS_VERTICAL | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,0,1,145,25
LTEXT "Static",IDC_STATUS,0,42,145,10,SS_SUNKEN
- CONTROL "",IDC_MESSAGE,"RICHEDIT",TCS_HOTTRACK | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_VSCROLL | WS_TABSTOP,0,29,145,12
+ CONTROL "",IDC_MESSAGE,"RichEdit50W",TCS_HOTTRACK | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_VSCROLL | WS_TABSTOP,0,29,145,12
CONTROL "",IDC_SPLITTER,"Static",SS_ENHMETAFILE,0,27,145,2
END
@@ -106,7 +106,7 @@ BEGIN LTEXT "Text color",IDC_TXTTXT,18,141,85,11
CONTROL "",IDC_TXT,"ColourPicker",WS_TABSTOP,115,140,39,10
PUSHBUTTON "Plugin default",IDC_DEFAULT_TXT,159,139,65,11
- CONTROL "",IDC_OPTIONS_RE,"RICHEDIT",TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED | WS_TABSTOP,5,191,242,44
+ CONTROL "",IDC_OPTIONS_RE,"RichEdit50W",TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED | WS_TABSTOP,5,191,242,44
GROUPBOX "General settings",IDC_STATIC,0,0,226,85
CONTROL "Open links always in a new window",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,19,216,10
CONTROL "Update list on new events",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,30,216,10
diff --git a/plugins/HistoryLinkListPlus/src/linklist.cpp b/plugins/HistoryLinkListPlus/src/linklist.cpp index 15fc8679bb..b41af89a65 100644 --- a/plugins/HistoryLinkListPlus/src/linklist.cpp +++ b/plugins/HistoryLinkListPlus/src/linklist.cpp @@ -18,8 +18,8 @@ #include "linklist.h"
// Global variables
-HINSTANCE hInst;
-HINSTANCE hRichEdit;
+HINSTANCE hInst;
+
HANDLE hWindowList;
HCURSOR splitCursor;
@@ -49,16 +49,6 @@ extern "C" __declspec(dllexport) int Load(void) {
mir_getLP(&pluginInfo);
- // Load Rich Edit control
- hRichEdit = LoadLibrary(_T("Msftedit.DLL"));
- if (!hRichEdit)
- {
- // If Rich Edit DLL load fails, exit
- MessageBox(NULL, _T("Unable to load the Rich Edit control!"), _T("Error"), MB_OK | MB_ICONEXCLAMATION);
- FreeLibrary(hRichEdit);
- return 1;
- }
-
#ifdef DEBUG
{
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
@@ -75,7 +65,7 @@ extern "C" __declspec(dllexport) int Load(void) mi.ptszName = LPGENT("&Create Linklist");
mi.pszService = "Linklist/MenuCommand";
Menu_AddContactMenuItem(&mi);
-
+
hWindowList = WindowList_Create();
WNDCLASS wndclass = { 0 };
@@ -89,10 +79,10 @@ extern "C" __declspec(dllexport) int Load(void) RegisterClass(&wndclass);
splitCursor = LoadCursor(NULL, IDC_SIZENS);
-
+
HookEvent(ME_OPT_INITIALISE, InitOptionsDlg);
HookEvent(ME_DB_EVENT_ADDED, DBUpdate);
-
+
return 0;
}
@@ -124,18 +114,17 @@ int InitOptionsDlg(WPARAM wParam, LPARAM) static INT_PTR LinkList_Main(WPARAM hContact, LPARAM)
{
HWND hWnd = WindowList_Find(hWindowList, hContact);
- if ( hWnd != NULL ) {
- int len;
+ if (hWnd != NULL) {
SetForegroundWindow(hWnd);
SetFocus(hWnd);
- len = GetWindowTextLength(GetDlgItem(hWnd, IDC_MAIN));
+ int len = GetWindowTextLength(GetDlgItem(hWnd, IDC_MAIN));
PostMessage(GetDlgItem(hWnd, IDC_MAIN), EM_SETSEL, (WPARAM)len, (LPARAM)len);
return 0;
}
HANDLE hEvent = db_event_first(hContact);
if (hEvent == NULL) {
- MessageBox(NULL, TXT_EMPTYHISTORY, TXT_PLUGINNAME, MB_OK | MB_ICONINFORMATION );
+ MessageBox(NULL, TXT_EMPTYHISTORY, TXT_PLUGINNAME, (MB_OK | MB_ICONINFORMATION));
return 0;
}
@@ -143,68 +132,68 @@ static INT_PTR LinkList_Main(WPARAM hContact, LPARAM) DBEVENTINFO dbe = { sizeof(dbe) };
dbe.cbBlob = db_event_getBlobSize(hEvent);
- dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1);
+ dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob + 1);
db_event_get(hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
RECT DesktopRect;
GetWindowRect(GetDesktopWindow(), &DesktopRect);
HWND hWndProgress = CreateWindow(_T("Progressbar"), TranslateT("Processing history..."), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, 350, 45, NULL, NULL, hInst, NULL);
- if ( hWndProgress == 0 ) {
- free(dbe.pBlob);
+ if (hWndProgress == NULL) {
+ mir_free(dbe.pBlob);
MessageBox(NULL, TranslateT("Could not create window!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION );
return -1;
}
- SetWindowPos(hWndProgress, HWND_TOP, (int)(DesktopRect.right*0.5)-175, (int)(DesktopRect.bottom*0.5)-22, 0, 0, SWP_NOSIZE);
+ SetWindowPos(hWndProgress, HWND_TOP, (int)((DesktopRect.right / 2) - 175), (int)((DesktopRect.bottom / 2) - 22), 0, 0, SWP_NOSIZE);
ShowWindow(hWndProgress, SW_SHOW);
SetForegroundWindow(hWndProgress);
- LISTELEMENT *listStart = (LISTELEMENT*)malloc(sizeof(LISTELEMENT));
+ LISTELEMENT *listStart = (LISTELEMENT*)mir_alloc(sizeof(LISTELEMENT));
memset(listStart, 0, sizeof(LISTELEMENT));
- while( 1 ) {
- if ( dbe.eventType == EVENTTYPE_URL || dbe.eventType == EVENTTYPE_MESSAGE ) {
+ for (;;) {
+ if (dbe.eventType == EVENTTYPE_URL || dbe.eventType == EVENTTYPE_MESSAGE) {
// Call function to find URIs
- if ( ExtractURI(&dbe, hEvent, listStart) < 0 ) {
- free(dbe.pBlob);
+ if (ExtractURI(&dbe, hEvent, listStart) < 0) {
+ mir_free(dbe.pBlob);
RemoveList(listStart);
MessageBox(NULL, TranslateT("Could not allocate memory!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION);
return -1;
}
}
- actCount++;
- if ( ((int)(((float)actCount/histCount)*100.00)) % 10 == 0 )
- SendMessage(hWndProgress, WM_COMMAND, 100, ((int)(((float)actCount/histCount)*100.00)));
+ actCount ++;
+ if (((int)(((float)actCount / histCount) * 100.00)) % 10 == 0)
+ SendMessage(hWndProgress, WM_COMMAND, 100, ((int)(((float)actCount / histCount) * 100.00)));
hEvent = db_event_next(hContact, hEvent);
- if ( hEvent == NULL )
+ if (hEvent == NULL)
break;
-
- free(dbe.pBlob);
+ mir_free(dbe.pBlob);
dbe.cbBlob = db_event_getBlobSize(hEvent);
- dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1);
+ dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob + 1);
db_event_get(hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
}
- free(dbe.pBlob);
+ mir_free(dbe.pBlob);
SendMessage(hWndProgress, WM_CLOSE, 0, 0);
- if ( ListCount(listStart) <= 0 ) {
+ if (ListCount(listStart) <= 0) {
RemoveList(listStart);
- MessageBox(NULL, TXT_NOLINKINHISTORY, TXT_PLUGINNAME, MB_OK | MB_ICONINFORMATION);
+ MessageBox(NULL, TXT_NOLINKINHISTORY, TXT_PLUGINNAME, (MB_OK | MB_ICONINFORMATION));
return 0;
}
- DIALOGPARAM *DlgParam = (DIALOGPARAM*)malloc(sizeof(DIALOGPARAM));
- DlgParam->hContact = hContact;
- DlgParam->listStart = listStart;
+ DIALOGPARAM *DlgParam = (DIALOGPARAM*)mir_alloc(sizeof(DIALOGPARAM));
+ DlgParam->hContact = hContact;
+ DlgParam->listStart = listStart;
DlgParam->findMessage = 0;
- DlgParam->chrg.cpMax = -1;
- DlgParam->chrg.cpMin = -1;
+ DlgParam->chrg.cpMax = -1;
+ DlgParam->chrg.cpMin = -1;
HWND hWndMain = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_MAIN_DLG), NULL, MainDlgProc, (LPARAM)DlgParam);
- if (hWndMain == 0) {
+ if (hWndMain == NULL) {
+ mir_free(DlgParam);
RemoveList(listStart);
- MessageBox(NULL, TranslateT("Could not create window!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION );
+ MessageBox(NULL, TranslateT("Could not create window!"), TranslateT("Error"), (MB_OK | MB_ICONEXCLAMATION));
return -1;
}
diff --git a/plugins/HistoryLinkListPlus/src/linklist.h b/plugins/HistoryLinkListPlus/src/linklist.h index be23192b05..f3e89dd275 100644 --- a/plugins/HistoryLinkListPlus/src/linklist.h +++ b/plugins/HistoryLinkListPlus/src/linklist.h @@ -45,11 +45,11 @@ #define WLL_FILE 0x04
#define WLL_IN 0x08
#define WLL_OUT 0x10
-#define WLL_ALL (WLL_URL|WLL_MAIL|WLL_FILE|WLL_IN|WLL_OUT)
+#define WLL_ALL (WLL_URL | WLL_MAIL | WLL_FILE | WLL_IN | WLL_OUT)
#define SLL_DEEP 0x20
// String length
-#define LINK_MAX 1024
+#define LINK_MAX 1024
#define DIR_SIZE 6
#define TYPE_SIZE 5
#define DATE_SIZE 11
@@ -57,9 +57,9 @@ // Link types
#define LINK_UNKNOWN 0x00
-#define LINK_URL 0x01
-#define LINK_MAIL 0x02
-#define LINK_FILE 0x03
+#define LINK_URL 0x01
+#define LINK_MAIL 0x02
+#define LINK_FILE 0x03
// Directions
#define DIRECTION_IN 1
@@ -84,7 +84,7 @@ struct LISTELEMENT { struct LISTELEMENT *nextElement;
} ;
-typedef struct{
+typedef struct {
BYTE openNewWindow;
BYTE updateWindow;
BYTE mouseEvent;
@@ -94,9 +94,9 @@ typedef struct{ BYTE showTime;
BYTE showDirection;
BYTE showType;
-}LISTOPTIONS;
+} LISTOPTIONS;
-typedef struct{
+typedef struct {
DWORD incoming;
DWORD outgoing;
DWORD background;
@@ -111,24 +111,24 @@ typedef struct{ #define LINKLIST_BG_COL "BGColour"
#define LINKLIST_TXT_COL "TxtColour"
#define LINKLIST_USE_DEF "UseMirandaDefault"
-#define LINKLIST_OPEN_WINDOW "OpenNewWindow"
-#define LINKLIST_UPDATE_WINDOW "UpdateWindow"
-#define LINKLIST_MOUSE_EVENT "MessageView"
+#define LINKLIST_OPEN_WINDOW "OpenNewWindow"
+#define LINKLIST_UPDATE_WINDOW "UpdateWindow"
+#define LINKLIST_MOUSE_EVENT "MessageView"
#define LINKLIST_LEFT "WindowLeft"
#define LINKLIST_RIGHT "WindowRight"
#define LINKLIST_BOTTOM "WindowBottom"
#define LINKLIST_TOP "WindowTop"
#define LINKLIST_SPLITPOS "SplitterPos"
-#define LINKLIST_SAVESPECIAL "SavePosSpecial"
+#define LINKLIST_SAVESPECIAL "SavePosSpecial"
#define LINKLIST_FIRST "FirstStartup"
#define LINKLIST_SHOW_DATE "ShowDate"
#define LINKLIST_SHOW_LINE "ShowLine"
#define LINKLIST_SHOW_TIME "ShowTime"
-#define LINKLIST_SHOW_DIRECTION "ShowMessageDirection"
+#define LINKLIST_SHOW_DIRECTION "ShowMessageDirection"
#define LINKLIST_SHOW_TYPE "ShowMessageType"
-#define _mstrlen(x) (_countof(x)-1)
+#define _mstrlen(x) (SIZEOF(x) - 1)
#define MAKE_TXT_COL(BGCol) ((DWORD)~BGCol & 0x00FFFFFF)
#define DM_LINKSPLITTER WM_USER+99
@@ -136,7 +136,7 @@ typedef struct{ typedef struct LISTELEMENT LISTELEMENT;
// Dialogbox Parameter
-typedef struct{
+typedef struct {
MCONTACT hContact;
LISTELEMENT *listStart;
UINT findMessage;
diff --git a/plugins/HistoryLinkListPlus/src/linklist_dlg.cpp b/plugins/HistoryLinkListPlus/src/linklist_dlg.cpp index fc54122677..2836925d22 100644 --- a/plugins/HistoryLinkListPlus/src/linklist_dlg.cpp +++ b/plugins/HistoryLinkListPlus/src/linklist_dlg.cpp @@ -27,434 +27,328 @@ LISTOPTIONS options; /*
MainDlgProc handles messages to the main dialog box
*/
-INT_PTR WINAPI MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+INT_PTR CALLBACK MainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- ENLINK* pENLink;
- DIALOGPARAM *DlgParam;
- HMENU listMenu = GetMenu(hDlg);
-
- DlgParam = (DIALOGPARAM *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
- switch ( msg )
- {
- case WM_INITDIALOG:
- {
- MCONTACT hContact;
- TCHAR title[256];
- TCHAR filter[FILTERTEXT];
- RECT rc;
- POINT pt;
-
- SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
- DlgParam = (DIALOGPARAM *)lParam;
- TranslateDialogDefault(hDlg);
- TranslateMenu(listMenu);
-
- if ( db_get_b(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0x00) == 0x00 )
- hContact = NULL;
- else
- hContact = DlgParam->hContact;
+ DIALOGPARAM *DlgParam = (DIALOGPARAM*)GetWindowLongPtr(hDlg, GWLP_USERDATA);
+ HMENU listMenu;
+
+ switch (msg) {
+ case WM_INITDIALOG: {
+ MCONTACT hContact;
+ TCHAR title[256];
+ TCHAR filter[FILTERTEXT];
+ RECT rc;
+ POINT pt;
- if ( db_get_b(hContact, LINKLIST_MODULE, LINKLIST_FIRST, 0) == 0 )
- {
- // First use of this plugin! Set default size!
- db_set_dw(hContact, LINKLIST_MODULE, "LinklistWidth", 400);
- db_set_dw(hContact, LINKLIST_MODULE, "LinklistHeight", 450);
- db_set_dw(hContact, LINKLIST_MODULE, "LinklistX", 0);
- db_set_dw(hContact, LINKLIST_MODULE, "LinklistY", 0);
+ SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
+ DlgParam = (DIALOGPARAM*)lParam;
+ listMenu = GetMenu(hDlg);
+ TranslateDialogDefault(hDlg);
+ TranslateMenu(listMenu);
+
+ hContact = ((db_get_b(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0) == 0) ? NULL: DlgParam->hContact);
+ if (db_get_b(hContact, LINKLIST_MODULE, LINKLIST_FIRST, 0) == 0) {
+ // First use of this plugin! Set default size!
+ db_set_dw(hContact, LINKLIST_MODULE, "LinklistWidth", 400);
+ db_set_dw(hContact, LINKLIST_MODULE, "LinklistHeight", 450);
+ db_set_dw(hContact, LINKLIST_MODULE, "LinklistX", 0);
+ db_set_dw(hContact, LINKLIST_MODULE, "LinklistY", 0);
- db_set_b(hContact, LINKLIST_MODULE, LINKLIST_FIRST, 1);
- }
+ db_set_b(hContact, LINKLIST_MODULE, LINKLIST_FIRST, 1);
+ }
- DlgParam->splitterPosNew = (int)db_get_dw(hContact, LINKLIST_MODULE, LINKLIST_SPLITPOS, -1);
+ DlgParam->splitterPosNew = (int)db_get_dw(hContact, LINKLIST_MODULE, LINKLIST_SPLITPOS, -1);
- GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rc);
- DlgParam->minSize.cx = rc.right - rc.left;
- DlgParam->minSize.cy = rc.bottom - rc.top;
+ GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rc);
+ DlgParam->minSize.cx = rc.right - rc.left;
+ DlgParam->minSize.cy = rc.bottom - rc.top;
- GetWindowRect(GetDlgItem(hDlg, IDC_SPLITTER), &rc);
- pt.y = (rc.top + rc.bottom) / 2;
- pt.x = 0;
- ScreenToClient(hDlg, &pt);
+ GetWindowRect(GetDlgItem(hDlg, IDC_SPLITTER), &rc);
+ pt.y = (rc.top + rc.bottom) / 2;
+ pt.x = 0;
+ ScreenToClient(hDlg, &pt);
- DlgParam->splitterPosOld = rc.bottom - 20 - pt.y;
- if(DlgParam->splitterPosNew == -1)
- DlgParam->splitterPosNew = DlgParam->splitterPosOld;
+ DlgParam->splitterPosOld = rc.bottom - 20 - pt.y;
+ if(DlgParam->splitterPosNew == -1)
+ DlgParam->splitterPosNew = DlgParam->splitterPosOld;
- Utils_RestoreWindowPosition(hDlg, hContact, LINKLIST_MODULE, "Linklist");
-
- SetClassLongPtr(hDlg, GCLP_HICON, (LONG_PTR)LoadIcon(hInst, MAKEINTRESOURCE(IDI_LINKLISTICON)));
- WindowList_Add(hWindowList, hDlg, DlgParam->hContact);
- mir_sntprintf(title, SIZEOF(title), _T("%s [%s]"), TranslateT("Linklist plugin"), (LPCTSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)DlgParam->hContact, GCDNF_TCHAR));
- SetWindowText(hDlg, title);
- GetFilterText(listMenu, filter, _countof(filter));
- SetDlgItemText(hDlg, IDC_STATUS, filter);
+ Utils_RestoreWindowPosition(hDlg, hContact, LINKLIST_MODULE, "Linklist");
+
+ SetClassLongPtr(hDlg, GCLP_HICON, (LONG_PTR)LoadIcon(hInst, MAKEINTRESOURCE(IDI_LINKLISTICON)));
+ WindowList_Add(hWindowList, hDlg, DlgParam->hContact);
+ mir_sntprintf(title, SIZEOF(title), _T("%s [%s]"), TranslateT("Linklist plugin"), (LPCTSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)DlgParam->hContact, GCDNF_TCHAR));
+ SetWindowText(hDlg, title);
+ GetFilterText(listMenu, filter, SIZEOF(filter));
+ SetDlgItemText(hDlg, IDC_STATUS, filter);
- mir_subclassWindow(GetDlgItem(hDlg, IDC_SPLITTER), SplitterProc);
+ mir_subclassWindow(GetDlgItem(hDlg, IDC_SPLITTER), SplitterProc);
- SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETEVENTMASK, 0, (LPARAM)ENM_LINK );
- SendDlgItemMessage( hDlg, IDC_MAIN, EM_AUTOURLDETECT, TRUE, 0 );
- // This is used in srmm... and I think he knew what he did... :)
- SendDlgItemMessage(hDlg, IDC_MAIN, EM_LIMITTEXT, (WPARAM)-1, 0);
-
- WriteLinkList( hDlg, WLL_ALL, (LISTELEMENT *)DlgParam->listStart, NULL, 0);
-
- return TRUE;
- }
-
- // open browser an load url if link is pressed
- // found at
- // http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.ui/2004-03/0133.html
- //
- // Popup menu on right mouse button is mainly taken from the miranda
- // send/receive messaging plugin.
- case WM_NOTIFY:
- {
- LPNMHDR lpNmhdr;
-
- lpNmhdr = (LPNMHDR)lParam;
- if ( lpNmhdr->code == EN_LINK )
- {
- LPTSTR link;
- char shEvent[10+1];
- BYTE openNewWindow, mouseEvent;
-
- memset(shEvent, 0, sizeof(shEvent));
-
- pENLink = (ENLINK*)lpNmhdr;
+ SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETEVENTMASK, 0, (LPARAM)ENM_LINK);
+ SendDlgItemMessage( hDlg, IDC_MAIN, EM_AUTOURLDETECT, TRUE, 0 );
+ // This is used in srmm... and I think he knew what he did... :)
+ SendDlgItemMessage(hDlg, IDC_MAIN, EM_LIMITTEXT, (WPARAM)-1, 0);
- mouseEvent = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0xFF);
+ WriteLinkList(hDlg, WLL_ALL, (LISTELEMENT*)DlgParam->listStart, NULL, 0);
- if ( pENLink->msg == WM_MOUSEMOVE && mouseEvent == 0x01 )
- {
- CopyMemory(&DlgParam->chrg, &pENLink->chrg, sizeof(CHARRANGE));
- SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)&pENLink->chrg);
- WriteMessage(hDlg, DlgParam->listStart, SendDlgItemMessage(hDlg, IDC_MAIN, EM_LINEFROMCHAR, -1, 0));
- }
- else if ( pENLink->msg == WM_LBUTTONUP )
- {
- link = (LPTSTR)malloc( (pENLink->chrg.cpMax-pENLink->chrg.cpMin+2)*sizeof(TCHAR));
- SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)(&pENLink->chrg));
- SendDlgItemMessage(hDlg, IDC_MAIN, EM_GETSELTEXT, 0, (LPARAM)link);
-
- if ( _tcsstr(link, _T("mailto:")) != NULL )
- ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL);
- else
- {
- openNewWindow = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_OPEN_WINDOW, 0xFF);
- if ( openNewWindow == 0xFF )
- openNewWindow = 0;
-
- CallService(MS_UTILS_OPENURL, openNewWindow, (LPARAM)link);
- }
- free(link);
- }
- else if ( pENLink->msg == WM_RBUTTONDOWN )
- {
- HMENU hPopup, hSubMenu;
- POINT pt;
- hPopup = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU2));
- hSubMenu = GetSubMenu(hPopup, 0);
-
- // Disable Menuoption if "mouse over" events are active
- mouseEvent = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0xFF);
- if (mouseEvent == 0x01 )
- EnableMenuItem(hSubMenu, IDM_SHOWMESSAGE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
-
- TranslateMenu(hSubMenu);
-
- link = (LPTSTR)malloc( (pENLink->chrg.cpMax-pENLink->chrg.cpMin+2)*sizeof(TCHAR));
- SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)(&(pENLink->chrg)));
- SendDlgItemMessage(hDlg, IDC_MAIN, EM_GETSELTEXT, 0, (LPARAM)link);
-
- pt.x = (short) LOWORD(((ENLINK *) lParam)->lParam);
- pt.y = (short) HIWORD(((ENLINK *) lParam)->lParam);
- ClientToScreen(((NMHDR *) lParam)->hwndFrom, &pt);
-
- switch ( TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, NULL))
- {
- case IDM_LINK_OPEN:
- {
- if ( _tcsstr(link, _T("mailto:")) != NULL )
- ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL);
- else
- CallService(MS_UTILS_OPENURL, 0, (LPARAM)link);
-
- break;
- }
- case IDM_LINK_OPENNEW:
- {
- if ( _tcsstr(link, _T("mailto:")) != NULL )
- ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL);
- else
- CallService(MS_UTILS_OPENURL, 1, (LPARAM)link);
-
- break;
- }
- case IDM_LINK_COPY:
- {
- size_t dataLen;
- HGLOBAL hData;
- if ( !OpenClipboard(hDlg))
- break;
- EmptyClipboard();
-
- dataLen = (_tcslen(link)+1)*sizeof(TCHAR);
- hData = GlobalAlloc(GMEM_MOVEABLE, dataLen);
- _tcscpy_s((LPTSTR)GlobalLock(hData), dataLen/2, link);
- GlobalUnlock(hData);
- SetClipboardData(CF_TEXT, hData);
- CloseClipboard();
- break;
- }
- case IDM_SHOWMESSAGE:
- {
- WriteMessage(hDlg, DlgParam->listStart, SendDlgItemMessage(hDlg, IDC_MAIN, EM_LINEFROMCHAR, -1, 0));
- break;
- }
- }
- free(link);
- DestroyMenu(hPopup);
- }
- }
+ return TRUE;
+ } break;
+ // open browser an load url if link is pressed
+ // found at
+ // http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.ui/2004-03/0133.html
+ //
+ // Popup menu on right mouse button is mainly taken from the miranda
+ // send/receive messaging plugin.
+ case WM_NOTIFY: {
+ if (lParam == NULL)
break;
- }
-
- case WM_COMMAND:
- {
- TCHAR filter[40];
+ if (((LPNMHDR)lParam)->code != EN_LINK)
+ break;
+ LPTSTR link;
+ BYTE openNewWindow, mouseEvent;
+ ENLINK *pENLink = (ENLINK*)lParam;
- // open Search Box
- if ( wParam == IDM_SEARCH )
- {
+ mouseEvent = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0xFF);
- HWND hWndSearchDlg;
- if ( DlgParam != 0 )
- {
- hWndSearchDlg = CreateDialogParam( hInst, MAKEINTRESOURCE(IDD_SEARCH_DLG), hDlg, SearchDlgProc, (LPARAM)DlgParam);
- EnableMenuItem(listMenu, IDM_SEARCH, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
- ShowWindow(hWndSearchDlg, SW_SHOW);
- SetFocus(GetDlgItem(hWndSearchDlg, IDC_SEARCHSTRING));
- }
-
+ switch (pENLink->msg) {
+ case WM_MOUSEMOVE:
+ if (mouseEvent != 0x01)
break;
- }
- // clear search results
- else if ( wParam == IDM_CLEARSEARCH )
- {
- GetFilterText(listMenu, filter, _countof(filter));
- SetDlgItemText(hDlg, IDC_STATUS, filter);
- SetDlgItemText(hDlg, IDC_MAIN, _T(""));
- WriteLinkList( hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
- }
- // save button
- else if ( wParam == IDM_SAVE )
- {
- SaveEditAsStream(hDlg);
- SetFocus(GetDlgItem( hDlg, IDC_MAIN ));
- break;
- }
- // Esc or Close pressed
- else if ( wParam == IDCANCEL || wParam == IDM_CLOSE )
- {
- SendMessage(hDlg, WM_CLOSE, 0, 0);
+ CopyMemory(&DlgParam->chrg, &pENLink->chrg, sizeof(CHARRANGE));
+ SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)&pENLink->chrg);
+ WriteMessage(hDlg, DlgParam->listStart, SendDlgItemMessage(hDlg, IDC_MAIN, EM_LINEFROMCHAR, -1, 0));
+ break;
+ case WM_LBUTTONUP:
+ link = (LPTSTR)mir_alloc((pENLink->chrg.cpMax - pENLink->chrg.cpMin + 2) * sizeof(TCHAR));
+ if (link == NULL)
break;
+ SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)(&pENLink->chrg));
+ SendDlgItemMessage(hDlg, IDC_MAIN, EM_GETSELTEXT, 0, (LPARAM)link);
+ if (_tcsstr(link, _T("mailto:")) != NULL) {
+ ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL);
+ } else {
+ openNewWindow = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_OPEN_WINDOW, 0xFF);
+ if (openNewWindow == 0xFF)
+ openNewWindow = 0;
+ CallService(MS_UTILS_OPENURL, openNewWindow, (LPARAM)link);
}
-
- // view only incoming messages
- else if ( wParam == IDM_DIR_IN )
- {
- GetFilterText(listMenu, filter, _countof(filter));
- SetDlgItemText(hDlg, IDC_STATUS, filter);
-
- // not possible if search dialog is open
- if ( !(GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
- {
- SetDlgItemText(hDlg, IDC_MAIN, _T(""));
-
- if ( GetMenuState(listMenu, IDM_DIR_IN, MF_BYCOMMAND) == MF_CHECKED )
- {
- CheckMenuItem(listMenu, IDM_DIR_IN, MF_UNCHECKED);
- WriteLinkList( hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
- }
- else
- {
- CheckMenuItem(listMenu, IDM_DIR_IN, MF_CHECKED);
- CheckMenuItem(listMenu, IDM_DIR_OUT, MF_UNCHECKED);
- WriteLinkList( hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
- }
-
- GetFilterText(GetMenu(hDlg), filter, _countof(filter));
- SetDlgItemText(hDlg, IDC_STATUS, filter);
- }
+ mir_free(link);
+ break;
+ case WM_RBUTTONDOWN: {
+ HMENU hPopup, hSubMenu;
+ POINT pt;
+ hPopup = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU2));
+ hSubMenu = GetSubMenu(hPopup, 0);
+
+ // Disable Menuoption if "mouse over" events are active
+ mouseEvent = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0xFF);
+ if (mouseEvent == 0x01)
+ EnableMenuItem(hSubMenu, IDM_SHOWMESSAGE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ TranslateMenu(hSubMenu);
+ link = (LPTSTR)mir_alloc((pENLink->chrg.cpMax - pENLink->chrg.cpMin + 2) * sizeof(TCHAR));
+ if (link == NULL)
break;
- }
-
- // view only outgoing messages
- else if ( wParam == IDM_DIR_OUT )
- {
- GetFilterText(listMenu, filter, _countof(filter));
- SetDlgItemText(hDlg, IDC_STATUS, filter);
+ SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)(&(pENLink->chrg)));
+ SendDlgItemMessage(hDlg, IDC_MAIN, EM_GETSELTEXT, 0, (LPARAM)link);
- // not possible if search dialog is open
- if ( !(GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
- {
- SetDlgItemText(hDlg, IDC_MAIN, _T(""));
- if ( GetMenuState(listMenu, IDM_DIR_OUT, MF_BYCOMMAND) == MF_CHECKED )
- {
- CheckMenuItem(listMenu, IDM_DIR_OUT, MF_UNCHECKED);
- WriteLinkList( hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
- }
- else
- {
- CheckMenuItem(listMenu, IDM_DIR_OUT, MF_CHECKED);
- CheckMenuItem(listMenu, IDM_DIR_IN, MF_UNCHECKED);
- WriteLinkList( hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
- }
+ pt.x = (short)LOWORD(pENLink->lParam);
+ pt.y = (short)HIWORD(pENLink->lParam);
+ ClientToScreen(((NMHDR*)lParam)->hwndFrom, &pt);
- GetFilterText(listMenu, filter, _countof(filter));
- SetDlgItemText(hDlg, IDC_STATUS, filter);
- }
+ switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, NULL)) {
+ case IDM_LINK_OPEN:
+ if (_tcsstr(link, _T("mailto:")) != NULL)
+ ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL);
+ else
+ CallService(MS_UTILS_OPENURL, 0, (LPARAM)link);
break;
- }
-
- // view only e-mailaddresses
- else if ( wParam == IDM_TYPE_WEB )
- {
- GetFilterText(listMenu, filter, _countof(filter));
- SetDlgItemText(hDlg, IDC_STATUS, filter);
-
- // not possible if search dialog is open
- if ( !(GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
- {
- SetDlgItemText(hDlg, IDC_MAIN, _T(""));
- if ( GetMenuState(listMenu, IDM_TYPE_WEB, MF_BYCOMMAND) == MF_CHECKED )
- {
- CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_UNCHECKED);
- WriteLinkList( hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
- }
- else
- {
- CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_CHECKED);
- CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_UNCHECKED);
- WriteLinkList( hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
- }
-
- GetFilterText(listMenu, filter, _countof(filter));
- SetDlgItemText(hDlg, IDC_STATUS, filter);
- }
+ case IDM_LINK_OPENNEW:
+ if (_tcsstr(link, _T("mailto:")) != NULL)
+ ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL);
+ else
+ CallService(MS_UTILS_OPENURL, 1, (LPARAM)link);
break;
- }
-
- // view only URLs
- else if ( wParam == IDM_TYPE_MAIL )
- {
- // not possible if search dialog is open
- if ( !(GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
- {
- SetDlgItemText(hDlg, IDC_MAIN, _T(""));
- if ( GetMenuState(listMenu, IDM_TYPE_MAIL, MF_BYCOMMAND) == MF_CHECKED )
- {
- CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_UNCHECKED);
- WriteLinkList( hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
- }
- else
- {
- CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_CHECKED);
- CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_UNCHECKED);
- WriteLinkList( hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
- }
-
- GetFilterText(listMenu, filter, _countof(filter));
- SetDlgItemText(hDlg, IDC_STATUS, filter);
- }
+ case IDM_LINK_COPY: {
+ size_t dataLen;
+ HGLOBAL hData;
+ if (!OpenClipboard(hDlg))
+ break;
+ EmptyClipboard();
+
+ dataLen = (_tcslen(link) + 1) * sizeof(TCHAR);
+ hData = GlobalAlloc(GMEM_MOVEABLE, dataLen);
+ _tcscpy_s((LPTSTR)GlobalLock(hData), dataLen / 2, link);
+ GlobalUnlock(hData);
+ SetClipboardData(CF_TEXT, hData);
+ CloseClipboard();
+ } break;
+ case IDM_SHOWMESSAGE:
+ WriteMessage(hDlg, DlgParam->listStart, SendDlgItemMessage(hDlg, IDC_MAIN, EM_LINEFROMCHAR, -1, 0));
break;
}
-
-
- break;
+ mir_free(link);
+ DestroyMenu(hPopup);
+ } break;
}
-
- // Taken from srmm.
- // Btw: The longer I searched the source of this plugin
- // to learn how things work, the more I became a fan of
- // the programmer!
- case WM_GETMINMAXINFO:
- {
- MINMAXINFO *mmi = (MINMAXINFO *)lParam;
- RECT rcWindow, rcMain;
- GetWindowRect(hDlg, &rcWindow);
- GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rcMain);
- mmi->ptMinTrackSize.x = rcWindow.right - rcWindow.left - ((rcMain.right - rcMain.left) - DlgParam->minSize.cx);
- mmi->ptMinTrackSize.y = rcWindow.bottom - rcWindow.top - ((rcMain.bottom - rcMain.top) - DlgParam->minSize.cy);
- return 0;
- }
-
- case WM_SIZE:
- {
- UTILRESIZEDIALOG urd = {0};
-
- urd.cbSize = sizeof(urd);
- urd.hwndDlg = hDlg;
- urd.hInstance = hInst;
- urd.lpTemplate = MAKEINTRESOURCEA(IDD_MAIN_DLG);
- urd.pfnResizer = LinklistResizer;
- urd.lParam = (LPARAM)DlgParam;
- CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
-
- // To get some scrollbars if needed...
- RedrawWindow(GetDlgItem(hDlg, IDC_MAIN), NULL, NULL, RDW_INVALIDATE);
- RedrawWindow(GetDlgItem(hDlg, IDC_MESSAGE), NULL, NULL, RDW_INVALIDATE);
+ } break;
+ case WM_COMMAND: {
+ TCHAR filter[40];
+
+ listMenu = GetMenu(hDlg);
+ switch (wParam) {
+ case IDM_SEARCH: // open Search Box
+ if (DlgParam != 0) {
+ HWND hWndSearchDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SEARCH_DLG), hDlg, SearchDlgProc, (LPARAM)DlgParam);
+ EnableMenuItem(listMenu, IDM_SEARCH, (MF_BYCOMMAND | MF_DISABLED | MF_GRAYED));
+ ShowWindow(hWndSearchDlg, SW_SHOW);
+ SetFocus(GetDlgItem(hWndSearchDlg, IDC_SEARCHSTRING));
+ }
break;
- }
-
- case DM_LINKSPLITTER:
- {
- POINT pt;
- RECT rc;
- int splitPosOld;
-
- GetClientRect(hDlg, &rc);
- pt.x = 0;
- pt.y = wParam;
- ScreenToClient(hDlg, &pt);
-
- splitPosOld = DlgParam->splitterPosNew;
- DlgParam->splitterPosNew = rc.bottom - pt.y;
-
- GetWindowRect(GetDlgItem(hDlg, IDC_MESSAGE), &rc);
- if (rc.bottom - rc.top + (DlgParam->splitterPosNew - splitPosOld) < 0)
- DlgParam->splitterPosNew = splitPosOld + 0 - (rc.bottom - rc.top);
-
- GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rc);
- if (rc.bottom - rc.top - (DlgParam->splitterPosNew - splitPosOld) < DlgParam->minSize.cy)
- DlgParam->splitterPosNew = splitPosOld - DlgParam->minSize.cy + (rc.bottom - rc.top);
-
- SendMessage(hDlg, WM_SIZE, 0, 0);
+ case IDM_CLEARSEARCH: // clear search results
+ GetFilterText(listMenu, filter, SIZEOF(filter));
+ SetDlgItemText(hDlg, IDC_STATUS, filter);
+ SetDlgItemText(hDlg, IDC_MAIN, _T(""));
+ WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
break;
- }
-
- case WM_CLOSE:
- {
- DestroyWindow(hDlg);
+ case IDM_SAVE: // save button
+ SaveEditAsStream(hDlg);
+ SetFocus(GetDlgItem(hDlg, IDC_MAIN));
+ break;
+ case IDCANCEL: // Esc or Close pressed
+ case IDM_CLOSE:
+ SendMessage(hDlg, WM_CLOSE, 0, 0);
+ break;
+ case IDM_DIR_IN: // view only incoming messages
+ GetFilterText(listMenu, filter, SIZEOF(filter));
+ SetDlgItemText(hDlg, IDC_STATUS, filter);
+ if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
+ break; // not possible if search dialog is open
+ SetDlgItemText(hDlg, IDC_MAIN, _T(""));
+ if (GetMenuState(listMenu, IDM_DIR_IN, MF_BYCOMMAND) == MF_CHECKED) {
+ CheckMenuItem(listMenu, IDM_DIR_IN, MF_UNCHECKED);
+ WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
+ } else {
+ CheckMenuItem(listMenu, IDM_DIR_IN, MF_CHECKED);
+ CheckMenuItem(listMenu, IDM_DIR_OUT, MF_UNCHECKED);
+ WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
+ }
+ GetFilterText(GetMenu(hDlg), filter, SIZEOF(filter));
+ SetDlgItemText(hDlg, IDC_STATUS, filter);
+ break;
+ case IDM_DIR_OUT: // view only outgoing messages
+ GetFilterText(listMenu, filter, SIZEOF(filter));
+ SetDlgItemText(hDlg, IDC_STATUS, filter);
+ if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
+ break; // not possible if search dialog is open
+ SetDlgItemText(hDlg, IDC_MAIN, _T(""));
+ if (GetMenuState(listMenu, IDM_DIR_OUT, MF_BYCOMMAND) == MF_CHECKED) {
+ CheckMenuItem(listMenu, IDM_DIR_OUT, MF_UNCHECKED);
+ WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
+ } else {
+ CheckMenuItem(listMenu, IDM_DIR_OUT, MF_CHECKED);
+ CheckMenuItem(listMenu, IDM_DIR_IN, MF_UNCHECKED);
+ WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
+ }
+ GetFilterText(listMenu, filter, SIZEOF(filter));
+ SetDlgItemText(hDlg, IDC_STATUS, filter);
+ break;
+ case IDM_TYPE_WEB: // view only e-mail addresses
+ GetFilterText(listMenu, filter, SIZEOF(filter));
+ SetDlgItemText(hDlg, IDC_STATUS, filter);
+ // not possible if search dialog is open
+ if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
+ break;
+ SetDlgItemText(hDlg, IDC_MAIN, _T(""));
+ if (GetMenuState(listMenu, IDM_TYPE_WEB, MF_BYCOMMAND) == MF_CHECKED) {
+ CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_UNCHECKED);
+ WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
+ } else {
+ CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_CHECKED);
+ CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_UNCHECKED);
+ WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
+ }
+ GetFilterText(listMenu, filter, SIZEOF(filter));
+ SetDlgItemText(hDlg, IDC_STATUS, filter);
+ break;
+ case IDM_TYPE_MAIL: // view only URLs
+ if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED))
+ break; // not possible if search dialog is open
+ SetDlgItemText(hDlg, IDC_MAIN, _T(""));
+ if (GetMenuState(listMenu, IDM_TYPE_MAIL, MF_BYCOMMAND) == MF_CHECKED) {
+ CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_UNCHECKED);
+ WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
+ } else {
+ CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_CHECKED);
+ CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_UNCHECKED);
+ WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0);
+ }
+ GetFilterText(listMenu, filter, SIZEOF(filter));
+ SetDlgItemText(hDlg, IDC_STATUS, filter);
break;
}
+ } break;
+ // Taken from srmm.
+ // Btw: The longer I searched the source of this plugin
+ // to learn how things work, the more I became a fan of
+ // the programmer!
+ case WM_GETMINMAXINFO: {
+ MINMAXINFO *mmi = (MINMAXINFO *)lParam;
+ RECT rcWindow, rcMain;
+
+ GetWindowRect(hDlg, &rcWindow);
+ GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rcMain);
+ mmi->ptMinTrackSize.x = rcWindow.right - rcWindow.left - ((rcMain.right - rcMain.left) - DlgParam->minSize.cx);
+ mmi->ptMinTrackSize.y = rcWindow.bottom - rcWindow.top - ((rcMain.bottom - rcMain.top) - DlgParam->minSize.cy);
+ } break;
+ case WM_SIZE: {
+ UTILRESIZEDIALOG urd = {0};
+
+ urd.cbSize = sizeof(urd);
+ urd.hwndDlg = hDlg;
+ urd.hInstance = hInst;
+ urd.lpTemplate = MAKEINTRESOURCEA(IDD_MAIN_DLG);
+ urd.pfnResizer = LinklistResizer;
+ urd.lParam = (LPARAM)DlgParam;
+ CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
+ // To get some scrollbars if needed...
+ RedrawWindow(GetDlgItem(hDlg, IDC_MAIN), NULL, NULL, RDW_INVALIDATE);
+ RedrawWindow(GetDlgItem(hDlg, IDC_MESSAGE), NULL, NULL, RDW_INVALIDATE);
+ } break;
+ case DM_LINKSPLITTER: {
+ POINT pt;
+ RECT rc;
+ int splitPosOld;
- case WM_DESTROY:
- {
- MCONTACT hContact;
- if ( db_get_b(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0x00) == 0x00 )
- hContact = NULL;
- else
- hContact = DlgParam->hContact;
+ GetClientRect(hDlg, &rc);
+ pt.x = 0;
+ pt.y = wParam;
+ ScreenToClient(hDlg, &pt);
+
+ splitPosOld = DlgParam->splitterPosNew;
+ DlgParam->splitterPosNew = rc.bottom - pt.y;
+
+ GetWindowRect(GetDlgItem(hDlg, IDC_MESSAGE), &rc);
+ if (rc.bottom - rc.top + (DlgParam->splitterPosNew - splitPosOld) < 0)
+ DlgParam->splitterPosNew = splitPosOld + 0 - (rc.bottom - rc.top);
+
+ GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rc);
+ if (rc.bottom - rc.top - (DlgParam->splitterPosNew - splitPosOld) < DlgParam->minSize.cy)
+ DlgParam->splitterPosNew = splitPosOld - DlgParam->minSize.cy + (rc.bottom - rc.top);
+ SendMessage(hDlg, WM_SIZE, 0, 0);
+ } break;
+ case WM_CLOSE:
+ DestroyWindow(hDlg);
+ break;
+ case WM_DESTROY:
+ if (DlgParam != NULL) {
+ MCONTACT hContact = ((db_get_b(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0) == 0) ? NULL: DlgParam->hContact);
Utils_SaveWindowPosition(hDlg, hContact, LINKLIST_MODULE, "Linklist");
db_set_dw(NULL, LINKLIST_MODULE, LINKLIST_SPLITPOS, DlgParam->splitterPosNew);
RemoveList(DlgParam->listStart);
- free(DlgParam);
- // Remove entry from Window list
- WindowList_Remove(hWindowList, hDlg);
- break;
+ mir_free(DlgParam);
}
-
+ // Remove entry from Window list
+ WindowList_Remove(hWindowList, hDlg);
+ break;
}
return FALSE;
}
@@ -462,74 +356,65 @@ INT_PTR WINAPI MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam ) /*
This function handles the search dialog messages
*/
-INT_PTR WINAPI SearchDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+INT_PTR CALLBACK SearchDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
{
HWND hListDlg;
- DIALOGPARAM *DlgParam;
-
- DlgParam = (DIALOGPARAM *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
- switch( msg )
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hDlg);
- SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)lParam);
- SetWindowText(hDlg, TXT_SEARCH);
- SendDlgItemMessage(hDlg, IDC_DIR_ALL, BM_SETCHECK, BST_CHECKED, 0);
- SendDlgItemMessage(hDlg, IDC_TYPE_ALL, BM_SETCHECK, BST_CHECKED, 0);
- return TRUE;
- }
- case WM_COMMAND:
- {
- HWND hWndMain;
- hWndMain = WindowList_Find(hWindowList,DlgParam->hContact);
+ DIALOGPARAM *DlgParam = (DIALOGPARAM *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hDlg);
+ SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ SetWindowText(hDlg, TXT_SEARCH);
+ SendDlgItemMessage(hDlg, IDC_DIR_ALL, BM_SETCHECK, BST_CHECKED, 0);
+ SendDlgItemMessage(hDlg, IDC_TYPE_ALL, BM_SETCHECK, BST_CHECKED, 0);
+ return TRUE;
+ break;
+ case WM_COMMAND: {
+ HWND hWndMain;
+ hWndMain = WindowList_Find(hWindowList,DlgParam->hContact);
- if ( wParam == IDCLOSE || wParam == IDCANCEL )
- {
- HMENU listMenu = GetMenu(hWndMain);
- EnableMenuItem(listMenu, 101, MF_BYCOMMAND | MF_ENABLED);
- DestroyWindow(hDlg);
- return TRUE;
- }
- else if ( wParam == IDSEARCH )
- {
- BYTE flags = 0x00;
- TCHAR filter[FILTERTEXT];
- LPTSTR buffer;
- int length;
-
- hListDlg = WindowList_Find(hWindowList, DlgParam->hContact);
- if ( hListDlg )
- {
- SetDlgItemText(hListDlg, IDC_MAIN, _T(""));
-
- if ( SendDlgItemMessage(hDlg, IDC_TYPE_WEB, BM_GETCHECK, 0, 0) == BST_UNCHECKED )
- flags = flags | WLL_MAIL;
-
- if ( SendDlgItemMessage(hDlg, IDC_TYPE_MAIL, BM_GETCHECK, 0, 0) == BST_UNCHECKED )
- flags = flags | WLL_URL;
-
- if ( SendDlgItemMessage(hDlg, IDC_DIR_IN, BM_GETCHECK, 0, 0) == BST_UNCHECKED )
- flags = flags | WLL_OUT;
-
- if ( SendDlgItemMessage(hDlg, IDC_DIR_OUT, BM_GETCHECK, 0, 0) == BST_UNCHECKED )
- flags = flags | WLL_IN;
+ switch (wParam) {
+ case IDCLOSE:
+ case IDCANCEL: {
+ HMENU listMenu = GetMenu(hWndMain);
+ EnableMenuItem(listMenu, 101, MF_BYCOMMAND | MF_ENABLED);
+ DestroyWindow(hDlg);
+ return TRUE;
+ } break;
+ case IDSEARCH: {
+ BYTE flags = 0x00;
+ TCHAR filter[FILTERTEXT];
+ LPTSTR buffer;
+ int length;
- if ( SendDlgItemMessage(hDlg, IDC_WHOLE_MESSAGE, BM_GETCHECK, 0, 0) == BST_CHECKED )
- flags = flags | SLL_DEEP;
-
- length = GetWindowTextLength(GetDlgItem(hDlg, IDC_SEARCHSTRING))+1;
- buffer = (LPTSTR)malloc( (length + 1)*sizeof(TCHAR));
- GetDlgItemText(hDlg, IDC_SEARCHSTRING, buffer, length);
- WriteLinkList(hListDlg, flags, DlgParam->listStart, buffer, 0);
- free(buffer);
-
- mir_sntprintf(filter, SIZEOF(filter), _T("%s: %s"), TXT_FILTER, TXT_SEARCHFILTER);
- SetDlgItemText(hWndMain, IDC_STATUS, filter);
- }
+ hListDlg = WindowList_Find(hWindowList, DlgParam->hContact);
+ if (hListDlg == NULL)
break;
- }
+ SetDlgItemText(hListDlg, IDC_MAIN, _T(""));
+ if (SendDlgItemMessage(hDlg, IDC_TYPE_WEB, BM_GETCHECK, 0, 0) == BST_UNCHECKED)
+ flags |= WLL_MAIL;
+ if (SendDlgItemMessage(hDlg, IDC_TYPE_MAIL, BM_GETCHECK, 0, 0) == BST_UNCHECKED)
+ flags |= WLL_URL;
+ if (SendDlgItemMessage(hDlg, IDC_DIR_IN, BM_GETCHECK, 0, 0) == BST_UNCHECKED)
+ flags |= WLL_OUT;
+ if (SendDlgItemMessage(hDlg, IDC_DIR_OUT, BM_GETCHECK, 0, 0) == BST_UNCHECKED)
+ flags |= WLL_IN;
+ if (SendDlgItemMessage(hDlg, IDC_WHOLE_MESSAGE, BM_GETCHECK, 0, 0) == BST_CHECKED)
+ flags |= SLL_DEEP;
+
+ length = GetWindowTextLength(GetDlgItem(hDlg, IDC_SEARCHSTRING)) + 1;
+ buffer = (LPTSTR)mir_alloc((length + 1) * sizeof(TCHAR));
+ if (buffer) {
+ GetDlgItemText(hDlg, IDC_SEARCHSTRING, buffer, length);
+ WriteLinkList(hListDlg, flags, DlgParam->listStart, buffer, 0);
+ mir_free(buffer);
+ }
+ mir_sntprintf(filter, SIZEOF(filter), _T("%s: %s"), TXT_FILTER, TXT_SEARCHFILTER);
+ SetDlgItemText(hWndMain, IDC_STATUS, filter);
+ } break;
}
+ } break;
}
return FALSE;
}
@@ -912,28 +797,21 @@ Progressbar */
LRESULT CALLBACK ProgressBarDlg(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- static HWND hwndBN_OK, hwndBN_Cancel, hwndEdit, hwndPB;
- static int cxChar, cyChar;
+ static HWND hwndPB;
- switch ( message )
- {
- case WM_CREATE:
- {
- cxChar = LOWORD(GetDialogBaseUnits());
- cyChar = HIWORD(GetDialogBaseUnits());
- InitCommonControls();
- hwndPB = CreateWindowEx(0, PROGRESS_CLASS, _T(""), WS_CHILD | WS_VISIBLE, 0, 2, 343, 17, hwnd, NULL, hInst, NULL);
+ switch (message) {
+ case WM_CREATE:
+ hwndPB = CreateWindowEx(0, PROGRESS_CLASS, _T(""), WS_CHILD | WS_VISIBLE, 0, 2, 343, 17, hwnd, NULL, hInst, NULL);
SendMessage(hwndPB, PBM_SETRANGE, 0, MAKELPARAM (0, 100));
- return 0;
- }
- case WM_COMMAND:
- {
- if ( wParam == 100 )
- SendMessage(hwndPB, PBM_SETPOS, (WPARAM)lParam, 0);
- return 0;
- }
- case WM_DESTROY:
- return 0;
+ return 0;
+ break;
+ case WM_COMMAND:
+ if (wParam == 100)
+ SendMessage(hwndPB, PBM_SETPOS, (WPARAM)lParam, 0);
+ return 0;
+ break;
+ case WM_DESTROY:
+ return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
@@ -946,32 +824,29 @@ Taken from srmm-plugin.... */
LRESULT CALLBACK SplitterProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
- {
+
+ switch (msg) {
case WM_NCHITTEST:
return HTCLIENT;
-
- case WM_SETCURSOR:
- {
+ break;
+ case WM_SETCURSOR: {
RECT rc;
GetClientRect(hWnd, &rc);
SetCursor(splitCursor);
return TRUE;
- }
-
+ } break;
case WM_LBUTTONDOWN:
SetCapture(hWnd);
return 0;
-
+ break;
case WM_MOUSEMOVE:
- if ( GetCapture() == hWnd )
- {
+ if (GetCapture() == hWnd) {
RECT rc;
GetClientRect(hWnd, &rc);
SendMessage( GetParent(hWnd), DM_LINKSPLITTER, (WPARAM)(HIWORD(GetMessagePos()) + rc.bottom / 2), (LPARAM)hWnd);
}
return 0;
-
+ break;
case WM_LBUTTONUP:
ReleaseCapture();
return 0;
diff --git a/plugins/HistoryLinkListPlus/src/linklist_dlg.h b/plugins/HistoryLinkListPlus/src/linklist_dlg.h index 9fe31f73b2..a08c4d64f8 100644 --- a/plugins/HistoryLinkListPlus/src/linklist_dlg.h +++ b/plugins/HistoryLinkListPlus/src/linklist_dlg.h @@ -20,9 +20,9 @@ #ifndef _LINKLIST_DLG_H
#define _LINKLIST_DLG_H
-INT_PTR WINAPI MainDlgProc( HWND, UINT, WPARAM, LPARAM );
+INT_PTR CALLBACK MainDlgProc( HWND, UINT, WPARAM, LPARAM );
LRESULT CALLBACK ProgressBarDlg(HWND, UINT, WPARAM, LPARAM);
-INT_PTR WINAPI SearchDlgProc( HWND, UINT, WPARAM, LPARAM );
+INT_PTR CALLBACK SearchDlgProc( HWND, UINT, WPARAM, LPARAM );
INT_PTR CALLBACK OptionsDlgProc(HWND, UINT, WPARAM, LPARAM );
LRESULT CALLBACK SplitterProc(HWND, UINT, WPARAM, LPARAM);
diff --git a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp index 952ae5217c..16725d987b 100644 --- a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp +++ b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp @@ -29,196 +29,172 @@ Great job! It works! ;-) */
int ExtractURI(DBEVENTINFO *dbei, HANDLE hEvent, LISTELEMENT *listStart)
{
- int wordStart,i,iLastAlphaNum, linkFound=0;
- int charCount=0,cpLastAlphaNum=0,cpWordStart;
+ size_t wordStart, i, j, wordlen, iLastAlphaNum;
+ size_t charCount = 0, cpLastAlphaNum = 0, cpWordStart;
LPCTSTR msg;
LPTSTR word, wordsearch, date_ptr, time_ptr;
+ LPTSTR tok_ctx;
static LPCTSTR hyperlinkPrefixes[] = {
_T("http://"),_T("ftp://"),_T("https://"),_T("mailto:"),_T("www."),_T("ftp."),
_T("icq#"),_T("gopher://"),_T("news://"),_T("file://"),_T("\\\\")
};
static LPCTSTR hyperlinkSubstrings[] = {
- _T(".com/"),_T(".net/"),_T(".org/"),_T(".co.uk"),_T(".ru")
+ _T(".com"),_T(".net"),_T(".org"),_T(".co.uk"),_T(".ru")
};
DBTIMETOSTRINGT dbtimestring;
LISTELEMENT *newElement, *actualElement;
- TCHAR templink[LINK_MAX+1];
- TCHAR dbdate[DATE_SIZE + TIME_SIZE];
BYTE type = LINK_UNKNOWN;
- int direction;
- TCHAR date[DATE_SIZE+1];
- TCHAR time[TIME_SIZE+1];
- TCHAR link[LINK_MAX+1];
+ int direction, isLink, linkFound = 0;
+ TCHAR date[DATE_SIZE + 1];
+ TCHAR time[TIME_SIZE + 1];
+ TCHAR link[LINK_MAX + 1];
+ TCHAR templink[LINK_MAX + 1];
+ TCHAR dbdate[DATE_SIZE + TIME_SIZE];
- if ( listStart == NULL )
+ if (listStart == NULL)
return -1;
- memset(link, 0, sizeof(link));
- memset(date, 0, sizeof(date));
- memset(time, 0, sizeof(time));
+ link[0] = 0;
+ date[0] = 0;
+ time[0] = 0;
msg = DbGetEventTextT(dbei, CP_ACP);
-
- if ( msg == NULL )
+ if (msg == NULL)
return 0;
- for ( i=0; msg[i]; )
- {
+ for (i = 0; msg[i]; ) {
//hyperlinks are delimited by: <non-alphanumeric>"hyperlink"<whitespace>
//then all punctuation is stripped from the end of "hyperlink"
iLastAlphaNum = 0;
- while ( msg[i] && !_istalnum(msg[i]))
- {
+ while (msg[i] && !_istalnum(msg[i])) {
// support for files
- if ( (msg[i]==_T('\\')) && (msg[i+1]==_T('\\')) && (_istalnum(msg[i+2])))
- {
+ if (msg[i] == _T('\\') && msg[i + 1] == _T('\\') && _istalnum(msg[i + 2]))
break;
- }
-
- if(IsDBCSLeadByte(msg[i]) && msg[i+1]) i++;
-
- i++;
- if ( msg[i] != _T('\n')) charCount++;
+ if(IsDBCSLeadByte(msg[i]) && msg[i + 1])
+ i ++;
+ i ++;
+ if (msg[i] != _T('\n'))
+ charCount ++;
}
- if ( msg[i] == _T('\0')) break;
-
+ if (msg[i] == _T('\0'))
+ break;
cpWordStart = charCount;
wordStart = i;
- while ( msg[i] && !_istspace(msg[i]))
- {
-
- if ( IsDBCSLeadByte(msg[i] ) && msg[i+1]) i++;
- else
-
- if ( _istalnum(msg[i]) || msg[i]==_T('/'))
- {
- cpLastAlphaNum = charCount;
- iLastAlphaNum = i;
+ while (msg[i] && !_istspace(msg[i])) {
+ if (IsDBCSLeadByte(msg[i]) && msg[i + 1]) {
+ i ++;
+ } else {
+ if (_istalnum(msg[i]) || msg[i]==_T('/')) {
+ cpLastAlphaNum = charCount;
+ iLastAlphaNum = i;
+ }
}
- charCount++;
- i++;
+ charCount ++;
+ i ++;
}
- charCount = cpLastAlphaNum+1;
- i = iLastAlphaNum+1;
+ charCount = cpLastAlphaNum + 1;
+ i = iLastAlphaNum + 1;
- if ( i-wordStart >= 7 )
- {
- int j, isLink = 0, wordlen;
+ if ((i - wordStart) < 8)
+ continue;
+ isLink = 0;
- wordlen = i-wordStart+1;
- word = (LPTSTR)malloc(wordlen*sizeof(TCHAR));
- wordsearch = (LPTSTR)malloc(wordlen*sizeof(TCHAR));
-
- _tcsncpy_s(word, wordlen, msg+wordStart, wordlen-1);
- _tcsncpy_s(wordsearch, wordlen, msg+wordStart, wordlen-1);
- CharLower(wordsearch);
-
- for ( j=0; j<_countof(hyperlinkPrefixes); j++ )
- {
- if ( !_tcsncmp(wordsearch, hyperlinkPrefixes[j], _tcslen(hyperlinkPrefixes[j])))
- {
- isLink = 1;
- break;
- }
+ wordlen = (i - wordStart + 1);
+ word = (LPTSTR)mir_alloc(wordlen * sizeof(TCHAR));
+ wordsearch = (LPTSTR)mir_alloc(wordlen * sizeof(TCHAR));
+ if (word == NULL || wordsearch == NULL) {
+ mir_free(word);
+ mir_free(wordsearch);
+ linkFound = -1;
+ break;
+ }
+
+ _tcsncpy_s(word, wordlen, msg + wordStart, (wordlen - 1));
+ _tcsncpy_s(wordsearch, wordlen, msg + wordStart, (wordlen - 1));
+ CharLower(wordsearch);
+
+ for (j = 0; j < SIZEOF(hyperlinkPrefixes); j ++) {
+ if (!_tcsncmp(wordsearch, hyperlinkPrefixes[j], _tcslen(hyperlinkPrefixes[j]))) {
+ isLink = 1;
+ break;
}
-
- if ( !isLink ) {
- for ( j=0; j<_countof(hyperlinkSubstrings); j++ )
- {
- if ( _tcsstr(wordsearch+1,hyperlinkSubstrings[j]))
- {
- isLink = 1;
- break;
- }
+ }
+ if (!isLink) {
+ for (j = 0; j < SIZEOF(hyperlinkSubstrings); j ++) {
+ if (_tcsstr(wordsearch + 1,hyperlinkSubstrings[j])) {
+ isLink = 1;
+ break;
}
}
-
- if ( _tcschr(wordsearch,_T('@')) && _tcschr(wordsearch,_T('.')) && !_tcschr(wordsearch,_T(':')) && !_tcschr(wordsearch,_T('/')))
- {
- isLink = 1; //e-mail addresses
- type = LINK_MAIL;
- }
- else if ( isLink ) {
- type = LINK_URL;
- }
-
- if ( isLink && ( (i-wordStart+1) <= (int)(LINK_MAX - _mstrlen(_T("http://")))))
- {
- LPTSTR tok_ctx;
+ }
- if ( (_tcsstr(wordsearch, _T("www.")) != NULL) && (_tcsstr(wordsearch, _T("http://")) == NULL))
- {
- _tcsncpy_s(link, _T("http://"), _mstrlen(_T("http://")));
- // Link longer than defined max -> cut link to max
- if ( (i-wordStart+1) > (int)(LINK_MAX-_mstrlen(_T("http://"))))
- _tcsncpy_s(link + _mstrlen(_T("http://")), _countof(link), word, LINK_MAX - _mstrlen(_T("http://")));
- else
- _tcsncpy_s(link + _mstrlen(_T("http://")), _countof(link), word, i-wordStart+1);
- }
+ if (_tcschr(wordsearch,_T('@')) && _tcschr(wordsearch,_T('.')) && !_tcschr(wordsearch,_T(':')) && !_tcschr(wordsearch,_T('/'))) {
+ isLink = 1; //e-mail addresses
+ type = LINK_MAIL;
+ } else if (isLink) {
+ type = LINK_URL;
+ }
+
+ if (isLink && wordlen <= (LINK_MAX - _mstrlen(_T("http://")))) {
+ if (_tcsstr(wordsearch, _T("www.")) != NULL && _tcsstr(wordsearch, _T("http://")) == NULL) {
+ _tcsncpy_s(link, _T("http://"), _mstrlen(_T("http://")));
+ // Link longer than defined max -> cut link to max
+ if (wordlen > (LINK_MAX - _mstrlen(_T("http://"))))
+ _tcsncpy_s((link + _mstrlen(_T("http://"))), (SIZEOF(link) - _mstrlen(_T("http://"))), word, LINK_MAX - _mstrlen(_T("http://")));
else
- {
- size_t link_size;
- if ( (i-wordStart+1) > LINK_MAX )
- link_size = LINK_MAX;
- else
- link_size = i-wordStart+1;
- _tcsncpy_s(link, word, link_size);
- }
+ _tcsncpy_s((link + _mstrlen(_T("http://"))), (SIZEOF(link) - _mstrlen(_T("http://"))), word, wordlen);
+ } else {
+ _tcsncpy_s(link, word, ((wordlen > LINK_MAX) ? LINK_MAX : wordlen));
+ }
- dbtimestring.szFormat = _T("d-t");
- dbtimestring.szDest = dbdate;
- dbtimestring.cbDest = _countof(dbdate);
- CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT,(WPARAM)dbei->timestamp, (LPARAM)&dbtimestring);
- date_ptr = _tcstok_s(dbdate, _T("-"), &tok_ctx);
- time_ptr = _tcstok_s(NULL, _T("-"), &tok_ctx);
- _tcsncpy_s(date, date_ptr, _TRUNCATE);
- _tcsncpy_s(time, time_ptr, _TRUNCATE);
- // Prevent overflow
- date[DATE_SIZE] = _T('\0');
- time[TIME_SIZE] = _T('\0');
-
- if ( dbei->flags & DBEF_SENT ) {
- direction = DIRECTION_OUT;
- } else {
- direction = DIRECTION_IN;
- }
+ dbtimestring.szFormat = _T("d-t");
+ dbtimestring.szDest = dbdate;
+ dbtimestring.cbDest = SIZEOF(dbdate);
+ CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT,(WPARAM)dbei->timestamp, (LPARAM)&dbtimestring);
+ date_ptr = _tcstok_s(dbdate, _T("-"), &tok_ctx);
+ time_ptr = _tcstok_s(NULL, _T("-"), &tok_ctx);
+ _tcsncpy_s(date, date_ptr, _TRUNCATE);
+ _tcsncpy_s(time, time_ptr, _TRUNCATE);
+
+ if (dbei->flags & DBEF_SENT) {
+ direction = DIRECTION_OUT;
+ } else {
+ direction = DIRECTION_IN;
+ }
- if ( type == LINK_MAIL && _tcsstr(link, _T("mailto:")) == NULL )
- {
- _tcsncpy_s(templink, link, _TRUNCATE);
- _tcsncpy_s(link, _T("mailto:"), _TRUNCATE);
- _tcsncpy_s(link + _mstrlen(_T("mailto:")), _countof(link), templink, _TRUNCATE);
- }
-
- // Add new Element to list:
- newElement = (LISTELEMENT*)malloc(sizeof(LISTELEMENT));
- if ( newElement == NULL )
- return -1;
-
- memset(newElement, 0, sizeof(LISTELEMENT));
- newElement->direction = direction;
- newElement->type = type;
- _tcsncpy_s(newElement->date, date, _TRUNCATE);
- _tcsncpy_s(newElement->time, time, _TRUNCATE);
- _tcsncpy_s(newElement->link, link, _TRUNCATE);
- newElement->hEvent = hEvent;
-
- actualElement = listStart;
- while ( actualElement->nextElement != NULL )
- {
- actualElement = actualElement->nextElement;
- }
+ if (type == LINK_MAIL && _tcsstr(link, _T("mailto:")) == NULL) {
+ _tcsncpy_s(templink, link, _TRUNCATE);
+ _tcsncpy_s(link, _T("mailto:"), _TRUNCATE);
+ _tcsncpy_s((link + _mstrlen(_T("mailto:"))), (SIZEOF(link) - _mstrlen(_T("mailto:"))), templink, _TRUNCATE);
+ }
+
+ // Add new Element to list:
+ newElement = (LISTELEMENT*)mir_alloc(sizeof(LISTELEMENT));
+ if (newElement == NULL) {
+ linkFound = -1;
+ break;
+ }
+ memset(newElement, 0, sizeof(LISTELEMENT));
+ newElement->direction = direction;
+ newElement->type = type;
+ _tcsncpy_s(newElement->date, date, _TRUNCATE);
+ _tcsncpy_s(newElement->time, time, _TRUNCATE);
+ _tcsncpy_s(newElement->link, link, _TRUNCATE);
+ newElement->hEvent = hEvent;
- actualElement->nextElement = newElement;
- linkFound++;
+ actualElement = listStart;
+ while (actualElement->nextElement != NULL) {
+ actualElement = actualElement->nextElement;
}
- free(word);
- free(wordsearch);
+
+ actualElement->nextElement = newElement;
+ linkFound ++;
}
+ mir_free(word);
+ mir_free(wordsearch);
}
-
mir_free((void*)msg);
return linkFound;
@@ -239,10 +215,10 @@ int RemoveList(LISTELEMENT *listStart) while ( actualElement != NULL )
{
tempElement = actualElement->nextElement;
- free(actualElement);
+ mir_free(actualElement);
actualElement = tempElement;
}
- free(listStart);
+ mir_free(listStart);
return 0;
}
@@ -311,7 +287,7 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc cf.cbSize = sizeof(cf);
cf.dwMask = CFM_COLOR;
cf.crTextColor = colourSet.text;
- SendDlgItemMessage( hDlg, IDC_MESSAGE, EM_SETCHARFORMAT, SCF_SELECTION|SCF_WORD, (LPARAM)&cf);
+ SendDlgItemMessage( hDlg, IDC_MESSAGE, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
SendDlgItemMessage( hDlg, IDC_MESSAGE, EM_AUTOURLDETECT, TRUE, 0 );
SendDlgItemMessage( hDlg, IDC_MESSAGE, EM_SETBKGNDCOLOR, FALSE, colourSet.background);
@@ -337,7 +313,6 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc _tcscpy_s(cf.szFaceName, _T("Arial"));
SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf);
- memset(searchText, 0, sizeof(searchText));
mir_sntprintf(searchText, SIZEOF(searchText), _T("%s '%s': %d\n\n"), TranslateT("Matches for searchtext"), searchString, listCount);
SendDlgItemMessage(hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM)searchText);
linePos += 2;
@@ -413,14 +388,14 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc {
DBEVENTINFO dbe = { sizeof(dbe) };
dbe.cbBlob = db_event_getBlobSize(actualElement->hEvent);
- dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1);
+ dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob+1);
db_event_get(actualElement->hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
LPTSTR msg = DbGetEventTextT(&dbe, CP_ACP);
if ( _tcsstr(msg, searchString))
filter3 = 1;
- free(dbe.pBlob);
+ mir_free(dbe.pBlob);
mir_free(msg);
}
else filter3 = 0;
@@ -647,14 +622,14 @@ void WriteMessage(HWND hDlg, LISTELEMENT *listStart, int actLinePos) if (hEvent != NULL ) {
DBEVENTINFO dbe = { sizeof(dbe) };
dbe.cbBlob = db_event_getBlobSize(hEvent);
- dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1);
+ dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob+1);
db_event_get(hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
LPCTSTR msg = DbGetEventTextT(&dbe, CP_ACP);
SendDlgItemMessage(hDlg, IDC_MESSAGE, WM_SETTEXT , 0, 0);
SendDlgItemMessage(hDlg, IDC_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg);
mir_free((void*)msg);
- free(dbe.pBlob);
+ mir_free(dbe.pBlob);
}
break;
}
@@ -804,13 +779,13 @@ void GetListInfo(BYTE params, LISTELEMENT *listStart, LPCTSTR searchString, siz {
DBEVENTINFO dbe = { sizeof(dbe) };
dbe.cbBlob = db_event_getBlobSize(actualElement->hEvent);
- dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1);
+ dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob+1);
db_event_get(actualElement->hEvent, &dbe);
dbe.pBlob[dbe.cbBlob] = 0;
if ( _tcsstr((LPTSTR)dbe.pBlob, searchString))
filter3 = 1;
- free(dbe.pBlob);
+ mir_free(dbe.pBlob);
}
else
filter3 = 0;
@@ -1215,7 +1190,7 @@ int DBUpdate(WPARAM wParam, LPARAM lParam) if(hDlg) {
DBEVENTINFO dbe = { sizeof(dbe) };
dbe.cbBlob = db_event_getBlobSize(hEvent);
- dbe.pBlob = (PBYTE)malloc((size_t)dbe.cbBlob+1);
+ dbe.pBlob = (PBYTE)mir_alloc((size_t)dbe.cbBlob+1);
db_event_get(hEvent, &dbe);
if (dbe.eventType == EVENTTYPE_URL || dbe.eventType == EVENTTYPE_MESSAGE) {
// Call function to find URIs
@@ -1223,7 +1198,7 @@ int DBUpdate(WPARAM wParam, LPARAM lParam) if ( linkNum > 0 )
WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, linkNum);
}
- free(dbe.pBlob);
+ mir_free(dbe.pBlob);
}
return 0;
}
|