summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yapp/common.h58
-rw-r--r--yapp/docs/m_popup.h338
-rw-r--r--yapp/docs/m_yapp.h466
-rw-r--r--yapp/message_pump.cpp11
-rw-r--r--yapp/notify_imp.cpp2
-rw-r--r--yapp/options.cpp56
-rw-r--r--yapp/popup_history.cpp35
-rw-r--r--yapp/popup_history.h9
-rw-r--r--yapp/popup_history_dlg.cpp10
-rw-r--r--yapp/popups2.cpp79
-rw-r--r--yapp/popups2.dsp10
-rw-r--r--yapp/popups2_9.vcproj49
-rw-r--r--yapp/popwin.cpp56
-rw-r--r--yapp/services.cpp202
-rw-r--r--yapp/services.h26
-rw-r--r--yapp/str_utils.cpp229
-rw-r--r--yapp/str_utils.h53
-rw-r--r--yapp/version.h24
-rw-r--r--yapp/version.rc1
19 files changed, 296 insertions, 1418 deletions
diff --git a/yapp/common.h b/yapp/common.h
index 7cfcd5f..cd8db2c 100644
--- a/yapp/common.h
+++ b/yapp/common.h
@@ -27,17 +27,15 @@
#define _UNICODE
#endif
-#include <tchar.h>
+#include <m_stdhdr.h>
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include <commctrl.h>
-#include <malloc.h>
-#include <stdlib.h>
#include <time.h>
-#define MIRANDA_VER 0x0600
+#define MIRANDA_VER 0x0700
#include <newpluginapi.h>
#include <statusmodes.h>
@@ -45,18 +43,17 @@
#include <m_langpack.h>
#include <m_options.h>
#include <m_system.h>
+#include <m_system_cpp.h>
#include <m_idle.h>
#include <m_skin.h>
#include <m_clui.h>
#include <m_clist.h>
-#include <stdio.h>
#include <m_utils.h>
-
-#include <m_yapp.h>
-
-#include "m_updater.h"
#include <m_fontservice.h>
#include <m_avatars.h>
+#include <m_popup.h>
+
+#include "m_updater.h"
#include <m_notify.h>
@@ -64,19 +61,16 @@
extern HMODULE hInst;
extern PLUGINLINK *pluginLink;
-extern HANDLE mainThread;
extern HFONT hFontFirstLine, hFontSecondLine, hFontTime;
extern COLORREF colFirstLine, colSecondLine, colBg, colTime, colBorder, colSidebar, colTitleUnderline;
extern MNOTIFYLINK *notifyLink;
-extern int code_page;
-
// work around a bug in neweventnotify, possibly httpserver
// ignore the address passed to the 'get plugin data' service
extern bool ignore_gpd_passed_addy;
-
+
// win32 defines for mingw version of windows headers :(
#ifndef LVM_SORTITEMSEX
#define LVM_SORTITEMSEX (LVM_FIRST + 81)
@@ -86,3 +80,41 @@ typedef int (CALLBACK *PFNLVCOMPARE)(LPARAM, LPARAM, LPARAM);
#define ListView_SortItemsEx(hwndLV, _pfnCompare, _lPrm) \
(BOOL)SendMessage((hwndLV), LVM_SORTITEMSEX, (WPARAM)(LPARAM)(_lPrm), (LPARAM)(PFNLVCOMPARE)(_pfnCompare))
#endif
+
+
+typedef struct {
+ int cbSize;
+ int flags; // OR of PDF_* flags below
+ HANDLE hContact;
+ HICON hIcon;
+ union {
+ char *pszTitle;
+ TCHAR *ptzTitle;
+ wchar_t *pwzTitle;
+ };
+ union {
+ char *pszText;
+ TCHAR *ptzText;
+ wchar_t *pwzText;
+ };
+ COLORREF colorBack; // if colorBack and colorText are equal, defaults will be used
+ COLORREF colorText;
+ WNDPROC windowProc; // optional custom window procedure
+ int timeout; // -1 == infinite, 0 == default, otherwise timeout in seconds
+ void *opaque;
+} PopupData;
+
+#define PDF_UNICODE 0x0001
+#ifdef _UNICODE
+#define PDF_TCHAR PDF_UNICODE
+#else
+#define PDF_TCHAR 0
+#endif
+
+// windowProc messages
+#define PM_INIT (WM_USER + 0x0202) // message sent to your windowProc after the window has been initialized
+#define PM_DIENOTIFY (WM_USER + 0x0200) // message sent to your windowProc just before the window is destroyed (can be used e.g. to free your opaque data)
+
+#define PM_DESTROY (WM_USER + 0x0201) // send to the popup hWnd (use PostMessage generally, or SendMessage inside your windowProc) to kill it
+
+void ShowPopup(PopupData &pd_in); \ No newline at end of file
diff --git a/yapp/docs/m_popup.h b/yapp/docs/m_popup.h
deleted file mode 100644
index 8078d86..0000000
--- a/yapp/docs/m_popup.h
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
-===============================================================================
- PopUp plugin
-Plugin Name: PopUp
-Plugin authors: Luca Santarelli aka hrk (hrk@users.sourceforge.net)
- Victor Pavlychko aka zazoo (nullbie@gmail.com)
-===============================================================================
-The purpose of this plugin is to give developers a common "platform/interface"
-to show PopUps. It is born from the source code of NewStatusNotify, another
-plugin I've made.
-
-Remember that users *must* have this plugin enabled, or they won't get any
-popup. Write this in the requirements, do whatever you wish ;-)... but tell
-them!
-===============================================================================
-*/
-
-#ifndef M_POPUP_H
-#define M_POPUP_H
-
-/*
-NOTE! Since Popup 1.0.1.2 there is a main meun group called "PopUps" where I
-have put a "Enable/Disable" item. You can add your own "enable/disable" items
-by adding these lines before you call MS_CLIST_ADDMAINMENUITEM:
-mi.pszPopUpName = Translate("PopUps");
-mi.position = 0; //You don't need it and it's better if you put it to zero.
-*/
-
-#define MAX_CONTACTNAME 2048
-#define MAX_SECONDLINE 2048
-
-// This is the basic data you'll need to fill and pass to the service function.
-typedef struct
-{
- HANDLE lchContact; // Handle to the contact, can be NULL (main contact).
- HICON lchIcon; // Handle to a icon to be shown. Cannot be NULL.
- union
- {
- char lptzContactName[MAX_CONTACTNAME]; // This is the contact name or the first line in the plugin. Cannot be NULL.
- char lpzContactName[MAX_CONTACTNAME];
- };
- union
- {
- char lptzText[MAX_SECONDLINE]; // This is the second line text. Users can choose to hide it. Cannot be NULL.
- char lpzText[MAX_SECONDLINE];
- };
- COLORREF colorBack; // COLORREF to be used for the background. Can be NULL, default will be used.
- COLORREF colorText; // COLORREF to be used for the text. Can be NULL, default will be used.
- WNDPROC PluginWindowProc; // Read below. Can be NULL; default will be used.
- void * PluginData; // Read below. Can be NULL.
-} POPUPDATA, * LPPOPUPDATA;
-
-// Extended popup data
-typedef struct
-{
- HANDLE lchContact;
- HICON lchIcon;
- union
- {
- char lptzContactName[MAX_CONTACTNAME];
- char lpzContactName[MAX_CONTACTNAME];
- };
- union
- {
- char lptzText[MAX_SECONDLINE];
- char lpzText[MAX_SECONDLINE];
- };
- COLORREF colorBack;
- COLORREF colorText;
- WNDPROC PluginWindowProc;
- void * PluginData;
- int iSeconds; // Custom delay time in seconds. -1 means "forever", 0 means "default time".
- char cZero[16]; // Some unused bytes which may come useful in the future.
-} POPUPDATAEX, *LPPOPUPDATAEX;
-
-// Unicode version of POPUPDATAEX
-typedef struct
-{
- HANDLE lchContact;
- HICON lchIcon;
- union
- {
- WCHAR lptzContactName[MAX_CONTACTNAME];
- WCHAR lpwzContactName[MAX_CONTACTNAME];
- };
- union
- {
- WCHAR lptzText[MAX_SECONDLINE];
- WCHAR lpwzText[MAX_SECONDLINE];
- };
- COLORREF colorBack;
- COLORREF colorText;
- WNDPROC PluginWindowProc;
- void * PluginData;
- int iSeconds;
- char cZero[16];
-} POPUPDATAW, *LPPOPUPDATAW;
-
-#if defined(_UNICODE) || defined(UNICODE)
- typedef POPUPDATAW POPUPDATAT;
- typedef LPPOPUPDATAW LPPOPUPDATAT;
-#else
- typedef POPUPDATAEX POPUPDATAT;
- typedef LPPOPUPDATAEX LPPOPUPDATAT;
-#endif
-
-/* PopUp/AddPopup
-Creates, adds and shows a popup, given a (valid) POPUPDATA structure pointer.
-
-wParam = (WPARAM)(*POPUPDATA)PopUpDataAddress
-lParam = 0
-
-Returns: > 0 on success, 0 if creation went bad, -1 if the PopUpData contained unacceptable values.
-NOTE: it returns -1 if the PopUpData was not valid, if there were already too many popups, if the module was disabled.
-Otherwise, it can return anything else...
-
-Popup Plus 2.0.4.0+
-You may pass additional creation flags via lParam:
- APF_RETURN_HWND ....... function returns handle to newly created popup window (however this calls are a bit slower)
- APF_CUSTOM_POPUP ...... new popup is created in hidden state and doesn't obey to popup queue rules.
- you may control it via UM_* messages and custom window procedure
-*/
-#define APF_RETURN_HWND 0x1
-#define APF_CUSTOM_POPUP 0x2
-
-#define MS_POPUP_ADDPOPUP "PopUp/AddPopUp"
-static INT_PTR __inline PUAddPopUp(POPUPDATA* ppdp) {
- return CallService(MS_POPUP_ADDPOPUP, (WPARAM)ppdp,0);
-}
-
-#define MS_POPUP_ADDPOPUPEX "PopUp/AddPopUpEx"
-static INT_PTR __inline PUAddPopUpEx(POPUPDATAEX* ppdp) {
- return CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)ppdp,0);
-}
-
-#define MS_POPUP_ADDPOPUPW "PopUp/AddPopUpW"
-static INT_PTR __inline PUAddPopUpW(POPUPDATAW* ppdp) {
- return CallService(MS_POPUP_ADDPOPUPW, (WPARAM)ppdp,0);
-}
-
-#if defined(_UNICODE) || defined(UNICODE)
- #define MS_POPUP_ADDPOPUPT MS_POPUP_ADDPOPUPW
- #define PUAddPopUpT PUAddPopUpW
-#else
- #define MS_POPUP_ADDPOPUPT MS_POPUP_ADDPOPUPEX
- #define PUAddPopUpT PUAddPopUpEx
-#endif
-
-
-/* PopUp/GetContact
-Returns the handle to the contact associated to the specified PopUpWindow.
-
-wParam = (WPARAM)(HWND)hPopUpWindow
-lParam = 0;
-
-Returns: the HANDLE of the contact. Can return NULL, meaning it's the main contact. -1 means failure.
-*/
-#define MS_POPUP_GETCONTACT "PopUp/GetContact"
-static HANDLE __inline PUGetContact(HWND hPopUpWindow) {
- return (HANDLE)CallService(MS_POPUP_GETCONTACT, (WPARAM)hPopUpWindow,0);
-}
-
-/* PopUp/GetPluginData
-Returns custom plugin date associated with popup
-
-wParam = (WPARAM)(HWND)hPopUpWindow
-lParam = (LPARAM)(PLUGINDATA*)PluginDataAddress;
-
-Returns: the address of the PLUGINDATA structure. Can return NULL, meaning nothing was given. -1 means failure.
-
-IMPORTANT NOTE: it doesn't seem to work if you do:
-CallService(..., (LPARAM)aPointerToAStruct);
-and then use that struct.
-Do this, instead:
-aPointerToStruct = CallService(..., (LPARAM)aPointerToAStruct);
-and it will work. Just look at the example I've written above (PopUpDlgProc).
-
-*/
-#define MS_POPUP_GETPLUGINDATA "PopUp/GetPluginData"
-static void __inline * PUGetPluginData(HWND hPopUpWindow) {
- long * uselessPointer = NULL;
- return (void*)CallService(MS_POPUP_GETPLUGINDATA,(WPARAM)hPopUpWindow,(LPARAM)uselessPointer);
-}
-
-/* PopUp/IsSecondLineShown
-Checks if second line is enable
-
-wParam = 0
-lParam = 0
-
-Returns: 0 if the user has chosen not to have the second line, 1 if he choose to have the second line.
-*/
-#define MS_POPUP_ISSECONDLINESHOWN "PopUp/IsSecondLineShown"
-static BOOL __inline PUIsSecondLineShown() {
- return (BOOL)CallService(MS_POPUP_ISSECONDLINESHOWN,0,0);
-}
-
-/* PopUp/Query
-
-Requests an action or an answer from PopUp module.
-
-wParam = (WPARAM)wpQuery
-
-returns 0 on success, -1 on error, 1 on stupid calls ;-)
-*/
-
-#define PUQS_ENABLEPOPUPS 1 // returns 0 if state was changed, 1 if state wasn't changed
-#define PUQS_DISABLEPOPUPS 2 // " "
-#define PUQS_GETSTATUS 3 //Returns 1 (TRUE) if popups are enabled, 0 (FALSE) if popups are disabled.
-
-#define MS_POPUP_QUERY "PopUp/Query"
-
-/* UM_FREEPLUGINDATA
-Process this message if you have allocated your own memory. (i.e.: POPUPDATA.PluginData != NULL)
-
-wParam = 0
-lParam = 0
-*/
-#define UM_FREEPLUGINDATA (WM_USER + 0x0200)
-
-/* UM_DESTROYPOPUP
-Send this message when you want to destroy the popup, or use the function below.
-
-wParam = 0
-lParam = 0
-*/
-#define UM_DESTROYPOPUP (WM_USER + 0x0201)
-static int __inline PUDeletePopUp(HWND hWndPopUp) {
- return (int)SendMessage(hWndPopUp, UM_DESTROYPOPUP,0,0);
-}
-
-/* UM_INITPOPUP
-This message is sent to the PopUp when its creation has been finished, so POPUPDATA (and thus your PluginData) is reachable.
-Catch it if you needed to catch WM_CREATE or WM_INITDIALOG, which you'll never ever get in your entire popup-life.
-Return value: if you process this message, return 0. If you don't process it, return 0. Do whatever you like ;-)
-
-wParam = (WPARAM)(HWND)hPopUpWindow (this is useless, you get message inside your popup window)
-lParam = 0
-*/
-#define UM_INITPOPUP (WM_USER + 0x0202)
-
-/* PopUp/Changetext
-Changes the text displayed in the second line of the popup.
-
-wParam = (WPARAM)(HWND)hPopUpWindow
-lParam = (LPARAM)(char*)lpzNewText
-
-returns: > 0 for success, -1 for failure, 0 if the failure is due to second line not being shown. (but you could call
-PUIsSecondLineShown() before changing the text...)
-*/
-#define MS_POPUP_CHANGETEXT "PopUp/Changetext"
-static int __inline PUChangeText(HWND hWndPopUp, LPCTSTR lpzNewText) {
- return (int)CallService(MS_POPUP_CHANGETEXT, (WPARAM)hWndPopUp, (LPARAM)lpzNewText);
-}
-
-#define MS_POPUP_CHANGETEXTW "PopUp/ChangetextW"
-static int __inline PUChangeTextW(HWND hWndPopUp, LPCWSTR lpwzNewText) {
- return (int)CallService(MS_POPUP_CHANGETEXTW, (WPARAM)hWndPopUp, (LPARAM)lpwzNewText);
-}
-
-#if defined(_UNICODE) || defined(UNICODE)
- #define MS_POPUP_CHANGETEXTT MS_POPUP_CHANGETEXTW
- #define PUChangeTextT PUChangeTextW
-#else
- #define MS_POPUP_CHANGETEXTT MS_POPUP_CHANGETEXT
- #define PUChangeTextT PUChangeText
-#endif
-
-/* PopUp/Change
-Changes the entire popup
-
-wParam = (WPARAM)(HWND)hPopUpWindow
-lParam = (LPARAM)(POPUPDATAEX*)newData
-*/
-#define MS_POPUP_CHANGE "PopUp/Change"
-static int __inline PUChange(HWND hWndPopUp, POPUPDATAEX *newData) {
- return (int)CallService(MS_POPUP_CHANGE, (WPARAM)hWndPopUp, (LPARAM)newData);
-}
-
-#define MS_POPUP_CHANGEW "PopUp/ChangeW"
-static int __inline PUChangeW(HWND hWndPopUp, POPUPDATAW *newData) {
- return (int)CallService(MS_POPUP_CHANGE, (WPARAM)hWndPopUp, (LPARAM)newData);
-}
-
-#if defined(_UNICODE) || defined(UNICODE)
- #define MS_POPUP_CHANGET MS_POPUP_CHANGEW
- #define PUChangeT PUChangeW
-#else
- #define MS_POPUP_CHANGET MS_POPUP_CHANGE
- #define PUChangeT PUChange
-#endif
-
-/* UM_CHANGEPOPUP
-This message is triggered by Change/ChangeText services. You also may post it directly :)
-
-wParam = Modification type
-lParam = value of type defined by wParam
-*/
-
-#define CPT_TEXT 1 // lParam = (char *)text
-#define CPT_TEXTW 2 // lParam = (WCHAR *)text
-#define CPT_TITLE 3 // lParam = (char *)title
-#define CPT_TITLEW 4 // lParam = (WCHAR *)title
-#define CPT_DATA 5 // lParam = (POPUPDATA *)data
-#define CPT_DATAEX 6 // lParam = (POPUPDATAEX *)data
-#define CPT_DATAW 7 // lParam = (POPUPDATAW *)data
-
-#define UM_CHANGEPOPUP (WM_USER + 0x0203)
-
-#if defined(_UNICODE) || defined(UNICODE)
- #define CPT_TEXTT CPT_TEXTW
- #define CPT_TITLET CPT_TITLEW
- #define CPT_DATAT CPT_DATAW
-#else
- #define CPT_TEXTT CPT_TEXT
- #define CPT_TITLET CPT_TITLE
- #define CPT_DATAT CPT_DATA
-#endif
-
-/* PopUp/ShowMessage
-This is mainly for developers.
-Shows a warning message in a PopUp. It's useful if you need a "MessageBox" like function, but you don't want a modal
-window (which will interfere with a DialogProcedure. MessageBox steals focus and control, this one not.
-
-wParam = (char *)lpzMessage
-lParam = 0;
-
-Returns: 0 if the popup was shown, -1 in case of failure.
-*/
-#define SM_WARNING 0x01 //Triangle icon.
-#define SM_NOTIFY 0x02 //Exclamation mark icon.
-#define MS_POPUP_SHOWMESSAGE "PopUp/ShowMessage"
-
-static int __inline PUShowMessage(char *lpzText, BYTE kind) {
- return (int)CallService(MS_POPUP_SHOWMESSAGE, (WPARAM)lpzText,(LPARAM)kind);
-}
-
-#endif // __m_popup_h__
diff --git a/yapp/docs/m_yapp.h b/yapp/docs/m_yapp.h
deleted file mode 100644
index 25b5e45..0000000
--- a/yapp/docs/m_yapp.h
+++ /dev/null
@@ -1,466 +0,0 @@
-#ifndef _YAPP_INC
-#define _YAPP_INC
-
-////////////////////////////////////////////////
-// YAPP API
-///////////////////////////////////////////////
-
-typedef struct {
- int cbSize;
- int flags; // OR of PDF_* flags below
- HANDLE hContact;
- HICON hIcon;
- union {
- char *pszTitle;
- TCHAR *ptzTitle;
- wchar_t *pwzTitle;
- };
- union {
- char *pszText;
- TCHAR *ptzText;
- wchar_t *pwzText;
- };
- COLORREF colorBack; // if colorBack and colorText are equal, defaults will be used
- COLORREF colorText;
- WNDPROC windowProc; // optional custom window procedure
- int timeout; // -1 == infinite, 0 == default, otherwise timeout in seconds
- void *opaque;
-} PopupData;
-
-#define PDF_UNICODE 0x0001
-#ifdef _UNICODE
-#define PDF_TCHAR PDF_UNICODE
-#else
-#define PDF_TCHAR 0
-#endif
-
-// windowProc messages
-#define PM_INIT (WM_USER + 0x0202) // message sent to your windowProc after the window has been initialized
-#define PM_DIENOTIFY (WM_USER + 0x0200) // message sent to your windowProc just before the window is destroyed (can be used e.g. to free your opaque data)
-
-#define PM_DESTROY (WM_USER + 0x0201) // send to the popup hWnd (use PostMessage generally, or SendMessage inside your windowProc) to kill it
-
-// Show a popup
-//wParam = &PopupData
-//lParam = 0
-// returns -1 if popups disabled
-#define MS_YAPP_SHOWPOPUP "YAPP/ShowPopup"
-
-static int __inline ShowPopup(PopupData* pd) {
- return CallService(MS_YAPP_SHOWPOPUP, (WPARAM)pd,0);
-}
-
-// get hContact from PopupData
-// wParam = hWnd
-// lParam = 0
-// return hContact
-#define MS_YAPP_GETCONTACT "YAPP/GetContact"
-
-static HANDLE __inline PGetContact(HWND hWndPopup) {
- return (HANDLE)CallService(MS_YAPP_GETCONTACT, (WPARAM)hWndPopup, 0);
-}
-
-// get opaque from PopupData
-// wParam = hWnd
-// lParam = 0
-// returns opaque
-#define MS_YAPP_GETOPAQUE "YAPP/GetOpaque"
-static void __inline * PGetOpaque(HWND hWndPopup) {
- return (void*)CallService(MS_YAPP_GETOPAQUE,(WPARAM)hWndPopup, 0);
-}
-
-
-//------------- Class API ----------------//
-
-typedef struct {
- int cbSize;
- int flags;
- char *pszName;
- union {
- char *pszDescription;
- wchar_t *pwszDescription;
- TCHAR *ptszDescription;
- };
-
- HICON hIcon;
-
- COLORREF colorBack;
- COLORREF colorText;
-
- WNDPROC windowProc;
-
- int timeout;
-} PopupClass;
-
-#define PCF_UNICODE 0x0001
-
-#ifdef _UNICODE
-#define PCF_TCHAR PCF_UNICODE
-#else
-#define PCF_TCHAR 0
-#endif
-
-// wParam = 0
-// lParam = (POPUPCLASS *)&pc
-#define MS_POPUP_REGISTERCLASS "PopUp/RegisterClass"
-
-typedef struct {
- int cbSize;
- const char *pszClassName;
- union {
- const char *pszTitle;
- const wchar_t *pwszTitle;
- const TCHAR *ptszTitle;
- };
- union {
- const char *pszText;
- const wchar_t *pwszText;
- const TCHAR *ptszText;
- };
- void *opaque;
- HANDLE hContact;
-} PopupClassInstance;
-
-// wParam = 0
-// lParam = (POPUPDATACLASS *)&pdc
-#define MS_POPUP_ADDPOPUPCLASS "PopUp/AddPopupClass"
-
-static int __inline ShowClassPopupA(const char *name, const char *title, const char *text) {
- PopupClassInstance d = {sizeof(d), name};
- d.pszTitle = title;
- d.pszText = text;
- return CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&d);
-}
-
-static int __inline ShowClassPopupW(const char *name, const wchar_t *title, const wchar_t *text) {
- PopupClassInstance d = {sizeof(d), name};
- d.pwszTitle = title;
- d.pwszText = text;
- return CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&d);
-}
-
-#ifdef _UNICODE
-#define ShowClassPopup ShowClassPopupW
-#else
-#define ShowClassPopup ShowClassPopupA
-#endif
-
-////////////////////////////////////////////////
-//// legacy support for old popup structures
-///////////////////////////////////////////////
-
-/*
-NOTE! Since Popup 1.0.1.2 there is a main meun group called "PopUps" where I
-have put a "Enable/Disable" item. You can add your own "enable/disable" items
-by adding these lines before you call MS_CLIST_ADDMAINMENUITEM:
-mi.pszPopUpName = Translate("PopUps");
-mi.position = 0; //You don't need it and it's better if you put it to zero.
-*/
-
-#define MAX_CONTACTNAME 2048
-#define MAX_SECONDLINE 2048
-
-// This is the basic data you'll need to fill and pass to the service function.
-typedef struct
-{
- HANDLE lchContact; // Handle to the contact, can be NULL (main contact).
- HICON lchIcon; // Handle to a icon to be shown. Cannot be NULL.
- union
- {
- char lptzContactName[MAX_CONTACTNAME]; // This is the contact name or the first line in the plugin. Cannot be NULL.
- char lpzContactName[MAX_CONTACTNAME];
- };
- union
- {
- char lptzText[MAX_SECONDLINE]; // This is the second line text. Users can choose to hide it. Cannot be NULL.
- char lpzText[MAX_SECONDLINE];
- };
- COLORREF colorBack; // COLORREF to be used for the background. Can be NULL, default will be used.
- COLORREF colorText; // COLORREF to be used for the text. Can be NULL, default will be used.
- WNDPROC PluginWindowProc; // Read below. Can be NULL; default will be used.
- void * PluginData; // Read below. Can be NULL.
-} POPUPDATA, * LPPOPUPDATA;
-
-// Extended popup data
-typedef struct
-{
- HANDLE lchContact;
- HICON lchIcon;
- union
- {
- char lptzContactName[MAX_CONTACTNAME];
- char lpzContactName[MAX_CONTACTNAME];
- };
- union
- {
- char lptzText[MAX_SECONDLINE];
- char lpzText[MAX_SECONDLINE];
- };
- COLORREF colorBack;
- COLORREF colorText;
- WNDPROC PluginWindowProc;
- void * PluginData;
- int iSeconds; // Custom delay time in seconds. -1 means "forever", 0 means "default time".
- char cZero[16]; // Some unused bytes which may come useful in the future.
-} POPUPDATAEX, *LPPOPUPDATAEX;
-
-// Unicode version of POPUPDATAEX
-typedef struct
-{
- HANDLE lchContact;
- HICON lchIcon;
- union
- {
- WCHAR lptzContactName[MAX_CONTACTNAME];
- WCHAR lpwzContactName[MAX_CONTACTNAME];
- };
- union
- {
- WCHAR lptzText[MAX_CONTACTNAME];
- WCHAR lpwzText[MAX_CONTACTNAME];
- };
- COLORREF colorBack;
- COLORREF colorText;
- WNDPROC PluginWindowProc;
- void * PluginData;
- int iSeconds;
- char cZero[16];
-} POPUPDATAW, *LPPOPUPDATAW;
-
-#if defined(_UNICODE) || defined(UNICODE)
- typedef POPUPDATAW POPUPDATAT;
- typedef LPPOPUPDATAW LPPOPUPDATAT;
-#else
- typedef POPUPDATAEX POPUPDATAT;
- typedef LPPOPUPDATAEX LPPOPUPDATAT;
-#endif
-
-/* PopUp/AddPopup
-Creates, adds and shows a popup, given a (valid) POPUPDATA structure pointer.
-
-wParam = (WPARAM)(*POPUPDATA)PopUpDataAddress
-lParam = 0
-
-Returns: > 0 on success, 0 if creation went bad, -1 if the PopUpData contained unacceptable values.
-NOTE: it returns -1 if the PopUpData was not valid, if there were already too many popups, if the module was disabled.
-Otherwise, it can return anything else...
-
-*/
-
-#define MS_POPUP_ADDPOPUP "PopUp/AddPopUp"
-static int __inline PUAddPopUp(POPUPDATA* ppdp) {
- return CallService(MS_POPUP_ADDPOPUP, (WPARAM)ppdp,0);
-}
-
-#define MS_POPUP_ADDPOPUPEX "PopUp/AddPopUpEx"
-static int __inline PUAddPopUpEx(POPUPDATAEX* ppdp) {
- return CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)ppdp,0);
-}
-
-#define MS_POPUP_ADDPOPUPW "PopUp/AddPopUpW"
-static int __inline PUAddPopUpW(POPUPDATAW* ppdp) {
- return CallService(MS_POPUP_ADDPOPUPW, (WPARAM)ppdp,0);
-}
-
-#if defined(_UNICODE) || defined(UNICODE)
- #define MS_POPUP_ADDPOPUPT MS_POPUP_ADDPOPUPW
- #define PUAddPopUpT PUAddPopUpW
-#else
- #define MS_POPUP_ADDPOPUPT MS_POPUP_ADDPOPUPEX
- #define PUAddPopUpT PUAddPopUpEx
-#endif
-
-
-/* PopUp/GetContact
-Returns the handle to the contact associated to the specified PopUpWindow.
-
-wParam = (WPARAM)(HWND)hPopUpWindow
-lParam = 0;
-
-Returns: the HANDLE of the contact. Can return NULL, meaning it's the main contact. -1 means failure.
-*/
-#define MS_POPUP_GETCONTACT "PopUp/GetContact"
-static HANDLE __inline PUGetContact(HWND hPopUpWindow) {
- return (HANDLE)CallService(MS_POPUP_GETCONTACT, (WPARAM)hPopUpWindow,0);
-}
-
-/* PopUp/GetPluginData
-Returns custom plugin date associated with popup
-
-wParam = (WPARAM)(HWND)hPopUpWindow
-lParam = (LPARAM)(PLUGINDATA*)PluginDataAddress;
-
-Returns: the address of the PLUGINDATA structure. Can return NULL, meaning nothing was given. -1 means failure.
-
-IMPORTANT NOTE: it doesn't seem to work if you do:
-CallService(..., (LPARAM)aPointerToAStruct);
-and then use that struct.
-Do this, instead:
-aPointerToStruct = CallService(..., (LPARAM)aPointerToAStruct);
-and it will work. Just look at the example I've written above (PopUpDlgProc).
-
-*/
-#define MS_POPUP_GETPLUGINDATA "PopUp/GetPluginData"
-static void __inline * PUGetPluginData(HWND hPopUpWindow) {
- long * uselessPointer = NULL;
- return (void*)CallService(MS_POPUP_GETPLUGINDATA,(WPARAM)hPopUpWindow,(LPARAM)uselessPointer);
-}
-
-/* PopUp/IsSecondLineShown
-Checks if second line is enable
-
-wParam = 0
-lParam = 0
-
-Returns: 0 if the user has chosen not to have the second line, 1 if he choose to have the second line.
-*/
-#define MS_POPUP_ISSECONDLINESHOWN "PopUp/IsSecondLineShown"
-static BOOL __inline PUIsSecondLineShown() {
- return (BOOL)CallService(MS_POPUP_ISSECONDLINESHOWN,0,0);
-}
-
-/* PopUp/Query
-
-Requests an action or an answer from PopUp module.
-
-wParam = (WPARAM)wpQuery
-
-returns 0 on success, -1 on error, 1 on stupid calls ;-)
-*/
-
-#define PUQS_ENABLEPOPUPS 1 // returns 0 if state was changed, 1 if state wasn't changed
-#define PUQS_DISABLEPOPUPS 2 // " "
-#define PUQS_GETSTATUS 3 //Returns 1 (TRUE) if popups are enabled, 0 (FALSE) if popups are disabled.
-
-#define MS_POPUP_QUERY "PopUp/Query"
-
-/* UM_FREEPLUGINDATA
-Process this message if you have allocated your own memory. (i.e.: POPUPDATA.PluginData != NULL)
-
-wParam = 0
-lParam = 0
-*/
-#define UM_FREEPLUGINDATA (WM_USER + 0x0200)
-
-/* UM_DESTROYPOPUP
-Send this message when you want to destroy the popup, or use the function below.
-
-wParam = 0
-lParam = 0
-*/
-#define UM_DESTROYPOPUP (WM_USER + 0x0201)
-static int __inline PUDeletePopUp(HWND hWndPopUp) {
- return (int)SendMessage(hWndPopUp, UM_DESTROYPOPUP,0,0);
-}
-
-/* UM_INITPOPUP
-This message is sent to the PopUp when its creation has been finished, so POPUPDATA (and thus your PluginData) is reachable.
-Catch it if you needed to catch WM_CREATE or WM_INITDIALOG, which you'll never ever get in your entire popup-life.
-Return value: if you process this message, return 0. If you don't process it, return 0. Do whatever you like ;-)
-
-wParam = (WPARAM)(HWND)hPopUpWindow (this is useless, you get message inside your popup window)
-lParam = 0
-*/
-#define UM_INITPOPUP (WM_USER + 0x0202)
-
-/* PopUp/Changetext
-Changes the text displayed in the second line of the popup.
-
-wParam = (WPARAM)(HWND)hPopUpWindow
-lParam = (LPARAM)(char*)lpzNewText
-
-returns: > 0 for success, -1 for failure, 0 if the failure is due to second line not being shown. (but you could call
-PUIsSecondLineShown() before changing the text...)
-*/
-#define MS_POPUP_CHANGETEXT "PopUp/Changetext"
-static int __inline PUChangeText(HWND hWndPopUp, LPCTSTR lpzNewText) {
- return (int)CallService(MS_POPUP_CHANGETEXT, (WPARAM)hWndPopUp, (LPARAM)lpzNewText);
-}
-
-#define MS_POPUP_CHANGETEXTW "PopUp/ChangetextW"
-static int __inline PUChangeTextW(HWND hWndPopUp, LPCWSTR lpwzNewText) {
- return (int)CallService(MS_POPUP_CHANGETEXTW, (WPARAM)hWndPopUp, (LPARAM)lpwzNewText);
-}
-
-#if defined(_UNICODE) || defined(UNICODE)
- #define MS_POPUP_CHANGETEXTT MS_POPUP_CHANGETEXTW
- #define PUChangeTextT PUChangeTextW
-#else
- #define MS_POPUP_CHANGETEXTT MS_POPUP_CHANGETEXT
- #define PUChangeTextT PUChangeText
-#endif
-
-/* PopUp/Change
-Changes the entire popup
-
-wParam = (WPARAM)(HWND)hPopUpWindow
-lParam = (LPARAM)(POPUPDATAEX*)newData
-*/
-#define MS_POPUP_CHANGE "PopUp/Change"
-static int __inline PUChange(HWND hWndPopUp, POPUPDATAEX *newData) {
- return (int)CallService(MS_POPUP_CHANGE, (WPARAM)hWndPopUp, (LPARAM)newData);
-}
-
-#define MS_POPUP_CHANGEW "PopUp/ChangeW"
-static int __inline PUChangeW(HWND hWndPopUp, POPUPDATAW *newData) {
- return (int)CallService(MS_POPUP_CHANGEW, (WPARAM)hWndPopUp, (LPARAM)newData);
-}
-
-#if defined(_UNICODE) || defined(UNICODE)
- #define MS_POPUP_CHANGET MS_POPUP_CHANGEW
- #define PUChangeT PUChangeW
-#else
- #define MS_POPUP_CHANGET MS_POPUP_CHANGE
- #define PUChangeT PUChange
-#endif
-
-/* UM_CHANGEPOPUP
-This message is triggered by Change/ChangeText services. You also may post it directly :)
-
-wParam = Modification type
-lParam = value of type defined by wParam
-*/
-
-#define CPT_TEXT 1 // lParam = (char *)text
-#define CPT_TEXTW 2 // lParam = (WCHAR *)text
-#define CPT_TITLE 3 // lParam = (char *)title
-#define CPT_TITLEW 4 // lParam = (WCHAR *)title
-#define CPT_DATA 5 // lParam = (POPUPDATA *)data
-#define CPT_DATAEX 6 // lParam = (POPUPDATAEX *)data
-#define CPT_DATAW 7 // lParam = (POPUPDATAW *)data
-
-#define UM_CHANGEPOPUP (WM_USER + 0x0203)
-
-#if defined(_UNICODE) || defined(UNICODE)
- #define CPT_TEXTT CPT_TEXTW
- #define CPT_TITLET CPT_TITLEW
- #define CPT_DATAT CPT_DATAW
-#else
- #define CPT_TEXTT CPT_TEXT
- #define CPT_TITLET CPT_TITLE
- #define CPT_DATAT CPT_DATA
-#endif
-
-/* PopUp/ShowMessage
-This is mainly for developers.
-Shows a warning message in a PopUp. It's useful if you need a "MessageBox" like function, but you don't want a modal
-window (which will interfere with a DialogProcedure. MessageBox steals focus and control, this one not.
-
-wParam = (char *)lpzMessage
-lParam = 0;
-
-Returns: 0 if the popup was shown, -1 in case of failure.
-*/
-#define SM_WARNING 0x01 //Triangle icon.
-#define SM_NOTIFY 0x02 //Exclamation mark icon.
-#define MS_POPUP_SHOWMESSAGE "PopUp/ShowMessage"
-#define MS_POPUP_SHOWMESSAGEW "PopUp/ShowMessageW"
-
-static int __inline PUShowMessage(char *lpzText, BYTE kind) {
- return (int)CallService(MS_POPUP_SHOWMESSAGE, (WPARAM)lpzText,(LPARAM)kind);
-}
-
-static int __inline PUShowMessageW(wchar_t *lpwzText, BYTE kind) {
- return (int)CallService(MS_POPUP_SHOWMESSAGEW, (WPARAM)lpwzText,(LPARAM)kind);
-}
-#endif // _YAPP_INC
diff --git a/yapp/message_pump.cpp b/yapp/message_pump.cpp
index a03dae3..c2483d3 100644
--- a/yapp/message_pump.cpp
+++ b/yapp/message_pump.cpp
@@ -97,9 +97,11 @@ DWORD CALLBACK MessagePumpThread(LPVOID param) {
if(hwndMsg.wParam) // set notifyer handle
SendMessage(hwnd, PUM_SETNOTIFYH, hwndMsg.wParam, 0);
} else {
- if(pd && pd->pwzTitle) free(pd->pwzTitle);
- if(pd && pd->pwzText) free(pd->pwzText);
- if(pd) free(pd);
+ if (pd) {
+ mir_free(pd->pwzTitle);
+ mir_free(pd->pwzText);
+ mir_free(pd);
+ }
}
}
break;
@@ -134,7 +136,7 @@ DWORD CALLBACK MessagePumpThread(LPVOID param) {
DispatchMessage(&hwndMsg);
// do this here in case the window has gone
if(hwndMsg.message == PUM_CHANGE || hwndMsg.message == PUM_SETTEXT)
- free((void *)hwndMsg.lParam);
+ mir_free((void *)hwndMsg.lParam);
}
break;
}
@@ -166,7 +168,6 @@ void FindWindow(PopupData *pd, HANDLE hEvent, HWND *hwnd);
void InitMessagePump() {
WNDCLASS popup_win_class = {0};
- popup_win_class.style = 0;
popup_win_class.lpfnWndProc = PopupWindowProc;
popup_win_class.hInstance = hInst;
popup_win_class.lpszClassName = POP_WIN_CLASS;
diff --git a/yapp/notify_imp.cpp b/yapp/notify_imp.cpp
index 66f31e3..2f2ca99 100644
--- a/yapp/notify_imp.cpp
+++ b/yapp/notify_imp.cpp
@@ -12,7 +12,7 @@ int Popup2Show(WPARAM wParam, LPARAM lParam) {
HANDLE hNotify = (HANDLE)lParam;
- PopupData *pd_out = (PopupData *)malloc(sizeof(PopupData));
+ PopupData *pd_out = (PopupData *)mir_alloc(sizeof(PopupData));
memset(pd_out, 0, sizeof(PopupData));
PostMPMessage(MUM_CREATEPOPUP, (WPARAM)hNotify, (LPARAM)pd_out);
diff --git a/yapp/options.cpp b/yapp/options.cpp
index 5edca0b..ea49116 100644
--- a/yapp/options.cpp
+++ b/yapp/options.cpp
@@ -2,8 +2,6 @@
#include "options.h"
#include "resource.h"
#include "popwin.h"
-#include <commctrl.h>
-#include "str_utils.h"
#include "services.h"
Options options;
@@ -92,13 +90,15 @@ void ShowExamplePopups() {
pd.ptzTitle = TranslateT("Example");
pd.ptzText = TranslateT("The quick brown fox jumped over the lazy dog.");
- CallService(MS_YAPP_SHOWPOPUP, (WPARAM)&pd, 0);
+ ShowPopup(pd);
+
pd.ptzTitle = TranslateT("Example With a Long Title");
pd.ptzText = TranslateT("The quick brown fox jumped over the lazy dog.");
- CallService(MS_YAPP_SHOWPOPUP, (WPARAM)&pd, 0);
+ ShowPopup(pd);
+
pd.ptzTitle = TranslateT("Example");
pd.ptzText = TranslateT("Thequickbrownfoxjumpedoverthelazydog.");
- CallService(MS_YAPP_SHOWPOPUP, (WPARAM)&pd, 0);
+ ShowPopup(pd);
HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
while(hContact) {
@@ -107,7 +107,7 @@ void ShowExamplePopups() {
if(ace && (ace->dwFlags & AVS_BITMAP_VALID)) {
pd.hContact = hContact;
pd.ptzText = TranslateT("An avatar.");
- CallService(MS_YAPP_SHOWPOPUP, (WPARAM)&pd, 0);
+ ShowPopup(pd);
break;
}
}
@@ -183,15 +183,14 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
lvI.mask = LVIF_TEXT;
char *strptr;
- TCHAR buff[256];
int i = 0;
for(; i < 10; i++) {
strptr = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)(ID_STATUS_OFFLINE + i), (LPARAM)0);
- a2t(strptr, buff, 256);
- lvI.pszText = buff;
+ lvI.pszText = mir_a2t(strptr);
lvI.iItem = i;
ListView_InsertItem(hwndList, &lvI);
ListView_SetCheckState(hwndList, i, options.disable_status[i]);
+ mir_free(lvI.pszText);
}
lvI.pszText = TranslateT("Full-screen app running");
lvI.iItem = i;
@@ -354,17 +353,17 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
return 0;
}
-PopupClass *newclasses = 0;
+POPUPCLASS *newclasses = 0;
static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch ( msg ) {
case WM_INITDIALOG:
TranslateDialogDefault( hwndDlg );
{
if(num_classes) {
- newclasses = (PopupClass *)malloc(num_classes * sizeof(PopupClass));
- memcpy(newclasses, classes, num_classes * sizeof(PopupClass));
+ newclasses = (POPUPCLASS *)mir_alloc(num_classes * sizeof(POPUPCLASS));
+ memcpy(newclasses, classes, num_classes * sizeof(POPUPCLASS));
- PopupClass *pc;
+ POPUPCLASS *pc;
int index;
for(int i = 0; i < num_classes; i++) {
pc = &newclasses[i];
@@ -389,8 +388,8 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_SETCOLOUR, 0, (LPARAM)newclasses[i].colorText);
SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_SETCOLOUR, 0, (LPARAM)newclasses[i].colorBack);
- CheckDlgButton(hwndDlg, IDC_CHK_TIMEOUT, newclasses[i].timeout != -1);
- SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, newclasses[i].timeout, TRUE);
+ CheckDlgButton(hwndDlg, IDC_CHK_TIMEOUT, newclasses[i].iSeconds != -1);
+ SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, newclasses[i].iSeconds, TRUE);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), index != -1 && IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT));
return TRUE;
@@ -400,7 +399,7 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
BOOL tr;
int t = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &tr, FALSE);
- newclasses[i].timeout = t;
+ newclasses[i].iSeconds = t;
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
@@ -413,9 +412,9 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
{
BOOL isChecked = IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT);
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), isChecked);
- if(isChecked) newclasses[i].timeout = 0;
- else newclasses[i].timeout = -1;
- SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, newclasses[i].timeout, TRUE);
+ if(isChecked) newclasses[i].iSeconds = 0;
+ else newclasses[i].iSeconds = -1;
+ SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, newclasses[i].iSeconds, TRUE);
}
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
break;
@@ -429,16 +428,16 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
break;
case IDC_BTN_PREVIEW:
if(newclasses[i].flags & PCF_UNICODE) {
- PopupClass pc = newclasses[i];
- pc.windowProc = 0;
- PopupClassInstance d = {sizeof(d), pc.pszName};
+ POPUPCLASS pc = newclasses[i];
+ pc.PluginWindowProc = 0;
+ POPUPDATACLASS d = {sizeof(d), pc.pszName};
d.pwszTitle = L"Preview";
d.pwszText = L"The quick brown fox jumps over the lazy dog.";
CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d);
} else {
- PopupClass pc = newclasses[i];
- pc.windowProc = 0;
- PopupClassInstance d = {sizeof(d), pc.pszName};
+ POPUPCLASS pc = newclasses[i];
+ pc.PluginWindowProc = 0;
+ POPUPDATACLASS d = {sizeof(d), pc.pszName};
d.pszTitle = "Preview";
d.pszText = "The quick brown fox jumps over the lazy dog.";
CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d);
@@ -450,11 +449,11 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
break;
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) {
- memcpy(classes, newclasses, num_classes * sizeof(PopupClass));
+ memcpy(classes, newclasses, num_classes * sizeof(POPUPCLASS));
char setting[256];
for(int i = 0; i < num_classes; i++) {
mir_snprintf(setting, 256, "%s/Timeout", classes[i].pszName);
- DBWriteContactSettingWord(0, MODULE, setting, classes[i].timeout);
+ DBWriteContactSettingWord(0, MODULE, setting, classes[i].iSeconds);
mir_snprintf(setting, 256, "%s/TextCol", classes[i].pszName);
DBWriteContactSettingDword(0, MODULE, setting, (DWORD)classes[i].colorText);
mir_snprintf(setting, 256, "%s/BgCol", classes[i].pszName);
@@ -464,7 +463,7 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
}
break;
case WM_DESTROY:
- if(newclasses) free(newclasses);
+ mir_free(newclasses);
break;
}
return 0;
@@ -506,5 +505,4 @@ void InitOptions() {
void DeinitOptions() {
UnhookEvent(hEventOptInit);
- DestroyIcon(hPopupIcon);
}
diff --git a/yapp/popup_history.cpp b/yapp/popup_history.cpp
index b413727..8658d6f 100644
--- a/yapp/popup_history.cpp
+++ b/yapp/popup_history.cpp
@@ -1,6 +1,3 @@
-#define STRICT
-#define WIN32_LEAN_AND_MEAN
-
#include "common.h"
#include "popup_history.h"
@@ -28,16 +25,6 @@ void PopupHistoryList::Clear()
count = 0;
}
-int PopupHistoryList::Count()
-{
- return count;
-}
-
-int PopupHistoryList::Size()
-{
- return size;
-}
-
void PopupHistoryList::RemoveItem(int index)
{
int i;
@@ -51,8 +38,8 @@ void PopupHistoryList::RemoveItem(int index)
void PopupHistoryList::DeleteData(int index)
{
PopupHistoryData *item = &historyData[index];
- free(item->titleT);
- free(item->messageT);
+ mir_free(item->titleT);
+ mir_free(item->messageT);
item->timestamp = 0; //invalidate item
item->title = NULL;
item->message = NULL;
@@ -74,8 +61,8 @@ void PopupHistoryList::Add(char *title, char *message, time_t timestamp)
{
PopupHistoryData item = {0}; //create a history item
item.timestamp = timestamp;
- item.title = strdup(title);
- item.message = strdup(message);
+ item.title = mir_strdup(title);
+ item.message = mir_strdup(message);
AddItem(item); //add it (flags = 0)
}
@@ -84,8 +71,8 @@ void PopupHistoryList::Add(wchar_t *title, wchar_t *message, time_t timestamp)
PopupHistoryData item = {0}; //create an unicode history item
item.flags = PHDF_UNICODE; //mark it as unicode
item.timestamp = timestamp;
- item.titleW = _wcsdup(title);
- item.messageW = _wcsdup(message);
+ item.titleW = mir_wstrdup(title);
+ item.messageW = mir_wstrdup(message);
AddItem(item); //add it
}
@@ -98,13 +85,3 @@ PopupHistoryData *PopupHistoryList::Get(int index)
return &historyData[index];
}
-
-int PopupHistoryList::GetRenderer()
-{
- return renderer;
-}
-
-void PopupHistoryList::SetRenderer(int newRenderer)
-{
- renderer = newRenderer;
-}
diff --git a/yapp/popup_history.h b/yapp/popup_history.h
index db48a8c..f79b6ee 100644
--- a/yapp/popup_history.h
+++ b/yapp/popup_history.h
@@ -52,7 +52,6 @@ struct PopupHistoryData{
};
class PopupHistoryList{
- protected:
private:
PopupHistoryData *historyData; //historyData[0] - oldest, historyData[size - 1] - newest
int count;
@@ -67,8 +66,8 @@ class PopupHistoryList{
PopupHistoryList(int renderer = RENDER_DEFAULT);
~PopupHistoryList();
- int GetRenderer();
- void SetRenderer(int newRenderer);
+ int GetRenderer() { return renderer; }
+ void SetRenderer(int newRenderer) { renderer = newRenderer; }
void Add(char *title, char *message, time_t timestamp);
void Add(wchar_t *title, wchar_t *message, time_t timestamp);
@@ -76,8 +75,8 @@ class PopupHistoryList{
PopupHistoryData *Get(int index);
void Clear();
- int Count();
- int Size();
+ int Count() { return count; }
+ int Size() { return size; }
};
/*Shows a history with the last popups.
diff --git a/yapp/popup_history_dlg.cpp b/yapp/popup_history_dlg.cpp
index b5673c7..ebf80bf 100644
--- a/yapp/popup_history_dlg.cpp
+++ b/yapp/popup_history_dlg.cpp
@@ -256,7 +256,7 @@ void LoadRenderer(HWND hWnd, int renderer)
CallService((renderer == RENDER_HISTORYPP) ? MS_HPP_EG_WINDOW : MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd); //create the IeView or H++ control.
- PopupHistoryWindowData *data = (PopupHistoryWindowData *) malloc(sizeof(PopupHistoryWindowData)); //create custom control data
+ PopupHistoryWindowData *data = (PopupHistoryWindowData *) mir_alloc(sizeof(PopupHistoryWindowData)); //create custom control data
data->hIEView = ieWnd.hwnd;
ShowWindow(data->hIEView, SW_SHOW);
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) data); //set it as the window's user data
@@ -286,7 +286,7 @@ void UnloadRenderer(HWND hWnd, int renderer)
ieWnd.iType = IEW_DESTROY;
CallService((renderer == RENDER_HISTORYPP) ? MS_HPP_EG_WINDOW : MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd);
- free(data);
+ mir_free(data);
}
break;
@@ -331,11 +331,9 @@ typedef void (*SIG_ADDEVENTS)(HWND hWnd, int renderer, TCHAR *filter, SIG_MATCHE
IEVIEWEVENTDATA *CreateAndFillEventData(PopupHistoryData *popupItem)
{
- IEVIEWEVENTDATA *eventData = (IEVIEWEVENTDATA *) malloc(sizeof(IEVIEWEVENTDATA));
+ IEVIEWEVENTDATA *eventData = (IEVIEWEVENTDATA *) mir_calloc(sizeof(IEVIEWEVENTDATA));
if (eventData)
{
- memset(eventData, 0, sizeof(IEVIEWEVENTDATA));
-
eventData->cbSize = sizeof(IEVIEWEVENTDATA);
eventData->iType = IEED_EVENT_MESSAGE;
#ifdef UNICODE
@@ -401,7 +399,7 @@ void AddEventsCustomControl(HWND hWnd, int renderer, TCHAR *filter, SIG_MATCHESF
{
cED = eventData;
eventData = eventData->next;
- free(cED);
+ mir_free(cED);
}
}
}
diff --git a/yapp/popups2.cpp b/yapp/popups2.cpp
index 845635b..2b7cdf1 100644
--- a/yapp/popups2.cpp
+++ b/yapp/popups2.cpp
@@ -8,12 +8,10 @@
#include "options.h"
#include "popwin.h"
#include "notify.h"
-#include "str_utils.h"
#include "popup_history.h" //to be able to update the renderer
HMODULE hInst = 0;
-HANDLE mainThread = 0;
MNOTIFYLINK *notifyLink = 0;
@@ -49,7 +47,10 @@ PLUGININFOEX pluginInfo={
#endif
};
-PLUGINLINK *pluginLink = 0;
+PLUGINLINK *pluginLink;
+
+MM_INTERFACE mmi;
+LIST_INTERFACE li;
extern "C" BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
@@ -64,12 +65,6 @@ extern "C" POPUPS2_API PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
return &pluginInfo;
}
-extern "C" __declspec(dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion)
-{
- pluginInfo.cbSize = sizeof(PLUGININFO);
- return (PLUGININFO*)&pluginInfo;
-}
-
static const MUUID interfaces[] = {MIID_POPUPS, MIID_LAST};
extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
{
@@ -157,24 +152,24 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
{
font_id_firstlinew.cbSize = sizeof(FontIDW);
font_id_firstlinew.flags = FIDF_ALLOWEFFECTS;
- t2w(TranslateT("Popups"), font_id_firstlinew.group, 64);
- t2w(TranslateT("First line"), font_id_firstlinew.name, 64);
+ _tcscpy(font_id_firstlinew.group, _T("Popups"));
+ _tcscpy(font_id_firstlinew.name, _T("First line"));
strcpy(font_id_firstlinew.dbSettingsGroup, MODULE);
strcpy(font_id_firstlinew.prefix, "FontFirst");
font_id_firstlinew.order = 0;
font_id_secondlinew.cbSize = sizeof(FontIDW);
font_id_secondlinew.flags = FIDF_ALLOWEFFECTS;
- t2w(TranslateT("Popups"), font_id_secondlinew.group, 64);
- t2w(TranslateT("Second line"), font_id_secondlinew.name, 64);
+ _tcscpy(font_id_secondlinew.group, _T("Popups"));
+ _tcscpy(font_id_secondlinew.name, _T("Second line"));
strcpy(font_id_secondlinew.dbSettingsGroup, MODULE);
strcpy(font_id_secondlinew.prefix, "FontSecond");
font_id_secondlinew.order = 1;
font_id_timew.cbSize = sizeof(FontIDW);
font_id_timew.flags = FIDF_ALLOWEFFECTS;
- t2w(TranslateT("Popups"), font_id_timew.group, 64);
- t2w(TranslateT("Time"), font_id_timew.name, 64);
+ _tcscpy(font_id_timew.group, _T("Popups"));
+ _tcscpy(font_id_timew.name, _T("Time"));
strcpy(font_id_timew.dbSettingsGroup, MODULE);
strcpy(font_id_timew.prefix, "FontTime");
font_id_timew.order = 2;
@@ -184,32 +179,32 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
CallService(MS_FONT_REGISTERW, (WPARAM)&font_id_timew, 0);
colour_id_bgw.cbSize = sizeof(ColourIDW);
- t2w(TranslateT("Popups"), colour_id_bgw.group, 64);
- t2w(TranslateT("Background"), colour_id_bgw.name, 64);
+ _tcscpy(colour_id_bgw.group, _T("Popups"));
+ _tcscpy(colour_id_bgw.name, _T("Background"));
strcpy(colour_id_bgw.dbSettingsGroup, MODULE);
strcpy(colour_id_bgw.setting, "ColourBg");
colour_id_bgw.defcolour = GetSysColor(COLOR_3DSHADOW);
colour_id_bgw.order = 0;
colour_id_borderw.cbSize = sizeof(ColourIDW);
- t2w(TranslateT("Popups"), colour_id_borderw.group, 64);
- t2w(TranslateT("Border"), colour_id_borderw.name, 64);
+ _tcscpy(colour_id_borderw.group, _T("Popups"));
+ _tcscpy(colour_id_borderw.name, _T("Border"));
strcpy(colour_id_borderw.dbSettingsGroup, MODULE);
strcpy(colour_id_borderw.setting, "ColourBorder");
colour_id_borderw.defcolour = RGB(0, 0, 0);
colour_id_borderw.order = 1;
colour_id_sidebarw.cbSize = sizeof(ColourIDW);
- t2w(TranslateT("Popups"), colour_id_sidebarw.group, 64);
- t2w(TranslateT("Sidebar"), colour_id_sidebarw.name, 64);
+ _tcscpy(colour_id_sidebarw.group, _T("Popups"));
+ _tcscpy(colour_id_sidebarw.name, _T("Sidebar"));
strcpy(colour_id_sidebarw.dbSettingsGroup, MODULE);
strcpy(colour_id_sidebarw.setting, "ColourSidebar");
colour_id_sidebarw.defcolour = RGB(128, 128, 128);
colour_id_sidebarw.order = 2;
colour_id_titleunderlinew.cbSize = sizeof(ColourIDW);
- t2w(TranslateT("Popups"), colour_id_titleunderlinew.group, 64);
- t2w(TranslateT("Title underline"), colour_id_titleunderlinew.name, 64);
+ _tcscpy(colour_id_titleunderlinew.group, _T("Popups"));
+ _tcscpy(colour_id_titleunderlinew.name, _T("Title underline"));
strcpy(colour_id_titleunderlinew.dbSettingsGroup, MODULE);
strcpy(colour_id_titleunderlinew.setting, "ColourTitleUnderline");
colour_id_titleunderlinew.defcolour = GetSysColor(COLOR_3DSHADOW);
@@ -223,27 +218,29 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
ReloadFont(0, 0);
hEventReloadFont = HookEvent(ME_FONT_RELOAD, ReloadFont);
- } else if(ServiceExists(MS_FONT_REGISTER)) {
+ }
+ else if(ServiceExists(MS_FONT_REGISTER))
+ {
font_id_firstline.cbSize = sizeof(FontID);
font_id_firstline.flags = FIDF_ALLOWEFFECTS;
- t2a(TranslateT("Popups"), font_id_firstline.group, 64);
- t2a(TranslateT("First line"), font_id_firstline.name, 64);
+ strcpy(font_id_firstline.group, "Popups");
+ strcpy(font_id_firstline.name, "First line");
strcpy(font_id_firstline.dbSettingsGroup, MODULE);
strcpy(font_id_firstline.prefix, "FontFirst");
font_id_firstline.order = 0;
font_id_secondline.cbSize = sizeof(FontID);
font_id_secondline.flags = FIDF_ALLOWEFFECTS;
- t2a(TranslateT("Popups"), font_id_secondline.group, 64);
- t2a(TranslateT("Second line"), font_id_secondline.name, 64);
+ strcpy(font_id_secondline.group, "Popups");
+ strcpy(font_id_secondline.name, "Second line");
strcpy(font_id_secondline.dbSettingsGroup, MODULE);
strcpy(font_id_secondline.prefix, "FontSecond");
font_id_secondline.order = 1;
font_id_time.cbSize = sizeof(FontID);
font_id_time.flags = FIDF_ALLOWEFFECTS;
- t2a(TranslateT("Popups"), font_id_time.group, 64);
- t2a(TranslateT("Time"), font_id_time.name, 64);
+ strcpy(font_id_time.group, "Popups");
+ strcpy(font_id_time.name, "Time");
strcpy(font_id_time.dbSettingsGroup, MODULE);
strcpy(font_id_time.prefix, "FontTime");
font_id_time.order = 2;
@@ -253,32 +250,32 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
CallService(MS_FONT_REGISTER, (WPARAM)&font_id_time, 0);
colour_id_bg.cbSize = sizeof(ColourID);
- t2a(TranslateT("Popups"), colour_id_bg.group, 64);
- t2a(TranslateT("Background"), colour_id_bg.name, 64);
+ strcpy(colour_id_bg.group, "Popups");
+ strcpy(colour_id_bg.name, "Background");
strcpy(colour_id_bg.dbSettingsGroup, MODULE);
strcpy(colour_id_bg.setting, "ColourBg");
colour_id_bg.defcolour = GetSysColor(COLOR_3DSHADOW);
colour_id_bg.order = 0;
colour_id_border.cbSize = sizeof(ColourID);
- t2a(TranslateT("Popups"), colour_id_border.group, 64);
- t2a(TranslateT("Border"), colour_id_border.name, 64);
+ strcpy(colour_id_border.group, "Popups");
+ strcpy(colour_id_border.name, "Border");
strcpy(colour_id_border.dbSettingsGroup, MODULE);
strcpy(colour_id_border.setting, "ColourBorder");
colour_id_border.defcolour = RGB(0, 0, 0);
colour_id_border.order = 1;
colour_id_sidebar.cbSize = sizeof(ColourID);
- t2a(TranslateT("Popups"), colour_id_sidebar.group, 64);
- t2a(TranslateT("Sidebar"), colour_id_sidebar.name, 64);
+ strcpy(colour_id_sidebar.group, "Popups");
+ strcpy(colour_id_sidebar.name, "Sidebar");
strcpy(colour_id_sidebar.dbSettingsGroup, MODULE);
strcpy(colour_id_sidebar.setting, "ColourSidebar");
colour_id_sidebar.defcolour = RGB(128, 128, 128);
colour_id_sidebar.order = 2;
colour_id_titleunderline.cbSize = sizeof(ColourID);
- t2a(TranslateT("Popups"), colour_id_titleunderline.group, 64);
- t2a(TranslateT("Title underline"), colour_id_titleunderline.name, 64);
+ strcpy(colour_id_titleunderline.group, "Popups");
+ strcpy(colour_id_titleunderline.name, "Title underline");
strcpy(colour_id_titleunderline.dbSettingsGroup, MODULE);
strcpy(colour_id_titleunderline.setting, "ColourTitleUnderline");
colour_id_titleunderline.defcolour = GetSysColor(COLOR_3DSHADOW);
@@ -328,9 +325,9 @@ HANDLE hEventPreShutdown, hEventModulesLoaded;
extern "C" int POPUPS2_API Load(PLUGINLINK *link) {
pluginLink = link;
- DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, 0, FALSE, DUPLICATE_SAME_ACCESS);
- set_codepage();
+ mir_getLI(&li);
+ mir_getMMI(&mmi);
INITCOMMONCONTROLSEX icex;
@@ -373,6 +370,6 @@ extern "C" int POPUPS2_API Unload() {
DeleteObject(hFontSecondLine);
DeleteObject(hFontTime);
} // otherwise, no need to delete the handle
- CloseHandle(mainThread);
+
return 0;
}
diff --git a/yapp/popups2.dsp b/yapp/popups2.dsp
index 8df19be..1cc1426 100644
--- a/yapp/popups2.dsp
+++ b/yapp/popups2.dsp
@@ -101,7 +101,7 @@ LINK32=link.exe
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /Zi /O1 /I "../../include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NO_GZIP" /D "PNG_NO_STDIO" /D "PNG_NO_CONSOLE_IO" /FD /c
# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /MD /W3 /GX- /Zi /O1 /I "../../../include" /I "." /I "docs" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "UNICODE" /D "_USRDLL" /D "POPUPS2_EXPORTS" /Yu"common.h" /FD /c
+# ADD CPP /nologo /MD /W3 /Zi /O1 /I "../../../include" /I "." /I "docs" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "UNICODE" /D "_USRDLL" /D "POPUPS2_EXPORTS" /Yu"common.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
@@ -188,10 +188,6 @@ SOURCE=.\popwin.cpp
SOURCE=.\services.cpp
# End Source File
-# Begin Source File
-
-SOURCE=.\str_utils.cpp
-# End Source File
# End Group
# Begin Group "Resource Files"
@@ -242,10 +238,6 @@ SOURCE=.\services.h
# End Source File
# Begin Source File
-SOURCE=.\str_utils.h
-# End Source File
-# Begin Source File
-
SOURCE=.\version.h
# End Source File
# End Group
diff --git a/yapp/popups2_9.vcproj b/yapp/popups2_9.vcproj
index 876d06e..a09c649 100644
--- a/yapp/popups2_9.vcproj
+++ b/yapp/popups2_9.vcproj
@@ -267,6 +267,7 @@
IntermediateDirectory="$(ConfigurationName)64"
ConfigurationType="2"
CharacterSet="1"
+ WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -286,8 +287,8 @@
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="3"
- InlineFunctionExpansion="1"
+ Optimization="1"
+ InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="2"
WholeProgramOptimization="true"
@@ -434,6 +435,7 @@
IntermediateDirectory="$(ConfigurationName)64"
ConfigurationType="2"
CharacterSet="1"
+ WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -453,13 +455,15 @@
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="0"
+ Optimization="1"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="2"
+ WholeProgramOptimization="true"
AdditionalIncludeDirectories="./docs;../../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POPUPS2_EXPORTS;_UNICODE;UNICODE"
- MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
- BufferSecurityCheck="true"
PrecompiledHeaderThrough="common.h"
WarningLevel="3"
DebugInformationFormat="3"
@@ -480,10 +484,11 @@
AdditionalDependencies="comctl32.lib"
OutputFile="c:\miranda im\plugins\$(ProjectName).dll"
LinkIncremental="2"
+ AdditionalManifestDependencies=""
GenerateDebugInformation="true"
- SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
@@ -514,6 +519,7 @@
IntermediateDirectory="$(SolutionDir)$(ConfigurationName)/Obj/$(ProjectName)"
ConfigurationType="2"
CharacterSet="1"
+ WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -532,8 +538,9 @@
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="3"
- InlineFunctionExpansion="1"
+ Optimization="1"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="2"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="./docs;../../include"
@@ -560,17 +567,12 @@
/>
<Tool
Name="VCLinkerTool"
- IgnoreImportLibrary="true"
AdditionalDependencies="comctl32.lib"
IgnoreDefaultLibraryNames="Kernel32.lib Advapi32.lib User32.lib Gdi32.lib Shell32.lib Comdlg32.lib Version.lib Mpr.lib Rasapi32.lib Winmm.lib Winspool.lib Vfw32.lib Secur32.lib Oleacc.lib Oledlg.lib Sensapi.lib"
GenerateDebugInformation="true"
- GenerateMapFile="true"
- SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
- LinkTimeCodeGeneration="1"
RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
@@ -601,6 +603,7 @@
IntermediateDirectory="$(ConfigurationName)64"
ConfigurationType="2"
CharacterSet="1"
+ WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -620,8 +623,9 @@
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="3"
- InlineFunctionExpansion="1"
+ Optimization="1"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="2"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="./docs;../../include;..\..\..\include"
@@ -648,17 +652,12 @@
/>
<Tool
Name="VCLinkerTool"
- IgnoreImportLibrary="true"
AdditionalDependencies="comctl32.lib"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
- GenerateMapFile="true"
- SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
- LinkTimeCodeGeneration="1"
RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
@@ -852,10 +851,6 @@
RelativePath=".\services.cpp"
>
</File>
- <File
- RelativePath=".\str_utils.cpp"
- >
- </File>
</Filter>
<Filter
Name="Header Files"
@@ -899,10 +894,6 @@
>
</File>
<File
- RelativePath=".\str_utils.h"
- >
- </File>
- <File
RelativePath=".\version.h"
>
</File>
diff --git a/yapp/popwin.cpp b/yapp/popwin.cpp
index 010da7a..557a9cf 100644
--- a/yapp/popwin.cpp
+++ b/yapp/popwin.cpp
@@ -2,7 +2,6 @@
#include "popwin.h"
#include "message_pump.h"
#include "options.h"
-#include "str_utils.h"
HMODULE hUserDll;
BOOL (WINAPI *MySetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD) = 0;
@@ -16,6 +15,19 @@ BOOL (WINAPI *MyGetMonitorInfo)(HMONITOR hMonitor, LPMONITORINFO mi) = 0;
DWORD pop_start_x, pop_start_y;
int global_mouse_in = 0;
+void trimW(wchar_t *str) {
+ int len = (int)wcslen(str), pos;
+ // trim whitespace (e.g. from OTR detection)
+ for(pos = len - 1; pos >= 0; pos--) {
+ if(str[pos] == L' ' || str[pos] == L'\t' || str[pos] == L'\r' || str[pos] == L'\n') str[pos] = 0;
+ else break;
+ }
+
+ // remove tabs
+ for(pos = len - 1; pos >= 0; pos--)
+ if(str[pos] == L'\t') str[pos] = L' ';
+}
+
void SetStartValues() {
RECT wa_rect;
if(options.use_mim_monitor && MyMonitorFromRect && MyGetMonitorInfo) {
@@ -80,7 +92,7 @@ void RepositionWindows() {
void AddWindowToStack(HWND hwnd) {
SetStartValues();
- HWNDStackNode *new_node = (HWNDStackNode *)malloc(sizeof(HWNDStackNode));
+ HWNDStackNode *new_node = (HWNDStackNode *)mir_alloc(sizeof(HWNDStackNode));
new_node->hwnd = hwnd;
new_node->next = hwnd_stack_top;
hwnd_stack_top = new_node;
@@ -112,7 +124,7 @@ void RemoveWindowFromStack(HWND hwnd) {
} else {
hwnd_stack_top = current->next;
}
- free(current);
+ mir_free(current);
stack_size--;
break;
}
@@ -161,7 +173,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
case WM_CREATE:
{
CREATESTRUCT *cs = (CREATESTRUCT *)lParam;
- pwd = (PopupWindowData *)malloc(sizeof(PopupWindowData));
+ pwd = (PopupWindowData *)mir_alloc(sizeof(PopupWindowData));
pd = (PopupData *)cs->lpCreateParams;
pwd->pd = pd;
pwd->hNotify = 0;
@@ -523,10 +535,12 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
SendMessage(hwnd, PM_DIENOTIFY, 0, 0);
- if(pd && pd->pwzTitle) free(pd->pwzTitle);
- if(pd && pd->pwzText) free(pd->pwzText);
- if(pd) free(pd);
- free(pwd); pwd = 0; pd = 0;
+ if (pd) {
+ mir_free(pd->pwzTitle);
+ mir_free(pd->pwzText);
+ mir_free(pd);
+ }
+ mir_free(pwd); pwd = 0; pd = 0;
SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
break;
@@ -565,12 +579,12 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
return TRUE;
case PUM_SETTEXT:
{
- if(pd->pszText) free(pd->pszText);
+ mir_free(pd->pszText);
if(lParam)
- pd->pwzText = wcsdup((wchar_t *)lParam);
+ pd->pwzText = mir_wstrdup((wchar_t *)lParam);
else
- pd->pwzText = 0;
- // free((void *)lParam); // freed in message pump in case the window has gone
+ pd->pwzText = NULL;
+ // mir_free((void *)lParam); // freed in message pump in case the window has gone
InvalidateRect(hwnd, 0, TRUE);
RepositionWindows();
}
@@ -669,9 +683,11 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
case PUM_CHANGE:
{
KillTimer(hwnd, ID_CLOSETIMER);
- if(pd && pd->pwzTitle) free(pd->pwzTitle);
- if(pd && pd->pwzText) free(pd->pwzText);
- if(pd) free(pd);
+ if (pd) {
+ mir_free(pd->pwzTitle);
+ mir_free(pd->pwzText);
+ mir_free(pd);
+ }
pwd->pd = pd = (PopupData *)lParam;
if(pd->timeout != -1) {
@@ -703,14 +719,12 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
pd->hIcon = (HICON)MNotifyGetDWord(pwd->hNotify, NFOPT_ICON, 0);
const wchar_t *swzName = MNotifyGetWString(pwd->hNotify, NFOPT_TITLEW, 0);
- if(pd->pwzTitle) free(pd->pwzTitle);
- if(swzName) pd->pwzTitle = wcsdup(swzName);
- else pd->pwzTitle = 0;
+ mir_free(pd->pwzTitle);
+ pd->pwzTitle = mir_wstrdup(swzName);
const wchar_t *swzText = MNotifyGetWString(pwd->hNotify, NFOPT_TEXTW, 0);
- if(pd->pwzText) free(pd->pwzText);
- if(swzText) pd->pwzText = wcsdup(swzText);
- else pd->pwzText= 0;
+ mir_free(pd->pwzText);
+ pd->pwzText = mir_wstrdup(swzText);
InvalidateRect(hwnd, 0, TRUE);
RepositionWindows();
diff --git a/yapp/services.cpp b/yapp/services.cpp
index 9cda824..84213ab 100644
--- a/yapp/services.cpp
+++ b/yapp/services.cpp
@@ -4,8 +4,6 @@
#include "message_pump.h"
#include "resource.h"
#include "popup_history.h"
-#include <time.h>
-#include "str_utils.h"
#define NUM_SERVICES 20
HANDLE hService[NUM_SERVICES];
@@ -48,13 +46,12 @@ void StripBBCodesInPlace(wchar_t *text) {
INT_PTR OldCreatePopupA(WPARAM wParam, LPARAM lParam) {
POPUPDATA *pd_in = (POPUPDATA *)wParam;
- PopupData *pd_out = (PopupData *)malloc(sizeof(PopupData));
- ZeroMemory(pd_out, sizeof(PopupData));
+ PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData));
pd_out->cbSize = sizeof(PopupData);
pd_out->flags = PDF_UNICODE;
- pd_out->pwzTitle = a2w(pd_in->lpzContactName);
- pd_out->pwzText = a2w(pd_in->lpzText);
+ pd_out->pwzTitle = mir_a2u(pd_in->lpzContactName);
+ pd_out->pwzText = mir_a2u(pd_in->lpzText);
StripBBCodesInPlace(pd_out->pwzTitle);
StripBBCodesInPlace(pd_out->pwzText);
@@ -73,9 +70,9 @@ INT_PTR OldCreatePopupA(WPARAM wParam, LPARAM lParam) {
lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0));
if(!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) {
- free(pd_out->pwzTitle);
- free(pd_out->pwzText);
- free(pd_out);
+ mir_free(pd_out->pwzTitle);
+ mir_free(pd_out->pwzText);
+ mir_free(pd_out);
return -1;
}
@@ -87,12 +84,12 @@ INT_PTR OldCreatePopupA(WPARAM wParam, LPARAM lParam) {
INT_PTR OldCreatePopupExA(WPARAM wParam, LPARAM lParam) {
POPUPDATAEX *pd_in = (POPUPDATAEX *)wParam;
- PopupData *pd_out = (PopupData *)malloc(sizeof(PopupData));
- ZeroMemory(pd_out, sizeof(PopupData));
+ PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData));
+
pd_out->cbSize = sizeof(PopupData);
pd_out->flags = PDF_UNICODE;
- pd_out->pwzTitle = a2w(pd_in->lpzContactName);
- pd_out->pwzText = a2w(pd_in->lpzText);
+ pd_out->pwzTitle = mir_a2u(pd_in->lpzContactName);
+ pd_out->pwzText = mir_a2u(pd_in->lpzText);
StripBBCodesInPlace(pd_out->pwzTitle);
StripBBCodesInPlace(pd_out->pwzText);
@@ -105,14 +102,14 @@ INT_PTR OldCreatePopupExA(WPARAM wParam, LPARAM lParam) {
pd_out->colorText = pd_in->colorText & 0xFFFFFF;
}
pd_out->windowProc = pd_in->PluginWindowProc;
- pd_out->opaque= pd_in->PluginData;
+ pd_out->opaque = pd_in->PluginData;
pd_out->timeout = pd_in->iSeconds;
lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0));
if(!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) {
- free(pd_out->pwzTitle);
- free(pd_out->pwzText);
- free(pd_out);
+ mir_free(pd_out->pwzTitle);
+ mir_free(pd_out->pwzText);
+ mir_free(pd_out);
return -1;
}
@@ -124,12 +121,12 @@ INT_PTR OldCreatePopupExA(WPARAM wParam, LPARAM lParam) {
INT_PTR OldCreatePopupW(WPARAM wParam, LPARAM lParam) {
POPUPDATAW *pd_in = (POPUPDATAW *)wParam;
- PopupData *pd_out = (PopupData *)malloc(sizeof(PopupData));
- ZeroMemory(pd_out, sizeof(PopupData));
+ PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData));
+
pd_out->cbSize = sizeof(PopupData);
pd_out->flags = PDF_UNICODE;
- pd_out->pwzTitle = wcsdup(pd_in->lpwzContactName);
- pd_out->pwzText = wcsdup(pd_in->lpwzText);
+ pd_out->pwzTitle = mir_wstrdup(pd_in->lpwzContactName);
+ pd_out->pwzText = mir_wstrdup(pd_in->lpwzText);
StripBBCodesInPlace(pd_out->pwzTitle);
StripBBCodesInPlace(pd_out->pwzText);
@@ -142,14 +139,14 @@ INT_PTR OldCreatePopupW(WPARAM wParam, LPARAM lParam) {
pd_out->colorText = pd_in->colorText & 0xFFFFFF;
}
pd_out->windowProc = pd_in->PluginWindowProc;
- pd_out->opaque= pd_in->PluginData;
+ pd_out->opaque = pd_in->PluginData;
pd_out->timeout = pd_in->iSeconds;
lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0));
if(!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) {
- free(pd_out->pwzTitle);
- free(pd_out->pwzText);
- free(pd_out);
+ mir_free(pd_out->pwzTitle);
+ mir_free(pd_out->pwzText);
+ mir_free(pd_out);
return -1;
}
@@ -160,52 +157,54 @@ INT_PTR OldCreatePopupW(WPARAM wParam, LPARAM lParam) {
INT_PTR ChangeTextW(WPARAM wParam, LPARAM lParam) {
HWND hwndPop = (HWND)wParam;
- wchar_t *newText = wcsdup((wchar_t *)lParam);
+ wchar_t *newText = mir_wstrdup((wchar_t *)lParam);
StripBBCodesInPlace(newText);
if(IsWindow(hwndPop))
PostMessage(hwndPop, PUM_SETTEXT, 0, (LPARAM)newText);
+ else
+ mir_free(newText);
return 0;
}
INT_PTR ChangeTextA(WPARAM wParam, LPARAM lParam) {
HWND hwndPop = (HWND)wParam;
char *newText = (char *)lParam;
- wchar_t buff[MAX_SECONDLINE];
- a2w(newText, buff, MAX_SECONDLINE);
+ wchar_t* buff = mir_a2u(newText);
StripBBCodesInPlace(buff);
if(IsWindow(hwndPop))
- PostMessage(hwndPop, PUM_SETTEXT, 0, (LPARAM)wcsdup(buff));
+ PostMessage(hwndPop, PUM_SETTEXT, 0, (LPARAM)buff);
+ else
+ mir_free(buff);
return 0;
}
-INT_PTR ShowPopup(WPARAM wParam, LPARAM lParam) {
- PopupData *pd_in = (PopupData *)wParam;
- PopupData *pd_out = (PopupData *)malloc(sizeof(PopupData));
- *pd_out = *pd_in;
- if(pd_in->flags & PDF_UNICODE) {
- if(pd_in->pwzTitle) pd_out->pwzTitle = wcsdup(pd_in->pwzTitle);
- if(pd_in->pwzText) pd_out->pwzText = wcsdup(pd_in->pwzText);
+void ShowPopup(PopupData &pd_in)
+{
+ PopupData *pd_out = (PopupData *)mir_alloc(sizeof(PopupData));
+ *pd_out = pd_in;
+ if (pd_in.flags & PDF_UNICODE) {
+ pd_out->pwzTitle = mir_wstrdup(pd_in.pwzTitle);
+ pd_out->pwzText = mir_wstrdup(pd_in.pwzText);
} else {
pd_out->flags |= PDF_UNICODE;
- if(pd_in->pszTitle) pd_out->pwzTitle = a2w(pd_in->pszTitle);
- if(pd_in->pszText) pd_out->pwzText = a2w(pd_in->pszText);
+ pd_out->pwzTitle = mir_a2u(pd_in.pszTitle);
+ pd_out->pwzText = mir_a2u(pd_in.pszText);
}
StripBBCodesInPlace(pd_out->pwzTitle);
StripBBCodesInPlace(pd_out->pwzText);
lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0));
- if(!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) {
- if(pd_out->pwzTitle) free(pd_out->pwzTitle);
- if(pd_out->pwzText) free(pd_out->pwzText);
- free(pd_out);
- return -1;
- }
- //MessageBox(0, pd_out->lpwzContactName, _T("CreatePopupW"), MB_OK);
- PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)pd_out);
- return 0;
+ if(!DBGetContactSettingByte(0, MODULE, "Enabled", 1))
+ {
+ mir_free(pd_out->pwzTitle);
+ mir_free(pd_out->pwzText);
+ mir_free(pd_out);
+ }
+ else
+ PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)pd_out);
}
INT_PTR GetContact(WPARAM wParam, LPARAM lParam) {
@@ -254,17 +253,16 @@ INT_PTR PopupQuery(WPARAM wParam, LPARAM lParam) {
switch(wParam) {
case PUQS_ENABLEPOPUPS:
{
- bool enabled = (DBGetContactSettingByte(0, MODULE, "Enabled", 1) == 1);
- if(!enabled) DBWriteContactSettingByte(0, MODULE, "Enabled", 1);
- return enabled ? 0: 1;
+ bool enabled = DBGetContactSettingByte(0, MODULE, "Enabled", 1) != 0;
+ if (!enabled) DBWriteContactSettingByte(0, MODULE, "Enabled", 1);
+ return !enabled;
}
break;
case PUQS_DISABLEPOPUPS:
{
- bool enabled = (DBGetContactSettingByte(0, MODULE, "Enabled", 1) == 1);
- if(enabled) DBWriteContactSettingByte(0, MODULE, "Enabled", 0);
- DBWriteContactSettingByte(0, MODULE, "Enabled", 0);
- return enabled ? 1 : 0;
+ bool enabled = DBGetContactSettingByte(0, MODULE, "Enabled", 1) != 0;
+ if (enabled) DBWriteContactSettingByte(0, MODULE, "Enabled", 0);
+ return enabled;
}
break;
case PUQS_GETSTATUS:
@@ -277,11 +275,8 @@ INT_PTR PopupQuery(WPARAM wParam, LPARAM lParam) {
}
INT_PTR TogglePopups(WPARAM wParam, LPARAM lParam) {
- if(DBGetContactSettingByte(0, MODULE, "Enabled", 1)) {
- DBWriteContactSettingByte(0, MODULE, "Enabled", 0);
- } else {
- DBWriteContactSettingByte(0, MODULE, "Enabled", 1);
- }
+ BYTE val = DBGetContactSettingByte(0, MODULE, "Enabled", 1);
+ DBWriteContactSettingByte(0, MODULE, "Enabled", !val);
UpdateMenu();
return 0;
}
@@ -291,12 +286,12 @@ INT_PTR PopupChangeA(WPARAM wParam, LPARAM lParam) {
POPUPDATAEX *pd_in = (POPUPDATAEX *)lParam;
if(IsWindow(hwndPop)) {
- PopupData *pd_out = (PopupData *)malloc(sizeof(PopupData));
+ PopupData *pd_out = (PopupData *)mir_alloc(sizeof(PopupData));
pd_out->cbSize = sizeof(PopupData);
pd_out->flags = PDF_UNICODE;
- pd_out->pwzTitle = a2w(pd_in->lpzContactName);
- pd_out->pwzText = a2w(pd_in->lpzText);
+ pd_out->pwzTitle = mir_a2u(pd_in->lpzContactName);
+ pd_out->pwzText = mir_a2u(pd_in->lpzText);
StripBBCodesInPlace(pd_out->pwzTitle);
StripBBCodesInPlace(pd_out->pwzText);
@@ -326,12 +321,12 @@ INT_PTR PopupChangeW(WPARAM wParam, LPARAM lParam) {
POPUPDATAW *pd_in = (POPUPDATAW *)lParam;
if(IsWindow(hwndPop)) {
- PopupData *pd_out = (PopupData *)malloc(sizeof(PopupData));
+ PopupData *pd_out = (PopupData *)mir_alloc(sizeof(PopupData));
pd_out->cbSize = sizeof(PopupData);
pd_out->flags = PDF_UNICODE;
- pd_out->pwzTitle = wcsdup(pd_in->lpwzContactName);
- pd_out->pwzText = wcsdup(pd_in->lpwzText);
+ pd_out->pwzTitle = mir_wstrdup(pd_in->lpwzContactName);
+ pd_out->pwzText = mir_wstrdup(pd_in->lpwzText);
StripBBCodesInPlace(pd_out->pwzTitle);
StripBBCodesInPlace(pd_out->pwzText);
@@ -362,9 +357,9 @@ INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam) {
POPUPDATAT pd = {0};
_tcscpy(pd.lptzContactName, lParam == SM_WARNING ? _T("Warning") : _T("Notification"));
pd.lchIcon = LoadIcon(0, lParam == SM_WARNING ? IDI_WARNING : IDI_INFORMATION);
- TCHAR buff[MAX_SECONDLINE];
- a2t((char *)wParam, buff, MAX_SECONDLINE);
- _tcscpy(pd.lptzText, buff);
+ TCHAR *buff = mir_a2t((char *)wParam);
+ _tcscpy(pd.lptzText, buff); pd.lptzText[MAX_SECONDLINE-1] = 0;
+ mir_free(buff);
CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, 0);
@@ -396,37 +391,40 @@ INT_PTR PopUp_ShowHistory(WPARAM wParam, LPARAM lParam)
}
int num_classes = 0;
-PopupClass *classes = 0;
+POPUPCLASS *classes = 0;
-INT_PTR RegisterPopupClass(WPARAM wParam, LPARAM lParam) {
- PopupClass *pc = (PopupClass *)lParam;
- pc->pszName = strdup(pc->pszName);
+INT_PTR RegisterPopupClass(WPARAM wParam, LPARAM lParam)
+{
+ POPUPCLASS *pc = (POPUPCLASS *)lParam;
+ pc->pszName = mir_strdup(pc->pszName);
if(pc->flags & PCF_UNICODE)
- pc->pwszDescription = wcsdup(pc->pwszDescription);
+ pc->pwszDescription = mir_wstrdup(pc->pwszDescription);
else
- pc->pszDescription = strdup(pc->pszDescription);
+ pc->pszDescription = mir_strdup(pc->pszDescription);
char setting[256];
mir_snprintf(setting, 256, "%s/Timeout", pc->pszName);
- pc->timeout = DBGetContactSettingWord(0, MODULE, setting, pc->timeout);
- if(pc->timeout == (WORD)-1) pc->timeout = -1;
+ pc->iSeconds = DBGetContactSettingWord(0, MODULE, setting, pc->iSeconds);
+ if(pc->iSeconds == (WORD)-1) pc->iSeconds = -1;
mir_snprintf(setting, 256, "%s/TextCol", pc->pszName);
pc->colorText = (COLORREF)DBGetContactSettingDword(0, MODULE, setting, (DWORD)pc->colorText);
mir_snprintf(setting, 256, "%s/BgCol", pc->pszName);
pc->colorBack = (COLORREF)DBGetContactSettingDword(0, MODULE, setting, (DWORD)pc->colorBack);
- classes = (PopupClass *)realloc(classes, sizeof(PopupClass) * (num_classes + 1));
- memcpy(classes + num_classes, pc, sizeof(PopupClass));
+ classes = (POPUPCLASS *)mir_realloc(classes, sizeof(POPUPCLASS) * (num_classes + 1));
+ memcpy(classes + num_classes, pc, sizeof(POPUPCLASS));
num_classes++;
return 0;
}
-INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam) {
- PopupClassInstance *pdc = (PopupClassInstance *)lParam;
- if(pdc->cbSize != sizeof(PopupClassInstance)) return 1;
+INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam)
+{
+ POPUPDATACLASS *pdc = (POPUPDATACLASS *)lParam;
+ if(pdc->cbSize < sizeof(POPUPDATACLASS)) return 1;
- PopupClass *pc = 0;
- if(wParam) pc = (PopupClass *)wParam;
+ POPUPCLASS *pc = 0;
+ if(wParam)
+ pc = (POPUPCLASS *)wParam;
else {
for(int i = 0; i < num_classes; i++) {
if(strcmp(classes[i].pszName, pdc->pszClassName) == 0) {
@@ -441,15 +439,15 @@ INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam) {
pd.colorBack = pc->colorBack;
pd.colorText = pc->colorText;
pd.hIcon = pc->hIcon;
- pd.timeout = pc->timeout;
- pd.windowProc = pc->windowProc;
+ pd.timeout = pc->iSeconds;
+ pd.windowProc = pc->PluginWindowProc;
pd.hContact = pdc->hContact;
- pd.opaque = pdc->opaque;
+ pd.opaque = pdc->PluginData;
pd.pszTitle = (char *)pdc->pszTitle;
pd.pszText = (char *)pdc->pszText;
- CallService(MS_YAPP_SHOWPOPUP, (WPARAM)&pd, 0);
+ ShowPopup(pd);
}
return 0;
}
@@ -462,13 +460,8 @@ HANDLE hEventBuildMenu;
void InitServices() {
int i = 0;
- hService[i++] = CreateServiceFunction(MS_YAPP_SHOWPOPUP, ShowPopup);
hService[i++] = CreateServiceFunction(MS_POPUP_REGISTERCLASS, RegisterPopupClass);
hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, CreateClassPopup);
- hService[i++] = CreateServiceFunction(MS_YAPP_GETCONTACT, GetContact);
- hService[i++] = CreateServiceFunction(MS_YAPP_GETOPAQUE, GetOpaque);
-
- // legacy support
hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUP, OldCreatePopupA);
hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPEX, OldCreatePopupExA);
hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPW, OldCreatePopupW);
@@ -490,37 +483,34 @@ void InitServices() {
CLISTMENUITEM menu = {0};
- menu.cbSize=sizeof(menu);
+ menu.cbSize = sizeof(menu);
menu.flags = CMIM_ALL;
- menu.hIcon=0;
menu.position = 500010000;
- menu.pszPopupName = "PopUps";
+ menu.pszPopupName = LPGEN("PopUps");
hiPopupHistory = LoadIcon(hInst, MAKEINTRESOURCE(IDI_POPUP_HISTORY));
menu.hIcon = hiPopupHistory;
menu.pszService= MS_POPUP_SHOWHISTORY;
- menu.pszName = "Popup History";
+ menu.pszName = LPGEN("Popup History");
hMenuShowHistory = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM)&menu);
- menu.hIcon = 0;
-
- menu.pszService= "PopUp/ToggleEnabled";
- menu.pszName = (DBGetContactSettingByte(0, MODULE, "Enabled", 1) == 1 ? "Disable Popups" : "Enable Popups");
+
+ menu.hIcon = NULL;
+ menu.pszService = "PopUp/ToggleEnabled";
+ menu.pszName = DBGetContactSettingByte(0, MODULE, "Enabled", 1) ?
+ LPGEN("Disable Popups") : LPGEN("Enable Popups");
hMenuToggleOnOff = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM, 0, (LPARAM)&menu);
hEventBuildMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildMenu);
-
- if(ServiceExists(MS_LANGPACK_GETCODEPAGE))
- code_page = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
}
void DeinitServices() {
int i;
for(i = 0; i < num_classes; i++) {
- free(classes[i].pszName);
- free(classes[i].pszDescription);
+ mir_free(classes[i].pszName);
+ mir_free(classes[i].pszDescription);
}
- free(classes); num_classes = 0;
+ mir_free(classes); num_classes = 0;
UnhookEvent(hEventBuildMenu);
diff --git a/yapp/services.h b/yapp/services.h
index efb6d15..8243b0b 100644
--- a/yapp/services.h
+++ b/yapp/services.h
@@ -1,34 +1,10 @@
#ifndef _SERVICES_INC
#define _SERVICES_INC
-#include <m_yapp.h>
-
void InitServices();
void DeinitServices();
-/*
-INT_PTR CreatePopupA(WPARAM wParam, LPARAM lParam);
-INT_PTR CreatePopupExA(WPARAM wParam, LPARAM lParam);
-INT_PTR CreatePopupW(WPARAM wParam, LPARAM lParam);
-INT_PTR ChangeTextW(WPARAM wParam, LPARAM lParam);
-INT_PTR ChangeTextA(WPARAM wParam, LPARAM lParam);
-INT_PTR GetContact(WPARAM wParam, LPARAM lParam);
-INT_PTR GetPluginData(WPARAM wParam, LPARAM lParam);
-INT_PTR IsSecondLineShown(WPARAM wParam, LPARAM lParam);
-INT_PTR PopupQuery(WPARAM wParam, LPARAM lParam);
-INT_PTR PopupChange(WPARAM wParam, LPARAM lParam);
-INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam);
-
-INT_PTR PopUp_ShowHistory(WPARAM wParam, LPARAM lParam);
-
-INT_PTR TogglePopups(WPARAM wParam, LPARAM lParam);
-
-INT_PTR RegisterPopupClass(WPARAM wParam, LPARAM lParam);
-INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam);
-*/
-
extern int num_classes;
-extern PopupClass *classes;
-
+extern POPUPCLASS *classes;
#endif
diff --git a/yapp/str_utils.cpp b/yapp/str_utils.cpp
deleted file mode 100644
index c2636ac..0000000
--- a/yapp/str_utils.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-#include "common.h"
-#include "str_utils.h"
-
-int code_page = CP_ACP;
-
-void set_codepage() {
- if(ServiceExists(MS_LANGPACK_GETCODEPAGE))
- code_page = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
-}
-
-bool a2w(const char *as, wchar_t *buff, int bufflen){
- if(as) MultiByteToWideChar(code_page, 0, as, -1, buff, bufflen);
- return true;
-}
-
-bool w2a(const wchar_t *ws, char *buff, int bufflen) {
- if(ws) WideCharToMultiByte(code_page, 0, ws, -1, buff, bufflen, 0, 0);
- return true;
-}
-
-bool u2w(const char *us, wchar_t *buff, int bufflen) {
- if(us) MultiByteToWideChar(CP_UTF8, 0, us, -1, buff, bufflen);
- return true;
-}
-
-bool w2u(const wchar_t *ws, char *buff, int bufflen) {
- if(ws) WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, bufflen, 0, 0);
- return true;
-}
-
-bool a2u(const char *as, char *buff, int bufflen) {
- if(!as) return false;
-
- wchar_t *ws = a2w(as);
- if(ws) WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, bufflen, 0, 0);
- free(ws);
- return true;
-}
-
-bool u2a(const char *us, char *buff, int bufflen) {
- if(!us) return false;
-
- wchar_t *ws = u2w(us);
- if(ws) WideCharToMultiByte(code_page, 0, ws, -1, buff, bufflen, 0, 0);
- free(ws);
- return true;
-}
-
-
-bool t2w(const TCHAR *ts, wchar_t *buff, int bufflen) {
-#ifdef _UNICODE
- wcsncpy(buff, ts, bufflen);
- return true;
-#else
- return a2w(ts, buff, bufflen);
-#endif
-}
-
-bool w2t(const wchar_t *ws, TCHAR *buff, int bufflen) {
-#ifdef _UNICODE
- wcsncpy(buff, ws, bufflen);
- return true;
-#else
- return w2a(ws, buff, bufflen);
-#endif
-}
-
-bool t2a(const TCHAR *ts, char *buff, int bufflen) {
-#ifdef _UNICODE
- return w2a(ts, buff, bufflen);
-#else
- strncpy(buff, ts, bufflen);
- return true;
-#endif
-}
-
-bool a2t(const char *as, TCHAR *buff, int bufflen) {
-#ifdef _UNICODE
- return a2w(as, buff, bufflen);
-#else
- strncpy(buff, as, bufflen);
- return true;
-#endif
-}
-
-bool t2u(const TCHAR *ts, char *buff, int bufflen) {
-#ifdef _UNICODE
- return w2u(ts, buff, bufflen);
-#else
- return a2u(ts, buff, bufflen);
-#endif
-}
-
-bool u2t(const char *us, TCHAR *buff, int bufflen) {
-#ifdef _UNICODE
- return u2w(us, buff, bufflen);
-#else
- return u2a(us, buff, bufflen);
-#endif
-}
-
-wchar_t *u2w(const char *us) {
- if(us) {
- int size = MultiByteToWideChar(CP_UTF8, 0, us, -1, 0, 0);
- wchar_t *buff = (wchar_t *)malloc(size * sizeof(wchar_t));
- MultiByteToWideChar(CP_UTF8, 0, us, -1, buff, size);
- return buff;
- } else
- return 0;
-}
-
-char *w2u(const wchar_t *ws) {
- if(ws) {
- int size = WideCharToMultiByte(CP_UTF8, 0, ws, -1, 0, 0, 0, 0);
- char *buff = (char *)malloc(size);
- WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, size, 0, 0);
- return buff;
- } else
- return 0;
-}
-
-wchar_t *a2w(const char *as) {
- int size = MultiByteToWideChar(code_page, 0, as, -1, 0, 0);
- wchar_t *buff = (wchar_t *)malloc(size * sizeof(wchar_t));
- MultiByteToWideChar(code_page, 0, as, -1, buff, size);
- return buff;
-}
-
-char *w2a(const wchar_t *ws) {
- int size = WideCharToMultiByte(code_page, 0, ws, -1, 0, 0, 0, 0);
- char *buff = (char *)malloc(size);
- WideCharToMultiByte(code_page, 0, ws, -1, buff, size, 0, 0);
- return buff;
-}
-
-char *u2a(const char *utfs) {
- wchar_t *ws = u2w(utfs);
- char *ret = w2a(ws);
- free(ws);
- return ret;
-}
-
-char *a2u(const char *as) {
- wchar_t *ws = a2w(as);
- char *ret = w2u(ws);
- free(ws);
- return ret;
-}
-
-TCHAR *w2t(const wchar_t *ws) {
-#ifdef _UNICODE
- return wcsdup(ws);
-#else
- return w2a(ws);
-#endif
-}
-
-wchar_t *t2w(const TCHAR *ts) {
-#ifdef _UNICODE
- return _tcsdup(ts);
-#else
- return a2w(ts);
-#endif
-}
-
-
-char *t2a(const TCHAR *ts) {
-#ifdef _UNICODE
- return w2a(ts);
-#else
- return _strdup(ts);
-#endif
-}
-
-TCHAR *a2t(const char *as) {
-#ifdef _UNICODE
- return a2w(as);
-#else
- return _strdup(as);
-#endif
-}
-
-TCHAR *u2t(const char *utfs) {
-#ifdef _UNICODE
- return u2w(utfs);
-#else
- wchar_t *ws = u2w(utfs);
- char *ret = w2a(ws);
- free(ws);
- return ret;
-#endif
-}
-
-char *t2u(const TCHAR *ts) {
-#ifdef _UNICODE
- return w2u(ts);
-#else
- wchar_t *ws = a2w(ts);
- char *ret = w2u(ws);
- free(ws);
- return ret;
-#endif
-}
-
-void trimW(wchar_t *str) {
- int len = (int)wcslen(str), pos;
- // trim whitespace (e.g. from OTR detection)
- for(pos = len - 1; pos >= 0; pos--) {
- if(str[pos] == L' ' || str[pos] == L'\t' || str[pos] == L'\r' || str[pos] == L'\n') str[pos] = 0;
- else break;
- }
-
- // remove tabs
- for(pos = len - 1; pos >= 0; pos--)
- if(str[pos] == L'\t') str[pos] = L' ';
-}
-
-void trimA(char *str) {
- int len = (int)strlen(str), pos;
- // trim whitespace (e.g. from OTR detection)
- for(pos = len - 1; pos >= 0; pos--) {
- if(str[pos] == ' ' || str[pos] == '\t' || str[pos] == '\r' || str[pos] == '\n') str[pos] = 0;
- else break;
- }
-
- // remove tabs
- for(pos = len - 1; pos >= 0; pos--)
- if(str[pos] == '\t') str[pos] = ' ';
-}
diff --git a/yapp/str_utils.h b/yapp/str_utils.h
deleted file mode 100644
index d7db510..0000000
--- a/yapp/str_utils.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef _STR_UTILS_INC
-#define _STR_UTILS_INC
-
-void set_codepage();
-
-bool a2w(const char *as, wchar_t *buff, int bufflen);
-bool w2a(const wchar_t *ws, char *buff, int bufflen);
-
-bool u2w(const char *us, wchar_t *buff, int bufflen);
-bool w2u(const wchar_t *ws, char *buff, int bufflen);
-
-bool a2u(const char *as, char *buff, int bufflen);
-bool u2a(const char *ws, char *buff, int bufflen);
-
-bool t2w(const TCHAR *ts, wchar_t *buff, int bufflen);
-bool w2t(const wchar_t *ws, TCHAR *buff, int bufflen);
-
-bool t2a(const TCHAR *ts, char *buff, int bufflen);
-bool a2t(const char *as, TCHAR *buff, int bufflen);
-
-bool t2u(const TCHAR *ts, char *buff, int bufflen);
-bool u2t(const char *us, TCHAR *buff, int bufflen);
-
-// remember to free return value
-wchar_t *a2w(const char *as);
-char *w2a(const wchar_t *ws);
-
-wchar_t *u2w(const char *us);
-char *w2u(const wchar_t *ws);
-
-char *u2a(const char *us);
-char *a2u(const char *as);
-
-wchar_t *t2w(const TCHAR *ts);
-TCHAR *w2t(const wchar_t *ws);
-
-TCHAR *u2t(const char *us);
-char *t2u(const TCHAR *ts);
-
-char *t2a(const TCHAR *ts);
-TCHAR *a2t(const char *as);
-
-void trimW(wchar_t *str);
-void trimA(char *str);
-
-#ifndef _UNICODE
-#define trim trimW
-#else
-#define trim trimA
-#endif
-
-#endif
-
diff --git a/yapp/version.h b/yapp/version.h
index 34e1ed6..61f1f0f 100644
--- a/yapp/version.h
+++ b/yapp/version.h
@@ -4,25 +4,25 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 5
#define __RELEASE_NUM 0
-#define __BUILD_NUM 7
+#define __BUILD_NUM 8
-#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
-#define __STRINGIFY(x) #x
-#define __VERSION_STRING __STRINGIFY(__FILEVERSION_STRING_DOTS)
+#define __STRINGIFY(x) #x
+#define __VERSION_STRING __STRINGIFY(__FILEVERSION_STRING_DOTS)
-#define __DESC "Yet Another Popup Plugin - Provides popup notification window services (unicode and ansi) to other plugins"
-#define __AUTHOR "Scott Ellis"
-#define __AUTHOREMAIL "mail@scottellis.com.au"
-#define __COPYRIGHT "© 2005,2006 Scott Ellis"
-#define __AUTHORWEB "http://www.scottellis.com.au"
+#define __DESC "Yet Another Popup Plugin - Provides popup notification window services (unicode and ansi) to other plugins"
+#define __AUTHOR "Scott Ellis"
+#define __AUTHOREMAIL "mail@scottellis.com.au"
+#define __COPYRIGHT "© 2005,2006 Scott Ellis"
+#define __AUTHORWEB "http://www.scottellis.com.au"
#ifdef _WIN64
-#define __PLUGIN_NAME "YAPP x64"
+#define __PLUGIN_NAME "YAPP x64"
#else
-#define __PLUGIN_NAME "YAPP"
+#define __PLUGIN_NAME "YAPP"
#endif
-#define __FILENAME "yapp.dll"
+#define __FILENAME "yapp.dll"
#endif //__VERSION_H_INCLUDED
diff --git a/yapp/version.rc b/yapp/version.rc
index 842659d..0bb7a49 100644
--- a/yapp/version.rc
+++ b/yapp/version.rc
@@ -21,7 +21,6 @@ BEGIN
BEGIN
VALUE "Author", __AUTHOR
VALUE "FileDescription", __DESC
- VALUE "FileVersion", __VERSION_STRING
VALUE "InternalName", __PLUGIN_NAME
VALUE "LegalCopyright", __COPYRIGHT
VALUE "OriginalFilename", __FILENAME