summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-03-06 17:14:40 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-03-06 17:14:47 +0300
commitc09a65cb4153f151ec2eb074614b4ccfe7c22bdb (patch)
tree171522c9a9aaf456bd68484008e7692a6b7d8361
parent000d773f687e5931699fc4de4d4b472b6325f3fb (diff)
popups: pascal code cleaning
-rw-r--r--include/delphi/m_popup.inc354
-rw-r--r--plugins/Utils.pas/mirutils.pas5
-rw-r--r--plugins/Watrack/lastfm/i_last_api.inc4
-rw-r--r--plugins/Watrack/lastfm/i_last_opt.inc4
-rw-r--r--plugins/Watrack/myshows/i_myshows_api.inc38
-rw-r--r--plugins/Watrack/myshows/i_myshows_opt.inc4
-rw-r--r--plugins/Watrack/popup/pop_dlg.inc2
-rw-r--r--plugins/Watrack/popup/popups.pas153
-rw-r--r--src/mir_app/src/popups.cpp10
9 files changed, 88 insertions, 486 deletions
diff --git a/include/delphi/m_popup.inc b/include/delphi/m_popup.inc
index 961f98c063..19e736345b 100644
--- a/include/delphi/m_popup.inc
+++ b/include/delphi/m_popup.inc
@@ -27,16 +27,17 @@ mi.position = 0; //You don't need it and it's better if you put it to zero.
}
const
- POPUP_VERSION = $02010003;
-
-const
MAX_CONTACTNAME = 2048;
MAX_SECONDLINE = 2048;
MAX_ACTIONTITLE = 64;
-// POPUP_USE_SKINNED_BG = $FFFFFFFF;
+const
+ APF_RETURN_HWND = 1;
+ APF_CUSTOM_POPUP = 2;
+ APF_NO_HISTORY = 4;
+ APF_NO_POPUP = 8;
-// Popup Action flags
+ // Popup Action flags
PAF_ENABLED = $01; // Actions is enabled. You may store one global
// action set and toggle some items depending on
// popup you are requesting
@@ -65,18 +66,7 @@ type
colorText : COLORREF;
PluginWindowProc: pointer;
PluginData : pointer;
- iSeconds : int; // Custom delay time in seconds.
- // -1 means "forever", 0 means = 'default time".
-{ Data prior $02010003 version
- lpzClass : PAnsiChar; // Popup class. Used with skinning. See Popup/AddClass for details
- skinBack : COLORREF; // Background color for colorizable skins
- cZero: array [0..15-SizeOf(PAnsiChar)-SizeOf(COLORREF)] of byte;
-}
- // you *MUST* pass APT_NEWDATA flag for services to take care of this data
- hReserved : THANDLE; // Reserved. Must be NULL
- actionCount : int; // Amount of passed actions
- lpActions : PPOPUPACTION; // Popup Actions
- icbSize : int; // struct size for future
+ iSeconds : int;
end;
type
@@ -92,115 +82,17 @@ type
PluginData : pointer;
iSeconds : int; // Custom delay time in seconds.
// -1 means = 'forever", 0 means = 'default time".
-{ Data prior $02010003 version
- cZero: array [0..15] of AnsiChar; //16 unused bytes which may come useful in the future.
-}
- // you *MUST* pass APT_NEWDATA flag for services to take care of this data
hReserved : THANDLE; // Reserved. Must be NULL
actionCount : int; // Amount of passed actions
lpActions : PPOPUPACTION; // Popup Actions
- icbSize : int; // struct size for future
end;
-{
- When you call MS_POPUP_ADDPOPUP, my plugin will check if the given POPUPDATA
-structure is filled with acceptable values. If not, the data will be rejected
-and no popup will be shown.
-
-- lpzText should be given, because it's really bad if a user chooses to have the
-second line displayed and it's empty :-) Just write it and let the user choose
-if it will be displayed or not.
+function PUAddPopupW(ppd:PPOPUPDATAW; flags:int):THANDLE; stdcall; external AppDll;
-- PluginWindowProc is a WNDPROC address you have to give me. Why? What? Where?
-Calm down 8) My plugin will take care of the creation of the popup, of the
-destruction of the popup, of the come into view and the hiding of the popup.
-Transparency, animations... all this stuff.
- My plugin will not (as example) open the MessageWindow when you left click on
-a popup. Why? Because I don't know if your popup desires to open the
-MessageWindow :)))) This means that you need to make a WNDPROC which takes care
-of the WM_messages you need.
- For example, WM_COMMAND or WM_CONTEXTMENU or WM_LMOUSEUP or whatever.
- At the end of your WNDPROC remember to "return DefWindowProc(hwnd, msg,
-wParam, lParam);" When you process a message that needs a return value (an
-example could be WM_CTLCOLORSTATIC, but you don't need to catch it 'cause it's
-my plugin's job), simply return the nedeed value. :)
-The default WNDPROC does nothing.
-
-- PluginData is a pointer to a void, which means a pointer to anything. You can
-make your own structure to store the data you need (example: a status
-information, a date, your name, whatever) and give me a pointer to that struct.
-You will need to destroy that structure and free the memory when the Popup is
-going to be destroyed. You'll know this when you receive a UM_FREEPLUGINDATA.
-The name tells it all: free your own plugin data.
-
-Appendix A: Messages my plugin will handle and your WNDPROC will never see.
-WM_CREATE, WM_DESTROY, WM_TIMER, WM_ERASEBKGND
-WM_CTLCOLOR* [whatever it may be: WM_CTLCOLORDLG, WM_CTLCOLORSTATIC...]
-WM_PAINT, WM_PRINT, WM_PRINTCLIENT
-}
+/////////////////////////////////////////////////////////////////////////////////////////
const
{
- 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
- APF_NO_HISTORY ........ do not log this popup in popup history (useful for previews)
- APF_NO_POPUP .......... do not show popup. this is useful if you want popup yo be stored in history only
- APF_NEWDATA ........... use new version of POPUPDATAEX/POPUPDATAW structs
-}
- APF_RETURN_HWND = 1;
- APF_CUSTOM_POPUP = 2;
- APF_NO_HISTORY = 4;
- APF_NO_POPUP = 8;
- APF_NEWDATA = $10;
-
- MS_POPUP_ADDPOPUPW:PAnsiChar = 'Popup/AddPopupW';
- MS_POPUP_ADDPOPUP :PAnsiChar = 'Popup/AddPopupEx';
-
-{
- Returns the handle to the contact associated to the specified PopupWindow.
- You will probably need to know this handle inside your WNDPROC. Exampole: you want to open the MessageWindow. :-)
- Call MS_POPUP_GETCONTACT on the hWnd you were given in the WNDPROC.
- wParam = (WPARAM)(HWND)hPopupWindow
- lParam = 0;
- Returns: the HANDLE of the contact. Can return NULL, meaning it's the main contact. -1 means failure.
-}
- MS_POPUP_GETCONTACT:PAnsiChar = 'Popup/GetContact';
-
-{
- wParam = hPopupWindow
- lParam = 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).
-}
- MS_POPUP_GETPLUGINDATA:PAnsiChar = 'Popup/GetPluginData';
-
-{
- Requests an action or an answer from Popup module.
- wParam = (WPARAM)wpQuery
- returns 0 on success, -1 on error, 1 on stupid calls ;-)
-}
- PUQS_ENABLEPOPUPS = 1; // returns 0 if state was changed, 1 if state wasn't changed
- PUQS_DISABLEPOPUPS = 2; // " "
- PUQS_GETSTATUS = 3; // Returns 1 if popups are enabled, 0 if popups are disabled.
-
- MS_POPUP_QUERY:PAnsiChar = 'Popup/Query';
-
-{
UM_FREEPLUGINDATA
wParam = lParam = 0. Process this message if you have allocated your own memory. (i.e.: POPUPDATA.PluginData != NULL)
}
@@ -222,38 +114,6 @@ You may pass additional creation flags via lParam:
}
UM_INITPOPUP = (WM_USER + $202);
-{
- wParam = hPopupWindow
- lParam = lpzNewText
- returns: > 0 for success, -1 for failure, 0 if the failure is due to second line not being shown.
- Changes the text displayed in the second line of the popup.
-}
- MS_POPUP_CHANGETEXTW:PAnsiChar = 'Popup/ChangetextW';
-
-{
- wParam = (WPARAM)(HWND)hPopupWindow
- lParam = (LPARAM)(POPUPDATAEX*)newData
- Changes the entire popup
-}
- MS_POPUP_CHANGEW:PAnsiChar = 'Popup/ChangeW';
-
-{
- 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
-}
-
-// CPT_TEXT = 1; // lParam = (AnsiChar *)text
- CPT_TEXTW = 2; // lParam = (WCHAR *)text
-// CPT_TITLE = 3; // lParam = (AnsiChar *)title
- CPT_TITLEW = 4; // lParam = (WCHAR *)title
- CPT_DATAW = 7; // lParam = (POPUPDATAW *)data
- CPT_DATA2 = 8; // lParam = (POPUPDATA2 *)data
-
- UM_CHANGEPOPUP = WM_USER + $0203;
-
{ UM_POPUPACTION
Popup Action notification
@@ -263,204 +123,18 @@ You may pass additional creation flags via lParam:
UM_POPUPACTION = WM_USER + $0204;
-{ UM_POPUPMODIFYACTIONICON
- Modify Popup Action Icon
-
- wParam = (WPARAM)(LPPOPUPACTIONID)&actionId
- lParam = (LPARAM)(HICON)hIcon
-}
-
-type
- PPOPUPACTIONID = ^TPOPUPACTIONID;
- TPOPUPACTIONID = record
- wParam:WPARAM;
- lParam:LPARAM;
- end;
-
-const
- UM_POPUPMODIFYACTIONICON = WM_USER + $0205;
-
const
SM_WARNING = $01; //Triangle icon.
SM_NOTIFY = $02; //Exclamation mark icon.
SM_ERROR = $03; //Cross icon.
-{
- 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 = lpzMessage
- lParam = SM_* flag
- Returns: 0 if the popup was shown, -1 in case of failure.
-}
- MS_POPUP_SHOWMESSAGE :PAnsiChar = 'Popup/ShowMessage';
- MS_POPUP_SHOWMESSAGEW:PAnsiChar = 'Popup/ShowMessageW';
-
-{ Popup/Filter
-Filters Popups out
-
-wParam = (HANDLE)hContact
-lParam = (void*)pWindowProc;
-
-returns: 0 = Popup allowed, 1 = Popup filtered out
-}
-
- ME_POPUP_FILTER:PAnsiChar = 'Popup/Filter';
-
-{ Popup/RegisterActions
-Registers your action in popup action list
-
-wParam = (WPARAM)(LPPOPUPACTION)actions
-lParam = (LPARAM)actionCount
-
-Returns: 0 if the popup was shown, -1 in case of failure.
-}
- MS_POPUP_REGISTERACTIONS:PAnsiChar = 'Popup/RegisterActions';
-
-//------------- Class API ----------------//
-
-type
- TPOPUPCLASS = record
- cbSize :int;
- flags :int;
- pszName :PAnsiChar;
- szDescription :TChar;
- hIcon :HICON;
- colorBack :TCOLORREF;
- colorText :TCOLORREF;
- PluginWindowProc:pointer;
- iSeconds :int;
- lParam :LPARAM; //APF_RETURN_HWND, APF_CUSTOM_POPUP ... as above
- end;
-
-const
- PCF_UNICODE = $0001;
-
-// wParam = 0
-// lParam = (POPUPCLASS *)&pc
- MS_POPUP_REGISTERCLASS = 'Popup/RegisterClass';
- MS_POPUP_UNREGISTERCLASS = 'Popup/UnregisterClass';
-
-type
- TPOPUPDATACLASS = record
- cbSize :int;
- pszClassName:PAnsiChar;
- szTitle :TChar;
- szText :TChar;
- PluginData :pointer;
- hContact :TMCONTACT;
- end;
-
-const
-// wParam = 0
-// lParam = (POPUPDATACLASS *)&pdc
- MS_POPUP_ADDPOPUPCLASS = 'Popup/AddPopupClass';
-
-(* OLD
-{
- Each skinned popup (e.g. with colorBack == POPUP_USE_SKINNED_BG) should have
- class set. Then you can choose separate skin for each class (for example, you
- can create separate class for your plugin and use it for all ypu popups. User
- would became able to choose skin for your popups independently from others)
-
- You have to register popup class before using it. To do so call
- "Popup/AddClass" with lParam = (LPARAM)(const AnsiChar * )popUpClassName.
- All class names are translated (via Translate()) before being added to list.
- You should use english names for them.
-
- There are three predefined classes and one for backward compatability.
-
- Note that you can add clases after popup wal loaded, e.g. you shoul intercept
- ME_SYSTEM_MODULESLOADED event
-}
- MS_POPUP_ADDCLASS = 'Popup/AddClass';
-
- POPUP_CLASS_DEFAULT = 'Default';
- POPUP_CLASS_WARNING = 'Warning';
- POPUP_CLASS_NOTIFY = 'Notify';
- POPUP_CLASS_OLDAPI = 'Popup 1.0.1.x compatability'; // for internal purposes
-
-const
- NFOPT_POPUP2_BACKCOLOR = 'Popup2/BackColor';
- NFOPT_POPUP2_TEXTCOLOR = 'Popup2/TextColor';
- NFOPT_POPUP2_TIMEOUT = 'Popup2/Timeout';
- NFOPT_POPUP2_LCLICKSVC = 'Popup2/LClickSvc';
- NFOPT_POPUP2_LCLICKCOOKIE = 'Popup2/LClickCookie';
- NFOPT_POPUP2_RCLICKSVC = 'Popup2/RClickSvc';
- NFOPT_POPUP2_RCLICKCOOKIE = 'Popup2/RClickCookie';
- NFOPT_POPUP2_STATUSMODE = 'Popup2/StatusMode';
- NFOPT_POPUP2_PLUGINDATA = 'Popup2/PluginData';
- NFOPT_POPUP2_WNDPROC = 'Popup2/WndProc';
+/////////////////////////////////////////////////////////////////////////////////////////
- NFOPT_POPUP2_BACKCOLOR_S = 'Popup2/BackColor/Save';
- NFOPT_POPUP2_TEXTCOLOR_S = 'Popup2/TextColor/Save';
- NFOPT_POPUP2_TIMEOUT_S = 'Popup2/Timeout/Save';
+function PUGetPluginData(popup:HWND):LPARAM; stdcall; external AppDll;
- MS_POPUP2_SHOW = 'Popup2/Show';
- MS_POPUP2_UPDATE = 'Popup2/Update';
- MS_POPUP2_REMOVE = 'Popup2/Remove';
-*)
-///////////////////////////////////////////////////////////////
-// Few notes about new popup api
-// ------------------------------
-// When you call any ADD service, Popup Plus creates local
-// copy of POPUPDATA2 to store the data. Each time you call
-// CHANGE service this data is updated. You can use the
-// MS_POPUP_GETDATA2 service to retrieve Popups's copy of
-// this data, however you MUST NOT chahge that.
-
-// unicode or ansi mode
-const
- PU2_ANSI = 00;
- PU2_UNICODE = 01;
- PU2_CUSTOM_POPUP = 02;
-
-type
- PPOPUPDATA2 = ^TPOPUPDATA2;
- TPOPUPDATA2 = record
- // general
- cbSize:int;
- flags:dword;
-
- // miranda bindings
- lchContact:TMCONTACT;
- lchEvent :THANDLE;
-
- // style
- colorBack:TCOLORREF;
- colorText:TCOLORREF;
- lchIcon:HICON;
- hbmAvatar:HBITMAP;
- pzTitle:TCHAR;
- pzText:TCHAR;
- lpzSkin:PAnsiChar;
-
- // time and timeout
- iSeconds:int;
- dwTimestamp:dword;
-
- // plugin bindings
- PluginWindowProc:TWNDPROC;
- PluginData:pointer;
-
- // popup actions
- actionCount:int;
- lpActions:PPOPUPACTION; // Ansi or unicode
- lchNotification:THANDLE;
- end;
-
-const
-// Creates new popup
-// wParam = (WPARAM)(LPPOPUPDATA2)&ppd2
-// lParam = (LPARAM)(combination of APF_* flags)
-// returns: window handle (if requested) of NULL on success, -1 on failure.
- MS_POPUP_ADDPOPUP2:PAnsiChar = 'Popup/AddPopup2';
+function PURegisterActions(actions:PPOPUPACTION; count:int):int; stdcall; external AppDll;
-// Update an popup
-// wParam = (WPARAM)(HWND)hwndPopup
-// lParam = (LPARAM)(LPPOPUPDATA2)&ppd2
-// returns: zero on success, -1 on failure.
- MS_POPUP_CHANGEPOPUP2:PAnsiChar = 'Popup/ChangePopup2';
+function PUShowMessage(szMessage:PAnsiChar;options:int):int; stdcall; external AppDll;
+function PUShowMessageW(szMessage:PWideChar;options:int):int; stdcall; external AppDll;
{$ENDIF}
diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas
index 47f28ea776..852223cbda 100644
--- a/plugins/Utils.pas/mirutils.pas
+++ b/plugins/Utils.pas/mirutils.pas
@@ -228,16 +228,13 @@ procedure ShowPopupW(text:PWideChar;title:PWideChar=nil);
var
ppdu:TPOPUPDATAW;
begin
- if not ServiceExists(MS_POPUP_ADDPOPUPW) then
- exit;
-
FillChar(ppdu,SizeOf(TPOPUPDATAW),0);
StrCopyW(ppdu.lpwzText,text,MAX_SECONDLINE-1);
if title<>nil then
StrCopyW(ppdu.lpwzContactName,title,MAX_CONTACTNAME-1)
else
ppdu.lpwzContactName[0]:=' ';
- CallService(MS_POPUP_ADDPOPUPW,wparam(@ppdu),APF_NO_HISTORY);
+ PUAddPopupW(@ppdu,APF_NO_HISTORY);
end;
function TranslateA2W(sz:PAnsiChar):PWideChar;
diff --git a/plugins/Watrack/lastfm/i_last_api.inc b/plugins/Watrack/lastfm/i_last_api.inc
index 3d58bd27dd..f8975305df 100644
--- a/plugins/Watrack/lastfm/i_last_api.inc
+++ b/plugins/Watrack/lastfm/i_last_api.inc
@@ -81,7 +81,7 @@ begin
else if StrCmp(res,'BADAUTH' )=0 then StrCopy(tmp,Translate('Bad Auth. Check login and password'))
else if StrCmp(res,'BADTIME' )=0 then StrCopy(tmp,Translate('Bad TimeStamp'))
else if StrCmp(res,'FAILED',6)=0 then StrCopy(tmp,res+7);
- CallService(MS_POPUP_SHOWMESSAGE,wparam(@request),SM_ERROR);
+ PUShowMessage(@request,SM_ERROR);
end;
mFreeMem(res);
end;
@@ -194,7 +194,7 @@ begin
else if StrCmp(res,'FAILED',6)=0 then
begin
StrCopy(StrCopyE(args,Translate('Last.fm error: ')),res+7);
- CallService(MS_POPUP_SHOWMESSAGE,wparam(@args),SM_NOTIFY);
+ PUShowMessage(@args,SM_NOTIFY);
result:=0;
end;
mFreeMem(res);
diff --git a/plugins/Watrack/lastfm/i_last_opt.inc b/plugins/Watrack/lastfm/i_last_opt.inc
index c629962697..9628dcf163 100644
--- a/plugins/Watrack/lastfm/i_last_opt.inc
+++ b/plugins/Watrack/lastfm/i_last_opt.inc
@@ -23,9 +23,7 @@ begin
mFreeMem(lfm_login ); lfm_login :=DBReadString(0,PluginShort,optLogin);
mFreeMem(lfm_password); lfm_password:=DBReadString(0,PluginShort,optPassword);
if (lfm_login=nil) or (lfm_password=nil) then
- CallService(MS_POPUP_SHOWMESSAGEW,
- wparam(TranslateW('Don''t forget to enter Login and Password to use Last.fm service')),
- SM_WARNING);
+ PUShowMessageW(TranslateW('Don''t forget to enter Login and Password to use Last.fm service'), SM_WARNING);
end;
procedure FreeOpt;
diff --git a/plugins/Watrack/myshows/i_myshows_api.inc b/plugins/Watrack/myshows/i_myshows_api.inc
index 25593311d7..f92df86b50 100644
--- a/plugins/Watrack/myshows/i_myshows_api.inc
+++ b/plugins/Watrack/myshows/i_myshows_api.inc
@@ -36,10 +36,7 @@ begin
end;
StrCopyW(StrCopyEW(buf,'MyShows: '),TranslateW(ppc));
- if ServiceExists(MS_POPUP_SHOWMESSAGEW) then
- CallService(MS_POPUP_SHOWMESSAGEW,TWPARAM(@buf),SM_WARNING)
- else
- MessageBoxW(0,@buf,'ERROR',MB_ICONERROR)
+ PUShowMessage(@buf,SM_WARNING);
end;
function GetMD5Str(const digest:TMD5Hash; buf:pAnsiChar):PAnsiChar;
@@ -199,28 +196,25 @@ begin
if SendMSRequest(buf,show) then
begin
//!! add option to show it??
- if ServiceExists(MS_POPUP_SHOWMESSAGEW) then
- begin
- jn:=json_get(jroot,'show');
- shId:=json_as_string(json_get(jn,'title'));
+ jn:=json_get(jroot,'show');
+ shId:=json_as_string(json_get(jn,'title'));
- jn:=json_get(jn,'episodes');
- jn:=json_get(jn,'episodes');
- pWideChar(epId):=json_as_string(json_get(jn,'title'));
+ jn:=json_get(jn,'episodes');
+ jn:=json_get(jn,'episodes');
+ pWideChar(epId):=json_as_string(json_get(jn,'title'));
- mGetMem(pc,1024);
- StrCopyW(
+ mGetMem(pc,1024);
+ StrCopyW(
+ StrCopyEW(
StrCopyEW(
StrCopyEW(
- StrCopyEW(
- StrCopyEW(pWideChar(pc),'Show "'),
- shId),
- '"'#13#10'episode "'),
- pWideChar(epId)),
- '" checked');
- CallService(MS_POPUP_SHOWMESSAGEW,TWPARAM(pc),SM_NOTIFY);
- mFreeMem(pc);
- end;
+ StrCopyEW(pWideChar(pc),'Show "'),
+ shId),
+ '"'#13#10'episode "'),
+ pWideChar(epId)),
+ '" checked');
+ PUShowMessage(pc,SM_NOTIFY);
+ mFreeMem(pc);
result:=true;
end;
end;
diff --git a/plugins/Watrack/myshows/i_myshows_opt.inc b/plugins/Watrack/myshows/i_myshows_opt.inc
index 125d4deda5..c5696771c6 100644
--- a/plugins/Watrack/myshows/i_myshows_opt.inc
+++ b/plugins/Watrack/myshows/i_myshows_opt.inc
@@ -26,9 +26,7 @@ begin
mFreeMem(msh_login ); msh_login :=DBReadString(0,PluginShort,optLogin);
mFreeMem(msh_password); msh_password:=DBReadString(0,PluginShort,optPassword);
if (msh_login=nil) or (msh_password=nil) then
- CallService(MS_POPUP_SHOWMESSAGEW,
- WPARAM(TranslateW('Don''t forget to enter Login and Password to use MyShows service')),
- SM_WARNING);
+ PUShowMessageW(TranslateW('Don''t forget to enter Login and Password to use MyShows service'), SM_WARNING);
end;
procedure FreeOpt;
diff --git a/plugins/Watrack/popup/pop_dlg.inc b/plugins/Watrack/popup/pop_dlg.inc
index 4ee10e1952..4e76a6c6ed 100644
--- a/plugins/Watrack/popup/pop_dlg.inc
+++ b/plugins/Watrack/popup/pop_dlg.inc
@@ -98,7 +98,7 @@ begin
ppd^.colorBack:=SendMessage(back,CPM_GETCOLOUR,0,0);
ppd^.colorText:=SendMessage(fore,CPM_GETCOLOUR,0,0);
end;
- CallService(MS_POPUP_ADDPOPUPW,twparam(ppd),0);
+ PUAddPopupW(ppd,0);
mFreeMem(ppd);
end;
IDC_DELAYCUST:
diff --git a/plugins/Watrack/popup/popups.pas b/plugins/Watrack/popup/popups.pas
index 604436c835..4bf7f5adc0 100644
--- a/plugins/Watrack/popup/popups.pas
+++ b/plugins/Watrack/popup/popups.pas
@@ -97,8 +97,7 @@ begin
result:=CallServiceSync(MS_WAT_PRESSBUTTON,lParam,0);
end;
UM_FREEPLUGINDATA: begin
- h:=0;
- h:=CallService(MS_POPUP_GETPLUGINDATA,wnd,h);
+ h:=PUGetPluginData(wnd);
if h<>0 then
DeleteObject(h);
result:=0;
@@ -144,10 +143,9 @@ end;
procedure ThShowPopup(si:pSongInfo); cdecl;
var
- ppdu:PPOPUPDATAW;
+ ppdu:TPOPUPDATAW;
title,descr:pWideChar;
flag:dword;
- ppd2:PPOPUPDATA2;
Icon:HICON;
sec:integer;
cb,ct:TCOLORREF;
@@ -185,78 +183,35 @@ begin
ct:=0;
end;
- if IsPopup2Present then
+ FillChar(ppdu,SizeOf(TPOPUPDATAW),0);
+ with ppdu do
begin
- mGetMem (ppd2 ,SizeOf(TPOPUPDATA2));
- FillChar(ppd2^,SizeOf(TPOPUPDATA2),0);
- with ppd2^ do
- begin
- cbSize :=SizeOf(TPOPUPDATA2);
- flags :=PU2_UNICODE;
- lchIcon :=Icon;
- colorBack :=cb;
- colorText :=ct;
- PluginWindowProc:=@DumbPopupDlgProc;
-
- pzTitle.w:=title;
- pzText .w:=descr;
-
- if ActionList=nil then
- flag:=0
- else
- begin
- flag :=APF_NEWDATA;
- actionCount:=7;
- lpActions :=ActionList;
- end;
+ if title<>nil then
+ StrCopyW(lpwzContactName,title,MAX_CONTACTNAME-1)
+ else
+ lpwzContactName[0]:=' ';
+ if descr<>nil then
+ StrCopyW(lpwzText,descr,MAX_SECONDLINE-1)
+ else
+ lpwzText[0]:=' ';
- if si.cover<>nil then
- begin
- hbmAvatar:=Image_Load(si.cover, IMGL_WCHAR);
- if hbmAvatar=0 then
- begin
- hbmAvatar:=CallService(MS_UTILS_LOADBITMAPW,0,lparam(si.cover));
- end;
- end;
- PluginData:=pointer(hbmAvatar);
- end;
- CallService(MS_POPUP_ADDPOPUP2,wparam(ppd2),flag);
- mFreeMem(ppd2);
- end
- else
- begin
- mGetMem (ppdu ,SizeOf(TPOPUPDATAW));
- FillChar(ppdu^,SizeOf(TPOPUPDATAW),0);
- with ppdu^ do
+ lchIcon :=Icon;
+ PluginWindowProc:=@DumbPopupDlgProc;
+ iSeconds :=sec;
+ colorBack :=cb;
+ colorText :=ct;
+
+ if ActionList=nil then
+ flag:=0
+ else
begin
- if title<>nil then
- StrCopyW(lpwzContactName,title,MAX_CONTACTNAME-1)
- else
- lpwzContactName[0]:=' ';
- if descr<>nil then
- StrCopyW(lpwzText,descr,MAX_SECONDLINE-1)
- else
- lpwzText[0]:=' ';
-
- lchIcon :=Icon;
- PluginWindowProc:=@DumbPopupDlgProc;
- iSeconds :=sec;
- colorBack :=cb;
- colorText :=ct;
-
- if ActionList=nil then
- flag:=0
- else
- begin
- flag :=APF_NEWDATA;
- icbSize :=SizeOf(TPOPUPDATAW);
- actionCount:=7;
- lpActions :=ActionList;
- end;
+ flag :=0;
+ actionCount:=7;
+ lpActions :=ActionList;
end;
- CallService(MS_POPUP_ADDPOPUPW,wparam(ppdu),flag);
- mFreeMem(ppdu);
end;
+ PUAddPopupW(@ppdu,flag);
+
mFreeMem(title);
mFreeMem(descr);
end;
@@ -339,7 +294,7 @@ begin
begin
mFreeMem(ActionList);
ActionList:=MakeActions;
- CallService(MS_POPUP_REGISTERACTIONS,twparam(ActionList),7);
+ PURegisterActions(ActionList,7);
end;
end;
@@ -385,31 +340,19 @@ var
newstate:boolean;
begin
result:=true;
- // Popups
- newstate:=ServiceExists(MS_POPUP_ADDPOPUPW);
- if newstate=PopupPresent then
- exit;
- PopupPresent:=newstate;
- if PopupPresent then
+ // Popups
+ if PopupPresent=false then
begin
- IsPopup2Present :=ServiceExists(MS_POPUP_ADDPOPUP2);
+ PopupPresent:=true;
opthook:=HookEvent(ME_OPT_INITIALISE,@OnOptInitialise);
- if ServiceExists(MS_POPUP_REGISTERACTIONS) then
+ if RegisterButtonIcons then
begin
- if RegisterButtonIcons then
- begin
- ActionList:=MakeActions;
- if ActionList<>nil then
- CallService(MS_POPUP_REGISTERACTIONS,wparam(ActionList),7);
- end;
+ ActionList:=MakeActions;
+ if ActionList<>nil then
+ PURegisterActions(ActionList,7);
end;
- end
- else
- begin
- UnhookEvent(opthook);
- mFreeMem(ActionList);
end;
// TTB
@@ -474,28 +417,18 @@ begin
hMenuInfo:=Menu_AddMainMenuItem(@mi);
ActionList:=nil;
- if ServiceExists(MS_POPUP_ADDPOPUPW) then
- begin
- IsPopup2Present := ServiceExists(MS_POPUP_ADDPOPUP2);
- PopupPresent:=true;
- opthook:=HookEvent(ME_OPT_INITIALISE,@OnOptInitialise);
- loadpopup;
- if ServiceExists(MS_POPUP_REGISTERACTIONS) then
- begin
- if RegisterButtonIcons then
- begin
- ActionList:=MakeActions;
- if ActionList<>nil then
- CallService(MS_POPUP_REGISTERACTIONS,wparam(ActionList),7);
- end;
- end;
- end
- else
+ PopupPresent:=true;
+ opthook:=HookEvent(ME_OPT_INITIALISE,@OnOptInitialise);
+ loadpopup;
+
+ if RegisterButtonIcons then
begin
- PopupPresent:=false;
- opthook:=0;
+ ActionList:=MakeActions;
+ if ActionList<>nil then
+ PURegisterActions(ActionList,7);
end;
+
regpophotkey;
plStatusHook:=HookEvent(ME_WAT_NEWSTATUS,@NewPlStatus);
diff --git a/src/mir_app/src/popups.cpp b/src/mir_app/src/popups.cpp
index 67bee51a6e..d6958bcb46 100644
--- a/src/mir_app/src/popups.cpp
+++ b/src/mir_app/src/popups.cpp
@@ -24,13 +24,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
+static bool bModuleInit = false, bPopupsEnabled = true;
+
MIR_APP_DLL(bool) Popup_Enabled()
{
- return db_get_b(0, "Popup", "ModuleIsEnabled", 1) != 0;
+ if (!bModuleInit) {
+ bModuleInit = true;
+ bPopupsEnabled = db_get_b(0, "Popup", "ModuleIsEnabled", 1) != 0;
+ }
+
+ return bPopupsEnabled;
}
MIR_APP_DLL(void) Popup_Enable(bool bEnable)
{
+ bPopupsEnabled = bEnable;
db_set_b(0, "Popup", "ModuleIsEnabled", bEnable);
}