From 9984e12867718ad6b6c4973cf30e5b00d4005d14 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Fri, 20 Jul 2012 07:36:46 +0000 Subject: HistoryLinkListPlus: changed folder structure git-svn-id: http://svn.miranda-ng.org/main/trunk@1065 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/HistoryLinkListPlus/src/language.h | 37 + plugins/HistoryLinkListPlus/src/linklist.cpp | 245 ++++ plugins/HistoryLinkListPlus/src/linklist.h | 156 +++ plugins/HistoryLinkListPlus/src/linklist_dlg.cpp | 1001 ++++++++++++++++ plugins/HistoryLinkListPlus/src/linklist_dlg.h | 29 + plugins/HistoryLinkListPlus/src/linklist_fct.cpp | 1360 ++++++++++++++++++++++ plugins/HistoryLinkListPlus/src/linklist_fct.h | 46 + plugins/HistoryLinkListPlus/src/resource.h | 72 ++ plugins/HistoryLinkListPlus/src/utils.cpp | 29 + plugins/HistoryLinkListPlus/src/utils.h | 25 + 10 files changed, 3000 insertions(+) create mode 100644 plugins/HistoryLinkListPlus/src/language.h create mode 100644 plugins/HistoryLinkListPlus/src/linklist.cpp create mode 100644 plugins/HistoryLinkListPlus/src/linklist.h create mode 100644 plugins/HistoryLinkListPlus/src/linklist_dlg.cpp create mode 100644 plugins/HistoryLinkListPlus/src/linklist_dlg.h create mode 100644 plugins/HistoryLinkListPlus/src/linklist_fct.cpp create mode 100644 plugins/HistoryLinkListPlus/src/linklist_fct.h create mode 100644 plugins/HistoryLinkListPlus/src/resource.h create mode 100644 plugins/HistoryLinkListPlus/src/utils.cpp create mode 100644 plugins/HistoryLinkListPlus/src/utils.h (limited to 'plugins/HistoryLinkListPlus/src') diff --git a/plugins/HistoryLinkListPlus/src/language.h b/plugins/HistoryLinkListPlus/src/language.h new file mode 100644 index 0000000000..92eb5a6486 --- /dev/null +++ b/plugins/HistoryLinkListPlus/src/language.h @@ -0,0 +1,37 @@ +// History Linklist Plus +// Copyright (C) 2010 Thomas Wendel, gureedo +// +// 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 your option) any later version. +// +// 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. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +#pragma once + +#ifndef _LANGUAGE_H +#define _LANGUAGE_H + +#define TXT_PLUGINNAME "History Linklist" +#define TXT_EMPTYHISTORY "History is empty!" +#define TXT_ERROR "Error" +#define TXT_INCOMING "incoming" +#define TXT_OUTGOING "outgoing" +#define TXT_FILTER "Filter" +#define TXT_NOFILTER "no filter" +#define TXT_URLSONLY "Web addresses only" +#define TXT_MAILSONLY "Mail addresses only" +#define TXT_SEARCH "Search" +#define TXT_SEARCHFILTER "Search Filter" +#define TXT_NOSETTING "no settings" +#define TXT_DATE "Date" + +#endif // _LANGUAGE_H \ No newline at end of file diff --git a/plugins/HistoryLinkListPlus/src/linklist.cpp b/plugins/HistoryLinkListPlus/src/linklist.cpp new file mode 100644 index 0000000000..6de2a4a1e9 --- /dev/null +++ b/plugins/HistoryLinkListPlus/src/linklist.cpp @@ -0,0 +1,245 @@ +// History Linklist Plus +// Copyright (C) 2010 Thomas Wendel, gureedo +// +// 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 your option) any later version. +// +// 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. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +#include "linklist.h" + +// Global variables +HINSTANCE hInst; +HINSTANCE hRichEdit; + +HANDLE hWindowList; +HCURSOR splitCursor; +int hLangpack; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + "History Linklist Plus", + PLUGIN_MAKE_VERSION(0,0,0,2), + "Generates a list of extracted URIs from the history.", + "Thomas Wendel, gureedo", + "gureedo@gmail.com", + "© 2010-2011 gureedo", + "http://www.miranda-im.org", + UNICODE_AWARE, + // {DA0B09F5-9C66-488C-AE37-8A5F191C9079} + { 0xDA0B09F5, 0x9C66, 0x488C, { 0xAE, 0x37, 0x8A, 0x5F, 0x19, 0x1C, 0x90, 0x79 } } +}; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) int Load(void) +{ + CLISTMENUITEM linklistmenuitem; + WNDCLASS wndclass; + + + mir_getLP(&pluginInfo); + // Load Rich Edit control + hRichEdit = LoadLibrary(_T("RICHED32.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); + flag |= _CRTDBG_LEAK_CHECK_DF|_CRTDBG_CHECK_ALWAYS_DF; + _CrtSetDbgFlag(flag); + } +#endif + + CreateServiceFunction("Linklist/MenuCommand", LinkList_Main); + ZeroMemory(&linklistmenuitem, sizeof(linklistmenuitem)); + linklistmenuitem.cbSize = sizeof(linklistmenuitem); + linklistmenuitem.position = 0x00; + linklistmenuitem.flags = CMIF_TCHAR; + linklistmenuitem.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_LINKLISTICON)); + linklistmenuitem.ptszName = LPGENT("&Create Linklist"); + linklistmenuitem.pszService = "Linklist/MenuCommand"; + Menu_AddContactMenuItem(&linklistmenuitem); + hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); + + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = ProgressBarDlg; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = hInst; + wndclass.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_LINKLISTICON)); + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); + wndclass.lpszClassName = _T("Progressbar"); + wndclass.lpszMenuName = NULL; + RegisterClass(&wndclass); + + splitCursor = LoadCursor(NULL, IDC_SIZENS); + + HookEvent(ME_OPT_INITIALISE, InitOptionsDlg); + HookEvent(ME_DB_EVENT_ADDED, DBUpdate); + + return 0; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + UnhookEvent(ME_DB_EVENT_ADDED); + DestroyCursor(splitCursor); + return 0; +} + +int InitOptionsDlg(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + UNREFERENCED_PARAMETER(lParam); + + odp.cbSize = sizeof(odp); + odp.hInstance = hInst; + odp.pszGroup = LPGEN("History"); + odp.pszTitle = LPGEN("History Linklist"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_DLG); + odp.pfnDlgProc = OptionsDlgProc; + odp.flags = ODPF_BOLDGROUPS; + Options_AddPage(wParam, &odp); + return 0; +} + +static INT_PTR LinkList_Main(WPARAM wParam,LPARAM lParam) +{ + HANDLE hEvent; + HANDLE hContact = (HANDLE)wParam; + DBEVENTINFO dbe; + HWND hWnd; + HWND hWndProgress; + HWND hWndMain; + + int histCount = 0; + int actCount = 0; + + RECT DesktopRect; + DIALOGPARAM *DlgParam; + LISTELEMENT *listStart; + + UNREFERENCED_PARAMETER(lParam); + + listStart = (LISTELEMENT*)malloc(sizeof(LISTELEMENT)); + ZeroMemory(listStart, sizeof(LISTELEMENT)); + + hWnd = WindowList_Find(hWindowList,hContact); + if ( hWnd != NULL ) + { + int len; + SetForegroundWindow(hWnd); + SetFocus(hWnd); + len = GetWindowTextLength(GetDlgItem(hWnd, IDC_MAIN)); + PostMessage(GetDlgItem(hWnd, IDC_MAIN), EM_SETSEL, (WPARAM)len, (LPARAM)len); + return 0; + } + + hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0); + if ( hEvent == NULL ) + { + MessageBox(NULL, TranslateT(TXT_EMPTYHISTORY), TranslateT(TXT_PLUGINNAME), MB_OK | MB_ICONINFORMATION ); + return 0; + } + + histCount = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)hContact, 0); + ZeroMemory(&dbe, sizeof(dbe)); + dbe.cbSize = sizeof(dbe); + dbe.cbBlob = (int)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0); + dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1); + CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbe); + dbe.pBlob[dbe.cbBlob] = 0; + + GetWindowRect(GetDesktopWindow(), &DesktopRect); + 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); + 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); + ShowWindow(hWndProgress, SW_SHOW); + SetForegroundWindow(hWndProgress); + + while( 1 ) + { + if ( dbe.eventType == EVENTTYPE_URL || dbe.eventType == EVENTTYPE_MESSAGE ) + { + // Call function to find URIs + if ( ExtractURI(&dbe, hEvent, listStart) < 0 ) + { + 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))); + + hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hEvent, 0); + if ( hEvent == NULL ) + break; + + free(dbe.pBlob); + dbe.cbBlob = (int)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0); + dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1); + CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbe); + dbe.pBlob[dbe.cbBlob] = 0; + } + free(dbe.pBlob); + SendMessage(hWndProgress, WM_CLOSE, 0, 0); + if ( ListCount(listStart) <= 0 ) { + RemoveList(listStart); + MessageBox(NULL, TranslateT("There are no links in history!"), TranslateT(TXT_PLUGINNAME), MB_OK | MB_ICONINFORMATION); + return 0; + } + + + + DlgParam = (DIALOGPARAM*)malloc(sizeof(DIALOGPARAM)); + DlgParam->hContact = hContact; + DlgParam->listStart = listStart; + DlgParam->findMessage = 0; + DlgParam->chrg.cpMax = -1; + DlgParam->chrg.cpMin = -1; + + hWndMain = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_MAIN_DLG), NULL, MainDlgProc, (LPARAM)DlgParam); + if ( hWndMain == 0 ) + { + RemoveList(listStart); + MessageBox(NULL, TranslateT("Could not create window!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION ); + return -1; + } + + ShowWindow(hWndMain, SW_SHOW); + return 0; +} diff --git a/plugins/HistoryLinkListPlus/src/linklist.h b/plugins/HistoryLinkListPlus/src/linklist.h new file mode 100644 index 0000000000..17cc63e9c9 --- /dev/null +++ b/plugins/HistoryLinkListPlus/src/linklist.h @@ -0,0 +1,156 @@ +// History Linklist Plus +// Copyright (C) 2010 Thomas Wendel, gureedo +// +// 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 your option) any later version. +// +// 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. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +#pragma once + +#ifndef _LINKLIST_H +#define _LINKLIST_H + +#define _CRT_SECURE_NO_WARNINGS +#include +#ifdef _DEBUG +#include +#endif +#include + +// Miranda SDK Includes +#include +#include +#include +#include +#include +#include + +#include "resource.h" +#include "linklist_dlg.h" +#include "language.h" + +// Filter Flags +#define WLL_URL 0x01 +#define WLL_MAIL 0x02 +#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 SLL_DEEP 0x20 + +// String length +#define LINK_MAX 1024 +#define DIR_SIZE 6 +#define TYPE_SIZE 5 +#define DATE_SIZE 11 +#define TIME_SIZE 15 + +// Link types +#define LINK_UNKNOWN 0x00 +#define LINK_URL 0x01 +#define LINK_MAIL 0x02 +#define LINK_FILE 0x03 + +// Directions +#define DIRECTION_IN 1 +#define DIRECTION_OUT 2 + + +#define FILTERTEXT 125 + +#define IN_COL_DEF 0x005050A0 +#define OUT_COL_DEF 0x00206020 +#define BG_COL_DEF 0x00EAFFFF +#define TXT_COL_DEF 0x00000000 + +#define LINKLIST_MODULE "HistoryLinklist" +#define LINKLIST_IN_COL "InColour" +#define LINKLIST_OUT_COL "OutColour" +#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_LEFT "WindowLeft" +#define LINKLIST_RIGHT "WindowRight" +#define LINKLIST_BOTTOM "WindowBottom" +#define LINKLIST_TOP "WindowTop" +#define LINKLIST_SPLITPOS "SplitterPos" +#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_TYPE "ShowMessageType" + + + +#define MAKE_TXT_COL(BGCol) ((DWORD)~BGCol & 0x00FFFFFF) + +#define DM_LINKSPLITTER WM_USER+99 + +struct LISTELEMENT { + BYTE direction; + BYTE type; + TCHAR date[DATE_SIZE]; + TCHAR time[TIME_SIZE]; + TCHAR link[LINK_MAX]; + HANDLE hEvent; + int linePos; + struct LISTELEMENT *nextElement; +} ; + +typedef struct LISTELEMENT LISTELEMENT; + +// Dialogbox Parameter +typedef struct{ + HANDLE hContact; + LISTELEMENT *listStart; + UINT findMessage; + CHARRANGE chrg; + int splitterPosNew; + int splitterPosOld; + SIZE minSize; +} DIALOGPARAM; + + +typedef struct{ + DWORD incoming; + DWORD outgoing; + DWORD background; + DWORD text; +} MYCOLOURSET; + + +typedef struct{ + BYTE openNewWindow; + BYTE updateWindow; + BYTE mouseEvent; + BYTE saveSpecial; + BYTE showDate; + BYTE showLine; + BYTE showTime; + BYTE showDirection; + BYTE showType; +}LISTOPTIONS; + +static INT_PTR LinkList_Main(WPARAM, LPARAM); +int InitOptionsDlg(WPARAM, LPARAM); +int DBUpdate(WPARAM, LPARAM); +int ExtractURI(DBEVENTINFO*, HANDLE, LISTELEMENT*); +int RemoveList(LISTELEMENT*); +int ListCount(LISTELEMENT*); + +#endif //_LINKLIST_H \ No newline at end of file diff --git a/plugins/HistoryLinkListPlus/src/linklist_dlg.cpp b/plugins/HistoryLinkListPlus/src/linklist_dlg.cpp new file mode 100644 index 0000000000..6e26d8538d --- /dev/null +++ b/plugins/HistoryLinkListPlus/src/linklist_dlg.cpp @@ -0,0 +1,1001 @@ +// History Linklist Plus +// Copyright (C) 2010 Thomas Wendel, gureedo +// +// 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 your option) any later version. +// +// 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. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +#include +#include +#include "resource.h" +#ifdef _DEBUG +#include +#endif + +// Miranda SDK Includes +#pragma warning(disable:4996) +#pragma warning(disable:4100) +#include +#include +#include +#include +#include +#pragma warning(default:4100) +#pragma warning(default:4996) + +#include "linklist.h" +#include "linklist_dlg.h" +#include "linklist_fct.h" +#include "language.h" + +extern HINSTANCE hInst; +extern HANDLE hWindowList; +extern HCURSOR splitCursor; + +MYCOLOURSET colourSet; +WNDPROC wndSplitterProc; +LISTOPTIONS options; +/* +MainDlgProc handles messages to the main dialog box +*/ +INT_PTR WINAPI 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: + { + HANDLE hContact; + TCHAR title[256]; + TCHAR filter[FILTERTEXT]; + RECT rc; + POINT pt; + + SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam); + DlgParam = (DIALOGPARAM *)lParam; + TranslateDialogDefault(hDlg); + TranslateMenu(listMenu); + + if ( DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0x00) == 0x00 ) + hContact = NULL; + else + hContact = DlgParam->hContact; + + if ( DBGetContactSettingByte(hContact, LINKLIST_MODULE, LINKLIST_FIRST, 0) == 0 ) + { + // First use of this plugin! Set default size! + DBWriteContactSettingDword(hContact, LINKLIST_MODULE, "LinklistWidth", 400); + DBWriteContactSettingDword(hContact, LINKLIST_MODULE, "LinklistHeight", 450); + DBWriteContactSettingDword(hContact, LINKLIST_MODULE, "LinklistX", 0); + DBWriteContactSettingDword(hContact, LINKLIST_MODULE, "LinklistY", 0); + + DBWriteContactSettingByte(hContact, LINKLIST_MODULE, LINKLIST_FIRST, 1); + } + + DlgParam->splitterPosNew = (int)DBGetContactSettingDword(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_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; + + 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, _countof(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); + + wndSplitterProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hDlg, IDC_SPLITTER), GWLP_WNDPROC, (LONG_PTR)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; + + ZeroMemory(shEvent, _countof(shEvent)); + + pENLink = (ENLINK*)lpNmhdr; + + mouseEvent = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0xFF); + + 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 = DBGetContactSettingByte(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 = DBGetContactSettingByte(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); + } + } + break; + } + + case WM_COMMAND: + { + TCHAR filter[40]; + + // open Search Box + if ( wParam == IDM_SEARCH ) + { + + 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)); + } + + 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); + break; + } + + // 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); + } + break; + } + + // view only outgoing messages + else if ( wParam == IDM_DIR_OUT ) + { + 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_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, _countof(filter)); + SetDlgItemText(hDlg, IDC_STATUS, filter); + } + 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); + } + 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); + } + 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); + 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 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); + break; + } + + case WM_CLOSE: + { + DestroyWindow(hDlg); + break; + } + + case WM_DESTROY: + { + HANDLE hContact; + if ( DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0x00) == 0x00 ) + hContact = NULL; + else + hContact = DlgParam->hContact; + Utils_SaveWindowPosition(hDlg, hContact, LINKLIST_MODULE, "Linklist"); + DBWriteContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_SPLITPOS, DlgParam->splitterPosNew); + RemoveList(DlgParam->listStart); + free(DlgParam); + // Remove entry from Window list + WindowList_Remove(hWindowList, hDlg); + break; + } + + } + return FALSE; +} + +/* +This function handles the search dialog messages +*/ +INT_PTR WINAPI 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, (LPARAM)lParam); + SetWindowText(hDlg, TranslateT(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); + + 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; + + 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*sizeof(TCHAR)); + GetDlgItemText(hDlg, IDC_SEARCHSTRING, buffer, length); + WriteLinkList(hListDlg, flags, DlgParam->listStart, buffer, 0); + free(buffer); + + mir_sntprintf(filter, _countof(filter), _T("%s: %s"), TranslateT(TXT_FILTER), TranslateT(TXT_SEARCHFILTER)); + SetDlgItemText(hWndMain, IDC_STATUS, filter); + } + break; + } + } + } + return FALSE; +} + + +/* +This function handles the options dialog messages +*/ +INT_PTR CALLBACK OptionsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + BYTE useDefault; + int mCol; + + switch(message) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hDlg); + useDefault = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_USE_DEF, 0xFF); + if ( useDefault == 0x01 ) + { + mCol = GetMirandaColour(&colourSet); + if(mCol == 0) + { + SendDlgItemMessage(hDlg, IDC_CHECK1, BM_SETCHECK, BST_CHECKED, 0); + EnableWindow(GetDlgItem(hDlg, IDC_INCOMING), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_OUTGOING), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_BACKGROUND), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_TXT), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_DEFAULT_IN), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_DEFAULT_OUT), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_DEFAULT_BG), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_DEFAULT_TXT), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_TXTIN), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_TXTOUT), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_TXTBG), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_TXTTXT), FALSE); + } + else + useDefault = 0x00; + + } + if (useDefault == 0x00 ) + { + GetDBColour(&colourSet); + SendDlgItemMessage(hDlg, IDC_CHECK1, BM_SETCHECK, BST_UNCHECKED, 0); + SendDlgItemMessage(hDlg, IDC_INCOMING, CPM_SETCOLOUR, 0, colourSet.incoming); + SendDlgItemMessage(hDlg, IDC_OUTGOING, CPM_SETCOLOUR, 0, colourSet.outgoing); + SendDlgItemMessage(hDlg, IDC_BACKGROUND, CPM_SETCOLOUR, 0, colourSet.background); + SendDlgItemMessage(hDlg, IDC_TXT, CPM_SETCOLOUR, 0, colourSet.text); + } + + //Shifted to the end of this function + //WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text); + + // Init variables with current values from DB + GetListOptions(&options); + + if(options.openNewWindow == 0x00) + SendDlgItemMessage(hDlg, IDC_CHECK2, BM_SETCHECK, BST_UNCHECKED, 0); + if(options.openNewWindow == 0x01) + SendDlgItemMessage(hDlg, IDC_CHECK2, BM_SETCHECK, BST_CHECKED, 0); + + if(options.updateWindow == 0x00) + SendDlgItemMessage(hDlg, IDC_CHECK3, BM_SETCHECK, BST_UNCHECKED, 0); + if(options.updateWindow == 0x01) + SendDlgItemMessage(hDlg, IDC_CHECK3, BM_SETCHECK, BST_CHECKED, 0); + + if(options.mouseEvent == 0x00) + SendDlgItemMessage(hDlg, IDC_CHECK4, BM_SETCHECK, BST_UNCHECKED, 0); + if(options.mouseEvent == 0x01) + SendDlgItemMessage(hDlg, IDC_CHECK4, BM_SETCHECK, BST_CHECKED, 0); + + if(options.saveSpecial == 0x00) + SendDlgItemMessage(hDlg, IDC_CHECK5, BM_SETCHECK, BST_UNCHECKED, 0); + if(options.saveSpecial == 0x01) + SendDlgItemMessage(hDlg, IDC_CHECK5, BM_SETCHECK, BST_CHECKED, 0); + + if(options.showDate == 0x00) + SendDlgItemMessage(hDlg, IDC_CHECK6, BM_SETCHECK, BST_UNCHECKED, 0); + if(options.showDate == 0x01) + SendDlgItemMessage(hDlg, IDC_CHECK6, BM_SETCHECK, BST_CHECKED, 0); + + if(options.showLine == 0x00) + SendDlgItemMessage(hDlg, IDC_CHECK7, BM_SETCHECK, BST_UNCHECKED, 0); + if(options.showLine == 0x01) + SendDlgItemMessage(hDlg, IDC_CHECK7, BM_SETCHECK, BST_CHECKED, 0); + + if(options.showTime == 0x00) + SendDlgItemMessage(hDlg, IDC_CHECK8, BM_SETCHECK, BST_UNCHECKED, 0); + if(options.showTime == 0x01) + SendDlgItemMessage(hDlg, IDC_CHECK8, BM_SETCHECK, BST_CHECKED, 0); + + if(options.showDirection == 0x00) + SendDlgItemMessage(hDlg, IDC_CHECK9, BM_SETCHECK, BST_UNCHECKED, 0); + if(options.showDirection == 0x01) + SendDlgItemMessage(hDlg, IDC_CHECK9, BM_SETCHECK, BST_CHECKED, 0); + + if(options.showType == 0x00) + SendDlgItemMessage(hDlg, IDC_CHECK10, BM_SETCHECK, BST_UNCHECKED, 0); + if(options.showType == 0x01) + SendDlgItemMessage(hDlg, IDC_CHECK10, BM_SETCHECK, BST_CHECKED, 0); + + // Write example window + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + + return TRUE; + } + case WM_COMMAND: + { + if ( LOWORD(wParam) == IDC_DEFAULT_IN ) + { + colourSet.incoming = IN_COL_DEF; + SendDlgItemMessage(hDlg, IDC_INCOMING, CPM_SETCOLOUR, 0, colourSet.incoming); + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + break; + } + if ( LOWORD(wParam) == IDC_DEFAULT_OUT ) + { + colourSet.outgoing = OUT_COL_DEF; + SendDlgItemMessage(hDlg, IDC_OUTGOING, CPM_SETCOLOUR, 0, colourSet.outgoing); + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + break; + } + if ( LOWORD(wParam) == IDC_DEFAULT_BG ) + { + colourSet.background = BG_COL_DEF; + SendDlgItemMessage(hDlg, IDC_BACKGROUND, CPM_SETCOLOUR, 0, colourSet.background); + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + break; + } + if ( LOWORD(wParam) == IDC_DEFAULT_TXT ) + { + colourSet.text = TXT_COL_DEF; + SendDlgItemMessage(hDlg, IDC_TXT, CPM_SETCOLOUR, 0, colourSet.text); + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + break; + } + if ( LOWORD(wParam) == IDC_INCOMING ) + { + colourSet.incoming = SendDlgItemMessage(hDlg, IDC_INCOMING, CPM_GETCOLOUR, 0, 0); + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + break; + } + if ( LOWORD(wParam) == IDC_OUTGOING ) + { + colourSet.outgoing = SendDlgItemMessage(hDlg, IDC_OUTGOING, CPM_GETCOLOUR, 0, 0); + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + break; + } + if ( LOWORD(wParam) == IDC_BACKGROUND ) + { + colourSet.background = SendDlgItemMessage(hDlg, IDC_BACKGROUND, CPM_GETCOLOUR, 0, 0); + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + break; + } + if ( LOWORD(wParam) == IDC_TXT ) + { + colourSet.text = SendDlgItemMessage(hDlg, IDC_TXT, CPM_GETCOLOUR, 0, 0); + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + break; + } + if ( LOWORD(wParam) == IDC_CHECK1 ) + { + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + if ( SendDlgItemMessage(hDlg, IDC_CHECK1, BM_GETCHECK, 0, 0) == BST_UNCHECKED ) + { + EnableWindow(GetDlgItem(hDlg, IDC_INCOMING), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_OUTGOING), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_BACKGROUND), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_TXT), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_DEFAULT_IN), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_DEFAULT_OUT), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_DEFAULT_BG), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_DEFAULT_TXT), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_TXTIN), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_TXTOUT), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_TXTBG), TRUE); + EnableWindow(GetDlgItem(hDlg, IDC_TXTTXT), TRUE); + GetDBColour(&colourSet); + SendDlgItemMessage(hDlg, IDC_INCOMING, CPM_SETCOLOUR, 0, colourSet.incoming); + SendDlgItemMessage(hDlg, IDC_OUTGOING, CPM_SETCOLOUR, 0, colourSet.outgoing); + SendDlgItemMessage(hDlg, IDC_BACKGROUND, CPM_SETCOLOUR, 0, colourSet.background); + SendDlgItemMessage(hDlg, IDC_TXT, CPM_SETCOLOUR, 0, colourSet.text); + } + else + { + mCol = GetMirandaColour(&colourSet); + if(mCol == 1) + { + MessageBox(NULL, TranslateT(TXT_NOSETTING), TranslateT(TXT_ERROR), MB_OK | MB_ICONEXCLAMATION); + SendDlgItemMessage(hDlg, IDC_CHECK1, BM_SETCHECK, BST_UNCHECKED, 0); + break; + } + else + { + EnableWindow(GetDlgItem(hDlg, IDC_INCOMING), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_OUTGOING), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_BACKGROUND), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_TXT), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_DEFAULT_IN), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_DEFAULT_OUT), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_DEFAULT_BG), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_DEFAULT_TXT), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_TXTIN), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_TXTOUT), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_TXTBG), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_TXTTXT), FALSE); + } + } + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + break; + } + + if ( wParam == IDC_CHECK2 ) + { + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + if ( SendDlgItemMessage(hDlg, IDC_CHECK2, BM_GETCHECK, 0, 0) == BST_UNCHECKED ) + options.openNewWindow = 0; + else + options.openNewWindow = 1; + + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + + break; + } + if ( wParam == IDC_CHECK3 ) + { + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + if ( SendDlgItemMessage(hDlg, IDC_CHECK3, BM_GETCHECK, 0, 0) == BST_UNCHECKED ) + options.updateWindow = 0; + else + options.updateWindow = 1; + + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + + break; + } + + if ( wParam == IDC_CHECK4 ) + { + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + if ( SendDlgItemMessage(hDlg, IDC_CHECK4, BM_GETCHECK, 0, 0) == BST_UNCHECKED ) + options.mouseEvent = 0; + else + options.mouseEvent = 1; + + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + + break; + } + + if ( wParam == IDC_CHECK5 ) + { + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + if(SendDlgItemMessage(hDlg, IDC_CHECK5, BM_GETCHECK, 0, 0) == BST_UNCHECKED) + options.saveSpecial = 0; + else + options.saveSpecial = 1; + + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + + break; + } + + if ( wParam == IDC_CHECK6 ) + { + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + if(SendDlgItemMessage(hDlg, IDC_CHECK6, BM_GETCHECK, 0, 0) == BST_UNCHECKED) + options.showDate = 0; + else + options.showDate = 1; + + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + + break; + } + + if ( wParam == IDC_CHECK7 ) + { + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + if(SendDlgItemMessage(hDlg, IDC_CHECK7, BM_GETCHECK, 0, 0) == BST_UNCHECKED) + options.showLine = 0; + else + options.showLine = 1; + + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + + break; + } + + if ( wParam == IDC_CHECK8 ) + { + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + if(SendDlgItemMessage(hDlg, IDC_CHECK8, BM_GETCHECK, 0, 0) == BST_UNCHECKED) + options.showTime = 0; + else + options.showTime = 1; + + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + //DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_TIME, 0x01); + + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + break; + } + + if ( wParam == IDC_CHECK9 ) + { + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + if(SendDlgItemMessage(hDlg, IDC_CHECK9, BM_GETCHECK, 0, 0) == BST_UNCHECKED) + options.showDirection = 0; + else + options.showDirection = 1; + + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + //DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_DIRECTION, 0x01); + + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + break; + } + + if ( wParam == IDC_CHECK10 ) + { + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + if(SendDlgItemMessage(hDlg, IDC_CHECK10, BM_GETCHECK, 0, 0) == BST_UNCHECKED) + options.showType = 0; + else + options.showType = 1; + + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + //DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_TYPE, 0x01); + + WriteOptionExample(hDlg, colourSet.incoming, colourSet.outgoing, colourSet.background, colourSet.text, &options); + break; + } + + } + + case WM_NOTIFY: + { + if ( ((LPNMHDR)lParam)->code == PSN_APPLY ) + { + // Write Settings to Database + if ( SendDlgItemMessage(hDlg, IDC_CHECK1, BM_GETCHECK, 0, 0) == BST_CHECKED ) + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_USE_DEF, 0x01); + else + { + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_USE_DEF, 0x00); + colourSet.incoming = SendDlgItemMessage(hDlg, IDC_INCOMING, CPM_GETCOLOUR, 0, 0); + colourSet.outgoing = SendDlgItemMessage(hDlg, IDC_OUTGOING, CPM_GETCOLOUR, 0, 0); + colourSet.background = SendDlgItemMessage(hDlg, IDC_BACKGROUND, CPM_GETCOLOUR, 0, 0); + colourSet.text = SendDlgItemMessage(hDlg, IDC_TXT, CPM_GETCOLOUR, 0, 0); + SetDBColour(&colourSet); + } + + SetListOptions(&options); + + // Write temporary values to Database + + + + + } + } + } + return FALSE; +} + + +/* +Progressbar +*/ +LRESULT CALLBACK ProgressBarDlg(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + static HWND hwndBN_OK, hwndBN_Cancel, hwndEdit, hwndPB; + static int cxChar, cyChar; + + 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); + 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 DefWindowProc(hwnd, message, wParam, lParam); +} + + + +/* +Splitter function. +Taken from srmm-plugin.... +*/ +LRESULT CALLBACK SplitterProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_NCHITTEST: + return HTCLIENT; + + case WM_SETCURSOR: + { + RECT rc; + GetClientRect(hWnd, &rc); + SetCursor(splitCursor); + return TRUE; + } + + case WM_LBUTTONDOWN: + SetCapture(hWnd); + return 0; + + case WM_MOUSEMOVE: + if ( GetCapture() == hWnd ) + { + RECT rc; + GetClientRect(hWnd, &rc); + SendMessage( GetParent(hWnd), DM_LINKSPLITTER, (WPARAM)(HIWORD(GetMessagePos()) + rc.bottom / 2), (LPARAM)hWnd); + } + return 0; + + case WM_LBUTTONUP: + ReleaseCapture(); + return 0; + } + return CallWindowProc(wndSplitterProc, hWnd, msg, wParam, lParam); +} \ No newline at end of file diff --git a/plugins/HistoryLinkListPlus/src/linklist_dlg.h b/plugins/HistoryLinkListPlus/src/linklist_dlg.h new file mode 100644 index 0000000000..9fe31f73b2 --- /dev/null +++ b/plugins/HistoryLinkListPlus/src/linklist_dlg.h @@ -0,0 +1,29 @@ +// History Linklist Plus +// Copyright (C) 2010 Thomas Wendel, gureedo +// +// 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 your option) any later version. +// +// 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. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +#pragma once + +#ifndef _LINKLIST_DLG_H +#define _LINKLIST_DLG_H + +INT_PTR WINAPI MainDlgProc( HWND, UINT, WPARAM, LPARAM ); +LRESULT CALLBACK ProgressBarDlg(HWND, UINT, WPARAM, LPARAM); +INT_PTR WINAPI SearchDlgProc( HWND, UINT, WPARAM, LPARAM ); +INT_PTR CALLBACK OptionsDlgProc(HWND, UINT, WPARAM, LPARAM ); +LRESULT CALLBACK SplitterProc(HWND, UINT, WPARAM, LPARAM); + +#endif //_LINKLIST_DLG_H \ No newline at end of file diff --git a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp new file mode 100644 index 0000000000..4d73448865 --- /dev/null +++ b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp @@ -0,0 +1,1360 @@ +// History Linklist Plus +// Copyright (C) 2010 Thomas Wendel, gureedo +// +// 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 your option) any later version. +// +// 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. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +#include +#include "resource.h" +#ifdef _DEBUG +#include +#endif + +// Miranda SDK Includes +#pragma warning(disable:4996) +#pragma warning(disable:4100) +#include +#include +#include +#include +#include +#pragma warning(default:4100) +#pragma warning(default:4996) + +#include "linklist.h" +#include "linklist_fct.h" +#include "language.h" +#include "utils.h" + + +extern HINSTANCE hInst; +extern HANDLE hWindowList; + +/* +The hyperlink detection in this function is taken from the +Miranda core. It looks a bit sophisticated. I'd made a few +changes but I didn't really understand what these guys did! +Great job! It works! ;-) +*/ +int ExtractURI(DBEVENTINFO *dbei, HANDLE hEvent, LISTELEMENT *listStart) +{ + int wordStart,i,iLastAlphaNum, linkFound=0; + int charCount=0,cpLastAlphaNum=0,cpWordStart; + LPCTSTR msg; + LPTSTR word, wordsearch, date_ptr, time_ptr; + 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") + }; + 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]; + + if ( listStart == NULL ) + return -1; + + ZeroMemory(link, _countof(link)*sizeof(TCHAR)); + ZeroMemory(date, _countof(date)*sizeof(TCHAR)); + ZeroMemory(time, _countof(time)*sizeof(TCHAR)); + + msg = DbGetEventTextT(dbei, CP_ACP); + for ( i=0; msg[i]; ) + { + //hyperlinks are delimited by: "hyperlink" + //then all punctuation is stripped from the end of "hyperlink" + iLastAlphaNum = 0; + while ( msg[i] && !_istalnum(msg[i])) + { + // support for files + 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 ( 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; + } + charCount++; + i++; + } + + charCount = cpLastAlphaNum+1; + i = iLastAlphaNum+1; + + if ( i-wordStart >= 7 ) + { + int j, isLink = 0, wordlen; + + 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; + } + } + + if ( !isLink ) { + for ( j=0; j<_countof(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, _countof(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); + } + else + { + size_t link_size; + if ( (i-wordStart+1) > LINK_MAX ) + link_size = LINK_MAX; + else + link_size = i-wordStart+1; + _tcsncpy_s(link, _countof(link), word, link_size); + } + + 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, _countof(date), date_ptr, DATE_SIZE); + _tcsncpy_s(time, _countof(time), time_ptr, TIME_SIZE); + // Prevent overflow + date[DATE_SIZE] = _T('\0'); + time[TIME_SIZE] = _T('\0'); + + if ( dbei->flags & DBEF_SENT ) { + direction = DIRECTION_OUT; + } else { + direction = DIRECTION_IN; + } + + if ( type == LINK_MAIL && _tcsstr(link, _T("mailto:")) == NULL ) + { + _tcscpy_s(templink, _countof(templink), link); + _tcscpy_s(link, _countof(link), _T("mailto:")); + _tcsncpy_s(link + _mstrlen(_T("mailto:")), _countof(link), templink, LINK_MAX-_mstrlen(_T("mailto:"))); + } + + // Add new Element to list: + newElement = (LISTELEMENT*)malloc(sizeof(LISTELEMENT)); + if ( newElement == NULL ) + return -1; + + ZeroMemory(newElement, sizeof(LISTELEMENT)); + newElement->direction = direction; + newElement->type = type; + _tcscpy_s(newElement->date, _countof(newElement->date), date); + _tcscpy_s(newElement->time, _countof(newElement->time), time); + _tcscpy_s(newElement->link, _countof(newElement->link), link); + newElement->hEvent = hEvent; + + actualElement = listStart; + while ( actualElement->nextElement != NULL ) + { + actualElement = actualElement->nextElement; + } + + actualElement->nextElement = newElement; + linkFound++; + } + free(word); + free(wordsearch); + } + } + + mir_free((void*)msg); + + return linkFound; +} + + +/* +Remove the linked list an free memory +*/ +int RemoveList(LISTELEMENT *listStart) +{ + LISTELEMENT *actualElement, *tempElement; + + if ( listStart == NULL ) + return -1; + + actualElement = listStart->nextElement; + while ( actualElement != NULL ) + { + tempElement = actualElement->nextElement; + free(actualElement); + actualElement = tempElement; + } + free(listStart); + return 0; +} + + +/* +Count the elements of the list +*/ +int ListCount(LISTELEMENT *listStart) +{ + LISTELEMENT *actualElement; + int count = 0; + + if ( listStart == NULL ) + return -1; + + actualElement = listStart->nextElement; + while ( actualElement != NULL ) + { + count++; + actualElement = actualElement->nextElement; + } + return count; +} + + +/* +Fill the richedit field with informations ;-) + +Special thanks to MatriX for his help with the cursor postion! +*/ +void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searchString, int append) +{ + CHARFORMAT2 cf; + PARAFORMAT2 pf; + HWND hwndProgress = NULL; + RECT DesktopRect; + MYCOLOURSET colourSet; + TCHAR textLine[LINK_MAX + DIR_SIZE + TIME_SIZE + TYPE_SIZE + 6]; + TCHAR searchText[320]; + TCHAR lastDate[11] = {0}; + TCHAR filter1, filter2, filter3; + size_t lineLen, listCount=0, realListCount=0, actCount=0, len, appCount = 0; + int linePos = -1; + LISTELEMENT *actualElement; + LISTOPTIONS options; + CHARRANGE sel; + GETTEXTLENGTHEX gtl; + DBEVENTINFO dbe; + + GetListInfo(params, listStart, searchString, &lineLen, &listCount, &realListCount); + GetColour(&colourSet); + GetListOptions(&options); + + if ( append == 0 ) + ShowWindow(GetDlgItem(hDlg, IDC_MAIN), SW_HIDE); + + if ( (append > 0) && (GetMenuState(GetMenu(hDlg), IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED)) + return; + + if ( GetDlgItem(hDlg, IDC_MAIN) && GetDlgItem(hDlg, IDC_MESSAGE)) + { + SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETEVENTMASK, 0, (LPARAM)(ENM_LINK)); + SendDlgItemMessage( hDlg, IDC_MAIN, EM_AUTOURLDETECT, TRUE, 0 ); + SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETBKGNDCOLOR, FALSE, colourSet.background); + + ZeroMemory(&cf, sizeof(cf)); + 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_AUTOURLDETECT, TRUE, 0 ); + SendDlgItemMessage( hDlg, IDC_MESSAGE, EM_SETBKGNDCOLOR, FALSE, colourSet.background); + + if ( append == 0 ) + { + ClearLinePos(listStart); + + // How to set RTF colour, font, etc.... found at + // http://www.winehq.com/hypermail/wine-devel/2004/08/0608.html + ZeroMemory(&pf, sizeof(pf)); + pf.cbSize = sizeof(pf); + pf.dwMask = PFM_ALIGNMENT; + pf.wAlignment = PFA_LEFT; + SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETPARAFORMAT, FALSE, (LPARAM) &pf); + + if ( searchString != NULL ) + { + ZeroMemory( &cf, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_FACE | CFM_COLOR; + cf.dwEffects = CFE_BOLD; + cf.crTextColor = colourSet.text; + _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Arial")); + SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf); + + ZeroMemory(searchText, _countof(searchText)*sizeof(TCHAR)); + mir_sntprintf(searchText, _countof(searchText), _T("%s '%s': %d\n\n"), TranslateT("Matches for searchtext"), searchString, listCount); + SendDlgItemMessage(hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM)searchText); + linePos += 2; + } + + ZeroMemory(&cf, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_FACE | CFM_BOLD; + _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Courier")); + SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); + } + + actualElement = listStart->nextElement; + + if ( append > 0 ) + { + linePos = GetLastLinePos(listStart); + + if ((realListCount - append) == 1) + _tcscpy_s(lastDate, _countof(lastDate), actualElement->date); + + for(appCount = 1; appCount <= (realListCount - append); appCount++) + { + actualElement = actualElement->nextElement; + if(appCount == (realListCount - append - 1)) + _tcscpy_s(lastDate, _countof(lastDate), actualElement->date); + } + gtl.flags = GTL_PRECISE; + gtl.codepage = CP_ACP; + sel.cpMin = sel.cpMax = SendMessage(GetDlgItem(hDlg, IDC_MAIN), EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); + SendMessage(GetDlgItem(hDlg, IDC_MAIN), EM_EXSETSEL, 0, (LPARAM) &sel); + } + + if ( append == 0 ) + { + // Create Progressbar + GetWindowRect(GetDesktopWindow(), &DesktopRect); + hwndProgress = CreateWindow(_T("Progressbar"), TranslateT("Processing list..."), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, 350, 45, NULL, NULL, hInst, NULL); + SetWindowPos(hwndProgress,HWND_TOP,(int)(DesktopRect.right*0.5)-175,(int)(DesktopRect.bottom*0.5)-22,0,0,SWP_NOSIZE); + + if ( hwndProgress != NULL ) + { + ShowWindow(hwndProgress, SW_SHOW); + SetForegroundWindow(hwndProgress); + } + } + + while ( actualElement != NULL ) + { + filter1 = 0; + filter2 = 0; + filter3 = 0; + + if ( (params & WLL_IN) && (actualElement->direction == DIRECTION_IN)) + filter1 = 1; + else if ( (params & WLL_OUT) && (actualElement->direction == DIRECTION_OUT)) + filter1 = 1; + + if ( (params & WLL_MAIL) && (actualElement->type == LINK_MAIL)) + filter2 = 1; + else if ( (params & WLL_URL) && (actualElement->type == LINK_URL)) + filter2 = 1; + else if ( (params & WLL_FILE) && (actualElement->type == LINK_FILE)) + filter2 = 1; + + + if ( searchString != NULL ) + { + if ( params & SLL_DEEP ) + { + // Perform deep scan + if ( actualElement->hEvent != NULL ) + { + LPCTSTR msg; + dbe.cbSize = sizeof(dbe); + dbe.cbBlob = (int)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)actualElement->hEvent, 0); + dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1); + CallService(MS_DB_EVENT_GET, (WPARAM)actualElement->hEvent, (LPARAM)&dbe); + dbe.pBlob[dbe.cbBlob] = 0; + msg = DbGetEventTextT(&dbe, CP_ACP); + if ( _tcsstr(msg, searchString)) + filter3 = 1; + + free(dbe.pBlob); + mir_free((void*)msg); + } + else + filter3 = 0; + } + else + { + if ( _tcsstr(actualElement->link, searchString)) + filter3 = 1; + } + } + else + filter3 = 1; + + if ( (filter1 == 1) && (filter2 == 1) && (filter3 == 1)) + { + LPCTSTR type; + + if ( _tcscmp(actualElement->date, lastDate) != 0 ) + { + ZeroMemory(&cf, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_COLOR; + cf.crTextColor = colourSet.text; + SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); + if ( options.showLine != 0 ) + DrawLine(hDlg, lineLen); + ZeroMemory(&cf, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_FACE; + cf.dwEffects = CFE_BOLD; + _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Arial")); + SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf); + if ( options.showDate != 0 ) + { + SendDlgItemMessage( hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM) actualElement->date); + SendDlgItemMessage( hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM) _T("\n\n")); + linePos += 3; + } + _tcscpy_s(lastDate, _countof(lastDate), actualElement->date); + ZeroMemory( &cf, sizeof(cf)); + cf.cbSize = sizeof cf; + cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_UNDERLINE | CFM_FACE; + _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Courier")); + SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf); + } + ZeroMemory( &cf, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_COLOR; + + if ( actualElement->direction == DIRECTION_OUT ) + { + cf.crTextColor = colourSet.incoming; + } + else + cf.crTextColor = colourSet.outgoing; + + switch( actualElement->type ) { + case LINK_MAIL: + type = _T("[mail]"); + break; + case LINK_URL: + type = _T("[URL ]"); + break; + case LINK_FILE: + type = _T("[file]"); + break; + default: + type = _T("[UNK ]"); + } + + mir_sntprintf(textLine, _countof(textLine), _T("%s%s%s%s%s%s%s\n"), + options.showDirection ? (actualElement->direction==DIRECTION_IN?_T("[in ]"):_T("[out]")) : _T(""), + options.showDirection? _T(" ") : _T(""), + options.showType ? type : _T(""), + options.showType ? _T(" ") : _T(""), + options.showTime ? actualElement->time : _T(""), + options.showTime ? _T(" ") : _T(""), + actualElement->link); + SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &cf); + SendDlgItemMessage(hDlg, IDC_MAIN, EM_REPLACESEL, FALSE,(LPARAM)textLine); + linePos++; + actualElement->linePos = linePos; + actCount++; + if ( hwndProgress && ( ((int)(((float)actCount/listCount)*100.00)) % 10 == 0 )) + SendMessage(hwndProgress, WM_COMMAND, 100,((int)(((float)actCount/listCount)*100.00))); + + } + actualElement = actualElement->nextElement; + } + if ( listCount > 0 ) + { + if ((actCount < listCount) && (append == 0) && (options.showLine != 0)) + DrawLine(hDlg, lineLen); + } + else if ( searchString == NULL ) + { + ZeroMemory( &cf, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_FACE; + cf.dwEffects = CFE_BOLD; + _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Arial")); + SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf); + SendDlgItemMessage( hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM)TranslateT("No messages found!\nPlease change current filter options.")); + SendDlgItemMessage( hDlg, IDC_MAIN, EM_REPLACESEL, FALSE, (LPARAM)_T("\n")); + } + + } + if ( append == 0 ) + { + SendMessage(hwndProgress, WM_CLOSE, 0, 0); + ShowWindow(GetDlgItem(hDlg, IDC_MAIN), SW_SHOW); + } + + PostMessage(GetDlgItem(hDlg, IDC_MAIN), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0); + len = GetWindowTextLength(GetDlgItem(hDlg, IDC_MAIN)); + PostMessage(GetDlgItem(hDlg, IDC_MAIN), EM_SETSEL, len, len); +} + + +/* +Output some example text to the options dialog +*/ +int WriteOptionExample(HWND hDlg, DWORD InColourSel, DWORD OutColourSel, DWORD BGColourSel, DWORD TxtColourSel, LISTOPTIONS *options) +{ + CHARFORMAT cf; + PARAFORMAT pf; + + ZeroMemory(&pf, sizeof(pf)); + pf.cbSize = sizeof(pf); + pf.dwMask = PFM_ALIGNMENT; + pf.wAlignment = PFA_LEFT; + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_SETPARAFORMAT, FALSE, (LPARAM)&pf); + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_SETEVENTMASK, 0, (LPARAM)(ENM_LINK)); + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_AUTOURLDETECT, TRUE, 0); + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_SETBKGNDCOLOR, FALSE, BGColourSel); + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, WM_SETTEXT , 0, (LPARAM)NULL); + + ZeroMemory(&cf, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_FACE | CFM_BOLD | CFM_ITALIC | CFM_COLOR; + _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Courier")); + cf.crTextColor = TxtColourSel; + SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf); + if ( options->showLine == 1 ) + SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("___________________________________________\n")); + else + SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("\n")); + + ZeroMemory(&cf, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_BOLD | CFM_FACE | CFM_COLOR; + cf.dwEffects = CFE_BOLD; + _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Arial")); + cf.crTextColor = TxtColourSel; + SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf); + + if(options->showDate == 1) + SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)TranslateT(TXT_DATE)); + + SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM) _T("\n")); + + ZeroMemory(&cf, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_ITALIC | CFM_BOLD | CFM_UNDERLINE | CFM_FACE; + _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Courier")); + SendDlgItemMessage( hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM) &cf); + + // incoming + ZeroMemory(&cf, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_COLOR | CFM_FACE; + cf.crTextColor = InColourSel; + _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Courier")); + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf ); + + if ( options->showDirection == 1 ) + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("\n[in ] ")); + else + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("\n")); + + if ( options->showType == 1 ) + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("URL ")); + else + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("")); + + if ( options->showTime == 1 ) + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("08:15 http://www.miranda-im.org\n")); + else + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("http://www.miranda-im.org\n")); + + // outgoing + ZeroMemory( &cf, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_COLOR | CFM_FACE; + cf.crTextColor = OutColourSel; + _tcscpy_s(cf.szFaceName, _countof(cf.szFaceName), _T("Courier")); + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_SETCHARFORMAT, SCF_SELECTION | SCF_WORD, (LPARAM)&cf); + + + if ( options->showDirection == 1 ) + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("[out] ")); + else + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("")); + + if(options->showType == 1) + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("URL ")); + else + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("")); + + if(options->showTime == 1) + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("08:16 http://www.miranda-im.org\n")); + else + SendDlgItemMessage(hDlg, IDC_OPTIONS_RE, EM_REPLACESEL, FALSE, (LPARAM)_T("http://www.miranda-im.org\n")); + + return 0; +} + + +/* +Write Message to window +*/ +void WriteMessage(HWND hDlg, LISTELEMENT *listStart, int actLinePos) +{ + LISTELEMENT *actualElement; + HANDLE hEvent; + DBEVENTINFO dbe; + + actualElement = listStart->nextElement; + while ( actualElement != NULL ) + { + if ( actualElement->linePos == actLinePos ) + { + hEvent = actualElement->hEvent; + if (hEvent != NULL ) + { + LPCTSTR msg; + dbe.cbSize = sizeof(dbe); + dbe.cbBlob = (int)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0); + dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1); + CallService(MS_DB_EVENT_GET,(WPARAM)hEvent,(LPARAM)&dbe); + dbe.pBlob[dbe.cbBlob] = 0; + msg = DbGetEventTextT(&dbe, CP_ACP); + SendDlgItemMessage(hDlg, IDC_MESSAGE, WM_SETTEXT , 0, (LPARAM)NULL); + SendDlgItemMessage(hDlg, IDC_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg); + mir_free((void*)msg); + free(dbe.pBlob); + } + break; + } + actualElement = actualElement->nextElement; + } +} + +/* +Little helper functions to get the actual state of +user options. +*/ +BYTE GetFlags(HMENU listMenu) +{ + BYTE returnflags = 0x00; + + if ( GetMenuState(listMenu, IDM_TYPE_WEB, MF_BYCOMMAND) == MF_UNCHECKED ) + returnflags = returnflags | WLL_MAIL; + + if ( GetMenuState(listMenu, IDM_TYPE_MAIL, MF_BYCOMMAND) == MF_UNCHECKED ) + returnflags = returnflags | WLL_URL; + + if ( GetMenuState(listMenu, IDM_DIR_IN, MF_BYCOMMAND) == MF_UNCHECKED ) + returnflags = returnflags | WLL_OUT; + + if ( GetMenuState(listMenu, IDM_DIR_OUT, MF_BYCOMMAND) == MF_UNCHECKED ) + returnflags = returnflags | WLL_IN; + + return returnflags; +} + +void GetFilterText(HMENU listMenu, LPTSTR filter, size_t max_len) +{ + + if ( GetMenuState(listMenu, IDM_TYPE_WEB, MF_BYCOMMAND) == MF_CHECKED ) + { + if ( GetMenuState(listMenu, IDM_DIR_IN, MF_BYCOMMAND) == MF_CHECKED ) + { + //incoming URLs + mir_sntprintf(filter, max_len, _T("%s: %s %s"), TranslateT(TXT_FILTER), TranslateT(TXT_INCOMING), TranslateT(TXT_URLSONLY)); + } + else if ( GetMenuState(listMenu, IDM_DIR_OUT, MF_BYCOMMAND) == MF_CHECKED ) + { + //outgoing URLs + mir_sntprintf(filter, max_len, _T("%s: %s %s"), TranslateT(TXT_FILTER), TranslateT(TXT_OUTGOING), TranslateT(TXT_URLSONLY)); + } + else + { + // both directions (URL) + mir_sntprintf(filter, max_len, _T("%s: %s %s"), TranslateT(TXT_FILTER), "", TranslateT(TXT_URLSONLY)); + } + } + else if ( GetMenuState(listMenu, IDM_TYPE_MAIL, MF_BYCOMMAND) == MF_CHECKED ) + { + if ( GetMenuState(listMenu, IDM_DIR_IN, MF_BYCOMMAND) == MF_CHECKED ) + { + //incoming mail + mir_sntprintf(filter, max_len, _T("%s: %s %s"), TranslateT(TXT_FILTER), TranslateT(TXT_INCOMING), TranslateT(TXT_MAILSONLY)); + } + else if ( GetMenuState(listMenu, IDM_DIR_OUT, MF_BYCOMMAND) == MF_CHECKED ) + { + //outgoing mail + mir_sntprintf(filter, max_len, _T("%s: %s %s"), TranslateT(TXT_FILTER), TranslateT(TXT_OUTGOING), TranslateT(TXT_MAILSONLY)); + } + else + { + // both directions (mail) + mir_sntprintf(filter, max_len, _T("%s: %s %s"), TranslateT(TXT_FILTER), "", TranslateT(TXT_MAILSONLY)); + } + } + else + { + if ( GetMenuState(listMenu, IDM_DIR_IN, MF_BYCOMMAND) == MF_CHECKED ) + { + //incoming (both) + mir_sntprintf(filter, max_len, _T("%s: %s %s"), TranslateT(TXT_FILTER), TranslateT(TXT_INCOMING), ""); + } + else if ( GetMenuState(listMenu, IDM_DIR_OUT, MF_BYCOMMAND) == MF_CHECKED ) + { + //outgoing (both) + mir_sntprintf(filter, max_len, _T("%s: %s %s"), TranslateT(TXT_FILTER), TranslateT(TXT_OUTGOING), ""); + } + else + { + // no filter + mir_sntprintf(filter, max_len, _T("%s: %s %s"), TranslateT(TXT_FILTER), TranslateT(TXT_NOFILTER), ""); + } + } +} + + +/* +Little helper function to draw a horizontal line +*/ +void DrawLine(HWND hDlg, size_t lineLen) +{ + TCHAR line[LINK_MAX + 18]; + size_t i; + for (i=0; (inextElement; + + while ( actualElement != NULL ) + { + (*realElementCount)++; + + filter1 = 0; + filter2 = 0; + filter3 = 0; + + if ( (params & WLL_IN) && (actualElement->direction == DIRECTION_IN)) + filter1 = 1; + else if ( (params & WLL_OUT) && (actualElement->direction == DIRECTION_OUT)) + filter1 = 1; + + if ( (params & WLL_MAIL) && (actualElement->type == LINK_MAIL)) + filter2 = 1; + else if ( (params & WLL_URL) && (actualElement->type == LINK_URL)) + filter2 = 1; + + if ( searchString != NULL ) + { + if ( params & SLL_DEEP ) + { + // Perform deep scan + if ( actualElement->hEvent != NULL ) + { + dbe.cbSize = sizeof(dbe); + dbe.pBlob = NULL; + dbe.cbBlob = (int)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)actualElement->hEvent, 0); + dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1); + CallService(MS_DB_EVENT_GET, (WPARAM)actualElement->hEvent, (LPARAM)&dbe); + dbe.pBlob[dbe.cbBlob] = 0; + if ( _tcsstr((LPTSTR)dbe.pBlob, searchString)) + filter3 = 1; + + free(dbe.pBlob); + } + else + filter3 = 0; + } + else + { + if(_tcsstr(actualElement->link, searchString)) + filter3 = 1; + } + } + else + filter3 = 1; + + if ((filter1 == 1) && (filter2 == 1) && (filter3 == 1)) + { + (*elementCount)++; + + tempLen = _tcslen(actualElement->link); + if (*maxLen < tempLen) + *maxLen = tempLen; + } + actualElement = actualElement->nextElement; + } + return; +} + + + +void GetListOptions(LISTOPTIONS *options) +{ + + options->openNewWindow = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_OPEN_WINDOW, 0xFF); + if(options->openNewWindow == 0xFF) + { + // No DB entry for this Plugin + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_OPEN_WINDOW, 0x00); + options->openNewWindow = 0x00; + } + + + options->updateWindow = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_UPDATE_WINDOW, 0xFF); + if(options->updateWindow == 0xFF) + { + // No DB entry for this Plugin + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_UPDATE_WINDOW, 0x00); + options->updateWindow = 0x00; + } + + options->mouseEvent = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0xFF); + if(options->mouseEvent == 0xFF) + { + // No DB entry for this Plugin + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0x00); + options->mouseEvent = 0x00; + } + + options->saveSpecial = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0xFF); + if(options->saveSpecial == 0xFF) + { + // No DB entry for this Plugin + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0x00); + options->saveSpecial = 0x00; + } + + + options->showDate = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_DATE, 0xFF); + if(options->showDate == 0xFF) + { + // No DB entry for this Plugin + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_DATE, 0x01); + options->showDate = 0x01; + } + + options->showLine = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_LINE, 0xFF); + if(options->showLine == 0xFF) + { + // No DB entry for this Plugin + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_LINE, 0x01); + options->showLine = 0x01; + } + + options->showTime = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_TIME, 0xFF); + if(options->showTime == 0xFF) + { + // No DB entry for this Plugin + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_TIME, 0x01); + options->showTime = 0x01; + } + + options->showDirection = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_DIRECTION, 0xFF); + if(options->showDirection == 0xFF) + { + // No DB entry for this Plugin + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_DIRECTION, 0x01); + options->showDirection = 0x01; + } + + options->showType = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_TYPE, 0xFF); + if(options->showType == 0xFF) + { + // No DB entry for this Plugin + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_TYPE, 0x01); + options->showType = 0x01; + } + + return; +} + +void SetListOptions(LISTOPTIONS *options) +{ + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_OPEN_WINDOW, options->openNewWindow); + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_UPDATE_WINDOW, options->updateWindow); + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, options->mouseEvent); + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, options->saveSpecial); + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_DATE, options->showDate); + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_LINE, options->showLine); + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_TIME, options->showTime); + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_DIRECTION, options->showDirection); + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_SHOW_TYPE, options->showType); +} + +/* +Clear temporary stored Linenumbers in List +*/ +void ClearLinePos(LISTELEMENT *listStart) +{ + LISTELEMENT *actualElement; + + if ( listStart == NULL ) + return; + + actualElement = listStart->nextElement; + while ( actualElement != NULL ) + { + actualElement->linePos = -1; + actualElement = actualElement->nextElement; + } +} + +int GetLastLinePos(LISTELEMENT *listStart) +{ + LISTELEMENT *actualElement; + int maxPos = -1; + + if ( listStart == NULL ) + return -1; + + actualElement = listStart->nextElement; + while ( actualElement != NULL ) + { + if ( actualElement->linePos > maxPos ) + maxPos = actualElement->linePos; + + actualElement = actualElement->nextElement; + } + return maxPos; +} + +/* +Read current coloursettings from the database +*/ +void GetColour(MYCOLOURSET *colourSet) +{ + DWORD colour; + BYTE useDefault; + + useDefault = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_USE_DEF, 0xFF); + if ( useDefault == 0xFF ) + { + // No DB entry for this Plugin + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_USE_DEF, 0x01); + useDefault = 0x01; + } + + if ( useDefault == 0x01 ) + { + // Use Miranda-IM Default colours + // CHANGED AT MIRANDA 0.4!!!! + // Use SRMM... if it is not there try SRMsg (older Miranda Versions) + colour = DBGetContactSettingDword(NULL, "SRMM", "SRMFont1Col", 0xFF000000); + if ( colour != 0xFF000000 ) + colourSet->incoming = colour; + else + { + colour = DBGetContactSettingDword(NULL, "SRMsg", "Font3Col", 0xFF000000); + if ( colour != 0xFF000000 ) + colourSet->incoming = colour; + else + { + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_USE_DEF, 0x00); + useDefault = 0x00; + } + } + + // SRMM + colour = DBGetContactSettingDword(NULL, "SRMM", "SRMFont0Col", 0xFF000000); + if ( colour != 0xFF000000 ) + colourSet->outgoing = colour; + else + { + // SRMsg + colour = DBGetContactSettingDword(NULL, "SRMsg", "Font0Col", 0xFF000000); + if ( colour != 0xFF000000 ) + colourSet->outgoing = colour; + else + { + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_USE_DEF, 0x00); + useDefault = 0x00; + } + } + + // SRMM + colour = DBGetContactSettingDword(NULL, "SRMM", "BkgColour", 0xFF000000); + if ( colour != 0xFF000000 ) + colourSet->background = colour; + else + { + // SRMsg + colour = DBGetContactSettingDword(NULL, "SRMsg", "BkgColour", 0xFF000000); + if ( colour != 0xFF000000 ) + colourSet->background = colour; + else + { + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_USE_DEF, 0x00); + useDefault = 0x00; + } + } + colourSet->text = MAKE_TXT_COL(colourSet->background); + } + + if ( useDefault == 0x00 ) + { + // Use Plugin user defined or default colours + colour = DBGetContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_IN_COL, 0xFF000000); + if ( colour != 0xFF000000 ) + colourSet->incoming = colour; + else + colourSet->incoming = IN_COL_DEF; + + colour = DBGetContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_OUT_COL, 0xFF000000); + if ( colour != 0xFF000000 ) + colourSet->outgoing = colour; + else + colourSet->outgoing = OUT_COL_DEF; + + colour = DBGetContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_BG_COL, 0xFF000000); + if ( colour != 0xFF000000 ) + colourSet->background = colour; + else + colourSet->background = BG_COL_DEF; + + colour = DBGetContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_TXT_COL, 0xFF000000); + if ( colour != 0xFF000000 ) + colourSet->text = colour; + else + colourSet->text = TXT_COL_DEF; + } +} + +/* +Read current coloursettings from the database and set default values +if entry does not exist. +*/ +void GetDBColour(MYCOLOURSET *colourSet) +{ + DWORD colour; + + // Use Plugin user defined or default colours + colour = DBGetContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_IN_COL, 0xFF000000); + if(colour != 0xFF000000) + colourSet->incoming = colour; + else + { + DBWriteContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_IN_COL, IN_COL_DEF); + colourSet->incoming = IN_COL_DEF; + } + + colour = DBGetContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_OUT_COL, 0xFF000000); + if(colour != 0xFF000000) + colourSet->outgoing = colour; + else + { + DBWriteContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_OUT_COL, OUT_COL_DEF); + colourSet->outgoing = OUT_COL_DEF; + } + + colour = DBGetContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_BG_COL, 0xFF000000); + if(colour != 0xFF000000) + colourSet->background = colour; + else + { + DBWriteContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_BG_COL, BG_COL_DEF); + colourSet->background = BG_COL_DEF; + } + + colour = DBGetContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_TXT_COL, 0xFF000000); + if(colour != 0xFF000000) + colourSet->text = colour; + else + { + DBWriteContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_TXT_COL, TXT_COL_DEF); + colourSet->text = TXT_COL_DEF; + } +} + +/* +Read current coloursettings from the database (Miranda settings) +*/ +int GetMirandaColour(MYCOLOURSET *colourSet) +{ + DWORD colour; + + // Use Miranda-IM Default colours + // Try SRMM (Miranda 0.4) .... or SRMsg... for older versions + colour = DBGetContactSettingDword(NULL, "SRMM", "SRMFont1Col", 0xFF000000); + if(colour != 0xFF000000) + colourSet->incoming = colour; + else + { + colour = DBGetContactSettingDword(NULL, "SRMsg", "Font3Col", 0xFF000000); + if(colour != 0xFF000000) + colourSet->incoming = colour; + else + return 1; + } + + + colour = DBGetContactSettingDword(NULL, "SRMM", "SRMFont0Col", 0xFF000000); + if(colour != 0xFF000000) + colourSet->outgoing = colour; + else + { + colour = DBGetContactSettingDword(NULL, "SRMsg", "Font0Col", 0xFF000000); + if(colour != 0xFF000000) + colourSet->outgoing = colour; + else + return 1; + } + + colour = DBGetContactSettingDword(NULL, "SRMM", "BkgColour", 0xFF000000); + if(colour != 0xFF000000) + colourSet->background = colour; + else + { + colour = DBGetContactSettingDword(NULL, "SRMsg", "BkgColour", 0xFF000000); + if(colour != 0xFF000000) + colourSet->background = colour; + else + return 1; + } + + colourSet->text = MAKE_TXT_COL(colourSet->background); + return 0; +} + + +/* +Write user defined colours to the database +*/ +void SetDBColour(MYCOLOURSET *colourSet) +{ + DBWriteContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_IN_COL, colourSet->incoming); + DBWriteContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_OUT_COL, colourSet->outgoing); + DBWriteContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_BG_COL, colourSet->background); + DBWriteContactSettingDword(NULL, LINKLIST_MODULE, LINKLIST_TXT_COL, colourSet->text); +} + +BYTE GetUpdateSetting(void) +{ + BYTE updateWindow; + + updateWindow = DBGetContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_UPDATE_WINDOW, 0xFF); + if ( updateWindow == 0xFF ) + { + // No DB entry for this Plugin + DBWriteContactSettingByte(NULL, LINKLIST_MODULE, LINKLIST_UPDATE_WINDOW, 0x00); + return 0; + } + if ( updateWindow == 0x00 ) + return 0; + else + return 1; +} + +/* +Special thanks to Tobi H.! +This function is derived from his Wordlookup Plugin +*/ +int DBUpdate(WPARAM wParam, LPARAM lParam) +{ + HANDLE hEvent=(HANDLE)lParam; + HWND hDlg = WindowList_Find(hWindowList, (HANDLE)wParam); + DBEVENTINFO dbe; + DIALOGPARAM *DlgParam; + HMENU listMenu = GetMenu(hDlg); + int linkNum = 0; + + DlgParam = (DIALOGPARAM *)GetWindowLongPtr(hDlg, GWLP_USERDATA); + + if(GetUpdateSetting() != 1) + return 0; + + if(hDlg) + { + ZeroMemory(&dbe, sizeof(dbe)); + dbe.cbSize = sizeof(dbe); + + dbe.cbBlob = (int)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0); + dbe.pBlob = (PBYTE)malloc((size_t)dbe.cbBlob+1); + CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbe); + + if ( (dbe.eventType == EVENTTYPE_URL) || (dbe.eventType == EVENTTYPE_MESSAGE)) + { + // Call function to find URIs + linkNum = ExtractURI(&dbe, hEvent, DlgParam->listStart); + if ( linkNum > 0 ) + WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, linkNum); + } + free(dbe.pBlob); + } + return 0; +} + + +/* +Little resize helper +*/ +int LinklistResizer(HWND hDlg, LPARAM lParam, UTILRESIZECONTROL *urc) +{ + DIALOGPARAM *DlgParam = (DIALOGPARAM*)lParam; + UNREFERENCED_PARAMETER(hDlg); + + switch(urc->wId) + { + case IDC_MAIN: + urc->rcItem.bottom -= DlgParam->splitterPosNew - DlgParam->splitterPosOld; + return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT; + + case IDC_MESSAGE: + urc->rcItem.top -= DlgParam->splitterPosNew - DlgParam->splitterPosOld; + return RD_ANCHORX_WIDTH|RD_ANCHORY_BOTTOM; + + case IDC_STATUS: + return RD_ANCHORX_WIDTH|RD_ANCHORY_BOTTOM; + + case IDC_SPLITTER: + urc->rcItem.top -= DlgParam->splitterPosNew - DlgParam->splitterPosOld; + urc->rcItem.bottom -= DlgParam->splitterPosNew - DlgParam->splitterPosOld; + return RD_ANCHORX_WIDTH|RD_ANCHORY_BOTTOM; + } + + return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; +} + + +/* +Next both functions are taken from a example projekt, found at +http://www.programmersheaven.com/zone15/cat236/2405.htm +The author is unknown, but this peace of code made my work much easier! +*/ +BOOL SaveEditAsStream( HWND hDlg ) +{ + EDITSTREAM es; + LONG lOut; + OPENFILENAME ofn; + HANDLE hFile; + TCHAR szFilename[MAX_PATH]; + + // Initialize filename field + _tcscpy_s(szFilename, _countof(szFilename), _T("*.rtf")); + // Fill in OPENFILENAME struct + ZeroMemory(&ofn, sizeof(OPENFILENAME)); + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = hDlg; + ofn.lpstrFilter = _T("RTF File\0*.rtf\0All Files\0*.*\0\0"); + ofn.lpstrFile = szFilename; + ofn.nMaxFile = _countof(szFilename); + ofn.lpstrTitle = _T("Save RTF File"); + ofn.Flags = OFN_OVERWRITEPROMPT; + // Get a filename or quit + if ( ! GetSaveFileName( &ofn )) + return FALSE; + // Create the specified file + hFile = CreateFile( szFilename, GENERIC_WRITE, 0, NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); + // Quit if file creation fails + if ( hFile == INVALID_HANDLE_VALUE ) + return FALSE; + // Pass file handle to callback + // so the callback can do the file write + es.dwCookie = (DWORD_PTR)hFile; + es.dwError = 0; + es.pfnCallback = (EDITSTREAMCALLBACK)RTFSaveStreamCallback; + // Start the callback proc + lOut = SendDlgItemMessage( hDlg, IDC_MAIN, EM_STREAMOUT, SF_RTF, (LPARAM)&es ); + // Close file handle and exit + CloseHandle(hFile); + return TRUE; +} + +DWORD CALLBACK RTFSaveStreamCallback(DWORD_PTR dwCookie, LPBYTE lpBuffer, LONG lSize, LONG *plRead) +{ + // Sanity check...exit if nothing passed + if ( ! lSize ) + return 1; + // Initialize "amount read" variable for WriteFile() + *plRead = 0; + // dwCookie is the file handle + WriteFile( (HANDLE)dwCookie, lpBuffer, lSize, (LPDWORD)plRead, NULL ); + // Continue, if needed + return 0; +} + + diff --git a/plugins/HistoryLinkListPlus/src/linklist_fct.h b/plugins/HistoryLinkListPlus/src/linklist_fct.h new file mode 100644 index 0000000000..b29c8f82db --- /dev/null +++ b/plugins/HistoryLinkListPlus/src/linklist_fct.h @@ -0,0 +1,46 @@ +// History Linklist Plus +// Copyright (C) 2010 Thomas Wendel, gureedo +// +// 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 your option) any later version. +// +// 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. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +#pragma once + +#ifndef _LINKLIST_FCT_H +#define _LINKLIST_FCT_H + +#include "linklist.h" + +void DrawLine(HWND, size_t); +BYTE GetFlags(HMENU); +void GetFilterText(HMENU, LPTSTR, size_t); +void GetListInfo(BYTE, LISTELEMENT*, LPCTSTR, size_t*, size_t*, size_t*); +void GetListOptions(LISTOPTIONS*); +void SetListOptions(LISTOPTIONS*); +void ClearLinePos(LISTELEMENT*); +int GetLastLinePos(LISTELEMENT*); +void WriteLinkList(HWND, BYTE, LISTELEMENT*, LPCTSTR, int); +int WriteOptionExample(HWND, DWORD, DWORD, DWORD, DWORD, LISTOPTIONS*); +void WriteMessage(HWND, LISTELEMENT*, int); +void GetColour(MYCOLOURSET*); +void GetDBColour(MYCOLOURSET*); +void SetDBColour(MYCOLOURSET*); +int GetMirandaColour(MYCOLOURSET*); +BYTE GetUpdateSetting(void); +int LinklistResizer(HWND,LPARAM,UTILRESIZECONTROL*); +// RTF Save functions +BOOL SaveEditAsStream( HWND ); +DWORD CALLBACK RTFSaveStreamCallback( DWORD_PTR, LPBYTE, LONG, LONG * ); + +#endif //_LINKLIST_FCT_H \ No newline at end of file diff --git a/plugins/HistoryLinkListPlus/src/resource.h b/plugins/HistoryLinkListPlus/src/resource.h new file mode 100644 index 0000000000..740b3d8479 --- /dev/null +++ b/plugins/HistoryLinkListPlus/src/resource.h @@ -0,0 +1,72 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by linklist.rc +// +#define IDC_MAIN 100 +#define IDR_MENU1 101 +#define IDM_SEARCH 101 +#define IDC_MESSAGE 101 +#define IDM_SAVE 102 +#define IDM_CLOSE 103 +#define IDM_DIR_IN 105 +#define IDM_DIR_OUT 106 +#define IDM_TYPE_MAIL 108 +#define IDD_OPTIONS_DLG 108 +#define IDM_TYPE_WEB 109 +#define IDR_MENU2 110 +#define IDI_LINKLISTICON 300 +#define IDC_SEARCHSTRING 400 +#define IDSEARCH 401 +#define IDC_DIR_IN 402 +#define IDC_DIR_OUT 403 +#define IDC_TYPE_MAIL 404 +#define IDC_TYPE_WEB 405 +#define IDC_DIR_ALL 410 +#define IDC_TYPE_ALL 411 +#define IDC_OPTIONS_ALT 1023 +#define IDC_DEFAULT_IN 1024 +#define IDC_TXTIN 1026 +#define IDC_TXTOUT 1027 +#define IDC_TXTBG 1028 +#define IDC_TXTTXT 1029 +#define IDC_DEFAULT_OUT 1031 +#define IDC_DEFAULT_BG 1032 +#define IDC_DEFAULT_TXT 1033 +#define IDC_CHECK1 1034 +#define IDC_BACKGROUND 1039 +#define IDC_OUTGOING 1040 +#define IDC_INCOMING 1041 +#define IDC_TXT 1042 +#define IDC_OPTIONS_RE 1043 +#define IDC_CHECK2 1046 +#define IDC_CHECK3 1047 +#define IDC_STATUS 1047 +#define IDC_CHECK4 1048 +#define IDC_WHOLE_MESSAGE 1049 +#define IDC_CHECK5 1049 +#define IDC_SPLITTER 1051 +#define IDC_CHECK6 1052 +#define IDC_CHECK7 1053 +#define IDC_CHECK8 1054 +#define IDC_CHECK9 1055 +#define IDC_CHECK10 1056 +#define IDD_MAIN_DLG 10000 +#define IDD_SEARCH_DLG 11001 +#define IDM_CLEARSEARCH 40009 +#define IDM_LINK_OPEN 40010 +#define IDM_LINK_OPENNEW 40011 +#define IDM_LINK_COPY 40012 +#define IDM_SHOWMESSAGE 40013 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 112 +#define _APS_NEXT_COMMAND_VALUE 40015 +#define _APS_NEXT_CONTROL_VALUE 1052 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/HistoryLinkListPlus/src/utils.cpp b/plugins/HistoryLinkListPlus/src/utils.cpp new file mode 100644 index 0000000000..e21f75ee89 --- /dev/null +++ b/plugins/HistoryLinkListPlus/src/utils.cpp @@ -0,0 +1,29 @@ +// History Linklist Plus +// Copyright (C) 2010 Thomas Wendel, gureedo +// +// 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 your option) any later version. +// +// 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. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +#include + +// Miranda SDK Includes +#pragma warning(disable:4996) +#pragma warning(disable:4100) +#include +#include +#pragma warning(default:4100) +#pragma warning(default:4996) + +#include "utils.h" diff --git a/plugins/HistoryLinkListPlus/src/utils.h b/plugins/HistoryLinkListPlus/src/utils.h new file mode 100644 index 0000000000..5338981bd0 --- /dev/null +++ b/plugins/HistoryLinkListPlus/src/utils.h @@ -0,0 +1,25 @@ +// History Linklist Plus +// Copyright (C) 2010 Thomas Wendel, gureedo +// +// 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 your option) any later version. +// +// 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. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +#pragma once + +#ifndef _UTILS_H_ +#define _UTILS_H_ + +#define _mstrlen(x) (_countof(x)-1) + +#endif // _UTILS_H_ \ No newline at end of file -- cgit v1.2.3